tokentracker-cli 0.95.1 → 0.96.0

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 (107) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-Cyju9OnL.js → AchievementBadge-Bb2ljquW.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-Bh2dQR-I.js → AchievementsPage-ByUP2x8a.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-DSFAM0Zp.js → AchievementsSection-_L6sCLTw.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-CgVF0VI0.js → BadgeDetailModal-B9n_-45B.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-DI-rTxI9.js → BotAnimated-lWmg-aZg.js} +1 -1
  6. package/dashboard/dist/assets/{Card-DAlV-PSI.js → Card-aSp259T0.js} +1 -1
  7. package/dashboard/dist/assets/{ClawdAnimated-oOYKgcpq.js → ClawdAnimated-Cy-XaTXW.js} +2 -2
  8. package/dashboard/dist/assets/{CommandPalette-bYE5uD63.js → CommandPalette-CNwtKCUm.js} +1 -1
  9. package/dashboard/dist/assets/{CommunityStatsModal-DCx0sQjk.js → CommunityStatsModal-DJSezaPV.js} +1 -1
  10. package/dashboard/dist/assets/{ConfirmModal-DrYf9m15.js → ConfirmModal-CVjmhZd6.js} +1 -1
  11. package/dashboard/dist/assets/{Controls-DAift9Z4.js → Controls-BIj6yVxE.js} +1 -1
  12. package/dashboard/dist/assets/{DashboardPage-CLswnOil.js → DashboardPage-BjYZLmqQ.js} +1 -1
  13. package/dashboard/dist/assets/{DevicePage-uWLgMC4Z.js → DevicePage-ptsI2fZc.js} +1 -1
  14. package/dashboard/dist/assets/{DialogClose-NitVrdVC.js → DialogClose-D1pLoZ56.js} +1 -1
  15. package/dashboard/dist/assets/DialogDescription-KY7X94CG.js +1 -0
  16. package/dashboard/dist/assets/{DialogTitle-CA_ZstJL.js → DialogTitle-DfSBUjWf.js} +1 -1
  17. package/dashboard/dist/assets/{FadeIn-CIkYDamA.js → FadeIn-DBn4L_BV.js} +1 -1
  18. package/dashboard/dist/assets/{HeaderGithubStar-CYTJNLpL.js → HeaderGithubStar-EJLBwEqp.js} +1 -1
  19. package/dashboard/dist/assets/{HoverTooltip-jh3sI8NC.js → HoverTooltip-DaSrZhYd.js} +1 -1
  20. package/dashboard/dist/assets/{IpCheckPage-Brpe-N7B.js → IpCheckPage-diQTVaYt.js} +1 -1
  21. package/dashboard/dist/assets/{LandingPage-D4PjaNcN.js → LandingPage-BqCxjwar.js} +2 -2
  22. package/dashboard/dist/assets/{LeaderboardAvatar-D9dc6frq.js → LeaderboardAvatar-CQImCsPN.js} +1 -1
  23. package/dashboard/dist/assets/{LeaderboardPage-CEuqopiC.js → LeaderboardPage-D2ZDUi_O.js} +2 -2
  24. package/dashboard/dist/assets/{LeaderboardProfileModal-TeYdXeIA.js → LeaderboardProfileModal-DHvADX1d.js} +3 -3
  25. package/dashboard/dist/assets/{LeaderboardProfilePage-DmtuwJkL.js → LeaderboardProfilePage-CJsedB28.js} +1 -1
  26. package/dashboard/dist/assets/LimitsPage-CAwff24b.js +6 -0
  27. package/dashboard/dist/assets/{LocalOnlyNotice-V8_KFKOD.js → LocalOnlyNotice-Cmnvu9tI.js} +1 -1
  28. package/dashboard/dist/assets/{LoginCard-ud0lCY_u.js → LoginCard-BQmKkD7X.js} +1 -1
  29. package/dashboard/dist/assets/{LoginModal-Bnemx4UD.js → LoginModal-2oPROePZ.js} +1 -1
  30. package/dashboard/dist/assets/{LoginPage-v89BHssa.js → LoginPage-aqdUJoQK.js} +1 -1
  31. package/dashboard/dist/assets/{PetPage-Bg9kEi7o.js → PetPage-Bn3p_o5r.js} +1 -1
  32. package/dashboard/dist/assets/{PopoverPopup-CCHVwh0w.js → PopoverPopup-DXD_YdiB.js} +1 -1
  33. package/dashboard/dist/assets/{ProviderIcon-BecpRylD.js → ProviderIcon-BZZ45-gY.js} +1 -1
  34. package/dashboard/dist/assets/{ResetPasswordPage-CsUtFeUr.js → ResetPasswordPage-Bn5ITiHQ.js} +1 -1
  35. package/dashboard/dist/assets/{SegmentedControl-3rBqbzW_.js → SegmentedControl-hGXboQZy.js} +1 -1
  36. package/dashboard/dist/assets/{Select-DZ2ll7Qv.js → Select-BP8aVRZ1.js} +1 -1
  37. package/dashboard/dist/assets/{SelectItemText-Dr1W47W6.js → SelectItemText-Odx47kND.js} +1 -1
  38. package/dashboard/dist/assets/{ServiceStatusPage-Cc1LXdAh.js → ServiceStatusPage-DUueam0N.js} +1 -1
  39. package/dashboard/dist/assets/SessionsPage-BA9IFqQ1.js +2 -0
  40. package/dashboard/dist/assets/{SettingsPage-2wYQ2ly6.js → SettingsPage-DLOHHB4f.js} +2 -2
  41. package/dashboard/dist/assets/{SkillsPage-BEDAwBTN.js → SkillsPage-Ds2vH_PG.js} +1 -1
  42. package/dashboard/dist/assets/{TokenGalaxy-DxG0dBeG.js → TokenGalaxy-CWBR4jnB.js} +1 -1
  43. package/dashboard/dist/assets/{ToolbarRootContext-DG1pr5UP.js → ToolbarRootContext-Bmg56vYz.js} +1 -1
  44. package/dashboard/dist/assets/{TrendMonitor-CeuEQ0XC.js → TrendMonitor-BQzcllvg.js} +1 -1
  45. package/dashboard/dist/assets/{WidgetsPage-ALDlZ5aR.js → WidgetsPage-Bu3tHDjO.js} +1 -1
  46. package/dashboard/dist/assets/{WrappedPage-BF59ouR-.js → WrappedPage-BrAMJhgy.js} +1 -1
  47. package/dashboard/dist/assets/{__vite-browser-external-DXtgoDkV.js → __vite-browser-external-4IGm4Djn.js} +12 -12
  48. package/dashboard/dist/assets/{agent-logos-D6Ya1qw1.js → agent-logos-B8lT-HcI.js} +1 -1
  49. package/dashboard/dist/assets/{arrow-up-right-DUR69elJ.js → arrow-up-right-rpBCOTg2.js} +1 -1
  50. package/dashboard/dist/assets/{check-9_1xp5h5.js → check-DIKw7TYH.js} +1 -1
  51. package/dashboard/dist/assets/{composite-CEzovOpb.js → composite-_NeXO0lv.js} +1 -1
  52. package/dashboard/dist/assets/{copy-DEoLQqJE.js → copy-CsfAtL7P.js} +1 -1
  53. package/dashboard/dist/assets/{download-BNjfcJ1g.js → download-DM1W9pIW.js} +1 -1
  54. package/dashboard/dist/assets/{external-link-fV_WJ5f_.js → external-link-CwbuMbeQ.js} +1 -1
  55. package/dashboard/dist/assets/{flame-DqpuFJ14.js → flame-DcYbLdhE.js} +1 -1
  56. package/dashboard/dist/assets/{format-tokens-CatddjmK.js → format-tokens-CEvr3dNy.js} +1 -1
  57. package/dashboard/dist/assets/{icons-CBT1KI7V.js → icons-DaGMVsJ5.js} +1 -1
  58. package/dashboard/dist/assets/{index-_2LEUZTl.js → index-BVVLPj3N.js} +1 -1
  59. package/dashboard/dist/assets/{index-BK3SzL7v.js → index-ChZkJjpk.js} +1 -1
  60. package/dashboard/dist/assets/{index-tK7s2SeO.js → index-T7OjmEuX.js} +1 -1
  61. package/dashboard/dist/assets/{info-DBotcfT9.js → info-CAjN3dX4.js} +1 -1
  62. package/dashboard/dist/assets/limits-providers-jn7Yln_V.js +1 -0
  63. package/dashboard/dist/assets/{link-2-Wc54x2fh.js → link-2-DaWH2Tyc.js} +1 -1
  64. package/dashboard/dist/assets/{loader-circle-nRhGIddE.js → loader-circle-CnF8qPi1.js} +1 -1
  65. package/dashboard/dist/assets/{maximize-2-Dw3_GuKW.js → maximize-2-B-2Pnj6g.js} +1 -1
  66. package/dashboard/dist/assets/{modifiers.esm-rTZ5BUxp.js → modifiers.esm-BoDOvUKl.js} +1 -1
  67. package/dashboard/dist/assets/{monitor-smartphone-CNVAqV_N.js → monitor-smartphone-DDgwxG_E.js} +1 -1
  68. package/dashboard/dist/assets/{plus-B5oPOXhp.js → plus-DIc1YUWB.js} +1 -1
  69. package/dashboard/dist/assets/{provider-display-DhAUWfC6.js → provider-display-yeNsVCO_.js} +1 -1
  70. package/dashboard/dist/assets/{react-BKACWrsB.js → react-DZqS6YTX.js} +1 -1
  71. package/dashboard/dist/assets/{search-DgddmV09.js → search-D6tEppYJ.js} +1 -1
  72. package/dashboard/dist/assets/{skills-api-BT1uiqeq.js → skills-api-vsA1rc1Z.js} +1 -1
  73. package/dashboard/dist/assets/{sortable.esm-UCoNfZ6z.js → sortable.esm-DDCnS1HI.js} +1 -1
  74. package/dashboard/dist/assets/{store-ZswY8Voz.js → store-Crne4DqF.js} +1 -1
  75. package/dashboard/dist/assets/{terminal-BtQyotJS.js → terminal-Ca7dkLMF.js} +1 -1
  76. package/dashboard/dist/assets/{trash-2-Dc_NLbWs.js → trash-2-CjEAS5ic.js} +1 -1
  77. package/dashboard/dist/assets/{use-community-stats-yOKag_ou.js → use-community-stats-BHx2YxyK.js} +1 -1
  78. package/dashboard/dist/assets/{use-latest-request-guard-BEiszvlI.js → use-latest-request-guard-BLGbXQdf.js} +1 -1
  79. package/dashboard/dist/assets/{use-limits-display-prefs-C-l_Mxvy.js → use-limits-display-prefs-DBkAp6ob.js} +1 -1
  80. package/dashboard/dist/assets/{use-ordered-list-CKjRaO6K.js → use-ordered-list-BTfW5M9u.js} +1 -1
  81. package/dashboard/dist/assets/use-reduced-motion-D_kUnDs4.js +1 -0
  82. package/dashboard/dist/assets/{use-session-efficiency-pref-DPI_--W2.js → use-session-efficiency-pref-DBmd-MqH.js} +1 -1
  83. package/dashboard/dist/assets/{use-transform-BQUem5OA.js → use-transform-Bp5XrwaQ.js} +1 -1
  84. package/dashboard/dist/assets/{use-usage-limits-lvkMBnNR.js → use-usage-limits-BmqRcyhH.js} +1 -1
  85. package/dashboard/dist/assets/{useCurrency-C5xhS1QV.js → useCurrency-B0YsRDj-.js} +1 -1
  86. package/dashboard/dist/assets/{useTokenFormat-FBMikfEq.js → useTokenFormat-PP3D0Ket.js} +1 -1
  87. package/dashboard/dist/assets/{zap-BsCNYelz.js → zap-BVOm1aBH.js} +1 -1
  88. package/dashboard/dist/index.html +1 -1
  89. package/dashboard/dist/ip-check.html +1 -1
  90. package/dashboard/dist/leaderboard.html +1 -1
  91. package/dashboard/dist/share.html +1 -1
  92. package/package.json +1 -1
  93. package/src/lib/ark-agent-plan-limits.js +437 -0
  94. package/src/lib/ark-coding-plan-limits.js +104 -27
  95. package/src/lib/codex-model-attribution.js +128 -0
  96. package/src/lib/codex-rollout-parser.js +98 -4
  97. package/src/lib/pricing/curated-overrides.json +24 -6
  98. package/src/lib/pricing/index.js +38 -1
  99. package/src/lib/pricing/seed-snapshot.json +1 -1
  100. package/src/lib/rollout.js +50 -9
  101. package/src/lib/session-analytics.js +374 -110
  102. package/src/lib/usage-limits.js +19 -5
  103. package/dashboard/dist/assets/DialogDescription-CQuJCP4L.js +0 -1
  104. package/dashboard/dist/assets/LimitsPage-BJW3teYA.js +0 -5
  105. package/dashboard/dist/assets/SessionsPage-ytOFN1h9.js +0 -2
  106. package/dashboard/dist/assets/limits-providers-CjMU709b.js +0 -1
  107. package/dashboard/dist/assets/use-reduced-motion-BlOkflqU.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{m as ee,r as i,j as e,e as F,c as a,M as ue,J as Z,R as xe,X as me,d as te,l as x,a4 as he,a5 as q}from"./__vite-browser-external-4IGm4Djn.js";import{L as ge,I as pe}from"./LocalOnlyNotice-Cmnvu9tI.js";import{S as J}from"./SegmentedControl-hGXboQZy.js";import{C as fe}from"./ToolbarRootContext-Bmg56vYz.js";import{S as ae}from"./search-D6tEppYJ.js";import{C as be}from"./check-DIKw7TYH.js";import{P as ye,a as ke,b as _e,c as ve,d as je}from"./PopoverPopup-DXD_YdiB.js";import{P as we}from"./ProviderIcon-BZZ45-gY.js";import{H as Ne}from"./HoverTooltip-DaSrZhYd.js";import{u as Ce}from"./useCurrency-B0YsRDj-.js";import{i as Se}from"./host-mode-Bc_iTzHk.js";import{L as Me}from"./loader-circle-CnF8qPi1.js";import{T as Le}from"./terminal-Ca7dkLMF.js";import"./arrow-up-right-rpBCOTg2.js";import"./download-DM1W9pIW.js";import"./composite-_NeXO0lv.js";import"./store-Crne4DqF.js";const Re=[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]],Te=ee("calendar",Re);const De=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Ie=ee("folder",De),Ee="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function Pe({options:r,value:t,onChange:s,allValue:m="all",allLabel:p,searchPlaceholder:y,emptyLabel:u,ariaLabel:j,disabled:k=!1,className:w=""}){const[f,b]=i.useState(!1),[h,D]=i.useState(""),[g,_]=i.useState(-1),N=i.useRef(null),C=`${i.useId()}-listbox`,U=t===m?p:r.find(l=>l.value===t)?.label??t,S=h.trim().toLowerCase(),I=i.useMemo(()=>S?r.filter(l=>l.label.toLowerCase().includes(S)):r,[r,S]),E=i.useMemo(()=>[{value:m,label:p},...I],[m,p,I]),M=g>=0&&g<E.length?E[g]:null,P=l=>{s(l),b(!1),D(""),_(-1)};i.useEffect(()=>{f&&N.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[f,g]);const L=l=>{if(l.key==="ArrowDown"||l.key==="ArrowUp"){l.preventDefault();const v=l.key==="ArrowDown";_($=>{const R=E.length;return R?v?$>=R-1?0:$+1:$<=0?R-1:$-1:-1});return}if(l.key==="Enter"){const v=M||(S&&I.length?I[0]:null);if(!v)return;l.preventDefault(),P(v.value)}};return e.jsxs(ye,{open:f,onOpenChange:l=>{b(l),_(-1),l||D("")},children:[e.jsxs(ke,{disabled:k,"aria-label":j,className:F("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==m?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",w),children:[e.jsx(Ie,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:U}),e.jsx(fe,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(_e,{children:e.jsx(ve,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(je,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx(ae,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":M?`${C}-${g}`:void 0,value:h,onChange:l=>{D(l.target.value),_(-1)},onKeyDown:L,placeholder:y,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:N,id:C,role:"listbox","aria-label":j,className:"max-h-64 overflow-y-auto",children:[E.map((l,v)=>e.jsxs("button",{id:`${C}-${v}`,type:"button",role:"option","aria-selected":t===l.value,"data-active":v===g?"true":void 0,onMouseEnter:()=>_(v),onClick:()=>P(l.value),className:F(Ee,t===l.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",v===g&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:l.label}),t===l.value?e.jsx(be,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},l.value)),I.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:u}):null]})]})})})]})}const Fe="tokentracker-sessions";async function $e(r={}){const t=new URL(`/functions/${Fe}`,window.location.origin);r.from&&t.searchParams.set("from",r.from),r.to&&t.searchParams.set("to",r.to),r.limit&&t.searchParams.set("limit",String(r.limit)),r.refresh&&t.searchParams.set("refresh","1");const s=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),m=await s.json().catch(()=>null);if(!s.ok){const p=s.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${s.status}`,y=new Error(m?.error||p);throw y.status=s.status,y}return m}const V=Se(),Oe=[],Q=100,Ae=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],re=[{id:"all",days:0,label:()=>a("sessions.filter.range_all")},{id:"7d",days:7,label:()=>a("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>a("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>a("sessions.filter.range_90d")}];function Ue(r){const t=re.find(m=>m.id===r)?.days||0;if(!t)return 0;const s=new Date;return s.setDate(s.getDate()-(t-1)),s.setHours(0,0,0,0),s.getTime()}function qe(r,t){if(!t)return!0;const s=Date.parse(r.ended_at||r.started_at||"");return Number.isFinite(s)?s>=t:!0}function B(r){const t=Array.isArray(r?.model_usage)?r.model_usage.filter(s=>s&&typeof s.model=="string"&&s.model):[];return t.length?t:[{model:r?.model||a("sessions.model.unknown"),total_tokens:Number(r?.own_total_tokens||r?.total_tokens||0)}]}function Be(r){const t=B(r);return t.length===1?t[0].model:t.map(s=>`${s.model} ${x(Number(s.total_tokens||0))}`).join(" · ")}function He(r,t){if(!r)return"—";const s=Date.parse(r);if(!Number.isFinite(s))return"—";try{return new Date(s).toLocaleString(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return new Date(s).toISOString().slice(0,16).replace("T"," ")}}function Ge(r){const t=Number(r);if(!Number.isFinite(t)||t<=0)return null;const s=Math.round(t/6e4);if(s<60)return a("sessions.duration.minutes",{minutes:s});const m=Math.floor(s/60),p=s%60;return a("sessions.duration.hours",{hours:m,minutes:p})}async function X(r){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(r),!0;const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const s=document.execCommand("copy");return document.body.removeChild(t),s}const Y=te.memo(function({session:t,locale:s,nested:m=!1,childCount:p=0,expanded:y=!1,onToggle:u}){const{currency:j,rate:k}=Ce(),w=String(t.source||"").toUpperCase(),f=Ge(t.duration_ms),b=t.resume_command,h=t.project_key||a("sessions.project.unknown"),D=m||t.thread_kind==="subagent",g=D?t.agent_nickname||t.agent_role||t.title||h:t.title||h,_=!!(t.title&&t.project_key),N=String(t.source||"").toLowerCase()==="grok",C=N&&t.usage_precision?a("sessions.grok.token_breakdown",{input:x(t.input_tokens),cacheRead:x(t.cached_input_tokens),cacheWrite:x(t.cache_creation_input_tokens),output:x(t.output_tokens),reasoning:x(t.reasoning_output_tokens)}):null,U=N&&t.usage_precision?a("sessions.grok.runtime_breakdown",{calls:x(t.model_calls),seconds:(Number(t.api_duration_ms||0)/1e3).toFixed(1),tools:x(t.tool_calls),errors:x(t.error_count)}):null,S=N&&Number(t.context_window_tokens)>0?a("sessions.grok.context_breakdown",{used:x(t.context_tokens_used),window:x(t.context_window_tokens),percent:Number(t.context_usage_percent||0).toFixed(0)}):null,I=t.project_ref?`${t.project_ref}
2
+ ${a("sessions.project.copy_hint")}`:void 0,E=async()=>{if(t.project_ref)try{await X(t.project_ref)?q({title:a("sessions.project.copied")}):q({title:a("sessions.project.copy_failed")})}catch{q({title:a("sessions.project.copy_failed")})}},M=L=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(Ne,{text:I,placement:"bottom"}),e.jsx("button",{type:"button",onClick:E,"aria-label":a("sessions.project.copy_aria",{project:h}),className:F("max-w-full truncate rounded text-left underline decoration-dotted decoration-oai-gray-300 underline-offset-4 hover:decoration-oai-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:decoration-oai-gray-600 dark:hover:decoration-oai-gray-400",L),children:h})]}),P=async()=>{if(b)try{await X(b)?q({title:a("sessions.resume.copied")}):q({title:a("sessions.resume.copy_failed")})}catch{q({title:a("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:F("flex flex-col gap-3 py-4 sm:flex-row sm:items-start",m&&"ml-6 border-l-2 border-oai-gray-200 pl-4 dark:border-oai-gray-800"),children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(we,{provider:w,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!D&&!t.title&&t.project_ref?M("font-medium text-oai-black dark:text-white"):e.jsx("span",{className:"truncate font-medium text-oai-black dark:text-white",children:g}),D?e.jsxs("span",{className:"inline-flex items-center rounded-full bg-sky-50 px-2 py-0.5 text-[11px] font-medium text-sky-700 dark:bg-sky-500/10 dark:text-sky-300",children:[a("sessions.badge.subagent"),t.agent_role?` · ${t.agent_role}`:""]}):null,t.first_pass?e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:a("sessions.badge.first_pass")}):null,N&&t.usage_precision||t.cost_is_partial?e.jsx("span",{className:F("inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium",t.usage_is_incomplete||t.cost_is_partial?"bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300":"bg-sky-50 text-sky-700 dark:bg-sky-500/10 dark:text-sky-300"),children:t.usage_is_incomplete?a("sessions.badge.partial_usage"):t.cost_is_partial?a("sessions.badge.partial_cost"):t.cost_source==="provider_reported"?a("sessions.badge.reported_cost"):a("sessions.badge.reported_usage")}):null,p?e.jsx("button",{type:"button",onClick:u,"aria-expanded":y,className:"inline-flex items-center rounded-full border border-oai-gray-200 px-2 py-0.5 text-[11px] font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:y?a("sessions.thread.collapse",{count:p}):a("sessions.thread.expand",{count:p})}):null]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[_?e.jsxs(e.Fragment,{children:[t.project_ref?M("hover:text-oai-black dark:hover:text-white"):e.jsx("span",{className:"truncate",children:h}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,e.jsx("span",{className:"truncate",children:Be(t)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:He(t.started_at,s)}),f?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:f})]}):null]}),C?e.jsx("div",{className:"mt-1 text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:C}):null,U?e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 text-[11px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:U}),S?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:S})]}):null]}):null]})]}),e.jsxs("div",{className:"flex items-start gap-5 pl-[30px] sm:pl-0",children:[e.jsxs("dl",{className:"flex items-start gap-6 text-right",children:[e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.tokens")}),e.jsxs("dd",{title:Number(t.subagent_total_tokens)?a("sessions.thread.tokens_summary",{own:x(t.own_total_tokens),subagents:x(t.subagent_total_tokens),combined:x(t.combined_total_tokens)}):void 0,className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:[x(t.total_tokens),Number(t.subagent_total_tokens)?e.jsxs("span",{className:"block text-[9px] font-normal text-oai-gray-400 dark:text-oai-gray-500",children:["Σ ",x(t.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.cost")}),e.jsxs("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",title:t.cost_is_partial?a("sessions.cost.partial_title"):void 0,children:[t.cost_is_partial?"≥":"",he(t.cost_usd,{currency:j,rate:k})]})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.turns")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:x(t.turns)})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.edits")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:x(t.edit_turns)})]})]}),e.jsxs("button",{type:"button",onClick:P,disabled:!b,title:b||a("sessions.resume.unavailable"),"aria-label":b?a("sessions.resume.copy_aria",{command:b}):a("sessions.resume.unavailable"),className:F("-mt-0.5 inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",b?"text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white":"cursor-not-allowed text-oai-gray-300 dark:text-oai-gray-600"),children:[e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:a("sessions.resume.copy")})]})]})]})});function Qe({sessions:r,selectedModel:t,onSelect:s}){const{groups:m,totalTokens:p}=i.useMemo(()=>{const u=new Map;let j=0;for(const k of r)for(const w of B(k)){const f=w.model||a("sessions.model.unknown"),b=Number(w.total_tokens||0),h=u.get(f)||{model:f,count:0,tokens:0};h.count+=1,h.tokens+=b,j+=b,u.set(f,h)}return{groups:[...u.values()].sort((k,w)=>w.tokens-k.tokens),totalTokens:j}},[r]);function y(u){return F("rounded-full border px-2.5 py-1 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u?"border-oai-brand-500 bg-oai-brand-50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-300":"border-oai-gray-200 text-oai-gray-600 hover:bg-oai-gray-100 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800")}return e.jsx("li",{className:"ml-6 border-l-2 border-oai-gray-200 py-3 pl-4 dark:border-oai-gray-800",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"mr-1 text-xs font-medium text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":t==="all",onClick:()=>s("all"),className:y(t==="all"),children:a("sessions.thread.model_all",{count:r.length,tokens:x(p)})}),m.map(u=>e.jsx("button",{type:"button","aria-pressed":t===u.model,onClick:()=>s(u.model),className:y(t===u.model),children:a("sessions.thread.model_item",{model:u.model,count:u.count,tokens:x(u.tokens)})},u.model))]})})}function ct(){const[r,t]=i.useState(null),[s,m]=i.useState(null),[p,y]=i.useState(!0),[u,j]=i.useState(!1),[k,w]=i.useState("all"),[f,b]=i.useState("all"),[h,D]=i.useState("all"),[g,_]=i.useState(""),[N,C]=i.useState(Q),[U,S]=i.useState(()=>new Set),[I,E]=i.useState(()=>new Map),M=i.useRef(0),{resolvedLocale:P}=ue(),L=i.useCallback(async(o=!1)=>{const d=++M.current;o?j(!0):y(!0),m(null);try{const n=await $e({refresh:o});d===M.current&&t(n)}catch(n){d===M.current&&m(n?.message||String(n))}finally{d===M.current&&(y(!1),j(!1))}},[]);i.useEffect(()=>{V||Z()?L(!1):y(!1)},[L]);const l=r?.sessions||Oe,v=i.useMemo(()=>{const o=new Set,d=[];for(const n of l){const c=n.project_key;!c||o.has(c)||(o.add(c),d.push({value:c,label:c}))}return d.sort((n,c)=>n.label.localeCompare(c.label))},[l]),$=i.useDeferredValue(g),R=i.useMemo(()=>{const o=$.trim().toLowerCase(),d=Ue(f);return l.filter(n=>{if(k!=="all"&&n.source!==k||h!=="all"&&n.project_key!==h||!qe(n,d))return!1;if(!o)return!0;const c=B(n).map(T=>T.model).join(" ");return`${n.title||""} ${n.project_key||""} ${c} ${n.agent_nickname||""} ${n.agent_role||""} ${n.project_ref||""} ${n.session_id||""}`.toLowerCase().includes(o)})},[l,k,h,f,$]),O=i.useMemo(()=>{const o=new Set(R.map(c=>c.session_hash)),d=new Map,n=[];for(const c of R){const A=c.root_session_hash||c.parent_session_hash;if(c.parent_session_hash&&A&&o.has(A)){const T=d.get(A)||[];T.push(c),d.set(A,T)}else n.push(c)}return{roots:n,childrenByRoot:d,foldedCount:R.length-n.length}},[R]),K=k!=="all"||f!=="all"||h!=="all"||g.trim()!=="";i.useEffect(()=>{C(Q),S(new Set),E(new Map)},[k,h,f,$,l]);const z=i.useMemo(()=>O.roots.slice(0,N),[O.roots,N]),H=O.roots.length>z.length,G=i.useCallback(()=>C(o=>o+Q),[]),se=i.useCallback(o=>{S(d=>{const n=new Set(d);return n.has(o)?n.delete(o):n.add(o),n})},[]),oe=i.useCallback((o,d)=>{E(n=>{const c=new Map(n);return d==="all"?c.delete(o):c.set(o,d),c})},[]),W=i.useRef(null);i.useEffect(()=>{if(!H||typeof IntersectionObserver>"u")return;const o=W.current;if(!o)return;const d=new IntersectionObserver(n=>{n.some(c=>c.isIntersecting)&&G()},{rootMargin:"400px"});return d.observe(o),()=>d.disconnect()},[H,G]);const ne=i.useMemo(()=>Ae.map(o=>({id:o.id,label:o.label()})),[P]),ie=i.useMemo(()=>re.map(o=>({id:o.id,label:o.label()})),[P]),le=Number(r?.session_count)>Number(r?.returned_count);return!V&&!Z()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(ge,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"mb-3 text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("sessions.page.subtitle")})]}),e.jsx("button",{type:"button",onClick:()=>{L(!0)},disabled:u||p,"aria-label":a("sessions.page.refresh"),title:a("sessions.page.refresh"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(xe,{className:F("h-4 w-4",u&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pt-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(J,{ariaLabel:a("sessions.filter.source_aria"),options:ne,value:k,onChange:w}),e.jsx(J,{className:"pl-2",ariaLabel:a("sessions.filter.range_aria"),leading:e.jsx(Te,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),options:ie,value:f,onChange:b}),e.jsx(Pe,{options:v,value:h,onChange:D,allLabel:a("sessions.filter.project_all"),searchPlaceholder:a("sessions.filter.project_search"),emptyLabel:a("sessions.filter.project_empty"),ariaLabel:a("sessions.filter.project_aria")}),e.jsxs("div",{className:"relative w-72 max-w-full",children:[e.jsx(ae,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(pe,{type:"search",value:g,onChange:o=>_(o.target.value),onKeyDown:o=>{o.key==="Escape"&&g&&(o.preventDefault(),_(""))},"aria-label":a("sessions.action.search_aria"),placeholder:a("sessions.search.placeholder"),className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:o=>o.preventDefault(),onClick:()=>_(""),"aria-label":a("sessions.action.search_clear"),"aria-hidden":!g,tabIndex:g?0:-1,className:F("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",g?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(me,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:O.foldedCount>0?a("sessions.thread.result_count",{roots:O.roots.length,subagents:O.foldedCount}):a("sessions.filter.result_count",{filtered:R.length,total:l.length})})]}),le?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.truncated",{shown:r.returned_count,total:r.session_count})}):null,s&&!r?e.jsxs("div",{className:"rounded-xl border border-dashed border-red-300 py-16 text-center dark:border-red-500/40",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:a("sessions.error.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s}),e.jsx("button",{type:"button",onClick:()=>{L(!1)},className:"mt-4 inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.error.retry")})]}):p?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Me,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),a("sessions.loading")]}):R.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-oai-gray-200 py-16 text-center dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:K?a("sessions.empty.filtered_title"):a("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:K?a("sessions.empty.filtered_body"):a("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[s?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:a("shared.error.prefix",{error:s})}):null,e.jsx("ul",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:z.map(o=>{const d=O.childrenByRoot.get(o.session_hash)||[],n=U.has(o.session_hash),c=I.get(o.session_hash)||"all",A=c==="all"?d:d.filter(function(ce){return B(ce).some(de=>de.model===c)});return e.jsxs(te.Fragment,{children:[e.jsx(Y,{session:o,locale:P,childCount:d.length,expanded:n,onToggle:()=>se(o.session_hash)}),n&&d.length?e.jsx(Qe,{sessions:d,selectedModel:c,onSelect:T=>oe(o.session_hash,T)}):null,n?A.map(T=>e.jsx(Y,{session:T,locale:P,nested:!0},T.session_hash)):null]},o.session_hash)})}),H?e.jsx("div",{ref:W,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:G,className:"inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.privacy")})]})})})}export{ct as SessionsPage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-DXtgoDkV.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-DXtgoDkV.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-UCoNfZ6z.js";import{a as Ze}from"./modifiers.esm-rTZ5BUxp.js";import{u as Ye,L as $}from"./use-limits-display-prefs-C-l_Mxvy.js";import{P as Je}from"./ProviderIcon-BecpRylD.js";import{a as B,l as V}from"./limits-providers-CjMU709b.js";import{m as J}from"./react-BKACWrsB.js";import{a as A,T as j,b,S as _,u as T}from"./Controls-DAift9Z4.js";import{P as Xe,u as Qe,a as et}from"./use-session-efficiency-pref-DPI_--W2.js";import{C as tt}from"./check-9_1xp5h5.js";import{C as nt}from"./copy-DEoLQqJE.js";import{A as X}from"./index-BK3SzL7v.js";import{u as at}from"./useCurrency-C5xhS1QV.js";import{u as st}from"./useTokenFormat-FBMikfEq.js";import{S as U}from"./Select-DZ2ll7Qv.js";import{I as it}from"./info-DBotcfT9.js";import{C as ot}from"./ConfirmModal-DrYf9m15.js";import{A as rt}from"./arrow-up-right-DUR69elJ.js";import{D as lt}from"./download-BNjfcJ1g.js";import{i as ct}from"./host-mode-Bc_iTzHk.js";import"./Card-DAlV-PSI.js";import"./ToolbarRootContext-DG1pr5UP.js";import"./composite-CEzovOpb.js";import"./SelectItemText-Dr1W47W6.js";import"./DialogTitle-CA_ZstJL.js";import"./store-ZswY8Voz.js";import"./DialogDescription-CQuJCP4L.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.95.1",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-DXtgoDkV.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};
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};