tokentracker-cli 1.4.14 → 1.5.1

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 (125) hide show
  1. package/README.md +3 -3
  2. package/README.zh-CN.md +1 -1
  3. package/dashboard/dist/.well-known/submitby-ai/6e2fa70e-9eb2-4c97-a9a9-fed567a3d4a9.txt +1 -0
  4. package/dashboard/dist/assets/AchievementBadge-mB7HZSGE.js +1 -0
  5. package/dashboard/dist/assets/{AchievementsPage-YvgCj3Tf.js → AchievementsPage-DLzeq_eo.js} +2 -2
  6. package/dashboard/dist/assets/{AchievementsSection-C2llp4CQ.js → AchievementsSection-DrXQyDns.js} +1 -1
  7. package/dashboard/dist/assets/{BadgeDetailModal-DH1lqy_t.js → BadgeDetailModal-WrgKRybi.js} +1 -1
  8. package/dashboard/dist/assets/{BotAnimated-BPJ80H6q.js → BotAnimated-DFRaixVK.js} +1 -1
  9. package/dashboard/dist/assets/{Card-D0lZNo7p.js → Card-bFq2tlO8.js} +1 -1
  10. package/dashboard/dist/assets/{CloudCheckoutPage-YCIw4n94.js → CloudCheckoutPage-gwhGxavy.js} +1 -1
  11. package/dashboard/dist/assets/{CloudPage-D5PNgyOe.js → CloudPage-BD4iBYeZ.js} +2 -2
  12. package/dashboard/dist/assets/{CommandPalette-CfNOZlEo.js → CommandPalette-C_KlPl0U.js} +1 -1
  13. package/dashboard/dist/assets/{CommunityStatsModal-eywEJpBo.js → CommunityStatsModal-Cl1Bgv8M.js} +1 -1
  14. package/dashboard/dist/assets/{ConfirmModal-MvUDUW0j.js → ConfirmModal-NWoYevYC.js} +1 -1
  15. package/dashboard/dist/assets/{Controls-B3s01gQc.js → Controls-D2-D2cfA.js} +1 -1
  16. package/dashboard/dist/assets/{DashboardPage-7zQm3Y95.js → DashboardPage-vITMnPXx.js} +1 -1
  17. package/dashboard/dist/assets/{DateRangePopover-C7T4EjRr.js → DateRangePopover-8EMVXuH6.js} +1 -1
  18. package/dashboard/dist/assets/DevicePage-DbP8d6bM.js +1 -0
  19. package/dashboard/dist/assets/{DialogClose-DlVXuWgp.js → DialogClose-CEstgLa1.js} +1 -1
  20. package/dashboard/dist/assets/DialogDescription-0wcygxtH.js +1 -0
  21. package/dashboard/dist/assets/{DialogTitle-Dc0-pI0j.js → DialogTitle-DP5TLLbz.js} +1 -1
  22. package/dashboard/dist/assets/{ElectricLogo-BRp4UZF4.js → ElectricLogo-Uvi3yMum.js} +1 -1
  23. package/dashboard/dist/assets/{FadeIn-DFL15trS.js → FadeIn-Dpzihg6f.js} +1 -1
  24. package/dashboard/dist/assets/{HeaderGithubStar-CPWpKT2q.js → HeaderGithubStar-DllqemKr.js} +1 -1
  25. package/dashboard/dist/assets/{HoverTooltip-DXIFAD1D.js → HoverTooltip-Dc-TAH6l.js} +1 -1
  26. package/dashboard/dist/assets/{IpCheckPage-DBElmZxm.js → IpCheckPage-jd1D5ZKX.js} +1 -1
  27. package/dashboard/dist/assets/{LandingPage-3mpjg69k.js → LandingPage-CB1ZVw-a.js} +2 -2
  28. package/dashboard/dist/assets/{LeaderboardPage-xIQTyBSj.js → LeaderboardPage-Bt2cRRmE.js} +2 -2
  29. package/dashboard/dist/assets/{LeaderboardProBadge-hMzno53J.js → LeaderboardProBadge-BVlyVOFf.js} +1 -1
  30. package/dashboard/dist/assets/LeaderboardProfileModal-CwQFRJg_.js +73 -0
  31. package/dashboard/dist/assets/{LeaderboardProfilePage-CIVWObmo.js → LeaderboardProfilePage-CeqcTbUG.js} +1 -1
  32. package/dashboard/dist/assets/LimitsPage-Bp4ZORmR.js +6 -0
  33. package/dashboard/dist/assets/{LocalOnlyNotice-Cnzi2tn4.js → LocalOnlyNotice-B2_HoCVD.js} +1 -1
  34. package/dashboard/dist/assets/{LoginCard-DOO_XdQm.js → LoginCard-nw9JOc2d.js} +1 -1
  35. package/dashboard/dist/assets/{LoginModal-B5Ec0gTs.js → LoginModal-BHNLTK1D.js} +1 -1
  36. package/dashboard/dist/assets/{LoginPage-BcyuULTm.js → LoginPage-LI2GZKhM.js} +1 -1
  37. package/dashboard/dist/assets/{PetPage-DeTdSNPI.js → PetPage-CK6sPeI0.js} +2 -2
  38. package/dashboard/dist/assets/{PopoverPopup-BqiCJJkn.js → PopoverPopup-BsXchEVa.js} +1 -1
  39. package/dashboard/dist/assets/{ProviderIcon-94H7cG7M.js → ProviderIcon-vgCEy0dh.js} +1 -1
  40. package/dashboard/dist/assets/{ResetPasswordPage-BfaaiVWq.js → ResetPasswordPage-B4CPj2vX.js} +1 -1
  41. package/dashboard/dist/assets/{Select-Dk1g2jS1.js → Select-BkAy6P2r.js} +1 -1
  42. package/dashboard/dist/assets/{SelectItemText-CgY3YTCX.js → SelectItemText-C0RNqDrD.js} +1 -1
  43. package/dashboard/dist/assets/{SelfHostPage-CINWSnGe.js → SelfHostPage-B-_w-Z-a.js} +1 -1
  44. package/dashboard/dist/assets/{ServiceStatusPage-B3bZ4RLp.js → ServiceStatusPage-5YevsGGD.js} +1 -1
  45. package/dashboard/dist/assets/{SessionsPage-Bt-zYCLB.js → SessionsPage-CmWXBqD2.js} +2 -2
  46. package/dashboard/dist/assets/{SettingsPage-DgvNelAH.js → SettingsPage-CA70zP-t.js} +3 -3
  47. package/dashboard/dist/assets/{SkillsPage-BeapUXZg.js → SkillsPage-CNamhfzU.js} +1 -1
  48. package/dashboard/dist/assets/{TokenGalaxy-BmARBReu.js → TokenGalaxy-CXrVBSk6.js} +1 -1
  49. package/dashboard/dist/assets/{TooltipPopup-DMkTj-q1.js → TooltipPopup-CR4MqElX.js} +1 -1
  50. package/dashboard/dist/assets/{TrendMonitor-DErfAB4Q.js → TrendMonitor-DQfcrEve.js} +1 -1
  51. package/dashboard/dist/assets/{WidgetsPage-D7MRIlIQ.js → WidgetsPage-BBXxtZbP.js} +1 -1
  52. package/dashboard/dist/assets/{WrappedPage-Dwl8J96o.js → WrappedPage-C8i2KlMF.js} +1 -1
  53. package/dashboard/dist/assets/{__vite-browser-external-Bp0fEMn1.js → __vite-browser-external-BEEzY7mq.js} +3 -3
  54. package/dashboard/dist/assets/{agent-logos-D5X6WoAY.js → agent-logos-CxQb8vir.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-left-Bmf0v8yS.js → arrow-left-D6zkcLVt.js} +1 -1
  56. package/dashboard/dist/assets/{arrow-right-CrY1rjed.js → arrow-right-BGb-XVn_.js} +1 -1
  57. package/dashboard/dist/assets/{arrow-up-right-CK7lXR6O.js → arrow-up-right-XTStagDJ.js} +1 -1
  58. package/dashboard/dist/assets/{calendar-days-zge_5pfQ.js → calendar-days-Cz3NGZiS.js} +1 -1
  59. package/dashboard/dist/assets/{check-Bt-LY4Pn.js → check-1z_vmHPD.js} +1 -1
  60. package/dashboard/dist/assets/{chevron-down-BOy_MKfd.js → chevron-down-CkSBY3bE.js} +1 -1
  61. package/dashboard/dist/assets/{cloud-checkout-4NPL78Jg.js → cloud-checkout-pD5C4r_S.js} +1 -1
  62. package/dashboard/dist/assets/{composite-UMkd0X7k.js → composite-BtDzx3a2.js} +1 -1
  63. package/dashboard/dist/assets/{copy-DJTFZc8D.js → copy-Ctv_wxuD.js} +1 -1
  64. package/dashboard/dist/assets/{download-BJD3ff5y.js → download-DKbKMGSR.js} +1 -1
  65. package/dashboard/dist/assets/{external-link-D2m7vRGI.js → external-link-g9cU017t.js} +1 -1
  66. package/dashboard/dist/assets/{flame-D7CLiokj.js → flame-DZq3kXUt.js} +1 -1
  67. package/dashboard/dist/assets/{format-tokens-BYDaVVT_.js → format-tokens-CXQfx0PC.js} +1 -1
  68. package/dashboard/dist/assets/{gift-toIl7elE.js → gift-CKlKjGP6.js} +1 -1
  69. package/dashboard/dist/assets/{icons-DscB4AX2.js → icons-xPGMnBjl.js} +1 -1
  70. package/dashboard/dist/assets/{index-BGu15oeA.js → index-BwOjMtB2.js} +1 -1
  71. package/dashboard/dist/assets/{index-6krHCwUe.js → index-CDBOKcDh.js} +1 -1
  72. package/dashboard/dist/assets/{index-BLS9byMs.js → index-Dl0oFLNr.js} +33 -33
  73. package/dashboard/dist/assets/{index-CEsURfpC.js → index-fVbP5wOv.js} +1 -1
  74. package/dashboard/dist/assets/{info-D73-a9a_.js → info-D9xNIuGh.js} +1 -1
  75. package/dashboard/dist/assets/{link-2-DwpvF9Sr.js → link-2-Bk5wYt2n.js} +1 -1
  76. package/dashboard/dist/assets/{loader-circle-BTs6Fc8Y.js → loader-circle-CcN3pHWb.js} +1 -1
  77. package/dashboard/dist/assets/{local-usage-transfer-BXhe_z5f.js → local-usage-transfer-CYcy1ici.js} +1 -1
  78. package/dashboard/dist/assets/{modifiers.esm-CFoTDZHy.js → modifiers.esm-DbpEzkJe.js} +1 -1
  79. package/dashboard/dist/assets/module-ZyVsxBG_.js +3 -0
  80. package/dashboard/dist/assets/{monitor-smartphone-4ejjSL5C.js → monitor-smartphone-WkWv1qIS.js} +1 -1
  81. package/dashboard/dist/assets/{play-Ch1IEQyR.js → play-2yZGWMes.js} +1 -1
  82. package/dashboard/dist/assets/{plus-Bc8vdvFi.js → plus-mOF8tG1F.js} +1 -1
  83. package/dashboard/dist/assets/{provider-display-BhKfIayc.js → provider-display-7gaOvgMp.js} +1 -1
  84. package/dashboard/dist/assets/{react-BhuZeLEc.js → react-CdPiPDhk.js} +1 -1
  85. package/dashboard/dist/assets/{safePolygon-ag21oDI1.js → safePolygon-C7FJLAlh.js} +1 -1
  86. package/dashboard/dist/assets/{search-BhM-pD0f.js → search-C63nCrjo.js} +1 -1
  87. package/dashboard/dist/assets/{server-CWZM_fiB.js → server-BaG1rnuv.js} +1 -1
  88. package/dashboard/dist/assets/{shield-check-BdF9MoZ4.js → shield-check-D_4-Cm6L.js} +1 -1
  89. package/dashboard/dist/assets/{skills-api-PC7TzIba.js → skills-api-DfbzwpDv.js} +1 -1
  90. package/dashboard/dist/assets/{sortable.esm-u_yCrBFE.js → sortable.esm-D-v8FRX5.js} +1 -1
  91. package/dashboard/dist/assets/{store-19qppboP.js → store-Dv_FYrXK.js} +1 -1
  92. package/dashboard/dist/assets/{terminal-ikPM7Gyt.js → terminal-FQi6MaYt.js} +1 -1
  93. package/dashboard/dist/assets/{trash-DuS_INdf.js → trash-TbK96dEz.js} +1 -1
  94. package/dashboard/dist/assets/use-community-stats-DGoWVZuk.js +1 -0
  95. package/dashboard/dist/assets/{use-latest-request-guard-CClqxkji.js → use-latest-request-guard-Dg6uSaYt.js} +1 -1
  96. package/dashboard/dist/assets/{use-limits-display-prefs-C2IK7QqP.js → use-limits-display-prefs-Djbdp7fi.js} +1 -1
  97. package/dashboard/dist/assets/{use-native-settings-wciHeNL2.js → use-native-settings-DIk0AF3b.js} +1 -1
  98. package/dashboard/dist/assets/{use-ordered-list-CUnip521.js → use-ordered-list-CUqV3Zgl.js} +1 -1
  99. package/dashboard/dist/assets/use-reduced-motion-DMCok-vZ.js +1 -0
  100. package/dashboard/dist/assets/{use-transform-BFydEHQY.js → use-transform-D_-w22c8.js} +1 -1
  101. package/dashboard/dist/assets/{use-usage-limits-BqWWrW6O.js → use-usage-limits-h7aGsIQr.js} +1 -1
  102. package/dashboard/dist/assets/{useCurrency-sg6d4Wea.js → useCurrency-B_AuLCsL.js} +1 -1
  103. package/dashboard/dist/assets/{usePositioner-CLPx448B.js → usePositioner-DfxvIif8.js} +1 -1
  104. package/dashboard/dist/assets/{useTokenFormat-BOt7YH_Y.js → useTokenFormat-bbO13V4s.js} +1 -1
  105. package/dashboard/dist/assets/{zap-B6nc-Upg.js → zap-k07-EXTK.js} +1 -1
  106. package/dashboard/dist/index.html +20 -1
  107. package/dashboard/dist/indexnow-key.txt +1 -0
  108. package/dashboard/dist/ip-check.html +1 -1
  109. package/dashboard/dist/leaderboard.html +1 -1
  110. package/dashboard/dist/share.html +1 -1
  111. package/dashboard/dist/tt6a1c9e2f4b8d.txt +1 -0
  112. package/package.json +3 -3
  113. package/src/lib/dsh-session.js +580 -0
  114. package/src/lib/local-api.js +40 -3
  115. package/src/lib/pricing/seed-snapshot.json +1 -1
  116. package/src/lib/qoder-limits.js +178 -38
  117. package/src/lib/session-analytics.js +89 -11
  118. package/dashboard/dist/assets/AchievementBadge-BUYKivjx.js +0 -1
  119. package/dashboard/dist/assets/DevicePage-CZNBMHfk.js +0 -1
  120. package/dashboard/dist/assets/DialogDescription-C3mLrii8.js +0 -1
  121. package/dashboard/dist/assets/LeaderboardProfileModal-Cw0_YCXH.js +0 -73
  122. package/dashboard/dist/assets/LimitsPage-i_AEHRcd.js +0 -6
  123. package/dashboard/dist/assets/module-C2SOSUuR.js +0 -3
  124. package/dashboard/dist/assets/use-community-stats-DnRz7Akf.js +0 -1
  125. package/dashboard/dist/assets/use-reduced-motion-D586B7AA.js +0 -1
@@ -1,73 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BadgeDetailModal-DH1lqy_t.js","assets/__vite-browser-external-Bp0fEMn1.js","assets/__vite-browser-external-Br-KAXh6.css","assets/react-BhuZeLEc.js","assets/AchievementBadge-BUYKivjx.js","assets/zap-B6nc-Upg.js","assets/flame-D7CLiokj.js","assets/calendar-days-zge_5pfQ.js","assets/shield-check-BdF9MoZ4.js","assets/use-transform-BFydEHQY.js","assets/use-reduced-motion-D586B7AA.js","assets/AchievementsSection-C2llp4CQ.js","assets/format-tokens-BYDaVVT_.js","assets/DialogTitle-Dc0-pI0j.js","assets/composite-UMkd0X7k.js","assets/store-19qppboP.js"])))=>i.map(i=>d[i]);
2
- import{o as ie,a as W,r as h,aO as ne,j as e,c as i,aP as le,Q as de,U as ce,aQ as me,aR as xe,y as c,x as ge,aA as Z,A as pe,L as he,V as G,an as ue,l as fe,az as be,X as ye,i as ke,_ as je,aS as ve}from"./__vite-browser-external-Bp0fEMn1.js";import{A as _e,f as Ne}from"./provider-display-BhKfIayc.js";import{u as we}from"./useCurrency-sg6d4Wea.js";import{u as X}from"./useTokenFormat-BOt7YH_Y.js";import{L as Y,a as K}from"./LeaderboardProBadge-hMzno53J.js";import{P as $}from"./ProviderIcon-94H7cG7M.js";import{H as Ae,A as V,s as Se,c as Me,b as ze,t as Pe,h as Ce}from"./AchievementBadge-BUYKivjx.js";import{A as Ie}from"./AchievementsSection-C2llp4CQ.js";import{A as U}from"./arrow-up-right-CK7lXR6O.js";import{L as De}from"./link-2-DwpvF9Sr.js";import{C as Te}from"./check-Bt-LY4Pn.js";import{D as Be,a as Le,b as $e,c as Ue,d as Re,e as Fe}from"./DialogTitle-Dc0-pI0j.js";import"./terminal-ikPM7Gyt.js";import"./play-Ch1IEQyR.js";import"./info-D73-a9a_.js";import"./TooltipPopup-DMkTj-q1.js";import"./composite-UMkd0X7k.js";import"./store-19qppboP.js";import"./safePolygon-ag21oDI1.js";import"./usePositioner-CLPx448B.js";import"./zap-B6nc-Upg.js";import"./flame-D7CLiokj.js";import"./calendar-days-zge_5pfQ.js";import"./shield-check-BdF9MoZ4.js";import"./react-BhuZeLEc.js";import"./format-tokens-BYDaVVT_.js";import"./use-reduced-motion-D586B7AA.js";const q={name:"code-xml",size:24,node:[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],aliases:["code-2"]};q.node;const Oe=ie(q),R="tokentracker_anon_id";let M=null;function F(){try{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const r=Math.random()*16|0;return(a==="x"?r:r&3|8).toString(16)})}function O(){if(M)return M;try{let a=localStorage.getItem(R);return a||(a=F(),localStorage.setItem(R,a)),M=a,a}catch{return M=F(),M}}function Q({userId:a}){const{signedIn:r,getAccessToken:o}=W(),[t,s]=h.useState(!1),[n,g]=h.useState(0),[l,x]=h.useState(!1),[u,b]=h.useState(!1),[j,z]=h.useState(!1),[P,T]=h.useState([]),[N,w]=h.useState(!1),C=h.useRef(0),v=h.useCallback(async()=>{if(r)try{const d=await o();if(d)return{accessToken:d,anonId:O()}}catch{}return{anonId:O()}},[r,o]);h.useEffect(()=>{let d=!1;return a?(x(!1),(async()=>{const m=await v();try{const p=await ne({userId:a,...m});if(d)return;g(Number(p?.count)||0),s(!!p?.liked),x(!0)}catch{if(d)return;g(0),s(!1),x(!0)}})(),()=>{d=!0}):(x(!1),()=>{d=!0})},[a,v]);const _=()=>{z(!0),setTimeout(()=>z(!1),450),w(!0),setTimeout(()=>w(!1),500);const d=["#ff4757","#ff6b81","#ffa502","#70a1ff","#2ed573","#a29bfe"],m=["circle","heart"],p=[];for(let y=0;y<12;y++){const f=(y*30+Math.random()*20-10)*(Math.PI/180),k=45+Math.random()*45,B=Math.cos(f)*k,ee=Math.sin(f)*k-(10+Math.random()*15),ae=Math.random()*360-180,re=6+Math.random()*8,te=d[Math.floor(Math.random()*d.length)],se=m[Math.floor(Math.random()*m.length)],oe=++C.current;p.push({id:oe,tx:B,ty:ee,rot:ae,size:re,color:te,shape:se})}T(y=>[...y,...p]),setTimeout(()=>{T(y=>y.filter(f=>!p.find(k=>k.id===f.id)))},850)},A=async d=>{b(!0);try{const m=await v(),p=await le({userId:a,action:d,...m});p&&Number.isFinite(Number(p.count))&&g(Number(p.count)),p&&typeof p.liked=="boolean"&&s(p.liked)}catch{s(m=>!m),g(m=>d==="like"?Math.max(0,m-1):m+1)}finally{b(!1)}},S=d=>{d.stopPropagation(),!(!a||!l||u)&&(t?(s(!1),g(m=>Math.max(0,m-1)),A("unlike")):(s(!0),g(m=>m+1),_(),A("like")))};return e.jsxs("div",{className:"relative inline-flex items-center select-none z-10",children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:`
3
- @keyframes tt-like-pop {
4
- 0% { transform: scale(1); }
5
- 25% { transform: scale(0.75); }
6
- 50% { transform: scale(1.35); }
7
- 75% { transform: scale(0.9); }
8
- 100% { transform: scale(1); }
9
- }
10
- @keyframes tt-particle-fly {
11
- 0% {
12
- transform: translate(0, 0) scale(1) rotate(0deg);
13
- opacity: 1;
14
- }
15
- 70% {
16
- opacity: 0.8;
17
- }
18
- 100% {
19
- transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rot));
20
- opacity: 0;
21
- }
22
- }
23
- @keyframes tt-num-scroll {
24
- 0% { transform: translateY(8px); opacity: 0; }
25
- 100% { transform: translateY(0); opacity: 1; }
26
- }
27
- .tt-animate-pop {
28
- animation: tt-like-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
29
- }
30
- .tt-particle {
31
- position: absolute;
32
- top: 50%;
33
- left: 50%;
34
- margin-top: -6px;
35
- margin-left: -6px;
36
- pointer-events: none;
37
- z-index: 50;
38
- }
39
- .tt-num-anim {
40
- animation: tt-num-scroll 0.25s ease-out forwards;
41
- }
42
- `}}),P.map(d=>e.jsx("span",{className:"tt-particle",style:{"--tx":`${d.tx}px`,"--ty":`${d.ty}px`,"--rot":`${d.rot}deg`,width:`${d.size}px`,height:`${d.size}px`,backgroundColor:d.shape==="circle"?d.color:"transparent",borderRadius:d.shape==="circle"?"50%":"0",animation:"tt-particle-fly 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards"},children:d.shape==="heart"&&e.jsx("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:d.color,className:"w-full h-full",children:e.jsx("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"})})},d.id)),e.jsxs("button",{type:"button",onClick:S,disabled:!l||u,"aria-label":t?i("leaderboard.profile.like.aria_unlike"):i("leaderboard.profile.like.aria_like"),className:`group flex items-center justify-center gap-1.5 h-8 min-w-[48px] px-2.5 rounded-full border transition-all duration-300 outline-none focus-visible:ring-2 focus-visible:ring-rose-500/50 disabled:opacity-60 disabled:cursor-default ${t?"bg-rose-50/60 border-rose-200/80 text-rose-500 dark:bg-rose-950/20 dark:border-rose-900/40 dark:text-rose-400 shadow-sm":"bg-white/80 border-oai-gray-200 text-oai-gray-500 hover:border-rose-200 hover:text-rose-500 hover:bg-rose-50/30 dark:bg-oai-gray-950/50 dark:border-white/10 dark:text-oai-gray-400 dark:hover:border-rose-900/50 dark:hover:text-rose-400 dark:hover:bg-rose-950/5"}`,children:[e.jsx("span",{className:j?"tt-animate-pop":"group-active:scale-90 transition-transform duration-100",children:e.jsx(Ae,{size:14,className:`transition-all duration-300 ${t?"fill-rose-500 text-rose-500 dark:fill-rose-400 dark:text-rose-400":"fill-transparent"}`})}),e.jsx("span",{className:`text-[12px] font-bold font-mono tabular-nums tracking-tight ${t?"text-rose-600 dark:text-rose-400":"text-oai-gray-600 dark:text-oai-gray-400"} ${N?"tt-num-anim":""}`,children:l?n:"·"})]})]})}function He({badge:a,badgeLabel:r,className:o="",...t}){return e.jsxs("div",{className:`relative inline-flex shrink-0 ${o}`,children:[e.jsx(Y,{...t}),a?e.jsx("span",{className:"absolute -bottom-1 -right-1 inline-flex rounded-full ring-2 ring-white dark:ring-oai-gray-950",children:e.jsx(V,{badgeId:a.id,tier:a.tier,size:"sm",label:r})}):null]})}function Ee({badges:a,isOwn:r=!1,onSelect:o,className:t=""}){const s=Se((Array.isArray(a)?a:[]).filter(n=>n&&Me.has(n.id))).filter(n=>r||(n.tier||0)>=1);return s.length===0?null:e.jsx("div",{className:`flex flex-wrap items-center pr-2.5 ${t}`,children:s.map((n,g)=>{const l=(n.tier||0)>=1,x=i(ze(n.id,"name")),u=l?i(`achievements.tier.${Pe(n.tier)}`):i("achievements.modal.locked");return e.jsx("button",{type:"button",onClick:o?()=>o(n):void 0,title:`${x} · ${u}`,"aria-label":i("achievements.badge.aria",{name:x,tier:u}),style:{zIndex:s.length-g},className:"group relative shrink-0 -mr-2.5 rounded-full transition-transform duration-200 ease-out hover:z-30 hover:-translate-y-1 active:scale-95 focus-visible:z-30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60",children:e.jsx(V,{badgeId:n.id,tier:n.tier,locked:!l,size:"md",className:"rounded-full ring-2 ring-white transition-shadow duration-200 group-hover:shadow-md dark:ring-oai-gray-950"})},n.id)})})}const We=G.lazy(()=>je(()=>import("./BadgeDetailModal-DH1lqy_t.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])));function Ze(a,r,o){const t=Number(a);return!Number.isFinite(t)||t<0?"—":t>0&&t<.01?`<${r==="USD"?"$":""}0.01`:Z(t,{decimals:2,currency:r,rate:o})}function H(a,r,o){const t=Number(a);if(!Number.isFinite(t)||t<0)return"—";if(t<1e3)return Ze(t,r,o);const s=r==="USD"?t:t*(o||1);return`${r==="USD"?"$":""}${ke(s,{decimals:1})}`}function Ge(a){const r=Array.isArray(a)?a:[];if(r.length===0)return null;const o=r.map(s=>({day:s.date,total_tokens:s.total_tokens,models:s.models||null})),t=r[r.length-1]?.date;return be({dailyRows:o,weeks:52,to:t})}const Xe=`
43
- @keyframes tt-shimmer {
44
- 100% { transform: translateX(100%); }
45
- }
46
- .tt-shimmer-bar {
47
- position: relative;
48
- overflow: hidden;
49
- }
50
- .tt-shimmer-bar::after {
51
- position: absolute;
52
- top: 0; right: 0; bottom: 0; left: 0;
53
- transform: translateX(-100%);
54
- background-image: linear-gradient(
55
- 90deg,
56
- rgba(0, 0, 0, 0) 0%,
57
- rgba(0, 0, 0, 0.02) 20%,
58
- rgba(0, 0, 0, 0.06) 60%,
59
- rgba(0, 0, 0, 0) 100%
60
- );
61
- animation: tt-shimmer 1.6s infinite;
62
- content: '';
63
- }
64
- .dark .tt-shimmer-bar::after {
65
- background-image: linear-gradient(
66
- 90deg,
67
- rgba(255, 255, 255, 0) 0%,
68
- rgba(255, 255, 255, 0.02) 20%,
69
- rgba(255, 255, 255, 0.06) 60%,
70
- rgba(255, 255, 255, 0) 100%
71
- );
72
- }
73
- `;function Ye({variant:a="modal"}){const r="rounded bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar",o=a==="page";return e.jsxs("div",{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Xe}}),o?e.jsxs("div",{className:"flex items-start gap-5 px-6 sm:px-8 pt-8 pb-7 animate-fade-in",children:[e.jsx("div",{className:"h-[68px] w-[68px] rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start justify-between gap-4 pt-0.5",children:[e.jsxs("div",{className:"min-w-0 space-y-2.5",children:[e.jsx("div",{className:c(r,"h-7 w-48")}),e.jsx("div",{className:c(r,"h-3.5 w-32")})]}),e.jsxs("div",{className:"shrink-0 space-y-1.5 flex flex-col items-end",children:[e.jsx("div",{className:c(r,"h-2.5 w-8")}),e.jsx("div",{className:c(r,"h-7 w-12")})]})]})]}):e.jsxs("div",{className:"flex items-start gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60 animate-fade-in",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2 pt-1",children:[e.jsx("div",{className:c(r,"h-4 w-40")}),e.jsx("div",{className:c(r,"h-3 w-56")})]}),e.jsx("div",{className:c(r,"h-4 w-4 shrink-0 mt-1")})]}),e.jsxs("div",{className:c("space-y-6",o?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"px-6 py-5"),children:[e.jsx("div",{className:"grid grid-cols-4 gap-x-6 gap-y-4",children:Array.from({length:4}).map((t,s)=>e.jsxs("div",{children:[e.jsx("div",{className:c(r,"h-6 w-20")}),e.jsx("div",{className:c(r,"mt-2 h-3 w-14")})]},s))}),e.jsx("div",{className:"space-y-3 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:Array.from({length:3}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-3 w-24")}),e.jsx("div",{className:c(r,"h-3 w-44")})]},s))}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-44 mb-4")}),e.jsx("div",{className:"grid grid-cols-[repeat(52,1fr)] gap-[2px]",children:Array.from({length:364}).map((t,s)=>e.jsx("div",{className:"aspect-square rounded-[2px] bg-oai-gray-200/40 dark:bg-oai-gray-800/30 tt-shimmer-bar"},s))})]}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-28 mb-3")}),e.jsx("div",{className:"space-y-2.5",children:Array.from({length:5}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-4 w-4")}),e.jsx("div",{className:c(r,"h-3 w-16")}),e.jsx("div",{className:c(r,"h-[3px] flex-1")}),e.jsx("div",{className:c(r,"h-3 w-12")})]},s))})]})]})]})}function J(a){if(!a)return null;const r=String(a).match(/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})/i);return r?r[1]:null}function I({children:a}){return e.jsx("h3",{className:"text-[11px] uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400 mb-3",children:a})}function D({value:a,label:r,title:o}){return e.jsxs("div",{children:[e.jsx("div",{title:o,className:"text-2xl font-black tabular-nums tracking-tight leading-none text-oai-black dark:text-white",style:{fontFamily:'"DIN Alternate-Bold", "DIN Alternate", "DIN Condensed-Bold", "Impact", -apple-system, sans-serif',fontWeight:900},children:a}),e.jsx("div",{className:"mt-1.5 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r})]})}function L({label:a,children:r}){return e.jsxs("div",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"shrink-0 w-28 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"min-w-0 flex-1 text-oai-gray-900 dark:text-oai-gray-100 tabular-nums truncate flex items-baseline gap-2 flex-wrap",children:r})]})}function Ke({user:a,onClose:r}){const o=J(a?.github_url);return e.jsxs("div",{className:"flex items-center gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60",children:[e.jsx(Y,{avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"lg",proActive:a?.pro_active===!0,className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:a?.display_name||"—"}),e.jsx(K,{proActive:a?.pro_active===!0}),a?.rank?e.jsx("span",{className:c("shrink-0 inline-flex items-center px-2 py-0.5 rounded text-xs font-bold font-mono uppercase tracking-wider border shadow-sm",a.rank===1&&"bg-amber-500/10 text-amber-600 border-amber-500/20 dark:text-amber-400 dark:bg-amber-400/10",a.rank===2&&"bg-slate-500/10 text-slate-600 border-slate-500/20 dark:text-slate-400 dark:bg-slate-400/10",a.rank===3&&"bg-orange-500/10 text-orange-700 border-orange-500/20 dark:text-orange-400 dark:bg-orange-400/10",a.rank>3&&"bg-oai-gray-100 dark:bg-oai-gray-900/60 text-oai-gray-500 dark:text-oai-gray-400 border-oai-gray-200/60 dark:border-oai-gray-800"),children:i("leaderboard.profile_modal.rank",{rank:a.rank})}):null]}),o&&e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-[12px] text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200 transition-colors",children:[e.jsx($,{provider:"GITHUB",size:11}),e.jsxs("span",{children:["@",o]})]})]}),a?.user_id&&e.jsx("div",{className:"shrink-0 flex items-center justify-center",children:e.jsx(Q,{userId:a.user_id})}),r&&e.jsx("button",{type:"button",onClick:r,className:"shrink-0 -mr-1 -mt-1 flex h-8 w-8 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors group","aria-label":i("leaderboard.profile_modal.close"),children:e.jsx(ye,{size:16,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:rotate-90 group-active:scale-90"})})]})}function Ve({user:a,topBadge:r}){const o=J(a?.github_url),t=Number(a?.rank)||0,s=t===1?"text-amber-500 dark:text-amber-400":t===2?"text-slate-500 dark:text-slate-300":t===3?"text-orange-600 dark:text-orange-400":"text-oai-gray-400 dark:text-oai-gray-500";return e.jsxs("div",{className:"flex items-center gap-5 px-6 sm:px-8 pt-8 pb-7",children:[e.jsx(He,{badge:r,avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"xl",proActive:a?.pro_active===!0,className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"truncate text-2xl sm:text-[28px] font-semibold tracking-tight leading-tight text-oai-black dark:text-white",children:a?.display_name||"—"}),e.jsx(K,{proActive:a?.pro_active===!0}),a?.user_id&&e.jsx(Q,{userId:a.user_id})]}),o?e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white transition-colors",children:[e.jsx($,{provider:"GITHUB",size:13}),e.jsxs("span",{children:["@",o]})]}):null]}),t?e.jsxs("div",{className:"shrink-0 text-right leading-none",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-oai-gray-400 dark:text-oai-gray-500",children:i("leaderboard.profile.hero.rank_label")}),e.jsx("div",{className:c("mt-1.5 text-3xl font-black tabular-nums tracking-tight",s),children:i("leaderboard.profile_modal.rank",{rank:t})})]}):null]})]})}function qe({data:a}){const{formatTokens:r,formatTokensTooltip:o}=X(),t=Array.isArray(a)?a:[];return t.length===0?e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i("leaderboard.profile_modal.providers.none")}):e.jsx("ul",{className:"space-y-2",children:t.map(s=>{const n=Math.max(0,Math.min(1,Number(s?.percent)||0));return e.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"shrink-0 inline-flex items-center justify-center w-4 h-4",children:e.jsx($,{provider:String(s.source).toUpperCase(),size:14})}),e.jsx("span",{className:"w-20 shrink-0 text-oai-gray-700 dark:text-oai-gray-300",children:Ne(s.source)}),e.jsx("span",{className:"flex-1 h-[3px] rounded-full bg-oai-gray-200/60 dark:bg-oai-gray-800/80 overflow-hidden",children:e.jsx("span",{className:"block h-full bg-oai-brand-500 dark:bg-oai-brand-400",style:{width:`${(n*100).toFixed(1)}%`}})}),e.jsx("span",{title:o(s.total_tokens),className:"shrink-0 w-14 text-right tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:r(s.total_tokens)}),e.jsxs("span",{className:"shrink-0 w-10 text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[(n*100).toFixed(0),"%"]})]},s.source)})})}function E({icon:a,label:r,value:o}){const[t,s]=h.useState(!1),n=async()=>{await ve(o)&&(s(!0),setTimeout(()=>s(!1),1600))};return e.jsxs("button",{type:"button",onClick:n,className:c("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",t?"border-emerald-500/30 text-emerald-600 dark:text-emerald-400 bg-emerald-500/[0.06]":"border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-gray-900 dark:hover:text-oai-gray-100 hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[t?e.jsx(Te,{size:13,strokeWidth:2,"aria-hidden":!0}):e.jsx(a,{size:13,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t?i("leaderboard.profile_modal.badge.copied"):r})]})}function Qe({data:a,currency:r,rate:o,onClose:t,variant:s="modal"}){const{formatTokens:n,formatTokensTooltip:g}=X(),{user:l,totals:x,streak:u,best_day:b,models:j,by_provider:z,heatmap:P,period:T}=a,N=s==="page",w=h.useMemo(()=>Ge(P),[P]),C=j?.favorite?.model_name,v=Number(j?.count)||0,_=Array.isArray(a.badges)?a.badges:[],[A,S]=h.useState(null),d=W(),m=!!(d?.user?.id&&l?.user_id&&d.user.id===l.user_id),p=l?.user_id?`https://www.tokentracker.cc/u/${l.user_id}`:null,y=l?.user_id?`[![My AI coding usage](${ge()}/functions/tokentracker-embed-svg?user_id=${l.user_id}&theme=dark)](${p}?ref=readme)`:null;return e.jsxs(e.Fragment,{children:[N?e.jsx(Ve,{user:l,topBadge:Ce(_)}):e.jsx(Ke,{user:l,onClose:t}),e.jsxs("div",{className:c("space-y-6",N?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"flex-1 min-h-0 overflow-y-auto oai-scrollbar px-6 py-5"),children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-4",children:[e.jsx(D,{value:n(x?.total_tokens),title:g(x?.total_tokens),label:i("leaderboard.profile_modal.stat.total_tokens")}),e.jsx(D,{value:H(x?.estimated_cost_usd,r,o),label:i("leaderboard.profile_modal.stat.total_cost")}),e.jsx(D,{value:String(x?.active_days??0),label:i("leaderboard.profile_modal.stat.active_days")}),e.jsx(D,{value:H(x?.avg_per_day_usd,r,o),label:i("leaderboard.profile_modal.stat.avg_per_day")})]}),e.jsxs("dl",{className:"space-y-2 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsxs(L,{label:i("leaderboard.profile_modal.streak.current"),children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:i("leaderboard.profile_modal.streak.days",{count:u?.current_days??0})}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["(max ",u?.longest_days??0,")"]})]}),e.jsx(L,{label:i("leaderboard.profile_modal.best_day.title"),children:b?e.jsxs(e.Fragment,{children:[e.jsx("span",{title:g(b.total_tokens),className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:n(b.total_tokens)}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["on ",b.date]})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:i("leaderboard.profile_modal.best_day.none")})}),e.jsx(L,{label:i("leaderboard.profile_modal.models.favorite"),children:C?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30 truncate max-w-[200px] inline-block align-bottom",children:C}),v>1&&e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:i("leaderboard.profile_modal.models.count",{count:v})})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:i("leaderboard.profile_modal.models.none")})})]}),Array.isArray(j?.breakdown)&&!!j.breakdown.length&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(I,{children:i("usage.overview.all_models")}),j.breakdown.map(f=>e.jsxs("details",{className:"border-b border-oai-gray-100 py-2 text-xs dark:border-oai-gray-800",children:[e.jsxs("summary",{className:"cursor-pointer rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx("span",{className:"font-medium",children:f.model_name}),e.jsx("span",{className:"ml-3 tabular-nums",title:g(f.total_tokens),children:n(f.total_tokens)}),e.jsx("span",{className:"ml-3 tabular-nums",children:Z(f.estimated_cost_usd,{currency:r,rate:o})})]}),e.jsx("dl",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-oai-gray-500",children:[["input_tokens","dashboard.projects.detail.comp_input"],["cached_input_tokens","dashboard.projects.detail.comp_cached"],["cache_creation_input_tokens","dashboard.projects.detail.comp_cache_write"],["output_tokens","dashboard.projects.detail.comp_output"],["reasoning_output_tokens","dashboard.projects.detail.comp_reasoning"]].map(([k,B])=>e.jsxs("div",{className:"flex gap-1",children:[e.jsx("dt",{children:i(B)}),e.jsx("dd",{title:g(f[k]),children:n(f[k])})]},k))})]},f.model_name))]}),(m||_.some(f=>(f?.tier||0)>=1))&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(I,{children:i("achievements.section.title")}),N?e.jsx(Ie,{achievements:_,isOwn:m&&!!a.badges_include_unearned,scope:"cloud",onSelect:S}):e.jsx(Ee,{badges:_,isOwn:m&&!!a.badges_include_unearned,onSelect:S})]}),w&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(I,{children:i("leaderboard.profile_modal.heatmap.title")}),e.jsx("div",{className:"min-w-0",children:e.jsx(_e,{heatmap:w,hideLegend:!0,embedded:!0})})]}),e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(I,{children:i("leaderboard.profile_modal.providers.title")}),e.jsx(qe,{data:z})]}),l?.user_id&&(t||m)&&e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-3",children:[t&&(pe()?e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",onClick:t,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:i("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]}):e.jsxs(he,{to:`/u/${l.user_id}`,onClick:t,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:i("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})),m&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{icon:De,label:i("leaderboard.profile_modal.badge.copy_url"),value:p}),e.jsx(E,{icon:Oe,label:i("leaderboard.profile_modal.badge.copy"),value:y})]})]})]}),A&&e.jsx(G.Suspense,{fallback:null,children:e.jsx(We,{badge:A,onClose:()=>S(null)})})]})}function Je({userId:a,period:r,accessToken:o,enabled:t=!0}){const[s,n]=h.useState({loading:!1,error:null,data:null}),g=h.useMemo(()=>de(),[]),l=h.useMemo(()=>ce(),[]);return h.useEffect(()=>{if(!t||!a)return;let x=!0;return n({loading:!0,error:null,data:null}),(async()=>{try{const u=o?await me(o):null;if(!x)return;const b=await xe({accessToken:u,userId:a,period:r||"week",timeZone:g,tzOffsetMinutes:l});if(!x)return;n({loading:!1,error:null,data:b})}catch(u){if(!x)return;u?.status===404?n({loading:!1,error:null,data:null}):n({loading:!1,error:u?.message||String(u),data:null})}})(),()=>{x=!1}},[t,a,r,o,g,l]),s}function Sa({isOpen:a,onClose:r,userId:o,period:t,accessToken:s}){const{currency:n,rate:g}=we(),l=Je({userId:o,period:t,accessToken:s,enabled:a});return e.jsx(Be,{open:a,onOpenChange:x=>{x||r?.()},children:e.jsxs(Le,{children:[e.jsx($e,{className:"cost-modal-backdrop"}),e.jsx(Ue,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(Re,{className:c("cost-modal-popup","relative w-full max-w-[540px] max-h-[calc(100vh-2rem)] flex flex-col","rounded-2xl bg-white dark:bg-oai-gray-950","shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)]","ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden","dark:border-t dark:border-white/[0.08]"),children:[e.jsx(Fe,{render:e.jsx("h2",{className:"sr-only"}),children:l.data?.user?.display_name||i("leaderboard.profile_modal.loading")}),l.loading&&e.jsx(Ye,{}),!l.loading&&l.error&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:i("leaderboard.profile_modal.error")})}),!l.loading&&!l.error&&!l.data&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:i("leaderboard.profile_modal.empty")})}),!l.loading&&!l.error&&l.data&&e.jsx(ue,{mode:fe.COMPACT,children:e.jsx(Qe,{data:l.data,currency:n,rate:g,onClose:r})})]})})]})})}export{Sa as LeaderboardProfileModal,Qe as ProfileContent,Ye as ProfileSkeleton,Je as useLeaderboardProfileData};
@@ -1,6 +0,0 @@
1
- import{o as ee,j as e,y as Le,c as r,h as B,r as p,bm as vt,V as P,bn as jt,al as kt,B as Z,bo as wt,e as Nt,W as _e,R as _t,L as St,bp as Pt,t as Ct,w as Mt}from"./__vite-browser-external-Bp0fEMn1.js";import{m as Se}from"./react-BhuZeLEc.js";import{P as ne,c as Dt,r as de,a as Et,u as Tt,b as Rt,s as It}from"./use-usage-limits-BqWWrW6O.js";import{b as $e,c as C,l as se,d as Ue,u as At}from"./use-limits-display-prefs-C2IK7QqP.js";import{F as Ht}from"./FadeIn-DFL15trS.js";import{P as ze}from"./ProviderIcon-94H7cG7M.js";import{H as Ft}from"./HoverTooltip-DXIFAD1D.js";import{C as be}from"./chevron-down-BOy_MKfd.js";import{G as Ot}from"./gift-toIl7elE.js";import{C as Lt}from"./ConfirmModal-MvUDUW0j.js";import{I as Pe,L as $t}from"./LocalOnlyNotice-Cnzi2tn4.js";import{S as ge}from"./Select-Dk1g2jS1.js";import{P as Ut}from"./plus-Bc8vdvFi.js";import{P as zt,a as Bt,b as Gt,c as Wt,d as Kt}from"./PopoverPopup-BqiCJJkn.js";import{u as qt}from"./use-reduced-motion-D586B7AA.js";import"./use-latest-request-guard-CClqxkji.js";import"./DialogTitle-Dc0-pI0j.js";import"./composite-UMkd0X7k.js";import"./store-19qppboP.js";import"./DialogDescription-C3mLrii8.js";import"./arrow-up-right-CK7lXR6O.js";import"./download-BJD3ff5y.js";import"./check-Bt-LY4Pn.js";import"./SelectItemText-CgY3YTCX.js";import"./usePositioner-CLPx448B.js";import"./safePolygon-ag21oDI1.js";const Be={name:"bell-off",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]};Be.node;const Vt=ee(Be);const Ge={name:"bell",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]};Ge.node;const Yt=ee(Ge);const We={name:"calendar-clock",size:24,node:[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338",key:"7hb8p4"}],["path",{d:"M3 9h5.859",key:"numkqi"}],["path",{d:"M8 2v3",key:"1ioesn"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]};We.node;const Ke=ee(We);const qe={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};qe.node;const Ve=ee(qe);const Ye={name:"infinity",size:24,node:[["path",{d:"M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8",key:"18ogeb"}]]};Ye.node;const Xe=ee(Ye),Xt=[3,2,3,3,2,2,3];function q({className:t}){return e.jsx("div",{className:Le("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Zt(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-3 w-12 shrink-0"}),e.jsx(q,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(q,{className:"h-3 w-[30px] shrink-0"}),e.jsx(q,{className:"h-3 w-6 shrink-0"})]})}function Jt({bars:t,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return e.jsxs("div",{className:"rounded-xl border border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-900",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-oai-gray-200 px-4 py-4 dark:border-oai-gray-800 sm:px-5",children:[e.jsx(q,{className:"h-[22px] w-[22px] shrink-0 rounded"}),e.jsx(q,{className:Le("h-4",i)})]}),e.jsx("div",{className:"flex flex-col gap-2 px-4 py-4 sm:px-5",children:Array.from({length:t},(s,n)=>e.jsx(Zt,{},n))})]})}function Qt(){return e.jsx("div",{className:"flex flex-col gap-3","aria-hidden":"true",children:Xt.map((t,a)=>e.jsx(Jt,{bars:t,index:a},a))})}const ye=100;function Ce(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function ea(t){return Math.max(0,Math.min(ye,Math.round(t)))}function ta(t){return new Intl.DateTimeFormat(B(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function aa(t,a,i){if(t==null||t>=a)return ye;const s=a-t,n=a-i;return ea(n/s*ye)}function ra(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function ia(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=ra(t);if(i===void 0)return null;const s=Array.isArray(t.credits)?t.credits:[],n=a instanceof Date?a.getTime():Number(a??Date.now()),o=[];for(const l of s){const c=Ce(l?.expires_at);if(c==null)continue;const d=o.length+1;o.push({key:`reset-${d}`,label:r("limits.codex_reset_bank.row_label",{index:d}),expiresAt:ta(c),expiresMs:c,percent:aa(Ce(l?.granted_at),c,n)})}return i===0?null:o.length>0?{kind:"rows",availableCount:i??o.length,rows:o}:i>0?{kind:"count_only",availableCount:i,rows:[]}:null}const Q=864e5;function z(t,a){const i=new Date(t),s=i.getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+a,1,i.getUTCHours(),i.getUTCMinutes())),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(s,o)),n.getTime()}function Ze(t,a){if(a==="weekly")return t-7*Q;if(a==="yearly")return z(t,-12);const i=new Date(t),s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),0)).getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()-1,1,i.getUTCHours(),i.getUTCMinutes()));return n.setUTCDate(Math.min(i.getUTCDate(),s)),n.getTime()}function Je(t,a){return a==="weekly"?t+7*Q:a==="yearly"?z(t,12):z(t,1)}function na(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return Ze(new Date(t.nextBillingAt).getTime(),t.cycle)}function sa(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return Ze(i,a)}function oa(t,a,i){if(a==="weekly"){const c=7*Q,d=i<=t?0:Math.floor((i-t)/c);return{startMs:t+d*c,endMs:t+(d+1)*c}}const s=a==="yearly"?12:1,n=s*30.436875*Q;let o=i<=t?0:Math.floor((i-t)/n);for(;o>0&&z(t,o*s)>i;)o-=1;let l=0;for(;z(t,(o+1)*s)<=i&&l<12e3;)o+=1,l+=1;return{startMs:z(t,o*s),endMs:z(t,(o+1)*s)}}function oe(t,a){const i=new Date(t.nextBillingAt).getTime();if(!Number.isFinite(i))return null;const s=["weekly","monthly","yearly"].includes(t.cycle)?t.cycle:"monthly",n=sa(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=oa(n,s,a):t.startedAt!=null?(o=n,l=Je(n,s),c=l<=a):(o=n,l=i,c=l<=a);const d=Math.max(1,l-o),m=c?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:l,startMs:o,progress:m,cycleDays:Math.max(1,Math.round(d/Q)),expired:c}}function Qe(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.ceil(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function ve(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.floor(i/6e4),n=Math.floor(s/1440),o=Math.floor(s%1440/60),l=s%60;return r("subscriptions.countdown",{days:n,hours:o,minutes:l})}const la="shrink-0 text-oai-black dark:text-oai-white",ca={opencodeGo:"OPENCODE_GO_API_KEY",commandCode:"COMMAND_CODE_API_KEY"},da={opencodeGo:"opencode-go",commandCode:"command-code"};function et(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function tt(){return et()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function at(){return r("limits.devin.setupHint.snippet_login")}function ua(t){const a=de(t);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const s=Math.floor(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function rt(t,a){const i=a===C.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function le(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ue(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function re(t){const a=Math.max(0,Math.min(100,Number(t)||0)),i=Math.round(a);return a>0&&i===0?r("limits.bar.sub_one_percent"):String(i)}function ie(t,{useGrouping:a=!0,maximumFractionDigits:i}={}){const s=Number(t);return Number.isFinite(s)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:i??(s>=100?0:2),useGrouping:a}).format(s):null}function it(t,a){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const i={useGrouping:t.unit!=="calls",maximumFractionDigits:a},s=ie(t.used_credits,i),n=ie(t.limit_credits,i),o=ie(t.remaining_credits,i);if(!s||!n||!o)return null;const l=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(l,{used:s,limit:n,remaining:o})}function nt(t,a,i){return Dt({usedPercent:le(t.window,t.pctField),windowSeconds:Et(t,t.window),resetMs:de(ue(t.window,t.resetField)),mode:a,now:i})}function ce(t){return Number.isFinite(t)?new Intl.DateTimeFormat(B(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function ma(t,a,i){const s=[ot(t,a,i)],n=de(ue(t.window,t.resetField)),o=ce(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=it(t.window,t.creditPrecision);return l&&s.push(l),s.join(`
2
- `)}const st=Ft,Me=[1,.65,.45,.3,.2];function je(t){return Me[Math.min(t,Me.length-1)]}function De({paceX:t,paceOver:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${t}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${a?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${t}% - 1px)`,width:"2px"}})]})}function xa({label:t,pct:a,reset:i,mode:s=C.USED,pacePercent:n=null,paceOver:o=!1,title:l=null,segments:c=null}){const d=Math.max(0,Math.min(100,Number(a)||0)),m=s===C.REMAINING?100-d:d,u=rt(m,s),g=Math.round(m),y=m>0&&g===0?Math.max(m,.35):m;let b=String(g);m>0&&g===0&&(b=r("limits.bar.sub_one_percent"));const v=n==null?null:Math.max(0,Math.min(100,n)),_=c?.map(w=>Math.max(0,Math.min(100,Number(w.pct)||0))),j=_?.reduce((w,E)=>w+E,0)||0,M=c?Math.max(0,d-j):0,k=Math.max(0,100-j-M);return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(st,{text:l}),e.jsx("span",{"data-limit-label":"",className:"text-xs sm:text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),c?e.jsxs("div",{"data-limit-segments":"",className:"relative flex min-w-0 flex-1 h-1.5 overflow-hidden",style:{gap:"min(2px, 1%)"},children:[c.map((w,E)=>e.jsx("div",{"data-limit-segment":w.key,className:`${u} min-w-0 rounded-full h-full transition-[flex-grow] duration-500 ease-out`,style:{flex:`${_[E]} 1 0px`,opacity:je(E)}},w.key)),M?e.jsx("div",{"data-limit-unallocated-used":"",className:`${u} min-w-0 rounded-full h-full`,style:{flex:`${M} 1 0px`,opacity:je(c.length)}}):null,k?e.jsx("div",{"data-limit-remainder":"",className:"min-w-0 rounded-full h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{flex:`${k} 1 0px`}}):null,v!=null&&e.jsx(De,{paceX:v,paceOver:o})]}):e.jsxs("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${u} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${y}%`,minWidth:m>0?"3px":0}}),v!=null&&e.jsx(De,{paceX:v,paceOver:o})]}),e.jsxs("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:[b,"%"]}),i&&e.jsx("span",{className:"text-xs tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-8 text-right shrink-0",children:i})]})}function pa({segments:t,fillColor:a}){return e.jsx("div",{"data-limit-legend":"",className:"-mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] leading-snug",style:{paddingLeft:"calc(var(--tt-limits-label-w, 0px) + 0.5rem)"},children:t.map((i,s)=>e.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[e.jsx("span",{"aria-hidden":!0,className:`${a} inline-block h-1.5 w-1.5 shrink-0 rounded-full`,style:{opacity:je(s)}}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:i.label??r(i.labelKey)}),e.jsxs("span",{className:"tabular-nums text-oai-gray-700 dark:text-oai-gray-200",children:[re(i.pct),"%"]})]},i.key))})}function ot(t,a,i){const s=t.label??r(t.labelKey),n=i===C.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(le(t.window,t.pctField))||0)),m=re(o(d));return n?r("limits.explain.remaining",{label:s,used:m}):r("limits.explain.used",{label:s,used:m})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=re(o(a.projectedEnd??100));return r(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:s,pct:d})}const l=Math.max(0,Math.min(100,Number(le(t.window,t.pctField))||0)),c=re(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function lt({pace:t}){return t.pacePercent!=null}function ga(t,a){return t.some(i=>lt(i)&&(i.mode??a)===C.REMAINING)}function ct({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=ga(t,a),n=t.some(lt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l,mode:c=a})=>{const d=ce(de(ue(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[ot(o,l,c),d?e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",r(o.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:d})]}):null,o.showCreditDetail?e.jsx("div",{children:it(o.window,o.creditPrecision)}):null]},o.key)}),n?e.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(s?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function J(t){if(!t)return null;const a=Date.now()-new Date(t).getTime();if(a<0)return null;const i=Math.floor(a/6e4);if(i<1)return r("shared.time.now");if(i<60)return r("shared.time.m_ago",{n:i});const s=Math.floor(i/60);if(s<24)return r("shared.time.h_ago",{n:s});const n=Math.floor(s/24);return r("shared.time.d_ago",{n})}const Ee={live:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-emerald-500",pulse:"bg-emerald-400"},stale:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"},cached:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"}},ha={claude:"claude",codex:"codex",antigravity:"agy"};function K({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=Ee[i]||Ee.live,o=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:l=>l.stopPropagation(),children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold uppercase tracking-wider border leading-normal ${n.surface}`,children:[o?e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${n.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${n.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),s?e.jsxs("span",{className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-2 -translate-x-1/2 w-48 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-1.5 text-[10px] font-normal text-white text-center opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-normal shadow-lg origin-bottom border border-oai-gray-800 dark:border-oai-gray-700",children:[s,e.jsx("span",{className:"absolute left-1/2 top-full -translate-x-1/2 border-4 border-transparent border-t-oai-gray-900 dark:border-t-oai-gray-800"})]}):null]})}function dt({name:t,providerId:a,children:i,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null,toggleOnHeader:d=!1}){const m=Ue(a),u=e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[m?e.jsx(ze,{provider:m,size:22,className:la}):null,e.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white",children:t}),c?e.jsx("span",{className:"shrink-0",children:c}):null,l]}),g="rounded-xl border border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-900",y="flex w-full items-center justify-between gap-3 border-b border-oai-gray-200 px-4 py-4 text-left dark:border-oai-gray-800 sm:px-5",b=e.jsx("div",{className:"flex flex-col gap-2 px-4 py-4 sm:px-5",children:i});return s?d?e.jsxs("div",{className:g,children:[e.jsxs("button",{type:"button","aria-expanded":n,onClick:o,className:`${y} rounded-t-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500`,children:[u,e.jsx(be,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${n?"rotate-180":""}`})]}),b]}):e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:o,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),o?.())},className:`${g} cursor-pointer transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500`,children:[e.jsxs("div",{className:y,children:[u,e.jsx(be,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${n?"rotate-180":""}`})]}),b]}):e.jsxs("div",{className:g,children:[e.jsx("div",{className:y,children:u}),b]})}function ut({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?Xe:Ve;return e.jsx("span",{role:"img","aria-label":a,title:a,className:`inline-flex translate-y-px ${t.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:e.jsx(i,{size:14,strokeWidth:2,"aria-hidden":!0})})}function mt({subscription:t,now:a,mode:i=C.USED}){const s=oe(t,a);if(!s)return null;const{endMs:n,expired:o}=s,l=!o&&n-a<=3*864e5,c=o?100:s.progress*100,d=i===C.REMAINING?100-c:c,m=o?100:Math.max(0,Math.min(100,d)),u=Math.round(m),g=m>0&&u===0?r("limits.bar.sub_one_percent"):`${u}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs sm:text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:r("subscriptions.inline.label")}),e.jsx("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:`${o?"bg-red-500":l?"bg-amber-500":"bg-blue-500"} rounded-full h-full block motion-safe:transition-[width] motion-safe:duration-500 ease-out motion-reduce:transition-none`,style:{width:`${m}%`,minWidth:m>0?"3px":0}})}),e.jsx("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:g}),e.jsx("span",{className:`text-xs tabular-nums shrink-0 whitespace-nowrap w-8 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Qe(n,a)})]})}function xt({subscription:t,now:a}){const i=oe(t,a);if(!i)return null;const s=new Intl.DateTimeFormat(B(),{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("subscriptions.inline.label")}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:":"}),e.jsx("span",{children:t.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")}),e.jsx("span",{children:" "}),e.jsx("span",{className:"font-mono tabular-nums",children:s.format(new Date(i.endMs))}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{className:i.expired?"text-oai-error":void 0,children:ve(i.endMs,a)}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{children:t.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]})}const fa=$e;function A({children:t,tone:a="neutral"}){return a==="error"?e.jsxs("div",{className:"flex items-start gap-2 text-xs leading-relaxed text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(vt,{size:15,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-red-500 dark:text-red-400"}),e.jsx("span",{className:"min-w-0 break-words",children:t})]}):e.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:t})}function pt({rows:t,mode:a,extra:i=null,expanded:s=!1}){const n=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:o,pace:l,mode:c=a})=>{const d=le(o.window,o.pctField),m=s?o.segments:null;return e.jsxs(P.Fragment,{children:[e.jsx(xa,{label:o.label??r(o.labelKey),pct:d,reset:ua(ue(o.window,o.resetField)),mode:c,segments:m,pacePercent:l.pacePercent,paceOver:l.paceOver,title:ma(o,l,c)}),m?e.jsx(pa,{segments:m,fillColor:rt(d,C.USED)}):null]},o.key)}),n?e.jsx(A,{children:r("limits.status.no_data")}):null,i]})}function ba(t){if(!Number.isFinite(t.expiresMs))return null;const a=Math.floor((t.expiresMs-Date.now())/864e5);return a<0?null:a===0?r("limits.reset_bank.hover_detail_today",{date:t.expiresAt}):r("limits.reset_bank.hover_detail",{date:t.expiresAt,days:a})}function ya({row:t}){const a=Math.max(0,Math.min(100,Number(t.percent)||0));return e.jsxs("div",{className:"group relative flex items-center gap-2","data-reset-bank-row":"",children:[e.jsx(st,{text:ba(t)}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t.label}),e.jsx("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${a}%`,minWidth:a>0?"3px":0}})}),e.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:t.expiresAt})]})}function va({model:t}){const a=t.kind==="count_only"?r("limits.codex_reset_bank.count_only",{count:t.availableCount}):null;return e.jsxs("div",{className:"mt-1 flex flex-col gap-1","data-reset-bank-section":t.kind,children:[e.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codex_reset_bank.title")}),a?e.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:a}):t.rows.map(i=>e.jsx(ya,{row:i},i.key))]})}function ja({data:t}){const a=Date.now(),i=[{key:"five_hour",label:r("limits.label.zcode_5h")},{key:"weekly",label:r("limits.label.zcode_weekly")}].map(s=>({...s,cards:(t[s.key]||[]).filter(n=>Date.parse(n.expires_at)>a).slice().sort((n,o)=>Date.parse(n.expires_at)-Date.parse(o.expires_at))}));return e.jsxs("div",{className:"mt-1 flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.reset_bank.title")}),t.error?e.jsx(A,{tone:"error",children:t.error}):i.map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{"data-limit-label":"",className:"shrink-0 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",style:{width:"var(--tt-limits-label-w)"},children:s.label}),e.jsx("span",{className:"rounded-full bg-oai-gray-100 px-2 py-0.5 tabular-nums text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:r("limits.zcode.reset_bank.count",{count:s.cards.length})}),s.cards.length?e.jsx("span",{className:"ml-auto text-right text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",title:s.cards.map(n=>ce(Date.parse(n.expires_at))).join(`
3
- `),children:r("limits.zcode.reset_bank.earliest",{time:ce(Date.parse(s.cards[0].expires_at))})}):null]},s.key))]})}function gt(t,a){if(t==="zcode_reset_bank")return a.reset_credits?e.jsx(ja,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=ia(a.reset_credits);return i?e.jsx(va,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(A,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})});if(t==="kiro_credits"&&Number.isFinite(Number(a.tracked_credits))&&Number(a.tracked_credit_records)>0){const i=ie(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(A,{children:r("limits.label.kiro_tracked_credits",{credits:i,count:Number(a.tracked_credit_records)})})}return t==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?e.jsx(_a,{defaultDir:a.otel_default_dir}):null}function ka({data:t,mode:a,now:i}){const[s,n]=p.useState(!1),o=p.useRef(null),l=ht(o),c=[...new Set((t.buckets||[]).map(u=>u.plan_name).filter(Boolean))],d=c.length?c.join(" · "):r("limits.zcode.start_grants"),m=ne.zcode.windows(t).filter(u=>u.window).map(u=>({spec:u,pace:nt(u,a,i)}));return e.jsxs("div",{className:"mt-2 border-t border-oai-gray-200/60 pt-2 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:u=>{u.stopPropagation(),n(g=>!g)},onKeyDown:u=>u.stopPropagation(),className:"flex w-full items-center gap-1.5 rounded text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx(Ot,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(be,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${s?"rotate-180":""}`})]}),s?e.jsx("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:l>0?{"--tt-limits-label-w":`${l}px`}:void 0,children:t.error?e.jsx(A,{tone:"error",children:t.error}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{rows:m,mode:a}),e.jsx(ct,{rows:m,mode:a,now:i}),(t.buckets||[]).filter(u=>Number.isFinite(u.remaining_units)&&Number.isFinite(u.total_units)).map((u,g)=>e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.grant_amount",{remaining:u.remaining_units.toLocaleString(B()),total:u.total_units.toLocaleString(B())})},u.entitlement_id||g))]})}):null]})}function wa(t,a,i,s,n,o,l=null,c=null,d=Date.now(),m=null){const u=ne[t];if(!u)return null;const g=u.windows(a).filter(b=>b.window).map(b=>{const v=b.productPool?C.USED:s;return{spec:b,mode:v,pace:nt(b,v,d)}}),y=gt(u.extra,a);return e.jsxs(dt,{name:i,providerId:t,expandable:g.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(ut,{subscription:c}):null,toggleOnHeader:t==="zcode",children:[e.jsx(pt,{mode:s,rows:g,extra:y,expanded:n}),t==="opencodeGo"||t==="commandCode"?e.jsx(Sa,{providerId:t,data:a,onSaved:m}):null,c?e.jsx(mt,{subscription:c,now:d,mode:s}):null,n?e.jsx(ct,{rows:g,mode:s,now:d}):null,n&&c?e.jsx(xt,{subscription:c,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(ka,{data:a.start_plan,mode:s,now:d}):null]},t)}function he(t,a,i,s,n=null,o=Date.now(),l=C.USED){const c=!!n;return e.jsxs(dt,{name:se(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(ut,{subscription:n}):null,children:[a,c?e.jsx(mt,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(xt,{subscription:n,now:o})}):null]},t)}function Na(t,a,i,s,n,o=null,l=Date.now(),c=null){if(!ne[t])return null;if(!a?.configured)return he(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(T,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Te,{onSaved:c})}):null,t==="commandCode"?e.jsx(T,{title:r("limits.commandCode.setupHint.title"),children:e.jsx(Re,{onSaved:c})}):null,t==="codingPlan"?e.jsx(T,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Ae,{})}):null,t==="agentPlan"?e.jsx(T,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(He,{})}):null,t==="devin"?e.jsx(T,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ie,{})}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return he(t,e.jsx(A,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return he(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{tone:"error",children:a.error}),t==="kiro"?gt(ne.kiro.extra,a):null,t==="opencodeGo"?e.jsx(T,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Te,{onSaved:c})}):null,t==="commandCode"?e.jsx(T,{title:r("limits.commandCode.setupHint.title"),children:e.jsx(Re,{onSaved:c})}):null,t==="codingPlan"?e.jsx(T,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Ae,{})}):null,t==="agentPlan"?e.jsx(T,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(He,{})}):null,t==="devin"?e.jsx(T,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ie,{})}):null]}),s,n,o,l,i);const d=se(t),m=a.plan_label?`${d} ${a.plan_label}`:d;let u=null;if(a.auth_action_required==="reauth"){const y=t==="commandCode"?tt():t==="devin"?at():ha[t];u=e.jsx(K,{label:r("limits.reauth.badge"),age:J(a.cached_at),tone:"stale",tooltip:y?r("limits.reauth.tooltip",{command:y}):null})}if(!u&&t==="antigravity")if(a.cached){const y=J(a.cached_at);u=e.jsx(K,{label:r("limits.label.antigravity_cached"),age:y,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(K,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(K,{label:r("limits.label.antigravity_cached"),age:J(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(K,{label:r("limits.label.antigravity_cached"),age:J(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const g=a.provenance;return g?.stale&&!u&&(u=e.jsx(K,{label:r("limits.provenance.stale"),age:J(g.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:g.source,confidence:g.confidence})})),wa(t,a,m,i,s,n,u,o,l,c)}function _a({defaultDir:t}){const[a,i]=p.useState(!1),n=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${t||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
4
- `),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:r("limits.copilot.otelHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug",children:r("limits.copilot.otelHint.body")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:n}),e.jsx("button",{type:"button",onClick:o,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:a?r("limits.copilot.otelHint.copied"):r("limits.copilot.otelHint.copy")})]})}function D({n:t,children:a}){return e.jsxs("li",{className:"flex gap-2.5",children:[e.jsx("span",{className:"mt-[1px] flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-oai-brand/15 text-[9px] font-semibold text-oai-brand",children:t}),e.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:a})]})}function ke(){return e.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",className:"h-2.5 w-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M4.5 2.75h4.75V7.5M9.25 2.75 3 9"})})}function we({provider:t,onSaved:a}){const[i,s]=p.useState(""),[n,o]=p.useState("idle"),[l,c]=p.useState(!1),d=async m=>{m.preventDefault(),m.stopPropagation();const u=i.trim();if(!(!u||n==="saving")){o("saving"),c(!1);try{await jt(t,u),s(""),o("saved"),a?.()}catch{o("idle"),c(!0)}}};return e.jsxs("form",{className:"mt-1.5 space-y-1.5",onSubmit:d,onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"password",value:i,onChange:m=>{s(m.target.value),o("idle"),c(!1)},placeholder:r("limits.apiKey.placeholder"),"aria-label":r("limits.apiKey.placeholder"),autoComplete:"new-password",spellCheck:!1,className:"min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-white px-2 py-1 font-mono text-[11px] text-oai-gray-800 outline-none focus:border-oai-brand dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-100"}),e.jsx("button",{type:"submit",disabled:!i.trim()||n==="saving",className:"shrink-0 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 disabled:opacity-50 transition-colors",children:n==="saving"?r("limits.apiKey.saving"):n==="saved"?r("limits.apiKey.saved"):r("limits.apiKey.save")})]}),e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:l?r("limits.apiKey.save_failed"):r("limits.apiKey.local_note")})]})}function Sa({providerId:t,data:a,onSaved:i}){if(a?.credential_source!=="env")return null;const s=ca[t],n=da[t];return!s||!n?null:e.jsxs("div",{className:"mt-1.5 rounded-md border border-amber-300/60 bg-amber-50/60 px-2 py-1.5 text-[10.5px] leading-snug text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",children:[e.jsx("div",{children:r("limits.apiKey.env_note",{env:s})}),e.jsx(we,{provider:n,onSaved:i}),et()==="macos"?e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.jsx("code",{className:"rounded bg-white/70 px-1 py-0.5 font-mono text-[10px] dark:bg-oai-gray-900/60",children:r("limits.apiKey.env_unset_command",{env:s})}),e.jsx("span",{children:r("limits.apiKey.env_unset_note")})]}):null]})}function T({title:t,children:a}){return e.jsxs("div",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",onClick:i=>i.stopPropagation(),onKeyDown:i=>i.stopPropagation(),children:[e.jsx("div",{className:"font-medium text-oai-gray-800 dark:text-oai-gray-100",children:t}),a]})}function Te({onSaved:t}){return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.opencodeGo.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),e.jsx(ke,{})]})]}),e.jsx(D,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(D,{n:"3",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step3")}),e.jsx(we,{provider:"opencode-go",onSaved:t})]})]})]})}function Re({onSaved:t}){const a=tt();return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.commandCode.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:a})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step2")}),e.jsx(we,{provider:"command-code",onSaved:t})]})]})]})}function Ie(){const t=at();return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.devin.setupHint.subtitle")}),e.jsx("ol",{className:"mt-2.5 space-y-2.5",children:e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.devin.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:t}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.devin.setupHint.note")})]})})]})}function Ae(){const[t,a]=p.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
5
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.codingPlan.setupHint.cta"),e.jsx(ke,{})]})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.step2_remote")})]}),e.jsxs(D,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.codingPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.codingPlan.setupHint.copied"):r("limits.codingPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codingPlan.setupHint.note_app")})]})]})]})}function He(){const[t,a]=p.useState(!1),i=[r("limits.agentPlan.setupHint.snippet_install"),r("limits.agentPlan.setupHint.snippet_login"),r("limits.agentPlan.setupHint.snippet_status")].join(`
6
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.agentPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.agentPlan.setupHint.cta"),e.jsx(ke,{})]})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.agentPlan.setupHint.step2_remote")})]}),e.jsxs(D,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.agentPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.agentPlan.setupHint.copied"):r("limits.agentPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.agentPlan.setupHint.note_app")})]})]})]})}function ht(t){const[a,i]=p.useState(0);return p.useLayoutEffect(()=>{const s=t.current;if(!s)return;const n=[...s.querySelectorAll("[data-limit-label]")].filter(d=>d.closest("[data-limit-label-group]")===s);let o=0,l=null;if(n.length>0)try{l=document.createElement("canvas").getContext("2d")}catch{l=null}if(l){const d=window.getComputedStyle(n[0]);l.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`;for(const m of n)o=Math.max(o,l.measureText(m.textContent).width)}const c=Math.ceil(o);i(d=>d===c?d:c)}),a}function Pa({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:u,commandCode:g,qoder:y,qoderCn:b,codingPlan:v,agentPlan:_,devin:j,workbuddy:M,order:k,visibility:w,displayMode:E,subscriptions:R=[],showSubscriptions:I=!0,onProviderKeySaved:V=null}){const H={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:u,commandCode:g,qoder:y,qoderCn:b,codingPlan:v,agentPlan:_,devin:j,workbuddy:M},te=p.useRef(null),Y=ht(te),[$,ae]=p.useState(null),[X,me]=p.useState(()=>Date.now()),xe=[...new Set((Array.isArray(k)&&k.length>0?k:fa).map(f=>f==="workbuddyAi"?"workbuddy":f))],pe=E===C.REMAINING?C.REMAINING:C.USED;p.useEffect(()=>{const f=setInterval(()=>me(Date.now()),6e4);return()=>clearInterval(f)},[]);const F=new Map;if(I)for(const f of R||[]){if(!f?.provider)continue;const L=new Date(f.nextBillingAt).getTime();if(!Number.isFinite(L))continue;const U=F.get(f.provider);if(!U){F.set(f.provider,f);continue}const G=new Date(U.nextBillingAt).getTime(),x=L>X,N=G>X;(x&&(!N||G>L)||!x&&!N&&L>G)&&F.set(f.provider,f)}const O=xe.filter(f=>!w||w[f]!==!1||F.has(f)).map(f=>Na(f,H[f],pe,$===f,()=>ae(L=>L===f?null:f),F.get(f)||null,X,V)).filter(Boolean);return e.jsx(Ht,{delay:.15,children:e.jsx("div",{ref:te,"data-limit-label-group":"",className:"flex flex-col gap-3",style:Y>0?{"--tt-limits-label-w":`${Y}px`}:void 0,children:O.length>0?O:e.jsx(A,{children:r("limits.status.all_hidden")})})})}async function ft(t){const a=await t.json().catch(()=>null);if(!t.ok||a?.ok===!1)throw new Error(a?.error||`Subscription request failed with HTTP ${t.status}`);return a}async function Ca(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await ft(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function Ne(t){const a=await kt();return ft(await fetch("/functions/tokentracker-subscription-manager",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function Ma(t){return Ne({action:"create",subscription:t})}function Da(t,a){return Ne({action:"update",id:t,subscription:a})}function Ea(t){return Ne({action:"delete",id:t})}const fe={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function Ta(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const i=s=>String(s).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())}T${i(a.getHours())}:${i(a.getMinutes())}`}function Ra({subscriptions:t,onChanged:a}){const[i,s]=p.useState(!1),[n,o]=p.useState(null),[l,c]=p.useState(fe),[d,m]=p.useState(!1),[u,g]=p.useState(!1),[y,b]=p.useState(!1),[v,_]=p.useState(!1),[j,M]=p.useState(null),[k,w]=p.useState(!1),[E,R]=p.useState(!1),[I,V]=p.useState(null),[H,te]=p.useState(()=>Date.now()),Y=p.useRef(null),$=B(),ae=p.useMemo(()=>new Intl.DateTimeFormat($,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[$]);p.useEffect(()=>{const x=setInterval(()=>te(Date.now()),6e4);return()=>clearInterval(x)},[]),p.useEffect(()=>{if(!i)return;const x=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;Y.current?.scrollIntoView?.({behavior:x?"auto":"smooth",block:"nearest"})},[i,n]);const X=p.useMemo(()=>$e.map(x=>{const N=(t||[]).some(S=>S.provider===x&&S.id!==n),h=se(x);return{value:x,label:N?`${h} ${r("subscriptions.form.provider_taken_suffix")}`:h,disabled:N}}),[$,t,n]),me=p.useMemo(()=>[{value:"weekly",label:r("subscriptions.form.cycle_weekly")},{value:"monthly",label:r("subscriptions.form.cycle_monthly")},{value:"yearly",label:r("subscriptions.form.cycle_yearly")}],[$]),xe=p.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[$]),pe=p.useCallback(()=>{c(fe),o(null),g(!1),b(!1),_(!1),s(!0)},[]),F=p.useCallback(x=>{c({plan:x.plan||"",provider:x.provider||"",cycle:x.cycle||"monthly",autoRenew:x.autoRenew,startedAt:Ta(new Date(na(x)).toISOString())}),o(x.id),g(!1),b(!1),_(!1),s(!0)},[]),O=p.useCallback(()=>{s(!1),o(null),c(fe),g(!1),b(!1),_(!1)},[]),f=p.useCallback(async x=>{if(x.preventDefault(),g(!1),!l.provider){b(!0);return}if((t||[]).some(W=>W.provider===l.provider&&W.id!==n)){_(!0);return}const h=new Date(l.startedAt).getTime();if(!Number.isFinite(h)){g(!0);return}const S={service:se(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:h,nextBillingAt:Je(h,l.cycle)};m(!0);try{n?await Da(n,S):await Ma(S),O(),await a?.()}catch{g(!0)}finally{m(!1)}},[O,n,l,a,t]),L=p.useCallback(async()=>{if(j){w(!0),R(!1);try{await Ea(j.id),j.id===n&&O(),M(null),await a?.()}catch{R(!0)}finally{w(!1)}}},[O,n,a,j]),U=t||[],G=()=>{const x=n?U.find(h=>h.id===n):null,N=x?oe(x,H):null;return e.jsxs("form",{ref:Y,onSubmit:f,className:"grid grid-cols-1 gap-3 px-3 py-3 text-left sm:grid-cols-2",children:[e.jsx("div",{className:"flex items-center justify-between sm:col-span-2",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:n?r("subscriptions.edit"):r("subscriptions.add")})}),N?e.jsxs("div",{className:"sm:col-span-2 rounded-md bg-oai-gray-50 dark:bg-oai-gray-800/50 px-2.5 py-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:ae.format(new Date(N.endMs))})," · ",e.jsx("span",{className:N.expired?"text-oai-error":void 0,children:ve(N.endMs,H)})]}):null,e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-provider",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.provider")}),e.jsx(ge,{id:"subscription-provider",value:l.provider,onValueChange:h=>c({...l,provider:String(h)}),options:X,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(Pe,{label:r("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:h=>c({...l,plan:h.target.value})})}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-cycle",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.cycle")}),e.jsx(ge,{id:"subscription-cycle",value:l.cycle,onValueChange:h=>c({...l,cycle:String(h)}),options:me,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-auto-renew",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.auto_renew")}),e.jsx(ge,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:h=>c({...l,autoRenew:h==="true"}),options:xe,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(Pe,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:h=>c({...l,startedAt:h.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[n?e.jsx(Z,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const h=U.find(S=>S.id===n);h&&M(h)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,y?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,v?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,u?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(Z,{type:"button",variant:"secondary",size:"sm",onClick:O,children:r("shared.action.cancel")}),e.jsx(Z,{type:"submit",size:"sm",disabled:d,children:r("subscriptions.save")})]})]})};return e.jsxs("div",{className:"flex max-h-[min(80vh,42rem)] w-[min(92vw,32rem)] flex-col gap-3 overflow-y-auto rounded-xl border border-oai-gray-200 bg-white p-4 shadow-lg dark:border-oai-gray-700 dark:bg-oai-gray-900",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("span",{className:"block truncate text-sm font-semibold text-oai-black dark:text-white",children:r("limits.page.openSubscriptions")})}),e.jsxs(Z,{type:"button",size:"sm",onClick:pe,className:"shrink-0 gap-1.5",children:[e.jsx(Ut,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),U.length===0&&!(i&&!n)?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-700",children:[e.jsx(Ke,{className:"h-6 w-6 text-oai-gray-300 dark:text-oai-gray-600 mb-2","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:r("subscriptions.empty.title")}),e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("subscriptions.empty.body")})]}):e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[U.map(x=>{const N=oe(x,H);if(!N)return null;const{endMs:h,expired:S}=N,W=S?100:N.progress*100,bt=!S&&h-H<=3*864e5,yt=I===x.id;return e.jsxs("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button",onClick:()=>F(x),"aria-label":`${r("subscriptions.edit")} ${x.service}`,"aria-expanded":n===x.id,className:"w-full flex flex-col gap-1.5 px-3 py-2.5 text-left cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ze,{provider:Ue(x.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:x.service}),e.jsx("span",{role:"img","aria-label":x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${x.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:x.autoRenew?e.jsx(Xe,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Ve,{size:14,strokeWidth:2,"aria-hidden":!0})}),x.plan?e.jsx("span",{className:"text-xs rounded-full border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-0.5 text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:x.plan}):null]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:r("subscriptions.inline.label")}),e.jsx("span",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1 overflow-hidden",children:e.jsx("span",{className:`${S?"bg-red-500":bt?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${W}%`,minWidth:W>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${S?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Qe(h,H)})]})]}),n===x.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:G()}):null,n!==x.id&&yt?e.jsxs("div",{className:"px-3 pb-3 flex flex-col gap-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("p",{className:"pt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:ae.format(new Date(h))})," · ",e.jsx("span",{className:S?"text-oai-error":void 0,children:ve(h,H)})," · ",e.jsx("span",{children:x.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Z,{type:"button",variant:"secondary",size:"sm",onClick:()=>F(x),children:r("subscriptions.edit")})})]}):null]},x.id)}),i&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:G()}):null]}),e.jsx(Lt,{open:!!j,title:r("subscriptions.confirm_delete_title"),description:j?.service||"",error:E?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:k,onCancel:()=>{M(null),R(!1)},onConfirm:L})]})}const Fe=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Ia="x-apple.systempreferences:com.apple.preference.notifications";function Oe(t){const a=Date.parse(t);return Number.isFinite(a)?new Intl.DateTimeFormat(B(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(a)):String(t)}function Aa(t){const a=Object.entries(t||{}).filter(([o,l])=>o!=="fetched_at"&&l&&typeof l=="object"&&l.configured!==!1),i=a.filter(([,o])=>!!o.error),s=a.some(([,o])=>!!o.start_plan?.error||!!o.reset_credits?.error),n=a.filter(([,o])=>o.provenance?.stale===!0||o.provenance?.source==="disk-cache");return a.length&&i.length===0&&!s&&n.length===a.length?{kind:"stale"}:i.length||n.length||s?{kind:"partial",at:t.fetched_at}:{kind:"updated",at:t.fetched_at}}function Ha(){const t=qt(),a=Ct(),i=r("limits.alert.blocked"),s=a?Se.button:Se.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>Mt({type:"action",name:"openURL",value:Ia}):void 0,initial:t?!1:{opacity:0,x:14,scale:.9},animate:{opacity:1,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:18},title:i,className:`relative hidden sm:inline-flex min-w-0 max-w-[360px] items-center gap-1.5 rounded-full border border-amber-300/70 bg-amber-50 px-3 py-1.5 text-xs text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300 ${a?"cursor-pointer transition-colors hover:bg-amber-100 dark:hover:bg-amber-500/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/60":""}`,children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"truncate",children:i}),e.jsx("span",{"aria-hidden":!0,className:"absolute left-full top-1/2 -translate-y-1/2 border-[5px] border-transparent border-l-amber-300/80 dark:border-l-amber-500/40"})]})}function cr(){const t=wt(),{data:a,error:i,isLoading:s,refresh:n}=Tt(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),o=At(),l=Rt(),[c,d]=P.useState([]),[m,u]=P.useState(!1),[g,y]=P.useState(!1),[b]=Nt(),v=P.useRef(0),_=P.useRef(!1),[j,M]=P.useState(!1),[k,w]=P.useState(null),E=P.useCallback(async()=>{if(!_.current){_.current=!0,M(!0),w(null);try{const I=await n();w(I?Aa(I):{kind:"failed"})}finally{_.current=!1,M(!1)}}},[n]),R=P.useCallback(async()=>{if(!Fe&&!_e())return;const I=++v.current;try{const V=await Ca();if(I!==v.current)return;d(V),u(!1)}catch{if(I!==v.current)return;u(!0)}},[]);return P.useEffect(()=>{R()},[R]),P.useEffect(()=>{b.get("openSubscriptions")==="1"&&y(!0)},[b]),P.useEffect(()=>{l.enabled&&a&&It(a)},[l.enabled,a]),!Fe&&!_e()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx($t,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-6 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 sm:mb-8 sm:gap-x-4 sm:gap-y-3",children:[e.jsx("h1",{className:"min-w-0 text-2xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white",children:r("nav.limits")}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[l.enabled&&l.permissionBlocked?e.jsx(Ha,{}):null,e.jsx("button",{type:"button",onClick:()=>{E()},disabled:j,"aria-label":r("limits.page.refresh"),title:r("limits.page.refresh"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm:w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50",children:e.jsx(_t,{className:`h-4 w-4 ${j?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(zt,{open:g,onOpenChange:y,children:[e.jsx(Bt,{"aria-label":r("limits.page.openSubscriptions"),title:r("limits.page.openSubscriptions"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm:w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(Ke,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Gt,{children:e.jsx(Wt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Kt,{children:e.jsx(Ra,{subscriptions:c,onChanged:R})})})})]}),e.jsx("button",{type:"button",onClick:()=>{l.setEnabled(!l.enabled)},"aria-label":l.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:l.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:`inline-flex h-10 w-10 sm:h-9 sm:w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 ${l.enabled&&l.permissionBlocked?"text-amber-600 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"}`,children:l.enabled?e.jsx(Yt,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Vt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(St,{to:"/settings?section=limits","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm:w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(Pt,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsx("p",{className:"col-span-2 hidden sm:block sm:text-base text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.page.subtitle")})]}),e.jsx("span",{role:"status",className:"sr-only",children:j?r("limits.page.refresh_loading"):""}),k?.kind==="updated"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-emerald-700 dark:text-emerald-300",children:r("limits.page.refreshed_at",{time:Oe(k.at)})}):null,k?.kind==="partial"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_partial",{time:Oe(k.at)})}):null,k?.kind==="stale"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_stale")}):null,k?.kind==="failed"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_failed")}):null,s?e.jsx(Qt,{}):e.jsxs(e.Fragment,{children:[i?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:i}):null,m?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(Pa,{claude:a?.claude,codex:a?.codex,cursor:a?.cursor,gemini:a?.gemini,kimi:a?.kimi,kiro:a?.kiro,grok:a?.grok,antigravity:a?.antigravity,copilot:a?.copilot,zcode:a?.zcode,opencodeGo:a?.opencodeGo,commandCode:a?.commandCode,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,agentPlan:a?.agentPlan,devin:a?.devin,workbuddy:a?.workbuddy,order:o.order,visibility:o.visibility,displayMode:o.displayMode,subscriptions:c,showSubscriptions:o.showSubscriptions!==!1,onProviderKeySaved:()=>{n()}})]})]})})})}export{cr as LimitsPage};