tokentracker-cli 1.4.13 → 1.5.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 (116) hide show
  1. package/README.md +2 -2
  2. package/dashboard/dist/assets/{AchievementBadge-6wnHO-Hp.js → AchievementBadge-Dn39pyx9.js} +1 -1
  3. package/dashboard/dist/assets/{AchievementsPage-BpHA9auG.js → AchievementsPage-9_MxdI7O.js} +2 -2
  4. package/dashboard/dist/assets/{AchievementsSection-ySXWiLC3.js → AchievementsSection-CKDQGcJh.js} +1 -1
  5. package/dashboard/dist/assets/{BadgeDetailModal-DuxcntYu.js → BadgeDetailModal-DdrXPVRL.js} +1 -1
  6. package/dashboard/dist/assets/{BotAnimated-Dg1gSql-.js → BotAnimated-DsJDdDid.js} +1 -1
  7. package/dashboard/dist/assets/{Card-73qYdlEv.js → Card-Bz-sWY1C.js} +1 -1
  8. package/dashboard/dist/assets/{CloudCheckoutPage-C7-9p9zk.js → CloudCheckoutPage-DRjZcE0W.js} +1 -1
  9. package/dashboard/dist/assets/{CloudPage-CKcDcf6O.js → CloudPage-BNDyyX9r.js} +2 -2
  10. package/dashboard/dist/assets/{CommandPalette-Cq7TSYUV.js → CommandPalette-LbE6Icc0.js} +1 -1
  11. package/dashboard/dist/assets/{CommunityStatsModal-C0gj8QaO.js → CommunityStatsModal-DuEcAOB9.js} +1 -1
  12. package/dashboard/dist/assets/{ConfirmModal-Cuf2JDA9.js → ConfirmModal-B5V7ONKv.js} +1 -1
  13. package/dashboard/dist/assets/{Controls-COaS9RLV.js → Controls-ZfN0QwwD.js} +1 -1
  14. package/dashboard/dist/assets/{DashboardPage-Beg--N9T.js → DashboardPage-DqZPFmlv.js} +1 -1
  15. package/dashboard/dist/assets/{DateRangePopover-rNSRXWkr.js → DateRangePopover-CbkBeaEI.js} +1 -1
  16. package/dashboard/dist/assets/DevicePage-DrHjmpPH.js +1 -0
  17. package/dashboard/dist/assets/{DialogClose-CEYsCJ6-.js → DialogClose-DHaAwV1u.js} +1 -1
  18. package/dashboard/dist/assets/DialogDescription-CEY6jbs9.js +1 -0
  19. package/dashboard/dist/assets/{DialogTitle-CnaGDa7P.js → DialogTitle-CBhd4oLc.js} +1 -1
  20. package/dashboard/dist/assets/{ElectricLogo-CM0HfX6y.js → ElectricLogo-CSWd3b2H.js} +1 -1
  21. package/dashboard/dist/assets/{FadeIn-CngXKUqj.js → FadeIn-D5p6nDla.js} +1 -1
  22. package/dashboard/dist/assets/{HeaderGithubStar-DQn0rAVr.js → HeaderGithubStar-BKVSzY27.js} +1 -1
  23. package/dashboard/dist/assets/{HoverTooltip-By7PDA5D.js → HoverTooltip-CvkAyCDm.js} +1 -1
  24. package/dashboard/dist/assets/{IpCheckPage-BvrRGJNy.js → IpCheckPage-BEMJGKtl.js} +1 -1
  25. package/dashboard/dist/assets/{LandingPage-C0CnNfi_.js → LandingPage-iRp33enQ.js} +2 -2
  26. package/dashboard/dist/assets/{LeaderboardPage-iUXnjGy-.js → LeaderboardPage-DVMPrN4z.js} +2 -2
  27. package/dashboard/dist/assets/{LeaderboardProBadge-CrV2bYaH.js → LeaderboardProBadge-DwnaJoje.js} +1 -1
  28. package/dashboard/dist/assets/LeaderboardProfileModal-DnzVweLM.js +73 -0
  29. package/dashboard/dist/assets/{LeaderboardProfilePage-DmiiHi5U.js → LeaderboardProfilePage-BHNuPuW7.js} +1 -1
  30. package/dashboard/dist/assets/LimitsPage-9LitacBf.js +6 -0
  31. package/dashboard/dist/assets/{LocalOnlyNotice-0pQm9-gI.js → LocalOnlyNotice-DStlbPET.js} +1 -1
  32. package/dashboard/dist/assets/{LoginCard-OaDObE8j.js → LoginCard-I47ukXU5.js} +1 -1
  33. package/dashboard/dist/assets/{LoginModal-C0dRPusa.js → LoginModal-C4iotNjY.js} +1 -1
  34. package/dashboard/dist/assets/{LoginPage-D6CoX42w.js → LoginPage-46QSEnG0.js} +1 -1
  35. package/dashboard/dist/assets/{PetPage-Ch5t4JT_.js → PetPage-SvgDUR8o.js} +2 -2
  36. package/dashboard/dist/assets/{PopoverPopup-UtHXvmNC.js → PopoverPopup-k2ejLK1I.js} +1 -1
  37. package/dashboard/dist/assets/{ProviderIcon-CRlMy2AY.js → ProviderIcon-Bx1XKzin.js} +1 -1
  38. package/dashboard/dist/assets/{ResetPasswordPage-DijAhwkr.js → ResetPasswordPage-CcKIDknp.js} +1 -1
  39. package/dashboard/dist/assets/{Select-D1FvgdDV.js → Select-D0hLQyU8.js} +1 -1
  40. package/dashboard/dist/assets/{SelectItemText-Conq3RQN.js → SelectItemText-DJGBJhDK.js} +1 -1
  41. package/dashboard/dist/assets/{SelfHostPage-CLUgPEFh.js → SelfHostPage-CeIFGRep.js} +1 -1
  42. package/dashboard/dist/assets/{ServiceStatusPage-D7KRjgOE.js → ServiceStatusPage-DMtw0YDh.js} +1 -1
  43. package/dashboard/dist/assets/{SessionsPage-CWNrbLT4.js → SessionsPage-D6h5vSZn.js} +2 -2
  44. package/dashboard/dist/assets/{SettingsPage-Bh_PuEXU.js → SettingsPage-BZgpB5SB.js} +3 -3
  45. package/dashboard/dist/assets/{SkillsPage-DxZuztPd.js → SkillsPage-CtFuZ1ob.js} +1 -1
  46. package/dashboard/dist/assets/{TokenGalaxy-BE-dqlDy.js → TokenGalaxy-DC-no047.js} +1 -1
  47. package/dashboard/dist/assets/{TooltipPopup-DQrTDsmN.js → TooltipPopup-ZM0Ie2_C.js} +1 -1
  48. package/dashboard/dist/assets/{TrendMonitor-Cal2kaMh.js → TrendMonitor-fpLaqJ-o.js} +1 -1
  49. package/dashboard/dist/assets/{WidgetsPage-Cvv2NXRK.js → WidgetsPage-DIoHY6ZJ.js} +1 -1
  50. package/dashboard/dist/assets/{WrappedPage-H99MjZkq.js → WrappedPage-D1-7o8Z1.js} +1 -1
  51. package/dashboard/dist/assets/{__vite-browser-external-I1de5Swt.js → __vite-browser-external-DZF5L1pt.js} +3 -3
  52. package/dashboard/dist/assets/{agent-logos-BUBtw9FF.js → agent-logos-YBC1iAbE.js} +1 -1
  53. package/dashboard/dist/assets/{arrow-left-C99UO2S4.js → arrow-left-BIe3z7iW.js} +1 -1
  54. package/dashboard/dist/assets/{arrow-right-BMFV-A6L.js → arrow-right-CJmRcvYZ.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-up-right-CReo0rju.js → arrow-up-right-IgkBHoCl.js} +1 -1
  56. package/dashboard/dist/assets/{calendar-days-CiEobm13.js → calendar-days-DTuIv3ts.js} +1 -1
  57. package/dashboard/dist/assets/{check-BBOwGLur.js → check-DrXhhj46.js} +1 -1
  58. package/dashboard/dist/assets/{chevron-down-C08QHnpk.js → chevron-down-DHaFKHMK.js} +1 -1
  59. package/dashboard/dist/assets/{cloud-checkout-NOmtAy01.js → cloud-checkout-BffVMyzI.js} +1 -1
  60. package/dashboard/dist/assets/{composite-C5GvW04X.js → composite-M_CP_KSx.js} +1 -1
  61. package/dashboard/dist/assets/{copy-DgY9F9FR.js → copy-D5xoS-Q8.js} +1 -1
  62. package/dashboard/dist/assets/{download-B7xuZSZ2.js → download-CqomMv4-.js} +1 -1
  63. package/dashboard/dist/assets/{external-link-1nRJjSL1.js → external-link--q3pCw6b.js} +1 -1
  64. package/dashboard/dist/assets/{flame-CR1qiptA.js → flame-CUGlDV__.js} +1 -1
  65. package/dashboard/dist/assets/{format-tokens-DNLvupK2.js → format-tokens-BZ6TX9Km.js} +1 -1
  66. package/dashboard/dist/assets/{gift-DUUpsPxb.js → gift-BBgOeC20.js} +1 -1
  67. package/dashboard/dist/assets/{icons-qY8ZAPUu.js → icons-BELeB4ms.js} +1 -1
  68. package/dashboard/dist/assets/{index-Tl9T3Nm3.js → index-B1B6oAbl.js} +1 -1
  69. package/dashboard/dist/assets/{index-BvNIpRP0.js → index-CoRqgJ71.js} +1 -1
  70. package/dashboard/dist/assets/{index-CfdotR_D.js → index-CsdgnKGf.js} +1 -1
  71. package/dashboard/dist/assets/{index-7VLgsnkO.js → index-DkBvk4Qg.js} +1 -1
  72. package/dashboard/dist/assets/{info-DnT3wtaz.js → info-BG1vQZ1r.js} +1 -1
  73. package/dashboard/dist/assets/{link-2-CjxRD2lW.js → link-2-oi5TrXqi.js} +1 -1
  74. package/dashboard/dist/assets/{loader-circle-BYCsfrhr.js → loader-circle-BQQ_Xbby.js} +1 -1
  75. package/dashboard/dist/assets/{local-usage-transfer-DBfMvvqx.js → local-usage-transfer-Dwz-clJ-.js} +1 -1
  76. package/dashboard/dist/assets/{modifiers.esm-DG_gVjqU.js → modifiers.esm-C7a817l7.js} +1 -1
  77. package/dashboard/dist/assets/{monitor-smartphone-CJUH6nwc.js → monitor-smartphone-Bnbo7uRg.js} +1 -1
  78. package/dashboard/dist/assets/{play-DY4d-C2J.js → play-C_xI_JM_.js} +1 -1
  79. package/dashboard/dist/assets/{plus-Dydx6cB7.js → plus-xF6PK5As.js} +1 -1
  80. package/dashboard/dist/assets/{provider-display-DCtG1A8I.js → provider-display-DxquW3js.js} +1 -1
  81. package/dashboard/dist/assets/{react-D9IQudPE.js → react-CGK0_x3G.js} +1 -1
  82. package/dashboard/dist/assets/{safePolygon-CxfZ_vVn.js → safePolygon-CCoDMR4f.js} +1 -1
  83. package/dashboard/dist/assets/{search-DBso9ppI.js → search-EZAGpmfJ.js} +1 -1
  84. package/dashboard/dist/assets/{server-Bb_KzpvJ.js → server-2qbrx2G0.js} +1 -1
  85. package/dashboard/dist/assets/{shield-check-cnqpE0zI.js → shield-check-D8kUejpE.js} +1 -1
  86. package/dashboard/dist/assets/{skills-api-DMbIT8CJ.js → skills-api-DYPf1Vxh.js} +1 -1
  87. package/dashboard/dist/assets/{sortable.esm-2Wnda4fq.js → sortable.esm-D9gC08dQ.js} +1 -1
  88. package/dashboard/dist/assets/{store-CGDaAZE0.js → store-BWUCbK6Y.js} +1 -1
  89. package/dashboard/dist/assets/{terminal-yZ69kiqV.js → terminal-B16b7r6H.js} +1 -1
  90. package/dashboard/dist/assets/{trash-DytHiAPM.js → trash-BIEoE13C.js} +1 -1
  91. package/dashboard/dist/assets/{use-community-stats-DkR1XWs8.js → use-community-stats-DWS7YKbM.js} +1 -1
  92. package/dashboard/dist/assets/{use-latest-request-guard-D_4XuEoM.js → use-latest-request-guard-CYKu-VOB.js} +1 -1
  93. package/dashboard/dist/assets/{use-limits-display-prefs-BadNsZG8.js → use-limits-display-prefs-CEAjVxFr.js} +1 -1
  94. package/dashboard/dist/assets/{use-native-settings-BfxfnQAn.js → use-native-settings-vTg4j5Ln.js} +1 -1
  95. package/dashboard/dist/assets/{use-ordered-list-BHn-XC6u.js → use-ordered-list-CtXedlqH.js} +1 -1
  96. package/dashboard/dist/assets/use-reduced-motion-DVLsAhSA.js +1 -0
  97. package/dashboard/dist/assets/{use-transform-C0qKlh_s.js → use-transform-CdeW5xhz.js} +1 -1
  98. package/dashboard/dist/assets/{use-usage-limits-CQugaku6.js → use-usage-limits-DmDa5Py8.js} +1 -1
  99. package/dashboard/dist/assets/{useCurrency-ChAc4UHj.js → useCurrency-bqycM681.js} +1 -1
  100. package/dashboard/dist/assets/{usePositioner-CGtwrNEt.js → usePositioner-DEXS10fY.js} +1 -1
  101. package/dashboard/dist/assets/{useTokenFormat-CjvWdxnV.js → useTokenFormat-YF6hY8_m.js} +1 -1
  102. package/dashboard/dist/assets/{zap-WTlrDMoe.js → zap-Dg-ij-lq.js} +1 -1
  103. package/dashboard/dist/index.html +1 -1
  104. package/dashboard/dist/ip-check.html +1 -1
  105. package/dashboard/dist/leaderboard.html +1 -1
  106. package/dashboard/dist/share.html +1 -1
  107. package/package.json +1 -1
  108. package/src/lib/dsh-session.js +580 -0
  109. package/src/lib/local-api.js +40 -3
  110. package/src/lib/pricing/seed-snapshot.json +1 -1
  111. package/src/lib/session-analytics.js +89 -11
  112. package/dashboard/dist/assets/DevicePage-jZ9S-taT.js +0 -1
  113. package/dashboard/dist/assets/DialogDescription-BAaD46Xg.js +0 -1
  114. package/dashboard/dist/assets/LeaderboardProfileModal-iGgVOvl7.js +0 -73
  115. package/dashboard/dist/assets/LimitsPage-Bpp0LYGk.js +0 -6
  116. package/dashboard/dist/assets/use-reduced-motion-BsG6Qxa-.js +0 -1
@@ -28,7 +28,7 @@ const fsp = require("node:fs/promises");
28
28
  const os = require("node:os");
29
29
  const path = require("node:path");
30
30
  const readline = require("node:readline");
31
- const { listClaudeProjectFiles, listRolloutFilesDeep, claudeMessageDedupKey, normalizeClaudeUsage, readZcodeDbMessages, coerceEpochMs, resolveZcodeInstallPaths, normalizeOpencodeModelFields, normalizeOpencodeTokens, deriveOpencodeMessageFingerprint } = require("./rollout");
31
+ const { listClaudeProjectFiles, listRolloutFilesDeep, claudeMessageDedupKey, normalizeClaudeUsage, readZcodeDbMessages, coerceEpochMs, resolveZcodeInstallPaths, normalizeOpencodeModelFields, normalizeOpencodeTokens, deriveOpencodeMessageFingerprint, resolveDshHomes } = require("./rollout");
32
32
  const { parseCodexRolloutFile } = require("./codex-rollout-parser");
33
33
  const { computeRowCost, getModelPricingInfo } = require("./pricing");
34
34
  const { normalizePerformance, mergePerformance, createClaudePerformanceCollector, createCodexPerformanceCollector, createZcodePerformanceCollector } = require("./session-performance");
@@ -39,6 +39,7 @@ const { USD_TICKS_PER_USD, normalizeGrokUsage } = require("./grok-usage");
39
39
  const wsl = require("./wsl-probe");
40
40
  const { discoverKimiWireFiles, kimiSessionDependencies, readKimiSessions } = require("./kimi-session");
41
41
  const { discoverOmpSessionFiles, ompSessionDependencies, readOmpSessions } = require("./omp-session");
42
+ const { discoverDshSessionFiles, readDshSessions } = require("./dsh-session");
42
43
  const {
43
44
  appendUniqueDirs,
44
45
  dedupeDirsByRealpath,
@@ -1970,6 +1971,38 @@ async function scanOmpSession(filePath) {
1970
1971
  return rows[0] || null;
1971
1972
  }
1972
1973
 
1974
+ async function scanDshSessions(filePaths) {
1975
+ // Batch the whole inventory: a seeded Harness session replays its parent's
1976
+ // message ids, so cross-file identity is resolved before any row is emitted
1977
+ // (same contract as the hourly dsh reader's per-message identity).
1978
+ const rows = await readDshSessions(Array.isArray(filePaths) ? filePaths : [filePaths]);
1979
+ const scanned = rows.map(({ identity, files, title, ...row }) => finalizeRecord({
1980
+ ...row,
1981
+ title: cleanSessionTitle(title),
1982
+ version: SIDECAR_VERSION,
1983
+ source: "dsh",
1984
+ session_hash: sessionHash("dsh", identity),
1985
+ project_key: projectKey(row.project_ref, files[0]),
1986
+ ...sessionStorageUsage(files),
1987
+ }));
1988
+ // readDshSessions reports unreadable transcripts on a non-enumerable
1989
+ // property; map() built a fresh array, so carry the count (and the matching
1990
+ // accessor) over or the caller would cache a partial inventory as complete.
1991
+ return defineSkippedFileCount(scanned, rows.skippedFiles);
1992
+ }
1993
+
1994
+ function defineSkippedFileCount(rows, skippedFiles) {
1995
+ if (Number.isFinite(skippedFiles) && skippedFiles > 0) {
1996
+ Object.defineProperty(rows, "skippedFiles", { value: skippedFiles, enumerable: false });
1997
+ }
1998
+ return rows;
1999
+ }
2000
+
2001
+ async function scanDshSession(filePath) {
2002
+ const rows = await scanDshSessions([filePath]);
2003
+ return rows[0] || null;
2004
+ }
2005
+
1973
2006
  async function discoverSessionFiles(home, env = process.env, deps = {}) {
1974
2007
  const grokHome = resolveGrokHome(home);
1975
2008
  // config.scanRoots (#657): read from the tracker config unless the caller
@@ -2052,6 +2085,22 @@ async function discoverSessionFiles(home, env = process.env, deps = {}) {
2052
2085
  const opencodePaths = resolveInstallPaths({ nativeValue: opencodeNativeDir, wslValue: opencodeWslDir }, env, { platform: zcodePlatform });
2053
2086
  const opencode = [...new Set(Object.values(opencodePaths).filter(Boolean)
2054
2087
  .map((dir) => path.join(dir, "opencode.db")).filter((dbPath) => fs.existsSync(dbPath)))];
2088
+ // DeepSeek Harness keeps one directory per session under ~/.dsh/sessions.
2089
+ // Reuse the hourly reader's resolver so the Usage and Sessions views always
2090
+ // agree: an explicit TOKENTRACKER_DSH_HOME/$DSH_HOME replaces the home
2091
+ // outright (a user who pointed the harness elsewhere is not also running the
2092
+ // default, so an override never gets a WSL sibling spliced in), and only the
2093
+ // machine home probes WSL. A private harness home therefore needs no
2094
+ // config.scanRoots entry: the variable itself is the override.
2095
+ // An override describes where the *machine* keeps its harness home, so it only
2096
+ // applies when the caller asked about that same home: a test or a fixture
2097
+ // home must never pick up the logged-in user's transcripts. Same gate as the
2098
+ // kimi roots below.
2099
+ const usingMachineHome = path.resolve(home) === path.resolve((deps.homedir || os.homedir)());
2100
+ const dshRoots = usingMachineHome
2101
+ ? resolveDshHomes(env, { nativeHome: path.join(home, ".dsh") })
2102
+ : [path.join(home, ".dsh")];
2103
+ const dsh = discoverDshSessionFiles(dedupeDirsByRealpath(dshRoots), incomplete);
2055
2104
  const kimiRoots = [".kimi", ".kimi-code"].flatMap((directory) => {
2056
2105
  const roots = providerRoots(home, directory, env, deps);
2057
2106
  const override = env[directory === ".kimi" ? "KIMI_HOME" : "KIMI_CODE_HOME"];
@@ -2062,12 +2111,11 @@ async function discoverSessionFiles(home, env = process.env, deps = {}) {
2062
2111
  return roots;
2063
2112
  });
2064
2113
  const kimi = discoverKimiWireFiles(dedupeDirsByRealpath(kimiRoots), incomplete);
2065
- const usingMachineHome = path.resolve(home) === path.resolve((deps.homedir || os.homedir)());
2066
2114
  const ompEnv = usingMachineHome
2067
2115
  ? { ...env, HOME: home }
2068
2116
  : { HOME: home, OMP_HOME: path.join(home, ".omp") };
2069
2117
  const omp = discoverOmpSessionFiles(ompEnv, incomplete);
2070
- return { claude, codex: groupCodexFiles([...codex, ...archived]), grok, zcode, opencode, kimi, omp, incomplete };
2118
+ return { claude, codex: groupCodexFiles([...codex, ...archived]), grok, zcode, opencode, kimi, omp, dsh, incomplete };
2071
2119
  }
2072
2120
 
2073
2121
  // Warn once per unreadable directory per process: the dashboard polls this
@@ -2217,13 +2265,15 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2217
2265
  const retryKimiScan = fs.existsSync(incompleteKimiPath);
2218
2266
  const incompleteOmpPath = `${metaPath}.omp-incomplete`;
2219
2267
  const retryOmpScan = fs.existsSync(incompleteOmpPath);
2268
+ const incompleteDshPath = `${metaPath}.dsh-incomplete`;
2269
+ const retryDshScan = fs.existsSync(incompleteDshPath);
2220
2270
  let previousMeta = null;
2221
2271
  if (!force) {
2222
2272
  try {
2223
2273
  previousMeta = JSON.parse(fs.readFileSync(metaPath, "utf8"));
2224
2274
  const checkedAt = Date.parse(previousMeta.checked_at || previousMeta.generated_at || "");
2225
2275
  if (
2226
- !retryZcodeScan && !retryOpencodeScan && !retryKimiScan && !retryOmpScan && previousMeta.version === SIDECAR_VERSION &&
2276
+ !retryZcodeScan && !retryOpencodeScan && !retryKimiScan && !retryOmpScan && !retryDshScan && previousMeta.version === SIDECAR_VERSION &&
2227
2277
  Number.isFinite(checkedAt) &&
2228
2278
  Date.now() - checkedAt < Math.max(0, Number(cacheTtlMs) || 0)
2229
2279
  ) {
@@ -2257,13 +2307,14 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2257
2307
  ...kimiSessionDependencies(discovered.kimi),
2258
2308
  ...discovered.omp,
2259
2309
  ...ompSessionDependencies(discovered.omp),
2310
+ ...discovered.dsh,
2260
2311
  ...discovered.grok,
2261
2312
  ...discovered.grok.map(grokSummaryPathFor),
2262
2313
  ...discovered.grok.map(grokSignalsPathFor),
2263
2314
  // db + its WAL sidecars: the trio is one logical file for change detection.
2264
2315
  ...[...(discovered.zcode || []), ...(discovered.opencode || [])].flatMap((dbPath) => [dbPath, `${dbPath}-wal`, `${dbPath}-shm`]),
2265
2316
  ]);
2266
- if (!force && !retryZcodeScan && !retryOpencodeScan && !retryKimiScan && !retryOmpScan && previousMeta?.version === SIDECAR_VERSION && previousMeta.signature === signature) {
2317
+ if (!force && !retryZcodeScan && !retryOpencodeScan && !retryKimiScan && !retryOmpScan && !retryDshScan && previousMeta?.version === SIDECAR_VERSION && previousMeta.signature === signature) {
2267
2318
  await writeAtomic(metaPath, `${JSON.stringify({ ...previousMeta, checked_at: new Date().toISOString() })}\n`);
2268
2319
  return readSidecar(sidecarPath);
2269
2320
  }
@@ -2287,6 +2338,7 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2287
2338
  ...(discovered.opencode.length ? [{ source: "opencode", filePath: discovered.opencode, scan: scanOpencodeSessions }] : []),
2288
2339
  ...(discovered.kimi.length ? [{ source: "kimi", filePath: discovered.kimi, scan: scanKimiSessions }] : []),
2289
2340
  ...(discovered.omp.length ? [{ source: "omp", filePath: discovered.omp, scan: scanOmpSessions }] : []),
2341
+ ...(discovered.dsh.length ? [{ source: "dsh", filePath: discovered.dsh, scan: scanDshSessions }] : []),
2290
2342
  ];
2291
2343
  // Files we could not turn into a row (permission denied, half-written line,
2292
2344
  // vanished mid-scan). Swallowing these silently made sessions disappear with
@@ -2296,6 +2348,7 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2296
2348
  let incompleteOpencodeScan = false;
2297
2349
  let incompleteKimiScan = false;
2298
2350
  let incompleteOmpScan = false;
2351
+ let incompleteDshScan = false;
2299
2352
  for (const entry of entries) {
2300
2353
  const cacheKey = sessionFileCacheKey(entry.source, entry.filePath);
2301
2354
  const statKey = analyticsEntryStatKey(entry.source, entry.filePath);
@@ -2305,11 +2358,12 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2305
2358
  if (entry.source === "opencode") incompleteOpencodeScan = true;
2306
2359
  if (entry.source === "kimi") incompleteKimiScan = true;
2307
2360
  if (entry.source === "omp") incompleteOmpScan = true;
2361
+ if (entry.source === "dsh") incompleteDshScan = true;
2308
2362
  continue;
2309
2363
  }
2310
2364
  let rows = null;
2311
- if (!force && !(entry.source === "zcode" && retryZcodeScan) && !(entry.source === "opencode" && retryOpencodeScan) && !(entry.source === "kimi" && retryKimiScan) && !(entry.source === "omp" && retryOmpScan) && previousFiles[cacheKey]?.stat_key === statKey) {
2312
- if (entry.source === "zcode" || entry.source === "opencode" || entry.source === "kimi" || entry.source === "omp") {
2365
+ if (!force && !(entry.source === "zcode" && retryZcodeScan) && !(entry.source === "opencode" && retryOpencodeScan) && !(entry.source === "kimi" && retryKimiScan) && !(entry.source === "omp" && retryOmpScan) && !(entry.source === "dsh" && retryDshScan) && previousFiles[cacheKey]?.stat_key === statKey) {
2366
+ if (entry.source === "zcode" || entry.source === "opencode" || entry.source === "kimi" || entry.source === "omp" || entry.source === "dsh") {
2313
2367
  // One db scans to many cached rows; recover them all from the previous
2314
2368
  // pass. An empty recovery means the sidecar lost its rows — rescan.
2315
2369
  const cached = previousRows.filter((row) => row?.source === entry.source);
@@ -2323,6 +2377,17 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2323
2377
  try {
2324
2378
  const scanned = await entry.scan(entry.filePath);
2325
2379
  rows = Array.isArray(scanned) ? scanned.filter(Boolean) : (scanned ? [scanned] : []);
2380
+ // Batch sources count the files they had to give up on themselves.
2381
+ // A dsh batch is one deduplicated inventory, so a single unreadable log
2382
+ // makes the whole batch partial: flag it incomplete and keep the last
2383
+ // complete rows instead of caching a silently smaller inventory.
2384
+ if (Array.isArray(scanned) && Number.isFinite(scanned.skippedFiles)) {
2385
+ skippedFiles += scanned.skippedFiles;
2386
+ if (entry.source === "dsh" && scanned.skippedFiles > 0) {
2387
+ incompleteDshScan = true;
2388
+ rows = [];
2389
+ }
2390
+ }
2326
2391
  } catch (error) {
2327
2392
  // One active/partial session must not poison the sidecar, but do not
2328
2393
  // pretend it never existed either.
@@ -2331,6 +2396,7 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2331
2396
  if (entry.source === "opencode") incompleteOpencodeScan = true;
2332
2397
  if (entry.source === "kimi") incompleteKimiScan = true;
2333
2398
  if (entry.source === "omp") incompleteOmpScan = true;
2399
+ if (entry.source === "dsh") incompleteDshScan = true;
2334
2400
  if (!process.env.NODE_TEST_CONTEXT) {
2335
2401
  console.warn(`[session-analytics] skipped ${entry.source} session file: ${error?.message || error}`);
2336
2402
  }
@@ -2344,7 +2410,7 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2344
2410
  // so key each by the db path plus its session id; a bare session id as a
2345
2411
  // separate path element would be path.resolve()d against the process cwd
2346
2412
  // and never match across runs.
2347
- row._cache_key = (entry.source === "zcode" || entry.source === "opencode" || entry.source === "kimi" || entry.source === "omp") && (row.session_id || row.session_hash)
2413
+ row._cache_key = (entry.source === "zcode" || entry.source === "opencode" || entry.source === "kimi" || entry.source === "omp" || entry.source === "dsh") && (row.session_id || row.session_hash)
2348
2414
  ? `${cacheKey}#${sessionHash(entry.source, row.session_id || row.session_hash)}`
2349
2415
  : cacheKey;
2350
2416
  sessions.push(row);
@@ -2372,10 +2438,18 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2372
2438
  await writeAtomic(incompleteOmpPath, "1\n");
2373
2439
  sessions.push(...readSidecar(sidecarPath).filter((row) => row.source === "omp" && row.version === SIDECAR_VERSION));
2374
2440
  }
2441
+ if (incompleteDshScan) {
2442
+ await writeAtomic(incompleteDshPath, "1\n");
2443
+ // Replay ownership depends on the entire inventory. A readable fork may
2444
+ // claim an unreadable parent's events, so retain the complete batch rather
2445
+ // than combining newly attributed rows with the parent's cached usage.
2446
+ sessions.push(...readSidecar(sidecarPath).filter((row) =>
2447
+ row.source === "dsh" && row.version === SIDECAR_VERSION));
2448
+ }
2375
2449
  sessions.sort((a, b) => String(b.ended_at || "").localeCompare(String(a.ended_at || "")));
2376
2450
  // A failed database scan is an incomplete inventory. Keep the last complete
2377
2451
  // snapshot and signature so an unchanged database is retried next build.
2378
- if (incompleteDirs.length === 0 && !incompleteZcodeScan && !incompleteOpencodeScan && !incompleteKimiScan && !incompleteOmpScan) {
2452
+ if (incompleteDirs.length === 0 && !incompleteZcodeScan && !incompleteOpencodeScan && !incompleteKimiScan && !incompleteOmpScan && !incompleteDshScan) {
2379
2453
  const content = sessions.map(serializeSessionRecord).join("\n") + (sessions.length ? "\n" : "");
2380
2454
  await writeAtomic(sidecarPath, content);
2381
2455
  const generatedAt = new Date().toISOString();
@@ -2390,6 +2464,7 @@ async function buildSessionAnalyticsInternal({ home = os.homedir(), force = fals
2390
2464
  await fsp.rm(incompleteOpencodePath, { force: true });
2391
2465
  await fsp.rm(incompleteKimiPath, { force: true });
2392
2466
  await fsp.rm(incompleteOmpPath, { force: true });
2467
+ await fsp.rm(incompleteDshPath, { force: true });
2393
2468
  }
2394
2469
  // Non-enumerable so the array still behaves exactly like a plain row list
2395
2470
  // for every existing caller (map/filter/JSON of the rows is unaffected).
@@ -2863,7 +2938,7 @@ function annotateThreadUsage(rows) {
2863
2938
  const identity = (row, id = row.session_id) => `${row.source}\u0000${id}`;
2864
2939
 
2865
2940
  for (const row of rows || []) {
2866
- if ((row?.source !== "codex" && row?.source !== "zcode" && row?.source !== "opencode") || typeof row.session_id !== "string" || !row.session_id) continue;
2941
+ if ((row?.source !== "codex" && row?.source !== "zcode" && row?.source !== "opencode" && row?.source !== "dsh") || typeof row.session_id !== "string" || !row.session_id) continue;
2867
2942
  const existing = byId.get(identity(row));
2868
2943
  if (existing && existing !== row) {
2869
2944
  existing.parent_link_conflict = true;
@@ -2941,7 +3016,8 @@ function annotateThreadUsage(rows) {
2941
3016
  }
2942
3017
 
2943
3018
  for (const row of rows || []) {
2944
- const threadAware = (row.source === "codex" || row.source === "zcode" || row.source === "opencode")
3019
+ const threadAware = (row.source === "codex" || row.source === "zcode"
3020
+ || row.source === "opencode" || row.source === "dsh")
2945
3021
  && typeof row.session_id === "string" && row.session_id;
2946
3022
  row.own_total_tokens = finite(row.total_tokens);
2947
3023
  row.own_cost_usd = finite(row.cost_usd);
@@ -3019,6 +3095,8 @@ module.exports = {
3019
3095
  scanKimiSessions,
3020
3096
  scanOmpSessions,
3021
3097
  scanOmpSession,
3098
+ scanDshSessions,
3099
+ scanDshSession,
3022
3100
  buildSessionAnalytics,
3023
3101
  summarizeSessions,
3024
3102
  listSessionsForBrowser,
@@ -1 +0,0 @@
1
- import{a as b,r as l,j as r,c as e,f as v}from"./__vite-browser-external-I1de5Swt.js";const f={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_VERSION:"1.4.13",VITE_INSFORGE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3OC0xMjM0LTU2NzgtOTBhYi1jZGVmMTIzNDU2NzgiLCJlbWFpbCI6ImFub25AaW5zZm9yZ2UuY29tIiwicm9sZSI6ImFub24iLCJpYXQiOjE3ODExNDU5NDd9.T0auta_IrVIh0uXW1bob5QSnzvsnJmN28r5XkSGEuQY",VITE_INSFORGE_BASE_URL:"https://srctyff5.us-east.insforge.app",VITE_SENTRY_DSN:"https://5f9fc9cc76a1d9320197c63a4cbef478@o4512274440781824.ingest.us.sentry.io/4512286762139648"};function x(){return v(),`${(f&&"https://srctyff5.us-east.insforge.app"||"https://srctyff5.us-east.insforge.app").replace(/\/$/,"")}/functions/tokentracker-device-flow-grant`}function p(s){return(s||"").toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9-]/g,"")}function h(){const s=b(),[m,g]=l.useState(""),[i,a]=l.useState({kind:"idle",message:""});l.useEffect(()=>{try{const d=new URLSearchParams(window.location.search).get("user_code");d&&g(p(d))}catch{}},[]);async function u(c){if(c?.preventDefault?.(),!s?.signedIn){a({kind:"error",message:e("device.approval.error.sign_in")});return}const d=p(m);if(!/^[A-HJKMNP-Z2-9]{4}-[A-HJKMNP-Z2-9]{4}$/.test(d)){a({kind:"error",message:e("device.approval.error.invalid_code")});return}a({kind:"working",message:e("device.approval.action.approving")});try{const n=await s.getAccessToken?.();if(!n){a({kind:"error",message:e("device.approval.error.no_token")});return}const o=await fetch(x(),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({user_code:d})}),t=await o.json().catch(()=>({}));o.ok?a({kind:"success",message:t.status==="already_approved"?t.client_info?e("device.approval.success.already_client",{client:t.client_info}):e("device.approval.success.already"):t.client_info?e("device.approval.success.approved_client",{client:t.client_info}):e("device.approval.success.approved")}):o.status===404?a({kind:"error",message:e("device.approval.error.not_found")}):o.status===410?a({kind:"error",message:e("device.approval.error.expired")}):o.status===401?a({kind:"error",message:e("device.approval.error.session_expired")}):a({kind:"error",message:t?.error?e("device.approval.error.server_detail",{message:t.error}):e("device.approval.error.server",{status:o.status})})}catch(n){a({kind:"error",message:e("device.approval.error.network",{message:n?.message||n})})}}return r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white dark:bg-oai-gray-950 px-6 py-12",children:r.jsxs("div",{className:"w-full max-w-md rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-8",children:[r.jsx("h1",{className:"text-2xl font-semibold text-oai-gray-900 dark:text-white mb-2",children:e("device.approval.title")}),r.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mb-6",children:e("device.approval.description")}),s?.signedIn?null:r.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 dark:bg-amber-900/20 dark:border-amber-800 p-4 mb-4",children:r.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:e("device.approval.sign_in_banner")})}),r.jsxs("form",{onSubmit:u,className:"space-y-4",children:[r.jsxs("label",{className:"block",children:[r.jsx("span",{className:"block text-xs font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400 mb-1",children:e("device.approval.code_label")}),r.jsx("input",{type:"text",value:m,onChange:c=>g(p(c.target.value)),placeholder:"XXXX-XXXX",spellCheck:!1,autoCapitalize:"characters",maxLength:9,className:"w-full font-mono text-xl tracking-widest text-center rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-900 dark:text-white px-4 py-3 focus:outline-none focus:ring-inset focus:ring-2 focus:ring-emerald-600"})]}),r.jsx("button",{type:"submit",disabled:i.kind==="working"||!s?.signedIn,className:"w-full rounded-md bg-emerald-600 hover:bg-emerald-500 disabled:bg-oai-gray-300 disabled:cursor-not-allowed text-white font-medium py-3 transition-colors",children:i.kind==="working"?e("device.approval.action.approving"):e("device.approval.action.approve")})]}),i.kind==="success"&&r.jsx("div",{className:"mt-4 rounded-md border border-emerald-200 bg-emerald-50 dark:bg-emerald-900/20 dark:border-emerald-800 p-4",children:r.jsx("p",{className:"text-sm text-emerald-700 dark:text-emerald-300",children:i.message})}),i.kind==="error"&&r.jsx("div",{className:"mt-4 rounded-md border border-red-200 bg-red-50 dark:bg-red-900/20 dark:border-red-800 p-4",children:r.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:i.message})})]})})}export{h as default};
@@ -1 +0,0 @@
1
- import{r as n,J as a}from"./__vite-browser-external-I1de5Swt.js";import{u as p}from"./DialogTitle-CnaGDa7P.js";import{u as c}from"./composite-C5GvW04X.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,73 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BadgeDetailModal-DuxcntYu.js","assets/__vite-browser-external-I1de5Swt.js","assets/__vite-browser-external-Br-KAXh6.css","assets/react-D9IQudPE.js","assets/AchievementBadge-6wnHO-Hp.js","assets/zap-WTlrDMoe.js","assets/flame-CR1qiptA.js","assets/calendar-days-CiEobm13.js","assets/shield-check-cnqpE0zI.js","assets/use-transform-C0qKlh_s.js","assets/use-reduced-motion-BsG6Qxa-.js","assets/AchievementsSection-ySXWiLC3.js","assets/format-tokens-DNLvupK2.js","assets/DialogTitle-CnaGDa7P.js","assets/composite-C5GvW04X.js","assets/store-CGDaAZE0.js"])))=>i.map(i=>d[i]);
2
- import{o as ie,a as W,r as h,aO as ne,j as e,c as i,aP as le,Q as de,U as ce,aQ as me,aR as xe,y as c,x as ge,aA as Z,A as pe,L as he,V as G,an as ue,l as fe,az as be,X as ye,i as ke,_ as je,aS as ve}from"./__vite-browser-external-I1de5Swt.js";import{A as _e,f as Ne}from"./provider-display-DCtG1A8I.js";import{u as we}from"./useCurrency-ChAc4UHj.js";import{u as X}from"./useTokenFormat-CjvWdxnV.js";import{L as Y,a as K}from"./LeaderboardProBadge-CrV2bYaH.js";import{P as $}from"./ProviderIcon-CRlMy2AY.js";import{H as Ae,A as V,s as Se,c as Me,b as ze,t as Pe,h as Ce}from"./AchievementBadge-6wnHO-Hp.js";import{A as Ie}from"./AchievementsSection-ySXWiLC3.js";import{A as U}from"./arrow-up-right-CReo0rju.js";import{L as De}from"./link-2-CjxRD2lW.js";import{C as Te}from"./check-BBOwGLur.js";import{D as Be,a as Le,b as $e,c as Ue,d as Re,e as Fe}from"./DialogTitle-CnaGDa7P.js";import"./terminal-yZ69kiqV.js";import"./play-DY4d-C2J.js";import"./info-DnT3wtaz.js";import"./TooltipPopup-DQrTDsmN.js";import"./composite-C5GvW04X.js";import"./store-CGDaAZE0.js";import"./safePolygon-CxfZ_vVn.js";import"./usePositioner-CGtwrNEt.js";import"./zap-WTlrDMoe.js";import"./flame-CR1qiptA.js";import"./calendar-days-CiEobm13.js";import"./shield-check-cnqpE0zI.js";import"./react-D9IQudPE.js";import"./format-tokens-DNLvupK2.js";import"./use-reduced-motion-BsG6Qxa-.js";const q={name:"code-xml",size:24,node:[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],aliases:["code-2"]};q.node;const Oe=ie(q),R="tokentracker_anon_id";let M=null;function F(){try{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const r=Math.random()*16|0;return(a==="x"?r:r&3|8).toString(16)})}function O(){if(M)return M;try{let a=localStorage.getItem(R);return a||(a=F(),localStorage.setItem(R,a)),M=a,a}catch{return M=F(),M}}function Q({userId:a}){const{signedIn:r,getAccessToken:o}=W(),[t,s]=h.useState(!1),[n,g]=h.useState(0),[l,x]=h.useState(!1),[u,b]=h.useState(!1),[j,z]=h.useState(!1),[P,T]=h.useState([]),[N,w]=h.useState(!1),C=h.useRef(0),v=h.useCallback(async()=>{if(r)try{const d=await o();if(d)return{accessToken:d,anonId:O()}}catch{}return{anonId:O()}},[r,o]);h.useEffect(()=>{let d=!1;return a?(x(!1),(async()=>{const m=await v();try{const p=await ne({userId:a,...m});if(d)return;g(Number(p?.count)||0),s(!!p?.liked),x(!0)}catch{if(d)return;g(0),s(!1),x(!0)}})(),()=>{d=!0}):(x(!1),()=>{d=!0})},[a,v]);const _=()=>{z(!0),setTimeout(()=>z(!1),450),w(!0),setTimeout(()=>w(!1),500);const d=["#ff4757","#ff6b81","#ffa502","#70a1ff","#2ed573","#a29bfe"],m=["circle","heart"],p=[];for(let y=0;y<12;y++){const f=(y*30+Math.random()*20-10)*(Math.PI/180),k=45+Math.random()*45,B=Math.cos(f)*k,ee=Math.sin(f)*k-(10+Math.random()*15),ae=Math.random()*360-180,re=6+Math.random()*8,te=d[Math.floor(Math.random()*d.length)],se=m[Math.floor(Math.random()*m.length)],oe=++C.current;p.push({id:oe,tx:B,ty:ee,rot:ae,size:re,color:te,shape:se})}T(y=>[...y,...p]),setTimeout(()=>{T(y=>y.filter(f=>!p.find(k=>k.id===f.id)))},850)},A=async d=>{b(!0);try{const m=await v(),p=await le({userId:a,action:d,...m});p&&Number.isFinite(Number(p.count))&&g(Number(p.count)),p&&typeof p.liked=="boolean"&&s(p.liked)}catch{s(m=>!m),g(m=>d==="like"?Math.max(0,m-1):m+1)}finally{b(!1)}},S=d=>{d.stopPropagation(),!(!a||!l||u)&&(t?(s(!1),g(m=>Math.max(0,m-1)),A("unlike")):(s(!0),g(m=>m+1),_(),A("like")))};return e.jsxs("div",{className:"relative inline-flex items-center select-none z-10",children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:`
3
- @keyframes tt-like-pop {
4
- 0% { transform: scale(1); }
5
- 25% { transform: scale(0.75); }
6
- 50% { transform: scale(1.35); }
7
- 75% { transform: scale(0.9); }
8
- 100% { transform: scale(1); }
9
- }
10
- @keyframes tt-particle-fly {
11
- 0% {
12
- transform: translate(0, 0) scale(1) rotate(0deg);
13
- opacity: 1;
14
- }
15
- 70% {
16
- opacity: 0.8;
17
- }
18
- 100% {
19
- transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rot));
20
- opacity: 0;
21
- }
22
- }
23
- @keyframes tt-num-scroll {
24
- 0% { transform: translateY(8px); opacity: 0; }
25
- 100% { transform: translateY(0); opacity: 1; }
26
- }
27
- .tt-animate-pop {
28
- animation: tt-like-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
29
- }
30
- .tt-particle {
31
- position: absolute;
32
- top: 50%;
33
- left: 50%;
34
- margin-top: -6px;
35
- margin-left: -6px;
36
- pointer-events: none;
37
- z-index: 50;
38
- }
39
- .tt-num-anim {
40
- animation: tt-num-scroll 0.25s ease-out forwards;
41
- }
42
- `}}),P.map(d=>e.jsx("span",{className:"tt-particle",style:{"--tx":`${d.tx}px`,"--ty":`${d.ty}px`,"--rot":`${d.rot}deg`,width:`${d.size}px`,height:`${d.size}px`,backgroundColor:d.shape==="circle"?d.color:"transparent",borderRadius:d.shape==="circle"?"50%":"0",animation:"tt-particle-fly 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards"},children:d.shape==="heart"&&e.jsx("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:d.color,className:"w-full h-full",children:e.jsx("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"})})},d.id)),e.jsxs("button",{type:"button",onClick:S,disabled:!l||u,"aria-label":t?i("leaderboard.profile.like.aria_unlike"):i("leaderboard.profile.like.aria_like"),className:`group flex items-center justify-center gap-1.5 h-8 min-w-[48px] px-2.5 rounded-full border transition-all duration-300 outline-none focus-visible:ring-2 focus-visible:ring-rose-500/50 disabled:opacity-60 disabled:cursor-default ${t?"bg-rose-50/60 border-rose-200/80 text-rose-500 dark:bg-rose-950/20 dark:border-rose-900/40 dark:text-rose-400 shadow-sm":"bg-white/80 border-oai-gray-200 text-oai-gray-500 hover:border-rose-200 hover:text-rose-500 hover:bg-rose-50/30 dark:bg-oai-gray-950/50 dark:border-white/10 dark:text-oai-gray-400 dark:hover:border-rose-900/50 dark:hover:text-rose-400 dark:hover:bg-rose-950/5"}`,children:[e.jsx("span",{className:j?"tt-animate-pop":"group-active:scale-90 transition-transform duration-100",children:e.jsx(Ae,{size:14,className:`transition-all duration-300 ${t?"fill-rose-500 text-rose-500 dark:fill-rose-400 dark:text-rose-400":"fill-transparent"}`})}),e.jsx("span",{className:`text-[12px] font-bold font-mono tabular-nums tracking-tight ${t?"text-rose-600 dark:text-rose-400":"text-oai-gray-600 dark:text-oai-gray-400"} ${N?"tt-num-anim":""}`,children:l?n:"·"})]})]})}function He({badge:a,badgeLabel:r,className:o="",...t}){return e.jsxs("div",{className:`relative inline-flex shrink-0 ${o}`,children:[e.jsx(Y,{...t}),a?e.jsx("span",{className:"absolute -bottom-1 -right-1 inline-flex rounded-full ring-2 ring-white dark:ring-oai-gray-950",children:e.jsx(V,{badgeId:a.id,tier:a.tier,size:"sm",label:r})}):null]})}function Ee({badges:a,isOwn:r=!1,onSelect:o,className:t=""}){const s=Se((Array.isArray(a)?a:[]).filter(n=>n&&Me.has(n.id))).filter(n=>r||(n.tier||0)>=1);return s.length===0?null:e.jsx("div",{className:`flex flex-wrap items-center pr-2.5 ${t}`,children:s.map((n,g)=>{const l=(n.tier||0)>=1,x=i(ze(n.id,"name")),u=l?i(`achievements.tier.${Pe(n.tier)}`):i("achievements.modal.locked");return e.jsx("button",{type:"button",onClick:o?()=>o(n):void 0,title:`${x} · ${u}`,"aria-label":i("achievements.badge.aria",{name:x,tier:u}),style:{zIndex:s.length-g},className:"group relative shrink-0 -mr-2.5 rounded-full transition-transform duration-200 ease-out hover:z-30 hover:-translate-y-1 active:scale-95 focus-visible:z-30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60",children:e.jsx(V,{badgeId:n.id,tier:n.tier,locked:!l,size:"md",className:"rounded-full ring-2 ring-white transition-shadow duration-200 group-hover:shadow-md dark:ring-oai-gray-950"})},n.id)})})}const We=G.lazy(()=>je(()=>import("./BadgeDetailModal-DuxcntYu.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])));function Ze(a,r,o){const t=Number(a);return!Number.isFinite(t)||t<0?"—":t>0&&t<.01?`<${r==="USD"?"$":""}0.01`:Z(t,{decimals:2,currency:r,rate:o})}function H(a,r,o){const t=Number(a);if(!Number.isFinite(t)||t<0)return"—";if(t<1e3)return Ze(t,r,o);const s=r==="USD"?t:t*(o||1);return`${r==="USD"?"$":""}${ke(s,{decimals:1})}`}function Ge(a){const r=Array.isArray(a)?a:[];if(r.length===0)return null;const o=r.map(s=>({day:s.date,total_tokens:s.total_tokens,models:s.models||null})),t=r[r.length-1]?.date;return be({dailyRows:o,weeks:52,to:t})}const Xe=`
43
- @keyframes tt-shimmer {
44
- 100% { transform: translateX(100%); }
45
- }
46
- .tt-shimmer-bar {
47
- position: relative;
48
- overflow: hidden;
49
- }
50
- .tt-shimmer-bar::after {
51
- position: absolute;
52
- top: 0; right: 0; bottom: 0; left: 0;
53
- transform: translateX(-100%);
54
- background-image: linear-gradient(
55
- 90deg,
56
- rgba(0, 0, 0, 0) 0%,
57
- rgba(0, 0, 0, 0.02) 20%,
58
- rgba(0, 0, 0, 0.06) 60%,
59
- rgba(0, 0, 0, 0) 100%
60
- );
61
- animation: tt-shimmer 1.6s infinite;
62
- content: '';
63
- }
64
- .dark .tt-shimmer-bar::after {
65
- background-image: linear-gradient(
66
- 90deg,
67
- rgba(255, 255, 255, 0) 0%,
68
- rgba(255, 255, 255, 0.02) 20%,
69
- rgba(255, 255, 255, 0.06) 60%,
70
- rgba(255, 255, 255, 0) 100%
71
- );
72
- }
73
- `;function Ye({variant:a="modal"}){const r="rounded bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar",o=a==="page";return e.jsxs("div",{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Xe}}),o?e.jsxs("div",{className:"flex items-start gap-5 px-6 sm:px-8 pt-8 pb-7 animate-fade-in",children:[e.jsx("div",{className:"h-[68px] w-[68px] rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start justify-between gap-4 pt-0.5",children:[e.jsxs("div",{className:"min-w-0 space-y-2.5",children:[e.jsx("div",{className:c(r,"h-7 w-48")}),e.jsx("div",{className:c(r,"h-3.5 w-32")})]}),e.jsxs("div",{className:"shrink-0 space-y-1.5 flex flex-col items-end",children:[e.jsx("div",{className:c(r,"h-2.5 w-8")}),e.jsx("div",{className:c(r,"h-7 w-12")})]})]})]}):e.jsxs("div",{className:"flex items-start gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60 animate-fade-in",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2 pt-1",children:[e.jsx("div",{className:c(r,"h-4 w-40")}),e.jsx("div",{className:c(r,"h-3 w-56")})]}),e.jsx("div",{className:c(r,"h-4 w-4 shrink-0 mt-1")})]}),e.jsxs("div",{className:c("space-y-6",o?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"px-6 py-5"),children:[e.jsx("div",{className:"grid grid-cols-4 gap-x-6 gap-y-4",children:Array.from({length:4}).map((t,s)=>e.jsxs("div",{children:[e.jsx("div",{className:c(r,"h-6 w-20")}),e.jsx("div",{className:c(r,"mt-2 h-3 w-14")})]},s))}),e.jsx("div",{className:"space-y-3 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:Array.from({length:3}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-3 w-24")}),e.jsx("div",{className:c(r,"h-3 w-44")})]},s))}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-44 mb-4")}),e.jsx("div",{className:"grid grid-cols-[repeat(52,1fr)] gap-[2px]",children:Array.from({length:364}).map((t,s)=>e.jsx("div",{className:"aspect-square rounded-[2px] bg-oai-gray-200/40 dark:bg-oai-gray-800/30 tt-shimmer-bar"},s))})]}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-28 mb-3")}),e.jsx("div",{className:"space-y-2.5",children:Array.from({length:5}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-4 w-4")}),e.jsx("div",{className:c(r,"h-3 w-16")}),e.jsx("div",{className:c(r,"h-[3px] flex-1")}),e.jsx("div",{className:c(r,"h-3 w-12")})]},s))})]})]})]})}function J(a){if(!a)return null;const r=String(a).match(/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})/i);return r?r[1]:null}function I({children:a}){return e.jsx("h3",{className:"text-[11px] uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400 mb-3",children:a})}function D({value:a,label:r,title:o}){return e.jsxs("div",{children:[e.jsx("div",{title:o,className:"text-2xl font-black tabular-nums tracking-tight leading-none text-oai-black dark:text-white",style:{fontFamily:'"DIN Alternate-Bold", "DIN Alternate", "DIN Condensed-Bold", "Impact", -apple-system, sans-serif',fontWeight:900},children:a}),e.jsx("div",{className:"mt-1.5 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r})]})}function L({label:a,children:r}){return e.jsxs("div",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"shrink-0 w-28 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"min-w-0 flex-1 text-oai-gray-900 dark:text-oai-gray-100 tabular-nums truncate flex items-baseline gap-2 flex-wrap",children:r})]})}function Ke({user:a,onClose:r}){const o=J(a?.github_url);return e.jsxs("div",{className:"flex items-center gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60",children:[e.jsx(Y,{avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"lg",proActive:a?.pro_active===!0,className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:a?.display_name||"—"}),e.jsx(K,{proActive:a?.pro_active===!0}),a?.rank?e.jsx("span",{className:c("shrink-0 inline-flex items-center px-2 py-0.5 rounded text-xs font-bold font-mono uppercase tracking-wider border shadow-sm",a.rank===1&&"bg-amber-500/10 text-amber-600 border-amber-500/20 dark:text-amber-400 dark:bg-amber-400/10",a.rank===2&&"bg-slate-500/10 text-slate-600 border-slate-500/20 dark:text-slate-400 dark:bg-slate-400/10",a.rank===3&&"bg-orange-500/10 text-orange-700 border-orange-500/20 dark:text-orange-400 dark:bg-orange-400/10",a.rank>3&&"bg-oai-gray-100 dark:bg-oai-gray-900/60 text-oai-gray-500 dark:text-oai-gray-400 border-oai-gray-200/60 dark:border-oai-gray-800"),children:i("leaderboard.profile_modal.rank",{rank:a.rank})}):null]}),o&&e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-[12px] text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200 transition-colors",children:[e.jsx($,{provider:"GITHUB",size:11}),e.jsxs("span",{children:["@",o]})]})]}),a?.user_id&&e.jsx("div",{className:"shrink-0 flex items-center justify-center",children:e.jsx(Q,{userId:a.user_id})}),r&&e.jsx("button",{type:"button",onClick:r,className:"shrink-0 -mr-1 -mt-1 flex h-8 w-8 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors group","aria-label":i("leaderboard.profile_modal.close"),children:e.jsx(ye,{size:16,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:rotate-90 group-active:scale-90"})})]})}function Ve({user:a,topBadge:r}){const o=J(a?.github_url),t=Number(a?.rank)||0,s=t===1?"text-amber-500 dark:text-amber-400":t===2?"text-slate-500 dark:text-slate-300":t===3?"text-orange-600 dark:text-orange-400":"text-oai-gray-400 dark:text-oai-gray-500";return e.jsxs("div",{className:"flex items-center gap-5 px-6 sm:px-8 pt-8 pb-7",children:[e.jsx(He,{badge:r,avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"xl",proActive:a?.pro_active===!0,className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"truncate text-2xl sm:text-[28px] font-semibold tracking-tight leading-tight text-oai-black dark:text-white",children:a?.display_name||"—"}),e.jsx(K,{proActive:a?.pro_active===!0}),a?.user_id&&e.jsx(Q,{userId:a.user_id})]}),o?e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white transition-colors",children:[e.jsx($,{provider:"GITHUB",size:13}),e.jsxs("span",{children:["@",o]})]}):null]}),t?e.jsxs("div",{className:"shrink-0 text-right leading-none",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-oai-gray-400 dark:text-oai-gray-500",children:i("leaderboard.profile.hero.rank_label")}),e.jsx("div",{className:c("mt-1.5 text-3xl font-black tabular-nums tracking-tight",s),children:i("leaderboard.profile_modal.rank",{rank:t})})]}):null]})]})}function qe({data:a}){const{formatTokens:r,formatTokensTooltip:o}=X(),t=Array.isArray(a)?a:[];return t.length===0?e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i("leaderboard.profile_modal.providers.none")}):e.jsx("ul",{className:"space-y-2",children:t.map(s=>{const n=Math.max(0,Math.min(1,Number(s?.percent)||0));return e.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"shrink-0 inline-flex items-center justify-center w-4 h-4",children:e.jsx($,{provider:String(s.source).toUpperCase(),size:14})}),e.jsx("span",{className:"w-20 shrink-0 text-oai-gray-700 dark:text-oai-gray-300",children:Ne(s.source)}),e.jsx("span",{className:"flex-1 h-[3px] rounded-full bg-oai-gray-200/60 dark:bg-oai-gray-800/80 overflow-hidden",children:e.jsx("span",{className:"block h-full bg-oai-brand-500 dark:bg-oai-brand-400",style:{width:`${(n*100).toFixed(1)}%`}})}),e.jsx("span",{title:o(s.total_tokens),className:"shrink-0 w-14 text-right tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:r(s.total_tokens)}),e.jsxs("span",{className:"shrink-0 w-10 text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[(n*100).toFixed(0),"%"]})]},s.source)})})}function E({icon:a,label:r,value:o}){const[t,s]=h.useState(!1),n=async()=>{await ve(o)&&(s(!0),setTimeout(()=>s(!1),1600))};return e.jsxs("button",{type:"button",onClick:n,className:c("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",t?"border-emerald-500/30 text-emerald-600 dark:text-emerald-400 bg-emerald-500/[0.06]":"border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-gray-900 dark:hover:text-oai-gray-100 hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[t?e.jsx(Te,{size:13,strokeWidth:2,"aria-hidden":!0}):e.jsx(a,{size:13,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t?i("leaderboard.profile_modal.badge.copied"):r})]})}function Qe({data:a,currency:r,rate:o,onClose:t,variant:s="modal"}){const{formatTokens:n,formatTokensTooltip:g}=X(),{user:l,totals:x,streak:u,best_day:b,models:j,by_provider:z,heatmap:P,period:T}=a,N=s==="page",w=h.useMemo(()=>Ge(P),[P]),C=j?.favorite?.model_name,v=Number(j?.count)||0,_=Array.isArray(a.badges)?a.badges:[],[A,S]=h.useState(null),d=W(),m=!!(d?.user?.id&&l?.user_id&&d.user.id===l.user_id),p=l?.user_id?`https://www.tokentracker.cc/u/${l.user_id}`:null,y=l?.user_id?`[![My AI coding usage](${ge()}/functions/tokentracker-embed-svg?user_id=${l.user_id}&theme=dark)](${p}?ref=readme)`:null;return e.jsxs(e.Fragment,{children:[N?e.jsx(Ve,{user:l,topBadge:Ce(_)}):e.jsx(Ke,{user:l,onClose:t}),e.jsxs("div",{className:c("space-y-6",N?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"flex-1 min-h-0 overflow-y-auto oai-scrollbar px-6 py-5"),children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-4",children:[e.jsx(D,{value:n(x?.total_tokens),title:g(x?.total_tokens),label:i("leaderboard.profile_modal.stat.total_tokens")}),e.jsx(D,{value:H(x?.estimated_cost_usd,r,o),label:i("leaderboard.profile_modal.stat.total_cost")}),e.jsx(D,{value:String(x?.active_days??0),label:i("leaderboard.profile_modal.stat.active_days")}),e.jsx(D,{value:H(x?.avg_per_day_usd,r,o),label:i("leaderboard.profile_modal.stat.avg_per_day")})]}),e.jsxs("dl",{className:"space-y-2 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsxs(L,{label:i("leaderboard.profile_modal.streak.current"),children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:i("leaderboard.profile_modal.streak.days",{count:u?.current_days??0})}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["(max ",u?.longest_days??0,")"]})]}),e.jsx(L,{label:i("leaderboard.profile_modal.best_day.title"),children:b?e.jsxs(e.Fragment,{children:[e.jsx("span",{title:g(b.total_tokens),className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:n(b.total_tokens)}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["on ",b.date]})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:i("leaderboard.profile_modal.best_day.none")})}),e.jsx(L,{label:i("leaderboard.profile_modal.models.favorite"),children:C?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30 truncate max-w-[200px] inline-block align-bottom",children:C}),v>1&&e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:i("leaderboard.profile_modal.models.count",{count:v})})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:i("leaderboard.profile_modal.models.none")})})]}),Array.isArray(j?.breakdown)&&!!j.breakdown.length&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(I,{children:i("usage.overview.all_models")}),j.breakdown.map(f=>e.jsxs("details",{className:"border-b border-oai-gray-100 py-2 text-xs dark:border-oai-gray-800",children:[e.jsxs("summary",{className:"cursor-pointer rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx("span",{className:"font-medium",children:f.model_name}),e.jsx("span",{className:"ml-3 tabular-nums",title:g(f.total_tokens),children:n(f.total_tokens)}),e.jsx("span",{className:"ml-3 tabular-nums",children:Z(f.estimated_cost_usd,{currency:r,rate:o})})]}),e.jsx("dl",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-oai-gray-500",children:[["input_tokens","dashboard.projects.detail.comp_input"],["cached_input_tokens","dashboard.projects.detail.comp_cached"],["cache_creation_input_tokens","dashboard.projects.detail.comp_cache_write"],["output_tokens","dashboard.projects.detail.comp_output"],["reasoning_output_tokens","dashboard.projects.detail.comp_reasoning"]].map(([k,B])=>e.jsxs("div",{className:"flex gap-1",children:[e.jsx("dt",{children:i(B)}),e.jsx("dd",{title:g(f[k]),children:n(f[k])})]},k))})]},f.model_name))]}),(m||_.some(f=>(f?.tier||0)>=1))&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(I,{children:i("achievements.section.title")}),N?e.jsx(Ie,{achievements:_,isOwn:m&&!!a.badges_include_unearned,scope:"cloud",onSelect:S}):e.jsx(Ee,{badges:_,isOwn:m&&!!a.badges_include_unearned,onSelect:S})]}),w&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(I,{children:i("leaderboard.profile_modal.heatmap.title")}),e.jsx("div",{className:"min-w-0",children:e.jsx(_e,{heatmap:w,hideLegend:!0,embedded:!0})})]}),e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(I,{children:i("leaderboard.profile_modal.providers.title")}),e.jsx(qe,{data:z})]}),l?.user_id&&(t||m)&&e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-3",children:[t&&(pe()?e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",onClick:t,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:i("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]}):e.jsxs(he,{to:`/u/${l.user_id}`,onClick:t,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:i("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})),m&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{icon:De,label:i("leaderboard.profile_modal.badge.copy_url"),value:p}),e.jsx(E,{icon:Oe,label:i("leaderboard.profile_modal.badge.copy"),value:y})]})]})]}),A&&e.jsx(G.Suspense,{fallback:null,children:e.jsx(We,{badge:A,onClose:()=>S(null)})})]})}function Je({userId:a,period:r,accessToken:o,enabled:t=!0}){const[s,n]=h.useState({loading:!1,error:null,data:null}),g=h.useMemo(()=>de(),[]),l=h.useMemo(()=>ce(),[]);return h.useEffect(()=>{if(!t||!a)return;let x=!0;return n({loading:!0,error:null,data:null}),(async()=>{try{const u=o?await me(o):null;if(!x)return;const b=await xe({accessToken:u,userId:a,period:r||"week",timeZone:g,tzOffsetMinutes:l});if(!x)return;n({loading:!1,error:null,data:b})}catch(u){if(!x)return;u?.status===404?n({loading:!1,error:null,data:null}):n({loading:!1,error:u?.message||String(u),data:null})}})(),()=>{x=!1}},[t,a,r,o,g,l]),s}function Sa({isOpen:a,onClose:r,userId:o,period:t,accessToken:s}){const{currency:n,rate:g}=we(),l=Je({userId:o,period:t,accessToken:s,enabled:a});return e.jsx(Be,{open:a,onOpenChange:x=>{x||r?.()},children:e.jsxs(Le,{children:[e.jsx($e,{className:"cost-modal-backdrop"}),e.jsx(Ue,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(Re,{className:c("cost-modal-popup","relative w-full max-w-[540px] max-h-[calc(100vh-2rem)] flex flex-col","rounded-2xl bg-white dark:bg-oai-gray-950","shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)]","ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden","dark:border-t dark:border-white/[0.08]"),children:[e.jsx(Fe,{render:e.jsx("h2",{className:"sr-only"}),children:l.data?.user?.display_name||i("leaderboard.profile_modal.loading")}),l.loading&&e.jsx(Ye,{}),!l.loading&&l.error&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:i("leaderboard.profile_modal.error")})}),!l.loading&&!l.error&&!l.data&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:i("leaderboard.profile_modal.empty")})}),!l.loading&&!l.error&&l.data&&e.jsx(ue,{mode:fe.COMPACT,children:e.jsx(Qe,{data:l.data,currency:n,rate:g,onClose:r})})]})})]})})}export{Sa as LeaderboardProfileModal,Qe as ProfileContent,Ye as ProfileSkeleton,Je as useLeaderboardProfileData};
@@ -1,6 +0,0 @@
1
- import{o as ee,j as e,y as Le,c as r,h as B,r as p,bm as vt,V as P,bn as jt,al as kt,B as Z,bo as wt,e as Nt,W as _e,R as _t,L as St,bp as Pt,t as Ct,w as Mt}from"./__vite-browser-external-I1de5Swt.js";import{m as Se}from"./react-D9IQudPE.js";import{P as ne,c as Dt,r as de,a as Et,u as Tt,b as Rt,s as It}from"./use-usage-limits-CQugaku6.js";import{b as $e,c as C,l as se,d as Ue,u as At}from"./use-limits-display-prefs-BadNsZG8.js";import{F as Ht}from"./FadeIn-CngXKUqj.js";import{P as ze}from"./ProviderIcon-CRlMy2AY.js";import{H as Ft}from"./HoverTooltip-By7PDA5D.js";import{C as be}from"./chevron-down-C08QHnpk.js";import{G as Ot}from"./gift-DUUpsPxb.js";import{C as Lt}from"./ConfirmModal-Cuf2JDA9.js";import{I as Pe,L as $t}from"./LocalOnlyNotice-0pQm9-gI.js";import{S as ge}from"./Select-D1FvgdDV.js";import{P as Ut}from"./plus-Dydx6cB7.js";import{P as zt,a as Bt,b as Gt,c as Wt,d as Kt}from"./PopoverPopup-UtHXvmNC.js";import{u as qt}from"./use-reduced-motion-BsG6Qxa-.js";import"./use-latest-request-guard-D_4XuEoM.js";import"./DialogTitle-CnaGDa7P.js";import"./composite-C5GvW04X.js";import"./store-CGDaAZE0.js";import"./DialogDescription-BAaD46Xg.js";import"./arrow-up-right-CReo0rju.js";import"./download-B7xuZSZ2.js";import"./check-BBOwGLur.js";import"./SelectItemText-Conq3RQN.js";import"./usePositioner-CGtwrNEt.js";import"./safePolygon-CxfZ_vVn.js";const Be={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"}]]};Be.node;const Vt=ee(Be);const Ge={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"}]]};Ge.node;const Yt=ee(Ge);const We={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"}]]};We.node;const Ke=ee(We);const qe={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};qe.node;const Ve=ee(qe);const Ye={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"}]]};Ye.node;const Xe=ee(Ye),Xt=[3,2,3,3,2,2,3];function q({className:t}){return e.jsx("div",{className:Le("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Zt(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-3 w-12 shrink-0"}),e.jsx(q,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(q,{className:"h-3 w-[30px] shrink-0"}),e.jsx(q,{className:"h-3 w-6 shrink-0"})]})}function Jt({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(q,{className:"h-[22px] w-[22px] shrink-0 rounded"}),e.jsx(q,{className:Le("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(Zt,{},n))})]})}function Qt(){return e.jsx("div",{className:"flex flex-col gap-3","aria-hidden":"true",children:Xt.map((t,a)=>e.jsx(Jt,{bars:t,index:a},a))})}const ye=100;function Ce(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function ea(t){return Math.max(0,Math.min(ye,Math.round(t)))}function ta(t){return new Intl.DateTimeFormat(B(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function aa(t,a,i){if(t==null||t>=a)return ye;const s=a-t,n=a-i;return ea(n/s*ye)}function ra(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function ia(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=ra(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=Ce(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:ta(c),expiresMs:c,percent:aa(Ce(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 Q=864e5;function z(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 Ze(t,a){if(a==="weekly")return t-7*Q;if(a==="yearly")return z(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 Je(t,a){return a==="weekly"?t+7*Q:a==="yearly"?z(t,12):z(t,1)}function na(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return Ze(new Date(t.nextBillingAt).getTime(),t.cycle)}function sa(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return Ze(i,a)}function oa(t,a,i){if(a==="weekly"){const c=7*Q,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*Q;let o=i<=t?0:Math.floor((i-t)/n);for(;o>0&&z(t,o*s)>i;)o-=1;let l=0;for(;z(t,(o+1)*s)<=i&&l<12e3;)o+=1,l+=1;return{startMs:z(t,o*s),endMs:z(t,(o+1)*s)}}function oe(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=sa(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=oa(n,s,a):t.startedAt!=null?(o=n,l=Je(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/Q)),expired:c}}function Qe(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 la="shrink-0 text-oai-black dark:text-oai-white",ca={opencodeGo:"OPENCODE_GO_API_KEY",commandCode:"COMMAND_CODE_API_KEY"},da={opencodeGo:"opencode-go",commandCode:"command-code"};function et(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function tt(){return et()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function at(){return r("limits.devin.setupHint.snippet_login")}function ua(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 rt(t,a){const i=a===C.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function le(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 re(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 ie(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 it(t,a){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const i={useGrouping:t.unit!=="calls",maximumFractionDigits:a},s=ie(t.used_credits,i),n=ie(t.limit_credits,i),o=ie(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 nt(t,a,i){return Dt({usedPercent:le(t.window,t.pctField),windowSeconds:Et(t,t.window),resetMs:de(ue(t.window,t.resetField)),mode:a,now:i})}function ce(t){return Number.isFinite(t)?new Intl.DateTimeFormat(B(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function ma(t,a,i){const s=[ot(t,a,i)],n=de(ue(t.window,t.resetField)),o=ce(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=it(t.window,t.creditPrecision);return l&&s.push(l),s.join(`
2
- `)}const st=Ft,Me=[1,.65,.45,.3,.2];function je(t){return Me[Math.min(t,Me.length-1)]}function De({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 xa({label:t,pct:a,reset:i,mode:s=C.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===C.REMAINING?100-d:d,u=rt(m,s),g=Math.round(m),y=m>0&&g===0?Math.max(m,.35):m;let b=String(g);m>0&&g===0&&(b=r("limits.bar.sub_one_percent"));const v=n==null?null:Math.max(0,Math.min(100,n)),_=c?.map(w=>Math.max(0,Math.min(100,Number(w.pct)||0))),j=_?.reduce((w,E)=>w+E,0)||0,M=c?Math.max(0,d-j):0,k=Math.max(0,100-j-M);return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(st,{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((w,E)=>e.jsx("div",{"data-limit-segment":w.key,className:`${u} min-w-0 rounded-full h-full transition-[flex-grow] duration-500 ease-out`,style:{flex:`${_[E]} 1 0px`,opacity:je(E)}},w.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,k?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:`${k} 1 0px`}}):null,v!=null&&e.jsx(De,{paceX:v,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:`${y}%`,minWidth:m>0?"3px":0}}),v!=null&&e.jsx(De,{paceX:v,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:[b,"%"]}),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 pa({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:[re(i.pct),"%"]})]},i.key))})}function ot(t,a,i){const s=t.label??r(t.labelKey),n=i===C.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(le(t.window,t.pctField))||0)),m=re(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=re(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(le(t.window,t.pctField))||0)),c=re(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function lt({pace:t}){return t.pacePercent!=null}function ga(t,a){return t.some(i=>lt(i)&&(i.mode??a)===C.REMAINING)}function ct({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=ga(t,a),n=t.some(lt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l,mode:c=a})=>{const d=ce(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:[ot(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:it(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 J(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 Ee={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"}},ha={claude:"claude",codex:"codex",antigravity:"agy"};function K({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=Ee[i]||Ee.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 dt({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=Ue(a),u=e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[m?e.jsx(ze,{provider:m,size:22,className:la}):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]}),g="rounded-xl border border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-900",y="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",b=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:g,children:[e.jsxs("button",{type:"button","aria-expanded":n,onClick:o,className:`${y} 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(be,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${n?"rotate-180":""}`})]}),b]}):e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:o,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),o?.())},className:`${g} 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:y,children:[u,e.jsx(be,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${n?"rotate-180":""}`})]}),b]}):e.jsxs("div",{className:g,children:[e.jsx("div",{className:y,children:u}),b]})}function ut({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?Xe:Ve;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 mt({subscription:t,now:a,mode:i=C.USED}){const s=oe(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===C.REMAINING?100-c:c,m=o?100:Math.max(0,Math.min(100,d)),u=Math.round(m),g=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:g}),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:Qe(n,a)})]})}function xt({subscription:t,now:a}){const i=oe(t,a);if(!i)return null;const s=new Intl.DateTimeFormat(B(),{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 fa=$e;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(vt,{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 pt({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=le(o.window,o.pctField),m=s?o.segments:null;return e.jsxs(P.Fragment,{children:[e.jsx(xa,{label:o.label??r(o.labelKey),pct:d,reset:ua(ue(o.window,o.resetField)),mode:c,segments:m,pacePercent:l.pacePercent,paceOver:l.paceOver,title:ma(o,l,c)}),m?e.jsx(pa,{segments:m,fillColor:rt(d,C.USED)}):null]},o.key)}),n?e.jsx(A,{children:r("limits.status.no_data")}):null,i]})}function ba(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 ya({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(st,{text:ba(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 va({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(ya,{row:i},i.key))]})}function ja({data:t}){const a=Date.now(),i=[{key:"five_hour",label:r("limits.label.zcode_5h")},{key:"weekly",label:r("limits.label.zcode_weekly")}].map(s=>({...s,cards:(t[s.key]||[]).filter(n=>Date.parse(n.expires_at)>a).slice().sort((n,o)=>Date.parse(n.expires_at)-Date.parse(o.expires_at))}));return e.jsxs("div",{className:"mt-1 flex flex-col gap-1.5",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.zcode.reset_bank.title")}),t.error?e.jsx(A,{tone:"error",children:t.error}):i.map(s=>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:s.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:s.cards.length})}),s.cards.length?e.jsx("span",{className:"ml-auto text-right text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",title:s.cards.map(n=>ce(Date.parse(n.expires_at))).join(`
3
- `),children:r("limits.zcode.reset_bank.earliest",{time:ce(Date.parse(s.cards[0].expires_at))})}):null]},s.key))]})}function gt(t,a){if(t==="zcode_reset_bank")return a.reset_credits?e.jsx(ja,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=ia(a.reset_credits);return i?e.jsx(va,{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=ie(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(_a,{defaultDir:a.otel_default_dir}):null}function ka({data:t,mode:a,now:i}){const[s,n]=p.useState(!1),o=p.useRef(null),l=ht(o),c=[...new Set((t.buckets||[]).map(u=>u.plan_name).filter(Boolean))],d=c.length?c.join(" · "):r("limits.zcode.start_grants"),m=ne.zcode.windows(t).filter(u=>u.window).map(u=>({spec:u,pace:nt(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(g=>!g)},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(Ot,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(be,{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(pt,{rows:m,mode:a}),e.jsx(ct,{rows:m,mode:a,now:i}),(t.buckets||[]).filter(u=>Number.isFinite(u.remaining_units)&&Number.isFinite(u.total_units)).map((u,g)=>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(B()),total:u.total_units.toLocaleString(B())})},u.entitlement_id||g))]})}):null]})}function wa(t,a,i,s,n,o,l=null,c=null,d=Date.now(),m=null){const u=ne[t];if(!u)return null;const g=u.windows(a).filter(b=>b.window).map(b=>{const v=b.productPool?C.USED:s;return{spec:b,mode:v,pace:nt(b,v,d)}}),y=gt(u.extra,a);return e.jsxs(dt,{name:i,providerId:t,expandable:g.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(ut,{subscription:c}):null,toggleOnHeader:t==="zcode",children:[e.jsx(pt,{mode:s,rows:g,extra:y,expanded:n}),t==="opencodeGo"||t==="commandCode"?e.jsx(Sa,{providerId:t,data:a,onSaved:m}):null,c?e.jsx(mt,{subscription:c,now:d,mode:s}):null,n?e.jsx(ct,{rows:g,mode:s,now:d}):null,n&&c?e.jsx(xt,{subscription:c,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(ka,{data:a.start_plan,mode:s,now:d}):null]},t)}function he(t,a,i,s,n=null,o=Date.now(),l=C.USED){const c=!!n;return e.jsxs(dt,{name:se(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(ut,{subscription:n}):null,children:[a,c?e.jsx(mt,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(xt,{subscription:n,now:o})}):null]},t)}function Na(t,a,i,s,n,o=null,l=Date.now(),c=null){if(!ne[t])return null;if(!a?.configured)return he(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(T,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Te,{onSaved:c})}):null,t==="commandCode"?e.jsx(T,{title:r("limits.commandCode.setupHint.title"),children:e.jsx(Re,{onSaved:c})}):null,t==="codingPlan"?e.jsx(T,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Ae,{})}):null,t==="agentPlan"?e.jsx(T,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(He,{})}):null,t==="devin"?e.jsx(T,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ie,{})}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return he(t,e.jsx(A,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return he(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{tone:"error",children:a.error}),t==="kiro"?gt(ne.kiro.extra,a):null,t==="opencodeGo"?e.jsx(T,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Te,{onSaved:c})}):null,t==="commandCode"?e.jsx(T,{title:r("limits.commandCode.setupHint.title"),children:e.jsx(Re,{onSaved:c})}):null,t==="codingPlan"?e.jsx(T,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Ae,{})}):null,t==="agentPlan"?e.jsx(T,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(He,{})}):null,t==="devin"?e.jsx(T,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ie,{})}):null]}),s,n,o,l,i);const d=se(t),m=a.plan_label?`${d} ${a.plan_label}`:d;let u=null;if(a.auth_action_required==="reauth"){const y=t==="commandCode"?tt():t==="devin"?at():ha[t];u=e.jsx(K,{label:r("limits.reauth.badge"),age:J(a.cached_at),tone:"stale",tooltip:y?r("limits.reauth.tooltip",{command:y}):null})}if(!u&&t==="antigravity")if(a.cached){const y=J(a.cached_at);u=e.jsx(K,{label:r("limits.label.antigravity_cached"),age:y,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(K,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(K,{label:r("limits.label.antigravity_cached"),age:J(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(K,{label:r("limits.label.antigravity_cached"),age:J(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const g=a.provenance;return g?.stale&&!u&&(u=e.jsx(K,{label:r("limits.provenance.stale"),age:J(g.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:g.source,confidence:g.confidence})})),wa(t,a,m,i,s,n,u,o,l,c)}function _a({defaultDir:t}){const[a,i]=p.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 ke(){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 we({provider:t,onSaved:a}){const[i,s]=p.useState(""),[n,o]=p.useState("idle"),[l,c]=p.useState(!1),d=async m=>{m.preventDefault(),m.stopPropagation();const u=i.trim();if(!(!u||n==="saving")){o("saving"),c(!1);try{await jt(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 Sa({providerId:t,data:a,onSaved:i}){if(a?.credential_source!=="env")return null;const s=ca[t],n=da[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(we,{provider:n,onSaved:i}),et()==="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 T({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 Te({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(ke,{})]})]}),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(we,{provider:"opencode-go",onSaved:t})]})]})]})}function Re({onSaved:t}){const a=tt();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(we,{provider:"command-code",onSaved:t})]})]})]})}function Ie(){const t=at();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 Ae(){const[t,a]=p.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(ke,{})]})]}),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 He(){const[t,a]=p.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(ke,{})]})]}),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 ht(t){const[a,i]=p.useState(0);return p.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 Pa({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:u,commandCode:g,qoder:y,qoderCn:b,codingPlan:v,agentPlan:_,devin:j,workbuddy:M,order:k,visibility:w,displayMode:E,subscriptions:R=[],showSubscriptions:I=!0,onProviderKeySaved:V=null}){const H={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:u,commandCode:g,qoder:y,qoderCn:b,codingPlan:v,agentPlan:_,devin:j,workbuddy:M},te=p.useRef(null),Y=ht(te),[$,ae]=p.useState(null),[X,me]=p.useState(()=>Date.now()),xe=[...new Set((Array.isArray(k)&&k.length>0?k:fa).map(f=>f==="workbuddyAi"?"workbuddy":f))],pe=E===C.REMAINING?C.REMAINING:C.USED;p.useEffect(()=>{const f=setInterval(()=>me(Date.now()),6e4);return()=>clearInterval(f)},[]);const F=new Map;if(I)for(const f of R||[]){if(!f?.provider)continue;const L=new Date(f.nextBillingAt).getTime();if(!Number.isFinite(L))continue;const U=F.get(f.provider);if(!U){F.set(f.provider,f);continue}const G=new Date(U.nextBillingAt).getTime(),x=L>X,N=G>X;(x&&(!N||G>L)||!x&&!N&&L>G)&&F.set(f.provider,f)}const O=xe.filter(f=>!w||w[f]!==!1||F.has(f)).map(f=>Na(f,H[f],pe,$===f,()=>ae(L=>L===f?null:f),F.get(f)||null,X,V)).filter(Boolean);return e.jsx(Ht,{delay:.15,children:e.jsx("div",{ref:te,"data-limit-label-group":"",className:"flex flex-col gap-3",style:Y>0?{"--tt-limits-label-w":`${Y}px`}:void 0,children:O.length>0?O:e.jsx(A,{children:r("limits.status.all_hidden")})})})}async function ft(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 Ca(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await ft(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function Ne(t){const a=await kt();return ft(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 Ma(t){return Ne({action:"create",subscription:t})}function Da(t,a){return Ne({action:"update",id:t,subscription:a})}function Ea(t){return Ne({action:"delete",id:t})}const fe={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function Ta(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 Ra({subscriptions:t,onChanged:a}){const[i,s]=p.useState(!1),[n,o]=p.useState(null),[l,c]=p.useState(fe),[d,m]=p.useState(!1),[u,g]=p.useState(!1),[y,b]=p.useState(!1),[v,_]=p.useState(!1),[j,M]=p.useState(null),[k,w]=p.useState(!1),[E,R]=p.useState(!1),[I,V]=p.useState(null),[H,te]=p.useState(()=>Date.now()),Y=p.useRef(null),$=B(),ae=p.useMemo(()=>new Intl.DateTimeFormat($,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[$]);p.useEffect(()=>{const x=setInterval(()=>te(Date.now()),6e4);return()=>clearInterval(x)},[]),p.useEffect(()=>{if(!i)return;const x=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;Y.current?.scrollIntoView?.({behavior:x?"auto":"smooth",block:"nearest"})},[i,n]);const X=p.useMemo(()=>$e.map(x=>{const N=(t||[]).some(S=>S.provider===x&&S.id!==n),h=se(x);return{value:x,label:N?`${h} ${r("subscriptions.form.provider_taken_suffix")}`:h,disabled:N}}),[$,t,n]),me=p.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")}],[$]),xe=p.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[$]),pe=p.useCallback(()=>{c(fe),o(null),g(!1),b(!1),_(!1),s(!0)},[]),F=p.useCallback(x=>{c({plan:x.plan||"",provider:x.provider||"",cycle:x.cycle||"monthly",autoRenew:x.autoRenew,startedAt:Ta(new Date(na(x)).toISOString())}),o(x.id),g(!1),b(!1),_(!1),s(!0)},[]),O=p.useCallback(()=>{s(!1),o(null),c(fe),g(!1),b(!1),_(!1)},[]),f=p.useCallback(async x=>{if(x.preventDefault(),g(!1),!l.provider){b(!0);return}if((t||[]).some(W=>W.provider===l.provider&&W.id!==n)){_(!0);return}const h=new Date(l.startedAt).getTime();if(!Number.isFinite(h)){g(!0);return}const S={service:se(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:h,nextBillingAt:Je(h,l.cycle)};m(!0);try{n?await Da(n,S):await Ma(S),O(),await a?.()}catch{g(!0)}finally{m(!1)}},[O,n,l,a,t]),L=p.useCallback(async()=>{if(j){w(!0),R(!1);try{await Ea(j.id),j.id===n&&O(),M(null),await a?.()}catch{R(!0)}finally{w(!1)}}},[O,n,a,j]),U=t||[],G=()=>{const x=n?U.find(h=>h.id===n):null,N=x?oe(x,H):null;return e.jsxs("form",{ref:Y,onSubmit:f,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,H)})]}):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(ge,{id:"subscription-provider",value:l.provider,onValueChange:h=>c({...l,provider:String(h)}),options:X,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(Pe,{label:r("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:h=>c({...l,plan:h.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(ge,{id:"subscription-cycle",value:l.cycle,onValueChange:h=>c({...l,cycle:String(h)}),options:me,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(ge,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:h=>c({...l,autoRenew:h==="true"}),options:xe,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(Pe,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:h=>c({...l,startedAt:h.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 h=U.find(S=>S.id===n);h&&M(h)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,y?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,v?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:O,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:pe,className:"shrink-0 gap-1.5",children:[e.jsx(Ut,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),U.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(Ke,{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:[U.map(x=>{const N=oe(x,H);if(!N)return null;const{endMs:h,expired:S}=N,W=S?100:N.progress*100,bt=!S&&h-H<=3*864e5,yt=I===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:()=>F(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(ze,{provider:Ue(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(Xe,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Ve,{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:`${S?"bg-red-500":bt?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${W}%`,minWidth:W>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${S?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Qe(h,H)})]})]}),n===x.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:G()}):null,n!==x.id&&yt?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(h))})," · ",e.jsx("span",{className:S?"text-oai-error":void 0,children:ve(h,H)})," · ",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:()=>F(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:G()}):null]}),e.jsx(Lt,{open:!!j,title:r("subscriptions.confirm_delete_title"),description:j?.service||"",error:E?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:k,onCancel:()=>{M(null),R(!1)},onConfirm:L})]})}const Fe=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Ia="x-apple.systempreferences:com.apple.preference.notifications";function Oe(t){const a=Date.parse(t);return Number.isFinite(a)?new Intl.DateTimeFormat(B(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(a)):String(t)}function Aa(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 Ha(){const t=qt(),a=Ct(),i=r("limits.alert.blocked"),s=a?Se.button:Se.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>Mt({type:"action",name:"openURL",value:Ia}):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 cr(){const t=wt(),{data:a,error:i,isLoading:s,refresh:n}=Tt(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),o=At(),l=Rt(),[c,d]=P.useState([]),[m,u]=P.useState(!1),[g,y]=P.useState(!1),[b]=Nt(),v=P.useRef(0),_=P.useRef(!1),[j,M]=P.useState(!1),[k,w]=P.useState(null),E=P.useCallback(async()=>{if(!_.current){_.current=!0,M(!0),w(null);try{const I=await n();w(I?Aa(I):{kind:"failed"})}finally{_.current=!1,M(!1)}}},[n]),R=P.useCallback(async()=>{if(!Fe&&!_e())return;const I=++v.current;try{const V=await Ca();if(I!==v.current)return;d(V),u(!1)}catch{if(I!==v.current)return;u(!0)}},[]);return P.useEffect(()=>{R()},[R]),P.useEffect(()=>{b.get("openSubscriptions")==="1"&&y(!0)},[b]),P.useEffect(()=>{l.enabled&&a&&It(a)},[l.enabled,a]),!Fe&&!_e()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx($t,{})}):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(Ha,{}):null,e.jsx("button",{type:"button",onClick:()=>{E()},disabled:j,"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(_t,{className:`h-4 w-4 ${j?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(zt,{open:g,onOpenChange:y,children:[e.jsx(Bt,{"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(Ke,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Gt,{children:e.jsx(Wt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Kt,{children:e.jsx(Ra,{subscriptions:c,onChanged:R})})})})]}),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(Yt,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Vt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(St,{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(Pt,{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:j?r("limits.page.refresh_loading"):""}),k?.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:Oe(k.at)})}):null,k?.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:Oe(k.at)})}):null,k?.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,k?.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(Qt,{}):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(Pa,{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,order:o.order,visibility:o.visibility,displayMode:o.displayMode,subscriptions:c,showSubscriptions:o.showSubscriptions!==!1,onProviderKeySaved:()=>{n()}})]})]})})})}export{cr as LimitsPage};
@@ -1 +0,0 @@
1
- import{r as o}from"./__vite-browser-external-I1de5Swt.js";import{h as r,i as t,p as s}from"./react-D9IQudPE.js";function i(){!r.current&&t();const[e]=o.useState(s.current);return e}export{i as u};