tokentracker-cli 1.0.2 → 1.0.4

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 (96) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-CBGtv8Gf.js → AchievementBadge-mGuF3SZV.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-DBNXAqHB.js → AchievementsPage-CqgkEdCy.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-D9ndOgjA.js → AchievementsSection-DVZBBX6U.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-B_xo1k4z.js → BadgeDetailModal-Cv_PJVWo.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-OaYL-NrW.js → BotAnimated-CAqF-G07.js} +1 -1
  6. package/dashboard/dist/assets/{Card-BprDyWQy.js → Card-yUa-1eMj.js} +1 -1
  7. package/dashboard/dist/assets/{ClawdAnimated-DKzj5hnk.js → ClawdAnimated-CMG3gYTO.js} +2 -2
  8. package/dashboard/dist/assets/{CommandPalette-Y7y8uy9B.js → CommandPalette-BENO2SWB.js} +1 -1
  9. package/dashboard/dist/assets/{CommunityStatsModal-DtJjD6Gk.js → CommunityStatsModal-DrzMkmYd.js} +1 -1
  10. package/dashboard/dist/assets/{ConfirmModal-Dnq9wDSB.js → ConfirmModal-BzG_SVcZ.js} +1 -1
  11. package/dashboard/dist/assets/{Controls-B3LyuY9G.js → Controls-DiMs4jCI.js} +1 -1
  12. package/dashboard/dist/assets/{DashboardPage-uyz3GHPG.js → DashboardPage-Bkgu9gBF.js} +1 -1
  13. package/dashboard/dist/assets/{DevicePage-TBvBfX-E.js → DevicePage-JIPbcJj_.js} +1 -1
  14. package/dashboard/dist/assets/{DialogClose-C0xfVNxI.js → DialogClose-CAXMC_Ej.js} +1 -1
  15. package/dashboard/dist/assets/DialogDescription-q53be2If.js +1 -0
  16. package/dashboard/dist/assets/{DialogTitle-h96NnlwF.js → DialogTitle-BThuBA7Z.js} +1 -1
  17. package/dashboard/dist/assets/{FadeIn-BlT9LOhg.js → FadeIn-D_7oApb1.js} +1 -1
  18. package/dashboard/dist/assets/{HeaderGithubStar-BC8PlJFf.js → HeaderGithubStar-BfvlxDLm.js} +1 -1
  19. package/dashboard/dist/assets/{HoverTooltip-D2H0rvOx.js → HoverTooltip-DNdNDNui.js} +1 -1
  20. package/dashboard/dist/assets/{IpCheckPage-Bf9pTUyL.js → IpCheckPage-Bt2v2bcs.js} +1 -1
  21. package/dashboard/dist/assets/{LandingPage-CqFZZcgl.js → LandingPage-CSlXEZtQ.js} +2 -2
  22. package/dashboard/dist/assets/{LeaderboardAvatar-Bglw3mWk.js → LeaderboardAvatar-Dd6Q1LT0.js} +1 -1
  23. package/dashboard/dist/assets/{LeaderboardPage-Ba4rstvv.js → LeaderboardPage-BUf-DcVp.js} +2 -2
  24. package/dashboard/dist/assets/{LeaderboardProfileModal-DITfDxdj.js → LeaderboardProfileModal-BCI81oDf.js} +3 -3
  25. package/dashboard/dist/assets/{LeaderboardProfilePage-9DgMqaVi.js → LeaderboardProfilePage-CrE4dToF.js} +1 -1
  26. package/dashboard/dist/assets/{LimitsPage-Ct5IA5Ny.js → LimitsPage-swNbh5fv.js} +1 -1
  27. package/dashboard/dist/assets/{LocalOnlyNotice-DCgOvXBZ.js → LocalOnlyNotice-BDOSLg08.js} +1 -1
  28. package/dashboard/dist/assets/{LoginCard-Bo3St7wp.js → LoginCard-BJflNfwb.js} +1 -1
  29. package/dashboard/dist/assets/{LoginModal-CqN9Lhx0.js → LoginModal-CxZ6cxtY.js} +1 -1
  30. package/dashboard/dist/assets/{LoginPage-CLvn_ZAo.js → LoginPage-Ds85HImr.js} +1 -1
  31. package/dashboard/dist/assets/{PetPage-B-tmGNaA.js → PetPage-DZbmph67.js} +1 -1
  32. package/dashboard/dist/assets/{PopoverPopup-D0KIhAfw.js → PopoverPopup-JzxAr4q_.js} +1 -1
  33. package/dashboard/dist/assets/{ProviderIcon-DLytDN3-.js → ProviderIcon-MDkXefRU.js} +1 -1
  34. package/dashboard/dist/assets/{ResetPasswordPage-CGVTHdB9.js → ResetPasswordPage-CRvRNlWA.js} +1 -1
  35. package/dashboard/dist/assets/{SegmentedControl-B7gk-3QK.js → SegmentedControl-Bbw7Dypd.js} +1 -1
  36. package/dashboard/dist/assets/{Select-qbqB_qtp.js → Select-D1CFS_EY.js} +1 -1
  37. package/dashboard/dist/assets/{SelectItemText-Qzhp3UFE.js → SelectItemText-CHj4a14t.js} +1 -1
  38. package/dashboard/dist/assets/{ServiceStatusPage-DPe_EeVu.js → ServiceStatusPage-DFJSyj3M.js} +1 -1
  39. package/dashboard/dist/assets/{SessionsPage-Dza7qrmT.js → SessionsPage-BvIA_7Db.js} +1 -1
  40. package/dashboard/dist/assets/{SettingsPage-C_Am0uFM.js → SettingsPage-DxiO3RuB.js} +2 -2
  41. package/dashboard/dist/assets/{SkillsPage-Bsu5m-xp.js → SkillsPage-C1lMnXpP.js} +1 -1
  42. package/dashboard/dist/assets/{TokenGalaxy-COH6RLu3.js → TokenGalaxy-8ml284Vt.js} +1 -1
  43. package/dashboard/dist/assets/{ToolbarRootContext-B_XUhyzz.js → ToolbarRootContext-6-c1WW_C.js} +1 -1
  44. package/dashboard/dist/assets/{TrendMonitor-DMgbTVNO.js → TrendMonitor-Dtb1Vw8P.js} +1 -1
  45. package/dashboard/dist/assets/{WidgetsPage-gQTmgsN6.js → WidgetsPage-DI0m4BOv.js} +1 -1
  46. package/dashboard/dist/assets/{WrappedPage-B5nLQG1F.js → WrappedPage-DlodZhPp.js} +1 -1
  47. package/dashboard/dist/assets/{__vite-browser-external-DUAYhIIg.js → __vite-browser-external-DYzNZTW8.js} +2 -2
  48. package/dashboard/dist/assets/{agent-logos-B92se84f.js → agent-logos-D-NR9sq6.js} +1 -1
  49. package/dashboard/dist/assets/{arrow-up-right-THgpMHTL.js → arrow-up-right-DY2sXgRx.js} +1 -1
  50. package/dashboard/dist/assets/{check-CZ5GlBuF.js → check-iVengRka.js} +1 -1
  51. package/dashboard/dist/assets/{composite-pohmvEEN.js → composite-DdGB3lqE.js} +1 -1
  52. package/dashboard/dist/assets/{copy-BEu6UqzK.js → copy-hls2Bt--.js} +1 -1
  53. package/dashboard/dist/assets/{download-580FSMzx.js → download-BAPBndt2.js} +1 -1
  54. package/dashboard/dist/assets/{external-link-DSl6rKSu.js → external-link-Ca5PZfay.js} +1 -1
  55. package/dashboard/dist/assets/{flame-CuoqhgO0.js → flame-D1yeuyUj.js} +1 -1
  56. package/dashboard/dist/assets/{format-tokens-yngxPaJs.js → format-tokens-CGo6fsIE.js} +1 -1
  57. package/dashboard/dist/assets/{icons-C5P7F226.js → icons-Ba6V3IjJ.js} +1 -1
  58. package/dashboard/dist/assets/{index-CVccZBhd.js → index-BTyWWSgS.js} +1 -1
  59. package/dashboard/dist/assets/{index-1CFe9s91.js → index-C93m3GcS.js} +1 -1
  60. package/dashboard/dist/assets/{index-DkLVCz9v.js → index-CxRQ-BOI.js} +1 -1
  61. package/dashboard/dist/assets/{info-BtYRYa79.js → info-DyDVFBHF.js} +1 -1
  62. package/dashboard/dist/assets/{link-2-D4bPs6lx.js → link-2-gW7EnjBY.js} +1 -1
  63. package/dashboard/dist/assets/{loader-circle-CAcXf7Ue.js → loader-circle-CCBcIYQZ.js} +1 -1
  64. package/dashboard/dist/assets/{maximize-2-B3xxE3HC.js → maximize-2-lQE0Y8sM.js} +1 -1
  65. package/dashboard/dist/assets/{modifiers.esm-DvoWZTDt.js → modifiers.esm-Tonvsf-M.js} +1 -1
  66. package/dashboard/dist/assets/{monitor-smartphone-CkyNQoTv.js → monitor-smartphone-DxmsWtQn.js} +1 -1
  67. package/dashboard/dist/assets/{plus-BCXK4rAO.js → plus-B1xi3Vdy.js} +1 -1
  68. package/dashboard/dist/assets/{provider-display-Y5ggva-H.js → provider-display-DpZdlOXQ.js} +1 -1
  69. package/dashboard/dist/assets/{react-CjlEHr8p.js → react-CXLTMo1j.js} +1 -1
  70. package/dashboard/dist/assets/{search-Dh5kBuL2.js → search-vQged-EC.js} +1 -1
  71. package/dashboard/dist/assets/{skills-api-XhL8INjh.js → skills-api-D7EpxvhF.js} +1 -1
  72. package/dashboard/dist/assets/{sortable.esm-CFa-CzqV.js → sortable.esm-DMH9aB9A.js} +1 -1
  73. package/dashboard/dist/assets/{store-Bt47laU0.js → store-DJbKAU4R.js} +1 -1
  74. package/dashboard/dist/assets/{terminal-BXW29s08.js → terminal-C2TY01x3.js} +1 -1
  75. package/dashboard/dist/assets/{trash-CYw5PqQr.js → trash-G_ESCgKH.js} +1 -1
  76. package/dashboard/dist/assets/{use-community-stats-C5t_95Jj.js → use-community-stats-CIyY98uR.js} +1 -1
  77. package/dashboard/dist/assets/{use-latest-request-guard-CcrXitYE.js → use-latest-request-guard--vNleRV1.js} +1 -1
  78. package/dashboard/dist/assets/{use-limits-display-prefs-DktuWI-1.js → use-limits-display-prefs-BFxVkhZc.js} +1 -1
  79. package/dashboard/dist/assets/{use-ordered-list-DUHxxfXc.js → use-ordered-list-CO0krJmN.js} +1 -1
  80. package/dashboard/dist/assets/use-reduced-motion-B3bqraBN.js +1 -0
  81. package/dashboard/dist/assets/{use-session-efficiency-pref-CDSUns2p.js → use-session-efficiency-pref-CS1rGoPh.js} +1 -1
  82. package/dashboard/dist/assets/{use-transform-DkLOu1mx.js → use-transform-DxSRxn8c.js} +1 -1
  83. package/dashboard/dist/assets/{use-usage-limits-BTbbhOUs.js → use-usage-limits-DQJTSjOH.js} +1 -1
  84. package/dashboard/dist/assets/{useCurrency-C7QiSZUH.js → useCurrency-Dk_equa7.js} +1 -1
  85. package/dashboard/dist/assets/{useTokenFormat-Kv5h6RPd.js → useTokenFormat-C0kEMmzx.js} +1 -1
  86. package/dashboard/dist/assets/{zap-DOdxB6Nn.js → zap-DNBTWu7a.js} +1 -1
  87. package/dashboard/dist/index.html +1 -1
  88. package/dashboard/dist/ip-check.html +1 -1
  89. package/dashboard/dist/leaderboard.html +1 -1
  90. package/dashboard/dist/share.html +1 -1
  91. package/package.json +2 -2
  92. package/src/lib/pricing/curated-overrides.json +30 -0
  93. package/src/lib/pricing/index.js +2 -1
  94. package/src/lib/pricing/seed-snapshot.json +1 -1
  95. package/dashboard/dist/assets/DialogDescription-B1_lWQbi.js +0 -1
  96. package/dashboard/dist/assets/use-reduced-motion-dYTH0OxK.js +0 -1
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-DUAYhIIg.js","assets/__vite-browser-external-5P7me0Qq.css"])))=>i.map(i=>d[i]);
2
- import{m as I,j as t,e as _,c as n,a as xe,r as u,an as ye,aS as ve,at as ke,au as je,a7 as X,aT as Se,aU as we,u as Ne,d as H,$ as Ce,I as Q,n as U,aV as V,aW as Ee,aX as Pe,V as ee,aY as Ae,q as Oe,aZ as Le,a_ as _e,a$ as Te,b0 as Ie,b1 as Ge,b2 as Re,b3 as De,b4 as te,L as Ue,R as Me,b5 as He,b6 as Fe,a4 as B,_ as $e,h as Ve,f as Be,b7 as ze,b8 as Ke,aw as qe}from"./__vite-browser-external-DUAYhIIg.js";import{a as We,b as z,s as Ye,K as Ze,P as Je,D as Xe,c as Qe,S as et,v as tt,u as nt,C as at}from"./sortable.esm-CFa-CzqV.js";import{a as st}from"./modifiers.esm-DvoWZTDt.js";import{d as K,l as q,u as it,b as W}from"./use-limits-display-prefs-DktuWI-1.js";import{P as ot}from"./ProviderIcon-DLytDN3-.js";import{m as ne}from"./react-CjlEHr8p.js";import{a as O,T as k,b,S as G,u as R}from"./Controls-B3LyuY9G.js";import{P as rt,u as lt,a as ct}from"./use-session-efficiency-pref-CDSUns2p.js";import{C as dt}from"./check-CZ5GlBuF.js";import{C as ut}from"./copy-BEu6UqzK.js";import{A as ae}from"./index-1CFe9s91.js";import{u as gt}from"./useCurrency-C7QiSZUH.js";import{u as pt}from"./useTokenFormat-Kv5h6RPd.js";import{S as F}from"./Select-qbqB_qtp.js";import{I as ht}from"./info-BtYRYa79.js";import{C as mt}from"./ConfirmModal-Dnq9wDSB.js";import{A as bt}from"./arrow-up-right-THgpMHTL.js";import{D as ft}from"./download-580FSMzx.js";import{i as xt}from"./host-mode-Bc_iTzHk.js";import"./Card-BprDyWQy.js";import"./ToolbarRootContext-B_XUhyzz.js";import"./composite-pohmvEEN.js";import"./SelectItemText-Qzhp3UFE.js";import"./DialogTitle-h96NnlwF.js";import"./store-Bt47laU0.js";import"./DialogDescription-B1_lWQbi.js";const se={name:"flask-conical",size:24,node:[["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"}]]};se.node;const yt=I(se);const ie={name:"grip-vertical",size:24,node:[["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"}]]};ie.node;const vt=I(ie);const oe={name:"languages",size:24,node:[["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"}]]};oe.node;const kt=I(oe);const re={name:"log-out",size:24,node:[["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"}]]};re.node;const jt=I(re);const le={name:"palette",size:24,node:[["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"}]]};le.node;const St=I(le);const ce={name:"user-round",size:24,node:[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],aliases:["user-2"]};ce.node;const wt=I(ce),Nt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Ct({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:_("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:_("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Et({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:d}=nt({id:e}),h={transform:at.Transform.toString(l)||void 0,transition:c,zIndex:d?20:void 0};return t.jsxs("div",{ref:r,style:h,className:_("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",d&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(vt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),K(e)?t.jsx(ot,{provider:K(e),size:18,className:_("pointer-events-none",Nt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:q(e)}),t.jsx("div",{onPointerDown:p=>p.stopPropagation(),children:t.jsx(Ct,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${q(e)}`})})]})}function Pt({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=We(z(Je,{activationConstraint:{distance:6}}),z(Ze,{coordinateGetter:Ye})),l=({active:c,over:d})=>{d&&c.id!==d.id&&o(c.id,d.id)};return t.jsx(Xe,{sensors:r,collisionDetection:Qe,modifiers:[st],onDragEnd:l,children:t.jsx(et,{items:a,strategy:tt,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(Et,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function At(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 Ot(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Lt(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function $(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function _t(e,a,s){const[i,o]=u.useState(()=>ye()),r=a&&s&&ve(),l=u.useCallback(async()=>{const c=!i;if(ke(c),o(c),!!c)try{await je(()=>e())}catch(d){$("cloud sync",d)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function Tt(e){const[a,s]=u.useState(!1),[i,o]=u.useState(!1),[r,l]=u.useState(!1),[c,d]=u.useState(!1),[h,p]=u.useState(null),[g,m]=u.useState(!1),[v,j]=u.useState(""),[A,y]=u.useState(!1),[w,N]=u.useState(""),[f,S]=u.useState(""),[L,x]=u.useState(!1),[E,D]=u.useState(null),T=u.useMemo(()=>At(e),[e]),me=u.useMemo(()=>Ot(e),[e]),be=u.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),fe=u.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:p,setGithubUrl:N,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:y}),[]);return{anonymousOn:i,customDisplayName:h,displayName:T,editingGithub:L,editingName:g,email:me,githubError:E,githubInput:f,githubUrl:w,loadSetters:fe,nameInput:v,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:p,setEditingGithub:x,setEditingName:m,setGithubError:D,setGithubInput:S,setGithubUrl:N,setNameInput:j,setProfileLoading:l,setProfileSaving:d,setPublicProfileOn:s,setShowGithubOn:y,showGithubOn:A,userId:be}}function It(e,a,s){u.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await X({getAccessToken:e});if(!i||!o)return;const r=await Se({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){$("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function Gt(e,a){return u.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await X({getAccessToken:e});if(!l)return!1;const c=await we({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):$(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Rt(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 Dt(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 Ut(e,a){const s=u.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:u.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Mt(e,a,s){const i=u.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=u.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ht(e,a){const s=u.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=u.useCallback(async()=>{const r=Lt(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=u.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Ft(){const e=xe(),a=Tt(e.user),s=_t(e.getAccessToken,e.enabled,e.signedIn);It(e.getAccessToken,e.signedIn,a.loadSetters);const i=Gt(e.getAccessToken,a),o=Ut(a,i),r=Mt(a,i,e.refreshDisplayName),l=Ht(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Rt(a,{...o,...r}),github:Dt(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function de({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 $t({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(de,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Vt({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(de,{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 ue({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(rt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function ge({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 Bt({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(ue,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function zt({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:d,profileSaving:h,setEditingName:p,setNameInput:g,startEditingName:m}=e,v=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(ge,{label:n("settings.account.displayName"),editing:o,hint:v,editor:t.jsx($t,{nameInput:c,setEditingName:p,setNameInput:g,profileSaving:h,handleSaveName:l}),actions:t.jsx(Bt,{name:e})})}function Kt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:d,setEditingGithub:h,setGithubError:p,setGithubInput:g,showGithubOn:m,startEditingGithub:v}=e;return t.jsx(t.Fragment,{children:t.jsx(ge,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Vt,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:d,setEditingGithub:h,setGithubError:p,setGithubInput:g}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ue,{label:n("settings.account.edit"),onClick:v}),t.jsx(k,{checked:m,onChange:l,disabled:c||d,ariaLabel:n("settings.account.githubUrl")})]})})})}function qt(){const{openLoginModal:e}=Ne();return t.jsx(O,{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 Wt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx(zt,{name:e}),t.jsx(Kt,{github:a})]})}function Yt(){const e=Ft();return e.enabled?e.signedIn?t.jsxs(O,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Jt,{onSignOut:e.signOut}),children:[t.jsx(Zt,{userId:e.userId}),t.jsx(Xt,{settings:e}),t.jsx(Qt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(en,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(qt,{}):null}function Zt({userId:e}){const[a,s]=H.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(dt,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(ut,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Jt({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(jt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Xt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Qt({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(k,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function en({visible:e,name:a,github:s}){return t.jsx(ae,{initial:!1,children:e?t.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(Wt,{name:a,github:s})},"public-profile-fields"):null})}function tn(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:Ee},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:Pe},{value:"system",label:n("settings.appearance.theme.system"),Icon:ee}]}function nn(){return[{value:Le,label:n("settings.appearance.language.system")},{value:_e,label:n("settings.appearance.language.english")},{value:Te,label:n("settings.appearance.language.chinese")},{value:Ie,label:n("settings.appearance.language.traditional_chinese")},{value:Ge,label:n("settings.appearance.language.japanese")},{value:Re,label:n("settings.appearance.language.korean")},{value:De,label:n("settings.appearance.language.german")}]}function an(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function sn(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=an(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function on({locale:e,setLocale:a}){const s=nn();return t.jsx(F,{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(kt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function rn({currency:e,setCurrency:a}){const s=Ae().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(F,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function ln({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===Oe)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=sn(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(ht,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function cn(){const{theme:e,setTheme:a}=Ce(),{locale:s,setLocale:i}=Q(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:d}=gt(),{mode:h,setMode:p,unitSystem:g,setUnitSystem:m}=pt();return t.jsxs(O,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(G,{options:tn(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(on,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(ln,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(rn,{currency:o,setCurrency:d})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(G,{options:[{value:U.COMPACT,label:n("settings.appearance.token_format.compact")},{value:U.FULL,label:n("settings.appearance.token_format.full")}],value:h,onChange:p})}),t.jsx(b,{label:n("settings.appearance.token_unit.label"),hint:n("settings.appearance.token_unit.hint"),control:t.jsx(G,{disabled:h!==U.COMPACT,options:[{value:V.ENGLISH,label:n("settings.appearance.token_unit.english")},{value:V.CHINESE,label:n("settings.appearance.token_unit.chinese")}],value:g,onChange:m})})]})}function M({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 dn(){const{enabled:e,toggle:a}=lt(),{enabled:s,toggle:i}=ct(),{available:o,settings:r,setSetting:l}=R(),c=o&&!!r?.dynamicIslandSupported,d=!!r?.dynamicIslandEnabled;return t.jsxs(O,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(k,{checked:d,onChange:()=>l("dynamicIslandEnabled",!d),ariaLabel:n("settings.labs.island.aria")})}),d&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(k,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(k,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(k,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function un(){const{available:e,settings:a,setSetting:s,runAction:i}=R();if(!e)return null;const o=te(),r=!!a?.launchAtLogin,l=a?.toastOnReset!==!1,c=a?.confettiOnReset!==!1,d=a?.launchAtLoginSupported!==!1,h=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,g=!!a?.updateBusy,m=!!a?.isSyncing;return t.jsxs(O,{title:n("settings.section.menubar"),children:[o?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Ue,{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(bt,{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(k,{checked:l,onChange:()=>s("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,onChange:()=>s("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),d?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(k,{checked:r,onChange:()=>s("launchAtLogin",!r),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:m,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Me,{className:_("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(k,{checked:h,onChange:()=>s("autoUpdateEnabled",!h),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(ft,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function gn(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 pn(){const{available:e,settings:a,runAction:s}=R(),i=e&&a?.version,o=a?.platform||"macos",[r,l]=H.useState(!1),[c,d]=H.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:h}=Q(),p="1.0.2",g=async()=>{l(!0);try{const y=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!y.ok)throw new Error("Failed to fetch");const w=await y.json(),N=w.tag_name;gn(p,N)?d({open:!0,latestVersion:N,htmlUrl:w.html_url}):B({title:n("settings.menubar.updates.upToDate")})}catch(y){console.error("Check updates failed:",y),B({title:n("settings.menubar.updates.failed")})}finally{l(!1)}},m=n("settings.menubar.updates.modalTitle"),v=n("settings.menubar.updates.modalDescription",{version:c.latestVersion}),j=n("settings.menubar.updates.modalConfirm"),A=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:o==="windows"?n("settings.menubar.updates.footerCore",{version:a.version}):n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:g,disabled:r,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:r?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:He,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(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(mt,{open:c.open,title:m,description:v,confirmLabel:j,cancelLabel:A,onConfirm:()=>{window.open(c.htmlUrl,"_blank"),d(y=>({...y,open:!1}))},onCancel:()=>d(y=>({...y,open:!1}))})]})}const hn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],mn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],Y="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 bn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=u.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=u.useState({}),[d,h]=u.useState(!1),[p,g]=u.useState(""),[m,v]=u.useState(null),[j,A]=u.useState(!1),[y,w]=u.useState(null);u.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const N=u.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),f=x=>{r(E=>({...E,...x})),c({}),g(""),v(null),w(null)},S=async()=>{if(o.mode==="manual"){const x=Z(o);if(Object.keys(x).length){c(x);return}}h(!0),g(""),v(null);try{await s(o),g("saved")}catch(x){g("error"),v(x)}finally{h(!1)}},L=async()=>{const x=Z(o);if(Object.keys(x).length){c(x);return}A(!0),w(null);try{const E=await i(o);w(E)}catch(E){w({ok:!1,error:E?.message||String(E)})}finally{A(!1)}};return t.jsxs(O,{title:n("settings.section.network"),subtitle:N,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(G,{options:hn(),value:o.mode,onChange:x=>f({mode:x})})}),t.jsx(ae,{initial:!1,children:o.mode==="manual"?t.jsxs(ne.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(F,{value:o.protocol,onValueChange:x=>f({protocol:x}),options:mn(),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:x=>f({host:x.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:Y})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:x=>f({port:x.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:Y})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:L,disabled:j||d,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:j?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:S,disabled:d||j,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:d?n("settings.network.saving"):n("settings.network.save")})]}),y?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y.ok?n("settings.network.test.ok",{status:String(y.status??"")}):n("settings.network.test.fail",{error:y.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:S,disabled:d,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:d?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),p==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,p==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:m?.unprotected?n("settings.network.save_error_unprotected",{error:m?.message||String(m||"")}):n("settings.network.save_error",{error:m?.message||String(m||"")})}):null]})}const pe="/functions/tokentracker-proxy-config",fn="/functions/tokentracker-proxy-test",xn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function he(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 yn(){const e=await fetch(pe,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return he(a)}async function J(){const{getLocalApiAuthHeaders:e}=await $e(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-DUAYhIIg.js").then(s=>s.d9);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function vn(){const[e,a]=u.useState(!1),[s,i]=u.useState(!0),[o,r]=u.useState(xn);u.useEffect(()=>{if(!xt()){a(!1),i(!1);return}let d=!1;return(async()=>{try{const h=await yn();if(d)return;if(!h){a(!1),i(!1);return}r(h),a(!0),i(!1)}catch{d||(a(!1),i(!1))}})(),()=>{d=!0}},[]);const l=u.useCallback(async d=>{const h=await J(),p=await fetch(pe,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({mode:d.mode,protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),g=await p.json().catch(()=>null);if(!p.ok){const v=g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`;throw new Error(v)}const m=he(g);if(m&&r(m),g&&g.ok===!1){const v=g&&typeof g.applyError=="string"&&g.applyError||g&&typeof g.error=="string"&&g.error||`HTTP ${p.status}`,j=new Error(v);throw g.unprotected===!0&&(j.unprotected=!0),j}return m||g},[]),c=u.useCallback(async d=>{const h=await J(),p=await fetch(fn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),g=await p.json().catch(()=>null);if(!g||typeof g.ok!="boolean")throw new Error(g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`);return g},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const C={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"},P={PERSONAL:"personal",APP:"app",DEVELOPER:"developer"};function kn({prefs:e}){return t.jsx(G,{options:[{value:W.USED,label:n("limits.settings.display_mode_used")},{value:W.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Wn(){const e=it(),{available:a,settings:s,setSetting:i}=R(),o=vn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,d=te()||s?.platform==="windows",[h,p]=Ve(),g=Be(),m=h.get("section"),j=Object.values(C).includes(m)&&(m!==C.NATIVE_APP||a)&&(m!==C.NETWORK||r)?m:C.APPEARANCE,A=f=>{const S=new URLSearchParams(h);f===C.APPEARANCE?S.delete("section"):S.set("section",f),p(S,{replace:!0})},y=[{id:C.APPEARANCE,label:n("settings.section.appearance"),description:n("settings.section.appearance.description"),group:P.PERSONAL,Icon:St,content:t.jsx(cn,{})},...a?[{id:C.NATIVE_APP,label:n("settings.section.menubar"),description:n("settings.section.menubar.description"),group:P.APP,Icon:ee,content:t.jsx(un,{})}]:[],...r?[{id:C.NETWORK,label:n("settings.section.network"),description:n("settings.section.network.description"),group:P.APP,Icon:ze,content:t.jsx(bn,{proxySettings:o})}]:[],{id:C.ACCOUNT,label:n("settings.section.account"),description:n("settings.section.account.description"),group:P.PERSONAL,Icon:wt,content:t.jsx(Yt,{})},{id:C.LIMITS,label:n("settings.section.limits"),description:n("settings.section.limits.description"),group:P.APP,Icon:Ke,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(O,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(kn,{prefs:e})}),d?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),t.jsx(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:()=>g("/limits?openSubscriptions=1"),"aria-label":n("limits.page.openSubscriptions"),title:n("limits.page.openSubscriptions"),className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(qe,{size:14,"aria-hidden":!0})}),t.jsx(k,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(O,{title:n("settings.limits.providers"),children:t.jsx(Pt,{prefs:e})})]})},{id:C.LABS,label:n("settings.section.labs"),description:n("settings.section.labs.description"),group:P.DEVELOPER,Icon:yt,content:t.jsx(dn,{})}],w=[{id:P.PERSONAL,label:n("settings.nav.group.personal")},{id:P.APP,label:n("settings.nav.group.app")},{id:P.DEVELOPER,label:n("settings.nav.group.developer")}].map(f=>({...f,sections:y.filter(S=>S.group===f.id)})).filter(f=>f.sections.length>0);let N=y[0];for(const f of y)if(f.id===j){N=f;break}return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-7 max-w-2xl",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:n("settings.page.subtitle")})]}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[14rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 rounded-xl border border-oai-gray-200 bg-oai-gray-50/70 p-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 md:border-0 md:bg-transparent md:p-0 md:dark:bg-transparent",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-4 md:overflow-visible",children:w.map(({id:f,label:S,sections:L})=>t.jsxs("div",{className:"flex shrink-0 gap-1 md:block",children:[t.jsx("div",{className:"hidden px-3 pb-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-oai-gray-400 dark:text-oai-gray-500 md:block",children:S}),t.jsx("div",{className:"flex gap-1 md:flex-col",children:L.map(({id:x,label:E,Icon:D})=>{const T=j===x;return t.jsxs("button",{id:`settings-nav-${x}`,type:"button","aria-current":T?"page":void 0,"aria-controls":`settings-panel-${x}`,onClick:()=>A(x),className:_("relative inline-flex min-h-10 min-w-max shrink-0 items-center gap-2 rounded-lg px-3 py-2 text-left text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0",T?"bg-white text-oai-black shadow-sm ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-white dark:ring-oai-gray-700":"text-oai-gray-500 hover:bg-white/80 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800/70 dark:hover:text-oai-gray-200"),children:[T?t.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-oai-brand-500","aria-hidden":!0}):null,t.jsx(D,{className:_("h-4 w-4 shrink-0",T?"text-oai-brand-600 dark:text-oai-brand-400":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:E})]},x)})})]},f))})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"mb-4 border-b border-oai-gray-200 pb-4 dark:border-oai-gray-800",children:[t.jsx("h2",{className:"text-xl font-semibold tracking-tight text-oai-black dark:text-white",children:N.label}),t.jsx("p",{className:"mt-1 text-sm leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:N.description})]}),y.map(({id:f,label:S,content:L})=>t.jsx("section",{id:`settings-panel-${f}`,"aria-labelledby":`settings-nav-${f}`,"aria-label":S,"data-settings-panel":f,hidden:j!==f,children:L},f)),t.jsx(pn,{})]})]})]})})})}export{Wn as SettingsPage};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-DYzNZTW8.js","assets/__vite-browser-external-5P7me0Qq.css"])))=>i.map(i=>d[i]);
2
+ import{m as I,j as t,e as _,c as n,a as xe,r as u,an as ye,aS as ve,at as ke,au as je,a7 as X,aT as Se,aU as we,u as Ne,d as H,$ as Ce,I as Q,n as U,aV as V,aW as Ee,aX as Pe,V as ee,aY as Ae,q as Oe,aZ as Le,a_ as _e,a$ as Te,b0 as Ie,b1 as Ge,b2 as Re,b3 as De,b4 as te,L as Ue,R as Me,b5 as He,b6 as Fe,a4 as B,_ as $e,h as Ve,f as Be,b7 as ze,b8 as Ke,aw as qe}from"./__vite-browser-external-DYzNZTW8.js";import{a as We,b as z,s as Ye,K as Ze,P as Je,D as Xe,c as Qe,S as et,v as tt,u as nt,C as at}from"./sortable.esm-DMH9aB9A.js";import{a as st}from"./modifiers.esm-Tonvsf-M.js";import{d as K,l as q,u as it,b as W}from"./use-limits-display-prefs-BFxVkhZc.js";import{P as ot}from"./ProviderIcon-MDkXefRU.js";import{m as ne}from"./react-CXLTMo1j.js";import{a as O,T as k,b,S as G,u as R}from"./Controls-DiMs4jCI.js";import{P as rt,u as lt,a as ct}from"./use-session-efficiency-pref-CS1rGoPh.js";import{C as dt}from"./check-iVengRka.js";import{C as ut}from"./copy-hls2Bt--.js";import{A as ae}from"./index-C93m3GcS.js";import{u as gt}from"./useCurrency-Dk_equa7.js";import{u as pt}from"./useTokenFormat-C0kEMmzx.js";import{S as F}from"./Select-D1CFS_EY.js";import{I as ht}from"./info-DyDVFBHF.js";import{C as mt}from"./ConfirmModal-BzG_SVcZ.js";import{A as bt}from"./arrow-up-right-DY2sXgRx.js";import{D as ft}from"./download-BAPBndt2.js";import{i as xt}from"./host-mode-Bc_iTzHk.js";import"./Card-yUa-1eMj.js";import"./ToolbarRootContext-6-c1WW_C.js";import"./composite-DdGB3lqE.js";import"./SelectItemText-CHj4a14t.js";import"./DialogTitle-BThuBA7Z.js";import"./store-DJbKAU4R.js";import"./DialogDescription-q53be2If.js";const se={name:"flask-conical",size:24,node:[["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"}]]};se.node;const yt=I(se);const ie={name:"grip-vertical",size:24,node:[["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"}]]};ie.node;const vt=I(ie);const oe={name:"languages",size:24,node:[["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"}]]};oe.node;const kt=I(oe);const re={name:"log-out",size:24,node:[["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"}]]};re.node;const jt=I(re);const le={name:"palette",size:24,node:[["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"}]]};le.node;const St=I(le);const ce={name:"user-round",size:24,node:[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],aliases:["user-2"]};ce.node;const wt=I(ce),Nt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Ct({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:_("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:_("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Et({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:d}=nt({id:e}),h={transform:at.Transform.toString(l)||void 0,transition:c,zIndex:d?20:void 0};return t.jsxs("div",{ref:r,style:h,className:_("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",d&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(vt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),K(e)?t.jsx(ot,{provider:K(e),size:18,className:_("pointer-events-none",Nt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:q(e)}),t.jsx("div",{onPointerDown:p=>p.stopPropagation(),children:t.jsx(Ct,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${q(e)}`})})]})}function Pt({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=We(z(Je,{activationConstraint:{distance:6}}),z(Ze,{coordinateGetter:Ye})),l=({active:c,over:d})=>{d&&c.id!==d.id&&o(c.id,d.id)};return t.jsx(Xe,{sensors:r,collisionDetection:Qe,modifiers:[st],onDragEnd:l,children:t.jsx(et,{items:a,strategy:tt,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(Et,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function At(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 Ot(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Lt(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function $(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function _t(e,a,s){const[i,o]=u.useState(()=>ye()),r=a&&s&&ve(),l=u.useCallback(async()=>{const c=!i;if(ke(c),o(c),!!c)try{await je(()=>e())}catch(d){$("cloud sync",d)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function Tt(e){const[a,s]=u.useState(!1),[i,o]=u.useState(!1),[r,l]=u.useState(!1),[c,d]=u.useState(!1),[h,p]=u.useState(null),[g,m]=u.useState(!1),[v,j]=u.useState(""),[A,y]=u.useState(!1),[w,N]=u.useState(""),[f,S]=u.useState(""),[L,x]=u.useState(!1),[E,D]=u.useState(null),T=u.useMemo(()=>At(e),[e]),me=u.useMemo(()=>Ot(e),[e]),be=u.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),fe=u.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:p,setGithubUrl:N,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:y}),[]);return{anonymousOn:i,customDisplayName:h,displayName:T,editingGithub:L,editingName:g,email:me,githubError:E,githubInput:f,githubUrl:w,loadSetters:fe,nameInput:v,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:p,setEditingGithub:x,setEditingName:m,setGithubError:D,setGithubInput:S,setGithubUrl:N,setNameInput:j,setProfileLoading:l,setProfileSaving:d,setPublicProfileOn:s,setShowGithubOn:y,showGithubOn:A,userId:be}}function It(e,a,s){u.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await X({getAccessToken:e});if(!i||!o)return;const r=await Se({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){$("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function Gt(e,a){return u.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await X({getAccessToken:e});if(!l)return!1;const c=await we({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):$(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Rt(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 Dt(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 Ut(e,a){const s=u.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:u.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Mt(e,a,s){const i=u.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=u.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ht(e,a){const s=u.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=u.useCallback(async()=>{const r=Lt(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=u.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Ft(){const e=xe(),a=Tt(e.user),s=_t(e.getAccessToken,e.enabled,e.signedIn);It(e.getAccessToken,e.signedIn,a.loadSetters);const i=Gt(e.getAccessToken,a),o=Ut(a,i),r=Mt(a,i,e.refreshDisplayName),l=Ht(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Rt(a,{...o,...r}),github:Dt(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function de({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 $t({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(de,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Vt({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(de,{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 ue({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(rt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function ge({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 Bt({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(ue,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function zt({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:d,profileSaving:h,setEditingName:p,setNameInput:g,startEditingName:m}=e,v=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(ge,{label:n("settings.account.displayName"),editing:o,hint:v,editor:t.jsx($t,{nameInput:c,setEditingName:p,setNameInput:g,profileSaving:h,handleSaveName:l}),actions:t.jsx(Bt,{name:e})})}function Kt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:d,setEditingGithub:h,setGithubError:p,setGithubInput:g,showGithubOn:m,startEditingGithub:v}=e;return t.jsx(t.Fragment,{children:t.jsx(ge,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Vt,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:d,setEditingGithub:h,setGithubError:p,setGithubInput:g}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ue,{label:n("settings.account.edit"),onClick:v}),t.jsx(k,{checked:m,onChange:l,disabled:c||d,ariaLabel:n("settings.account.githubUrl")})]})})})}function qt(){const{openLoginModal:e}=Ne();return t.jsx(O,{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 Wt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx(zt,{name:e}),t.jsx(Kt,{github:a})]})}function Yt(){const e=Ft();return e.enabled?e.signedIn?t.jsxs(O,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Jt,{onSignOut:e.signOut}),children:[t.jsx(Zt,{userId:e.userId}),t.jsx(Xt,{settings:e}),t.jsx(Qt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(en,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(qt,{}):null}function Zt({userId:e}){const[a,s]=H.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(dt,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(ut,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Jt({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(jt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Xt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Qt({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(k,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function en({visible:e,name:a,github:s}){return t.jsx(ae,{initial:!1,children:e?t.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(Wt,{name:a,github:s})},"public-profile-fields"):null})}function tn(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:Ee},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:Pe},{value:"system",label:n("settings.appearance.theme.system"),Icon:ee}]}function nn(){return[{value:Le,label:n("settings.appearance.language.system")},{value:_e,label:n("settings.appearance.language.english")},{value:Te,label:n("settings.appearance.language.chinese")},{value:Ie,label:n("settings.appearance.language.traditional_chinese")},{value:Ge,label:n("settings.appearance.language.japanese")},{value:Re,label:n("settings.appearance.language.korean")},{value:De,label:n("settings.appearance.language.german")}]}function an(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function sn(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=an(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function on({locale:e,setLocale:a}){const s=nn();return t.jsx(F,{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(kt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function rn({currency:e,setCurrency:a}){const s=Ae().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(F,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function ln({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===Oe)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=sn(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(ht,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function cn(){const{theme:e,setTheme:a}=Ce(),{locale:s,setLocale:i}=Q(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:d}=gt(),{mode:h,setMode:p,unitSystem:g,setUnitSystem:m}=pt();return t.jsxs(O,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(G,{options:tn(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(on,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(ln,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(rn,{currency:o,setCurrency:d})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(G,{options:[{value:U.COMPACT,label:n("settings.appearance.token_format.compact")},{value:U.FULL,label:n("settings.appearance.token_format.full")}],value:h,onChange:p})}),t.jsx(b,{label:n("settings.appearance.token_unit.label"),hint:n("settings.appearance.token_unit.hint"),control:t.jsx(G,{disabled:h!==U.COMPACT,options:[{value:V.ENGLISH,label:n("settings.appearance.token_unit.english")},{value:V.CHINESE,label:n("settings.appearance.token_unit.chinese")}],value:g,onChange:m})})]})}function M({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 dn(){const{enabled:e,toggle:a}=lt(),{enabled:s,toggle:i}=ct(),{available:o,settings:r,setSetting:l}=R(),c=o&&!!r?.dynamicIslandSupported,d=!!r?.dynamicIslandEnabled;return t.jsxs(O,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(k,{checked:d,onChange:()=>l("dynamicIslandEnabled",!d),ariaLabel:n("settings.labs.island.aria")})}),d&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(k,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(k,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(k,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function un(){const{available:e,settings:a,setSetting:s,runAction:i}=R();if(!e)return null;const o=te(),r=!!a?.launchAtLogin,l=a?.toastOnReset!==!1,c=a?.confettiOnReset!==!1,d=a?.launchAtLoginSupported!==!1,h=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,g=!!a?.updateBusy,m=!!a?.isSyncing;return t.jsxs(O,{title:n("settings.section.menubar"),children:[o?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Ue,{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(bt,{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(k,{checked:l,onChange:()=>s("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,onChange:()=>s("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),d?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(k,{checked:r,onChange:()=>s("launchAtLogin",!r),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:m,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Me,{className:_("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(k,{checked:h,onChange:()=>s("autoUpdateEnabled",!h),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(ft,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function gn(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 pn(){const{available:e,settings:a,runAction:s}=R(),i=e&&a?.version,o=a?.platform||"macos",[r,l]=H.useState(!1),[c,d]=H.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:h}=Q(),p="1.0.4",g=async()=>{l(!0);try{const y=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!y.ok)throw new Error("Failed to fetch");const w=await y.json(),N=w.tag_name;gn(p,N)?d({open:!0,latestVersion:N,htmlUrl:w.html_url}):B({title:n("settings.menubar.updates.upToDate")})}catch(y){console.error("Check updates failed:",y),B({title:n("settings.menubar.updates.failed")})}finally{l(!1)}},m=n("settings.menubar.updates.modalTitle"),v=n("settings.menubar.updates.modalDescription",{version:c.latestVersion}),j=n("settings.menubar.updates.modalConfirm"),A=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:o==="windows"?n("settings.menubar.updates.footerCore",{version:a.version}):n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:g,disabled:r,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:r?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:He,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(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(mt,{open:c.open,title:m,description:v,confirmLabel:j,cancelLabel:A,onConfirm:()=>{window.open(c.htmlUrl,"_blank"),d(y=>({...y,open:!1}))},onCancel:()=>d(y=>({...y,open:!1}))})]})}const hn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],mn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],Y="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 bn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=u.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=u.useState({}),[d,h]=u.useState(!1),[p,g]=u.useState(""),[m,v]=u.useState(null),[j,A]=u.useState(!1),[y,w]=u.useState(null);u.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const N=u.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),f=x=>{r(E=>({...E,...x})),c({}),g(""),v(null),w(null)},S=async()=>{if(o.mode==="manual"){const x=Z(o);if(Object.keys(x).length){c(x);return}}h(!0),g(""),v(null);try{await s(o),g("saved")}catch(x){g("error"),v(x)}finally{h(!1)}},L=async()=>{const x=Z(o);if(Object.keys(x).length){c(x);return}A(!0),w(null);try{const E=await i(o);w(E)}catch(E){w({ok:!1,error:E?.message||String(E)})}finally{A(!1)}};return t.jsxs(O,{title:n("settings.section.network"),subtitle:N,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(G,{options:hn(),value:o.mode,onChange:x=>f({mode:x})})}),t.jsx(ae,{initial:!1,children:o.mode==="manual"?t.jsxs(ne.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(F,{value:o.protocol,onValueChange:x=>f({protocol:x}),options:mn(),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:x=>f({host:x.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:Y})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:x=>f({port:x.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:Y})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:L,disabled:j||d,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:j?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:S,disabled:d||j,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:d?n("settings.network.saving"):n("settings.network.save")})]}),y?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y.ok?n("settings.network.test.ok",{status:String(y.status??"")}):n("settings.network.test.fail",{error:y.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:S,disabled:d,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:d?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),p==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,p==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:m?.unprotected?n("settings.network.save_error_unprotected",{error:m?.message||String(m||"")}):n("settings.network.save_error",{error:m?.message||String(m||"")})}):null]})}const pe="/functions/tokentracker-proxy-config",fn="/functions/tokentracker-proxy-test",xn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function he(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 yn(){const e=await fetch(pe,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return he(a)}async function J(){const{getLocalApiAuthHeaders:e}=await $e(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-DYzNZTW8.js").then(s=>s.d9);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function vn(){const[e,a]=u.useState(!1),[s,i]=u.useState(!0),[o,r]=u.useState(xn);u.useEffect(()=>{if(!xt()){a(!1),i(!1);return}let d=!1;return(async()=>{try{const h=await yn();if(d)return;if(!h){a(!1),i(!1);return}r(h),a(!0),i(!1)}catch{d||(a(!1),i(!1))}})(),()=>{d=!0}},[]);const l=u.useCallback(async d=>{const h=await J(),p=await fetch(pe,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({mode:d.mode,protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),g=await p.json().catch(()=>null);if(!p.ok){const v=g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`;throw new Error(v)}const m=he(g);if(m&&r(m),g&&g.ok===!1){const v=g&&typeof g.applyError=="string"&&g.applyError||g&&typeof g.error=="string"&&g.error||`HTTP ${p.status}`,j=new Error(v);throw g.unprotected===!0&&(j.unprotected=!0),j}return m||g},[]),c=u.useCallback(async d=>{const h=await J(),p=await fetch(fn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),g=await p.json().catch(()=>null);if(!g||typeof g.ok!="boolean")throw new Error(g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`);return g},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const C={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"},P={PERSONAL:"personal",APP:"app",DEVELOPER:"developer"};function kn({prefs:e}){return t.jsx(G,{options:[{value:W.USED,label:n("limits.settings.display_mode_used")},{value:W.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Wn(){const e=it(),{available:a,settings:s,setSetting:i}=R(),o=vn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,d=te()||s?.platform==="windows",[h,p]=Ve(),g=Be(),m=h.get("section"),j=Object.values(C).includes(m)&&(m!==C.NATIVE_APP||a)&&(m!==C.NETWORK||r)?m:C.APPEARANCE,A=f=>{const S=new URLSearchParams(h);f===C.APPEARANCE?S.delete("section"):S.set("section",f),p(S,{replace:!0})},y=[{id:C.APPEARANCE,label:n("settings.section.appearance"),description:n("settings.section.appearance.description"),group:P.PERSONAL,Icon:St,content:t.jsx(cn,{})},...a?[{id:C.NATIVE_APP,label:n("settings.section.menubar"),description:n("settings.section.menubar.description"),group:P.APP,Icon:ee,content:t.jsx(un,{})}]:[],...r?[{id:C.NETWORK,label:n("settings.section.network"),description:n("settings.section.network.description"),group:P.APP,Icon:ze,content:t.jsx(bn,{proxySettings:o})}]:[],{id:C.ACCOUNT,label:n("settings.section.account"),description:n("settings.section.account.description"),group:P.PERSONAL,Icon:wt,content:t.jsx(Yt,{})},{id:C.LIMITS,label:n("settings.section.limits"),description:n("settings.section.limits.description"),group:P.APP,Icon:Ke,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(O,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(kn,{prefs:e})}),d?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),t.jsx(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:()=>g("/limits?openSubscriptions=1"),"aria-label":n("limits.page.openSubscriptions"),title:n("limits.page.openSubscriptions"),className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(qe,{size:14,"aria-hidden":!0})}),t.jsx(k,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(O,{title:n("settings.limits.providers"),children:t.jsx(Pt,{prefs:e})})]})},{id:C.LABS,label:n("settings.section.labs"),description:n("settings.section.labs.description"),group:P.DEVELOPER,Icon:yt,content:t.jsx(dn,{})}],w=[{id:P.PERSONAL,label:n("settings.nav.group.personal")},{id:P.APP,label:n("settings.nav.group.app")},{id:P.DEVELOPER,label:n("settings.nav.group.developer")}].map(f=>({...f,sections:y.filter(S=>S.group===f.id)})).filter(f=>f.sections.length>0);let N=y[0];for(const f of y)if(f.id===j){N=f;break}return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-7 max-w-2xl",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:n("settings.page.subtitle")})]}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[14rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 rounded-xl border border-oai-gray-200 bg-oai-gray-50/70 p-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 md:border-0 md:bg-transparent md:p-0 md:dark:bg-transparent",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-4 md:overflow-visible",children:w.map(({id:f,label:S,sections:L})=>t.jsxs("div",{className:"flex shrink-0 gap-1 md:block",children:[t.jsx("div",{className:"hidden px-3 pb-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-oai-gray-400 dark:text-oai-gray-500 md:block",children:S}),t.jsx("div",{className:"flex gap-1 md:flex-col",children:L.map(({id:x,label:E,Icon:D})=>{const T=j===x;return t.jsxs("button",{id:`settings-nav-${x}`,type:"button","aria-current":T?"page":void 0,"aria-controls":`settings-panel-${x}`,onClick:()=>A(x),className:_("relative inline-flex min-h-10 min-w-max shrink-0 items-center gap-2 rounded-lg px-3 py-2 text-left text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0",T?"bg-white text-oai-black shadow-sm ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-white dark:ring-oai-gray-700":"text-oai-gray-500 hover:bg-white/80 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800/70 dark:hover:text-oai-gray-200"),children:[T?t.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-oai-brand-500","aria-hidden":!0}):null,t.jsx(D,{className:_("h-4 w-4 shrink-0",T?"text-oai-brand-600 dark:text-oai-brand-400":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:E})]},x)})})]},f))})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"mb-4 border-b border-oai-gray-200 pb-4 dark:border-oai-gray-800",children:[t.jsx("h2",{className:"text-xl font-semibold tracking-tight text-oai-black dark:text-white",children:N.label}),t.jsx("p",{className:"mt-1 text-sm leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:N.description})]}),y.map(({id:f,label:S,content:L})=>t.jsx("section",{id:`settings-panel-${f}`,"aria-labelledby":`settings-nav-${f}`,"aria-label":S,"data-settings-panel":f,hidden:j!==f,children:L},f)),t.jsx(pn,{})]})]})]})})})}export{Wn as SettingsPage};
@@ -1 +1 @@
1
- import{m as yt,r as i,v as xa,j as e,X as Le,c as r,e as se,ax as ua,ay as bt,t as kt,az as wt,aA as vt,E as jt,aB as Nt,aC as Ct,aD as St,aE as _t,w as It,aF as Lt,aG as Rt,aH as Pt,aI as Bt,a3 as Dt,a as Et,aJ as Tt,an as At,G as Ot,B as X,R as $t,d as Mt,aK as Ut,a4 as W}from"./__vite-browser-external-DUAYhIIg.js";import{L as Ft,I as ha}from"./LocalOnlyNotice-DCgOvXBZ.js";import{C as zt}from"./Card-BprDyWQy.js";import{C as da}from"./ConfirmModal-Dnq9wDSB.js";import{S as Vt}from"./SegmentedControl-B7gk-3QK.js";import{I as Ra}from"./info-BtYRYa79.js";import{P as ve}from"./ProviderIcon-DLytDN3-.js";import{m as wa}from"./react-CjlEHr8p.js";import{u as Kt}from"./useCurrency-C7QiSZUH.js";import{E as ma}from"./external-link-DSl6rKSu.js";import{L as Y}from"./loader-circle-CAcXf7Ue.js";import{M as Pa}from"./monitor-smartphone-CkyNQoTv.js";import{C as Re}from"./check-CZ5GlBuF.js";import{T as pa}from"./trash-CYw5PqQr.js";import{A as qt}from"./index-1CFe9s91.js";import{u as Ht}from"./use-reduced-motion-dYTH0OxK.js";import{u as Gt,k as Wt,l as Qt,m as Xt,n as Jt,o as Yt,p as Zt,q as er,S as Ba,c as Da,d as Ea,e as Ta,f as Aa,g as Oa,h as ta,j as ra,i as sa}from"./SelectItemText-Qzhp3UFE.js";import{t as ar,u as $a,a as tr}from"./composite-pohmvEEN.js";import{u as rr,C as fa}from"./ToolbarRootContext-B_XUhyzz.js";import{g as sr,a as nr,p as ir,m as or,b as lr,d as dr,c as cr,e as ur,f as mr,s as gr,i as xr,u as va,h as ja,r as hr,j as Na,k as Ca,l as Sa,n as pr,o as fr}from"./skills-api-XhL8INjh.js";import{F as yr}from"./flame-CuoqhgO0.js";import{S as ga}from"./search-Dh5kBuL2.js";import{P as Ma}from"./plus-BCXK4rAO.js";import{D as Ua}from"./download-580FSMzx.js";import{P as Fa,a as za,b as Va,c as Ka,d as qa}from"./PopoverPopup-D0KIhAfw.js";import"./arrow-up-right-THgpMHTL.js";import"./DialogTitle-h96NnlwF.js";import"./store-Bt47laU0.js";import"./DialogDescription-B1_lWQbi.js";const Ha={name:"circle-arrow-up",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],aliases:["arrow-up-circle"]};Ha.node;const ya=yt(Ha),Ga=i.forwardRef(function(s,d){const{render:l,className:p,style:g,...x}=s,v={open:Gt().useState("open")};return xa("span",s,{state:v,ref:d,props:[{"aria-hidden":!0,children:"▼"},x],stateAttributesMapping:ar})}),br="tt:hint:dismissed:";function Wa(a){return br+a}function kr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Wa(a))==="1"}catch{return!1}}function wr({id:a,children:s,className:d,ariaLabel:l}){const[p,g]=i.useState(()=>kr(a)),x=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Wa(a),"1")}catch{}g(!0)},[a]);return p?null:e.jsxs("div",{role:"note","aria-label":l||r("hint.dismissible_aria"),className:se("relative rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 text-sm text-oai-gray-700","dark:border-oai-gray-800 dark:bg-oai-gray-900/40 dark:text-oai-gray-300",d),children:[e.jsx("button",{type:"button",onClick:x,"aria-label":r("hint.dismiss"),className:"absolute top-2 right-2 inline-flex h-7 w-7 items-center justify-center rounded-md text-oai-gray-500 transition-colors hover:bg-oai-gray-200/70 hover:text-oai-gray-700 focus:outline-none focus:ring-2 focus:ring-oai-blue/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800/70 dark:hover:text-oai-gray-200",children:e.jsx(Le,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Ra,{className:"mt-0.5 h-4 w-4 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:s})]})]})}function vr(a){if(!a)return null;for(const s of a.elements){const d=s.tagName;if(d==="BUTTON"||d==="INPUT"){const l=s;if(l.type==="submit")return l}}return null}const jr="data-checked",Nr="data-unchecked";function Qa(a){return{checked(s){return a.indeterminate?{}:s?{[jr]:""}:{[Nr]:""}},...Wt}}const Cr=i.createContext({disabled:!1});function Sr(){return i.useContext(Cr)}function _r(a,s,d,l=!0,p){const[g,x]=i.useState(),c=$a(p?`${p}-label`:void 0),y=a??s??g;return ua(()=>{const v=a||s||!l?void 0:Ir(d.current,c);g!==v&&x(v)}),y}function Ir(a,s){const d=Lr(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function Lr(a){if(!a)return;const s=a.parentElement;if(s&&s.tagName==="LABEL")return s;const d=a.id;if(d){const p=a.nextElementSibling;if(p&&p.htmlFor===d)return p}const l=a.labels;return l&&l[0]}const Rr=i.createContext(void 0);function Pr(){return i.useContext(Rr)}const Xa=i.createContext(void 0);function Br(){const a=i.useContext(Xa);if(a===void 0)throw new Error(bt(14));return a}const Dr="data-parent",Er=i.forwardRef(function(s,d){const{checked:l,className:p,defaultChecked:g=!1,"aria-labelledby":x,disabled:c=!1,form:y,id:v,indeterminate:f=!1,inputRef:N,name:I,onCheckedChange:u,parent:j=!1,readOnly:m=!1,render:C,required:P=!1,uncheckedValue:$,value:M,nativeButton:K=!1,style:de,...pe}=s,{clearErrors:ne}=Qt(),{disabled:B,name:fe,setDirty:_,setFilled:U,setFocused:q,setTouched:E,state:Z,validationMode:J,validityData:je,validation:ce}=Xt(),Pe=Sr(),{labelId:He,registerControlId:Be,getDescriptionProps:De}=Jt(),S=Pr(),L=S?.allValues===void 0?void 0:S.parent,H=L!==void 0,D=B||Pe.disabled||S?.disabled||c,ee=fe??I,R=M??ee,Ne=$a(),Ee=S?.registerControlId!==Be,ie=Yt({id:v||void 0,enabled:Ee}),Te=K?ie:Ne;let ue={};H&&(j?ue=L.getParentProps():R!==void 0&&(ue=L.getChildProps(R)));const{checked:Ae=l,indeterminate:Oe=f,onCheckedChange:Ge,...Ce}=ue,$e=S?.value,me=i.useRef(null),{getButtonProps:We,buttonRef:Me}=kt({disabled:D,native:K}),ae=S?.validation??ce,[T,Se]=Zt({controlled:R!==void 0&&$e!==void 0&&!j?$e.includes(R):Ae,default:g,name:"Checkbox",state:"checked"}),ge=H?!!Ae:T,G=H&&Oe||f;er(me,Ne,T,void 0,!S&&!D,I);const xe=L?.registerChildId,A=i.useRef(null),Ue=ae.registerInput,ye=S?R:void 0,_e=i.useCallback(k=>Ue(k,{controlRef:me,value:ye}),[Ue,ye]),ia=wt(N,A,j?void 0:_e),Qe=_r(x,He,A,!K,ie);ua(()=>{A.current&&(A.current.indeterminate=G),S||U(T)},[T,G,S,U]),rr(T,()=>{S||(ne(ee),_(T!==je.initialValue),ae.change(T))});const Xe=vt({checked:T,disabled:D,form:y,name:j?void 0:ee,id:K?void 0:ie,required:P,ref:ia,style:ee?St:_t,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(k){if(k.nativeEvent.defaultPrevented)return;if(m){k.preventDefault();return}const z=k.currentTarget.checked,oe=It(Lt,k.nativeEvent);if(u?.(z,oe),!oe.isCanceled&&(Ge?.(z,oe),!oe.isCanceled&&(Se(z),R!==void 0&&S!==void 0&&!j&&!H))){const te=z?[...S.value,R]:S.value.filter(Ie=>Ie!==R);S.setValue(te,oe)}},onClick(k){k.stopPropagation()},onFocus(){me.current?.focus()}},M!==void 0?{value:(S?T&&M:M)||""}:jt,De,k=>ae.getValidationProps(D,k));i.useEffect(()=>{if(!L||R===void 0)return;const k=L.disabledStatesRef.current;return k.set(R,D),()=>{k.delete(R)}},[L,D,R]);const F=i.useMemo(()=>({...Z,checked:ge,disabled:D,readOnly:m,required:P,indeterminate:G}),[Z,ge,D,m,P,G]),oa=Qa(F),Je=xa("span",s,{state:F,ref:[Me,me,d],props:[{id:Te,role:"checkbox","aria-checked":G?"mixed":ge,"aria-readonly":m||void 0,"aria-required":P||void 0,"aria-labelledby":Qe,[Dr]:j?"":void 0,onFocus(){D||q(!0)},onBlur(){const k=A.current;k&&(E(!0),q(!1),J==="onBlur"&&ae.commit(S?$e:k.checked))},onKeyDown(k){if(k.key!=="Enter"||(k.preventBaseUIHandler(),k.defaultPrevented))return;const z=A.current?.form??null,oe=k.currentTarget,te=k.nativeEvent,Ie=k.preventDefault,ze=te.preventDefault;let Ve=!1;k.preventDefault=()=>{Ve=!0,Ie.call(k)},te.preventDefault=()=>{Ve=!0,ze.call(te)},ze.call(te),Ct(oe).queueMicrotask(()=>{k.preventDefault=Ie,te.preventDefault=ze,Ve||vr(z)?.click()})},onClick(k){if(m||D)return;k.preventDefault();const z=A.current;z&&Nt(z,k)}},pe,Ce,We,De,k=>ae.getValidationProps(D,k)],stateAttributesMapping:oa}),Fe=Je.props.id;return ua(()=>{if(!(!xe||j||R===void 0||Fe===void 0))return xe(R,Fe)},[xe,j,R,Fe]),e.jsxs(Xa.Provider,{value:F,children:[Je,!T&&!S&&ee&&!j&&$!==void 0&&e.jsx("input",{type:"hidden",form:y,name:ee,value:$,disabled:D}),e.jsx("input",{...Xe,suppressHydrationWarning:!0})]})}),Tr=i.forwardRef(function(s,d){const{render:l,className:p,style:g,keepMounted:x=!1,...c}=s,y=Br(),v=y.checked||y.indeterminate,{mounted:f,transitionStatus:N,setMounted:I}=tr(v),u=i.useRef(null),j={...y,transitionStatus:N};Rt({batch:!0,enabled:!v,open:v,ref:u,onComplete(){v||I(!1)}});const C={...Qa(y),...Pt},P=x||f,$=xa("span",s,{ref:[d,u],state:j,stateAttributesMapping:C,props:c});return P?$:null});function Ar(a,s){return`target:${a}:${s}`}function Or(a){return`remove:${a.id||a.directory}`}function Ja(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function $r(a){const s=Ja(a);if(s==null)return null;if(s<=0)return r("skills.usage.today");if(s<30)return r("skills.usage.days_ago",{days:s});const d=Math.max(1,Math.floor(s/30));return r("skills.usage.months_ago",{months:d})}function Mr(a){const s=Ja(a);return s==null?"bg-oai-gray-300 dark:bg-oai-gray-600":s<=7?"bg-emerald-500":s<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function ca({label:a,children:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 text-sm",children:[e.jsx("dt",{className:"flex items-center gap-1 text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:s})]})}function Ur({skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:g,onUpdate:x,onClose:c,onToggleTarget:y,onRemove:v}){return e.jsx(qt,{children:a?e.jsx(Fr,{skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:g,onUpdate:x,onClose:c,onToggleTarget:y,onRemove:v},a.id||a.directory):null})}function Fr({skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:g,onUpdate:x,onClose:c,onToggleTarget:y,onRemove:v}){const f=Ht(),{currency:N,rate:I}=Kt(),u=i.useRef(null);i.useEffect(()=>{const _=q=>{q.key==="Escape"&&(q.stopPropagation(),c?.())},U=q=>{const E=q.target;E instanceof Element&&(u.current?.contains(E)||E.closest('[data-skill-row="1"]')||c?.())};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",U),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",U)}},[c]);const j=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),C=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,P=new Set(a.targets||[]),$=!!(a.readOnly||a.remote),M=!!a.remote,K=Array.isArray(a.deviceSources)?a.deviceSources:[],de=!M&&(!$||P.has("claude")),pe=d===Or(a),ne=$r(l?.lastUsedAt),B=!!(l&&l.invocations>0),fe=f?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(wa.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:f?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:f?0:.15},onClick:c,"aria-hidden":!0}),e.jsxs(wa.aside,{ref:u,role:"complementary","aria-label":j,initial:f?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:f?{opacity:0}:{opacity:0,x:24,scale:.98},transition:fe,className:"fixed inset-x-3 bottom-3 top-20 z-30 flex flex-col overflow-hidden rounded-2xl border border-white/40 bg-white/75 shadow-[0_24px_60px_-20px_rgba(15,23,42,0.25)] backdrop-blur-xl backdrop-saturate-150 supports-[backdrop-filter]:bg-white/65 dark:border-white/10 dark:bg-oai-gray-950/70 dark:shadow-[0_24px_60px_-20px_rgba(0,0,0,0.7)] dark:supports-[backdrop-filter]:bg-oai-gray-950/55 lg:inset-auto lg:right-6 lg:top-24 lg:bottom-6 lg:w-[22rem] lg:max-h-[calc(100vh-7.5rem)]",children:[e.jsxs("header",{className:"flex items-center gap-3 border-b border-white/40 bg-gradient-to-b from-white/30 to-transparent px-5 pb-4 pt-5 dark:border-white/10 dark:from-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",title:j,children:j}),m?e.jsxs("a",{href:C,target:"_blank",rel:"noreferrer noopener",className:"mt-1 inline-flex max-w-full items-center gap-1 truncate text-xs text-oai-gray-500 transition-colors hover:text-oai-black hover:underline dark:text-oai-gray-400 dark:hover:text-white",title:C,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(ma,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):a.directory&&a.directory!==j?e.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:a.directory,children:a.directory}):null]}),e.jsx("button",{type:"button",onClick:c,"aria-label":r("skills.detail.close"),className:"-mr-1 inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-oai-gray-500 transition hover:bg-oai-gray-100 hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(Le,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5",children:[p?e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-sky-50/80 px-3 py-2.5 ring-1 ring-sky-200 dark:bg-sky-950/30 dark:ring-sky-800/60",children:[e.jsx(ya,{className:"h-4 w-4 shrink-0 text-sky-600 dark:text-sky-300","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 text-xs text-sky-800 dark:text-sky-200",children:r("skills.update.available")}),e.jsxs("button",{type:"button",onClick:()=>x?.(a),disabled:g||!!d,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-sky-600 px-2.5 text-xs font-semibold text-white transition hover:bg-sky-700 focus:outline-none focus:ring-2 focus:ring-sky-400/40 disabled:cursor-not-allowed disabled:opacity-60 dark:bg-sky-500 dark:hover:bg-sky-400",children:[g?e.jsx(Y,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,r("skills.update.action")]})]}):null,a.description?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a.description}):null,$?e.jsx("div",{className:"mt-4 rounded-xl bg-oai-gray-50 px-3 py-2.5 text-xs leading-5 text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-900/60 dark:text-oai-gray-300 dark:ring-oai-gray-800",children:r(M?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed")}):null,a.sourceName?e.jsx("div",{className:"mt-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.source",{source:a.sourceName})}):null,K.length?e.jsxs("section",{className:"mt-5",children:[e.jsx("h3",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.devices_title")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:K.map(_=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 rounded-full bg-oai-gray-100 px-2.5 py-1 text-xs text-oai-gray-700 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-200 dark:ring-oai-gray-700",children:[e.jsx(Pa,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:_.name})]},_.id))})]}):null,de?e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.usage.section_title")}),e.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[e.jsx(ca,{label:r("skills.usage.invocations"),children:Bt(l?.invocations||0)}),e.jsx(ca,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:se("h-1.5 w-1.5 rounded-full",Mr(l?.lastUsedAt)),"aria-hidden":!0}),B?ne||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ca,{label:e.jsxs(e.Fragment,{children:[r("skills.usage.cost"),e.jsx("span",{title:r("skills.usage.disclaimer"),className:"inline-flex cursor-help text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(Ra,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:Dt(l?.cost||0,{currency:N,rate:I})})]}),B?null:e.jsx("p",{className:"mt-2 text-[11px] leading-4 text-oai-gray-400 dark:text-oai-gray-500",children:r("skills.usage.unused")})]}):null,$?null:e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.sync_section_title")}),e.jsx("div",{children:(s||[]).filter(_=>_.manageable!==!1).map(_=>{const U=P.has(_.id),q=d===Ar(a.id||a.directory,_.id),E=`skill-detail-sync-${a.id||a.directory}-${_.id}`;return e.jsxs("label",{htmlFor:E,className:"-mx-2 flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-oai-black transition-colors hover:bg-oai-gray-100/70 dark:text-white dark:hover:bg-white/[0.05]",children:[e.jsx(Er,{id:E,checked:U,disabled:!!d,onCheckedChange:Z=>y?.(a,_.id,!!Z),className:"peer flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border border-oai-gray-300/80 bg-white/80 shadow-sm transition-colors hover:border-oai-gray-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:border-oai-black data-[checked]:bg-oai-black dark:border-oai-gray-500/60 dark:bg-oai-gray-900/60 dark:hover:border-oai-gray-400 dark:data-[checked]:border-white dark:data-[checked]:bg-white",children:e.jsx(Tr,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(Re,{className:"h-3 w-3",strokeWidth:3.5,"aria-hidden":!0})})}),e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center","aria-hidden":!0,children:e.jsx(ve,{provider:_.id,size:16})}),e.jsx("span",{className:"flex-1",children:_.label}),q?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},_.id)})})]})]}),$?null:e.jsxs("footer",{className:"border-t border-white/40 bg-white/30 px-5 py-4 dark:border-white/10 dark:bg-white/[0.02]",children:[e.jsxs("button",{type:"button",onClick:()=>v?.(a),disabled:!!d,className:"inline-flex w-full items-center justify-center gap-2 rounded-lg border border-red-200/70 bg-white px-3 py-2 text-sm font-medium text-red-600 transition hover:border-red-300 hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-red-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-900/60 dark:bg-oai-gray-950 dark:text-red-300 dark:hover:border-red-800 dark:hover:bg-red-950/30",children:[pe?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.detail.remove_button")]}),e.jsx("p",{className:"mt-2 text-center text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.remove_confirm_hint")})]})]})]})}const zr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),_a=["claude","codex"],Q="popular",Vr={claude:"text-orange-500 dark:text-orange-300",codex:"text-emerald-600 dark:text-emerald-300",grok:"text-zinc-700 dark:text-zinc-200",antigravity:"text-violet-600 dark:text-violet-300",gemini:"text-sky-600 dark:text-sky-300",opencode:"text-amber-600 dark:text-amber-300",hermes:"text-indigo-500 dark:text-indigo-300"},he="all",V="skillssh";function na(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Ya(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function Kr(a){return Ya(a).split("/").filter(Boolean).pop()||""}function qr(a){if(a.repoOwner||a.repoName)return"";const s=Ya(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Ia(a){const s=Kr(a.directory);return s?`dir:${s}`:""}function Za(a){const s=new Set([na(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=qr(a);return d&&s.add(d),s}function Hr(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function Gr(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Hr(d))for(const l of Za(d))s.add(l);return s}function aa(a){return`install:${na(a)}`}function La(a){return`remove:${a.id||a.directory}`}function et(a,s){return`target:${a}:${s}`}function we(a){return a.id||a.directory}function ba(a){return a.manageable!==!1}function Wr({target:a,state:s,busy:d,disabled:l,disabledLabel:p,onToggle:g}){const x=s==="synced",c=s==="orphan",y=c?r("skills.dot.orphan_aria",{agent:a.label}):x?r("skills.dot.synced_aria",{agent:a.label}):r("skills.dot.off_aria",{agent:a.label}),v=l&&p?`${y} — ${p}`:y;return e.jsxs("button",{type:"button",title:v,"aria-label":v,"aria-pressed":x,disabled:d||l,onClick:f=>{f.stopPropagation(),g?.(a.id,!x)},className:"relative flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/40 disabled:cursor-not-allowed dark:hover:bg-oai-gray-800/60",children:[d?e.jsx(Y,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:se("flex h-[18px] w-[18px] items-center justify-center transition",x&&Vr[a.id],!x&&!c&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(ve,{provider:a.id,size:18})}),c&&!d?e.jsx("span",{className:"absolute -bottom-px -right-px h-2 w-2 rounded-full bg-amber-500 ring-2 ring-oai-white dark:ring-oai-gray-900","aria-hidden":!0}):null]})}function Qr({skill:a,targets:s,onToggleTarget:d,busyKey:l}){const p=new Set(a.targets||[]),g=!!(a.readOnly||a.remote),x=[];for(const c of s)(g?p.has(c.id):ba(c))&&x.push(c);return e.jsx("div",{className:"flex items-center gap-1",onClick:c=>c.stopPropagation(),children:x.map(c=>e.jsx(Wr,{target:c,state:a.targetStates?.[c.id]||"off",busy:l===et(we(a),c.id),disabled:g||c.manageable===!1,disabledLabel:r(a.remote?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed"),onToggle:(y,v)=>d?.(a,y,v)},c.id))})}function Xr({skill:a,targets:s,selected:d,onSelect:l,selectable:p,checked:g,onToggleSelect:x,onToggleTarget:c,hasUpdate:y,busyKey:v}){const f=a.repoOwner&&a.repoName?`${a.repoOwner}/${a.repoName}`:null,N=[a.directory,f,a.sourceName].filter(Boolean).join(" · "),I=Array.isArray(a.deviceSources)?a.deviceSources:[],u=[a.remote?r("skills.inventory.remote"):null,a.scope==="plugin"?r("skills.inventory.plugin"):null].filter(Boolean),j=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),l?.(a))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":d,"aria-label":r("skills.row.open_details",{name:a.name||a.directory}),onClick:()=>l?.(a),onKeyDown:j,className:se("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",d?"bg-oai-gray-100 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800/60 dark:ring-oai-gray-800":g?"bg-oai-gray-50 dark:bg-oai-gray-900/40":"hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[p?e.jsx("label",{className:"flex shrink-0 items-center",onClick:m=>m.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:g,onChange:m=>x?.(a,m.target.checked),"aria-label":r("skills.select.row_aria",{name:a.name||a.directory}),className:"h-4 w-4 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white"})}):null,e.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-oai-black dark:text-white",title:N,children:a.name||a.directory}),u.map(m=>e.jsx("span",{className:"inline-flex shrink-0 rounded-full bg-oai-gray-100 px-1.5 py-0.5 text-[10px] font-semibold text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-300 dark:ring-oai-gray-700",children:m},m)),y?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-semibold text-sky-700 ring-1 ring-sky-200 dark:bg-sky-950/40 dark:text-sky-300 dark:ring-sky-800/60",children:[e.jsx(ya,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Qr,{skill:a,targets:s,onToggleTarget:c,busyKey:v}),e.jsx(Ut,{className:se("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",d&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),a.description?e.jsx("p",{className:se("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",p&&"pl-7"),children:a.description}):null,a.sourceName||I.length?e.jsxs("div",{className:se("mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",p&&"pl-7"),children:[a.sourceName?e.jsx("span",{className:"truncate",children:a.sourceName}):null,I.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:I.map(m=>m.name).join(", "),children:[e.jsx(Pa,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:I.map(m=>m.name).join(", ")})})]}):null]}):null]})}function Jr({agentFilter:a,agentOptions:s,onAgentFilter:d,filteredCount:l,totalCount:p,anyFilter:g,onClearFilters:x,searchQuery:c,onSearchQuery:y,searchPlaceholder:v}){return 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.jsxs(Ba,{value:a,onValueChange:d,children:[e.jsxs(Da,{"aria-label":r("skills.filter.agent_label"),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200 dark:hover:border-oai-gray-700",children:[e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:[r("skills.filter.agent_label"),":"]}),e.jsx(Ea,{children:f=>f==="all"?r("skills.filter.agent_all"):s.find(N=>N.id===f)?.label||f}),e.jsx(Ga,{className:"text-oai-gray-400",children:e.jsx(fa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ta,{children:e.jsx(Aa,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Oa,{className:"min-w-[var(--anchor-width)] 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(ta,{value:"all",className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:r("skills.filter.agent_all")}),e.jsx(sa,{children:e.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(f=>e.jsxs(ta,{value:f.id,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{provider:f.id,size:14}),e.jsx(ra,{children:f.label})]}),e.jsx(sa,{children:e.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},f.id))]})})})]}),e.jsxs("div",{className:"relative w-56 max-w-full",children:[e.jsx(ga,{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(ha,{type:"search",value:c,onChange:f=>y(f.target.value),onKeyDown:f=>{f.key==="Escape"&&c&&(f.preventDefault(),y(""))},"aria-label":r("skills.action.search_aria"),placeholder:v,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:f=>f.preventDefault(),onClick:()=>y(""),"aria-label":r("skills.action.search_clear"),"aria-hidden":!c,tabIndex:c?0:-1,className:se("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 before:absolute before:-inset-1.5 before:content-[''] 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 motion-reduce:transition-none dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",c?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{role:"status","aria-live":"polite",className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.filter.result_count",{filtered:l,total:p})}),g?e.jsxs("button",{type:"button",onClick:x,className:"shrink-0 inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Le,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Yr({count:a,targets:s,busy:d,onBulkSync:l,onBulkRemove:p,onClear:g}){const x=s.filter(ba);return e.jsxs("div",{role:"toolbar","aria-label":r("skills.select.toolbar_aria"),className:"mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/50",children:[e.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200","aria-live":"polite",children:r("skills.select.count",{count:a})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(Fa,{children:[e.jsxs(za,{disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:[e.jsx(Ua,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(fa,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Va,{children:e.jsx(Ka,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(qa,{className:"min-w-[200px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.select.bulk_sync_hint")}),x.map(c=>e.jsxs("button",{type:"button",onClick:()=>l(c.id),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx(ve,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(X,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:p,children:[e.jsx(pa,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_remove")]}),e.jsxs("button",{type:"button",onClick:g,className:"inline-flex h-7 items-center gap-1 rounded-full px-2 text-[11px] font-medium text-oai-gray-500 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",children:[e.jsx(Le,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Zr({items:a,totalCount:s,targets:d,agentOptions:l,agentFilter:p,onAgentFilter:g,anyFilter:x,onClearFilters:c,searchQuery:y,onSearchQuery:v,searchPlaceholder:f,selectedId:N,onSelect:I,onToggleTarget:u,busyKey:j,updates:m,selectedIds:C,onToggleSelect:P,onClearSelection:$,onBulkSync:M,onBulkRemove:K,updateCount:de,onUpdateAll:pe}){const ne=C.size;return e.jsxs("div",{children:[ne>0?e.jsx(Yr,{count:ne,targets:d,busy:j==="batch",onBulkSync:M,onBulkRemove:K,onClear:$}):e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx(Jr,{agentFilter:p,agentOptions:l,onAgentFilter:g,filteredCount:a.length,totalCount:s,anyFilter:x,onClearFilters:c,searchQuery:y,onSearchQuery:v,searchPlaceholder:f}),de?e.jsxs(X,{type:"button",variant:"secondary",size:"sm",className:"mb-2 shrink-0",disabled:!!j,onClick:pe,children:[j==="update-all"?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ya,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.update.all_action",{count:de})]}):null]}),a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r("skills.empty.no_match")}),e.jsx(X,{type:"button",variant:"secondary",size:"sm",onClick:c,children:r("skills.filter.clear")})]}):e.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(B=>e.jsx(Xr,{skill:B,targets:d,selected:N===(B.id||B.directory),onSelect:I,selectable:!B.readOnly&&!B.remote,checked:C.has(we(B)),onToggleSelect:P,onToggleTarget:u,hasUpdate:!!(B.id&&m?.[B.id]),busyKey:j},we(B)))})]})}const es={contentVisibility:"auto",containIntrinsicSize:"0 240px"},as=Mt.memo(function({skill:s,installed:d,installing:l,allTargets:p,defaultTargets:g,onInstall:x,onManage:c}){const[y,v]=i.useState(()=>(g||[]).filter(m=>p.some(C=>C.id===m))),f=m=>{v(C=>C.includes(m)?C.filter(P=>P!==m):[...C,m])},N=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,I=N?`https://github.com/${s.repoOwner}/${s.repoName}`:null,u=s.installs!=null?r("skills.card.installs",{count:Number(s.installs||0).toLocaleString()}):null,j=y.length?y.map(m=>p.find(C=>C.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(zt,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[s.readmeUrl?e.jsxs("a",{href:s.readmeUrl,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex max-w-full items-center gap-1 truncate text-base font-semibold text-oai-black hover:underline dark:text-white",title:s.readmeUrl,children:[e.jsx("span",{className:"truncate",children:s.name||s.directory}),e.jsx(ma,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:s.name||s.directory}),N||u?e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[I?e.jsxs("a",{href:I,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"inline-flex items-center gap-1 truncate rounded text-oai-gray-500 hover:text-oai-black hover:underline focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",title:I,children:[e.jsx("span",{className:"truncate",children:N}),e.jsx(ma,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,N&&u?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,u?e.jsx("span",{className:"truncate",children:u}):null]}):null]})}),s.description?e.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s.description}):null,e.jsx("div",{className:"mt-auto pt-5",children:d?e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>c?.(s),className:"w-full",children:[e.jsx(Re,{className:"mr-1.5 h-3.5 w-3.5 text-emerald-500 dark:text-emerald-400","aria-hidden":!0}),r("skills.card.manage")]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.card.targets_prefix")}),e.jsx("span",{className:"min-w-0 truncate font-medium text-oai-black dark:text-white",children:y.length?j:r("skills.target.none")}),e.jsxs(Fa,{children:[e.jsx(za,{disabled:l,"aria-label":r("skills.action.choose_targets"),className:"rounded text-xs font-medium text-oai-gray-500 underline decoration-oai-gray-300 decoration-dotted underline-offset-2 transition hover:text-oai-black hover:decoration-oai-gray-500 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:text-oai-gray-400 dark:decoration-oai-gray-600 dark:hover:text-white dark:hover:decoration-oai-gray-400",children:r("skills.card.targets_change")}),e.jsx(Va,{children:e.jsx(Ka,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(qa,{className:"min-w-[220px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.target.menu_label")}),p.map(m=>{const C=y.includes(m.id);return e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 shrink-0 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white",checked:C,onChange:()=>f(m.id)}),e.jsx(ve,{provider:m.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:m.label})]},m.id)})]})})})]})]}),e.jsxs(X,{type:"button",size:"sm",onClick:()=>x(s,y),disabled:l||y.length===0,className:"w-full",children:[l?e.jsx(Y,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Ua,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function ts({repos:a,repoInput:s,onRepoInput:d,busyKey:l,onAdd:p,onRemove:g}){return e.jsxs("div",{className:"rounded-lg border border-oai-gray-200 bg-white p-4 dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx(ha,{value:s,onChange:x=>d(x.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(X,{type:"button",variant:"secondary",size:"md",onClick:p,disabled:l==="repo:add",className:"shrink-0 whitespace-nowrap",children:[l==="repo:add"?e.jsx(Y,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Ma,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.repo.add")]})]}),a.length?e.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(x=>{const c=l===`repo:${x.owner}/${x.name}`;return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[x.owner,"/",x.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:x.branch})]}),e.jsxs(X,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>g(x),className:"shrink-0",children:[c?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${x.owner}/${x.name}`)})}):null]})}function rs(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Ds(){const a=Et()||{},s=!!a.signedIn,d=a.getAccessToken,[l,p]=i.useState(rs),[g,x]=i.useState({skills:[],targets:[]}),[c,y]=i.useState([]),[v,f]=i.useState([]),[N,I]=i.useState([]),[u,j]=i.useState(he),[m,C]=i.useState(""),[P,$]=i.useState(""),[M,K]=i.useState(""),[de,pe]=i.useState(""),[ne,B]=i.useState(""),[fe,_]=i.useState(!1),[U,q]=i.useState("all"),[E,Z]=i.useState(null),[J,je]=i.useState(""),ce=i.useRef(!1),[Pe,He]=i.useState(!0),[Be,De]=i.useState(!1),[S,L]=i.useState(""),[H,D]=i.useState(null),[ee,R]=i.useState(null),[Ne,Ee]=i.useState(null),[ie,Te]=i.useState(()=>new Set),[ue,Ae]=i.useState({}),[Oe,Ge]=i.useState({}),[Ce,$e]=i.useState([]),[me,We]=i.useState(!1),Me=i.useRef(!1),ae=i.useRef(0),T=i.useMemo(()=>Gr(g.skills),[g.skills]),Se=i.useCallback(async()=>{const t=++ae.current,n=await sr();if(ae.current!==t)return;const o={skills:n.skills||[],targets:n.targets||[]};x(o);const h=Tt();!s||!At()||!h||typeof d!="function"||(async()=>{try{const b=await d();if(!b||ae.current!==t)return;const[w]=await Promise.allSettled([nr(b),ir({accessToken:b,deviceId:h,skills:o.skills})]);if(w.status!=="fulfilled")return;const ke=w.value;if(ae.current!==t)return;x({targets:o.targets,skills:or(o.skills,ke,h)})}catch{}})()},[d,s]),ge=i.useCallback(async()=>{const t=await lr();I(t.repos||[])},[]),G=i.useCallback(async({force:t=!1}={})=>{De(!0);try{const n=await dr({force:t});y(n.skills||[])}finally{De(!1)}},[]),xe=i.useCallback(async({force:t=!1}={})=>{We(!0);try{const n=await cr({force:t});$e(n.skills||[])}finally{We(!1)}},[]),A=i.useCallback(async()=>{try{const t=await ur();Ae(t?.updates||{})}catch{}},[]),Ue=i.useCallback(t=>{const n=new Set((t||[]).filter(Boolean));n.size&&Ae(o=>{if(!Object.keys(o).some(b=>n.has(b)))return o;const h={};for(const[b,w]of Object.entries(o))n.has(b)||(h[b]=w);return h})},[]),ye=i.useCallback(async()=>{try{const t=await mr(),n={};for(const o of t?.skills||[])o.installed&&(o.directory&&(n[String(o.directory).toLowerCase()]=o),n[String(o.skill).toLowerCase()]=o);Ge(n)}catch{Ge({})}},[]),_e=i.useCallback(async()=>{He(!0),L("");try{await Promise.all([Se(),ge()])}catch(t){L(t?.message||r("skills.error.generic"))}finally{He(!1)}},[Se,ge]),ia=i.useCallback(async()=>{await _e();const t=n=>L(n?.message||r("skills.error.generic"));l==="my"?(A(),ye()):u===Q?xe({force:!0}).catch(t):u!==V&&G({force:!0}).catch(t)},[G,_e,xe,A,ye,u,l]);i.useEffect(()=>{_e()},[_e]),i.useEffect(()=>{if(Me.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){Me.current=!0;return}const o=g.skills||[];if(!o.length)return;const h=o.find(w=>w.directory===n||w.id===n);h&&(p("my"),Z(h.id||h.directory)),Me.current=!0,t.delete("skill");const b=t.toString();window.history.replaceState({},"",`${window.location.pathname}${b?`?${b}`:""}${window.location.hash}`)},[g.skills]),i.useEffect(()=>{l==="browse"&&(u===V||u===Q||c.length===0&&G().catch(t=>L(t?.message||r("skills.error.generic"))))},[c.length,G,u,l]),i.useEffect(()=>{l!=="browse"||u!==Q||Ce.length===0&&xe().catch(t=>L(t?.message||r("skills.error.generic")))},[xe,Ce.length,u,l]);const Qe=Object.keys(ue).length>0,Xe=Object.keys(Oe).length>0;if(i.useEffect(()=>{l==="my"&&(Qe||A(),Xe||ye())},[l,Qe,Xe,A,ye]),i.useEffect(()=>{const t=setTimeout(()=>$(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>pe(M),120);return()=>clearTimeout(t)},[M]),i.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("tab");if(l==="my"){if(!n)return;t.delete("tab")}else{if(n===l)return;t.set("tab",l)}const o=t.toString(),h=`${window.location.pathname}${o?`?${o}`:""}${window.location.hash}`;window.history.replaceState({},"",h)},[l]),!zr&&!Ot())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Ft,{})});const F=async(t,n)=>{if(!ce.current){ce.current=!0,je(t),L("");try{await n(),await Se()}catch(o){L(o?.message||r("skills.error.generic"))}finally{ce.current=!1,je("")}}},oa=(t,n)=>{const o=(n&&n.length?n:_a).filter(h=>(g.targets||[]).some(b=>b.id===h));F(aa(t),async()=>{await xr(t,o);const h=o.map(b=>(g.targets||[]).find(w=>w.id===b)?.label||b).join(", ");W({title:r("skills.toast.installed",{name:t.name||t.directory,targets:h||r("skills.target.none")}),timeout:4e3})})},Je=t=>{t?.readOnly||t?.remote||D(t)},Fe=()=>{const t=H;t&&(D(null),F(La(t),async()=>{let n=null;t.managed?n=await va(t.id):await ja(t.directory,t.targets||[]),Ue([t.id]);const o=!!(n?.trashed&&t.managed&&t.id);W({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:o?{onUndo:async()=>{try{await hr(t.id),await Se()}catch(h){L(h?.message||r("skills.error.generic"))}}}:void 0})}))},k=(t,n,o)=>t?.readOnly||t?.remote?Promise.resolve():F(et(we(t),n),async()=>{const h=new Set(t.targets||[]);o?h.add(n):h.delete(n),t.managed?await Na(t.id,Array.from(h)):await Ca(t.directory,Array.from(h));const b={name:t.name||t.directory,agent:te(n)};W({title:o?r("skills.toast.synced_one",b):r("skills.toast.unsynced_one",b),timeout:3e3})}),z=i.useCallback(()=>Te(new Set),[]),oe=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const o=we(t);Te(h=>{const b=new Set(h);return n?b.add(o):b.delete(o),b})},[]),te=t=>(g.targets||[]).find(n=>n.id===t)?.label||t,Ie=t=>{const n=(g.skills||[]).filter(o=>ie.has(we(o))&&!o.readOnly&&!o.remote);n.length&&F("batch",async()=>{for(const o of n){const h=new Set(o.targets||[]);h.add(t),o.managed?await Na(o.id,Array.from(h)):await Ca(o.directory,Array.from(h))}z(),W({title:r("skills.toast.bulk_synced",{count:n.length,agent:te(t)}),timeout:4e3})})},ze=()=>{const t=(g.skills||[]).filter(n=>ie.has(we(n))&&!n.readOnly&&!n.remote);t.length&&R(t)},Ve=()=>{const t=ee;t&&(R(null),F("batch",async()=>{for(const n of t)n.managed?await va(n.id):await ja(n.directory,n.targets||[]);Ue(t.map(n=>n.id)),z(),W({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},at=t=>{!t?.id||!t?.repoOwner||!t?.repoName||F(aa(t),async()=>{const n=await Sa([t.id]);await A();const{results:o=[],rateLimited:h=null,updated:b=0}=n||{};if(h){W({title:r("skills.update.rate_limited",{count:b}),timeout:6e3});return}const w=o[0];if(!w||!w.ok)throw new Error(w?.error||r("skills.error.generic"));W({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},tt=new Set((g.skills||[]).map(t=>t.id).filter(Boolean)),la=Object.entries(ue).filter(([t,n])=>n&&tt.has(t)).map(([t])=>t),rt=la.length,st=()=>{la.length&&Ee(la)},nt=()=>{const t=Ne;Ee(null),!(!t||!t.length)&&F("update-all",async()=>{const n=await Sa(t);await A();const{updated:o=0,failed:h=0,rateLimited:b=null,results:w=[]}=n||{},ke=w.length;if(b)W({title:r("skills.update.rate_limited",{count:o}),timeout:6e3});else if(h>0)W({title:r("skills.toast.updated_partial",{count:o,total:ke,failed:h}),timeout:6e3});else if(o===0)W({title:r("skills.toast.updated_none"),timeout:4e3});else if(o===1){const O=w.find(ea=>ea.ok&&!ea.skipped);W({title:r("skills.toast.updated",{name:O?.name||""}),timeout:4e3})}else W({title:r("skills.toast.updated_many",{count:o}),timeout:4e3})})},ka=async()=>{const t=m.trim();if(!(t.length<2||ce.current)){ce.current=!0,je("search"),L("");try{const n=await gr(t);f(n.skills||[])}catch(n){L(n?.message||r("skills.error.generic"))}finally{ce.current=!1,je("")}}},it=async()=>{const t=ne.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,o]=t.split("/");if(!n||!o){L(r("skills.repo.invalid"));return}await F("repo:add",async()=>{await fr({owner:n,name:o,branch:"main",enabled:!0}),B(""),await ge(),await G()})},ot=async t=>{await F(`repo:${t.owner}/${t.name}`,async()=>{await pr(t.owner,t.name),await ge(),await G()})},le=g.targets||[],lt=le.filter(ba),be=g.skills||[],dt=i.useMemo(()=>{const t=U==="all"?be:be.filter(o=>(o.targets||[]).includes(U)),n=de.trim().toLowerCase();return n?t.filter(o=>(o.name||"").toLowerCase().includes(n)||(o.directory||"").toLowerCase().includes(n)||(o.description||"").toLowerCase().includes(n)):t},[be,U,de]),ct=U!=="all",re=i.useMemo(()=>E&&be.find(t=>(t.id||t.directory)===E)||null,[be,E]),ut=i.useCallback(()=>{q("all"),K("")},[]),mt=i.useCallback(t=>{Z(n=>{const o=t?.id||t?.directory||null;return n===o?null:o})},[]),gt=i.useCallback(()=>Z(null),[]),xt=i.useCallback(t=>{const n=na(t).toLowerCase(),o=Ia(t),h=(g.skills||[]).find(b=>{const w=Za(b);return w.has(n)||o&&w.has(o)});h&&Z(h.id||h.directory)},[g.skills]);i.useEffect(()=>{l!=="my"&&ie.size&&Te(new Set)},[l,ie.size]),i.useEffect(()=>{E&&!re&&Z(null)},[re,E]);const Ke=i.useMemo(()=>{const t=u===V?v:u===Q?Ce:c,o=u===V||u===Q||u===he?t:t.filter(w=>`${w.repoOwner}/${w.repoName}`===u),h=P.trim().toLowerCase();return(u===V||!h?o:o.filter(w=>(w.name||"").toLowerCase().includes(h)||(w.directory||"").toLowerCase().includes(h)||(w.description||"").toLowerCase().includes(h))).map(w=>{const ke=na(w).toLowerCase(),O=Ia(w);return{...w,installed:T.has(ke)||O&&T.has(O)}})},[P,c,T,Ce,v,u]),ht=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(Y,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),pt=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(Y,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),e.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.browse.loading_hint")})]}),Ye=(t,n=null)=>e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r(t)}),n]});let Ze;if(Pe)Ze=ht;else if(l==="my")Ze=be.length?e.jsx(Zr,{items:dt,totalCount:be.length,targets:le,agentOptions:le,agentFilter:U,onAgentFilter:q,anyFilter:ct,onClearFilters:ut,searchQuery:M,onSearchQuery:K,searchPlaceholder:r("skills.my.placeholder"),selectedId:E,onSelect:mt,onToggleTarget:k,busyKey:J,updates:ue,selectedIds:ie,onToggleSelect:oe,onClearSelection:z,onBulkSync:Ie,onBulkRemove:ze,updateCount:rt,onUpdateAll:st}):e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-800",children:[le.length>0?e.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)",WebkitMaskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ve,{provider:t.id,size:30})},`b-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)",WebkitMaskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ve,{provider:t.id,size:30})},`c-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-oai-white to-transparent dark:from-oai-gray-900"}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-oai-white to-transparent dark:from-oai-gray-900"})]}):null,e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.empty.my")}),e.jsx(X,{type:"button",size:"sm",onClick:()=>p("browse"),children:r("skills.empty.my_cta")})]});else{const t=u===V,n=u===Q,o=N.length===0&&!t&&!n,h=Be&&!t&&!n||n&&me,b=!t&&!n&&(P.trim()!==""||u!==he),w=()=>{C(""),j(he)},ke=!o&&!h&&(Ke.length>0||b)?e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 px-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("skills.filter.result_count_browse",{count:Ke.length})}),b?e.jsxs("button",{type:"button",onClick:w,className:"ml-auto inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Le,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let O;o?O=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:e.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:r("skills.browse.empty_sources")})}):h?O=pt:t&&m.trim().length<2?O=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 px-4 py-6 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:r("skills.browse.hint_skillssh")}):Ke.length?O=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Ke.map(qe=>e.jsx("div",{style:es,children:e.jsx(as,{skill:qe,installed:!!qe.installed,installing:J===aa(qe),allTargets:lt,defaultTargets:_a,onInstall:oa,onManage:xt})},qe.id||qe.key))}):b?O=Ye("skills.empty.no_match",e.jsx(X,{type:"button",variant:"secondary",size:"sm",onClick:w,children:r("skills.filter.clear")})):t?O=Ye("skills.empty.search"):n?O=Ye("skills.empty.popular"):O=Ye("skills.empty.browse");const ea=o||fe?e.jsx("div",{className:"mb-5",children:e.jsx(ts,{repos:N,repoInput:ne,onRepoInput:B,busyKey:J,onAdd:it,onRemove:ot})}):null,ft=!fe&&!t&&!n&&N.length<=1&&Ke.length>0?e.jsx(wr,{id:"skills-browse-intro",className:"mt-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{children:r("skills.browse.add_repo_hint")}),e.jsx("button",{type:"button",onClick:()=>_(!0),className:"rounded font-medium text-oai-gray-700 underline decoration-dotted underline-offset-2 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-200 dark:hover:text-white",children:r("skills.browse.manage_sources")})]})}):null;Ze=e.jsxs(e.Fragment,{children:[ea,ke,O,ft]})}return e.jsxs("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:[e.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:r("skills.page.title")}),e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:ia,disabled:Pe||Be||me,children:[e.jsx($t,{className:se("mr-1.5 h-3.5 w-3.5",(Pe||Be||me)&&"animate-spin"),"aria-hidden":!0}),r("skills.action.refresh")]})]}),e.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",r("skills.tab.my")],["browse",r("skills.tab.browse")]].map(([t,n])=>e.jsx("button",{type:"button","aria-pressed":l===t,onClick:()=>p(t),className:se("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",l===t?"border-oai-black text-oai-black dark:border-white dark:text-white":"border-transparent text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:n},t))}),S?e.jsx("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-200",children:S}):null,l==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx(Vt,{className:"shrink-0",ariaLabel:r("skills.source.label"),options:[{id:"repo",label:r("skills.mode.repo")},{id:"popular",label:r("skills.mode.popular"),icon:e.jsx(yr,{className:"h-3.5 w-3.5","aria-hidden":!0})},{id:"skillssh",label:r("skills.mode.skillssh")}],value:u===V?"skillssh":u===Q?"popular":"repo",onChange:t=>{t==="skillssh"?j(V):t==="popular"?j(Q):(u===V||u===Q)&&j(he)}}),u!==V&&u!==Q?e.jsxs(Ba,{value:u,onValueChange:j,children:[e.jsxs(Da,{"aria-label":r("skills.source.label"),className:"inline-flex h-8 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs text-oai-black focus:outline-none data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:data-[popup-open]:border-oai-gray-700",children:[e.jsx(Ea,{children:t=>t===he?r("skills.source.all"):t}),e.jsx(Ga,{className:"text-oai-gray-400",children:e.jsx(fa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ta,{children:e.jsx(Aa,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Oa,{className:"min-w-[var(--anchor-width)] 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 transition-[opacity,transform] duration-150 ease-out data-[ending-style]:scale-[0.97] data-[ending-style]:opacity-0 data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0 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(ta,{value:he,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:r("skills.source.all")}),e.jsx(sa,{children:e.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),N.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(ta,{value:n,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:n}),e.jsx(sa,{children:e.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ga,{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(ha,{type:"search",value:m,onChange:t=>C(t.target.value),onKeyDown:t=>{t.key==="Enter"&&u===V&&ka()},"aria-label":r("skills.action.search_aria"),placeholder:u===V?r("skills.browse.placeholder_skillssh"):u===Q?r("skills.browse.placeholder_popular"):u===he?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:u}),className:"h-8 pl-9 !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"})]}),u===V?e.jsxs(X,{type:"button",size:"sm",onClick:ka,disabled:m.trim().length<2||J==="search",className:"focus:!ring-oai-gray-400/30",children:[J==="search"?e.jsx(Y,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(ga,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):u===Q?null:e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>_(t=>!t),"aria-expanded":fe,className:"!h-8 shrink-0 whitespace-nowrap !border-oai-gray-200 dark:!border-oai-gray-800 hover:!border-oai-gray-300 dark:hover:!border-oai-gray-700 hover:!text-oai-black dark:hover:!text-white focus:!ring-oai-gray-400/30",children:[e.jsx(Ma,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.browse.manage_sources"),e.jsx("span",{className:"ml-1.5 rounded bg-oai-gray-100 px-1.5 py-0.5 text-xs font-medium text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:N.length})]})]}):null,Ze,e.jsx(Ur,{skill:re,targets:le,busyKey:J,usage:re&&(Oe[String(re.directory||"").toLowerCase()]||Oe[String(re.name||"").toLowerCase()])||null,hasUpdate:!!(re?.id&&ue?.[re.id]),updating:re?J===aa(re):!1,onUpdate:at,onClose:gt,onToggleTarget:k,onRemove:Je})]})}),e.jsx(da,{open:!!H,title:r("skills.confirm.remove_title",{name:H?.name||H?.directory||""}),description:H?H.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:J===La(H||{}),onCancel:()=>D(null),onConfirm:Fe}),e.jsx(da,{open:!!ee,title:r("skills.confirm.bulk_remove_title",{count:ee?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:J==="batch",onCancel:()=>R(null),onConfirm:Ve}),e.jsx(da,{open:!!Ne,title:r("skills.confirm.update_all_title",{count:Ne?.length||0}),description:r("skills.confirm.update_all_desc"),confirmLabel:r("skills.update.action"),cancelLabel:r("shared.action.cancel"),onCancel:()=>Ee(null),onConfirm:nt})]})}export{Ds as SkillsPage,Gr as buildLocallyInstalledKeys};
1
+ import{m as yt,r as i,v as xa,j as e,X as Le,c as r,e as se,ax as ua,ay as bt,t as kt,az as wt,aA as vt,E as jt,aB as Nt,aC as Ct,aD as St,aE as _t,w as It,aF as Lt,aG as Rt,aH as Pt,aI as Bt,a3 as Dt,a as Et,aJ as Tt,an as At,G as Ot,B as X,R as $t,d as Mt,aK as Ut,a4 as W}from"./__vite-browser-external-DYzNZTW8.js";import{L as Ft,I as ha}from"./LocalOnlyNotice-BDOSLg08.js";import{C as zt}from"./Card-yUa-1eMj.js";import{C as da}from"./ConfirmModal-BzG_SVcZ.js";import{S as Vt}from"./SegmentedControl-Bbw7Dypd.js";import{I as Ra}from"./info-DyDVFBHF.js";import{P as ve}from"./ProviderIcon-MDkXefRU.js";import{m as wa}from"./react-CXLTMo1j.js";import{u as Kt}from"./useCurrency-Dk_equa7.js";import{E as ma}from"./external-link-Ca5PZfay.js";import{L as Y}from"./loader-circle-CCBcIYQZ.js";import{M as Pa}from"./monitor-smartphone-DxmsWtQn.js";import{C as Re}from"./check-iVengRka.js";import{T as pa}from"./trash-G_ESCgKH.js";import{A as qt}from"./index-C93m3GcS.js";import{u as Ht}from"./use-reduced-motion-B3bqraBN.js";import{u as Gt,k as Wt,l as Qt,m as Xt,n as Jt,o as Yt,p as Zt,q as er,S as Ba,c as Da,d as Ea,e as Ta,f as Aa,g as Oa,h as ta,j as ra,i as sa}from"./SelectItemText-CHj4a14t.js";import{t as ar,u as $a,a as tr}from"./composite-DdGB3lqE.js";import{u as rr,C as fa}from"./ToolbarRootContext-6-c1WW_C.js";import{g as sr,a as nr,p as ir,m as or,b as lr,d as dr,c as cr,e as ur,f as mr,s as gr,i as xr,u as va,h as ja,r as hr,j as Na,k as Ca,l as Sa,n as pr,o as fr}from"./skills-api-D7EpxvhF.js";import{F as yr}from"./flame-D1yeuyUj.js";import{S as ga}from"./search-vQged-EC.js";import{P as Ma}from"./plus-B1xi3Vdy.js";import{D as Ua}from"./download-BAPBndt2.js";import{P as Fa,a as za,b as Va,c as Ka,d as qa}from"./PopoverPopup-JzxAr4q_.js";import"./arrow-up-right-DY2sXgRx.js";import"./DialogTitle-BThuBA7Z.js";import"./store-DJbKAU4R.js";import"./DialogDescription-q53be2If.js";const Ha={name:"circle-arrow-up",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],aliases:["arrow-up-circle"]};Ha.node;const ya=yt(Ha),Ga=i.forwardRef(function(s,d){const{render:l,className:p,style:g,...x}=s,v={open:Gt().useState("open")};return xa("span",s,{state:v,ref:d,props:[{"aria-hidden":!0,children:"▼"},x],stateAttributesMapping:ar})}),br="tt:hint:dismissed:";function Wa(a){return br+a}function kr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Wa(a))==="1"}catch{return!1}}function wr({id:a,children:s,className:d,ariaLabel:l}){const[p,g]=i.useState(()=>kr(a)),x=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Wa(a),"1")}catch{}g(!0)},[a]);return p?null:e.jsxs("div",{role:"note","aria-label":l||r("hint.dismissible_aria"),className:se("relative rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 text-sm text-oai-gray-700","dark:border-oai-gray-800 dark:bg-oai-gray-900/40 dark:text-oai-gray-300",d),children:[e.jsx("button",{type:"button",onClick:x,"aria-label":r("hint.dismiss"),className:"absolute top-2 right-2 inline-flex h-7 w-7 items-center justify-center rounded-md text-oai-gray-500 transition-colors hover:bg-oai-gray-200/70 hover:text-oai-gray-700 focus:outline-none focus:ring-2 focus:ring-oai-blue/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800/70 dark:hover:text-oai-gray-200",children:e.jsx(Le,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Ra,{className:"mt-0.5 h-4 w-4 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:s})]})]})}function vr(a){if(!a)return null;for(const s of a.elements){const d=s.tagName;if(d==="BUTTON"||d==="INPUT"){const l=s;if(l.type==="submit")return l}}return null}const jr="data-checked",Nr="data-unchecked";function Qa(a){return{checked(s){return a.indeterminate?{}:s?{[jr]:""}:{[Nr]:""}},...Wt}}const Cr=i.createContext({disabled:!1});function Sr(){return i.useContext(Cr)}function _r(a,s,d,l=!0,p){const[g,x]=i.useState(),c=$a(p?`${p}-label`:void 0),y=a??s??g;return ua(()=>{const v=a||s||!l?void 0:Ir(d.current,c);g!==v&&x(v)}),y}function Ir(a,s){const d=Lr(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function Lr(a){if(!a)return;const s=a.parentElement;if(s&&s.tagName==="LABEL")return s;const d=a.id;if(d){const p=a.nextElementSibling;if(p&&p.htmlFor===d)return p}const l=a.labels;return l&&l[0]}const Rr=i.createContext(void 0);function Pr(){return i.useContext(Rr)}const Xa=i.createContext(void 0);function Br(){const a=i.useContext(Xa);if(a===void 0)throw new Error(bt(14));return a}const Dr="data-parent",Er=i.forwardRef(function(s,d){const{checked:l,className:p,defaultChecked:g=!1,"aria-labelledby":x,disabled:c=!1,form:y,id:v,indeterminate:f=!1,inputRef:N,name:I,onCheckedChange:u,parent:j=!1,readOnly:m=!1,render:C,required:P=!1,uncheckedValue:$,value:M,nativeButton:K=!1,style:de,...pe}=s,{clearErrors:ne}=Qt(),{disabled:B,name:fe,setDirty:_,setFilled:U,setFocused:q,setTouched:E,state:Z,validationMode:J,validityData:je,validation:ce}=Xt(),Pe=Sr(),{labelId:He,registerControlId:Be,getDescriptionProps:De}=Jt(),S=Pr(),L=S?.allValues===void 0?void 0:S.parent,H=L!==void 0,D=B||Pe.disabled||S?.disabled||c,ee=fe??I,R=M??ee,Ne=$a(),Ee=S?.registerControlId!==Be,ie=Yt({id:v||void 0,enabled:Ee}),Te=K?ie:Ne;let ue={};H&&(j?ue=L.getParentProps():R!==void 0&&(ue=L.getChildProps(R)));const{checked:Ae=l,indeterminate:Oe=f,onCheckedChange:Ge,...Ce}=ue,$e=S?.value,me=i.useRef(null),{getButtonProps:We,buttonRef:Me}=kt({disabled:D,native:K}),ae=S?.validation??ce,[T,Se]=Zt({controlled:R!==void 0&&$e!==void 0&&!j?$e.includes(R):Ae,default:g,name:"Checkbox",state:"checked"}),ge=H?!!Ae:T,G=H&&Oe||f;er(me,Ne,T,void 0,!S&&!D,I);const xe=L?.registerChildId,A=i.useRef(null),Ue=ae.registerInput,ye=S?R:void 0,_e=i.useCallback(k=>Ue(k,{controlRef:me,value:ye}),[Ue,ye]),ia=wt(N,A,j?void 0:_e),Qe=_r(x,He,A,!K,ie);ua(()=>{A.current&&(A.current.indeterminate=G),S||U(T)},[T,G,S,U]),rr(T,()=>{S||(ne(ee),_(T!==je.initialValue),ae.change(T))});const Xe=vt({checked:T,disabled:D,form:y,name:j?void 0:ee,id:K?void 0:ie,required:P,ref:ia,style:ee?St:_t,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(k){if(k.nativeEvent.defaultPrevented)return;if(m){k.preventDefault();return}const z=k.currentTarget.checked,oe=It(Lt,k.nativeEvent);if(u?.(z,oe),!oe.isCanceled&&(Ge?.(z,oe),!oe.isCanceled&&(Se(z),R!==void 0&&S!==void 0&&!j&&!H))){const te=z?[...S.value,R]:S.value.filter(Ie=>Ie!==R);S.setValue(te,oe)}},onClick(k){k.stopPropagation()},onFocus(){me.current?.focus()}},M!==void 0?{value:(S?T&&M:M)||""}:jt,De,k=>ae.getValidationProps(D,k));i.useEffect(()=>{if(!L||R===void 0)return;const k=L.disabledStatesRef.current;return k.set(R,D),()=>{k.delete(R)}},[L,D,R]);const F=i.useMemo(()=>({...Z,checked:ge,disabled:D,readOnly:m,required:P,indeterminate:G}),[Z,ge,D,m,P,G]),oa=Qa(F),Je=xa("span",s,{state:F,ref:[Me,me,d],props:[{id:Te,role:"checkbox","aria-checked":G?"mixed":ge,"aria-readonly":m||void 0,"aria-required":P||void 0,"aria-labelledby":Qe,[Dr]:j?"":void 0,onFocus(){D||q(!0)},onBlur(){const k=A.current;k&&(E(!0),q(!1),J==="onBlur"&&ae.commit(S?$e:k.checked))},onKeyDown(k){if(k.key!=="Enter"||(k.preventBaseUIHandler(),k.defaultPrevented))return;const z=A.current?.form??null,oe=k.currentTarget,te=k.nativeEvent,Ie=k.preventDefault,ze=te.preventDefault;let Ve=!1;k.preventDefault=()=>{Ve=!0,Ie.call(k)},te.preventDefault=()=>{Ve=!0,ze.call(te)},ze.call(te),Ct(oe).queueMicrotask(()=>{k.preventDefault=Ie,te.preventDefault=ze,Ve||vr(z)?.click()})},onClick(k){if(m||D)return;k.preventDefault();const z=A.current;z&&Nt(z,k)}},pe,Ce,We,De,k=>ae.getValidationProps(D,k)],stateAttributesMapping:oa}),Fe=Je.props.id;return ua(()=>{if(!(!xe||j||R===void 0||Fe===void 0))return xe(R,Fe)},[xe,j,R,Fe]),e.jsxs(Xa.Provider,{value:F,children:[Je,!T&&!S&&ee&&!j&&$!==void 0&&e.jsx("input",{type:"hidden",form:y,name:ee,value:$,disabled:D}),e.jsx("input",{...Xe,suppressHydrationWarning:!0})]})}),Tr=i.forwardRef(function(s,d){const{render:l,className:p,style:g,keepMounted:x=!1,...c}=s,y=Br(),v=y.checked||y.indeterminate,{mounted:f,transitionStatus:N,setMounted:I}=tr(v),u=i.useRef(null),j={...y,transitionStatus:N};Rt({batch:!0,enabled:!v,open:v,ref:u,onComplete(){v||I(!1)}});const C={...Qa(y),...Pt},P=x||f,$=xa("span",s,{ref:[d,u],state:j,stateAttributesMapping:C,props:c});return P?$:null});function Ar(a,s){return`target:${a}:${s}`}function Or(a){return`remove:${a.id||a.directory}`}function Ja(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function $r(a){const s=Ja(a);if(s==null)return null;if(s<=0)return r("skills.usage.today");if(s<30)return r("skills.usage.days_ago",{days:s});const d=Math.max(1,Math.floor(s/30));return r("skills.usage.months_ago",{months:d})}function Mr(a){const s=Ja(a);return s==null?"bg-oai-gray-300 dark:bg-oai-gray-600":s<=7?"bg-emerald-500":s<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function ca({label:a,children:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 text-sm",children:[e.jsx("dt",{className:"flex items-center gap-1 text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:s})]})}function Ur({skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:g,onUpdate:x,onClose:c,onToggleTarget:y,onRemove:v}){return e.jsx(qt,{children:a?e.jsx(Fr,{skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:g,onUpdate:x,onClose:c,onToggleTarget:y,onRemove:v},a.id||a.directory):null})}function Fr({skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:g,onUpdate:x,onClose:c,onToggleTarget:y,onRemove:v}){const f=Ht(),{currency:N,rate:I}=Kt(),u=i.useRef(null);i.useEffect(()=>{const _=q=>{q.key==="Escape"&&(q.stopPropagation(),c?.())},U=q=>{const E=q.target;E instanceof Element&&(u.current?.contains(E)||E.closest('[data-skill-row="1"]')||c?.())};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",U),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",U)}},[c]);const j=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),C=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,P=new Set(a.targets||[]),$=!!(a.readOnly||a.remote),M=!!a.remote,K=Array.isArray(a.deviceSources)?a.deviceSources:[],de=!M&&(!$||P.has("claude")),pe=d===Or(a),ne=$r(l?.lastUsedAt),B=!!(l&&l.invocations>0),fe=f?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(wa.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:f?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:f?0:.15},onClick:c,"aria-hidden":!0}),e.jsxs(wa.aside,{ref:u,role:"complementary","aria-label":j,initial:f?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:f?{opacity:0}:{opacity:0,x:24,scale:.98},transition:fe,className:"fixed inset-x-3 bottom-3 top-20 z-30 flex flex-col overflow-hidden rounded-2xl border border-white/40 bg-white/75 shadow-[0_24px_60px_-20px_rgba(15,23,42,0.25)] backdrop-blur-xl backdrop-saturate-150 supports-[backdrop-filter]:bg-white/65 dark:border-white/10 dark:bg-oai-gray-950/70 dark:shadow-[0_24px_60px_-20px_rgba(0,0,0,0.7)] dark:supports-[backdrop-filter]:bg-oai-gray-950/55 lg:inset-auto lg:right-6 lg:top-24 lg:bottom-6 lg:w-[22rem] lg:max-h-[calc(100vh-7.5rem)]",children:[e.jsxs("header",{className:"flex items-center gap-3 border-b border-white/40 bg-gradient-to-b from-white/30 to-transparent px-5 pb-4 pt-5 dark:border-white/10 dark:from-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",title:j,children:j}),m?e.jsxs("a",{href:C,target:"_blank",rel:"noreferrer noopener",className:"mt-1 inline-flex max-w-full items-center gap-1 truncate text-xs text-oai-gray-500 transition-colors hover:text-oai-black hover:underline dark:text-oai-gray-400 dark:hover:text-white",title:C,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(ma,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):a.directory&&a.directory!==j?e.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:a.directory,children:a.directory}):null]}),e.jsx("button",{type:"button",onClick:c,"aria-label":r("skills.detail.close"),className:"-mr-1 inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-oai-gray-500 transition hover:bg-oai-gray-100 hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(Le,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5",children:[p?e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-sky-50/80 px-3 py-2.5 ring-1 ring-sky-200 dark:bg-sky-950/30 dark:ring-sky-800/60",children:[e.jsx(ya,{className:"h-4 w-4 shrink-0 text-sky-600 dark:text-sky-300","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 text-xs text-sky-800 dark:text-sky-200",children:r("skills.update.available")}),e.jsxs("button",{type:"button",onClick:()=>x?.(a),disabled:g||!!d,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-sky-600 px-2.5 text-xs font-semibold text-white transition hover:bg-sky-700 focus:outline-none focus:ring-2 focus:ring-sky-400/40 disabled:cursor-not-allowed disabled:opacity-60 dark:bg-sky-500 dark:hover:bg-sky-400",children:[g?e.jsx(Y,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,r("skills.update.action")]})]}):null,a.description?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a.description}):null,$?e.jsx("div",{className:"mt-4 rounded-xl bg-oai-gray-50 px-3 py-2.5 text-xs leading-5 text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-900/60 dark:text-oai-gray-300 dark:ring-oai-gray-800",children:r(M?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed")}):null,a.sourceName?e.jsx("div",{className:"mt-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.source",{source:a.sourceName})}):null,K.length?e.jsxs("section",{className:"mt-5",children:[e.jsx("h3",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.devices_title")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:K.map(_=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 rounded-full bg-oai-gray-100 px-2.5 py-1 text-xs text-oai-gray-700 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-200 dark:ring-oai-gray-700",children:[e.jsx(Pa,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:_.name})]},_.id))})]}):null,de?e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.usage.section_title")}),e.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[e.jsx(ca,{label:r("skills.usage.invocations"),children:Bt(l?.invocations||0)}),e.jsx(ca,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:se("h-1.5 w-1.5 rounded-full",Mr(l?.lastUsedAt)),"aria-hidden":!0}),B?ne||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ca,{label:e.jsxs(e.Fragment,{children:[r("skills.usage.cost"),e.jsx("span",{title:r("skills.usage.disclaimer"),className:"inline-flex cursor-help text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(Ra,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:Dt(l?.cost||0,{currency:N,rate:I})})]}),B?null:e.jsx("p",{className:"mt-2 text-[11px] leading-4 text-oai-gray-400 dark:text-oai-gray-500",children:r("skills.usage.unused")})]}):null,$?null:e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.sync_section_title")}),e.jsx("div",{children:(s||[]).filter(_=>_.manageable!==!1).map(_=>{const U=P.has(_.id),q=d===Ar(a.id||a.directory,_.id),E=`skill-detail-sync-${a.id||a.directory}-${_.id}`;return e.jsxs("label",{htmlFor:E,className:"-mx-2 flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-oai-black transition-colors hover:bg-oai-gray-100/70 dark:text-white dark:hover:bg-white/[0.05]",children:[e.jsx(Er,{id:E,checked:U,disabled:!!d,onCheckedChange:Z=>y?.(a,_.id,!!Z),className:"peer flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border border-oai-gray-300/80 bg-white/80 shadow-sm transition-colors hover:border-oai-gray-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:border-oai-black data-[checked]:bg-oai-black dark:border-oai-gray-500/60 dark:bg-oai-gray-900/60 dark:hover:border-oai-gray-400 dark:data-[checked]:border-white dark:data-[checked]:bg-white",children:e.jsx(Tr,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(Re,{className:"h-3 w-3",strokeWidth:3.5,"aria-hidden":!0})})}),e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center","aria-hidden":!0,children:e.jsx(ve,{provider:_.id,size:16})}),e.jsx("span",{className:"flex-1",children:_.label}),q?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},_.id)})})]})]}),$?null:e.jsxs("footer",{className:"border-t border-white/40 bg-white/30 px-5 py-4 dark:border-white/10 dark:bg-white/[0.02]",children:[e.jsxs("button",{type:"button",onClick:()=>v?.(a),disabled:!!d,className:"inline-flex w-full items-center justify-center gap-2 rounded-lg border border-red-200/70 bg-white px-3 py-2 text-sm font-medium text-red-600 transition hover:border-red-300 hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-red-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-900/60 dark:bg-oai-gray-950 dark:text-red-300 dark:hover:border-red-800 dark:hover:bg-red-950/30",children:[pe?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.detail.remove_button")]}),e.jsx("p",{className:"mt-2 text-center text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.remove_confirm_hint")})]})]})]})}const zr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),_a=["claude","codex"],Q="popular",Vr={claude:"text-orange-500 dark:text-orange-300",codex:"text-emerald-600 dark:text-emerald-300",grok:"text-zinc-700 dark:text-zinc-200",antigravity:"text-violet-600 dark:text-violet-300",gemini:"text-sky-600 dark:text-sky-300",opencode:"text-amber-600 dark:text-amber-300",hermes:"text-indigo-500 dark:text-indigo-300"},he="all",V="skillssh";function na(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Ya(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function Kr(a){return Ya(a).split("/").filter(Boolean).pop()||""}function qr(a){if(a.repoOwner||a.repoName)return"";const s=Ya(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Ia(a){const s=Kr(a.directory);return s?`dir:${s}`:""}function Za(a){const s=new Set([na(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=qr(a);return d&&s.add(d),s}function Hr(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function Gr(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Hr(d))for(const l of Za(d))s.add(l);return s}function aa(a){return`install:${na(a)}`}function La(a){return`remove:${a.id||a.directory}`}function et(a,s){return`target:${a}:${s}`}function we(a){return a.id||a.directory}function ba(a){return a.manageable!==!1}function Wr({target:a,state:s,busy:d,disabled:l,disabledLabel:p,onToggle:g}){const x=s==="synced",c=s==="orphan",y=c?r("skills.dot.orphan_aria",{agent:a.label}):x?r("skills.dot.synced_aria",{agent:a.label}):r("skills.dot.off_aria",{agent:a.label}),v=l&&p?`${y} — ${p}`:y;return e.jsxs("button",{type:"button",title:v,"aria-label":v,"aria-pressed":x,disabled:d||l,onClick:f=>{f.stopPropagation(),g?.(a.id,!x)},className:"relative flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/40 disabled:cursor-not-allowed dark:hover:bg-oai-gray-800/60",children:[d?e.jsx(Y,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:se("flex h-[18px] w-[18px] items-center justify-center transition",x&&Vr[a.id],!x&&!c&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(ve,{provider:a.id,size:18})}),c&&!d?e.jsx("span",{className:"absolute -bottom-px -right-px h-2 w-2 rounded-full bg-amber-500 ring-2 ring-oai-white dark:ring-oai-gray-900","aria-hidden":!0}):null]})}function Qr({skill:a,targets:s,onToggleTarget:d,busyKey:l}){const p=new Set(a.targets||[]),g=!!(a.readOnly||a.remote),x=[];for(const c of s)(g?p.has(c.id):ba(c))&&x.push(c);return e.jsx("div",{className:"flex items-center gap-1",onClick:c=>c.stopPropagation(),children:x.map(c=>e.jsx(Wr,{target:c,state:a.targetStates?.[c.id]||"off",busy:l===et(we(a),c.id),disabled:g||c.manageable===!1,disabledLabel:r(a.remote?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed"),onToggle:(y,v)=>d?.(a,y,v)},c.id))})}function Xr({skill:a,targets:s,selected:d,onSelect:l,selectable:p,checked:g,onToggleSelect:x,onToggleTarget:c,hasUpdate:y,busyKey:v}){const f=a.repoOwner&&a.repoName?`${a.repoOwner}/${a.repoName}`:null,N=[a.directory,f,a.sourceName].filter(Boolean).join(" · "),I=Array.isArray(a.deviceSources)?a.deviceSources:[],u=[a.remote?r("skills.inventory.remote"):null,a.scope==="plugin"?r("skills.inventory.plugin"):null].filter(Boolean),j=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),l?.(a))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":d,"aria-label":r("skills.row.open_details",{name:a.name||a.directory}),onClick:()=>l?.(a),onKeyDown:j,className:se("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",d?"bg-oai-gray-100 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800/60 dark:ring-oai-gray-800":g?"bg-oai-gray-50 dark:bg-oai-gray-900/40":"hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[p?e.jsx("label",{className:"flex shrink-0 items-center",onClick:m=>m.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:g,onChange:m=>x?.(a,m.target.checked),"aria-label":r("skills.select.row_aria",{name:a.name||a.directory}),className:"h-4 w-4 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white"})}):null,e.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-oai-black dark:text-white",title:N,children:a.name||a.directory}),u.map(m=>e.jsx("span",{className:"inline-flex shrink-0 rounded-full bg-oai-gray-100 px-1.5 py-0.5 text-[10px] font-semibold text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-300 dark:ring-oai-gray-700",children:m},m)),y?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-semibold text-sky-700 ring-1 ring-sky-200 dark:bg-sky-950/40 dark:text-sky-300 dark:ring-sky-800/60",children:[e.jsx(ya,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Qr,{skill:a,targets:s,onToggleTarget:c,busyKey:v}),e.jsx(Ut,{className:se("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",d&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),a.description?e.jsx("p",{className:se("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",p&&"pl-7"),children:a.description}):null,a.sourceName||I.length?e.jsxs("div",{className:se("mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",p&&"pl-7"),children:[a.sourceName?e.jsx("span",{className:"truncate",children:a.sourceName}):null,I.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:I.map(m=>m.name).join(", "),children:[e.jsx(Pa,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:I.map(m=>m.name).join(", ")})})]}):null]}):null]})}function Jr({agentFilter:a,agentOptions:s,onAgentFilter:d,filteredCount:l,totalCount:p,anyFilter:g,onClearFilters:x,searchQuery:c,onSearchQuery:y,searchPlaceholder:v}){return 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.jsxs(Ba,{value:a,onValueChange:d,children:[e.jsxs(Da,{"aria-label":r("skills.filter.agent_label"),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200 dark:hover:border-oai-gray-700",children:[e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:[r("skills.filter.agent_label"),":"]}),e.jsx(Ea,{children:f=>f==="all"?r("skills.filter.agent_all"):s.find(N=>N.id===f)?.label||f}),e.jsx(Ga,{className:"text-oai-gray-400",children:e.jsx(fa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ta,{children:e.jsx(Aa,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Oa,{className:"min-w-[var(--anchor-width)] 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(ta,{value:"all",className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:r("skills.filter.agent_all")}),e.jsx(sa,{children:e.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(f=>e.jsxs(ta,{value:f.id,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{provider:f.id,size:14}),e.jsx(ra,{children:f.label})]}),e.jsx(sa,{children:e.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},f.id))]})})})]}),e.jsxs("div",{className:"relative w-56 max-w-full",children:[e.jsx(ga,{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(ha,{type:"search",value:c,onChange:f=>y(f.target.value),onKeyDown:f=>{f.key==="Escape"&&c&&(f.preventDefault(),y(""))},"aria-label":r("skills.action.search_aria"),placeholder:v,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:f=>f.preventDefault(),onClick:()=>y(""),"aria-label":r("skills.action.search_clear"),"aria-hidden":!c,tabIndex:c?0:-1,className:se("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 before:absolute before:-inset-1.5 before:content-[''] 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 motion-reduce:transition-none dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",c?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{role:"status","aria-live":"polite",className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.filter.result_count",{filtered:l,total:p})}),g?e.jsxs("button",{type:"button",onClick:x,className:"shrink-0 inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Le,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Yr({count:a,targets:s,busy:d,onBulkSync:l,onBulkRemove:p,onClear:g}){const x=s.filter(ba);return e.jsxs("div",{role:"toolbar","aria-label":r("skills.select.toolbar_aria"),className:"mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/50",children:[e.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200","aria-live":"polite",children:r("skills.select.count",{count:a})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(Fa,{children:[e.jsxs(za,{disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:[e.jsx(Ua,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(fa,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Va,{children:e.jsx(Ka,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(qa,{className:"min-w-[200px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.select.bulk_sync_hint")}),x.map(c=>e.jsxs("button",{type:"button",onClick:()=>l(c.id),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx(ve,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(X,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:p,children:[e.jsx(pa,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_remove")]}),e.jsxs("button",{type:"button",onClick:g,className:"inline-flex h-7 items-center gap-1 rounded-full px-2 text-[11px] font-medium text-oai-gray-500 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",children:[e.jsx(Le,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Zr({items:a,totalCount:s,targets:d,agentOptions:l,agentFilter:p,onAgentFilter:g,anyFilter:x,onClearFilters:c,searchQuery:y,onSearchQuery:v,searchPlaceholder:f,selectedId:N,onSelect:I,onToggleTarget:u,busyKey:j,updates:m,selectedIds:C,onToggleSelect:P,onClearSelection:$,onBulkSync:M,onBulkRemove:K,updateCount:de,onUpdateAll:pe}){const ne=C.size;return e.jsxs("div",{children:[ne>0?e.jsx(Yr,{count:ne,targets:d,busy:j==="batch",onBulkSync:M,onBulkRemove:K,onClear:$}):e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx(Jr,{agentFilter:p,agentOptions:l,onAgentFilter:g,filteredCount:a.length,totalCount:s,anyFilter:x,onClearFilters:c,searchQuery:y,onSearchQuery:v,searchPlaceholder:f}),de?e.jsxs(X,{type:"button",variant:"secondary",size:"sm",className:"mb-2 shrink-0",disabled:!!j,onClick:pe,children:[j==="update-all"?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ya,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.update.all_action",{count:de})]}):null]}),a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r("skills.empty.no_match")}),e.jsx(X,{type:"button",variant:"secondary",size:"sm",onClick:c,children:r("skills.filter.clear")})]}):e.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(B=>e.jsx(Xr,{skill:B,targets:d,selected:N===(B.id||B.directory),onSelect:I,selectable:!B.readOnly&&!B.remote,checked:C.has(we(B)),onToggleSelect:P,onToggleTarget:u,hasUpdate:!!(B.id&&m?.[B.id]),busyKey:j},we(B)))})]})}const es={contentVisibility:"auto",containIntrinsicSize:"0 240px"},as=Mt.memo(function({skill:s,installed:d,installing:l,allTargets:p,defaultTargets:g,onInstall:x,onManage:c}){const[y,v]=i.useState(()=>(g||[]).filter(m=>p.some(C=>C.id===m))),f=m=>{v(C=>C.includes(m)?C.filter(P=>P!==m):[...C,m])},N=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,I=N?`https://github.com/${s.repoOwner}/${s.repoName}`:null,u=s.installs!=null?r("skills.card.installs",{count:Number(s.installs||0).toLocaleString()}):null,j=y.length?y.map(m=>p.find(C=>C.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(zt,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[s.readmeUrl?e.jsxs("a",{href:s.readmeUrl,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex max-w-full items-center gap-1 truncate text-base font-semibold text-oai-black hover:underline dark:text-white",title:s.readmeUrl,children:[e.jsx("span",{className:"truncate",children:s.name||s.directory}),e.jsx(ma,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:s.name||s.directory}),N||u?e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[I?e.jsxs("a",{href:I,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"inline-flex items-center gap-1 truncate rounded text-oai-gray-500 hover:text-oai-black hover:underline focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",title:I,children:[e.jsx("span",{className:"truncate",children:N}),e.jsx(ma,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,N&&u?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,u?e.jsx("span",{className:"truncate",children:u}):null]}):null]})}),s.description?e.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s.description}):null,e.jsx("div",{className:"mt-auto pt-5",children:d?e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>c?.(s),className:"w-full",children:[e.jsx(Re,{className:"mr-1.5 h-3.5 w-3.5 text-emerald-500 dark:text-emerald-400","aria-hidden":!0}),r("skills.card.manage")]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.card.targets_prefix")}),e.jsx("span",{className:"min-w-0 truncate font-medium text-oai-black dark:text-white",children:y.length?j:r("skills.target.none")}),e.jsxs(Fa,{children:[e.jsx(za,{disabled:l,"aria-label":r("skills.action.choose_targets"),className:"rounded text-xs font-medium text-oai-gray-500 underline decoration-oai-gray-300 decoration-dotted underline-offset-2 transition hover:text-oai-black hover:decoration-oai-gray-500 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:text-oai-gray-400 dark:decoration-oai-gray-600 dark:hover:text-white dark:hover:decoration-oai-gray-400",children:r("skills.card.targets_change")}),e.jsx(Va,{children:e.jsx(Ka,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(qa,{className:"min-w-[220px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.target.menu_label")}),p.map(m=>{const C=y.includes(m.id);return e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 shrink-0 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white",checked:C,onChange:()=>f(m.id)}),e.jsx(ve,{provider:m.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:m.label})]},m.id)})]})})})]})]}),e.jsxs(X,{type:"button",size:"sm",onClick:()=>x(s,y),disabled:l||y.length===0,className:"w-full",children:[l?e.jsx(Y,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Ua,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function ts({repos:a,repoInput:s,onRepoInput:d,busyKey:l,onAdd:p,onRemove:g}){return e.jsxs("div",{className:"rounded-lg border border-oai-gray-200 bg-white p-4 dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx(ha,{value:s,onChange:x=>d(x.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(X,{type:"button",variant:"secondary",size:"md",onClick:p,disabled:l==="repo:add",className:"shrink-0 whitespace-nowrap",children:[l==="repo:add"?e.jsx(Y,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Ma,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.repo.add")]})]}),a.length?e.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(x=>{const c=l===`repo:${x.owner}/${x.name}`;return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[x.owner,"/",x.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:x.branch})]}),e.jsxs(X,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>g(x),className:"shrink-0",children:[c?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${x.owner}/${x.name}`)})}):null]})}function rs(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Ds(){const a=Et()||{},s=!!a.signedIn,d=a.getAccessToken,[l,p]=i.useState(rs),[g,x]=i.useState({skills:[],targets:[]}),[c,y]=i.useState([]),[v,f]=i.useState([]),[N,I]=i.useState([]),[u,j]=i.useState(he),[m,C]=i.useState(""),[P,$]=i.useState(""),[M,K]=i.useState(""),[de,pe]=i.useState(""),[ne,B]=i.useState(""),[fe,_]=i.useState(!1),[U,q]=i.useState("all"),[E,Z]=i.useState(null),[J,je]=i.useState(""),ce=i.useRef(!1),[Pe,He]=i.useState(!0),[Be,De]=i.useState(!1),[S,L]=i.useState(""),[H,D]=i.useState(null),[ee,R]=i.useState(null),[Ne,Ee]=i.useState(null),[ie,Te]=i.useState(()=>new Set),[ue,Ae]=i.useState({}),[Oe,Ge]=i.useState({}),[Ce,$e]=i.useState([]),[me,We]=i.useState(!1),Me=i.useRef(!1),ae=i.useRef(0),T=i.useMemo(()=>Gr(g.skills),[g.skills]),Se=i.useCallback(async()=>{const t=++ae.current,n=await sr();if(ae.current!==t)return;const o={skills:n.skills||[],targets:n.targets||[]};x(o);const h=Tt();!s||!At()||!h||typeof d!="function"||(async()=>{try{const b=await d();if(!b||ae.current!==t)return;const[w]=await Promise.allSettled([nr(b),ir({accessToken:b,deviceId:h,skills:o.skills})]);if(w.status!=="fulfilled")return;const ke=w.value;if(ae.current!==t)return;x({targets:o.targets,skills:or(o.skills,ke,h)})}catch{}})()},[d,s]),ge=i.useCallback(async()=>{const t=await lr();I(t.repos||[])},[]),G=i.useCallback(async({force:t=!1}={})=>{De(!0);try{const n=await dr({force:t});y(n.skills||[])}finally{De(!1)}},[]),xe=i.useCallback(async({force:t=!1}={})=>{We(!0);try{const n=await cr({force:t});$e(n.skills||[])}finally{We(!1)}},[]),A=i.useCallback(async()=>{try{const t=await ur();Ae(t?.updates||{})}catch{}},[]),Ue=i.useCallback(t=>{const n=new Set((t||[]).filter(Boolean));n.size&&Ae(o=>{if(!Object.keys(o).some(b=>n.has(b)))return o;const h={};for(const[b,w]of Object.entries(o))n.has(b)||(h[b]=w);return h})},[]),ye=i.useCallback(async()=>{try{const t=await mr(),n={};for(const o of t?.skills||[])o.installed&&(o.directory&&(n[String(o.directory).toLowerCase()]=o),n[String(o.skill).toLowerCase()]=o);Ge(n)}catch{Ge({})}},[]),_e=i.useCallback(async()=>{He(!0),L("");try{await Promise.all([Se(),ge()])}catch(t){L(t?.message||r("skills.error.generic"))}finally{He(!1)}},[Se,ge]),ia=i.useCallback(async()=>{await _e();const t=n=>L(n?.message||r("skills.error.generic"));l==="my"?(A(),ye()):u===Q?xe({force:!0}).catch(t):u!==V&&G({force:!0}).catch(t)},[G,_e,xe,A,ye,u,l]);i.useEffect(()=>{_e()},[_e]),i.useEffect(()=>{if(Me.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){Me.current=!0;return}const o=g.skills||[];if(!o.length)return;const h=o.find(w=>w.directory===n||w.id===n);h&&(p("my"),Z(h.id||h.directory)),Me.current=!0,t.delete("skill");const b=t.toString();window.history.replaceState({},"",`${window.location.pathname}${b?`?${b}`:""}${window.location.hash}`)},[g.skills]),i.useEffect(()=>{l==="browse"&&(u===V||u===Q||c.length===0&&G().catch(t=>L(t?.message||r("skills.error.generic"))))},[c.length,G,u,l]),i.useEffect(()=>{l!=="browse"||u!==Q||Ce.length===0&&xe().catch(t=>L(t?.message||r("skills.error.generic")))},[xe,Ce.length,u,l]);const Qe=Object.keys(ue).length>0,Xe=Object.keys(Oe).length>0;if(i.useEffect(()=>{l==="my"&&(Qe||A(),Xe||ye())},[l,Qe,Xe,A,ye]),i.useEffect(()=>{const t=setTimeout(()=>$(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>pe(M),120);return()=>clearTimeout(t)},[M]),i.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("tab");if(l==="my"){if(!n)return;t.delete("tab")}else{if(n===l)return;t.set("tab",l)}const o=t.toString(),h=`${window.location.pathname}${o?`?${o}`:""}${window.location.hash}`;window.history.replaceState({},"",h)},[l]),!zr&&!Ot())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Ft,{})});const F=async(t,n)=>{if(!ce.current){ce.current=!0,je(t),L("");try{await n(),await Se()}catch(o){L(o?.message||r("skills.error.generic"))}finally{ce.current=!1,je("")}}},oa=(t,n)=>{const o=(n&&n.length?n:_a).filter(h=>(g.targets||[]).some(b=>b.id===h));F(aa(t),async()=>{await xr(t,o);const h=o.map(b=>(g.targets||[]).find(w=>w.id===b)?.label||b).join(", ");W({title:r("skills.toast.installed",{name:t.name||t.directory,targets:h||r("skills.target.none")}),timeout:4e3})})},Je=t=>{t?.readOnly||t?.remote||D(t)},Fe=()=>{const t=H;t&&(D(null),F(La(t),async()=>{let n=null;t.managed?n=await va(t.id):await ja(t.directory,t.targets||[]),Ue([t.id]);const o=!!(n?.trashed&&t.managed&&t.id);W({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:o?{onUndo:async()=>{try{await hr(t.id),await Se()}catch(h){L(h?.message||r("skills.error.generic"))}}}:void 0})}))},k=(t,n,o)=>t?.readOnly||t?.remote?Promise.resolve():F(et(we(t),n),async()=>{const h=new Set(t.targets||[]);o?h.add(n):h.delete(n),t.managed?await Na(t.id,Array.from(h)):await Ca(t.directory,Array.from(h));const b={name:t.name||t.directory,agent:te(n)};W({title:o?r("skills.toast.synced_one",b):r("skills.toast.unsynced_one",b),timeout:3e3})}),z=i.useCallback(()=>Te(new Set),[]),oe=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const o=we(t);Te(h=>{const b=new Set(h);return n?b.add(o):b.delete(o),b})},[]),te=t=>(g.targets||[]).find(n=>n.id===t)?.label||t,Ie=t=>{const n=(g.skills||[]).filter(o=>ie.has(we(o))&&!o.readOnly&&!o.remote);n.length&&F("batch",async()=>{for(const o of n){const h=new Set(o.targets||[]);h.add(t),o.managed?await Na(o.id,Array.from(h)):await Ca(o.directory,Array.from(h))}z(),W({title:r("skills.toast.bulk_synced",{count:n.length,agent:te(t)}),timeout:4e3})})},ze=()=>{const t=(g.skills||[]).filter(n=>ie.has(we(n))&&!n.readOnly&&!n.remote);t.length&&R(t)},Ve=()=>{const t=ee;t&&(R(null),F("batch",async()=>{for(const n of t)n.managed?await va(n.id):await ja(n.directory,n.targets||[]);Ue(t.map(n=>n.id)),z(),W({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},at=t=>{!t?.id||!t?.repoOwner||!t?.repoName||F(aa(t),async()=>{const n=await Sa([t.id]);await A();const{results:o=[],rateLimited:h=null,updated:b=0}=n||{};if(h){W({title:r("skills.update.rate_limited",{count:b}),timeout:6e3});return}const w=o[0];if(!w||!w.ok)throw new Error(w?.error||r("skills.error.generic"));W({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},tt=new Set((g.skills||[]).map(t=>t.id).filter(Boolean)),la=Object.entries(ue).filter(([t,n])=>n&&tt.has(t)).map(([t])=>t),rt=la.length,st=()=>{la.length&&Ee(la)},nt=()=>{const t=Ne;Ee(null),!(!t||!t.length)&&F("update-all",async()=>{const n=await Sa(t);await A();const{updated:o=0,failed:h=0,rateLimited:b=null,results:w=[]}=n||{},ke=w.length;if(b)W({title:r("skills.update.rate_limited",{count:o}),timeout:6e3});else if(h>0)W({title:r("skills.toast.updated_partial",{count:o,total:ke,failed:h}),timeout:6e3});else if(o===0)W({title:r("skills.toast.updated_none"),timeout:4e3});else if(o===1){const O=w.find(ea=>ea.ok&&!ea.skipped);W({title:r("skills.toast.updated",{name:O?.name||""}),timeout:4e3})}else W({title:r("skills.toast.updated_many",{count:o}),timeout:4e3})})},ka=async()=>{const t=m.trim();if(!(t.length<2||ce.current)){ce.current=!0,je("search"),L("");try{const n=await gr(t);f(n.skills||[])}catch(n){L(n?.message||r("skills.error.generic"))}finally{ce.current=!1,je("")}}},it=async()=>{const t=ne.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,o]=t.split("/");if(!n||!o){L(r("skills.repo.invalid"));return}await F("repo:add",async()=>{await fr({owner:n,name:o,branch:"main",enabled:!0}),B(""),await ge(),await G()})},ot=async t=>{await F(`repo:${t.owner}/${t.name}`,async()=>{await pr(t.owner,t.name),await ge(),await G()})},le=g.targets||[],lt=le.filter(ba),be=g.skills||[],dt=i.useMemo(()=>{const t=U==="all"?be:be.filter(o=>(o.targets||[]).includes(U)),n=de.trim().toLowerCase();return n?t.filter(o=>(o.name||"").toLowerCase().includes(n)||(o.directory||"").toLowerCase().includes(n)||(o.description||"").toLowerCase().includes(n)):t},[be,U,de]),ct=U!=="all",re=i.useMemo(()=>E&&be.find(t=>(t.id||t.directory)===E)||null,[be,E]),ut=i.useCallback(()=>{q("all"),K("")},[]),mt=i.useCallback(t=>{Z(n=>{const o=t?.id||t?.directory||null;return n===o?null:o})},[]),gt=i.useCallback(()=>Z(null),[]),xt=i.useCallback(t=>{const n=na(t).toLowerCase(),o=Ia(t),h=(g.skills||[]).find(b=>{const w=Za(b);return w.has(n)||o&&w.has(o)});h&&Z(h.id||h.directory)},[g.skills]);i.useEffect(()=>{l!=="my"&&ie.size&&Te(new Set)},[l,ie.size]),i.useEffect(()=>{E&&!re&&Z(null)},[re,E]);const Ke=i.useMemo(()=>{const t=u===V?v:u===Q?Ce:c,o=u===V||u===Q||u===he?t:t.filter(w=>`${w.repoOwner}/${w.repoName}`===u),h=P.trim().toLowerCase();return(u===V||!h?o:o.filter(w=>(w.name||"").toLowerCase().includes(h)||(w.directory||"").toLowerCase().includes(h)||(w.description||"").toLowerCase().includes(h))).map(w=>{const ke=na(w).toLowerCase(),O=Ia(w);return{...w,installed:T.has(ke)||O&&T.has(O)}})},[P,c,T,Ce,v,u]),ht=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(Y,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),pt=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(Y,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),e.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.browse.loading_hint")})]}),Ye=(t,n=null)=>e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r(t)}),n]});let Ze;if(Pe)Ze=ht;else if(l==="my")Ze=be.length?e.jsx(Zr,{items:dt,totalCount:be.length,targets:le,agentOptions:le,agentFilter:U,onAgentFilter:q,anyFilter:ct,onClearFilters:ut,searchQuery:M,onSearchQuery:K,searchPlaceholder:r("skills.my.placeholder"),selectedId:E,onSelect:mt,onToggleTarget:k,busyKey:J,updates:ue,selectedIds:ie,onToggleSelect:oe,onClearSelection:z,onBulkSync:Ie,onBulkRemove:ze,updateCount:rt,onUpdateAll:st}):e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-800",children:[le.length>0?e.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)",WebkitMaskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ve,{provider:t.id,size:30})},`b-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)",WebkitMaskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ve,{provider:t.id,size:30})},`c-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-oai-white to-transparent dark:from-oai-gray-900"}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-oai-white to-transparent dark:from-oai-gray-900"})]}):null,e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.empty.my")}),e.jsx(X,{type:"button",size:"sm",onClick:()=>p("browse"),children:r("skills.empty.my_cta")})]});else{const t=u===V,n=u===Q,o=N.length===0&&!t&&!n,h=Be&&!t&&!n||n&&me,b=!t&&!n&&(P.trim()!==""||u!==he),w=()=>{C(""),j(he)},ke=!o&&!h&&(Ke.length>0||b)?e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 px-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("skills.filter.result_count_browse",{count:Ke.length})}),b?e.jsxs("button",{type:"button",onClick:w,className:"ml-auto inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Le,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let O;o?O=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:e.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:r("skills.browse.empty_sources")})}):h?O=pt:t&&m.trim().length<2?O=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 px-4 py-6 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:r("skills.browse.hint_skillssh")}):Ke.length?O=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Ke.map(qe=>e.jsx("div",{style:es,children:e.jsx(as,{skill:qe,installed:!!qe.installed,installing:J===aa(qe),allTargets:lt,defaultTargets:_a,onInstall:oa,onManage:xt})},qe.id||qe.key))}):b?O=Ye("skills.empty.no_match",e.jsx(X,{type:"button",variant:"secondary",size:"sm",onClick:w,children:r("skills.filter.clear")})):t?O=Ye("skills.empty.search"):n?O=Ye("skills.empty.popular"):O=Ye("skills.empty.browse");const ea=o||fe?e.jsx("div",{className:"mb-5",children:e.jsx(ts,{repos:N,repoInput:ne,onRepoInput:B,busyKey:J,onAdd:it,onRemove:ot})}):null,ft=!fe&&!t&&!n&&N.length<=1&&Ke.length>0?e.jsx(wr,{id:"skills-browse-intro",className:"mt-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{children:r("skills.browse.add_repo_hint")}),e.jsx("button",{type:"button",onClick:()=>_(!0),className:"rounded font-medium text-oai-gray-700 underline decoration-dotted underline-offset-2 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-200 dark:hover:text-white",children:r("skills.browse.manage_sources")})]})}):null;Ze=e.jsxs(e.Fragment,{children:[ea,ke,O,ft]})}return e.jsxs("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:[e.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:r("skills.page.title")}),e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:ia,disabled:Pe||Be||me,children:[e.jsx($t,{className:se("mr-1.5 h-3.5 w-3.5",(Pe||Be||me)&&"animate-spin"),"aria-hidden":!0}),r("skills.action.refresh")]})]}),e.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",r("skills.tab.my")],["browse",r("skills.tab.browse")]].map(([t,n])=>e.jsx("button",{type:"button","aria-pressed":l===t,onClick:()=>p(t),className:se("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",l===t?"border-oai-black text-oai-black dark:border-white dark:text-white":"border-transparent text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:n},t))}),S?e.jsx("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-200",children:S}):null,l==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx(Vt,{className:"shrink-0",ariaLabel:r("skills.source.label"),options:[{id:"repo",label:r("skills.mode.repo")},{id:"popular",label:r("skills.mode.popular"),icon:e.jsx(yr,{className:"h-3.5 w-3.5","aria-hidden":!0})},{id:"skillssh",label:r("skills.mode.skillssh")}],value:u===V?"skillssh":u===Q?"popular":"repo",onChange:t=>{t==="skillssh"?j(V):t==="popular"?j(Q):(u===V||u===Q)&&j(he)}}),u!==V&&u!==Q?e.jsxs(Ba,{value:u,onValueChange:j,children:[e.jsxs(Da,{"aria-label":r("skills.source.label"),className:"inline-flex h-8 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs text-oai-black focus:outline-none data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:data-[popup-open]:border-oai-gray-700",children:[e.jsx(Ea,{children:t=>t===he?r("skills.source.all"):t}),e.jsx(Ga,{className:"text-oai-gray-400",children:e.jsx(fa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ta,{children:e.jsx(Aa,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Oa,{className:"min-w-[var(--anchor-width)] 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 transition-[opacity,transform] duration-150 ease-out data-[ending-style]:scale-[0.97] data-[ending-style]:opacity-0 data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0 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(ta,{value:he,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:r("skills.source.all")}),e.jsx(sa,{children:e.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),N.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(ta,{value:n,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:n}),e.jsx(sa,{children:e.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ga,{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(ha,{type:"search",value:m,onChange:t=>C(t.target.value),onKeyDown:t=>{t.key==="Enter"&&u===V&&ka()},"aria-label":r("skills.action.search_aria"),placeholder:u===V?r("skills.browse.placeholder_skillssh"):u===Q?r("skills.browse.placeholder_popular"):u===he?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:u}),className:"h-8 pl-9 !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"})]}),u===V?e.jsxs(X,{type:"button",size:"sm",onClick:ka,disabled:m.trim().length<2||J==="search",className:"focus:!ring-oai-gray-400/30",children:[J==="search"?e.jsx(Y,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(ga,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):u===Q?null:e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>_(t=>!t),"aria-expanded":fe,className:"!h-8 shrink-0 whitespace-nowrap !border-oai-gray-200 dark:!border-oai-gray-800 hover:!border-oai-gray-300 dark:hover:!border-oai-gray-700 hover:!text-oai-black dark:hover:!text-white focus:!ring-oai-gray-400/30",children:[e.jsx(Ma,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.browse.manage_sources"),e.jsx("span",{className:"ml-1.5 rounded bg-oai-gray-100 px-1.5 py-0.5 text-xs font-medium text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:N.length})]})]}):null,Ze,e.jsx(Ur,{skill:re,targets:le,busyKey:J,usage:re&&(Oe[String(re.directory||"").toLowerCase()]||Oe[String(re.name||"").toLowerCase()])||null,hasUpdate:!!(re?.id&&ue?.[re.id]),updating:re?J===aa(re):!1,onUpdate:at,onClose:gt,onToggleTarget:k,onRemove:Je})]})}),e.jsx(da,{open:!!H,title:r("skills.confirm.remove_title",{name:H?.name||H?.directory||""}),description:H?H.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:J===La(H||{}),onCancel:()=>D(null),onConfirm:Fe}),e.jsx(da,{open:!!ee,title:r("skills.confirm.bulk_remove_title",{count:ee?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:J==="batch",onCancel:()=>R(null),onConfirm:Ve}),e.jsx(da,{open:!!Ne,title:r("skills.confirm.update_all_title",{count:Ne?.length||0}),description:r("skills.confirm.update_all_desc"),confirmLabel:r("skills.update.action"),cancelLabel:r("shared.action.cancel"),onCancel:()=>Ee(null),onConfirm:nt})]})}export{Ds as SkillsPage,Gr as buildLocallyInstalledKeys};