tokentracker-cli 0.83.4 → 0.83.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-Cj42BYfJ.js → AchievementBadge-bb85jTC_.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-B41jhL7x.js → AchievementsPage-CQROtjFC.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-Lp1iynwg.js → AchievementsSection-DtPA6JRC.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-DuaMzaGW.js → BadgeDetailModal-ClNP9o6O.js} +1 -1
  5. package/dashboard/dist/assets/Card-CODGNqLE.js +1 -0
  6. package/dashboard/dist/assets/{ClawdAnimated-C-Hry4YB.js → ClawdAnimated-D4gKSsF0.js} +1 -1
  7. package/dashboard/dist/assets/{CommandPalette-CTJBaWpw.js → CommandPalette-BIFV44le.js} +1 -1
  8. package/dashboard/dist/assets/{CommunityStatsModal-qSclg4Bj.js → CommunityStatsModal-CRy5X2iH.js} +1 -1
  9. package/dashboard/dist/assets/{ConfirmModal-Dh3VzEaA.js → ConfirmModal-CcmMz3l0.js} +1 -1
  10. package/dashboard/dist/assets/DashboardPage-XeXAYgKI.js +1 -0
  11. package/dashboard/dist/assets/{DevicePage-BrH5YYqa.js → DevicePage-DojgM7c5.js} +1 -1
  12. package/dashboard/dist/assets/{DialogClose-CH61tv1C.js → DialogClose-Do5zKE_e.js} +1 -1
  13. package/dashboard/dist/assets/DialogDescription-xAzuNBeK.js +1 -0
  14. package/dashboard/dist/assets/{DialogTitle-D945fBHg.js → DialogTitle-AfjYgW9_.js} +1 -1
  15. package/dashboard/dist/assets/{FadeIn-PByY-20e.js → FadeIn-BLIoLlDr.js} +1 -1
  16. package/dashboard/dist/assets/{HeaderGithubStar-JqnF9WrS.js → HeaderGithubStar-kIZC8t7g.js} +1 -1
  17. package/dashboard/dist/assets/{IpCheckPage-BL8s0rdr.js → IpCheckPage-Cp5PaKZ2.js} +1 -1
  18. package/dashboard/dist/assets/{LandingPage-Dq0YMelT.js → LandingPage-DVm8soRU.js} +2 -2
  19. package/dashboard/dist/assets/{LeaderboardAvatar-BV85AG35.js → LeaderboardAvatar-VOe0xbW6.js} +1 -1
  20. package/dashboard/dist/assets/{LeaderboardPage-CW9nMYRr.js → LeaderboardPage-BxqtZ5XC.js} +2 -2
  21. package/dashboard/dist/assets/{LeaderboardProfileModal-DF5nu051.js → LeaderboardProfileModal-Jd0LadRF.js} +3 -3
  22. package/dashboard/dist/assets/{LeaderboardProfilePage-Cid2lIXh.js → LeaderboardProfilePage-UjcQrVw9.js} +1 -1
  23. package/dashboard/dist/assets/{LimitsPage-D_SjLBQb.js → LimitsPage-BCT373SL.js} +1 -1
  24. package/dashboard/dist/assets/{LocalOnlyNotice-BgjVuk6t.js → LocalOnlyNotice-B6OY1s7h.js} +1 -1
  25. package/dashboard/dist/assets/{LoginCard-DcOOJ7F4.js → LoginCard-DSHO0tm0.js} +1 -1
  26. package/dashboard/dist/assets/{LoginModal-BmbXCQpU.js → LoginModal-BDWfRxca.js} +1 -1
  27. package/dashboard/dist/assets/{LoginPage-BReX-hIM.js → LoginPage-C6CUveep.js} +1 -1
  28. package/dashboard/dist/assets/{PetPage-cKhD5kRw.js → PetPage-Wbdo96d7.js} +1 -1
  29. package/dashboard/dist/assets/{PopoverPopup-BL8WWGQD.js → PopoverPopup-CnBdmF9h.js} +1 -1
  30. package/dashboard/dist/assets/{ProviderIcon-Dv8LjXBc.js → ProviderIcon-BUmOfjp8.js} +1 -1
  31. package/dashboard/dist/assets/{ResetPasswordPage-BggDvUTE.js → ResetPasswordPage-CoRcV6wA.js} +1 -1
  32. package/dashboard/dist/assets/{Select-DFLOEvtQ.js → Select-Bz_TBa69.js} +1 -1
  33. package/dashboard/dist/assets/{SelectItemText-l_IytZ1x.js → SelectItemText-De1kreqq.js} +1 -1
  34. package/dashboard/dist/assets/SettingsPage-BKhfZgg5.js +1 -0
  35. package/dashboard/dist/assets/{SkillsPage-DJeX_hFu.js → SkillsPage-Dxfd-u3a.js} +1 -1
  36. package/dashboard/dist/assets/{TokenGalaxy-CvtOZNXz.js → TokenGalaxy-F8A-Nd-g.js} +1 -1
  37. package/dashboard/dist/assets/{TrendMonitor-CbFaoSZx.js → TrendMonitor-93OdRFml.js} +2 -2
  38. package/dashboard/dist/assets/{WidgetsPage-Dj37UajB.js → WidgetsPage-CoHxwJKq.js} +1 -1
  39. package/dashboard/dist/assets/{WrappedPage-BbRezT_v.js → WrappedPage-BEtvNwJo.js} +1 -1
  40. package/dashboard/dist/assets/__vite-browser-external-Bvb__wvZ.js +1351 -0
  41. package/dashboard/dist/assets/__vite-browser-external-ByIYTB6l.css +1 -0
  42. package/dashboard/dist/assets/{agent-logos-C2WjBjZi.js → agent-logos-DlTPMVzM.js} +1 -1
  43. package/dashboard/dist/assets/{arrow-up-right-_bkVN_-t.js → arrow-up-right-CPpFgxPI.js} +1 -1
  44. package/dashboard/dist/assets/{check-QQtC-jGr.js → check-BJqIqX_n.js} +1 -1
  45. package/dashboard/dist/assets/{copy-tnrXJIlX.js → copy-CJju6E4t.js} +1 -1
  46. package/dashboard/dist/assets/{download-DJgEaI-n.js → download-Bd_X_ESz.js} +1 -1
  47. package/dashboard/dist/assets/{flame-D7el_0f3.js → flame-D0gF6_lO.js} +1 -1
  48. package/dashboard/dist/assets/{format-tokens-CmFsnNFY.js → format-tokens-Bb2duR4k.js} +1 -1
  49. package/dashboard/dist/assets/{icons-D__mI241.js → icons-CHX4hzd-.js} +1 -1
  50. package/dashboard/dist/assets/{index-DG0NZ_W7.js → index-BQenUM0D.js} +1 -1
  51. package/dashboard/dist/assets/{index-1pzviHs-.js → index-BvyZynlf.js} +1 -1
  52. package/dashboard/dist/assets/{index-CKS8Swvi.js → index-DuF533lT.js} +1 -1
  53. package/dashboard/dist/assets/{info-7xyGxNal.js → info-DvFIO61W.js} +1 -1
  54. package/dashboard/dist/assets/{limits-providers-D8LfR6Om.js → limits-providers-Dzhqid5x.js} +1 -1
  55. package/dashboard/dist/assets/{link-2-DRYdgDC2.js → link-2-WXEM8anD.js} +1 -1
  56. package/dashboard/dist/assets/{loader-circle-CX24zxqF.js → loader-circle-CBitYCbd.js} +1 -1
  57. package/dashboard/dist/assets/{provider-display-DPIFKw3O.js → provider-display-Ck8wx5F_.js} +1 -1
  58. package/dashboard/dist/assets/{react-D9H9IC9r.js → react-qsffbXoL.js} +1 -1
  59. package/dashboard/dist/assets/{skills-api-BVQc9owa.js → skills-api-BGjRnLBu.js} +1 -1
  60. package/dashboard/dist/assets/{terminal-4058d4_A.js → terminal-BFA955Sz.js} +1 -1
  61. package/dashboard/dist/assets/{trash-2-D3cJG7LG.js → trash-2-BoxFSMOq.js} +1 -1
  62. package/dashboard/dist/assets/{use-community-stats-MKJhkjxa.js → use-community-stats-D_aufn0k.js} +1 -1
  63. package/dashboard/dist/assets/{use-limits-display-prefs-FXO2f5fy.js → use-limits-display-prefs-DWg_VJVc.js} +1 -1
  64. package/dashboard/dist/assets/use-native-settings-RHW0eAGh.js +1 -0
  65. package/dashboard/dist/assets/{use-ordered-list-D1Ts8ut3.js → use-ordered-list-cn5T3Bi0.js} +1 -1
  66. package/dashboard/dist/assets/use-reduced-motion-Cp5udRu_.js +1 -0
  67. package/dashboard/dist/assets/{use-session-efficiency-pref-CtzlSied.js → use-session-efficiency-pref-DRobup6T.js} +1 -1
  68. package/dashboard/dist/assets/{use-transform-CO582voD.js → use-transform-BlvN9UW0.js} +1 -1
  69. package/dashboard/dist/assets/{use-usage-limits-Ca15KPkK.js → use-usage-limits-Cp5aKXRQ.js} +1 -1
  70. package/dashboard/dist/assets/{useCurrency-CKFbWGkT.js → useCurrency-CRDGDglc.js} +1 -1
  71. package/dashboard/dist/assets/{useScrollLock-DNdxd1UW.js → useScrollLock-D0qxSW2G.js} +1 -1
  72. package/dashboard/dist/assets/{useTokenFormat-DTK4cojM.js → useTokenFormat-R9Gepc9g.js} +1 -1
  73. package/dashboard/dist/assets/{zap-DDCrktFO.js → zap-xt3KIPjK.js} +1 -1
  74. package/dashboard/dist/index.html +2 -2
  75. package/dashboard/dist/share.html +2 -2
  76. package/package.json +1 -1
  77. package/src/lib/local-api.js +20 -4
  78. package/src/lib/pricing/seed-snapshot.json +1 -1
  79. package/dashboard/dist/assets/Card-CBJAS2Mp.js +0 -1
  80. package/dashboard/dist/assets/DashboardPage-BYnPMlX8.js +0 -1
  81. package/dashboard/dist/assets/DialogDescription-DqSqTcXg.js +0 -1
  82. package/dashboard/dist/assets/SettingsPage-DD6EiVg7.js +0 -1
  83. package/dashboard/dist/assets/__vite-browser-external-BRzJpYc1.js +0 -1350
  84. package/dashboard/dist/assets/__vite-browser-external-C44tPAD-.css +0 -1
  85. package/dashboard/dist/assets/use-native-settings-BeED1BpH.js +0 -1
  86. package/dashboard/dist/assets/use-reduced-motion-8J-IDPSQ.js +0 -1
@@ -1 +0,0 @@
1
- import{k as w,r as c,j as t,d as N,c as a,a as ae,am as ie,aQ as se,as as oe,at as re,a1 as U,aR as le,aS as ce,u as ue,R as C,U as de,Y as F,l as G,aT as ge,aU as he,M as pe,aV as me,v as be,aW as fe,aX as xe,aY as ye,aZ as ve,a_ as je,a$ as ke,b0 as Ne,L as Se,aP as we,b1 as Ce,ai as P}from"./__vite-browser-external-BRzJpYc1.js";import{b as Le,g as Ee,L as I,m as R}from"./react-D9H9IC9r.js";import{u as Ae,L as _}from"./use-limits-display-prefs-FXO2f5fy.js";import{P as Ge}from"./ProviderIcon-Dv8LjXBc.js";import{a as O,l as T}from"./limits-providers-D8LfR6Om.js";import{a as k,T as j,b,S as L,u as H}from"./use-native-settings-BeED1BpH.js";import{P as Pe,u as Ie,a as _e}from"./use-session-efficiency-pref-CtzlSied.js";import{C as Oe}from"./check-QQtC-jGr.js";import{C as Te}from"./copy-tnrXJIlX.js";import{A as De}from"./index-1pzviHs-.js";import{u as Me}from"./useCurrency-CKFbWGkT.js";import{u as Ue}from"./useTokenFormat-DTK4cojM.js";import{S as $}from"./Select-DFLOEvtQ.js";import{I as Fe}from"./info-7xyGxNal.js";import{C as Re}from"./ConfirmModal-Dh3VzEaA.js";import{A as He}from"./arrow-up-right-_bkVN_-t.js";import{D as $e}from"./download-DJgEaI-n.js";import"./Card-CBJAS2Mp.js";import"./SelectItemText-l_IytZ1x.js";import"./useScrollLock-DNdxd1UW.js";import"./DialogTitle-D945fBHg.js";import"./DialogDescription-DqSqTcXg.js";const Ve=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Be=w("activity",Ve);const ze=[["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"}]],Ke=w("grip-vertical",ze);const Ze=[["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"}]],We=w("languages",Ze);const qe=[["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"}]],Ye=w("log-out",qe),Qe=e=>!e.isLayoutDirty&&e.willUpdate(!1);function D(){const e=new Set,n=new WeakMap,i=()=>e.forEach(Qe);return{add:s=>{e.add(s),n.set(s,s.addEventListener("willUpdate",i))},remove:s=>{e.delete(s);const o=n.get(s);o&&(o(),n.delete(s)),i()},dirty:i}}const Je=c.createContext(null);function Xe(){const e=c.useRef(!1);return Le(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function et(){const e=Xe(),[n,i]=c.useState(0),s=c.useCallback(()=>{e.current&&i(n+1)},[n]);return[c.useCallback(()=>Ee.postRender(s),[s]),n]}const V=e=>e===!0,tt=e=>V(e===!0)||e==="id",nt=({children:e,id:n,inherit:i=!0})=>{const s=c.useContext(I),o=c.useContext(Je),[r,l]=et(),u=c.useRef(null),g=s.id||o;u.current===null&&(tt(i)&&g&&(n=n?g+"-"+n:g),u.current={id:n,group:V(i)&&s.group||D()});const h=c.useMemo(()=>({...u.current,forceRender:r}),[l]);return t.jsx(I.Provider,{value:h,children:e})},at="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function it({checked:e,onChange:n,ariaLabel:i}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":i,onClick:n,className:N("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:N("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function st({prefs:e}){const{order:n,visibility:i,toggle:s,moveToward:o}=e,[r,l]=c.useState(null),[u,g]=c.useState(null),h=d=>f=>{l(d),f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",d)},m=d=>f=>{f.preventDefault(),f.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},x=()=>{l(null),g(null)},y=d=>{d.preventDefault(),l(null),g(null)};return t.jsx(nt,{children:t.jsx("div",{className:"flex flex-col",children:n.map(d=>{const f=i[d]!==!1,p=r===d;return t.jsxs(R.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:h(d),onDragOver:m(d),onDragEnd:x,onDrop:y,className:N("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",p&&"opacity-40"),style:{cursor:p?"grabbing":"grab"},children:[t.jsx(Ke,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),O(d)?t.jsx(Ge,{provider:O(d),size:18,className:N("pointer-events-none",at)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:T(d)}),t.jsx("div",{onMouseDown:v=>v.stopPropagation(),draggable:!1,children:t.jsx(it,{checked:f,onChange:()=>s(d),ariaLabel:`${a("limits.settings.toggle_visible")}: ${T(d)}`})})]},d)})})})}function ot(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},i=e.profile&&typeof e.profile=="object"?e.profile:{},s=n.full_name||n.name||i.name||n.user_name||n.preferred_username;return typeof s=="string"&&s.trim()?s.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function rt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function lt(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const i=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),s=n.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=i?.[1]||s?.[1];return o?`https://github.com/${o}`:null}function E(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function ct(e,n,i){const[s,o]=c.useState(()=>ie()),r=n&&i&&se(),l=c.useCallback(async()=>{const u=!s;if(oe(u),o(u),!!u)try{await re(()=>e())}catch(g){E("cloud sync",g)}},[s,e]);return{cloudSyncOn:s,handleCloudSyncToggle:l,showLocalCloudSync:r}}function ut(e){const[n,i]=c.useState(!1),[s,o]=c.useState(!1),[r,l]=c.useState(!1),[u,g]=c.useState(!1),[h,m]=c.useState(null),[x,y]=c.useState(!1),[d,f]=c.useState(""),[p,v]=c.useState(!1),[S,A]=c.useState(""),[Z,W]=c.useState(""),[q,Y]=c.useState(!1),[Q,J]=c.useState(null),X=c.useMemo(()=>ot(e),[e]),ee=c.useMemo(()=>rt(e),[e]),te=c.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),ne=c.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:A,setProfileLoading:l,setPublicProfileOn:i,setShowGithubOn:v}),[]);return{anonymousOn:s,customDisplayName:h,displayName:X,editingGithub:q,editingName:x,email:ee,githubError:Q,githubInput:Z,githubUrl:S,loadSetters:ne,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:Y,setEditingName:y,setGithubError:J,setGithubInput:W,setGithubUrl:A,setNameInput:f,setProfileLoading:l,setProfileSaving:g,setPublicProfileOn:i,setShowGithubOn:v,showGithubOn:p,userId:te}}function dt(e,n,i){c.useEffect(()=>{if(!n)return;let s=!0;return i.setProfileLoading(!0),(async()=>{try{const o=await U({getAccessToken:e});if(!s||!o)return;const r=await le({accessToken:o});if(!s)return;i.setPublicProfileOn(!!r?.enabled),i.setAnonymousOn(!!r?.anonymous),r?.display_name&&i.setCustomDisplayName(r.display_name),i.setShowGithubOn(!!r?.show_github_url),i.setGithubUrl(r?.github_url||"")}catch(o){E("load public profile",o)}finally{s&&i.setProfileLoading(!1)}})(),()=>{s=!1}},[e,n,i])}function gt(e,n){return c.useCallback(async(i,{label:s,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await U({getAccessToken:e});if(!l)return!1;const u=await ce({accessToken:l,...i});return r?.(u),!0}catch(l){return o?o(l):E(s||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function ht(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function pt(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function mt(e,n){const i=c.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:c.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:i}}function bt(e,n,i){const s=c.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await n({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),i?.()}})},[n,e,i]),o=c.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:s,startEditingName:o}}function ft(e,n){const i=c.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),s=c.useCallback(async()=>{const r=lt(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(a("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||a("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=c.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:s,handleShowGithubToggle:i,startEditingGithub:o}}function xt(){const e=ae(),n=ut(e.user),i=ct(e.getAccessToken,e.enabled,e.signedIn);dt(e.getAccessToken,e.signedIn,n.loadSetters);const s=gt(e.getAccessToken,n),o=mt(n,s),r=bt(n,s,e.refreshDisplayName),l=ft(n,s);return{...e,...i,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:ht(n,{...o,...r}),github:pt(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function B({disabled:e,onCancel:n,onSave:i,saveLabel:s=a("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:i,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:s}),t.jsx("button",{type:"button",onClick:n,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:a("settings.account.cancel")})]})}function yt({nameInput:e,setEditingName:n,setNameInput:i,profileSaving:s,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>i(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&n(!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:a("settings.account.displayName")}),t.jsx(B,{disabled:s||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:s?a("settings.account.saving"):void 0})]})}function vt({githubError:e,githubInput:n,handleSaveGithub:i,profileSaving:s,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:n,onChange:u=>{l(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&i(),u.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:a("settings.account.githubUrlPlaceholder")}),t.jsx(B,{disabled:s,onCancel:()=>{o(!1),r(null)},onSave:i,saveLabel:s?a("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 z({disabled:e=!1,label:n,onClick:i,title:s}){return t.jsxs("button",{type:"button",onClick:i,disabled:e,title:s,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(Pe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function K({actions:e,editing:n,editor:i,hint:s,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}),n?i:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s})]}),n?null:e]})})}function jt({name:e}){const n=e.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(z,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function kt({name:e}){const{anonymousOn:n,customDisplayName:i,displayName:s,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:u,profileLoading:g,profileSaving:h,setEditingName:m,setNameInput:x,startEditingName:y}=e,d=n?a("settings.account.displayNameAnonymousHint"):i||s;return t.jsx(K,{label:a("settings.account.displayName"),editing:o,hint:d,editor:t.jsx(yt,{nameInput:u,setEditingName:m,setNameInput:x,profileSaving:h,handleSaveName:l}),actions:t.jsx(jt,{name:e})})}function Nt({github:e}){const{editingGithub:n,githubError:i,githubInput:s,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:u,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:x,showGithubOn:y,startEditingGithub:d}=e;return t.jsx(t.Fragment,{children:t.jsx(K,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(vt,{githubError:i,githubInput:s,handleSaveGithub:r,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:x}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(z,{label:a("settings.account.edit"),onClick:d}),t.jsx(j,{checked:y,onChange:l,disabled:u||g,ariaLabel:a("settings.account.githubUrl")})]})})})}function St(){const{openLoginModal:e}=ue();return t.jsx(k,{title:a("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:a("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:a("settings.account.signIn")})]})})}function wt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(kt,{name:e}),t.jsx(Nt,{github:n})]})}function Ct(){const e=xt();return e.enabled?e.signedIn?t.jsxs(k,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Et,{onSignOut:e.signOut}),children:[t.jsx(Lt,{userId:e.userId}),t.jsx(At,{settings:e}),t.jsx(Gt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Pt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(St,{}):null}function Lt({userId:e}){const[n,i]=C.useState(!1);if(!e)return null;const s=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),i(!0),globalThis.setTimeout(()=>i(!1),1200)}catch{i(!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:a("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:s,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":a("settings.account.copyUserId"),children:[n?t.jsx(Oe,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function Et({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(Ye,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function At({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function Gt({checked:e,disabled:n,onChange:i}){return t.jsx(b,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:i,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function Pt({visible:e,name:n,github:i}){return t.jsx(De,{initial:!1,children:e?t.jsx(R.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(wt,{name:n,github:i})},"public-profile-fields"):null})}function It(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:ge},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:he},{value:"system",label:a("settings.appearance.theme.system"),Icon:pe}]}function _t(){return[{value:fe,label:a("settings.appearance.language.system")},{value:xe,label:a("settings.appearance.language.english")},{value:ye,label:a("settings.appearance.language.chinese")},{value:ve,label:a("settings.appearance.language.traditional_chinese")},{value:je,label:a("settings.appearance.language.japanese")},{value:ke,label:a("settings.appearance.language.korean")},{value:Ne,label:a("settings.appearance.language.german")}]}function Ot(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function Tt(e,n){const i=a(`settings.appearance.currency.rate_source.${e}`),s=Ot(n),o=s?a("settings.appearance.currency.rate_updated",{when:s}):a("settings.appearance.currency.rate_never");return`${i} · ${o}`}function Dt({locale:e,setLocale:n}){const i=_t();return t.jsx($,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(We,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Mt({currency:e,setCurrency:n}){const i=me().map(s=>({value:s.code,label:a(s.labelKey)}));return t.jsx($,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Ut({currency:e,rate:n,rateSource:i,rateFetchedAt:s}){if(e===be)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=Tt(i,s);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.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(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Ft(){const{theme:e,setTheme:n}=de(),{locale:i,setLocale:s}=F(),{currency:o,rate:r,rateSource:l,rateFetchedAt:u,setCurrency:g}=Me(),{mode:h,setMode:m}=Ue();return t.jsxs(k,{title:a("settings.section.appearance"),children:[t.jsx(b,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(L,{options:It(),value:e,onChange:n})}),t.jsx(b,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(Dt,{locale:i,setLocale:s})}),t.jsx(b,{label:a("settings.appearance.currency.label"),hint:t.jsx(Ut,{currency:o,rate:r,rateSource:l,rateFetchedAt:u}),control:t.jsx(Mt,{currency:o,setCurrency:g})}),t.jsx(b,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:t.jsx(L,{options:[{value:G.COMPACT,label:a("settings.appearance.token_format.compact")},{value:G.FULL,label:a("settings.appearance.token_format.full")}],value:h,onChange:m})})]})}function M({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:a(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:a("qpd.card.badge")})]})}function Rt(){const{enabled:e,toggle:n}=Ie(),{enabled:i,toggle:s}=_e();return t.jsxs(k,{title:a("settings.section.labs"),children:[t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:n,ariaLabel:a("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:t.jsx(j,{checked:i,onChange:s,ariaLabel:a("settings.labs.sessions.aria")})})]})}function Ht(){const{available:e,settings:n,setSetting:i,runAction:s}=H();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.launchAtLoginSupported!==!1,l=n?.updateStatus||null,u=!!n?.updateBusy,g=!!n?.isSyncing;return t.jsxs(k,{title:a("settings.section.menubar"),children:[t.jsx(b,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:t.jsxs(Se,{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:[a("settings.menubar.appearanceLink"),t.jsx(He,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),r?t.jsx(b,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>i("launchAtLogin",!o),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>s("syncNow"),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(we,{className:N("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(b,{label:a("settings.menubar.updates"),hint:l||void 0,control:t.jsxs("button",{type:"button",onClick:()=>s("checkForUpdates"),disabled:u,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","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function $t(e,n){function i(r){return r.replace(/^v/,"").split(".").map(Number)}const s=i(e),o=i(n);for(let r=0;r<Math.max(s.length,o.length);r++){const l=s[r]||0,u=o[r]||0;if(l<u)return!0;if(l>u)return!1}return!1}function Vt(){const{available:e,settings:n,runAction:i}=H(),s=e&&n?.version,[o,r]=C.useState(!1),[l,u]=C.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:g}=F(),h="0.83.4",m=async()=>{r(!0);try{const p=await fetch("https://api.github.com/repos/mm7894215/TokenTracker/releases/latest");if(!p.ok)throw new Error("Failed to fetch");const v=await p.json(),S=v.tag_name;$t(h,S)?u({open:!0,latestVersion:S,htmlUrl:v.html_url}):P({title:a("settings.menubar.updates.upToDate")})}catch(p){console.error("Check updates failed:",p),P({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},x=a("settings.menubar.updates.modalTitle"),y=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),d=a("settings.menubar.updates.modalConfirm"),f=a("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:[s?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:h})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>i("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:a("settings.menubar.updates.footerCore",{version:h})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:m,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?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Ce,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(Be,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(Re,{open:l.open,title:x,description:y,confirmLabel:d,cancelLabel:f,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),u(p=>({...p,open:!1}))},onCancel:()=>u(p=>({...p,open:!1}))})]})}function Bt({prefs:e}){return t.jsx(L,{options:[{value:_.USED,label:a("limits.settings.display_mode_used")},{value:_.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function pn(){const e=Ae();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 max-w-3xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.page.subtitle")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ft,{}),t.jsx(Ht,{}),t.jsx(Ct,{}),t.jsx(Rt,{}),t.jsx(k,{title:a("settings.section.limits"),action:t.jsx(Bt,{prefs:e}),children:t.jsx(st,{prefs:e})})]}),t.jsx(Vt,{})]})})})}export{pn as SettingsPage};