tokentracker-cli 1.5.8 → 1.5.10

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 (120) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-Ck1DmXtu.js → AchievementBadge-C1sNmjy1.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-DjvMoc2i.js → AchievementsPage-CEes3r9C.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-DvTHE8Vd.js → AchievementsSection-DUNbD6b3.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-COa2Rd6M.js → BadgeDetailModal-Qmr7VqYE.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-CeR3jSce.js → BotAnimated-jsDF2HFl.js} +1 -1
  6. package/dashboard/dist/assets/{Card-bQCEOe_K.js → Card-B_lOewQz.js} +1 -1
  7. package/dashboard/dist/assets/CloudCheckoutPage-C_JuBsD4.js +1 -0
  8. package/dashboard/dist/assets/{CloudPage-RygH3R8b.js → CloudPage-CzME2Zwr.js} +2 -2
  9. package/dashboard/dist/assets/{CommandPalette-E7YqsdAH.js → CommandPalette-C9-pZkuM.js} +1 -1
  10. package/dashboard/dist/assets/{CommunityStatsModal-B5heTDUE.js → CommunityStatsModal-CykqgS9V.js} +1 -1
  11. package/dashboard/dist/assets/{ConfirmModal-D3vd882N.js → ConfirmModal-fM615n-k.js} +1 -1
  12. package/dashboard/dist/assets/{Controls-CK74JkE8.js → Controls-BUgYy1q2.js} +1 -1
  13. package/dashboard/dist/assets/{DashboardPage-DwTrlQZQ.js → DashboardPage-TMedKsgf.js} +1 -1
  14. package/dashboard/dist/assets/{DateRangePopover-BxVCPuEX.js → DateRangePopover-ChqqPFBz.js} +1 -1
  15. package/dashboard/dist/assets/DevicePage-BVM0mnCp.js +1 -0
  16. package/dashboard/dist/assets/{DialogClose-teXmwU1d.js → DialogClose-BSYpqJ7I.js} +1 -1
  17. package/dashboard/dist/assets/DialogDescription-C-V5YErj.js +1 -0
  18. package/dashboard/dist/assets/{DialogTitle-B3m-31sy.js → DialogTitle-Ck0801ZS.js} +1 -1
  19. package/dashboard/dist/assets/{ElectricLogo-0wyvks4K.js → ElectricLogo-Duu4aJps.js} +1 -1
  20. package/dashboard/dist/assets/{FadeIn-C60pLKXu.js → FadeIn-C0nDQZXG.js} +1 -1
  21. package/dashboard/dist/assets/{HeaderGithubStar-CCEUzMqo.js → HeaderGithubStar-9_Cou9eQ.js} +1 -1
  22. package/dashboard/dist/assets/{HoverTooltip-D9RtbhSZ.js → HoverTooltip-Dko6Ml2q.js} +1 -1
  23. package/dashboard/dist/assets/{IpCheckPage-BCyW0SWY.js → IpCheckPage-CAy4LTD9.js} +1 -1
  24. package/dashboard/dist/assets/{LandingPage-DCEofDST.js → LandingPage-De_k34Bm.js} +2 -2
  25. package/dashboard/dist/assets/{LeaderboardPage-CsTbalIm.js → LeaderboardPage-upmKCiU2.js} +2 -2
  26. package/dashboard/dist/assets/{LeaderboardProBadge-Crun5RUJ.js → LeaderboardProBadge-Bp_4HRGy.js} +1 -1
  27. package/dashboard/dist/assets/{LeaderboardProfileModal-Bim9cms6.js → LeaderboardProfileModal-CfeTu2mg.js} +3 -3
  28. package/dashboard/dist/assets/{LeaderboardProfilePage-D9pBE7f4.js → LeaderboardProfilePage-dwGCnqt1.js} +1 -1
  29. package/dashboard/dist/assets/LimitsPage-FxEd8pgt.js +6 -0
  30. package/dashboard/dist/assets/{LocalOnlyNotice-F_qczacX.js → LocalOnlyNotice-DITDSNOI.js} +1 -1
  31. package/dashboard/dist/assets/{LoginCard-CQm_T5K2.js → LoginCard-B0Y5nGs3.js} +1 -1
  32. package/dashboard/dist/assets/{LoginModal-BUf4mPCT.js → LoginModal-C7UJchsM.js} +1 -1
  33. package/dashboard/dist/assets/{LoginPage-njdEUQEX.js → LoginPage-CuSeHCfR.js} +1 -1
  34. package/dashboard/dist/assets/{PetPage-COczIU1k.js → PetPage-DmKwqkVp.js} +2 -2
  35. package/dashboard/dist/assets/{PopoverPopup-DxB1k4g7.js → PopoverPopup-CUOqufwL.js} +1 -1
  36. package/dashboard/dist/assets/{ProviderIcon-BQfkoaQE.js → ProviderIcon-RNmBCqqB.js} +1 -1
  37. package/dashboard/dist/assets/{ResetPasswordPage-PGRVaPTN.js → ResetPasswordPage-DzWUR5w4.js} +1 -1
  38. package/dashboard/dist/assets/{Select-CQVnpoBO.js → Select-8FQRH1NU.js} +1 -1
  39. package/dashboard/dist/assets/{SelectItemText-DmAn7osh.js → SelectItemText-Dxwcx_oH.js} +1 -1
  40. package/dashboard/dist/assets/{SelfHostPage-BUURA-Vt.js → SelfHostPage-B7-Tn3dF.js} +1 -1
  41. package/dashboard/dist/assets/{ServiceStatusPage-DuzSen0Q.js → ServiceStatusPage-BsfvaKsB.js} +1 -1
  42. package/dashboard/dist/assets/{SessionsPage-DndGq61W.js → SessionsPage-DW87f0ht.js} +1 -1
  43. package/dashboard/dist/assets/{SettingsPage-CHh0yqsZ.js → SettingsPage-DGgUxidi.js} +3 -3
  44. package/dashboard/dist/assets/{SkillsPage-CCaYXQWN.js → SkillsPage-BVLlMuY6.js} +1 -1
  45. package/dashboard/dist/assets/{TokenGalaxy-CGxUtq9x.js → TokenGalaxy-CO6GVguL.js} +1 -1
  46. package/dashboard/dist/assets/{TooltipPopup-B_B4qQD-.js → TooltipPopup-Bevc5eEL.js} +1 -1
  47. package/dashboard/dist/assets/{TrendMonitor-CdRQTLZL.js → TrendMonitor-2BCVwA7W.js} +1 -1
  48. package/dashboard/dist/assets/{WidgetsPage-DP_w32wh.js → WidgetsPage-BP2OAK7_.js} +1 -1
  49. package/dashboard/dist/assets/{WrappedPage-C_DCqHUH.js → WrappedPage-DHaMc2cB.js} +1 -1
  50. package/dashboard/dist/assets/__vite-browser-external-BBQzCxHU.js +45 -0
  51. package/dashboard/dist/assets/__vite-browser-external-D-6XhI1J.css +1 -0
  52. package/dashboard/dist/assets/{agent-logos-DlnSKc2A.js → agent-logos-CJnyo7vh.js} +1 -1
  53. package/dashboard/dist/assets/{arrow-left-CjLKt_5C.js → arrow-left-Cc3forJV.js} +1 -1
  54. package/dashboard/dist/assets/{arrow-right-Bh-Ezs8y.js → arrow-right-CmzbBPo3.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-up-right-C87CvEJ5.js → arrow-up-right-D91fA8Iw.js} +1 -1
  56. package/dashboard/dist/assets/{calendar-days-B5VHwV9j.js → calendar-days-CUz-Kohj.js} +1 -1
  57. package/dashboard/dist/assets/{check-D2uclldH.js → check-SYGeJ9ML.js} +1 -1
  58. package/dashboard/dist/assets/{chevron-down-Beacyoub.js → chevron-down-CNtNmxJK.js} +1 -1
  59. package/dashboard/dist/assets/{cloud-checkout-3Y7NDSG1.js → cloud-checkout-At2YeP3_.js} +1 -1
  60. package/dashboard/dist/assets/{composite-B28yORTL.js → composite-C01XLAWQ.js} +1 -1
  61. package/dashboard/dist/assets/{copy-C8fZJwms.js → copy-UBZcDOSY.js} +1 -1
  62. package/dashboard/dist/assets/{download-IIXYYmyo.js → download-BSroeXtu.js} +1 -1
  63. package/dashboard/dist/assets/{external-link-BEb0dms0.js → external-link-wc6SpmRT.js} +1 -1
  64. package/dashboard/dist/assets/{flame-gmfpE-PO.js → flame-Cwq8Msm_.js} +1 -1
  65. package/dashboard/dist/assets/{format-tokens-CKwy7NXi.js → format-tokens-BuH-wp-o.js} +1 -1
  66. package/dashboard/dist/assets/{gift-twpInP_O.js → gift-DmQ-nWNf.js} +1 -1
  67. package/dashboard/dist/assets/{icons-DQfkB5-5.js → icons-DceEefzQ.js} +1 -1
  68. package/dashboard/dist/assets/{index-D2-6Msd9.js → index-8CXny7rg.js} +1 -1
  69. package/dashboard/dist/assets/{index-ClwErGKW.js → index-CNJKLAOc.js} +1 -1
  70. package/dashboard/dist/assets/{index-ChVgw-dM.js → index-CuYxRxFQ.js} +1 -1
  71. package/dashboard/dist/assets/{index-DzUxfO5e.js → index-b-RBn81T.js} +1 -1
  72. package/dashboard/dist/assets/{info-BvndJDmD.js → info-BzwD8qDF.js} +1 -1
  73. package/dashboard/dist/assets/{link-2-BhU_5JKG.js → link-2-0X79vqnY.js} +1 -1
  74. package/dashboard/dist/assets/{loader-circle-BR_62BDE.js → loader-circle-Dto5GLrC.js} +1 -1
  75. package/dashboard/dist/assets/{local-usage-transfer-CfoyR0hM.js → local-usage-transfer-DLixSavG.js} +1 -1
  76. package/dashboard/dist/assets/{modifiers.esm-CnttlnRD.js → modifiers.esm-CL6p6jBJ.js} +1 -1
  77. package/dashboard/dist/assets/{monitor-smartphone-D4vzGxrq.js → monitor-smartphone-Bnaw35Qv.js} +1 -1
  78. package/dashboard/dist/assets/{play-BVWEKYTF.js → play-xmEUnE2_.js} +1 -1
  79. package/dashboard/dist/assets/{plus-B9GQ6VvV.js → plus-67TZHqQi.js} +1 -1
  80. package/dashboard/dist/assets/{provider-display-DCFgR7FO.js → provider-display-jd8V87bA.js} +1 -1
  81. package/dashboard/dist/assets/{react-BKUD3UPr.js → react-B68xm5mg.js} +1 -1
  82. package/dashboard/dist/assets/{safePolygon-DPIi3FGf.js → safePolygon-DiBm4xSb.js} +1 -1
  83. package/dashboard/dist/assets/{search-BBRJvYNz.js → search-DFZoQllp.js} +1 -1
  84. package/dashboard/dist/assets/{server-Cg3zBK6a.js → server-MOh3NKXh.js} +1 -1
  85. package/dashboard/dist/assets/{shield-check-BBzYplRb.js → shield-check-CqZ0Vz1G.js} +1 -1
  86. package/dashboard/dist/assets/{skills-api-CcAQ6fJX.js → skills-api-CvOFtmbw.js} +1 -1
  87. package/dashboard/dist/assets/{sortable.esm-kNieGfR9.js → sortable.esm-WjS3aHfu.js} +1 -1
  88. package/dashboard/dist/assets/{store-DQpd_ZKv.js → store-AWGUrRH9.js} +1 -1
  89. package/dashboard/dist/assets/{terminal-zj_c8_SG.js → terminal-C6wQj1wD.js} +1 -1
  90. package/dashboard/dist/assets/{trash-Sl7eOlF7.js → trash-pcTDGbRp.js} +1 -1
  91. package/dashboard/dist/assets/{use-community-stats-Bg-4yvQQ.js → use-community-stats-DmweXTA6.js} +1 -1
  92. package/dashboard/dist/assets/{use-latest-request-guard-COF23Bfs.js → use-latest-request-guard-tDJgPNLH.js} +1 -1
  93. package/dashboard/dist/assets/{use-limits-display-prefs-QOlhCOgQ.js → use-limits-display-prefs-C2cSKBpC.js} +1 -1
  94. package/dashboard/dist/assets/{use-native-settings-CKDqyirL.js → use-native-settings-CwhfcBmO.js} +1 -1
  95. package/dashboard/dist/assets/{use-ordered-list-mFHPMcF_.js → use-ordered-list-BP0VcBim.js} +1 -1
  96. package/dashboard/dist/assets/use-reduced-motion-C_uu1NvN.js +1 -0
  97. package/dashboard/dist/assets/{use-transform-CO5wZ0ML.js → use-transform-BSah0zOz.js} +1 -1
  98. package/dashboard/dist/assets/{use-usage-limits-CeKjW8jG.js → use-usage-limits-BENTyA06.js} +1 -1
  99. package/dashboard/dist/assets/{useCurrency-WruYNKxG.js → useCurrency-BPBG40V4.js} +1 -1
  100. package/dashboard/dist/assets/{usePositioner-C3NGxtZa.js → usePositioner-f0OVujvk.js} +1 -1
  101. package/dashboard/dist/assets/{useTokenFormat-ObRZ_T9W.js → useTokenFormat-DPbt6lUi.js} +1 -1
  102. package/dashboard/dist/assets/{zap-CyZ3Tf1D.js → zap-DLgyM5GN.js} +1 -1
  103. package/dashboard/dist/index.html +2 -2
  104. package/dashboard/dist/ip-check.html +2 -2
  105. package/dashboard/dist/leaderboard.html +2 -2
  106. package/dashboard/dist/share.html +2 -2
  107. package/package.json +1 -1
  108. package/src/commands/sync.js +2 -2
  109. package/src/lib/cursor-config.js +11 -21
  110. package/src/lib/cursor-login.js +157 -0
  111. package/src/lib/local-api.js +43 -0
  112. package/src/lib/pricing/seed-snapshot.json +1 -1
  113. package/src/lib/usage-limits.js +14 -9
  114. package/dashboard/dist/assets/CloudCheckoutPage-DDH-3QOd.js +0 -1
  115. package/dashboard/dist/assets/DevicePage-B6x5fBdU.js +0 -1
  116. package/dashboard/dist/assets/DialogDescription-BSCcGkVT.js +0 -1
  117. package/dashboard/dist/assets/LimitsPage-CFhzwKzB.js +0 -6
  118. package/dashboard/dist/assets/__vite-browser-external-CMBWGkOq.css +0 -1
  119. package/dashboard/dist/assets/__vite-browser-external-Lw3ipvYF.js +0 -45
  120. package/dashboard/dist/assets/use-reduced-motion-B4rpC-Zt.js +0 -1
@@ -911,12 +911,15 @@ function normalizeCursorSandUsageStatus(body, { eligible = true } = {}) {
911
911
  return buildWindow({ usedPercent, resetAt, windowSeconds });
912
912
  }
913
913
 
914
- async function fetchCursorLimits({ home, env, fetchImpl = fetch } = {}) {
915
- if (!isCursorInstalled({ home, env })) {
914
+ async function fetchCursorLimits({ home, env, trackerDir, fetchImpl = fetch } = {}) {
915
+ if (!isCursorInstalled({ home, env, trackerDir })) {
916
916
  return { configured: false };
917
917
  }
918
- const auth = extractCursorAuth({ home, env });
918
+ const auth = extractCursorAuth({ home, env, trackerDir });
919
919
  if (!auth?.cookie || !auth?.accessToken) {
920
+ if (require("./cursor-login").readCursorConnection({ home, trackerDir }).status === "expired") {
921
+ return { configured: true, connection_source: "browser", auth_error: true, auth_action_required: "reauth", error: "Cursor session expired. Reconnect Cursor in Usage & Limits." };
922
+ }
920
923
  return { configured: false };
921
924
  }
922
925
  try {
@@ -937,6 +940,7 @@ async function fetchCursorLimits({ home, env, fetchImpl = fetch } = {}) {
937
940
  configured: true,
938
941
  error: null,
939
942
  ...normalizeCursorUsageSummary(body),
943
+ ...(auth.source === "browser" ? { connection_source: "browser" } : {}),
940
944
  quaternary_window: grokBotWindow,
941
945
  // Internal cache-partition key (stripped before the payload is served).
942
946
  cache_identity: auth.userId,
@@ -945,10 +949,11 @@ async function fetchCursorLimits({ home, env, fetchImpl = fetch } = {}) {
945
949
  return {
946
950
  configured: true,
947
951
  error: error?.message || "Unknown error",
952
+ ...(auth.source === "browser" ? { connection_source: "browser" } : {}),
948
953
  // A session-expiry error is actionable (re-login) and must not be hidden
949
954
  // behind the stale disk-cache fallback (opencode-go auth_error precedent).
950
955
  // Internal marker — stripped before the payload is served.
951
- ...(error?.code === "AUTH_EXPIRED" ? { auth_error: true } : {}),
956
+ ...(error?.code === "AUTH_EXPIRED" ? { auth_error: true, auth_action_required: "reauth" } : {}),
952
957
  cache_identity: auth.userId,
953
958
  };
954
959
  }
@@ -3178,9 +3183,9 @@ function writeCursorLimitsCache(limits, { home, nowMs = Date.now(), identity } =
3178
3183
  // Failure-only identity re-derivation for the cache fallback: when the provider slot's
3179
3184
  // result was produced by the outer timeout race, the fetcher's own identity field is
3180
3185
  // lost, so read the (still-local) state DB once to learn who we are serving for.
3181
- function resolveCursorCacheIdentity({ home, env } = {}) {
3186
+ function resolveCursorCacheIdentity({ home, env, trackerDir } = {}) {
3182
3187
  try {
3183
- return extractCursorAuth({ home, env })?.userId || null;
3188
+ return extractCursorAuth({ home, env, trackerDir })?.userId || null;
3184
3189
  } catch (_error) {
3185
3190
  return null;
3186
3191
  }
@@ -5207,7 +5212,7 @@ async function fetchUsageLimitsUncached({
5207
5212
  (reason) => ({ status: "rejected", reason }),
5208
5213
  )
5209
5214
  : Promise.resolve(null),
5210
- hiddenSet.has("cursor") ? hiddenSentinel : withProviderTimeout(fetchCursorLimits({ home, env, fetchImpl: providerFetch }), "Cursor", providerTimeoutMs)
5215
+ hiddenSet.has("cursor") ? hiddenSentinel : withProviderTimeout(fetchCursorLimits({ home, env, trackerDir, fetchImpl: providerFetch }), "Cursor", providerTimeoutMs)
5211
5216
  .catch((reason) => ({ configured: true, error: reason?.message || "Unknown error" })),
5212
5217
  hiddenSet.has("kimi") ? hiddenSentinel : withProviderTimeout(fetchKimiLimits({ home, env, fetchImpl: providerFetch }), "Kimi", providerTimeoutMs)
5213
5218
  .catch((reason) => ({ configured: true, error: reason?.message || "Unknown error" })),
@@ -5647,7 +5652,7 @@ async function fetchUsageLimitsUncached({
5647
5652
  nowMs,
5648
5653
  identity: typeof cursor.cache_identity === "string"
5649
5654
  ? cursor.cache_identity
5650
- : resolveCursorCacheIdentity({ home, env }),
5655
+ : resolveCursorCacheIdentity({ home, env, trackerDir }),
5651
5656
  });
5652
5657
  }
5653
5658
  } else {
@@ -5656,7 +5661,7 @@ async function fetchUsageLimitsUncached({
5656
5661
  // re-derive it from the local state DB on this failure-only path.
5657
5662
  const identity = typeof cursor.cache_identity === "string"
5658
5663
  ? cursor.cache_identity
5659
- : resolveCursorCacheIdentity({ home, env });
5664
+ : resolveCursorCacheIdentity({ home, env, trackerDir });
5660
5665
  const cached = readCursorLimitsCache({ home, nowMs, identity });
5661
5666
  cursorWithCache = cached || cursor;
5662
5667
  }
@@ -1 +0,0 @@
1
- import{o as nt,d as ct,u as it,r as o,e as ot,a0 as lt,a1 as dt,a2 as ut,a3 as mt,a4 as Te,c as t,t as ht,v as xt,p as ft,a5 as ee,a6 as Me,a7 as pt,j as e,B as x,a8 as je,L as w,a9 as E,aa as gt,ab as _t,ac as kt,ad as yt,ae as bt,af as vt,ag as wt}from"./__vite-browser-external-Lw3ipvYF.js";import{c as fe,r as pe,C as Ne,a as jt,g as Nt,s as ze,o as $e,b as Ct}from"./cloud-checkout-3Y7NDSG1.js";import{d as It}from"./os-DMmhX9tk.js";import{C as St}from"./Card-bQCEOe_K.js";import{T as Lt}from"./Controls-CK74JkE8.js";import{CloudPlanView as Rt}from"./CloudPage-RygH3R8b.js";import{L as Ue}from"./loader-circle-BR_62BDE.js";import{S as Et}from"./shield-check-BBzYplRb.js";import{E as Pt}from"./external-link-BEb0dms0.js";import{A as Fe}from"./arrow-left-CjLKt_5C.js";import"./arrow-right-Bh-Ezs8y.js";import"./chevron-down-Beacyoub.js";import"./server-Cg3zBK6a.js";import"./check-D2uclldH.js";const He={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};He.node;const At=nt(He);function Kt(){const H=ct(),{openLoginModal:te}=it(),re=o.useRef(null),[P,A]=ot();o.useEffect(()=>{if(!P.has("_ptxn"))return;const a=new URLSearchParams(P);a.delete("_ptxn"),A(a,{replace:!0})},[P,A]);const{catalog:S,loading:_,error:j,refresh:Ce}=lt(),{account:f,auth:k,loading:G,error:U,refresh:q}=dt(),s=P.get("order")||"",L=P.get("intent")==="trial",Ge=P.get("sku"),u=`/billing/checkout?${P}`,[V,ae]=o.useState(null),[h,Ie]=o.useState(!1),[ge,_e]=o.useState(!!s),[Se,Q]=o.useState(null),[ke,Ve]=o.useState(null),[se,ye]=o.useState(null),[We,Le]=o.useState(!1),[X,Re]=o.useState(null),ne=o.useRef(null),ce=o.useRef(!1),Y=o.useRef(0),be=o.useRef(null),y=o.useRef(!0),r=k?.signedIn?k.user?.id:null,i=ut(),T=o.useRef(i);T.current=i;const Ee=o.useRef(s);Ee.current=s;const N=o.useRef(r);N.current=r;const ie=V?.ownerId===r&&V?.backend===i&&(s?V.order?.id?.toLowerCase()===s.toLowerCase():!V.verified&&V.createdFrom===u)?V:null,Pe=ke?.ownerId===r&&ke?.backend===i?ke:null,Je=se?.ownerId===r&&se?.backend===i&&se?.orderId===s?se.error:null,R=Se||Je,n=ie?.order,p=Pe||ie?.membership||f?.membership,B=S?.policy?.hosting_mode==="self_hosted"||p?.status==="self_hosted",M=n?.sku||Ge,m=S?.prices?.find(a=>a.sku===M),Ke=n?.currency||m?.currency,Qe=n?.amount_cents??m?.amount_cents,C=n?.billing_mode||m?.billing_mode,Xe=n?.term_months||m?.term_months,F=n?.provider||"waffo",l=Pe?"trial_success":h&&!n?"creating":fe(n,p),g=mt(S),I=!!S?.providers?.[F],b=!!(n?.retry_payment_conflict_at||[...f?.conflict_orders||[],...f?.pending_orders||[]].some(a=>a.retry_payment_conflict_at)),W=p?.has_gift===!0||p?.access_source==="gift"||f?.membership?.has_gift===!0||f?.gifts?.some(a=>["active","pending"].includes(a.state)),Ye=n?.provider==="waffo"&&n.payment_state==="unpaid"&&n.status!=="paid"&&["awaiting","expired","canceled"].includes(l)&&g&&I&&!b&&!W,z=k?.getAccessToken,v=pe(r),oe=f?.subscriptions?.some(a=>["active","trialing","past_due","paused"].includes(a.status)&&!a.cancel_at_period_end),le=p?.status==="active"||f?.payments?.some(a=>a.refunded_cents<a.amount_cents&&Date.parse(a.ends_at)>Date.now()),Ae=["fixed","recurring"].includes(m?.billing_mode)?S?.prices?.find(a=>a.currency===m.currency&&a.term_months===m.term_months&&a.billing_mode===(m.billing_mode==="recurring"?"fixed":"recurring")):null,qe=!!(r&&p&&!k?.loading&&!G&&!U&&l==="review"&&!L&&!s&&!n&&!h&&g&&I&&!_&&!j&&Ae&&!le&&!W&&!oe&&!b&&!v?.request_id&&!v?.order_id&&!f?.pending_orders?.length),Ze=()=>{if(!qe||ce.current)return;const a=pe(r);if(a?.request_id||a?.order_id)return;const c=new URLSearchParams(P);c.set("sku",Ae.sku),A(c,{replace:!0})},et=Te(u,r)||(X?.nextPath===u&&X?.ownerId===r&&X?.backend===i?X:null),de=t(L?"cloud.login.trial_context":"cloud.login.purchase_context");o.useEffect(()=>{if(r){re.current=null;return}k?.loading||_||B||re.current===u||(re.current=u,te({nextPath:u,subtitle:de,closePath:"/cloud"}))},[r,k?.loading,_,B,u,de,te]);const Be=S?.environment==="live"&&!L&&P.getAll("order").length===1&&Ne.test(s)&&["mac","windows"].includes(It())&&!(navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)&&!ht()&&!xt()&&!ft()?`tokentracker://billing/return?order=${s.toLowerCase()}`:null;o.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const J=o.useCallback(async()=>{if(B||!s||!r||N.current!==r)return null;if(!Ne.test(s))return Q({code:"order_not_found"}),_e(!1),null;const a=++Y.current;try{const c=await ee("order",{auth:z,params:{id:s}});if(a!==Y.current||N.current!==r||T.current!==i)return null;ae({...c,ownerId:r,backend:i,verified:!0}),Q(null);const d=fe(c.order,c.membership);if(d==="success"&&ye(null),["success","refunded"].includes(d)){const $=`${r}:${s}:${d}`;be.current!==$&&(be.current=$,q())}if(["success","expired","canceled","refunded"].includes(fe(c.order,c.membership))){const $=pe(r),K=c.order.payment_state==="unpaid"&&c.order.status!=="paid"&&["expired","canceled"].includes(fe(c.order,c.membership))&&$?.retry_order_id===s&&$?.retry_request_id;$?.order_id===s&&!K&&jt(r)}return c}catch(c){return a===Y.current&&Q(c),null}finally{a===Y.current&&_e(!1)}},[s,r,z,B,q,i]);o.useEffect(()=>(ae(null),Q(null),be.current=null,_e(!!(s&&r)),J(),()=>{Y.current+=1}),[J,s,r]),o.useEffect(()=>{if(B||!s||!r||["success","canceled","expired","refunded"].includes(l))return;const a=()=>{document.visibilityState==="visible"&&J()},c=window.setInterval(a,5e3);return window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),()=>{window.clearInterval(c),window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a)}},[s,r,l,J,B]);const D=o.useCallback(async a=>{if(!ce.current){ce.current=!0,Ie(!0),Q(null),ye(null);try{await a()}catch(c){y.current&&N.current===r&&T.current===i&&ye({ownerId:r,backend:i,orderId:s,error:c})}finally{ce.current=!1,y.current&&Ie(!1)}}},[r,s,i]),ue=o.useCallback((a=!1)=>D(async()=>{const c=Nt(r,M,F),d=await ee("checkout",{auth:z,body:{sku:M,provider:F,request_id:c.request_id,mobile:window.matchMedia("(max-width: 640px)").matches}});T.current===i&&(ze(r,{...c,order_id:d.order.id}),!(!y.current||N.current!==r)&&(a===!0&&(ne.current={ownerId:r,backend:i,orderId:d.order.id,opened:!1}),ae({...d,ownerId:r,backend:i,createdFrom:u,order:{...m,provider:F,...d.order}}),A({order:d.order.id},{replace:!0})))}),[D,r,M,F,z,m,A,i,u]),me=o.useCallback((a=!1)=>D(async()=>{let c;try{c=await ee("trial",{auth:z,body:{}})}catch(d){if(a===!0&&(d.code||d.message)==="trial_unavailable"){y.current&&N.current===r&&T.current===i&&(await q(),y.current&&N.current===r&&T.current===i&&H("/cloud",{replace:!0}));return}throw d}!y.current||N.current!==r||T.current!==i||(Ve({...c.membership,ownerId:r,backend:i}),a===!0?(await q(),y.current&&N.current===r&&T.current===i&&H("/dashboard",{replace:!0})):q())}),[D,z,r,q,H,i]);o.useEffect(()=>{const a=Te(u,r);if(!a||!r||h||k?.loading||G||U||_||j||!p||B||!g)return;if(a.orderId){if(a.orderId!==s)return;const xe=Me(u,r);if(!xe)return;Re({...xe,ownerId:r}),b||(ne.current={ownerId:r,backend:i,orderId:s,opened:!1});return}if(s||!a.trial&&(!m||!I||!C))return;const c=Me(u,r);if(!c)return;if(Re({...c,ownerId:r}),a.trial){if(p.trial_available)me(!0);else{const xe=p.can_read_cloud||["active","trial","transition"].includes(p.status);H(xe?"/dashboard":"/cloud",{replace:!0})}return}if(W||oe||le&&C!=="fixed"||b){H("/settings?section=cloud",{replace:!0});return}const d=pe(r),$=f?.pending_orders?.[0],K=d?.order_id||$?.id;K&&Ne.test(K)?(ne.current={ownerId:r,backend:i,orderId:K,opened:!1},A({order:K},{replace:!0})):d?.request_id&&(d.sku!==M||d.provider!==F)?A({sku:d.sku},{replace:!0}):ue(!0)},[u,r,s,h,k?.loading,G,U,_,j,p,B,g,m,I,C,W,oe,le,b,f?.pending_orders,M,F,me,ue,H,A,i]),o.useEffect(()=>{const a=ne.current;!a||a.opened||a.ownerId!==r||a.backend!==i||a.orderId!==s||!ie?.verified||n?.id?.toLowerCase()!==s.toLowerCase()||!n?.checkout_url||l!=="awaiting"||h||!g||!I||b||(a.opened=!0,D(()=>$e(n.checkout_url,{sameTab:!0})))},[r,s,n?.id,n?.checkout_url,ie?.verified,X?.nextPath,l,h,g,I,b,D,i]);const De=()=>D(async()=>{await ee("reconcile",{auth:z,body:{id:s}}),!(!y.current||N.current!==r)&&(await J(),await q())}),tt=()=>D(async()=>{const a=Ct(r,n);Le(!0);try{const c=await ee("restart-checkout",{auth:z,body:{id:n.id,request_id:a.retry_request_id}});if(ze(r,{sku:n.sku,provider:n.provider,request_id:a.retry_request_id,order_id:c.order.id}),!y.current||N.current!==r||Ee.current!==n.id)return;ae({...c,ownerId:r,backend:i}),A({order:c.order.id},{replace:!0})}finally{y.current&&Le(!1)}}),rt=()=>D(async()=>{await $e(n.checkout_url)}),ve=S?.limits?.trial_days||7,we=wt(),Z=we&&!pt(),at=new Date(Date.now()+ve*864e5).toISOString(),he=L?t("cloud.checkout.starting_trial"):t("cloud.checkout.creating"),st={review:L?t("cloud.checkout.trial_title"):t("cloud.checkout.title"),creating:he,awaiting:t("cloud.checkout.awaiting"),activating:t("cloud.checkout.activating"),success:t("cloud.checkout.success"),canceled:t("cloud.checkout.canceled"),expired:n?.status==="paid"?t("cloud.checkout.term_ended"):t("cloud.checkout.expired"),refunded:t("cloud.checkout.refunded"),trial_success:t("cloud.checkout.trial_success")};let O=null;if(!r)O=e.jsx("div",{className:"space-y-5",children:e.jsx(x,{onClick:()=>te({nextPath:u,subtitle:de,closePath:"/cloud"}),className:"w-full",disabled:k?.loading,children:t("cloud.action.sign_in_continue")})});else if(ge||h&&!n)O=e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-sm",children:[e.jsx(Ue,{className:"motion-safe:animate-spin",size:17,"aria-hidden":!0}),ge?t("cloud.checkout.loading"):he]});else if(l==="trial_success"||l==="success")O=e.jsxs("div",{className:"space-y-5",children:[e.jsx(At,{size:32,className:"text-oai-gray-700 dark:text-oai-gray-200","aria-hidden":!0}),e.jsx("p",{className:"text-sm leading-6",children:l==="trial_success"?t("cloud.trial.ends",{date:je(p.trial_ends_at)}):t("cloud.membership.expires",{date:je(p.expires_at)})}),Z||!we?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:t(we?"cloud.onboarding.local_next":"cloud.onboarding.web_next")}):null,e.jsx(x,{as:w,to:Z?"/settings?section=cloud":"/dashboard",className:"w-full no-underline",children:t(Z?"cloud.action.setup_sync":"cloud.action.open_dashboard")}),e.jsx(w,{to:Z?"/dashboard":"/settings?section=cloud",className:"flex min-h-10 items-center justify-center text-sm underline underline-offset-4",children:t(Z?"cloud.action.open_dashboard":"cloud.action.manage_membership")})]});else if(l==="review"&&!s&&W)O=e.jsxs("div",{className:"space-y-5",children:[e.jsx(E,{children:t("cloud.gift.error_active")}),e.jsx(x,{as:w,to:"/settings?section=cloud",variant:"secondary",className:"w-full no-underline",children:t("cloud.action.manage_membership")})]});else if(l==="review"&&!s&&L)O=e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6",children:t("cloud.trial.disclosure",{days:ve,date:je(at)})}),e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.trial.expiry")}),f?.membership&&!f.membership.trial_available?e.jsxs("div",{className:"space-y-3",children:[e.jsx(E,{children:t("cloud.error.trial")}),m?null:e.jsx(x,{as:w,to:"/cloud",variant:"secondary",className:"w-full no-underline",children:t("cloud.action.view_plans")})]}):null,e.jsx(x,{onClick:me,disabled:h||!g||!f?.membership?.trial_available,className:"w-full",children:t("cloud.action.start_trial",{days:ve})}),m&&g&&I&&!h?e.jsx(x,{as:w,to:`/billing/checkout?sku=${encodeURIComponent(m.sku)}`,variant:"ghost",className:"mx-auto flex w-fit no-underline",children:t("cloud.plan.skip_trial")}):null]});else if(l==="review"&&!s&&m)O=e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6",children:t("cloud.checkout.review")}),e.jsxs("p",{className:"inline-flex items-center gap-2 text-sm",children:[e.jsx(Et,{size:16,"aria-hidden":!0}),t("cloud.checkout.waffo")]}),C?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:C==="fixed"?t("cloud.checkout.methods_fixed"):t("cloud.checkout.methods_recurring")}):null,C?e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:C==="fixed"?t("cloud.renewal.manual"):t("cloud.renewal.auto")}),qe?e.jsx(Lt,{checked:C==="recurring",onChange:Ze,ariaLabel:t("cloud.billing_mode.recurring")}):null]}):null,v?.order_id?e.jsx(x,{as:w,to:`/billing/checkout?order=${encodeURIComponent(v.order_id)}`,className:"w-full no-underline",children:t("cloud.action.resume_order")}):null,v?.request_id&&!v.order_id&&v.sku!==M?e.jsx(x,{as:w,to:`/billing/checkout?sku=${encodeURIComponent(v.sku)}`,className:"w-full no-underline",children:t("cloud.action.resume_purchase")}):null,!v?.order_id&&!(v?.request_id&&v.sku!==M)?e.jsx(x,{onClick:ue,disabled:h||!g||!I||!C||!!v?.order_id||b,className:"w-full",children:t("cloud.action.create_checkout",{amount:gt(Qe,Ke)})}):null]});else if(n){const a={creating:t("cloud.checkout.pending_creation"),awaiting:t("cloud.checkout.pending_payment"),activating:t("cloud.checkout.received"),expired:n?.status==="paid"?t("cloud.checkout.term_ended_detail"):t("cloud.checkout.expired_detail"),canceled:t("cloud.checkout.canceled_detail"),refunded:t("cloud.checkout.refunded_detail")};O=e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:a[l]}),l==="awaiting"&&n.checkout_url&&g&&I&&!b?e.jsxs(x,{onClick:rt,disabled:h,className:"w-full",children:[t("cloud.action.open_payment"),e.jsx(Pt,{size:15,className:"ml-2","aria-hidden":!0})]}):null,l!=="refunded"?e.jsxs(e.Fragment,{children:[e.jsx(x,{onClick:De,disabled:h,variant:"ghost",className:"mx-auto flex underline underline-offset-4",children:h?t("cloud.action.checking"):t("cloud.action.check_payment")}),e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.recovery_hint")})]}):null,Ye?e.jsxs("details",{open:l!=="awaiting",className:"border-t border-oai-gray-200 pt-4 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"min-h-10 cursor-pointer text-sm font-medium leading-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:t("cloud.checkout.help_title")}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.restart_detail")}),e.jsx(x,{onClick:tt,disabled:h,variant:l==="awaiting"?"secondary":"primary",className:"w-full",children:We?t("cloud.action.restarting_checkout"):t("cloud.action.restart_checkout")})]})]}):null,["canceled","expired"].includes(l)&&!b?e.jsx(w,{to:"/cloud",className:"flex min-h-10 items-center justify-center text-sm underline underline-offset-4",children:n.status==="paid"?t("cloud.action.renew"):t("cloud.action.choose_plan")}):null,l==="refunded"?e.jsx(x,{as:w,to:"/settings?section=cloud",className:"w-full no-underline",children:t("cloud.action.manage_membership")}):null,e.jsxs("details",{className:"border-t border-oai-gray-200 pt-4 dark:border-oai-gray-800",children:[e.jsxs("summary",{className:"min-h-10 cursor-pointer text-xs leading-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:[t("cloud.checkout.order_id")," · ",n.id.slice(0,8)]}),e.jsx("p",{className:"mb-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:_t(n.provider)}),e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.order_id")}),e.jsx("p",{className:"mt-1 break-all font-mono text-xs select-all",children:n.id}),n.status!=="paid"&&n.expires_at?e.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.expires",{date:kt(n.expires_at)})}):null]})]})}else O=e.jsx(E,{children:s?t("cloud.error.order_not_found"):t("cloud.checkout.choose_plan")});const Oe=e.jsxs("div",{className:"space-y-3",children:[R?e.jsx(E,{error:R,onRetry:s?Se?J:De:void 0}):null,R&&["subscription_already_exists","fixed_term_still_active","checkout_request_conflict","pending_checkout_exists","gift_membership_active"].includes(R.code||R.message)?e.jsx(x,{as:w,to:"/settings?section=cloud",variant:"secondary",className:"no-underline",children:t("cloud.action.manage_membership")}):null,R&&["authentication_required","invalid_token","invalid_authentication"].includes(R.code||R.message)?e.jsx(x,{onClick:async()=>{await k?.signOut?.(),re.current=u,te({nextPath:u,subtitle:de,closePath:"/cloud"})},variant:"secondary",children:t("cloud.action.sign_in_continue")}):null,j?e.jsx(E,{error:j,onRetry:Ce}):null,U?e.jsx(E,{error:U,onRetry:q}):null,!j&&_?e.jsx(E,{children:t("cloud.catalog.loading")}):null,!j&&!_&&!g?e.jsx(E,{children:t("cloud.catalog.preview")}):null,!j&&!_&&g&&!L&&!R&&!I&&["review","creating","awaiting"].includes(l)?e.jsx(E,{children:t("cloud.catalog.provider_unavailable")}):null,!j&&!_&&g&&S?.environment==="sandbox"?e.jsx(E,{children:t("cloud.catalog.sandbox")}):null]});return B?e.jsx(yt,{}):!r&&!s?e.jsx(e.Fragment,{children:e.jsx(Rt,{catalogState:{catalog:S,loading:_,error:j,refresh:Ce},accountState:{account:f,auth:k,loading:G,error:U,refresh:q},selection:{termMonths:Xe,billingMode:C}})}):et&&r&&!s?e.jsx("div",{className:"tt-cloud-theme flex flex-1 flex-col font-oai text-oai-black dark:text-oai-white",children:e.jsxs("main",{className:"mx-auto w-full max-w-lg px-4 py-12 sm:px-6",children:[e.jsxs(w,{to:"/cloud",onClick:()=>bt(u),className:"mb-6 inline-flex min-h-10 items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Fe,{size:16,"aria-hidden":!0}),t("cloud.checkout.back")]}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:he}),h||k?.loading||_||G?e.jsxs("p",{role:"status",className:"mt-5 flex items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Ue,{className:"motion-safe:animate-spin",size:17,"aria-hidden":!0}),he]}):null,e.jsx("div",{className:"mt-5",children:Oe}),R&&!h?e.jsx(x,{onClick:()=>L?me(!0):ue(!0),disabled:G||!!U||_||!!j||!g||(L?!p?.trial_available:!m||!I||b||W||le&&C!=="fixed"||oe),className:"mt-5 w-full",children:t("cloud.action.retry")}):null]})}):e.jsx("div",{className:"tt-cloud-theme flex flex-1 flex-col font-oai text-oai-black dark:text-oai-white",children:e.jsxs("main",{className:"mx-auto w-full max-w-xl px-4 py-8 sm:px-6 sm:py-12",children:[e.jsxs(w,{to:"/cloud",className:"mb-7 inline-flex min-h-10 items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-brand focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand",children:[e.jsx(Fe,{size:16,"aria-hidden":!0}),t("cloud.checkout.back")]}),e.jsx("h1",{className:"text-3xl font-semibold tracking-tight","aria-live":"polite",children:ge?t("cloud.checkout.loading"):st[l]}),S?.environment==="sandbox"&&!L?e.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.price.draft")}):null,b?e.jsx("div",{className:"mt-5",children:e.jsx(vt,{})}):null,e.jsx("div",{className:"mt-7",children:e.jsxs(St,{bodyClassName:"sm:p-7",children:[O,Be?e.jsxs("div",{className:"mt-5 space-y-3 border-t border-oai-gray-200 pt-5 dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.return_app_hint")}),e.jsx("a",{href:Be,className:"inline-flex min-h-10 items-center text-sm underline underline-offset-4",children:t("cloud.action.open_app")})]}):null]})}),e.jsx("div",{className:"mt-5",children:Oe})]})})}export{Kt as CloudCheckoutPage};
@@ -1 +0,0 @@
1
- import{a as b,r as l,j as r,c as e,f as v}from"./__vite-browser-external-Lw3ipvYF.js";const f={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_VERSION:"1.5.8",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-Lw3ipvYF.js";import{u as p}from"./DialogTitle-B3m-31sy.js";import{u as c}from"./composite-B28yORTL.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,6 +0,0 @@
1
- import{o as ne,j as e,y as Ke,c as r,h as W,r as g,bm as Nt,V as w,bn as _t,bo as St,al as Pt,B as te,bp as Ct,e as Mt,W as ye,R as Dt,L as Et,bq as Rt,t as Tt,w as It}from"./__vite-browser-external-Lw3ipvYF.js";import{m as Re}from"./react-BKUD3UPr.js";import{P as re,c as At,r as pe,a as Ht,u as Ot,b as Ft,s as Lt}from"./use-usage-limits-CeKjW8jG.js";import{b as qe,c as M,l as ue,d as Ve,u as $t,h as Te}from"./use-limits-display-prefs-QOlhCOgQ.js";import{F as zt}from"./FadeIn-C60pLKXu.js";import{P as Ye}from"./ProviderIcon-BQfkoaQE.js";import{H as Ut}from"./HoverTooltip-D9RtbhSZ.js";import{C as ie}from"./chevron-down-Beacyoub.js";import{G as Bt}from"./gift-twpInP_O.js";import{C as Gt}from"./ConfirmModal-D3vd882N.js";import{I as Ie,L as Wt}from"./LocalOnlyNotice-F_qczacX.js";import{S as ve}from"./Select-CQVnpoBO.js";import{P as Kt}from"./plus-B9GQ6VvV.js";import{P as qt,a as Vt,b as Yt,c as Zt,d as Xt}from"./PopoverPopup-DxB1k4g7.js";import{u as Jt}from"./use-reduced-motion-B4rpC-Zt.js";import"./use-latest-request-guard-COF23Bfs.js";import"./DialogTitle-B3m-31sy.js";import"./composite-B28yORTL.js";import"./store-DQpd_ZKv.js";import"./DialogDescription-BSCcGkVT.js";import"./arrow-up-right-C87CvEJ5.js";import"./download-IIXYYmyo.js";import"./check-D2uclldH.js";import"./SelectItemText-DmAn7osh.js";import"./usePositioner-C3NGxtZa.js";import"./safePolygon-DPIi3FGf.js";const Ze={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"}]]};Ze.node;const Qt=ne(Ze);const Xe={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"}]]};Xe.node;const ea=ne(Xe);const Je={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"}]]};Je.node;const Qe=ne(Je);const et={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};et.node;const Se=ne(et);const tt={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"}]]};tt.node;const at=ne(tt),ta=[3,2,3,3,2,2,3];function Y({className:t}){return e.jsx("div",{className:Ke("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function aa(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-3 w-12 shrink-0"}),e.jsx(Y,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(Y,{className:"h-3 w-[30px] shrink-0"}),e.jsx(Y,{className:"h-3 w-6 shrink-0"})]})}function ra({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(Y,{className:"h-[22px] w-[22px] shrink-0 rounded"}),e.jsx(Y,{className:Ke("h-4",i)})]}),e.jsx("div",{className:"flex flex-col gap-2 px-4 py-4 sm:px-5",children:Array.from({length:t},(n,s)=>e.jsx(aa,{},s))})]})}function ia(){return e.jsx("div",{className:"flex flex-col gap-3","aria-hidden":"true",children:ta.map((t,a)=>e.jsx(ra,{bars:t,index:a},a))})}const we=100;function Ae(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function sa(t){return Math.max(0,Math.min(we,Math.round(t)))}function na(t){return new Intl.DateTimeFormat(W(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function oa(t,a,i){if(t==null||t>=a)return we;const n=a-t,s=a-i;return sa(s/n*we)}function la(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function ca(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=la(t);if(i===void 0)return null;const n=Array.isArray(t.credits)?t.credits:[],s=a instanceof Date?a.getTime():Number(a??Date.now()),o=[];for(const c of n){const l=Ae(c?.expires_at);if(l==null)continue;const d=o.length+1;o.push({key:`reset-${d}`,label:r("limits.codex_reset_bank.row_label",{index:d}),expiresAt:na(l),expiresMs:l,percent:oa(Ae(c?.granted_at),l,s)})}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 se=864e5;function G(t,a){const i=new Date(t),n=i.getUTCDate(),s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+a,1,i.getUTCHours(),i.getUTCMinutes())),o=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()+1,0)).getUTCDate();return s.setUTCDate(Math.min(n,o)),s.getTime()}function rt(t,a){if(a==="weekly")return t-7*se;if(a==="yearly")return G(t,-12);const i=new Date(t),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),0)).getUTCDate(),s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()-1,1,i.getUTCHours(),i.getUTCMinutes()));return s.setUTCDate(Math.min(i.getUTCDate(),n)),s.getTime()}function it(t,a){return a==="weekly"?t+7*se:a==="yearly"?G(t,12):G(t,1)}function da(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return rt(new Date(t.nextBillingAt).getTime(),t.cycle)}function ua(t,a,i){if(t.startedAt!=null){const n=new Date(t.startedAt).getTime();if(Number.isFinite(n))return n}return rt(i,a)}function ma(t,a,i){if(a==="weekly"){const l=7*se,d=i<=t?0:Math.floor((i-t)/l);return{startMs:t+d*l,endMs:t+(d+1)*l}}const n=a==="yearly"?12:1,s=n*30.436875*se;let o=i<=t?0:Math.floor((i-t)/s);for(;o>0&&G(t,o*n)>i;)o-=1;let c=0;for(;G(t,(o+1)*n)<=i&&c<12e3;)o+=1,c+=1;return{startMs:G(t,o*n),endMs:G(t,(o+1)*n)}}function me(t,a){const i=new Date(t.nextBillingAt).getTime();if(!Number.isFinite(i))return null;const n=["weekly","monthly","yearly"].includes(t.cycle)?t.cycle:"monthly",s=ua(t,n,i);if(!Number.isFinite(s))return null;let o,c,l=!1;t.autoRenew?{startMs:o,endMs:c}=ma(s,n,a):t.startedAt!=null?(o=s,c=it(s,n),l=c<=a):(o=s,c=i,l=c<=a);const d=Math.max(1,c-o),m=l?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:c,startMs:o,progress:m,cycleDays:Math.max(1,Math.round(d/se)),expired:l}}function st(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const n=Math.ceil(i/6e4);if(n<60)return`${n}m`;const s=Math.floor(n/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function Ne(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const n=Math.floor(i/6e4),s=Math.floor(n/1440),o=Math.floor(n%1440/60),c=n%60;return r("subscriptions.countdown",{days:s,hours:o,minutes:c})}const xa="shrink-0 text-oai-black dark:text-oai-white",pa={opencodeGo:"OPENCODE_GO_API_KEY",commandCode:"COMMAND_CODE_API_KEY",deepseek:"DEEPSEEK_API_KEY"},ga={opencodeGo:"opencode-go",commandCode:"command-code",deepseek:"deepseek"};function nt(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function ot(){return nt()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function lt(){return r("limits.devin.setupHint.snippet_login")}function ha(t){const a=pe(t);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const n=Math.floor(i/6e4);if(n<60)return`${n}m`;const s=Math.floor(n/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function ct(t,a){const i=a===M.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function xe(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ge(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function de(t){const a=Math.max(0,Math.min(100,Number(t)||0)),i=Math.round(a);return a>0&&i===0?r("limits.bar.sub_one_percent"):String(i)}function Z(t,{useGrouping:a=!0,maximumFractionDigits:i}={}){const n=Number(t);return Number.isFinite(n)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:i??(n>=100?0:2),useGrouping:a}).format(n):null}function dt(t,a){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const i={useGrouping:t.unit!=="calls",maximumFractionDigits:a},n=Z(t.used_credits,i),s=Z(t.limit_credits,i),o=Z(t.remaining_credits,i);if(!n||!s||!o)return null;const c=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(c,{used:n,limit:s,remaining:o})}function Pe(t,a,i){return At({usedPercent:xe(t.window,t.pctField),windowSeconds:Ht(t,t.window),resetMs:pe(ge(t.window,t.resetField)),mode:a,now:i})}function X(t){return Number.isFinite(t)?new Intl.DateTimeFormat(W(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function fa(t,a,i){const n=[mt(t,a,i)],s=pe(ge(t.window,t.resetField)),o=X(s);o&&n.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const c=dt(t.window,t.creditPrecision);return c&&n.push(c),n.join(`
2
- `)}const ut=Ut,He=[1,.65,.45,.3,.2];function _e(t){return He[Math.min(t,He.length-1)]}function Oe({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 ba({label:t,pct:a,reset:i,mode:n=M.USED,pacePercent:s=null,paceOver:o=!1,title:c=null,segments:l=null}){const d=Math.max(0,Math.min(100,Number(a)||0)),m=n===M.REMAINING?100-d:d,u=ct(m,n),p=Math.round(m),h=m>0&&p===0?Math.max(m,.35):m;let y=String(p);m>0&&p===0&&(y=r("limits.bar.sub_one_percent"));const b=s==null?null:Math.max(0,Math.min(100,s)),k=l?.map(C=>Math.max(0,Math.min(100,Number(C.pct)||0))),S=k?.reduce((C,j)=>C+j,0)||0,E=l?Math.max(0,d-S):0,F=Math.max(0,100-S-E);return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(ut,{text:c}),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}),l?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:[l.map((C,j)=>e.jsx("div",{"data-limit-segment":C.key,className:`${u} min-w-0 rounded-full h-full transition-[flex-grow] duration-500 ease-out`,style:{flex:`${k[j]} 1 0px`,opacity:_e(j)}},C.key)),E?e.jsx("div",{"data-limit-unallocated-used":"",className:`${u} min-w-0 rounded-full h-full`,style:{flex:`${E} 1 0px`,opacity:_e(l.length)}}):null,F?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:`${F} 1 0px`}}):null,b!=null&&e.jsx(Oe,{paceX:b,paceOver:o})]}):e.jsxs("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${u} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${h}%`,minWidth:m>0?"3px":0}}),b!=null&&e.jsx(Oe,{paceX:b,paceOver:o})]}),e.jsxs("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:[y,"%"]}),i&&e.jsx("span",{className:"text-xs tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-8 text-right shrink-0",children:i})]})}function ya({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,n)=>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:_e(n)}}),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:[de(i.pct),"%"]})]},i.key))})}function mt(t,a,i){const n=t.label??r(t.labelKey),s=i===M.REMAINING,o=d=>s?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(xe(t.window,t.pctField))||0)),m=de(o(d));return s?r("limits.explain.remaining",{label:n,used:m}):r("limits.explain.used",{label:n,used:m})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:n,eta:a.runsOutEta});const d=de(o(a.projectedEnd??100));return r(s?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:n,pct:d})}const c=Math.max(0,Math.min(100,Number(xe(t.window,t.pctField))||0)),l=de(o(a.projectedEnd??c));return r(s?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:n,pct:l})}function xt({pace:t}){return t.pacePercent!=null}function va(t,a){return t.some(i=>xt(i)&&(i.mode??a)===M.REMAINING)}function Ce({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const n=va(t,a),s=t.some(xt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:c,mode:l=a})=>{const d=X(pe(ge(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[mt(o,c,l),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:dt(o.window,o.creditPrecision)}):null]},o.key)}),s?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(n?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function ae(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 n=Math.floor(i/60);if(n<24)return r("shared.time.h_ago",{n});const s=Math.floor(n/24);return r("shared.time.d_ago",{n:s})}const Fe={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"}},ka={claude:"claude",codex:"codex",antigravity:"agy"};function V({label:t,age:a=null,tone:i="live",tooltip:n=null}){const s=Fe[i]||Fe.live,o=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:c=>c.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 ${s.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 ${s.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${s.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${s.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),n?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:[n,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 pt({name:t,providerId:a,children:i,expandable:n=!1,expanded:s=!1,onToggle:o,badge:c=null,rightAdornment:l=null,toggleOnHeader:d=!1}){const m=Ve(a),u=e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[m?e.jsx(Ye,{provider:m,size:22,className:xa}):null,e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t}),l?e.jsx("span",{className:"shrink-0",children:l}):null,c]}),p="rounded-xl border border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-900",h="flex w-full items-center justify-between gap-3 border-b border-oai-gray-200 px-4 py-3 text-left dark:border-oai-gray-800 sm:px-5",y=e.jsx("div",{className:"flex flex-col gap-2 px-4 py-4 sm:px-5",children:i});return n?d?e.jsxs("div",{className:p,children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:o,className:`${h} rounded-t-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500`,children:[u,e.jsx(ie,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${s?"rotate-180":""}`})]}),y]}):e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),o?.())},className:`${p} cursor-pointer transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500`,children:[e.jsxs("div",{className:h,children:[u,e.jsx(ie,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${s?"rotate-180":""}`})]}),y]}):e.jsxs("div",{className:p,children:[e.jsx("div",{className:h,children:u}),y]})}function gt({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?at:Se;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 ht({subscription:t,now:a,mode:i=M.USED}){const n=me(t,a);if(!n)return null;const{endMs:s,expired:o}=n,c=!o&&s-a<=3*864e5,l=o?100:n.progress*100,d=i===M.REMAINING?100-l:l,m=o?100:Math.max(0,Math.min(100,d)),u=Math.round(m),p=m>0&&u===0?r("limits.bar.sub_one_percent"):`${u}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"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: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":c?"bg-amber-500":"bg-blue-500"} rounded-full h-full block motion-safe:transition-[width] motion-safe:duration-500 ease-out motion-reduce:transition-none`,style:{width:`${m}%`,minWidth:m>0?"3px":0}})}),e.jsx("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:p}),e.jsx("span",{className:`text-xs tabular-nums shrink-0 whitespace-nowrap w-8 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:st(s,a)})]})}function ft({subscription:t,now:a}){const i=me(t,a);if(!i)return null;const n=new Intl.DateTimeFormat(W(),{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:n.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:Ne(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 ja=qe;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(Nt,{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 Me({rows:t,mode:a,extra:i=null,expanded:n=!1}){const s=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:o,pace:c,mode:l=a})=>{const d=xe(o.window,o.pctField),u=n&&o.productPool&&Array.isArray(o.segments)&&o.segments.length!==0?o.segments:null,p=u&&l!==M.REMAINING?u:null;return e.jsxs(w.Fragment,{children:[e.jsx(ba,{label:o.label??r(o.labelKey),pct:d,reset:ha(ge(o.window,o.resetField)),mode:l,segments:p,pacePercent:c.pacePercent,paceOver:c.paceOver,title:fa(o,c,l)}),u?e.jsxs(e.Fragment,{children:[e.jsx(ya,{segments:u,fillColor:ct(d,M.USED)}),l===M.REMAINING?e.jsx("div",{"data-limit-share-note":"",className:"-mt-0.5 text-[11px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",style:{paddingLeft:"calc(var(--tt-limits-label-w, 0px) + 0.5rem)"},children:r("limits.grok.shares_are_used")}):null]}):null]},o.key)}),s?e.jsx(A,{children:r("limits.status.no_data")}):null,i]})}function wa(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 Na({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(ut,{text:wa(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 _a({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(Na,{row:i},i.key))]})}const Sa={five_hour:5*3600*1e3,weekly:168*3600*1e3};function bt(t,a){if(!t||typeof t!="object")return!1;if(t.error)return!0;for(const i of["five_hour","weekly"])for(const n of t[i]||[])if(Date.parse(n?.expires_at)>a)return!0;return!1}function Pa({data:t}){const[a,i]=g.useState(!1),n=Date.now();if(!bt(t,n))return null;const s=[{key:"five_hour",label:r("limits.label.zcode_5h")},{key:"weekly",label:r("limits.label.zcode_weekly")}].map(l=>{const d=(t[l.key]||[]).filter(b=>Date.parse(b.expires_at)>n).sort((b,k)=>Date.parse(b.expires_at)-Date.parse(k.expires_at)),m=new Map;for(const b of d){const k=Date.parse(b.expires_at);m.set(k,(m.get(k)||0)+1)}const p=[...m.entries()].sort((b,k)=>b[0]-k[0]).map(([b,k])=>k>1?r("limits.zcode.reset_bank.batch",{time:X(b),count:k}):X(b)).join(`
3
- `),h=Sa[l.key]||0,y=d.length&&h?Math.max(0,Math.min(100,(Date.parse(d[0].expires_at)-n)/h*100)):0;return{...l,cards:d,batchTitle:p,countdownPercent:y}});let o=0;const c=[];for(const l of s)o+=l.cards.length,l.cards.length&&c.push(l);return e.jsxs("div",{className:"mt-2 border-t border-oai-gray-200/60 pt-2 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:l=>{l.stopPropagation(),i(d=>!d)},onKeyDown:l=>l.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(Se,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",children:r("limits.zcode.reset_bank.title")}),o?e.jsx("span",{className:"rounded-full bg-oai-gray-100 px-2 py-0.5 text-[10px] tabular-nums text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:r("limits.zcode.reset_bank.count",{count:o})}):null,e.jsx(ie,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${a?"rotate-180":""}`})]}),t.error?e.jsx(A,{tone:"error",children:t.error}):null,a&&!t.error?e.jsx("div",{className:"mt-2 flex flex-col gap-1.5",children:c.map(l=>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:l.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:l.cards.length})}),e.jsx("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",title:l.batchTitle,children:e.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${l.countdownPercent}%`,minWidth:l.countdownPercent>0?"3px":0}})}),l.cards.length?e.jsx("span",{className:"ml-auto shrink-0 whitespace-nowrap text-right text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",title:l.batchTitle,children:r("limits.zcode.reset_bank.earliest",{time:X(Date.parse(l.cards[0].expires_at))})}):null]},l.key))}):null]})}function Ca({data:t}){const a=Array.isArray(t?.balances)?t.balances:[];return e.jsxs("div",{className:"mt-1 space-y-1","data-deepseek-balance":"",children:[a.map(i=>{const n=String(i?.currency||"").toUpperCase(),s=Z(i?.total,{maximumFractionDigits:2}),o=Number(i?.granted)>0?Z(i.granted,{maximumFractionDigits:2}):null;return!n||!s?null:e.jsxs("div",{className:"flex items-center gap-2",children:[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:r("limits.deepseek.balance_label",{currency:n})}),e.jsx("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300",children:s}),o?e.jsx("span",{className:"text-[10.5px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.deepseek.granted_detail",{amount:o})}):null]},n)}),t?.is_available===!1?e.jsx("div",{className:"mt-1",children:e.jsx(A,{tone:"error",children:r("limits.deepseek.unavailable")})}):null]})}function yt(t,a){if(t==="deepseek_balance")return e.jsx(Ca,{data:a});if(t==="zcode_reset_bank")return bt(a.reset_credits,Date.now())?e.jsx(Pa,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=ca(a.reset_credits);return i?e.jsx(_a,{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=Z(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(Ta,{defaultDir:a.otel_default_dir}):null}function Ma({data:t,mode:a,now:i}){const[n,s]=g.useState(!1),o=g.useRef(null),c=De(o),l=[...new Set((t.buckets||[]).map(u=>u.plan_name).filter(Boolean))],d=l.length?l.join(" · "):r("limits.zcode.start_grants"),m=re.zcode.windows(t).filter(u=>u.window).map(u=>({spec:u,pace:Pe(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":n,onClick:u=>{u.stopPropagation(),s(p=>!p)},onKeyDown:u=>u.stopPropagation(),className:"flex w-full items-center gap-1.5 rounded text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx(Bt,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(ie,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${n?"rotate-180":""}`})]}),n?e.jsx("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:c>0?{"--tt-limits-label-w":`${c}px`}:void 0,children:t.error?e.jsx(A,{tone:"error",children:t.error}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{rows:m,mode:a}),e.jsx(Ce,{rows:m,mode:a,now:i}),(t.buckets||[]).filter(u=>Number.isFinite(u.remaining_units)&&Number.isFinite(u.total_units)).map((u,p)=>e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.grant_amount",{remaining:u.remaining_units.toLocaleString(W()),total:u.total_units.toLocaleString(W())})},u.entitlement_id||p))]})}):null]})}function Da({data:t,mode:a,now:i}){const[n,s]=g.useState(!1),o=g.useRef(null),c=De(o),l=r(t.region==="zai"?"limits.zcode.region.zai":"limits.zcode.region.bigmodel"),d=t.plan_label||r("limits.zcode.start_grants"),m=r("limits.zcode.other_region.title",{region:l,plan:d}),u=re.zcode.windows(t).filter(h=>h.window).map(h=>({spec:h,mode:a,pace:Pe(h,a,i)})),p=Date.parse(t.log_timestamp);return e.jsxs("div",{className:"mt-2 border-t border-oai-gray-200/60 pt-2 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button","aria-expanded":n,onClick:h=>{h.stopPropagation(),s(y=>!y)},onKeyDown:h=>h.stopPropagation(),className:"flex w-full items-center gap-1.5 rounded text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx(_t,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:m,children:m}),e.jsx(ie,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${n?"rotate-180":""}`})]}),n?e.jsxs("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:c>0?{"--tt-limits-label-w":`${c}px`}:void 0,children:[e.jsx(Me,{rows:u,mode:a}),e.jsx(Ce,{rows:u,mode:a,now:i}),Number.isFinite(p)?e.jsx(A,{children:r("limits.zcode.other_region.snapshot",{time:X(p)})}):null]}):null]})}function Ea(t,a,i,n,s,o,c=null,l=null,d=Date.now(),m=null){const u=re[t];if(!u)return null;const p=u.windows(a).filter(y=>y.window).map(y=>({spec:y,mode:n,pace:Pe(y,n,d)})),h=yt(u.extra,a);return e.jsxs(pt,{name:i,providerId:t,expandable:p.length>0||!!l,expanded:s,onToggle:o,badge:c,rightAdornment:l?e.jsx(gt,{subscription:l}):null,toggleOnHeader:t==="zcode",children:[e.jsx(Me,{mode:n,rows:p,extra:h,expanded:s}),t==="opencodeGo"||t==="commandCode"||t==="deepseek"?e.jsx(vt,{providerId:t,data:a,onSaved:m}):null,l?e.jsx(ht,{subscription:l,now:d,mode:n}):null,s?e.jsx(Ce,{rows:p,mode:n,now:d}):null,s&&l?e.jsx(ft,{subscription:l,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(Ma,{data:a.start_plan,mode:n,now:d}):null,t==="zcode"&&a.other_region?e.jsx(Da,{data:a.other_region,mode:n,now:d}):null]},t)}function ce(t,a,i,n,s=null,o=Date.now(),c=M.USED){const l=!!s;return e.jsxs(pt,{name:ue(t),providerId:t,expandable:l,expanded:i,onToggle:n,rightAdornment:l?e.jsx(gt,{subscription:s}):null,children:[a,l?e.jsx(ht,{subscription:s,now:o,mode:c}):null,l&&i?e.jsx("div",{className:"mt-1",children:e.jsx(ft,{subscription:s,now:o})}):null]},t)}function Ra(t,a,i,n,s,o=null,c=Date.now(),l=null){if(!re[t])return null;if(t==="claude"&&a?.limits_status==="not_applicable")return ce(t,e.jsx(A,{children:r("limits.claude.custom_backend")}),n,s,o,c,i);if(!a?.configured)return ce(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(I,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Le,{onSaved:l})}):null,t==="commandCode"?e.jsx(I,{title:r("limits.commandCode.setupHint.title"),children:e.jsx($e,{onSaved:l})}):null,t==="codingPlan"?e.jsx(I,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Be,{})}):null,t==="agentPlan"?e.jsx(I,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(Ge,{})}):null,t==="devin"?e.jsx(I,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ue,{})}):null,t==="deepseek"?e.jsx(I,{title:r("limits.deepseek.setupHint.title"),children:e.jsx(ze,{onSaved:l})}):null]}),n,s,o,c,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return ce(t,e.jsx(A,{children:r("limits.opencodeGo.status.inactive")}),n,s,o,c,i);if(a.error)return ce(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{tone:"error",children:a.error}),t==="kiro"?yt(re.kiro.extra,a):null,t==="deepseek"?e.jsx(I,{title:r("limits.deepseek.setupHint.title"),children:e.jsx(ze,{onSaved:l})}):null,t==="deepseek"?e.jsx(vt,{providerId:t,data:a,onSaved:l}):null,t==="opencodeGo"?e.jsx(I,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Le,{onSaved:l})}):null,t==="commandCode"?e.jsx(I,{title:r("limits.commandCode.setupHint.title"),children:e.jsx($e,{onSaved:l})}):null,t==="codingPlan"?e.jsx(I,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Be,{})}):null,t==="agentPlan"?e.jsx(I,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(Ge,{})}):null,t==="devin"?e.jsx(I,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ue,{})}):null]}),n,s,o,c,i);const d=ue(t),m=a.plan_label?`${d} ${a.plan_label}`:d;let u=null;if(a.auth_action_required==="reauth"){const h=t==="commandCode"?ot():t==="devin"?lt():ka[t];u=e.jsx(V,{label:r("limits.reauth.badge"),age:ae(a.cached_at),tone:"stale",tooltip:h?r("limits.reauth.tooltip",{command:h}):null})}if(!u&&t==="antigravity")if(a.cached){const h=ae(a.cached_at);u=e.jsx(V,{label:r("limits.label.antigravity_cached"),age:h,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(V,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(V,{label:r("limits.label.antigravity_cached"),age:ae(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(V,{label:r("limits.label.antigravity_cached"),age:ae(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const p=a.provenance;return p?.stale&&!u&&(u=e.jsx(V,{label:r("limits.provenance.stale"),age:ae(p.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:p.source,confidence:p.confidence})})),Ea(t,a,m,i,n,s,u,o,c,l)}function Ta({defaultDir:t}){const[a,i]=g.useState(!1),s=["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 c=>{c.stopPropagation();try{await navigator.clipboard.writeText(s),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:s}),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 he(){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 fe({provider:t,onSaved:a}){const[i,n]=g.useState(""),[s,o]=g.useState("idle"),[c,l]=g.useState(!1),d=async m=>{m.preventDefault(),m.stopPropagation();const u=i.trim();if(!(!u||s==="saving")){o("saving"),l(!1);try{await St(t,u),n(""),o("saved"),a?.()}catch{o("idle"),l(!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=>{n(m.target.value),o("idle"),l(!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()||s==="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:s==="saving"?r("limits.apiKey.saving"):s==="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:c?r("limits.apiKey.save_failed"):r("limits.apiKey.local_note")})]})}function vt({providerId:t,data:a,onSaved:i}){if(a?.credential_source!=="env")return null;const n=pa[t],s=ga[t];return!n||!s?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:n})}),e.jsx(fe,{provider:s,onSaved:i}),nt()==="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:n})}),e.jsx("span",{children:r("limits.apiKey.env_unset_note")})]}):null]})}function I({title:t,children:a}){return e.jsxs("div",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",onClick:i=>i.stopPropagation(),onKeyDown:i=>i.stopPropagation(),children:[e.jsx("div",{className:"font-medium text-oai-gray-800 dark:text-oai-gray-100",children:t}),a]})}function Le({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(he,{})]})]}),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(fe,{provider:"opencode-go",onSaved:t})]})]})]})}function $e({onSaved:t}){const a=ot();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(fe,{provider:"command-code",onSaved:t})]})]})]})}function ze({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.deepseek.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.deepseek.setupHint.step1")}),e.jsxs("a",{href:"https://platform.deepseek.com",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.deepseek.setupHint.cta"),e.jsx(he,{})]})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.deepseek.setupHint.step2")}),e.jsx(fe,{provider:"deepseek",onSaved:t})]})]})]})}function Ue(){const t=lt();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 Be(){const[t,a]=g.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
5
- `),n=async s=>{s.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:s=>s.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(he,{})]})]}),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:n,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 Ge(){const[t,a]=g.useState(!1),i=[r("limits.agentPlan.setupHint.snippet_install"),r("limits.agentPlan.setupHint.snippet_login"),r("limits.agentPlan.setupHint.snippet_status")].join(`
6
- `),n=async s=>{s.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:s=>s.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(he,{})]})]}),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:n,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 De(t){const[a,i]=g.useState(0);return g.useLayoutEffect(()=>{const n=t.current;if(!n)return;const s=[...n.querySelectorAll("[data-limit-label]")].filter(d=>d.closest("[data-limit-label-group]")===n);let o=0,c=null;if(s.length>0)try{c=document.createElement("canvas").getContext("2d")}catch{c=null}if(c){const d=window.getComputedStyle(s[0]);c.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`;for(const m of s)o=Math.max(o,c.measureText(m.textContent).width)}const l=Math.ceil(o);i(d=>d===l?d:l)}),a}function Ia({claude:t,codex:a,cursor:i,gemini:n,kimi:s,kiro:o,grok:c,antigravity:l,copilot:d,zcode:m,opencodeGo:u,commandCode:p,qoder:h,qoderCn:y,codingPlan:b,agentPlan:k,devin:S,workbuddy:E,workbuddyAi:F,deepseek:C,order:j,visibility:L,displayMode:J,subscriptions:K=[],showSubscriptions:H=!0,onProviderKeySaved:R=null}){const T={claude:t,codex:a,cursor:i,gemini:n,kimi:s,kiro:o,grok:c,antigravity:l,copilot:d,zcode:m,opencodeGo:u,commandCode:p,qoder:h,qoderCn:y,codingPlan:b,agentPlan:k,devin:S,workbuddy:E,workbuddyAi:F,deepseek:C},P=g.useRef(null),$=De(P),[Q,ee]=g.useState(null),[O,be]=g.useState(()=>Date.now()),oe=[...new Set(Array.isArray(j)&&j.length>0?j:ja)],U=J===M.REMAINING?M.REMAINING:M.USED;g.useEffect(()=>{const v=setInterval(()=>be(Date.now()),6e4);return()=>clearInterval(v)},[]);const B=new Map;if(H)for(const v of K||[]){if(!v?.provider)continue;const z=new Date(v.nextBillingAt).getTime();if(!Number.isFinite(z))continue;const x=B.get(v.provider);if(!x){B.set(v.provider,v);continue}const N=new Date(x.nextBillingAt).getTime(),f=z>O,_=N>O;(f&&(!_||N>z)||!f&&!_&&z>N)&&B.set(v.provider,v)}const le=oe.filter(v=>!L||L[v]!==!1||B.has(v)).map(v=>Ra(v,T[v],U,Q===v,()=>ee(z=>z===v?null:v),B.get(v)||null,O,R)).filter(Boolean);return e.jsx(zt,{delay:.15,children:e.jsx("div",{ref:P,"data-limit-label-group":"",className:"flex flex-col gap-3",style:$>0?{"--tt-limits-label-w":`${$}px`}:void 0,children:le.length>0?le:e.jsx(A,{children:r("limits.status.all_hidden")})})})}async function kt(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 Aa(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await kt(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function Ee(t){const a=await Pt();return kt(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 Ha(t){return Ee({action:"create",subscription:t})}function Oa(t,a){return Ee({action:"update",id:t,subscription:a})}function Fa(t){return Ee({action:"delete",id:t})}const ke={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function La(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const i=n=>String(n).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())}T${i(a.getHours())}:${i(a.getMinutes())}`}function $a({subscriptions:t,onChanged:a}){const[i,n]=g.useState(!1),[s,o]=g.useState(null),[c,l]=g.useState(ke),[d,m]=g.useState(!1),[u,p]=g.useState(!1),[h,y]=g.useState(!1),[b,k]=g.useState(!1),[S,E]=g.useState(null),[F,C]=g.useState(!1),[j,L]=g.useState(!1),[J,K]=g.useState(null),[H,R]=g.useState(()=>Date.now()),T=g.useRef(null),P=W(),$=g.useMemo(()=>new Intl.DateTimeFormat(P,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[P]);g.useEffect(()=>{const x=setInterval(()=>R(Date.now()),6e4);return()=>clearInterval(x)},[]),g.useEffect(()=>{if(!i)return;const x=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;T.current?.scrollIntoView?.({behavior:x?"auto":"smooth",block:"nearest"})},[i,s]);const Q=g.useMemo(()=>qe.map(x=>{const N=(t||[]).some(_=>_.provider===x&&_.id!==s),f=ue(x);return{value:x,label:N?`${f} ${r("subscriptions.form.provider_taken_suffix")}`:f,disabled:N}}),[P,t,s]),ee=g.useMemo(()=>[{value:"weekly",label:r("subscriptions.form.cycle_weekly")},{value:"monthly",label:r("subscriptions.form.cycle_monthly")},{value:"yearly",label:r("subscriptions.form.cycle_yearly")}],[P]),O=g.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[P]),be=g.useCallback(()=>{l(ke),o(null),p(!1),y(!1),k(!1),n(!0)},[]),oe=g.useCallback(x=>{l({plan:x.plan||"",provider:x.provider||"",cycle:x.cycle||"monthly",autoRenew:x.autoRenew,startedAt:La(new Date(da(x)).toISOString())}),o(x.id),p(!1),y(!1),k(!1),n(!0)},[]),U=g.useCallback(()=>{n(!1),o(null),l(ke),p(!1),y(!1),k(!1)},[]),B=g.useCallback(async x=>{if(x.preventDefault(),p(!1),!c.provider){y(!0);return}if((t||[]).some(q=>q.provider===c.provider&&q.id!==s)){k(!0);return}const f=new Date(c.startedAt).getTime();if(!Number.isFinite(f)){p(!0);return}const _={service:ue(c.provider),plan:c.plan,provider:c.provider||null,autoRenew:c.autoRenew,cycle:c.cycle,startedAt:f,nextBillingAt:it(f,c.cycle)};m(!0);try{s?await Oa(s,_):await Ha(_),U(),await a?.()}catch{p(!0)}finally{m(!1)}},[U,s,c,a,t]),le=g.useCallback(async()=>{if(S){C(!0),L(!1);try{await Fa(S.id),S.id===s&&U(),E(null),await a?.()}catch{L(!0)}finally{C(!1)}}},[U,s,a,S]),v=t||[],z=()=>{const x=s?v.find(f=>f.id===s):null,N=x?me(x,H):null;return e.jsxs("form",{ref:T,onSubmit:B,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:s?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:$.format(new Date(N.endMs))})," · ",e.jsx("span",{className:N.expired?"text-oai-error":void 0,children:Ne(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(ve,{id:"subscription-provider",value:c.provider,onValueChange:f=>l({...c,provider:String(f)}),options:Q,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(Ie,{label:r("subscriptions.form.plan"),value:c.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:f=>l({...c,plan:f.target.value})})}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-cycle",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.cycle")}),e.jsx(ve,{id:"subscription-cycle",value:c.cycle,onValueChange:f=>l({...c,cycle:String(f)}),options:ee,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(ve,{id:"subscription-auto-renew",value:String(c.autoRenew),onValueChange:f=>l({...c,autoRenew:f==="true"}),options:O,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(Ie,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:c.startedAt,required:!0,onChange:f=>l({...c,startedAt:f.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[s?e.jsx(te,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const f=v.find(_=>_.id===s);f&&E(f)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,h?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,b?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,u?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(te,{type:"button",variant:"secondary",size:"sm",onClick:U,children:r("shared.action.cancel")}),e.jsx(te,{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(te,{type:"button",size:"sm",onClick:be,className:"shrink-0 gap-1.5",children:[e.jsx(Kt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),v.length===0&&!(i&&!s)?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(Qe,{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:[v.map(x=>{const N=me(x,H);if(!N)return null;const{endMs:f,expired:_}=N,q=_?100:N.progress*100,jt=!_&&f-H<=3*864e5,wt=J===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:()=>oe(x),"aria-label":`${r("subscriptions.edit")} ${x.service}`,"aria-expanded":s===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(Ye,{provider:Ve(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(at,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Se,{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:`${_?"bg-red-500":jt?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${q}%`,minWidth:q>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${_?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:st(f,H)})]})]}),s===x.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:z()}):null,s!==x.id&&wt?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:$.format(new Date(f))})," · ",e.jsx("span",{className:_?"text-oai-error":void 0,children:Ne(f,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(te,{type:"button",variant:"secondary",size:"sm",onClick:()=>oe(x),children:r("subscriptions.edit")})})]}):null]},x.id)}),i&&!s?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:z()}):null]}),e.jsx(Gt,{open:!!S,title:r("subscriptions.confirm_delete_title"),description:S?.service||"",error:j?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:F,onCancel:()=>{E(null),L(!1)},onConfirm:le})]})}const je=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),za="x-apple.systempreferences:com.apple.preference.notifications";function We(t){const a=Date.parse(t);return Number.isFinite(a)?new Intl.DateTimeFormat(W(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(a)):String(t)}function Ua(t){const a=Object.entries(t||{}).filter(([o,c])=>o!=="fetched_at"&&c&&typeof c=="object"&&c.configured!==!1),i=a.filter(([,o])=>!!o.error),n=a.some(([,o])=>!!o.start_plan?.error||!!o.reset_credits?.error),s=a.filter(([,o])=>o.provenance?.stale===!0||o.provenance?.source==="disk-cache");return a.length&&i.length===0&&!n&&s.length===a.length?{kind:"stale"}:i.length||s.length||n?{kind:"partial",at:t.fetched_at}:{kind:"updated",at:t.fetched_at}}function Ba(){const t=Jt(),a=Tt(),i=r("limits.alert.blocked"),n=a?Re.button:Re.div;return e.jsxs(n,{type:a?"button":void 0,onClick:a?()=>It({type:"action",name:"openURL",value:za}):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 hr(){const t=Ct(),a=$t(),i=w.useRef(null),n=w.useCallback(()=>{const R=Te();if(!a.showSubscriptions)return R;const T=i.current;return!T||T.size===0?R:R.filter(P=>!T.has(P))},[a.showSubscriptions]),{data:s,error:o,isLoading:c,refresh:l}=Ot(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0,getHiddenProviders:n}:{initialRefresh:!0,publishToPreloadCache:!0,getHiddenProviders:n}),d=Ft(),[m,u]=w.useState([]),[p,h]=w.useState(!1),[y,b]=w.useState(!1),[k]=Mt(),S=w.useRef(0),E=w.useRef(!1),[F,C]=w.useState(!1),[j,L]=w.useState(null),J=w.useCallback(async()=>{if(!E.current){E.current=!0,C(!0),L(null);try{const R=await l();L(R?Ua(R):{kind:"failed"})}finally{E.current=!1,C(!1)}}},[l]),K=w.useCallback(async()=>{if(!je&&!ye())return;const R=++S.current;try{const T=await Aa();if(R!==S.current)return;u(T),h(!1);const P=new Set(T.map(O=>O?.provider).filter(Boolean)),$=i.current,Q=Te(),ee=$===null?a.showSubscriptions&&[...P].some(O=>Q.includes(O)):a.showSubscriptions&&($.size!==P.size||[...P].some(O=>!$.has(O)));i.current=P,ee&&l()}catch{if(R!==S.current)return;h(!0)}},[a.showSubscriptions,l]),H=w.useRef(a.showSubscriptions);return w.useEffect(()=>{H.current!==a.showSubscriptions&&(H.current=a.showSubscriptions,!(!je&&!ye())&&l())},[a.showSubscriptions,l]),w.useEffect(()=>{K()},[K]),w.useEffect(()=>{k.get("openSubscriptions")==="1"&&b(!0)},[k]),w.useEffect(()=>{d.enabled&&s&&Lt(s)},[d.enabled,s]),!je&&!ye()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Wt,{})}):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:[d.enabled&&d.permissionBlocked?e.jsx(Ba,{}):null,e.jsx("button",{type:"button",onClick:()=>{J()},disabled:F,"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(Dt,{className:`h-4 w-4 ${F?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(qt,{open:y,onOpenChange:b,children:[e.jsx(Vt,{"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(Qe,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Yt,{children:e.jsx(Zt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Xt,{children:e.jsx($a,{subscriptions:m,onChanged:K})})})})]}),e.jsx("button",{type:"button",onClick:()=>{d.setEnabled(!d.enabled)},"aria-label":d.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:d.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 ${d.enabled&&d.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:d.enabled?e.jsx(ea,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Qt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Et,{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(Rt,{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:F?r("limits.page.refresh_loading"):""}),j?.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:We(j.at)})}):null,j?.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:We(j.at)})}):null,j?.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,j?.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,c?e.jsx(ia,{}):e.jsxs(e.Fragment,{children:[o?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:o}):null,p?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(Ia,{claude:s?.claude,codex:s?.codex,cursor:s?.cursor,gemini:s?.gemini,kimi:s?.kimi,kiro:s?.kiro,grok:s?.grok,antigravity:s?.antigravity,copilot:s?.copilot,zcode:s?.zcode,opencodeGo:s?.opencodeGo,commandCode:s?.commandCode,qoder:s?.qoder,qoderCn:s?.qoderCn,codingPlan:s?.codingPlan,agentPlan:s?.agentPlan,devin:s?.devin,workbuddy:s?.workbuddy,workbuddyAi:s?.workbuddyAi,deepseek:s?.deepseek,order:a.order,visibility:a.visibility,displayMode:a.displayMode,subscriptions:m,showSubscriptions:a.showSubscriptions!==!1,onProviderKeySaved:()=>{l()}})]})]})})})}export{hr as LimitsPage};