tokentracker-cli 0.96.1 → 0.96.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.de.md +2 -2
  2. package/README.ja.md +2 -2
  3. package/README.ko.md +2 -2
  4. package/README.md +2 -2
  5. package/README.zh-CN.md +2 -2
  6. package/dashboard/dist/assets/{AchievementBadge-DKyElm0T.js → AchievementBadge-CgEitoX1.js} +1 -1
  7. package/dashboard/dist/assets/{AchievementsPage-BvCx3wND.js → AchievementsPage-dnnea0JH.js} +2 -2
  8. package/dashboard/dist/assets/{AchievementsSection-DN69LzXX.js → AchievementsSection-CJqG0UP7.js} +1 -1
  9. package/dashboard/dist/assets/{BadgeDetailModal-DGiKdZfz.js → BadgeDetailModal-BLV6SJoI.js} +1 -1
  10. package/dashboard/dist/assets/{BotAnimated-zN8rH7_K.js → BotAnimated-Cm78yEbz.js} +1 -1
  11. package/dashboard/dist/assets/{Card-COWo-ClV.js → Card-IPGSYT6O.js} +1 -1
  12. package/dashboard/dist/assets/{ClawdAnimated-BWsB7Eat.js → ClawdAnimated-04w1U1sm.js} +2 -2
  13. package/dashboard/dist/assets/{CommandPalette-BfvIwuoJ.js → CommandPalette-gSSa1V_s.js} +1 -1
  14. package/dashboard/dist/assets/{CommunityStatsModal-BQWg7R_y.js → CommunityStatsModal-CICwUz14.js} +1 -1
  15. package/dashboard/dist/assets/{ConfirmModal-C7ABSI-O.js → ConfirmModal-DaWC0cY7.js} +1 -1
  16. package/dashboard/dist/assets/{Controls-vMzEZzej.js → Controls-BDihA03F.js} +1 -1
  17. package/dashboard/dist/assets/{DashboardPage-QBhbCMZF.js → DashboardPage-hV7wncKF.js} +1 -1
  18. package/dashboard/dist/assets/{DevicePage-3ejUBLWM.js → DevicePage-BPpo_eiY.js} +1 -1
  19. package/dashboard/dist/assets/{DialogClose-D_dvtfGV.js → DialogClose-C_dF-r3s.js} +1 -1
  20. package/dashboard/dist/assets/DialogDescription-GClOSCaE.js +1 -0
  21. package/dashboard/dist/assets/{DialogTitle-_ahf0z8b.js → DialogTitle-Buh_5688.js} +1 -1
  22. package/dashboard/dist/assets/{FadeIn-D7Jcfz1N.js → FadeIn-DmI9PRLa.js} +1 -1
  23. package/dashboard/dist/assets/{HeaderGithubStar-D--Rx5BS.js → HeaderGithubStar-CBO4cY7i.js} +1 -1
  24. package/dashboard/dist/assets/{HoverTooltip-n1W0z3Wr.js → HoverTooltip-CPFGhi9K.js} +1 -1
  25. package/dashboard/dist/assets/{IpCheckPage-D202tl9B.js → IpCheckPage-Do7w_6z6.js} +1 -1
  26. package/dashboard/dist/assets/{LandingPage-D6yL2EZo.js → LandingPage-at_Ti1ZE.js} +2 -2
  27. package/dashboard/dist/assets/{LeaderboardAvatar-ChFg2mtA.js → LeaderboardAvatar-BH1cnKPp.js} +1 -1
  28. package/dashboard/dist/assets/{LeaderboardPage-BXHwGs8r.js → LeaderboardPage-Cd30aXwL.js} +2 -2
  29. package/dashboard/dist/assets/{LeaderboardProfileModal-B5LoOpCk.js → LeaderboardProfileModal-CVsti_HN.js} +3 -3
  30. package/dashboard/dist/assets/{LeaderboardProfilePage-jsukhRz8.js → LeaderboardProfilePage-BfSpDM9e.js} +1 -1
  31. package/dashboard/dist/assets/LimitsPage-_-BadDAj.js +8 -0
  32. package/dashboard/dist/assets/{LocalOnlyNotice-Du0lz657.js → LocalOnlyNotice-9-vRgsdn.js} +1 -1
  33. package/dashboard/dist/assets/{LoginCard-BFEX9x7-.js → LoginCard-DM_ZdFNl.js} +1 -1
  34. package/dashboard/dist/assets/{LoginModal-DqC7_d35.js → LoginModal-BaNMznwh.js} +1 -1
  35. package/dashboard/dist/assets/{LoginPage-Dzx8N7HE.js → LoginPage-BMMthUf4.js} +1 -1
  36. package/dashboard/dist/assets/{PetPage-CNlWHF4z.js → PetPage-Iq8Hswai.js} +1 -1
  37. package/dashboard/dist/assets/{PopoverPopup-D9jadD3j.js → PopoverPopup-DXr3JxVV.js} +1 -1
  38. package/dashboard/dist/assets/{ProviderIcon-Caz5PuAm.js → ProviderIcon-sb2keSY2.js} +1 -1
  39. package/dashboard/dist/assets/{ResetPasswordPage-x_GR79sR.js → ResetPasswordPage-Ca4SULSV.js} +1 -1
  40. package/dashboard/dist/assets/{SegmentedControl-BxDiDV4R.js → SegmentedControl-Bbsn-qvZ.js} +1 -1
  41. package/dashboard/dist/assets/{Select-B5o-1sEl.js → Select-vD-yj-qa.js} +1 -1
  42. package/dashboard/dist/assets/{SelectItemText-CiA6L7Wk.js → SelectItemText-CRtFEuvg.js} +1 -1
  43. package/dashboard/dist/assets/{ServiceStatusPage-BVQuVdjg.js → ServiceStatusPage-BPS8KJ3a.js} +1 -1
  44. package/dashboard/dist/assets/{SessionsPage-DE39wNIO.js → SessionsPage-C1yt3TMZ.js} +1 -1
  45. package/dashboard/dist/assets/SettingsPage-CWVHrMer.js +2 -0
  46. package/dashboard/dist/assets/{SkillsPage-COk-YQQ5.js → SkillsPage-DGWEH1xm.js} +1 -1
  47. package/dashboard/dist/assets/{TokenGalaxy-BPM779Wb.js → TokenGalaxy-DKvbJbnv.js} +1 -1
  48. package/dashboard/dist/assets/{ToolbarRootContext-CozJT6Vs.js → ToolbarRootContext-D8yov1dW.js} +1 -1
  49. package/dashboard/dist/assets/{TrendMonitor-BkNy-o1D.js → TrendMonitor-YF5C_-L1.js} +1 -1
  50. package/dashboard/dist/assets/{WidgetsPage-Bpg6H-ZB.js → WidgetsPage-BKV3DgXg.js} +1 -1
  51. package/dashboard/dist/assets/{WrappedPage-C6-NM-RO.js → WrappedPage-s4IRoLf7.js} +1 -1
  52. package/dashboard/dist/assets/__vite-browser-external-_LUatzwU.js +45 -0
  53. package/dashboard/dist/assets/{agent-logos-DpbkRqXT.js → agent-logos-Hbt-wyl2.js} +1 -1
  54. package/dashboard/dist/assets/{arrow-up-right-BjOtWUVs.js → arrow-up-right-KeIpKlw3.js} +1 -1
  55. package/dashboard/dist/assets/{check-BlxnX5jZ.js → check-_QKyY1v_.js} +1 -1
  56. package/dashboard/dist/assets/{composite-Dxmivlk4.js → composite-BidfcMeb.js} +1 -1
  57. package/dashboard/dist/assets/{copy-CIsWjLY5.js → copy-DpLM3QMD.js} +1 -1
  58. package/dashboard/dist/assets/{download-QDaQbQdd.js → download-C4NX-JnW.js} +1 -1
  59. package/dashboard/dist/assets/{external-link-DPV4VU3m.js → external-link-CG-7FcOF.js} +1 -1
  60. package/dashboard/dist/assets/{flame-B_X-7VNp.js → flame-CkWid7Ji.js} +1 -1
  61. package/dashboard/dist/assets/{format-tokens-DEx2TJj8.js → format-tokens-CbwWhioZ.js} +1 -1
  62. package/dashboard/dist/assets/{icons-983RyGSl.js → icons-BZq17rU3.js} +1 -1
  63. package/dashboard/dist/assets/{index-Cjs5stC0.js → index-CR9tDiiC.js} +1 -1
  64. package/dashboard/dist/assets/{index-BONYA8HZ.js → index-CSwEiUn4.js} +1 -1
  65. package/dashboard/dist/assets/{index-qtonw_x4.js → index-DDGLE0dz.js} +1 -1
  66. package/dashboard/dist/assets/{info-DpVOhXZI.js → info-mkeRjzqc.js} +1 -1
  67. package/dashboard/dist/assets/limits-providers-DRkcWQup.js +1 -0
  68. package/dashboard/dist/assets/{link-2-CBro-upz.js → link-2-BjMw8csC.js} +1 -1
  69. package/dashboard/dist/assets/{loader-circle-wYFdSyOd.js → loader-circle-cGWOJnWn.js} +1 -1
  70. package/dashboard/dist/assets/{maximize-2-DhTyQ4ly.js → maximize-2-Cg_S73tD.js} +1 -1
  71. package/dashboard/dist/assets/{modifiers.esm-CPljwVhN.js → modifiers.esm-DNxTWxId.js} +1 -1
  72. package/dashboard/dist/assets/{monitor-smartphone-D_wr-HOR.js → monitor-smartphone-BvE9Tt2U.js} +1 -1
  73. package/dashboard/dist/assets/{plus-BNjfkBEF.js → plus-BC2wdPRr.js} +1 -1
  74. package/dashboard/dist/assets/{provider-display-BOBtUyFi.js → provider-display-B7GggHQy.js} +1 -1
  75. package/dashboard/dist/assets/{react-yHv9MTUA.js → react-D0kcslTz.js} +1 -1
  76. package/dashboard/dist/assets/{search-Dfak92ZA.js → search-BuBNF3E3.js} +1 -1
  77. package/dashboard/dist/assets/{skills-api-By2PdNa1.js → skills-api-DxAN5pNx.js} +1 -1
  78. package/dashboard/dist/assets/{sortable.esm-B9xy66_v.js → sortable.esm-DoqMcEX-.js} +1 -1
  79. package/dashboard/dist/assets/{store-oQZR4d9M.js → store-Cg1HeUFM.js} +1 -1
  80. package/dashboard/dist/assets/{terminal-pbXWBmZM.js → terminal-COWFUJdU.js} +1 -1
  81. package/dashboard/dist/assets/{trash-2-CboDPwbW.js → trash-2-Cqjki3RI.js} +1 -1
  82. package/dashboard/dist/assets/{use-community-stats-D6HTdnHq.js → use-community-stats-DsrlOPDM.js} +1 -1
  83. package/dashboard/dist/assets/{use-latest-request-guard-hwSr9Cam.js → use-latest-request-guard-ryRFL2gx.js} +1 -1
  84. package/dashboard/dist/assets/{use-limits-display-prefs-B-pbwUS8.js → use-limits-display-prefs-DkSuu12m.js} +1 -1
  85. package/dashboard/dist/assets/{use-ordered-list-OtfOqrNb.js → use-ordered-list-D-Q86R1b.js} +1 -1
  86. package/dashboard/dist/assets/use-reduced-motion-D7NNqavo.js +1 -0
  87. package/dashboard/dist/assets/{use-session-efficiency-pref-BScvtS8F.js → use-session-efficiency-pref-CrNz45y7.js} +1 -1
  88. package/dashboard/dist/assets/{use-transform-Cy1ykjEs.js → use-transform-CoGM21px.js} +1 -1
  89. package/dashboard/dist/assets/{use-usage-limits-CSMb2zYW.js → use-usage-limits-C_6L1sO5.js} +1 -1
  90. package/dashboard/dist/assets/{useCurrency-VqF3cy1C.js → useCurrency-CgCfDktb.js} +1 -1
  91. package/dashboard/dist/assets/{useTokenFormat-Cgub4MXu.js → useTokenFormat-QKtzCKTL.js} +1 -1
  92. package/dashboard/dist/assets/{zap-DStzvQJI.js → zap-CTIobzgU.js} +1 -1
  93. package/dashboard/dist/brand-logos/commandcode.svg +1 -0
  94. package/dashboard/dist/index.html +4 -4
  95. package/dashboard/dist/ip-check.html +1 -1
  96. package/dashboard/dist/leaderboard.html +1 -1
  97. package/dashboard/dist/share.html +1 -1
  98. package/package.json +1 -1
  99. package/src/lib/codex-rollout-parser.js +2 -2
  100. package/src/lib/commandcode-limits.js +317 -0
  101. package/src/lib/pricing/curated-overrides.json +11 -0
  102. package/src/lib/pricing/index.js +6 -7
  103. package/src/lib/pricing/seed-snapshot.json +1 -1
  104. package/src/lib/rollout.js +166 -6
  105. package/src/lib/session-analytics.js +2 -2
  106. package/src/lib/usage-limits.js +42 -1
  107. package/dashboard/dist/assets/DialogDescription-ryGYdQjX.js +0 -1
  108. package/dashboard/dist/assets/LimitsPage-PvqkOOwp.js +0 -6
  109. package/dashboard/dist/assets/SettingsPage-DJrb_fsK.js +0 -2
  110. package/dashboard/dist/assets/__vite-browser-external-BGnq8Ebm.js +0 -45
  111. package/dashboard/dist/assets/limits-providers-BUoquSA-.js +0 -1
  112. package/dashboard/dist/assets/use-reduced-motion-DGXcZBX3.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-BGnq8Ebm.js","assets/__vite-browser-external-CvMMIjhi.css"])))=>i.map(i=>d[i]);
2
- import{m as I,j as t,e as _,c as n,a as ue,r as u,ao as ge,aU as pe,au as he,av as me,a8 as J,aV as be,aW as fe,u as xe,d as M,a0 as ye,M as X,n as $,aX as ve,aY as ke,U as Q,aZ as je,x as Se,a_ as we,a$ as Ne,b0 as Ce,b1 as Ee,b2 as Pe,b3 as Ae,b4 as Le,b5 as ee,L as Oe,R as _e,b6 as Te,b7 as Ie,a5 as V,_ as Ge,h as Re,f as De,b8 as Ue,b9 as Me,ax as He}from"./__vite-browser-external-BGnq8Ebm.js";import{a as Fe,b as B,s as $e,K as Ve,P as Be,D as Ke,c as ze,S as qe,v as We,u as Ze,C as Ye}from"./sortable.esm-B9xy66_v.js";import{a as Je}from"./modifiers.esm-CPljwVhN.js";import{u as Xe,L as K}from"./use-limits-display-prefs-B-pbwUS8.js";import{P as Qe}from"./ProviderIcon-Caz5PuAm.js";import{a as z,l as q}from"./limits-providers-BUoquSA-.js";import{m as te}from"./react-yHv9MTUA.js";import{a as L,T as k,b as x,S as G,u as R}from"./Controls-vMzEZzej.js";import{P as et,u as tt,a as nt}from"./use-session-efficiency-pref-BScvtS8F.js";import{C as at}from"./check-BlxnX5jZ.js";import{C as st}from"./copy-CIsWjLY5.js";import{A as ne}from"./index-Cjs5stC0.js";import{u as it}from"./useCurrency-VqF3cy1C.js";import{u as ot}from"./useTokenFormat-Cgub4MXu.js";import{S as H}from"./Select-B5o-1sEl.js";import{I as rt}from"./info-DpVOhXZI.js";import{C as lt}from"./ConfirmModal-C7ABSI-O.js";import{A as ct}from"./arrow-up-right-BjOtWUVs.js";import{D as dt}from"./download-QDaQbQdd.js";import{i as ut}from"./host-mode-Bc_iTzHk.js";import"./Card-COWo-ClV.js";import"./ToolbarRootContext-CozJT6Vs.js";import"./composite-Dxmivlk4.js";import"./SelectItemText-CiA6L7Wk.js";import"./DialogTitle-_ahf0z8b.js";import"./store-oQZR4d9M.js";import"./DialogDescription-ryGYdQjX.js";const gt=[["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"}]],pt=I("flask-conical",gt);const ht=[["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"}]],mt=I("grip-vertical",ht);const bt=[["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"}]],ft=I("languages",bt);const xt=[["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"}]],yt=I("log-out",xt);const vt=[["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"}]],kt=I("palette",vt);const jt=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],St=I("user-round",jt),wt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Nt({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:_("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:_("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Ct({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:d}=Ze({id:e}),h={transform:Ye.Transform.toString(l)||void 0,transition:c,zIndex:d?20:void 0};return t.jsxs("div",{ref:r,style:h,className:_("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",d&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(mt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),z(e)?t.jsx(Qe,{provider:z(e),size:18,className:_("pointer-events-none",wt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:q(e)}),t.jsx("div",{onPointerDown:p=>p.stopPropagation(),children:t.jsx(Nt,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${q(e)}`})})]})}function Et({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=Fe(B(Be,{activationConstraint:{distance:6}}),B(Ve,{coordinateGetter:$e})),l=({active:c,over:d})=>{d&&c.id!==d.id&&o(c.id,d.id)};return t.jsx(Ke,{sensors:r,collisionDetection:ze,modifiers:[Je],onDragEnd:l,children:t.jsx(qe,{items:a,strategy:We,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(Ct,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function Pt(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 At(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Lt(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 F(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function Ot(e,a,s){const[i,o]=u.useState(()=>ge()),r=a&&s&&pe(),l=u.useCallback(async()=>{const c=!i;if(he(c),o(c),!!c)try{await me(()=>e())}catch(d){F("cloud sync",d)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function _t(e){const[a,s]=u.useState(!1),[i,o]=u.useState(!1),[r,l]=u.useState(!1),[c,d]=u.useState(!1),[h,p]=u.useState(null),[g,m]=u.useState(!1),[v,j]=u.useState(""),[A,y]=u.useState(!1),[w,N]=u.useState(""),[b,S]=u.useState(""),[O,f]=u.useState(!1),[E,D]=u.useState(null),T=u.useMemo(()=>Pt(e),[e]),le=u.useMemo(()=>At(e),[e]),ce=u.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),de=u.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:p,setGithubUrl:N,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:y}),[]);return{anonymousOn:i,customDisplayName:h,displayName:T,editingGithub:O,editingName:g,email:le,githubError:E,githubInput:b,githubUrl:w,loadSetters:de,nameInput:v,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:p,setEditingGithub:f,setEditingName:m,setGithubError:D,setGithubInput:S,setGithubUrl:N,setNameInput:j,setProfileLoading:l,setProfileSaving:d,setPublicProfileOn:s,setShowGithubOn:y,showGithubOn:A,userId:ce}}function Tt(e,a,s){u.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await J({getAccessToken:e});if(!i||!o)return;const r=await be({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){F("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function It(e,a){return u.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await J({getAccessToken:e});if(!l)return!1;const c=await fe({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):F(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Gt(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 Rt(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 Dt(e,a){const s=u.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:u.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Ut(e,a,s){const i=u.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=u.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Mt(e,a){const s=u.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=u.useCallback(async()=>{const r=Lt(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=u.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Ht(){const e=ue(),a=_t(e.user),s=Ot(e.getAccessToken,e.enabled,e.signedIn);Tt(e.getAccessToken,e.signedIn,a.loadSetters);const i=It(e.getAccessToken,a),o=Dt(a,i),r=Ut(a,i,e.refreshDisplayName),l=Mt(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Gt(a,{...o,...r}),github:Rt(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function ae({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 Ft({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(ae,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function $t({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(ae,{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 se({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(et,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function ie({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 Vt({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(se,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function Bt({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:d,profileSaving:h,setEditingName:p,setNameInput:g,startEditingName:m}=e,v=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(ie,{label:n("settings.account.displayName"),editing:o,hint:v,editor:t.jsx(Ft,{nameInput:c,setEditingName:p,setNameInput:g,profileSaving:h,handleSaveName:l}),actions:t.jsx(Vt,{name:e})})}function Kt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:d,setEditingGithub:h,setGithubError:p,setGithubInput:g,showGithubOn:m,startEditingGithub:v}=e;return t.jsx(t.Fragment,{children:t.jsx(ie,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx($t,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:d,setEditingGithub:h,setGithubError:p,setGithubInput:g}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(se,{label:n("settings.account.edit"),onClick:v}),t.jsx(k,{checked:m,onChange:l,disabled:c||d,ariaLabel:n("settings.account.githubUrl")})]})})})}function zt(){const{openLoginModal:e}=xe();return t.jsx(L,{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 qt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx(Bt,{name:e}),t.jsx(Kt,{github:a})]})}function Wt(){const e=Ht();return e.enabled?e.signedIn?t.jsxs(L,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Yt,{onSignOut:e.signOut}),children:[t.jsx(Zt,{userId:e.userId}),t.jsx(Jt,{settings:e}),t.jsx(Xt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Qt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(zt,{}):null}function Zt({userId:e}){const[a,s]=M.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(at,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(st,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Yt({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(yt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Jt({settings:e}){return e.showLocalCloudSync?t.jsx(x,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Xt({checked:e,disabled:a,onChange:s}){return t.jsx(x,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(k,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function Qt({visible:e,name:a,github:s}){return t.jsx(ne,{initial:!1,children:e?t.jsx(te.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(qt,{name:a,github:s})},"public-profile-fields"):null})}function en(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:ve},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:ke},{value:"system",label:n("settings.appearance.theme.system"),Icon:Q}]}function tn(){return[{value:we,label:n("settings.appearance.language.system")},{value:Ne,label:n("settings.appearance.language.english")},{value:Ce,label:n("settings.appearance.language.chinese")},{value:Ee,label:n("settings.appearance.language.traditional_chinese")},{value:Pe,label:n("settings.appearance.language.japanese")},{value:Ae,label:n("settings.appearance.language.korean")},{value:Le,label:n("settings.appearance.language.german")}]}function nn(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function an(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=nn(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function sn({locale:e,setLocale:a}){const s=tn();return t.jsx(H,{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(ft,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function on({currency:e,setCurrency:a}){const s=je().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(H,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function rn({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===Se)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=an(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(rt,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function ln(){const{theme:e,setTheme:a}=ye(),{locale:s,setLocale:i}=X(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:d}=it(),{mode:h,setMode:p}=ot();return t.jsxs(L,{title:n("settings.section.appearance"),children:[t.jsx(x,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(G,{options:en(),value:e,onChange:a})}),t.jsx(x,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(sn,{locale:s,setLocale:i})}),t.jsx(x,{label:n("settings.appearance.currency.label"),hint:t.jsx(rn,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(on,{currency:o,setCurrency:d})}),t.jsx(x,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(G,{options:[{value:$.COMPACT,label:n("settings.appearance.token_format.compact")},{value:$.FULL,label:n("settings.appearance.token_format.full")}],value:h,onChange:p})})]})}function U({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 cn(){const{enabled:e,toggle:a}=tt(),{enabled:s,toggle:i}=nt(),{available:o,settings:r,setSetting:l}=R(),c=o&&!!r?.dynamicIslandSupported,d=!!r?.dynamicIslandEnabled;return t.jsxs(L,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(x,{label:t.jsx(U,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(k,{checked:d,onChange:()=>l("dynamicIslandEnabled",!d),ariaLabel:n("settings.labs.island.aria")})}),d&&t.jsx(x,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(k,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(x,{label:t.jsx(U,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(k,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(x,{label:t.jsx(U,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(k,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function dn(){const{available:e,settings:a,setSetting:s,runAction:i}=R();if(!e)return null;const o=ee(),r=!!a?.launchAtLogin,l=a?.toastOnReset!==!1,c=a?.confettiOnReset!==!1,d=a?.launchAtLoginSupported!==!1,h=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,g=!!a?.updateBusy,m=!!a?.isSyncing;return t.jsxs(L,{title:n("settings.section.menubar"),children:[o?null:t.jsxs(t.Fragment,{children:[t.jsx(x,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Oe,{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(ct,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(x,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:l,onChange:()=>s("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(x,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,onChange:()=>s("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),d?t.jsx(x,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(k,{checked:r,onChange:()=>s("launchAtLogin",!r),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(x,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:m,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(_e,{className:_("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(x,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(k,{checked:h,onChange:()=>s("autoUpdateEnabled",!h),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(x,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:g,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(dt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function un(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 gn(){const{available:e,settings:a,runAction:s}=R(),i=e&&a?.version,o=a?.platform||"macos",[r,l]=M.useState(!1),[c,d]=M.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:h}=X(),p="0.96.1",g=async()=>{l(!0);try{const y=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!y.ok)throw new Error("Failed to fetch");const w=await y.json(),N=w.tag_name;un(p,N)?d({open:!0,latestVersion:N,htmlUrl:w.html_url}):V({title:n("settings.menubar.updates.upToDate")})}catch(y){console.error("Check updates failed:",y),V({title:n("settings.menubar.updates.failed")})}finally{l(!1)}},m=n("settings.menubar.updates.modalTitle"),v=n("settings.menubar.updates.modalDescription",{version:c.latestVersion}),j=n("settings.menubar.updates.modalConfirm"),A=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:o==="windows"?n("settings.menubar.updates.footerCore",{version:a.version}):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:g,disabled:r,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:r?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Te,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(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(lt,{open:c.open,title:m,description:v,confirmLabel:j,cancelLabel:A,onConfirm:()=>{window.open(c.htmlUrl,"_blank"),d(y=>({...y,open:!1}))},onCancel:()=>d(y=>({...y,open:!1}))})]})}const pn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],hn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],W="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 mn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=u.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=u.useState({}),[d,h]=u.useState(!1),[p,g]=u.useState(""),[m,v]=u.useState(null),[j,A]=u.useState(!1),[y,w]=u.useState(null);u.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const N=u.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]),b=f=>{r(E=>({...E,...f})),c({}),g(""),v(null),w(null)},S=async()=>{if(o.mode==="manual"){const f=Z(o);if(Object.keys(f).length){c(f);return}}h(!0),g(""),v(null);try{await s(o),g("saved")}catch(f){g("error"),v(f)}finally{h(!1)}},O=async()=>{const f=Z(o);if(Object.keys(f).length){c(f);return}A(!0),w(null);try{const E=await i(o);w(E)}catch(E){w({ok:!1,error:E?.message||String(E)})}finally{A(!1)}};return t.jsxs(L,{title:n("settings.section.network"),subtitle:N,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(x,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(G,{options:pn(),value:o.mode,onChange:f=>b({mode:f})})}),t.jsx(ne,{initial:!1,children:o.mode==="manual"?t.jsxs(te.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(x,{label:n("settings.network.protocol.label"),control:t.jsx(H,{value:o.protocol,onValueChange:f=>b({protocol:f}),options:hn(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(x,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:f=>b({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:W})}),t.jsx(x,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:f=>b({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:W})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:O,disabled:j||d,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:j?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:S,disabled:d||j,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:d?n("settings.network.saving"):n("settings.network.save")})]}),y?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y.ok?n("settings.network.test.ok",{status:String(y.status??"")}):n("settings.network.test.fail",{error:y.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:S,disabled:d,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:d?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),p==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,p==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:m?.unprotected?n("settings.network.save_error_unprotected",{error:m?.message||String(m||"")}):n("settings.network.save_error",{error:m?.message||String(m||"")})}):null]})}const oe="/functions/tokentracker-proxy-config",bn="/functions/tokentracker-proxy-test",fn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function re(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 xn(){const e=await fetch(oe,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return re(a)}async function Y(){const{getLocalApiAuthHeaders:e}=await Ge(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-BGnq8Ebm.js").then(s=>s.d8);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function yn(){const[e,a]=u.useState(!1),[s,i]=u.useState(!0),[o,r]=u.useState(fn);u.useEffect(()=>{if(!ut()){a(!1),i(!1);return}let d=!1;return(async()=>{try{const h=await xn();if(d)return;if(!h){a(!1),i(!1);return}r(h),a(!0),i(!1)}catch{d||(a(!1),i(!1))}})(),()=>{d=!0}},[]);const l=u.useCallback(async d=>{const h=await Y(),p=await fetch(oe,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({mode:d.mode,protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),g=await p.json().catch(()=>null);if(!p.ok){const v=g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`;throw new Error(v)}const m=re(g);if(m&&r(m),g&&g.ok===!1){const v=g&&typeof g.applyError=="string"&&g.applyError||g&&typeof g.error=="string"&&g.error||`HTTP ${p.status}`,j=new Error(v);throw g.unprotected===!0&&(j.unprotected=!0),j}return m||g},[]),c=u.useCallback(async d=>{const h=await Y(),p=await fetch(bn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),g=await p.json().catch(()=>null);if(!g||typeof g.ok!="boolean")throw new Error(g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`);return g},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const C={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"},P={PERSONAL:"personal",APP:"app",DEVELOPER:"developer"};function vn({prefs:e}){return t.jsx(G,{options:[{value:K.USED,label:n("limits.settings.display_mode_used")},{value:K.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Wn(){const e=Xe(),{available:a,settings:s,setSetting:i}=R(),o=yn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,d=ee()||s?.platform==="windows",[h,p]=Re(),g=De(),m=h.get("section"),j=Object.values(C).includes(m)&&(m!==C.NATIVE_APP||a)&&(m!==C.NETWORK||r)?m:C.APPEARANCE,A=b=>{const S=new URLSearchParams(h);b===C.APPEARANCE?S.delete("section"):S.set("section",b),p(S,{replace:!0})},y=[{id:C.APPEARANCE,label:n("settings.section.appearance"),description:n("settings.section.appearance.description"),group:P.PERSONAL,Icon:kt,content:t.jsx(ln,{})},...a?[{id:C.NATIVE_APP,label:n("settings.section.menubar"),description:n("settings.section.menubar.description"),group:P.APP,Icon:Q,content:t.jsx(dn,{})}]:[],...r?[{id:C.NETWORK,label:n("settings.section.network"),description:n("settings.section.network.description"),group:P.APP,Icon:Ue,content:t.jsx(mn,{proxySettings:o})}]:[],{id:C.ACCOUNT,label:n("settings.section.account"),description:n("settings.section.account.description"),group:P.PERSONAL,Icon:St,content:t.jsx(Wt,{})},{id:C.LIMITS,label:n("settings.section.limits"),description:n("settings.section.limits.description"),group:P.APP,Icon:Me,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(L,{title:n("settings.section.limits"),children:[t.jsx(x,{label:n("limits.settings.display_mode_label"),control:t.jsx(vn,{prefs:e})}),d?null:t.jsxs(t.Fragment,{children:[t.jsx(x,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(x,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),t.jsx(x,{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:()=>g("/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(He,{size:14,"aria-hidden":!0})}),t.jsx(k,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(L,{title:n("settings.limits.providers"),children:t.jsx(Et,{prefs:e})})]})},{id:C.LABS,label:n("settings.section.labs"),description:n("settings.section.labs.description"),group:P.DEVELOPER,Icon:pt,content:t.jsx(cn,{})}],w=[{id:P.PERSONAL,label:n("settings.nav.group.personal")},{id:P.APP,label:n("settings.nav.group.app")},{id:P.DEVELOPER,label:n("settings.nav.group.developer")}].map(b=>({...b,sections:y.filter(S=>S.group===b.id)})).filter(b=>b.sections.length>0);let N=y[0];for(const b of y)if(b.id===j){N=b;break}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.jsxs("div",{className:"mb-7 max-w-2xl",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.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:n("settings.page.subtitle")})]}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[14rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 rounded-xl border border-oai-gray-200 bg-oai-gray-50/70 p-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 md:border-0 md:bg-transparent md:p-0 md:dark:bg-transparent",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-4 md:overflow-visible",children:w.map(({id:b,label:S,sections:O})=>t.jsxs("div",{className:"flex shrink-0 gap-1 md:block",children:[t.jsx("div",{className:"hidden px-3 pb-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-oai-gray-400 dark:text-oai-gray-500 md:block",children:S}),t.jsx("div",{className:"flex gap-1 md:flex-col",children:O.map(({id:f,label:E,Icon:D})=>{const T=j===f;return t.jsxs("button",{id:`settings-nav-${f}`,type:"button","aria-current":T?"page":void 0,"aria-controls":`settings-panel-${f}`,onClick:()=>A(f),className:_("relative inline-flex min-h-10 min-w-max shrink-0 items-center gap-2 rounded-lg px-3 py-2 text-left text-sm font-medium transition-all 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",T?"bg-white text-oai-black shadow-sm ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-white dark:ring-oai-gray-700":"text-oai-gray-500 hover:bg-white/80 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800/70 dark:hover:text-oai-gray-200"),children:[T?t.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-oai-brand-500","aria-hidden":!0}):null,t.jsx(D,{className:_("h-4 w-4 shrink-0",T?"text-oai-brand-600 dark:text-oai-brand-400":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:E})]},f)})})]},b))})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"mb-4 border-b border-oai-gray-200 pb-4 dark:border-oai-gray-800",children:[t.jsx("h2",{className:"text-xl font-semibold tracking-tight text-oai-black dark:text-white",children:N.label}),t.jsx("p",{className:"mt-1 text-sm leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:N.description})]}),y.map(({id:b,label:S,content:O})=>t.jsx("section",{id:`settings-panel-${b}`,"aria-labelledby":`settings-nav-${b}`,"aria-label":S,"data-settings-panel":b,hidden:j!==b,children:O},b)),t.jsx(gn,{})]})]})]})})})}export{Wn as SettingsPage};