tokentracker-cli 1.3.3 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +5 -5
- package/README.ja.md +3 -3
- package/README.ko.md +3 -3
- package/README.md +6 -5
- package/README.zh-CN.md +3 -3
- package/THIRD_PARTY_NOTICES.md +92 -0
- package/dashboard/dist/THIRD_PARTY_NOTICES.txt +92 -0
- package/dashboard/dist/assets/AchievementBadge-Dazs3pEa.js +1 -0
- package/dashboard/dist/assets/AchievementsPage-LWnxZvmw.js +2 -0
- package/dashboard/dist/assets/{AchievementsSection-CDUUEfIi.js → AchievementsSection-BLqczmU9.js} +1 -1
- package/dashboard/dist/assets/BadgeDetailModal-B_n4aj2S.js +1 -0
- package/dashboard/dist/assets/{BotAnimated-Dx_vvTtC.js → BotAnimated-KDWI_YcZ.js} +1 -1
- package/dashboard/dist/assets/Card-BYoxd4OC.js +1 -0
- package/dashboard/dist/assets/CloudCheckoutPage-BR2_B03P.js +1 -0
- package/dashboard/dist/assets/CloudPage-DL5RkJKK.js +1 -0
- package/dashboard/dist/assets/CloudUsageExport-C_DqZKo1.js +4 -0
- package/dashboard/dist/assets/CommandPalette-DkCaIQI4.js +1 -0
- package/dashboard/dist/assets/CommunityStatsModal-pX9OePi4.js +1 -0
- package/dashboard/dist/assets/{ConfirmModal-BQ-xB1S_.js → ConfirmModal-tkgZwz4u.js} +1 -1
- package/dashboard/dist/assets/Controls-MTUhGWy8.js +1 -0
- package/dashboard/dist/assets/DashboardPage-SOx-A7lH.js +1 -0
- package/dashboard/dist/assets/DateRangePopover-B-BMOm3O.js +1 -0
- package/dashboard/dist/assets/{DevicePage-Dg6XkIaY.js → DevicePage-DSK9lm7v.js} +1 -1
- package/dashboard/dist/assets/DialogClose-uVUNu4rg.js +1 -0
- package/dashboard/dist/assets/DialogDescription-DBqGGWNj.js +1 -0
- package/dashboard/dist/assets/DialogTitle-B-VifiA3.js +1 -0
- package/dashboard/dist/assets/{FadeIn-ChVf45WW.js → FadeIn-B6lrj4uo.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-B740_G7a.js → HeaderGithubStar-Cx5zOhXa.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-BzP5FudR.js → HoverTooltip-DY1ENf69.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-BuZH3F14.js → IpCheckPage-D6TEq64d.js} +1 -1
- package/dashboard/dist/assets/LandingPage-OdZUfq--.js +2 -0
- package/dashboard/dist/assets/LeaderboardPage-DCK5xcAt.js +2 -0
- package/dashboard/dist/assets/LeaderboardProBadge-CBXJ1u_m.js +1 -0
- package/dashboard/dist/assets/{LeaderboardProfileModal-OUZvO6u-.js → LeaderboardProfileModal-Ccdzb7QK.js} +4 -4
- package/dashboard/dist/assets/{LeaderboardProfilePage-bHI1oTEK.js → LeaderboardProfilePage-CFXlZ0fL.js} +2 -2
- package/dashboard/dist/assets/LimitsPage-5krjm-g9.js +9 -0
- package/dashboard/dist/assets/{LocalOnlyNotice-BaEq6qN7.js → LocalOnlyNotice-Rk1B8PaZ.js} +1 -1
- package/dashboard/dist/assets/LoginCard-DTTIm8vk.js +1 -0
- package/dashboard/dist/assets/LoginModal-BNcDdjfr.js +1 -0
- package/dashboard/dist/assets/LoginPage-CQgXP7Ee.js +1 -0
- package/dashboard/dist/assets/{PetPage-BPBsUHyL.js → PetPage-Cw_kAPRs.js} +1 -1
- package/dashboard/dist/assets/PopoverPopup-NYiGE8A2.js +1 -0
- package/dashboard/dist/assets/{ProviderIcon-BshO2uER.js → ProviderIcon-Bp7iFJ_m.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-RTFTD8Dr.js → ResetPasswordPage-Cf9kAWDW.js} +1 -1
- package/dashboard/dist/assets/Select-kIcvQFAo.js +1 -0
- package/dashboard/dist/assets/SelectItemText-BpIsAg3b.js +1 -0
- package/dashboard/dist/assets/{SelfHostPage-BlwTt8XM.js → SelfHostPage-Ch2vvSwI.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-BkIcJpYK.js → ServiceStatusPage-hoYBvGbu.js} +1 -1
- package/dashboard/dist/assets/SessionsPage-BzRB6q-Z.js +3 -0
- package/dashboard/dist/assets/SessionsPage-GV2fuNmd.css +1 -0
- package/dashboard/dist/assets/SettingsPage-DRl2uX-i.js +2 -0
- package/dashboard/dist/assets/SkillsPage-CkqThTZL.js +1 -0
- package/dashboard/dist/assets/{TokenGalaxy-DiXUpXKF.js → TokenGalaxy-eLG-UIZY.js} +1 -1
- package/dashboard/dist/assets/TooltipPopup-bnMJyilQ.js +1 -0
- package/dashboard/dist/assets/TrendMonitor-X7-aGzIv.js +19 -0
- package/dashboard/dist/assets/WidgetsPage-CGznIzrW.js +1 -0
- package/dashboard/dist/assets/{WrappedPage-ClEo-RmR.js → WrappedPage-p31-uUoF.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-2g_4s3ot.js +45 -0
- package/dashboard/dist/assets/__vite-browser-external-LpFw4zXh.css +1 -0
- package/dashboard/dist/assets/agent-logos-2TVT3fIE.js +1 -0
- package/dashboard/dist/assets/arrow-left-DL0hAp_7.js +1 -0
- package/dashboard/dist/assets/{arrow-right-CwBz5dwb.js → arrow-right-DFCpnV_9.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-jPmRN562.js → arrow-up-right-DLvfE0Wu.js} +1 -1
- package/dashboard/dist/assets/calendar-days-B0aDoKSG.js +1 -0
- package/dashboard/dist/assets/{check-CKwHc4Hv.js → check-C_cfrxiz.js} +1 -1
- package/dashboard/dist/assets/chevron-down-Ck8ml43e.js +1 -0
- package/dashboard/dist/assets/cloud-checkout-PYnwNfdH.js +1 -0
- package/dashboard/dist/assets/composite-INW-ELWX.js +1 -0
- package/dashboard/dist/assets/download-B7uokeIo.js +1 -0
- package/dashboard/dist/assets/{external-link-B5yXxdPy.js → external-link-CI3crg4K.js} +1 -1
- package/dashboard/dist/assets/{flame-CKjAluj_.js → flame-DCzvFKV1.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-mk49THtv.js → format-tokens-CSTEYK2m.js} +1 -1
- package/dashboard/dist/assets/gift-dEHDFMc6.js +1 -0
- package/dashboard/dist/assets/{host-mode-efKlSYjX.js → host-mode-r2SW9Mdv.js} +1 -1
- package/dashboard/dist/assets/{icons-ZB1ZthjH.js → icons-q-3zvEkh.js} +1 -1
- package/dashboard/dist/assets/{index-BImBG3eS.js → index-BV7qwUw4.js} +1 -1
- package/dashboard/dist/assets/{index-BgdM7kBl.js → index-BbrsgHf4.js} +1 -1
- package/dashboard/dist/assets/{index-DweUMAUD.js → index-CyHYj9XI.js} +1 -1
- package/dashboard/dist/assets/info-BBdY9hV4.js +1 -0
- package/dashboard/dist/assets/{link-2-Dn2soiyd.js → link-2-CLPePfXs.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-CNT630zn.js → loader-circle-ETrjzfmn.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-WPx0bc2K.js → modifiers.esm-DHqnp2ol.js} +1 -1
- package/dashboard/dist/assets/module-BNnaKM__.js +3 -0
- package/dashboard/dist/assets/monitor-smartphone-D1kdzrdb.js +1 -0
- package/dashboard/dist/assets/play-Cxp-ronD.js +1 -0
- package/dashboard/dist/assets/plus-4n94VzDK.js +1 -0
- package/dashboard/dist/assets/provider-display-CRlbeO7t.js +42 -0
- package/dashboard/dist/assets/{react-B7SkZTgg.js → react-DlHjGQFN.js} +1 -1
- package/dashboard/dist/assets/safePolygon-CVZ27a2_.js +1 -0
- package/dashboard/dist/assets/{search-Ol3OZBm4.js → search-BDPr56_h.js} +1 -1
- package/dashboard/dist/assets/{server-DFCbznC7.js → server-Bm7fHvVa.js} +1 -1
- package/dashboard/dist/assets/{shield-check-YcmLwVZ6.js → shield-check-DtT8ACzI.js} +1 -1
- package/dashboard/dist/assets/{skills-api-C-9vK884.js → skills-api-Dc1-2qu6.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-CKC9NuR-.js → sortable.esm-B-qN-Xk2.js} +1 -1
- package/dashboard/dist/assets/store-gHeBU8dQ.js +1 -0
- package/dashboard/dist/assets/{terminal-B3_fCLFs.js → terminal-D4VZbvhg.js} +1 -1
- package/dashboard/dist/assets/{trash-CZGfgbFa.js → trash-BZtLAFQy.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-CW-qkYn7.js → use-community-stats-BdqndrbB.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-DHv7vfFE.js → use-latest-request-guard-DhGg1cDS.js} +1 -1
- package/dashboard/dist/assets/use-limits-display-prefs-D3HOcRFv.js +1 -0
- package/dashboard/dist/assets/{use-native-settings-CWiLqfZh.js → use-native-settings-BniKwA_n.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-Df8pw-WJ.js → use-ordered-list-b09H7EHq.js} +1 -1
- package/dashboard/dist/assets/use-pet-settings-CPZdlq_e.js +2 -0
- package/dashboard/dist/assets/use-reduced-motion-D1gcKJUo.js +1 -0
- package/dashboard/dist/assets/{use-transform-BHwEAfmO.js → use-transform-CIdxjmI8.js} +1 -1
- package/dashboard/dist/assets/use-usage-limits-eJlU65yY.js +1 -0
- package/dashboard/dist/assets/{useCurrency-pwClnCZ5.js → useCurrency-CM22CmAq.js} +1 -1
- package/dashboard/dist/assets/usePositioner-B3l2ulTw.js +1 -0
- package/dashboard/dist/assets/{useTokenFormat-BMvVAe6V.js → useTokenFormat-D7nzgxKw.js} +1 -1
- package/dashboard/dist/assets/zap-Daxct1WV.js +1 -0
- package/dashboard/dist/index.html +14 -12
- package/dashboard/dist/ip-check.html +2 -2
- package/dashboard/dist/leaderboard.html +2 -2
- package/dashboard/dist/llms.txt +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +3 -2
- package/src/commands/init.js +43 -1
- package/src/commands/status.js +27 -0
- package/src/commands/sync.js +54 -4
- package/src/commands/uninstall.js +19 -0
- package/src/lib/claude-config.js +47 -15
- package/src/lib/codex-rollout-parser.js +11 -3
- package/src/lib/command-runner.js +15 -1
- package/src/lib/cursor-config.js +2 -1
- package/src/lib/gemini-config.js +3 -2
- package/src/lib/local-api.js +13 -3
- package/src/lib/notify-command.js +38 -0
- package/src/lib/openclaw-session-plugin.js +47 -14
- package/src/lib/passive-mode.js +12 -0
- package/src/lib/pricing/curated-overrides.json +42 -5
- package/src/lib/pricing/matcher.js +14 -5
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +150 -28
- package/src/lib/session-analytics.js +108 -9
- package/src/lib/usage-limits.js +183 -20
- package/src/lib/zcode-limits.js +218 -18
- package/src/lib/zcode-reset-credits.js +66 -0
- package/dashboard/dist/assets/AchievementBadge-BaqdyZaV.js +0 -1
- package/dashboard/dist/assets/AchievementsPage-B4Ju0guv.js +0 -2
- package/dashboard/dist/assets/BadgeDetailModal-B-XMJAvL.js +0 -1
- package/dashboard/dist/assets/Card-D-5mABVt.js +0 -1
- package/dashboard/dist/assets/CloudCheckoutPage-BELoh56h.js +0 -1
- package/dashboard/dist/assets/CloudPage-CfBruNxe.js +0 -1
- package/dashboard/dist/assets/CloudUsageExport-BoFU7xCT.js +0 -4
- package/dashboard/dist/assets/CommandPalette-BmmKZWn-.js +0 -1
- package/dashboard/dist/assets/CommunityStatsModal-BF77zVhN.js +0 -1
- package/dashboard/dist/assets/Controls-BnTeX7T4.js +0 -1
- package/dashboard/dist/assets/DashboardPage-BWulHa5J.js +0 -1
- package/dashboard/dist/assets/DialogClose-DAyilsH-.js +0 -1
- package/dashboard/dist/assets/DialogDescription-j4XnRy6y.js +0 -1
- package/dashboard/dist/assets/DialogTitle-B1iNGD2S.js +0 -1
- package/dashboard/dist/assets/LandingPage-Dtgq_caz.js +0 -2
- package/dashboard/dist/assets/LeaderboardPage-Di1kEg2O.js +0 -2
- package/dashboard/dist/assets/LeaderboardProBadge-h8FfR0au.js +0 -1
- package/dashboard/dist/assets/LimitsPage-DKojB73_.js +0 -8
- package/dashboard/dist/assets/LoginCard-Dn5Xy4If.js +0 -1
- package/dashboard/dist/assets/LoginModal-C5h-5GOA.js +0 -1
- package/dashboard/dist/assets/LoginPage-BpX8Tgjj.js +0 -1
- package/dashboard/dist/assets/PopoverPopup-CVTiEVHs.js +0 -1
- package/dashboard/dist/assets/Select-CtTceC4T.js +0 -1
- package/dashboard/dist/assets/SelectItemText-C7xi8iGp.js +0 -1
- package/dashboard/dist/assets/SessionsPage-BngTWN7Q.css +0 -1
- package/dashboard/dist/assets/SessionsPage-okHobk_L.js +0 -3
- package/dashboard/dist/assets/SettingsPage-C-cc6wcF.js +0 -2
- package/dashboard/dist/assets/SkillsPage-D2LlKKJN.js +0 -1
- package/dashboard/dist/assets/TrendMonitor-C88S-5aa.js +0 -19
- package/dashboard/dist/assets/WidgetsPage-WsEFPNwp.js +0 -1
- package/dashboard/dist/assets/__vite-browser-external-DFRX9dp-.css +0 -1
- package/dashboard/dist/assets/__vite-browser-external-DUJeOWgd.js +0 -45
- package/dashboard/dist/assets/agent-logos-BM9jlReI.js +0 -1
- package/dashboard/dist/assets/arrow-left-BEM-HVmC.js +0 -1
- package/dashboard/dist/assets/cloud-checkout-nYNHDFoR.js +0 -1
- package/dashboard/dist/assets/composite-B4Z3F65o.js +0 -1
- package/dashboard/dist/assets/download-CJUnX1Bs.js +0 -1
- package/dashboard/dist/assets/info-CyDY7NYM.js +0 -1
- package/dashboard/dist/assets/module-WSx8viXK.js +0 -3
- package/dashboard/dist/assets/monitor-smartphone-C-qC0RAt.js +0 -1
- package/dashboard/dist/assets/plus-Cx82jb7o.js +0 -1
- package/dashboard/dist/assets/provider-display-CodMmiRb.js +0 -42
- package/dashboard/dist/assets/safePolygon-CKpREa4K.js +0 -1
- package/dashboard/dist/assets/store-C9yWYHfg.js +0 -1
- package/dashboard/dist/assets/use-limits-display-prefs-NZ-AAYD5.js +0 -1
- package/dashboard/dist/assets/use-pet-settings-Bg2CDprr.js +0 -2
- package/dashboard/dist/assets/use-reduced-motion-iDZEUyua.js +0 -1
- package/dashboard/dist/assets/use-usage-limits-CSxFFn3_.js +0 -1
- package/dashboard/dist/assets/usePositioner-B0j1orGj.js +0 -1
- package/dashboard/dist/assets/zap-DvX2aYx5.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BadgeDetailModal-
|
|
2
|
-
import{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BadgeDetailModal-B_n4aj2S.js","assets/__vite-browser-external-2g_4s3ot.js","assets/__vite-browser-external-LpFw4zXh.css","assets/react-DlHjGQFN.js","assets/AchievementBadge-Dazs3pEa.js","assets/zap-Daxct1WV.js","assets/flame-DCzvFKV1.js","assets/calendar-days-B0aDoKSG.js","assets/shield-check-DtT8ACzI.js","assets/use-transform-CIdxjmI8.js","assets/use-reduced-motion-D1gcKJUo.js","assets/AchievementsSection-BLqczmU9.js","assets/format-tokens-CSTEYK2m.js","assets/DialogTitle-B-VifiA3.js","assets/composite-INW-ELWX.js","assets/store-gHeBU8dQ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as ie,a as W,r as h,aN as ne,j as e,c as i,aO as le,Q as de,U as ce,aP as me,aQ as xe,y as c,x as ge,az as Z,A as pe,L as he,V as G,an as ue,l as fe,ay as be,X as ye,i as ke,_ as je,aR as ve}from"./__vite-browser-external-2g_4s3ot.js";import{A as _e,f as Ne}from"./provider-display-CRlbeO7t.js";import{u as we}from"./useCurrency-CM22CmAq.js";import{u as X}from"./useTokenFormat-D7nzgxKw.js";import{L as Y,a as K}from"./LeaderboardProBadge-CBXJ1u_m.js";import{P as $}from"./ProviderIcon-Bp7iFJ_m.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-Dazs3pEa.js";import{A as Ie}from"./AchievementsSection-BLqczmU9.js";import{A as U}from"./arrow-up-right-DLvfE0Wu.js";import{L as De}from"./link-2-CLPePfXs.js";import{C as Te}from"./check-C_cfrxiz.js";import{D as Be,a as Le,b as $e,c as Ue,d as Re,e as Fe}from"./DialogTitle-B-VifiA3.js";import"./terminal-D4VZbvhg.js";import"./play-Cxp-ronD.js";import"./info-BBdY9hV4.js";import"./TooltipPopup-bnMJyilQ.js";import"./composite-INW-ELWX.js";import"./store-gHeBU8dQ.js";import"./safePolygon-CVZ27a2_.js";import"./usePositioner-B3l2ulTw.js";import"./zap-Daxct1WV.js";import"./flame-DCzvFKV1.js";import"./calendar-days-B0aDoKSG.js";import"./shield-check-DtT8ACzI.js";import"./react-DlHjGQFN.js";import"./format-tokens-CSTEYK2m.js";import"./use-reduced-motion-D1gcKJUo.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
3
|
@keyframes tt-like-pop {
|
|
4
4
|
0% { transform: scale(1); }
|
|
5
5
|
25% { transform: scale(0.75); }
|
|
@@ -39,7 +39,7 @@ import{A as oe,a as E,r as h,as as ie,j as e,c as i,at as ne,a3 as le,a5 as de,a
|
|
|
39
39
|
.tt-num-anim {
|
|
40
40
|
animation: tt-num-scroll 0.25s ease-out forwards;
|
|
41
41
|
}
|
|
42
|
-
`}}),
|
|
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-B_n4aj2S.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
43
|
@keyframes tt-shimmer {
|
|
44
44
|
100% { transform: translateX(100%); }
|
|
45
45
|
}
|
|
@@ -70,4 +70,4 @@ import{A as oe,a as E,r as h,as as ie,j as e,c as i,at as ne,a3 as le,a5 as de,a
|
|
|
70
70
|
rgba(255, 255, 255, 0) 100%
|
|
71
71
|
);
|
|
72
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 V(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 T({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=V(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(G,{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(X,{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(B,{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(be,{size:16,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:rotate-90 group-active:scale-90"})})]})}function qe({user:a,topBadge:r}){const o=V(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(Oe,{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(X,{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(B,{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 Ve({data:a}){const{formatTokens:r,formatTokensTooltip:o}=Z(),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 l=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(B,{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:_e(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:`${(l*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:[(l*100).toFixed(0),"%"]})]},s.source)})})}function O({icon:a,label:r,value:o}){const[t,s]=h.useState(!1),l=async()=>{await je(o)&&(s(!0),setTimeout(()=>s(!1),1600))};return e.jsxs("button",{type:"button",onClick:l,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 Je({data:a,currency:r,rate:o,onClose:t,variant:s="modal"}){const{formatTokens:l,formatTokensTooltip:g}=Z(),{user:n,totals:x,streak:u,best_day:f,models:S,by_provider:M,heatmap:z,period:I}=a,j=s==="page",N=h.useMemo(()=>Ge(z),[z]),P=S?.favorite?.model_name,y=Number(S?.count)||0,k=Array.isArray(a.badges)?a.badges:[],[_,w]=h.useState(null),d=E(),m=!!(d?.user?.id&&n?.user_id&&d.user.id===n.user_id),p=n?.user_id?`https://www.tokentracker.cc/u/${n.user_id}`:null,b=n?.user_id?`[}/functions/tokentracker-embed-svg?user_id=${n.user_id}&theme=dark)](${p}?ref=readme)`:null;return e.jsxs(e.Fragment,{children:[j?e.jsx(qe,{user:n,topBadge:Ce(k)}):e.jsx(Ke,{user:n,onClose:t}),e.jsxs("div",{className:c("space-y-6",j?"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:l(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:f?e.jsxs(e.Fragment,{children:[e.jsx("span",{title:g(f.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:l(f.total_tokens)}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["on ",f.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:P?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:P}),y>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:y})})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:i("leaderboard.profile_modal.models.none")})})]}),(m||k.some(v=>(v?.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(T,{children:i("achievements.section.title")}),j?e.jsx(De,{achievements:k,isOwn:m&&!!a.badges_include_unearned,scope:"cloud",onSelect:w}):e.jsx(Ee,{badges:k,isOwn:m&&!!a.badges_include_unearned,onSelect:w})]}),N&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(T,{children:i("leaderboard.profile_modal.heatmap.title")}),e.jsx("div",{className:"min-w-0",children:e.jsx(Ne,{heatmap:N,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(T,{children:i("leaderboard.profile_modal.providers.title")}),e.jsx(Ve,{data:M})]}),n?.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&&(ge()?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($,{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(pe,{to:`/u/${n.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($,{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(O,{icon:Ie,label:i("leaderboard.profile_modal.badge.copy_url"),value:p}),e.jsx(O,{icon:He,label:i("leaderboard.profile_modal.badge.copy"),value:b})]})]})]}),_&&e.jsx(W.Suspense,{fallback:null,children:e.jsx(We,{badge:_,onClose:()=>w(null)})})]})}function Qe({userId:a,period:r,accessToken:o,enabled:t=!0}){const[s,l]=h.useState({loading:!1,error:null,data:null}),g=h.useMemo(()=>le(),[]),n=h.useMemo(()=>de(),[]);return h.useEffect(()=>{if(!t||!a)return;let x=!0;return l({loading:!0,error:null,data:null}),(async()=>{try{const u=o?await ce(o):null;if(!x)return;const f=await me({accessToken:u,userId:a,period:r||"week",timeZone:g,tzOffsetMinutes:n});if(!x)return;l({loading:!1,error:null,data:f})}catch(u){if(!x)return;u?.status===404?l({loading:!1,error:null,data:null}):l({loading:!1,error:u?.message||String(u),data:null})}})(),()=>{x=!1}},[t,a,r,o,g,n]),s}function _a({isOpen:a,onClose:r,userId:o,period:t,accessToken:s}){const{currency:l,rate:g}=we(),n=Qe({userId:o,period:t,accessToken:s,enabled:a});return e.jsx(Le,{open:a,onOpenChange:x=>{x||r?.()},children:e.jsxs(Be,{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(Fe,{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(Re,{render:e.jsx("h2",{className:"sr-only"}),children:n.data?.user?.display_name||i("leaderboard.profile_modal.loading")}),n.loading&&e.jsx(Ye,{}),!n.loading&&n.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")})}),!n.loading&&!n.error&&!n.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")})}),!n.loading&&!n.error&&n.data&&e.jsx(he,{mode:ue.COMPACT,children:e.jsx(Je,{data:n.data,currency:l,rate:g,onClose:r})})]})})]})})}export{_a as LeaderboardProfileModal,Je as ProfileContent,Ye as ProfileSkeleton,Qe as useLeaderboardProfileData};
|
|
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?`[}/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,4 +1,4 @@
|
|
|
1
|
-
import{r as _,j as p,
|
|
1
|
+
import{r as _,j as p,ao as xe,u as ge,a as ve,A as be,L as Tt,ap as we,c as Y,aq as ye}from"./__vite-browser-external-2g_4s3ot.js";import{u as ke}from"./useCurrency-CM22CmAq.js";import{H as Me}from"./HeaderGithubStar-Cx5zOhXa.js";import{useLeaderboardProfileData as _e,ProfileSkeleton as Ce,ProfileContent as Se}from"./LeaderboardProfileModal-Ccdzb7QK.js";import{D as Te}from"./download-B7uokeIo.js";import"./provider-display-CRlbeO7t.js";import"./useTokenFormat-D7nzgxKw.js";import"./terminal-D4VZbvhg.js";import"./play-Cxp-ronD.js";import"./info-BBdY9hV4.js";import"./LeaderboardProBadge-CBXJ1u_m.js";import"./TooltipPopup-bnMJyilQ.js";import"./composite-INW-ELWX.js";import"./store-gHeBU8dQ.js";import"./safePolygon-CVZ27a2_.js";import"./usePositioner-B3l2ulTw.js";import"./ProviderIcon-Bp7iFJ_m.js";import"./AchievementBadge-Dazs3pEa.js";import"./zap-Daxct1WV.js";import"./flame-DCzvFKV1.js";import"./calendar-days-B0aDoKSG.js";import"./shield-check-DtT8ACzI.js";import"./AchievementsSection-BLqczmU9.js";import"./react-DlHjGQFN.js";import"./format-tokens-CSTEYK2m.js";import"./use-reduced-motion-D1gcKJUo.js";import"./arrow-up-right-DLvfE0Wu.js";import"./link-2-CLPePfXs.js";import"./check-C_cfrxiz.js";import"./DialogTitle-B-VifiA3.js";function $e(t){let e=t.replace("#","");return e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255]}function Re(t,e,a){t/=255,e/=255,a/=255;const r=Math.max(t,e,a),o=Math.min(t,e,a),n=r-o;let i=0;const u=r===0?0:n/r;return n!==0&&(r===t?i=((e-a)/n+6)%6:r===e?i=(a-t)/n+2:i=(t-e)/n+4,i/=6),[i,u,r]}function Fe(t,e,a){const r=Math.floor(t*6),o=t*6-r,n=a*(1-e),i=a*(1-o*e),u=a*(1-(1-o)*e);let l=0,c=0,h=0;switch(r%6){case 0:l=a,c=u,h=n;break;case 1:l=i,c=a,h=n;break;case 2:l=n,c=a,h=u;break;case 3:l=n,c=i,h=a;break;case 4:l=u,c=n,h=a;break;case 5:l=a,c=n,h=i;break}return[Math.round(l*255),Math.round(c*255),Math.round(h*255)]}const Ie=66,Oe=66,Pe=1500,Ae=1,$t=16,je=16,Ee=8,Le=96,Ne=2,We={name:"chromatic",modes:{dark:{colors:["#000000","#aae8ff","#c5fe9e","#f7888d","#0d0d0d","#fffdc3","#007cff"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:1.6,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.26,vigOpacity:.6,shaderOpacity:1},light:{colors:["#ffffff","#ffffff","#ffffff","#ffb3b3","#adadad","#f5ff70","#007cff"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.24,vigOpacity:.16,shaderOpacity:1}}},Be={name:"silver",modes:{dark:{colors:["#000000","#dedede","#747270","#e5e5e5","#0d0d0d","#ffffff","#e6e6e6"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.26,vigOpacity:.6,shaderOpacity:.88},light:{colors:["#f6f6f6","#ffffff","#ffffff","#f7f7f7","#c9c9c9","#d0d0d0","#d1d1d1"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.2,vigOpacity:.26,shaderOpacity:1}}},ze={name:"gold",modes:{dark:{colors:["#000000","#ffffff","#ffffff","#f7d488","#0d0d0d","#fffdc3","#ffffff"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.26,vigOpacity:.6,shaderOpacity:.92},light:{colors:["#fff8e1","#fffbe0","#ffffff","#fff6d6","#d2c7a7","#dcd2bc","#f9f7e5"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.22,vigOpacity:.24,shaderOpacity:1}}},Xt={chromatic:We,silver:Be,gold:ze},He=`
|
|
2
2
|
attribute vec2 a_position;
|
|
3
3
|
void main() { gl_Position = vec4(a_position, 0.0, 1.0); }
|
|
4
4
|
`,Ge=`
|
|
@@ -418,4 +418,4 @@ import{r as _,j as p,ak as xe,u as ge,a as ve,P as be,L as Tt,al as we,c as Y,am
|
|
|
418
418
|
[data-metal-fx-reflect-host] {
|
|
419
419
|
isolation: isolate;
|
|
420
420
|
}
|
|
421
|
-
`;let vt=!1;function dr(){if(vt||typeof document>"u")return;if(document.getElementById(Vt)){vt=!0;return}const t=document.createElement("style");t.id=Vt,t.textContent=cr,document.head.appendChild(t),vt=!0}dr();const ur={position:"absolute",inset:0,width:"100%",height:"100%"},hr={position:"absolute",inset:3},fr={position:"absolute",inset:0,pointerEvents:"none",zIndex:3,borderRadius:"inherit"},ct=new Map;aa((t,e)=>{const a=ct.get(t);a&&Pa(a.handles,t,e,t.opacityMul,a.themeRef.current)});function pr(t){const[e,a]=_.useState(()=>t!=="auto"?t:typeof window>"u"||!window.matchMedia||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return _.useEffect(()=>{if(t!=="auto"){a(t);return}if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>a(r.matches?"dark":"light");return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[t]),e}const he=_.forwardRef(function({children:t,variant:e="button",preset:a="chromatic",theme:r="auto",strength:o=1,paused:n=!1,borderRadius:i,normalizeHostStyles:u=!0,reflectionTargets:l,disableGlow:c=!1,shaderScale:h,ringCssPx:f,scale:d=1,className:g,style:x,...m},F){const b=_.useRef(null),P=_.useRef(null),j=_.useRef(null),L=_.useRef(null),C=_.useRef(null),E=_.useRef(null),z=_.useRef("dark"),X=_.useRef(0),[N,$]=_.useState(!1),k=pr(r);z.current=k;const I=e==="circle"?"circle":"pill",W=!c;_.useImperativeHandle(F,()=>b.current,[]);const B=(y,w)=>{if(I==="circle")return Math.min(y,w)/2;const v=typeof i=="number"?i:(()=>{var M;const S=(M=L.current)==null?void 0:M.firstElementChild;if(S){const O=parseFloat(getComputedStyle(S).borderTopLeftRadius);if(Number.isFinite(O)&&O>0)return O}return X.current})();return Math.min(v,Math.min(y,w)/2)};_.useEffect(()=>{ea(a,k)},[a,k]),_.useEffect(()=>{const y=C.current;y&&rt(y,{paused:n})},[n]),_.useEffect(()=>{const y=C.current;if(!y)return;const w={};h!==void 0&&(w.shaderScale=h),f!==void 0&&(w.ringCssPx=f),d!==void 0&&(w.scale=d),Object.keys(w).length>0&&rt(y,w)},[h,f,d]),_.useLayoutEffect(()=>{const y=P.current,w=b.current,v=j.current;if(!y||!w)return;{const T=getComputedStyle(w),A=parseFloat(T.borderTopLeftRadius);X.current=Number.isFinite(A)?A:0}const M=()=>{const T=w.getBoundingClientRect(),A=Math.max(1,Math.round(T.width)),Q=Math.max(1,Math.round(T.height));return{cssWidth:A,cssHeight:Q,cornerRadius:B(A,Q)}},S=M();C.current=Ye({hostCanvas:y,cssWidth:S.cssWidth,cssHeight:S.cssHeight,cornerRadius:S.cornerRadius,kind:I,paused:n,shaderScale:h,ringCssPx:f,scale:d,onFirstCopy:()=>$(!0)}),w.style.setProperty("--mfx-radius",`${S.cornerRadius}px`),w.style.borderRadius=`${S.cornerRadius}px`,v&&(E.current=zt(v,{width:S.cssWidth,height:S.cssHeight,cornerRadius:S.cornerRadius,kind:I,scale:d}));let O=0;const D=new ResizeObserver(()=>{O===0&&(O=requestAnimationFrame(()=>{O=0;const T=M(),A=C.current;A&&(rt(A,{cssWidth:T.cssWidth,cssHeight:T.cssHeight,cornerRadius:T.cornerRadius}),w.style.setProperty("--mfx-radius",`${T.cornerRadius}px`),w.style.borderRadius=`${T.cornerRadius}px`,v&&(v.innerHTML="",E.current=zt(v,{width:T.cssWidth,height:T.cssHeight,cornerRadius:T.cornerRadius,kind:I,scale:d}),A&&E.current&&ct.set(A,{handles:E.current,themeRef:z})))}))});D.observe(w);let U=null;return typeof IntersectionObserver<"u"&&(U=new IntersectionObserver(T=>{const A=C.current;if(A)for(const Q of T)ta(A,Q.isIntersecting)},{rootMargin:"64px"}),U.observe(w)),C.current&&E.current&&(ct.set(C.current,{handles:E.current,themeRef:z}),Ze(C.current)),()=>{D.disconnect(),U?.disconnect(),O!==0&&cancelAnimationFrame(O);const T=C.current;T&&(ct.delete(T),Je(T),Ke(T)),C.current=null,E.current=null,v&&(v.innerHTML="")}},[I]),_.useEffect(()=>{const y=C.current;y&&rt(y,{opacityMul:Math.max(0,Math.min(1,o))})},[o,e]),_.useEffect(()=>{const y=C.current,w=b.current;if(!y||!w||!l||k!=="dark")return;y.onAfterFrame=lr;const v=l.flatMap(M=>M.current?[M.current]:[]);for(const M of v)nr(M,y,w);return()=>{y.onAfterFrame=void 0;for(const M of v)ir(M)}},[l,k]),_.useEffect(()=>{const y=b.current,w=C.current;if(!y||!w)return;const v=B(w.cssWidth,w.cssHeight);rt(w,{cornerRadius:v}),y.style.setProperty("--mfx-radius",`${v}px`),y.style.borderRadius=`${v}px`},[i,k,e,I]);const H=_.useMemo(()=>({...x,"--mfx-strength":String(Math.min(1,Math.max(0,o))),opacity:N?1:0,visibility:N?"visible":"hidden",transition:N?"opacity 0.15s ease-out":"none"}),[x,o,N]);return p.jsxs("div",{...m,ref:b,className:g?`metal-fx-root ${g}`:"metal-fx-root","data-variant":e,"data-shape":I,"data-theme":k,"data-paused":n?"true":void 0,"data-normalize":u?"true":"false",style:H,children:[p.jsx("canvas",{ref:P,className:"metal-fx-canvas",style:ur}),p.jsx("div",{className:"metal-fx-inner","aria-hidden":"true",style:hr}),p.jsx("div",{ref:j,"aria-hidden":"true",style:{...fr,display:W?void 0:"none"}}),p.jsx("div",{ref:L,className:"metal-fx-content",children:t})]})});he.displayName="MetalFx";const et=18;function fe(){return p.jsxs("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"4"}),p.jsx("path",{d:"M12 2v2"}),p.jsx("path",{d:"M12 20v2"}),p.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),p.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),p.jsx("path",{d:"M2 12h2"}),p.jsx("path",{d:"M20 12h2"}),p.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),p.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function pe(){return p.jsx("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function mr(){return p.jsxs("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),p.jsx("path",{d:"M8 21h8"}),p.jsx("path",{d:"M12 17v4"})]})}const xr=[{value:"light",label:"Light",Icon:fe},{value:"dark",label:"Dark",Icon:pe},{value:"system",label:"System",Icon:mr}];function gr(t){return t==="dark"?pe:fe}function vr({theme:t,resolvedTheme:e,onSetTheme:a,className:r="",direction:o="down",align:n="right"}){const[i,u]=_.useState(!1),l=_.useRef(null),c=_.useCallback(()=>u(!1),[]);_.useEffect(()=>{if(!i)return;const f=d=>{l.current&&!l.current.contains(d.target)&&c()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i,c]),_.useEffect(()=>{if(!i)return;const f=d=>{d.key==="Escape"&&c()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[i,c]);const h=gr(e);return p.jsxs("div",{ref:l,className:`relative ${r}`,children:[p.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":i,onClick:()=>u(f=>!f),className:"flex items-center justify-center w-9 h-9 rounded-lg 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",children:p.jsx(h,{})}),i&&p.jsx("div",{className:`absolute z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg ${o==="up"?"bottom-full mb-1":"top-full mt-1"} ${n==="left"?"left-0":"right-0"}`,children:xr.map(({value:f,label:d,Icon:g})=>{const x=t===f;return p.jsxs("button",{type:"button",onClick:()=>{a(f),c()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-sm transition-colors ${x?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"}`,children:[p.jsx(g,{}),p.jsx("span",{children:d})]},f)})})]})}const br="https://github.com/xiufengsun/TokenTracker/releases/latest";function Qr({auth:t,signedIn:e,sessionSoftExpired:a,userId:r}){const{currency:o,rate:n}=ke(),{theme:i,resolvedTheme:u,setTheme:l}=xe(),{openLoginModal:c}=ge(),{signedIn:h,loading:f}=ve(),d=!be(),g=e&&!a,x=_.useMemo(()=>g&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,g]),m=_e({userId:r,period:"total",accessToken:x});return p.jsxs("div",{className:"flex flex-col min-h-screen bg-oai-gray-50 dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-oai antialiased transition-colors duration-200",children:[p.jsx("header",{className:"sticky top-0 z-50 w-full px-4 pt-4 pb-2 transition-all duration-300 pointer-events-none",children:p.jsxs("div",{className:"mx-auto max-w-3xl rounded-2xl border border-oai-gray-200/50 dark:border-white/10 bg-white/75 dark:bg-oai-gray-950/60 backdrop-blur-xl shadow-[0_8px_30px_rgb(0,0,0,0.04)] dark:shadow-[0_8px_30px_rgb(0,0,0,0.3)] flex h-14 items-center justify-between px-3 sm:px-4 pointer-events-auto transition-all duration-300",children:[p.jsxs("div",{className:"flex items-center gap-4",children:[p.jsxs(Tt,{to:"/",className:"flex items-center gap-3 no-underline outline-none rounded-md focus-visible:ring-2 focus-visible:ring-indigo-500 transition-opacity hover:opacity-80 active:scale-95",children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),p.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),p.jsx("div",{className:"hidden sm:block scale-90 origin-left opacity-90 hover:opacity-100 transition-opacity",children:p.jsx(Me,{})})]}),p.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[p.jsxs(Tt,{to:"/leaderboard",className:"group no-underline inline-flex items-center gap-1.5 h-8 px-3 text-xs font-bold rounded-full border border-oai-gray-200 dark:border-white/10 bg-transparent text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-white/5 hover:text-oai-black dark:hover:text-white transition-all duration-200 active:scale-95 shadow-sm",children:[p.jsx(we,{size:13,strokeWidth:2.5,"aria-hidden":!0,className:"transition-transform duration-150 ease-out group-hover:scale-110 group-hover:rotate-6"}),p.jsx("span",{children:Y("leaderboard.profile.nav.back")})]}),d&&p.jsx(he,{variant:"button",preset:"chromatic",theme:"dark",borderRadius:9999,disableGlow:!0,className:"!bg-black",children:p.jsxs("a",{href:br,target:"_blank",rel:"noopener noreferrer",className:"group no-underline inline-flex h-8 items-center gap-1.5 px-3 text-xs font-bold rounded-full bg-black text-white transition-transform duration-200 active:scale-[0.98]",children:[p.jsx(Te,{size:13,strokeWidth:2.5,"aria-hidden":!0,className:"transition-transform duration-150 ease-out group-hover:translate-y-0.5"}),p.jsx("span",{className:"hidden sm:inline",children:Y("leaderboard.profile.nav.download")})]})}),f?p.jsx("div",{className:"h-8 w-16 animate-pulse rounded-full bg-oai-gray-200 dark:bg-white/10","aria-hidden":!0}):h?p.jsx(ye,{}):p.jsx("button",{type:"button",onClick:c,className:"inline-flex h-8 min-w-[76px] items-center justify-center px-3 text-xs font-bold rounded-full border border-oai-gray-200 dark:border-white/10 bg-transparent text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-white/5 hover:text-oai-black dark:hover:text-white transition-all duration-200 active:scale-95 shadow-sm select-none",children:Y("header.auth.sign_in_aria")})]})]})}),p.jsx("main",{className:"flex-1 px-4 pt-4 pb-10 sm:pt-6 sm:pb-16",children:p.jsx("div",{className:"mx-auto max-w-3xl",children:p.jsxs("div",{className:"rounded-2xl bg-white dark:bg-oai-gray-950 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden shadow-sm dark:shadow-none",children:[m.loading&&p.jsx(Ce,{variant:"page"}),!m.loading&&m.error&&p.jsx("div",{className:"px-6 py-16 text-center",children:p.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:Y("leaderboard.profile_modal.error")})}),!m.loading&&!m.error&&!m.data&&p.jsx("div",{className:"px-6 py-16 text-center",children:p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:Y("leaderboard.profile_modal.empty")})}),!m.loading&&!m.error&&m.data&&p.jsx(Se,{data:m.data,currency:o,rate:n,variant:"page"})]})})}),p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 px-4 transition-colors duration-200",children:p.jsxs("div",{className:"mx-auto flex max-w-3xl items-center justify-between text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[p.jsx("p",{children:Y("landing.v2.footer.line")}),p.jsx(vr,{theme:i,resolvedTheme:u,onSetTheme:l,direction:"up",align:"right"})]})})]})}export{Qr as LeaderboardProfilePage};
|
|
421
|
+
`;let vt=!1;function dr(){if(vt||typeof document>"u")return;if(document.getElementById(Vt)){vt=!0;return}const t=document.createElement("style");t.id=Vt,t.textContent=cr,document.head.appendChild(t),vt=!0}dr();const ur={position:"absolute",inset:0,width:"100%",height:"100%"},hr={position:"absolute",inset:3},fr={position:"absolute",inset:0,pointerEvents:"none",zIndex:3,borderRadius:"inherit"},ct=new Map;aa((t,e)=>{const a=ct.get(t);a&&Pa(a.handles,t,e,t.opacityMul,a.themeRef.current)});function pr(t){const[e,a]=_.useState(()=>t!=="auto"?t:typeof window>"u"||!window.matchMedia||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return _.useEffect(()=>{if(t!=="auto"){a(t);return}if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>a(r.matches?"dark":"light");return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[t]),e}const he=_.forwardRef(function({children:t,variant:e="button",preset:a="chromatic",theme:r="auto",strength:o=1,paused:n=!1,borderRadius:i,normalizeHostStyles:u=!0,reflectionTargets:l,disableGlow:c=!1,shaderScale:h,ringCssPx:f,scale:d=1,className:g,style:x,...m},F){const b=_.useRef(null),P=_.useRef(null),j=_.useRef(null),L=_.useRef(null),C=_.useRef(null),E=_.useRef(null),z=_.useRef("dark"),X=_.useRef(0),[N,$]=_.useState(!1),k=pr(r);z.current=k;const I=e==="circle"?"circle":"pill",W=!c;_.useImperativeHandle(F,()=>b.current,[]);const B=(y,w)=>{if(I==="circle")return Math.min(y,w)/2;const v=typeof i=="number"?i:(()=>{var M;const S=(M=L.current)==null?void 0:M.firstElementChild;if(S){const O=parseFloat(getComputedStyle(S).borderTopLeftRadius);if(Number.isFinite(O)&&O>0)return O}return X.current})();return Math.min(v,Math.min(y,w)/2)};_.useEffect(()=>{ea(a,k)},[a,k]),_.useEffect(()=>{const y=C.current;y&&rt(y,{paused:n})},[n]),_.useEffect(()=>{const y=C.current;if(!y)return;const w={};h!==void 0&&(w.shaderScale=h),f!==void 0&&(w.ringCssPx=f),d!==void 0&&(w.scale=d),Object.keys(w).length>0&&rt(y,w)},[h,f,d]),_.useLayoutEffect(()=>{const y=P.current,w=b.current,v=j.current;if(!y||!w)return;{const T=getComputedStyle(w),A=parseFloat(T.borderTopLeftRadius);X.current=Number.isFinite(A)?A:0}const M=()=>{const T=w.getBoundingClientRect(),A=Math.max(1,Math.round(T.width)),Q=Math.max(1,Math.round(T.height));return{cssWidth:A,cssHeight:Q,cornerRadius:B(A,Q)}},S=M();C.current=Ye({hostCanvas:y,cssWidth:S.cssWidth,cssHeight:S.cssHeight,cornerRadius:S.cornerRadius,kind:I,paused:n,shaderScale:h,ringCssPx:f,scale:d,onFirstCopy:()=>$(!0)}),w.style.setProperty("--mfx-radius",`${S.cornerRadius}px`),w.style.borderRadius=`${S.cornerRadius}px`,v&&(E.current=zt(v,{width:S.cssWidth,height:S.cssHeight,cornerRadius:S.cornerRadius,kind:I,scale:d}));let O=0;const D=new ResizeObserver(()=>{O===0&&(O=requestAnimationFrame(()=>{O=0;const T=M(),A=C.current;A&&(rt(A,{cssWidth:T.cssWidth,cssHeight:T.cssHeight,cornerRadius:T.cornerRadius}),w.style.setProperty("--mfx-radius",`${T.cornerRadius}px`),w.style.borderRadius=`${T.cornerRadius}px`,v&&(v.innerHTML="",E.current=zt(v,{width:T.cssWidth,height:T.cssHeight,cornerRadius:T.cornerRadius,kind:I,scale:d}),A&&E.current&&ct.set(A,{handles:E.current,themeRef:z})))}))});D.observe(w);let U=null;return typeof IntersectionObserver<"u"&&(U=new IntersectionObserver(T=>{const A=C.current;if(A)for(const Q of T)ta(A,Q.isIntersecting)},{rootMargin:"64px"}),U.observe(w)),C.current&&E.current&&(ct.set(C.current,{handles:E.current,themeRef:z}),Ze(C.current)),()=>{D.disconnect(),U?.disconnect(),O!==0&&cancelAnimationFrame(O);const T=C.current;T&&(ct.delete(T),Je(T),Ke(T)),C.current=null,E.current=null,v&&(v.innerHTML="")}},[I]),_.useEffect(()=>{const y=C.current;y&&rt(y,{opacityMul:Math.max(0,Math.min(1,o))})},[o,e]),_.useEffect(()=>{const y=C.current,w=b.current;if(!y||!w||!l||k!=="dark")return;y.onAfterFrame=lr;const v=l.flatMap(M=>M.current?[M.current]:[]);for(const M of v)nr(M,y,w);return()=>{y.onAfterFrame=void 0;for(const M of v)ir(M)}},[l,k]),_.useEffect(()=>{const y=b.current,w=C.current;if(!y||!w)return;const v=B(w.cssWidth,w.cssHeight);rt(w,{cornerRadius:v}),y.style.setProperty("--mfx-radius",`${v}px`),y.style.borderRadius=`${v}px`},[i,k,e,I]);const H=_.useMemo(()=>({...x,"--mfx-strength":String(Math.min(1,Math.max(0,o))),opacity:N?1:0,visibility:N?"visible":"hidden",transition:N?"opacity 0.15s ease-out":"none"}),[x,o,N]);return p.jsxs("div",{...m,ref:b,className:g?`metal-fx-root ${g}`:"metal-fx-root","data-variant":e,"data-shape":I,"data-theme":k,"data-paused":n?"true":void 0,"data-normalize":u?"true":"false",style:H,children:[p.jsx("canvas",{ref:P,className:"metal-fx-canvas",style:ur}),p.jsx("div",{className:"metal-fx-inner","aria-hidden":"true",style:hr}),p.jsx("div",{ref:j,"aria-hidden":"true",style:{...fr,display:W?void 0:"none"}}),p.jsx("div",{ref:L,className:"metal-fx-content",children:t})]})});he.displayName="MetalFx";const et=18;function fe(){return p.jsxs("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"4"}),p.jsx("path",{d:"M12 2v2"}),p.jsx("path",{d:"M12 20v2"}),p.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),p.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),p.jsx("path",{d:"M2 12h2"}),p.jsx("path",{d:"M20 12h2"}),p.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),p.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function pe(){return p.jsx("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function mr(){return p.jsxs("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),p.jsx("path",{d:"M8 21h8"}),p.jsx("path",{d:"M12 17v4"})]})}const xr=[{value:"light",label:"Light",Icon:fe},{value:"dark",label:"Dark",Icon:pe},{value:"system",label:"System",Icon:mr}];function gr(t){return t==="dark"?pe:fe}function vr({theme:t,resolvedTheme:e,onSetTheme:a,className:r="",direction:o="down",align:n="right"}){const[i,u]=_.useState(!1),l=_.useRef(null),c=_.useCallback(()=>u(!1),[]);_.useEffect(()=>{if(!i)return;const f=d=>{l.current&&!l.current.contains(d.target)&&c()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i,c]),_.useEffect(()=>{if(!i)return;const f=d=>{d.key==="Escape"&&c()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[i,c]);const h=gr(e);return p.jsxs("div",{ref:l,className:`relative ${r}`,children:[p.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":i,onClick:()=>u(f=>!f),className:"flex items-center justify-center w-9 h-9 rounded-lg 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",children:p.jsx(h,{})}),i&&p.jsx("div",{className:`absolute z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg ${o==="up"?"bottom-full mb-1":"top-full mt-1"} ${n==="left"?"left-0":"right-0"}`,children:xr.map(({value:f,label:d,Icon:g})=>{const x=t===f;return p.jsxs("button",{type:"button",onClick:()=>{a(f),c()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-sm transition-colors ${x?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"}`,children:[p.jsx(g,{}),p.jsx("span",{children:d})]},f)})})]})}const br="https://github.com/xiufengsun/TokenTracker/releases/latest";function Yr({auth:t,signedIn:e,sessionSoftExpired:a,userId:r}){const{currency:o,rate:n}=ke(),{theme:i,resolvedTheme:u,setTheme:l}=xe(),{openLoginModal:c}=ge(),{signedIn:h,loading:f}=ve(),d=!be(),g=e&&!a,x=_.useMemo(()=>g&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,g]),m=_e({userId:r,period:"total",accessToken:x});return p.jsxs("div",{className:"flex flex-col min-h-screen bg-oai-gray-50 dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-oai antialiased transition-colors duration-200",children:[p.jsx("header",{className:"sticky top-0 z-50 w-full px-4 pt-4 pb-2 transition-all duration-300 pointer-events-none",children:p.jsxs("div",{className:"mx-auto max-w-3xl rounded-2xl border border-oai-gray-200/50 dark:border-white/10 bg-white/75 dark:bg-oai-gray-950/60 backdrop-blur-xl shadow-[0_8px_30px_rgb(0,0,0,0.04)] dark:shadow-[0_8px_30px_rgb(0,0,0,0.3)] flex h-14 items-center justify-between px-3 sm:px-4 pointer-events-auto transition-all duration-300",children:[p.jsxs("div",{className:"flex items-center gap-4",children:[p.jsxs(Tt,{to:"/",className:"flex items-center gap-3 no-underline outline-none rounded-md focus-visible:ring-2 focus-visible:ring-indigo-500 transition-opacity hover:opacity-80 active:scale-95",children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),p.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),p.jsx("div",{className:"hidden sm:block scale-90 origin-left opacity-90 hover:opacity-100 transition-opacity",children:p.jsx(Me,{})})]}),p.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[p.jsxs(Tt,{to:"/leaderboard",className:"group no-underline inline-flex items-center gap-1.5 h-8 px-3 text-xs font-bold rounded-full border border-oai-gray-200 dark:border-white/10 bg-transparent text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-white/5 hover:text-oai-black dark:hover:text-white transition-all duration-200 active:scale-95 shadow-sm",children:[p.jsx(we,{size:13,strokeWidth:2.5,"aria-hidden":!0,className:"transition-transform duration-150 ease-out group-hover:scale-110 group-hover:rotate-6"}),p.jsx("span",{children:Y("leaderboard.profile.nav.back")})]}),d&&p.jsx(he,{variant:"button",preset:"chromatic",theme:"dark",borderRadius:9999,disableGlow:!0,className:"!bg-black",children:p.jsxs("a",{href:br,target:"_blank",rel:"noopener noreferrer",className:"group no-underline inline-flex h-8 items-center gap-1.5 px-3 text-xs font-bold rounded-full bg-black text-white transition-transform duration-200 active:scale-[0.98]",children:[p.jsx(Te,{size:13,strokeWidth:2.5,"aria-hidden":!0,className:"transition-transform duration-150 ease-out group-hover:translate-y-0.5"}),p.jsx("span",{className:"hidden sm:inline",children:Y("leaderboard.profile.nav.download")})]})}),f?p.jsx("div",{className:"h-8 w-16 animate-pulse rounded-full bg-oai-gray-200 dark:bg-white/10","aria-hidden":!0}):h?p.jsx(ye,{}):p.jsx("button",{type:"button",onClick:c,className:"inline-flex h-8 min-w-[76px] items-center justify-center px-3 text-xs font-bold rounded-full border border-oai-gray-200 dark:border-white/10 bg-transparent text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-white/5 hover:text-oai-black dark:hover:text-white transition-all duration-200 active:scale-95 shadow-sm select-none",children:Y("header.auth.sign_in_aria")})]})]})}),p.jsx("main",{className:"flex-1 px-4 pt-4 pb-10 sm:pt-6 sm:pb-16",children:p.jsx("div",{className:"mx-auto max-w-3xl",children:p.jsxs("div",{className:"rounded-2xl bg-white dark:bg-oai-gray-950 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden shadow-sm dark:shadow-none",children:[m.loading&&p.jsx(Ce,{variant:"page"}),!m.loading&&m.error&&p.jsx("div",{className:"px-6 py-16 text-center",children:p.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:Y("leaderboard.profile_modal.error")})}),!m.loading&&!m.error&&!m.data&&p.jsx("div",{className:"px-6 py-16 text-center",children:p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:Y("leaderboard.profile_modal.empty")})}),!m.loading&&!m.error&&m.data&&p.jsx(Se,{data:m.data,currency:o,rate:n,variant:"page"})]})})}),p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 px-4 transition-colors duration-200",children:p.jsxs("div",{className:"mx-auto flex max-w-3xl items-center justify-between text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[p.jsx("p",{children:Y("landing.v2.footer.line")}),p.jsx(vr,{theme:i,resolvedTheme:u,onSetTheme:l,direction:"up",align:"right"})]})})]})}export{Yr as LeaderboardProfilePage};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{o as Z,j as e,y as Re,c as r,h as U,r as p,al as xt,B as Y,bv as pt,V as j,e as gt,W as ve,R as ht,L as ft,bw as bt,t as yt,w as kt}from"./__vite-browser-external-2g_4s3ot.js";import{m as je}from"./react-DlHjGQFN.js";import{P as re,c as vt,r as le,a as jt,u as wt,b as Nt,s as _t}from"./use-usage-limits-eJlU65yY.js";import{b as w,c as He,l as ie,d as Ie,u as Ct}from"./use-limits-display-prefs-D3HOcRFv.js";import{C as Ae}from"./Card-BYoxd4OC.js";import{F as St}from"./FadeIn-B6lrj4uo.js";import{P as Oe}from"./ProviderIcon-Bp7iFJ_m.js";import{H as Pt}from"./HoverTooltip-DY1ENf69.js";import{C as Fe}from"./chevron-down-Ck8ml43e.js";import{G as Mt}from"./gift-dEHDFMc6.js";import{C as Dt}from"./ConfirmModal-tkgZwz4u.js";import{I as we,L as Tt}from"./LocalOnlyNotice-Rk1B8PaZ.js";import{S as xe}from"./Select-kIcvQFAo.js";import{P as Et}from"./plus-4n94VzDK.js";import{P as Rt,a as Ht,b as It,c as At,d as Ot}from"./PopoverPopup-NYiGE8A2.js";import{u as Ft}from"./use-reduced-motion-D1gcKJUo.js";import"./use-latest-request-guard-DhGg1cDS.js";import"./DialogTitle-B-VifiA3.js";import"./composite-INW-ELWX.js";import"./store-gHeBU8dQ.js";import"./DialogDescription-DBqGGWNj.js";import"./arrow-up-right-DLvfE0Wu.js";import"./download-B7uokeIo.js";import"./check-C_cfrxiz.js";import"./SelectItemText-BpIsAg3b.js";import"./usePositioner-B3l2ulTw.js";import"./safePolygon-CVZ27a2_.js";const Le={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"}]]};Le.node;const Lt=Z(Le);const $e={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"}]]};$e.node;const $t=Z($e);const Ue={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"}]]};Ue.node;const Be=Z(Ue);const ze={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};ze.node;const Ge=Z(ze);const We={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"}]]};We.node;const qe=Z(We),Ut=[3,2,3,3,2,2,3];function L({className:t}){return e.jsx("div",{className:Re("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Bt(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-3 w-12 shrink-0"}),e.jsx(L,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(L,{className:"h-3 w-[30px] shrink-0"}),e.jsx(L,{className:"h-3 w-6 shrink-0"})]})}function zt({bars:t,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(L,{className:"h-[14px] w-[14px] rounded shrink-0"}),e.jsx(L,{className:Re("h-4",i)})]}),Array.from({length:t},(s,n)=>e.jsx(Bt,{},n))]})}function Gt(){return e.jsx(Ae,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(L,{className:"h-3.5 w-28"}),Ut.map((t,a)=>e.jsx(zt,{bars:t,index:a},a))]})})}const fe=100;function Ne(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function Wt(t){return Math.max(0,Math.min(fe,Math.round(t)))}function qt(t){return new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function Vt(t,a,i){if(t==null||t>=a)return fe;const s=a-t,n=a-i;return Wt(n/s*fe)}function Yt(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function Kt(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=Yt(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=Ne(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:qt(c),expiresMs:c,percent:Vt(Ne(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 X=864e5;function $(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 Ve(t,a){if(a==="weekly")return t-7*X;if(a==="yearly")return $(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 Ye(t,a){return a==="weekly"?t+7*X:a==="yearly"?$(t,12):$(t,1)}function Xt(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return Ve(new Date(t.nextBillingAt).getTime(),t.cycle)}function Zt(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return Ve(i,a)}function Jt(t,a,i){if(a==="weekly"){const c=7*X,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*X;let o=i<=t?0:Math.floor((i-t)/n);for(;o>0&&$(t,o*s)>i;)o-=1;let l=0;for(;$(t,(o+1)*s)<=i&&l<12e3;)o+=1,l+=1;return{startMs:$(t,o*s),endMs:$(t,(o+1)*s)}}function ne(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=Zt(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=Jt(n,s,a):t.startedAt!=null?(o=n,l=Ye(n,s),c=l<=a):(o=n,l=i,c=l<=a);const d=Math.max(1,l-o),u=c?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:l,startMs:o,progress:u,cycleDays:Math.max(1,Math.round(d/X)),expired:c}}function Ke(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 be(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 Qt="shrink-0 text-oai-black dark:text-oai-white";function Xe(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function Ze(){return Xe()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function Je(){return r("limits.devin.setupHint.snippet_login")}function ea(t){const a=le(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 ta(t,a){const i=a===w.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function se(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ce(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function pe(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 ae(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 aa(t){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const a={useGrouping:t.unit!=="calls"},i=ae(t.used_credits,a),s=ae(t.limit_credits,a),n=ae(t.remaining_credits,a);if(!i||!s||!n)return null;const o=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(o,{used:i,limit:s,remaining:n})}function Qe(t,a,i){return vt({usedPercent:se(t.window,t.pctField),windowSeconds:jt(t,t.window),resetMs:le(ce(t.window,t.resetField)),mode:a,now:i})}function oe(t){return Number.isFinite(t)?new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function ra(t,a,i){const s=[tt(t,a,i)],n=le(ce(t.window,t.resetField)),o=oe(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=aa(t.window);return l&&s.push(l),s.join(`
|
|
2
|
+
`)}const et=Pt;function ia({label:t,pct:a,reset:i,mode:s=w.USED,pacePercent:n=null,paceOver:o=!1,title:l=null}){const c=Math.max(0,Math.min(100,Number(a)||0)),d=s===w.REMAINING?100-c:c,u=Math.round(d),x=d>0&&u===0?Math.max(d,.35):d;let g=String(u);d>0&&u===0&&(g=r("limits.bar.sub_one_percent"));const b=n==null?null:Math.max(0,Math.min(100,n));return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(et,{text:l}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),e.jsxs("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${ta(d,s)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${x}%`,minWidth:d>0?"3px":0}}),b!=null&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${b}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${o?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${b}% - 1px)`,width:"2px"}})]})]}),e.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:[g,"%"]}),i&&e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:i})]})}function tt(t,a,i){const s=t.label??r(t.labelKey),n=i===w.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(se(t.window,t.pctField))||0)),u=pe(o(d));return n?r("limits.explain.remaining",{label:s,used:u}):r("limits.explain.used",{label:s,used:u})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=pe(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(se(t.window,t.pctField))||0)),c=pe(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function na({pace:t}){return t.pacePercent!=null}function at({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=a===w.REMAINING,n=t.some(na);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l})=>{const c=oe(le(ce(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[tt(o,l,a),c?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:c})]}):null]},o.key)}),n?e.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(s?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function K(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 _e={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"}},sa={claude:"claude",codex:"codex",antigravity:"agy"};function G({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=_e[i]||_e.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 rt({name:t,providerId:a,children:i,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null,toggleOnHeader:d=!1}){const u=Ie(a),x=e.jsxs("div",{className:"flex items-center gap-1.5",children:[u?e.jsx(Oe,{provider:u,size:14,className:Qt}):null,e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t}),c?e.jsx("span",{className:"shrink-0",children:c}):null,l]});return s?d?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button","aria-expanded":n,onClick:o,className:"flex w-full items-center justify-between rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[x,e.jsx(Fe,{size:13,"aria-hidden":!0,className:`text-oai-gray-400 transition-transform ${n?"rotate-180":""}`})]}),i]}):e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:o,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),o?.())},className:"flex flex-col gap-1.5 -mx-1.5 px-1.5 py-1 rounded-lg cursor-pointer transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 aria-expanded:bg-oai-gray-50 dark:aria-expanded:bg-oai-gray-800/40",children:[x,i]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[x,i]})}function it({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?qe:Ge;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 nt({subscription:t,now:a,mode:i=w.USED}){const s=ne(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===w.REMAINING?100-c:c,u=o?100:Math.max(0,Math.min(100,d)),x=Math.round(u),g=u>0&&x===0?r("limits.bar.sub_one_percent"):`${x}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:r("subscriptions.inline.label")}),e.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:`${o?"bg-red-500":l?"bg-amber-500":"bg-blue-500"} rounded-full h-full block motion-safe:transition-[width] motion-safe:duration-500 ease-out motion-reduce:transition-none`,style:{width:`${u}%`,minWidth:u>0?"3px":0}})}),e.jsx("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:g}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 whitespace-nowrap w-6 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Ke(n,a)})]})}function st({subscription:t,now:a}){const i=ne(t,a);if(!i)return null;const s=new Intl.DateTimeFormat(U(),{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:be(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 oa=He;function R({children:t,tone:a="neutral"}){const i=a==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return e.jsx("div",{className:`text-[11px] leading-snug ${i}`,children:t})}function ot({rows:t,mode:a,extra:i=null}){const s=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:n,pace:o})=>e.jsx(ia,{label:n.label??r(n.labelKey),pct:se(n.window,n.pctField),reset:ea(ce(n.window,n.resetField)),mode:a,pacePercent:o.pacePercent,paceOver:o.paceOver,title:ra(n,o,a)},n.key)),s?e.jsx(R,{children:r("limits.status.no_data")}):null,i]})}function la(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 ca({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(et,{text:la(t)}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t.label}),e.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${a}%`,minWidth:a>0?"3px":0}})}),e.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:t.expiresAt})]})}function da({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(ca,{row:i},i.key))]})}function ua({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(R,{tone:"error",children:r("shared.error.prefix",{error: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=>oe(Date.parse(n.expires_at))).join(`
|
|
3
|
+
`),children:r("limits.zcode.reset_bank.earliest",{time:oe(Date.parse(s.cards[0].expires_at))})}):null]},s.key))]})}function lt(t,a){if(t==="zcode_reset_bank")return a.reset_credits?e.jsx(ua,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=Kt(a.reset_credits);return i?e.jsx(da,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(R,{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=ae(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(R,{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(ga,{defaultDir:a.otel_default_dir}):null}function ma({data:t,mode:a,now:i}){const[s,n]=p.useState(!1),o=p.useRef(null),l=ct(o),c=[...new Set((t.buckets||[]).map(x=>x.plan_name).filter(Boolean))],d=c.length?c.join(" · "):r("limits.zcode.start_grants"),u=re.zcode.windows(t).filter(x=>x.window).map(x=>({spec:x,pace:Qe(x,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:x=>{x.stopPropagation(),n(g=>!g)},onKeyDown:x=>x.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(Mt,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(Fe,{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(R,{tone:"error",children:r("shared.error.prefix",{error:t.error})}):e.jsxs(e.Fragment,{children:[e.jsx(ot,{rows:u,mode:a}),e.jsx(at,{rows:u,mode:a,now:i}),(t.buckets||[]).filter(x=>Number.isFinite(x.remaining_units)&&Number.isFinite(x.total_units)).map((x,g)=>e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.grant_amount",{remaining:x.remaining_units.toLocaleString(U()),total:x.total_units.toLocaleString(U())})},x.entitlement_id||g))]})}):null]})}function xa(t,a,i,s,n,o,l=null,c=null,d=Date.now()){const u=re[t];if(!u)return null;const x=u.windows(a).filter(b=>b.window).map(b=>({spec:b,pace:Qe(b,s,d)})),g=lt(u.extra,a);return e.jsxs(rt,{name:i,providerId:t,expandable:x.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(it,{subscription:c}):null,toggleOnHeader:t==="zcode",children:[e.jsx(ot,{mode:s,rows:x,extra:g}),c?e.jsx(nt,{subscription:c,now:d,mode:s}):null,n?e.jsx(at,{rows:x,mode:s,now:d}):null,n&&c?e.jsx(st,{subscription:c,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(ma,{data:a.start_plan,mode:s,now:d}):null]},t)}function ge(t,a,i,s,n=null,o=Date.now(),l=w.USED){const c=!!n;return e.jsxs(rt,{name:ie(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(it,{subscription:n}):null,children:[a,c?e.jsx(nt,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(st,{subscription:n,now:o})}):null]},t)}function pa(t,a,i,s,n,o=null,l=Date.now()){if(!re[t])return null;if(!a?.configured)return ge(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(Ce,{}):null,t==="commandCode"?e.jsx(Se,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(De,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return ge(t,e.jsx(R,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return ge(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),t==="kiro"?lt(re.kiro.extra,a):null,t==="opencodeGo"?e.jsx(Ce,{}):null,t==="commandCode"?e.jsx(Se,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(De,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);const c=ie(t),d=a.plan_label?`${c} ${a.plan_label}`:c;let u=null;if(a.auth_action_required==="reauth"){const g=t==="commandCode"?Ze():t==="devin"?Je():sa[t];u=e.jsx(G,{label:r("limits.reauth.badge"),age:K(a.cached_at),tone:"stale",tooltip:g?r("limits.reauth.tooltip",{command:g}):null})}if(!u&&t==="antigravity")if(a.cached){const g=K(a.cached_at);u=e.jsx(G,{label:r("limits.label.antigravity_cached"),age:g,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(G,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(G,{label:r("limits.label.antigravity_cached"),age:K(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(G,{label:r("limits.label.antigravity_cached"),age:K(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const x=a.provenance;return x?.stale&&!u&&(u=e.jsx(G,{label:r("limits.provenance.stale"),age:K(x.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:x.source,confidence:x.confidence})})),xa(t,a,d,i,s,n,u,o,l)}function ga({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 N({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 ye(){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 Ce(){const[t,a]=p.useState(!1),i=["read -r -s OPENCODE_GO_API_KEY","export OPENCODE_GO_API_KEY",'launchctl setenv OPENCODE_GO_API_KEY "$OPENCODE_GO_API_KEY"'].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-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.opencodeGo.setupHint.title")}),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(N,{n:"1",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),e.jsx(ye,{})]})]}),e.jsx(N,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(N,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.opencodeGo.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.opencodeGo.setupHint.copied"):r("limits.opencodeGo.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.opencodeGo.setupHint.note_app")})]})]})]})}function Se(){const[t,a]=p.useState(!1),i=Xe(),s=Ze(),n=i==="windows"?r("limits.commandCode.setupHint.snippet_env_windows").replaceAll("\\n",`
|
|
6
|
+
`):[r("limits.commandCode.setupHint.snippet_read"),r("limits.commandCode.setupHint.snippet_export"),...i==="macos"?[r("limits.commandCode.setupHint.snippet_setenv")]:[]].join(`
|
|
7
|
+
`),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.commandCode.setupHint.title")}),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(N,{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:s})]}),e.jsxs(N,{n:"2",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step2")}),e.jsx("div",{className:"mt-1.5 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:o,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.commandCode.setupHint.copied"):r("limits.commandCode.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:n}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:i==="windows"?r("limits.commandCode.setupHint.note_windows"):i==="linux"?r("limits.commandCode.setupHint.note_linux"):r("limits.commandCode.setupHint.note_app")})]})]})]})}function Pe(){const t=Je();return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.devin.setupHint.title")}),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(N,{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 Me(){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(`
|
|
8
|
+
`),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.codingPlan.setupHint.title")}),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(N,{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(ye,{})]})]}),e.jsxs(N,{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(N,{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 De(){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(`
|
|
9
|
+
`),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.agentPlan.setupHint.title")}),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(N,{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(ye,{})]})]}),e.jsxs(N,{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(N,{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 ct(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 u of n)o=Math.max(o,l.measureText(u.textContent).width)}const c=Math.ceil(o);i(d=>d===c?d:c)}),a}function ha({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:u,opencodeGo:x,commandCode:g,qoder:b,qoderCn:P,codingPlan:A,agentPlan:C,devin:k,order:S,visibility:_,displayMode:O,subscriptions:W=[],showSubscriptions:M=!0}){const D={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:u,opencodeGo:x,commandCode:g,qoder:b,qoderCn:P,codingPlan:A,agentPlan:C,devin:k},B=p.useRef(null),T=ct(B),[de,J]=p.useState(null),[E,Q]=p.useState(()=>Date.now()),ue=Array.isArray(S)&&S.length>0?S:oa,ee=O===w.REMAINING?w.REMAINING:w.USED,me=ee===w.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used");p.useEffect(()=>{const f=setInterval(()=>Q(Date.now()),6e4);return()=>clearInterval(f)},[]);const F=new Map;if(M)for(const f of W||[]){if(!f?.provider)continue;const H=new Date(f.nextBillingAt).getTime();if(!Number.isFinite(H))continue;const te=F.get(f.provider);if(!te){F.set(f.provider,f);continue}const I=new Date(te.nextBillingAt).getTime(),V=H>E,m=I>E;(V&&(!m||I>H)||!V&&!m&&H>I)&&F.set(f.provider,f)}const q=ue.filter(f=>!_||_[f]!==!1||F.has(f)).map(f=>pa(f,D[f],ee,de===f,()=>J(H=>H===f?null:f),F.get(f)||null,E)).filter(Boolean);return e.jsx(St,{delay:.15,children:e.jsx(Ae,{children:e.jsxs("div",{ref:B,"data-limit-label-group":"",className:"flex flex-col gap-3",style:T>0?{"--tt-limits-label-w":`${T}px`}:void 0,children:[e.jsxs("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:[r("limits.panel.title"),r("limits.panel.mode_separator"),me]}),q.length>0?q:e.jsx(R,{children:r("limits.status.all_hidden")})]})})})}async function dt(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 fa(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await dt(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function ke(t){const a=await xt();return dt(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 ba(t){return ke({action:"create",subscription:t})}function ya(t,a){return ke({action:"update",id:t,subscription:a})}function ka(t){return ke({action:"delete",id:t})}const he={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function va(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 ja({subscriptions:t,onChanged:a}){const[i,s]=p.useState(!1),[n,o]=p.useState(null),[l,c]=p.useState(he),[d,u]=p.useState(!1),[x,g]=p.useState(!1),[b,P]=p.useState(!1),[A,C]=p.useState(!1),[k,S]=p.useState(null),[_,O]=p.useState(!1),[W,M]=p.useState(!1),[D,B]=p.useState(null),[T,de]=p.useState(()=>Date.now()),J=p.useRef(null),E=U(),Q=p.useMemo(()=>new Intl.DateTimeFormat(E,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[E]);p.useEffect(()=>{const m=setInterval(()=>de(Date.now()),6e4);return()=>clearInterval(m)},[]),p.useEffect(()=>{if(!i)return;const m=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;J.current?.scrollIntoView?.({behavior:m?"auto":"smooth",block:"nearest"})},[i,n]);const ue=p.useMemo(()=>He.map(m=>{const v=(t||[]).some(y=>y.provider===m&&y.id!==n),h=ie(m);return{value:m,label:v?`${h} ${r("subscriptions.form.provider_taken_suffix")}`:h,disabled:v}}),[E,t,n]),ee=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")}],[E]),me=p.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[E]),F=p.useCallback(()=>{c(he),o(null),g(!1),P(!1),C(!1),s(!0)},[]),q=p.useCallback(m=>{c({plan:m.plan||"",provider:m.provider||"",cycle:m.cycle||"monthly",autoRenew:m.autoRenew,startedAt:va(new Date(Xt(m)).toISOString())}),o(m.id),g(!1),P(!1),C(!1),s(!0)},[]),f=p.useCallback(()=>{s(!1),o(null),c(he),g(!1),P(!1),C(!1)},[]),H=p.useCallback(async m=>{if(m.preventDefault(),g(!1),!l.provider){P(!0);return}if((t||[]).some(z=>z.provider===l.provider&&z.id!==n)){C(!0);return}const h=new Date(l.startedAt).getTime();if(!Number.isFinite(h)){g(!0);return}const y={service:ie(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:h,nextBillingAt:Ye(h,l.cycle)};u(!0);try{n?await ya(n,y):await ba(y),f(),await a?.()}catch{g(!0)}finally{u(!1)}},[f,n,l,a,t]),te=p.useCallback(async()=>{if(k){O(!0),M(!1);try{await ka(k.id),k.id===n&&f(),S(null),await a?.()}catch{M(!0)}finally{O(!1)}}},[f,n,a,k]),I=t||[],V=()=>{const m=n?I.find(h=>h.id===n):null,v=m?ne(m,T):null;return e.jsxs("form",{ref:J,onSubmit:H,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")})}),v?e.jsxs("div",{className:"sm:col-span-2 rounded-md bg-oai-gray-50 dark:bg-oai-gray-800/50 px-2.5 py-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:m.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:Q.format(new Date(v.endMs))})," · ",e.jsx("span",{className:v.expired?"text-oai-error":void 0,children:be(v.endMs,T)})]}):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(xe,{id:"subscription-provider",value:l.provider,onValueChange:h=>c({...l,provider:String(h)}),options:ue,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(we,{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(xe,{id:"subscription-cycle",value:l.cycle,onValueChange:h=>c({...l,cycle:String(h)}),options:ee,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-auto-renew",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.auto_renew")}),e.jsx(xe,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:h=>c({...l,autoRenew:h==="true"}),options:me,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(we,{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(Y,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const h=I.find(y=>y.id===n);h&&S(h)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,b?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,A?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,x?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(Y,{type:"button",variant:"secondary",size:"sm",onClick:f,children:r("shared.action.cancel")}),e.jsx(Y,{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(Y,{type:"button",size:"sm",onClick:F,className:"shrink-0 gap-1.5",children:[e.jsx(Et,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),I.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(Be,{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:[I.map(m=>{const v=ne(m,T);if(!v)return null;const{endMs:h,expired:y}=v,z=y?100:v.progress*100,ut=!y&&h-T<=3*864e5,mt=D===m.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:()=>q(m),"aria-label":`${r("subscriptions.edit")} ${m.service}`,"aria-expanded":n===m.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(Oe,{provider:Ie(m.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:m.service}),e.jsx("span",{role:"img","aria-label":m.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:m.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${m.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:m.autoRenew?e.jsx(qe,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Ge,{size:14,strokeWidth:2,"aria-hidden":!0})}),m.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:m.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:`${y?"bg-red-500":ut?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${z}%`,minWidth:z>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${y?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Ke(h,T)})]})]}),n===m.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:V()}):null,n!==m.id&&mt?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:m.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:Q.format(new Date(h))})," · ",e.jsx("span",{className:y?"text-oai-error":void 0,children:be(h,T)})," · ",e.jsx("span",{children:m.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Y,{type:"button",variant:"secondary",size:"sm",onClick:()=>q(m),children:r("subscriptions.edit")})})]}):null]},m.id)}),i&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:V()}):null]}),e.jsx(Dt,{open:!!k,title:r("subscriptions.confirm_delete_title"),description:k?.service||"",error:W?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:_,onCancel:()=>{S(null),M(!1)},onConfirm:te})]})}const Te=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),wa="x-apple.systempreferences:com.apple.preference.notifications";function Ee(t){const a=Date.parse(t);return Number.isFinite(a)?new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(a)):String(t)}function Na(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 _a(){const t=Ft(),a=yt(),i=r("limits.alert.blocked"),s=a?je.button:je.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>kt({type:"action",name:"openURL",value:wa}):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 Qa(){const t=pt(),{data:a,error:i,isLoading:s,refresh:n}=wt(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),o=Ct(),l=Nt(),[c,d]=j.useState([]),[u,x]=j.useState(!1),[g,b]=j.useState(!1),[P]=gt(),A=j.useRef(0),C=j.useRef(!1),[k,S]=j.useState(!1),[_,O]=j.useState(null),W=j.useCallback(async()=>{if(!C.current){C.current=!0,S(!0),O(null);try{const D=await n();O(D?Na(D):{kind:"failed"})}finally{C.current=!1,S(!1)}}},[n]),M=j.useCallback(async()=>{if(!Te&&!ve())return;const D=++A.current;try{const B=await fa();if(D!==A.current)return;d(B),x(!1)}catch{if(D!==A.current)return;x(!0)}},[]);return j.useEffect(()=>{M()},[M]),j.useEffect(()=>{P.get("openSubscriptions")==="1"&&b(!0)},[P]),j.useEffect(()=>{l.enabled&&a&&_t(a)},[l.enabled,a]),!Te&&!ve()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Tt,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:r("nav.limits")}),e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:r("limits.page.subtitle")})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.enabled&&l.permissionBlocked?e.jsx(_a,{}):null,e.jsx("button",{type:"button",onClick:()=>{W()},disabled:k,"aria-label":r("limits.page.refresh"),title:r("limits.page.refresh"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50",children:e.jsx(ht,{className:`h-4 w-4 ${k?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(Rt,{open:g,onOpenChange:b,children:[e.jsx(Ht,{"aria-label":r("limits.page.openSubscriptions"),title:r("limits.page.openSubscriptions"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(Be,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(It,{children:e.jsx(At,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Ot,{children:e.jsx(ja,{subscriptions:c,onChanged:M})})})})]}),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-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 ${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($t,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Lt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(ft,{to:"/settings?section=limits","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(bt,{className:"h-4 w-4","aria-hidden":!0})})]})]}),e.jsx("span",{role:"status",className:"sr-only",children:k?r("limits.page.refresh_loading"):""}),_?.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:Ee(_.at)})}):null,_?.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:Ee(_.at)})}):null,_?.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,_?.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(Gt,{}):e.jsxs(e.Fragment,{children:[i?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:r("shared.error.prefix",{error:i})}):null,u?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(ha,{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,order:o.order,visibility:o.visibility,displayMode:o.displayMode,subscriptions:c,showSubscriptions:o.showSubscriptions!==!1})]})]})})})}export{Qa as LimitsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,j as e,c as r}from"./__vite-browser-external-
|
|
1
|
+
import{r as h,j as e,c as r}from"./__vite-browser-external-2g_4s3ot.js";import{A as p}from"./arrow-up-right-DLvfE0Wu.js";import{D as b}from"./download-B7uokeIo.js";function I({id:t,value:l,onChange:d,placeholder:c,disabled:i=!1,type:x="text",label:s,error:a,className:g="",...m}){const y=h.useId(),o=t||y,n=a?`${o}-error`:void 0,u=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${i?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${a?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${g}`;return e.jsxs("div",{className:"w-full",children:[s&&e.jsx("label",{htmlFor:o,className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:s}),e.jsx("input",{id:o,type:x,value:l,onChange:d,placeholder:c,disabled:i,"aria-invalid":a?!0:void 0,"aria-describedby":n,className:u,...m}),a&&e.jsx("p",{id:n,className:"mt-1.5 text-sm text-oai-error",children:a})]})}const f="https://github.com/xiufengsun/TokenTracker/releases/latest";function _(){const t=()=>{try{window.location.href="tokentracker://open"}catch{}};return e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-20 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-white",children:r("local_only.title")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("local_only.body")}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium bg-oai-gray-900 text-white hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:[e.jsx("span",{children:r("local_only.open_app")}),e.jsx(p,{size:14,strokeWidth:2,"aria-hidden":!0})]}),e.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900 transition-colors",children:[e.jsx(b,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("local_only.download")})]})]})]})})}export{I,_ as L};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as be,Z as ye,a as fe,r as o,q as pe,$ as we,c as a,j as e,y as b}from"./__vite-browser-external-2g_4s3ot.js";import{A as ke}from"./arrow-left-DL0hAp_7.js";const oe={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};oe.node;const ve=be(oe),je=e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),Ne=e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),_e={google:je,github:Ne},Ce={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function Ae(n){return Ce[n]||String(n||"").replace(/-/g," ")}function Pe(n){if(typeof n=="string"&&n.trim())return n.trim();if(n&&typeof n=="object"){if(typeof n.token=="string"&&n.token.trim())return n.token.trim();if(typeof n.otp=="string"&&n.otp.trim())return n.otp.trim()}return""}function Le({title:n,subtitle:H,className:se="",onSuccess:S,oauthReturnPath:Z,hideTitle:ie=!1,hideLogo:G=!1,initialMode:f="signin",tokenFromUrl:E="",initialEmail:p="",initialCode:v=""}){ye();const{enabled:w,configurationError:ne,connectionHost:T,signedIn:j,refreshUser:L,signInWithPassword:V,signUp:U,signInWithOAuth:W,getPublicAuthConfig:$,sendResetPasswordEmail:z,exchangeResetPasswordToken:J,resetPassword:K}=fe(),[l,m]=o.useState(f),[g,k]=o.useState(p),[x,N]=o.useState(""),[O,q]=o.useState(""),[F,le]=o.useState(""),[I,Q]=o.useState(v),[_,h]=o.useState(!1),[X,s]=o.useState(null),[C,y]=o.useState(null),[M,R]=o.useState(!1),[de,ce]=o.useState(!!(f!=="signin"||p)),[A,Y]=o.useState(!0),[P,ee]=o.useState([]),[re,ge]=o.useState(8);o.useEffect(()=>{f&&m(f)},[f]),o.useEffect(()=>{p&&k(p)},[p]),o.useEffect(()=>{v&&Q(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return Y(!0),(async()=>{const{data:t,error:i}=await $();if(!r)return;const c=t&&typeof t=="object"&&!Array.isArray(t)&&Array.isArray(t.oAuthProviders)&&t.oAuthProviders.every(d=>typeof d=="string"&&d.length>0)&&(t.customOAuthProviders===void 0||Array.isArray(t.customOAuthProviders)&&t.customOAuthProviders.every(d=>typeof d=="string"&&d.length>0));if(i||!c)ee(["google","github"]);else{const d=t.oAuthProviders,he=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];ee([...d,...he]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&ge(t.passwordMinLength)}Y(!1)})(),()=>{r=!1}},[w,$]),o.useEffect(()=>{j&&S&&S()},[j,S]);const ae=o.useCallback(()=>typeof window>"u"?"":pe()?"tokentracker://auth/callback":`${window.location.origin}/`,[]),te=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),h(!0);try{const t=we(Z);if(t)try{window.sessionStorage.setItem("tt.cloud.return",t)}catch{}const{error:i}=await W(r,ae());i&&s(i.message||String(i))}finally{h(!1)}},[W,ae,Z]);o.useEffect(()=>{if(!w||A||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),i=t.get("native")==="1",c=t.get("provider");i&&c&&[...P].includes(c)&&B(c)},[w,A,j,P,B]);const ue=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{if(l==="signup"){const{data:i,error:c}=await U({email:g.trim(),password:x,name:F.trim()||void 0});if(c){s(c.message||String(c));return}if(i?.requireEmailVerification){y(a("login.verify_email_pending")),m("signin");return}await L();return}const{error:t}=await V({email:g.trim(),password:x});if(t){s(t.message||String(t));return}await L()}finally{h(!1)}},[l,g,x,F,U,V,L]),me=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{const t=g.trim(),{error:i}=await z({email:t,redirectTo:te});if(i){s(i.message||String(i));return}k(t),y(a("reset_password.request.sent")),m("reset_confirm")}finally{h(!1)}},[g,te,z]),xe=o.useCallback(async r=>{if(r.preventDefault(),s(null),x!==O){s(a("reset_password.error.password_mismatch"));return}h(!0);try{let t=E;if(!t){const{data:c,error:d}=await J({email:g.trim(),code:I.trim()});if(d){s(d.message||String(d));return}if(t=Pe(c),!t){s(a("reset_password.error.missing_token"));return}}const{error:i}=await K({newPassword:x,otp:t});if(i){s(i.message||String(i));return}R(!0),y(a("reset_password.success"))}finally{h(!1)}},[I,O,g,J,x,K,E]);if(!w)return ne?e.jsx("p",{role:"alert",className:"p-4 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:a("instance.configuration.invalid")}):null;const u=l==="reset_email"||l==="reset_confirm",D=A||!!P.length;return e.jsxs("div",{className:b("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",se),children:[u&&e.jsxs("button",{type:"button",onClick:()=>{m("signin"),y(null),s(null),R(!1),N(""),q("")},className:"flex items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors mb-4 focus:outline-none",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:b("mb-6",u?"text-left":"text-center"),children:[!G&&!u&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white font-oai tracking-tight",children:a("shared.app_name")})]}),!ie||u?e.jsx("h2",{className:b("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(G||u)&&"text-base font-bold md:text-lg"),children:u?a("reset_password.title"):n||a("login_modal.subtitle")}):null,!u&&H&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px] mx-auto",children:H}),u&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px]",children:C&&l==="reset_confirm"&&!M?C:a("reset_password.subtitle")})]}),T?e.jsx("p",{className:"mb-4 text-center text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a("instance.connection.destination",{host:T})}):null,C&&(!u||M)&&e.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:C}),X&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:X}),l==="reset_email"&&e.jsxs("form",{onSubmit:me,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.request.submit")})]}),l==="reset_confirm"&&(M?e.jsx("button",{type:"button",onClick:()=>{m("signin"),R(!1),y(null),s(null),N(""),q("")},className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors text-center shadow-sm",children:a("reset_password.success_cta")}):e.jsxs("form",{onSubmit:xe,className:"space-y-3",children:[!E&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email-confirm",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-code",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.code")}),e.jsx("input",{id:"card-reset-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:I,onChange:r=>Q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.new_password")}),e.jsx("input",{id:"card-reset-password",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.confirm_password")}),e.jsx("input",{id:"card-reset-password-confirm",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:O,onChange:r=>q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.reset.submit")})]})),!u&&e.jsxs(e.Fragment,{children:[D?e.jsx("div",{className:"space-y-2.5 mb-5",children:A?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"}),e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"})]}):P.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[_e[r]||null,a("login.oauth.continue",{provider:Ae(r)})]},r))}):null,de?e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login_modal.divider_email")})})]}):null,e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:ue,className:"space-y-3",children:[l==="signup"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.name")}),e.jsx("input",{id:"card-name",type:"text",autoComplete:"name",value:F,onChange:r=>le(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:a("login.field.name_placeholder")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.password")}),e.jsx("input",{id:"card-password",type:"password",autoComplete:l==="signup"?"new-password":"current-password",required:!0,minLength:l==="signup"?re:void 0,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),l==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:a("login.password_hint",{min:String(re)})}),l==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{m("reset_email"),s(null),y(null)},className:"text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white no-underline bg-transparent border-0 p-0 cursor-pointer focus:outline-none",children:a("login.forgot_password")})})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:l==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login.divider")})})]}):null,e.jsxs("button",{type:"button",onClick:()=>ce(!0),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[e.jsx(ve,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{Le as L};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as p,a as x,r as l,j as a,c as o,X as y}from"./__vite-browser-external-2g_4s3ot.js";import{L as m}from"./LoginCard-DTTIm8vk.js";import{D as h,a as b,b as f,c as j,d as k,e as v}from"./DialogTitle-B-VifiA3.js";import{D as w}from"./DialogDescription-DBqGGWNj.js";import"./arrow-left-DL0hAp_7.js";import"./composite-INW-ELWX.js";import"./store-gHeBU8dQ.js";function E(){const{isOpen:c,request:t,closeLoginModal:i,completeLoginModal:s}=p(),{enabled:d,configurationError:r}=x(),e=t?.id,n=l.useCallback(()=>i(e),[i,e]),g=l.useCallback(()=>{s(e)},[s,e]);return a.jsx(h,{open:c,onOpenChange:u=>{u||n()},children:a.jsxs(b,{children:[a.jsx(f,{className:"fixed inset-0 z-[100] bg-black/40 transition-opacity duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 dark:bg-black/60"}),a.jsx(j,{className:"fixed inset-0 z-[101] flex items-center justify-center overflow-y-auto overscroll-contain p-4",children:a.jsxs(k,{className:"relative max-h-[calc(100dvh-2rem)] w-full max-w-[420px] overflow-y-auto overscroll-contain rounded-2xl border border-oai-gray-200 bg-white shadow-2xl transition-[opacity,transform] duration-200 data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.95] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.95] data-[starting-style]:opacity-0 motion-reduce:transition-none dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[a.jsx(v,{className:"sr-only",children:o("login.title")}),t?.subtitle?a.jsx(w,{className:"sr-only",children:t.subtitle}):null,a.jsx("button",{type:"button",onClick:n,"aria-label":o("shared.dialog.close"),className:"absolute right-2 top-2 z-10 flex h-11 w-11 items-center justify-center rounded-md text-oai-gray-400 transition-colors hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-500 dark:hover:text-white",children:a.jsx(y,{className:"h-5 w-5","aria-hidden":!0})}),d?a.jsx(m,{title:t?.nextPath?o("login.title"):void 0,hideTitle:!0,subtitle:t?.subtitle,oauthReturnPath:t?.nextPath,onSuccess:g,className:"p-6 bg-transparent"},e):a.jsx("p",{role:r?"alert":"status",className:"p-6 pt-14 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:o(r?"instance.configuration.invalid":"login.cloud_only")})]})})]})})}export{E as LoginModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as j,e as N,a as _,r,c as s,j as e,L as p}from"./__vite-browser-external-2g_4s3ot.js";import{L as k}from"./LoginCard-DTTIm8vk.js";import"./arrow-left-DL0hAp_7.js";function L(n){const t=new URLSearchParams(n).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function I(){const n=j(),[t,f]=N(),{enabled:o,configurationError:g,loading:x,signedIn:h,refreshUser:m}=_(),a=r.useMemo(()=>L(t.toString()),[t]),l=/^\/(cloud|billing\/checkout)(\?|$)/.test(a),w=l&&new URLSearchParams(a.split("?")[1]).get("intent")==="trial",[y,u]=r.useState(null);r.useEffect(()=>{if(/^\/(cloud|billing\/checkout)(\?|$)/.test(a))try{window.sessionStorage.setItem("tt.cloud.return",a)}catch{}},[a]),r.useEffect(()=>{const d=t.get("insforge_status"),i=t.get("insforge_type"),b=t.get("insforge_error");d==="success"&&i==="verify_email"?u(s("login.verify_email_success")):d==="error"&&i==="verify_email"&&b&&u(s("shared.error.prefix",{error:b}))},[t]);const c=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!o||x)&&h){if(c){window.location.href="/auth/native-callback";return}try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}},[o,x,h,n,a,c]),r.useEffect(()=>{o&&m()},[o,m]),r.useEffect(()=>{if(c&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[c]);const v=r.useCallback(()=>{f(d=>{const i=new URLSearchParams(d);return i.delete("insforge_status"),i.delete("insforge_type"),i.delete("insforge_error"),i},{replace:!0}),u(null)},[f]);return o?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(p,{to:l?"/cloud":"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:s(l?"cloud.checkout.back":"login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[y?e.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[e.jsx("span",{children:y}),e.jsx("button",{type:"button",onClick:v,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:s("login.dismiss")})]}):null,e.jsx("div",{className:"border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(k,{hideLogo:!0,title:s("login.title"),subtitle:s(l?w?"cloud.login.trial_context":"cloud.login.purchase_context":"login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{if(c)window.location.href="/auth/native-callback";else{try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}}})})]})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(p,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",role:g?"alert":void 0,children:g?s("instance.configuration.invalid"):s("login.cloud_only")})})]})}export{I as LoginPage};
|