tokentracker-cli 0.5.49 → 0.5.50

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.
@@ -1 +1 @@
1
- import{aa as s,D as n,ab as d}from"./main-DQ3-Wn2t.js";function v({children:i,delay:t=0,duration:o=.4,y:e=20,className:a="",once:r=!0}){return s()?n.jsx("div",{className:a,children:i}):n.jsx(d.div,{initial:{opacity:0,y:e},animate:{opacity:1,y:0},transition:{duration:o,delay:t,ease:[.25,.1,.25,1]},className:a,children:i})}function x({children:i,staggerDelay:t=.1,initialDelay:o=0,className:e=""}){return s()?n.jsx("div",{className:e,children:i}):n.jsx(d.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:t,delayChildren:o}}},className:e,children:i})}function h({children:i,className:t="",y:o=20}){return s()?n.jsx("div",{className:t,children:i}):n.jsx(d.div,{variants:{hidden:{opacity:0,y:o},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.25,.1,.25,1]}}},className:t,children:i})}export{v as F,x as S,h as a};
1
+ import{aa as s,D as n,ab as d}from"./main-C3JziweS.js";function v({children:i,delay:t=0,duration:o=.4,y:e=20,className:a="",once:r=!0}){return s()?n.jsx("div",{className:a,children:i}):n.jsx(d.div,{initial:{opacity:0,y:e},animate:{opacity:1,y:0},transition:{duration:o,delay:t,ease:[.25,.1,.25,1]},className:a,children:i})}function x({children:i,staggerDelay:t=.1,initialDelay:o=0,className:e=""}){return s()?n.jsx("div",{className:e,children:i}):n.jsx(d.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:t,delayChildren:o}}},className:e,children:i})}function h({children:i,className:t="",y:o=20}){return s()?n.jsx("div",{className:t,children:i}):n.jsx(d.div,{variants:{hidden:{opacity:0,y:o},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.25,.1,.25,1]}}},className:t,children:i})}export{v as F,x as S,h as a};
@@ -1 +1 @@
1
- import{D as e,ay as d,az as Ae,aA as Ce,ah as Ee,ai as Pe,r as x,aB as Te,h as Re,j as Me,B as o,aC as $e,aD as T,aE as Be,au as z,aF as le,aG as de,aH as Ie}from"./main-DQ3-Wn2t.js";import{L as be,a as he,b as M,l as D,c as F,d as Ue,e as ce}from"./leaderboard-columns-VBGLNKay.js";function S(t,{min:r,max:s,fallback:n}){const i=Number(t);if(!Number.isFinite(i))return n;const c=Math.floor(i);return c<r?r:c>s?s:c}function ze(t,r){const s=S(r,{min:0,max:1e6,fallback:0}),n=S(t,{min:1,max:Math.max(1,s||1),fallback:1});if(s<=1)return[1];const i=new Set([1,s,n-2,n-1,n,n+1,n+2]),c=Array.from(i).filter(m=>Number.isInteger(m)&&m>=1&&m<=s).sort((m,b)=>m-b),u=[];let w=null;for(const m of c)w!=null&&m-w>1&&u.push(null),u.push(m),w=m;return u}function De({page:t,totalPages:r}){const s=typeof r=="number"&&Number.isFinite(r)&&r>=0,n=s?S(r,{min:0,max:1e6,fallback:0}):null,i=S(t,{min:1,max:s?Math.max(1,n||1):1e6,fallback:1}),c=i>1,u=s?i<n:!0;return{canPrev:c,canNext:u,safePage:i,safeTotal:n}}function Fe({entries:t,me:r,meLabel:s,limit:n}){const i=S(n,{min:1,max:1e3,fallback:20}),c=Array.isArray(t)?t.slice(0,i):[],u=r&&typeof r.rank=="number"?r.rank:null,w=c.some(h=>!!h?.is_me);if(!u||w)return c;const m={rank:u,is_me:!0,display_name:s,avatar_url:null,gpt_tokens:r?.gpt_tokens??"0",claude_tokens:r?.claude_tokens??"0",gemini_tokens:r?.gemini_tokens??"0",cursor_tokens:r?.cursor_tokens??"0",opencode_tokens:r?.opencode_tokens??"0",openclaw_tokens:r?.openclaw_tokens??"0",other_tokens:r?.other_tokens??"0",total_tokens:r?.total_tokens??"0"},b=3,g=4,y=c.filter(h=>!h?.is_me).filter((h,C)=>C!==b).slice();return y.splice(Math.min(g,y.length),0,m),y.slice(0,i)}function p({className:t}){return e.jsx("div",{className:d("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Ke({index:t}){const r=t<3?"w-24":t<8?"w-20":"w-16",s=t<3?"w-16":"w-12",n=t<5?"w-14":"w-10";return e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:d(D(!1),"!group-hover:bg-transparent"),children:e.jsx(p,{className:"h-4 w-6"})}),e.jsx("td",{className:d(F(!1),"!group-hover:bg-transparent"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(p,{className:"h-8 w-8 min-w-8 rounded-full"}),e.jsx(p,{className:d("h-4",r)})]})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(p,{className:d("h-4",s)})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(p,{className:"h-4 w-12"})}),M.map(i=>e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(p,{className:d("h-4",n)})},i.key))]})}function Oe({rows:t=10}){return e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(be,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(p,{className:"h-3.5 w-6"})}),e.jsx("th",{className:d(he,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(p,{className:"h-3.5 w-12"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(p,{className:"h-3.5 w-10"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(p,{className:"h-3.5 w-14"})}),M.map(r=>e.jsx("th",{className:"px-4 py-4",children:e.jsx(p,{className:"h-3.5 w-12"})},r.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:t},(r,s)=>e.jsx(Ke,{index:s},s))})]})})}const R=20;function xe(t){const r=Number(t);return!Number.isFinite(r)||r<=0?"-":r>=1e3?`$${Math.round(r).toLocaleString()}`:r>=10?`$${Math.round(r)}`:`$${r.toFixed(2)}`}function me(t,r){const s=r?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",n=r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60";return M.map(i=>e.jsx("td",{className:d("px-4 py-4 whitespace-nowrap text-right tabular-nums",s,n),children:z(t?.[i.key])},i.key))}const He={1:{text:"text-amber-600 dark:text-amber-400",badge:"bg-amber-50 dark:bg-amber-900/20"},2:{text:"text-gray-500 dark:text-gray-300",badge:"bg-gray-50 dark:bg-gray-800/40"},3:{text:"text-orange-700 dark:text-orange-400",badge:"bg-orange-50 dark:bg-orange-900/20"}};function ge({rank:t,placeholder:r}){const s=He[t];return s?e.jsx("span",{className:d("inline-flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold",s.text,s.badge),children:t}):e.jsx("span",{className:"inline-flex items-center justify-center h-7 w-7 text-sm",children:t??r})}function K(t){if(typeof t!="string")return null;const r=t.trim().toLowerCase();return r==="week"||r==="month"||r==="total"?r:null}function We(t){if(!t)return o("shared.error.prefix",{error:o("leaderboard.error.unknown")});const r=t?.message||String(t),s=String(r||"").trim()||o("leaderboard.error.unknown");return o("shared.error.prefix",{error:s})}function fe(t){return typeof t!="string"?"":t.trim()}function Ge(t){const r=fe(t);return r?r.toLowerCase()==="anonymous":!0}function Ye(t,r=""){if(typeof t!="string")return null;const s=t.trim().toLowerCase();if(!s)return null;const n=new URLSearchParams(typeof r=="string"?r:""),i=K(n.get("period")),c=i?`?period=${i}`:"";return`/share/pv1-${s}${c}`}function ue(t,r){const s=typeof t?.user_id=="string"?t.user_id.trim():"";return s||`${t?.rank??""}:${r}`}function Qe({auth:t,signedIn:r,sessionSoftExpired:s}){const n=Ae(),i=Ce(),{openLoginModal:c}=Ee(),{signedIn:u,loading:w}=Pe(),m=x.useMemo(()=>Te(),[]),b=Re(),g=r&&!s,O=x.useMemo(()=>g&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,g]),y=g?O:null,h=g&&Me(y),C=o("shared.placeholder.short"),[$,L]=x.useState(1),[pe,H]=x.useState(0),[f,E]=x.useState(()=>({loading:!1,error:null,data:null})),[W,ye]=x.useState(()=>$e()),[G,Y]=x.useState(!1),[V,q]=x.useState(!1),j=x.useMemo(()=>{const a=new URLSearchParams(n?.search||"");return K(a.get("period"))||"total"},[n?.search]),ke=n?.search||"",we=a=>{const l=K(a);if(!l||l===j)return;const _=new URLSearchParams(n?.search||"");_.set("period",l),L(1),i(`${n?.pathname||"/leaderboard"}?${_.toString()}`,{replace:!0})};x.useEffect(()=>{w||b||u||c()},[u,w,b,c]),x.useEffect(()=>{L(1)},[j]),x.useEffect(()=>{b||g&&(h||E({loading:!1,error:null,data:null}))},[g,h,b]);const J=x.useMemo(()=>(S($,{min:1,max:1e6,fallback:1})-1)*R,[$]);x.useEffect(()=>{if(!m&&!b||!b&&g&&!h)return;let a=!0;return E(l=>({...l,loading:!0,error:null})),(async()=>{const l=g?await T(y):null,_=await Be({accessToken:l,period:j,limit:R,offset:J});a&&E({loading:!1,error:null,data:_})})().catch(l=>{a&&E({loading:!1,error:We(l),data:null})}),()=>{a=!1}},[m,y,g,h,J,pe,b,j]);const k=f.data,P=k?.total_pages??null,v=k?.page??$,je=x.useMemo(()=>ze(v,P),[v,P]),Q=k?.from||null,X=k?.to||null,Z=k?.generated_at||null,ee=k?.me||null,B=o("leaderboard.me_label"),Ne=o("leaderboard.anon_label"),ae=o("leaderboard.period.week"),re=o("leaderboard.period.month"),te=o("leaderboard.period.total"),se=j==="month"?re:j==="total"?te:ae,I=x.useMemo(()=>{const a=Array.isArray(k?.entries)?k.entries:[];return v!==1?a:Fe({entries:a,me:ee,meLabel:B,limit:R})},[v,k?.entries,ee,B]),ve=async()=>{Y(!0);try{Ie(!0),ye(!0),await le(()=>T(y));const a=await T(y);a&&await de({accessToken:a}),H(l=>l+1)}catch(a){console.warn("[tokentracker] sync:",a)}finally{Y(!1)}},_e=async()=>{q(!0);try{const a=await T(y);W&&a&&await le(()=>Promise.resolve(a)),a&&await de({accessToken:a}),H(l=>l+1)}catch(a){console.warn("[tokentracker] refresh:",a)}finally{q(!1)}},{canPrev:oe,canNext:ne}=De({page:v,totalPages:P}),Se=Array.isArray(I)&&I.length!==0;let A=null;f.loading?A=e.jsx(Oe,{rows:R}):f.error?A=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:f.error})}):Se?A=e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(be,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:o("leaderboard.column.rank")}),e.jsx("th",{className:d(he,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:o("leaderboard.column.user")}),e.jsx("th",{className:"px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",children:o("leaderboard.column.total")}),e.jsx("th",{className:"px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",title:"Based on estimated API pricing, not actual billing",children:"Est. Cost"}),M.map(a=>e.jsx("th",{className:"px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap align-middle",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsx(Ue,{iconSrc:a.icon,label:o(a.copyKey)})})},a.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:I.map(a=>{const l=!!a?.is_me,_=typeof a?.user_id=="string"?a.user_id:null,ie=fe(a?.display_name),Le=Ge(ie)?Ne:ie,N=l?B:Le;return!!_&&!l&&!!a?.is_public&&Ye(_,ke),l?e.jsxs("tr",{className:"border-y border-oai-brand-300/40 dark:border-oai-brand-500/30 bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",children:[e.jsx("td",{className:d(D(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400"),children:e.jsx(ge,{rank:a?.rank,placeholder:C})}),e.jsx("td",{className:F(!0),children:e.jsxs("div",{className:"flex min-w-0 max-w-[min(160px,40vw)] items-center gap-4",children:[e.jsx(ce,{avatarUrl:a?.avatar_url,displayName:N,seed:ue(a,N)}),e.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:N})]})}),e.jsx("td",{className:"px-4 py-4 font-medium text-oai-black dark:text-oai-white whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",children:z(a?.total_tokens)}),e.jsx("td",{className:"px-4 py-4 font-medium text-oai-brand-600 dark:text-oai-brand-400 whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",title:"Based on estimated API pricing, not actual billing",children:xe(a?.estimated_cost_usd)}),me(a,!0)]},`row-${a?.rank}-${N}`):e.jsxs("tr",{className:"group transition-colors",children:[e.jsx("td",{className:d(D(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(ge,{rank:a?.rank,placeholder:C})}),e.jsx("td",{className:F(!1),children:e.jsxs("div",{className:"flex min-w-0 max-w-[min(160px,40vw)] items-center gap-4",children:[e.jsx(ce,{avatarUrl:a?.avatar_url,displayName:N,seed:ue(a,N)}),e.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:N})]})}),e.jsx("td",{className:"px-4 py-4 font-semibold text-oai-gray-800 dark:text-oai-gray-200 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",children:z(a?.total_tokens)}),e.jsx("td",{className:"px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",title:"Based on estimated API pricing, not actual billing",children:xe(a?.estimated_cost_usd)}),me(a,!1)]},`row-${a?.rank}-${N}`)})})]})}):A=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o("leaderboard.empty")})});let U=null;return typeof P=="number"?U=je.map((a,l)=>a==null?e.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:o("leaderboard.pagination.ellipsis")},`ellipsis-${l}`):e.jsx("button",{className:d("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",a===v?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white"),onClick:()=>L(a),disabled:f.loading,children:String(a)},`page-${a}`)):U=e.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o("leaderboard.pagination.page_unknown",{page:String(v)})}),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:"flex flex-col md:flex-row md:items-end justify-between gap-6 mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:o("leaderboard.title")}),e.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[j==="total"?o("leaderboard.range.total"):Q&&X?o("leaderboard.range",{period:se,from:Q,to:X}):o("leaderboard.range_loading",{period:se}),Z&&e.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:o("leaderboard.generated_at",{ts:Z})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[g&&h&&e.jsx("button",{onClick:_e,disabled:V||f.loading,className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white transition-colors disabled:opacity-50",children:V?"Refreshing...":"↻"}),e.jsx("div",{className:"inline-flex p-1 border border-oai-gray-200 dark:border-oai-gray-800 rounded-lg",children:["week","month","total"].map(a=>e.jsx("button",{onClick:()=>we(a),disabled:f.loading,className:d("px-4 py-1.5 text-sm font-medium rounded-md transition-colors",j===a?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200"),children:a==="week"?ae:a==="month"?re:te},a))})]})]}),!r&&e.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:"Sign in to join the leaderboard"}),e.jsx("button",{onClick:c,className:"px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 transition-colors",children:"Sign In"})]}),g&&h&&!W&&e.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:"Enable Cloud Sync to appear in rankings"}),e.jsx("button",{onClick:ve,disabled:G,className:"px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 disabled:opacity-50 transition-colors",children:G?"Syncing...":"Enable & Sync"})]}),e.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:[A,e.jsxs("div",{className:"px-6 py-3 border-t border-oai-gray-200 dark:border-oai-gray-800 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:d("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",oe&&!f.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>L(a=>Math.max(1,a-1)),disabled:!oe||f.loading,children:o("leaderboard.pagination.prev")}),e.jsx("button",{className:d("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",ne&&!f.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>L(a=>a+1),disabled:!ne||f.loading,children:o("leaderboard.pagination.next")})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:U})]})]})]})}),e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("p",{children:o("landing.v2.footer.line")}),e.jsx("a",{href:"https://github.com/mm7894215/TokenTracker",className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:o("landing.v2.nav.github")})]})})]})}export{Qe as LeaderboardPage};
1
+ import{D as e,ay as d,az as Ae,aA as Ce,ah as Ee,ai as Pe,r as x,aB as Te,h as Re,j as Me,B as o,aC as $e,aD as T,aE as Be,au as z,aF as le,aG as de,aH as Ie}from"./main-C3JziweS.js";import{L as be,a as he,b as M,l as D,c as F,d as Ue,e as ce}from"./leaderboard-columns-DRWp1P6y.js";function S(t,{min:r,max:s,fallback:n}){const i=Number(t);if(!Number.isFinite(i))return n;const c=Math.floor(i);return c<r?r:c>s?s:c}function ze(t,r){const s=S(r,{min:0,max:1e6,fallback:0}),n=S(t,{min:1,max:Math.max(1,s||1),fallback:1});if(s<=1)return[1];const i=new Set([1,s,n-2,n-1,n,n+1,n+2]),c=Array.from(i).filter(m=>Number.isInteger(m)&&m>=1&&m<=s).sort((m,b)=>m-b),u=[];let w=null;for(const m of c)w!=null&&m-w>1&&u.push(null),u.push(m),w=m;return u}function De({page:t,totalPages:r}){const s=typeof r=="number"&&Number.isFinite(r)&&r>=0,n=s?S(r,{min:0,max:1e6,fallback:0}):null,i=S(t,{min:1,max:s?Math.max(1,n||1):1e6,fallback:1}),c=i>1,u=s?i<n:!0;return{canPrev:c,canNext:u,safePage:i,safeTotal:n}}function Fe({entries:t,me:r,meLabel:s,limit:n}){const i=S(n,{min:1,max:1e3,fallback:20}),c=Array.isArray(t)?t.slice(0,i):[],u=r&&typeof r.rank=="number"?r.rank:null,w=c.some(h=>!!h?.is_me);if(!u||w)return c;const m={rank:u,is_me:!0,display_name:s,avatar_url:null,gpt_tokens:r?.gpt_tokens??"0",claude_tokens:r?.claude_tokens??"0",gemini_tokens:r?.gemini_tokens??"0",cursor_tokens:r?.cursor_tokens??"0",opencode_tokens:r?.opencode_tokens??"0",openclaw_tokens:r?.openclaw_tokens??"0",other_tokens:r?.other_tokens??"0",total_tokens:r?.total_tokens??"0"},b=3,g=4,y=c.filter(h=>!h?.is_me).filter((h,C)=>C!==b).slice();return y.splice(Math.min(g,y.length),0,m),y.slice(0,i)}function p({className:t}){return e.jsx("div",{className:d("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Ke({index:t}){const r=t<3?"w-24":t<8?"w-20":"w-16",s=t<3?"w-16":"w-12",n=t<5?"w-14":"w-10";return e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:d(D(!1),"!group-hover:bg-transparent"),children:e.jsx(p,{className:"h-4 w-6"})}),e.jsx("td",{className:d(F(!1),"!group-hover:bg-transparent"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(p,{className:"h-8 w-8 min-w-8 rounded-full"}),e.jsx(p,{className:d("h-4",r)})]})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(p,{className:d("h-4",s)})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(p,{className:"h-4 w-12"})}),M.map(i=>e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(p,{className:d("h-4",n)})},i.key))]})}function Oe({rows:t=10}){return e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(be,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(p,{className:"h-3.5 w-6"})}),e.jsx("th",{className:d(he,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(p,{className:"h-3.5 w-12"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(p,{className:"h-3.5 w-10"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(p,{className:"h-3.5 w-14"})}),M.map(r=>e.jsx("th",{className:"px-4 py-4",children:e.jsx(p,{className:"h-3.5 w-12"})},r.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:t},(r,s)=>e.jsx(Ke,{index:s},s))})]})})}const R=20;function xe(t){const r=Number(t);return!Number.isFinite(r)||r<=0?"-":r>=1e3?`$${Math.round(r).toLocaleString()}`:r>=10?`$${Math.round(r)}`:`$${r.toFixed(2)}`}function me(t,r){const s=r?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",n=r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60";return M.map(i=>e.jsx("td",{className:d("px-4 py-4 whitespace-nowrap text-right tabular-nums",s,n),children:z(t?.[i.key])},i.key))}const He={1:{text:"text-amber-600 dark:text-amber-400",badge:"bg-amber-50 dark:bg-amber-900/20"},2:{text:"text-gray-500 dark:text-gray-300",badge:"bg-gray-50 dark:bg-gray-800/40"},3:{text:"text-orange-700 dark:text-orange-400",badge:"bg-orange-50 dark:bg-orange-900/20"}};function ge({rank:t,placeholder:r}){const s=He[t];return s?e.jsx("span",{className:d("inline-flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold",s.text,s.badge),children:t}):e.jsx("span",{className:"inline-flex items-center justify-center h-7 w-7 text-sm",children:t??r})}function K(t){if(typeof t!="string")return null;const r=t.trim().toLowerCase();return r==="week"||r==="month"||r==="total"?r:null}function We(t){if(!t)return o("shared.error.prefix",{error:o("leaderboard.error.unknown")});const r=t?.message||String(t),s=String(r||"").trim()||o("leaderboard.error.unknown");return o("shared.error.prefix",{error:s})}function fe(t){return typeof t!="string"?"":t.trim()}function Ge(t){const r=fe(t);return r?r.toLowerCase()==="anonymous":!0}function Ye(t,r=""){if(typeof t!="string")return null;const s=t.trim().toLowerCase();if(!s)return null;const n=new URLSearchParams(typeof r=="string"?r:""),i=K(n.get("period")),c=i?`?period=${i}`:"";return`/share/pv1-${s}${c}`}function ue(t,r){const s=typeof t?.user_id=="string"?t.user_id.trim():"";return s||`${t?.rank??""}:${r}`}function Qe({auth:t,signedIn:r,sessionSoftExpired:s}){const n=Ae(),i=Ce(),{openLoginModal:c}=Ee(),{signedIn:u,loading:w}=Pe(),m=x.useMemo(()=>Te(),[]),b=Re(),g=r&&!s,O=x.useMemo(()=>g&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,g]),y=g?O:null,h=g&&Me(y),C=o("shared.placeholder.short"),[$,L]=x.useState(1),[pe,H]=x.useState(0),[f,E]=x.useState(()=>({loading:!1,error:null,data:null})),[W,ye]=x.useState(()=>$e()),[G,Y]=x.useState(!1),[V,q]=x.useState(!1),j=x.useMemo(()=>{const a=new URLSearchParams(n?.search||"");return K(a.get("period"))||"total"},[n?.search]),ke=n?.search||"",we=a=>{const l=K(a);if(!l||l===j)return;const _=new URLSearchParams(n?.search||"");_.set("period",l),L(1),i(`${n?.pathname||"/leaderboard"}?${_.toString()}`,{replace:!0})};x.useEffect(()=>{w||b||u||c()},[u,w,b,c]),x.useEffect(()=>{L(1)},[j]),x.useEffect(()=>{b||g&&(h||E({loading:!1,error:null,data:null}))},[g,h,b]);const J=x.useMemo(()=>(S($,{min:1,max:1e6,fallback:1})-1)*R,[$]);x.useEffect(()=>{if(!m&&!b||!b&&g&&!h)return;let a=!0;return E(l=>({...l,loading:!0,error:null})),(async()=>{const l=g?await T(y):null,_=await Be({accessToken:l,period:j,limit:R,offset:J});a&&E({loading:!1,error:null,data:_})})().catch(l=>{a&&E({loading:!1,error:We(l),data:null})}),()=>{a=!1}},[m,y,g,h,J,pe,b,j]);const k=f.data,P=k?.total_pages??null,v=k?.page??$,je=x.useMemo(()=>ze(v,P),[v,P]),Q=k?.from||null,X=k?.to||null,Z=k?.generated_at||null,ee=k?.me||null,B=o("leaderboard.me_label"),Ne=o("leaderboard.anon_label"),ae=o("leaderboard.period.week"),re=o("leaderboard.period.month"),te=o("leaderboard.period.total"),se=j==="month"?re:j==="total"?te:ae,I=x.useMemo(()=>{const a=Array.isArray(k?.entries)?k.entries:[];return v!==1?a:Fe({entries:a,me:ee,meLabel:B,limit:R})},[v,k?.entries,ee,B]),ve=async()=>{Y(!0);try{Ie(!0),ye(!0),await le(()=>T(y));const a=await T(y);a&&await de({accessToken:a}),H(l=>l+1)}catch(a){console.warn("[tokentracker] sync:",a)}finally{Y(!1)}},_e=async()=>{q(!0);try{const a=await T(y);W&&a&&await le(()=>Promise.resolve(a)),a&&await de({accessToken:a}),H(l=>l+1)}catch(a){console.warn("[tokentracker] refresh:",a)}finally{q(!1)}},{canPrev:oe,canNext:ne}=De({page:v,totalPages:P}),Se=Array.isArray(I)&&I.length!==0;let A=null;f.loading?A=e.jsx(Oe,{rows:R}):f.error?A=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:f.error})}):Se?A=e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(be,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:o("leaderboard.column.rank")}),e.jsx("th",{className:d(he,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:o("leaderboard.column.user")}),e.jsx("th",{className:"px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",children:o("leaderboard.column.total")}),e.jsx("th",{className:"px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",title:"Based on estimated API pricing, not actual billing",children:"Est. Cost"}),M.map(a=>e.jsx("th",{className:"px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap align-middle",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsx(Ue,{iconSrc:a.icon,label:o(a.copyKey)})})},a.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:I.map(a=>{const l=!!a?.is_me,_=typeof a?.user_id=="string"?a.user_id:null,ie=fe(a?.display_name),Le=Ge(ie)?Ne:ie,N=l?B:Le;return!!_&&!l&&!!a?.is_public&&Ye(_,ke),l?e.jsxs("tr",{className:"border-y border-oai-brand-300/40 dark:border-oai-brand-500/30 bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",children:[e.jsx("td",{className:d(D(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400"),children:e.jsx(ge,{rank:a?.rank,placeholder:C})}),e.jsx("td",{className:F(!0),children:e.jsxs("div",{className:"flex min-w-0 max-w-[min(160px,40vw)] items-center gap-4",children:[e.jsx(ce,{avatarUrl:a?.avatar_url,displayName:N,seed:ue(a,N)}),e.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:N})]})}),e.jsx("td",{className:"px-4 py-4 font-medium text-oai-black dark:text-oai-white whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",children:z(a?.total_tokens)}),e.jsx("td",{className:"px-4 py-4 font-medium text-oai-brand-600 dark:text-oai-brand-400 whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",title:"Based on estimated API pricing, not actual billing",children:xe(a?.estimated_cost_usd)}),me(a,!0)]},`row-${a?.rank}-${N}`):e.jsxs("tr",{className:"group transition-colors",children:[e.jsx("td",{className:d(D(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(ge,{rank:a?.rank,placeholder:C})}),e.jsx("td",{className:F(!1),children:e.jsxs("div",{className:"flex min-w-0 max-w-[min(160px,40vw)] items-center gap-4",children:[e.jsx(ce,{avatarUrl:a?.avatar_url,displayName:N,seed:ue(a,N)}),e.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:N})]})}),e.jsx("td",{className:"px-4 py-4 font-semibold text-oai-gray-800 dark:text-oai-gray-200 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",children:z(a?.total_tokens)}),e.jsx("td",{className:"px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",title:"Based on estimated API pricing, not actual billing",children:xe(a?.estimated_cost_usd)}),me(a,!1)]},`row-${a?.rank}-${N}`)})})]})}):A=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o("leaderboard.empty")})});let U=null;return typeof P=="number"?U=je.map((a,l)=>a==null?e.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:o("leaderboard.pagination.ellipsis")},`ellipsis-${l}`):e.jsx("button",{className:d("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",a===v?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white"),onClick:()=>L(a),disabled:f.loading,children:String(a)},`page-${a}`)):U=e.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o("leaderboard.pagination.page_unknown",{page:String(v)})}),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:"flex flex-col md:flex-row md:items-end justify-between gap-6 mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:o("leaderboard.title")}),e.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[j==="total"?o("leaderboard.range.total"):Q&&X?o("leaderboard.range",{period:se,from:Q,to:X}):o("leaderboard.range_loading",{period:se}),Z&&e.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:o("leaderboard.generated_at",{ts:Z})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[g&&h&&e.jsx("button",{onClick:_e,disabled:V||f.loading,className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white transition-colors disabled:opacity-50",children:V?"Refreshing...":"↻"}),e.jsx("div",{className:"inline-flex p-1 border border-oai-gray-200 dark:border-oai-gray-800 rounded-lg",children:["week","month","total"].map(a=>e.jsx("button",{onClick:()=>we(a),disabled:f.loading,className:d("px-4 py-1.5 text-sm font-medium rounded-md transition-colors",j===a?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200"),children:a==="week"?ae:a==="month"?re:te},a))})]})]}),!r&&e.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:"Sign in to join the leaderboard"}),e.jsx("button",{onClick:c,className:"px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 transition-colors",children:"Sign In"})]}),g&&h&&!W&&e.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:"Enable Cloud Sync to appear in rankings"}),e.jsx("button",{onClick:ve,disabled:G,className:"px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 disabled:opacity-50 transition-colors",children:G?"Syncing...":"Enable & Sync"})]}),e.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:[A,e.jsxs("div",{className:"px-6 py-3 border-t border-oai-gray-200 dark:border-oai-gray-800 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:d("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",oe&&!f.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>L(a=>Math.max(1,a-1)),disabled:!oe||f.loading,children:o("leaderboard.pagination.prev")}),e.jsx("button",{className:d("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",ne&&!f.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>L(a=>a+1),disabled:!ne||f.loading,children:o("leaderboard.pagination.next")})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:U})]})]})]})}),e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("p",{children:o("landing.v2.footer.line")}),e.jsx("a",{href:"https://github.com/mm7894215/TokenTracker",className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:o("landing.v2.nav.github")})]})})]})}export{Qe as LeaderboardPage};
@@ -1 +1 @@
1
- import{r as n,D as e,az as $,C as H,aB as W,h as Y,j as Z,aD as G,aI as J,B as a,ay as L,au as I,a9 as E,aJ as q,aK as F}from"./main-DQ3-Wn2t.js";import{b as R,d as Q,l as V,f as X,e as ee,L as re,g as ae}from"./leaderboard-columns-VBGLNKay.js";const y=18;function O(){return e.jsxs("svg",{"aria-hidden":!0,width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"4"}),e.jsx("path",{d:"M12 2v2"}),e.jsx("path",{d:"M12 20v2"}),e.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),e.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),e.jsx("path",{d:"M2 12h2"}),e.jsx("path",{d:"M20 12h2"}),e.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),e.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function P(){return e.jsx("svg",{"aria-hidden":!0,width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function te(){return e.jsxs("svg",{"aria-hidden":!0,width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8"}),e.jsx("path",{d:"M12 17v4"})]})}const oe=[{value:"light",label:"Light",Icon:O},{value:"dark",label:"Dark",Icon:P},{value:"system",label:"System",Icon:te}];function se(r){return r==="dark"?P:O}function ne({theme:r,resolvedTheme:s,onSetTheme:b,className:d="",direction:p="down",align:T="right"}){const[c,k]=n.useState(!1),h=n.useRef(null),i=n.useCallback(()=>k(!1),[]);n.useEffect(()=>{if(!c)return;const t=l=>{h.current&&!h.current.contains(l.target)&&i()};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[c,i]),n.useEffect(()=>{if(!c)return;const t=l=>{l.key==="Escape"&&i()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[c,i]);const x=se(s);return e.jsxs("div",{ref:h,className:`relative ${d}`,children:[e.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":c,onClick:()=>k(t=>!t),className:"flex items-center justify-center w-9 h-9 rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors",children:e.jsx(x,{})}),c&&e.jsx("div",{className:`absolute z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg ${p==="up"?"bottom-full mb-1":"top-full mt-1"} ${T==="left"?"left-0":"right-0"}`,children:oe.map(({value:t,label:l,Icon:j})=>{const m=r===t;return e.jsxs("button",{type:"button",onClick:()=>{b(t),i()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-sm transition-colors ${m?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"}`,children:[e.jsx(j,{}),e.jsx("span",{children:l})]},t)})})]})}function ie(r){if(!r)return a("shared.error.prefix",{error:a("leaderboard.error.unknown")});const s=r?.message||String(r),b=String(s||"").trim()||a("leaderboard.error.unknown");return a("shared.error.prefix",{error:b})}function le(r){return typeof r!="string"?"":r.trim()}function de(r){if(typeof r!="string")return null;const s=r.trim().toLowerCase();return s==="week"||s==="month"||s==="total"?s:null}function me({auth:r,signedIn:s,sessionSoftExpired:b,userId:d}){const p=$(),{theme:T,resolvedTheme:c,setTheme:k}=H(),h=n.useMemo(()=>W(),[]),i=Y(),x=s&&!b,t=n.useMemo(()=>x&&(typeof r=="function"||typeof r=="string"||r&&typeof r=="object")?r:null,[r,x]),l=x?t:null,j=x&&Z(l),m=n.useMemo(()=>{const o=new URLSearchParams(p?.search||"");return de(o.get("period"))||"week"},[p?.search]),_=p?.search||"",[v,w]=n.useState(()=>({loading:!1,error:null,data:null}));n.useEffect(()=>{if(!h&&!i||!d||!i&&(!x||!j))return;let o=!0;return w(f=>({...f,loading:!0,error:null})),(async()=>{const f=await G(l);if(!o)return;if(!f){w({loading:!1,error:null,data:null});return}const U=await J({accessToken:f,userId:d,period:m});o&&w({loading:!1,error:null,data:U})})().catch(f=>{o&&w({loading:!1,error:ie(f),data:null})}),()=>{o=!1}},[x,j,h,l,i,m,d]);const N=v.data,C=N?.from||null,M=N?.to||null,A=N?.generated_at||null,g=N?.entry||null,S=le(g?.display_name)||a("leaderboard.anon_label"),z=a("leaderboard.period.week"),D=a("leaderboard.period.month"),K=a("leaderboard.period.total"),B=m==="month"?D:m==="total"?K:z;let u=null;return d?v.loading?u=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("leaderboard.loading")})}):v.error?u=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v.error})}):g?u=e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:L(re,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:a("leaderboard.column.rank")}),e.jsx("th",{className:L(ae,"font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap"),children:a("leaderboard.column.total")}),R.map(o=>e.jsx("th",{className:"px-4 py-4 font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:e.jsx(Q,{iconSrc:o.icon,label:a(o.copyKey)})},o.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:e.jsxs("tr",{className:"transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60",children:[e.jsx("td",{className:L(V(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:g?.rank??a("shared.placeholder.short")}),e.jsx("td",{className:L(X(),"text-oai-gray-700 dark:text-oai-gray-300"),children:I(g?.total_tokens)}),R.map(o=>e.jsx("td",{className:"px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:I(g?.[o.key])},o.key))]})})]})}):u=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("leaderboard.empty")})}):u=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("leaderboard.empty")})}),e.jsxs("div",{className:"flex flex-col min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-oai antialiased transition-colors duration-200",children:[e.jsx("header",{className:"sticky top-0 z-50 bg-white/80 dark:bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-200 dark:border-oai-gray-900 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsxs(E,{to:"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),e.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(q,{})})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx(E,{to:`/leaderboard${_}`,className:"no-underline inline-flex items-center justify-center h-9 px-5 text-sm font-medium rounded-full shadow-sm ring-1 ring-oai-gray-200 dark:ring-white/10 bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-900 hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors",children:a("leaderboard.profile.nav.back")}),e.jsx(ne,{theme:T,resolvedTheme:c,onSetTheme:k}),e.jsx(F,{})]})]})}),e.jsx("main",{className:"flex-1 py-12 sm:py-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-6 mb-10",children:[e.jsx(ee,{avatarUrl:g?.avatar_url,displayName:S,seed:typeof d=="string"?d:S,size:"lg",className:"shrink-0 ring-2 ring-oai-gray-200 dark:ring-oai-gray-800"}),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:S}),e.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[m==="total"?a("leaderboard.range.total"):C&&M?a("leaderboard.range",{period:B,from:C,to:M}):a("leaderboard.range_loading",{period:B}),A&&e.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:a("leaderboard.generated_at",{ts:A})})]})]})]}),e.jsx("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:u})]})}),e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("p",{children:a("landing.v2.footer.line")}),e.jsx(E,{to:`/leaderboard${_}`,className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:a("leaderboard.profile.nav.back")})]})})]})}export{me as LeaderboardProfilePage};
1
+ import{r as n,D as e,az as $,C as H,aB as W,h as Y,j as Z,aD as G,aI as J,B as a,ay as L,au as I,a9 as E,aJ as q,aK as F}from"./main-C3JziweS.js";import{b as R,d as Q,l as V,f as X,e as ee,L as re,g as ae}from"./leaderboard-columns-DRWp1P6y.js";const y=18;function O(){return e.jsxs("svg",{"aria-hidden":!0,width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"4"}),e.jsx("path",{d:"M12 2v2"}),e.jsx("path",{d:"M12 20v2"}),e.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),e.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),e.jsx("path",{d:"M2 12h2"}),e.jsx("path",{d:"M20 12h2"}),e.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),e.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function P(){return e.jsx("svg",{"aria-hidden":!0,width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function te(){return e.jsxs("svg",{"aria-hidden":!0,width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8"}),e.jsx("path",{d:"M12 17v4"})]})}const oe=[{value:"light",label:"Light",Icon:O},{value:"dark",label:"Dark",Icon:P},{value:"system",label:"System",Icon:te}];function se(r){return r==="dark"?P:O}function ne({theme:r,resolvedTheme:s,onSetTheme:b,className:d="",direction:p="down",align:T="right"}){const[c,k]=n.useState(!1),h=n.useRef(null),i=n.useCallback(()=>k(!1),[]);n.useEffect(()=>{if(!c)return;const t=l=>{h.current&&!h.current.contains(l.target)&&i()};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[c,i]),n.useEffect(()=>{if(!c)return;const t=l=>{l.key==="Escape"&&i()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[c,i]);const x=se(s);return e.jsxs("div",{ref:h,className:`relative ${d}`,children:[e.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":c,onClick:()=>k(t=>!t),className:"flex items-center justify-center w-9 h-9 rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors",children:e.jsx(x,{})}),c&&e.jsx("div",{className:`absolute z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg ${p==="up"?"bottom-full mb-1":"top-full mt-1"} ${T==="left"?"left-0":"right-0"}`,children:oe.map(({value:t,label:l,Icon:j})=>{const m=r===t;return e.jsxs("button",{type:"button",onClick:()=>{b(t),i()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-sm transition-colors ${m?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"}`,children:[e.jsx(j,{}),e.jsx("span",{children:l})]},t)})})]})}function ie(r){if(!r)return a("shared.error.prefix",{error:a("leaderboard.error.unknown")});const s=r?.message||String(r),b=String(s||"").trim()||a("leaderboard.error.unknown");return a("shared.error.prefix",{error:b})}function le(r){return typeof r!="string"?"":r.trim()}function de(r){if(typeof r!="string")return null;const s=r.trim().toLowerCase();return s==="week"||s==="month"||s==="total"?s:null}function me({auth:r,signedIn:s,sessionSoftExpired:b,userId:d}){const p=$(),{theme:T,resolvedTheme:c,setTheme:k}=H(),h=n.useMemo(()=>W(),[]),i=Y(),x=s&&!b,t=n.useMemo(()=>x&&(typeof r=="function"||typeof r=="string"||r&&typeof r=="object")?r:null,[r,x]),l=x?t:null,j=x&&Z(l),m=n.useMemo(()=>{const o=new URLSearchParams(p?.search||"");return de(o.get("period"))||"week"},[p?.search]),_=p?.search||"",[v,w]=n.useState(()=>({loading:!1,error:null,data:null}));n.useEffect(()=>{if(!h&&!i||!d||!i&&(!x||!j))return;let o=!0;return w(f=>({...f,loading:!0,error:null})),(async()=>{const f=await G(l);if(!o)return;if(!f){w({loading:!1,error:null,data:null});return}const U=await J({accessToken:f,userId:d,period:m});o&&w({loading:!1,error:null,data:U})})().catch(f=>{o&&w({loading:!1,error:ie(f),data:null})}),()=>{o=!1}},[x,j,h,l,i,m,d]);const N=v.data,C=N?.from||null,M=N?.to||null,A=N?.generated_at||null,g=N?.entry||null,S=le(g?.display_name)||a("leaderboard.anon_label"),z=a("leaderboard.period.week"),D=a("leaderboard.period.month"),K=a("leaderboard.period.total"),B=m==="month"?D:m==="total"?K:z;let u=null;return d?v.loading?u=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("leaderboard.loading")})}):v.error?u=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v.error})}):g?u=e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:L(re,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:a("leaderboard.column.rank")}),e.jsx("th",{className:L(ae,"font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap"),children:a("leaderboard.column.total")}),R.map(o=>e.jsx("th",{className:"px-4 py-4 font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:e.jsx(Q,{iconSrc:o.icon,label:a(o.copyKey)})},o.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:e.jsxs("tr",{className:"transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60",children:[e.jsx("td",{className:L(V(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:g?.rank??a("shared.placeholder.short")}),e.jsx("td",{className:L(X(),"text-oai-gray-700 dark:text-oai-gray-300"),children:I(g?.total_tokens)}),R.map(o=>e.jsx("td",{className:"px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:I(g?.[o.key])},o.key))]})})]})}):u=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("leaderboard.empty")})}):u=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("leaderboard.empty")})}),e.jsxs("div",{className:"flex flex-col min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-oai antialiased transition-colors duration-200",children:[e.jsx("header",{className:"sticky top-0 z-50 bg-white/80 dark:bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-200 dark:border-oai-gray-900 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsxs(E,{to:"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),e.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(q,{})})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx(E,{to:`/leaderboard${_}`,className:"no-underline inline-flex items-center justify-center h-9 px-5 text-sm font-medium rounded-full shadow-sm ring-1 ring-oai-gray-200 dark:ring-white/10 bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-900 hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors",children:a("leaderboard.profile.nav.back")}),e.jsx(ne,{theme:T,resolvedTheme:c,onSetTheme:k}),e.jsx(F,{})]})]})}),e.jsx("main",{className:"flex-1 py-12 sm:py-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-6 mb-10",children:[e.jsx(ee,{avatarUrl:g?.avatar_url,displayName:S,seed:typeof d=="string"?d:S,size:"lg",className:"shrink-0 ring-2 ring-oai-gray-200 dark:ring-oai-gray-800"}),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:S}),e.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[m==="total"?a("leaderboard.range.total"):C&&M?a("leaderboard.range",{period:B,from:C,to:M}):a("leaderboard.range_loading",{period:B}),A&&e.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:a("leaderboard.generated_at",{ts:A})})]})]})]}),e.jsx("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:u})]})}),e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("p",{children:a("landing.v2.footer.line")}),e.jsx(E,{to:`/leaderboard${_}`,className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:a("leaderboard.profile.nav.back")})]})})]})}export{me as LeaderboardProfilePage};
@@ -1 +1 @@
1
- import{D as r,ay as g,B as x,a9 as f,aL as _}from"./main-DQ3-Wn2t.js";import{u as j}from"./use-usage-limits-DiPkCZg-.js";import{u as b}from"./use-limits-display-prefs-B1qdCsIA.js";import{C as h}from"./Card-CDFJQidU.js";import{F as v}from"./FadeIn-Dt-Uvlsi.js";const k=[3,2,3,3,2,3];function o({className:s}){return r.jsx("div",{className:g("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",s)})}function N(){return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(o,{className:"h-3 w-12 shrink-0"}),r.jsx(o,{className:"flex-1 h-1.5 rounded-full min-w-0"}),r.jsx(o,{className:"h-3 w-[30px] shrink-0"}),r.jsx(o,{className:"h-3 w-6 shrink-0"})]})}function L({bars:s,index:e}){const a=e%3===0?"w-24":e%3===1?"w-20":"w-[4.5rem]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(o,{className:"h-[14px] w-[14px] rounded shrink-0"}),r.jsx(o,{className:g("h-4",a)})]}),Array.from({length:s},(i,l)=>r.jsx(N,{},l))]})}function P(){return r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(o,{className:"h-3.5 w-28"}),k.map((s,e)=>r.jsx(L,{bars:s,index:e},e))]})})}function n(s){if(!s)return null;const e=typeof s=="number"?s*1e3:Date.parse(s);if(!Number.isFinite(e))return null;const a=e-Date.now();if(a<=0)return"now";const i=Math.floor(a/6e4);if(i<60)return`${i}m`;const l=Math.floor(i/60);return l<24?`${l}h`:`${Math.floor(l/24)}d`}function C(s){return s>=90?"bg-red-500":s>=70?"bg-amber-500":"bg-emerald-500"}function t({label:s,pct:e,reset:a}){const i=Math.max(0,Math.min(100,Number(e)||0)),l=Math.round(i),m=i>0&&l===0?Math.max(i,.35):i,d=i>0&&l===0?"<1":String(l);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 w-12 shrink-0",children:s}),r.jsx("div",{className:"flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:r.jsx("div",{className:`${C(l)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${m}%`,minWidth:i>0?"3px":0}})}),r.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-[30px] text-right shrink-0",children:[d,"%"]}),a?r.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:a}):null]})}function c({name:s,icon:e,children:a}){const l=e==="/brand-logos/cursor.svg"||e==="/brand-logos/kiro.svg"?"w-[14px] h-[14px] dark:invert":"w-[14px] h-[14px]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[e?r.jsx("img",{src:e,alt:"",className:l}):null,r.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:s})]}),a]})}const R=["claude","codex","cursor","gemini","kiro","antigravity"];function A(s,e){if(!(i=>i?.configured&&!i.error)(e))return null;switch(s){case"claude":return r.jsxs(c,{name:"Claude",icon:"/brand-logos/claude-code.svg",children:[e.five_hour?r.jsx(t,{label:"5h",pct:e.five_hour.utilization,reset:n(e.five_hour.resets_at)}):null,e.seven_day?r.jsx(t,{label:"7d",pct:e.seven_day.utilization,reset:n(e.seven_day.resets_at)}):null,e.seven_day_opus?r.jsx(t,{label:"Opus",pct:e.seven_day_opus.utilization,reset:n(e.seven_day_opus.resets_at)}):null]},"claude");case"codex":return r.jsxs(c,{name:"Codex",icon:"/brand-logos/codex.svg",children:[e.primary_window?r.jsx(t,{label:"5h",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"7d",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null]},"codex");case"cursor":return r.jsxs(c,{name:"Cursor",icon:"/brand-logos/cursor.svg",children:[e.primary_window?r.jsx(t,{label:"Plan",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"Auto",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(t,{label:"API",pct:e.tertiary_window.used_percent,reset:n(e.tertiary_window.reset_at)}):null]},"cursor");case"gemini":return r.jsxs(c,{name:"Gemini",icon:"/brand-logos/gemini.svg",children:[e.primary_window?r.jsx(t,{label:"Pro",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"Flash",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(t,{label:"Lite",pct:e.tertiary_window.used_percent,reset:n(e.tertiary_window.reset_at)}):null]},"gemini");case"kiro":return r.jsxs(c,{name:"Kiro",icon:"/brand-logos/kiro.svg",children:[e.primary_window?r.jsx(t,{label:"Month",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"Bonus",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null]},"kiro");case"antigravity":return r.jsxs(c,{name:"Antigravity",icon:"/brand-logos/antigravity.svg",children:[e.primary_window?r.jsx(t,{label:"Claude",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"G Pro",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(t,{label:"Flash",pct:e.tertiary_window.used_percent,reset:n(e.tertiary_window.reset_at)}):null]},"antigravity");default:return null}}function B({claude:s,codex:e,cursor:a,gemini:i,kiro:l,antigravity:m,order:d,visibility:w}){const y={claude:s,codex:e,cursor:a,gemini:i,kiro:l,antigravity:m},p=(Array.isArray(d)&&d.length>0?d:R).filter(u=>!w||w[u]!==!1).map(u=>A(u,y[u])).filter(Boolean);return p.length===0?null:r.jsx(v,{delay:.15,children:r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:"Usage Limits"}),p]})})})}function E(){const{data:s,error:e,isLoading:a}=j({initialRefresh:!0}),i=b();return r.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:r.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:r.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[r.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:x("nav.limits")}),r.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:x("limits.page.subtitle")})]}),r.jsx(f,{to:"/settings","aria-label":x("limits.page.openSettings"),title:x("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:r.jsx(_,{className:"h-4 w-4","aria-hidden":!0})})]}),a?r.jsx(P,{}):r.jsxs(r.Fragment,{children:[e?r.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:x("shared.error.prefix",{error:e})}):null,r.jsx(B,{claude:s?.claude,codex:s?.codex,cursor:s?.cursor,gemini:s?.gemini,kiro:s?.kiro,antigravity:s?.antigravity,order:i.order,visibility:i.visibility})]})]})})})}export{E as LimitsPage};
1
+ import{D as r,ay as g,B as x,a9 as f,aL as _}from"./main-C3JziweS.js";import{u as j}from"./use-usage-limits-Dy8QZkuK.js";import{u as b}from"./use-limits-display-prefs-BWWU7eSJ.js";import{C as h}from"./Card-CvuIXN78.js";import{F as v}from"./FadeIn-70qYAVWA.js";const k=[3,2,3,3,2,3];function o({className:s}){return r.jsx("div",{className:g("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",s)})}function N(){return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(o,{className:"h-3 w-12 shrink-0"}),r.jsx(o,{className:"flex-1 h-1.5 rounded-full min-w-0"}),r.jsx(o,{className:"h-3 w-[30px] shrink-0"}),r.jsx(o,{className:"h-3 w-6 shrink-0"})]})}function L({bars:s,index:e}){const a=e%3===0?"w-24":e%3===1?"w-20":"w-[4.5rem]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(o,{className:"h-[14px] w-[14px] rounded shrink-0"}),r.jsx(o,{className:g("h-4",a)})]}),Array.from({length:s},(i,l)=>r.jsx(N,{},l))]})}function P(){return r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(o,{className:"h-3.5 w-28"}),k.map((s,e)=>r.jsx(L,{bars:s,index:e},e))]})})}function n(s){if(!s)return null;const e=typeof s=="number"?s*1e3:Date.parse(s);if(!Number.isFinite(e))return null;const a=e-Date.now();if(a<=0)return"now";const i=Math.floor(a/6e4);if(i<60)return`${i}m`;const l=Math.floor(i/60);return l<24?`${l}h`:`${Math.floor(l/24)}d`}function C(s){return s>=90?"bg-red-500":s>=70?"bg-amber-500":"bg-emerald-500"}function t({label:s,pct:e,reset:a}){const i=Math.max(0,Math.min(100,Number(e)||0)),l=Math.round(i),m=i>0&&l===0?Math.max(i,.35):i,d=i>0&&l===0?"<1":String(l);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 w-12 shrink-0",children:s}),r.jsx("div",{className:"flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:r.jsx("div",{className:`${C(l)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${m}%`,minWidth:i>0?"3px":0}})}),r.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-[30px] text-right shrink-0",children:[d,"%"]}),a?r.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:a}):null]})}function c({name:s,icon:e,children:a}){const l=e==="/brand-logos/cursor.svg"||e==="/brand-logos/kiro.svg"?"w-[14px] h-[14px] dark:invert":"w-[14px] h-[14px]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[e?r.jsx("img",{src:e,alt:"",className:l}):null,r.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:s})]}),a]})}const R=["claude","codex","cursor","gemini","kiro","antigravity"];function A(s,e){if(!(i=>i?.configured&&!i.error)(e))return null;switch(s){case"claude":return r.jsxs(c,{name:"Claude",icon:"/brand-logos/claude-code.svg",children:[e.five_hour?r.jsx(t,{label:"5h",pct:e.five_hour.utilization,reset:n(e.five_hour.resets_at)}):null,e.seven_day?r.jsx(t,{label:"7d",pct:e.seven_day.utilization,reset:n(e.seven_day.resets_at)}):null,e.seven_day_opus?r.jsx(t,{label:"Opus",pct:e.seven_day_opus.utilization,reset:n(e.seven_day_opus.resets_at)}):null]},"claude");case"codex":return r.jsxs(c,{name:"Codex",icon:"/brand-logos/codex.svg",children:[e.primary_window?r.jsx(t,{label:"5h",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"7d",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null]},"codex");case"cursor":return r.jsxs(c,{name:"Cursor",icon:"/brand-logos/cursor.svg",children:[e.primary_window?r.jsx(t,{label:"Plan",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"Auto",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(t,{label:"API",pct:e.tertiary_window.used_percent,reset:n(e.tertiary_window.reset_at)}):null]},"cursor");case"gemini":return r.jsxs(c,{name:"Gemini",icon:"/brand-logos/gemini.svg",children:[e.primary_window?r.jsx(t,{label:"Pro",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"Flash",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(t,{label:"Lite",pct:e.tertiary_window.used_percent,reset:n(e.tertiary_window.reset_at)}):null]},"gemini");case"kiro":return r.jsxs(c,{name:"Kiro",icon:"/brand-logos/kiro.svg",children:[e.primary_window?r.jsx(t,{label:"Month",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"Bonus",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null]},"kiro");case"antigravity":return r.jsxs(c,{name:"Antigravity",icon:"/brand-logos/antigravity.svg",children:[e.primary_window?r.jsx(t,{label:"Claude",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"G Pro",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(t,{label:"Flash",pct:e.tertiary_window.used_percent,reset:n(e.tertiary_window.reset_at)}):null]},"antigravity");default:return null}}function B({claude:s,codex:e,cursor:a,gemini:i,kiro:l,antigravity:m,order:d,visibility:w}){const y={claude:s,codex:e,cursor:a,gemini:i,kiro:l,antigravity:m},p=(Array.isArray(d)&&d.length>0?d:R).filter(u=>!w||w[u]!==!1).map(u=>A(u,y[u])).filter(Boolean);return p.length===0?null:r.jsx(v,{delay:.15,children:r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:"Usage Limits"}),p]})})})}function E(){const{data:s,error:e,isLoading:a}=j({initialRefresh:!0}),i=b();return r.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:r.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:r.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[r.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:x("nav.limits")}),r.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:x("limits.page.subtitle")})]}),r.jsx(f,{to:"/settings","aria-label":x("limits.page.openSettings"),title:x("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:r.jsx(_,{className:"h-4 w-4","aria-hidden":!0})})]}),a?r.jsx(P,{}):r.jsxs(r.Fragment,{children:[e?r.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:x("shared.error.prefix",{error:e})}):null,r.jsx(B,{claude:s?.claude,codex:s?.codex,cursor:s?.cursor,gemini:s?.gemini,kiro:s?.kiro,antigravity:s?.antigravity,order:i.order,visibility:i.visibility})]})]})})})}export{E as LimitsPage};
@@ -1 +1 @@
1
- import{r as o,b as X,f as Y,aN as R,D as e,e as T,aO as Z,aP as J,aQ as ee,aR as H,aS as te,aT as ae,ab as F,B as s,ay as k,C as ne,aU as se,aV as ie,aW as oe,ai as re,ah as ce,aC as le,aD as D,aX as de,aH as ue,aF as ge,aY as P,aj as me,aZ as xe}from"./main-DQ3-Wn2t.js";import{L as he,a as B,u as ye}from"./use-limits-display-prefs-B1qdCsIA.js";import{C as fe}from"./Card-CDFJQidU.js";import{D as be}from"./download-DsypqQx5.js";const pe=t=>!t.isLayoutDirty&&t.willUpdate(!1);function G(){const t=new Set,a=new WeakMap,n=()=>t.forEach(pe);return{add:i=>{t.add(i),a.set(i,i.addEventListener("willUpdate",n))},remove:i=>{t.delete(i);const r=a.get(i);r&&(r(),a.delete(i)),n()},dirty:n}}const ke=o.createContext(null);function ve(){const t=o.useRef(!1);return X(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function je(){const t=ve(),[a,n]=o.useState(0),i=o.useCallback(()=>{t.current&&n(a+1)},[a]);return[o.useCallback(()=>Y.postRender(i),[i]),a]}const U=t=>t===!0,Ne=t=>U(t===!0)||t==="id",we=({children:t,id:a,inherit:n=!0})=>{const i=o.useContext(R),r=o.useContext(ke),[m,d]=je(),x=o.useRef(null),u=i.id||r;x.current===null&&(Ne(n)&&u&&(a=a?u+"-"+a:u),x.current={id:a,group:U(n)&&i.group||G()});const b=o.useMemo(()=>({...x.current,forceRender:m}),[d]);return e.jsx(R.Provider,{value:b,children:t})};const Se=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ce=T("grip-vertical",Se);const Le=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ie=T("log-out",Le);const De=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Ae=T("pencil",De);const Te=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Me=T("refresh-cw",Te);function V(){const[t,a]=o.useState(null),n=Z()&&J();o.useEffect(()=>{if(!n)return;const d=ee(x=>a(x));return H(),d},[n]);const i=o.useCallback((d,x)=>{n&&(a(u=>u&&{...u,[d]:x}),te(d,x))},[n]),r=o.useCallback(d=>{n&&ae(d)},[n]),m=o.useCallback(()=>{n&&H()},[n]);return{available:n,settings:t,setSetting:i,runAction:r,refresh:m}}function Pe({checked:t,onChange:a,ariaLabel:n}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":n,onClick:a,className:k("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:e.jsx("span",{className:k("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function _e({prefs:t}){const{order:a,visibility:n,toggle:i,moveToward:r}=t,[m,d]=o.useState(null),[x,u]=o.useState(null),b=l=>g=>{d(l),g.dataTransfer.effectAllowed="move",g.dataTransfer.setData("text/plain",l)},y=l=>g=>{g.preventDefault(),g.dataTransfer.dropEffect="move",m&&m!==l&&x!==l&&(u(l),r(m,l))},N=()=>{d(null),u(null)},w=l=>{l.preventDefault(),d(null),u(null)};return e.jsx(we,{children:e.jsx("div",{className:"flex flex-col",children:a.map(l=>{const g=n[l]!==!1,f=m===l;return e.jsxs(F.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:b(l),onDragOver:y(l),onDragEnd:N,onDrop:w,className:k("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",f&&"opacity-40"),style:{cursor:f?"grabbing":"grab"},children:[e.jsx(Ce,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),e.jsx("img",{src:he[l],alt:"",width:18,height:18,className:"h-[18px] w-[18px] shrink-0 pointer-events-none",draggable:!1}),e.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:B[l]}),e.jsx("div",{onMouseDown:v=>v.stopPropagation(),draggable:!1,children:e.jsx(Pe,{checked:g,onChange:()=>i(l),ariaLabel:`${s("limits.settings.toggle_visible")}: ${B[l]}`})})]},l)})})})}function Ee(t){if(!t||typeof t!="object")return"";const a=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},i=a.full_name||a.name||n.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function Oe(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function j({checked:t,onChange:a,disabled:n,ariaLabel:i}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":i,onClick:a,disabled:n,className:k("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 disabled:cursor-not-allowed",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:e.jsx("span",{className:k("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function p({label:t,hint:a,control:n}){return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a})]}),e.jsx("div",{className:"shrink-0",children:n})]})}function A({title:t,subtitle:a,action:n,children:i}){return e.jsxs(fe,{children:[e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:t}),a&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 truncate",children:a})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:i})]})}const Re=[{value:"light",labelKey:"settings.appearance.theme.light",Icon:se},{value:"dark",labelKey:"settings.appearance.theme.dark",Icon:ie},{value:"system",labelKey:"settings.appearance.theme.system",Icon:oe}];function He({theme:t,onSetTheme:a}){return e.jsx("div",{className:"inline-flex items-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900",children:Re.map(({value:n,labelKey:i,Icon:r})=>{const m=t===n;return e.jsxs("button",{type:"button",onClick:()=>a(n),className:k("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",m?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"),"aria-pressed":m,children:[e.jsx(r,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:s(i)})]},n)})})}function Be(){const{enabled:t,signedIn:a,user:n,signOut:i,getAccessToken:r}=re(),{openLoginModal:m}=ce(),[d,x]=o.useState(()=>le()),[u,b]=o.useState(!1),[y,N]=o.useState(!1),[w,l]=o.useState(!1),[g,f]=o.useState(!1),[v,_]=o.useState(null),[M,S]=o.useState(!1),[C,E]=o.useState(""),$=t&&a&&xe(),L=o.useMemo(()=>Ee(n),[n]),z=o.useMemo(()=>Oe(n),[n]);o.useEffect(()=>{if(!a)return;let c=!0;return l(!0),(async()=>{try{const h=await D({getAccessToken:r});if(!c||!h)return;const I=await de({accessToken:h});if(!c)return;b(!!I?.enabled),N(!!I?.anonymous),I?.display_name&&_(I.display_name)}catch{}finally{c&&l(!1)}})(),()=>{c=!1}},[a,r]);const K=o.useCallback(async()=>{const c=!d;if(ue(c),x(c),c)try{await ge(()=>r())}catch(h){console.warn("[tokentracker] cloud sync:",h)}},[d,r]),W=o.useCallback(async()=>{if(!g){f(!0);try{const c=await D({getAccessToken:r});if(!c)return;const h=!u;await P({accessToken:c,enabled:h}),b(h)}catch{}finally{f(!1)}}},[u,g,r]),q=o.useCallback(async()=>{if(!g){f(!0);try{const c=await D({getAccessToken:r});if(!c)return;const h=!y;await P({accessToken:c,anonymous:h}),N(h)}catch{}finally{f(!1)}}},[y,g,r]),O=o.useCallback(async()=>{if(g)return;const c=C.trim().slice(0,50);if(c){f(!0);try{const h=await D({getAccessToken:r});if(!h)return;await P({accessToken:h,display_name:c}),_(c),S(!1)}catch{}finally{f(!1)}}},[C,g,r]),Q=o.useCallback(()=>{E(v||L),S(!0)},[v,L]);return t?a?e.jsxs(A,{title:s("settings.section.account"),subtitle:z||v||L,action:e.jsxs("button",{type:"button",onClick:()=>i(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors",children:[e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.account.signOut")]}),children:[$&&e.jsx(p,{label:s("settings.account.cloudSync"),hint:s("settings.account.cloudSyncHint"),control:e.jsx(j,{checked:d,onChange:K,ariaLabel:s("settings.account.cloudSync")})}),e.jsx(p,{label:s("settings.account.publicProfile"),hint:s("settings.account.publicProfileHint"),control:e.jsx(j,{checked:u,onChange:W,disabled:w||g,ariaLabel:s("settings.account.publicProfile")})}),e.jsx(me,{initial:!1,children:u&&e.jsxs(F.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:[e.jsx("div",{className:"py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s("settings.account.displayName")}),!M&&e.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400 truncate",children:v||L}),M&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:C,onChange:c=>E(c.target.value),onKeyDown:c=>{c.key==="Enter"&&O(),c.key==="Escape"&&S(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-transparent px-2.5 py-1.5 text-sm text-oai-black dark:text-white outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500",placeholder:s("settings.account.displayName")}),e.jsx("button",{type:"button",onClick:O,disabled:g||!C.trim(),className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white hover:bg-oai-brand-600 disabled:opacity-50 transition-colors",children:g?s("settings.account.saving"):s("settings.account.save")}),e.jsx("button",{type:"button",onClick:()=>S(!1),className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors",children:s("settings.account.cancel")})]})]}),!M&&e.jsxs("button",{type:"button",onClick:Q,className:"shrink-0 inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:[e.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.account.edit")]})]})}),e.jsx(p,{label:s("settings.account.anonymous"),hint:s("settings.account.anonymousHint"),control:e.jsx(j,{checked:y,onChange:q,disabled:w||g,ariaLabel:s("settings.account.anonymous")})})]},"public-profile-fields")})]}):e.jsx(A,{title:s("settings.section.account"),children:e.jsxs("div",{className:"flex items-center justify-between py-3 gap-4",children:[e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.account.signedOutHint")}),e.jsx("button",{type:"button",onClick:m,className:"shrink-0 inline-flex h-8 items-center justify-center rounded-md bg-oai-gray-900 text-white px-4 text-xs font-medium hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:s("settings.account.signIn")})]})}):null}function Ge(){const{available:t,settings:a,setSetting:n,runAction:i}=V();if(!t)return null;const r=!!a?.showStats,m=a?.animatedIcon!==!1,d=!!a?.launchAtLogin,x=a?.launchAtLoginSupported!==!1;a?.version;const u=a?.updateStatus||null,b=!!a?.updateBusy,y=!!a?.isSyncing;return e.jsxs(A,{title:s("settings.section.menubar"),children:[e.jsx(p,{label:s("settings.menubar.showStats"),hint:s("settings.menubar.showStatsHint"),control:e.jsx(j,{checked:r,onChange:()=>n("showStats",!r),ariaLabel:s("settings.menubar.showStats")})}),e.jsx(p,{label:s("settings.menubar.animatedIcon"),hint:s("settings.menubar.animatedIconHint"),control:e.jsx(j,{checked:m,onChange:()=>n("animatedIcon",!m),ariaLabel:s("settings.menubar.animatedIcon")})}),x&&e.jsx(p,{label:s("settings.menubar.launchAtLogin"),hint:s("settings.menubar.launchAtLoginHint"),control:e.jsx(j,{checked:d,onChange:()=>n("launchAtLogin",!d),ariaLabel:s("settings.menubar.launchAtLogin")})}),e.jsx(p,{label:s("settings.menubar.syncNow"),hint:s("settings.menubar.syncNowHint"),control:e.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:y,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Me,{className:k("h-3.5 w-3.5",y&&"animate-spin"),"aria-hidden":!0}),y?s("settings.menubar.syncing"):s("settings.menubar.syncNow")]})}),e.jsx(p,{label:s("settings.menubar.updates"),hint:u||void 0,control:e.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:b,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.menubar.checkUpdates")]})})]})}function Fe(){const{available:t,settings:a,runAction:n}=V();return!t||!a?.version?null:e.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-500",children:[e.jsxs("span",{children:["TokenTrackerBar v",a.version]}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("button",{type:"button",onClick:()=>n("openAbout"),className:"hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors underline-offset-2 hover:underline",children:"GitHub"})]})}function Ke(){const{theme:t,setTheme:a}=ne(),n=ye();return 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-3xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex items-center justify-between gap-4",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white",children:s("settings.page.title")}),e.jsx(He,{theme:t,onSetTheme:a})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ge,{}),e.jsx(Be,{}),e.jsx(A,{title:s("settings.section.limits"),children:e.jsx(_e,{prefs:n})})]}),e.jsx(Fe,{})]})})})}export{Ke as SettingsPage};
1
+ import{r as o,b as X,f as Y,aN as R,D as e,e as T,aO as Z,aP as J,aQ as ee,aR as H,aS as te,aT as ae,ab as F,B as s,ay as k,C as ne,aU as se,aV as ie,aW as oe,ai as re,ah as ce,aC as le,aD as D,aX as de,aH as ue,aF as ge,aY as P,aj as me,aZ as xe}from"./main-C3JziweS.js";import{L as he,a as B,u as ye}from"./use-limits-display-prefs-BWWU7eSJ.js";import{C as fe}from"./Card-CvuIXN78.js";import{D as be}from"./download-C9WeWMz5.js";const pe=t=>!t.isLayoutDirty&&t.willUpdate(!1);function G(){const t=new Set,a=new WeakMap,n=()=>t.forEach(pe);return{add:i=>{t.add(i),a.set(i,i.addEventListener("willUpdate",n))},remove:i=>{t.delete(i);const r=a.get(i);r&&(r(),a.delete(i)),n()},dirty:n}}const ke=o.createContext(null);function ve(){const t=o.useRef(!1);return X(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function je(){const t=ve(),[a,n]=o.useState(0),i=o.useCallback(()=>{t.current&&n(a+1)},[a]);return[o.useCallback(()=>Y.postRender(i),[i]),a]}const U=t=>t===!0,Ne=t=>U(t===!0)||t==="id",we=({children:t,id:a,inherit:n=!0})=>{const i=o.useContext(R),r=o.useContext(ke),[m,d]=je(),x=o.useRef(null),u=i.id||r;x.current===null&&(Ne(n)&&u&&(a=a?u+"-"+a:u),x.current={id:a,group:U(n)&&i.group||G()});const b=o.useMemo(()=>({...x.current,forceRender:m}),[d]);return e.jsx(R.Provider,{value:b,children:t})};const Se=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ce=T("grip-vertical",Se);const Le=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ie=T("log-out",Le);const De=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Ae=T("pencil",De);const Te=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Me=T("refresh-cw",Te);function V(){const[t,a]=o.useState(null),n=Z()&&J();o.useEffect(()=>{if(!n)return;const d=ee(x=>a(x));return H(),d},[n]);const i=o.useCallback((d,x)=>{n&&(a(u=>u&&{...u,[d]:x}),te(d,x))},[n]),r=o.useCallback(d=>{n&&ae(d)},[n]),m=o.useCallback(()=>{n&&H()},[n]);return{available:n,settings:t,setSetting:i,runAction:r,refresh:m}}function Pe({checked:t,onChange:a,ariaLabel:n}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":n,onClick:a,className:k("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:e.jsx("span",{className:k("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function _e({prefs:t}){const{order:a,visibility:n,toggle:i,moveToward:r}=t,[m,d]=o.useState(null),[x,u]=o.useState(null),b=l=>g=>{d(l),g.dataTransfer.effectAllowed="move",g.dataTransfer.setData("text/plain",l)},y=l=>g=>{g.preventDefault(),g.dataTransfer.dropEffect="move",m&&m!==l&&x!==l&&(u(l),r(m,l))},N=()=>{d(null),u(null)},w=l=>{l.preventDefault(),d(null),u(null)};return e.jsx(we,{children:e.jsx("div",{className:"flex flex-col",children:a.map(l=>{const g=n[l]!==!1,f=m===l;return e.jsxs(F.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:b(l),onDragOver:y(l),onDragEnd:N,onDrop:w,className:k("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",f&&"opacity-40"),style:{cursor:f?"grabbing":"grab"},children:[e.jsx(Ce,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),e.jsx("img",{src:he[l],alt:"",width:18,height:18,className:"h-[18px] w-[18px] shrink-0 pointer-events-none",draggable:!1}),e.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:B[l]}),e.jsx("div",{onMouseDown:v=>v.stopPropagation(),draggable:!1,children:e.jsx(Pe,{checked:g,onChange:()=>i(l),ariaLabel:`${s("limits.settings.toggle_visible")}: ${B[l]}`})})]},l)})})})}function Ee(t){if(!t||typeof t!="object")return"";const a=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},i=a.full_name||a.name||n.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function Oe(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function j({checked:t,onChange:a,disabled:n,ariaLabel:i}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":i,onClick:a,disabled:n,className:k("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 disabled:cursor-not-allowed",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:e.jsx("span",{className:k("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function p({label:t,hint:a,control:n}){return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a})]}),e.jsx("div",{className:"shrink-0",children:n})]})}function A({title:t,subtitle:a,action:n,children:i}){return e.jsxs(fe,{children:[e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:t}),a&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 truncate",children:a})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:i})]})}const Re=[{value:"light",labelKey:"settings.appearance.theme.light",Icon:se},{value:"dark",labelKey:"settings.appearance.theme.dark",Icon:ie},{value:"system",labelKey:"settings.appearance.theme.system",Icon:oe}];function He({theme:t,onSetTheme:a}){return e.jsx("div",{className:"inline-flex items-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900",children:Re.map(({value:n,labelKey:i,Icon:r})=>{const m=t===n;return e.jsxs("button",{type:"button",onClick:()=>a(n),className:k("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",m?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"),"aria-pressed":m,children:[e.jsx(r,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:s(i)})]},n)})})}function Be(){const{enabled:t,signedIn:a,user:n,signOut:i,getAccessToken:r}=re(),{openLoginModal:m}=ce(),[d,x]=o.useState(()=>le()),[u,b]=o.useState(!1),[y,N]=o.useState(!1),[w,l]=o.useState(!1),[g,f]=o.useState(!1),[v,_]=o.useState(null),[M,S]=o.useState(!1),[C,E]=o.useState(""),$=t&&a&&xe(),L=o.useMemo(()=>Ee(n),[n]),z=o.useMemo(()=>Oe(n),[n]);o.useEffect(()=>{if(!a)return;let c=!0;return l(!0),(async()=>{try{const h=await D({getAccessToken:r});if(!c||!h)return;const I=await de({accessToken:h});if(!c)return;b(!!I?.enabled),N(!!I?.anonymous),I?.display_name&&_(I.display_name)}catch{}finally{c&&l(!1)}})(),()=>{c=!1}},[a,r]);const K=o.useCallback(async()=>{const c=!d;if(ue(c),x(c),c)try{await ge(()=>r())}catch(h){console.warn("[tokentracker] cloud sync:",h)}},[d,r]),W=o.useCallback(async()=>{if(!g){f(!0);try{const c=await D({getAccessToken:r});if(!c)return;const h=!u;await P({accessToken:c,enabled:h}),b(h)}catch{}finally{f(!1)}}},[u,g,r]),q=o.useCallback(async()=>{if(!g){f(!0);try{const c=await D({getAccessToken:r});if(!c)return;const h=!y;await P({accessToken:c,anonymous:h}),N(h)}catch{}finally{f(!1)}}},[y,g,r]),O=o.useCallback(async()=>{if(g)return;const c=C.trim().slice(0,50);if(c){f(!0);try{const h=await D({getAccessToken:r});if(!h)return;await P({accessToken:h,display_name:c}),_(c),S(!1)}catch{}finally{f(!1)}}},[C,g,r]),Q=o.useCallback(()=>{E(v||L),S(!0)},[v,L]);return t?a?e.jsxs(A,{title:s("settings.section.account"),subtitle:z||v||L,action:e.jsxs("button",{type:"button",onClick:()=>i(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors",children:[e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.account.signOut")]}),children:[$&&e.jsx(p,{label:s("settings.account.cloudSync"),hint:s("settings.account.cloudSyncHint"),control:e.jsx(j,{checked:d,onChange:K,ariaLabel:s("settings.account.cloudSync")})}),e.jsx(p,{label:s("settings.account.publicProfile"),hint:s("settings.account.publicProfileHint"),control:e.jsx(j,{checked:u,onChange:W,disabled:w||g,ariaLabel:s("settings.account.publicProfile")})}),e.jsx(me,{initial:!1,children:u&&e.jsxs(F.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:[e.jsx("div",{className:"py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s("settings.account.displayName")}),!M&&e.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400 truncate",children:v||L}),M&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:C,onChange:c=>E(c.target.value),onKeyDown:c=>{c.key==="Enter"&&O(),c.key==="Escape"&&S(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-transparent px-2.5 py-1.5 text-sm text-oai-black dark:text-white outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500",placeholder:s("settings.account.displayName")}),e.jsx("button",{type:"button",onClick:O,disabled:g||!C.trim(),className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white hover:bg-oai-brand-600 disabled:opacity-50 transition-colors",children:g?s("settings.account.saving"):s("settings.account.save")}),e.jsx("button",{type:"button",onClick:()=>S(!1),className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors",children:s("settings.account.cancel")})]})]}),!M&&e.jsxs("button",{type:"button",onClick:Q,className:"shrink-0 inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:[e.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.account.edit")]})]})}),e.jsx(p,{label:s("settings.account.anonymous"),hint:s("settings.account.anonymousHint"),control:e.jsx(j,{checked:y,onChange:q,disabled:w||g,ariaLabel:s("settings.account.anonymous")})})]},"public-profile-fields")})]}):e.jsx(A,{title:s("settings.section.account"),children:e.jsxs("div",{className:"flex items-center justify-between py-3 gap-4",children:[e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.account.signedOutHint")}),e.jsx("button",{type:"button",onClick:m,className:"shrink-0 inline-flex h-8 items-center justify-center rounded-md bg-oai-gray-900 text-white px-4 text-xs font-medium hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:s("settings.account.signIn")})]})}):null}function Ge(){const{available:t,settings:a,setSetting:n,runAction:i}=V();if(!t)return null;const r=!!a?.showStats,m=a?.animatedIcon!==!1,d=!!a?.launchAtLogin,x=a?.launchAtLoginSupported!==!1;a?.version;const u=a?.updateStatus||null,b=!!a?.updateBusy,y=!!a?.isSyncing;return e.jsxs(A,{title:s("settings.section.menubar"),children:[e.jsx(p,{label:s("settings.menubar.showStats"),hint:s("settings.menubar.showStatsHint"),control:e.jsx(j,{checked:r,onChange:()=>n("showStats",!r),ariaLabel:s("settings.menubar.showStats")})}),e.jsx(p,{label:s("settings.menubar.animatedIcon"),hint:s("settings.menubar.animatedIconHint"),control:e.jsx(j,{checked:m,onChange:()=>n("animatedIcon",!m),ariaLabel:s("settings.menubar.animatedIcon")})}),x&&e.jsx(p,{label:s("settings.menubar.launchAtLogin"),hint:s("settings.menubar.launchAtLoginHint"),control:e.jsx(j,{checked:d,onChange:()=>n("launchAtLogin",!d),ariaLabel:s("settings.menubar.launchAtLogin")})}),e.jsx(p,{label:s("settings.menubar.syncNow"),hint:s("settings.menubar.syncNowHint"),control:e.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:y,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Me,{className:k("h-3.5 w-3.5",y&&"animate-spin"),"aria-hidden":!0}),y?s("settings.menubar.syncing"):s("settings.menubar.syncNow")]})}),e.jsx(p,{label:s("settings.menubar.updates"),hint:u||void 0,control:e.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:b,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.menubar.checkUpdates")]})})]})}function Fe(){const{available:t,settings:a,runAction:n}=V();return!t||!a?.version?null:e.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-500",children:[e.jsxs("span",{children:["TokenTrackerBar v",a.version]}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("button",{type:"button",onClick:()=>n("openAbout"),className:"hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors underline-offset-2 hover:underline",children:"GitHub"})]})}function Ke(){const{theme:t,setTheme:a}=ne(),n=ye();return 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-3xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex items-center justify-between gap-4",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white",children:s("settings.page.title")}),e.jsx(He,{theme:t,onSetTheme:a})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ge,{}),e.jsx(Be,{}),e.jsx(A,{title:s("settings.section.limits"),children:e.jsx(_e,{prefs:n})})]}),e.jsx(Fe,{})]})})})}export{Ke as SettingsPage};
@@ -1 +1 @@
1
- import{e as w,D as e,B as n,aT as b,aW as j,r as h,a_ as k,ay as v}from"./main-DQ3-Wn2t.js";import{F as f,S as N,a as W}from"./FadeIn-Dt-Uvlsi.js";import{D as S}from"./download-DsypqQx5.js";const F=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],C=w("arrow-up-right",F),M=264,A=124,c="ui-rounded, -apple-system, system-ui",m=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],D={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function _(a){return a>=.9?"#E64D4D":a>=.7?"#D9A633":"#33B866"}function g({size:a="sm",children:r}){const s=a==="lg",i=s?560:264,l=s?32:22;return e.jsx("div",{className:v("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",s?"py-10 sm:py-14 px-6":"py-6 px-4"),children:e.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:i,aspectRatio:`${M} / ${A}`,borderRadius:l},children:r})})}function E({size:a="sm"}){const r="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",s=`${r} L264,124 L0,124 Z`,i=`sparkArea-${a}`;return e.jsx(g,{size:a,children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:i,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),e.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),e.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"TODAY"}),e.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:c,children:"203.2M"}),e.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:c,children:"$129.56 ±0%"}),e.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"7 DAYS"}),e.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:c,children:"880.9M"}),e.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:c,children:"$673.61"}),e.jsx("path",{d:s,fill:`url(#${i})`,stroke:"none"}),e.jsx("path",{d:r,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const u=(()=>{const s=[];for(let i=0;i<26;i++)for(let l=0;l<7;l++){const t=Math.sin((i+1)*12.9898+(l+1)*78.233+17)*43758.5453,d=Math.floor(Math.abs(t-Math.floor(t))*100);s.push({w:i,d:l,v:d})}return s})();function p(a,r){return a<18?r?"#262626":"#e5e5e5":a<38?"rgba(10, 132, 255, 0.28)":a<58?"rgba(10, 132, 255, 0.50)":a<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function z(){return e.jsx(g,{children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:u.map(t=>e.jsx("rect",{x:t.w*(7.5+1.2),y:t.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:p(t.v,!0)},`d-${t.w}-${t.d}`))}),e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:u.map(t=>e.jsx("rect",{x:t.w*(7.5+1.2),y:t.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:p(t.v,!1)},`l-${t.w}-${t.d}`))}),e.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:c,children:"10.3B"}),e.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:"tokens · 202 active days"})]})})}function $(){const a=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],r=22,s=28,i=14,l=236;return e.jsx(g,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:a.map((t,d)=>{const o=s+d*r,x=m[d%m.length];return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:x}),e.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:t.name}),e.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:c,children:t.value}),e.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:c,children:[t.pct,"%"]}),e.jsx("rect",{x:i,y:o+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:i,y:o+4,width:Math.max(l*(t.pct/100),4),height:"2.8",rx:"1.4",fill:x})]},t.name)})})})}function L(){const a=[{label:"Claude · 7d",source:"claude",reset:"in 1d",pct:61},{label:"Claude · 5h",source:"claude",reset:"in 4h 28m",pct:4},{label:"Cursor",source:"cursor",reset:"in 25d",pct:51},{label:"Codex · weekly",source:"codex",reset:"in 1d",pct:32}],r=22,s=28,i=14,l=236;return e.jsx(g,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:a.map((t,d)=>{const o=s+d*r,x=D[t.source],y=_(t.pct/100);return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:x}),e.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:t.label}),e.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:c,children:t.reset}),e.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:c,children:[t.pct,"%"]}),e.jsx("rect",{x:i,y:o+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:i,y:o+4,width:Math.max(l*(t.pct/100),4),height:"2.8",rx:"1.4",fill:y})]},t.label)})})})}function P(){const[a,r]=h.useState("loading");return h.useEffect(()=>{if(typeof window>"u")return;if(k()){r("native");return}const s=(navigator.userAgent||"").toLowerCase(),i=/mac/.test(s)&&!/iphone|ipad/.test(s);r(i?"mac-web":"other")},[]),a}function O(){const a=P();return a==="loading"?e.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):a==="native"?e.jsxs("button",{type:"button",onClick:()=>b("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[n("widgets.cta.open_gallery"),e.jsx(C,{className:"h-4 w-4","aria-hidden":"true"})]}):a==="mac-web"?e.jsxs("a",{href:"https://github.com/mm7894215/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[e.jsx(S,{className:"h-4 w-4","aria-hidden":"true"}),n("widgets.cta.download")]}):e.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[e.jsx(j,{className:"h-4 w-4","aria-hidden":"true"}),n("widgets.cta.macos_only")]})}const H=[{id:"heatmap",Preview:z,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:$,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:L,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function G(){return 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-5xl px-4 sm:px-6",children:[e.jsx(f,{y:12,children:e.jsxs("header",{className:"mb-10 flex flex-col gap-6 sm:mb-14 sm:flex-row sm:items-start sm:justify-between",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:n("widgets.page.title")}),e.jsx("p",{className:"max-w-xl text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:n("widgets.page.subtitle")})]}),e.jsx("div",{className:"shrink-0",children:e.jsx(O,{})})]})}),e.jsx(f,{y:16,delay:.08,children:e.jsxs("section",{className:"mb-14 sm:mb-16","aria-label":n("widgets.hero.aria"),children:[e.jsx(E,{size:"lg"}),e.jsx("p",{className:"mt-5 text-center text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("widgets.hero.annotation")})]})}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-5 text-xs font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:n("widgets.section.more")}),e.jsx(N,{staggerDelay:.08,initialDelay:.12,children:e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3 sm:gap-5",children:H.map(({id:a,Preview:r,nameKey:s,descKey:i})=>e.jsx(W,{children:e.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[e.jsx(r,{}),e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:n(s)}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:n(i)})]})]})},a))})})]})]})})})}export{G as WidgetsPage};
1
+ import{e as w,D as e,B as n,aT as b,aW as j,r as h,a_ as k,ay as v}from"./main-C3JziweS.js";import{F as f,S as N,a as W}from"./FadeIn-70qYAVWA.js";import{D as S}from"./download-C9WeWMz5.js";const F=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],C=w("arrow-up-right",F),M=264,A=124,c="ui-rounded, -apple-system, system-ui",m=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],D={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function _(a){return a>=.9?"#E64D4D":a>=.7?"#D9A633":"#33B866"}function g({size:a="sm",children:r}){const s=a==="lg",i=s?560:264,l=s?32:22;return e.jsx("div",{className:v("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",s?"py-10 sm:py-14 px-6":"py-6 px-4"),children:e.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:i,aspectRatio:`${M} / ${A}`,borderRadius:l},children:r})})}function E({size:a="sm"}){const r="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",s=`${r} L264,124 L0,124 Z`,i=`sparkArea-${a}`;return e.jsx(g,{size:a,children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:i,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),e.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),e.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"TODAY"}),e.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:c,children:"203.2M"}),e.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:c,children:"$129.56 ±0%"}),e.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"7 DAYS"}),e.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:c,children:"880.9M"}),e.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:c,children:"$673.61"}),e.jsx("path",{d:s,fill:`url(#${i})`,stroke:"none"}),e.jsx("path",{d:r,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const u=(()=>{const s=[];for(let i=0;i<26;i++)for(let l=0;l<7;l++){const t=Math.sin((i+1)*12.9898+(l+1)*78.233+17)*43758.5453,d=Math.floor(Math.abs(t-Math.floor(t))*100);s.push({w:i,d:l,v:d})}return s})();function p(a,r){return a<18?r?"#262626":"#e5e5e5":a<38?"rgba(10, 132, 255, 0.28)":a<58?"rgba(10, 132, 255, 0.50)":a<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function z(){return e.jsx(g,{children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:u.map(t=>e.jsx("rect",{x:t.w*(7.5+1.2),y:t.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:p(t.v,!0)},`d-${t.w}-${t.d}`))}),e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:u.map(t=>e.jsx("rect",{x:t.w*(7.5+1.2),y:t.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:p(t.v,!1)},`l-${t.w}-${t.d}`))}),e.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:c,children:"10.3B"}),e.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:"tokens · 202 active days"})]})})}function $(){const a=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],r=22,s=28,i=14,l=236;return e.jsx(g,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:a.map((t,d)=>{const o=s+d*r,x=m[d%m.length];return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:x}),e.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:t.name}),e.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:c,children:t.value}),e.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:c,children:[t.pct,"%"]}),e.jsx("rect",{x:i,y:o+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:i,y:o+4,width:Math.max(l*(t.pct/100),4),height:"2.8",rx:"1.4",fill:x})]},t.name)})})})}function L(){const a=[{label:"Claude · 7d",source:"claude",reset:"in 1d",pct:61},{label:"Claude · 5h",source:"claude",reset:"in 4h 28m",pct:4},{label:"Cursor",source:"cursor",reset:"in 25d",pct:51},{label:"Codex · weekly",source:"codex",reset:"in 1d",pct:32}],r=22,s=28,i=14,l=236;return e.jsx(g,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:a.map((t,d)=>{const o=s+d*r,x=D[t.source],y=_(t.pct/100);return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:x}),e.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:t.label}),e.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:c,children:t.reset}),e.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:c,children:[t.pct,"%"]}),e.jsx("rect",{x:i,y:o+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:i,y:o+4,width:Math.max(l*(t.pct/100),4),height:"2.8",rx:"1.4",fill:y})]},t.label)})})})}function P(){const[a,r]=h.useState("loading");return h.useEffect(()=>{if(typeof window>"u")return;if(k()){r("native");return}const s=(navigator.userAgent||"").toLowerCase(),i=/mac/.test(s)&&!/iphone|ipad/.test(s);r(i?"mac-web":"other")},[]),a}function O(){const a=P();return a==="loading"?e.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):a==="native"?e.jsxs("button",{type:"button",onClick:()=>b("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[n("widgets.cta.open_gallery"),e.jsx(C,{className:"h-4 w-4","aria-hidden":"true"})]}):a==="mac-web"?e.jsxs("a",{href:"https://github.com/mm7894215/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[e.jsx(S,{className:"h-4 w-4","aria-hidden":"true"}),n("widgets.cta.download")]}):e.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[e.jsx(j,{className:"h-4 w-4","aria-hidden":"true"}),n("widgets.cta.macos_only")]})}const H=[{id:"heatmap",Preview:z,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:$,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:L,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function G(){return 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-5xl px-4 sm:px-6",children:[e.jsx(f,{y:12,children:e.jsxs("header",{className:"mb-10 flex flex-col gap-6 sm:mb-14 sm:flex-row sm:items-start sm:justify-between",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:n("widgets.page.title")}),e.jsx("p",{className:"max-w-xl text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:n("widgets.page.subtitle")})]}),e.jsx("div",{className:"shrink-0",children:e.jsx(O,{})})]})}),e.jsx(f,{y:16,delay:.08,children:e.jsxs("section",{className:"mb-14 sm:mb-16","aria-label":n("widgets.hero.aria"),children:[e.jsx(E,{size:"lg"}),e.jsx("p",{className:"mt-5 text-center text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("widgets.hero.annotation")})]})}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-5 text-xs font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:n("widgets.section.more")}),e.jsx(N,{staggerDelay:.08,initialDelay:.12,children:e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3 sm:gap-5",children:H.map(({id:a,Preview:r,nameKey:s,descKey:i})=>e.jsx(W,{children:e.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[e.jsx(r,{}),e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:n(s)}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:n(i)})]})]})},a))})})]})]})})})}export{G as WidgetsPage};
@@ -1 +1 @@
1
- import{e as o}from"./main-DQ3-Wn2t.js";const a=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],d=o("download",a);export{d as D};
1
+ import{e as o}from"./main-C3JziweS.js";const a=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],d=o("download",a);export{d as D};
@@ -1 +1 @@
1
- import{ad as g,D as n,ay as i}from"./main-DQ3-Wn2t.js";function y(r){let e=0;const o=String(r??"");for(let a=0;a<o.length;a+=1)e=Math.imul(31,e)+o.charCodeAt(a)|0;return Math.abs(e)%360}function m(r){const e=String(r??"").trim();if(!e)return"?";const o=e.split(/\s+/).filter(Boolean);if(o.length>=2){const a=o[0][0]||"",t=o[1][0]||"";return`${a}${t}`.toUpperCase()}return e.slice(0,2).toUpperCase()}const l={sm:"h-7 w-7 min-h-7 min-w-7 text-[10px]",md:"h-8 w-8 min-h-8 min-w-8 text-[11px]",lg:"h-14 w-14 min-h-14 min-w-14 text-base"};function k({avatarUrl:r,displayName:e,seed:o,size:a="md",className:t}){const d=l[a]||l.md,b=y(o??e??""),s=typeof r=="string"?r.trim():"",[p,c]=g.useState(!1);return g.useEffect(()=>{c(!1)},[s]),s&&!p?n.jsx("img",{src:s,alt:"",referrerPolicy:"no-referrer",onError:()=>c(!0),className:i("rounded-full object-cover ring-1 ring-white/10",d,t)}):n.jsx("div",{className:i("flex shrink-0 items-center justify-center rounded-full font-semibold text-white ring-1 ring-white/10",d,t),style:{backgroundColor:`hsl(${b} 42% 34%)`},"aria-hidden":!0,children:m(e)})}function h({iconSrc:r,label:e}){return n.jsxs("span",{className:"inline-flex items-center gap-3",children:[n.jsx("img",{src:r,alt:"",width:16,height:16,className:`h-4 w-4 shrink-0 object-contain opacity-90 ${r==="/brand-logos/cursor.svg"?"dark:invert":""}`}),n.jsx("span",{className:"whitespace-nowrap",children:e})]})}const x=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"opencode_tokens",copyKey:"leaderboard.column.opencode",icon:"/brand-logos/opencode.svg"},{key:"openclaw_tokens",copyKey:"leaderboard.column.openclaw",icon:"/brand-logos/openclaw.svg"},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:"/brand-logos/gemini.svg"}],w="sticky left-0 z-40 w-[72px] min-w-[72px] max-w-[72px] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4 align-middle",f="sticky left-[72px] z-40 min-w-[140px] max-w-[min(180px,35vw)] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4 align-middle",_="sticky left-[72px] z-40 min-w-[6rem] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4";function v(r){return i("sticky left-0 z-30 w-[72px] min-w-[72px] max-w-[72px] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 whitespace-nowrap",r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function S(r){return i("sticky left-[72px] z-30 min-w-[140px] max-w-[min(180px,35vw)] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 min-w-0",r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function T(r){return i("sticky left-[72px] z-30 min-w-[6rem] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 whitespace-nowrap","bg-white dark:bg-oai-gray-950")}export{w as L,f as a,x as b,S as c,h as d,k as e,T as f,_ as g,v as l};
1
+ import{ad as g,D as n,ay as i}from"./main-C3JziweS.js";function y(r){let e=0;const o=String(r??"");for(let a=0;a<o.length;a+=1)e=Math.imul(31,e)+o.charCodeAt(a)|0;return Math.abs(e)%360}function m(r){const e=String(r??"").trim();if(!e)return"?";const o=e.split(/\s+/).filter(Boolean);if(o.length>=2){const a=o[0][0]||"",t=o[1][0]||"";return`${a}${t}`.toUpperCase()}return e.slice(0,2).toUpperCase()}const l={sm:"h-7 w-7 min-h-7 min-w-7 text-[10px]",md:"h-8 w-8 min-h-8 min-w-8 text-[11px]",lg:"h-14 w-14 min-h-14 min-w-14 text-base"};function k({avatarUrl:r,displayName:e,seed:o,size:a="md",className:t}){const d=l[a]||l.md,b=y(o??e??""),s=typeof r=="string"?r.trim():"",[p,c]=g.useState(!1);return g.useEffect(()=>{c(!1)},[s]),s&&!p?n.jsx("img",{src:s,alt:"",referrerPolicy:"no-referrer",onError:()=>c(!0),className:i("rounded-full object-cover ring-1 ring-white/10",d,t)}):n.jsx("div",{className:i("flex shrink-0 items-center justify-center rounded-full font-semibold text-white ring-1 ring-white/10",d,t),style:{backgroundColor:`hsl(${b} 42% 34%)`},"aria-hidden":!0,children:m(e)})}function h({iconSrc:r,label:e}){return n.jsxs("span",{className:"inline-flex items-center gap-3",children:[n.jsx("img",{src:r,alt:"",width:16,height:16,className:`h-4 w-4 shrink-0 object-contain opacity-90 ${r==="/brand-logos/cursor.svg"?"dark:invert":""}`}),n.jsx("span",{className:"whitespace-nowrap",children:e})]})}const x=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"opencode_tokens",copyKey:"leaderboard.column.opencode",icon:"/brand-logos/opencode.svg"},{key:"openclaw_tokens",copyKey:"leaderboard.column.openclaw",icon:"/brand-logos/openclaw.svg"},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:"/brand-logos/gemini.svg"}],w="sticky left-0 z-40 w-[72px] min-w-[72px] max-w-[72px] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4 align-middle",f="sticky left-[72px] z-40 min-w-[140px] max-w-[min(180px,35vw)] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4 align-middle",_="sticky left-[72px] z-40 min-w-[6rem] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4";function v(r){return i("sticky left-0 z-30 w-[72px] min-w-[72px] max-w-[72px] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 whitespace-nowrap",r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function S(r){return i("sticky left-[72px] z-30 min-w-[140px] max-w-[min(180px,35vw)] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 min-w-0",r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function T(r){return i("sticky left-[72px] z-30 min-w-[6rem] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 whitespace-nowrap","bg-white dark:bg-oai-gray-950")}export{w as L,f as a,x as b,S as c,h as d,k as e,T as f,_ as g,v as l};