tokentracker-cli 1.5.2 → 1.5.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 (134) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-B5kmt0VD.js → AchievementBadge-CKNb_cwg.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-C0FlkOo0.js → AchievementsPage-u9P8DXJI.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-CRcp80Pp.js → AchievementsSection-BSCUJ4DR.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-DAFjGbKW.js → BadgeDetailModal-Bg7cE3Zq.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-CO0bbimB.js → BotAnimated-C7D2WbQA.js} +1 -1
  6. package/dashboard/dist/assets/{Card-Xhr5exz8.js → Card-B4IqAhai.js} +1 -1
  7. package/dashboard/dist/assets/{CloudCheckoutPage-DsQ7FmsI.js → CloudCheckoutPage-P75pH9Ym.js} +1 -1
  8. package/dashboard/dist/assets/{CloudPage-DkSexu5V.js → CloudPage-DDEZfmZg.js} +2 -2
  9. package/dashboard/dist/assets/{CommandPalette-Bm0huQdj.js → CommandPalette-CER_AklA.js} +1 -1
  10. package/dashboard/dist/assets/{CommunityStatsModal-BsL8GN8Q.js → CommunityStatsModal-Cbb74eib.js} +1 -1
  11. package/dashboard/dist/assets/{ConfirmModal-_WPp292g.js → ConfirmModal-Q1ZQdZHt.js} +1 -1
  12. package/dashboard/dist/assets/{Controls-ktzn68KM.js → Controls-DaGOfcoz.js} +1 -1
  13. package/dashboard/dist/assets/DashboardPage-CXI7RmxO.js +1 -0
  14. package/dashboard/dist/assets/{DateRangePopover-DWr4zIzF.js → DateRangePopover-DSS1Ira_.js} +1 -1
  15. package/dashboard/dist/assets/{DevicePage-CBa8Mk47.js → DevicePage-6zPLYydh.js} +1 -1
  16. package/dashboard/dist/assets/{DialogClose-CZ5jzgtb.js → DialogClose-DdCQ36LK.js} +1 -1
  17. package/dashboard/dist/assets/DialogDescription-DztHQvj-.js +1 -0
  18. package/dashboard/dist/assets/{DialogTitle-Dr0N6q15.js → DialogTitle-BjP217Y1.js} +1 -1
  19. package/dashboard/dist/assets/{ElectricLogo-sYqgrO6-.js → ElectricLogo-Dhq8PM4h.js} +1 -1
  20. package/dashboard/dist/assets/{FadeIn-Qq-hcrZW.js → FadeIn-CGNbED4E.js} +1 -1
  21. package/dashboard/dist/assets/{HeaderGithubStar-B77zSv7i.js → HeaderGithubStar-DwqEFzb6.js} +1 -1
  22. package/dashboard/dist/assets/{HoverTooltip-lRDaUmoW.js → HoverTooltip-CQZTgyQy.js} +1 -1
  23. package/dashboard/dist/assets/{IpCheckPage-B6AvHZjA.js → IpCheckPage-Bz09HXLn.js} +1 -1
  24. package/dashboard/dist/assets/{LandingPage-DgzOjf3x.js → LandingPage-DC-lZsYR.js} +2 -2
  25. package/dashboard/dist/assets/{LeaderboardPage-BtjjtDMC.js → LeaderboardPage-D8MpLM_t.js} +2 -2
  26. package/dashboard/dist/assets/{LeaderboardProBadge-B2wNTUTU.js → LeaderboardProBadge-pdXgokhE.js} +1 -1
  27. package/dashboard/dist/assets/{LeaderboardProfileModal-DJJckwHh.js → LeaderboardProfileModal-nHZLiE0m.js} +3 -3
  28. package/dashboard/dist/assets/{LeaderboardProfilePage-DJdxByl2.js → LeaderboardProfilePage-BKv3oIAW.js} +1 -1
  29. package/dashboard/dist/assets/LimitsPage-TmRTgSCb.js +6 -0
  30. package/dashboard/dist/assets/{LocalOnlyNotice-B2lVqf_H.js → LocalOnlyNotice-aF01udyR.js} +1 -1
  31. package/dashboard/dist/assets/{LoginCard-i0gg1yby.js → LoginCard-BaroD0Ct.js} +1 -1
  32. package/dashboard/dist/assets/{LoginModal-B-loLNZM.js → LoginModal-0jgyMGVM.js} +1 -1
  33. package/dashboard/dist/assets/{LoginPage-D_swI75j.js → LoginPage-BUx8U58i.js} +1 -1
  34. package/dashboard/dist/assets/{PetPage-DDpKvpjG.js → PetPage-CpOjtJqg.js} +2 -2
  35. package/dashboard/dist/assets/{PopoverPopup-Gja4MyEK.js → PopoverPopup-BYjfer-M.js} +1 -1
  36. package/dashboard/dist/assets/{ProviderIcon-DOPj7tAZ.js → ProviderIcon-NtYa2h0u.js} +1 -1
  37. package/dashboard/dist/assets/{ResetPasswordPage-BVADLk89.js → ResetPasswordPage-CYUg7TR1.js} +1 -1
  38. package/dashboard/dist/assets/{Select-D-38tN-E.js → Select-CYP95o5y.js} +1 -1
  39. package/dashboard/dist/assets/{SelectItemText-jN61ukxk.js → SelectItemText-BCDfusOM.js} +1 -1
  40. package/dashboard/dist/assets/{SelfHostPage-k7AkGpl1.js → SelfHostPage-BmVc2rIT.js} +1 -1
  41. package/dashboard/dist/assets/ServiceStatusPage-Dyp8NwIn.js +1 -0
  42. package/dashboard/dist/assets/SessionsPage-tGEj6Ztz.js +3 -0
  43. package/dashboard/dist/assets/{SettingsPage-DfnMCAuA.js → SettingsPage-CCMbq5wc.js} +3 -3
  44. package/dashboard/dist/assets/{SkillsPage-YyIHIaHN.js → SkillsPage-C4O4fbaQ.js} +1 -1
  45. package/dashboard/dist/assets/{TokenGalaxy-BLcvZuQ9.js → TokenGalaxy-D2d738xr.js} +1 -1
  46. package/dashboard/dist/assets/{TooltipPopup-3E8kyVzz.js → TooltipPopup-BJfFYesG.js} +1 -1
  47. package/dashboard/dist/assets/{TrendMonitor-ByKAdXSF.js → TrendMonitor-CElakFSU.js} +1 -1
  48. package/dashboard/dist/assets/{WidgetsPage-BgEVIIzL.js → WidgetsPage-Cvd1LbJm.js} +1 -1
  49. package/dashboard/dist/assets/{WrappedPage-HjbX8QaA.js → WrappedPage-wRC1tE_a.js} +1 -1
  50. package/dashboard/dist/assets/{__vite-browser-external-Br-KAXh6.css → __vite-browser-external-CMBWGkOq.css} +1 -1
  51. package/dashboard/dist/assets/__vite-browser-external-V4TPLCJG.js +45 -0
  52. package/dashboard/dist/assets/{agent-logos-BVF2siPQ.js → agent-logos-Ba57HF3w.js} +1 -1
  53. package/dashboard/dist/assets/{arrow-left-CYO24PGP.js → arrow-left-B1bKnxXL.js} +1 -1
  54. package/dashboard/dist/assets/{arrow-right-Xg9PZYhw.js → arrow-right-DrOlKzX5.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-up-right-B7ah6Qv-.js → arrow-up-right-hlYpo3yw.js} +1 -1
  56. package/dashboard/dist/assets/{calendar-days-BV_iG938.js → calendar-days-CSY6SEsI.js} +1 -1
  57. package/dashboard/dist/assets/{check--EZH8RTp.js → check-xrP1gLw5.js} +1 -1
  58. package/dashboard/dist/assets/{chevron-down-BzGTlk0-.js → chevron-down-6-zT5n9d.js} +1 -1
  59. package/dashboard/dist/assets/{cloud-checkout-BgyxPHEh.js → cloud-checkout-BZymZD4K.js} +1 -1
  60. package/dashboard/dist/assets/{composite-C0KrmLEK.js → composite-C9izWafa.js} +1 -1
  61. package/dashboard/dist/assets/{copy-BtucSK2U.js → copy-Dkas5wZX.js} +1 -1
  62. package/dashboard/dist/assets/{download-CWHq03Y2.js → download-CagGRs0_.js} +1 -1
  63. package/dashboard/dist/assets/{external-link-DCTXF5VZ.js → external-link-DRl10hxd.js} +1 -1
  64. package/dashboard/dist/assets/{flame-BE5TsqVF.js → flame-CkvmsTFB.js} +1 -1
  65. package/dashboard/dist/assets/{format-tokens-ThNIMWnZ.js → format-tokens-BtwhO3mV.js} +1 -1
  66. package/dashboard/dist/assets/{gift-DgaN9s4-.js → gift-YzjXkMQx.js} +1 -1
  67. package/dashboard/dist/assets/{icons-B4r5EiDC.js → icons-CHhKYs0u.js} +1 -1
  68. package/dashboard/dist/assets/{index-DqCtgU0G.js → index-B0MQZTrM.js} +1 -1
  69. package/dashboard/dist/assets/{index-fNKH4U7j.js → index-C2DK8av-.js} +1 -1
  70. package/dashboard/dist/assets/{index-CKhcCLNC.js → index-CJknN9Jd.js} +1 -1
  71. package/dashboard/dist/assets/{index-DFF9xo6f.js → index-DojzoMqd.js} +1 -1
  72. package/dashboard/dist/assets/{info-B4YzRR4y.js → info-Torep-Ti.js} +1 -1
  73. package/dashboard/dist/assets/{link-2-DzbUbaBw.js → link-2-DE5Yu-z6.js} +1 -1
  74. package/dashboard/dist/assets/{loader-circle-B9c7D-7v.js → loader-circle-BL8LxD9n.js} +1 -1
  75. package/dashboard/dist/assets/{local-usage-transfer-btuk_b0Y.js → local-usage-transfer-8X1InWix.js} +1 -1
  76. package/dashboard/dist/assets/{modifiers.esm-BjrU-Xz7.js → modifiers.esm-D60-6UQa.js} +1 -1
  77. package/dashboard/dist/assets/{monitor-smartphone-Bwn4tb4q.js → monitor-smartphone-C-IFPjqk.js} +1 -1
  78. package/dashboard/dist/assets/{play-DIFOwGIQ.js → play-n6uWrdH9.js} +1 -1
  79. package/dashboard/dist/assets/{plus-BpBqnwVg.js → plus-B2f6TaNj.js} +1 -1
  80. package/dashboard/dist/assets/{provider-display-DSrs4u7T.js → provider-display-DWqCEcsP.js} +1 -1
  81. package/dashboard/dist/assets/{react-BgG7_MY0.js → react-B-zfi_j6.js} +1 -1
  82. package/dashboard/dist/assets/{safePolygon-BUGWIDOM.js → safePolygon-C2PsvI-v.js} +1 -1
  83. package/dashboard/dist/assets/{search-aHrmBmtZ.js → search-DZOaTLF9.js} +1 -1
  84. package/dashboard/dist/assets/{server-DOEvwlEU.js → server-DIp4Qfsv.js} +1 -1
  85. package/dashboard/dist/assets/{shield-check-BPTnLhsT.js → shield-check-Cs2M8-iT.js} +1 -1
  86. package/dashboard/dist/assets/{skills-api-C052Mwez.js → skills-api-CoYy6Tov.js} +1 -1
  87. package/dashboard/dist/assets/{sortable.esm-DaZKhjhu.js → sortable.esm-B5_hjIfs.js} +1 -1
  88. package/dashboard/dist/assets/{store-Cq30Pofw.js → store-BLXqtJzb.js} +1 -1
  89. package/dashboard/dist/assets/{terminal-CoSDSkE7.js → terminal-CEMKX3ba.js} +1 -1
  90. package/dashboard/dist/assets/{trash-BAmt-kPj.js → trash-DOWYaXjK.js} +1 -1
  91. package/dashboard/dist/assets/{use-community-stats-Bxq0kBhm.js → use-community-stats-BjRI1Bzz.js} +1 -1
  92. package/dashboard/dist/assets/{use-latest-request-guard-DmIQDlvk.js → use-latest-request-guard-T7L5qBU6.js} +1 -1
  93. package/dashboard/dist/assets/use-limits-display-prefs-vNIrCPZA.js +1 -0
  94. package/dashboard/dist/assets/{use-native-settings-s_CIC8Bb.js → use-native-settings-Cg5Zb4q_.js} +1 -1
  95. package/dashboard/dist/assets/{use-ordered-list-BHhykAbt.js → use-ordered-list-BF-wIvmG.js} +1 -1
  96. package/dashboard/dist/assets/use-reduced-motion-B9K5mIx4.js +1 -0
  97. package/dashboard/dist/assets/{use-transform-CVeMFlS6.js → use-transform-CbJ1IcNc.js} +1 -1
  98. package/dashboard/dist/assets/use-usage-limits-Dgg3jpC4.js +1 -0
  99. package/dashboard/dist/assets/{useCurrency-DilqL2Iv.js → useCurrency-3oBHWfSe.js} +1 -1
  100. package/dashboard/dist/assets/{usePositioner-BcnySw8a.js → usePositioner-D0YrIW0A.js} +1 -1
  101. package/dashboard/dist/assets/{useTokenFormat-CvKW46WP.js → useTokenFormat-DZAHWE_R.js} +1 -1
  102. package/dashboard/dist/assets/{zap-D7VRNTwk.js → zap-kLub6Jiv.js} +1 -1
  103. package/dashboard/dist/index.html +2 -2
  104. package/dashboard/dist/ip-check.html +2 -2
  105. package/dashboard/dist/leaderboard.html +2 -2
  106. package/dashboard/dist/share.html +2 -2
  107. package/package.json +1 -1
  108. package/src/commands/serve.js +25 -15
  109. package/src/lib/accept-encoding.js +59 -0
  110. package/src/lib/cursor-config.js +3 -1
  111. package/src/lib/deepseek-limits.js +280 -0
  112. package/src/lib/deepseek-status.js +157 -0
  113. package/src/lib/grok-limits.js +40 -1
  114. package/src/lib/local-api.js +248 -10
  115. package/src/lib/opencode-status.js +88 -0
  116. package/src/lib/pricing/index.js +182 -79
  117. package/src/lib/pricing/seed-snapshot.json +1 -1
  118. package/src/lib/provider-api-key-store.js +2 -0
  119. package/src/lib/provider-status.js +27 -2
  120. package/src/lib/qoder-limits.js +17 -2
  121. package/src/lib/session-analytics.js +194 -29
  122. package/src/lib/static-server.js +74 -2
  123. package/src/lib/usage-limits.js +714 -53
  124. package/src/lib/workbuddy-limits.js +291 -26
  125. package/src/lib/zcode-limits.js +143 -35
  126. package/dashboard/dist/assets/DashboardPage-CdNXi3Im.js +0 -1
  127. package/dashboard/dist/assets/DialogDescription-kCZ4gN09.js +0 -1
  128. package/dashboard/dist/assets/LimitsPage-gSBHSBi_.js +0 -6
  129. package/dashboard/dist/assets/ServiceStatusPage-D_Fa_pYz.js +0 -1
  130. package/dashboard/dist/assets/SessionsPage-BymccEEz.js +0 -3
  131. package/dashboard/dist/assets/__vite-browser-external-D_cMeuqI.js +0 -45
  132. package/dashboard/dist/assets/use-limits-display-prefs-CyAn1fme.js +0 -1
  133. package/dashboard/dist/assets/use-reduced-motion-BmFyFE3S.js +0 -1
  134. package/dashboard/dist/assets/use-usage-limits-DRZMI20u.js +0 -1
@@ -1,6 +0,0 @@
1
- import{o as te,j as e,y as Ge,c as r,h as z,r as g,bm as jt,V as C,bn as kt,bo as wt,al as Nt,B as Z,bp as _t,e as St,W as De,R as Pt,L as Ct,bq as Mt,t as Dt,w as Et}from"./__vite-browser-external-D_cMeuqI.js";import{m as Ee}from"./react-BgG7_MY0.js";import{P as J,c as Rt,r as de,a as Tt,u as It,b as At,s as Ht}from"./use-usage-limits-DRZMI20u.js";import{b as We,c as _,l as oe,d as Ke,u as Ot}from"./use-limits-display-prefs-CyAn1fme.js";import{F as Ft}from"./FadeIn-Qq-hcrZW.js";import{P as qe}from"./ProviderIcon-DOPj7tAZ.js";import{H as Lt}from"./HoverTooltip-lRDaUmoW.js";import{C as Q}from"./chevron-down-BzGTlk0-.js";import{G as $t}from"./gift-DgaN9s4-.js";import{C as zt}from"./ConfirmModal-_WPp292g.js";import{I as Re,L as Ut}from"./LocalOnlyNotice-B2lVqf_H.js";import{S as he}from"./Select-D-38tN-E.js";import{P as Bt}from"./plus-BpBqnwVg.js";import{P as Gt,a as Wt,b as Kt,c as qt,d as Vt}from"./PopoverPopup-Gja4MyEK.js";import{u as Yt}from"./use-reduced-motion-BmFyFE3S.js";import"./use-latest-request-guard-DmIQDlvk.js";import"./DialogTitle-Dr0N6q15.js";import"./composite-C0KrmLEK.js";import"./store-Cq30Pofw.js";import"./DialogDescription-kCZ4gN09.js";import"./arrow-up-right-B7ah6Qv-.js";import"./download-CWHq03Y2.js";import"./check--EZH8RTp.js";import"./SelectItemText-jN61ukxk.js";import"./usePositioner-BcnySw8a.js";import"./safePolygon-BUGWIDOM.js";const Ve={name:"bell-off",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]};Ve.node;const Zt=te(Ve);const Ye={name:"bell",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]};Ye.node;const Xt=te(Ye);const Ze={name:"calendar-clock",size:24,node:[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338",key:"7hb8p4"}],["path",{d:"M3 9h5.859",key:"numkqi"}],["path",{d:"M8 2v3",key:"1ioesn"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]};Ze.node;const Xe=te(Ze);const Je={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};Je.node;const ke=te(Je);const Qe={name:"infinity",size:24,node:[["path",{d:"M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8",key:"18ogeb"}]]};Qe.node;const et=te(Qe),Jt=[3,2,3,3,2,2,3];function G({className:t}){return e.jsx("div",{className:Ge("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Qt(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-3 w-12 shrink-0"}),e.jsx(G,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(G,{className:"h-3 w-[30px] shrink-0"}),e.jsx(G,{className:"h-3 w-6 shrink-0"})]})}function ea({bars:t,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return e.jsxs("div",{className:"rounded-xl border border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-900",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-oai-gray-200 px-4 py-4 dark:border-oai-gray-800 sm:px-5",children:[e.jsx(G,{className:"h-[22px] w-[22px] shrink-0 rounded"}),e.jsx(G,{className:Ge("h-4",i)})]}),e.jsx("div",{className:"flex flex-col gap-2 px-4 py-4 sm:px-5",children:Array.from({length:t},(s,n)=>e.jsx(Qt,{},n))})]})}function ta(){return e.jsx("div",{className:"flex flex-col gap-3","aria-hidden":"true",children:Jt.map((t,a)=>e.jsx(ea,{bars:t,index:a},a))})}const ye=100;function Te(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function aa(t){return Math.max(0,Math.min(ye,Math.round(t)))}function ra(t){return new Intl.DateTimeFormat(z(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function ia(t,a,i){if(t==null||t>=a)return ye;const s=a-t,n=a-i;return aa(n/s*ye)}function na(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function sa(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=na(t);if(i===void 0)return null;const s=Array.isArray(t.credits)?t.credits:[],n=a instanceof Date?a.getTime():Number(a??Date.now()),o=[];for(const l of s){const c=Te(l?.expires_at);if(c==null)continue;const d=o.length+1;o.push({key:`reset-${d}`,label:r("limits.codex_reset_bank.row_label",{index:d}),expiresAt:ra(c),expiresMs:c,percent:ia(Te(l?.granted_at),c,n)})}return i===0?null:o.length>0?{kind:"rows",availableCount:i??o.length,rows:o}:i>0?{kind:"count_only",availableCount:i,rows:[]}:null}const ee=864e5;function $(t,a){const i=new Date(t),s=i.getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+a,1,i.getUTCHours(),i.getUTCMinutes())),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(s,o)),n.getTime()}function tt(t,a){if(a==="weekly")return t-7*ee;if(a==="yearly")return $(t,-12);const i=new Date(t),s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),0)).getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()-1,1,i.getUTCHours(),i.getUTCMinutes()));return n.setUTCDate(Math.min(i.getUTCDate(),s)),n.getTime()}function at(t,a){return a==="weekly"?t+7*ee:a==="yearly"?$(t,12):$(t,1)}function oa(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return tt(new Date(t.nextBillingAt).getTime(),t.cycle)}function la(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return tt(i,a)}function ca(t,a,i){if(a==="weekly"){const c=7*ee,d=i<=t?0:Math.floor((i-t)/c);return{startMs:t+d*c,endMs:t+(d+1)*c}}const s=a==="yearly"?12:1,n=s*30.436875*ee;let o=i<=t?0:Math.floor((i-t)/n);for(;o>0&&$(t,o*s)>i;)o-=1;let l=0;for(;$(t,(o+1)*s)<=i&&l<12e3;)o+=1,l+=1;return{startMs:$(t,o*s),endMs:$(t,(o+1)*s)}}function le(t,a){const i=new Date(t.nextBillingAt).getTime();if(!Number.isFinite(i))return null;const s=["weekly","monthly","yearly"].includes(t.cycle)?t.cycle:"monthly",n=la(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=ca(n,s,a):t.startedAt!=null?(o=n,l=at(n,s),c=l<=a):(o=n,l=i,c=l<=a);const d=Math.max(1,l-o),m=c?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:l,startMs:o,progress:m,cycleDays:Math.max(1,Math.round(d/ee)),expired:c}}function rt(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.ceil(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function ve(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.floor(i/6e4),n=Math.floor(s/1440),o=Math.floor(s%1440/60),l=s%60;return r("subscriptions.countdown",{days:n,hours:o,minutes:l})}const da="shrink-0 text-oai-black dark:text-oai-white",ua={opencodeGo:"OPENCODE_GO_API_KEY",commandCode:"COMMAND_CODE_API_KEY"},ma={opencodeGo:"opencode-go",commandCode:"command-code"};function it(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function nt(){return it()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function st(){return r("limits.devin.setupHint.snippet_login")}function xa(t){const a=de(t);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const s=Math.floor(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function ot(t,a){const i=a===_.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function ce(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ue(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function ne(t){const a=Math.max(0,Math.min(100,Number(t)||0)),i=Math.round(a);return a>0&&i===0?r("limits.bar.sub_one_percent"):String(i)}function se(t,{useGrouping:a=!0,maximumFractionDigits:i}={}){const s=Number(t);return Number.isFinite(s)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:i??(s>=100?0:2),useGrouping:a}).format(s):null}function lt(t,a){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const i={useGrouping:t.unit!=="calls",maximumFractionDigits:a},s=se(t.used_credits,i),n=se(t.limit_credits,i),o=se(t.remaining_credits,i);if(!s||!n||!o)return null;const l=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(l,{used:s,limit:n,remaining:o})}function we(t,a,i){return Rt({usedPercent:ce(t.window,t.pctField),windowSeconds:Tt(t,t.window),resetMs:de(ue(t.window,t.resetField)),mode:a,now:i})}function W(t){return Number.isFinite(t)?new Intl.DateTimeFormat(z(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function pa(t,a,i){const s=[dt(t,a,i)],n=de(ue(t.window,t.resetField)),o=W(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=lt(t.window,t.creditPrecision);return l&&s.push(l),s.join(`
2
- `)}const ct=Lt,Ie=[1,.65,.45,.3,.2];function je(t){return Ie[Math.min(t,Ie.length-1)]}function Ae({paceX:t,paceOver:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${t}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${a?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${t}% - 1px)`,width:"2px"}})]})}function ga({label:t,pct:a,reset:i,mode:s=_.USED,pacePercent:n=null,paceOver:o=!1,title:l=null,segments:c=null}){const d=Math.max(0,Math.min(100,Number(a)||0)),m=s===_.REMAINING?100-d:d,u=ot(m,s),p=Math.round(m),h=m>0&&p===0?Math.max(m,.35):m;let y=String(p);m>0&&p===0&&(y=r("limits.bar.sub_one_percent"));const b=n==null?null:Math.max(0,Math.min(100,n)),v=c?.map(k=>Math.max(0,Math.min(100,Number(k.pct)||0))),w=v?.reduce((k,E)=>k+E,0)||0,M=c?Math.max(0,d-w):0,S=Math.max(0,100-w-M);return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(ct,{text:l}),e.jsx("span",{"data-limit-label":"",className:"text-xs sm:text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),c?e.jsxs("div",{"data-limit-segments":"",className:"relative flex min-w-0 flex-1 h-1.5 overflow-hidden",style:{gap:"min(2px, 1%)"},children:[c.map((k,E)=>e.jsx("div",{"data-limit-segment":k.key,className:`${u} min-w-0 rounded-full h-full transition-[flex-grow] duration-500 ease-out`,style:{flex:`${v[E]} 1 0px`,opacity:je(E)}},k.key)),M?e.jsx("div",{"data-limit-unallocated-used":"",className:`${u} min-w-0 rounded-full h-full`,style:{flex:`${M} 1 0px`,opacity:je(c.length)}}):null,S?e.jsx("div",{"data-limit-remainder":"",className:"min-w-0 rounded-full h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{flex:`${S} 1 0px`}}):null,b!=null&&e.jsx(Ae,{paceX:b,paceOver:o})]}):e.jsxs("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${u} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${h}%`,minWidth:m>0?"3px":0}}),b!=null&&e.jsx(Ae,{paceX:b,paceOver:o})]}),e.jsxs("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:[y,"%"]}),i&&e.jsx("span",{className:"text-xs tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-8 text-right shrink-0",children:i})]})}function ha({segments:t,fillColor:a}){return e.jsx("div",{"data-limit-legend":"",className:"-mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] leading-snug",style:{paddingLeft:"calc(var(--tt-limits-label-w, 0px) + 0.5rem)"},children:t.map((i,s)=>e.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[e.jsx("span",{"aria-hidden":!0,className:`${a} inline-block h-1.5 w-1.5 shrink-0 rounded-full`,style:{opacity:je(s)}}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:i.label??r(i.labelKey)}),e.jsxs("span",{className:"tabular-nums text-oai-gray-700 dark:text-oai-gray-200",children:[ne(i.pct),"%"]})]},i.key))})}function dt(t,a,i){const s=t.label??r(t.labelKey),n=i===_.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(ce(t.window,t.pctField))||0)),m=ne(o(d));return n?r("limits.explain.remaining",{label:s,used:m}):r("limits.explain.used",{label:s,used:m})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=ne(o(a.projectedEnd??100));return r(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:s,pct:d})}const l=Math.max(0,Math.min(100,Number(ce(t.window,t.pctField))||0)),c=ne(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function ut({pace:t}){return t.pacePercent!=null}function fa(t,a){return t.some(i=>ut(i)&&(i.mode??a)===_.REMAINING)}function Ne({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=fa(t,a),n=t.some(ut);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l,mode:c=a})=>{const d=W(de(ue(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[dt(o,l,c),d?e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",r(o.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:d})]}):null,o.showCreditDetail?e.jsx("div",{children:lt(o.window,o.creditPrecision)}):null]},o.key)}),n?e.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(s?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function X(t){if(!t)return null;const a=Date.now()-new Date(t).getTime();if(a<0)return null;const i=Math.floor(a/6e4);if(i<1)return r("shared.time.now");if(i<60)return r("shared.time.m_ago",{n:i});const s=Math.floor(i/60);if(s<24)return r("shared.time.h_ago",{n:s});const n=Math.floor(s/24);return r("shared.time.d_ago",{n})}const He={live:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-emerald-500",pulse:"bg-emerald-400"},stale:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"},cached:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"}},ba={claude:"claude",codex:"codex",antigravity:"agy"};function B({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=He[i]||He.live,o=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:l=>l.stopPropagation(),children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold uppercase tracking-wider border leading-normal ${n.surface}`,children:[o?e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${n.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${n.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),s?e.jsxs("span",{className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-2 -translate-x-1/2 w-48 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-1.5 text-[10px] font-normal text-white text-center opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-normal shadow-lg origin-bottom border border-oai-gray-800 dark:border-oai-gray-700",children:[s,e.jsx("span",{className:"absolute left-1/2 top-full -translate-x-1/2 border-4 border-transparent border-t-oai-gray-900 dark:border-t-oai-gray-800"})]}):null]})}function mt({name:t,providerId:a,children:i,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null,toggleOnHeader:d=!1}){const m=Ke(a),u=e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[m?e.jsx(qe,{provider:m,size:22,className:da}):null,e.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white",children:t}),c?e.jsx("span",{className:"shrink-0",children:c}):null,l]}),p="rounded-xl border border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-900",h="flex w-full items-center justify-between gap-3 border-b border-oai-gray-200 px-4 py-4 text-left dark:border-oai-gray-800 sm:px-5",y=e.jsx("div",{className:"flex flex-col gap-2 px-4 py-4 sm:px-5",children:i});return s?d?e.jsxs("div",{className:p,children:[e.jsxs("button",{type:"button","aria-expanded":n,onClick:o,className:`${h} rounded-t-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500`,children:[u,e.jsx(Q,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${n?"rotate-180":""}`})]}),y]}):e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:o,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),o?.())},className:`${p} cursor-pointer transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500`,children:[e.jsxs("div",{className:h,children:[u,e.jsx(Q,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${n?"rotate-180":""}`})]}),y]}):e.jsxs("div",{className:p,children:[e.jsx("div",{className:h,children:u}),y]})}function xt({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?et:ke;return e.jsx("span",{role:"img","aria-label":a,title:a,className:`inline-flex translate-y-px ${t.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:e.jsx(i,{size:14,strokeWidth:2,"aria-hidden":!0})})}function pt({subscription:t,now:a,mode:i=_.USED}){const s=le(t,a);if(!s)return null;const{endMs:n,expired:o}=s,l=!o&&n-a<=3*864e5,c=o?100:s.progress*100,d=i===_.REMAINING?100-c:c,m=o?100:Math.max(0,Math.min(100,d)),u=Math.round(m),p=m>0&&u===0?r("limits.bar.sub_one_percent"):`${u}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs sm:text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:r("subscriptions.inline.label")}),e.jsx("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:`${o?"bg-red-500":l?"bg-amber-500":"bg-blue-500"} rounded-full h-full block motion-safe:transition-[width] motion-safe:duration-500 ease-out motion-reduce:transition-none`,style:{width:`${m}%`,minWidth:m>0?"3px":0}})}),e.jsx("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:p}),e.jsx("span",{className:`text-xs tabular-nums shrink-0 whitespace-nowrap w-8 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:rt(n,a)})]})}function gt({subscription:t,now:a}){const i=le(t,a);if(!i)return null;const s=new Intl.DateTimeFormat(z(),{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("subscriptions.inline.label")}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:":"}),e.jsx("span",{children:t.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")}),e.jsx("span",{children:" "}),e.jsx("span",{className:"font-mono tabular-nums",children:s.format(new Date(i.endMs))}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{className:i.expired?"text-oai-error":void 0,children:ve(i.endMs,a)}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{children:t.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]})}const ya=We;function A({children:t,tone:a="neutral"}){return a==="error"?e.jsxs("div",{className:"flex items-start gap-2 text-xs leading-relaxed text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(jt,{size:15,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-red-500 dark:text-red-400"}),e.jsx("span",{className:"min-w-0 break-words",children:t})]}):e.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:t})}function _e({rows:t,mode:a,extra:i=null,expanded:s=!1}){const n=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:o,pace:l,mode:c=a})=>{const d=ce(o.window,o.pctField),u=s&&o.productPool&&Array.isArray(o.segments)&&o.segments.length!==0?o.segments:null,p=u&&c!==_.REMAINING?u:null;return e.jsxs(C.Fragment,{children:[e.jsx(ga,{label:o.label??r(o.labelKey),pct:d,reset:xa(ue(o.window,o.resetField)),mode:c,segments:p,pacePercent:l.pacePercent,paceOver:l.paceOver,title:pa(o,l,c)}),u?e.jsxs(e.Fragment,{children:[e.jsx(ha,{segments:u,fillColor:ot(d,_.USED)}),c===_.REMAINING?e.jsx("div",{"data-limit-share-note":"",className:"-mt-0.5 text-[11px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",style:{paddingLeft:"calc(var(--tt-limits-label-w, 0px) + 0.5rem)"},children:r("limits.grok.shares_are_used")}):null]}):null]},o.key)}),n?e.jsx(A,{children:r("limits.status.no_data")}):null,i]})}function va(t){if(!Number.isFinite(t.expiresMs))return null;const a=Math.floor((t.expiresMs-Date.now())/864e5);return a<0?null:a===0?r("limits.reset_bank.hover_detail_today",{date:t.expiresAt}):r("limits.reset_bank.hover_detail",{date:t.expiresAt,days:a})}function ja({row:t}){const a=Math.max(0,Math.min(100,Number(t.percent)||0));return e.jsxs("div",{className:"group relative flex items-center gap-2","data-reset-bank-row":"",children:[e.jsx(ct,{text:va(t)}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t.label}),e.jsx("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${a}%`,minWidth:a>0?"3px":0}})}),e.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:t.expiresAt})]})}function ka({model:t}){const a=t.kind==="count_only"?r("limits.codex_reset_bank.count_only",{count:t.availableCount}):null;return e.jsxs("div",{className:"mt-1 flex flex-col gap-1","data-reset-bank-section":t.kind,children:[e.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codex_reset_bank.title")}),a?e.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:a}):t.rows.map(i=>e.jsx(ja,{row:i},i.key))]})}const wa={five_hour:5*3600*1e3,weekly:168*3600*1e3};function ht(t,a){if(!t||typeof t!="object")return!1;if(t.error)return!0;for(const i of["five_hour","weekly"])for(const s of t[i]||[])if(Date.parse(s?.expires_at)>a)return!0;return!1}function Na({data:t}){const[a,i]=g.useState(!1),s=Date.now();if(!ht(t,s))return null;const n=[{key:"five_hour",label:r("limits.label.zcode_5h")},{key:"weekly",label:r("limits.label.zcode_weekly")}].map(c=>{const d=(t[c.key]||[]).filter(b=>Date.parse(b.expires_at)>s).sort((b,v)=>Date.parse(b.expires_at)-Date.parse(v.expires_at)),m=new Map;for(const b of d){const v=Date.parse(b.expires_at);m.set(v,(m.get(v)||0)+1)}const p=[...m.entries()].sort((b,v)=>b[0]-v[0]).map(([b,v])=>v>1?r("limits.zcode.reset_bank.batch",{time:W(b),count:v}):W(b)).join(`
3
- `),h=wa[c.key]||0,y=d.length&&h?Math.max(0,Math.min(100,(Date.parse(d[0].expires_at)-s)/h*100)):0;return{...c,cards:d,batchTitle:p,countdownPercent:y}});let o=0;const l=[];for(const c of n)o+=c.cards.length,c.cards.length&&l.push(c);return e.jsxs("div",{className:"mt-2 border-t border-oai-gray-200/60 pt-2 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:c=>{c.stopPropagation(),i(d=>!d)},onKeyDown:c=>c.stopPropagation(),className:"flex w-full items-center gap-1.5 rounded text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx(ke,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",children:r("limits.zcode.reset_bank.title")}),o?e.jsx("span",{className:"rounded-full bg-oai-gray-100 px-2 py-0.5 text-[10px] tabular-nums text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:r("limits.zcode.reset_bank.count",{count:o})}):null,e.jsx(Q,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${a?"rotate-180":""}`})]}),t.error?e.jsx(A,{tone:"error",children:t.error}):null,a&&!t.error?e.jsx("div",{className:"mt-2 flex flex-col gap-1.5",children:l.map(c=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{"data-limit-label":"",className:"shrink-0 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",style:{width:"var(--tt-limits-label-w)"},children:c.label}),e.jsx("span",{className:"rounded-full bg-oai-gray-100 px-2 py-0.5 tabular-nums text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:r("limits.zcode.reset_bank.count",{count:c.cards.length})}),e.jsx("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",title:c.batchTitle,children:e.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${c.countdownPercent}%`,minWidth:c.countdownPercent>0?"3px":0}})}),c.cards.length?e.jsx("span",{className:"ml-auto shrink-0 whitespace-nowrap text-right text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",title:c.batchTitle,children:r("limits.zcode.reset_bank.earliest",{time:W(Date.parse(c.cards[0].expires_at))})}):null]},c.key))}):null]})}function ft(t,a){if(t==="zcode_reset_bank")return ht(a.reset_credits,Date.now())?e.jsx(Na,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=sa(a.reset_credits);return i?e.jsx(ka,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(A,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})});if(t==="kiro_credits"&&Number.isFinite(Number(a.tracked_credits))&&Number(a.tracked_credit_records)>0){const i=se(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(A,{children:r("limits.label.kiro_tracked_credits",{credits:i,count:Number(a.tracked_credit_records)})})}return t==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?e.jsx(Ma,{defaultDir:a.otel_default_dir}):null}function _a({data:t,mode:a,now:i}){const[s,n]=g.useState(!1),o=g.useRef(null),l=Ce(o),c=[...new Set((t.buckets||[]).map(u=>u.plan_name).filter(Boolean))],d=c.length?c.join(" · "):r("limits.zcode.start_grants"),m=J.zcode.windows(t).filter(u=>u.window).map(u=>({spec:u,pace:we(u,a,i)}));return e.jsxs("div",{className:"mt-2 border-t border-oai-gray-200/60 pt-2 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:u=>{u.stopPropagation(),n(p=>!p)},onKeyDown:u=>u.stopPropagation(),className:"flex w-full items-center gap-1.5 rounded text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx($t,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(Q,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${s?"rotate-180":""}`})]}),s?e.jsx("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:l>0?{"--tt-limits-label-w":`${l}px`}:void 0,children:t.error?e.jsx(A,{tone:"error",children:t.error}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{rows:m,mode:a}),e.jsx(Ne,{rows:m,mode:a,now:i}),(t.buckets||[]).filter(u=>Number.isFinite(u.remaining_units)&&Number.isFinite(u.total_units)).map((u,p)=>e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.grant_amount",{remaining:u.remaining_units.toLocaleString(z()),total:u.total_units.toLocaleString(z())})},u.entitlement_id||p))]})}):null]})}function Sa({data:t,mode:a,now:i}){const[s,n]=g.useState(!1),o=g.useRef(null),l=Ce(o),c=r(t.region==="zai"?"limits.zcode.region.zai":"limits.zcode.region.bigmodel"),d=t.plan_label||r("limits.zcode.start_grants"),m=r("limits.zcode.other_region.title",{region:c,plan:d}),u=J.zcode.windows(t).filter(h=>h.window).map(h=>({spec:h,mode:a,pace:we(h,a,i)})),p=Date.parse(t.log_timestamp);return e.jsxs("div",{className:"mt-2 border-t border-oai-gray-200/60 pt-2 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:h=>{h.stopPropagation(),n(y=>!y)},onKeyDown:h=>h.stopPropagation(),className:"flex w-full items-center gap-1.5 rounded text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx(kt,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:m,children:m}),e.jsx(Q,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${s?"rotate-180":""}`})]}),s?e.jsxs("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:l>0?{"--tt-limits-label-w":`${l}px`}:void 0,children:[e.jsx(_e,{rows:u,mode:a}),e.jsx(Ne,{rows:u,mode:a,now:i}),Number.isFinite(p)?e.jsx(A,{children:r("limits.zcode.other_region.snapshot",{time:W(p)})}):null]}):null]})}function Pa(t,a,i,s,n,o,l=null,c=null,d=Date.now(),m=null){const u=J[t];if(!u)return null;const p=u.windows(a).filter(y=>y.window).map(y=>({spec:y,mode:s,pace:we(y,s,d)})),h=ft(u.extra,a);return e.jsxs(mt,{name:i,providerId:t,expandable:p.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(xt,{subscription:c}):null,toggleOnHeader:t==="zcode",children:[e.jsx(_e,{mode:s,rows:p,extra:h,expanded:n}),t==="opencodeGo"||t==="commandCode"?e.jsx(Da,{providerId:t,data:a,onSaved:m}):null,c?e.jsx(pt,{subscription:c,now:d,mode:s}):null,n?e.jsx(Ne,{rows:p,mode:s,now:d}):null,n&&c?e.jsx(gt,{subscription:c,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(_a,{data:a.start_plan,mode:s,now:d}):null,t==="zcode"&&a.other_region?e.jsx(Sa,{data:a.other_region,mode:s,now:d}):null]},t)}function fe(t,a,i,s,n=null,o=Date.now(),l=_.USED){const c=!!n;return e.jsxs(mt,{name:oe(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(xt,{subscription:n}):null,children:[a,c?e.jsx(pt,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(gt,{subscription:n,now:o})}):null]},t)}function Ca(t,a,i,s,n,o=null,l=Date.now(),c=null){if(!J[t])return null;if(!a?.configured)return fe(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(I,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Oe,{onSaved:c})}):null,t==="commandCode"?e.jsx(I,{title:r("limits.commandCode.setupHint.title"),children:e.jsx(Fe,{onSaved:c})}):null,t==="codingPlan"?e.jsx(I,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx($e,{})}):null,t==="agentPlan"?e.jsx(I,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(ze,{})}):null,t==="devin"?e.jsx(I,{title:r("limits.devin.setupHint.title"),children:e.jsx(Le,{})}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return fe(t,e.jsx(A,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return fe(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{tone:"error",children:a.error}),t==="kiro"?ft(J.kiro.extra,a):null,t==="opencodeGo"?e.jsx(I,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Oe,{onSaved:c})}):null,t==="commandCode"?e.jsx(I,{title:r("limits.commandCode.setupHint.title"),children:e.jsx(Fe,{onSaved:c})}):null,t==="codingPlan"?e.jsx(I,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx($e,{})}):null,t==="agentPlan"?e.jsx(I,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(ze,{})}):null,t==="devin"?e.jsx(I,{title:r("limits.devin.setupHint.title"),children:e.jsx(Le,{})}):null]}),s,n,o,l,i);const d=oe(t),m=a.plan_label?`${d} ${a.plan_label}`:d;let u=null;if(a.auth_action_required==="reauth"){const h=t==="commandCode"?nt():t==="devin"?st():ba[t];u=e.jsx(B,{label:r("limits.reauth.badge"),age:X(a.cached_at),tone:"stale",tooltip:h?r("limits.reauth.tooltip",{command:h}):null})}if(!u&&t==="antigravity")if(a.cached){const h=X(a.cached_at);u=e.jsx(B,{label:r("limits.label.antigravity_cached"),age:h,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(B,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(B,{label:r("limits.label.antigravity_cached"),age:X(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(B,{label:r("limits.label.antigravity_cached"),age:X(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const p=a.provenance;return p?.stale&&!u&&(u=e.jsx(B,{label:r("limits.provenance.stale"),age:X(p.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:p.source,confidence:p.confidence})})),Pa(t,a,m,i,s,n,u,o,l,c)}function Ma({defaultDir:t}){const[a,i]=g.useState(!1),n=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${t||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
4
- `),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:r("limits.copilot.otelHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug",children:r("limits.copilot.otelHint.body")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:n}),e.jsx("button",{type:"button",onClick:o,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:a?r("limits.copilot.otelHint.copied"):r("limits.copilot.otelHint.copy")})]})}function D({n:t,children:a}){return e.jsxs("li",{className:"flex gap-2.5",children:[e.jsx("span",{className:"mt-[1px] flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-oai-brand/15 text-[9px] font-semibold text-oai-brand",children:t}),e.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:a})]})}function Se(){return e.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",className:"h-2.5 w-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M4.5 2.75h4.75V7.5M9.25 2.75 3 9"})})}function Pe({provider:t,onSaved:a}){const[i,s]=g.useState(""),[n,o]=g.useState("idle"),[l,c]=g.useState(!1),d=async m=>{m.preventDefault(),m.stopPropagation();const u=i.trim();if(!(!u||n==="saving")){o("saving"),c(!1);try{await wt(t,u),s(""),o("saved"),a?.()}catch{o("idle"),c(!0)}}};return e.jsxs("form",{className:"mt-1.5 space-y-1.5",onSubmit:d,onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"password",value:i,onChange:m=>{s(m.target.value),o("idle"),c(!1)},placeholder:r("limits.apiKey.placeholder"),"aria-label":r("limits.apiKey.placeholder"),autoComplete:"new-password",spellCheck:!1,className:"min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-white px-2 py-1 font-mono text-[11px] text-oai-gray-800 outline-none focus:border-oai-brand dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-100"}),e.jsx("button",{type:"submit",disabled:!i.trim()||n==="saving",className:"shrink-0 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 disabled:opacity-50 transition-colors",children:n==="saving"?r("limits.apiKey.saving"):n==="saved"?r("limits.apiKey.saved"):r("limits.apiKey.save")})]}),e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:l?r("limits.apiKey.save_failed"):r("limits.apiKey.local_note")})]})}function Da({providerId:t,data:a,onSaved:i}){if(a?.credential_source!=="env")return null;const s=ua[t],n=ma[t];return!s||!n?null:e.jsxs("div",{className:"mt-1.5 rounded-md border border-amber-300/60 bg-amber-50/60 px-2 py-1.5 text-[10.5px] leading-snug text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",children:[e.jsx("div",{children:r("limits.apiKey.env_note",{env:s})}),e.jsx(Pe,{provider:n,onSaved:i}),it()==="macos"?e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.jsx("code",{className:"rounded bg-white/70 px-1 py-0.5 font-mono text-[10px] dark:bg-oai-gray-900/60",children:r("limits.apiKey.env_unset_command",{env:s})}),e.jsx("span",{children:r("limits.apiKey.env_unset_note")})]}):null]})}function I({title:t,children:a}){return e.jsxs("div",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",onClick:i=>i.stopPropagation(),onKeyDown:i=>i.stopPropagation(),children:[e.jsx("div",{className:"font-medium text-oai-gray-800 dark:text-oai-gray-100",children:t}),a]})}function Oe({onSaved:t}){return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.opencodeGo.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),e.jsx(Se,{})]})]}),e.jsx(D,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(D,{n:"3",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step3")}),e.jsx(Pe,{provider:"opencode-go",onSaved:t})]})]})]})}function Fe({onSaved:t}){const a=nt();return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.commandCode.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:a})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step2")}),e.jsx(Pe,{provider:"command-code",onSaved:t})]})]})]})}function Le(){const t=st();return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.devin.setupHint.subtitle")}),e.jsx("ol",{className:"mt-2.5 space-y-2.5",children:e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.devin.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:t}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.devin.setupHint.note")})]})})]})}function $e(){const[t,a]=g.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
5
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.codingPlan.setupHint.cta"),e.jsx(Se,{})]})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.step2_remote")})]}),e.jsxs(D,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.codingPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.codingPlan.setupHint.copied"):r("limits.codingPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codingPlan.setupHint.note_app")})]})]})]})}function ze(){const[t,a]=g.useState(!1),i=[r("limits.agentPlan.setupHint.snippet_install"),r("limits.agentPlan.setupHint.snippet_login"),r("limits.agentPlan.setupHint.snippet_status")].join(`
6
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.agentPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.agentPlan.setupHint.cta"),e.jsx(Se,{})]})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.agentPlan.setupHint.step2_remote")})]}),e.jsxs(D,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.agentPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.agentPlan.setupHint.copied"):r("limits.agentPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.agentPlan.setupHint.note_app")})]})]})]})}function Ce(t){const[a,i]=g.useState(0);return g.useLayoutEffect(()=>{const s=t.current;if(!s)return;const n=[...s.querySelectorAll("[data-limit-label]")].filter(d=>d.closest("[data-limit-label-group]")===s);let o=0,l=null;if(n.length>0)try{l=document.createElement("canvas").getContext("2d")}catch{l=null}if(l){const d=window.getComputedStyle(n[0]);l.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`;for(const m of n)o=Math.max(o,l.measureText(m.textContent).width)}const c=Math.ceil(o);i(d=>d===c?d:c)}),a}function Ea({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:u,commandCode:p,qoder:h,qoderCn:y,codingPlan:b,agentPlan:v,devin:w,workbuddy:M,workbuddyAi:S,order:k,visibility:E,displayMode:H,subscriptions:O=[],showSubscriptions:K=!0,onProviderKeySaved:F=null}){const me={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:u,commandCode:p,qoder:h,qoderCn:y,codingPlan:b,agentPlan:v,devin:w,workbuddy:M,workbuddyAi:S},q=g.useRef(null),L=Ce(q),[ae,xe]=g.useState(null),[V,pe]=g.useState(()=>Date.now()),ge=[...new Set(Array.isArray(k)&&k.length>0?k:ya)],re=H===_.REMAINING?_.REMAINING:_.USED;g.useEffect(()=>{const j=setInterval(()=>pe(Date.now()),6e4);return()=>clearInterval(j)},[]);const R=new Map;if(K)for(const j of O||[]){if(!j?.provider)continue;const T=new Date(j.nextBillingAt).getTime();if(!Number.isFinite(T))continue;const Y=R.get(j.provider);if(!Y){R.set(j.provider,j);continue}const x=new Date(Y.nextBillingAt).getTime(),N=T>V,f=x>V;(N&&(!f||x>T)||!N&&!f&&T>x)&&R.set(j.provider,j)}const ie=ge.filter(j=>!E||E[j]!==!1||R.has(j)).map(j=>Ca(j,me[j],re,ae===j,()=>xe(T=>T===j?null:j),R.get(j)||null,V,F)).filter(Boolean);return e.jsx(Ft,{delay:.15,children:e.jsx("div",{ref:q,"data-limit-label-group":"",className:"flex flex-col gap-3",style:L>0?{"--tt-limits-label-w":`${L}px`}:void 0,children:ie.length>0?ie:e.jsx(A,{children:r("limits.status.all_hidden")})})})}async function bt(t){const a=await t.json().catch(()=>null);if(!t.ok||a?.ok===!1)throw new Error(a?.error||`Subscription request failed with HTTP ${t.status}`);return a}async function Ra(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await bt(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function Me(t){const a=await Nt();return bt(await fetch("/functions/tokentracker-subscription-manager",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function Ta(t){return Me({action:"create",subscription:t})}function Ia(t,a){return Me({action:"update",id:t,subscription:a})}function Aa(t){return Me({action:"delete",id:t})}const be={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function Ha(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const i=s=>String(s).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())}T${i(a.getHours())}:${i(a.getMinutes())}`}function Oa({subscriptions:t,onChanged:a}){const[i,s]=g.useState(!1),[n,o]=g.useState(null),[l,c]=g.useState(be),[d,m]=g.useState(!1),[u,p]=g.useState(!1),[h,y]=g.useState(!1),[b,v]=g.useState(!1),[w,M]=g.useState(null),[S,k]=g.useState(!1),[E,H]=g.useState(!1),[O,K]=g.useState(null),[F,me]=g.useState(()=>Date.now()),q=g.useRef(null),L=z(),ae=g.useMemo(()=>new Intl.DateTimeFormat(L,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[L]);g.useEffect(()=>{const x=setInterval(()=>me(Date.now()),6e4);return()=>clearInterval(x)},[]),g.useEffect(()=>{if(!i)return;const x=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;q.current?.scrollIntoView?.({behavior:x?"auto":"smooth",block:"nearest"})},[i,n]);const xe=g.useMemo(()=>We.map(x=>{const N=(t||[]).some(P=>P.provider===x&&P.id!==n),f=oe(x);return{value:x,label:N?`${f} ${r("subscriptions.form.provider_taken_suffix")}`:f,disabled:N}}),[L,t,n]),V=g.useMemo(()=>[{value:"weekly",label:r("subscriptions.form.cycle_weekly")},{value:"monthly",label:r("subscriptions.form.cycle_monthly")},{value:"yearly",label:r("subscriptions.form.cycle_yearly")}],[L]),pe=g.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[L]),ge=g.useCallback(()=>{c(be),o(null),p(!1),y(!1),v(!1),s(!0)},[]),re=g.useCallback(x=>{c({plan:x.plan||"",provider:x.provider||"",cycle:x.cycle||"monthly",autoRenew:x.autoRenew,startedAt:Ha(new Date(oa(x)).toISOString())}),o(x.id),p(!1),y(!1),v(!1),s(!0)},[]),R=g.useCallback(()=>{s(!1),o(null),c(be),p(!1),y(!1),v(!1)},[]),ie=g.useCallback(async x=>{if(x.preventDefault(),p(!1),!l.provider){y(!0);return}if((t||[]).some(U=>U.provider===l.provider&&U.id!==n)){v(!0);return}const f=new Date(l.startedAt).getTime();if(!Number.isFinite(f)){p(!0);return}const P={service:oe(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:f,nextBillingAt:at(f,l.cycle)};m(!0);try{n?await Ia(n,P):await Ta(P),R(),await a?.()}catch{p(!0)}finally{m(!1)}},[R,n,l,a,t]),j=g.useCallback(async()=>{if(w){k(!0),H(!1);try{await Aa(w.id),w.id===n&&R(),M(null),await a?.()}catch{H(!0)}finally{k(!1)}}},[R,n,a,w]),T=t||[],Y=()=>{const x=n?T.find(f=>f.id===n):null,N=x?le(x,F):null;return e.jsxs("form",{ref:q,onSubmit:ie,className:"grid grid-cols-1 gap-3 px-3 py-3 text-left sm:grid-cols-2",children:[e.jsx("div",{className:"flex items-center justify-between sm:col-span-2",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:n?r("subscriptions.edit"):r("subscriptions.add")})}),N?e.jsxs("div",{className:"sm:col-span-2 rounded-md bg-oai-gray-50 dark:bg-oai-gray-800/50 px-2.5 py-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:ae.format(new Date(N.endMs))})," · ",e.jsx("span",{className:N.expired?"text-oai-error":void 0,children:ve(N.endMs,F)})]}):null,e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-provider",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.provider")}),e.jsx(he,{id:"subscription-provider",value:l.provider,onValueChange:f=>c({...l,provider:String(f)}),options:xe,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(Re,{label:r("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:f=>c({...l,plan:f.target.value})})}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-cycle",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.cycle")}),e.jsx(he,{id:"subscription-cycle",value:l.cycle,onValueChange:f=>c({...l,cycle:String(f)}),options:V,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-auto-renew",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.auto_renew")}),e.jsx(he,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:f=>c({...l,autoRenew:f==="true"}),options:pe,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(Re,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:f=>c({...l,startedAt:f.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[n?e.jsx(Z,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const f=T.find(P=>P.id===n);f&&M(f)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,h?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,b?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,u?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(Z,{type:"button",variant:"secondary",size:"sm",onClick:R,children:r("shared.action.cancel")}),e.jsx(Z,{type:"submit",size:"sm",disabled:d,children:r("subscriptions.save")})]})]})};return e.jsxs("div",{className:"flex max-h-[min(80vh,42rem)] w-[min(92vw,32rem)] flex-col gap-3 overflow-y-auto rounded-xl border border-oai-gray-200 bg-white p-4 shadow-lg dark:border-oai-gray-700 dark:bg-oai-gray-900",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("span",{className:"block truncate text-sm font-semibold text-oai-black dark:text-white",children:r("limits.page.openSubscriptions")})}),e.jsxs(Z,{type:"button",size:"sm",onClick:ge,className:"shrink-0 gap-1.5",children:[e.jsx(Bt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),T.length===0&&!(i&&!n)?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-700",children:[e.jsx(Xe,{className:"h-6 w-6 text-oai-gray-300 dark:text-oai-gray-600 mb-2","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:r("subscriptions.empty.title")}),e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("subscriptions.empty.body")})]}):e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[T.map(x=>{const N=le(x,F);if(!N)return null;const{endMs:f,expired:P}=N,U=P?100:N.progress*100,yt=!P&&f-F<=3*864e5,vt=O===x.id;return e.jsxs("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button",onClick:()=>re(x),"aria-label":`${r("subscriptions.edit")} ${x.service}`,"aria-expanded":n===x.id,className:"w-full flex flex-col gap-1.5 px-3 py-2.5 text-left cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(qe,{provider:Ke(x.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:x.service}),e.jsx("span",{role:"img","aria-label":x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${x.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:x.autoRenew?e.jsx(et,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(ke,{size:14,strokeWidth:2,"aria-hidden":!0})}),x.plan?e.jsx("span",{className:"text-xs rounded-full border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-0.5 text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:x.plan}):null]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:r("subscriptions.inline.label")}),e.jsx("span",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1 overflow-hidden",children:e.jsx("span",{className:`${P?"bg-red-500":yt?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${U}%`,minWidth:U>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${P?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:rt(f,F)})]})]}),n===x.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:Y()}):null,n!==x.id&&vt?e.jsxs("div",{className:"px-3 pb-3 flex flex-col gap-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("p",{className:"pt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:ae.format(new Date(f))})," · ",e.jsx("span",{className:P?"text-oai-error":void 0,children:ve(f,F)})," · ",e.jsx("span",{children:x.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Z,{type:"button",variant:"secondary",size:"sm",onClick:()=>re(x),children:r("subscriptions.edit")})})]}):null]},x.id)}),i&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:Y()}):null]}),e.jsx(zt,{open:!!w,title:r("subscriptions.confirm_delete_title"),description:w?.service||"",error:E?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:S,onCancel:()=>{M(null),H(!1)},onConfirm:j})]})}const Ue=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Fa="x-apple.systempreferences:com.apple.preference.notifications";function Be(t){const a=Date.parse(t);return Number.isFinite(a)?new Intl.DateTimeFormat(z(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(a)):String(t)}function La(t){const a=Object.entries(t||{}).filter(([o,l])=>o!=="fetched_at"&&l&&typeof l=="object"&&l.configured!==!1),i=a.filter(([,o])=>!!o.error),s=a.some(([,o])=>!!o.start_plan?.error||!!o.reset_credits?.error),n=a.filter(([,o])=>o.provenance?.stale===!0||o.provenance?.source==="disk-cache");return a.length&&i.length===0&&!s&&n.length===a.length?{kind:"stale"}:i.length||n.length||s?{kind:"partial",at:t.fetched_at}:{kind:"updated",at:t.fetched_at}}function $a(){const t=Yt(),a=Dt(),i=r("limits.alert.blocked"),s=a?Ee.button:Ee.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>Et({type:"action",name:"openURL",value:Fa}):void 0,initial:t?!1:{opacity:0,x:14,scale:.9},animate:{opacity:1,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:18},title:i,className:`relative hidden sm:inline-flex min-w-0 max-w-[360px] items-center gap-1.5 rounded-full border border-amber-300/70 bg-amber-50 px-3 py-1.5 text-xs text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300 ${a?"cursor-pointer transition-colors hover:bg-amber-100 dark:hover:bg-amber-500/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/60":""}`,children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"truncate",children:i}),e.jsx("span",{"aria-hidden":!0,className:"absolute left-full top-1/2 -translate-y-1/2 border-[5px] border-transparent border-l-amber-300/80 dark:border-l-amber-500/40"})]})}function xr(){const t=_t(),{data:a,error:i,isLoading:s,refresh:n}=It(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),o=Ot(),l=At(),[c,d]=C.useState([]),[m,u]=C.useState(!1),[p,h]=C.useState(!1),[y]=St(),b=C.useRef(0),v=C.useRef(!1),[w,M]=C.useState(!1),[S,k]=C.useState(null),E=C.useCallback(async()=>{if(!v.current){v.current=!0,M(!0),k(null);try{const O=await n();k(O?La(O):{kind:"failed"})}finally{v.current=!1,M(!1)}}},[n]),H=C.useCallback(async()=>{if(!Ue&&!De())return;const O=++b.current;try{const K=await Ra();if(O!==b.current)return;d(K),u(!1)}catch{if(O!==b.current)return;u(!0)}},[]);return C.useEffect(()=>{H()},[H]),C.useEffect(()=>{y.get("openSubscriptions")==="1"&&h(!0)},[y]),C.useEffect(()=>{l.enabled&&a&&Ht(a)},[l.enabled,a]),!Ue&&!De()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Ut,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-6 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 sm:mb-8 sm:gap-x-4 sm:gap-y-3",children:[e.jsx("h1",{className:"min-w-0 text-2xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white",children:r("nav.limits")}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[l.enabled&&l.permissionBlocked?e.jsx($a,{}):null,e.jsx("button",{type:"button",onClick:()=>{E()},disabled:w,"aria-label":r("limits.page.refresh"),title:r("limits.page.refresh"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm:w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50",children:e.jsx(Pt,{className:`h-4 w-4 ${w?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(Gt,{open:p,onOpenChange:h,children:[e.jsx(Wt,{"aria-label":r("limits.page.openSubscriptions"),title:r("limits.page.openSubscriptions"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm:w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(Xe,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Kt,{children:e.jsx(qt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Vt,{children:e.jsx(Oa,{subscriptions:c,onChanged:H})})})})]}),e.jsx("button",{type:"button",onClick:()=>{l.setEnabled(!l.enabled)},"aria-label":l.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:l.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:`inline-flex h-10 w-10 sm:h-9 sm:w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 ${l.enabled&&l.permissionBlocked?"text-amber-600 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"}`,children:l.enabled?e.jsx(Xt,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Zt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Ct,{to:"/settings?section=limits","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm:w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(Mt,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsx("p",{className:"col-span-2 hidden sm:block sm:text-base text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.page.subtitle")})]}),e.jsx("span",{role:"status",className:"sr-only",children:w?r("limits.page.refresh_loading"):""}),S?.kind==="updated"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-emerald-700 dark:text-emerald-300",children:r("limits.page.refreshed_at",{time:Be(S.at)})}):null,S?.kind==="partial"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_partial",{time:Be(S.at)})}):null,S?.kind==="stale"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_stale")}):null,S?.kind==="failed"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_failed")}):null,s?e.jsx(ta,{}):e.jsxs(e.Fragment,{children:[i?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:i}):null,m?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(Ea,{claude:a?.claude,codex:a?.codex,cursor:a?.cursor,gemini:a?.gemini,kimi:a?.kimi,kiro:a?.kiro,grok:a?.grok,antigravity:a?.antigravity,copilot:a?.copilot,zcode:a?.zcode,opencodeGo:a?.opencodeGo,commandCode:a?.commandCode,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,agentPlan:a?.agentPlan,devin:a?.devin,workbuddy:a?.workbuddy,workbuddyAi:a?.workbuddyAi,order:o.order,visibility:o.visibility,displayMode:o.displayMode,subscriptions:c,showSubscriptions:o.showSubscriptions!==!1,onProviderKeySaved:()=>{n()}})]})]})})})}export{xr as LimitsPage};
@@ -1 +0,0 @@
1
- import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-D_cMeuqI.js";import{P as f}from"./ProviderIcon-DOPj7tAZ.js";import{E as w}from"./external-link-DCTXF5VZ.js";const x=[{id:"claude",name:"Claude",icon:"CLAUDE",apiUrl:"https://status.claude.com/api/v2/status.json",pageUrl:"https://status.claude.com"},{id:"openai",name:"OpenAI / Codex",icon:"CODEX",apiUrl:"https://status.openai.com/api/v2/status.json",pageUrl:"https://status.openai.com"},{id:"cursor",name:"Cursor",icon:"CURSOR",apiUrl:"https://status.cursor.com/api/v2/status.json",pageUrl:"https://status.cursor.com"},{id:"github",name:"GitHub / Copilot",icon:"GITHUB",apiUrl:"https://www.githubstatus.com/api/v2/status.json",pageUrl:"https://www.githubstatus.com"},{id:"gemini",name:"Gemini",icon:"GEMINI",kind:"google",serviceName:"Gemini",apiUrl:"https://www.google.com/appsstatus/dashboard/incidents.json",pageUrl:"https://www.google.com/appsstatus/dashboard"},{id:"kimi",name:"Kimi / Moonshot",icon:"KIMI",apiUrl:"https://status.moonshot.cn/api/v2/status.json",pageUrl:"https://status.moonshot.cn"},{id:"minimax",name:"MiniMax",icon:"MINIMAX",apiUrl:"https://status.minimaxi.com/api/v2/status.json",pageUrl:"https://status.minimaxi.com"},{id:"zed",name:"Zed",icon:"ZED",kind:"instatus",apiUrl:"https://status.zed.dev/summary.json",pageUrl:"https://status.zed.dev"},{id:"devin",name:"Devin / Cognition",icon:"DEVIN",apiUrl:"https://www.devinstatus.com/api/v2/status.json",pageUrl:"https://www.devinstatus.com"},{id:"factory",name:"Factory / Droid",icon:"DROID",apiUrl:"https://status.factory.ai/api/v2/status.json",pageUrl:"https://status.factory.ai"}],b=6e4,y=8e3,j=new Set(["none","minor","major","critical"]),g={none:{dot:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-400"},minor:{dot:"bg-yellow-500",text:"text-yellow-600 dark:text-yellow-400"},major:{dot:"bg-orange-500",text:"text-orange-600 dark:text-orange-400"},critical:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400"},unknown:{dot:"bg-oai-gray-400",text:"text-oai-gray-500 dark:text-oai-gray-400"}};function v(e){switch(e){case"none":return n("status.state.none");case"minor":return n("status.state.minor");case"major":return n("status.state.major");case"critical":return n("status.state.critical");default:return n("status.state.unknown")}}const k={low:"minor",medium:"major",high:"critical"},N={MAJOROUTAGE:"critical",PARTIALOUTAGE:"major",DEGRADEDPERFORMANCE:"minor"};function A(e){const a=e?.page?.status;if(typeof a!="string")throw new Error("Unexpected payload");if(a==="UP")return{indicator:"none",description:"",updatedAt:null};const s=Array.isArray(e?.activeIncidents)?e.activeIncidents:[],r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=N[i?.impact]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i?.name||"",updatedAt:i?.updated||null})}return o||{indicator:"minor",description:"",updatedAt:null}}function U(e,a){if(!Array.isArray(e))throw new Error("Unexpected payload");const s=e.filter(i=>i&&!i.end&&(i.service_name===a||Array.isArray(i.affected_products)&&i.affected_products.some(c=>c?.title===a)));if(s.length===0)return{indicator:"none",description:"",updatedAt:null};const r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=k[i.severity]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i.external_desc||"",updatedAt:i.modified||null})}return o}async function I(e){try{const a=await fetch(e.apiUrl,{cache:"no-store",signal:AbortSignal.timeout(y)});if(!a.ok)throw new Error(`HTTP ${a.status}`);const s=await a.json();if(e.kind==="google")return U(s,e.serviceName);if(e.kind==="instatus")return A(s);const r=s?.status?.indicator;if(!j.has(r))throw new Error("Unexpected payload");return{indicator:r,description:typeof s?.status?.description=="string"?s.status.description:"",updatedAt:typeof s?.page?.updated_at=="string"?s.page.updated_at:null}}catch{return{indicator:"unknown",description:"",updatedAt:null}}}function E({provider:e,result:a}){const s=g[a?.indicator]||g.unknown,r=a==null;return t.jsxs("a",{href:e.pageUrl,target:"_blank",rel:"noreferrer","aria-label":n("status.open_page",{provider:e.name}),title:n("status.open_page",{provider:e.name}),className:"group block no-underline text-inherit rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4 sm:p-5 transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(f,{provider:e.icon,size:20}),t.jsx("span",{className:"font-medium text-sm sm:text-base truncate",children:e.name})]}),t.jsx("span",{"aria-hidden":!0,className:"shrink-0 inline-flex h-8 w-8 items-center justify-center rounded-lg text-oai-gray-400 transition-colors group-hover:text-oai-black dark:group-hover:text-white",children:t.jsx(w,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[r?t.jsx("span",{className:"h-2 w-2 rounded-full bg-oai-gray-300 dark:bg-oai-gray-700 animate-pulse","aria-hidden":!0}):t.jsxs("span",{className:"relative flex h-2 w-2","aria-hidden":!0,children:[a.indicator!=="none"&&a.indicator!=="unknown"?t.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75 ${s.dot}`}):null,t.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${s.dot}`})]}),t.jsx("span",{className:`text-sm font-medium ${r?"text-oai-gray-400":s.text}`,children:r?n("status.state.checking"):v(a.indicator)})]}),!r&&a.description&&a.indicator!=="none"?t.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400 break-words",children:a.description}):null]})}function T(){const[e,a]=d.useState({}),[s,r]=d.useState(null),[o,i]=d.useState(!1),c=d.useRef(!0),u=d.useCallback(async()=>{i(!0);const l=await Promise.all(x.map(async p=>[p.id,await I(p)]));c.current&&(a(Object.fromEntries(l)),r(new Date),i(!1))},[]);d.useEffect(()=>{c.current=!0,u();const l=setInterval(()=>{u()},b);return()=>{c.current=!1,clearInterval(l)}},[u]);const m=d.useMemo(()=>s?n("status.last_checked",{time:s.toLocaleTimeString()}):null,[s]);return t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:t.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[t.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:n("nav.service_status")}),t.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:n("status.page.subtitle")})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[m?t.jsx("span",{className:"hidden sm:inline text-xs text-oai-gray-400 dark:text-oai-gray-500",children:m}):null,t.jsx("button",{type:"button",onClick:()=>{u()},disabled:o,"aria-label":n("status.refresh"),title:n("status.refresh"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50",children:t.jsx(h,{className:`h-4 w-4 ${o?"animate-spin":""}`,"aria-hidden":!0})})]})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:x.map(l=>t.jsx(E,{provider:l,result:e[l.id]??null},l.id))}),t.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:n("status.page.source_note")})]})})})}export{x as STATUS_PROVIDERS,T as ServiceStatusPage,T as default};
@@ -1,3 +0,0 @@
1
- import{o as Oe,r as i,j as e,y as P,c as t,Z as Ee,X as $e,i as N,aA as je,W as Ne,R as cs,V as _e,aN as ds,bl as J}from"./__vite-browser-external-D_cMeuqI.js";import{L as us,I as ms}from"./LocalOnlyNotice-B2lVqf_H.js";import{S as le}from"./Select-D-38tN-E.js";import{C as xs}from"./chevron-down-BzGTlk0-.js";import{S as Pe}from"./search-aHrmBmtZ.js";import{C as hs}from"./check--EZH8RTp.js";import{P as gs,a as ps,b as fs,c as bs,d as ys}from"./PopoverPopup-Gja4MyEK.js";import{P as Ae}from"./ProviderIcon-DOPj7tAZ.js";import{H as _s}from"./HoverTooltip-lRDaUmoW.js";import{u as we}from"./useCurrency-DilqL2Iv.js";import{i as ks}from"./host-mode-Bc_iTzHk.js";import{I as js}from"./info-B4YzRR4y.js";import{C as ws}from"./copy-BtucSK2U.js";import{a as vs,b as Ns,c as Ss,d as Cs,e as Ts}from"./TooltipPopup-3E8kyVzz.js";import"./arrow-up-right-B7ah6Qv-.js";import"./download-CWHq03Y2.js";import"./SelectItemText-jN61ukxk.js";import"./composite-C0KrmLEK.js";import"./usePositioner-BcnySw8a.js";import"./store-Cq30Pofw.js";import"./safePolygon-BUGWIDOM.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 Ds=Oe(qe);const ze={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"}]]};ze.node;const Ms=Oe(ze),Ls="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 Se({options:a,value:s,onChange:r,allValue:o="all",allLabel:u,searchPlaceholder:m,emptyLabel:n,ariaLabel:f,disabled:k=!1,className:j=""}){const[w,v]=i.useState(!1),[h,g]=i.useState(""),[b,y]=i.useState(-1),F=i.useRef(null),S=`${i.useId()}-listbox`,q=s===o?u:a.find(p=>p.value===s)?.label??s,T=h.trim().toLowerCase(),M=i.useMemo(()=>T?a.filter(p=>p.label.toLowerCase().includes(T)):a,[a,T]),C=i.useMemo(()=>[{value:o,label:u},...M],[o,u,M]),O=b>=0&&b<C.length?C[b]:null,z=p=>{r(p),v(!1),g(""),y(-1)};i.useEffect(()=>{w&&F.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[w,b]);const ee=p=>{if(p.key==="ArrowDown"||p.key==="ArrowUp"){p.preventDefault();const D=p.key==="ArrowDown";y(R=>{const c=C.length;return c?D?R>=c-1?0:R+1:R<=0?c-1:R-1:-1});return}if(p.key==="Enter"){const D=O||(T&&M.length?M[0]:null);if(!D)return;p.preventDefault(),z(D.value)}};return e.jsxs(gs,{open:w,onOpenChange:p=>{v(p),y(-1),p||g("")},children:[e.jsxs(ps,{disabled:k,"aria-label":f,className:P("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",s!==o?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",j),children:[e.jsx(Ms,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:q}),e.jsx(xs,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(fs,{children:e.jsx(bs,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(ys,{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(Pe,{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":S,"aria-activedescendant":O?`${S}-${b}`:void 0,value:h,onChange:p=>{g(p.target.value),y(-1)},onKeyDown:ee,placeholder:m,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:F,id:S,role:"listbox","aria-label":f,className:"max-h-64 overflow-y-auto",children:[C.map((p,D)=>e.jsxs("button",{id:`${S}-${D}`,type:"button",role:"option","aria-selected":s===p.value,"data-active":D===b?"true":void 0,onMouseEnter:()=>y(D),onClick:()=>z(p.value),className:P(Ls,s===p.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",D===b&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:p.label}),s===p.value?e.jsx(hs,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},p.value)),M.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:n}):null]})]})})})]})}const Fs="tokentracker-sessions";async function Is(a={}){const s=new URL(`/functions/${Fs}`,window.location.origin);a.from&&s.searchParams.set("from",a.from),a.to&&s.searchParams.set("to",a.to),a.limit&&s.searchParams.set("limit",String(a.limit)),a.refresh&&s.searchParams.set("refresh","1");const r=await fetch(s.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),o=await r.json().catch(()=>null);if(!r.ok){const u=r.status===404?t("sessions.error.outdated_app"):`Request failed with HTTP ${r.status}`,m=new Error(o?.error||u);throw m.status=r.status,m}return o}function Ge(a,s,{timeOnly:r=!1}={}){if(!a)return"—";const o=Date.parse(a);if(!Number.isFinite(o))return"—";const u=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(s||void 0,u)}catch{const m=new Date(o).toISOString();return r?m.slice(11,16):m.slice(0,16).replace("T"," ")}}function Ke(a){const s=Number(a);if(!Number.isFinite(s)||s<=0)return null;const r=Math.round(s/6e4);if(r<60)return t("sessions.duration.minutes",{minutes:r});const o=Math.floor(r/60),u=r%60;return t("sessions.duration.hours",{hours:o,minutes:u})}function V(a){return $(a?.own_total_tokens??a?.total_tokens)}function Rs(a,s=0,r=1/0){if(!s&&r===1/0)return a;const o=a.map(n=>{if(!Array.isArray(n.usage_buckets))return{...n};const f=n.usage_buckets.filter(h=>{const g=Date.parse(h.timestamp);return g>=s&&g<=r}),k=new Map,j=Object.fromEntries([...de,...be].map(h=>[h,0]));let w=0,v=0;for(const h of f){w+=$(h.total_tokens),v+=$(h.cost_usd);const g=k.get(h.model)||{...(n.model_usage||[]).find(b=>b.model===h.model),model:h.model,...Object.fromEntries([...de,...be].map(b=>[b,0])),cost_usd:0,selected_models:[],reroute_reasons:[],model_attribution:"selected"};for(const b of[...de,...be]){const y=$(h[b]);j[b]+=y,g[b]+=y}g.cost_usd+=$(h.cost_usd);for(const b of["selected_models","reroute_reasons"])Array.isArray(h[b])&&(g[b]=[...new Set([...g[b],...h[b]])]);h.model_attribution==="effective"&&(g.model_attribution="effective"),k.set(h.model,g)}return{...n,...j,total_tokens:w,own_total_tokens:w,cost_usd:v,own_cost_usd:v,model_usage:[...k.values()]}}).filter(n=>!Array.isArray(n.usage_buckets)||V(n)>0),u=new Map;for(const n of o){if(!n.parent_session_hash)continue;const f=u.get(n.parent_session_hash)||[];f.push(n),u.set(n.parent_session_hash,f)}const m=(n,f=new Set)=>{if(f.has(n.session_hash))return{tokens:0,cost:0};const k=new Set(f).add(n.session_hash);let j=V(n),w=X(n);for(const v of u.get(n.session_hash)||[]){const h=m(v,k);j+=h.tokens,w+=h.cost}return{tokens:j,cost:w}};for(const n of o){const f=m(n);n.combined_total_tokens=f.tokens,n.combined_cost_usd=f.cost,n.subagent_total_tokens=f.tokens-V(n),n.subagent_cost_usd=f.cost-X(n)}return o}function X(a){return $(a?.own_cost_usd??a?.cost_usd)}function $(a){const s=Number(a);return Number.isFinite(s)&&s>=0?s:0}const de=["input_tokens","output_tokens","cached_input_tokens","cache_creation_input_tokens","reasoning_output_tokens","total_tokens"],be=["long_context_","priority_","priority_long_context_","ultrafast_","ultrafast_long_context_"].flatMap(a=>de.filter(s=>s!=="total_tokens").map(s=>a+s));function Z(a){const s=Array.isArray(a?.model_usage)?a.model_usage.filter(r=>r&&typeof r.model=="string"&&r.model):[];return s.length?s:[{model:a?.model||"",total_tokens:V(a),cost_usd:X(a),performance:a?.performance}]}function Os(a){const s={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 u=$(o.estimated_duration_ms),m=$(o.estimated_output_tokens),n=$(o.estimated_request_count);u>0&&m>0&&n>0&&(s.estimated_output_tokens+=m,s.estimated_duration_ms+=u,s.estimated_request_count+=n);const f=$(o.first_response_sample_count),k=$(o.first_response_total_ms);f>0&&k>0&&(s.first_response_total_ms+=k,s.first_response_sample_count+=f)}return s.estimated_duration_ms>0&&(s.estimated_tokens_per_second=s.estimated_output_tokens*1e3/s.estimated_duration_ms),s.first_response_sample_count>0&&(s.first_response_ms=s.first_response_total_ms/s.first_response_sample_count),s}function Ue(a){const s=new Set,r=a.filter(o=>s.has(o.session_hash)?!1:(s.add(o.session_hash),!0));return{count:r.length,tokens:r.reduce((o,u)=>o+V(u),0),cost:r.reduce((o,u)=>o+X(u),0),costIsPartial:r.some(o=>o.cost_is_partial),performance:Os(r)}}function ke(a){const s=Date.parse(a?.ended_at||a?.started_at||"");return Number.isFinite(s)?s:0}function Es(a,s){return[...a].sort((r,o)=>(s==="cost"?X(o)-X(r):s==="tokens"?V(o)-V(r):0)||ke(o)-ke(r))}function ue(a){const s=ke(a);if(!s)return"";const r=new Date(s);return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function $s(a,s){const r=new Map;for(const o of a){const u=s==="project"?o.project_key||"":ue(o),m=r.get(u)||{key:u,sessions:[]};m.sessions.push(o),r.set(u,m)}return[...r.values()]}function Ps(a){const s=new URLSearchParams(a),r=s.get("source"),o=n=>{const f=s.get(n)||"";if(!/^\d{4}-\d{2}-\d{2}$/.test(f))return"";const k=new Date(`${f}T00:00:00`);return Number.isFinite(k.getTime())&&ue({ended_at:k.toISOString()})===f?f:""},u=o("from"),m=o("to");return{source:["claude","codex","grok","zcode","opencode","kimi","omp","dsh"].includes(r)?r:"all",model:s.get("model")||"all",from:u,to:m}}function As(a,s,r){let o=s?new Date(`${s}T00:00:00`).getTime():0,u=r?new Date(`${r}T23:59:59.999`).getTime():1/0;o>u&&(o=new Date(`${r}T00:00:00`).getTime(),u=new Date(`${s}T23:59:59.999`).getTime());const m=Date.parse(a.ended_at||a.started_at||""),n=Date.parse(a.started_at||a.ended_at||"");return(!Number.isFinite(m)||m>=o)&&(!Number.isFinite(n)||n<=u)}function re({performance:a,className:s=""}){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:s,title:`${t("sessions.performance.samples",{count:o})}
2
- ${t("sessions.performance.method")}`,children:t("sessions.performance.speed",{speed:Number(r.toFixed(1))})})}const qs=[{key:"input_tokens",label:()=>t("dashboard.projects.detail.comp_input")},{key:"cached_input_tokens",label:()=>t("dashboard.projects.detail.comp_cached")},{key:"cache_creation_input_tokens",label:()=>t("dashboard.projects.detail.comp_cache_write")},{key:"output_tokens",label:()=>t("dashboard.projects.detail.comp_output")},{key:"reasoning_output_tokens",label:()=>t("dashboard.projects.detail.comp_reasoning")}],zs=[{key:"turns",label:()=>t("sessions.col.turns")},{key:"edit_turns",label:()=>t("sessions.col.edits")},{key:"retry_turns",label:()=>t("sessions.detail.retries")},{key:"subagent_calls",label:()=>t("sessions.card.subagents")},{key:"tool_calls",grokOnly:!0,label:()=>t("sessions.detail.tools")},{key:"tool_failures",grokOnly:!0,label:()=>t("sessions.detail.tool_failures")},{key:"error_count",grokOnly:!0,label:()=>t("sessions.detail.errors")},{key:"model_calls",grokOnly:!0,label:()=>t("sessions.detail.model_calls")},{key:"compaction_count",grokOnly:!0,label:()=>t("sessions.detail.compactions")}];function Gs(a){return a==="provider_reported"?t("sessions.detail.cost_reported"):a==="model_pricing"?t("sessions.detail.cost_estimated"):a==="mixed"?t("sessions.detail.cost_mixed"):t("sessions.detail.cost_unknown")}function Ce(a){return String(a||"").startsWith("litellm")?t("sessions.detail.pricing_litellm"):String(a||"").startsWith("curated")?t("sessions.detail.pricing_curated"):null}function Ks(a,s){return s||Number(a)>0}function Te({label:a,children:s}){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:s})]})}function ce({label:a,title:s,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:s,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 Us({session:a,subagents:s=[],onClose:r}){const o=i.useRef(null),u=i.useRef(null),{currency:m,rate:n}=we(),{resolvedLocale:f}=Ee(),k=c=>je(c,{currency:m,rate:n}),j=Z(a),w=i.useMemo(()=>Ue(s),[s]),v=V(a),h=X(a),g=Number(a.subagent_total_tokens??w.tokens),b=Number(a.subagent_cost_usd??w.cost),y=a.performance,F=Number(y?.estimated_tokens_per_second)>0&&Number(y?.estimated_request_count)>0,S=Number(y?.first_response_sample_count)>0&&y?.first_response_ms!=null&&Number.isFinite(Number(y.first_response_ms)),q=S?{seconds:(Number(y.first_response_ms)/1e3).toFixed(2),count:y.first_response_sample_count}:null,T=Number(a.reasoning_output_tokens)>0,M=a.source==="grok",C=M&&Number(a.context_window_tokens)>0;i.useEffect(()=>{const c=document.activeElement,E=document.body.style.overflow;document.body.style.overflow="hidden",o.current?.focus();const A=I=>{if(I.key==="Escape"&&(I.preventDefault(),r()),I.key!=="Tab")return;const K=Array.from(u.current?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), summary, [tabindex="0"]')||[]),se=K[0],te=K[K.length-1];se?I.shiftKey&&(document.activeElement===se||!u.current?.contains(document.activeElement))?(I.preventDefault(),te.focus()):!I.shiftKey&&(document.activeElement===te||!u.current?.contains(document.activeElement))&&(I.preventDefault(),se.focus()):(I.preventDefault(),u.current?.focus())};return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A),document.body.style.overflow=E,c instanceof HTMLElement&&c.isConnected&&c.focus()}},[r]);const O=g>0||b>0,z=a.cost_is_partial||O&&w.costIsPartial,ee=[{label:t("sessions.detail.own"),tokens:v,cost:h,partial:a.cost_is_partial},{label:t("sessions.detail.subagents"),tokens:g,cost:b,partial:w.costIsPartial}],p=a.agent_nickname||a.title||a.project_key||t("sessions.project.unknown"),D=Ke(a.duration_ms),R=[a.project_key&&a.project_key!==p?a.project_key:null,Ge(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:c=>{c.target===c.currentTarget&&r()},children:e.jsxs("div",{ref:u,role:"dialog","aria-modal":"true","aria-label":t("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:p}),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":t("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($e,{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":t("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(ce,{label:t("sessions.col.tokens"),children:N(v+g)}),e.jsxs(ce,{label:t("sessions.col.cost"),className:"border-l",children:[z?"≥":"",k(h+b)]}),e.jsx(ce,{label:t("sessions.summary.speed"),className:"border-t",title:F?t("sessions.performance.samples",{count:y.estimated_request_count}):t("sessions.detail.no_speed"),children:F?e.jsx(re,{performance:y}):"—"}),e.jsx(ce,{label:t("sessions.performance.first_response"),className:"border-l border-t",title:t("sessions.performance.first_response_method"),children:S?Number(y.first_response_sample_count)===1?t("sessions.performance.first_response_value_single",q):t("sessions.performance.first_response_value",q):"—"})]}),O?e.jsx("dl",{className:"mt-3 space-y-1.5",children:ee.map(c=>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:c.label}),e.jsx("dd",{className:"text-right tabular-nums",children:N(c.tokens)}),e.jsxs("dd",{className:"text-right tabular-nums",children:[c.partial?"≥":"",k(c.cost)]})]},c.label))}):null,e.jsxs("p",{className:"mt-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:[t("sessions.detail.cost_source")," · ",Gs(a.cost_source),a.cost_is_partial?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",t("sessions.cost.partial_title")]}):null,a.usage_is_incomplete?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",t("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:t("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:qs.map(({key:c,label:E})=>e.jsx(Te,{label:E(),children:a[c]==null?"—":N(a[c])},c))})]}),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:t("sessions.detail.models")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:t("sessions.col.tokens")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:t("sessions.col.cost")})]}),e.jsx("ul",{className:"mt-1 divide-y divide-oai-gray-100 dark:divide-oai-gray-800/70",children:j.map(c=>{const E=c.pricing?.status==="unpriced",A=a.cost_source==="provider_reported"&&j.length===1,I=A?h:c.cost_usd,K=Ks(I,A);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:c.model||t("sessions.model.unknown")}),e.jsx("span",{className:"text-right tabular-nums",children:N(c.total_tokens)}),e.jsx("span",{className:"text-right tabular-nums",children:E&&!K?"—":k(I)})]}),c.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(re,{performance:c.performance,className:"tabular-nums"}),e.jsx("span",{className:"underline decoration-dotted underline-offset-4 group-open:no-underline",children:t("sessions.detail.pricing_details")})]}),e.jsxs("div",{className:"space-y-1 pt-1.5 leading-5",children:[E?e.jsx("p",{children:t("sessions.detail.pricing_unpriced")}):null,c.pricing.status==="free"?e.jsx("p",{children:t("sessions.detail.pricing_free")}):null,c.pricing.status==="priced"?e.jsx("p",{children:t("sessions.detail.pricing_rates",{input:c.pricing.input,output:c.pricing.output,cacheRead:c.pricing.cache_read,cacheWrite:c.pricing.cache_write})}):null,Ce(c.pricing.source)?e.jsx("p",{children:Ce(c.pricing.source)}):null]})]}):e.jsx(re,{performance:c.performance,className:"block pt-1 text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400"})]},c.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:t("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:zs.map(({key:c,label:E,grokOnly:A})=>e.jsx(Te,{label:E(),children:typeof a[c]=="number"&&(!A||M)?N(a[c]):t("sessions.detail.not_recorded")},c))}),M&&a.usage_precision?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.grok.runtime_breakdown",{calls:N(a.model_calls),seconds:(Number(a.api_duration_ms||0)/1e3).toFixed(1),tools:N(a.tool_calls),errors:N(a.error_count)})}):null,C?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.grok.context_breakdown",{used:N(a.context_tokens_used),window:N(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:t("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:t("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:t("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:t("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:[F?e.jsx("p",{children:t("sessions.performance.method")}):null,T?e.jsx("p",{children:t("sessions.detail.reasoning_note")}):null,e.jsx("p",{children:t("sessions.privacy")})]})]})]})})}const De=ks(),Me=[],ye=100,Ws=[{id:"all",label:()=>t("usage.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"opencode",label:()=>"OpenCode"},{id:"grok",label:()=>"Grok"},{id:"zcode",label:()=>"ZCode"},{id:"kimi",label:()=>t("leaderboard.column.kimi")},{id:"omp",label:()=>"oh-my-pi"},{id:"dsh",label:()=>t("provider.display.deepseek_harness")}],We=[{id:"all",days:0,label:()=>t("sessions.filter.range_label_all")},{id:"7d",days:7,label:()=>t("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>t("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>t("sessions.filter.range_90d")}];function Le(a){const s=We.find(o=>o.id===a)?.days||0;if(!s)return 0;const r=new Date;return r.setDate(r.getDate()-(s-1)),r.setHours(0,0,0,0),r.getTime()}function Hs(a,s){if(!s)return!0;const r=Date.parse(a.ended_at||a.started_at||"");return Number.isFinite(r)?r>=s:!0}function Vs(a){const s=Date.parse(a.started_at||"");return!Number.isFinite(s)||ue({started_at:a.started_at})===ue(a)}function Fe(a){const s=Z(a);return s.length===1?s[0].model||t("sessions.model.unknown"):s.map(r=>`${r.model} ${N(Number(r.total_tokens||0))}`).join(" · ")}async function Ie(a){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(a),!0;const s=document.createElement("textarea");s.value=a,s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s),s.select();const r=document.execCommand("copy");return document.body.removeChild(s),r}function Bs(){const[a,s]=i.useState(!1),r=i.useId();return e.jsxs(vs,{open:a,onOpenChange:s,children:[e.jsx(Ns,{delay:150,closeDelay:100,closeOnClick:!1,onClick:()=>s(!0),"aria-label":t("sessions.summary.scope_help"),"aria-describedby":a?r:void 0,className:"sessions-summary-help relative inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white before:absolute before:-inset-2 before:content-['']",children:e.jsx(js,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx(Ss,{children:e.jsx(Cs,{side:"bottom",align:"end",sideOffset:12,className:"z-[60]",children:e.jsx(Ts,{id:r,role:"tooltip",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:t("sessions.summary.scope")})})})]})}function L({className:a}){return e.jsx("span",{className:P("block rounded bg-oai-gray-200/70 animate-pulse dark:bg-oai-gray-800/70",a),"aria-hidden":"true"})}function Qs({index:a}){const s=["w-44","w-32","w-52","w-36","w-48","w-40"],r=["w-24","w-32","w-20"];return e.jsxs("li",{className:"sessions-row sessions-row-grid py-3","aria-hidden":"true",children:[e.jsxs("div",{className:"sessions-row-identity min-w-0",children:[e.jsx(L,{className:"h-4 w-4 rounded-full"}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx(L,{className:P("h-4",s[a%s.length])}),e.jsx("div",{className:"flex min-w-0 flex-wrap gap-2",children:r.map((o,u)=>e.jsx(L,{className:P("h-3",o)},u))})]})]}),e.jsxs("dl",{className:"sessions-row-metrics",children:[e.jsx("div",{className:"sessions-row-value",children:e.jsx(L,{className:"ml-auto h-4 w-14"})}),e.jsx("div",{className:"sessions-row-value",children:e.jsx(L,{className:"ml-auto h-4 w-12"})}),e.jsx("div",{className:"sessions-row-value",children:e.jsx(L,{className:"ml-auto h-4 w-16"})})]}),e.jsx(L,{className:"sessions-row-action h-8 w-8 rounded-md"})]})}function Zs({rows:a=6}){return e.jsxs("div",{"data-testid":"sessions-skeleton",role:"status","aria-busy":"true","aria-live":"polite",children:[e.jsx("span",{className:"sr-only",children:t("sessions.loading")}),e.jsx("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","aria-hidden":"true",children:e.jsx("dl",{className:"sessions-kpis grid min-w-0 flex-1 grid-cols-2 gap-y-3 sm:grid-cols-4",children:Array.from({length:4},(s,r)=>e.jsxs("div",{children:[e.jsx(L,{className:"h-3 w-16"}),e.jsx(L,{className:P("mt-2 h-6",r===2?"w-20":"w-14")})]},r))})}),e.jsxs("div",{className:"sessions-row-grid sessions-list-header border-b border-oai-gray-200 py-2 dark:border-oai-gray-800","aria-hidden":"true",children:[e.jsx(L,{className:"h-3 w-16"}),e.jsx(L,{className:"ml-auto h-3 w-10"}),e.jsx(L,{className:"ml-auto h-3 w-9"}),e.jsx(L,{className:"ml-auto h-3 w-10"}),e.jsx("span",{})]}),e.jsxs("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800","aria-hidden":"true",children:[e.jsx("li",{className:"pb-2 pt-5",children:e.jsx(L,{className:"h-3 w-24"})}),Array.from({length:a},(s,r)=>e.jsx(Qs,{index:r},r))]})]})}const Re=_e.memo(function({session:s,locale:r,nested:o=!1,timeOnly:u=!1,childCount:m=0,expanded:n=!1,onToggle:f,onDetail:k}){const{currency:j,rate:w}=we(),v=String(s.source||"").toUpperCase(),h=Ke(s.duration_ms),g=s.resume_command,b=s.project_key||t("sessions.project.unknown"),y=o||s.thread_kind==="subagent",F=y?s.agent_nickname||s.agent_role||s.title||b:s.title||b,S=s.usage_is_incomplete?t("sessions.badge.partial_usage"):s.cost_is_partial?t("sessions.badge.partial_cost"):null,q=s.project_ref?`${s.project_ref}
3
- ${t("sessions.project.copy_hint")}`:void 0,T=async()=>{if(s.project_ref)try{await Ie(s.project_ref)?J({title:t("sessions.project.copied")}):J({title:t("sessions.project.copy_failed")})}catch{J({title:t("sessions.project.copy_failed")})}},M=O=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(_s,{text:q,placement:"bottom"}),e.jsx("button",{type:"button",onClick:T,"aria-label":t("sessions.project.copy_aria",{project:b}),className:P("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:b})]}),C=async()=>{if(g)try{await Ie(g)?J({title:t("sessions.resume.copied")}):J({title:t("sessions.resume.copy_failed")})}catch{J({title:t("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:P("sessions-row sessions-row-grid py-3",o&&"sessions-row-nested"),children:[e.jsxs("div",{className:"sessions-row-identity min-w-0",children:[e.jsx("span",{className:"sessions-row-provider inline-flex items-center justify-center text-oai-gray-600 dark:text-oai-gray-300","aria-hidden":"true",children:e.jsx(Ae,{provider:v,size:o?16:18})}),e.jsxs("div",{className:"contents",children:[e.jsx("button",{type:"button",onClick:()=>k(s),"aria-label":t("sessions.detail.open_aria",{title:F}),title:F,className:"sessions-row-title block min-h-9 min-w-0 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-5",children:F}),e.jsxs("div",{className:"sessions-row-meta 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:s.project_ref?M("min-h-6 inline-flex items-center md:min-h-0"):e.jsx("span",{className:"truncate",children:b})}),e.jsx("span",{className:"sessions-meta-item min-w-0 max-w-full truncate",title:Fe(s),children:Fe(s)}),e.jsx("span",{className:"sessions-meta-item tabular-nums",children:Ge(s.started_at,r,{timeOnly:u&&Vs(s)})}),h?e.jsx("span",{className:"sessions-meta-item tabular-nums",children:h}):null,Number.isFinite(s.session_store_bytes)?e.jsx("span",{className:"sessions-meta-item tabular-nums",title:t("sessions.storage.tooltip",{metric:t(s.session_store_metric==="allocated"?"sessions.storage.allocated":"sessions.storage.logical"),ratio:Math.round(s.bytes_per_1k_tokens||0).toLocaleString(r)}),children:t("sessions.storage.label",{size:t("sessions.storage.size",{value:(s.session_store_bytes/1024/1024).toLocaleString(r,{maximumFractionDigits:2})})})}):null,y?e.jsxs("span",{className:"sessions-meta-item",children:[t("sessions.badge.subagent"),s.agent_role?` · ${s.agent_role}`:""]}):null,s.first_pass?e.jsx("span",{className:"sessions-meta-item text-emerald-700 dark:text-emerald-300",children:t("sessions.badge.first_pass")}):null,S?e.jsx("span",{className:"sessions-meta-item text-amber-700 dark:text-amber-300",children:S}):null,s.cost_source==="provider_reported"?e.jsx("span",{className:"sessions-meta-item",children:t("sessions.badge.reported_cost")}):null,m?e.jsxs("button",{type:"button",onClick:()=>f(s.session_hash),"aria-expanded":n,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:P("h-3.5 w-3.5 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),n?t("sessions.thread.collapse",{count:m}):t("sessions.thread.expand",{count:m})]}):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:t("sessions.col.tokens")}),e.jsxs("dd",{title:Number(s.subagent_total_tokens)?t("sessions.thread.tokens_summary",{own:N(s.own_total_tokens),subagents:N(s.subagent_total_tokens),combined:N(s.combined_total_tokens)}):void 0,className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",children:[N(s.total_tokens),Number(s.subagent_total_tokens)?e.jsxs("span",{className:"mt-0.5 block text-xs text-oai-gray-500 dark:text-oai-gray-400",children:["Σ ",N(s.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:t("sessions.col.cost")}),e.jsxs("dd",{className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",title:s.cost_is_partial?t("sessions.cost.partial_title"):void 0,children:[s.cost_is_partial?"≥":"",je(s.cost_usd,{currency:j,rate:w})]})]}),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:t("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(re,{performance:s.performance})})]})]}),e.jsx("button",{type:"button",onClick:C,disabled:!g,title:g||t("sessions.resume.unavailable"),"aria-label":g?t("sessions.resume.copy_aria",{command:g}):t("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(ws,{className:"h-4 w-4","aria-hidden":!0})})]})});function Xs({sessions:a,selectedModel:s,onSelect:r}){const{groups:o,totalTokens:u}=i.useMemo(()=>{const n=new Map;let f=0;for(const k of a)for(const j of Z(k)){const w=j.model||t("sessions.model.unknown"),v=Number(j.total_tokens||0),h=n.get(w)||{model:w,count:0,tokens:0};h.count+=1,h.tokens+=v,f+=v,n.set(w,h)}return{groups:[...n.values()].sort((k,j)=>j.tokens-k.tokens),totalTokens:f}},[a]);function m(n){return P("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",n?"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:t("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":s==="all",onClick:()=>r("all"),className:m(s==="all"),children:t("sessions.thread.model_all",{count:a.length,tokens:N(u)})}),o.map(n=>e.jsx("button",{type:"button","aria-pressed":s===n.model,onClick:()=>r(n.model),className:m(s===n.model),children:t("sessions.thread.model_item",{model:n.model,count:n.count,tokens:N(n.tokens)})},n.model))]})})}function yt(){const[a]=i.useState(()=>Ps(window.location.search)),[s,r]=i.useState(null),[o,u]=i.useState(null),[m,n]=i.useState(!0),[f,k]=i.useState(!1),[j,w]=i.useState(a.source),[v,h]=i.useState(a.model),[g,b]=i.useState(a.from||a.to?"custom":"all"),[y,F]=i.useState(a.from),[S,q]=i.useState(a.to),[T,M]=i.useState("all"),[C,O]=i.useState("time"),[z,ee]=i.useState("recent"),[p,D]=i.useState(null),[R,c]=i.useState(""),[E,A]=i.useState(ye),[I,K]=i.useState(()=>new Set),[se,te]=i.useState(()=>new Map),oe=i.useRef(0),{resolvedLocale:B}=Ee(),{currency:He,rate:Ve}=we(),ne=i.useCallback(async(l=!1)=>{const x=++oe.current;l?k(!0):n(!0),u(null);try{const d=await Is({refresh:l});x===oe.current&&r(d)}catch(d){x===oe.current&&u(d?.message||String(d))}finally{x===oe.current&&(n(!1),k(!1))}},[]);i.useEffect(()=>{De||Ne()?ne(!1):n(!1)},[ne]);const U=s?.sessions||Me,Be=i.useMemo(()=>{const l=new Set,x=[];for(const d of U){const _=d.project_key;!_||l.has(_)||(l.add(_),x.push({value:_,label:_}))}return x.sort((d,_)=>d.label.localeCompare(_.label))},[U]),Qe=i.useMemo(()=>{const l=new Set;for(const x of U)for(const d of Z(x))d.model&&l.add(d.model);return[...l].sort().map(x=>({value:x,label:x}))},[U]),me=i.useDeferredValue(R),ie=i.useMemo(()=>{let x=Le(g),d=1/0;return g==="custom"&&(x=y?new Date(`${y}T00:00:00`).getTime():0,d=S?new Date(`${S}T23:59:59.999`).getTime():1/0,x>d&&(x=new Date(`${S}T00:00:00`).getTime(),d=new Date(`${y}T23:59:59.999`).getTime())),Rs(U,x,d)},[U,g,y,S]),W=i.useMemo(()=>{const l=me.trim().toLowerCase(),x=Le(g);return ie.filter(d=>{if(j!=="all"&&d.source!==j||T!=="all"&&d.project_key!==T||v!=="all"&&!Z(d).some(H=>H.model===v))return!1;if(g==="custom"){if(!As(d,y,S))return!1}else if(!Hs(d,x))return!1;if(!l)return!0;const _=Z(d).map(H=>H.model).join(" ");return`${d.title||""} ${d.project_key||""} ${_} ${d.agent_nickname||""} ${d.agent_role||""} ${d.project_ref||""} ${d.session_id||""}`.toLowerCase().includes(l)})},[ie,j,T,v,g,y,S,me]),Y=i.useMemo(()=>Ue(W),[W]),Q=i.useMemo(()=>{const l=new Set(W.map(_=>_.session_hash)),x=new Map,d=[];for(const _ of Es(W,z)){const G=_.root_session_hash||_.parent_session_hash;if(_.parent_session_hash&&G&&l.has(G)){const H=x.get(G)||[];H.push(_),x.set(G,H)}else d.push(_)}return{roots:d,childrenByRoot:x,foldedCount:W.length-d.length}},[W,z]),xe=j!=="all"||v!=="all"||g!=="all"||T!=="all"||R.trim()!=="";i.useEffect(()=>{A(ye),K(new Set),te(new Map)},[j,T,v,g,y,S,me,z,C,U]);const he=i.useMemo(()=>Q.roots.slice(0,E),[Q.roots,E]),Ze=i.useMemo(()=>$s(he,C),[he,C]),Xe=i.useMemo(()=>p?ie.filter(l=>l.session_hash!==p.session_hash&&(l.root_session_hash===p.session_hash||l.parent_session_hash===p.session_hash)):Me,[ie,p]),Ye=i.useCallback(()=>D(null),[]),ge=i.useCallback(l=>{b(l),l!=="custom"&&(F(""),q(""))},[]),Je=i.useCallback(()=>{w("all"),h("all"),M("all"),c(""),ge("all")},[ge]),pe=Q.roots.length>he.length,fe=i.useCallback(()=>A(l=>l+ye),[]),es=i.useCallback(l=>{K(x=>{const d=new Set(x);return d.has(l)?d.delete(l):d.add(l),d})},[]),ss=i.useCallback((l,x)=>{te(d=>{const _=new Map(d);return x==="all"?_.delete(l):_.set(l,x),_})},[]),ve=i.useRef(null);i.useEffect(()=>{if(!pe||typeof IntersectionObserver>"u")return;const l=ve.current;if(!l)return;const x=new IntersectionObserver(d=>{d.some(_=>_.isIntersecting)&&fe()},{rootMargin:"400px"});return x.observe(l),()=>x.disconnect()},[pe,fe]);const ts=i.useMemo(()=>Ws.map(l=>({value:l.id,label:l.label()})),[B]),as=i.useMemo(()=>[...We.map(l=>({value:l.id,label:l.label()})),{value:"custom",label:t("sessions.filter.range_custom")}],[B]),rs=i.useMemo(()=>[{value:"time",label:t("sessions.group.time")},{value:"project",label:t("sessions.group.project")}],[B]),os=i.useMemo(()=>[{value:"recent",label:t("sessions.sort.recent")},{value:"cost",label:t("sessions.sort.cost")},{value:"tokens",label:t("sessions.sort.tokens")}],[B]),ns=Number(s?.session_count)>Number(s?.returned_count);return!De&&!Ne()?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:t("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:t("sessions.page.summary")})]}),e.jsx("button",{type:"button",onClick:()=>{ne(!0)},disabled:f||m,"aria-label":t("sessions.page.refresh"),title:t("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:P("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(Pe,{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:l=>c(l.target.value),onKeyDown:l=>{l.key==="Escape"&&R&&(l.preventDefault(),c(""))},"aria-label":t("sessions.action.search_aria"),placeholder:t("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:l=>l.preventDefault(),onClick:()=>c(""),"aria-label":t("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($e,{className:"h-4 w-4","aria-hidden":!0})}):null]}),e.jsx(le,{ariaLabel:t("sessions.filter.source_aria"),options:ts,value:j,onValueChange:w,className:"sessions-filter-trigger h-11 min-w-0 px-3 text-sm sm:h-9",matchTriggerWidth:!0}),e.jsx(le,{ariaLabel:t("sessions.filter.range_aria"),options:as,value:g,onValueChange:ge,leadingIcon:e.jsx(Ds,{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(Se,{options:Be,value:T,onChange:M,allLabel:t("sessions.filter.project_all"),searchPlaceholder:t("sessions.filter.project_search"),emptyLabel:t("sessions.filter.project_empty"),ariaLabel:t("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(Se,{options:Qe,value:v,onChange:h,allLabel:t("sessions.filter.model_all"),searchPlaceholder:t("sessions.filter.model_search"),emptyLabel:t("sessions.filter.model_empty"),ariaLabel:t("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"})]}),g==="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:t("sessions.filter.from")}),e.jsx("input",{type:"date","aria-label":t("sessions.filter.from"),value:y,onChange:l=>F(l.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:t("sessions.filter.to")}),e.jsx("input",{type:"date","aria-label":t("sessions.filter.to"),value:S,onChange:l=>q(l.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]}),!m&&s?e.jsx("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:t("sessions.summary.count")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:N(Y.count)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.col.tokens")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:N(Y.tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.col.cost")}),e.jsxs("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:[Y.costIsPartial?"≥":"",je(Y.cost,{currency:He,rate:Ve})]})]}),e.jsxs("div",{children:[e.jsxs("dt",{className:"flex items-center gap-1.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:t("sessions.summary.speed")}),e.jsx(Bs,{})]}),e.jsxs("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:[e.jsx(re,{performance:Y.performance}),Y.performance.estimated_tokens_per_second==null?"—":null]})]})]})}):null,!m&&s?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:Q.foldedCount>0?t("sessions.thread.result_count",{roots:Q.roots.length,subagents:Q.foldedCount}):t("sessions.filter.result_count",{filtered:W.length,total:U.length})}),xe?e.jsx("button",{type:"button",onClick:Je,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:t("sessions.filter.clear")}):null]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(le,{ariaLabel:t("sessions.group.aria"),options:rs,value:C,onValueChange:O,className:"sessions-filter-trigger h-11 min-w-0 max-w-40 px-2.5 text-xs sm:h-8"}),e.jsx(le,{ariaLabel:t("sessions.sort.aria"),options:os,value:z,onValueChange:ee,className:"sessions-filter-trigger h-11 min-w-0 max-w-44 px-2.5 text-xs sm:h-8",align:"end"})]})]}):null,!m&&ns?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.truncated",{shown:s.returned_count,total:s.session_count})}):null,o&&!s?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:t("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:()=>{ne(!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:t("sessions.error.retry")})]}):m?e.jsx(Zs,{}):W.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:xe?t("sessions.empty.filtered_title"):t("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:xe?t("sessions.empty.filtered_body"):t("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:t("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:t("sessions.col.session")}),e.jsx("span",{className:"text-right",children:t("sessions.col.tokens")}),e.jsx("span",{className:"text-right",children:t("sessions.col.cost")}),e.jsx("span",{className:"text-right",children:t("sessions.col.speed")}),e.jsx("span",{className:"sr-only",children:t("sessions.col.actions")})]}),e.jsx("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:Ze.map(l=>e.jsxs(_e.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:C==="project"?l.key||t("sessions.project.unknown"):l.key?new Date(`${l.key}T12:00:00`).toLocaleDateString(B||void 0,{year:"numeric",month:"short",day:"numeric"}):t("sessions.group.unknown_date")})}),l.sessions.map(x=>{const d=Q.childrenByRoot.get(x.session_hash)||[],_=I.has(x.session_hash),G=se.get(x.session_hash)||"all",H=G==="all"?d:d.filter(function(is){return Z(is).some(ls=>ls.model===G)});return e.jsxs(_e.Fragment,{children:[e.jsx(Re,{session:x,locale:B,timeOnly:C==="time",childCount:d.length,expanded:_,onToggle:es,onDetail:D}),_&&d.length?e.jsx(Xs,{sessions:d,selectedModel:G,onSelect:ae=>ss(x.session_hash,ae)}):null,_?H.map(ae=>e.jsx(Re,{session:ae,locale:B,nested:!0,timeOnly:C==="time",onDetail:D},ae.session_hash)):null]},x.session_hash)})]},l.key))}),pe?e.jsx("div",{ref:ve,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:fe,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:t("sessions.action.load_more")})}):null]}),m?null:e.jsx("p",{className:"mt-8 max-w-3xl text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:t("sessions.privacy")})]})}),p?e.jsx(Us,{session:p,subagents:Xe,onClose:Ye}):null]})}export{yt as SessionsPage};