tokentracker-cli 1.5.7 → 1.5.9
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.
- package/dashboard/dist/assets/{AchievementBadge-DIHKXKgm.js → AchievementBadge-DxevOMMv.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-U66jjKFf.js → AchievementsPage-wQh6dPiW.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-BAW79xKg.js → AchievementsSection-vYIgdSyO.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-IfomOw9B.js → BadgeDetailModal-isUD2b76.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-B33gSUM3.js → BotAnimated-DRT695hH.js} +1 -1
- package/dashboard/dist/assets/{Card-dtrkef-y.js → Card-CtiqYzpy.js} +1 -1
- package/dashboard/dist/assets/{CloudCheckoutPage-jYPgHJYE.js → CloudCheckoutPage-BjtTYFRB.js} +1 -1
- package/dashboard/dist/assets/{CloudPage-BumdgM5w.js → CloudPage-Ca9vK72O.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-CFEeoIo3.js → CommandPalette-DFNVDGDw.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-DL3MrPmb.js → CommunityStatsModal-CBhB1FCI.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-BRdtCv2g.js → ConfirmModal-BpxbxobQ.js} +1 -1
- package/dashboard/dist/assets/{Controls-Bb-_ZAsT.js → Controls-alGdX7nF.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-GXwt6DoC.js → DashboardPage-BzcooUrM.js} +1 -1
- package/dashboard/dist/assets/{DateRangePopover-CHkFCFkE.js → DateRangePopover-CV7k3TK2.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-Da753sLS.js → DevicePage-BK3-XhwI.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-4A_jISLc.js → DialogClose-D5qE4Ncq.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-bgtuNhON.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-C0oQdI9n.js → DialogTitle-DD0PN4lA.js} +1 -1
- package/dashboard/dist/assets/{ElectricLogo-Bv-sB-O-.js → ElectricLogo-BkeGognF.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-Ch2AuGxY.js → FadeIn-WKLfxTCh.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-C_dy8a5K.js → HeaderGithubStar-CAe4FRv5.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-iuzo5YeN.js → HoverTooltip-By_5OH4b.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-BKEID9fw.js → IpCheckPage-CsLsYWer.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-DZt5JWZ7.js → LandingPage-Dz7Kwfno.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardPage-CYrCQF5P.js → LeaderboardPage-Bwk5cUdL.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProBadge-B8vG2SAW.js → LeaderboardProBadge-DuuM_Qd4.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfileModal-DpAvBJPT.js → LeaderboardProfileModal-dLdTP76d.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-CofOk8GO.js → LeaderboardProfilePage-BC8q5Yiz.js} +1 -1
- package/dashboard/dist/assets/LimitsPage-B_joQM6T.js +6 -0
- package/dashboard/dist/assets/{LocalOnlyNotice-BBVCEm5Q.js → LocalOnlyNotice-Df1TymDu.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-DcPazHo1.js → LoginCard-CSadewRf.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-CGXPaeWD.js → LoginModal-xa_R4jkx.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-Ct6Al1pz.js → LoginPage-DQKRFd-i.js} +1 -1
- package/dashboard/dist/assets/{PetPage-8NPEAa-c.js → PetPage-DXjUI-Fm.js} +2 -2
- package/dashboard/dist/assets/{PopoverPopup-R69ks89h.js → PopoverPopup-C9nxf0YB.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-svF44YE0.js → ProviderIcon-COeK1iE9.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-DJIYKu8C.js → ResetPasswordPage-yFhu0KjP.js} +1 -1
- package/dashboard/dist/assets/{Select-BVK4XZD5.js → Select-WAuTo5wB.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-Bh74D8lr.js → SelectItemText-Ft1My1rn.js} +1 -1
- package/dashboard/dist/assets/{SelfHostPage-8gj2lAFp.js → SelfHostPage-BxF88Cud.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-CWPV_Mou.js → ServiceStatusPage-Bwphp1_T.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-Bo5plK6O.js → SessionsPage-BDZoT8S9.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-BptJrWn-.js → SettingsPage-BpQqI7sS.js} +3 -3
- package/dashboard/dist/assets/{SkillsPage-CRgGXnJS.js → SkillsPage-DPS8DP98.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-dgOy0Eo7.js → TokenGalaxy-Bqdu32RZ.js} +1 -1
- package/dashboard/dist/assets/{TooltipPopup-DpGnyoFz.js → TooltipPopup-CpC_9aso.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-BEy_GbMg.js → TrendMonitor-DVWB1_L7.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-ChUelFrP.js → WidgetsPage-BQSjbWew.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-n63RsX8z.js → WrappedPage-DLQyBtR9.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-D-6XhI1J.css +1 -0
- package/dashboard/dist/assets/__vite-browser-external-DtVR8sgH.js +45 -0
- package/dashboard/dist/assets/{agent-logos-DQ1h5uQF.js → agent-logos-BcEyTuIb.js} +1 -1
- package/dashboard/dist/assets/{arrow-left-Bo3Sg_cg.js → arrow-left-C8aE6WcJ.js} +1 -1
- package/dashboard/dist/assets/{arrow-right-DdxkL8Ul.js → arrow-right-Dt4QZ45w.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-CpvelPD2.js → arrow-up-right-DR4MOP3X.js} +1 -1
- package/dashboard/dist/assets/{calendar-days-BvNVya0e.js → calendar-days-DHwLFNka.js} +1 -1
- package/dashboard/dist/assets/{check-tO40Glrg.js → check-D57wJVNi.js} +1 -1
- package/dashboard/dist/assets/{chevron-down-Dnrra3mC.js → chevron-down-1Am_McS5.js} +1 -1
- package/dashboard/dist/assets/{cloud-checkout-COC4zB8s.js → cloud-checkout-D1uji-1j.js} +1 -1
- package/dashboard/dist/assets/{composite-C0NgnRTl.js → composite-CWdL18RN.js} +1 -1
- package/dashboard/dist/assets/{copy-DTKN2SO4.js → copy-Bv-Of2CY.js} +1 -1
- package/dashboard/dist/assets/{download-CSq2Yd3D.js → download-C6CZhQJ_.js} +1 -1
- package/dashboard/dist/assets/{external-link-BtGedmuQ.js → external-link-DluFPan_.js} +1 -1
- package/dashboard/dist/assets/{flame-ChjXIFSx.js → flame-Q-O2BjcZ.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-CXqZY114.js → format-tokens-D6xfDQk6.js} +1 -1
- package/dashboard/dist/assets/{gift-YFwBvsUA.js → gift-CjyNlhMb.js} +1 -1
- package/dashboard/dist/assets/{icons-DCiBpbK0.js → icons-C7bLOnL0.js} +1 -1
- package/dashboard/dist/assets/{index-B7sRX2EC.js → index-C0c77eg0.js} +1 -1
- package/dashboard/dist/assets/{index-Dpmdg98T.js → index-CuFScIzn.js} +1 -1
- package/dashboard/dist/assets/{index-XSya-vft.js → index-CxtJQkWU.js} +1 -1
- package/dashboard/dist/assets/{index-DMqIbTL4.js → index-dN_XEOTc.js} +1 -1
- package/dashboard/dist/assets/{info-PYzcoobJ.js → info-DVIccqnI.js} +1 -1
- package/dashboard/dist/assets/{link-2-BxSrdKyR.js → link-2-C70V-255.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-CgvCCDTH.js → loader-circle-B-Rab-PT.js} +1 -1
- package/dashboard/dist/assets/{local-usage-transfer-eTzMdhbs.js → local-usage-transfer-qvjPuuZr.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-B796CRz-.js → modifiers.esm-BHs-2K1Y.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-M5nbcGRy.js → monitor-smartphone-CgrOD78L.js} +1 -1
- package/dashboard/dist/assets/{play-12ZzPH9r.js → play-Ip40EFaD.js} +1 -1
- package/dashboard/dist/assets/{plus-OqDA7xZy.js → plus-CbCC4SC4.js} +1 -1
- package/dashboard/dist/assets/{provider-display-JlEBv1VB.js → provider-display-CZGQ6_EQ.js} +1 -1
- package/dashboard/dist/assets/{react-CeDcnQho.js → react-CgvoKjQY.js} +1 -1
- package/dashboard/dist/assets/{safePolygon-B_SGhQbo.js → safePolygon-BxArCd9t.js} +1 -1
- package/dashboard/dist/assets/{search-D9wz4rWp.js → search-Cc1m7nId.js} +1 -1
- package/dashboard/dist/assets/{server-UCMw4AQF.js → server-B9RX1Vuc.js} +1 -1
- package/dashboard/dist/assets/{shield-check-lJ0-Z5Ot.js → shield-check-DFuUPXVr.js} +1 -1
- package/dashboard/dist/assets/{skills-api-Da-WZbvW.js → skills-api-NyM68NUT.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-Bj1ZkbqW.js → sortable.esm-CYnTi7kq.js} +1 -1
- package/dashboard/dist/assets/{store-Bpwwxxsy.js → store-DDaZ-mNZ.js} +1 -1
- package/dashboard/dist/assets/{terminal-BHQMC4hm.js → terminal-RKmu3r3J.js} +1 -1
- package/dashboard/dist/assets/{trash-yTV6vhGX.js → trash-V0PYmC5p.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-rrE4Ohic.js → use-community-stats-48odwOSW.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-D4Y1aCyd.js → use-latest-request-guard-CwOWDCBH.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-ChHr4XEF.js → use-limits-display-prefs-Lo9XLIUG.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-BmoCls3D.js → use-native-settings-BjPp_hnp.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-BZSSYcLx.js → use-ordered-list-DdTbfk26.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-C58neEWc.js +1 -0
- package/dashboard/dist/assets/{use-transform-CJO1b0Iu.js → use-transform-CmzDZQtp.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-BbAC_LWP.js → use-usage-limits-DT684bcx.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-B2enOMwJ.js → useCurrency-CNQ1UMsM.js} +1 -1
- package/dashboard/dist/assets/{usePositioner-BaoW4QRL.js → usePositioner-KdfYUR_c.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-B2bbeEu-.js → useTokenFormat-CregnoYF.js} +1 -1
- package/dashboard/dist/assets/{zap-CT5a8-_j.js → zap-CMv1W1Qs.js} +1 -1
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/ip-check.html +2 -2
- package/dashboard/dist/leaderboard.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +1 -1
- package/src/commands/sync.js +2 -2
- package/src/lib/cursor-config.js +21 -54
- package/src/lib/cursor-login.js +157 -0
- package/src/lib/local-api.js +43 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/usage-limits.js +14 -9
- package/dashboard/dist/assets/DialogDescription-CiEhDvt9.js +0 -1
- package/dashboard/dist/assets/LimitsPage-DXknvxtI.js +0 -6
- package/dashboard/dist/assets/__vite-browser-external-CMBWGkOq.css +0 -1
- package/dashboard/dist/assets/__vite-browser-external-D_JnEwiu.js +0 -45
- package/dashboard/dist/assets/use-reduced-motion-CKTIXp4-.js +0 -1
- package/src/lib/cursor-safe-storage.js +0 -119
package/src/lib/usage-limits.js
CHANGED
|
@@ -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{r as n,J as a}from"./__vite-browser-external-D_JnEwiu.js";import{u as p}from"./DialogTitle-C0oQdI9n.js";import{u as c}from"./composite-C0NgnRTl.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-D_JnEwiu.js";import{m as Re}from"./react-CeDcnQho.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-BbAC_LWP.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-ChHr4XEF.js";import{F as zt}from"./FadeIn-Ch2AuGxY.js";import{P as Ye}from"./ProviderIcon-svF44YE0.js";import{H as Ut}from"./HoverTooltip-iuzo5YeN.js";import{C as ie}from"./chevron-down-Dnrra3mC.js";import{G as Bt}from"./gift-YFwBvsUA.js";import{C as Gt}from"./ConfirmModal-BRdtCv2g.js";import{I as Ie,L as Wt}from"./LocalOnlyNotice-BBVCEm5Q.js";import{S as ve}from"./Select-BVK4XZD5.js";import{P as Kt}from"./plus-OqDA7xZy.js";import{P as qt,a as Vt,b as Yt,c as Zt,d as Xt}from"./PopoverPopup-R69ks89h.js";import{u as Jt}from"./use-reduced-motion-CKTIXp4-.js";import"./use-latest-request-guard-D4Y1aCyd.js";import"./DialogTitle-C0oQdI9n.js";import"./composite-C0NgnRTl.js";import"./store-Bpwwxxsy.js";import"./DialogDescription-CiEhDvt9.js";import"./arrow-up-right-CpvelPD2.js";import"./download-CSq2Yd3D.js";import"./check-tO40Glrg.js";import"./SelectItemText-Bh74D8lr.js";import"./usePositioner-BaoW4QRL.js";import"./safePolygon-B_SGhQbo.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};
|