tokentracker-cli 1.4.11 → 1.4.13
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 -4
- package/README.ja.md +5 -4
- package/README.ko.md +5 -4
- package/README.md +6 -4
- package/README.zh-CN.md +5 -4
- package/dashboard/dist/assets/{AchievementBadge-DALWiLQQ.js → AchievementBadge-6wnHO-Hp.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-CjWobmn1.js → AchievementsPage-BpHA9auG.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-CTryGWII.js → AchievementsSection-ySXWiLC3.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-D4lMxewA.js → BadgeDetailModal-DuxcntYu.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-CsLNf9WH.js → BotAnimated-Dg1gSql-.js} +1 -1
- package/dashboard/dist/assets/{Card-BOnNTrmF.js → Card-73qYdlEv.js} +1 -1
- package/dashboard/dist/assets/{CloudCheckoutPage-CrY15xqT.js → CloudCheckoutPage-C7-9p9zk.js} +1 -1
- package/dashboard/dist/assets/{CloudPage-hNSCMzVG.js → CloudPage-CKcDcf6O.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-CE4UfPXk.js → CommandPalette-Cq7TSYUV.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-CLUegC6z.js → CommunityStatsModal-C0gj8QaO.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-D3wwfiYB.js → ConfirmModal-Cuf2JDA9.js} +1 -1
- package/dashboard/dist/assets/{Controls-B_ta_8zw.js → Controls-COaS9RLV.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-Beg--N9T.js +1 -0
- package/dashboard/dist/assets/{DateRangePopover-CYud1FKu.js → DateRangePopover-rNSRXWkr.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-D_eSLfM3.js → DevicePage-jZ9S-taT.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-Bu1ct4DA.js → DialogClose-CEYsCJ6-.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-BAaD46Xg.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-BJxM52J1.js → DialogTitle-CnaGDa7P.js} +1 -1
- package/dashboard/dist/assets/{ElectricLogo-DYVZebgD.js → ElectricLogo-CM0HfX6y.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-CVaq5ALh.js → FadeIn-CngXKUqj.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-BCwYSguq.js → HeaderGithubStar-DQn0rAVr.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-YsG-TdOX.js → HoverTooltip-By7PDA5D.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-C0qiyZXr.js → IpCheckPage-BvrRGJNy.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-BlRJWwvx.js → LandingPage-C0CnNfi_.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardPage-DcCCKL2q.js → LeaderboardPage-iUXnjGy-.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProBadge-I_oW0KCc.js → LeaderboardProBadge-CrV2bYaH.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfileModal-DM5Vc7MB.js → LeaderboardProfileModal-iGgVOvl7.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-DnYBBGNe.js → LeaderboardProfilePage-DmiiHi5U.js} +1 -1
- package/dashboard/dist/assets/LimitsPage-Bpp0LYGk.js +6 -0
- package/dashboard/dist/assets/{LocalOnlyNotice-083BoEX9.js → LocalOnlyNotice-0pQm9-gI.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-CN1db2Rj.js → LoginCard-OaDObE8j.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-Dfi7_ory.js → LoginModal-C0dRPusa.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-BzMdiYlx.js → LoginPage-D6CoX42w.js} +1 -1
- package/dashboard/dist/assets/{PetPage-CsE95lfJ.js → PetPage-Ch5t4JT_.js} +2 -2
- package/dashboard/dist/assets/{PopoverPopup-U7DTTTE0.js → PopoverPopup-UtHXvmNC.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-CnLfT5d9.js → ProviderIcon-CRlMy2AY.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-De2RzCj-.js → ResetPasswordPage-DijAhwkr.js} +1 -1
- package/dashboard/dist/assets/{Select-BS5MWHdB.js → Select-D1FvgdDV.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-D3i379K-.js → SelectItemText-Conq3RQN.js} +1 -1
- package/dashboard/dist/assets/{SelfHostPage-CTL0dnp5.js → SelfHostPage-CLUgPEFh.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-BmEvOk3B.js → ServiceStatusPage-D7KRjgOE.js} +1 -1
- package/dashboard/dist/assets/SessionsPage-CWNrbLT4.js +3 -0
- package/dashboard/dist/assets/{SettingsPage-Cgpiwh-C.js → SettingsPage-Bh_PuEXU.js} +3 -3
- package/dashboard/dist/assets/{SkillsPage-DpagshiB.js → SkillsPage-DxZuztPd.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-Do1U_-E3.js → TokenGalaxy-BE-dqlDy.js} +1 -1
- package/dashboard/dist/assets/{TooltipPopup-MOAnEqf3.js → TooltipPopup-DQrTDsmN.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-B55RUbQm.js → TrendMonitor-Cal2kaMh.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-CehbGk-6.js → WidgetsPage-Cvv2NXRK.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-Cqt-U0Zx.js → WrappedPage-H99MjZkq.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-Br-KAXh6.css +1 -0
- package/dashboard/dist/assets/{__vite-browser-external-CR0vo15z.js → __vite-browser-external-I1de5Swt.js} +3 -3
- package/dashboard/dist/assets/{agent-logos-DuW-DWAl.js → agent-logos-BUBtw9FF.js} +1 -1
- package/dashboard/dist/assets/{arrow-left-DIvQjuji.js → arrow-left-C99UO2S4.js} +1 -1
- package/dashboard/dist/assets/{arrow-right-BURLycHb.js → arrow-right-BMFV-A6L.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-Bl1QMMkY.js → arrow-up-right-CReo0rju.js} +1 -1
- package/dashboard/dist/assets/{calendar-days-CmIWJC3A.js → calendar-days-CiEobm13.js} +1 -1
- package/dashboard/dist/assets/{check-DB2ZTWor.js → check-BBOwGLur.js} +1 -1
- package/dashboard/dist/assets/{chevron-down-BflN3NJt.js → chevron-down-C08QHnpk.js} +1 -1
- package/dashboard/dist/assets/{cloud-checkout-BugQolSC.js → cloud-checkout-NOmtAy01.js} +1 -1
- package/dashboard/dist/assets/{composite-DJsqXsjA.js → composite-C5GvW04X.js} +1 -1
- package/dashboard/dist/assets/{copy-CtB-GPN2.js → copy-DgY9F9FR.js} +1 -1
- package/dashboard/dist/assets/{download-x5Botpqc.js → download-B7xuZSZ2.js} +1 -1
- package/dashboard/dist/assets/{external-link-DH9sRkJW.js → external-link-1nRJjSL1.js} +1 -1
- package/dashboard/dist/assets/{flame-DEcsokoL.js → flame-CR1qiptA.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-BH0jc1MG.js → format-tokens-DNLvupK2.js} +1 -1
- package/dashboard/dist/assets/{gift-BZk9muk9.js → gift-DUUpsPxb.js} +1 -1
- package/dashboard/dist/assets/{icons-BMf9-bfS.js → icons-qY8ZAPUu.js} +1 -1
- package/dashboard/dist/assets/{index-BEtrik3j.js → index-7VLgsnkO.js} +1 -1
- package/dashboard/dist/assets/{index-Cm-9apOR.js → index-BvNIpRP0.js} +1 -1
- package/dashboard/dist/assets/{index-TErx-xPb.js → index-CfdotR_D.js} +1 -1
- package/dashboard/dist/assets/{index-axJYocSc.js → index-Tl9T3Nm3.js} +1 -1
- package/dashboard/dist/assets/{info-DWdPAxu8.js → info-DnT3wtaz.js} +1 -1
- package/dashboard/dist/assets/{link-2-c3ZZd-w-.js → link-2-CjxRD2lW.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-BKdtxfky.js → loader-circle-BYCsfrhr.js} +1 -1
- package/dashboard/dist/assets/{local-usage-transfer-BFTJyQl3.js → local-usage-transfer-DBfMvvqx.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-C3yIfOiP.js → modifiers.esm-DG_gVjqU.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-DbdL7Mei.js → monitor-smartphone-CJUH6nwc.js} +1 -1
- package/dashboard/dist/assets/{play-qtWt2ArI.js → play-DY4d-C2J.js} +1 -1
- package/dashboard/dist/assets/{plus-C_-__5vi.js → plus-Dydx6cB7.js} +1 -1
- package/dashboard/dist/assets/{provider-display-IKHnhvaj.js → provider-display-DCtG1A8I.js} +2 -2
- package/dashboard/dist/assets/{react-H6DfeMUm.js → react-D9IQudPE.js} +1 -1
- package/dashboard/dist/assets/{safePolygon-OEQJQTVa.js → safePolygon-CxfZ_vVn.js} +1 -1
- package/dashboard/dist/assets/{search-MZE76qNU.js → search-DBso9ppI.js} +1 -1
- package/dashboard/dist/assets/{server-CUWYLMjG.js → server-Bb_KzpvJ.js} +1 -1
- package/dashboard/dist/assets/{shield-check-lA0Ja0RB.js → shield-check-cnqpE0zI.js} +1 -1
- package/dashboard/dist/assets/{skills-api-CJJIPvSe.js → skills-api-DMbIT8CJ.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-DTnvt1IN.js → sortable.esm-2Wnda4fq.js} +1 -1
- package/dashboard/dist/assets/{store-CC0YKrxA.js → store-CGDaAZE0.js} +1 -1
- package/dashboard/dist/assets/{terminal-yc2l_-3m.js → terminal-yZ69kiqV.js} +1 -1
- package/dashboard/dist/assets/{trash-Dl9f-o2h.js → trash-DytHiAPM.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-CZCKWCO7.js → use-community-stats-DkR1XWs8.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-DTrOu0gD.js → use-latest-request-guard-D_4XuEoM.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-DGqP231e.js → use-limits-display-prefs-BadNsZG8.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-BEATnxB6.js → use-native-settings-BfxfnQAn.js} +1 -1
- package/dashboard/dist/assets/use-ordered-list-BHn-XC6u.js +1 -0
- package/dashboard/dist/assets/use-reduced-motion-BsG6Qxa-.js +1 -0
- package/dashboard/dist/assets/{use-transform-DM0QGq_O.js → use-transform-C0qKlh_s.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-BnjBG2fM.js → use-usage-limits-CQugaku6.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-xQrRFokb.js → useCurrency-ChAc4UHj.js} +1 -1
- package/dashboard/dist/assets/{usePositioner-DkVdsypM.js → usePositioner-CGtwrNEt.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-CvA_kIPe.js → useTokenFormat-CjvWdxnV.js} +1 -1
- package/dashboard/dist/assets/{zap-BJNS4i_u.js → zap-WTlrDMoe.js} +1 -1
- 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 +3 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +2 -2
- package/src/commands/init.js +1 -0
- package/src/commands/status.js +10 -0
- package/src/commands/sync.js +24 -0
- package/src/lib/local-usage-transfer.js +1 -1
- package/src/lib/pricing/curated-overrides.json +78 -0
- package/src/lib/pricing/index.js +2 -1
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +408 -37
- package/src/lib/trae-cn-config.js +36 -20
- package/dashboard/dist/assets/DashboardPage-RevVPZFt.js +0 -1
- package/dashboard/dist/assets/DialogDescription-GUHQVNGf.js +0 -1
- package/dashboard/dist/assets/LimitsPage-Cyy3PI8p.js +0 -6
- package/dashboard/dist/assets/SessionsPage-DIog3JA_.js +0 -3
- package/dashboard/dist/assets/__vite-browser-external-C9a2vCBN.css +0 -1
- package/dashboard/dist/assets/use-ordered-list-C_HTFP5C.js +0 -1
- package/dashboard/dist/assets/use-reduced-motion-CfCWjE-a.js +0 -1
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{o as Z,j as e,y as Fe,c as r,h as U,r as p,V as C,bm as vt,al as kt,B as V,bn as jt,e as wt,W as we,R as Nt,L as _t,bo as St,t as Mt,w as Ct}from"./__vite-browser-external-CR0vo15z.js";import{m as Ne}from"./react-H6DfeMUm.js";import{P as ne,c as Pt,r as de,a as Dt,u as Et,b as Tt,s as Rt}from"./use-usage-limits-BnjBG2fM.js";import{b as Oe,c as _,l as se,d as Le,u as It}from"./use-limits-display-prefs-DGqP231e.js";import{C as $e}from"./Card-BOnNTrmF.js";import{F as At}from"./FadeIn-CVaq5ALh.js";import{P as Ue}from"./ProviderIcon-CnLfT5d9.js";import{H as Ht}from"./HoverTooltip-YsG-TdOX.js";import{C as Be}from"./chevron-down-BflN3NJt.js";import{G as Ft}from"./gift-BZk9muk9.js";import{C as Ot}from"./ConfirmModal-D3wwfiYB.js";import{I as _e,L as Lt}from"./LocalOnlyNotice-083BoEX9.js";import{S as pe}from"./Select-BS5MWHdB.js";import{P as $t}from"./plus-C_-__5vi.js";import{P as Ut,a as Bt,b as zt,c as Gt,d as Wt}from"./PopoverPopup-U7DTTTE0.js";import{u as Kt}from"./use-reduced-motion-CfCWjE-a.js";import"./use-latest-request-guard-DTrOu0gD.js";import"./DialogTitle-BJxM52J1.js";import"./composite-DJsqXsjA.js";import"./store-CC0YKrxA.js";import"./DialogDescription-GUHQVNGf.js";import"./arrow-up-right-Bl1QMMkY.js";import"./download-x5Botpqc.js";import"./check-DB2ZTWor.js";import"./SelectItemText-D3i379K-.js";import"./usePositioner-DkVdsypM.js";import"./safePolygon-OEQJQTVa.js";const ze={name:"bell-off",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]};ze.node;const qt=Z(ze);const Ge={name:"bell",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]};Ge.node;const Vt=Z(Ge);const We={name:"calendar-clock",size:24,node:[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338",key:"7hb8p4"}],["path",{d:"M3 9h5.859",key:"numkqi"}],["path",{d:"M8 2v3",key:"1ioesn"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]};We.node;const Ke=Z(We);const qe={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};qe.node;const Ve=Z(qe);const Ye={name:"infinity",size:24,node:[["path",{d:"M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8",key:"18ogeb"}]]};Ye.node;const Xe=Z(Ye),Yt=[3,2,3,3,2,2,3];function L({className:t}){return e.jsx("div",{className:Fe("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Xt(){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:Fe("h-4",i)})]}),Array.from({length:t},(s,n)=>e.jsx(Xt,{},n))]})}function Jt(){return e.jsx($e,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(L,{className:"h-3.5 w-28"}),Yt.map((t,a)=>e.jsx(Zt,{bars:t,index:a},a))]})})}const he=100;function Se(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function Qt(t){return Math.max(0,Math.min(he,Math.round(t)))}function ea(t){return new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function ta(t,a,i){if(t==null||t>=a)return he;const s=a-t,n=a-i;return Qt(n/s*he)}function aa(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function ra(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=aa(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=Se(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:ea(c),expiresMs:c,percent:ta(Se(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 Ze(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 Je(t,a){return a==="weekly"?t+7*X:a==="yearly"?$(t,12):$(t,1)}function ia(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return Ze(new Date(t.nextBillingAt).getTime(),t.cycle)}function na(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return Ze(i,a)}function sa(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 oe(t,a){const i=new Date(t.nextBillingAt).getTime();if(!Number.isFinite(i))return null;const s=["weekly","monthly","yearly"].includes(t.cycle)?t.cycle:"monthly",n=na(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=sa(n,s,a):t.startedAt!=null?(o=n,l=Je(n,s),c=l<=a):(o=n,l=i,c=l<=a);const d=Math.max(1,l-o),m=c?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:l,startMs:o,progress:m,cycleDays:Math.max(1,Math.round(d/X)),expired:c}}function Qe(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.ceil(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function 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 oa="shrink-0 text-oai-black dark:text-oai-white",la={opencodeGo:"OPENCODE_GO_API_KEY",commandCode:"COMMAND_CODE_API_KEY"},ca={opencodeGo:"opencode-go",commandCode:"command-code"};function et(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function tt(){return et()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function at(){return r("limits.devin.setupHint.snippet_login")}function da(t){const a=de(t);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const s=Math.floor(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function rt(t,a){const i=a===_.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function le(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ue(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function re(t){const a=Math.max(0,Math.min(100,Number(t)||0)),i=Math.round(a);return a>0&&i===0?r("limits.bar.sub_one_percent"):String(i)}function ie(t,{useGrouping:a=!0,maximumFractionDigits:i}={}){const s=Number(t);return Number.isFinite(s)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:i??(s>=100?0:2),useGrouping:a}).format(s):null}function it(t,a){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const i={useGrouping:t.unit!=="calls",maximumFractionDigits:a},s=ie(t.used_credits,i),n=ie(t.limit_credits,i),o=ie(t.remaining_credits,i);if(!s||!n||!o)return null;const l=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(l,{used:s,limit:n,remaining:o})}function nt(t,a,i){return Pt({usedPercent:le(t.window,t.pctField),windowSeconds:Dt(t,t.window),resetMs:de(ue(t.window,t.resetField)),mode:a,now:i})}function ce(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 ua(t,a,i){const s=[ot(t,a,i)],n=de(ue(t.window,t.resetField)),o=ce(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=it(t.window,t.creditPrecision);return l&&s.push(l),s.join(`
|
|
2
|
-
`)}const st=Ht,Me=[1,.65,.45,.3,.2];function ye(t){return Me[Math.min(t,Me.length-1)]}function Ce({paceX:t,paceOver:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${t}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${a?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${t}% - 1px)`,width:"2px"}})]})}function ma({label:t,pct:a,reset:i,mode:s=_.USED,pacePercent:n=null,paceOver:o=!1,title:l=null,segments:c=null}){const d=Math.max(0,Math.min(100,Number(a)||0)),m=s===_.REMAINING?100-d:d,u=rt(m,s),g=Math.round(m),y=m>0&&g===0?Math.max(m,.35):m;let b=String(g);m>0&&g===0&&(b=r("limits.bar.sub_one_percent"));const v=n==null?null:Math.max(0,Math.min(100,n)),S=c?.map(w=>Math.max(0,Math.min(100,Number(w.pct)||0))),k=S?.reduce((w,R)=>w+R,0)||0,P=c?Math.max(0,d-k):0,j=Math.max(0,100-k-P);return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(st,{text:l}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),c?e.jsxs("div",{"data-limit-segments":"",className:"relative flex flex-1 h-1.5 overflow-hidden",style:{gap:"min(2px, 1%)"},children:[c.map((w,R)=>e.jsx("div",{"data-limit-segment":w.key,className:`${u} min-w-0 rounded-full h-full transition-[flex-grow] duration-500 ease-out`,style:{flex:`${S[R]} 1 0px`,opacity:ye(R)}},w.key)),P?e.jsx("div",{"data-limit-unallocated-used":"",className:`${u} min-w-0 rounded-full h-full`,style:{flex:`${P} 1 0px`,opacity:ye(c.length)}}):null,j?e.jsx("div",{"data-limit-remainder":"",className:"min-w-0 rounded-full h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{flex:`${j} 1 0px`}}):null,v!=null&&e.jsx(Ce,{paceX:v,paceOver:o})]}):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:`${u} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${y}%`,minWidth:m>0?"3px":0}}),v!=null&&e.jsx(Ce,{paceX:v,paceOver:o})]}),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:[b,"%"]}),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 xa({segments:t,fillColor:a}){return e.jsx("div",{"data-limit-legend":"",className:"-mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] leading-snug",style:{paddingLeft:"calc(var(--tt-limits-label-w, 0px) + 0.5rem)"},children:t.map((i,s)=>e.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[e.jsx("span",{"aria-hidden":!0,className:`${a} inline-block h-1.5 w-1.5 shrink-0 rounded-full`,style:{opacity:ye(s)}}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:i.label??r(i.labelKey)}),e.jsxs("span",{className:"tabular-nums text-oai-gray-700 dark:text-oai-gray-200",children:[re(i.pct),"%"]})]},i.key))})}function ot(t,a,i){const s=t.label??r(t.labelKey),n=i===_.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(le(t.window,t.pctField))||0)),m=re(o(d));return n?r("limits.explain.remaining",{label:s,used:m}):r("limits.explain.used",{label:s,used:m})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=re(o(a.projectedEnd??100));return r(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:s,pct:d})}const l=Math.max(0,Math.min(100,Number(le(t.window,t.pctField))||0)),c=re(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function lt({pace:t}){return t.pacePercent!=null}function pa(t,a){return t.some(i=>lt(i)&&(i.mode??a)===_.REMAINING)}function ct({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=pa(t,a),n=t.some(lt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l,mode:c=a})=>{const d=ce(de(ue(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[ot(o,l,c),d?e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",r(o.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:d})]}):null,o.showCreditDetail?e.jsx("div",{children:it(o.window,o.creditPrecision)}):null]},o.key)}),n?e.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(s?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function Y(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 Pe={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"}},ga={claude:"claude",codex:"codex",antigravity:"agy"};function z({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=Pe[i]||Pe.live,o=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:l=>l.stopPropagation(),children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold uppercase tracking-wider border leading-normal ${n.surface}`,children:[o?e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${n.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${n.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),s?e.jsxs("span",{className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-2 -translate-x-1/2 w-48 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-1.5 text-[10px] font-normal text-white text-center opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-normal shadow-lg origin-bottom border border-oai-gray-800 dark:border-oai-gray-700",children:[s,e.jsx("span",{className:"absolute left-1/2 top-full -translate-x-1/2 border-4 border-transparent border-t-oai-gray-900 dark:border-t-oai-gray-800"})]}):null]})}function dt({name:t,providerId:a,children:i,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null,toggleOnHeader:d=!1}){const m=Le(a),u=e.jsxs("div",{className:"flex items-center gap-1.5",children:[m?e.jsx(Ue,{provider:m,size:14,className:oa}):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:[u,e.jsx(Be,{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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[u,i]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[u,i]})}function ut({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?Xe:Ve;return e.jsx("span",{role:"img","aria-label":a,title:a,className:`inline-flex translate-y-px ${t.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:e.jsx(i,{size:14,strokeWidth:2,"aria-hidden":!0})})}function mt({subscription:t,now:a,mode:i=_.USED}){const s=oe(t,a);if(!s)return null;const{endMs:n,expired:o}=s,l=!o&&n-a<=3*864e5,c=o?100:s.progress*100,d=i===_.REMAINING?100-c:c,m=o?100:Math.max(0,Math.min(100,d)),u=Math.round(m),g=m>0&&u===0?r("limits.bar.sub_one_percent"):`${u}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[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:`${m}%`,minWidth:m>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:Qe(n,a)})]})}function xt({subscription:t,now:a}){const i=oe(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 fa=Oe;function H({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 pt({rows:t,mode:a,extra:i=null,expanded:s=!1}){const n=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:o,pace:l,mode:c=a})=>{const d=le(o.window,o.pctField),m=s?o.segments:null;return e.jsxs(C.Fragment,{children:[e.jsx(ma,{label:o.label??r(o.labelKey),pct:d,reset:da(ue(o.window,o.resetField)),mode:c,segments:m,pacePercent:l.pacePercent,paceOver:l.paceOver,title:ua(o,l,c)}),m?e.jsx(xa,{segments:m,fillColor:rt(d,_.USED)}):null]},o.key)}),n?e.jsx(H,{children:r("limits.status.no_data")}):null,i]})}function ha(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 ba({row:t}){const a=Math.max(0,Math.min(100,Number(t.percent)||0));return e.jsxs("div",{className:"group relative flex items-center gap-2","data-reset-bank-row":"",children:[e.jsx(st,{text:ha(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 ya({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(ba,{row:i},i.key))]})}function va({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(H,{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=>ce(Date.parse(n.expires_at))).join(`
|
|
3
|
-
`),children:r("limits.zcode.reset_bank.earliest",{time:ce(Date.parse(s.cards[0].expires_at))})}):null]},s.key))]})}function gt(t,a){if(t==="zcode_reset_bank")return a.reset_credits?e.jsx(va,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=ra(a.reset_credits);return i?e.jsx(ya,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(H,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})});if(t==="kiro_credits"&&Number.isFinite(Number(a.tracked_credits))&&Number(a.tracked_credit_records)>0){const i=ie(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(H,{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(Na,{defaultDir:a.otel_default_dir}):null}function ka({data:t,mode:a,now:i}){const[s,n]=p.useState(!1),o=p.useRef(null),l=ft(o),c=[...new Set((t.buckets||[]).map(u=>u.plan_name).filter(Boolean))],d=c.length?c.join(" · "):r("limits.zcode.start_grants"),m=ne.zcode.windows(t).filter(u=>u.window).map(u=>({spec:u,pace:nt(u,a,i)}));return e.jsxs("div",{className:"mt-2 border-t border-oai-gray-200/60 pt-2 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:u=>{u.stopPropagation(),n(g=>!g)},onKeyDown:u=>u.stopPropagation(),className:"flex w-full items-center gap-1.5 rounded text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx(Ft,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(Be,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${s?"rotate-180":""}`})]}),s?e.jsx("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:l>0?{"--tt-limits-label-w":`${l}px`}:void 0,children:t.error?e.jsx(H,{tone:"error",children:r("shared.error.prefix",{error:t.error})}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{rows:m,mode:a}),e.jsx(ct,{rows:m,mode:a,now:i}),(t.buckets||[]).filter(u=>Number.isFinite(u.remaining_units)&&Number.isFinite(u.total_units)).map((u,g)=>e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.grant_amount",{remaining:u.remaining_units.toLocaleString(U()),total:u.total_units.toLocaleString(U())})},u.entitlement_id||g))]})}):null]})}function ja(t,a,i,s,n,o,l=null,c=null,d=Date.now(),m=null){const u=ne[t];if(!u)return null;const g=u.windows(a).filter(b=>b.window).map(b=>{const v=b.productPool?_.USED:s;return{spec:b,mode:v,pace:nt(b,v,d)}}),y=gt(u.extra,a);return e.jsxs(dt,{name:i,providerId:t,expandable:g.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(ut,{subscription:c}):null,toggleOnHeader:t==="zcode",children:[e.jsx(pt,{mode:s,rows:g,extra:y,expanded:n}),t==="opencodeGo"||t==="commandCode"?e.jsx(_a,{providerId:t,data:a,onSaved:m}):null,c?e.jsx(mt,{subscription:c,now:d,mode:s}):null,n?e.jsx(ct,{rows:g,mode:s,now:d}):null,n&&c?e.jsx(xt,{subscription:c,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(ka,{data:a.start_plan,mode:s,now:d}):null]},t)}function ge(t,a,i,s,n=null,o=Date.now(),l=_.USED){const c=!!n;return e.jsxs(dt,{name:se(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(ut,{subscription:n}):null,children:[a,c?e.jsx(mt,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(xt,{subscription:n,now:o})}):null]},t)}function wa(t,a,i,s,n,o=null,l=Date.now(),c=null){if(!ne[t])return null;if(!a?.configured)return ge(t,e.jsxs(e.Fragment,{children:[e.jsx(H,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(De,{onSaved:c}):null,t==="commandCode"?e.jsx(Ee,{onSaved:c}):null,t==="codingPlan"?e.jsx(Re,{}):null,t==="agentPlan"?e.jsx(Ie,{}):null,t==="devin"?e.jsx(Te,{}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return ge(t,e.jsx(H,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return ge(t,e.jsxs(e.Fragment,{children:[e.jsx(H,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),t==="kiro"?gt(ne.kiro.extra,a):null,t==="opencodeGo"?e.jsx(De,{onSaved:c}):null,t==="commandCode"?e.jsx(Ee,{onSaved:c}):null,t==="codingPlan"?e.jsx(Re,{}):null,t==="agentPlan"?e.jsx(Ie,{}):null,t==="devin"?e.jsx(Te,{}):null]}),s,n,o,l,i);const d=se(t),m=a.plan_label?`${d} ${a.plan_label}`:d;let u=null;if(a.auth_action_required==="reauth"){const y=t==="commandCode"?tt():t==="devin"?at():ga[t];u=e.jsx(z,{label:r("limits.reauth.badge"),age:Y(a.cached_at),tone:"stale",tooltip:y?r("limits.reauth.tooltip",{command:y}):null})}if(!u&&t==="antigravity")if(a.cached){const y=Y(a.cached_at);u=e.jsx(z,{label:r("limits.label.antigravity_cached"),age:y,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(z,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(z,{label:r("limits.label.antigravity_cached"),age:Y(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(z,{label:r("limits.label.antigravity_cached"),age:Y(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const g=a.provenance;return g?.stale&&!u&&(u=e.jsx(z,{label:r("limits.provenance.stale"),age:Y(g.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:g.source,confidence:g.confidence})})),ja(t,a,m,i,s,n,u,o,l,c)}function Na({defaultDir:t}){const[a,i]=p.useState(!1),n=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${t||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
|
|
4
|
-
`),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:r("limits.copilot.otelHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug",children:r("limits.copilot.otelHint.body")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:n}),e.jsx("button",{type:"button",onClick:o,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:a?r("limits.copilot.otelHint.copied"):r("limits.copilot.otelHint.copy")})]})}function D({n:t,children:a}){return e.jsxs("li",{className:"flex gap-2.5",children:[e.jsx("span",{className:"mt-[1px] flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-oai-brand/15 text-[9px] font-semibold text-oai-brand",children:t}),e.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:a})]})}function ve(){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 ke({provider:t,onSaved:a}){const[i,s]=p.useState(""),[n,o]=p.useState("idle"),[l,c]=p.useState(!1),d=async m=>{m.preventDefault(),m.stopPropagation();const u=i.trim();if(!(!u||n==="saving")){o("saving"),c(!1);try{await vt(t,u),s(""),o("saved"),a?.()}catch{o("idle"),c(!0)}}};return e.jsxs("form",{className:"mt-1.5 space-y-1.5",onSubmit:d,onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"password",value:i,onChange:m=>{s(m.target.value),o("idle"),c(!1)},placeholder:r("limits.apiKey.placeholder"),"aria-label":r("limits.apiKey.placeholder"),autoComplete:"new-password",spellCheck:!1,className:"min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-white px-2 py-1 font-mono text-[11px] text-oai-gray-800 outline-none focus:border-oai-brand dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-100"}),e.jsx("button",{type:"submit",disabled:!i.trim()||n==="saving",className:"shrink-0 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 disabled:opacity-50 transition-colors",children:n==="saving"?r("limits.apiKey.saving"):n==="saved"?r("limits.apiKey.saved"):r("limits.apiKey.save")})]}),e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:l?r("limits.apiKey.save_failed"):r("limits.apiKey.local_note")})]})}function _a({providerId:t,data:a,onSaved:i}){if(a?.credential_source!=="env")return null;const s=la[t],n=ca[t];return!s||!n?null:e.jsxs("div",{className:"mt-1.5 rounded-md border border-amber-300/60 bg-amber-50/60 px-2 py-1.5 text-[10.5px] leading-snug text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",children:[e.jsx("div",{children:r("limits.apiKey.env_note",{env:s})}),e.jsx(ke,{provider:n,onSaved:i}),et()==="macos"?e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.jsx("code",{className:"rounded bg-white/70 px-1 py-0.5 font-mono text-[10px] dark:bg-oai-gray-900/60",children:r("limits.apiKey.env_unset_command",{env:s})}),e.jsx("span",{children:r("limits.apiKey.env_unset_note")})]}):null]})}function De({onSaved:t}){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(D,{n:"1",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),e.jsx(ve,{})]})]}),e.jsx(D,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(D,{n:"3",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step3")}),e.jsx(ke,{provider:"opencode-go",onSaved:t})]})]})]})}function Ee({onSaved:t}){const a=tt();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(D,{n:"1",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:a})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step2")}),e.jsx(ke,{provider:"command-code",onSaved:t})]})]})]})}function Te(){const t=at();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(D,{n:"1",children:[e.jsx("div",{children:r("limits.devin.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:t}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.devin.setupHint.note")})]})})]})}function Re(){const[t,a]=p.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
|
|
5
|
-
`),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-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(D,{n:"1",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.codingPlan.setupHint.cta"),e.jsx(ve,{})]})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.step2_remote")})]}),e.jsxs(D,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.codingPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.codingPlan.setupHint.copied"):r("limits.codingPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codingPlan.setupHint.note_app")})]})]})]})}function Ie(){const[t,a]=p.useState(!1),i=[r("limits.agentPlan.setupHint.snippet_install"),r("limits.agentPlan.setupHint.snippet_login"),r("limits.agentPlan.setupHint.snippet_status")].join(`
|
|
6
|
-
`),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-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(D,{n:"1",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.agentPlan.setupHint.cta"),e.jsx(ve,{})]})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.agentPlan.setupHint.step2_remote")})]}),e.jsxs(D,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.agentPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.agentPlan.setupHint.copied"):r("limits.agentPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.agentPlan.setupHint.note_app")})]})]})]})}function ft(t){const[a,i]=p.useState(0);return p.useLayoutEffect(()=>{const s=t.current;if(!s)return;const n=[...s.querySelectorAll("[data-limit-label]")].filter(d=>d.closest("[data-limit-label-group]")===s);let o=0,l=null;if(n.length>0)try{l=document.createElement("canvas").getContext("2d")}catch{l=null}if(l){const d=window.getComputedStyle(n[0]);l.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`;for(const m of n)o=Math.max(o,l.measureText(m.textContent).width)}const c=Math.ceil(o);i(d=>d===c?d:c)}),a}function Sa({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:u,commandCode:g,qoder:y,qoderCn:b,codingPlan:v,agentPlan:S,devin:k,workbuddy:P,order:j,visibility:w,displayMode:R,subscriptions:I=[],showSubscriptions:A=!0,onProviderKeySaved:G=null}){const F={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:u,commandCode:g,qoder:y,qoderCn:b,codingPlan:v,agentPlan:S,devin:k,workbuddy:P},J=p.useRef(null),W=ft(J),[O,Q]=p.useState(null),[K,me]=p.useState(()=>Date.now()),xe=[...new Set((Array.isArray(j)&&j.length>0?j:fa).map(h=>h==="workbuddyAi"?"workbuddy":h))],ee=R===_.REMAINING?_.REMAINING:_.USED,te=ee===_.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used");p.useEffect(()=>{const h=setInterval(()=>me(Date.now()),6e4);return()=>clearInterval(h)},[]);const E=new Map;if(A)for(const h of I||[]){if(!h?.provider)continue;const T=new Date(h.nextBillingAt).getTime();if(!Number.isFinite(T))continue;const q=E.get(h.provider);if(!q){E.set(h.provider,h);continue}const x=new Date(q.nextBillingAt).getTime(),N=T>K,f=x>K;(N&&(!f||x>T)||!N&&!f&&T>x)&&E.set(h.provider,h)}const ae=xe.filter(h=>!w||w[h]!==!1||E.has(h)).map(h=>wa(h,F[h],ee,O===h,()=>Q(T=>T===h?null:h),E.get(h)||null,K,G)).filter(Boolean);return e.jsx(At,{delay:.15,children:e.jsx($e,{children:e.jsxs("div",{ref:J,"data-limit-label-group":"",className:"flex flex-col gap-3",style:W>0?{"--tt-limits-label-w":`${W}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"),te]}),ae.length>0?ae:e.jsx(H,{children:r("limits.status.all_hidden")})]})})})}async function ht(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 Ma(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await ht(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function je(t){const a=await kt();return ht(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 Ca(t){return je({action:"create",subscription:t})}function Pa(t,a){return je({action:"update",id:t,subscription:a})}function Da(t){return je({action:"delete",id:t})}const fe={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function Ea(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 Ta({subscriptions:t,onChanged:a}){const[i,s]=p.useState(!1),[n,o]=p.useState(null),[l,c]=p.useState(fe),[d,m]=p.useState(!1),[u,g]=p.useState(!1),[y,b]=p.useState(!1),[v,S]=p.useState(!1),[k,P]=p.useState(null),[j,w]=p.useState(!1),[R,I]=p.useState(!1),[A,G]=p.useState(null),[F,J]=p.useState(()=>Date.now()),W=p.useRef(null),O=U(),Q=p.useMemo(()=>new Intl.DateTimeFormat(O,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[O]);p.useEffect(()=>{const x=setInterval(()=>J(Date.now()),6e4);return()=>clearInterval(x)},[]),p.useEffect(()=>{if(!i)return;const x=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;W.current?.scrollIntoView?.({behavior:x?"auto":"smooth",block:"nearest"})},[i,n]);const K=p.useMemo(()=>Oe.map(x=>{const N=(t||[]).some(M=>M.provider===x&&M.id!==n),f=se(x);return{value:x,label:N?`${f} ${r("subscriptions.form.provider_taken_suffix")}`:f,disabled:N}}),[O,t,n]),me=p.useMemo(()=>[{value:"weekly",label:r("subscriptions.form.cycle_weekly")},{value:"monthly",label:r("subscriptions.form.cycle_monthly")},{value:"yearly",label:r("subscriptions.form.cycle_yearly")}],[O]),xe=p.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[O]),ee=p.useCallback(()=>{c(fe),o(null),g(!1),b(!1),S(!1),s(!0)},[]),te=p.useCallback(x=>{c({plan:x.plan||"",provider:x.provider||"",cycle:x.cycle||"monthly",autoRenew:x.autoRenew,startedAt:Ea(new Date(ia(x)).toISOString())}),o(x.id),g(!1),b(!1),S(!1),s(!0)},[]),E=p.useCallback(()=>{s(!1),o(null),c(fe),g(!1),b(!1),S(!1)},[]),ae=p.useCallback(async x=>{if(x.preventDefault(),g(!1),!l.provider){b(!0);return}if((t||[]).some(B=>B.provider===l.provider&&B.id!==n)){S(!0);return}const f=new Date(l.startedAt).getTime();if(!Number.isFinite(f)){g(!0);return}const M={service:se(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:f,nextBillingAt:Je(f,l.cycle)};m(!0);try{n?await Pa(n,M):await Ca(M),E(),await a?.()}catch{g(!0)}finally{m(!1)}},[E,n,l,a,t]),h=p.useCallback(async()=>{if(k){w(!0),I(!1);try{await Da(k.id),k.id===n&&E(),P(null),await a?.()}catch{I(!0)}finally{w(!1)}}},[E,n,a,k]),T=t||[],q=()=>{const x=n?T.find(f=>f.id===n):null,N=x?oe(x,F):null;return e.jsxs("form",{ref:W,onSubmit:ae,className:"grid grid-cols-1 gap-3 px-3 py-3 text-left sm:grid-cols-2",children:[e.jsx("div",{className:"flex items-center justify-between sm:col-span-2",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:n?r("subscriptions.edit"):r("subscriptions.add")})}),N?e.jsxs("div",{className:"sm:col-span-2 rounded-md bg-oai-gray-50 dark:bg-oai-gray-800/50 px-2.5 py-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:Q.format(new Date(N.endMs))})," · ",e.jsx("span",{className:N.expired?"text-oai-error":void 0,children:be(N.endMs,F)})]}):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(pe,{id:"subscription-provider",value:l.provider,onValueChange:f=>c({...l,provider:String(f)}),options:K,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(_e,{label:r("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:f=>c({...l,plan:f.target.value})})}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-cycle",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.cycle")}),e.jsx(pe,{id:"subscription-cycle",value:l.cycle,onValueChange:f=>c({...l,cycle:String(f)}),options:me,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-auto-renew",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.auto_renew")}),e.jsx(pe,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:f=>c({...l,autoRenew:f==="true"}),options:xe,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(_e,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:f=>c({...l,startedAt:f.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[n?e.jsx(V,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const f=T.find(M=>M.id===n);f&&P(f)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,y?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,v?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,u?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(V,{type:"button",variant:"secondary",size:"sm",onClick:E,children:r("shared.action.cancel")}),e.jsx(V,{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(V,{type:"button",size:"sm",onClick:ee,className:"shrink-0 gap-1.5",children:[e.jsx($t,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),T.length===0&&!(i&&!n)?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-700",children:[e.jsx(Ke,{className:"h-6 w-6 text-oai-gray-300 dark:text-oai-gray-600 mb-2","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:r("subscriptions.empty.title")}),e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("subscriptions.empty.body")})]}):e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[T.map(x=>{const N=oe(x,F);if(!N)return null;const{endMs:f,expired:M}=N,B=M?100:N.progress*100,bt=!M&&f-F<=3*864e5,yt=A===x.id;return e.jsxs("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button",onClick:()=>te(x),"aria-label":`${r("subscriptions.edit")} ${x.service}`,"aria-expanded":n===x.id,className:"w-full flex flex-col gap-1.5 px-3 py-2.5 text-left cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ue,{provider:Le(x.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:x.service}),e.jsx("span",{role:"img","aria-label":x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${x.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:x.autoRenew?e.jsx(Xe,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Ve,{size:14,strokeWidth:2,"aria-hidden":!0})}),x.plan?e.jsx("span",{className:"text-xs rounded-full border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-0.5 text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:x.plan}):null]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:r("subscriptions.inline.label")}),e.jsx("span",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1 overflow-hidden",children:e.jsx("span",{className:`${M?"bg-red-500":bt?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${B}%`,minWidth:B>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${M?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Qe(f,F)})]})]}),n===x.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:q()}):null,n!==x.id&&yt?e.jsxs("div",{className:"px-3 pb-3 flex flex-col gap-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("p",{className:"pt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:Q.format(new Date(f))})," · ",e.jsx("span",{className:M?"text-oai-error":void 0,children:be(f,F)})," · ",e.jsx("span",{children:x.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(V,{type:"button",variant:"secondary",size:"sm",onClick:()=>te(x),children:r("subscriptions.edit")})})]}):null]},x.id)}),i&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:q()}):null]}),e.jsx(Ot,{open:!!k,title:r("subscriptions.confirm_delete_title"),description:k?.service||"",error:R?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:j,onCancel:()=>{P(null),I(!1)},onConfirm:h})]})}const Ae=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Ra="x-apple.systempreferences:com.apple.preference.notifications";function He(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 Ia(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 Aa(){const t=Kt(),a=Mt(),i=r("limits.alert.blocked"),s=a?Ne.button:Ne.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>Ct({type:"action",name:"openURL",value:Ra}):void 0,initial:t?!1:{opacity:0,x:14,scale:.9},animate:{opacity:1,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:18},title:i,className:`relative hidden sm:inline-flex min-w-0 max-w-[360px] items-center gap-1.5 rounded-full border border-amber-300/70 bg-amber-50 px-3 py-1.5 text-xs text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300 ${a?"cursor-pointer transition-colors hover:bg-amber-100 dark:hover:bg-amber-500/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/60":""}`,children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"truncate",children:i}),e.jsx("span",{"aria-hidden":!0,className:"absolute left-full top-1/2 -translate-y-1/2 border-[5px] border-transparent border-l-amber-300/80 dark:border-l-amber-500/40"})]})}function cr(){const t=jt(),{data:a,error:i,isLoading:s,refresh:n}=Et(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),o=It(),l=Tt(),[c,d]=C.useState([]),[m,u]=C.useState(!1),[g,y]=C.useState(!1),[b]=wt(),v=C.useRef(0),S=C.useRef(!1),[k,P]=C.useState(!1),[j,w]=C.useState(null),R=C.useCallback(async()=>{if(!S.current){S.current=!0,P(!0),w(null);try{const A=await n();w(A?Ia(A):{kind:"failed"})}finally{S.current=!1,P(!1)}}},[n]),I=C.useCallback(async()=>{if(!Ae&&!we())return;const A=++v.current;try{const G=await Ma();if(A!==v.current)return;d(G),u(!1)}catch{if(A!==v.current)return;u(!0)}},[]);return C.useEffect(()=>{I()},[I]),C.useEffect(()=>{b.get("openSubscriptions")==="1"&&y(!0)},[b]),C.useEffect(()=>{l.enabled&&a&&Rt(a)},[l.enabled,a]),!Ae&&!we()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Lt,{})}):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(Aa,{}):null,e.jsx("button",{type:"button",onClick:()=>{R()},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(Nt,{className:`h-4 w-4 ${k?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(Ut,{open:g,onOpenChange:y,children:[e.jsx(Bt,{"aria-label":r("limits.page.openSubscriptions"),title:r("limits.page.openSubscriptions"),className:"shrink-0 inline-flex h-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(Ke,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(zt,{children:e.jsx(Gt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Wt,{children:e.jsx(Ta,{subscriptions:c,onChanged:I})})})})]}),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(Vt,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(qt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(_t,{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(St,{className:"h-4 w-4","aria-hidden":!0})})]})]}),e.jsx("span",{role:"status",className:"sr-only",children:k?r("limits.page.refresh_loading"):""}),j?.kind==="updated"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-emerald-700 dark:text-emerald-300",children:r("limits.page.refreshed_at",{time:He(j.at)})}):null,j?.kind==="partial"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_partial",{time:He(j.at)})}):null,j?.kind==="stale"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_stale")}):null,j?.kind==="failed"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_failed")}):null,s?e.jsx(Jt,{}):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,m?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(Sa,{claude:a?.claude,codex:a?.codex,cursor:a?.cursor,gemini:a?.gemini,kimi:a?.kimi,kiro:a?.kiro,grok:a?.grok,antigravity:a?.antigravity,copilot:a?.copilot,zcode:a?.zcode,opencodeGo:a?.opencodeGo,commandCode:a?.commandCode,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,agentPlan:a?.agentPlan,devin:a?.devin,workbuddy:a?.workbuddy,order:o.order,visibility:o.visibility,displayMode:o.displayMode,subscriptions:c,showSubscriptions:o.showSubscriptions!==!1,onProviderKeySaved:()=>{n()}})]})]})})})}export{cr as LimitsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{o as Oe,r as i,j as e,y as Q,c as s,Z as Re,X as Ee,i as N,aA as ke,W as we,R as ls,V as ye,aN as cs,bl as Y}from"./__vite-browser-external-CR0vo15z.js";import{L as ds,I as us}from"./LocalOnlyNotice-083BoEX9.js";import{S as ie}from"./Select-BS5MWHdB.js";import{C as ms}from"./chevron-down-BflN3NJt.js";import{S as $e}from"./search-MZE76qNU.js";import{C as xs}from"./check-DB2ZTWor.js";import{P as gs,a as hs,b as ps,c as fs,d as bs}from"./PopoverPopup-U7DTTTE0.js";import{P as Pe}from"./ProviderIcon-CnLfT5d9.js";import{H as ys}from"./HoverTooltip-YsG-TdOX.js";import{u as je}from"./useCurrency-xQrRFokb.js";import{i as _s}from"./host-mode-Bc_iTzHk.js";import{L as ks}from"./loader-circle-BKdtxfky.js";import{I as js}from"./info-DWdPAxu8.js";import{C as vs}from"./copy-CtB-GPN2.js";import{a as ws,b as Ns,c as Ss,d as Cs,e as Ts}from"./TooltipPopup-MOAnEqf3.js";import"./arrow-up-right-Bl1QMMkY.js";import"./download-x5Botpqc.js";import"./SelectItemText-D3i379K-.js";import"./composite-DJsqXsjA.js";import"./usePositioner-DkVdsypM.js";import"./store-CC0YKrxA.js";import"./safePolygon-OEQJQTVa.js";const Ae={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]};Ae.node;const Ds=Oe(Ae);const qe={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};qe.node;const Ms=Oe(qe),Ls="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function Ne({options:a,value:t,onChange:r,allValue:o="all",allLabel:u,searchPlaceholder:p,emptyLabel:n,ariaLabel:f,disabled:k=!1,className:j=""}){const[v,w]=i.useState(!1),[x,g]=i.useState(""),[b,y]=i.useState(-1),L=i.useRef(null),S=`${i.useId()}-listbox`,P=t===o?u:a.find(h=>h.value===t)?.label??t,T=x.trim().toLowerCase(),M=i.useMemo(()=>T?a.filter(h=>h.label.toLowerCase().includes(T)):a,[a,T]),C=i.useMemo(()=>[{value:o,label:u},...M],[o,u,M]),O=b>=0&&b<C.length?C[b]:null,A=h=>{r(h),w(!1),g(""),y(-1)};i.useEffect(()=>{v&&L.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[v,b]);const J=h=>{if(h.key==="ArrowDown"||h.key==="ArrowUp"){h.preventDefault();const D=h.key==="ArrowDown";y(I=>{const c=C.length;return c?D?I>=c-1?0:I+1:I<=0?c-1:I-1:-1});return}if(h.key==="Enter"){const D=O||(T&&M.length?M[0]:null);if(!D)return;h.preventDefault(),A(D.value)}};return e.jsxs(gs,{open:v,onOpenChange:h=>{w(h),y(-1),h||g("")},children:[e.jsxs(hs,{disabled:k,"aria-label":f,className:Q("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==o?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",j),children:[e.jsx(Ms,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:P}),e.jsx(ms,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(ps,{children:e.jsx(fs,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(bs,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx($e,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":S,"aria-activedescendant":O?`${S}-${b}`:void 0,value:x,onChange:h=>{g(h.target.value),y(-1)},onKeyDown:J,placeholder:p,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:L,id:S,role:"listbox","aria-label":f,className:"max-h-64 overflow-y-auto",children:[C.map((h,D)=>e.jsxs("button",{id:`${S}-${D}`,type:"button",role:"option","aria-selected":t===h.value,"data-active":D===b?"true":void 0,onMouseEnter:()=>y(D),onClick:()=>A(h.value),className:Q(Ls,t===h.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",D===b&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:h.label}),t===h.value?e.jsx(xs,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},h.value)),M.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:n}):null]})]})})})]})}const Fs="tokentracker-sessions";async function Is(a={}){const t=new URL(`/functions/${Fs}`,window.location.origin);a.from&&t.searchParams.set("from",a.from),a.to&&t.searchParams.set("to",a.to),a.limit&&t.searchParams.set("limit",String(a.limit)),a.refresh&&t.searchParams.set("refresh","1");const r=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),o=await r.json().catch(()=>null);if(!r.ok){const u=r.status===404?s("sessions.error.outdated_app"):`Request failed with HTTP ${r.status}`,p=new Error(o?.error||u);throw p.status=r.status,p}return o}function ze(a,t,{timeOnly:r=!1}={}){if(!a)return"—";const o=Date.parse(a);if(!Number.isFinite(o))return"—";const u=r?{hour:"2-digit",minute:"2-digit"}:{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};try{return new Date(o).toLocaleString(t||void 0,u)}catch{const p=new Date(o).toISOString();return r?p.slice(11,16):p.slice(0,16).replace("T"," ")}}function Ge(a){const t=Number(a);if(!Number.isFinite(t)||t<=0)return null;const r=Math.round(t/6e4);if(r<60)return s("sessions.duration.minutes",{minutes:r});const o=Math.floor(r/60),u=r%60;return s("sessions.duration.hours",{hours:o,minutes:u})}function W(a){return E(a?.own_total_tokens??a?.total_tokens)}function Os(a,t=0,r=1/0){if(!t&&r===1/0)return a;const o=a.map(n=>{if(!Array.isArray(n.usage_buckets))return{...n};const f=n.usage_buckets.filter(x=>{const g=Date.parse(x.timestamp);return g>=t&&g<=r}),k=new Map,j=Object.fromEntries([...ce,...fe].map(x=>[x,0]));let v=0,w=0;for(const x of f){v+=E(x.total_tokens),w+=E(x.cost_usd);const g=k.get(x.model)||{...(n.model_usage||[]).find(b=>b.model===x.model),model:x.model,...Object.fromEntries([...ce,...fe].map(b=>[b,0])),cost_usd:0,selected_models:[],reroute_reasons:[],model_attribution:"selected"};for(const b of[...ce,...fe]){const y=E(x[b]);j[b]+=y,g[b]+=y}g.cost_usd+=E(x.cost_usd);for(const b of["selected_models","reroute_reasons"])Array.isArray(x[b])&&(g[b]=[...new Set([...g[b],...x[b]])]);x.model_attribution==="effective"&&(g.model_attribution="effective"),k.set(x.model,g)}return{...n,...j,total_tokens:v,own_total_tokens:v,cost_usd:w,own_cost_usd:w,model_usage:[...k.values()]}}).filter(n=>!Array.isArray(n.usage_buckets)||W(n)>0),u=new Map;for(const n of o){if(!n.parent_session_hash)continue;const f=u.get(n.parent_session_hash)||[];f.push(n),u.set(n.parent_session_hash,f)}const p=(n,f=new Set)=>{if(f.has(n.session_hash))return{tokens:0,cost:0};const k=new Set(f).add(n.session_hash);let j=W(n),v=Z(n);for(const w of u.get(n.session_hash)||[]){const x=p(w,k);j+=x.tokens,v+=x.cost}return{tokens:j,cost:v}};for(const n of o){const f=p(n);n.combined_total_tokens=f.tokens,n.combined_cost_usd=f.cost,n.subagent_total_tokens=f.tokens-W(n),n.subagent_cost_usd=f.cost-Z(n)}return o}function Z(a){return E(a?.own_cost_usd??a?.cost_usd)}function E(a){const t=Number(a);return Number.isFinite(t)&&t>=0?t:0}const ce=["input_tokens","output_tokens","cached_input_tokens","cache_creation_input_tokens","reasoning_output_tokens","total_tokens"],fe=["long_context_","priority_","priority_long_context_"].flatMap(a=>ce.filter(t=>t!=="total_tokens").map(t=>a+t));function B(a){const t=Array.isArray(a?.model_usage)?a.model_usage.filter(r=>r&&typeof r.model=="string"&&r.model):[];return t.length?t:[{model:a?.model||"",total_tokens:W(a),cost_usd:Z(a),performance:a?.performance}]}function Rs(a){const t={estimated_output_tokens:0,estimated_duration_ms:0,estimated_request_count:0,estimated_tokens_per_second:null,first_response_total_ms:0,first_response_sample_count:0,first_response_ms:null};for(const r of a){const o=r?.performance;if(!o)continue;const u=E(o.estimated_duration_ms),p=E(o.estimated_output_tokens),n=E(o.estimated_request_count);u>0&&p>0&&n>0&&(t.estimated_output_tokens+=p,t.estimated_duration_ms+=u,t.estimated_request_count+=n);const f=E(o.first_response_sample_count),k=E(o.first_response_total_ms);f>0&&k>0&&(t.first_response_total_ms+=k,t.first_response_sample_count+=f)}return t.estimated_duration_ms>0&&(t.estimated_tokens_per_second=t.estimated_output_tokens*1e3/t.estimated_duration_ms),t.first_response_sample_count>0&&(t.first_response_ms=t.first_response_total_ms/t.first_response_sample_count),t}function Ke(a){const t=new Set,r=a.filter(o=>t.has(o.session_hash)?!1:(t.add(o.session_hash),!0));return{count:r.length,tokens:r.reduce((o,u)=>o+W(u),0),cost:r.reduce((o,u)=>o+Z(u),0),costIsPartial:r.some(o=>o.cost_is_partial),performance:Rs(r)}}function _e(a){const t=Date.parse(a?.ended_at||a?.started_at||"");return Number.isFinite(t)?t:0}function Es(a,t){return[...a].sort((r,o)=>(t==="cost"?Z(o)-Z(r):t==="tokens"?W(o)-W(r):0)||_e(o)-_e(r))}function de(a){const t=_e(a);if(!t)return"";const r=new Date(t);return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function $s(a,t){const r=new Map;for(const o of a){const u=t==="project"?o.project_key||"":de(o),p=r.get(u)||{key:u,sessions:[]};p.sessions.push(o),r.set(u,p)}return[...r.values()]}function Ps(a){const t=new URLSearchParams(a),r=t.get("source"),o=n=>{const f=t.get(n)||"";if(!/^\d{4}-\d{2}-\d{2}$/.test(f))return"";const k=new Date(`${f}T00:00:00`);return Number.isFinite(k.getTime())&&de({ended_at:k.toISOString()})===f?f:""},u=o("from"),p=o("to");return{source:["claude","codex","grok","zcode","opencode","kimi","omp"].includes(r)?r:"all",model:t.get("model")||"all",from:u,to:p}}function As(a,t,r){let o=t?new Date(`${t}T00:00:00`).getTime():0,u=r?new Date(`${r}T23:59:59.999`).getTime():1/0;o>u&&(o=new Date(`${r}T00:00:00`).getTime(),u=new Date(`${t}T23:59:59.999`).getTime());const p=Date.parse(a.ended_at||a.started_at||""),n=Date.parse(a.started_at||a.ended_at||"");return(!Number.isFinite(p)||p>=o)&&(!Number.isFinite(n)||n<=u)}function ae({performance:a,className:t=""}){const r=Number(a?.estimated_tokens_per_second),o=Number(a?.estimated_request_count||0);return!Number.isFinite(r)||r<=0||o<=0?null:e.jsx("span",{className:t,title:`${s("sessions.performance.samples",{count:o})}
|
|
2
|
-
${s("sessions.performance.method")}`,children:s("sessions.performance.speed",{speed:Number(r.toFixed(1))})})}const qs=[{key:"input_tokens",label:()=>s("dashboard.projects.detail.comp_input")},{key:"cached_input_tokens",label:()=>s("dashboard.projects.detail.comp_cached")},{key:"cache_creation_input_tokens",label:()=>s("dashboard.projects.detail.comp_cache_write")},{key:"output_tokens",label:()=>s("dashboard.projects.detail.comp_output")},{key:"reasoning_output_tokens",label:()=>s("dashboard.projects.detail.comp_reasoning")}],zs=[{key:"turns",label:()=>s("sessions.col.turns")},{key:"edit_turns",label:()=>s("sessions.col.edits")},{key:"retry_turns",label:()=>s("sessions.detail.retries")},{key:"subagent_calls",label:()=>s("sessions.card.subagents")},{key:"tool_calls",grokOnly:!0,label:()=>s("sessions.detail.tools")},{key:"tool_failures",grokOnly:!0,label:()=>s("sessions.detail.tool_failures")},{key:"error_count",grokOnly:!0,label:()=>s("sessions.detail.errors")},{key:"model_calls",grokOnly:!0,label:()=>s("sessions.detail.model_calls")},{key:"compaction_count",grokOnly:!0,label:()=>s("sessions.detail.compactions")}];function Gs(a){return a==="provider_reported"?s("sessions.detail.cost_reported"):a==="model_pricing"?s("sessions.detail.cost_estimated"):a==="mixed"?s("sessions.detail.cost_mixed"):s("sessions.detail.cost_unknown")}function Se(a){return String(a||"").startsWith("litellm")?s("sessions.detail.pricing_litellm"):String(a||"").startsWith("curated")?s("sessions.detail.pricing_curated"):null}function Ks(a,t){return t||Number(a)>0}function Ce({label:a,children:t}){return e.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:a}),e.jsx("dd",{className:"min-w-0 break-words text-right text-sm tabular-nums text-oai-black dark:text-white",children:t})]})}function le({label:a,title:t,className:r="",children:o}){return e.jsxs("div",{className:`min-w-0 border-oai-gray-200 px-3 py-2.5 dark:border-oai-gray-800 ${r}`,title:t,children:[e.jsx("dt",{className:"truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"mt-0.5 truncate text-base font-medium tabular-nums text-oai-black dark:text-white",children:o})]})}function Us({session:a,subagents:t=[],onClose:r}){const o=i.useRef(null),u=i.useRef(null),{currency:p,rate:n}=je(),{resolvedLocale:f}=Re(),k=c=>ke(c,{currency:p,rate:n}),j=B(a),v=i.useMemo(()=>Ke(t),[t]),w=W(a),x=Z(a),g=Number(a.subagent_total_tokens??v.tokens),b=Number(a.subagent_cost_usd??v.cost),y=a.performance,L=Number(y?.estimated_tokens_per_second)>0&&Number(y?.estimated_request_count)>0,S=Number(y?.first_response_sample_count)>0&&y?.first_response_ms!=null&&Number.isFinite(Number(y.first_response_ms)),P=S?{seconds:(Number(y.first_response_ms)/1e3).toFixed(2),count:y.first_response_sample_count}:null,T=Number(a.reasoning_output_tokens)>0,M=a.source==="grok",C=M&&Number(a.context_window_tokens)>0;i.useEffect(()=>{const c=document.activeElement,R=document.body.style.overflow;document.body.style.overflow="hidden",o.current?.focus();const $=F=>{if(F.key==="Escape"&&(F.preventDefault(),r()),F.key!=="Tab")return;const z=Array.from(u.current?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), summary, [tabindex="0"]')||[]),ee=z[0],se=z[z.length-1];ee?F.shiftKey&&(document.activeElement===ee||!u.current?.contains(document.activeElement))?(F.preventDefault(),se.focus()):!F.shiftKey&&(document.activeElement===se||!u.current?.contains(document.activeElement))&&(F.preventDefault(),ee.focus()):(F.preventDefault(),u.current?.focus())};return window.addEventListener("keydown",$),()=>{window.removeEventListener("keydown",$),document.body.style.overflow=R,c instanceof HTMLElement&&c.isConnected&&c.focus()}},[r]);const O=g>0||b>0,A=a.cost_is_partial||O&&v.costIsPartial,J=[{label:s("sessions.detail.own"),tokens:w,cost:x,partial:a.cost_is_partial},{label:s("sessions.detail.subagents"),tokens:g,cost:b,partial:v.costIsPartial}],h=a.agent_nickname||a.title||a.project_key||s("sessions.project.unknown"),D=Ge(a.duration_ms),I=[a.project_key&&a.project_key!==h?a.project_key:null,ze(a.started_at,f),D].filter(Boolean);return e.jsx("div",{className:"fixed inset-0 z-50 flex justify-end bg-black/20 dark:bg-black/40",onClick:c=>{c.target===c.currentTarget&&r()},children:e.jsxs("div",{ref:u,role:"dialog","aria-modal":"true","aria-label":s("sessions.detail.title"),tabIndex:-1,className:"flex h-full w-full max-w-[36rem] flex-col border-l border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex shrink-0 items-start gap-3 border-b border-oai-gray-200 px-5 py-4 dark:border-oai-gray-800",children:[e.jsx("span",{className:"shrink-0 pt-0.5 text-oai-gray-600 dark:text-oai-gray-300",children:e.jsx(Pe,{provider:String(a.source||"").toUpperCase(),size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"break-words text-base font-semibold leading-6 text-oai-black dark:text-white",children:h}),e.jsx("p",{className:"mt-0.5 break-words text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:I.join(" · ")})]}),e.jsx("button",{ref:o,type:"button",onClick:r,"aria-label":s("sessions.detail.close"),className:"-mr-2 -mt-1 flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white sm:h-9 sm:w-9",children:e.jsx(Ee,{size:18,"aria-hidden":!0})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-5",children:[e.jsxs("section",{"aria-label":s("sessions.detail.consumption"),children:[e.jsxs("dl",{className:"grid grid-cols-2 overflow-hidden rounded-lg border border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx(le,{label:s("sessions.col.tokens"),children:N(w+g)}),e.jsxs(le,{label:s("sessions.col.cost"),className:"border-l",children:[A?"≥":"",k(x+b)]}),e.jsx(le,{label:s("sessions.summary.speed"),className:"border-t",title:L?s("sessions.performance.samples",{count:y.estimated_request_count}):s("sessions.detail.no_speed"),children:L?e.jsx(ae,{performance:y}):"—"}),e.jsx(le,{label:s("sessions.performance.first_response"),className:"border-l border-t",title:s("sessions.performance.first_response_method"),children:S?Number(y.first_response_sample_count)===1?s("sessions.performance.first_response_value_single",P):s("sessions.performance.first_response_value",P):"—"})]}),O?e.jsx("dl",{className:"mt-3 space-y-1.5",children:J.map(c=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"text-oai-gray-600 dark:text-oai-gray-300",children:c.label}),e.jsx("dd",{className:"text-right tabular-nums",children:N(c.tokens)}),e.jsxs("dd",{className:"text-right tabular-nums",children:[c.partial?"≥":"",k(c.cost)]})]},c.label))}):null,e.jsxs("p",{className:"mt-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:[s("sessions.detail.cost_source")," · ",Gs(a.cost_source),a.cost_is_partial?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",s("sessions.cost.partial_title")]}):null,a.usage_is_incomplete?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",s("sessions.badge.partial_usage")]}):null]})]}),e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-white",children:s("sessions.detail.tokens")}),e.jsx("dl",{className:"mt-2 grid grid-cols-1 gap-x-8 gap-y-1.5 sm:grid-cols-2",children:qs.map(({key:c,label:R})=>e.jsx(Ce,{label:R(),children:a[c]==null?"—":N(a[c])},c))})]}),e.jsxs("section",{className:"mt-6",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-white",children:s("sessions.detail.models")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:s("sessions.col.tokens")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:s("sessions.col.cost")})]}),e.jsx("ul",{className:"mt-1 divide-y divide-oai-gray-100 dark:divide-oai-gray-800/70",children:j.map(c=>{const R=c.pricing?.status==="unpriced",$=a.cost_source==="provider_reported"&&j.length===1,F=$?x:c.cost_usd,z=Ks(F,$);return e.jsxs("li",{className:"py-2.5",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 break-words text-oai-black dark:text-white",children:c.model||s("sessions.model.unknown")}),e.jsx("span",{className:"text-right tabular-nums",children:N(c.total_tokens)}),e.jsx("span",{className:"text-right tabular-nums",children:R&&!z?"—":k(F)})]}),c.pricing?e.jsxs("details",{className:"group text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsxs("summary",{className:"flex min-h-10 cursor-pointer list-none items-center gap-2 rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 sm:min-h-0 sm:pt-1 [&::-webkit-details-marker]:hidden",children:[e.jsx(ae,{performance:c.performance,className:"tabular-nums"}),e.jsx("span",{className:"underline decoration-dotted underline-offset-4 group-open:no-underline",children:s("sessions.detail.pricing_details")})]}),e.jsxs("div",{className:"space-y-1 pt-1.5 leading-5",children:[R?e.jsx("p",{children:s("sessions.detail.pricing_unpriced")}):null,c.pricing.status==="free"?e.jsx("p",{children:s("sessions.detail.pricing_free")}):null,c.pricing.status==="priced"?e.jsx("p",{children:s("sessions.detail.pricing_rates",{input:c.pricing.input,output:c.pricing.output,cacheRead:c.pricing.cache_read,cacheWrite:c.pricing.cache_write})}):null,Se(c.pricing.source)?e.jsx("p",{children:Se(c.pricing.source)}):null]})]}):e.jsx(ae,{performance:c.performance,className:"block pt-1 text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400"})]},c.model)})})]}),e.jsxs("details",{className:"mt-5 border-t border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer items-center rounded text-sm font-medium text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white",children:s("sessions.detail.signals")}),e.jsx("dl",{className:"grid grid-cols-1 gap-x-8 gap-y-1.5 pb-4 sm:grid-cols-2",children:zs.map(({key:c,label:R,grokOnly:$})=>e.jsx(Ce,{label:R(),children:typeof a[c]=="number"&&(!$||M)?N(a[c]):s("sessions.detail.not_recorded")},c))}),M&&a.usage_precision?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.grok.runtime_breakdown",{calls:N(a.model_calls),seconds:(Number(a.api_duration_ms||0)/1e3).toFixed(1),tools:N(a.tool_calls),errors:N(a.error_count)})}):null,C?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.grok.context_breakdown",{used:N(a.context_tokens_used),window:N(a.context_window_tokens),percent:Number(a.context_usage_percent||0).toFixed(0)})}):null]}),e.jsxs("details",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer items-center rounded text-sm font-medium text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white",children:s("sessions.detail.identifiers")}),e.jsxs("dl",{className:"space-y-3 pb-4",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.detail.session_id")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.session_id||a.session_hash})]}),a.project_ref?e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.detail.local_path")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.project_ref})]}):null,a.resume_command?e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.detail.resume_command")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.resume_command})]}):null]})]}),e.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-oai-gray-200 pt-4 text-xs leading-5 text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[L?e.jsx("p",{children:s("sessions.performance.method")}):null,T?e.jsx("p",{children:s("sessions.detail.reasoning_note")}):null,e.jsx("p",{children:s("sessions.privacy")})]})]})]})})}const Te=_s(),De=[],be=100,Ws=[{id:"all",label:()=>s("usage.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"opencode",label:()=>"OpenCode"},{id:"grok",label:()=>"Grok"},{id:"zcode",label:()=>"ZCode"},{id:"kimi",label:()=>s("leaderboard.column.kimi")},{id:"omp",label:()=>"oh-my-pi"}],Ue=[{id:"all",days:0,label:()=>s("sessions.filter.range_label_all")},{id:"7d",days:7,label:()=>s("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>s("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>s("sessions.filter.range_90d")}];function Me(a){const t=Ue.find(o=>o.id===a)?.days||0;if(!t)return 0;const r=new Date;return r.setDate(r.getDate()-(t-1)),r.setHours(0,0,0,0),r.getTime()}function Hs(a,t){if(!t)return!0;const r=Date.parse(a.ended_at||a.started_at||"");return Number.isFinite(r)?r>=t:!0}function Vs(a){const t=Date.parse(a.started_at||"");return!Number.isFinite(t)||de({started_at:a.started_at})===de(a)}function Le(a){const t=B(a);return t.length===1?t[0].model||s("sessions.model.unknown"):t.map(r=>`${r.model} ${N(Number(r.total_tokens||0))}`).join(" · ")}async function Fe(a){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(a),!0;const t=document.createElement("textarea");t.value=a,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const r=document.execCommand("copy");return document.body.removeChild(t),r}function Bs(){const[a,t]=i.useState(!1),r=i.useId();return e.jsxs(ws,{open:a,onOpenChange:t,children:[e.jsx(Ns,{delay:150,closeDelay:100,closeOnClick:!1,onClick:()=>t(!0),"aria-label":s("sessions.summary.scope_help"),"aria-describedby":a?r:void 0,className:"sessions-summary-help relative inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white before:absolute before:-inset-2 before:content-['']",children:e.jsx(js,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx(Ss,{children:e.jsx(Cs,{side:"bottom",align:"end",sideOffset:12,className:"z-[60]",children:e.jsx(Ts,{id:r,role:"tooltip",className:"max-w-xs rounded-lg border border-oai-gray-200 bg-white p-4 text-sm leading-6 text-oai-gray-700 outline-none dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:s("sessions.summary.scope")})})})]})}const Ie=ye.memo(function({session:t,locale:r,nested:o=!1,timeOnly:u=!1,childCount:p=0,expanded:n=!1,onToggle:f,onDetail:k}){const{currency:j,rate:v}=je(),w=String(t.source||"").toUpperCase(),x=Ge(t.duration_ms),g=t.resume_command,b=t.project_key||s("sessions.project.unknown"),y=o||t.thread_kind==="subagent",L=y?t.agent_nickname||t.agent_role||t.title||b:t.title||b,S=t.usage_is_incomplete?s("sessions.badge.partial_usage"):t.cost_is_partial?s("sessions.badge.partial_cost"):null,P=t.project_ref?`${t.project_ref}
|
|
3
|
-
${s("sessions.project.copy_hint")}`:void 0,T=async()=>{if(t.project_ref)try{await Fe(t.project_ref)?Y({title:s("sessions.project.copied")}):Y({title:s("sessions.project.copy_failed")})}catch{Y({title:s("sessions.project.copy_failed")})}},M=O=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(ys,{text:P,placement:"bottom"}),e.jsx("button",{type:"button",onClick:T,"aria-label":s("sessions.project.copy_aria",{project:b}),className:Q("max-w-full truncate rounded text-left underline decoration-dotted decoration-oai-gray-300 underline-offset-4 hover:decoration-oai-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:decoration-oai-gray-600 dark:hover:decoration-oai-gray-400",O),children:b})]}),C=async()=>{if(g)try{await Fe(g)?Y({title:s("sessions.resume.copied")}):Y({title:s("sessions.resume.copy_failed")})}catch{Y({title:s("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:Q("sessions-row sessions-row-grid py-3",o&&"sessions-row-nested"),children:[e.jsxs("div",{className:"sessions-row-identity min-w-0",children:[e.jsx("span",{className:"sessions-row-provider inline-flex items-center justify-center text-oai-gray-600 dark:text-oai-gray-300","aria-hidden":"true",children:e.jsx(Pe,{provider:w,size:o?16:18})}),e.jsxs("div",{className:"contents",children:[e.jsx("button",{type:"button",onClick:()=>k(t),"aria-label":s("sessions.detail.open_aria",{title:L}),title:L,className:"sessions-row-title block min-h-9 min-w-0 max-w-full truncate rounded text-left text-sm font-medium text-oai-black underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white md:min-h-5",children:L}),e.jsxs("div",{className:"sessions-row-meta flex min-w-0 flex-wrap items-center gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{className:"sessions-meta-item min-w-0 max-w-full",children:t.project_ref?M("min-h-6 inline-flex items-center md:min-h-0"):e.jsx("span",{className:"truncate",children:b})}),e.jsx("span",{className:"sessions-meta-item min-w-0 max-w-full truncate",title:Le(t),children:Le(t)}),e.jsx("span",{className:"sessions-meta-item tabular-nums",children:ze(t.started_at,r,{timeOnly:u&&Vs(t)})}),x?e.jsx("span",{className:"sessions-meta-item tabular-nums",children:x}):null,Number.isFinite(t.session_store_bytes)?e.jsx("span",{className:"sessions-meta-item tabular-nums",title:s("sessions.storage.tooltip",{metric:s(t.session_store_metric==="allocated"?"sessions.storage.allocated":"sessions.storage.logical"),ratio:Math.round(t.bytes_per_1k_tokens||0).toLocaleString(r)}),children:s("sessions.storage.label",{size:s("sessions.storage.size",{value:(t.session_store_bytes/1024/1024).toLocaleString(r,{maximumFractionDigits:2})})})}):null,y?e.jsxs("span",{className:"sessions-meta-item",children:[s("sessions.badge.subagent"),t.agent_role?` · ${t.agent_role}`:""]}):null,t.first_pass?e.jsx("span",{className:"sessions-meta-item text-emerald-700 dark:text-emerald-300",children:s("sessions.badge.first_pass")}):null,S?e.jsx("span",{className:"sessions-meta-item text-amber-700 dark:text-amber-300",children:S}):null,t.cost_source==="provider_reported"?e.jsx("span",{className:"sessions-meta-item",children:s("sessions.badge.reported_cost")}):null,p?e.jsxs("button",{type:"button",onClick:()=>f(t.session_hash),"aria-expanded":n,className:"-mx-1.5 inline-flex min-h-8 items-center md:-my-1 md:ml-2 md:mr-0 gap-0.5 rounded px-1.5 font-medium text-oai-gray-700 hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white md:min-h-6",children:[e.jsx(cs,{className:Q("h-3.5 w-3.5 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),n?s("sessions.thread.collapse",{count:p}):s("sessions.thread.expand",{count:p})]}):null]})]})]}),e.jsxs("dl",{className:"sessions-row-metrics",children:[e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:s("sessions.col.tokens")}),e.jsxs("dd",{title:Number(t.subagent_total_tokens)?s("sessions.thread.tokens_summary",{own:N(t.own_total_tokens),subagents:N(t.subagent_total_tokens),combined:N(t.combined_total_tokens)}):void 0,className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",children:[N(t.total_tokens),Number(t.subagent_total_tokens)?e.jsxs("span",{className:"mt-0.5 block text-xs text-oai-gray-500 dark:text-oai-gray-400",children:["Σ ",N(t.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:s("sessions.col.cost")}),e.jsxs("dd",{className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",title:t.cost_is_partial?s("sessions.cost.partial_title"):void 0,children:[t.cost_is_partial?"≥":"",ke(t.cost_usd,{currency:j,rate:v})]})]}),e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:s("sessions.col.speed")}),e.jsx("dd",{className:"mt-1 min-h-5 text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 md:mt-0",children:e.jsx(ae,{performance:t.performance})})]})]}),e.jsx("button",{type:"button",onClick:C,disabled:!g,title:g||s("sessions.resume.unavailable"),"aria-label":g?s("sessions.resume.copy_aria",{command:g}):s("sessions.resume.unavailable"),className:"sessions-row-action inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 transition hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:cursor-not-allowed dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white md:h-8 md:w-8",children:e.jsx(vs,{className:"h-4 w-4","aria-hidden":!0})})]})});function Qs({sessions:a,selectedModel:t,onSelect:r}){const{groups:o,totalTokens:u}=i.useMemo(()=>{const n=new Map;let f=0;for(const k of a)for(const j of B(k)){const v=j.model||s("sessions.model.unknown"),w=Number(j.total_tokens||0),x=n.get(v)||{model:v,count:0,tokens:0};x.count+=1,x.tokens+=w,f+=w,n.set(v,x)}return{groups:[...n.values()].sort((k,j)=>j.tokens-k.tokens),totalTokens:f}},[a]);function p(n){return Q("min-h-10 rounded-md border px-2.5 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 md:min-h-7",n?"border-oai-brand-500 bg-oai-brand-50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-300":"border-oai-gray-200 text-oai-gray-600 hover:bg-oai-gray-100 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800")}return e.jsx("li",{className:"sessions-thread-models py-2.5",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"mr-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":t==="all",onClick:()=>r("all"),className:p(t==="all"),children:s("sessions.thread.model_all",{count:a.length,tokens:N(u)})}),o.map(n=>e.jsx("button",{type:"button","aria-pressed":t===n.model,onClick:()=>r(n.model),className:p(t===n.model),children:s("sessions.thread.model_item",{model:n.model,count:n.count,tokens:N(n.tokens)})},n.model))]})})}function bt(){const[a]=i.useState(()=>Ps(window.location.search)),[t,r]=i.useState(null),[o,u]=i.useState(null),[p,n]=i.useState(!0),[f,k]=i.useState(!1),[j,v]=i.useState(a.source),[w,x]=i.useState(a.model),[g,b]=i.useState(a.from||a.to?"custom":"all"),[y,L]=i.useState(a.from),[S,P]=i.useState(a.to),[T,M]=i.useState("all"),[C,O]=i.useState("time"),[A,J]=i.useState("recent"),[h,D]=i.useState(null),[I,c]=i.useState(""),[R,$]=i.useState(be),[F,z]=i.useState(()=>new Set),[ee,se]=i.useState(()=>new Map),re=i.useRef(0),{resolvedLocale:H}=Re(),{currency:We,rate:He}=je(),oe=i.useCallback(async(l=!1)=>{const m=++re.current;l?k(!0):n(!0),u(null);try{const d=await Is({refresh:l});m===re.current&&r(d)}catch(d){m===re.current&&u(d?.message||String(d))}finally{m===re.current&&(n(!1),k(!1))}},[]);i.useEffect(()=>{Te||we()?oe(!1):n(!1)},[oe]);const G=t?.sessions||De,Ve=i.useMemo(()=>{const l=new Set,m=[];for(const d of G){const _=d.project_key;!_||l.has(_)||(l.add(_),m.push({value:_,label:_}))}return m.sort((d,_)=>d.label.localeCompare(_.label))},[G]),Be=i.useMemo(()=>{const l=new Set;for(const m of G)for(const d of B(m))d.model&&l.add(d.model);return[...l].sort().map(m=>({value:m,label:m}))},[G]),ue=i.useDeferredValue(I),ne=i.useMemo(()=>{let m=Me(g),d=1/0;return g==="custom"&&(m=y?new Date(`${y}T00:00:00`).getTime():0,d=S?new Date(`${S}T23:59:59.999`).getTime():1/0,m>d&&(m=new Date(`${S}T00:00:00`).getTime(),d=new Date(`${y}T23:59:59.999`).getTime())),Os(G,m,d)},[G,g,y,S]),K=i.useMemo(()=>{const l=ue.trim().toLowerCase(),m=Me(g);return ne.filter(d=>{if(j!=="all"&&d.source!==j||T!=="all"&&d.project_key!==T||w!=="all"&&!B(d).some(U=>U.model===w))return!1;if(g==="custom"){if(!As(d,y,S))return!1}else if(!Hs(d,m))return!1;if(!l)return!0;const _=B(d).map(U=>U.model).join(" ");return`${d.title||""} ${d.project_key||""} ${_} ${d.agent_nickname||""} ${d.agent_role||""} ${d.project_ref||""} ${d.session_id||""}`.toLowerCase().includes(l)})},[ne,j,T,w,g,y,S,ue]),X=i.useMemo(()=>Ke(K),[K]),V=i.useMemo(()=>{const l=new Set(K.map(_=>_.session_hash)),m=new Map,d=[];for(const _ of Es(K,A)){const q=_.root_session_hash||_.parent_session_hash;if(_.parent_session_hash&&q&&l.has(q)){const U=m.get(q)||[];U.push(_),m.set(q,U)}else d.push(_)}return{roots:d,childrenByRoot:m,foldedCount:K.length-d.length}},[K,A]),me=j!=="all"||w!=="all"||g!=="all"||T!=="all"||I.trim()!=="";i.useEffect(()=>{$(be),z(new Set),se(new Map)},[j,T,w,g,y,S,ue,A,C,G]);const xe=i.useMemo(()=>V.roots.slice(0,R),[V.roots,R]),Qe=i.useMemo(()=>$s(xe,C),[xe,C]),Ze=i.useMemo(()=>h?ne.filter(l=>l.session_hash!==h.session_hash&&(l.root_session_hash===h.session_hash||l.parent_session_hash===h.session_hash)):De,[ne,h]),Xe=i.useCallback(()=>D(null),[]),ge=i.useCallback(l=>{b(l),l!=="custom"&&(L(""),P(""))},[]),Ye=i.useCallback(()=>{v("all"),x("all"),M("all"),c(""),ge("all")},[ge]),he=V.roots.length>xe.length,pe=i.useCallback(()=>$(l=>l+be),[]),Je=i.useCallback(l=>{z(m=>{const d=new Set(m);return d.has(l)?d.delete(l):d.add(l),d})},[]),es=i.useCallback((l,m)=>{se(d=>{const _=new Map(d);return m==="all"?_.delete(l):_.set(l,m),_})},[]),ve=i.useRef(null);i.useEffect(()=>{if(!he||typeof IntersectionObserver>"u")return;const l=ve.current;if(!l)return;const m=new IntersectionObserver(d=>{d.some(_=>_.isIntersecting)&&pe()},{rootMargin:"400px"});return m.observe(l),()=>m.disconnect()},[he,pe]);const ss=i.useMemo(()=>Ws.map(l=>({value:l.id,label:l.label()})),[H]),ts=i.useMemo(()=>[...Ue.map(l=>({value:l.id,label:l.label()})),{value:"custom",label:s("sessions.filter.range_custom")}],[H]),as=i.useMemo(()=>[{value:"time",label:s("sessions.group.time")},{value:"project",label:s("sessions.group.project")}],[H]),rs=i.useMemo(()=>[{value:"recent",label:s("sessions.sort.recent")},{value:"cost",label:s("sessions.sort.cost")},{value:"tokens",label:s("sessions.sort.tokens")}],[H]),os=Number(t?.session_count)>Number(t?.returned_count);return!Te&&!we()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(ds,{})}):e.jsxs("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:[e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"mb-3 text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:s("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:s("sessions.page.summary")})]}),e.jsx("button",{type:"button",onClick:()=>{oe(!0)},disabled:f||p,"aria-label":s("sessions.page.refresh"),title:s("sessions.page.refresh"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(ls,{className:Q("h-4 w-4",f&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-6 space-y-3",children:[e.jsxs("div",{className:"sessions-toolbar",children:[e.jsxs("div",{className:"sessions-toolbar-search relative",children:[e.jsx($e,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),e.jsx(us,{type:"search",value:I,onChange:l=>c(l.target.value),onKeyDown:l=>{l.key==="Escape"&&I&&(l.preventDefault(),c(""))},"aria-label":s("sessions.action.search_aria"),placeholder:s("sessions.search.placeholder"),className:"h-11 pl-10 pr-12 text-sm !bg-white dark:!bg-oai-gray-900 !border-oai-gray-200 placeholder:!text-oai-gray-500 dark:!border-oai-gray-800 dark:placeholder:!text-oai-gray-400 sm:h-9 [&::-webkit-search-cancel-button]:appearance-none"}),I?e.jsx("button",{type:"button",onMouseDown:l=>l.preventDefault(),onClick:()=>c(""),"aria-label":s("sessions.action.search_clear"),className:"absolute right-0 top-0 flex h-11 w-11 items-center justify-center rounded-md text-oai-gray-600 hover:bg-oai-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 sm:h-9 sm:w-9",children:e.jsx(Ee,{className:"h-4 w-4","aria-hidden":!0})}):null]}),e.jsx(ie,{ariaLabel:s("sessions.filter.source_aria"),options:ss,value:j,onValueChange:v,className:"sessions-filter-trigger h-11 min-w-0 px-3 text-sm sm:h-9",matchTriggerWidth:!0}),e.jsx(ie,{ariaLabel:s("sessions.filter.range_aria"),options:ts,value:g,onValueChange:ge,leadingIcon:e.jsx(Ds,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),className:"sessions-filter-trigger h-11 min-w-0 px-3 text-sm sm:h-9",matchTriggerWidth:!0}),e.jsx(Ne,{options:Ve,value:T,onChange:M,allLabel:s("sessions.filter.project_all"),searchPlaceholder:s("sessions.filter.project_search"),emptyLabel:s("sessions.filter.project_empty"),ariaLabel:s("sessions.filter.project_aria"),className:"sessions-filter-trigger !h-11 !w-full !max-w-none !px-3 !text-sm !font-normal sm:!h-9 !bg-white !text-oai-black dark:!bg-oai-gray-900 dark:!text-white [&>svg]:!text-oai-gray-500 dark:[&>svg]:!text-oai-gray-400"}),e.jsx(Ne,{options:Be,value:w,onChange:x,allLabel:s("sessions.filter.model_all"),searchPlaceholder:s("sessions.filter.model_search"),emptyLabel:s("sessions.filter.model_empty"),ariaLabel:s("sessions.filter.model_aria"),className:"sessions-filter-trigger sessions-model-filter !h-11 !w-full !max-w-none !px-3 !text-sm !font-normal sm:!h-9 !bg-white !text-oai-black dark:!bg-oai-gray-900 dark:!text-white [&>svg]:!text-oai-gray-500 dark:[&>svg]:!text-oai-gray-400"})]}),g==="custom"?e.jsxs("div",{className:"grid max-w-lg grid-cols-2 gap-3",children:[e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"mb-1 block",children:s("sessions.filter.from")}),e.jsx("input",{type:"date","aria-label":s("sessions.filter.from"),value:y,onChange:l=>L(l.target.value),className:"h-11 w-full min-w-0 rounded-md border border-oai-gray-200 bg-white px-3 text-sm outline-none focus:ring-2 focus:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:h-10"})]}),e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"mb-1 block",children:s("sessions.filter.to")}),e.jsx("input",{type:"date","aria-label":s("sessions.filter.to"),value:S,onChange:l=>P(l.target.value),className:"h-11 w-full min-w-0 rounded-md border border-oai-gray-200 bg-white px-3 text-sm outline-none focus:ring-2 focus:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:h-10"})]})]}):null]}),!p&&t?e.jsx("section",{className:"mb-6 flex items-start gap-3 rounded-lg border border-oai-gray-200 px-4 py-3 dark:border-oai-gray-800",children:e.jsxs("dl",{className:"sessions-kpis grid min-w-0 flex-1 grid-cols-2 gap-y-3 sm:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.summary.count")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:N(X.count)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.col.tokens")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:N(X.tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.col.cost")}),e.jsxs("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:[X.costIsPartial?"≥":"",ke(X.cost,{currency:We,rate:He})]})]}),e.jsxs("div",{children:[e.jsxs("dt",{className:"flex items-center gap-1.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:s("sessions.summary.speed")}),e.jsx(Bs,{})]}),e.jsxs("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:[e.jsx(ae,{performance:X.performance}),X.performance.estimated_tokens_per_second==null?"—":null]})]})]})}):null,e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-x-3 gap-y-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:V.foldedCount>0?s("sessions.thread.result_count",{roots:V.roots.length,subagents:V.foldedCount}):s("sessions.filter.result_count",{filtered:K.length,total:G.length})}),me?e.jsx("button",{type:"button",onClick:Ye,className:"inline-flex min-h-10 items-center rounded text-oai-gray-700 underline decoration-oai-gray-300 underline-offset-4 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-200 dark:decoration-oai-gray-600 dark:hover:text-white sm:min-h-0",children:s("sessions.filter.clear")}):null]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ie,{ariaLabel:s("sessions.group.aria"),options:as,value:C,onValueChange:O,className:"sessions-filter-trigger h-11 min-w-0 max-w-40 px-2.5 text-xs sm:h-8"}),e.jsx(ie,{ariaLabel:s("sessions.sort.aria"),options:rs,value:A,onValueChange:J,className:"sessions-filter-trigger h-11 min-w-0 max-w-44 px-2.5 text-xs sm:h-8",align:"end"})]})]}),os?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.truncated",{shown:t.returned_count,total:t.session_count})}):null,o&&!t?e.jsxs("div",{className:"rounded-xl border border-dashed border-red-300 py-16 text-center dark:border-red-500/40",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:s("sessions.error.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o}),e.jsx("button",{type:"button",onClick:()=>{oe(!1)},className:"mt-4 inline-flex h-11 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:s("sessions.error.retry")})]}):p?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(ks,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),s("sessions.loading")]}):K.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-oai-gray-200 py-16 text-center dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:me?s("sessions.empty.filtered_title"):s("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:me?s("sessions.empty.filtered_body"):s("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[o?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:s("shared.error.prefix",{error:o})}):null,e.jsxs("div",{className:"sessions-row-grid sessions-list-header border-b border-oai-gray-200 py-2 text-xs text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400","aria-hidden":!0,children:[e.jsx("span",{children:s("sessions.col.session")}),e.jsx("span",{className:"text-right",children:s("sessions.col.tokens")}),e.jsx("span",{className:"text-right",children:s("sessions.col.cost")}),e.jsx("span",{className:"text-right",children:s("sessions.col.speed")}),e.jsx("span",{className:"sr-only",children:s("sessions.col.actions")})]}),e.jsx("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:Qe.map(l=>e.jsxs(ye.Fragment,{children:[e.jsx("li",{className:"pb-2 pt-5",children:e.jsx("h2",{className:"break-words text-xs font-medium text-oai-gray-900 dark:text-oai-gray-100",children:C==="project"?l.key||s("sessions.project.unknown"):l.key?new Date(`${l.key}T12:00:00`).toLocaleDateString(H||void 0,{year:"numeric",month:"short",day:"numeric"}):s("sessions.group.unknown_date")})}),l.sessions.map(m=>{const d=V.childrenByRoot.get(m.session_hash)||[],_=F.has(m.session_hash),q=ee.get(m.session_hash)||"all",U=q==="all"?d:d.filter(function(ns){return B(ns).some(is=>is.model===q)});return e.jsxs(ye.Fragment,{children:[e.jsx(Ie,{session:m,locale:H,timeOnly:C==="time",childCount:d.length,expanded:_,onToggle:Je,onDetail:D}),_&&d.length?e.jsx(Qs,{sessions:d,selectedModel:q,onSelect:te=>es(m.session_hash,te)}):null,_?U.map(te=>e.jsx(Ie,{session:te,locale:H,nested:!0,timeOnly:C==="time",onDetail:D},te.session_hash)):null]},m.session_hash)})]},l.key))}),he?e.jsx("div",{ref:ve,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:pe,className:"inline-flex h-11 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:s("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-8 max-w-3xl text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.privacy")})]})}),h?e.jsx(Us,{session:h,subagents:Ze,onClose:Xe}):null]})}export{bt as SessionsPage};
|