tokentracker-cli 0.96.0 → 0.96.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/README.zh-CN.md +1 -1
- package/dashboard/dist/assets/{AchievementBadge-Bb2ljquW.js → AchievementBadge-DKyElm0T.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-ByUP2x8a.js → AchievementsPage-BvCx3wND.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-_L6sCLTw.js → AchievementsSection-DN69LzXX.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-B9n_-45B.js → BadgeDetailModal-DGiKdZfz.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-lWmg-aZg.js → BotAnimated-zN8rH7_K.js} +1 -1
- package/dashboard/dist/assets/{Card-aSp259T0.js → Card-COWo-ClV.js} +1 -1
- package/dashboard/dist/assets/{ClawdAnimated-Cy-XaTXW.js → ClawdAnimated-BWsB7Eat.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-CNwtKCUm.js → CommandPalette-BfvIwuoJ.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-DJSezaPV.js → CommunityStatsModal-BQWg7R_y.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-CVjmhZd6.js → ConfirmModal-C7ABSI-O.js} +1 -1
- package/dashboard/dist/assets/{Controls-BIj6yVxE.js → Controls-vMzEZzej.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-QBhbCMZF.js +1 -0
- package/dashboard/dist/assets/{DevicePage-ptsI2fZc.js → DevicePage-3ejUBLWM.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-D1pLoZ56.js → DialogClose-D_dvtfGV.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-ryGYdQjX.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-DfSBUjWf.js → DialogTitle-_ahf0z8b.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-DBn4L_BV.js → FadeIn-D7Jcfz1N.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-EJLBwEqp.js → HeaderGithubStar-D--Rx5BS.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-DaSrZhYd.js → HoverTooltip-n1W0z3Wr.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-diQTVaYt.js → IpCheckPage-D202tl9B.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-BqCxjwar.js → LandingPage-D6yL2EZo.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardAvatar-CQImCsPN.js → LeaderboardAvatar-ChFg2mtA.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-D2ZDUi_O.js → LeaderboardPage-BXHwGs8r.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProfileModal-DHvADX1d.js → LeaderboardProfileModal-B5LoOpCk.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-CJsedB28.js → LeaderboardProfilePage-jsukhRz8.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-CAwff24b.js → LimitsPage-PvqkOOwp.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-Cmnvu9tI.js → LocalOnlyNotice-Du0lz657.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-BQmKkD7X.js → LoginCard-BFEX9x7-.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-2oPROePZ.js → LoginModal-DqC7_d35.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-aqdUJoQK.js → LoginPage-Dzx8N7HE.js} +1 -1
- package/dashboard/dist/assets/{PetPage-Bn3p_o5r.js → PetPage-CNlWHF4z.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-DXD_YdiB.js → PopoverPopup-D9jadD3j.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-BZZ45-gY.js → ProviderIcon-Caz5PuAm.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-Bn5ITiHQ.js → ResetPasswordPage-x_GR79sR.js} +1 -1
- package/dashboard/dist/assets/{SegmentedControl-hGXboQZy.js → SegmentedControl-BxDiDV4R.js} +1 -1
- package/dashboard/dist/assets/{Select-BP8aVRZ1.js → Select-B5o-1sEl.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-Odx47kND.js → SelectItemText-CiA6L7Wk.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-DUueam0N.js → ServiceStatusPage-BVQuVdjg.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-BA9IFqQ1.js → SessionsPage-DE39wNIO.js} +1 -1
- package/dashboard/dist/assets/SettingsPage-DJrb_fsK.js +2 -0
- package/dashboard/dist/assets/{SkillsPage-Ds2vH_PG.js → SkillsPage-COk-YQQ5.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-CWBR4jnB.js → TokenGalaxy-BPM779Wb.js} +1 -1
- package/dashboard/dist/assets/{ToolbarRootContext-Bmg56vYz.js → ToolbarRootContext-CozJT6Vs.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-BQzcllvg.js → TrendMonitor-BkNy-o1D.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-Bu3tHDjO.js → WidgetsPage-Bpg6H-ZB.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-BrAMJhgy.js → WrappedPage-C6-NM-RO.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-BGnq8Ebm.js +45 -0
- package/dashboard/dist/assets/__vite-browser-external-CvMMIjhi.css +1 -0
- package/dashboard/dist/assets/{agent-logos-B8lT-HcI.js → agent-logos-DpbkRqXT.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-rpBCOTg2.js → arrow-up-right-BjOtWUVs.js} +1 -1
- package/dashboard/dist/assets/{check-DIKw7TYH.js → check-BlxnX5jZ.js} +1 -1
- package/dashboard/dist/assets/{composite-_NeXO0lv.js → composite-Dxmivlk4.js} +1 -1
- package/dashboard/dist/assets/{copy-CsfAtL7P.js → copy-CIsWjLY5.js} +1 -1
- package/dashboard/dist/assets/{download-DM1W9pIW.js → download-QDaQbQdd.js} +1 -1
- package/dashboard/dist/assets/{external-link-CwbuMbeQ.js → external-link-DPV4VU3m.js} +1 -1
- package/dashboard/dist/assets/{flame-DcYbLdhE.js → flame-B_X-7VNp.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-CEvr3dNy.js → format-tokens-DEx2TJj8.js} +1 -1
- package/dashboard/dist/assets/{icons-DaGMVsJ5.js → icons-983RyGSl.js} +1 -1
- package/dashboard/dist/assets/{index-BVVLPj3N.js → index-BONYA8HZ.js} +1 -1
- package/dashboard/dist/assets/{index-ChZkJjpk.js → index-Cjs5stC0.js} +1 -1
- package/dashboard/dist/assets/{index-T7OjmEuX.js → index-qtonw_x4.js} +1 -1
- package/dashboard/dist/assets/{info-CAjN3dX4.js → info-DpVOhXZI.js} +1 -1
- package/dashboard/dist/assets/{limits-providers-jn7Yln_V.js → limits-providers-BUoquSA-.js} +1 -1
- package/dashboard/dist/assets/{link-2-DaWH2Tyc.js → link-2-CBro-upz.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-CnF8qPi1.js → loader-circle-wYFdSyOd.js} +1 -1
- package/dashboard/dist/assets/{maximize-2-B-2Pnj6g.js → maximize-2-DhTyQ4ly.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-BoDOvUKl.js → modifiers.esm-CPljwVhN.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-DDgwxG_E.js → monitor-smartphone-D_wr-HOR.js} +1 -1
- package/dashboard/dist/assets/{plus-DIc1YUWB.js → plus-BNjfkBEF.js} +1 -1
- package/dashboard/dist/assets/{provider-display-yeNsVCO_.js → provider-display-BOBtUyFi.js} +1 -1
- package/dashboard/dist/assets/{react-DZqS6YTX.js → react-yHv9MTUA.js} +1 -1
- package/dashboard/dist/assets/{search-D6tEppYJ.js → search-Dfak92ZA.js} +1 -1
- package/dashboard/dist/assets/{skills-api-vsA1rc1Z.js → skills-api-By2PdNa1.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-DDCnS1HI.js → sortable.esm-B9xy66_v.js} +1 -1
- package/dashboard/dist/assets/{store-Crne4DqF.js → store-oQZR4d9M.js} +1 -1
- package/dashboard/dist/assets/{terminal-Ca7dkLMF.js → terminal-pbXWBmZM.js} +1 -1
- package/dashboard/dist/assets/{trash-2-CjEAS5ic.js → trash-2-CboDPwbW.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-BHx2YxyK.js → use-community-stats-D6HTdnHq.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-BLGbXQdf.js → use-latest-request-guard-hwSr9Cam.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-DBkAp6ob.js → use-limits-display-prefs-B-pbwUS8.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-BTfW5M9u.js → use-ordered-list-OtfOqrNb.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-DGXcZBX3.js +1 -0
- package/dashboard/dist/assets/{use-session-efficiency-pref-DBmd-MqH.js → use-session-efficiency-pref-BScvtS8F.js} +1 -1
- package/dashboard/dist/assets/{use-transform-Bp5XrwaQ.js → use-transform-Cy1ykjEs.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-BmqRcyhH.js → use-usage-limits-CSMb2zYW.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-B0YsRDj-.js → useCurrency-VqF3cy1C.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-PP3D0Ket.js → useTokenFormat-Cgub4MXu.js} +1 -1
- package/dashboard/dist/assets/{zap-BVOm1aBH.js → zap-DStzvQJI.js} +1 -1
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/ip-check.html +2 -2
- package/dashboard/dist/leaderboard.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +1 -1
- package/src/commands/status.js +4 -4
- package/src/commands/sync.js +5 -3
- package/src/lib/ark-agent-plan-limits.js +4 -3
- package/src/lib/ark-coding-plan-limits.js +6 -8
- package/src/lib/command-runner.js +13 -0
- package/src/lib/local-api.js +3 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +17 -5
- package/src/lib/usage-limits.js +111 -13
- package/dashboard/dist/assets/DashboardPage-BjYZLmqQ.js +0 -1
- package/dashboard/dist/assets/DialogDescription-KY7X94CG.js +0 -1
- package/dashboard/dist/assets/SettingsPage-DLOHHB4f.js +0 -2
- package/dashboard/dist/assets/__vite-browser-external-4IGm4Djn.js +0 -45
- package/dashboard/dist/assets/__vite-browser-external-CCMdjCX2.css +0 -1
- package/dashboard/dist/assets/use-reduced-motion-D_kUnDs4.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-4IGm4Djn.js","assets/__vite-browser-external-CCMdjCX2.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{m as O,j as t,e as L,c as n,a as ce,r as g,ao as ue,aU as de,au as ge,av as pe,a8 as W,aV as he,aW as me,u as be,d as R,a0 as fe,M as Z,n as M,aX as xe,aY as ye,U as Y,aZ as ve,x as ke,a_ as je,a$ as Se,b0 as we,b1 as Ne,b2 as Ce,b3 as Ee,b4 as Ae,L as Le,R as Oe,b5 as Pe,b6 as _e,a5 as H,_ as Te,h as Ie,f as Ge,b7 as Re,b8 as Ue,ax as De}from"./__vite-browser-external-4IGm4Djn.js";import{a as Me,b as F,s as He,K as Fe,P as $e,D as Be,c as Ve,S as Ke,v as ze,u as qe,C as We}from"./sortable.esm-DDCnS1HI.js";import{a as Ze}from"./modifiers.esm-BoDOvUKl.js";import{u as Ye,L as $}from"./use-limits-display-prefs-DBkAp6ob.js";import{P as Je}from"./ProviderIcon-BZZ45-gY.js";import{a as B,l as V}from"./limits-providers-jn7Yln_V.js";import{m as J}from"./react-DZqS6YTX.js";import{a as A,T as j,b,S as _,u as T}from"./Controls-BIj6yVxE.js";import{P as Xe,u as Qe,a as et}from"./use-session-efficiency-pref-DBmd-MqH.js";import{C as tt}from"./check-DIKw7TYH.js";import{C as nt}from"./copy-CsfAtL7P.js";import{A as X}from"./index-ChZkJjpk.js";import{u as at}from"./useCurrency-B0YsRDj-.js";import{u as st}from"./useTokenFormat-PP3D0Ket.js";import{S as U}from"./Select-BP8aVRZ1.js";import{I as it}from"./info-CAjN3dX4.js";import{C as ot}from"./ConfirmModal-CVjmhZd6.js";import{A as rt}from"./arrow-up-right-rpBCOTg2.js";import{D as lt}from"./download-DM1W9pIW.js";import{i as ct}from"./host-mode-Bc_iTzHk.js";import"./Card-aSp259T0.js";import"./ToolbarRootContext-Bmg56vYz.js";import"./composite-_NeXO0lv.js";import"./SelectItemText-Odx47kND.js";import"./DialogTitle-DfSBUjWf.js";import"./store-Crne4DqF.js";import"./DialogDescription-KY7X94CG.js";const ut=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],dt=O("flask-conical",ut);const gt=[["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"}]],pt=O("grip-vertical",gt);const ht=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],mt=O("languages",ht);const bt=[["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"}]],ft=O("log-out",bt);const xt=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],yt=O("palette",xt);const vt=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],kt=O("user-round",vt),jt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function St({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:L("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",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:L("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function wt({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=qe({id:e}),p={transform:We.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:p,className:L("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(pt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),B(e)?t.jsx(Je,{provider:B(e),size:18,className:L("pointer-events-none",jt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:V(e)}),t.jsx("div",{onPointerDown:h=>h.stopPropagation(),children:t.jsx(St,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${V(e)}`})})]})}function Nt({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=Me(F($e,{activationConstraint:{distance:6}}),F(Fe,{coordinateGetter:He})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(Be,{sensors:r,collisionDetection:Ve,modifiers:[Ze],onDragEnd:l,children:t.jsx(Ke,{items:a,strategy:ze,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(wt,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function Ct(e){if(!e||typeof e!="object")return"";const a=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=a.full_name||a.name||s.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Et(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function At(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function D(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function Lt(e,a,s){const[i,o]=g.useState(()=>ue()),r=a&&s&&de(),l=g.useCallback(async()=>{const c=!i;if(ge(c),o(c),!!c)try{await pe(()=>e())}catch(u){D("cloud sync",u)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function Ot(e){const[a,s]=g.useState(!1),[i,o]=g.useState(!1),[r,l]=g.useState(!1),[c,u]=g.useState(!1),[p,h]=g.useState(null),[d,y]=g.useState(!1),[x,S]=g.useState(""),[k,m]=g.useState(!1),[v,C]=g.useState(""),[N,P]=g.useState(""),[I,f]=g.useState(!1),[E,se]=g.useState(null),ie=g.useMemo(()=>Ct(e),[e]),oe=g.useMemo(()=>Et(e),[e]),re=g.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),le=g.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:h,setGithubUrl:C,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:m}),[]);return{anonymousOn:i,customDisplayName:p,displayName:ie,editingGithub:I,editingName:d,email:oe,githubError:E,githubInput:N,githubUrl:v,loadSetters:le,nameInput:x,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:h,setEditingGithub:f,setEditingName:y,setGithubError:se,setGithubInput:P,setGithubUrl:C,setNameInput:S,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:s,setShowGithubOn:m,showGithubOn:k,userId:re}}function Pt(e,a,s){g.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await W({getAccessToken:e});if(!i||!o)return;const r=await he({accessToken:o});if(!i)return;s.setPublicProfileOn(!!r?.enabled),s.setAnonymousOn(!!r?.anonymous),r?.display_name&&s.setCustomDisplayName(r.display_name),s.setShowGithubOn(!!r?.show_github_url),s.setGithubUrl(r?.github_url||"")}catch(o){D("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function _t(e,a){return g.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await W({getAccessToken:e});if(!l)return!1;const c=await me({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):D(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Tt(e,a){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:a.handleAnonymousToggle,handleSaveName:a.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:a.startEditingName}}function It(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Gt(e,a){const s=g.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:g.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Rt(e,a,s){const i=g.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=g.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ut(e,a){const s=g.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=g.useCallback(async()=>{const r=At(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=g.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Dt(){const e=ce(),a=Ot(e.user),s=Lt(e.getAccessToken,e.enabled,e.signedIn);Pt(e.getAccessToken,e.signedIn,a.loadSetters);const i=_t(e.getAccessToken,a),o=Gt(a,i),r=Rt(a,i,e.refreshDisplayName),l=Ut(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Tt(a,{...o,...r}),github:It(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function Q({disabled:e,onCancel:a,onSave:s,saveLabel:i=n("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),t.jsx("button",{type:"button",onClick:a,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:n("settings.account.cancel")})]})}function Mt({nameInput:e,setEditingName:a,setNameInput:s,profileSaving:i,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&a(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.displayName")}),t.jsx(Q,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Ht({githubError:e,githubInput:a,handleSaveGithub:s,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:a,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&s(),c.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.githubUrlPlaceholder")}),t.jsx(Q,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?n("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function ee({disabled:e=!1,label:a,onClick:s,title:i}){return t.jsxs("button",{type:"button",onClick:s,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Xe,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function te({actions:e,editing:a,editor:s,hint:i,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),a?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),a?null:e]})})}function Ft({name:e}){const a=e.anonymousOn?n("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function $t({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:p,setEditingName:h,setNameInput:d,startEditingName:y}=e,x=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(te,{label:n("settings.account.displayName"),editing:o,hint:x,editor:t.jsx(Mt,{nameInput:c,setEditingName:h,setNameInput:d,profileSaving:p,handleSaveName:l}),actions:t.jsx(Ft,{name:e})})}function Bt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:p,setGithubError:h,setGithubInput:d,showGithubOn:y,startEditingGithub:x}=e;return t.jsx(t.Fragment,{children:t.jsx(te,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Ht,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:u,setEditingGithub:p,setGithubError:h,setGithubInput:d}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{label:n("settings.account.edit"),onClick:x}),t.jsx(j,{checked:y,onChange:l,disabled:c||u,ariaLabel:n("settings.account.githubUrl")})]})})})}function Vt(){const{openLoginModal:e}=be();return t.jsx(A,{title:n("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:n("settings.account.signIn")})]})})}function Kt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx($t,{name:e}),t.jsx(Bt,{github:a})]})}function zt(){const e=Dt();return e.enabled?e.signedIn?t.jsxs(A,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Wt,{onSignOut:e.signOut}),children:[t.jsx(qt,{userId:e.userId}),t.jsx(Zt,{settings:e}),t.jsx(Yt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Jt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(Vt,{}):null}function qt({userId:e}){const[a,s]=R.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),s(!0),globalThis.setTimeout(()=>s(!1),1200)}catch{s(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":n("settings.account.copyUserId"),children:[a?t.jsx(tt,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(nt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Wt({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(ft,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Zt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Yt({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function Jt({visible:e,name:a,github:s}){return t.jsx(X,{initial:!1,children:e?t.jsx(J.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:t.jsx(Kt,{name:a,github:s})},"public-profile-fields"):null})}function Xt(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:xe},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:ye},{value:"system",label:n("settings.appearance.theme.system"),Icon:Y}]}function Qt(){return[{value:je,label:n("settings.appearance.language.system")},{value:Se,label:n("settings.appearance.language.english")},{value:we,label:n("settings.appearance.language.chinese")},{value:Ne,label:n("settings.appearance.language.traditional_chinese")},{value:Ce,label:n("settings.appearance.language.japanese")},{value:Ee,label:n("settings.appearance.language.korean")},{value:Ae,label:n("settings.appearance.language.german")}]}function en(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function tn(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=en(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function nn({locale:e,setLocale:a}){const s=Qt();return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(mt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function an({currency:e,setCurrency:a}){const s=ve().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function sn({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===ke)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=tn(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${a.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(it,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function on(){const{theme:e,setTheme:a}=fe(),{locale:s,setLocale:i}=Z(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=at(),{mode:p,setMode:h}=st();return t.jsxs(A,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(_,{options:Xt(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(nn,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(sn,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(an,{currency:o,setCurrency:u})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(_,{options:[{value:M.COMPACT,label:n("settings.appearance.token_format.compact")},{value:M.FULL,label:n("settings.appearance.token_format.full")}],value:p,onChange:h})})]})}function G({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:n(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:n("qpd.card.badge")})]})}function rn(){const{enabled:e,toggle:a}=Qe(),{enabled:s,toggle:i}=et(),{available:o,settings:r,setSetting:l}=T(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(A,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(j,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:n("settings.labs.island.aria")})}),u&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(j,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(j,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function ln(){const{available:e,settings:a,setSetting:s,runAction:i}=T();if(!e)return null;const o=!!a?.launchAtLogin,r=a?.toastOnReset!==!1,l=a?.confettiOnReset!==!1,c=a?.launchAtLoginSupported!==!1,u=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,h=!!a?.updateBusy,d=!!a?.isSyncing;return t.jsxs(A,{title:n("settings.section.menubar"),children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Le,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n("settings.menubar.appearanceLink"),t.jsx(rt,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:r,onChange:()=>s("toastOnReset",!r),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:l,onChange:()=>s("confettiOnReset",!l),ariaLabel:n("settings.menubar.confettiOnReset")})}),c?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>s("launchAtLogin",!o),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Oe,{className:L("h-3.5 w-3.5",d&&"animate-spin"),"aria-hidden":!0}),d?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(j,{checked:u,onChange:()=>s("autoUpdateEnabled",!u),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:h,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(lt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function cn(e,a){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(a);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function un(){const{available:e,settings:a,runAction:s}=T(),i=e&&a?.version,[o,r]=R.useState(!1),[l,c]=R.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:u}=Z(),p="0.96.0",h=async()=>{r(!0);try{const k=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!k.ok)throw new Error("Failed to fetch");const m=await k.json(),v=m.tag_name;cn(p,v)?c({open:!0,latestVersion:v,htmlUrl:m.html_url}):H({title:n("settings.menubar.updates.upToDate")})}catch(k){console.error("Check updates failed:",k),H({title:n("settings.menubar.updates.failed")})}finally{r(!1)}},d=n("settings.menubar.updates.modalTitle"),y=n("settings.menubar.updates.modalDescription",{version:l.latestVersion}),x=n("settings.menubar.updates.modalConfirm"),S=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:h,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Pe,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(ot,{open:l.open,title:d,description:y,confirmLabel:x,cancelLabel:S,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),c(k=>({...k,open:!1}))},onCancel:()=>c(k=>({...k,open:!1}))})]})}const dn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],gn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],K="w-full rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white";function z(e){const a={},s=String(e.host||"").trim();(!s||/:\/\//.test(s)||s.includes("/"))&&(a.host=n("settings.network.error.host"));const i=String(e.port??"").trim(),o=Number(i);return(!i||!/^\d+$/.test(i)||!Number.isInteger(o)||o<1||o>65535)&&(a.port=n("settings.network.error.port")),a}function pn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=g.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=g.useState({}),[u,p]=g.useState(!1),[h,d]=g.useState(""),[y,x]=g.useState(null),[S,k]=g.useState(!1),[m,v]=g.useState(null);g.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const C=g.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),N=f=>{r(E=>({...E,...f})),c({}),d(""),x(null),v(null)},P=async()=>{if(o.mode==="manual"){const f=z(o);if(Object.keys(f).length){c(f);return}}p(!0),d(""),x(null);try{await s(o),d("saved")}catch(f){d("error"),x(f)}finally{p(!1)}},I=async()=>{const f=z(o);if(Object.keys(f).length){c(f);return}k(!0),v(null);try{const E=await i(o);v(E)}catch(E){v({ok:!1,error:E?.message||String(E)})}finally{k(!1)}};return t.jsxs(A,{title:n("settings.section.network"),subtitle:C,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(_,{options:dn(),value:o.mode,onChange:f=>N({mode:f})})}),t.jsx(X,{initial:!1,children:o.mode==="manual"?t.jsxs(J.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:[t.jsx(b,{label:n("settings.network.protocol.label"),control:t.jsx(U,{value:o.protocol,onValueChange:f=>N({protocol:f}),options:gn(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(b,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:f=>N({host:f.target.value}),placeholder:n("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.host?!0:void 0,"aria-label":n("settings.network.host.label"),className:K})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:f=>N({port:f.target.value}),placeholder:n("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.port?!0:void 0,"aria-label":n("settings.network.port.label"),className:K})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:I,disabled:S||u,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:S?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:P,disabled:u||S,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})]}),m?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:m.ok?n("settings.network.test.ok",{status:String(m.status??"")}):n("settings.network.test.fail",{error:m.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:P,disabled:u,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),h==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,h==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:y?.unprotected?n("settings.network.save_error_unprotected",{error:y?.message||String(y||"")}):n("settings.network.save_error",{error:y?.message||String(y||"")})}):null]})}const ne="/functions/tokentracker-proxy-config",hn="/functions/tokentracker-proxy-test",mn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function ae(e){return!e||typeof e.mode!="string"?null:{mode:e.mode,protocol:typeof e.protocol=="string"?e.protocol:"http",host:typeof e.host=="string"?e.host:"",port:e.port==null||e.port===0?"":String(e.port),effective:typeof e.effective=="string"?e.effective:"none",applyError:typeof e.applyError=="string"&&e.applyError.trim()?e.applyError:null}}async function bn(){const e=await fetch(ne,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return ae(a)}async function q(){const{getLocalApiAuthHeaders:e}=await Te(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-4IGm4Djn.js").then(s=>s.d8);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function fn(){const[e,a]=g.useState(!1),[s,i]=g.useState(!0),[o,r]=g.useState(mn);g.useEffect(()=>{if(!ct()){a(!1),i(!1);return}let u=!1;return(async()=>{try{const p=await bn();if(u)return;if(!p){a(!1),i(!1);return}r(p),a(!0),i(!1)}catch{u||(a(!1),i(!1))}})(),()=>{u=!0}},[]);const l=g.useCallback(async u=>{const p=await q(),h=await fetch(ne,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({mode:u.mode,protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),d=await h.json().catch(()=>null);if(!h.ok){const x=d&&typeof d.error=="string"?d.error:`HTTP ${h.status}`;throw new Error(x)}const y=ae(d);if(y&&r(y),d&&d.ok===!1){const x=d&&typeof d.applyError=="string"&&d.applyError||d&&typeof d.error=="string"&&d.error||`HTTP ${h.status}`,S=new Error(x);throw d.unprotected===!0&&(S.unprotected=!0),S}return y||d},[]),c=g.useCallback(async u=>{const p=await q(),h=await fetch(hn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),d=await h.json().catch(()=>null);if(!d||typeof d.ok!="boolean")throw new Error(d&&typeof d.error=="string"?d.error:`HTTP ${h.status}`);return d},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const w={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function xn({prefs:e}){return t.jsx(_,{options:[{value:$.USED,label:n("limits.settings.display_mode_used")},{value:$.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function zn(){const e=Ye(),{available:a,settings:s,setSetting:i}=T(),o=fn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,[u,p]=Ie(),h=Ge(),d=u.get("section"),x=Object.values(w).includes(d)&&(d!==w.NATIVE_APP||a)&&(d!==w.NETWORK||r)?d:w.APPEARANCE,S=m=>{const v=new URLSearchParams(u);m===w.APPEARANCE?v.delete("section"):v.set("section",m),p(v,{replace:!0})},k=[{id:w.APPEARANCE,label:n("settings.section.appearance"),Icon:yt,content:t.jsx(on,{})},...a?[{id:w.NATIVE_APP,label:n("settings.section.menubar"),Icon:Y,content:t.jsx(ln,{})}]:[],...r?[{id:w.NETWORK,label:n("settings.section.network"),Icon:Re,content:t.jsx(pn,{proxySettings:o})}]:[],{id:w.ACCOUNT,label:n("settings.section.account"),Icon:kt,content:t.jsx(zt,{})},{id:w.LIMITS,label:n("settings.section.limits"),Icon:Ue,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(A,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(xn,{prefs:e})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})}),t.jsx(b,{label:n("settings.limits.showSubscriptions"),hint:n("settings.limits.showSubscriptionsHint"),control:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>h("/limits?openSubscriptions=1"),"aria-label":n("limits.page.openSubscriptions"),title:n("limits.page.openSubscriptions"),className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 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 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(De,{size:14,"aria-hidden":!0})}),t.jsx(j,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(A,{title:n("settings.limits.providers"),children:t.jsx(Nt,{prefs:e})})]})},{id:w.LABS,label:n("settings.section.labs"),Icon:dt,content:t.jsx(rn,{})}];return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsx("div",{className:"mb-7",children:t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")})}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[13.5rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 border-b border-oai-gray-200 pb-3 dark:border-oai-gray-800 md:border-b-0 md:border-r md:pb-0 md:pr-5",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-1 md:overflow-visible",children:k.map(({id:m,label:v,Icon:C})=>{const N=x===m;return t.jsxs("button",{id:`settings-nav-${m}`,type:"button","aria-current":N?"page":void 0,"aria-controls":`settings-panel-${m}`,onClick:()=>S(m),className:L("inline-flex min-h-10 min-w-max shrink-0 items-center gap-1.5 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0 md:gap-2 md:px-3",N?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:bg-oai-gray-50 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200"),children:[t.jsx(C,{className:L("h-4 w-4 shrink-0",N?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:v})]},m)})})}),t.jsxs("div",{className:"min-w-0",children:[k.map(({id:m,label:v,content:C})=>t.jsx("section",{id:`settings-panel-${m}`,"aria-labelledby":`settings-nav-${m}`,"aria-label":v,"data-settings-panel":m,hidden:x!==m,children:C},m)),t.jsx(un,{})]})]})]})})})}export{zn as SettingsPage};
|