tokentracker-cli 0.95.2 → 0.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-DtB1MwFe.js → AchievementBadge-Bb2ljquW.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage--vddu0dC.js → AchievementsPage-ByUP2x8a.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-CDl9hsbj.js → AchievementsSection-_L6sCLTw.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-C7WsIRy9.js → BadgeDetailModal-B9n_-45B.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-CmXyzIhX.js → BotAnimated-lWmg-aZg.js} +1 -1
  6. package/dashboard/dist/assets/{Card-SUbC3VNS.js → Card-aSp259T0.js} +1 -1
  7. package/dashboard/dist/assets/{ClawdAnimated-BdEbs8Me.js → ClawdAnimated-Cy-XaTXW.js} +2 -2
  8. package/dashboard/dist/assets/{CommandPalette-D1RLLeHB.js → CommandPalette-CNwtKCUm.js} +1 -1
  9. package/dashboard/dist/assets/{CommunityStatsModal-5ESGJgZQ.js → CommunityStatsModal-DJSezaPV.js} +1 -1
  10. package/dashboard/dist/assets/{ConfirmModal-DsCd51b2.js → ConfirmModal-CVjmhZd6.js} +1 -1
  11. package/dashboard/dist/assets/{Controls-BVrLC_QD.js → Controls-BIj6yVxE.js} +1 -1
  12. package/dashboard/dist/assets/{DashboardPage-DtUOG6og.js → DashboardPage-BjYZLmqQ.js} +1 -1
  13. package/dashboard/dist/assets/{DevicePage-zYjj-m5V.js → DevicePage-ptsI2fZc.js} +1 -1
  14. package/dashboard/dist/assets/{DialogClose-D66yBqkd.js → DialogClose-D1pLoZ56.js} +1 -1
  15. package/dashboard/dist/assets/DialogDescription-KY7X94CG.js +1 -0
  16. package/dashboard/dist/assets/{DialogTitle-C4ia00lc.js → DialogTitle-DfSBUjWf.js} +1 -1
  17. package/dashboard/dist/assets/{FadeIn-DF2c8XaR.js → FadeIn-DBn4L_BV.js} +1 -1
  18. package/dashboard/dist/assets/{HeaderGithubStar-Cnr3aqcX.js → HeaderGithubStar-EJLBwEqp.js} +1 -1
  19. package/dashboard/dist/assets/{HoverTooltip-DBOpxlH7.js → HoverTooltip-DaSrZhYd.js} +1 -1
  20. package/dashboard/dist/assets/{IpCheckPage-CUY6KBaV.js → IpCheckPage-diQTVaYt.js} +1 -1
  21. package/dashboard/dist/assets/{LandingPage-DKL8hZEq.js → LandingPage-BqCxjwar.js} +2 -2
  22. package/dashboard/dist/assets/{LeaderboardAvatar-DRYeMNlq.js → LeaderboardAvatar-CQImCsPN.js} +1 -1
  23. package/dashboard/dist/assets/{LeaderboardPage-DpD9Az3k.js → LeaderboardPage-D2ZDUi_O.js} +2 -2
  24. package/dashboard/dist/assets/{LeaderboardProfileModal-Dfg0V13F.js → LeaderboardProfileModal-DHvADX1d.js} +3 -3
  25. package/dashboard/dist/assets/{LeaderboardProfilePage-DH-jcVDu.js → LeaderboardProfilePage-CJsedB28.js} +1 -1
  26. package/dashboard/dist/assets/LimitsPage-CAwff24b.js +6 -0
  27. package/dashboard/dist/assets/{LocalOnlyNotice-Bj_m0hw7.js → LocalOnlyNotice-Cmnvu9tI.js} +1 -1
  28. package/dashboard/dist/assets/{LoginCard-BVKvtx60.js → LoginCard-BQmKkD7X.js} +1 -1
  29. package/dashboard/dist/assets/{LoginModal-mUGiSIJN.js → LoginModal-2oPROePZ.js} +1 -1
  30. package/dashboard/dist/assets/{LoginPage-BORCuCUt.js → LoginPage-aqdUJoQK.js} +1 -1
  31. package/dashboard/dist/assets/{PetPage-D1JfEOVA.js → PetPage-Bn3p_o5r.js} +1 -1
  32. package/dashboard/dist/assets/{PopoverPopup-DK3et-HG.js → PopoverPopup-DXD_YdiB.js} +1 -1
  33. package/dashboard/dist/assets/{ProviderIcon-By8FAjxR.js → ProviderIcon-BZZ45-gY.js} +1 -1
  34. package/dashboard/dist/assets/{ResetPasswordPage-DPa81jqa.js → ResetPasswordPage-Bn5ITiHQ.js} +1 -1
  35. package/dashboard/dist/assets/{SegmentedControl-DLzS-2eZ.js → SegmentedControl-hGXboQZy.js} +1 -1
  36. package/dashboard/dist/assets/{Select-C05W6XEM.js → Select-BP8aVRZ1.js} +1 -1
  37. package/dashboard/dist/assets/{SelectItemText-CcfB3blP.js → SelectItemText-Odx47kND.js} +1 -1
  38. package/dashboard/dist/assets/{ServiceStatusPage-ByqLbHv1.js → ServiceStatusPage-DUueam0N.js} +1 -1
  39. package/dashboard/dist/assets/SessionsPage-BA9IFqQ1.js +2 -0
  40. package/dashboard/dist/assets/{SettingsPage-DAcndJZQ.js → SettingsPage-DLOHHB4f.js} +2 -2
  41. package/dashboard/dist/assets/{SkillsPage-BuuqQuNU.js → SkillsPage-Ds2vH_PG.js} +1 -1
  42. package/dashboard/dist/assets/{TokenGalaxy-DzccxkXW.js → TokenGalaxy-CWBR4jnB.js} +1 -1
  43. package/dashboard/dist/assets/{ToolbarRootContext-XUDMp5uy.js → ToolbarRootContext-Bmg56vYz.js} +1 -1
  44. package/dashboard/dist/assets/{TrendMonitor-B-yYabbz.js → TrendMonitor-BQzcllvg.js} +1 -1
  45. package/dashboard/dist/assets/{WidgetsPage-CwUDjEFo.js → WidgetsPage-Bu3tHDjO.js} +1 -1
  46. package/dashboard/dist/assets/{WrappedPage-Dr9ow3gH.js → WrappedPage-BrAMJhgy.js} +1 -1
  47. package/dashboard/dist/assets/{__vite-browser-external-DPOlUkcY.js → __vite-browser-external-4IGm4Djn.js} +12 -12
  48. package/dashboard/dist/assets/{agent-logos-Cqc_suYk.js → agent-logos-B8lT-HcI.js} +1 -1
  49. package/dashboard/dist/assets/{arrow-up-right-DSsR3Ntr.js → arrow-up-right-rpBCOTg2.js} +1 -1
  50. package/dashboard/dist/assets/{check-Cy35lAKh.js → check-DIKw7TYH.js} +1 -1
  51. package/dashboard/dist/assets/{composite-BDwOlhhX.js → composite-_NeXO0lv.js} +1 -1
  52. package/dashboard/dist/assets/{copy-4szu5cYh.js → copy-CsfAtL7P.js} +1 -1
  53. package/dashboard/dist/assets/{download-DdGW6Krz.js → download-DM1W9pIW.js} +1 -1
  54. package/dashboard/dist/assets/{external-link-DwSt83cq.js → external-link-CwbuMbeQ.js} +1 -1
  55. package/dashboard/dist/assets/{flame-DubukWqK.js → flame-DcYbLdhE.js} +1 -1
  56. package/dashboard/dist/assets/{format-tokens-B70EdQcN.js → format-tokens-CEvr3dNy.js} +1 -1
  57. package/dashboard/dist/assets/{icons-B86TLdAj.js → icons-DaGMVsJ5.js} +1 -1
  58. package/dashboard/dist/assets/{index-B_KMoBeK.js → index-BVVLPj3N.js} +1 -1
  59. package/dashboard/dist/assets/{index-DI-W-pun.js → index-ChZkJjpk.js} +1 -1
  60. package/dashboard/dist/assets/{index-DzEMcUwI.js → index-T7OjmEuX.js} +1 -1
  61. package/dashboard/dist/assets/{info-BzFpLbl6.js → info-CAjN3dX4.js} +1 -1
  62. package/dashboard/dist/assets/limits-providers-jn7Yln_V.js +1 -0
  63. package/dashboard/dist/assets/{link-2-BQp7-3T7.js → link-2-DaWH2Tyc.js} +1 -1
  64. package/dashboard/dist/assets/{loader-circle-lrDmbIg5.js → loader-circle-CnF8qPi1.js} +1 -1
  65. package/dashboard/dist/assets/{maximize-2-Cnd_Oth8.js → maximize-2-B-2Pnj6g.js} +1 -1
  66. package/dashboard/dist/assets/{modifiers.esm-CPTpZdHU.js → modifiers.esm-BoDOvUKl.js} +1 -1
  67. package/dashboard/dist/assets/{monitor-smartphone-C7UY1zRx.js → monitor-smartphone-DDgwxG_E.js} +1 -1
  68. package/dashboard/dist/assets/{plus-Bglp9N_7.js → plus-DIc1YUWB.js} +1 -1
  69. package/dashboard/dist/assets/{provider-display-CGsFySs6.js → provider-display-yeNsVCO_.js} +1 -1
  70. package/dashboard/dist/assets/{react-DKXriBSF.js → react-DZqS6YTX.js} +1 -1
  71. package/dashboard/dist/assets/{search-D_LLDRdU.js → search-D6tEppYJ.js} +1 -1
  72. package/dashboard/dist/assets/{skills-api-CJWjKIco.js → skills-api-vsA1rc1Z.js} +1 -1
  73. package/dashboard/dist/assets/{sortable.esm-zlY09tye.js → sortable.esm-DDCnS1HI.js} +1 -1
  74. package/dashboard/dist/assets/{store-8e16Ac2h.js → store-Crne4DqF.js} +1 -1
  75. package/dashboard/dist/assets/{terminal-CR228ekj.js → terminal-Ca7dkLMF.js} +1 -1
  76. package/dashboard/dist/assets/{trash-2-BjLWewOp.js → trash-2-CjEAS5ic.js} +1 -1
  77. package/dashboard/dist/assets/{use-community-stats-DhOJPaVg.js → use-community-stats-BHx2YxyK.js} +1 -1
  78. package/dashboard/dist/assets/{use-latest-request-guard-lcGhb-NC.js → use-latest-request-guard-BLGbXQdf.js} +1 -1
  79. package/dashboard/dist/assets/{use-limits-display-prefs-DJIImtLN.js → use-limits-display-prefs-DBkAp6ob.js} +1 -1
  80. package/dashboard/dist/assets/{use-ordered-list-BJZfZuoJ.js → use-ordered-list-BTfW5M9u.js} +1 -1
  81. package/dashboard/dist/assets/use-reduced-motion-D_kUnDs4.js +1 -0
  82. package/dashboard/dist/assets/{use-session-efficiency-pref-C-l4b1cD.js → use-session-efficiency-pref-DBmd-MqH.js} +1 -1
  83. package/dashboard/dist/assets/{use-transform-UjIt477N.js → use-transform-Bp5XrwaQ.js} +1 -1
  84. package/dashboard/dist/assets/{use-usage-limits-DqoTZrqT.js → use-usage-limits-BmqRcyhH.js} +1 -1
  85. package/dashboard/dist/assets/{useCurrency-CnM8aB4v.js → useCurrency-B0YsRDj-.js} +1 -1
  86. package/dashboard/dist/assets/{useTokenFormat-D4pAK2ld.js → useTokenFormat-PP3D0Ket.js} +1 -1
  87. package/dashboard/dist/assets/{zap-Du1IyEtj.js → zap-BVOm1aBH.js} +1 -1
  88. package/dashboard/dist/index.html +1 -1
  89. package/dashboard/dist/ip-check.html +1 -1
  90. package/dashboard/dist/leaderboard.html +1 -1
  91. package/dashboard/dist/share.html +1 -1
  92. package/package.json +1 -1
  93. package/src/lib/ark-agent-plan-limits.js +437 -0
  94. package/src/lib/ark-coding-plan-limits.js +104 -27
  95. package/src/lib/codex-model-attribution.js +128 -0
  96. package/src/lib/codex-rollout-parser.js +98 -4
  97. package/src/lib/pricing/curated-overrides.json +6 -6
  98. package/src/lib/pricing/index.js +38 -1
  99. package/src/lib/pricing/seed-snapshot.json +1 -1
  100. package/src/lib/rollout.js +50 -9
  101. package/src/lib/session-analytics.js +374 -110
  102. package/src/lib/usage-limits.js +19 -5
  103. package/dashboard/dist/assets/DialogDescription-BVlaoajd.js +0 -1
  104. package/dashboard/dist/assets/LimitsPage-CVCKPScf.js +0 -5
  105. package/dashboard/dist/assets/SessionsPage-CEDv1thj.js +0 -2
  106. package/dashboard/dist/assets/limits-providers-DxZOjiXQ.js +0 -1
  107. package/dashboard/dist/assets/use-reduced-motion-DdpxZQoh.js +0 -1
@@ -32,6 +32,7 @@ const { fetchZcodeLimits } = require("./zcode-limits");
32
32
  const { fetchOpencodeGoLimits } = require("./opencode-go-limits");
33
33
  const { fetchQoderLimits, fetchQoderCnLimits } = require("./qoder-limits");
34
34
  const { fetchArkCodingPlanLimits } = require("./ark-coding-plan-limits");
35
+ const { fetchArkAgentPlanLimits } = require("./ark-agent-plan-limits");
35
36
  const { fetchProviderServiceStatus } = require("./provider-status");
36
37
  const { readSqliteJsonRows, readSqliteJsonRowsAsync } = require("./sqlite-reader");
37
38
  const {
@@ -3619,7 +3620,7 @@ async function fetchUsageLimitsUncached({
3619
3620
  : null;
3620
3621
 
3621
3622
  const providerFetch = withFetchTimeout(fetchImpl, providerTimeoutMs);
3622
- const [claudeResult, codexResult, cursor, kimi, gemini, kiro, antigravity, copilot, grok, zcode, opencodeGoRaw, qoder, qoderCn, codingPlan, claudeServiceStatus] = await Promise.all([
3623
+ const [claudeResult, codexResult, cursor, kimi, gemini, kiro, antigravity, copilot, grok, zcode, opencodeGoRaw, qoder, qoderCn, codingPlan, agentPlan, claudeServiceStatus] = await Promise.all([
3623
3624
  claudeToken && !freshClaudeCache && !claudeRetryAtMs
3624
3625
  ? withProviderTimeout(fetchClaudeUsageLimits(claudeToken, { fetchImpl: providerFetch, maxAttempts: 1 }), "Claude", providerTimeoutMs).then(
3625
3626
  (value) => ({ status: "fulfilled", value }),
@@ -3692,10 +3693,10 @@ async function fetchUsageLimitsUncached({
3692
3693
  "Qoder CN",
3693
3694
  providerTimeoutMs,
3694
3695
  ).catch((reason) => ({ configured: true, error: reason?.message || "Unknown error" })),
3695
- // Ark Coding Plan (火山方舟): subscription quota via the user's own
3696
- // arkcli binary. No token-consumption source — consumption for the
3697
- // compatible CLIs is already counted from their local files; this only
3698
- // surfaces the 5h/week/month quota percentages.
3696
+ // Ark Coding Plan / Agent Plan (火山方舟): two parallel subscription
3697
+ // products sharing the same arkcli binary. No token-consumption source —
3698
+ // consumption for the compatible CLIs is already counted from their
3699
+ // local files; these only surface the 5h/week/month quota percentages.
3699
3700
  withAbortableProviderTimeout(
3700
3701
  (signal) => fetchArkCodingPlanLimits({
3701
3702
  commandRunner,
@@ -3708,6 +3709,18 @@ async function fetchUsageLimitsUncached({
3708
3709
  "Ark Coding Plan",
3709
3710
  providerTimeoutMs,
3710
3711
  ).catch((reason) => ({ configured: true, error: reason?.message || "Unknown error" })),
3712
+ withAbortableProviderTimeout(
3713
+ (signal) => fetchArkAgentPlanLimits({
3714
+ commandRunner,
3715
+ home,
3716
+ nowMs,
3717
+ platform,
3718
+ signal,
3719
+ providerTimeoutMs,
3720
+ }),
3721
+ "Ark Agent Plan",
3722
+ providerTimeoutMs,
3723
+ ).catch((reason) => ({ configured: true, error: reason?.message || "Unknown error" })),
3711
3724
  // Public status-page probe (fail-soft, own 5-min cache in provider-status.js).
3712
3725
  // Only probed for configured accounts — without a token the Claude section
3713
3726
  // never renders, so the reading would have nowhere to go.
@@ -3904,6 +3917,7 @@ async function fetchUsageLimitsUncached({
3904
3917
  qoder: withPlanLabel(qoder, qoder?.plan_label, "Qoder"),
3905
3918
  qoderCn: withPlanLabel(qoderCn, qoderCn?.plan_label, "Qoder CN"),
3906
3919
  codingPlan: withPlanLabel(codingPlan, codingPlan?.plan_label, "Ark Coding Plan"),
3920
+ agentPlan: withPlanLabel(agentPlan, agentPlan?.plan_label, "Ark Agent Plan"),
3907
3921
  };
3908
3922
 
3909
3923
  for (const [providerName, provider] of Object.entries(data)) {
@@ -1 +0,0 @@
1
- import{r as n,z as a}from"./__vite-browser-external-DPOlUkcY.js";import{u as p}from"./DialogTitle-C4ia00lc.js";import{u as c}from"./composite-BDwOlhhX.js";const x=n.forwardRef(function(e,r){const{render:l,className:u,style:m,id:s,...t}=e,i=p(),o=c(s);return i.useSyncedValueWithCleanup("descriptionElementId",o),a("p",e,{ref:r,props:[{id:o},t]})});export{x as D};
@@ -1,5 +0,0 @@
1
- import{m as G,j as e,e as Se,c as i,k as re,r as x,Q as Xe,B as H,aw as Je,d as D,h as Qe,J as ye,L as Ze,ax as et,q as tt,ac as at}from"./__vite-browser-external-DPOlUkcY.js";import{m as ve}from"./react-DKXriBSF.js";import{P as xe,c as rt,r as ie,a as it,u as nt,b as st,s as ot}from"./use-usage-limits-DqoTZrqT.js";import{L as k,u as lt}from"./use-limits-display-prefs-DJIImtLN.js";import{C as Pe}from"./Card-SUbC3VNS.js";import{F as ct}from"./FadeIn-DF2c8XaR.js";import{L as Ce,l as ee,a as De}from"./limits-providers-DxZOjiXQ.js";import{P as Ee}from"./ProviderIcon-By8FAjxR.js";import{H as dt}from"./HoverTooltip-DBOpxlH7.js";import{C as ut}from"./ConfirmModal-DsCd51b2.js";import{I as ke,L as mt}from"./LocalOnlyNotice-Bj_m0hw7.js";import{S as ce}from"./Select-C05W6XEM.js";import{P as xt}from"./plus-Bglp9N_7.js";import{P as pt,a as gt,b as ft,c as ht,d as bt}from"./PopoverPopup-DK3et-HG.js";import{u as yt}from"./use-reduced-motion-DdpxZQoh.js";import"./use-latest-request-guard-lcGhb-NC.js";import"./DialogTitle-C4ia00lc.js";import"./composite-BDwOlhhX.js";import"./store-8e16Ac2h.js";import"./DialogDescription-BVlaoajd.js";import"./arrow-up-right-DSsR3Ntr.js";import"./download-DdGW6Krz.js";import"./ToolbarRootContext-XUDMp5uy.js";import"./check-Cy35lAKh.js";import"./SelectItemText-CcfB3blP.js";const vt=[["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"}]],kt=G("bell-off",vt);const jt=[["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"}]],wt=G("bell",jt);const Nt=[["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"}]],Te=G("calendar-clock",Nt);const _t=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Ie=G("clock",_t);const Mt=[["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"}]],Re=G("infinity",Mt),St=[3,2,3,3,2,2,3];function T({className:t}){return e.jsx("div",{className:Se("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Pt(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{className:"h-3 w-12 shrink-0"}),e.jsx(T,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(T,{className:"h-3 w-[30px] shrink-0"}),e.jsx(T,{className:"h-3 w-6 shrink-0"})]})}function Ct({bars:t,index:a}){const r=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{className:"h-[14px] w-[14px] rounded shrink-0"}),e.jsx(T,{className:Se("h-4",r)})]}),Array.from({length:t},(s,n)=>e.jsx(Pt,{},n))]})}function Dt(){return e.jsx(Pe,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(T,{className:"h-3.5 w-28"}),St.map((t,a)=>e.jsx(Ct,{bars:t,index:a},a))]})})}const pe=100;function je(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function Et(t){return Math.max(0,Math.min(pe,Math.round(t)))}function Tt(t){return new Intl.DateTimeFormat(re(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function It(t,a,r){if(t==null||t>=a)return pe;const s=a-t,n=a-r;return Et(n/s*pe)}function Rt(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function At(t,{now:a}={}){if(!t||typeof t!="object")return null;const r=Rt(t);if(r===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=je(l?.expires_at);if(c==null)continue;const d=o.length+1;o.push({key:`reset-${d}`,label:i("limits.codex_reset_bank.row_label",{index:d}),expiresAt:Tt(c),expiresMs:c,percent:It(je(l?.granted_at),c,n)})}return r===0?null:o.length>0?{kind:"rows",availableCount:r??o.length,rows:o}:r>0?{kind:"count_only",availableCount:r,rows:[]}:null}const B=864e5;function I(t,a){const r=new Date(t),s=r.getUTCDate(),n=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()+a,1,r.getUTCHours(),r.getUTCMinutes())),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(s,o)),n.getTime()}function Ae(t,a){if(a==="weekly")return t-7*B;if(a==="yearly")return I(t,-12);const r=new Date(t),s=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),0)).getUTCDate(),n=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-1,1,r.getUTCHours(),r.getUTCMinutes()));return n.setUTCDate(Math.min(r.getUTCDate(),s)),n.getTime()}function Oe(t,a){return a==="weekly"?t+7*B:a==="yearly"?I(t,12):I(t,1)}function Ot(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return Ae(new Date(t.nextBillingAt).getTime(),t.cycle)}function Ft(t,a,r){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return Ae(r,a)}function Lt(t,a,r){if(a==="weekly"){const c=7*B,d=r<=t?0:Math.floor((r-t)/c);return{startMs:t+d*c,endMs:t+(d+1)*c}}const s=a==="yearly"?12:1,n=s*30.436875*B;let o=r<=t?0:Math.floor((r-t)/n);for(;o>0&&I(t,o*s)>r;)o-=1;let l=0;for(;I(t,(o+1)*s)<=r&&l<12e3;)o+=1,l+=1;return{startMs:I(t,o*s),endMs:I(t,(o+1)*s)}}function te(t,a){const r=new Date(t.nextBillingAt).getTime();if(!Number.isFinite(r))return null;const s=["weekly","monthly","yearly"].includes(t.cycle)?t.cycle:"monthly",n=Ft(t,s,r);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=Lt(n,s,a):t.startedAt!=null?(o=n,l=Oe(n,s),c=l<=a):(o=n,l=r,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/B)),expired:c}}function Fe(t,a){const r=t-a;if(r<=0)return i("subscriptions.expired");const s=Math.ceil(r/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function ge(t,a){const r=t-a;if(r<=0)return i("subscriptions.expired");const s=Math.floor(r/6e4),n=Math.floor(s/1440),o=Math.floor(s%1440/60),l=s%60;return i("subscriptions.countdown",{days:n,hours:o,minutes:l})}const $t="shrink-0 text-oai-black dark:text-oai-white";function Ht(t){const a=ie(t);if(!Number.isFinite(a))return null;const r=a-Date.now();if(r<=0)return i("shared.time.now");const s=Math.floor(r/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function Ut(t,a){const r=a===k.REMAINING?100-t:t;return r>=90?"bg-red-500":r>=70?"bg-amber-500":"bg-emerald-500"}function ae(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ne(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function de(t){const a=Math.max(0,Math.min(100,Number(t)||0)),r=Math.round(a);return a>0&&r===0?i("limits.bar.sub_one_percent"):String(r)}function Z(t,{useGrouping:a=!0,maximumFractionDigits:r}={}){const s=Number(t);return Number.isFinite(s)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:r??(s>=100?0:2),useGrouping:a}).format(s):null}function Bt(t){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const a={useGrouping:t.unit!=="calls"},r=Z(t.used_credits,a),s=Z(t.limit_credits,a),n=Z(t.remaining_credits,a);if(!r||!s||!n)return null;const o=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return i(o,{used:r,limit:s,remaining:n})}function Gt(t,a){return rt({usedPercent:ae(t.window,t.pctField),windowSeconds:it(t,t.window),resetMs:ie(ne(t.window,t.resetField)),mode:a})}function Le(t){return Number.isFinite(t)?new Intl.DateTimeFormat(re(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function Wt(t,a,r){const s=[He(t,a,r)],n=ie(ne(t.window,t.resetField)),o=Le(n);o&&s.push(i(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=Bt(t.window);return l&&s.push(l),s.join(`
2
- `)}const $e=dt;function qt({label:t,pct:a,reset:r,mode:s=k.USED,pacePercent:n=null,paceOver:o=!1,title:l=null}){const c=Math.max(0,Math.min(100,Number(a)||0)),d=s===k.REMAINING?100-c:c,m=Math.round(d),g=d>0&&m===0?Math.max(d,.35):d;let f=String(m);d>0&&m===0&&(f=i("limits.bar.sub_one_percent"));const b=n==null?null:Math.max(0,Math.min(100,n));return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx($e,{text:l}),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}),e.jsxs("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${Ut(d,s)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${g}%`,minWidth:d>0?"3px":0}}),b!=null&&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(${b}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${o?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${b}% - 1px)`,width:"2px"}})]})]}),e.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:[f,"%"]}),r&&e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:r})]})}function He(t,a,r){const s=t.label??i(t.labelKey),n=r===k.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(ae(t.window,t.pctField))||0)),m=de(o(d));return n?i("limits.explain.remaining",{label:s,used:m}):i("limits.explain.used",{label:s,used:m})}if(a.paceOver){if(a.runsOutEta)return i("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=de(o(a.projectedEnd??100));return i(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:s,pct:d})}const l=Math.max(0,Math.min(100,Number(ae(t.window,t.pctField))||0)),c=de(o(a.projectedEnd??l));return i(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function zt({pace:t}){return t.pacePercent!=null}function Vt({rows:t,mode:a,now:r=Date.now()}){if(t.length===0)return null;const s=a===k.REMAINING,n=t.some(zt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l})=>{const c=Le(ie(ne(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[He(o,l,a),c?e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",i(o.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:c})]}):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:i(s?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function Q(t){if(!t)return null;const a=Date.now()-new Date(t).getTime();if(a<0)return null;const r=Math.floor(a/6e4);if(r<1)return i("shared.time.now");if(r<60)return i("shared.time.m_ago",{n:r});const s=Math.floor(r/60);if(s<24)return i("shared.time.h_ago",{n:s});const n=Math.floor(s/24);return i("shared.time.d_ago",{n})}const we={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"}},Yt={claude:"claude",codex:"codex"};function U({label:t,age:a=null,tone:r="live",tooltip:s=null}){const n=we[r]||we.live,o=r==="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 Ue({name:t,providerId:a,children:r,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null}){const d=De(a),m=e.jsxs("div",{className:"flex items-center gap-1.5",children:[d?e.jsx(Ee,{provider:d,size:14,className:$t}):null,e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t}),c?e.jsx("span",{className:"shrink-0",children:c}):null,l]});return s?e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:o,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),o?.())},className:"flex flex-col gap-1.5 -mx-1.5 px-1.5 py-1 rounded-lg cursor-pointer transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 aria-expanded:bg-oai-gray-50 dark:aria-expanded:bg-oai-gray-800/40",children:[m,r]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[m,r]})}function Be({subscription:t}){const a=t.autoRenew?i("subscriptions.badge.auto_renew"):i("subscriptions.badge.stops"),r=t.autoRenew?Re:Ie;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(r,{size:14,strokeWidth:2,"aria-hidden":!0})})}function Ge({subscription:t,now:a,mode:r=k.USED}){const s=te(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=r===k.REMAINING?100-c:c,m=o?100:Math.max(0,Math.min(100,d)),g=Math.round(m),f=m>0&&g===0?i("limits.bar.sub_one_percent"):`${g}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:i("subscriptions.inline.label")}),e.jsx("div",{className:"relative 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-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:f}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 whitespace-nowrap w-6 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Fe(n,a)})]})}function We({subscription:t,now:a}){const r=te(t,a);if(!r)return null;const s=new Intl.DateTimeFormat(re(),{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:i("subscriptions.inline.label")}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:":"}),e.jsx("span",{children:t.autoRenew?i("subscriptions.label.renews_at"):i("subscriptions.label.expires_at")}),e.jsx("span",{children:" "}),e.jsx("span",{className:"font-mono tabular-nums",children:s.format(new Date(r.endMs))}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{className:r.expired?"text-oai-error":void 0,children:ge(r.endMs,a)}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{children:t.autoRenew?i("subscriptions.status.auto_renew"):i("subscriptions.status.manual")})]})}const Kt=Ce;function R({children:t,tone:a="neutral"}){const r=a==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return e.jsx("div",{className:`text-[11px] leading-snug ${r}`,children:t})}function Xt({rows:t,mode:a,extra:r=null}){const s=t.length===0&&!r;return e.jsxs(e.Fragment,{children:[t.map(({spec:n,pace:o})=>e.jsx(qt,{label:n.label??i(n.labelKey),pct:ae(n.window,n.pctField),reset:Ht(ne(n.window,n.resetField)),mode:a,pacePercent:o.pacePercent,paceOver:o.paceOver,title:Wt(n,o,a)},n.key)),s?e.jsx(R,{children:i("limits.status.no_data")}):null,r]})}function Jt(t){if(!Number.isFinite(t.expiresMs))return null;const a=Math.floor((t.expiresMs-Date.now())/864e5);return a<0?null:a===0?i("limits.reset_bank.hover_detail_today",{date:t.expiresAt}):i("limits.reset_bank.hover_detail",{date:t.expiresAt,days:a})}function Qt({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($e,{text:Jt(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 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 Zt({model:t}){const a=t.kind==="count_only"?i("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:i("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(r=>e.jsx(Qt,{row:r},r.key))]})}function qe(t,a){if(t==="codex_meta"){const r=At(a.reset_credits);return r?e.jsx(Zt,{model:r}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(R,{children:i("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 r=Z(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(R,{children:i("limits.label.kiro_tracked_credits",{credits:r,count:Number(a.tracked_credit_records)})})}return t==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?e.jsx(aa,{defaultDir:a.otel_default_dir}):null}function ea(t,a,r,s,n,o,l=null,c=null,d=Date.now()){const m=xe[t];if(!m)return null;const g=m.windows(a).filter(b=>b.window).map(b=>({spec:b,pace:Gt(b,s)})),f=qe(m.extra,a);return e.jsxs(Ue,{name:r,providerId:t,expandable:g.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(Be,{subscription:c}):null,children:[e.jsx(Xt,{mode:s,rows:g,extra:f}),c?e.jsx(Ge,{subscription:c,now:d,mode:s}):null,n?e.jsx(Vt,{rows:g,mode:s,now:d}):null,n&&c?e.jsx(We,{subscription:c,now:d}):null]},t)}function ue(t,a,r,s,n=null,o=Date.now(),l=k.USED){const c=!!n;return e.jsxs(Ue,{name:ee(t),providerId:t,expandable:c,expanded:r,onToggle:s,rightAdornment:c?e.jsx(Be,{subscription:n}):null,children:[a,c?e.jsx(Ge,{subscription:n,now:o,mode:l}):null,c&&r?e.jsx("div",{className:"mt-1",children:e.jsx(We,{subscription:n,now:o})}):null]},t)}function ta(t,a,r,s,n,o=null,l=Date.now()){if(!xe[t])return null;if(!a?.configured)return ue(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{children:i("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(Ne,{}):null,t==="codingPlan"?e.jsx(_e,{}):null]}),s,n,o,l,r);if(t==="opencodeGo"&&a.subscription_status==="inactive")return ue(t,e.jsx(R,{children:i("limits.opencodeGo.status.inactive")}),s,n,o,l,r);if(a.error)return ue(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{tone:"error",children:i("shared.error.prefix",{error:a.error})}),t==="kiro"?qe(xe.kiro.extra,a):null,t==="opencodeGo"?e.jsx(Ne,{}):null,t==="codingPlan"?e.jsx(_e,{}):null]}),s,n,o,l,r);const c=ee(t),d=a.plan_label?`${c} ${a.plan_label}`:c;let m=null;if(t==="antigravity")if(a.cached){const f=Q(a.cached_at);m=e.jsx(U,{label:i("limits.label.antigravity_cached"),age:f,tone:"cached",tooltip:i("limits.tooltip.antigravity_cached")})}else m=e.jsx(U,{label:i("limits.label.antigravity_live"),tone:"live",tooltip:i("limits.tooltip.antigravity_live")});if((t==="qoder"||t==="qoderCn"||t==="codingPlan")&&a.cached&&(m=e.jsx(U,{label:i("limits.label.antigravity_cached"),age:Q(a.cached_at),tone:"cached",tooltip:i("limits.tooltip.qoder_cached")})),!m&&a.auth_action_required==="reauth"){const f=Yt[t];m=e.jsx(U,{label:i("limits.reauth.badge"),age:Q(a.cached_at),tone:"stale",tooltip:f?i("limits.reauth.tooltip",{command:f}):null})}const g=a.provenance;return g?.stale&&!m&&(m=e.jsx(U,{label:i("limits.provenance.stale"),age:Q(g.captured_at),tone:"stale",tooltip:i("limits.provenance.tooltip",{source:g.source,confidence:g.confidence})})),ea(t,a,d,r,s,n,m,o,l)}function aa({defaultDir:t}){const[a,r]=x.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(`
3
- `),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),r(!0),setTimeout(()=>r(!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:i("limits.copilot.otelHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug",children:i("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?i("limits.copilot.otelHint.copied"):i("limits.copilot.otelHint.copy")})]})}function F({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 ze(){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 Ne(){const[t,a]=x.useState(!1),r=["read -r -s OPENCODE_GO_API_KEY","export OPENCODE_GO_API_KEY",'launchctl setenv OPENCODE_GO_API_KEY "$OPENCODE_GO_API_KEY"'].join(`
4
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(r),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:i("limits.opencodeGo.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:i("limits.opencodeGo.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(F,{n:"1",children:[e.jsx("div",{children:i("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",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:[i("limits.opencodeGo.setupHint.cta"),e.jsx(ze,{})]})]}),e.jsx(F,{n:"2",children:e.jsx("div",{children:i("limits.opencodeGo.setupHint.step2")})}),e.jsxs(F,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:i("limits.opencodeGo.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?i("limits.opencodeGo.setupHint.copied"):i("limits.opencodeGo.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:r}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:i("limits.opencodeGo.setupHint.note_app")})]})]})]})}function _e(){const[t,a]=x.useState(!1),r=["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(r),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:i("limits.codingPlan.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:i("limits.codingPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(F,{n:"1",children:[e.jsx("div",{children:i("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:[i("limits.codingPlan.setupHint.cta"),e.jsx(ze,{})]})]}),e.jsxs(F,{n:"2",children:[e.jsx("div",{children:i("limits.codingPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:i("limits.codingPlan.setupHint.step2_remote")})]}),e.jsxs(F,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:i("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?i("limits.codingPlan.setupHint.copied"):i("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:r}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:i("limits.codingPlan.setupHint.note_app")})]})]})]})}function ra(t){const[a,r]=x.useState(0);return x.useLayoutEffect(()=>{const s=t.current;if(!s)return;const n=s.querySelectorAll("[data-limit-label]");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);r(d=>d===c?d:c)}),a}function ia({claude:t,codex:a,cursor:r,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:g,qoder:f,qoderCn:b,codingPlan:w,order:M,visibility:N,displayMode:j,subscriptions:L=[],showSubscriptions:se=!0}){const W={claude:t,codex:a,cursor:r,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:g,qoder:f,qoderCn:b,codingPlan:w},q=x.useRef(null),A=ra(q),[oe,he]=x.useState(null),[_,le]=x.useState(()=>Date.now()),z=Array.isArray(M)&&M.length>0?M:Kt,P=j===k.REMAINING?k.REMAINING:k.USED,V=P===k.REMAINING?i("limits.settings.display_mode_remaining"):i("limits.settings.display_mode_used");x.useEffect(()=>{const h=setInterval(()=>le(Date.now()),6e4);return()=>clearInterval(h)},[]);const E=new Map;if(se)for(const h of L||[]){if(!h?.provider)continue;const C=new Date(h.nextBillingAt).getTime();if(!Number.isFinite(C))continue;const $=E.get(h.provider);if(!$){E.set(h.provider,h);continue}const S=new Date($.nextBillingAt).getTime(),K=C>_,X=S>_;(K&&(!X||S>C)||!K&&!X&&C>S)&&E.set(h.provider,h)}const Y=z.filter(h=>!N||N[h]!==!1||E.has(h)).map(h=>ta(h,W[h],P,oe===h,()=>he(C=>C===h?null:h),E.get(h)||null,_)).filter(Boolean);return e.jsx(ct,{delay:.15,children:e.jsx(Pe,{children:e.jsxs("div",{ref:q,className:"flex flex-col gap-3",style:A>0?{"--tt-limits-label-w":`${A}px`}:void 0,children:[e.jsxs("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:[i("limits.panel.title"),i("limits.panel.mode_separator"),V]}),Y.length>0?Y:e.jsx(R,{children:i("limits.status.all_hidden")})]})})})}async function Ve(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 na(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await Ve(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function fe(t){const a=await Xe();return Ve(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 sa(t){return fe({action:"create",subscription:t})}function oa(t,a){return fe({action:"update",id:t,subscription:a})}function la(t){return fe({action:"delete",id:t})}const me={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function ca(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const r=s=>String(s).padStart(2,"0");return`${a.getFullYear()}-${r(a.getMonth()+1)}-${r(a.getDate())}T${r(a.getHours())}:${r(a.getMinutes())}`}function da({subscriptions:t,onChanged:a}){const[r,s]=x.useState(!1),[n,o]=x.useState(null),[l,c]=x.useState(me),[d,m]=x.useState(!1),[g,f]=x.useState(!1),[b,w]=x.useState(!1),[M,N]=x.useState(!1),[j,L]=x.useState(null),[se,W]=x.useState(!1),[q,A]=x.useState(!1),[oe,he]=x.useState(null),[_,le]=x.useState(()=>Date.now()),z=x.useRef(null),P=re(),V=x.useMemo(()=>new Intl.DateTimeFormat(P,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[P]);x.useEffect(()=>{const u=setInterval(()=>le(Date.now()),6e4);return()=>clearInterval(u)},[]),x.useEffect(()=>{if(!r)return;const u=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;z.current?.scrollIntoView?.({behavior:u?"auto":"smooth",block:"nearest"})},[r,n]);const E=x.useMemo(()=>Ce.map(u=>{const v=(t||[]).some(y=>y.provider===u&&y.id!==n),p=ee(u);return{value:u,label:v?`${p} ${i("subscriptions.form.provider_taken_suffix")}`:p,disabled:v}}),[P,t,n]),Y=x.useMemo(()=>[{value:"weekly",label:i("subscriptions.form.cycle_weekly")},{value:"monthly",label:i("subscriptions.form.cycle_monthly")},{value:"yearly",label:i("subscriptions.form.cycle_yearly")}],[P]),h=x.useMemo(()=>[{value:"true",label:i("subscriptions.form.auto_renew_on")},{value:"false",label:i("subscriptions.form.auto_renew_off")}],[P]),C=x.useCallback(()=>{c(me),o(null),f(!1),w(!1),N(!1),s(!0)},[]),$=x.useCallback(u=>{c({plan:u.plan||"",provider:u.provider||"",cycle:u.cycle||"monthly",autoRenew:u.autoRenew,startedAt:ca(new Date(Ot(u)).toISOString())}),o(u.id),f(!1),w(!1),N(!1),s(!0)},[]),S=x.useCallback(()=>{s(!1),o(null),c(me),f(!1),w(!1),N(!1)},[]),K=x.useCallback(async u=>{if(u.preventDefault(),f(!1),!l.provider){w(!0);return}if((t||[]).some(O=>O.provider===l.provider&&O.id!==n)){N(!0);return}const p=new Date(l.startedAt).getTime();if(!Number.isFinite(p)){f(!0);return}const y={service:ee(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:p,nextBillingAt:Oe(p,l.cycle)};m(!0);try{n?await oa(n,y):await sa(y),S(),await a?.()}catch{f(!0)}finally{m(!1)}},[S,n,l,a,t]),X=x.useCallback(async()=>{if(j){W(!0),A(!1);try{await la(j.id),j.id===n&&S(),L(null),await a?.()}catch{A(!0)}finally{W(!1)}}},[S,n,a,j]),J=t||[],be=()=>{const u=n?J.find(p=>p.id===n):null,v=u?te(u,_):null;return e.jsxs("form",{ref:z,onSubmit:K,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?i("subscriptions.edit"):i("subscriptions.add")})}),v?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:u.autoRenew?i("subscriptions.label.renews_at"):i("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:V.format(new Date(v.endMs))})," · ",e.jsx("span",{className:v.expired?"text-oai-error":void 0,children:ge(v.endMs,_)})]}):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:i("subscriptions.form.provider")}),e.jsx(ce,{id:"subscription-provider",value:l.provider,onValueChange:p=>c({...l,provider:String(p)}),options:E,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(ke,{label:i("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:i("subscriptions.form.plan_placeholder"),onChange:p=>c({...l,plan:p.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:i("subscriptions.form.cycle")}),e.jsx(ce,{id:"subscription-cycle",value:l.cycle,onValueChange:p=>c({...l,cycle:String(p)}),options:Y,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:i("subscriptions.form.auto_renew")}),e.jsx(ce,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:p=>c({...l,autoRenew:p==="true"}),options:h,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(ke,{label:i("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:p=>c({...l,startedAt:p.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[n?e.jsx(H,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const p=J.find(y=>y.id===n);p&&L(p)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:i("subscriptions.delete")}):null,b?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:i("subscriptions.form.provider_required")}):null,M?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:i("subscriptions.form.provider_taken")}):null,g?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:i("subscriptions.form.error")}):null,e.jsx(H,{type:"button",variant:"secondary",size:"sm",onClick:S,children:i("shared.action.cancel")}),e.jsx(H,{type:"submit",size:"sm",disabled:d,children:i("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:i("limits.page.openSubscriptions")})}),e.jsxs(H,{type:"button",size:"sm",onClick:C,className:"shrink-0 gap-1.5",children:[e.jsx(xt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:i("subscriptions.add")})]})]}),J.length===0&&!(r&&!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(Te,{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:i("subscriptions.empty.title")}),e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i("subscriptions.empty.body")})]}):e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[J.map(u=>{const v=te(u,_);if(!v)return null;const{endMs:p,expired:y}=v,O=y?100:v.progress*100,Ye=!y&&p-_<=3*864e5,Ke=oe===u.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:()=>$(u),"aria-label":`${i("subscriptions.edit")} ${u.service}`,"aria-expanded":n===u.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(Ee,{provider:De(u.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:u.service}),e.jsx("span",{role:"img","aria-label":u.autoRenew?i("subscriptions.badge.auto_renew"):i("subscriptions.badge.stops"),title:u.autoRenew?i("subscriptions.badge.auto_renew"):i("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${u.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:u.autoRenew?e.jsx(Re,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Ie,{size:14,strokeWidth:2,"aria-hidden":!0})}),u.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:u.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:i("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:`${y?"bg-red-500":Ye?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${O}%`,minWidth:O>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${y?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Fe(p,_)})]})]}),n===u.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:be()}):null,n!==u.id&&Ke?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:u.autoRenew?i("subscriptions.label.renews_at"):i("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:V.format(new Date(p))})," · ",e.jsx("span",{className:y?"text-oai-error":void 0,children:ge(p,_)})," · ",e.jsx("span",{children:u.autoRenew?i("subscriptions.status.auto_renew"):i("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(H,{type:"button",variant:"secondary",size:"sm",onClick:()=>$(u),children:i("subscriptions.edit")})})]}):null]},u.id)}),r&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:be()}):null]}),e.jsx(ut,{open:!!j,title:i("subscriptions.confirm_delete_title"),description:j?.service||"",error:q?i("subscriptions.delete_error"):null,confirmLabel:i("subscriptions.delete"),cancelLabel:i("shared.action.cancel"),destructive:!0,busy:se,onCancel:()=>{L(null),A(!1)},onConfirm:X})]})}const Me=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),ua="x-apple.systempreferences:com.apple.preference.notifications";function ma(){const t=yt(),a=tt(),r=i("limits.alert.blocked"),s=a?ve.button:ve.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>at({type:"action",name:"openURL",value:ua}):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:r,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:r}),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 La(){const t=Je(),{data:a,error:r,isLoading:s}=nt(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),n=lt(),o=st(),[l,c]=D.useState([]),[d,m]=D.useState(!1),[g,f]=D.useState(!1),[b]=Qe(),w=D.useRef(0),M=D.useCallback(async()=>{if(!Me&&!ye())return;const N=++w.current;try{const j=await na();if(N!==w.current)return;c(j),m(!1)}catch{if(N!==w.current)return;m(!0)}},[]);return D.useEffect(()=>{M()},[M]),D.useEffect(()=>{b.get("openSubscriptions")==="1"&&f(!0)},[b]),D.useEffect(()=>{o.enabled&&a&&ot(a)},[o.enabled,a]),!Me&&!ye()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(mt,{})}):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:"flex flex-row items-start justify-between gap-4 mb-8",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:i("nav.limits")}),e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:i("limits.page.subtitle")})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.enabled&&o.permissionBlocked?e.jsx(ma,{}):null,e.jsxs(pt,{open:g,onOpenChange:f,children:[e.jsx(gt,{"aria-label":i("limits.page.openSubscriptions"),title:i("limits.page.openSubscriptions"),className:"shrink-0 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",children:e.jsx(Te,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(ft,{children:e.jsx(ht,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(bt,{children:e.jsx(da,{subscriptions:l,onChanged:M})})})})]}),e.jsx("button",{type:"button",onClick:()=>{o.setEnabled(!o.enabled)},"aria-label":o.enabled?i("limits.alert.disable"):i("limits.alert.enable"),title:o.enabled?i("limits.alert.disable"):i("limits.alert.enable"),className:`inline-flex h-9 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 ${o.enabled&&o.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:o.enabled?e.jsx(wt,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(kt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Ze,{to:"/settings?section=limits","aria-label":i("limits.page.openSettings"),title:i("limits.page.openSettings"),className:"shrink-0 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 no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(et,{className:"h-4 w-4","aria-hidden":!0})})]})]}),s?e.jsx(Dt,{}):e.jsxs(e.Fragment,{children:[r?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:i("shared.error.prefix",{error:r})}):null,d?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:i("subscriptions.load_error")}):null,e.jsx(ia,{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,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,order:n.order,visibility:n.visibility,displayMode:n.displayMode,subscriptions:l,showSubscriptions:n.showSubscriptions!==!1})]})]})})})}export{La as LimitsPage};
@@ -1,2 +0,0 @@
1
- import{m as Y,r as i,j as e,e as P,c as a,M as ce,J as W,R as de,X as ue,d as ee,l as m,a4 as xe,a5 as U}from"./__vite-browser-external-DPOlUkcY.js";import{L as me,I as he}from"./LocalOnlyNotice-Bj_m0hw7.js";import{S as Z}from"./SegmentedControl-DLzS-2eZ.js";import{C as ge}from"./ToolbarRootContext-XUDMp5uy.js";import{S as te}from"./search-D_LLDRdU.js";import{C as pe}from"./check-Cy35lAKh.js";import{P as fe,a as be,b as ye,c as ke,d as _e}from"./PopoverPopup-DK3et-HG.js";import{P as ve}from"./ProviderIcon-By8FAjxR.js";import{H as je}from"./HoverTooltip-DBOpxlH7.js";import{u as we}from"./useCurrency-CnM8aB4v.js";import{i as Ne}from"./host-mode-Bc_iTzHk.js";import{L as Ce}from"./loader-circle-lrDmbIg5.js";import{T as Se}from"./terminal-CR228ekj.js";import"./arrow-up-right-DSsR3Ntr.js";import"./download-DdGW6Krz.js";import"./composite-BDwOlhhX.js";import"./store-8e16Ac2h.js";const Me=[["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"}]],Le=Y("calendar",Me);const Te=[["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"}]],Re=Y("folder",Te),De="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 Ie({options:s,value:t,onChange:o,allValue:x="all",allLabel:g,searchPlaceholder:k,emptyLabel:u,ariaLabel:w,disabled:p=!1,className:_=""}){const[b,f]=i.useState(!1),[y,R]=i.useState(""),[h,v]=i.useState(-1),N=i.useRef(null),C=`${i.useId()}-listbox`,A=t===x?g:s.find(l=>l.value===t)?.label??t,S=y.trim().toLowerCase(),D=i.useMemo(()=>S?s.filter(l=>l.label.toLowerCase().includes(S)):s,[s,S]),I=i.useMemo(()=>[{value:x,label:g},...D],[x,g,D]),M=h>=0&&h<I.length?I[h]:null,E=l=>{o(l),f(!1),R(""),v(-1)};i.useEffect(()=>{b&&N.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[b,h]);const L=l=>{if(l.key==="ArrowDown"||l.key==="ArrowUp"){l.preventDefault();const j=l.key==="ArrowDown";v(F=>{const T=I.length;return T?j?F>=T-1?0:F+1:F<=0?T-1:F-1:-1});return}if(l.key==="Enter"){const j=M||(S&&D.length?D[0]:null);if(!j)return;l.preventDefault(),E(j.value)}};return e.jsxs(fe,{open:b,onOpenChange:l=>{f(l),v(-1),l||R("")},children:[e.jsxs(be,{disabled:p,"aria-label":w,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",t!==x?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",_),children:[e.jsx(Re,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:A}),e.jsx(ge,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(ye,{children:e.jsx(ke,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(_e,{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(te,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":M?`${C}-${h}`:void 0,value:y,onChange:l=>{R(l.target.value),v(-1)},onKeyDown:L,placeholder:k,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:N,id:C,role:"listbox","aria-label":w,className:"max-h-64 overflow-y-auto",children:[I.map((l,j)=>e.jsxs("button",{id:`${C}-${j}`,type:"button",role:"option","aria-selected":t===l.value,"data-active":j===h?"true":void 0,onMouseEnter:()=>v(j),onClick:()=>E(l.value),className:P(De,t===l.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",j===h&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:l.label}),t===l.value?e.jsx(pe,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},l.value)),D.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:u}):null]})]})})})]})}const Ee="tokentracker-sessions";async function Pe(s={}){const t=new URL(`/functions/${Ee}`,window.location.origin);s.from&&t.searchParams.set("from",s.from),s.to&&t.searchParams.set("to",s.to),s.limit&&t.searchParams.set("limit",String(s.limit)),s.refresh&&t.searchParams.set("refresh","1");const o=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),x=await o.json().catch(()=>null);if(!o.ok){const g=o.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${o.status}`,k=new Error(x?.error||g);throw k.status=o.status,k}return x}const J=Ne(),Fe=[],G=100,$e=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],ae=[{id:"all",days:0,label:()=>a("sessions.filter.range_all")},{id:"7d",days:7,label:()=>a("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>a("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>a("sessions.filter.range_90d")}];function Oe(s){const t=ae.find(x=>x.id===s)?.days||0;if(!t)return 0;const o=new Date;return o.setDate(o.getDate()-(t-1)),o.setHours(0,0,0,0),o.getTime()}function Ae(s,t){if(!t)return!0;const o=Date.parse(s.ended_at||s.started_at||"");return Number.isFinite(o)?o>=t:!0}function qe(s,t){if(!s)return"—";const o=Date.parse(s);if(!Number.isFinite(o))return"—";try{return new Date(o).toLocaleString(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return new Date(o).toISOString().slice(0,16).replace("T"," ")}}function Ue(s){const t=Number(s);if(!Number.isFinite(t)||t<=0)return null;const o=Math.round(t/6e4);if(o<60)return a("sessions.duration.minutes",{minutes:o});const x=Math.floor(o/60),g=o%60;return a("sessions.duration.hours",{hours:x,minutes:g})}async function V(s){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(s),!0;const t=document.createElement("textarea");t.value=s,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const o=document.execCommand("copy");return document.body.removeChild(t),o}const X=ee.memo(function({session:t,locale:o,nested:x=!1,childCount:g=0,expanded:k=!1,onToggle:u}){const{currency:w,rate:p}=we(),_=String(t.source||"").toUpperCase(),b=Ue(t.duration_ms),f=t.resume_command,y=t.project_key||a("sessions.project.unknown"),R=x||t.thread_kind==="subagent",h=R?t.agent_nickname||t.agent_role||t.title||y:t.title||y,v=!!(t.title&&t.project_key),N=String(t.source||"").toLowerCase()==="grok",C=N&&t.usage_precision?a("sessions.grok.token_breakdown",{input:m(t.input_tokens),cacheRead:m(t.cached_input_tokens),cacheWrite:m(t.cache_creation_input_tokens),output:m(t.output_tokens),reasoning:m(t.reasoning_output_tokens)}):null,A=N&&t.usage_precision?a("sessions.grok.runtime_breakdown",{calls:m(t.model_calls),seconds:(Number(t.api_duration_ms||0)/1e3).toFixed(1),tools:m(t.tool_calls),errors:m(t.error_count)}):null,S=N&&Number(t.context_window_tokens)>0?a("sessions.grok.context_breakdown",{used:m(t.context_tokens_used),window:m(t.context_window_tokens),percent:Number(t.context_usage_percent||0).toFixed(0)}):null,D=t.project_ref?`${t.project_ref}
2
- ${a("sessions.project.copy_hint")}`:void 0,I=async()=>{if(t.project_ref)try{await V(t.project_ref)?U({title:a("sessions.project.copied")}):U({title:a("sessions.project.copy_failed")})}catch{U({title:a("sessions.project.copy_failed")})}},M=L=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(je,{text:D,placement:"bottom"}),e.jsx("button",{type:"button",onClick:I,"aria-label":a("sessions.project.copy_aria",{project:y}),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",L),children:y})]}),E=async()=>{if(f)try{await V(f)?U({title:a("sessions.resume.copied")}):U({title:a("sessions.resume.copy_failed")})}catch{U({title:a("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:P("flex flex-col gap-3 py-4 sm:flex-row sm:items-start",x&&"ml-6 border-l-2 border-oai-gray-200 pl-4 dark:border-oai-gray-800"),children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(ve,{provider:_,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!R&&!t.title&&t.project_ref?M("font-medium text-oai-black dark:text-white"):e.jsx("span",{className:"truncate font-medium text-oai-black dark:text-white",children:h}),R?e.jsxs("span",{className:"inline-flex items-center rounded-full bg-sky-50 px-2 py-0.5 text-[11px] font-medium text-sky-700 dark:bg-sky-500/10 dark:text-sky-300",children:[a("sessions.badge.subagent"),t.agent_role?` · ${t.agent_role}`:""]}):null,t.first_pass?e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:a("sessions.badge.first_pass")}):null,N&&t.usage_precision?e.jsx("span",{className:P("inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium",t.usage_is_incomplete||t.cost_is_partial?"bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300":"bg-sky-50 text-sky-700 dark:bg-sky-500/10 dark:text-sky-300"),children:t.usage_is_incomplete||t.cost_is_partial?a("sessions.badge.partial_usage"):t.cost_source==="provider_reported"?a("sessions.badge.reported_cost"):a("sessions.badge.reported_usage")}):null,g?e.jsx("button",{type:"button",onClick:u,"aria-expanded":k,className:"inline-flex items-center rounded-full border border-oai-gray-200 px-2 py-0.5 text-[11px] 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-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:k?a("sessions.thread.collapse",{count:g}):a("sessions.thread.expand",{count:g})}):null]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[v?e.jsxs(e.Fragment,{children:[t.project_ref?M("hover:text-oai-black dark:hover:text-white"):e.jsx("span",{className:"truncate",children:y}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,e.jsx("span",{className:"truncate",children:t.model||a("sessions.model.unknown")}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:qe(t.started_at,o)}),b?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:b})]}):null]}),C?e.jsx("div",{className:"mt-1 text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:C}):null,A?e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 text-[11px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:A}),S?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:S})]}):null]}):null]})]}),e.jsxs("div",{className:"flex items-start gap-5 pl-[30px] sm:pl-0",children:[e.jsxs("dl",{className:"flex items-start gap-6 text-right",children:[e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.tokens")}),e.jsxs("dd",{title:Number(t.subagent_total_tokens)?a("sessions.thread.tokens_summary",{own:m(t.own_total_tokens),subagents:m(t.subagent_total_tokens),combined:m(t.combined_total_tokens)}):void 0,className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:[m(t.total_tokens),Number(t.subagent_total_tokens)?e.jsxs("span",{className:"block text-[9px] font-normal text-oai-gray-400 dark:text-oai-gray-500",children:["Σ ",m(t.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.cost")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:xe(t.cost_usd,{currency:w,rate:p})})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.turns")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:m(t.turns)})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.edits")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:m(t.edit_turns)})]})]}),e.jsxs("button",{type:"button",onClick:E,disabled:!f,title:f||a("sessions.resume.unavailable"),"aria-label":f?a("sessions.resume.copy_aria",{command:f}):a("sessions.resume.unavailable"),className:P("-mt-0.5 inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",f?"text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white":"cursor-not-allowed text-oai-gray-300 dark:text-oai-gray-600"),children:[e.jsx(Se,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:a("sessions.resume.copy")})]})]})]})});function Be({sessions:s,selectedModel:t,onSelect:o}){const{groups:x,totalTokens:g}=i.useMemo(()=>{const u=new Map;let w=0;for(const p of s){const _=p.model||a("sessions.model.unknown"),b=Number(p.own_total_tokens||p.total_tokens||0),f=u.get(_)||{model:_,count:0,tokens:0};f.count+=1,f.tokens+=b,w+=b,u.set(_,f)}return{groups:[...u.values()].sort((p,_)=>_.tokens-p.tokens),totalTokens:w}},[s]);function k(u){return P("rounded-full border px-2.5 py-1 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u?"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:"ml-6 border-l-2 border-oai-gray-200 py-3 pl-4 dark:border-oai-gray-800",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"mr-1 text-xs font-medium text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":t==="all",onClick:()=>o("all"),className:k(t==="all"),children:a("sessions.thread.model_all",{count:s.length,tokens:m(g)})}),x.map(u=>e.jsx("button",{type:"button","aria-pressed":t===u.model,onClick:()=>o(u.model),className:k(t===u.model),children:a("sessions.thread.model_item",{model:u.model,count:u.count,tokens:m(u.tokens)})},u.model))]})})}function nt(){const[s,t]=i.useState(null),[o,x]=i.useState(null),[g,k]=i.useState(!0),[u,w]=i.useState(!1),[p,_]=i.useState("all"),[b,f]=i.useState("all"),[y,R]=i.useState("all"),[h,v]=i.useState(""),[N,C]=i.useState(G),[A,S]=i.useState(()=>new Set),[D,I]=i.useState(()=>new Map),M=i.useRef(0),{resolvedLocale:E}=ce(),L=i.useCallback(async(r=!1)=>{const c=++M.current;r?w(!0):k(!0),x(null);try{const n=await Pe({refresh:r});c===M.current&&t(n)}catch(n){c===M.current&&x(n?.message||String(n))}finally{c===M.current&&(k(!1),w(!1))}},[]);i.useEffect(()=>{J||W()?L(!1):k(!1)},[L]);const l=s?.sessions||Fe,j=i.useMemo(()=>{const r=new Set,c=[];for(const n of l){const d=n.project_key;!d||r.has(d)||(r.add(d),c.push({value:d,label:d}))}return c.sort((n,d)=>n.label.localeCompare(d.label))},[l]),F=i.useDeferredValue(h),T=i.useMemo(()=>{const r=F.trim().toLowerCase(),c=Oe(b);return l.filter(n=>p!=="all"&&n.source!==p||y!=="all"&&n.project_key!==y||!Ae(n,c)?!1:r?`${n.title||""} ${n.project_key||""} ${n.model||""} ${n.agent_nickname||""} ${n.agent_role||""} ${n.project_ref||""} ${n.session_id||""}`.toLowerCase().includes(r):!0)},[l,p,y,b,F]),O=i.useMemo(()=>{const r=new Set(T.map(d=>d.session_hash)),c=new Map,n=[];for(const d of T){const q=d.root_session_hash||d.parent_session_hash;if(d.parent_session_hash&&q&&r.has(q)){const $=c.get(q)||[];$.push(d),c.set(q,$)}else n.push(d)}return{roots:n,childrenByRoot:c,foldedCount:T.length-n.length}},[T]),Q=p!=="all"||b!=="all"||y!=="all"||h.trim()!=="";i.useEffect(()=>{C(G),S(new Set),I(new Map)},[p,y,b,F,l]);const K=i.useMemo(()=>O.roots.slice(0,N),[O.roots,N]),B=O.roots.length>K.length,H=i.useCallback(()=>C(r=>r+G),[]),re=i.useCallback(r=>{S(c=>{const n=new Set(c);return n.has(r)?n.delete(r):n.add(r),n})},[]),se=i.useCallback((r,c)=>{I(n=>{const d=new Map(n);return c==="all"?d.delete(r):d.set(r,c),d})},[]),z=i.useRef(null);i.useEffect(()=>{if(!B||typeof IntersectionObserver>"u")return;const r=z.current;if(!r)return;const c=new IntersectionObserver(n=>{n.some(d=>d.isIntersecting)&&H()},{rootMargin:"400px"});return c.observe(r),()=>c.disconnect()},[B,H]);const oe=i.useMemo(()=>$e.map(r=>({id:r.id,label:r.label()})),[E]),ne=i.useMemo(()=>ae.map(r=>({id:r.id,label:r.label()})),[E]),ie=Number(s?.session_count)>Number(s?.returned_count);return!J&&!W()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(me,{})}):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-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:a("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("sessions.page.subtitle")})]}),e.jsx("button",{type:"button",onClick:()=>{L(!0)},disabled:u||g,"aria-label":a("sessions.page.refresh"),title:a("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(de,{className:P("h-4 w-4",u&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pt-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(Z,{ariaLabel:a("sessions.filter.source_aria"),options:oe,value:p,onChange:_}),e.jsx(Z,{className:"pl-2",ariaLabel:a("sessions.filter.range_aria"),leading:e.jsx(Le,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),options:ne,value:b,onChange:f}),e.jsx(Ie,{options:j,value:y,onChange:R,allLabel:a("sessions.filter.project_all"),searchPlaceholder:a("sessions.filter.project_search"),emptyLabel:a("sessions.filter.project_empty"),ariaLabel:a("sessions.filter.project_aria")}),e.jsxs("div",{className:"relative w-72 max-w-full",children:[e.jsx(te,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(he,{type:"search",value:h,onChange:r=>v(r.target.value),onKeyDown:r=>{r.key==="Escape"&&h&&(r.preventDefault(),v(""))},"aria-label":a("sessions.action.search_aria"),placeholder:a("sessions.search.placeholder"),className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:r=>r.preventDefault(),onClick:()=>v(""),"aria-label":a("sessions.action.search_clear"),"aria-hidden":!h,tabIndex:h?0:-1,className:P("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",h?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(ue,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:O.foldedCount>0?a("sessions.thread.result_count",{roots:O.roots.length,subagents:O.foldedCount}):a("sessions.filter.result_count",{filtered:T.length,total:l.length})})]}),ie?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("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:a("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:()=>{L(!1)},className:"mt-4 inline-flex h-8 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:a("sessions.error.retry")})]}):g?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Ce,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),a("sessions.loading")]}):T.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:Q?a("sessions.empty.filtered_title"):a("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:Q?a("sessions.empty.filtered_body"):a("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:a("shared.error.prefix",{error:o})}):null,e.jsx("ul",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:K.map(r=>{const c=O.childrenByRoot.get(r.session_hash)||[],n=A.has(r.session_hash),d=D.get(r.session_hash)||"all",q=d==="all"?c:c.filter(function(le){return(le.model||a("sessions.model.unknown"))===d});return e.jsxs(ee.Fragment,{children:[e.jsx(X,{session:r,locale:E,childCount:c.length,expanded:n,onToggle:()=>re(r.session_hash)}),n&&c.length?e.jsx(Be,{sessions:c,selectedModel:d,onSelect:$=>se(r.session_hash,$)}):null,n?q.map($=>e.jsx(X,{session:$,locale:E,nested:!0},$.session_hash)):null]},r.session_hash)})}),B?e.jsx("div",{ref:z,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:H,className:"inline-flex h-8 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:a("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.privacy")})]})})})}export{nt as SessionsPage};
@@ -1 +0,0 @@
1
- import{c as r}from"./__vite-browser-external-DPOlUkcY.js";const t=["claude","codex","cursor","gemini","kimi","kiro","grok","copilot","antigravity","zcode","opencodeGo","qoder","qoderCn","codingPlan"],e={claude:"CLAUDE",codex:"CODEX",cursor:"CURSOR",gemini:"GEMINI",kimi:"KIMI",kiro:"KIRO",grok:"GROK",copilot:"COPILOT",antigravity:"ANTIGRAVITY",zcode:"ZCODE",opencodeGo:"OPENCODE",qoder:"QODER",qoderCn:"QODER-CN",codingPlan:"VOLCANO-ARK"};function c(i){return e[i]||null}function n(i){switch(i){case"claude":return r("limits.provider.claude");case"codex":return r("limits.provider.codex");case"cursor":return r("limits.provider.cursor");case"gemini":return r("limits.provider.gemini");case"kimi":return r("limits.provider.kimi");case"kiro":return r("limits.provider.kiro");case"grok":return r("limits.provider.grok");case"copilot":return r("limits.provider.copilot");case"antigravity":return r("limits.provider.antigravity");case"zcode":return r("limits.provider.zcode");case"opencodeGo":return r("limits.provider.opencode_go");case"qoder":return r("limits.provider.qoder");case"qoderCn":return r("limits.provider.qoder_cn");case"codingPlan":return r("limits.provider.ark_coding_plan");default:return String(i||"")}}export{t as L,c as a,n as l};
@@ -1 +0,0 @@
1
- import{r as o}from"./__vite-browser-external-DPOlUkcY.js";import{h as r,i as t,p as s}from"./react-DKXriBSF.js";function i(){!r.current&&t();const[e]=o.useState(s.current);return e}export{i as u};