tokentracker-cli 1.3.3 → 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 (156) hide show
  1. package/THIRD_PARTY_NOTICES.md +92 -0
  2. package/dashboard/dist/THIRD_PARTY_NOTICES.txt +92 -0
  3. package/dashboard/dist/assets/AchievementBadge-CKjtQp-U.js +1 -0
  4. package/dashboard/dist/assets/AchievementsPage-DpOXrabE.js +2 -0
  5. package/dashboard/dist/assets/{AchievementsSection-CDUUEfIi.js → AchievementsSection-DiXyIoa0.js} +1 -1
  6. package/dashboard/dist/assets/BadgeDetailModal-CILTTkPF.js +1 -0
  7. package/dashboard/dist/assets/{BotAnimated-Dx_vvTtC.js → BotAnimated-CrBHWiRi.js} +1 -1
  8. package/dashboard/dist/assets/Card-DUItW3xI.js +1 -0
  9. package/dashboard/dist/assets/CloudCheckoutPage-C_t_PDlG.js +1 -0
  10. package/dashboard/dist/assets/CloudPage-pvJUrhya.js +1 -0
  11. package/dashboard/dist/assets/CloudUsageExport-DQbDwiyk.js +4 -0
  12. package/dashboard/dist/assets/CommandPalette-BvHilrbV.js +1 -0
  13. package/dashboard/dist/assets/CommunityStatsModal-CizxEYv-.js +1 -0
  14. package/dashboard/dist/assets/{ConfirmModal-BQ-xB1S_.js → ConfirmModal-h9nISVy7.js} +1 -1
  15. package/dashboard/dist/assets/Controls-BjdIonTX.js +1 -0
  16. package/dashboard/dist/assets/DashboardPage-Bxryr4qp.js +1 -0
  17. package/dashboard/dist/assets/DateRangePopover-DpKh-0l8.js +1 -0
  18. package/dashboard/dist/assets/{DevicePage-Dg6XkIaY.js → DevicePage-DUJR9hJC.js} +1 -1
  19. package/dashboard/dist/assets/DialogClose-BmVAmN-o.js +1 -0
  20. package/dashboard/dist/assets/DialogDescription-C0Cgq67g.js +1 -0
  21. package/dashboard/dist/assets/DialogTitle-BsaIbN8k.js +1 -0
  22. package/dashboard/dist/assets/{FadeIn-ChVf45WW.js → FadeIn-BpSt2P_W.js} +1 -1
  23. package/dashboard/dist/assets/{HeaderGithubStar-B740_G7a.js → HeaderGithubStar-Cc_VHB0R.js} +1 -1
  24. package/dashboard/dist/assets/{HoverTooltip-BzP5FudR.js → HoverTooltip-WFd21iP9.js} +1 -1
  25. package/dashboard/dist/assets/{IpCheckPage-BuZH3F14.js → IpCheckPage-C_mUPSRB.js} +1 -1
  26. package/dashboard/dist/assets/LandingPage-DVR8ClZO.js +2 -0
  27. package/dashboard/dist/assets/LeaderboardPage-D8ydzVpn.js +2 -0
  28. package/dashboard/dist/assets/LeaderboardProBadge-BjX4EFl2.js +1 -0
  29. package/dashboard/dist/assets/{LeaderboardProfileModal-OUZvO6u-.js → LeaderboardProfileModal-vbPMNn7W.js} +4 -4
  30. package/dashboard/dist/assets/{LeaderboardProfilePage-bHI1oTEK.js → LeaderboardProfilePage-CqClmuA-.js} +2 -2
  31. package/dashboard/dist/assets/{LimitsPage-DKojB73_.js → LimitsPage-DaRggHge.js} +2 -2
  32. package/dashboard/dist/assets/{LocalOnlyNotice-BaEq6qN7.js → LocalOnlyNotice-B6nDke_u.js} +1 -1
  33. package/dashboard/dist/assets/LoginCard-C28QVjd7.js +1 -0
  34. package/dashboard/dist/assets/LoginModal-Bx1btNhH.js +1 -0
  35. package/dashboard/dist/assets/LoginPage-DVOGNGYI.js +1 -0
  36. package/dashboard/dist/assets/{PetPage-BPBsUHyL.js → PetPage-nOKryTde.js} +1 -1
  37. package/dashboard/dist/assets/PopoverPopup-Ch6NLnu6.js +1 -0
  38. package/dashboard/dist/assets/{ProviderIcon-BshO2uER.js → ProviderIcon-BRY2br-g.js} +1 -1
  39. package/dashboard/dist/assets/{ResetPasswordPage-RTFTD8Dr.js → ResetPasswordPage-ko1OQecQ.js} +1 -1
  40. package/dashboard/dist/assets/Select-Q8mS3_od.js +1 -0
  41. package/dashboard/dist/assets/SelectItemText-C1id8GDj.js +1 -0
  42. package/dashboard/dist/assets/{SelfHostPage-BlwTt8XM.js → SelfHostPage-Dzb2bDiM.js} +1 -1
  43. package/dashboard/dist/assets/{ServiceStatusPage-BkIcJpYK.js → ServiceStatusPage-ewFwz29J.js} +1 -1
  44. package/dashboard/dist/assets/SessionsPage-C6Y8kbnM.js +3 -0
  45. package/dashboard/dist/assets/SessionsPage-GV2fuNmd.css +1 -0
  46. package/dashboard/dist/assets/SettingsPage-nztCXEPs.js +2 -0
  47. package/dashboard/dist/assets/SkillsPage-CcG77tqU.js +1 -0
  48. package/dashboard/dist/assets/{TokenGalaxy-DiXUpXKF.js → TokenGalaxy-D2HDrbQR.js} +1 -1
  49. package/dashboard/dist/assets/TooltipPopup-C_bF2ZwO.js +1 -0
  50. package/dashboard/dist/assets/TrendMonitor-BcyoN5ns.js +19 -0
  51. package/dashboard/dist/assets/WidgetsPage-BirK0U_N.js +1 -0
  52. package/dashboard/dist/assets/{WrappedPage-ClEo-RmR.js → WrappedPage-thsXBuw6.js} +1 -1
  53. package/dashboard/dist/assets/__vite-browser-external-Bq8nj-JV.js +45 -0
  54. package/dashboard/dist/assets/__vite-browser-external-BwmeEfv7.css +1 -0
  55. package/dashboard/dist/assets/agent-logos-CK6SzhI7.js +1 -0
  56. package/dashboard/dist/assets/arrow-left-c_NOSfoq.js +1 -0
  57. package/dashboard/dist/assets/{arrow-right-CwBz5dwb.js → arrow-right-CP7drKCT.js} +1 -1
  58. package/dashboard/dist/assets/{arrow-up-right-jPmRN562.js → arrow-up-right-DQ6QfCpo.js} +1 -1
  59. package/dashboard/dist/assets/calendar-days-D_pxFQvT.js +1 -0
  60. package/dashboard/dist/assets/{check-CKwHc4Hv.js → check-HAS31kTT.js} +1 -1
  61. package/dashboard/dist/assets/chevron-down-BIMuk6oN.js +1 -0
  62. package/dashboard/dist/assets/cloud-checkout-COmDwrUT.js +1 -0
  63. package/dashboard/dist/assets/composite-kLwqpqEk.js +1 -0
  64. package/dashboard/dist/assets/download-9RgsZIiH.js +1 -0
  65. package/dashboard/dist/assets/{external-link-B5yXxdPy.js → external-link-C_gYjHGF.js} +1 -1
  66. package/dashboard/dist/assets/{flame-CKjAluj_.js → flame-BSsCvgT8.js} +1 -1
  67. package/dashboard/dist/assets/{format-tokens-mk49THtv.js → format-tokens-N22Wqv1X.js} +1 -1
  68. package/dashboard/dist/assets/{host-mode-efKlSYjX.js → host-mode-JzrhHX7F.js} +1 -1
  69. package/dashboard/dist/assets/{icons-ZB1ZthjH.js → icons-pK99mIMv.js} +1 -1
  70. package/dashboard/dist/assets/{index-DweUMAUD.js → index-BhviBroj.js} +1 -1
  71. package/dashboard/dist/assets/{index-BImBG3eS.js → index-CmD84EJi.js} +1 -1
  72. package/dashboard/dist/assets/{index-BgdM7kBl.js → index-Dk43KNa6.js} +1 -1
  73. package/dashboard/dist/assets/info-D-RLFnSK.js +1 -0
  74. package/dashboard/dist/assets/{link-2-Dn2soiyd.js → link-2-BiKXW9mV.js} +1 -1
  75. package/dashboard/dist/assets/{loader-circle-CNT630zn.js → loader-circle-KVUaEKV2.js} +1 -1
  76. package/dashboard/dist/assets/{modifiers.esm-WPx0bc2K.js → modifiers.esm-5NK8j3mT.js} +1 -1
  77. package/dashboard/dist/assets/monitor-smartphone-u9yr-_Es.js +1 -0
  78. package/dashboard/dist/assets/play-D0MaDCOx.js +1 -0
  79. package/dashboard/dist/assets/plus-DTJVtoAJ.js +1 -0
  80. package/dashboard/dist/assets/provider-display-YhtG0I9Y.js +42 -0
  81. package/dashboard/dist/assets/{react-B7SkZTgg.js → react-gIVxucOB.js} +1 -1
  82. package/dashboard/dist/assets/safePolygon-C_sPnJ1L.js +1 -0
  83. package/dashboard/dist/assets/{search-Ol3OZBm4.js → search-DdQRwFYV.js} +1 -1
  84. package/dashboard/dist/assets/{server-DFCbznC7.js → server-M0rmbGWy.js} +1 -1
  85. package/dashboard/dist/assets/{shield-check-YcmLwVZ6.js → shield-check-9-sqQKdD.js} +1 -1
  86. package/dashboard/dist/assets/{skills-api-C-9vK884.js → skills-api-B0qBWnuK.js} +1 -1
  87. package/dashboard/dist/assets/{sortable.esm-CKC9NuR-.js → sortable.esm-iqbm7x5D.js} +1 -1
  88. package/dashboard/dist/assets/store-DstuWd4a.js +1 -0
  89. package/dashboard/dist/assets/{terminal-B3_fCLFs.js → terminal-Dz0MxHNG.js} +1 -1
  90. package/dashboard/dist/assets/{trash-CZGfgbFa.js → trash-DBMFOFVz.js} +1 -1
  91. package/dashboard/dist/assets/{use-community-stats-CW-qkYn7.js → use-community-stats-CacbAcUR.js} +1 -1
  92. package/dashboard/dist/assets/{use-latest-request-guard-DHv7vfFE.js → use-latest-request-guard-nBuQVZOR.js} +1 -1
  93. package/dashboard/dist/assets/use-limits-display-prefs-fqg8hs6b.js +1 -0
  94. package/dashboard/dist/assets/{use-native-settings-CWiLqfZh.js → use-native-settings-EAqAFx2x.js} +1 -1
  95. package/dashboard/dist/assets/{use-ordered-list-Df8pw-WJ.js → use-ordered-list-DGLjjU6Q.js} +1 -1
  96. package/dashboard/dist/assets/use-pet-settings-C5MzWHE7.js +2 -0
  97. package/dashboard/dist/assets/use-reduced-motion-DK2oZ2uC.js +1 -0
  98. package/dashboard/dist/assets/{use-transform-BHwEAfmO.js → use-transform-C25eCuz_.js} +1 -1
  99. package/dashboard/dist/assets/{use-usage-limits-CSxFFn3_.js → use-usage-limits-BhqnEai3.js} +1 -1
  100. package/dashboard/dist/assets/{useCurrency-pwClnCZ5.js → useCurrency-t3PYQi1l.js} +1 -1
  101. package/dashboard/dist/assets/usePositioner-C59mj6kG.js +1 -0
  102. package/dashboard/dist/assets/{useTokenFormat-BMvVAe6V.js → useTokenFormat-C0xQsBGf.js} +1 -1
  103. package/dashboard/dist/assets/zap-CyH0tvKM.js +1 -0
  104. package/dashboard/dist/index.html +2 -2
  105. package/dashboard/dist/ip-check.html +2 -2
  106. package/dashboard/dist/leaderboard.html +2 -2
  107. package/dashboard/dist/share.html +2 -2
  108. package/package.json +2 -1
  109. package/src/lib/pricing/seed-snapshot.json +1 -1
  110. package/dashboard/dist/assets/AchievementBadge-BaqdyZaV.js +0 -1
  111. package/dashboard/dist/assets/AchievementsPage-B4Ju0guv.js +0 -2
  112. package/dashboard/dist/assets/BadgeDetailModal-B-XMJAvL.js +0 -1
  113. package/dashboard/dist/assets/Card-D-5mABVt.js +0 -1
  114. package/dashboard/dist/assets/CloudCheckoutPage-BELoh56h.js +0 -1
  115. package/dashboard/dist/assets/CloudPage-CfBruNxe.js +0 -1
  116. package/dashboard/dist/assets/CloudUsageExport-BoFU7xCT.js +0 -4
  117. package/dashboard/dist/assets/CommandPalette-BmmKZWn-.js +0 -1
  118. package/dashboard/dist/assets/CommunityStatsModal-BF77zVhN.js +0 -1
  119. package/dashboard/dist/assets/Controls-BnTeX7T4.js +0 -1
  120. package/dashboard/dist/assets/DashboardPage-BWulHa5J.js +0 -1
  121. package/dashboard/dist/assets/DialogClose-DAyilsH-.js +0 -1
  122. package/dashboard/dist/assets/DialogDescription-j4XnRy6y.js +0 -1
  123. package/dashboard/dist/assets/DialogTitle-B1iNGD2S.js +0 -1
  124. package/dashboard/dist/assets/LandingPage-Dtgq_caz.js +0 -2
  125. package/dashboard/dist/assets/LeaderboardPage-Di1kEg2O.js +0 -2
  126. package/dashboard/dist/assets/LeaderboardProBadge-h8FfR0au.js +0 -1
  127. package/dashboard/dist/assets/LoginCard-Dn5Xy4If.js +0 -1
  128. package/dashboard/dist/assets/LoginModal-C5h-5GOA.js +0 -1
  129. package/dashboard/dist/assets/LoginPage-BpX8Tgjj.js +0 -1
  130. package/dashboard/dist/assets/PopoverPopup-CVTiEVHs.js +0 -1
  131. package/dashboard/dist/assets/Select-CtTceC4T.js +0 -1
  132. package/dashboard/dist/assets/SelectItemText-C7xi8iGp.js +0 -1
  133. package/dashboard/dist/assets/SessionsPage-BngTWN7Q.css +0 -1
  134. package/dashboard/dist/assets/SessionsPage-okHobk_L.js +0 -3
  135. package/dashboard/dist/assets/SettingsPage-C-cc6wcF.js +0 -2
  136. package/dashboard/dist/assets/SkillsPage-D2LlKKJN.js +0 -1
  137. package/dashboard/dist/assets/TrendMonitor-C88S-5aa.js +0 -19
  138. package/dashboard/dist/assets/WidgetsPage-WsEFPNwp.js +0 -1
  139. package/dashboard/dist/assets/__vite-browser-external-DFRX9dp-.css +0 -1
  140. package/dashboard/dist/assets/__vite-browser-external-DUJeOWgd.js +0 -45
  141. package/dashboard/dist/assets/agent-logos-BM9jlReI.js +0 -1
  142. package/dashboard/dist/assets/arrow-left-BEM-HVmC.js +0 -1
  143. package/dashboard/dist/assets/cloud-checkout-nYNHDFoR.js +0 -1
  144. package/dashboard/dist/assets/composite-B4Z3F65o.js +0 -1
  145. package/dashboard/dist/assets/download-CJUnX1Bs.js +0 -1
  146. package/dashboard/dist/assets/info-CyDY7NYM.js +0 -1
  147. package/dashboard/dist/assets/monitor-smartphone-C-qC0RAt.js +0 -1
  148. package/dashboard/dist/assets/plus-Cx82jb7o.js +0 -1
  149. package/dashboard/dist/assets/provider-display-CodMmiRb.js +0 -42
  150. package/dashboard/dist/assets/safePolygon-CKpREa4K.js +0 -1
  151. package/dashboard/dist/assets/store-C9yWYHfg.js +0 -1
  152. package/dashboard/dist/assets/use-limits-display-prefs-NZ-AAYD5.js +0 -1
  153. package/dashboard/dist/assets/use-pet-settings-Bg2CDprr.js +0 -2
  154. package/dashboard/dist/assets/use-reduced-motion-iDZEUyua.js +0 -1
  155. package/dashboard/dist/assets/usePositioner-B0j1orGj.js +0 -1
  156. package/dashboard/dist/assets/zap-DvX2aYx5.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeaderboardProfileModal-OUZvO6u-.js","assets/__vite-browser-external-DUJeOWgd.js","assets/__vite-browser-external-DFRX9dp-.css","assets/provider-display-CodMmiRb.js","assets/useCurrency-pwClnCZ5.js","assets/useTokenFormat-BMvVAe6V.js","assets/terminal-B3_fCLFs.js","assets/info-CyDY7NYM.js","assets/LeaderboardProBadge-h8FfR0au.js","assets/safePolygon-CKpREa4K.js","assets/composite-B4Z3F65o.js","assets/store-C9yWYHfg.js","assets/usePositioner-B0j1orGj.js","assets/ProviderIcon-BshO2uER.js","assets/AchievementBadge-BaqdyZaV.js","assets/zap-DvX2aYx5.js","assets/flame-CKjAluj_.js","assets/shield-check-YcmLwVZ6.js","assets/AchievementsSection-CDUUEfIi.js","assets/react-B7SkZTgg.js","assets/format-tokens-mk49THtv.js","assets/use-reduced-motion-iDZEUyua.js","assets/arrow-up-right-jPmRN562.js","assets/link-2-Dn2soiyd.js","assets/check-CKwHc4Hv.js","assets/DialogTitle-B1iNGD2S.js","assets/CommunityStatsModal-BF77zVhN.js","assets/icons-ZB1ZthjH.js","assets/TrendMonitor-C88S-5aa.js","assets/use-latest-request-guard-DHv7vfFE.js","assets/PopoverPopup-CVTiEVHs.js","assets/SelectItemText-C7xi8iGp.js","assets/DialogDescription-j4XnRy6y.js","assets/DialogClose-DAyilsH-.js"])))=>i.map(i=>d[i]);
2
- import{j as e,a6 as ua,c as s,J as c,r as d,a_ as xa,d as ba,u as pa,a as ha,a$ as ya,a7 as fa,b0 as ka,b1 as wa,b2 as Be,b3 as va,b4 as ie,g as ja,b5 as Na,L as _a,b6 as Sa,i as Ca,b7 as Aa,b8 as La,au as Ea,a9 as Ge,h as Ta,O as Ma}from"./__vite-browser-external-DUJeOWgd.js";import{S as Pa}from"./Select-CtTceC4T.js";import{m as Ka}from"./react-B7SkZTgg.js";import{u as Ra,C as Ia,a as za,b as $e,D as Ba,c as $a,S as Da,h as Ua,s as Oa,K as Fa,P as Ga}from"./sortable.esm-CKC9NuR-.js";import{r as Ha}from"./modifiers.esm-WPx0bc2K.js";import{P as ye}from"./ProviderIcon-BshO2uER.js";import{u as Ya}from"./useCurrency-pwClnCZ5.js";import{u as Q}from"./useTokenFormat-BMvVAe6V.js";import{L as X,a as ne}from"./LeaderboardProBadge-h8FfR0au.js";import{s as Wa,c as Va,A as Ja,t as Za,b as Xa}from"./AchievementBadge-BaqdyZaV.js";import{u as qa}from"./use-ordered-list-Df8pw-WJ.js";import{A as Qa}from"./arrow-right-CwBz5dwb.js";import{u as er}from"./use-community-stats-CW-qkYn7.js";import"./SelectItemText-C7xi8iGp.js";import"./composite-B4Z3F65o.js";import"./usePositioner-B0j1orGj.js";import"./check-CKwHc4Hv.js";import"./safePolygon-CKpREa4K.js";import"./store-C9yWYHfg.js";import"./zap-DvX2aYx5.js";import"./flame-CKjAluj_.js";import"./shield-check-YcmLwVZ6.js";function H(a,{min:r,max:o,fallback:i}){const l=Number(a);if(!Number.isFinite(l))return i;const n=Math.floor(l);return n<r?r:n>o?o:n}function ar(a,r){const o=H(r,{min:0,max:1e6,fallback:0}),i=H(a,{min:1,max:Math.max(1,o||1),fallback:1});if(o<=1)return[1];const l=new Set([1,o,i-2,i-1,i,i+1,i+2]),n=Array.from(l).filter(u=>Number.isInteger(u)&&u>=1&&u<=o).sort((u,h)=>u-h),m=[];let b=null;for(const u of n)b!=null&&u-b>1&&m.push(null),m.push(u),b=u;return m}function rr({page:a,totalPages:r}){const o=typeof r=="number"&&Number.isFinite(r)&&r>=0,i=o?H(r,{min:0,max:1e6,fallback:0}):null,l=H(a,{min:1,max:o?Math.max(1,i||1):1e6,fallback:1}),n=l>1,m=o?l<i:!0;return{canPrev:n,canNext:m,safePage:l,safeTotal:i}}function tr({entries:a,me:r,meLabel:o}){const i=Array.isArray(a)?a:[],l=r&&typeof r.rank=="number"?r.rank:null;return!l||i.some(m=>!!m?.is_me)?i:[{rank:l,is_me:!0,is_pinned:!0,user_id:r?.user_id??null,display_name:o,avatar_url:r?.avatar_url??null,pro_active:r?.pro_active===!0,github_url:null,is_public:!1,gpt_tokens:r?.gpt_tokens??"0",claude_tokens:r?.claude_tokens??"0",gemini_tokens:r?.gemini_tokens??"0",cursor_tokens:r?.cursor_tokens??"0",opencode_tokens:r?.opencode_tokens??"0",openclaw_tokens:r?.openclaw_tokens??"0",hermes_tokens:r?.hermes_tokens??"0",kiro_tokens:r?.kiro_tokens??"0",copilot_tokens:r?.copilot_tokens??"0",kimi_tokens:r?.kimi_tokens??"0",other_tokens:r?.other_tokens??"0",total_tokens:r?.total_tokens??"0",estimated_cost_usd:r?.estimated_cost_usd??null,badges:Array.isArray(r?.badges)?r.badges:[]},...i]}function or(a,r){const o=Number(a),i=Number(r);return!Number.isFinite(o)||o<1||!Number.isFinite(i)||i<1?null:Math.ceil(o/i)}const sr=new Set(["/brand-logos/cursor.svg","/brand-logos/kimi.svg","/brand-logos/kiro.svg","/brand-logos/copilot.svg","/brand-logos/hermes.svg"]);function ir({iconSrc:a,label:r}){return e.jsxs("span",{className:"inline-flex items-center gap-3",children:[a?e.jsx("img",{src:a,alt:"",width:16,height:16,className:`h-4 w-4 shrink-0 object-contain opacity-90 ${sr.has(a)?"dark:invert":""}`}):null,e.jsx("span",{className:"whitespace-nowrap",children:r})]})}const le=ua.memo(function({badges:r,max:o=3,className:i=""}){const l=Wa((r||[]).filter(n=>n&&Va.has(n.id)&&(n.tier||0)>=1)).slice(0,o);return l.length===0?null:e.jsx("span",{className:`pointer-events-none inline-flex shrink-0 items-center ${i}`,children:l.map((n,m)=>e.jsx("span",{title:s("achievements.mini.tooltip",{name:s(Xa(n.id,"name")),tier:s(`achievements.tier.${Za(n.tier)}`)}),style:{zIndex:l.length-m},className:`pointer-events-auto relative inline-flex ${m>0?"-ml-1.5":""}`,children:e.jsx(Ja,{badgeId:n.id,tier:n.tier,size:"xs",className:"rounded-full ring-[1.5px] ring-white dark:ring-oai-gray-950"})},n.id))})}),q=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"kiro_tokens",copyKey:"leaderboard.column.kiro",icon:"/brand-logos/kiro.svg"},{key:"copilot_tokens",copyKey:"leaderboard.column.copilot",icon:"/brand-logos/copilot.svg"},{key:"kimi_tokens",copyKey:"leaderboard.column.kimi",icon:"/brand-logos/kimi.svg"},{key:"opencode_tokens",copyKey:"leaderboard.column.opencode",icon:"/brand-logos/opencode.svg"},{key:"openclaw_tokens",copyKey:"leaderboard.column.openclaw",icon:"/brand-logos/openclaw.svg"},{key:"hermes_tokens",copyKey:"leaderboard.column.hermes",icon:"/brand-logos/hermes.svg"},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:null}],He="sticky left-0 z-40 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] bg-white dark:bg-oai-gray-950 px-2.5 sm:px-4 py-4 align-middle",Ye="sticky left-[55px] sm:left-[71px] z-40 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-3 sm:px-4 py-4 align-middle";function de(a){return c("sticky left-0 z-30 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] px-2.5 sm:px-4 py-4 whitespace-nowrap",a?"bg-oai-gray-50 dark:bg-oai-gray-900":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function ce(a){return c("sticky left-[55px] sm:left-[71px] z-30 hover:z-50 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 px-3 sm:px-4 py-4 min-w-0",a?"bg-oai-gray-50 dark:bg-oai-gray-900":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function f({className:a}){return e.jsx("div",{className:c("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",a)})}function nr({index:a}){const r=a<3?"w-24":a<8?"w-20":"w-16",o=a<3?"w-16":"w-12",i=a<5?"w-14":"w-10";return e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:c(de(!1),"!group-hover:bg-transparent"),children:e.jsx(f,{className:"h-4 w-6"})}),e.jsx("td",{className:c(ce(!1),"!group-hover:bg-transparent"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(f,{className:"h-8 w-8 min-w-8 rounded-full"}),e.jsx(f,{className:c("h-4",r)})]})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(f,{className:c("h-4",o)})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(f,{className:"h-4 w-12"})}),q.map(l=>e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(f,{className:c("h-4",i)})},l.key))]})}function lr({index:a}){const r=a<3?"w-24":a<8?"w-20":"w-16",o=a%3===0?3:a%3===1?2:1;return e.jsxs("div",{className:"mx-0 my-1 rounded-xl bg-white dark:bg-oai-gray-950 border border-oai-gray-100 dark:border-oai-gray-800/60 px-3.5 py-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(f,{className:"h-4 w-3 shrink-0 rounded"}),e.jsx(f,{className:"h-9 w-9 shrink-0 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(f,{className:c("h-4",r)}),e.jsx(f,{className:"mt-2 h-3.5 w-20"})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx(f,{className:"ml-auto h-3 w-8"}),e.jsx(f,{className:"mt-1.5 ml-auto h-4 w-14"})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-oai-gray-100 pt-2.5 dark:border-oai-gray-800/70",children:Array.from({length:o},(i,l)=>e.jsx(f,{className:"h-5 w-12 rounded-full"},l))})]})}function dr({rows:a=10}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:c(He,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(f,{className:"h-3.5 w-6"})}),e.jsx("th",{className:c(Ye,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(f,{className:"h-3.5 w-12"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(f,{className:"h-3.5 w-10"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(f,{className:"h-3.5 w-14"})}),q.map(r=>e.jsx("th",{className:"px-4 py-4",children:e.jsx(f,{className:"h-3.5 w-12"})},r.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:a},(r,o)=>e.jsx(nr,{index:o},o))})]})}),e.jsx("div",{className:"flex flex-col py-1 sm:hidden",children:Array.from({length:a},(r,o)=>e.jsx(lr,{index:o},o))})]})}function cr({id:a,thClassName:r,children:o}){const{attributes:i,listeners:l,setNodeRef:n,transform:m,transition:b,isDragging:u}=Ra({id:a}),h=Ia.Transform.toString(m)||"";d.useLayoutEffect(()=>{const y=document.querySelectorAll(`td[data-column-key="${a}"]`),p="0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)";return y.forEach(x=>{x.style.transform=h,x.style.transition=b||"",x.style.zIndex=u?"20":"",x.style.position=h?"relative":"",x.style.boxShadow=u?p:""}),()=>{y.forEach(x=>{x.style.transform="",x.style.transition="",x.style.zIndex="",x.style.position="",x.style.boxShadow=""})}},[a,h,b,u]);const v={transform:h,transition:b,position:h?"relative":void 0,zIndex:u?20:void 0,boxShadow:u?"0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)":void 0};return e.jsx("th",{ref:n,style:v,className:c(r,"group/col select-none cursor-grab active:cursor-grabbing touch-none"),...i,...l,children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:c("-mr-1 inline-flex h-4 w-3 shrink-0 items-center justify-center text-oai-gray-400 dark:text-oai-gray-600","opacity-0 transition-opacity duration-150 group-hover/col:opacity-100",u&&"opacity-100"),children:e.jsxs("svg",{viewBox:"0 0 8 14",width:"8",height:"14",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"2",cy:"2",r:"1"}),e.jsx("circle",{cx:"6",cy:"2",r:"1"}),e.jsx("circle",{cx:"2",cy:"7",r:"1"}),e.jsx("circle",{cx:"6",cy:"7",r:"1"}),e.jsx("circle",{cx:"2",cy:"12",r:"1"}),e.jsx("circle",{cx:"6",cy:"12",r:"1"})]})}),o]})})}const mr="tokentracker.leaderboard.columnOrder.v1";function gr(a){return qa(mr,a)}const ur=50;function xr(a,r){const o=Number(a),i=Number(r);return!Number.isFinite(o)||o<1||!Number.isFinite(i)||i<1?null:Math.min(100,Math.max(1,Math.ceil(o/i*100)))}function We(a){return typeof a=="string"?a.trim():""}function br(a){const r=We(a);return r?r.toLowerCase()==="anonymous":!0}function pr({me:a,totalEntries:r,meLabel:o,onOpenProfile:i,onJumpToMe:l,canJump:n,className:m}){const b=a&&typeof a.rank=="number"?a.rank:null;if(!b)return null;const u=Number(r)||0,h=xr(b,u),v=We(a?.display_name),y=!v||br(v)?o||"You":v,p=a?.user_id||y,x=i||(n?l:null),E=typeof x=="function",C=E?"button":"div",ee=E?{type:"button",onClick:x,"aria-label":s(i?"leaderboard.summary.view_profile":"leaderboard.summary.jump_to_me")}:{};return e.jsxs(C,{...ee,className:c("group inline-flex h-9 items-center gap-2.5 rounded-full border pl-1 pr-3.5 transition-all duration-300 select-none",E?"border-oai-gray-200 hover:border-oai-gray-400 dark:border-oai-gray-800 dark:hover:border-oai-gray-500/80 bg-oai-gray-50/50 dark:bg-white/[0.02] backdrop-blur-md hover:bg-oai-gray-100/40 dark:hover:bg-oai-gray-900/20 active:scale-[0.97] dark:ring-1 dark:ring-white/[0.04] dark:hover:ring-white/[0.08]":"border-oai-gray-100 dark:border-oai-gray-800/60 bg-oai-gray-50/20 dark:bg-white/[0.01] backdrop-blur-sm dark:ring-1 dark:ring-white/[0.02]",m),children:[e.jsx(X,{size:"sm",avatarUrl:a?.avatar_url,displayName:y,seed:p,proActive:a?.pro_active===!0}),e.jsx("span",{className:"hidden sm:inline max-w-[120px] truncate text-xs font-semibold text-oai-black dark:text-oai-gray-200 group-hover:text-oai-gray-800 dark:group-hover:text-oai-gray-100 transition-colors",children:y}),a?.pro_active===!0&&e.jsx("span",{className:"leaderboard-pro-badge",role:"img","aria-label":s("leaderboard.pro.badge_aria"),"aria-description":s("leaderboard.pro.tooltip"),children:s("leaderboard.pro.badge")}),e.jsxs("span",{className:"text-xs font-bold tabular-nums text-oai-gray-800 dark:text-white",children:["#",b.toLocaleString()]}),h!=null&&h<=ur&&e.jsx("span",{className:"hidden sm:inline-flex items-center rounded-full px-2 py-0.5 text-[9px] font-extrabold tracking-wider tabular-nums uppercase transition-colors duration-300 ring-1 bg-oai-gray-100 text-oai-gray-700 dark:bg-oai-gray-800 dark:text-oai-gray-300 ring-oai-gray-300/30 dark:ring-oai-gray-600/30",children:s("leaderboard.summary.percentile",{p:String(h)})}),E?e.jsx(Qa,{"aria-hidden":!0,className:"size-3 text-oai-gray-400 transition-all duration-300 group-hover:text-oai-gray-600 dark:text-oai-gray-500 group-hover:translate-x-0.5 group-hover:scale-110"}):e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0 items-center justify-center ml-1",title:"You are here",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-oai-gray-400 opacity-75 duration-1000"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-oai-gray-400 dark:bg-oai-gray-500"})]})]})}const hr=d.lazy(()=>Ge(()=>import("./LeaderboardProfileModal-OUZvO6u-.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25])).then(a=>({default:a.LeaderboardProfileModal}))),yr=d.lazy(()=>Ge(()=>import("./CommunityStatsModal-BF77zVhN.js"),__vite__mapDeps([26,1,2,19,27,5,13,28,4,29,6,30,11,10,31,12,9,21,14,15,16,17,25,32,33])).then(a=>({default:a.CommunityStatsModal}))),me=[10,20,50,100],ge=20,Ve="tokentracker:leaderboard:pageSize";function fr(){if(typeof window>"u")return ge;try{const a=window.localStorage.getItem(Ve),r=Number(a);if(me.includes(r))return r}catch{}return ge}function ue(a,r,o){const i=Number(a);if(!Number.isFinite(i)||i<=0)return"-";const l=Sa(r),n=r===Ma?i:i*o;return n>=1e3?`${l}${Math.round(n).toLocaleString()}`:n>=10?`${l}${Math.round(n)}`:`${l}${n.toFixed(2)}`}function kr(a){if(typeof a!="string"||!a.trim())return null;const r=new Date(a);if(!Number.isFinite(r.getTime()))return null;const o=Ta();return{dateTime:r.toISOString(),display:new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(r),exact:new Intl.DateTimeFormat(o,{dateStyle:"full",timeStyle:"long"}).format(r)}}function xe({value:a}){const{formatTokens:r,formatTokensTooltip:o}=Q();return e.jsx("span",{title:o(a),children:r(a)})}function wr({communityStats:a,onClick:r}){const{formatTokens:o,formatTokensTooltip:i}=Q();return a.status!=="ready"?null:e.jsxs("button",{type:"button",onClick:r,className:"inline-flex min-w-0 max-w-full flex-1 items-center gap-1.5 whitespace-nowrap rounded-xl border border-oai-gray-200 bg-oai-gray-50/50 px-2.5 py-2 text-xs text-oai-gray-500 backdrop-blur-md transition-all duration-300 hover:border-oai-gray-400 hover:bg-oai-gray-100/40 active:scale-[0.97] dark:border-oai-gray-800 dark:bg-white/[0.02] dark:text-oai-gray-400 dark:hover:border-oai-gray-500/80 dark:hover:bg-oai-gray-900/20 sm:h-9 sm:flex-none sm:gap-2.5 sm:rounded-full sm:px-3.5 sm:py-0",title:s("leaderboard.community.view_stats"),children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0","aria-hidden":"true",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-oai-gray-400/80 opacity-75 duration-1000"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-oai-gray-400 dark:bg-oai-gray-500"})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-semibold text-oai-black dark:text-white tabular-nums",children:e.jsx("span",{title:i(a.tokenFloor),children:o(a.tokenFloor)})}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:s("leaderboard.community.tokens_chip")})]}),e.jsx("span",{className:"text-oai-gray-200 dark:text-oai-gray-800 select-none",children:"·"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("span",{className:"font-semibold text-oai-black dark:text-white tabular-nums",children:[e.jsx("span",{className:"sm:hidden",children:Ca(a.totalEntries)}),e.jsx("span",{className:"hidden sm:inline",children:(Number(a.totalEntries)||0).toLocaleString("en-US")})]}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:s("leaderboard.community.devs_chip")})]})]})}function De({entry:a,isMe:r,orderedColumns:o}){const{formatTokens:i,formatTokensTooltip:l}=Q(),n=r?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",m=r?"bg-oai-gray-50 dark:bg-oai-gray-900":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900";return o.map(b=>e.jsx("td",{"data-column-key":b.key,title:l(a?.[b.key]),className:c("hidden sm:table-cell px-3 sm:px-4 py-4 whitespace-nowrap text-right tabular-nums",n,m),children:i(a?.[b.key])},b.key))}function vr(a){return a?.key==="gpt_tokens"?"CODEX":a?.key==="claude_tokens"?"CLAUDE":(a?.icon?.split("/").pop()||"").replace(/\.svg$/i,"").toUpperCase()||"OTHER"}const jr={1:"ring-2 ring-amber-400 dark:ring-amber-500/80 shadow-[0_0_8px_rgba(245,158,11,0.25)]",2:"ring-2 ring-slate-350 dark:ring-slate-450 shadow-[0_0_8px_rgba(148,163,184,0.2)]",3:"ring-2 ring-orange-400 dark:ring-orange-500/70 shadow-[0_0_8px_rgba(249,115,22,0.25)]"};function Nr({rank:a,placeholder:r}){return a===1?e.jsx("span",{className:"text-base font-extrabold italic text-amber-500 dark:text-amber-400 tracking-tighter",children:"1"}):a===2?e.jsx("span",{className:"text-base font-extrabold italic text-slate-400 dark:text-slate-350 tracking-tighter",children:"2"}):a===3?e.jsx("span",{className:"text-base font-extrabold italic text-orange-500 dark:text-orange-400 tracking-tighter",children:"3"}):e.jsx("span",{className:"text-[13px] font-bold tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:a==null?r:`#${a}`})}function _r({githubUrl:a}){return e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":"GitHub profile",className:"absolute bottom-0 right-0 translate-x-1 translate-y-1 flex h-4.5 w-4.5 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 shadow border border-oai-gray-100 dark:border-oai-gray-800 transition-transform active:scale-110",children:e.jsx(ye,{provider:"GITHUB",size:11})})}function Sr({entry:a,orderedColumns:r}){const{formatTokens:o,formatTokensTooltip:i}=Q(),l=r.filter(n=>{const m=Number(a?.[n.key]);return Number.isFinite(m)&&m>0});return l.length===0?null:e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-x-1.5 gap-y-2 border-t border-oai-gray-100/70 pt-3 dark:border-oai-gray-800/60",children:l.map(n=>{const m=s(n.copyKey);return e.jsxs("span",{title:m,"aria-label":`${m}: ${i(a?.[n.key])}`,className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-oai-gray-50/80 dark:bg-oai-gray-900/60 px-2 py-0.5 border border-oai-gray-100/80 dark:border-oai-gray-800/40 text-[10px] font-medium text-oai-gray-600 dark:text-oai-gray-300 transition-colors",children:[e.jsx(ye,{provider:vr(n),size:12,className:"shrink-0 opacity-90"}),e.jsx("span",{className:"tabular-nums",children:o(a?.[n.key])})]},n.key)})})}function Cr({entry:a,entryIdx:r,name:o,meLabel:i,currency:l,rate:n,orderedColumns:m,placeholder:b,onOpenProfile:u}){if(a?.is_ellipsis)return e.jsx("div",{"aria-hidden":"true",className:"px-4 py-2 text-center text-xs tracking-[0.4em] text-oai-gray-400 dark:text-oai-gray-600",children:"···"},`mobile-ellipsis-${r}`);const h=!!a?.is_me,v=!h&&pe(a?.display_name),y=typeof a?.user_id=="string"?a.user_id:null,p=!!y,x=h?i:o,E=C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),u(y))};return e.jsxs("div",{role:p?"button":void 0,tabIndex:p?0:void 0,onClick:p?()=>u(y):void 0,onKeyDown:p?E:void 0,"aria-label":p?s("leaderboard.profile_modal.row_aria",{name:x}):void 0,className:c("relative mx-0 my-1 rounded-xl px-3.5 py-3 transition-all duration-200 border shadow-sm select-none",h?"bg-oai-gray-50 dark:bg-oai-gray-900 border-oai-gray-300/60 dark:border-oai-gray-500/25":v?"bg-white/90 dark:bg-oai-gray-950/90 border-oai-gray-100/70 dark:border-oai-gray-800/40":"bg-white dark:bg-oai-gray-950 border-oai-gray-100 dark:border-oai-gray-800/60",p&&"cursor-pointer hover:border-oai-gray-200 dark:hover:border-oai-gray-700/80 active:scale-[0.985] active:bg-oai-gray-50/60 dark:active:bg-oai-gray-900/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-oai-gray-500/60"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"flex w-5 shrink-0 items-center justify-center",children:e.jsx(Nr,{rank:a?.rank,placeholder:b})}),e.jsxs("span",{className:"relative inline-flex shrink-0",children:[e.jsx("span",{className:c("inline-flex rounded-full p-0.5 transition-all duration-300",a?.pro_active!==!0&&(jr[a?.rank]||"ring-1 ring-oai-gray-200 dark:ring-oai-gray-800/80"),v&&"opacity-60 grayscale-[15%]"),children:e.jsx(X,{size:"md",avatarUrl:a?.avatar_url,displayName:x,seed:he(a,x),proActive:a?.pro_active===!0})}),a?.github_url&&e.jsx(_r,{githubUrl:a.github_url})]}),e.jsxs("div",{className:"min-w-0 flex-1 pl-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:c("min-w-0 truncate text-sm tracking-tight",h?"font-semibold text-oai-black dark:text-oai-white":v?"font-normal text-oai-gray-400 dark:text-oai-gray-500":"font-medium text-oai-gray-800 dark:text-oai-gray-200"),children:x}),e.jsx(ne,{proActive:a?.pro_active===!0}),e.jsx(le,{badges:a?.badges,className:"shrink-0 scale-95"})]}),e.jsxs("div",{className:"mt-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:s("leaderboard.column.est_cost")}),e.jsx("span",{className:c("ml-1 tabular-nums font-medium",v?"text-oai-gray-400/80 dark:text-oai-gray-500/80":"text-oai-gray-600 dark:text-oai-gray-300"),children:ue(a?.estimated_cost_usd,l,n)})]})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.08em] text-oai-gray-400 dark:text-oai-gray-500",children:s("leaderboard.column.total")}),e.jsx("div",{className:c("mt-0.5 text-sm font-semibold tabular-nums tracking-tight",h?"text-oai-black dark:text-oai-white":v?"text-oai-gray-400 dark:text-oai-gray-500":"text-oai-gray-800 dark:text-oai-gray-200"),children:e.jsx(xe,{value:a?.total_tokens})})]})]}),e.jsx(Sr,{entry:a,orderedColumns:m})]},`mobile-row-${a?.rank}-${x}`)}const Ar={1:{text:"text-amber-600 dark:text-amber-400",badge:"bg-amber-50 dark:bg-amber-900/20"},2:{text:"text-gray-500 dark:text-gray-300",badge:"bg-gray-50 dark:bg-gray-800/40"},3:{text:"text-orange-700 dark:text-orange-400",badge:"bg-orange-50 dark:bg-orange-900/20"}};function Ue({rank:a,placeholder:r}){const o=Ar[a];return o?e.jsx("span",{className:c("inline-flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold",o.text,o.badge),children:a}):e.jsx("span",{className:"inline-flex items-center justify-center h-7 w-7 text-sm",children:a??r})}function Oe(a){if(typeof a!="string")return null;const r=a.trim().toLowerCase();return r==="week"||r==="month"||r==="total"?r:null}function Lr(a){if(!a)return s("shared.error.prefix",{error:s("leaderboard.error.unknown")});const r=a?.message||String(a),o=String(r||"").trim()||s("leaderboard.error.unknown");return s("shared.error.prefix",{error:o})}function be(a){return typeof a!="string"?"":a.trim()}function pe(a){const r=be(a);return r?r.toLowerCase()==="anonymous":!0}function he(a,r){const o=typeof a?.user_id=="string"?a.user_id.trim():"";return o||`${a?.rank??""}:${r}`}function Fe({githubUrl:a}){return e.jsxs("span",{className:"absolute left-1/2 top-full -translate-x-1/2 -translate-y-1/2 inline-flex group/gh",children:[e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":s("leaderboard.github.aria"),className:"flex h-4 w-4 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 transition-transform hover:scale-110",children:e.jsx(ye,{provider:"GITHUB",size:14})}),e.jsxs("span",{role:"tooltip",className:"invisible opacity-0 group-hover/gh:visible group-hover/gh:opacity-100 absolute left-0 bottom-full mb-2 whitespace-nowrap rounded-md bg-oai-black dark:bg-oai-gray-700 px-2.5 py-1.5 text-[11px] leading-relaxed text-white shadow-lg transition-opacity duration-150 z-50 before:content-[''] before:absolute before:inset-x-0 before:top-full before:h-2.5",children:[e.jsx("span",{className:"block",children:s("leaderboard.github.tooltipAction")}),e.jsxs("span",{className:"block text-oai-gray-300 dark:text-oai-gray-400",children:[s("leaderboard.github.tooltipPrefix")," ",e.jsx(_a,{to:"/settings",onClick:r=>r.stopPropagation(),className:"text-white underline underline-offset-2 decoration-oai-gray-400 hover:text-oai-brand-300 hover:decoration-oai-brand-300",children:s("leaderboard.github.tooltipSettingsLink")})," ",s("leaderboard.github.tooltipSuffix")]})]})]})}function et({auth:a,signedIn:r,sessionSoftExpired:o}){const i=xa(),l=ba(),{openLoginModal:n}=pa(),{signedIn:m,loading:b,user:u}=ha(),{currency:h,rate:v}=Ya(),y=d.useMemo(()=>ya(),[]),p=fa(),x=r&&!o,E=d.useMemo(()=>x&&(typeof a=="function"||typeof a=="string"||a&&typeof a=="object")?a:null,[a,x]),C=x?E:null,ee=x&&ka(C),ae=s("shared.placeholder.short"),Je=d.useMemo(()=>q.map(t=>t.key),[]),{order:re,reorder:fe}=gr(Je),ke=d.useMemo(()=>{const t=new Map;for(const g of q)t.set(g.key,g);return t},[]),B=d.useMemo(()=>re.map(t=>ke.get(t)).filter(Boolean),[re,ke]),Ze=za($e(Ga,{activationConstraint:{distance:6}}),$e(Fa,{coordinateGetter:Oa})),Xe=d.useCallback(t=>{const{active:g,over:w}=t;!w||g.id===w.id||fe(String(g.id),String(w.id))},[fe]),[te,M]=d.useState(1),[_,qe]=d.useState(fr),[we,ve]=d.useState(null),[Qe,je]=d.useState(!1),Y=d.useCallback(t=>{typeof t=="string"&&t.trim()&&ve(t.trim())},[]),ea=d.useCallback(()=>ve(null),[]),aa=d.useCallback(t=>{const g=me.includes(t)?t:ge;qe(g),M(1);try{window.localStorage.setItem(Ve,String(g))}catch{}},[]),[Ne,ra]=d.useState(0),[ta,oa]=d.useState(()=>wa()),[_e,Se]=d.useState(!1);d.useEffect(()=>{if(typeof window>"u")return;const t=()=>{ra(g=>g+1)};return window.addEventListener(Be,t),()=>{window.removeEventListener(Be,t)}},[]);const N=d.useMemo(()=>{const t=new URLSearchParams(i?.search||"");return Oe(t.get("period"))||"total"},[i?.search]),sa=t=>{const g=Oe(t);if(!g||g===N)return;const w=new URLSearchParams(i?.search||"");w.set("period",g),M(1),l(`${i?.pathname||"/leaderboard"}?${w.toString()}`,{replace:!0})};d.useEffect(()=>{b||p||m||n()},[m,b,p,n]),d.useEffect(()=>{M(1)},[N]);const W=d.useMemo(()=>(H(te,{min:1,max:1e6,fallback:1})-1)*_,[te,_]),R=d.useMemo(()=>p?"mock":b?"unavailable":m?"cloud":r?"local":y?"public":"unavailable",[b,m,y,p,r]),k=d.useMemo(()=>va({accessMode:R,baseUrl:y,mockEnabled:p,userId:u?.id||null,period:N,pageSize:_,offset:W}),[u?.id,R,y,W,p,_,N]),[$,D]=d.useState(()=>{const t=ie(k);return t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!1,error:null,data:null,contextKey:null}});d.useEffect(()=>{if(!y&&!p||!p&&R==="unavailable"){D({loading:!1,error:null,data:null,contextKey:null});return}const t=ie(k);let g=!0;return D(t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!0,error:null,data:null,contextKey:null}),(async()=>{const w=await ja({userId:u?.id||null,period:N,limit:_,offset:W});g&&(Na(w,{activeContextKey:k,contextKey:k,source:Ne>0?"manual-refresh":"page-load"}),D({loading:!1,error:null,data:w,contextKey:k}))})().catch(w=>{if(!g)return;const T=Lr(w);D(F=>F.contextKey===k?{...F,loading:!1,error:T}:{loading:!1,error:T,data:null,contextKey:k})}),()=>{g=!1}},[y,R,u?.id,k,W,Ne,p,N,_]);const oe=d.useMemo(()=>$.contextKey===k?null:ie(k),[k,$.contextKey]),j=d.useMemo(()=>$.contextKey===k?$:oe?{loading:!1,error:null,data:oe.data,contextKey:k}:{loading:!!(y||p)&&R!=="unavailable",error:null,data:null,contextKey:k},[R,y,k,$,p,oe]),S=j.data,U=S?.total_pages??null,ia=S?.total_entries??0,P=S?.page??te,na=d.useMemo(()=>ar(P,U),[P,U]),Ce=S?.from||null,Ae=S?.to||null,la=S?.generated_at||null,V=kr(la),Le=er(),K=S?.me||null,I=s("leaderboard.me_label"),Ee=s("leaderboard.anon_label"),Te=s("leaderboard.period.week"),Me=s("leaderboard.period.month"),Pe=s("leaderboard.period.total"),Ke=N==="month"?Me:N==="total"?Pe:Te,J=d.useMemo(()=>{const t=Array.isArray(S?.entries)?S.entries:[];return tr({entries:t,me:K,meLabel:I})},[S?.entries,K,I]),z=d.useMemo(()=>or(K?.rank,_),[K?.rank,_]),da=z!=null&&z===P,ca=d.useCallback(()=>{z!=null&&M(z)},[z]),ma=async()=>{Se(!0);try{Aa(!0),oa(!0),await La(()=>Ea(C))}catch(t){console.warn("[tokentracker] sync:",t)}finally{Se(!1)}},{canPrev:Re,canNext:Ie}=rr({page:P,totalPages:U}),Z=Array.isArray(J)&&J.length!==0;let O=null;j.loading&&!Z?O=e.jsx(dr,{rows:_}):j.error&&!Z?O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:j.error})}):Z?O=e.jsxs(Ba,{sensors:Ze,collisionDetection:$a,modifiers:[Ha],onDragEnd:Xe,children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-full w-full text-left text-sm sm:min-w-max",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:c(He,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:s("leaderboard.column.rank")}),e.jsx("th",{className:c(Ye,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:s("leaderboard.column.user")}),e.jsx("th",{className:"px-3 sm:px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",children:s("leaderboard.column.total")}),e.jsx("th",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",title:"Based on estimated API pricing, not actual billing",children:s("leaderboard.column.est_cost")}),e.jsx(Da,{items:re,strategy:Ua,children:B.map(t=>e.jsx(cr,{id:t.key,thClassName:"hidden sm:table-cell px-3 sm:px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap align-middle",children:e.jsx(ir,{iconSrc:t.icon,label:s(t.copyKey)})},t.key))})]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:J.map((t,g)=>{if(t?.is_ellipsis){const L=4+B.length;return e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:L,className:"px-4 py-2 text-center text-oai-gray-400 dark:text-oai-gray-600 bg-white dark:bg-oai-gray-950 select-none tracking-[0.4em] text-xs",children:"···"})},`ellipsis-${g}`)}const w=!!t?.is_me,T=typeof t?.user_id=="string"?t.user_id:null,F=be(t?.display_name),ga=pe(F)?Ee:F,A=w?I:ga,G=!!T,ze=G?{role:"button",tabIndex:0,onClick:G?()=>Y(T):void 0,onKeyDown:G?L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),Y(T))}:void 0,"aria-label":s("leaderboard.profile_modal.row_aria",{name:A})}:{};if(w){const L=!!t?.is_pinned;return e.jsxs("tr",{...ze,className:c("bg-oai-gray-50 dark:bg-oai-gray-900 transition-colors",L?"border-t border-b border-oai-gray-300/40 dark:border-oai-gray-500/20":"border-y border-oai-gray-300/40 dark:border-oai-gray-500/30",G&&"cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-500/60"),children:[e.jsx("td",{className:c(de(!0),"font-semibold text-oai-gray-700 dark:text-oai-gray-300",L&&"before:absolute before:left-0 before:top-[15%] before:h-[70%] before:w-[3px] before:rounded-r before:bg-oai-gray-500 dark:before:bg-oai-gray-400"),children:e.jsx(Ue,{rank:t?.rank,placeholder:ae})}),e.jsx("td",{className:ce(!0),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:c("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&t?.pro_active!==!0&&"gh-avatar-frame"),children:[e.jsx("span",{className:c("inline-flex rounded-full p-px",t?.github_url&&t?.pro_active!==!0&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(X,{avatarUrl:t?.avatar_url,displayName:A,seed:he(t,A),proActive:t?.pro_active===!0})}),t?.github_url&&e.jsx(Fe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:A}),e.jsx(ne,{proActive:t?.pro_active===!0}),e.jsx(le,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-medium text-oai-black dark:text-oai-white whitespace-nowrap text-right tabular-nums bg-oai-gray-50 dark:bg-oai-gray-900",children:e.jsx(xe,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 font-medium text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap text-right tabular-nums bg-oai-gray-50 dark:bg-oai-gray-900",title:"Based on estimated API pricing, not actual billing",children:ue(t?.estimated_cost_usd,h,v)}),e.jsx(De,{entry:t,isMe:!0,orderedColumns:B})]},`row-${t?.rank}-${A}${L?"-pin":""}`)}return e.jsxs("tr",{...ze,className:c("group transition-colors",G&&"cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-500/60"),children:[e.jsx("td",{className:c(de(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(Ue,{rank:t?.rank,placeholder:ae})}),e.jsx("td",{className:ce(!1),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:c("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&t?.pro_active!==!0&&"gh-avatar-frame"),children:[e.jsx("span",{className:c("inline-flex rounded-full p-px",t?.github_url&&t?.pro_active!==!0&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(X,{avatarUrl:t?.avatar_url,displayName:A,seed:he(t,A),proActive:t?.pro_active===!0})}),t?.github_url&&e.jsx(Fe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:A}),e.jsx(ne,{proActive:t?.pro_active===!0}),e.jsx(le,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-semibold text-oai-gray-800 dark:text-oai-gray-200 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",children:e.jsx(xe,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",title:"Based on estimated API pricing, not actual billing",children:ue(t?.estimated_cost_usd,h,v)}),e.jsx(De,{entry:t,isMe:!1,orderedColumns:B})]},`row-${t?.rank}-${A}`)})})]})}),e.jsx("div",{className:"flex flex-col py-1.5 sm:hidden",children:J.map((t,g)=>{const w=be(t?.display_name),T=pe(w)?Ee:w;return e.jsx(Cr,{entry:t,entryIdx:g,name:t?.is_me?I:T,meLabel:I,currency:h,rate:v,orderedColumns:B,placeholder:ae,onOpenProfile:Y},`mobile-${t?.rank??"ellipsis"}-${g}`)})})]}):O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("leaderboard.empty")})});let se=null;return typeof U=="number"?se=na.map((t,g)=>t==null?e.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:s("leaderboard.pagination.ellipsis")},`ellipsis-${g}`):e.jsx("button",{className:c("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",t===P?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white"),onClick:()=>M(t),disabled:j.loading,children:String(t)},`page-${t}`)):se=e.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("leaderboard.pagination.page_unknown",{page:String(P)})}),e.jsxs("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-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-4 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-3.5 sm:mb-8 sm:grid-cols-[minmax(0,1fr)_auto] sm:gap-4",children:[e.jsx("h1",{className:"col-start-1 row-start-1 min-w-0 whitespace-nowrap text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:col-span-2 sm:row-start-1 sm:text-4xl",children:s("leaderboard.title")}),e.jsxs("p",{className:"col-span-2 row-start-2 hidden text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:block sm:row-start-2 sm:text-base",children:[N==="total"?s("leaderboard.range.total"):Ce&&Ae?s("leaderboard.range",{period:Ke,from:Ce,to:Ae}):s("leaderboard.range_loading",{period:Ke}),V&&e.jsx("time",{dateTime:V.dateTime,title:s("leaderboard.generated_at",{ts:V.exact}),className:"ml-2 hidden border-l border-oai-gray-200 pl-2 text-xs text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400 sm:inline-block",children:s("leaderboard.generated_at",{ts:V.display})})]}),e.jsx("div",{className:"col-start-2 row-start-1 inline-flex h-9 shrink-0 items-center rounded-full border border-oai-gray-200 p-1 dark:border-oai-gray-800 sm:col-start-1 sm:row-start-3 sm:justify-self-start",children:["week","month","total"].map(t=>{const g=N===t;return e.jsxs("button",{onClick:()=>sa(t),disabled:j.loading,className:c("px-3 sm:px-4 h-7 text-sm font-medium rounded-full flex items-center justify-center transition-colors relative",g?"text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200"),children:[e.jsx("span",{className:"relative z-10",children:t==="week"?Te:t==="month"?Me:Pe}),g&&e.jsx(Ka.div,{layoutId:"leaderboard-period-active-bg",className:"absolute inset-0 bg-oai-gray-200 dark:bg-oai-gray-800 rounded-full z-0",transition:{type:"spring",stiffness:380,damping:30}})]},t)})}),e.jsxs("div",{className:"col-span-2 row-start-2 mb-0 flex w-full min-w-0 items-center justify-between sm:justify-end gap-2.5 sm:col-span-1 sm:col-start-2 sm:row-start-3 sm:mb-0 sm:w-auto sm:shrink-0",children:[e.jsx(wr,{communityStats:Le,onClick:()=>je(!0)}),e.jsx(pr,{me:K,totalEntries:ia,meLabel:I,onOpenProfile:K?.user_id?()=>Y(K.user_id):void 0,onJumpToMe:ca,canJump:z!=null&&!da&&!j.loading,className:"shrink-0"})]})]}),!r&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:s("leaderboard.signin_prompt")}),e.jsx("button",{onClick:n,className:"shrink-0 whitespace-nowrap self-start sm:self-auto px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 transition-colors",children:s("leaderboard.signin_button")})]}),x&&ee&&!ta&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:s("leaderboard.sync_prompt")}),e.jsx("button",{onClick:ma,disabled:_e,className:"shrink-0 whitespace-nowrap self-start sm:self-auto px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 disabled:opacity-50 transition-colors",children:_e?s("leaderboard.sync_button.busy"):s("leaderboard.sync_button.idle")})]}),e.jsxs("div",{className:"sm:rounded-xl sm:border sm:border-oai-gray-200 sm:dark:border-oai-gray-800 sm:overflow-hidden border-none bg-transparent",children:[j.error&&Z?e.jsx("div",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-3",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:j.error})}):null,O,e.jsxs("div",{className:"flex flex-col gap-3 sm:border-t border-oai-gray-200 px-4 py-3 sm:flex-row sm:items-center sm:justify-end sm:gap-x-4 sm:px-6 dark:border-oai-gray-800 border-none mt-2.5 sm:mt-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:justify-start",children:[e.jsx("label",{htmlFor:"leaderboard-page-size",className:"whitespace-nowrap",children:s("leaderboard.pagination.page_size_label")}),e.jsx(Pa,{id:"leaderboard-page-size",value:_,onValueChange:t=>aa(Number(t)),disabled:j.loading,ariaLabel:s("leaderboard.pagination.page_size_label"),options:me.map(t=>({value:t,label:String(t)})),align:"end",className:"px-3 py-1 text-oai-gray-700 dark:text-oai-gray-300"})]}),e.jsx("div",{className:"hidden h-5 w-px bg-oai-gray-200 dark:bg-oai-gray-800 sm:block","aria-hidden":"true"}),e.jsxs("div",{className:"flex w-full items-center justify-between sm:w-auto sm:justify-end gap-1.5",children:[e.jsx("button",{className:c("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Re&&!j.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>M(t=>Math.max(1,t-1)),disabled:!Re||j.loading,children:s("leaderboard.pagination.prev")}),e.jsxs("span",{className:"text-xs font-semibold tabular-nums text-oai-gray-500 dark:text-oai-gray-455 px-2 sm:hidden",children:[P," / ",U||"?"]}),e.jsx("div",{className:"hidden sm:flex items-center gap-1",children:se}),e.jsx("button",{className:c("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Ie&&!j.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>M(t=>t+1),disabled:!Ie||j.loading,children:s("leaderboard.pagination.next")})]})]})]})]})}),e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("p",{children:s("landing.v2.footer.line")}),e.jsx("a",{href:"https://github.com/xiufengsun/TokenTracker",className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:s("landing.v2.nav.github")})]})}),e.jsxs(d.Suspense,{fallback:null,children:[e.jsx(hr,{isOpen:!!we,userId:we,period:N,accessToken:C,onClose:ea}),e.jsx(yr,{isOpen:Qe,onClose:()=>je(!1),communityStats:Le})]})]})}export{et as LeaderboardPage};
@@ -1 +0,0 @@
1
- import{r as c,aI as te,aK as k,j as v,aH as Fe,$ as M,bT as Te,aJ as z,bz as Pe,aO as G,aQ as xe,aT as U,aN as Le,bW as Ne,bX as Be,aL as j,bY as _e,bZ as le,aM as ue,aS as pe,b_ as Q,b$ as Ue,c0 as Ve,bw as Ye,be,bf as Xe,a6 as de,J as fe,bc as J,bd as $e,bi as Ge,c1 as Ke,bj as Je,bP as We,a1 as Ze,bo as ze,_ as Re,c2 as Qe,aP as q,c3 as qe,bs as et,bv as tt,c as $}from"./__vite-browser-external-DUJeOWgd.js";import{g as K,u as nt,c as ot,a as rt,s as st,b as it}from"./safePolygon-CKpREa4K.js";import{i as ye,D as at,P as ct,m as lt,j as ut,k as pt,l as dt,n as ft,o as gt,u as ht,p as mt,c as Tt,t as Pt,x as xt,y as bt}from"./composite-B4Z3F65o.js";import{p as Rt,c as yt}from"./store-C9yWYHfg.js";import{u as vt,a as Ct,g as St}from"./usePositioner-B0j1orGj.js";const ve=c.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new Fe,currentIdRef:{current:null},currentContextRef:{current:null}});function Et(n,e){n.current=e.current}function Ot(n){const{children:e,delay:t,timeoutMs:r=0}=n,o=c.useRef(t),p=c.useRef(t),i=c.useRef(null),l=c.useRef(null),f=te();return k(()=>{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]),v.jsx(ve.Provider,{value:c.useMemo(()=>({hasProvider:!0,delayRef:o,initialDelayRef:p,currentIdRef:i,timeoutMs:r,currentContextRef:l,timeout:f}),[r,f]),children:e})}function It(n,e={open:!1}){const{open:t}=e,r="rootStore"in n?n.rootStore:n,o=r.useState("floatingId"),p=c.useContext(ve),{currentIdRef:i,delayRef:l,timeoutMs:f,initialDelayRef:h,currentContextRef:u,hasProvider:T,timeout:d}=p,[m,s]=c.useState(!1),x=c.useRef(t);return k(()=>{x.current=t},[t]),k(()=>{function a(){u.current?.setIsInstantPhase(!1),i.current=null,u.current=null,l.current=h.current,d.clear()}if(i.current&&!t&&i.current===o){if(s(!1),f){const g=o;return d.start(f,()=>{r.select("open")||i.current&&i.current!==g||a()}),()=>{(x.current||i.current!==g)&&d.clear()}}a()}},[t,o,i,l,f,h,u,d,r]),k(()=>{if(!t)return;const a=u.current,g=i.current;d.clear(),u.current={onOpenChange:r.setOpen,setIsInstantPhase:s},i.current=o,l.current={open:0,close:K(h.current,"close")},g!==null&&g!==o?(s(!0),a?.setIsInstantPhase(!0),a?.onOpenChange(!1,M(Te))):(s(!1),a?.setIsInstantPhase(!1))},[t,o,r,i,l,h,u,d]),k(()=>()=>{if(i.current===o){if(u.current=null,!x.current)return;i.current=null,Et(l,h),d.clear()}},[u,i,l,o,h,d]),c.useMemo(()=>({activeIdRef:i,hasProvider:T,delayRef:l,isInstantPhase:m}),[i,T,l,m])}function wt(n,e){let t=null,r=null,o=!1;return{contextElement:n||void 0,getBoundingClientRect(){const p=n?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},i=e.axis==="x"||e.axis==="both",l=e.axis==="y"||e.axis==="both",f=["mouseenter","mousemove"].includes(e.dataRef.current.openEvent?.type||"")&&e.pointerType!=="touch";let h=p.width,u=p.height,T=p.x,d=p.y;return t==null&&e.x&&i&&(t=p.x-e.x),r==null&&e.y&&l&&(r=p.y-e.y),T-=t||0,d-=r||0,h=0,u=0,!o||f?(h=e.axis==="y"?p.width:0,u=e.axis==="x"?p.height:0,T=i&&e.x!=null?e.x:T,d=l&&e.y!=null?e.y:d):o&&!f&&(u=e.axis==="x"?p.height:u,h=e.axis==="y"?p.width:h),o=!0,{width:h,height:u,x:T,y:d,top:d,right:T+h,bottom:d+u,left:T}}}}function ge(n){return n!=null&&n.clientX!=null}function Mt(n,e={}){const{enabled:t=!0,axis:r="both"}=e,o="rootStore"in n?n.rootStore:n,p=o.useState("open"),i=o.useState("floatingElement"),l=o.useState("domReferenceElement"),f=o.context.dataRef,h=c.useRef(!1),u=c.useRef(null),[T,d]=c.useState(),[m,s]=c.useState([]),x=z(P=>{o.set("positionReference",P)}),a=z((P,y,E)=>{h.current||f.current.openEvent&&!ge(f.current.openEvent)||o.set("positionReference",wt(E??l,{x:P,y,axis:r,dataRef:f,pointerType:T}))}),g=z(P=>{p?u.current||(a(P.clientX,P.clientY,P.currentTarget),s([])):a(P.clientX,P.clientY,P.currentTarget)}),C=ye(T)?i:p;c.useEffect(()=>{if(!t){x(l);return}if(!C)return;function P(){u.current?.(),u.current=null}const y=Pe(i);function E(S){const I=xe(S);U(i,I)?P():a(S.clientX,S.clientY)}return!f.current.openEvent||ge(f.current.openEvent)?u.current=G(y,"mousemove",E):x(l),P},[C,t,i,f,l,o,a,x,m]),c.useEffect(()=>()=>{o.set("positionReference",null)},[o]),c.useEffect(()=>{t&&!i&&(h.current=!1)},[t,i]),c.useEffect(()=>{!t&&p&&(h.current=!0)},[t,p]);const b=c.useMemo(()=>{function P(y){d(y.pointerType)}return{onPointerDown:P,onPointerEnter:P,onMouseMove:g,onMouseEnter:g}},[g]);return c.useMemo(()=>t?{reference:b,trigger:b}:{},[t,b])}const ee=Ne&&Be;function Dt(n,e={}){const{enabled:t=!0,delay:r}=e,o="rootStore"in n?n.rootStore:n,{events:p,dataRef:i}=o.context,l=c.useRef(!1),f=c.useRef(null),h=c.useRef(!0),u=te();c.useEffect(()=>{const d=o.select("domReferenceElement");if(!t)return;const m=Pe(d);function s(){const g=o.select("domReferenceElement");!o.select("open")&&Ye(g)&&g===le(ue(g))&&(l.current=!0,f.current=g)}function x(){h.current=!0}function a(){h.current=!1}return Le(G(m,"blur",s),ee&&G(m,"keydown",x,!0),ee&&G(m,"pointerdown",a,!0))},[o,t]),c.useEffect(()=>{if(!t)return;function d(m){if(m.reason===be||m.reason===Xe){const s=o.select("domReferenceElement");j(s)&&(f.current=s,l.current=!0)}}return p.on("openchange",d),()=>{p.off("openchange",d)}},[p,t,o]);const T=c.useMemo(()=>{function d(){l.current=!1,f.current=null}return{onMouseLeave(){d()},onFocus(m){const s=m.currentTarget;if(l.current){if(f.current===s)return;d()}const x=xe(m.nativeEvent);if(j(x)){if(ee&&!m.relatedTarget){if(!h.current&&!Ue(x))return}else if(!Ve(x))return}const a=pe(m.relatedTarget,o.context.triggerElements),{nativeEvent:g,currentTarget:C}=m,b=typeof r=="function"?r():r;if(o.select("open")&&a||b===0||b===void 0){o.setOpen(!0,M(Q,g,C));return}u.start(b,()=>{l.current||o.setOpen(!0,M(Q,g,C))})},onBlur(m){d();const s=m.relatedTarget,x=m.nativeEvent,a=j(s)&&s.hasAttribute(_e("focus-guard"))&&s.getAttribute("data-type")==="outside";u.start(0,()=>{const g=o.select("domReferenceElement"),C=le(ue(g));!s&&C===g||U(i.current.floatingContext?.refs.floating.current,C)||U(g,C)||a||pe(s??C,o.context.triggerElements)||o.setOpen(!1,M(Q,x))})}}},[i,r,o,u]);return c.useMemo(()=>t?{reference:T,trigger:T}:{},[t,T])}function kt(n){let e=0;const t=String(n??"");for(let r=0;r<t.length;r+=1)e=Math.imul(31,e)+t.charCodeAt(r)|0;return Math.abs(e)%360}function At(n){const e=String(n??"").trim();if(!e)return"?";const t=e.split(/\s+/).filter(Boolean);if(t.length>=2){const r=t[0][0]||"",o=t[1][0]||"";return`${r}${o}`.toUpperCase()}return e.slice(0,2).toUpperCase()}const he={sm:"h-7 w-7 min-h-7 min-w-7 text-[10px]",md:"h-8 w-8 min-h-8 min-w-8 text-[11px]",lg:"h-14 w-14 min-h-14 min-w-14 text-base",xl:"h-[68px] w-[68px] min-h-[68px] min-w-[68px] text-xl"};function rn({avatarUrl:n,displayName:e,seed:t,size:r="md",proActive:o=!1,className:p}){const i=he[r]||he.md,l=kt(t??e??""),f=typeof n=="string"?n.trim():"",[h,u]=de.useState(!1),T=o===!0?"leaderboard-pro-avatar":null;return de.useEffect(()=>{u(!1)},[f]),f&&!h?v.jsx("img",{src:f,alt:"",referrerPolicy:"no-referrer",onError:()=>u(!0),className:fe("rounded-full object-cover ring-1 ring-white/10",i,p,T)}):v.jsx("div",{className:fe("flex shrink-0 items-center justify-center rounded-full font-semibold text-white ring-1 ring-white/10",i,p,T),style:{backgroundColor:`hsl(${l} 42% 34%)`},"aria-hidden":!0,children:At(e)})}const Ce=c.createContext(void 0);function W(n){const e=c.useContext(Ce);if(e===void 0&&!n)throw new Error(J(72));return e}const Ht={...Rt,disabled:n=>n.disabled,instantType:n=>n.instantType,isInstantPhase:n=>n.isInstantPhase,trackCursorAxis:n=>n.trackCursorAxis,disableHoverablePopup:n=>n.disableHoverablePopup,lastOpenChangeReason:n=>n.openChangeReason,closeOnClick:n=>n.closeOnClick,closeDelay:n=>n.closeDelay,adaptiveOrigin:n=>n.adaptiveOrigin};class jt extends $e{constructor(e,t,r){const o=new ct;super(Ft(e,o,t,r),Lt(o),Ht)}setOpen=(e,t)=>{at(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,M(be,e))}}function Ft(n,e,t,r=!1){return{...yt(e,t,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...n}}function Lt(n){return{popupRef:c.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:n}}const Nt=Ge(function(e){const{disabled:t=!1,defaultOpen:r=!1,open:o,disableHoverablePopup:p=!1,trackCursorAxis:i="none",actionsRef:l,onOpenChange:f,onOpenChangeComplete:h,handle:u,triggerId:T,defaultTriggerId:d=null,children:m}=e,s=lt((F,L)=>new jt({open:r,openProp:o,activeTriggerId:d,triggerIdProp:T},F,L));s.useControlledProp("openProp",o),s.useControlledProp("triggerIdProp",T),s.useContextCallback("onOpenChange",f),s.useContextCallback("onOpenChangeComplete",h);const x=s.useState("open"),a=!t&&x,g=s.useState("activeTriggerId"),C=s.useState("mounted"),b=s.useState("payload");s.useSyncedValues({trackCursorAxis:i,disableHoverablePopup:p,disabled:t}),ut(s,{closeOnActiveTriggerUnmount:!0});const{forceUnmount:P,transitionStatus:y}=pt(a,s),E=s.useState("isInstantPhase"),S=s.useState("instantType"),I=s.useState("lastOpenChangeReason"),D=c.useRef(null);k(()=>{x&&t&&s.setOpen(!1,M(Ke))},[x,t,s]),k(()=>{y==="ending"&&I===Te||y!=="ending"&&E?(S!=="delay"&&(D.current=S),s.set("instantType","delay")):D.current!==null&&(s.set("instantType",D.current),D.current=null)},[y,E,I,S,s]),k(()=>{a&&g==null&&s.set("payload",void 0)},[s,g,a]),c.useImperativeHandle(l,()=>({unmount:P,close:()=>s.setOpen(!1,M(Je))}),[P,s]);const H=a||C||!t&&i!=="none";return v.jsxs(Ce.Provider,{value:s,children:[u&&v.jsx(dt,{handle:u,store:s}),H&&v.jsx(Bt,{store:s,disabled:t,trackCursorAxis:i}),typeof m=="function"?m({payload:b}):m]})});function Bt({store:n,disabled:e,trackCursorAxis:t}){const r=n.useState("floatingRootContext"),o=ft(r,{enabled:!e,referencePress:()=>n.select("closeOnClick")}),p=Mt(r,{enabled:!e&&t!=="none",axis:t==="none"?void 0:t}),i=c.useMemo(()=>We(p.reference,o.reference),[p.reference,o.reference]);return gt(n,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:o.floating??Ze}),null}const Se=c.createContext(void 0);function _t(){return c.useContext(Se)}const Ut=600,Ee="data-base-ui-tooltip-trigger";function me(n){if("composedPath"in n){const t=n.composedPath();for(let r=0;r<t.length;r+=1){const o=t[r];if(j(o))return o}}const e=n.target;return j(e)?e:null}function Vt(n){let e=n;for(;e;){const t=e.closest(`[${Ee}]`);if(t)return t;const r=e.getRootNode();e="host"in r&&j(r.host)?r.host:null}return null}const Yt=ze(function(e,t){const{render:r,className:o,style:p,handle:i,payload:l,disabled:f,delay:h,closeOnClick:u=!0,closeDelay:T,id:d,...m}=e,s=W(!0),a=nt(i)??s;if(!a)throw new Error(J(82));const g=ht(d),C=a.useState("isTriggerActive",g),b=a.useState("isOpenedByTrigger",g),P=a.useState("floatingRootContext"),y=c.useRef(null),E=T??0,{registerTrigger:S,isMountedByThisTrigger:I}=mt(g,y,a,{payload:l,closeOnClick:u,closeDelay:E}),D=_t(),{activeIdRef:H,delayRef:F,isInstantPhase:L,hasProvider:O}=It(P,{open:b}),N=ot(P);a.useSyncedValue("isInstantPhase",L);const Z=a.useState("disabled"),B=f??Z,ne=Tt(B),oe=a.useState("trackCursorAxis"),we=a.useState("disableHoverablePopup"),_=c.useRef(!1),V=te(),Y=c.useRef(void 0);function re(){return O&&H.current!=null?0:h??D??Ut}function se(R){const w=y.current;if(!w||!R)return!1;const A=Vt(R);return A!==null&&A!==w&&U(w,A)}function Me(R){const w=se(R);return _.current=w,w&&(N.openChangeTimeout.clear(),N.restTimeout.clear(),N.restTimeoutPending=!1,V.clear()),w}const De=rt(P,{enabled:!B,mouseOnly:!0,move:!1,handleClose:!we&&oe!=="both"?st():null,restMs:re,delay(){return T==null&&O?{close:K(F.current,"close")}:{close:E}},triggerElementRef:y,isActiveTrigger:C,isClosing:()=>a.select("transitionStatus")==="ending",shouldOpen(){return!_.current}}),ke=Dt(P,{enabled:!B}).reference,Ae=R=>{const w=_.current,A=me(R),ie=Me(A),X=y.current,je=X&&A&&U(X,A);if(ie&&a.select("open")&&a.select("lastOpenChangeReason")===q){a.setOpen(!1,M(q,R));return}if(w&&!ie&&je&&!ne.current&&!a.select("open")&&X&&ye(Y.current)){const ae=()=>{!_.current&&!ne.current&&!a.select("open")&&a.setOpen(!0,M(q,R,X))},ce=re();ce===0?(V.clear(),ae()):V.start(ce,ae)}},He=a.useState("triggerProps",I);return Re("button",e,{state:{open:b},ref:[t,S,y],props:[De,ke,I||oe!=="none"?He:void 0,{onMouseOver(R){Ae(R.nativeEvent)},onFocus(R){se(me(R.nativeEvent))&&R.preventBaseUIHandler()},onMouseLeave(){_.current=!1,V.clear(),Y.current=void 0},onPointerEnter(R){Y.current=R.pointerType},onPointerDown(R){Y.current=R.pointerType,a.set("closeOnClick",u),u&&!a.select("open")&&a.cancelPendingOpen(R.nativeEvent)},onClick(R){u&&!a.select("open")&&a.cancelPendingOpen(R.nativeEvent)},id:g,[Qe]:B?"":void 0,[Ee]:B?void 0:""},m],stateAttributesMapping:Pt})}),Oe=c.createContext(void 0);function Xt(){const n=c.useContext(Oe);if(n===void 0)throw new Error(J(70));return n}const $t=c.forwardRef(function(e,t){const{keepMounted:r=!1,...o}=e;return W().useState("mounted")||r?v.jsx(Oe.Provider,{value:r,children:v.jsx(qe,{ref:t,...o})}):null}),Ie=c.createContext(void 0);function Gt(){const n=c.useContext(Ie);if(n===void 0)throw new Error(J(71));return n}const Kt=c.forwardRef(function(e,t){const{render:r,className:o,anchor:p,positionMethod:i="absolute",side:l="top",align:f="center",sideOffset:h=0,alignOffset:u=0,collisionBoundary:T="clipping-ancestors",collisionPadding:d=5,arrowPadding:m=5,sticky:s=!1,disableAnchorTracking:x=!1,collisionAvoidance:a=et,style:g,...C}=e,b=W(),P=Xt(),y=b.useState("open"),E=b.useState("mounted"),S=b.useState("trackCursorAxis"),I=b.useState("disableHoverablePopup"),D=b.useState("floatingRootContext"),H=b.useState("instantType"),F=b.useState("transitionStatus"),L=b.useState("adaptiveOrigin"),O=vt({anchor:p,positionMethod:i,floatingRootContext:D,mounted:E,side:l,sideOffset:h,align:f,alignOffset:u,collisionBoundary:T,collisionPadding:d,sticky:s,arrowPadding:m,disableAnchorTracking:x,keepMounted:P,collisionAvoidance:a,adaptiveOrigin:L}),N=c.useMemo(()=>({open:y,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:S!=="none"?"tracking-cursor":H}),[y,O.side,O.align,O.anchorHidden,S,H]),Z=Ct(e,N,{styles:O.positionerStyles,transitionStatus:F,props:C,refs:[t,b.useStateSetter("positionerElement")],hidden:!E,inert:!y||S==="both"||I});return v.jsx(Ie.Provider,{value:O,children:Z})}),Jt=c.forwardRef(function(e,t){const{render:r,className:o,style:p,...i}=e,l=W(),{side:f,align:h}=Gt(),u=l.useState("open"),T=l.useState("instantType"),d=l.useState("transitionStatus"),m=l.useState("popupProps"),s=l.useState("floatingRootContext"),x=l.useState("disabled"),a=l.useState("closeDelay");tt({open:u,ref:l.context.popupRef,onComplete(){u&&l.context.onOpenChangeComplete?.(!0)}}),it(s,{enabled:!x,closeDelay:a});const g=l.useStateSetter("popupElement");return Re("div",e,{state:{open:u,side:f,align:h,instant:T,transitionStatus:d},ref:[t,l.context.popupRef,g],props:[xt,m,St(d),i],stateAttributesMapping:bt})}),Wt=function(e){const{delay:t,closeDelay:r,timeout:o=400}=e,p=c.useMemo(()=>({open:t,close:r}),[t,r]);return v.jsx(Se.Provider,{value:t,children:v.jsx(Ot,{delay:p,timeoutMs:o,children:e.children})})};function sn({proActive:n=!1}){return n!==!0?null:v.jsx(Wt,{delay:350,children:v.jsxs(Nt,{children:[v.jsx(Yt,{render:v.jsx("span",{role:"img",tabIndex:0}),className:"leaderboard-pro-badge","aria-label":$("leaderboard.pro.badge_aria"),"aria-description":$("leaderboard.pro.tooltip"),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&e.stopPropagation()},children:$("leaderboard.pro.badge")}),v.jsx($t,{children:v.jsx(Kt,{side:"top",sideOffset:6,className:"leaderboard-pro-tooltip-layer",children:v.jsx(Jt,{className:"leaderboard-pro-tooltip",children:$("leaderboard.pro.tooltip")})})})]})})}export{rn as L,sn as a};
@@ -1 +0,0 @@
1
- import{A as me,aa as xe,a as he,r as o,F as ae,c as a,j as e,J as h}from"./__vite-browser-external-DUJeOWgd.js";import{A as be}from"./arrow-left-BEM-HVmC.js";const te={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};te.node;const fe=me(te),pe=e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),ye=e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),we={google:pe,github:ye},ke={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function ve(i){return ke[i]||String(i||"").replace(/-/g," ")}function je(i){if(typeof i=="string"&&i.trim())return i.trim();if(i&&typeof i=="object"){if(typeof i.token=="string"&&i.token.trim())return i.token.trim();if(typeof i.otp=="string"&&i.otp.trim())return i.otp.trim()}return""}function Ce({title:i,subtitle:D,className:oe="",onSuccess:S,hideLogo:H=!1,initialMode:p="signin",tokenFromUrl:P="",initialEmail:y="",initialCode:v=""}){xe();const{enabled:w,configurationError:se,connectionHost:G,signedIn:j,refreshUser:A,signInWithPassword:Z,signUp:T,signInWithOAuth:U,getPublicAuthConfig:V,sendResetPasswordEmail:$,exchangeResetPasswordToken:W,resetPassword:z}=he(),[n,u]=o.useState(p),[c,k]=o.useState(y),[m,N]=o.useState(""),[E,L]=o.useState(""),[F,ie]=o.useState(""),[R,J]=o.useState(v),[_,x]=o.useState(!1),[K,s]=o.useState(null),[C,b]=o.useState(null),[q,O]=o.useState(!1),[ne,le]=o.useState(!!(p!=="signin"||y)),[M,Q]=o.useState(!0),[I,X]=o.useState([]),[Y,de]=o.useState(8);o.useEffect(()=>{p&&u(p)},[p]),o.useEffect(()=>{y&&k(y)},[y]),o.useEffect(()=>{v&&J(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return Q(!0),(async()=>{const{data:t,error:l}=await V();if(r){if(l||!t)X(["google","github"]);else{const d=Array.isArray(t.oAuthProviders)?t.oAuthProviders:[],f=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];X([...d,...f]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&de(t.passwordMinLength)}Q(!1)}})(),()=>{r=!1}},[w,V]),o.useEffect(()=>{j&&S&&S()},[j,S]);const ee=o.useCallback(()=>{if(typeof window>"u")return"";const r=new URLSearchParams(window.location.search).get("next");return!ae()&&/^\/(cloud|billing\/checkout)(\?|$)/.test(r||"")?`${window.location.origin}/dashboard`:ae()?"tokentracker://auth/callback":`${window.location.origin}/`},[]),re=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),x(!0);try{const{error:t}=await U(r,ee());t&&s(t.message||String(t))}finally{x(!1)}},[U,ee]);o.useEffect(()=>{if(!w||M||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),l=t.get("native")==="1",d=t.get("provider");l&&d&&[...I].includes(d)&&B(d)},[w,M,j,I,B]);const ce=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{if(n==="signup"){const{data:l,error:d}=await T({email:c.trim(),password:m,name:F.trim()||void 0});if(d){s(d.message||String(d));return}if(l?.requireEmailVerification){b(a("login.verify_email_pending")),u("signin");return}await A();return}const{error:t}=await Z({email:c.trim(),password:m});if(t){s(t.message||String(t));return}await A()}finally{x(!1)}},[n,c,m,F,T,Z,A]),ge=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{const t=c.trim(),{error:l}=await $({email:t,redirectTo:re});if(l){s(l.message||String(l));return}k(t),b(a("reset_password.request.sent")),u("reset_confirm")}finally{x(!1)}},[c,re,$]),ue=o.useCallback(async r=>{if(r.preventDefault(),s(null),m!==E){s(a("reset_password.error.password_mismatch"));return}x(!0);try{let t=P;if(!t){const{data:d,error:f}=await W({email:c.trim(),code:R.trim()});if(f){s(f.message||String(f));return}if(t=je(d),!t){s(a("reset_password.error.missing_token"));return}}const{error:l}=await z({newPassword:m,otp:t});if(l){s(l.message||String(l));return}O(!0),b(a("reset_password.success"))}finally{x(!1)}},[R,E,c,W,m,z,P]);if(!w)return se?e.jsx("p",{role:"alert",className:"p-4 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:a("instance.configuration.invalid")}):null;const g=n==="reset_email"||n==="reset_confirm";return e.jsxs("div",{className:h("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",oe),children:[g&&e.jsxs("button",{type:"button",onClick:()=>{u("signin"),b(null),s(null),O(!1),N(""),L("")},className:"flex items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors mb-4 focus:outline-none",children:[e.jsx(be,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:h("mb-6",g?"text-left":"text-center"),children:[!H&&!g&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white font-oai tracking-tight",children:a("shared.app_name")})]}),e.jsx("h2",{className:h("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(H||g)&&"text-base font-bold md:text-lg"),children:g?a("reset_password.title"):i||a("login_modal.subtitle")}),!g&&D&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px] mx-auto",children:D}),g&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px]",children:C&&n==="reset_confirm"&&!q?C:a("reset_password.subtitle")})]}),G?e.jsx("p",{className:"mb-4 text-center text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a("instance.connection.destination",{host:G})}):null,C&&(!g||q)&&e.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:C}),K&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:K}),n==="reset_email"&&e.jsxs("form",{onSubmit:ge,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.request.submit")})]}),n==="reset_confirm"&&(q?e.jsx("button",{type:"button",onClick:()=>{u("signin"),O(!1),b(null),s(null),N(""),L("")},className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors text-center shadow-sm",children:a("reset_password.success_cta")}):e.jsxs("form",{onSubmit:ue,className:"space-y-3",children:[!P&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email-confirm",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-code",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.code")}),e.jsx("input",{id:"card-reset-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:R,onChange:r=>J(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.new_password")}),e.jsx("input",{id:"card-reset-password",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:m,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.confirm_password")}),e.jsx("input",{id:"card-reset-password-confirm",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:E,onChange:r=>L(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.reset.submit")})]})),!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2.5 mb-5",children:M?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"}),e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"})]}):I.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:h("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[we[r]||null,a("login.oauth.continue",{provider:ve(r)})]},r))}),ne?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login_modal.divider_email")})})]}),e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[e.jsx("button",{type:"button",className:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{u("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{u("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:ce,className:"space-y-3",children:[n==="signup"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.name")}),e.jsx("input",{id:"card-name",type:"text",autoComplete:"name",value:F,onChange:r=>ie(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:a("login.field.name_placeholder")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-email",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.password")}),e.jsx("input",{id:"card-password",type:"password",autoComplete:n==="signup"?"new-password":"current-password",required:!0,minLength:n==="signup"?Y:void 0,value:m,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),n==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:a("login.password_hint",{min:String(Y)})}),n==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{u("reset_email"),s(null),b(null)},className:"text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white no-underline bg-transparent border-0 p-0 cursor-pointer focus:outline-none",children:a("login.forgot_password")})})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:n==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login.divider")})})]}),e.jsxs("button",{type:"button",onClick:()=>le(!0),className:h("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[e.jsx(fe,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{Ce as L};
@@ -1 +0,0 @@
1
- import{u as s,a as c,r as l,j as e,X as d}from"./__vite-browser-external-DUJeOWgd.js";import{m as o}from"./react-B7SkZTgg.js";import{L as m}from"./LoginCard-Dn5Xy4If.js";import{A as p}from"./index-BImBG3eS.js";import"./arrow-left-BEM-HVmC.js";function f(){const{isOpen:i,closeLoginModal:t}=s(),{enabled:r}=c();return l.useEffect(()=>{if(!i)return;const a=n=>{n.key==="Escape"&&t()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[i,t]),r?e.jsx(p,{children:i&&e.jsxs(o.div,{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[e.jsx(o.div,{className:"absolute inset-0 bg-black/40 dark:bg-black/60",onClick:t,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}),e.jsxs(o.div,{className:"relative w-full max-w-[420px] rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 shadow-2xl overflow-hidden",initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.2},onClick:a=>a.stopPropagation(),children:[e.jsx("button",{type:"button",onClick:t,className:"absolute right-4 top-4 z-10 text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:e.jsx(d,{className:"h-5 w-5"})}),e.jsx(m,{onSuccess:t,className:"p-6 bg-transparent"})]})]})}):null}export{f as LoginModal};
@@ -1 +0,0 @@
1
- import{d as w,e as v,a as j,r,c as s,j as e,L as b}from"./__vite-browser-external-DUJeOWgd.js";import{L as N}from"./LoginCard-Dn5Xy4If.js";import"./arrow-left-BEM-HVmC.js";function _(n){const t=new URLSearchParams(n).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function E(){const n=w(),[t,u]=v(),{enabled:o,configurationError:f,loading:g,signedIn:m,refreshUser:x}=j(),i=r.useMemo(()=>_(t.toString()),[t]),[h,d]=r.useState(null);r.useEffect(()=>{if(/^\/(cloud|billing\/checkout)(\?|$)/.test(i))try{window.sessionStorage.setItem("tt.cloud.return",i)}catch{}},[i]),r.useEffect(()=>{const l=t.get("insforge_status"),a=t.get("insforge_type"),y=t.get("insforge_error");l==="success"&&a==="verify_email"?d(s("login.verify_email_success")):l==="error"&&a==="verify_email"&&y&&d(s("shared.error.prefix",{error:y}))},[t]);const c=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!o||g)&&m){if(c){window.location.href="/auth/native-callback";return}try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(i,{replace:!0})}},[o,g,m,n,i,c]),r.useEffect(()=>{o&&x()},[o,x]),r.useEffect(()=>{if(c&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[c]);const p=r.useCallback(()=>{u(l=>{const a=new URLSearchParams(l);return a.delete("insforge_status"),a.delete("insforge_type"),a.delete("insforge_error"),a},{replace:!0}),d(null)},[u]);return o?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(b,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[h?e.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",onClick:p,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:s("login.dismiss")})]}):null,e.jsx("div",{className:"border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(N,{hideLogo:!0,title:s("login.title"),subtitle:s("login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{if(c)window.location.href="/auth/native-callback";else{try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(i,{replace:!0})}}})})]})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(b,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",role:f?"alert":void 0,children:f?s("instance.configuration.invalid"):s("login.cloud_only")})})]})}export{E as LoginPage};
@@ -1 +0,0 @@
1
- import{r as a,bc as V,bd as re,aP as Q,be as J,bf as ae,a0 as ie,bg as ce,an as Z,bh as $,aH as ue,j as d,bi as le,$ as z,bj as pe,bk as de,bl as ge,aT as fe,bm as me,bn as Pe,bo as he,Z as Ce,_ as te,bp as Se,bq as X,br as Te,bs as be,bt as ve,aK as xe,bu as Re,aJ as Ie,bv as Ee,bw as Oe}from"./__vite-browser-external-DUJeOWgd.js";import{p as ye,c as Fe}from"./store-C9yWYHfg.js";import{d as Me,e as ke,P as je,f as we,h as Ae,j as He,k as Be,l as Ge,m as Ne,n as _e,o as Le,u as Ke,p as Ue,q as De,t as Ve,r as qe,I as Ye,s as Je,v as Ze,w as $e,x as ze,C as Qe,y as We}from"./composite-B4Z3F65o.js";import{k as Xe,l as et,m as tt,n as ot}from"./SelectItemText-C7xi8iGp.js";import{u as nt,a as st,s as rt,b as at}from"./safePolygon-CKpREa4K.js";import{u as it,a as ct,g as ut}from"./usePositioner-B0j1orGj.js";const oe=a.createContext(void 0);function K(e){const o=a.useContext(oe);if(o===void 0&&!e)throw new Error(V(47));return o}const lt={...ye,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class pt extends re{constructor(o,t,i){const s=new je;super(dt(o,s,t,i),gt(s),lt)}setOpen=(o,t)=>{const i=t.reason===Q,s=t.reason===J&&t.event.detail===0,g=!o&&(t.reason===ae||t.reason==null),l=Me(t),c=this.select("activeTriggerId");if(!o&&t.reason===ie&&t.trigger==null&&c!=null&&(t.trigger=this.context.triggerElements.getById(c)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(o,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(o,t);const f=()=>{const m=ke(this.state,o,t.trigger,l());m.openChangeReason=t.reason,this.update(m)};i?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(ce,()=>{this.set("stickIfOpen",!1)}),Z.flushSync(f)):f();let n;s?n="click":g?n="dismiss":t.reason===$&&(n="focus"),this.set("instantType",n)}}function dt(e,o,t,i=!1){const s={...Fe(o,t,i),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return s.open&&e?.mounted===void 0&&(s.mounted=!0),s}function gt(e){return{popupRef:a.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:a.createRef(),beforeContentFocusGuardRef:a.createRef(),stickIfOpenTimeout:new ue,triggerElements:e}}const ee=le(function({props:o}){const{children:t,open:i,defaultOpen:s=!1,onOpenChange:g,onOpenChangeComplete:l,modal:c=!1,handle:f,triggerId:n,defaultTriggerId:m=null}=o,r=ft(f,{modal:c,open:s,openProp:i,activeTriggerId:m,triggerIdProp:n});r.useControlledProp("openProp",i),r.useControlledProp("triggerIdProp",n);const P=r.useState("open"),I=r.useState("mounted"),T=r.useState("payload");r.useContextCallback("onOpenChange",g),r.useContextCallback("onOpenChangeComplete",l),Ae(r,P),He(r);const{forceUnmount:v}=Be(P,r,()=>{r.update({stickIfOpen:!0,openChangeReason:null})});r.useSyncedValues({modal:c}),a.useEffect(()=>{P||r.context.stickIfOpenTimeout.clear()},[r,P]),a.useImperativeHandle(o.actionsRef,()=>({unmount:v,close:()=>r.setOpen(!1,z(pe))}),[v,r]);const y=P||I;return d.jsxs(oe.Provider,{value:r,children:[f&&d.jsx(Ge,{handle:f,store:r}),y&&d.jsx(mt,{store:r,modal:c}),typeof t=="function"?t({payload:T}):t]})});function yt(e){return K(!0)?d.jsx(ee,{props:e}):d.jsx(we,{children:d.jsx(ee,{props:e})})}function ft(e,o){const t=Ne((i,s)=>new pt(o,i,s));return a.useEffect(()=>t.context.stickIfOpenTimeout.disposeEffect(),[t]),t}function mt({store:e,modal:o}){const t=e.useState("floatingRootContext"),i=_e(t,{outsidePressEvent:{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),s=i.reference,g=i.floating;return Le(e,{activeTriggerProps:s,inactiveTriggerProps:s,popupProps:g}),null}const Pt=300;function ht(e,o){const t=a.useRef(null);function i(g){Z.flushSync(()=>{e.setOpen(!1,z($,g.nativeEvent,g.currentTarget))}),Pe(t.current)?.focus()}function s(g){const l=e.select("positionerElement");if(l&&de(g,l))e.context.beforeContentFocusGuardRef.current?.focus();else{Z.flushSync(()=>{e.setOpen(!1,z($,g.nativeEvent,g.currentTarget))});let c=ge(e.context.triggerFocusTargetRef.current||o.current);for(;c!==null&&fe(l,c);){const f=c;if(c=me(c),c===f)break}c?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:i,handleFocusTargetFocus:s}}const Ft=he(function(o,t){const{render:i,className:s,style:g,disabled:l=!1,nativeButton:c=!0,handle:f,payload:n,openOnHover:m=!1,delay:r=Pt,closeDelay:P=0,id:I,...T}=o,v=K(!0),u=nt(f)??v;if(!u)throw new Error(V(74));const h=Ke(I),p=u.useState("isTriggerActive",h),F=u.useState("floatingRootContext"),E=u.useState("isOpenedByTrigger",h),M=u.useState("triggerPopupId",h),C=a.useRef(null),{registerTrigger:b,isMountedByThisTrigger:x}=Ue(h,C,u,{payload:n,disabled:l,openOnHover:m,closeDelay:P}),O=u.useState("openChangeReason"),B=u.useState("stickIfOpen"),G=u.useState("openMethod"),k=u.useState("focusManagerModal"),N=st(F,{enabled:!l&&m&&(G!=="touch"||O!==J),mouseOnly:!0,move:!1,handleClose:rt(),restMs:r,delay:{close:P},triggerElementRef:C,isActiveTrigger:p,isClosing:()=>u.select("transitionStatus")==="ending"}),j=Xe(F,{stickIfOpen:B}),_=et(()=>u.select("open"),R=>{u.set("openMethod",R)}),w=u.useState("triggerProps",x),{getButtonProps:A,buttonRef:S}=Ce({disabled:l,native:c}),U={open(R){return R&&O===J?De.open(R):Ve.open(R)}},{preFocusGuardRef:D,handlePreFocusGuardFocus:q,handleFocusTargetFocus:Y}=ht(u,C),H=te("button",o,{state:{disabled:l,open:E},ref:[S,t,b,C],props:[j.reference,N,w,_,{[Se]:"",id:h,"aria-haspopup":"dialog","aria-expanded":E,"aria-controls":M},T,A],stateAttributesMapping:U}),L=d.jsx(a.Fragment,{children:H},h);return x&&!k?d.jsxs(a.Fragment,{children:[d.jsx(X,{ref:D,onFocus:q}),L,d.jsx(X,{ref:u.context.triggerFocusTargetRef,onFocus:Y})]}):L}),ne=a.createContext(void 0);function Ct(){const e=a.useContext(ne);if(e===void 0)throw new Error(V(45));return e}const Mt=a.forwardRef(function(o,t){const{keepMounted:i=!1,...s}=o;return K().useState("mounted")||i?d.jsx(ne.Provider,{value:i,children:d.jsx(Te,{ref:t,...s})}):null}),se=a.createContext(void 0);function St(){const e=a.useContext(se);if(!e)throw new Error(V(46));return e}const kt=a.forwardRef(function(o,t){const{render:i,className:s,style:g,anchor:l,positionMethod:c,side:f,align:n,sideOffset:m,alignOffset:r,collisionBoundary:P="clipping-ancestors",collisionPadding:I,arrowPadding:T,sticky:v,disableAnchorTracking:y=!1,collisionAvoidance:u=be,...h}=o,p=K(),F=Ct(),E=qe(),M=p.useState("floatingRootContext"),C=p.useState("mounted"),b=p.useState("open"),x=p.useState("openChangeReason"),O=p.useState("activeTriggerElement"),B=p.useState("modal"),G=p.useState("openMethod"),k=p.useState("positionerElement"),N=p.useState("instantType"),j=p.useState("transitionStatus"),_=p.useState("adaptiveOrigin"),w=a.useRef(null),A=ve(k),S=it({anchor:l,floatingRootContext:M,positionMethod:c,mounted:C,side:f,sideOffset:m,align:n,alignOffset:r,arrowPadding:T,collisionBoundary:P,collisionPadding:I,sticky:v,disableAnchorTracking:y,keepMounted:F,nodeId:E,collisionAvoidance:u,adaptiveOrigin:_}),U=M.useState("domReferenceElement");xe(()=>{const H=U,L=w.current;if(H&&(w.current=H),L&&H&&H!==L){p.set("instantType",void 0);const R=new AbortController;return A(()=>{p.set("instantType","trigger-change")},R.signal),()=>{R.abort()}}},[U,A,p]);const D=B===!0&&x!==Q;tt(b&&D,G==="touch",k,O);const q=p.useStateSetter("positionerElement"),Y={open:b,side:S.side,align:S.align,anchorHidden:S.anchorHidden,instant:N},W=ct(o,Y,{styles:S.positionerStyles,transitionStatus:j,props:h,refs:[t,q],hidden:!C,inert:!b});return d.jsxs(se.Provider,{value:S,children:[C&&D&&d.jsx(Ye,{inert:Re(!b),cutout:O}),d.jsx(Je,{id:E,children:W})]})}),Tt=a.createContext(void 0);function bt(){const[e,o]=a.useState(0),t=Ie(()=>(o(s=>s+1),()=>{o(s=>Math.max(0,s-1))}));return{context:a.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}const jt=a.forwardRef(function(o,t){const{render:i,className:s,style:g,initialFocus:l,finalFocus:c,...f}=o,n=K(),m=St(),r=ot()!=null,{context:P,hasClosePart:I}=bt(),T=n.useState("open"),v=n.useState("openMethod"),y=n.useState("instantType"),u=n.useState("transitionStatus"),h=n.useState("popupProps"),p=n.useState("titleElementId"),F=n.useState("descriptionElementId"),E=n.useState("modal"),M=n.useState("mounted"),C=n.useState("openChangeReason"),b=n.useState("activeTriggerElement"),x=n.useState("floatingRootContext"),O=x.useState("floatingId"),B=n.useState("disabled"),G=n.useState("openOnHover"),k=n.useState("closeDelay");Ee({open:T,ref:n.context.popupRef,onComplete(){T&&n.context.onOpenChangeComplete?.(!0)}}),at(x,{enabled:G&&!B,closeDelay:k});const N=l===void 0?Ze(n.context.popupRef):l,j=E!==!1&&I;n.useSyncedValue("focusManagerModal",j);const _=n.useStateSetter("popupElement"),w={open:T,side:m.side,align:m.align,instant:y,transitionStatus:u},A=te("div",o,{state:w,ref:[t,n.context.popupRef,_],props:[h,{id:O,role:"dialog",...ze,"aria-labelledby":p,"aria-describedby":F,onKeyDown(S){r&&Qe.has(S.key)&&S.stopPropagation()}},ut(u),f],stateAttributesMapping:We});return d.jsx($e,{context:x,openInteractionType:v,modal:j,disabled:!M||C===Q,initialFocus:N,returnFocus:c,restoreFocus:"popup",previousFocusableElement:Oe(b)?b:void 0,nextFocusableElement:n.context.triggerFocusTargetRef,beforeContentFocusGuardRef:n.context.beforeContentFocusGuardRef,children:d.jsx(Tt.Provider,{value:P,children:A})})});export{yt as P,Ft as a,Mt as b,kt as c,jt as d};
@@ -1 +0,0 @@
1
- import{r as p,_ as S,j as e,J as h}from"./__vite-browser-external-DUJeOWgd.js";import{u as v,a as w,b as k,L as j,s as N,S as C,c as R,d as E,C as I,e as T,f as L,g as P,h as A,i as _,j as O}from"./SelectItemText-C7xi8iGp.js";import{C as D}from"./check-CKwHc4Hv.js";const G=p.forwardRef(function(t,s){const{render:i,className:x,style:o,...l}=t,r=v(),{multiple:n,readOnly:c}=w(),{alignItemWithTriggerActive:d}=k(),g=r.useState("hasScrollArrows"),a=r.useState("openMethod"),u={id:`${r.useState("id")}-list`,role:"listbox","aria-multiselectable":n||void 0,"aria-readonly":c||void 0,onScroll(f){r.context.scrollHandlerRef.current?.(f.currentTarget)},...d&&{style:j},className:g&&a!=="touch"?N.className:void 0},y=r.useStateSetter("listElement");return S("div",t,{ref:[s,y],props:[u,l]})}),M="relative inline-flex items-center justify-between gap-2 rounded-lg border border-oai-gray-200 bg-white text-oai-black transition-colors hover:border-oai-gray-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:hover:border-oai-gray-700";function F({value:m,onValueChange:t,options:s=[],ariaLabel:i,id:x,disabled:o=!1,leadingIcon:l=null,className:r="",popupClassName:n="",align:c="start",matchTriggerWidth:d=!1}){const g=s.map(a=>({value:a.value,label:a.label}));return e.jsxs(C,{value:m,items:g,disabled:o,onValueChange:a=>{!o&&a!=null&&t?.(a)},children:[e.jsxs(R,{id:x,"aria-label":i,className:h(M,o&&"cursor-not-allowed opacity-50 hover:border-oai-gray-200 dark:hover:border-oai-gray-800",r),children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l,e.jsx(E,{className:"truncate"})]}),e.jsx(I,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),e.jsx(T,{children:e.jsx(L,{align:c,side:"bottom",sideOffset:4,className:"z-50",children:e.jsx(P,{className:h("max-h-[min(18rem,var(--available-height))] origin-[var(--transform-origin)] overflow-y-auto","rounded-xl border border-oai-gray-200 bg-white p-1 shadow-lg ring-1 ring-black/[0.04]","dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:ring-white/[0.05]","transition-[opacity,transform] duration-150 ease-out","data-[starting-style]:scale-95 data-[starting-style]:opacity-0","data-[ending-style]:scale-95 data-[ending-style]:opacity-0",d&&"min-w-[var(--anchor-width)]",n),children:e.jsx(G,{role:"listbox","aria-label":i,children:s.map(a=>e.jsxs(A,{value:a.value,disabled:a.disabled,className:({selected:b,disabled:u})=>h("flex w-full cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg py-1.5 pl-1.5 pr-6","text-left text-xs outline-none transition-colors",b?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800/70 dark:text-white":"text-oai-gray-600 hover:bg-oai-gray-50 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800/60",u&&"cursor-not-allowed opacity-50 hover:bg-transparent dark:hover:bg-transparent"),children:[e.jsx("span",{className:"flex w-3.5 shrink-0 items-center justify-center text-oai-gray-500 dark:text-oai-gray-300",children:e.jsx(_,{children:e.jsx(D,{className:"h-3 w-3","aria-hidden":!0})})}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.jsx(O,{children:a.label})})]},String(a.value)))})})})})]})}export{F as S};
@@ -1 +0,0 @@
1
- import{A as wn,be as vn,r as o,cL as st,aI as $e,aQ as Kt,b$ as Mn,a1 as Ge,$ as pe,cI as Pn,aF as ke,aK as q,aL as On,cM as Yt,cJ as An,aJ as Y,cZ as Dt,c_ as mt,c$ as kt,bZ as ht,aM as Ne,aT as Ee,d0 as Nt,bw as Ht,d1 as Je,bh as $t,bX as Gt,d2 as ct,d3 as ut,d4 as Xt,d5 as Tt,cT as Ln,d6 as Vn,d7 as bt,cY as Fn,bc as He,aD as te,j as ae,bv as Et,bP as yt,bO as Dn,bR as kn,bS as Nn,bT as it,bd as Hn,cO as _n,bz as rt,cG as Un,Z as Jt,_ as _e,d8 as Bn,br as Wn,d9 as jn,bu as zn,aO as qn,da as Kn,bN as Zt,db as xt}from"./__vite-browser-external-DUJeOWgd.js";import{i as St,E as Qt,b as en,F as Yn,P as $n,c as Oe,a as Gn,G as Xn,H as Ie,J as tn,A as Jn,u as Zn,B as nn,n as Qn,x as er,q as tr,I as nr,w as rr,z as or,C as sr}from"./composite-B4Z3F65o.js";import{u as ir,a as lr,b as cr,p as ur,r as ar,g as fr}from"./usePositioner-B0j1orGj.js";const rn={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};rn.node;const wo=wn(rn);function Ke(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function dr(e,t={}){const{enabled:n=!0,event:r="click",toggle:s=!0,ignoreMouse:i=!1,stickIfOpen:l=!0,touchOpenDelay:f=0,reason:c=vn}=t,y="rootStore"in e?e.rootStore:e,b=y.context.dataRef,x=o.useRef(void 0),w=st(),m=$e(),V=o.useMemo(()=>{function v(d,_,T,p){const a=pe(c,_,T);d&&p==="touch"&&f>0?m.start(f,()=>{y.setOpen(!0,a)}):y.setOpen(d,a)}function C(d,_,T){const p=b.current.openEvent,a=y.select("domReferenceElement")!==_;return d&&a||!d||!s?!0:p&&l?!T(p.type):!1}return{onPointerDown(d){x.current=St(d.pointerType,!0)&&Qt(d.nativeEvent)?"virtual":d.pointerType},onMouseDown(d){const _=x.current,T=d.nativeEvent,p=y.select("open");if(d.button!==0||r==="click"||St(_,!0)&&i)return;const a=C(p,d.currentTarget,S=>S==="click"||S==="mousedown"),O=Kt(T);if(Mn(O)){v(a,T,O,_);return}const h=d.currentTarget;w.request(()=>{v(a,T,h,_)})},onClick(d){if(r==="mousedown-only")return;const _=x.current;if(r==="mousedown"&&_){x.current=void 0;return}if(St(_,!0)&&i)return;const T=y.select("open"),p=C(T,d.currentTarget,a=>a==="click"||a==="mousedown"||a==="keydown"||a==="keyup");v(p,d.nativeEvent,d.currentTarget,_)},onKeyDown(){x.current=void 0}}},[b,r,i,c,y,l,s,w,m,f]);return o.useMemo(()=>n?{reference:V}:Ge,[n,V])}function pr(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=Pn(),i=en()!=null,l=ke(()=>new Yn({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new $n,floatingId:s,syncOnly:!1,nested:i})).current;return q(()=>{const f={open:t,floatingId:s};r.reference!==void 0&&(f.referenceElement=r.reference,f.domReferenceElement=On(r.reference)?r.reference:null),r.floating!==void 0&&(f.floatingElement=r.floating),l.update(f)},[t,s,r.reference,r.floating,l]),l.context.onOpenChange=n,l.context.nested=i,l}const gr="Escape";function _t(e){return Gt&&e.movementX===0&&e.movementY===0}function at(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Ze(e,t){return at(t,e===Xt||e===Tt,e===ct||e===ut)}function Rt(e,t,n){return at(t,e===Tt,n?e===ct:e===ut)||e==="Enter"||e===" "||e===""}function mr(e,t,n){return at(t,n?e===ct:e===ut,e===Tt)}function hr(e,t,n,r){const s=n?e===ut:e===ct,i=e===Xt;return t==="both"||t==="horizontal"&&r?e===gr:at(t,s,i)}function xr(e,t){const{listRef:n,activeIndex:r,onNavigate:s=()=>{},enabled:i=!0,selectedIndex:l=null,allowEscape:f=!1,loopFocus:c=!1,nested:y=!1,rtl:b=!1,virtual:x=!1,focusItemOnOpen:w="auto",focusItemOnHover:m=!0,openOnArrowKeyDown:V=!0,disabledIndices:v=void 0,orientation:C="vertical",parentOrientation:d,id:_,resetOnPointerLeave:T=!0,externalTree:p,grid:a}=t,O=a!=null,h="rootStore"in e?e.rootStore:e,S=h.useState("open"),H=h.useState("floatingElement"),D=h.useState("domReferenceElement"),G=h.context.dataRef,$=Yt(H),R=An(D),F=Oe($),K=en(),J=Gn(p),z=o.useRef(w),M=o.useRef(l??-1),U=o.useRef(null),g=o.useRef(!0),E=Y(u=>{s(M.current===-1?null:M.current,u)}),A=o.useRef(!!H),L=o.useRef(S),k=o.useRef(!1),X=o.useRef(!1),ne=o.useRef(null),re=Oe(v),se=Oe(S),le=Oe(l),oe=Oe(T),fe=st(),B=st(),j=Y(()=>{function u(N){x?J?.events.emit("virtualfocus",N):ne.current=Xn(N,{sync:k.current,preventScroll:!0})}const I=n.current[M.current],Q=X.current;I&&u(I),(k.current?N=>N():N=>fe.request(N))(()=>{const N=n.current[M.current]||I;if(!N)return;I||u(N),ue&&(Q||!g.current)&&N.scrollIntoView?.({block:"nearest",inline:"nearest"})})});q(()=>{G.current.orientation=C},[G,C]),q(()=>{i&&(S&&H?(M.current=l??-1,z.current&&l!=null&&(X.current=!0,E())):A.current&&(M.current=-1,E()))},[i,S,H,l,E]),q(()=>{if(i){if(!S){k.current=!1;return}if(H)if(r==null){if(k.current=!1,le.current!=null)return;if(A.current&&(M.current=-1,j()),(!L.current||!A.current)&&z.current&&(U.current!=null||z.current===!0&&U.current==null)){let u=0;const I=()=>{n.current[0]==null?(u<2&&(u?P=>B.request(P):queueMicrotask)(I),u+=1):(M.current=U.current==null||Rt(U.current,C,b)||y?mt(n):kt(n),U.current=null,E())};I()}}else Dt(n.current,r)||(M.current=r,j(),X.current=!1)}},[i,S,H,r,le,y,n,C,b,E,j,B]),q(()=>{if(!i||H||!J||x||!A.current)return;const u=J.nodesRef.current,I=u.find(N=>N.id===K)?.context?.elements.floating,Q=ht(Ne(D??I??null)),P=u.some(N=>N.context&&Ee(N.context.elements.floating,Q));I&&!P&&g.current&&I.focus({preventScroll:!0})},[i,H,D,J,K,x]),q(()=>{L.current=S,A.current=!!H}),q(()=>{S||(U.current=null,z.current=w)},[S,w]);const ce=r!=null,Z=Y(u=>{if(!se.current)return;const I=n.current.indexOf(u.currentTarget);I!==-1&&(M.current!==I||r!==I)&&(M.current=I,E(u))}),ge=Y(()=>d??J?.nodesRef.current.find(u=>u.id===K)?.context?.dataRef?.current.orientation),xe=Y(()=>mt(n,re.current)),de=Y(u=>{if(g.current=!1,k.current=!0,u.which===229||!se.current&&u.currentTarget===F.current)return;if(y&&hr(u.key,C,b,O)){Ze(u.key,ge())||Ie(u),h.setOpen(!1,pe(Nt,u.nativeEvent)),Ht(D)&&(x?J?.events.emit("virtualfocus",D):D.focus());return}const I=M.current,Q=mt(n,v),P=kt(n,v);if(R||(u.key==="Home"&&(Ie(u),M.current=Q,E(u)),u.key==="End"&&(Ie(u),M.current=P,E(u))),a!=null){const N=a(u,M.current,n,C,c,b,v,Q,P);if(N!=null&&(M.current=N,E(u)),C==="both")return}if(Ze(u.key,C)){if(Ie(u),S&&!x&&ht(u.currentTarget.ownerDocument)===u.currentTarget){M.current=Rt(u.key,C,b)?Q:P,E(u);return}Rt(u.key,C,b)?c?I>=P?f&&I!==n.current.length?M.current=-1:(k.current=!1,M.current=Q):M.current=Je(n.current,{startingIndex:I,disabledIndices:v}):M.current=Math.min(P,Je(n.current,{startingIndex:I,disabledIndices:v})):c?I<=Q?f&&I!==-1?M.current=n.current.length:(k.current=!1,M.current=P):M.current=Je(n.current,{startingIndex:I,decrement:!0,disabledIndices:v}):M.current=Math.max(Q,Je(n.current,{startingIndex:I,decrement:!0,disabledIndices:v})),Dt(n.current,M.current)&&(M.current=-1),E(u)}}),ue=o.useMemo(()=>({onFocus(I){k.current=!0,Z(I)},onClick:({currentTarget:I})=>I.focus({preventScroll:!0}),onMouseMove(I){_t(I)||(k.current=!0,X.current=!1,m&&Z(I))},onPointerLeave(I){if(!se.current||!g.current||I.pointerType==="touch")return;k.current=!0;const Q=I.relatedTarget;if(!(!m||n.current.includes(Q))&&oe.current&&(ne.current?.(),ne.current=null,M.current=-1,E(I),!x)){const P=F.current,N=ht(Ne(P));P&&Ee(P,N)&&P.focus({preventScroll:!0})}}}),[Z,se,F,m,n,E,oe,x]),me=o.useMemo(()=>x&&S&&ce&&{"aria-activedescendant":`${_}-${r}`},[x,S,ce,_,r]),Se=o.useMemo(()=>({...R?{}:me,onKeyDown(u){if(u.key==="Tab"&&u.shiftKey&&S&&!x){const I=Kt(u.nativeEvent);if(I&&!Ee(F.current,I))return;Ie(u),h.setOpen(!1,pe($t,u.nativeEvent)),Ht(D)&&D.focus();return}de(u)},onPointerMove(u){_t(u)||(g.current=!0)}}),[me,de,F,R,h,S,x,D]),ee=o.useMemo(()=>{function u(P){h.setOpen(!0,pe(Nt,P.nativeEvent,P.currentTarget))}function I(P){w==="auto"&&tn(P.nativeEvent)&&(z.current=!x)}function Q(P){z.current=w,w==="auto"&&Qt(P.nativeEvent)&&(z.current=!0)}return{onKeyDown(P){const N=h.select("open");g.current=!1;const ve=P.key.startsWith("Arrow"),Me=mr(P.key,ge(),b),be=Ze(P.key,C),Re=(y?Me:be)||P.key==="Enter"||P.key.trim()==="";if(x&&N)return de(P);if(!(!N&&!V&&ve)){if(Re){const Ue=Ze(P.key,ge());U.current=y&&Ue?null:P.key}if(y){Me&&(Ie(P),N?(M.current=xe(),E(P)):u(P));return}be&&(le.current!=null&&(M.current=le.current),Ie(P),!N&&V?u(P):de(P),N&&E(P))}},onFocus(P){h.select("open")&&!x&&(M.current=-1,E(P))},onPointerDown:Q,onPointerEnter:Q,onMouseDown:I,onClick:I}},[de,w,xe,y,E,h,V,C,ge,b,le,x]),we=o.useMemo(()=>({...me,...ee}),[me,ee]);return o.useMemo(()=>i?{reference:we,floating:Se,item:ue,trigger:ee}:{},[i,we,Se,ee,ue])}function Sr(e,t){const{listRef:n,elementsRef:r,activeIndex:s,onMatch:i,disabledIndices:l,onTyping:f,enabled:c=!0,resetMs:y=750,selectedIndex:b=null}=t,x="rootStore"in e?e.rootStore:e,w=x.useState("open"),m=$e(),V=o.useRef(""),v=o.useRef(b??s??-1),C=o.useRef(null),d=Y(p=>{function a(F){return r?.current[F]}function O(F){const K=a(F);return K&&!Ln(K)||K?.matches(":disabled")?!1:l==null||!Vn(bt,F,l)}function h(F,K,J=0){if(F.length===0)return-1;const z=(J%F.length+F.length)%F.length,M=K.toLowerCase();for(let U=0;U<F.length;U+=1){const g=(z+U)%F.length;if(!(!F[g]?.toLowerCase().startsWith(M)||!O(g)))return g}return-1}const S=n.current;if(V.current.length>0&&p.key===" "&&(Ie(p),f?.(!0)),V.current.length>0&&V.current[0]!==" "&&h(S,V.current)===-1&&p.key!==" "&&f?.(!1),S==null||p.key.length!==1||p.ctrlKey||p.metaKey||p.altKey)return;w&&p.key!==" "&&(Ie(p),f?.(!0));const H=V.current==="";H&&(v.current=b??s??-1),S.every((F,K)=>F&&O(K)?F[0]?.toLowerCase()!==F[1]?.toLowerCase():!0)&&V.current===p.key&&(V.current="",v.current=C.current),V.current+=p.key,m.start(y,()=>{V.current="",v.current=C.current,f?.(!1)});const $=((H?b??s??-1:v.current)??0)+1,R=h(S,V.current,$);R!==-1?(i?.(R),C.current=R):p.key!==" "&&(V.current="",f?.(!1))}),_=Y(p=>{const a=p.relatedTarget,O=x.select("domReferenceElement"),h=x.select("floatingElement");Ee(O,a)||Ee(h,a)||(m.clear(),V.current="",v.current=C.current,f?.(!1))});q(()=>{!w&&b!==null||(m.clear(),C.current=null,V.current!==""&&(V.current=""))},[w,b,m]);const T=o.useMemo(()=>({onKeyDown:d,onBlur:_}),[d,_]);return o.useMemo(()=>c?{reference:T,floating:T}:{},[c,T])}function Rr(e){const t=o.useRef(""),n=o.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:o.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s?e(s,s.pointerType):e(s,t.current),t.current=""},[e]),onPointerDown:n}}function on(e,t){const n=o.useRef(e),r=Y(t);q(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function br(e,t){const n=Y((i,l)=>{(typeof e=="function"?e():e)||t(l||(Fn?"touch":""))}),{onClick:r,onPointerDown:s}=Rr(n);return o.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function yr(e){const[t,n]=o.useState(null),r=br(e,n);return on(e,s=>{s&&!e&&n(null)}),o.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const Ir=20;function Cr(e,t,n,r){const[s,i]=o.useState(!1);q(()=>{if(!e||!t||n==null){i(!1);return}const l=Ne(n).documentElement.clientWidth,f=n.offsetWidth;i(l>0&&f>0&&f>=l-Ir)},[e,t,n]),Jn(e&&(!t||s),r)}const Tr=o.createContext(void 0);function Er(e){return o.useContext(Tr)}function wr(e){const[t,n]=o.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function vr(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function Mr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Ut({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=o.useRef(e!==void 0),[i,l]=o.useState(t),f=s&&e!==void 0?e:i,c=o.useCallback(y=>{s||l(y)},[]);return[f,c]}const sn=o.createContext(void 0),ln=o.createContext(void 0),cn=o.createContext(void 0);function Le(){const e=o.useContext(sn);if(e===void 0)throw new Error(He(60));return e}function wt(){const e=o.useContext(ln);if(e===void 0)throw new Error(He(101));return e}function un(){const e=o.useContext(cn);if(e===void 0)throw new Error(He(61));return e}const Pr="data-valid",Or="data-invalid",Ar={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Lr={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Vr={disabled:!1,...Lr},Fr={valid(e){return e===null?null:e?{[Pr]:""}:{[Or]:""}}},Dr={invalid:void 0,name:void 0,validityData:{state:Ar,errors:[],error:"",value:"",initialValue:null},setValidityData:te,disabled:void 0,setTouched:te,setDirty:te,setFilled:te,setFocused:te,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:Vr,registerFieldControl:te,validation:{getValidationProps:(e,t=Ge)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:te,getInputControl:()=>null,commit:async()=>{},change:te}},kr=o.createContext(Dr);function vt(e=!0){const t=o.useContext(kr);if(t.setValidityData===te&&!e)throw new Error(He(28));return t}function Nr(e,t,n,r,s=!0,i){const{registerFieldControl:l}=vt(),f=ke(()=>Symbol());q(()=>{const c=f.current;if(!s){l(c,void 0);return}l(c,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,s,r,t,i,l,f,n]),q(()=>{const c=f.current;return()=>{l(c,void 0)}},[l,f])}const Hr=o.createContext({controlId:void 0,registerControlId:te,resetControlId:te,labelId:void 0,setLabelId:te,messageIds:[],setMessageIds:te,getDescriptionProps:e=>e});function an(){return o.useContext(Hr)}function fn(e={}){const{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:s,resetControlId:i}=an(),l=Zn(),f=ke(()=>Symbol()),c=o.useRef(!1),y=o.useRef(!1),b=Y(()=>{!c.current||s===te||(c.current=!1,s(f.current,void 0))});return q(()=>{if(!n||s===te){b();return}let x;if(t!==void 0)y.current=!0,x=t;else if(y.current)x=l;else{i();return}if(x===void 0){b();return}c.current=!0,s(f.current,x)},[t,n,s,i,l,f,b]),q(()=>b,[b]),(n?r:void 0)??t??l}function _r(e,t,n=Object.is){const{length:r}=e;if(r!==t.length)return!1;for(let s=0;s<r;s+=1)if(!n(e[s],t[s]))return!1;return!0}const dn=(e,t)=>Object.is(e,t);function Ae(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Ur(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!_r(e,t,(r,s)=>Ae(r,s,n)):e!==t}function It(e,t,n){return e?e.some(r=>r===void 0?!1:Ae(t,r,n)):!1}function ot(e,t,n){return e?e.findIndex(r=>r===void 0?!1:Ae(r,t,n)):-1}function Br(e,t){if(t!==dn)return r=>It(e,r,t);const n=new Set(e);return n.delete(void 0),r=>n.has(r)&&(r!==0||e.some(s=>Object.is(r,s)))}function pn(e,t,n,r){const s=r&&Array.isArray(t)?e.findIndex(Br(t,n)):ot(e,t,n);return s===-1?null:s}function Wr(e,t,n,r,s,i){return It(r,t,s)?i!=null&&e>i&&It(r,n[i],s)?i:e:e===i?pn(n,r,s,!0):i}function jr(e,t,n){return e.filter(r=>!Ae(t,r,n))}function Ct(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function zr(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function gn(e){return zr(e?.[0])}function qr(e){return gn(e)?e.flatMap(t=>t.items):e}function Kr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(gn(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function mn(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return Ct(e)}function De(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Ct(e.value):Ct(e)}function hn(e,t,n){function r(){return mn(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){const i=qr(t);if(e==null||typeof e!="object"){const l=i.find(f=>f.value===e);return l&&l.label!=null?l.label:r()}if("value"in e){const l=i.find(f=>f&&f.value===e.value);if(l&&l.label!=null)return l.label}}return r()}function Yr(e,t,n){return e.reduce((r,s,i)=>(i>0&&r.push(", "),r.push(ae.jsx(o.Fragment,{children:hn(s,t,n)},i)),r),[])}const $r={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:De(t,r)!==""},hasNullItemLabel:(e,t)=>t?Kr(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(s=>Ae(t,s,n)):Ae(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},Gr=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:te,validationMode:"onSubmit",submitCountRef:{current:0}});function Xr(){return o.useContext(Gr)}const Ce=1;function xn(e,t){return Math.max(0,e-t)}function Jr(e,t){if(t<=0)return 0;const n=Ke(e,0,t),r=n,s=t-n,i=r<=Ce,l=s<=Ce;return i&&l?r<=s?0:t:i?0:l?t:n}function vo(e){const{id:t,value:n,defaultValue:r=null,onValueChange:s,open:i,defaultOpen:l=!1,onOpenChange:f,name:c,form:y,autoComplete:b,disabled:x=!1,readOnly:w=!1,required:m=!1,modal:V=!0,actionsRef:v,inputRef:C,onOpenChangeComplete:d,items:_,multiple:T=!1,itemToStringLabel:p,itemToStringValue:a,isItemEqualToValue:O=dn,highlightItemOnHover:h=!0,children:S}=e,{clearErrors:H}=Xr(),{setDirty:D,setTouched:G,setFocused:$,validityData:R,setFilled:F,name:K,disabled:J,validation:z,validationMode:M}=vt(),U=fn({id:t}),g=J||x,E=K??c,[A,L]=Ut({controlled:n,default:T?r??bt:r,name:"Select",state:"value"}),[k,X]=Ut({controlled:i,default:l,name:"Select",state:"open"}),ne=o.useRef([]),re=o.useRef([]),se=o.useRef(null),le=o.useRef(null),oe=o.useRef(0),fe=o.useRef(null),B=o.useRef([]),j=o.useRef(!1),ce=o.useRef(null),Z=o.useRef(null),ge=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),xe=o.useRef(!1),de=o.useRef(A),{mounted:ue,setMounted:me,transitionStatus:Se}=nn(k),{openMethod:ee,triggerProps:we}=yr(k),u=ke(()=>new Hn({id:U,labelId:void 0,modal:V,multiple:T,itemToStringLabel:p,itemToStringValue:a,isItemEqualToValue:O,value:A,open:k,mounted:ue,transitionStatus:Se,items:_,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Ge,triggerProps:Ge,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:te,setOpen:te,handleScrollArrowVisibility:te,onOpenChangeComplete:te,listRef:ne,popupRef:se,scrollHandlerRef:le,scrollArrowsMountedCountRef:oe,valueRef:fe,valuesRef:B,labelsRef:re,typingRef:j,selectionRef:ge,firstItemTextRef:ce,selectedItemTextRef:Z,alignItemWithTriggerActiveRef:xe,initialValueRef:de},$r)).current,I=u.useState("activeIndex"),Q=u.useState("selectedIndex"),P=u.useState("triggerElement"),N=u.useState("positionerElement"),ve=wr(ee),Me=ee??ve,be=o.useMemo(()=>T?"":De(A,a),[T,A,a]),Re=o.useMemo(()=>T&&Array.isArray(A)?A.map(W=>De(W,a)):De(A,a),[T,A,a]),Ue=Oe(P),Be=Y(()=>Re);Nr(Ue,U,A,Be,!g,c);const We=T?Array.isArray(A)&&A.length>0:A!=null&&be!=="";q(()=>{F(We)},[We,F]),q(function(){const ie=pn(B.current,A,O,T);ie===null&&(Z.current=null),!k&&u.set("selectedIndex",ie)},[T,k,A,O,u]),on(A,()=>{H(E),D(Ur(A,R.initialValue,O)),z.change(A)});const je=Y((W,ie)=>{f?.(W,ie),!ie.isCanceled&&(X(W),!W&&(ie.reason===$t||ie.reason===_n)&&(G(!0),$(!1),M==="onBlur"&&z.commit(A)))}),Ve=Y(()=>{me(!1),u.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),d?.(!1)});Et({enabled:!v,open:k,ref:se,onComplete(){k||Ve()}}),o.useImperativeHandle(v,()=>({unmount:Ve}),[Ve]);const ze=Y((W,ie)=>{s?.(W,ie),!ie.isCanceled&&L(W)}),ft=Y(W=>{const ie=xn(W.scrollHeight,W.clientHeight),Xe=Jr(W.scrollTop,ie),dt=Xe>0,qe=Xe<ie;u.set("scrollUpArrowVisible",dt),u.set("scrollDownArrowVisible",qe)}),Pe=pr({open:k,onOpenChange:je,elements:{reference:P,floating:N}}),he=dr(Pe,{enabled:!g,event:"mousedown"}),ye=Qn(Pe),Te=xr(Pe,{enabled:!g,listRef:ne,activeIndex:I,selectedIndex:Q,disabledIndices:bt,onNavigate(W){W===null&&!k||u.set("activeIndex",W)},focusItemOnHover:h}),Fe=Sr(Pe,{enabled:!g&&(k||!w&&!T),listRef:re,activeIndex:I,selectedIndex:Q,disabledIndices:W=>Mr(ne.current[W]),onMatch(W){k?u.set("activeIndex",W):ze(B.current[W],pe(it))},onTyping(W){j.current=W}}),Pt=o.useMemo(()=>yt(Fe.reference,Te.reference,ye.reference,he.reference,we),[he.reference,Fe.reference,Te.reference,ye.reference,we]),Ot=o.useMemo(()=>yt(er,Fe.floating,Te.floating,ye.floating),[Fe.floating,Te.floating,ye.floating]),At=Te.item??Ge;u.useContextCallback("setValue",ze),u.useContextCallback("setOpen",je),u.useContextCallback("handleScrollArrowVisibility",ft),u.useContextCallback("onOpenChangeComplete",d),vr(()=>{u.update({popupProps:Ot,triggerProps:Pt})}),u.useSyncedValues({id:U,modal:V,multiple:T,value:A,open:k,mounted:ue,transitionStatus:Se,popupProps:Ot,triggerProps:Pt,items:_,itemToStringLabel:p,itemToStringValue:a,isItemEqualToValue:O,openMethod:Me});const In=o.useMemo(()=>({disabled:g,readOnly:w,required:m,multiple:T,highlightItemOnHover:h,itemProps:At}),[g,w,m,T,h,At]),Cn=Dn(C,z.inputRef),Lt=T?void 0:E,Tn=o.useMemo(()=>!T||!Array.isArray(A)||!E?null:A.map(W=>{const ie=De(W,a);return ae.jsx("input",{type:"hidden",form:y,name:E,value:ie,disabled:g},ie)}),[T,A,y,E,a,g]);return ae.jsxs(sn.Provider,{value:u,children:[ae.jsx(ln.Provider,{value:In,children:ae.jsx(cn.Provider,{value:Pe,children:S})}),ae.jsx("input",{...z.getValidationProps(g,{onFocus(){u.state.triggerElement?.focus({focusVisible:!0})},onChange(W){if(W.nativeEvent.defaultPrevented||g||w)return;const ie=W.currentTarget.value,Xe=pe(it,W.nativeEvent);function dt(){if(T)return;const qe=ie.toLowerCase();let pt=B.current.findIndex(gt=>De(gt,a).toLowerCase()===qe||mn(gt,p).toLowerCase()===qe);pt===-1&&(pt=B.current.findIndex((gt,En)=>{const Ft=re.current[En];return Ft!=null&&Ft.toLowerCase()===qe}));const Vt=B.current[pt];Vt!=null&&ze(Vt,Xe)}u.set("forceMount",!0),queueMicrotask(dt)}}),id:U&&Lt==null?`${U}-hidden-input`:void 0,form:y,name:Lt,autoComplete:b,value:be,disabled:g,required:m&&!(T&&We),readOnly:w,ref:Cn,style:E?kn:Nn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Tn]})}function Zr(e,t){return e??t}const Qe=5;function Qr(e,t){const n=eo(t);return e.clientX>=n.left-Qe&&e.clientX<=n.right+Qe&&e.clientY>=n.top-Qe&&e.clientY<=n.bottom+Qe}function eo(e){const t=e.getBoundingClientRect(),n=rt(e);if(Un)return t;const r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const l=parseFloat(r.width)||0,f=parseFloat(r.height)||0,c=parseFloat(s.width)||0,y=parseFloat(s.height)||0,b=Math.max(t.width,l,c),x=Math.max(t.height,f,y),w=b-t.width,m=x-t.height;return{left:t.left-w/2,right:t.right+w/2,top:t.top-m/2,bottom:t.bottom+m/2}}const to="data-popup-side",no=400,ro={...tr,...Fr,popupSide:e=>e?{[to]:e}:null,value:()=>null},Mo=o.forwardRef(function(t,n){const{render:r,className:s,id:i,disabled:l=!1,nativeButton:f=!0,style:c,...y}=t,{setTouched:b,setFocused:x,validationMode:w,validation:m,state:V,disabled:v}=vt(),{labelId:C}=an(),d=Le(),{readOnly:_,required:T,disabled:p}=wt(),a=v||p||l,O=d.useState("open"),h=d.useState("mounted"),S=d.useState("value"),H=d.useState("triggerProps"),D=d.useState("positionerElement"),G=d.useState("listElement"),$=d.useState("popupSide"),R=d.useState("id"),F=d.useState("labelId"),K=d.useState("hasSelectedValue"),J=h&&D?$:null,z=i??R,M=Zr(C,F);fn({id:i});const U=Oe(D),g=o.useRef(null),{getButtonProps:E,buttonRef:A}=Jt({disabled:a,native:f}),L=d.useStateSetter("triggerElement"),k=$e(),X=$e(),ne=$e();o.useEffect(()=>{if(O)return ne.start(no,()=>{d.context.selectionRef.current.allowUnselectedMouseUp=!0,d.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{ne.clear()};d.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},X.clear()},[O,d,X,ne]);const re=yt(H,{id:z,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?G?.id??Yt(D)?.id:void 0,"aria-labelledby":M,"aria-readonly":_||void 0,"aria-required":T||void 0,tabIndex:a?-1:0,onFocus(oe){x(!0),O&&d.context.alignItemWithTriggerActiveRef.current&&d.context.setOpen(!1,pe(it,oe.nativeEvent)),k.start(0,()=>{d.set("forceMount",!0)})},onBlur(oe){Ee(D,oe.relatedTarget)||(b(!0),x(!1),w==="onBlur"&&m.commit(S))},onMouseDown(oe){if(O)return;const fe=Ne(oe.currentTarget);function B(j){if(!g.current)return;const ce=j.target;Ee(g.current,ce)||Ee(U.current,ce)||Qr(j,g.current)||d.context.setOpen(!1,pe(Bn,j))}X.start(0,()=>{fe.addEventListener("mouseup",B,{once:!0})})}},y,E),se=m.getValidationProps(a,re);se.role="combobox";const le={...V,open:O,disabled:a,value:S,readOnly:_,popupSide:J,placeholder:!K};return _e("button",t,{ref:[n,g,A,L],state:le,stateAttributesMapping:ro,props:se})}),oo={value:()=>null},Po=o.forwardRef(function(t,n){const{className:r,render:s,children:i,placeholder:l,style:f,...c}=t,y=Le(),b=y.useState("value"),x=y.useState("items"),w=y.useState("itemToStringLabel"),m=y.useState("hasSelectedValue"),V=!m&&l!=null&&i==null,v=y.useState("hasNullItemLabel",V),C={value:b,placeholder:!m};let d=null;return typeof i=="function"?d=i(b):i!=null?d=i:V&&!v?d=l:Array.isArray(b)?d=Yr(b,x,w):d=hn(b,x,w),_e("span",t,{state:C,ref:[n,y.context.valueRef],props:[{children:d},c],stateAttributesMapping:oo})}),Oo=o.forwardRef(function(t,n){const r=Le(),s=r.useState("mounted"),i=r.useState("forceMount");return s||i?ae.jsx(Wn,{ref:n,...t}):null}),Sn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function so(){return o.useContext(Sn)}function io(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,i=Y(s),[,l]=o.useState(!1),f=ke(co).current,c=ke(lo).current,y=o.useRef(0),b=o.useRef(!0),x=o.useRef(null),w=o.useRef(null),m=Y(()=>{b.current||(b.current=!0,l(a=>!a))}),V=Y((a,O)=>{c.set(a,O),m()}),v=Y(a=>{c.delete(a),m()}),C=Y(a=>{const O=new Map;return n.current.length=0,r&&(r.current.length=0),a.forEach(h=>{O.set(h.element,{...h.registration.metadata??{},index:h.index}),n.current[h.index]=h.element,r&&(r.current[h.index]=h.registration.label!==void 0?h.registration.label:h.registration.textRef?.current?.textContent??h.element.textContent)}),y.current=n.current.length,O});function d(a){if(w.current?.disconnect(),w.current=null,typeof MutationObserver!="function"||a.length<2)return;const O=new MutationObserver(S=>{if(!fo(S))return;let H=null;for(const D of a)if(D.isConnected){if(H&&Rn(H,D)>0){O.disconnect(),m();return}H=D}});w.current=O;const h=new Set;for(let S=1;S<a.length;S+=1){const H=ao(a[S-1],a[S]);H&&h.add(H)}h.forEach(S=>O.observe(S,{childList:!0}))}const _=Y(()=>{const[a,O]=uo(c),h=C(a),S=x.current,H=!S||S.length!==a.length||a.some((D,G)=>{const $=S[G];return D.index!==$.index||D.element!==$.element||D.registration.index!==$.registration.index||D.registration.metadata!==$.registration.metadata});d(O),x.current=a,b.current=!1,H&&(f.forEach(D=>D(h)),i(h))});q(()=>(!b.current&&x.current&&C(x.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,C]),q(()=>{b.current&&_()}),q(()=>()=>{w.current?.disconnect(),b.current=!0},[]);const T=Y(a=>(f.add(a),()=>{f.delete(a)})),p=o.useMemo(()=>({register:V,unregister:v,subscribeMapChange:T,nextIndexRef:y}),[V,v,T,y]);return ae.jsx(Sn.Provider,{value:p,children:t})}function lo(){return new Map}function co(){return new Set}function uo(e){const t=new Set,n=[],r=[];e.forEach((i,l)=>{if(!l.isConnected)return;const f=i.index,c={index:f??-1,element:l,registration:i};f===null?r.push(c):f>=0&&(t.add(f),n.push(c))});let s=0;return r.sort((i,l)=>Rn(i.element,l.element)),r.forEach(i=>{for(;t.has(s);)s+=1;i.index=s,n.push(i),s+=1}),t.size>0&&n.sort((i,l)=>i.index-l.index),[n,r.map(i=>i.element)]}function ao(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function fo(e){for(const t of e)for(let n=0;n<t.removedNodes.length;n+=1)if(t.removedNodes[n].isConnected)return!0;return!1}function Rn(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const bn=o.createContext(void 0);function po(){const e=o.useContext(bn);if(!e)throw new Error(He(59));return e}function lt(e,t){e&&Object.assign(e.style,t)}const go={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},mo={position:"fixed"},Ao=o.forwardRef(function(t,n){const{anchor:r,className:s,render:i,positionMethod:l,side:f,align:c,sideOffset:y,alignOffset:b,collisionBoundary:x="clipping-ancestors",collisionPadding:w,arrowPadding:m,sticky:V,disableAnchorTracking:v,alignItemWithTrigger:C=!0,collisionAvoidance:d=jn,style:_,...T}=t,p=Le(),a=un(),O=p.useState("open"),h=p.useState("mounted"),S=p.useState("modal"),H=p.useState("value"),D=p.useState("openMethod"),G=p.useState("positionerElement"),$=p.useState("triggerElement"),R=p.useState("isItemEqualToValue"),F=p.useState("transitionStatus"),K=o.useRef(null),J=o.useRef(null),[z,M]=o.useState(C),U=h&&z&&D!=="touch";!h&&z!==C&&M(C),o.useImperativeHandle(p.context.alignItemWithTriggerActiveRef,()=>U),Cr((U||S)&&O,D==="touch",G,$);const g=ir({anchor:r,floatingRootContext:a,positionMethod:l,mounted:h,side:f,sideOffset:y,align:c,alignOffset:b,arrowPadding:m,collisionBoundary:x,collisionPadding:w,sticky:V,disableAnchorTracking:v??U,collisionAvoidance:d,keepMounted:!0}),E=U?"none":g.side,A=U?mo:g.positionerStyles,L={open:O,side:E,align:g.align,anchorHidden:g.anchorHidden};q(()=>{p.set("popupSide",g.side)},[p,g.side]);const k=p.useStateSetter("positionerElement"),X=lr(t,L,{styles:A,transitionStatus:F,props:T,refs:[n,k],hidden:!h,inert:!O}),ne=o.useRef(0),re=Y(le=>{if(p.context.valuesRef.current.length===0)return;const oe=ne.current;ne.current=le.size;const fe=pe(it);if(oe!==0&&!p.state.multiple&&H!==null&&ot(p.context.valuesRef.current,H,R)===-1){const j=p.context.initialValueRef.current,Z=j!=null&&ot(p.context.valuesRef.current,j,R)!==-1?j:null;p.context.setValue(Z,fe),Z===null&&(p.set("selectedIndex",null),p.context.selectedItemTextRef.current=null)}if(oe!==0&&p.state.multiple&&Array.isArray(H)){const B=H.filter(j=>ot(p.context.valuesRef.current,j,R)!==-1);B.length!==H.length&&(p.context.setValue(B,fe),B.length===0&&(p.set("selectedIndex",null),p.context.selectedItemTextRef.current=null))}if(O&&U){p.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const B={height:""};lt(G,B),lt(p.context.popupRef.current,B)}}),se=o.useMemo(()=>({...g,side:E,alignItemWithTriggerActive:U,setControlledAlignItemWithTrigger:M,scrollUpArrowRef:K,scrollDownArrowRef:J}),[g,E,U,M]);return ae.jsx(io,{elementsRef:p.context.listRef,labelsRef:p.context.labelsRef,onMapChange:re,children:ae.jsxs(bn.Provider,{value:se,children:[h&&S&&ae.jsx(nr,{inert:zn(!O),cutout:$}),X]})})}),et="base-ui-disable-scrollbar",Bt={className:et,getElement(e){return ae.jsx("style",{nonce:e,href:et,precedence:"base-ui:low",children:`.${et}{scrollbar-width:none}.${et}::-webkit-scrollbar{display:none}`})}},ho=o.createContext(void 0),xo={disableStyleElements:!1};function So(){return o.useContext(ho)??xo}const Wt="--transform-origin",Ro={...or,...Zt},Lo=o.forwardRef(function(t,n){const{render:r,className:s,style:i,finalFocus:l,...f}=t,c=Le(),{multiple:y,readOnly:b,highlightItemOnHover:x}=wt(),w=un(),{side:m,align:V,alignItemWithTriggerActive:v,isPositioned:C,setControlledAlignItemWithTrigger:d}=po(),_=Er()!=null,T=cr(),{nonce:p,disableStyleElements:a}=So(),O=c.useState("id"),h=c.useState("open"),S=c.useState("openMethod"),H=c.useState("mounted"),D=c.useState("popupProps"),G=c.useState("transitionStatus"),$=c.useState("triggerElement"),R=c.useState("positionerElement"),F=c.useState("listElement"),K=o.useRef(!1),J=o.useRef(!1),z=o.useRef({}),M=st(),U=Y(L=>{if(!R||!c.context.popupRef.current||!J.current)return;const k=R.style.top==="0px",X=R.style.bottom==="0px";if(K.current||!v||!k&&!X){c.context.handleScrollArrowVisibility(L);return}const ne=zt(R),re=Ye(R.getBoundingClientRect().height,"y",ne),se=Ne(R),le=rt(R),oe=le.getComputedStyle(R),fe=parseFloat(oe.marginTop),B=parseFloat(oe.marginBottom),j=jt(le.getComputedStyle(c.context.popupRef.current)),ce=Math.min(se.documentElement.clientHeight-fe-B,j),Z=L.scrollTop,ge=tt(L);let xe=null;const de=ee=>{R.style.height=`${ee}px`},ue=k?ge-Z:Z,me=Math.min(re+ue,ce);if(ue<=Ce){const ee=Ke(ue,0,ce-re);ee>0&&de(re+ee),L.scrollTop=k?ge:0,ce-(re+ee)<=Ce&&(K.current=!0),c.context.handleScrollArrowVisibility(L);return}if(ce-me>Ce)xe=k?1/0:0;else if(X&&Z<ge){const ee=re+ue-ce;xe=Z-(ue-ee)}const Se=Math.ceil(me);if(Se!==0&&de(Se),xe!=null){const ee=Ke(xe,0,tt(L));Math.abs(L.scrollTop-ee)>Ce&&(L.scrollTop=ee)}Se>=ce-Ce&&(K.current=!0),c.context.handleScrollArrowVisibility(L)});o.useImperativeHandle(c.context.scrollHandlerRef,()=>U,[U]),Et({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete(!0)}});const g={open:h,transitionStatus:G,side:m,align:V};q(()=>{!R||!c.context.popupRef.current||Object.keys(z.current).length||(z.current={top:R.style.top||"0",left:R.style.left||"0",right:R.style.right,height:R.style.height,bottom:R.style.bottom,minHeight:R.style.minHeight,maxHeight:R.style.maxHeight,marginTop:R.style.marginTop,marginBottom:R.style.marginBottom})},[c,R]),q(()=>{h||v||(J.current=!1,K.current=!1,lt(R,z.current))},[h,v,R]),q(()=>{const L=c.context.popupRef.current;if(!h||!$||!R||!L||v&&!C||c.state.transitionStatus==="ending")return;if(J.current=!0,L.style.removeProperty(Wt),!v){M.request(()=>c.context.handleScrollArrowVisibility(F||L));return}const k=bo(L);try{let X=c.context.selectedItemTextRef.current;X?.isConnected||(X=!c.select("hasSelectedValue")&&c.context.firstItemTextRef.current?.isConnected?c.context.firstItemTextRef.current:null);const ne=c.context.valueRef.current,re=rt(R),se=re.getComputedStyle(R),le=re.getComputedStyle(L),oe=Ne($),fe=zt($),B=nt($.getBoundingClientRect(),fe),j=nt(R.getBoundingClientRect(),fe),ce=B.height,Z=F||L,ge=Z.scrollHeight,xe=parseFloat(le.borderBottomWidth),de=parseFloat(se.marginTop)||10,ue=parseFloat(se.marginBottom)||10,me=parseFloat(se.minHeight)||100,Se=jt(le),ee=5,we=5,u=20,I=oe.documentElement.clientHeight-de-ue,Q=oe.documentElement.clientWidth,P=I-B.bottom+ce;let N,ve=T==="rtl"?B.right-j.width:B.left,Me=0;if(X&&ne){const he=nt(ne.getBoundingClientRect(),fe);N=nt(X.getBoundingClientRect(),fe),ve=j.left+(T==="rtl"?he.right-N.right:he.left-N.left);const ye=he.top-B.top+he.height/2;Me=N.top-j.top+N.height/2-ye}const be=P+Me+ue+xe;let Re=Math.min(I,be);const Ue=I-de-ue,Be=be-Re,We=Q-we;R.style.left=`${Ke(ve,ee,We-j.width)}px`,R.style.height=`${Re}px`,R.style.maxHeight="none",R.style.marginTop=`${de}px`,R.style.marginBottom=`${ue}px`,L.style.height="100%";const je=tt(Z),Ve=Be>=je-Ce;Ve&&(Re=Math.min(I,j.height)-(Be-je));const ze=B.top<u||B.bottom>I-u||Math.ceil(Re)+Ce<Math.min(ge,me),ft=(re.visualViewport?.scale??1)!==1&&Gt;if(ze||ft){lt(R,z.current),d(!1);return}const Pe=Math.max(me,Re);if(Ve){const he=Math.max(0,I-be);R.style.top=j.height>=Ue?"0":`${he}px`,R.style.height=`${Re}px`,Z.scrollTop=tt(Z)}else R.style.bottom="0",Z.scrollTop=Be;if(N){const he=j.top,ye=j.height,Te=N.top+N.height/2,Fe=Ke(ye>0?(Te-he)/ye*100:50,0,100);L.style.setProperty(Wt,`50% ${Fe}%`)}(Pe===I||Re>=Se)&&(K.current=!0),c.context.handleScrollArrowVisibility(Z),x&&c.state.selectedIndex===null&&c.state.activeIndex===null&&c.context.listRef.current[0]!=null&&c.set("activeIndex",0)}finally{k()}},[c,h,R,$,v,d,M,F,x,T,C]),o.useEffect(()=>{if(!v||!R||!h)return;const L=rt(R);function k(X){c.context.setOpen(!1,pe(Kn,X))}return qn(L,"resize",k)},[c,v,R,h]);const E={...F?{role:"presentation"}:{role:"listbox","aria-multiselectable":y||void 0,"aria-readonly":b||void 0,id:`${O}-list`},onKeyDown(L){_&&sr.has(L.key)&&L.stopPropagation()},onScroll(L){F||U(L.currentTarget)},...v&&{style:F?{height:"100%"}:go},className:!F&&v?Bt.className:void 0},A=_e("div",t,{ref:[n,c.context.popupRef],state:g,stateAttributesMapping:Ro,props:[D,E,fr(G),f]});return ae.jsxs(o.Fragment,{children:[!a&&Bt.getElement(p),ae.jsx(rr,{context:w,modal:!1,disabled:!H,openInteractionType:S,returnFocus:l,restoreFocus:!0,children:A})]})});function jt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function tt(e){return xn(e.scrollHeight,e.clientHeight)}function zt(e){return ur.getScale(e)}function Ye(e,t,n){return e/n[t]}function nt(e,t){return ar({x:Ye(e.x,"x",t),y:Ye(e.y,"y",t),width:Ye(e.width,"x",t),height:Ye(e.height,"y",t)})}const qt=[["transform","none"],["scale","1"],["translate","0 0"]];function bo(e){const{style:t}=e,n={};for(const[r,s]of qt)n[r]=t.getPropertyValue(r),t.setProperty(r,s,"important");return()=>{for(const[r]of qt){const s=n[r];s?t.setProperty(r,s):t.removeProperty(r)}}}function yo(e={}){const{guess:t,label:n,metadata:r,textRef:s,index:i}=e,{register:l,unregister:f,subscribeMapChange:c,nextIndexRef:y}=so(),b=o.useRef(-1),[x,w]=o.useState(i==null&&t?()=>{if(b.current===-1){const C=y.current;y.current+=1,b.current=C}return b.current}:-1),m=i??x,V=o.useRef(null),v=o.useCallback(C=>{const d=V.current;d&&f(d),V.current=C,C&&l(C,{metadata:r??null,index:i??null,label:n,textRef:s})},[i,l,f,r,n,s]);return q(()=>{if(i==null)return c(C=>{const d=V.current?C.get(V.current)?.index:null;d!=null&&w(d)})},[i,c]),{ref:v,index:m}}const yn=o.createContext(void 0);function Mt(){const e=o.useContext(yn);if(!e)throw new Error(He(57));return e}const Vo=o.memo(o.forwardRef(function(t,n){const{render:r,className:s,style:i,value:l=null,label:f,disabled:c=!1,nativeButton:y=!1,...b}=t,x=o.useRef(null),w=yo({guess:!0,label:f,textRef:x}),m=Le(),{itemProps:V,multiple:v,disabled:C,readOnly:d}=wt(),_=C||c,T=m.useState("isActive",w.index),p=m.useState("open"),a=m.useState("isSelected",l),O=m.useState("isSelectedByFocus",w.index),h=m.useState("isItemEqualToValue"),S=w.index,H=o.useRef(null);q(()=>{const g=m.context.valuesRef.current;return g[S]=l,()=>{delete g[S]}},[S,l,m]),q(()=>{const g=m.state.value,E=m.state.selectedIndex;let A=E,L;v&&Array.isArray(g)?(A=Wr(S,l,m.context.valuesRef.current,g,h,E),L=A===S,S===E&&!L&&(m.context.selectedItemTextRef.current=null)):(L=g!==void 0&&Ae(l,g,h),L&&(A=S)),m.set("selectedIndex",A),L&&x.current&&(m.context.selectedItemTextRef.current=x.current)},[S,v,h,m,l]);const D=o.useRef("mouse"),G=o.useRef(!1),{getButtonProps:$,buttonRef:R}=Jt({disabled:_,focusableWhenDisabled:!0,native:y,composite:!0}),F={disabled:_,selected:a,highlighted:T};function K(g){if(C||d)return;const E=m.state.value;if(v){const A=Array.isArray(E)?E:[],L=a?jr(A,l,h):[...A,l];m.context.setValue(L,pe(xt,g))}else m.context.setValue(l,pe(xt,g)),m.context.setOpen(!1,pe(xt,g))}function J(){m.context.selectionRef.current.dragY=0}const z={role:"option","aria-selected":a,tabIndex:p&&T?0:-1,onKeyDown(g){m.set("activeIndex",S),g.key===" "&&m.context.typingRef.current&&g.preventDefault()},onClick(g){const E=D.current!=="touch",A=g.nativeEvent.pointerType,L=E&&tn(g.nativeEvent)&&(A!==void 0||T),k=E&&!L&&!G.current;G.current=!1,!(_||k)&&K(g.nativeEvent)},onPointerEnter(g){D.current=g.pointerType},onPointerMove(g){if(g.pointerType==="mouse"&&g.buttons===1){const E=m.context.selectionRef.current;E.dragY+=g.movementY,E.dragY**2>=64&&(E.allowUnselectedMouseUp=!0)}},onPointerDown(g){D.current=g.pointerType,G.current=!0,J()},onMouseUp(){if(J(),_||D.current==="touch"||G.current)return;const g=!m.context.selectionRef.current.allowSelectedMouseUp&&a,E=!m.context.selectionRef.current.allowUnselectedMouseUp&&!a;g||E||(G.current=!0,H.current?.click(),G.current=!1)}},M=_e("div",t,{ref:[R,n,w.ref,H],state:F,props:[V,z,b,$]}),U=o.useMemo(()=>({selected:a,index:S,textRef:x,selectedByFocus:O}),[a,S,x,O]);return ae.jsx(yn.Provider,{value:U,children:M})})),Fo=o.forwardRef(function(t,n){const{selected:r}=Mt();return t.keepMounted||r?ae.jsx(Io,{...t,ref:n}):null}),Io=o.memo(o.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:i,...l}=e,{selected:f}=Mt(),c=o.useRef(null),{transitionStatus:y,setMounted:b}=nn(f),w=_e("span",e,{ref:[t,c],state:{selected:f,transitionStatus:y},props:[{"aria-hidden":!0,children:"✔️"},l],stateAttributesMapping:Zt});return Et({batch:!0,enabled:!f,open:f,ref:c,onComplete(){f||b(!1)}}),w})),Do=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:s,selectedByFocus:i}=Mt(),l=Le(),{render:f,className:c,style:y,...b}=t,x=o.useCallback(m=>{m&&(r===0&&(l.context.firstItemTextRef.current=m),i&&(l.context.selectedItemTextRef.current=m))},[l,r,i]);return _e("div",t,{ref:[x,n,s],props:b})}));export{wo as C,go as L,vo as S,wt as a,po as b,Mo as c,Po as d,Oo as e,Ao as f,Lo as g,Vo as h,Fo as i,Do as j,dr as k,br as l,Cr as m,Er as n,Fr as o,Xr as p,vt as q,an as r,Bt as s,fn as t,Le as u,Ut as v,Nr as w,on as x};
@@ -1 +0,0 @@
1
- .sessions-row-grid{display:grid;grid-template-columns:minmax(0,1fr) 44px;gap:12px;align-items:start}.sessions-row-identity{grid-column:1;grid-row:1}.sessions-row-metrics{grid-column:1 / -1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.sessions-row-action{grid-column:2;grid-row:1}.sessions-row-action:disabled{opacity:.4}.sessions-row-value{min-width:0}.sessions-row-meta{-moz-column-gap:12px;column-gap:12px}@media(max-width:767px){.sessions-row-metrics dt{font-size:11px;line-height:16px}.sessions-row-metrics dd{margin-top:0}}.sessions-row-nested .sessions-row-identity,.sessions-thread-models{padding-left:16px}.sessions-list-header{display:none}.sessions-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.sessions-toolbar-search{grid-column:1 / -1}.sessions-filter-trigger{border-radius:6px}.sessions-filter-trigger>svg:last-child{margin-left:auto}.sessions-model-filter>svg:first-of-type{display:none}.sessions-kpis>div{min-width:0}@media(min-width:640px){.sessions-kpis>div+div{border-left:1px solid rgb(229 229 229);padding-left:16px}:root.dark .sessions-kpis>div+div{border-left-color:#262626}}@media(min-width:768px){.sessions-row-grid{grid-template-columns:minmax(0,1fr) 72px 80px 96px 32px;gap:16px}.sessions-row-metrics{display:contents}.sessions-row-meta{-moz-column-gap:0;column-gap:0}.sessions-meta-item+.sessions-meta-item:before{content:"·";padding:0 6px}.sessions-row-value{text-align:right}.sessions-row-action{grid-column:5;margin-top:-6px}@media(hover:hover){.sessions-row .sessions-row-action:not(:focus-visible){opacity:0}.sessions-row:hover .sessions-row-action:not(:disabled){opacity:1}.sessions-row:hover .sessions-row-action:disabled{opacity:.4}}.sessions-row-nested .sessions-row-identity,.sessions-thread-models{padding-left:30px}.sessions-list-header{display:grid}}@media(min-width:1024px){.sessions-toolbar{grid-template-columns:minmax(0,1fr) repeat(4,minmax(0,168px))}.sessions-toolbar-search{grid-column:auto}}
@@ -1,3 +0,0 @@
1
- import{A as Te,r as n,j as e,J as B,c as s,aa as Le,X as Fe,i as _,ax as fe,a7 as ke,R as cs,a6 as pe,b9 as ds,aV as Z}from"./__vite-browser-external-DUJeOWgd.js";import{L as us,I as ms}from"./LocalOnlyNotice-BaEq6qN7.js";import{S as ne}from"./Select-CtTceC4T.js";import{C as xs}from"./SelectItemText-C7xi8iGp.js";import{S as Re}from"./search-Ol3OZBm4.js";import{C as gs}from"./check-CKwHc4Hv.js";import{P as Oe,a as Ee,b as Ie,c as $e,d as Pe}from"./PopoverPopup-CVTiEVHs.js";import{P as Ae}from"./ProviderIcon-BshO2uER.js";import{H as hs}from"./HoverTooltip-BzP5FudR.js";import{u as ye}from"./useCurrency-pwClnCZ5.js";import{i as ps,C as bs}from"./host-mode-efKlSYjX.js";import{I as fs}from"./info-CyDY7NYM.js";import{L as ys}from"./loader-circle-CNT630zn.js";import"./arrow-up-right-jPmRN562.js";import"./download-CJUnX1Bs.js";import"./composite-B4Z3F65o.js";import"./usePositioner-B0j1orGj.js";import"./store-C9yWYHfg.js";import"./safePolygon-CKpREa4K.js";const qe={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]};qe.node;const _s=Te(qe);const Ke={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};Ke.node;const ks=Te(Ke),js="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function je({options:a,value:t,onChange:r,allValue:o="all",allLabel:d,searchPlaceholder:g,emptyLabel:m,ariaLabel:f,disabled:y=!1,className:j=""}){const[v,w]=n.useState(!1),[N,b]=n.useState(""),[k,p]=n.useState(-1),L=n.useRef(null),C=`${n.useId()}-listbox`,P=t===o?d:a.find(u=>u.value===t)?.label??t,M=N.trim().toLowerCase(),T=n.useMemo(()=>M?a.filter(u=>u.label.toLowerCase().includes(M)):a,[a,M]),S=n.useMemo(()=>[{value:o,label:d},...T],[o,d,T]),O=k>=0&&k<S.length?S[k]:null,A=u=>{r(u),w(!1),b(""),p(-1)};n.useEffect(()=>{v&&L.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[v,k]);const J=u=>{if(u.key==="ArrowDown"||u.key==="ArrowUp"){u.preventDefault();const D=u.key==="ArrowDown";p(R=>{const l=S.length;return l?D?R>=l-1?0:R+1:R<=0?l-1:R-1:-1});return}if(u.key==="Enter"){const D=O||(M&&T.length?T[0]:null);if(!D)return;u.preventDefault(),A(D.value)}};return e.jsxs(Oe,{open:v,onOpenChange:u=>{w(u),p(-1),u||b("")},children:[e.jsxs(Ee,{disabled:y,"aria-label":f,className:B("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==o?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",j),children:[e.jsx(ks,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:P}),e.jsx(xs,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(Ie,{children:e.jsx($e,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(Pe,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx(Re,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":O?`${C}-${k}`:void 0,value:N,onChange:u=>{b(u.target.value),p(-1)},onKeyDown:J,placeholder:g,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:L,id:C,role:"listbox","aria-label":f,className:"max-h-64 overflow-y-auto",children:[S.map((u,D)=>e.jsxs("button",{id:`${C}-${D}`,type:"button",role:"option","aria-selected":t===u.value,"data-active":D===k?"true":void 0,onMouseEnter:()=>p(D),onClick:()=>A(u.value),className:B(js,t===u.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",D===k&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:u.label}),t===u.value?e.jsx(gs,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},u.value)),T.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:m}):null]})]})})})]})}const vs="tokentracker-sessions";async function ws(a={}){const t=new URL(`/functions/${vs}`,window.location.origin);a.from&&t.searchParams.set("from",a.from),a.to&&t.searchParams.set("to",a.to),a.limit&&t.searchParams.set("limit",String(a.limit)),a.refresh&&t.searchParams.set("refresh","1");const r=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),o=await r.json().catch(()=>null);if(!r.ok){const d=r.status===404?s("sessions.error.outdated_app"):`Request failed with HTTP ${r.status}`,g=new Error(o?.error||d);throw g.status=r.status,g}return o}function Ue(a,t,{timeOnly:r=!1}={}){if(!a)return"—";const o=Date.parse(a);if(!Number.isFinite(o))return"—";const d=r?{hour:"2-digit",minute:"2-digit"}:{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};try{return new Date(o).toLocaleString(t||void 0,d)}catch{const g=new Date(o).toISOString();return r?g.slice(11,16):g.slice(0,16).replace("T"," ")}}function ze(a){const t=Number(a);if(!Number.isFinite(t)||t<=0)return null;const r=Math.round(t/6e4);if(r<60)return s("sessions.duration.minutes",{minutes:r});const o=Math.floor(r/60),d=r%60;return s("sessions.duration.hours",{hours:o,minutes:d})}function te(a){return W(a?.own_total_tokens??a?.total_tokens)}function ae(a){return W(a?.own_cost_usd??a?.cost_usd)}function W(a){const t=Number(a);return Number.isFinite(t)&&t>=0?t:0}function H(a){const t=Array.isArray(a?.model_usage)?a.model_usage.filter(r=>r&&typeof r.model=="string"&&r.model):[];return t.length?t:[{model:a?.model||"",total_tokens:te(a),cost_usd:ae(a),performance:a?.performance}]}function Ns(a){const t={estimated_output_tokens:0,estimated_duration_ms:0,estimated_request_count:0,estimated_tokens_per_second:null,first_response_total_ms:0,first_response_sample_count:0,first_response_ms:null};for(const r of a){const o=r?.performance;if(!o)continue;const d=W(o.estimated_duration_ms),g=W(o.estimated_output_tokens),m=W(o.estimated_request_count);d>0&&g>0&&m>0&&(t.estimated_output_tokens+=g,t.estimated_duration_ms+=d,t.estimated_request_count+=m);const f=W(o.first_response_sample_count),y=W(o.first_response_total_ms);f>0&&y>0&&(t.first_response_total_ms+=y,t.first_response_sample_count+=f)}return t.estimated_duration_ms>0&&(t.estimated_tokens_per_second=t.estimated_output_tokens*1e3/t.estimated_duration_ms),t.first_response_sample_count>0&&(t.first_response_ms=t.first_response_total_ms/t.first_response_sample_count),t}function Ge(a){const t=new Set,r=a.filter(o=>t.has(o.session_hash)?!1:(t.add(o.session_hash),!0));return{count:r.length,tokens:r.reduce((o,d)=>o+te(d),0),cost:r.reduce((o,d)=>o+ae(d),0),costIsPartial:r.some(o=>o.cost_is_partial),performance:Ns(r)}}function be(a){const t=Date.parse(a?.ended_at||a?.started_at||"");return Number.isFinite(t)?t:0}function Ss(a,t){return[...a].sort((r,o)=>(t==="cost"?ae(o)-ae(r):t==="tokens"?te(o)-te(r):0)||be(o)-be(r))}function le(a){const t=be(a);if(!t)return"";const r=new Date(t);return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function Cs(a,t){const r=new Map;for(const o of a){const d=t==="project"?o.project_key||"":le(o),g=r.get(d)||{key:d,sessions:[]};g.sessions.push(o),r.set(d,g)}return[...r.values()]}function Ms(a){const t=new URLSearchParams(a),r=t.get("source"),o=m=>{const f=t.get(m)||"";if(!/^\d{4}-\d{2}-\d{2}$/.test(f))return"";const y=new Date(`${f}T00:00:00`);return Number.isFinite(y.getTime())&&le({ended_at:y.toISOString()})===f?f:""},d=o("from"),g=o("to");return{source:["claude","codex","grok"].includes(r)?r:"all",model:t.get("model")||"all",from:d,to:g}}function Ds(a,t,r){let o=t?new Date(`${t}T00:00:00`).getTime():0,d=r?new Date(`${r}T23:59:59.999`).getTime():1/0;o>d&&(o=new Date(`${r}T00:00:00`).getTime(),d=new Date(`${t}T23:59:59.999`).getTime());const g=Date.parse(a.ended_at||a.started_at||""),m=Date.parse(a.started_at||a.ended_at||"");return(!Number.isFinite(g)||g>=o)&&(!Number.isFinite(m)||m<=d)}function se({performance:a,className:t=""}){const r=Number(a?.estimated_tokens_per_second),o=Number(a?.estimated_request_count||0);return!Number.isFinite(r)||r<=0||o<=0?null:e.jsx("span",{className:t,title:`${s("sessions.performance.samples",{count:o})}
2
- ${s("sessions.performance.method")}`,children:s("sessions.performance.speed",{speed:Number(r.toFixed(1))})})}const Ts=[{key:"input_tokens",label:()=>s("dashboard.projects.detail.comp_input")},{key:"cached_input_tokens",label:()=>s("dashboard.projects.detail.comp_cached")},{key:"cache_creation_input_tokens",label:()=>s("dashboard.projects.detail.comp_cache_write")},{key:"output_tokens",label:()=>s("dashboard.projects.detail.comp_output")},{key:"reasoning_output_tokens",label:()=>s("dashboard.projects.detail.comp_reasoning")}],Ls=[{key:"turns",label:()=>s("sessions.col.turns")},{key:"edit_turns",label:()=>s("sessions.col.edits")},{key:"retry_turns",label:()=>s("sessions.detail.retries")},{key:"subagent_calls",label:()=>s("sessions.card.subagents")},{key:"tool_calls",grokOnly:!0,label:()=>s("sessions.detail.tools")},{key:"tool_failures",grokOnly:!0,label:()=>s("sessions.detail.tool_failures")},{key:"error_count",grokOnly:!0,label:()=>s("sessions.detail.errors")},{key:"model_calls",grokOnly:!0,label:()=>s("sessions.detail.model_calls")},{key:"compaction_count",grokOnly:!0,label:()=>s("sessions.detail.compactions")}];function Fs(a){return a==="provider_reported"?s("sessions.detail.cost_reported"):a==="model_pricing"?s("sessions.detail.cost_estimated"):a==="mixed"?s("sessions.detail.cost_mixed"):s("sessions.detail.cost_unknown")}function ve(a){return String(a||"").startsWith("litellm")?s("sessions.detail.pricing_litellm"):String(a||"").startsWith("curated")?s("sessions.detail.pricing_curated"):null}function Rs(a,t){return t||Number(a)>0}function we({label:a,children:t}){return e.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:a}),e.jsx("dd",{className:"min-w-0 break-words text-right text-sm tabular-nums text-oai-black dark:text-white",children:t})]})}function ie({label:a,title:t,className:r="",children:o}){return e.jsxs("div",{className:`min-w-0 border-oai-gray-200 px-3 py-2.5 dark:border-oai-gray-800 ${r}`,title:t,children:[e.jsx("dt",{className:"truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"mt-0.5 truncate text-base font-medium tabular-nums text-oai-black dark:text-white",children:o})]})}function Os({session:a,subagents:t=[],onClose:r}){const o=n.useRef(null),d=n.useRef(null),{currency:g,rate:m}=ye(),{resolvedLocale:f}=Le(),y=l=>fe(l,{currency:g,rate:m}),j=H(a),v=n.useMemo(()=>Ge(t),[t]),w=te(a),N=ae(a),b=Number(a.subagent_total_tokens??v.tokens),k=Number(a.subagent_cost_usd??v.cost),p=a.performance,L=Number(p?.estimated_tokens_per_second)>0&&Number(p?.estimated_request_count)>0,C=Number(p?.first_response_sample_count)>0&&p?.first_response_ms!=null&&Number.isFinite(Number(p.first_response_ms)),P=C?{seconds:(Number(p.first_response_ms)/1e3).toFixed(2),count:p.first_response_sample_count}:null,M=Number(a.reasoning_output_tokens)>0,T=a.source==="grok",S=T&&Number(a.context_window_tokens)>0;n.useEffect(()=>{const l=document.activeElement,E=document.body.style.overflow;document.body.style.overflow="hidden",o.current?.focus();const I=F=>{if(F.key==="Escape"&&(F.preventDefault(),r()),F.key!=="Tab")return;const K=Array.from(d.current?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), summary, [tabindex="0"]')||[]),X=K[0],Y=K[K.length-1];X?F.shiftKey&&(document.activeElement===X||!d.current?.contains(document.activeElement))?(F.preventDefault(),Y.focus()):!F.shiftKey&&(document.activeElement===Y||!d.current?.contains(document.activeElement))&&(F.preventDefault(),X.focus()):(F.preventDefault(),d.current?.focus())};return window.addEventListener("keydown",I),()=>{window.removeEventListener("keydown",I),document.body.style.overflow=E,l instanceof HTMLElement&&l.isConnected&&l.focus()}},[r]);const O=b>0||k>0,A=a.cost_is_partial||O&&v.costIsPartial,J=[{label:s("sessions.detail.own"),tokens:w,cost:N,partial:a.cost_is_partial},{label:s("sessions.detail.subagents"),tokens:b,cost:k,partial:v.costIsPartial}],u=a.agent_nickname||a.title||a.project_key||s("sessions.project.unknown"),D=ze(a.duration_ms),R=[a.project_key&&a.project_key!==u?a.project_key:null,Ue(a.started_at,f),D].filter(Boolean);return e.jsx("div",{className:"fixed inset-0 z-50 flex justify-end bg-black/20 dark:bg-black/40",onClick:l=>{l.target===l.currentTarget&&r()},children:e.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-label":s("sessions.detail.title"),tabIndex:-1,className:"flex h-full w-full max-w-[36rem] flex-col border-l border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex shrink-0 items-start gap-3 border-b border-oai-gray-200 px-5 py-4 dark:border-oai-gray-800",children:[e.jsx("span",{className:"shrink-0 pt-0.5 text-oai-gray-600 dark:text-oai-gray-300",children:e.jsx(Ae,{provider:String(a.source||"").toUpperCase(),size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"break-words text-base font-semibold leading-6 text-oai-black dark:text-white",children:u}),e.jsx("p",{className:"mt-0.5 break-words text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:R.join(" · ")})]}),e.jsx("button",{ref:o,type:"button",onClick:r,"aria-label":s("sessions.detail.close"),className:"-mr-2 -mt-1 flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white sm:h-9 sm:w-9",children:e.jsx(Fe,{size:18,"aria-hidden":!0})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-5",children:[e.jsxs("section",{"aria-label":s("sessions.detail.consumption"),children:[e.jsxs("dl",{className:"grid grid-cols-2 overflow-hidden rounded-lg border border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx(ie,{label:s("sessions.col.tokens"),children:_(w+b)}),e.jsxs(ie,{label:s("sessions.col.cost"),className:"border-l",children:[A?"≥":"",y(N+k)]}),e.jsx(ie,{label:s("sessions.summary.speed"),className:"border-t",title:L?s("sessions.performance.samples",{count:p.estimated_request_count}):s("sessions.detail.no_speed"),children:L?e.jsx(se,{performance:p}):"—"}),e.jsx(ie,{label:s("sessions.performance.first_response"),className:"border-l border-t",title:s("sessions.performance.first_response_method"),children:C?Number(p.first_response_sample_count)===1?s("sessions.performance.first_response_value_single",P):s("sessions.performance.first_response_value",P):"—"})]}),O?e.jsx("dl",{className:"mt-3 space-y-1.5",children:J.map(l=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"text-oai-gray-600 dark:text-oai-gray-300",children:l.label}),e.jsx("dd",{className:"text-right tabular-nums",children:_(l.tokens)}),e.jsxs("dd",{className:"text-right tabular-nums",children:[l.partial?"≥":"",y(l.cost)]})]},l.label))}):null,e.jsxs("p",{className:"mt-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:[s("sessions.detail.cost_source")," · ",Fs(a.cost_source),a.cost_is_partial?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",s("sessions.cost.partial_title")]}):null,a.usage_is_incomplete?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",s("sessions.badge.partial_usage")]}):null]})]}),e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-white",children:s("sessions.detail.tokens")}),e.jsx("dl",{className:"mt-2 grid grid-cols-1 gap-x-8 gap-y-1.5 sm:grid-cols-2",children:Ts.map(({key:l,label:E})=>e.jsx(we,{label:E(),children:a[l]==null?"—":_(a[l])},l))})]}),e.jsxs("section",{className:"mt-6",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-white",children:s("sessions.detail.models")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:s("sessions.col.tokens")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:s("sessions.col.cost")})]}),e.jsx("ul",{className:"mt-1 divide-y divide-oai-gray-100 dark:divide-oai-gray-800/70",children:j.map(l=>{const E=l.pricing?.status==="unpriced",I=a.cost_source==="provider_reported"&&j.length===1,F=I?N:l.cost_usd,K=Rs(F,I);return e.jsxs("li",{className:"py-2.5",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 break-words text-oai-black dark:text-white",children:l.model||s("sessions.model.unknown")}),e.jsx("span",{className:"text-right tabular-nums",children:_(l.total_tokens)}),e.jsx("span",{className:"text-right tabular-nums",children:E&&!K?"—":y(F)})]}),l.pricing?e.jsxs("details",{className:"group text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsxs("summary",{className:"flex min-h-10 cursor-pointer list-none items-center gap-2 rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 sm:min-h-0 sm:pt-1 [&::-webkit-details-marker]:hidden",children:[e.jsx(se,{performance:l.performance,className:"tabular-nums"}),e.jsx("span",{className:"underline decoration-dotted underline-offset-4 group-open:no-underline",children:s("sessions.detail.pricing_details")})]}),e.jsxs("div",{className:"space-y-1 pt-1.5 leading-5",children:[E?e.jsx("p",{children:s("sessions.detail.pricing_unpriced")}):null,l.pricing.status==="free"?e.jsx("p",{children:s("sessions.detail.pricing_free")}):null,l.pricing.status==="priced"?e.jsx("p",{children:s("sessions.detail.pricing_rates",{input:l.pricing.input,output:l.pricing.output,cacheRead:l.pricing.cache_read,cacheWrite:l.pricing.cache_write})}):null,ve(l.pricing.source)?e.jsx("p",{children:ve(l.pricing.source)}):null]})]}):e.jsx(se,{performance:l.performance,className:"block pt-1 text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400"})]},l.model)})})]}),e.jsxs("details",{className:"mt-5 border-t border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer items-center rounded text-sm font-medium text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white",children:s("sessions.detail.signals")}),e.jsx("dl",{className:"grid grid-cols-1 gap-x-8 gap-y-1.5 pb-4 sm:grid-cols-2",children:Ls.map(({key:l,label:E,grokOnly:I})=>e.jsx(we,{label:E(),children:typeof a[l]=="number"&&(!I||T)?_(a[l]):s("sessions.detail.not_recorded")},l))}),T&&a.usage_precision?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.grok.runtime_breakdown",{calls:_(a.model_calls),seconds:(Number(a.api_duration_ms||0)/1e3).toFixed(1),tools:_(a.tool_calls),errors:_(a.error_count)})}):null,S?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.grok.context_breakdown",{used:_(a.context_tokens_used),window:_(a.context_window_tokens),percent:Number(a.context_usage_percent||0).toFixed(0)})}):null]}),e.jsxs("details",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer items-center rounded text-sm font-medium text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white",children:s("sessions.detail.identifiers")}),e.jsxs("dl",{className:"space-y-3 pb-4",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.detail.session_id")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.session_id||a.session_hash})]}),a.project_ref?e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.detail.local_path")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.project_ref})]}):null,a.resume_command?e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.detail.resume_command")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.resume_command})]}):null]})]}),e.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-oai-gray-200 pt-4 text-xs leading-5 text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[L?e.jsx("p",{children:s("sessions.performance.method")}):null,M?e.jsx("p",{children:s("sessions.detail.reasoning_note")}):null,e.jsx("p",{children:s("sessions.privacy")})]})]})]})})}const Ne=ps(),Se=[],he=100,Es=[{id:"all",label:()=>s("usage.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],Ve=[{id:"all",days:0,label:()=>s("sessions.filter.range_label_all")},{id:"7d",days:7,label:()=>s("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>s("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>s("sessions.filter.range_90d")}];function Is(a){const t=Ve.find(o=>o.id===a)?.days||0;if(!t)return 0;const r=new Date;return r.setDate(r.getDate()-(t-1)),r.setHours(0,0,0,0),r.getTime()}function $s(a,t){if(!t)return!0;const r=Date.parse(a.ended_at||a.started_at||"");return Number.isFinite(r)?r>=t:!0}function Ps(a){const t=Date.parse(a.started_at||"");return!Number.isFinite(t)||le({started_at:a.started_at})===le(a)}function Ce(a){const t=H(a);return t.length===1?t[0].model||s("sessions.model.unknown"):t.map(r=>`${r.model} ${_(Number(r.total_tokens||0))}`).join(" · ")}async function Me(a){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(a),!0;const t=document.createElement("textarea");t.value=a,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const r=document.execCommand("copy");return document.body.removeChild(t),r}const De=pe.memo(function({session:t,locale:r,nested:o=!1,timeOnly:d=!1,childCount:g=0,expanded:m=!1,onToggle:f,onDetail:y}){const{currency:j,rate:v}=ye(),w=String(t.source||"").toUpperCase(),N=ze(t.duration_ms),b=t.resume_command,k=t.project_key||s("sessions.project.unknown"),p=o||t.thread_kind==="subagent",L=p?t.agent_nickname||t.agent_role||t.title||k:t.title||k,C=t.usage_is_incomplete?s("sessions.badge.partial_usage"):t.cost_is_partial?s("sessions.badge.partial_cost"):null,P=t.project_ref?`${t.project_ref}
3
- ${s("sessions.project.copy_hint")}`:void 0,M=async()=>{if(t.project_ref)try{await Me(t.project_ref)?Z({title:s("sessions.project.copied")}):Z({title:s("sessions.project.copy_failed")})}catch{Z({title:s("sessions.project.copy_failed")})}},T=O=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(hs,{text:P,placement:"bottom"}),e.jsx("button",{type:"button",onClick:M,"aria-label":s("sessions.project.copy_aria",{project:k}),className:B("max-w-full truncate rounded text-left underline decoration-dotted decoration-oai-gray-300 underline-offset-4 hover:decoration-oai-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:decoration-oai-gray-600 dark:hover:decoration-oai-gray-400",O),children:k})]}),S=async()=>{if(b)try{await Me(b)?Z({title:s("sessions.resume.copied")}):Z({title:s("sessions.resume.copy_failed")})}catch{Z({title:s("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:B("sessions-row sessions-row-grid py-3",o&&"sessions-row-nested"),children:[e.jsxs("div",{className:"sessions-row-identity flex min-w-0 items-start gap-3",children:[e.jsx("span",{className:"shrink-0 pt-2 text-oai-gray-600 dark:text-oai-gray-300 md:pt-0.5",children:e.jsx(Ae,{provider:w,size:o?16:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>y(t),"aria-label":s("sessions.detail.open_aria",{title:L}),title:L,className:"min-h-9 max-w-full truncate rounded text-left text-sm font-medium text-oai-black underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white md:min-h-0",children:L}),e.jsxs("div",{className:"sessions-row-meta mt-0.5 flex min-w-0 flex-wrap items-center gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{className:"sessions-meta-item min-w-0 max-w-full",children:t.project_ref?T("min-h-6 inline-flex items-center md:min-h-0"):e.jsx("span",{className:"truncate",children:k})}),e.jsx("span",{className:"sessions-meta-item min-w-0 max-w-full truncate",title:Ce(t),children:Ce(t)}),e.jsx("span",{className:"sessions-meta-item tabular-nums",children:Ue(t.started_at,r,{timeOnly:d&&Ps(t)})}),N?e.jsx("span",{className:"sessions-meta-item tabular-nums",children:N}):null,p?e.jsxs("span",{className:"sessions-meta-item",children:[s("sessions.badge.subagent"),t.agent_role?` · ${t.agent_role}`:""]}):null,t.first_pass?e.jsx("span",{className:"sessions-meta-item text-emerald-700 dark:text-emerald-300",children:s("sessions.badge.first_pass")}):null,C?e.jsx("span",{className:"sessions-meta-item text-amber-700 dark:text-amber-300",children:C}):null,t.cost_source==="provider_reported"?e.jsx("span",{className:"sessions-meta-item",children:s("sessions.badge.reported_cost")}):null,g?e.jsxs("button",{type:"button",onClick:()=>f(t.session_hash),"aria-expanded":m,className:"-mx-1.5 inline-flex min-h-8 items-center md:-my-1 md:ml-2 md:mr-0 gap-0.5 rounded px-1.5 font-medium text-oai-gray-700 hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white md:min-h-6",children:[e.jsx(ds,{className:B("h-3.5 w-3.5 transition-transform",m&&"rotate-90"),"aria-hidden":!0}),m?s("sessions.thread.collapse",{count:g}):s("sessions.thread.expand",{count:g})]}):null]})]})]}),e.jsxs("dl",{className:"sessions-row-metrics",children:[e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:s("sessions.col.tokens")}),e.jsxs("dd",{title:Number(t.subagent_total_tokens)?s("sessions.thread.tokens_summary",{own:_(t.own_total_tokens),subagents:_(t.subagent_total_tokens),combined:_(t.combined_total_tokens)}):void 0,className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",children:[_(t.total_tokens),Number(t.subagent_total_tokens)?e.jsxs("span",{className:"mt-0.5 block text-xs text-oai-gray-500 dark:text-oai-gray-400",children:["Σ ",_(t.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:s("sessions.col.cost")}),e.jsxs("dd",{className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",title:t.cost_is_partial?s("sessions.cost.partial_title"):void 0,children:[t.cost_is_partial?"≥":"",fe(t.cost_usd,{currency:j,rate:v})]})]}),e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:s("sessions.col.speed")}),e.jsx("dd",{className:"mt-1 min-h-5 text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 md:mt-0",children:e.jsx(se,{performance:t.performance})})]})]}),e.jsx("button",{type:"button",onClick:S,disabled:!b,title:b||s("sessions.resume.unavailable"),"aria-label":b?s("sessions.resume.copy_aria",{command:b}):s("sessions.resume.unavailable"),className:"sessions-row-action inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 transition hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:cursor-not-allowed dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white md:h-8 md:w-8",children:e.jsx(bs,{className:"h-4 w-4","aria-hidden":!0})})]})});function As({sessions:a,selectedModel:t,onSelect:r}){const{groups:o,totalTokens:d}=n.useMemo(()=>{const m=new Map;let f=0;for(const y of a)for(const j of H(y)){const v=j.model||s("sessions.model.unknown"),w=Number(j.total_tokens||0),N=m.get(v)||{model:v,count:0,tokens:0};N.count+=1,N.tokens+=w,f+=w,m.set(v,N)}return{groups:[...m.values()].sort((y,j)=>j.tokens-y.tokens),totalTokens:f}},[a]);function g(m){return B("min-h-10 rounded-md border px-2.5 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 md:min-h-7",m?"border-oai-brand-500 bg-oai-brand-50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-300":"border-oai-gray-200 text-oai-gray-600 hover:bg-oai-gray-100 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800")}return e.jsx("li",{className:"sessions-thread-models py-2.5",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"mr-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":t==="all",onClick:()=>r("all"),className:g(t==="all"),children:s("sessions.thread.model_all",{count:a.length,tokens:_(d)})}),o.map(m=>e.jsx("button",{type:"button","aria-pressed":t===m.model,onClick:()=>r(m.model),className:g(t===m.model),children:s("sessions.thread.model_item",{model:m.model,count:m.count,tokens:_(m.tokens)})},m.model))]})})}function ot(){const[a]=n.useState(()=>Ms(window.location.search)),[t,r]=n.useState(null),[o,d]=n.useState(null),[g,m]=n.useState(!0),[f,y]=n.useState(!1),[j,v]=n.useState(a.source),[w,N]=n.useState(a.model),[b,k]=n.useState(a.from||a.to?"custom":"all"),[p,L]=n.useState(a.from),[C,P]=n.useState(a.to),[M,T]=n.useState("all"),[S,O]=n.useState("time"),[A,J]=n.useState("recent"),[u,D]=n.useState(null),[R,l]=n.useState(""),[E,I]=n.useState(he),[F,K]=n.useState(()=>new Set),[X,Y]=n.useState(()=>new Map),re=n.useRef(0),{resolvedLocale:G}=Le(),{currency:We,rate:He}=ye(),oe=n.useCallback(async(i=!1)=>{const x=++re.current;i?y(!0):m(!0),d(null);try{const c=await ws({refresh:i});x===re.current&&r(c)}catch(c){x===re.current&&d(c?.message||String(c))}finally{x===re.current&&(m(!1),y(!1))}},[]);n.useEffect(()=>{Ne||ke()?oe(!1):m(!1)},[oe]);const $=t?.sessions||Se,Be=n.useMemo(()=>{const i=new Set,x=[];for(const c of $){const h=c.project_key;!h||i.has(h)||(i.add(h),x.push({value:h,label:h}))}return x.sort((c,h)=>c.label.localeCompare(h.label))},[$]),Qe=n.useMemo(()=>{const i=new Set;for(const x of $)for(const c of H(x))c.model&&i.add(c.model);return[...i].sort().map(x=>({value:x,label:x}))},[$]),ce=n.useDeferredValue(R),U=n.useMemo(()=>{const i=ce.trim().toLowerCase(),x=Is(b);return $.filter(c=>{if(j!=="all"&&c.source!==j||M!=="all"&&c.project_key!==M||w!=="all"&&!H(c).some(z=>z.model===w))return!1;if(b==="custom"){if(!Ds(c,p,C))return!1}else if(!$s(c,x))return!1;if(!i)return!0;const h=H(c).map(z=>z.model).join(" ");return`${c.title||""} ${c.project_key||""} ${h} ${c.agent_nickname||""} ${c.agent_role||""} ${c.project_ref||""} ${c.session_id||""}`.toLowerCase().includes(i)})},[$,j,M,w,b,p,C,ce]),Q=n.useMemo(()=>Ge(U),[U]),V=n.useMemo(()=>{const i=new Set(U.map(h=>h.session_hash)),x=new Map,c=[];for(const h of Ss(U,A)){const q=h.root_session_hash||h.parent_session_hash;if(h.parent_session_hash&&q&&i.has(q)){const z=x.get(q)||[];z.push(h),x.set(q,z)}else c.push(h)}return{roots:c,childrenByRoot:x,foldedCount:U.length-c.length}},[U,A]),de=j!=="all"||w!=="all"||b!=="all"||M!=="all"||R.trim()!=="";n.useEffect(()=>{I(he),K(new Set),Y(new Map)},[j,M,w,b,p,C,ce,A,S,$]);const ue=n.useMemo(()=>V.roots.slice(0,E),[V.roots,E]),Ze=n.useMemo(()=>Cs(ue,S),[ue,S]),Je=n.useMemo(()=>u?$.filter(i=>i.session_hash!==u.session_hash&&(i.root_session_hash===u.session_hash||i.parent_session_hash===u.session_hash)):Se,[$,u]),Xe=n.useCallback(()=>D(null),[]),me=n.useCallback(i=>{k(i),i!=="custom"&&(L(""),P(""))},[]),Ye=n.useCallback(()=>{v("all"),N("all"),T("all"),l(""),me("all")},[me]),xe=V.roots.length>ue.length,ge=n.useCallback(()=>I(i=>i+he),[]),es=n.useCallback(i=>{K(x=>{const c=new Set(x);return c.has(i)?c.delete(i):c.add(i),c})},[]),ss=n.useCallback((i,x)=>{Y(c=>{const h=new Map(c);return x==="all"?h.delete(i):h.set(i,x),h})},[]),_e=n.useRef(null);n.useEffect(()=>{if(!xe||typeof IntersectionObserver>"u")return;const i=_e.current;if(!i)return;const x=new IntersectionObserver(c=>{c.some(h=>h.isIntersecting)&&ge()},{rootMargin:"400px"});return x.observe(i),()=>x.disconnect()},[xe,ge]);const ts=n.useMemo(()=>Es.map(i=>({value:i.id,label:i.label()})),[G]),as=n.useMemo(()=>[...Ve.map(i=>({value:i.id,label:i.label()})),{value:"custom",label:s("sessions.filter.range_custom")}],[G]),rs=n.useMemo(()=>[{value:"time",label:s("sessions.group.time")},{value:"project",label:s("sessions.group.project")}],[G]),os=n.useMemo(()=>[{value:"recent",label:s("sessions.sort.recent")},{value:"cost",label:s("sessions.sort.cost")},{value:"tokens",label:s("sessions.sort.tokens")}],[G]),ns=Number(t?.session_count)>Number(t?.returned_count);return!Ne&&!ke()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(us,{})}):e.jsxs("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-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"mb-3 text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:s("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:s("sessions.page.summary")})]}),e.jsx("button",{type:"button",onClick:()=>{oe(!0)},disabled:f||g,"aria-label":s("sessions.page.refresh"),title:s("sessions.page.refresh"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(cs,{className:B("h-4 w-4",f&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-6 space-y-3",children:[e.jsxs("div",{className:"sessions-toolbar",children:[e.jsxs("div",{className:"sessions-toolbar-search relative",children:[e.jsx(Re,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),e.jsx(ms,{type:"search",value:R,onChange:i=>l(i.target.value),onKeyDown:i=>{i.key==="Escape"&&R&&(i.preventDefault(),l(""))},"aria-label":s("sessions.action.search_aria"),placeholder:s("sessions.search.placeholder"),className:"h-11 pl-10 pr-12 text-sm !bg-white dark:!bg-oai-gray-900 !border-oai-gray-200 placeholder:!text-oai-gray-500 dark:!border-oai-gray-800 dark:placeholder:!text-oai-gray-400 sm:h-9 [&::-webkit-search-cancel-button]:appearance-none"}),R?e.jsx("button",{type:"button",onMouseDown:i=>i.preventDefault(),onClick:()=>l(""),"aria-label":s("sessions.action.search_clear"),className:"absolute right-0 top-0 flex h-11 w-11 items-center justify-center rounded-md text-oai-gray-600 hover:bg-oai-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 sm:h-9 sm:w-9",children:e.jsx(Fe,{className:"h-4 w-4","aria-hidden":!0})}):null]}),e.jsx(ne,{ariaLabel:s("sessions.filter.source_aria"),options:ts,value:j,onValueChange:v,className:"sessions-filter-trigger h-11 min-w-0 px-3 text-sm sm:h-9",matchTriggerWidth:!0}),e.jsx(ne,{ariaLabel:s("sessions.filter.range_aria"),options:as,value:b,onValueChange:me,leadingIcon:e.jsx(_s,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),className:"sessions-filter-trigger h-11 min-w-0 px-3 text-sm sm:h-9",matchTriggerWidth:!0}),e.jsx(je,{options:Be,value:M,onChange:T,allLabel:s("sessions.filter.project_all"),searchPlaceholder:s("sessions.filter.project_search"),emptyLabel:s("sessions.filter.project_empty"),ariaLabel:s("sessions.filter.project_aria"),className:"sessions-filter-trigger !h-11 !w-full !max-w-none !px-3 !text-sm !font-normal sm:!h-9 !bg-white !text-oai-black dark:!bg-oai-gray-900 dark:!text-white [&>svg]:!text-oai-gray-500 dark:[&>svg]:!text-oai-gray-400"}),e.jsx(je,{options:Qe,value:w,onChange:N,allLabel:s("sessions.filter.model_all"),searchPlaceholder:s("sessions.filter.model_search"),emptyLabel:s("sessions.filter.model_empty"),ariaLabel:s("sessions.filter.model_aria"),className:"sessions-filter-trigger sessions-model-filter !h-11 !w-full !max-w-none !px-3 !text-sm !font-normal sm:!h-9 !bg-white !text-oai-black dark:!bg-oai-gray-900 dark:!text-white [&>svg]:!text-oai-gray-500 dark:[&>svg]:!text-oai-gray-400"})]}),b==="custom"?e.jsxs("div",{className:"grid max-w-lg grid-cols-2 gap-3",children:[e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"mb-1 block",children:s("sessions.filter.from")}),e.jsx("input",{type:"date","aria-label":s("sessions.filter.from"),value:p,onChange:i=>L(i.target.value),className:"h-11 w-full min-w-0 rounded-md border border-oai-gray-200 bg-white px-3 text-sm outline-none focus:ring-2 focus:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:h-10"})]}),e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"mb-1 block",children:s("sessions.filter.to")}),e.jsx("input",{type:"date","aria-label":s("sessions.filter.to"),value:C,onChange:i=>P(i.target.value),className:"h-11 w-full min-w-0 rounded-md border border-oai-gray-200 bg-white px-3 text-sm outline-none focus:ring-2 focus:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:h-10"})]})]}):null]}),!g&&t?e.jsxs("section",{className:"mb-6 flex items-start gap-3 rounded-lg border border-oai-gray-200 px-4 py-3 dark:border-oai-gray-800",children:[e.jsxs("dl",{className:"sessions-kpis grid min-w-0 flex-1 grid-cols-2 gap-y-3 sm:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.summary.count")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:_(Q.count)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.col.tokens")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:_(Q.tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.col.cost")}),e.jsxs("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:[Q.costIsPartial?"≥":"",fe(Q.cost,{currency:We,rate:He})]})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.summary.speed")}),e.jsxs("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:[e.jsx(se,{performance:Q.performance}),Q.performance.estimated_tokens_per_second==null?"—":null]})]})]}),e.jsxs(Oe,{children:[e.jsx(Ee,{"aria-label":s("sessions.summary.scope_help"),className:"-mr-2 flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 hover:bg-oai-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 sm:h-8 sm:w-8",children:e.jsx(fs,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Ie,{children:e.jsx($e,{side:"bottom",align:"end",sideOffset:8,className:"z-[60]",children:e.jsx(Pe,{className:"max-w-xs rounded-lg border border-oai-gray-200 bg-white p-4 text-sm leading-6 text-oai-gray-700 outline-none dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:s("sessions.summary.scope")})})})]})]}):null,e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-x-3 gap-y-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:V.foldedCount>0?s("sessions.thread.result_count",{roots:V.roots.length,subagents:V.foldedCount}):s("sessions.filter.result_count",{filtered:U.length,total:$.length})}),de?e.jsx("button",{type:"button",onClick:Ye,className:"inline-flex min-h-10 items-center rounded text-oai-gray-700 underline decoration-oai-gray-300 underline-offset-4 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-200 dark:decoration-oai-gray-600 dark:hover:text-white sm:min-h-0",children:s("sessions.filter.clear")}):null]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ne,{ariaLabel:s("sessions.group.aria"),options:rs,value:S,onValueChange:O,className:"sessions-filter-trigger h-11 min-w-0 max-w-40 px-2.5 text-xs sm:h-8"}),e.jsx(ne,{ariaLabel:s("sessions.sort.aria"),options:os,value:A,onValueChange:J,className:"sessions-filter-trigger h-11 min-w-0 max-w-44 px-2.5 text-xs sm:h-8",align:"end"})]})]}),ns?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.truncated",{shown:t.returned_count,total:t.session_count})}):null,o&&!t?e.jsxs("div",{className:"rounded-xl border border-dashed border-red-300 py-16 text-center dark:border-red-500/40",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:s("sessions.error.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o}),e.jsx("button",{type:"button",onClick:()=>{oe(!1)},className:"mt-4 inline-flex h-11 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:s("sessions.error.retry")})]}):g?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(ys,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),s("sessions.loading")]}):U.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-oai-gray-200 py-16 text-center dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:de?s("sessions.empty.filtered_title"):s("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:de?s("sessions.empty.filtered_body"):s("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[o?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:s("shared.error.prefix",{error:o})}):null,e.jsxs("div",{className:"sessions-row-grid sessions-list-header border-b border-oai-gray-200 py-2 text-xs text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400","aria-hidden":!0,children:[e.jsx("span",{children:s("sessions.col.session")}),e.jsx("span",{className:"text-right",children:s("sessions.col.tokens")}),e.jsx("span",{className:"text-right",children:s("sessions.col.cost")}),e.jsx("span",{className:"text-right",children:s("sessions.col.speed")}),e.jsx("span",{className:"sr-only",children:s("sessions.col.actions")})]}),e.jsx("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:Ze.map(i=>e.jsxs(pe.Fragment,{children:[e.jsx("li",{className:"pb-2 pt-5",children:e.jsx("h2",{className:"break-words text-xs font-medium text-oai-gray-900 dark:text-oai-gray-100",children:S==="project"?i.key||s("sessions.project.unknown"):i.key?new Date(`${i.key}T12:00:00`).toLocaleDateString(G||void 0,{year:"numeric",month:"short",day:"numeric"}):s("sessions.group.unknown_date")})}),i.sessions.map(x=>{const c=V.childrenByRoot.get(x.session_hash)||[],h=F.has(x.session_hash),q=X.get(x.session_hash)||"all",z=q==="all"?c:c.filter(function(is){return H(is).some(ls=>ls.model===q)});return e.jsxs(pe.Fragment,{children:[e.jsx(De,{session:x,locale:G,timeOnly:S==="time",childCount:c.length,expanded:h,onToggle:es,onDetail:D}),h&&c.length?e.jsx(As,{sessions:c,selectedModel:q,onSelect:ee=>ss(x.session_hash,ee)}):null,h?z.map(ee=>e.jsx(De,{session:ee,locale:G,nested:!0,timeOnly:S==="time",onDetail:D},ee.session_hash)):null]},x.session_hash)})]},i.key))}),xe?e.jsx("div",{ref:_e,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:ge,className:"inline-flex h-11 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:s("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-8 max-w-3xl text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.privacy")})]})}),u?e.jsx(Os,{session:u,subagents:Je,onClose:Xe}):null]})}export{ot as SessionsPage};