tokentracker-cli 0.97.2 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/AchievementBadge-kRsjlB3p.js +1 -0
- package/dashboard/dist/assets/{AchievementsPage-CnkSNpJx.js → AchievementsPage-C3xybY0k.js} +2 -2
- package/dashboard/dist/assets/AchievementsSection-y5mok2w0.js +1 -0
- package/dashboard/dist/assets/{BadgeDetailModal-BJBrgn24.js → BadgeDetailModal-IFLXYuKp.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-BJM20N9T.js → BotAnimated-D6x0PDt2.js} +1 -1
- package/dashboard/dist/assets/{Card-BRWOMoBk.js → Card-CiKwEyVu.js} +1 -1
- package/dashboard/dist/assets/{ClawdAnimated-CtX8cne4.js → ClawdAnimated-BQFcAIOy.js} +2 -2
- package/dashboard/dist/assets/CommandPalette-BvpX8PM_.js +1 -0
- package/dashboard/dist/assets/CommunityStatsModal-D5rNlwfO.js +1 -0
- package/dashboard/dist/assets/{ConfirmModal-ZZXg_OLV.js → ConfirmModal-CR0Evu8-.js} +1 -1
- package/dashboard/dist/assets/{Controls-VDvgw_ed.js → Controls-lyLUkbJW.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-X8CLr_au.js +1 -0
- package/dashboard/dist/assets/{DevicePage-CP5m8azV.js → DevicePage-RCIANm45.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-8pTCallP.js → DialogClose-Bplj_718.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-C2EzE7DU.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-BWYdq4TT.js → DialogTitle-Ckzf1tdi.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-CEJfaKnL.js → FadeIn-C2Jqe95f.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-Bg2vijF8.js → HeaderGithubStar-DgE7Cd5u.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-B03JQ3PO.js → HoverTooltip-CEmo0N-P.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-DYZucBOf.js → IpCheckPage-BwkpsLaF.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-m-byhnVx.js → LandingPage-CA2klwbE.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardAvatar-JtGhJC1s.js → LeaderboardAvatar-B_PUenGZ.js} +1 -1
- package/dashboard/dist/assets/LeaderboardPage-D6HGW3jX.js +2 -0
- package/dashboard/dist/assets/{LeaderboardProfileModal-Cm4DDrcY.js → LeaderboardProfileModal-Bfo1dSsS.js} +4 -4
- package/dashboard/dist/assets/{LeaderboardProfilePage-bKbMm856.js → LeaderboardProfilePage-2OqwrqOs.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-B271tZOj.js → LimitsPage-BHrkLXHZ.js} +5 -5
- package/dashboard/dist/assets/{LocalOnlyNotice-DKIxuBP0.js → LocalOnlyNotice-C45MmWYt.js} +1 -1
- package/dashboard/dist/assets/LoginCard-BikBibax.js +1 -0
- package/dashboard/dist/assets/{LoginModal-PxTgIoLk.js → LoginModal-D0Aq85Zg.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-uEUnU7NP.js → LoginPage-B-kQaDQ_.js} +1 -1
- package/dashboard/dist/assets/PetPage-ZgPREiwD.js +1 -0
- package/dashboard/dist/assets/{PopoverPopup-DWIMb8D6.js → PopoverPopup-eQgg3h1i.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-DqqwXu3b.js → ProviderIcon-nDBPxn0N.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-BVuJTR9A.js → ResetPasswordPage-CjsOtiGr.js} +1 -1
- package/dashboard/dist/assets/{SegmentedControl-iHtWKWtc.js → SegmentedControl-6NcttkEH.js} +1 -1
- package/dashboard/dist/assets/{Select-Cr9wq8mD.js → Select-CzEhPICe.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-BWnP4yuq.js → SelectItemText-BwvzfXwj.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-DLuiUUYV.js → ServiceStatusPage-C35wpxrT.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-CBAH4ieT.js → SessionsPage-a30adkhf.js} +2 -2
- package/dashboard/dist/assets/SettingsPage-C_7ZPBUF.js +2 -0
- package/dashboard/dist/assets/SkillsPage-DsxkFnrV.js +1 -0
- package/dashboard/dist/assets/TokenGalaxy-D_bXRotA.js +4426 -0
- package/dashboard/dist/assets/ToolbarRootContext-CL7ma7ba.js +1 -0
- package/dashboard/dist/assets/{TrendMonitor-CCzwGDst.js → TrendMonitor-QZBF2IEY.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-CcWCidAd.js → WidgetsPage-CWlxR0H-.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-B6dn8eyh.js → WrappedPage-D8XQ72nF.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-CTGqjrCe.js +45 -0
- package/dashboard/dist/assets/{agent-logos-Dh2k8E_G.js → agent-logos-BscA25fS.js} +1 -1
- package/dashboard/dist/assets/arrow-up-right-DTxCEGbR.js +1 -0
- package/dashboard/dist/assets/check-CCEoh2wj.js +1 -0
- package/dashboard/dist/assets/{composite-CSBcryzA.js → composite-B2s880f5.js} +1 -1
- package/dashboard/dist/assets/copy-CJVQglwG.js +1 -0
- package/dashboard/dist/assets/download-Cn-OpYm6.js +1 -0
- package/dashboard/dist/assets/external-link-BnYlUn56.js +1 -0
- package/dashboard/dist/assets/flame-D4yFLV1L.js +1 -0
- package/dashboard/dist/assets/{format-tokens-CqiCmYtk.js → format-tokens-CBUNbBvp.js} +1 -1
- package/dashboard/dist/assets/{icons-DD8OvYVG.js → icons-CcgNgAvb.js} +1 -1
- package/dashboard/dist/assets/{index-DLLivlEh.js → index-CTjeDkbu.js} +1 -1
- package/dashboard/dist/assets/{index-21lDN4rA.js → index-CkELwUyg.js} +1 -1
- package/dashboard/dist/assets/{index-Cm8jn8Va.js → index-ZWeEKbo-.js} +1 -1
- package/dashboard/dist/assets/info-DoehRSQU.js +1 -0
- package/dashboard/dist/assets/link-2-D8xSsPqy.js +1 -0
- package/dashboard/dist/assets/loader-circle-DMu0-X5r.js +1 -0
- package/dashboard/dist/assets/maximize-2-DLyYsZvE.js +1 -0
- package/dashboard/dist/assets/{modifiers.esm-Cwj0l9Zb.js → modifiers.esm-Dm5Xy2jA.js} +1 -1
- package/dashboard/dist/assets/module-B5tW98jG.js +3 -0
- package/dashboard/dist/assets/monitor-smartphone-5uZGQNGJ.js +1 -0
- package/dashboard/dist/assets/plus-8fnU0dkt.js +1 -0
- package/dashboard/dist/assets/provider-display-B3ed-pSc.js +42 -0
- package/dashboard/dist/assets/{react-xH4nkyuj.js → react-Gft01KYk.js} +1 -1
- package/dashboard/dist/assets/search-jqzJg2kG.js +1 -0
- package/dashboard/dist/assets/{skills-api-B7lb1cjO.js → skills-api-Bwn_xcHV.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-BUPRsWL6.js → sortable.esm-CYjzLCp7.js} +1 -1
- package/dashboard/dist/assets/{store-DneqOW0h.js → store-CgJHe9jU.js} +1 -1
- package/dashboard/dist/assets/terminal-CZ5j8yEQ.js +1 -0
- package/dashboard/dist/assets/trash-DtMLjI_S.js +1 -0
- package/dashboard/dist/assets/{use-community-stats-DB98TGn9.js → use-community-stats-Px3dHGlR.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-DK3KulKx.js → use-latest-request-guard-B7Vw4Wsd.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-BACCRUMZ.js → use-limits-display-prefs-DWWrcMPi.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-DnKFdI9a.js → use-ordered-list-CevbB79U.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-CCuEY-79.js +1 -0
- package/dashboard/dist/assets/use-session-efficiency-pref-DoIaI0vm.js +1 -0
- package/dashboard/dist/assets/{use-transform-DweC2iKa.js → use-transform-qRwUetOk.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-CN5xWIBs.js → use-usage-limits-DlP7yg78.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-CFjvWawL.js → useCurrency-DRUe8YoY.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-Cf81HqWi.js → useTokenFormat-CmLbznUC.js} +1 -1
- package/dashboard/dist/assets/zap-CS80c_uN.js +1 -0
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/ip-check.html +1 -1
- package/dashboard/dist/leaderboard.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/sync.js +15 -4
- package/src/lib/cloud-account.js +120 -1
- package/src/lib/grok-limits.js +37 -0
- package/src/lib/heatmap-compact.js +114 -0
- package/src/lib/local-api.js +11 -10
- package/src/lib/opencode-config.js +20 -1
- package/src/lib/pricing/curated-overrides.json +22 -0
- package/src/lib/pricing/index.js +2 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +1085 -146
- package/src/lib/usage-limits.js +7 -1
- package/dashboard/dist/assets/AchievementBadge-Bf2T612R.js +0 -1
- package/dashboard/dist/assets/AchievementsSection-CPwsy04Y.js +0 -1
- package/dashboard/dist/assets/CommandPalette-C8BwOnSn.js +0 -1
- package/dashboard/dist/assets/CommunityStatsModal-BGMbgSjq.js +0 -1
- package/dashboard/dist/assets/DashboardPage-BcJGzQWK.js +0 -1
- package/dashboard/dist/assets/DialogDescription-DRQEfAWH.js +0 -1
- package/dashboard/dist/assets/LeaderboardPage-vVDKFLhl.js +0 -2
- package/dashboard/dist/assets/LoginCard-DA46RXDo.js +0 -1
- package/dashboard/dist/assets/PetPage-DDPZtxMw.js +0 -1
- package/dashboard/dist/assets/SettingsPage-Djku-i8K.js +0 -2
- package/dashboard/dist/assets/SkillsPage-DtBRoB8R.js +0 -1
- package/dashboard/dist/assets/TokenGalaxy-nvyPu5eV.js +0 -4314
- package/dashboard/dist/assets/ToolbarRootContext-DhpHv55w.js +0 -1
- package/dashboard/dist/assets/__vite-browser-external-sJsF0ioo.js +0 -45
- package/dashboard/dist/assets/arrow-up-right-BLDQog1A.js +0 -1
- package/dashboard/dist/assets/check-DNq_ySSn.js +0 -1
- package/dashboard/dist/assets/copy-DHRrNtRb.js +0 -1
- package/dashboard/dist/assets/download-CluyujgG.js +0 -1
- package/dashboard/dist/assets/external-link-Cf12tdLf.js +0 -1
- package/dashboard/dist/assets/flame-CJEYinxo.js +0 -1
- package/dashboard/dist/assets/info-dv3Y0z8Q.js +0 -1
- package/dashboard/dist/assets/link-2-CWHBxVuk.js +0 -1
- package/dashboard/dist/assets/loader-circle-9l5p9Dwa.js +0 -1
- package/dashboard/dist/assets/maximize-2-DQ2t3MJB.js +0 -1
- package/dashboard/dist/assets/module-DUSXqJtA.js +0 -3
- package/dashboard/dist/assets/monitor-smartphone-B-9at3iV.js +0 -1
- package/dashboard/dist/assets/plus-C_CTQjDD.js +0 -1
- package/dashboard/dist/assets/provider-display-XJQod7k9.js +0 -42
- package/dashboard/dist/assets/search-Ut41Fw1G.js +0 -1
- package/dashboard/dist/assets/terminal-DPQyZyHR.js +0 -1
- package/dashboard/dist/assets/trash-CVdV1bBR.js +0 -1
- package/dashboard/dist/assets/use-reduced-motion-BfdrKOsS.js +0 -1
- package/dashboard/dist/assets/use-session-efficiency-pref-BTm6RoSm.js +0 -1
- package/dashboard/dist/assets/zap-Vx_j5oJN.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeaderboardProfileModal-Cm4DDrcY.js","assets/__vite-browser-external-sJsF0ioo.js","assets/__vite-browser-external-5P7me0Qq.css","assets/provider-display-XJQod7k9.js","assets/useCurrency-CFjvWawL.js","assets/useTokenFormat-Cf81HqWi.js","assets/maximize-2-DQ2t3MJB.js","assets/terminal-DPQyZyHR.js","assets/info-dv3Y0z8Q.js","assets/LeaderboardAvatar-JtGhJC1s.js","assets/ProviderIcon-DqqwXu3b.js","assets/AchievementBadge-Bf2T612R.js","assets/zap-Vx_j5oJN.js","assets/flame-CJEYinxo.js","assets/AchievementsSection-CPwsy04Y.js","assets/react-xH4nkyuj.js","assets/format-tokens-CqiCmYtk.js","assets/use-reduced-motion-BfdrKOsS.js","assets/arrow-up-right-BLDQog1A.js","assets/link-2-CWHBxVuk.js","assets/check-DNq_ySSn.js","assets/DialogTitle-BWYdq4TT.js","assets/composite-CSBcryzA.js","assets/store-DneqOW0h.js","assets/CommunityStatsModal-BGMbgSjq.js","assets/icons-DD8OvYVG.js","assets/TrendMonitor-CCzwGDst.js","assets/use-latest-request-guard-DK3KulKx.js","assets/PopoverPopup-DWIMb8D6.js","assets/ToolbarRootContext-DhpHv55w.js","assets/DialogDescription-DRQEfAWH.js","assets/DialogClose-8pTCallP.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{m as ua,j as e,d as xa,c as s,e as d,r as c,ak as ga,f as ba,u as pa,a as ha,al as fa,G as ya,am as ka,an as wa,ao as ze,ap as ja,aq as ne,g as va,ar as Na,L as _a,as as Sa,l as Ca,at as La,au as Ea,a7 as Ta,_ as Fe,k as Aa,q as Ma}from"./__vite-browser-external-sJsF0ioo.js";import{S as Pa}from"./Select-Cr9wq8mD.js";import{m as Ka}from"./react-xH4nkyuj.js";import{u as Ra,C as Ia,a as za,b as Be,D as Ba,c as Da,S as $a,h as Ua,s as Oa,K as Fa,P as Ga}from"./sortable.esm-BUPRsWL6.js";import{r as Ha}from"./modifiers.esm-Cwj0l9Zb.js";import{P as he}from"./ProviderIcon-DqqwXu3b.js";import{u as Ya}from"./useCurrency-CFjvWawL.js";import{u as Q}from"./useTokenFormat-Cf81HqWi.js";import{L as Z}from"./LeaderboardAvatar-JtGhJC1s.js";import{s as Wa,c as Va,A as qa,t as Ja,b as Za}from"./AchievementBadge-Bf2T612R.js";import{u as Xa}from"./use-ordered-list-DnKFdI9a.js";import{u as Qa}from"./use-community-stats-DB98TGn9.js";import"./ToolbarRootContext-DhpHv55w.js";import"./composite-CSBcryzA.js";import"./check-DNq_ySSn.js";import"./SelectItemText-BWnP4yuq.js";import"./zap-Vx_j5oJN.js";import"./flame-CJEYinxo.js";const er=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],ar=ua("arrow-right",er);function H(a,{min:r,max:o,fallback:n}){const l=Number(a);if(!Number.isFinite(l))return n;const i=Math.floor(l);return i<r?r:i>o?o:i}function rr(a,r){const o=H(r,{min:0,max:1e6,fallback:0}),n=H(a,{min:1,max:Math.max(1,o||1),fallback:1});if(o<=1)return[1];const l=new Set([1,o,n-2,n-1,n,n+1,n+2]),i=Array.from(l).filter(x=>Number.isInteger(x)&&x>=1&&x<=o).sort((x,p)=>x-p),m=[];let b=null;for(const x of i)b!=null&&x-b>1&&m.push(null),m.push(x),b=x;return m}function tr({page:a,totalPages:r}){const o=typeof r=="number"&&Number.isFinite(r)&&r>=0,n=o?H(r,{min:0,max:1e6,fallback:0}):null,l=H(a,{min:1,max:o?Math.max(1,n||1):1e6,fallback:1}),i=l>1,m=o?l<n:!0;return{canPrev:i,canNext:m,safePage:l,safeTotal:n}}function or({entries:a,me:r,meLabel:o}){const n=Array.isArray(a)?a:[],l=r&&typeof r.rank=="number"?r.rank:null;return!l||n.some(m=>!!m?.is_me)?n:[{rank:l,is_me:!0,is_pinned:!0,user_id:r?.user_id??null,display_name:o,avatar_url:r?.avatar_url??null,github_url:null,is_public:!1,gpt_tokens:r?.gpt_tokens??"0",claude_tokens:r?.claude_tokens??"0",gemini_tokens:r?.gemini_tokens??"0",cursor_tokens:r?.cursor_tokens??"0",opencode_tokens:r?.opencode_tokens??"0",openclaw_tokens:r?.openclaw_tokens??"0",hermes_tokens:r?.hermes_tokens??"0",kiro_tokens:r?.kiro_tokens??"0",copilot_tokens:r?.copilot_tokens??"0",kimi_tokens:r?.kimi_tokens??"0",other_tokens:r?.other_tokens??"0",total_tokens:r?.total_tokens??"0",estimated_cost_usd:r?.estimated_cost_usd??null,badges:Array.isArray(r?.badges)?r.badges:[]},...n]}function sr(a,r){const o=Number(a),n=Number(r);return!Number.isFinite(o)||o<1||!Number.isFinite(n)||n<1?null:Math.ceil(o/n)}const nr=new Set(["/brand-logos/cursor.svg","/brand-logos/kimi.svg","/brand-logos/kiro.svg","/brand-logos/copilot.svg","/brand-logos/hermes.svg"]);function ir({iconSrc:a,label:r}){return e.jsxs("span",{className:"inline-flex items-center gap-3",children:[a?e.jsx("img",{src:a,alt:"",width:16,height:16,className:`h-4 w-4 shrink-0 object-contain opacity-90 ${nr.has(a)?"dark:invert":""}`}):null,e.jsx("span",{className:"whitespace-nowrap",children:r})]})}const ie=xa.memo(function({badges:r,max:o=3,className:n=""}){const l=Wa((r||[]).filter(i=>i&&Va.has(i.id)&&(i.tier||0)>=1)).slice(0,o);return l.length===0?null:e.jsx("span",{className:`pointer-events-none inline-flex shrink-0 items-center ${n}`,children:l.map((i,m)=>e.jsx("span",{title:s("achievements.mini.tooltip",{name:s(Za(i.id,"name")),tier:s(`achievements.tier.${Ja(i.tier)}`)}),style:{zIndex:l.length-m},className:`pointer-events-auto relative inline-flex ${m>0?"-ml-1.5":""}`,children:e.jsx(qa,{badgeId:i.id,tier:i.tier,size:"xs",className:"rounded-full ring-[1.5px] ring-white dark:ring-oai-gray-950"})},i.id))})}),X=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"kiro_tokens",copyKey:"leaderboard.column.kiro",icon:"/brand-logos/kiro.svg"},{key:"copilot_tokens",copyKey:"leaderboard.column.copilot",icon:"/brand-logos/copilot.svg"},{key:"kimi_tokens",copyKey:"leaderboard.column.kimi",icon:"/brand-logos/kimi.svg"},{key:"opencode_tokens",copyKey:"leaderboard.column.opencode",icon:"/brand-logos/opencode.svg"},{key:"openclaw_tokens",copyKey:"leaderboard.column.openclaw",icon:"/brand-logos/openclaw.svg"},{key:"hermes_tokens",copyKey:"leaderboard.column.hermes",icon:"/brand-logos/hermes.svg"},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:null}],Ge="sticky left-0 z-40 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] bg-white dark:bg-oai-gray-950 px-2.5 sm:px-4 py-4 align-middle",He="sticky left-[55px] sm:left-[71px] z-40 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-3 sm:px-4 py-4 align-middle";function le(a){return d("sticky left-0 z-30 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] px-2.5 sm:px-4 py-4 whitespace-nowrap",a?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function de(a){return d("sticky left-[55px] sm:left-[71px] z-30 hover:z-50 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 px-3 sm:px-4 py-4 min-w-0",a?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function y({className:a}){return e.jsx("div",{className:d("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",a)})}function lr({index:a}){const r=a<3?"w-24":a<8?"w-20":"w-16",o=a<3?"w-16":"w-12",n=a<5?"w-14":"w-10";return e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:d(le(!1),"!group-hover:bg-transparent"),children:e.jsx(y,{className:"h-4 w-6"})}),e.jsx("td",{className:d(de(!1),"!group-hover:bg-transparent"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(y,{className:"h-8 w-8 min-w-8 rounded-full"}),e.jsx(y,{className:d("h-4",r)})]})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:d("h-4",o)})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:"h-4 w-12"})}),X.map(l=>e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:d("h-4",n)})},l.key))]})}function dr({index:a}){const r=a<3?"w-24":a<8?"w-20":"w-16",o=a%3===0?3:a%3===1?2:1;return e.jsxs("div",{className:"mx-0 my-1 rounded-xl bg-white dark:bg-oai-gray-950 border border-oai-gray-100 dark:border-oai-gray-800/60 px-3.5 py-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(y,{className:"h-4 w-3 shrink-0 rounded"}),e.jsx(y,{className:"h-9 w-9 shrink-0 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(y,{className:d("h-4",r)}),e.jsx(y,{className:"mt-2 h-3.5 w-20"})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx(y,{className:"ml-auto h-3 w-8"}),e.jsx(y,{className:"mt-1.5 ml-auto h-4 w-14"})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-oai-gray-100 pt-2.5 dark:border-oai-gray-800/70",children:Array.from({length:o},(n,l)=>e.jsx(y,{className:"h-5 w-12 rounded-full"},l))})]})}function cr({rows:a=10}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(Ge,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(y,{className:"h-3.5 w-6"})}),e.jsx("th",{className:d(He,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(y,{className:"h-3.5 w-12"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-10"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-14"})}),X.map(r=>e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-12"})},r.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:a},(r,o)=>e.jsx(lr,{index:o},o))})]})}),e.jsx("div",{className:"flex flex-col py-1 sm:hidden",children:Array.from({length:a},(r,o)=>e.jsx(dr,{index:o},o))})]})}function mr({id:a,thClassName:r,children:o}){const{attributes:n,listeners:l,setNodeRef:i,transform:m,transition:b,isDragging:x}=Ra({id:a}),p=Ia.Transform.toString(m)||"";c.useLayoutEffect(()=>{const f=document.querySelectorAll(`td[data-column-key="${a}"]`),h="0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)";return f.forEach(g=>{g.style.transform=p,g.style.transition=b||"",g.style.zIndex=x?"20":"",g.style.position=p?"relative":"",g.style.boxShadow=x?h:""}),()=>{f.forEach(g=>{g.style.transform="",g.style.transition="",g.style.zIndex="",g.style.position="",g.style.boxShadow=""})}},[a,p,b,x]);const j={transform:p,transition:b,position:p?"relative":void 0,zIndex:x?20:void 0,boxShadow:x?"0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)":void 0};return e.jsx("th",{ref:i,style:j,className:d(r,"group/col select-none cursor-grab active:cursor-grabbing touch-none"),...n,...l,children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:d("-mr-1 inline-flex h-4 w-3 shrink-0 items-center justify-center text-oai-gray-400 dark:text-oai-gray-600","opacity-0 transition-opacity duration-150 group-hover/col:opacity-100",x&&"opacity-100"),children:e.jsxs("svg",{viewBox:"0 0 8 14",width:"8",height:"14",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"2",cy:"2",r:"1"}),e.jsx("circle",{cx:"6",cy:"2",r:"1"}),e.jsx("circle",{cx:"2",cy:"7",r:"1"}),e.jsx("circle",{cx:"6",cy:"7",r:"1"}),e.jsx("circle",{cx:"2",cy:"12",r:"1"}),e.jsx("circle",{cx:"6",cy:"12",r:"1"})]})}),o]})})}const ur="tokentracker.leaderboard.columnOrder.v1";function xr(a){return Xa(ur,a)}const gr=50;function br(a,r){const o=Number(a),n=Number(r);return!Number.isFinite(o)||o<1||!Number.isFinite(n)||n<1?null:Math.min(100,Math.max(1,Math.ceil(o/n*100)))}function Ye(a){return typeof a=="string"?a.trim():""}function pr(a){const r=Ye(a);return r?r.toLowerCase()==="anonymous":!0}function hr({me:a,totalEntries:r,meLabel:o,onOpenProfile:n,onJumpToMe:l,canJump:i,className:m}){const b=a&&typeof a.rank=="number"?a.rank:null;if(!b)return null;const x=Number(r)||0,p=br(b,x),j=Ye(a?.display_name),f=!j||pr(j)?o||"You":j,h=a?.user_id||f,g=n||(i?l:null),T=typeof g=="function",C=T?"button":"div",ee=T?{type:"button",onClick:g,"aria-label":s(n?"leaderboard.summary.view_profile":"leaderboard.summary.jump_to_me")}:{};return e.jsxs(C,{...ee,className:d("group inline-flex h-9 items-center gap-2.5 rounded-full border pl-1 pr-3.5 transition-all duration-300 select-none",T?"border-oai-gray-200 hover:border-oai-brand-400 dark:border-oai-gray-800 dark:hover:border-oai-brand-500/80 bg-oai-gray-50/50 dark:bg-white/[0.02] backdrop-blur-md hover:bg-oai-brand-50/40 dark:hover:bg-oai-brand-950/20 active:scale-[0.97] dark:ring-1 dark:ring-white/[0.04] dark:hover:ring-white/[0.08]":"border-oai-gray-100 dark:border-oai-gray-800/60 bg-oai-gray-50/20 dark:bg-white/[0.01] backdrop-blur-sm dark:ring-1 dark:ring-white/[0.02]",m),children:[e.jsx(Z,{size:"sm",avatarUrl:a?.avatar_url,displayName:f,seed:h}),e.jsx("span",{className:"hidden sm:inline max-w-[120px] truncate text-xs font-semibold text-oai-black dark:text-oai-gray-200 group-hover:text-oai-brand-600 dark:group-hover:text-oai-brand-400 transition-colors",children:f}),e.jsxs("span",{className:"text-xs font-bold tabular-nums text-oai-gray-800 dark:text-white",children:["#",b.toLocaleString()]}),p!=null&&p<=gr&&e.jsx("span",{className:d("hidden sm:inline-flex items-center rounded-full px-2 py-0.5 text-[9px] font-extrabold tracking-wider tabular-nums uppercase transition-colors duration-300 ring-1",p<=10?"bg-amber-500/10 text-amber-600 dark:bg-amber-500/15 dark:text-amber-400 ring-amber-500/20":"bg-oai-brand-100/50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-400 ring-oai-brand-500/10"),children:s("leaderboard.summary.percentile",{p:String(p)})}),T?e.jsx(ar,{"aria-hidden":!0,className:"size-3 text-oai-gray-400 transition-all duration-300 group-hover:text-oai-brand-500 dark:text-oai-gray-500 group-hover:translate-x-0.5 group-hover:scale-110"}):e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0 items-center justify-center ml-1",title:"You are here",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75 duration-1000"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500"})]})]})}const fr=c.lazy(()=>Fe(()=>import("./LeaderboardProfileModal-Cm4DDrcY.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])).then(a=>({default:a.LeaderboardProfileModal}))),yr=c.lazy(()=>Fe(()=>import("./CommunityStatsModal-BGMbgSjq.js"),__vite__mapDeps([24,1,2,15,25,5,10,26,4,27,7,28,23,22,29,6,17,11,12,13,21,30,31])).then(a=>({default:a.CommunityStatsModal}))),ce=[10,20,50,100],me=20,We="tokentracker:leaderboard:pageSize";function kr(){if(typeof window>"u")return me;try{const a=window.localStorage.getItem(We),r=Number(a);if(ce.includes(r))return r}catch{}return me}function ue(a,r,o){const n=Number(a);if(!Number.isFinite(n)||n<=0)return"-";const l=Sa(r),i=r===Ma?n:n*o;return i>=1e3?`${l}${Math.round(i).toLocaleString()}`:i>=10?`${l}${Math.round(i)}`:`${l}${i.toFixed(2)}`}function wr(a){if(typeof a!="string"||!a.trim())return null;const r=new Date(a);if(!Number.isFinite(r.getTime()))return null;const o=Aa();return{dateTime:r.toISOString(),display:new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(r),exact:new Intl.DateTimeFormat(o,{dateStyle:"full",timeStyle:"long"}).format(r)}}function xe({value:a}){const{formatTokens:r,formatTokensTooltip:o}=Q();return e.jsx("span",{title:o(a),children:r(a)})}function jr({communityStats:a,onClick:r}){const{formatTokens:o,formatTokensTooltip:n}=Q();return a.status!=="ready"?null:e.jsxs("button",{type:"button",onClick:r,className:"inline-flex min-w-0 max-w-full flex-1 items-center gap-1.5 whitespace-nowrap rounded-xl border border-oai-gray-200 bg-oai-gray-50/50 px-2.5 py-2 text-xs text-oai-gray-500 backdrop-blur-md transition-all duration-300 hover:border-oai-brand-400 hover:bg-oai-brand-50/40 active:scale-[0.97] dark:border-oai-gray-800 dark:bg-white/[0.02] dark:text-oai-gray-400 dark:hover:border-oai-brand-500/80 dark:hover:bg-oai-brand-950/20 sm:h-9 sm:flex-none sm:gap-2.5 sm:rounded-full sm:px-3.5 sm:py-0",title:s("leaderboard.community.view_stats"),children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0","aria-hidden":"true",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-500/80 opacity-75 duration-1000"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-semibold text-oai-black dark:text-white tabular-nums",children:e.jsx("span",{title:n(a.tokenFloor),children:o(a.tokenFloor)})}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:s("leaderboard.community.tokens_chip")})]}),e.jsx("span",{className:"text-oai-gray-200 dark:text-oai-gray-800 select-none",children:"·"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("span",{className:"font-semibold text-oai-black dark:text-white tabular-nums",children:[e.jsx("span",{className:"sm:hidden",children:Ca(a.totalEntries)}),e.jsx("span",{className:"hidden sm:inline",children:(Number(a.totalEntries)||0).toLocaleString("en-US")})]}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:s("leaderboard.community.devs_chip")})]})]})}function De({entry:a,isMe:r,orderedColumns:o}){const{formatTokens:n,formatTokensTooltip:l}=Q(),i=r?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",m=r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900";return o.map(b=>e.jsx("td",{"data-column-key":b.key,title:l(a?.[b.key]),className:d("hidden sm:table-cell px-3 sm:px-4 py-4 whitespace-nowrap text-right tabular-nums",i,m),children:n(a?.[b.key])},b.key))}function vr(a){return a?.key==="gpt_tokens"?"CODEX":a?.key==="claude_tokens"?"CLAUDE":(a?.icon?.split("/").pop()||"").replace(/\.svg$/i,"").toUpperCase()||"OTHER"}const Nr={1:"ring-2 ring-amber-400 dark:ring-amber-500/80 shadow-[0_0_8px_rgba(245,158,11,0.25)]",2:"ring-2 ring-slate-350 dark:ring-slate-450 shadow-[0_0_8px_rgba(148,163,184,0.2)]",3:"ring-2 ring-orange-400 dark:ring-orange-500/70 shadow-[0_0_8px_rgba(249,115,22,0.25)]"};function _r({rank:a,placeholder:r}){return a===1?e.jsx("span",{className:"text-base font-extrabold italic text-amber-500 dark:text-amber-400 tracking-tighter",children:"1"}):a===2?e.jsx("span",{className:"text-base font-extrabold italic text-slate-400 dark:text-slate-350 tracking-tighter",children:"2"}):a===3?e.jsx("span",{className:"text-base font-extrabold italic text-orange-500 dark:text-orange-400 tracking-tighter",children:"3"}):e.jsx("span",{className:"text-[13px] font-bold tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:a==null?r:`#${a}`})}function Sr({githubUrl:a}){return e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":"GitHub profile",className:"absolute bottom-0 right-0 translate-x-1 translate-y-1 flex h-4.5 w-4.5 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 shadow border border-oai-gray-100 dark:border-oai-gray-800 transition-transform active:scale-110",children:e.jsx(he,{provider:"GITHUB",size:11})})}function Cr({entry:a,orderedColumns:r}){const{formatTokens:o,formatTokensTooltip:n}=Q(),l=r.filter(i=>{const m=Number(a?.[i.key]);return Number.isFinite(m)&&m>0});return l.length===0?null:e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-x-1.5 gap-y-2 border-t border-oai-gray-100/70 pt-3 dark:border-oai-gray-800/60",children:l.map(i=>{const m=s(i.copyKey);return e.jsxs("span",{title:m,"aria-label":`${m}: ${n(a?.[i.key])}`,className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-oai-gray-50/80 dark:bg-oai-gray-900/60 px-2 py-0.5 border border-oai-gray-100/80 dark:border-oai-gray-800/40 text-[10px] font-medium text-oai-gray-600 dark:text-oai-gray-300 transition-colors",children:[e.jsx(he,{provider:vr(i),size:12,className:"shrink-0 opacity-90"}),e.jsx("span",{className:"tabular-nums",children:o(a?.[i.key])})]},i.key)})})}function Lr({entry:a,entryIdx:r,name:o,meLabel:n,currency:l,rate:i,orderedColumns:m,placeholder:b,onOpenProfile:x}){if(a?.is_ellipsis)return e.jsx("div",{"aria-hidden":"true",className:"px-4 py-2 text-center text-xs tracking-[0.4em] text-oai-gray-400 dark:text-oai-gray-600",children:"···"},`mobile-ellipsis-${r}`);const p=!!a?.is_me,j=!p&&be(a?.display_name),f=typeof a?.user_id=="string"?a.user_id:null,h=!!f,g=p?n:o,T=C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),x(f))};return e.jsxs("div",{role:h?"button":void 0,tabIndex:h?0:void 0,onClick:h?()=>x(f):void 0,onKeyDown:h?T:void 0,"aria-label":h?s("leaderboard.profile_modal.row_aria",{name:g}):void 0,className:d("relative mx-0 my-1 rounded-xl px-3.5 py-3 transition-all duration-200 border shadow-sm select-none",p?"bg-gradient-to-br from-oai-brand-50/70 via-oai-brand-50/20 to-transparent dark:from-oai-brand-950/20 dark:via-oai-brand-950/5 dark:to-transparent border-oai-brand-200/60 dark:border-oai-brand-500/25":j?"bg-white/90 dark:bg-oai-gray-950/90 border-oai-gray-100/70 dark:border-oai-gray-800/40":"bg-white dark:bg-oai-gray-950 border-oai-gray-100 dark:border-oai-gray-800/60",h&&"cursor-pointer hover:border-oai-gray-200 dark:hover:border-oai-gray-700/80 active:scale-[0.985] active:bg-oai-gray-50/60 dark:active:bg-oai-gray-900/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"flex w-5 shrink-0 items-center justify-center",children:e.jsx(_r,{rank:a?.rank,placeholder:b})}),e.jsxs("span",{className:"relative inline-flex shrink-0",children:[e.jsx("span",{className:d("inline-flex rounded-full p-0.5 transition-all duration-300",Nr[a?.rank]||"ring-1 ring-oai-gray-200 dark:ring-oai-gray-800/80",j&&"opacity-60 grayscale-[15%]"),children:e.jsx(Z,{size:"md",avatarUrl:a?.avatar_url,displayName:g,seed:pe(a,g)})}),a?.github_url&&e.jsx(Sr,{githubUrl:a.github_url})]}),e.jsxs("div",{className:"min-w-0 flex-1 pl-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:d("min-w-0 truncate text-sm tracking-tight",p?"font-semibold text-oai-black dark:text-oai-white":j?"font-normal text-oai-gray-400 dark:text-oai-gray-500":"font-medium text-oai-gray-800 dark:text-oai-gray-200"),children:g}),e.jsx(ie,{badges:a?.badges,className:"shrink-0 scale-95"})]}),e.jsxs("div",{className:"mt-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:s("leaderboard.column.est_cost")}),e.jsx("span",{className:d("ml-1 tabular-nums font-medium",j?"text-oai-gray-400/80 dark:text-oai-gray-500/80":"text-oai-gray-600 dark:text-oai-gray-300"),children:ue(a?.estimated_cost_usd,l,i)})]})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.08em] text-oai-gray-400 dark:text-oai-gray-500",children:s("leaderboard.column.total")}),e.jsx("div",{className:d("mt-0.5 text-sm font-semibold tabular-nums tracking-tight",p?"text-oai-black dark:text-oai-white":j?"text-oai-gray-400 dark:text-oai-gray-500":"text-oai-gray-800 dark:text-oai-gray-200"),children:e.jsx(xe,{value:a?.total_tokens})})]})]}),e.jsx(Cr,{entry:a,orderedColumns:m})]},`mobile-row-${a?.rank}-${g}`)}const Er={1:{text:"text-amber-600 dark:text-amber-400",badge:"bg-amber-50 dark:bg-amber-900/20"},2:{text:"text-gray-500 dark:text-gray-300",badge:"bg-gray-50 dark:bg-gray-800/40"},3:{text:"text-orange-700 dark:text-orange-400",badge:"bg-orange-50 dark:bg-orange-900/20"}};function $e({rank:a,placeholder:r}){const o=Er[a];return o?e.jsx("span",{className:d("inline-flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold",o.text,o.badge),children:a}):e.jsx("span",{className:"inline-flex items-center justify-center h-7 w-7 text-sm",children:a??r})}function Ue(a){if(typeof a!="string")return null;const r=a.trim().toLowerCase();return r==="week"||r==="month"||r==="total"?r:null}function Tr(a){if(!a)return s("shared.error.prefix",{error:s("leaderboard.error.unknown")});const r=a?.message||String(a),o=String(r||"").trim()||s("leaderboard.error.unknown");return s("shared.error.prefix",{error:o})}function ge(a){return typeof a!="string"?"":a.trim()}function be(a){const r=ge(a);return r?r.toLowerCase()==="anonymous":!0}function pe(a,r){const o=typeof a?.user_id=="string"?a.user_id.trim():"";return o||`${a?.rank??""}:${r}`}function Oe({githubUrl:a}){return e.jsxs("span",{className:"absolute left-1/2 top-full -translate-x-1/2 -translate-y-1/2 inline-flex group/gh",children:[e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":s("leaderboard.github.aria"),className:"flex h-4 w-4 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 transition-transform hover:scale-110",children:e.jsx(he,{provider:"GITHUB",size:14})}),e.jsxs("span",{role:"tooltip",className:"invisible opacity-0 group-hover/gh:visible group-hover/gh:opacity-100 absolute left-0 bottom-full mb-2 whitespace-nowrap rounded-md bg-oai-black dark:bg-oai-gray-700 px-2.5 py-1.5 text-[11px] leading-relaxed text-white shadow-lg transition-opacity duration-150 z-50 before:content-[''] before:absolute before:inset-x-0 before:top-full before:h-2.5",children:[e.jsx("span",{className:"block",children:s("leaderboard.github.tooltipAction")}),e.jsxs("span",{className:"block text-oai-gray-300 dark:text-oai-gray-400",children:[s("leaderboard.github.tooltipPrefix")," ",e.jsx(_a,{to:"/settings",onClick:r=>r.stopPropagation(),className:"text-white underline underline-offset-2 decoration-oai-gray-400 hover:text-oai-brand-300 hover:decoration-oai-brand-300",children:s("leaderboard.github.tooltipSettingsLink")})," ",s("leaderboard.github.tooltipSuffix")]})]})]})}function Zr({auth:a,signedIn:r,sessionSoftExpired:o}){const n=ga(),l=ba(),{openLoginModal:i}=pa(),{signedIn:m,loading:b,user:x}=ha(),{currency:p,rate:j}=Ya(),f=c.useMemo(()=>fa(),[]),h=ya(),g=r&&!o,T=c.useMemo(()=>g&&(typeof a=="function"||typeof a=="string"||a&&typeof a=="object")?a:null,[a,g]),C=g?T:null,ee=g&&ka(C),ae=s("shared.placeholder.short"),Ve=c.useMemo(()=>X.map(t=>t.key),[]),{order:re,reorder:fe}=xr(Ve),ye=c.useMemo(()=>{const t=new Map;for(const u of X)t.set(u.key,u);return t},[]),B=c.useMemo(()=>re.map(t=>ye.get(t)).filter(Boolean),[re,ye]),qe=za(Be(Ga,{activationConstraint:{distance:6}}),Be(Fa,{coordinateGetter:Oa})),Je=c.useCallback(t=>{const{active:u,over:w}=t;!w||u.id===w.id||fe(String(u.id),String(w.id))},[fe]),[te,M]=c.useState(1),[_,Ze]=c.useState(kr),[ke,we]=c.useState(null),[Xe,je]=c.useState(!1),Y=c.useCallback(t=>{typeof t=="string"&&t.trim()&&we(t.trim())},[]),Qe=c.useCallback(()=>we(null),[]),ea=c.useCallback(t=>{const u=ce.includes(t)?t:me;Ze(u),M(1);try{window.localStorage.setItem(We,String(u))}catch{}},[]),[ve,aa]=c.useState(0),[ra,ta]=c.useState(()=>wa()),[Ne,_e]=c.useState(!1);c.useEffect(()=>{if(typeof window>"u")return;const t=()=>{aa(u=>u+1)};return window.addEventListener(ze,t),()=>{window.removeEventListener(ze,t)}},[]);const N=c.useMemo(()=>{const t=new URLSearchParams(n?.search||"");return Ue(t.get("period"))||"total"},[n?.search]),oa=t=>{const u=Ue(t);if(!u||u===N)return;const w=new URLSearchParams(n?.search||"");w.set("period",u),M(1),l(`${n?.pathname||"/leaderboard"}?${w.toString()}`,{replace:!0})};c.useEffect(()=>{b||h||m||i()},[m,b,h,i]),c.useEffect(()=>{M(1)},[N]);const W=c.useMemo(()=>(H(te,{min:1,max:1e6,fallback:1})-1)*_,[te,_]),R=c.useMemo(()=>h?"mock":b?"unavailable":m?"cloud":r?"local":f?"public":"unavailable",[b,m,f,h,r]),k=c.useMemo(()=>ja({accessMode:R,baseUrl:f,mockEnabled:h,userId:x?.id||null,period:N,pageSize:_,offset:W}),[x?.id,R,f,W,h,_,N]),[D,$]=c.useState(()=>{const t=ne(k);return t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!1,error:null,data:null,contextKey:null}});c.useEffect(()=>{if(!f&&!h||!h&&R==="unavailable"){$({loading:!1,error:null,data:null,contextKey:null});return}const t=ne(k);let u=!0;return $(t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!0,error:null,data:null,contextKey:null}),(async()=>{const w=await va({userId:x?.id||null,period:N,limit:_,offset:W});u&&(Na(w,{activeContextKey:k,contextKey:k,source:ve>0?"manual-refresh":"page-load"}),$({loading:!1,error:null,data:w,contextKey:k}))})().catch(w=>{if(!u)return;const A=Tr(w);$(F=>F.contextKey===k?{...F,loading:!1,error:A}:{loading:!1,error:A,data:null,contextKey:k})}),()=>{u=!1}},[f,R,x?.id,k,W,ve,h,N,_]);const oe=c.useMemo(()=>D.contextKey===k?null:ne(k),[k,D.contextKey]),v=c.useMemo(()=>D.contextKey===k?D:oe?{loading:!1,error:null,data:oe.data,contextKey:k}:{loading:!!(f||h)&&R!=="unavailable",error:null,data:null,contextKey:k},[R,f,k,D,h,oe]),S=v.data,U=S?.total_pages??null,sa=S?.total_entries??0,P=S?.page??te,na=c.useMemo(()=>rr(P,U),[P,U]),Se=S?.from||null,Ce=S?.to||null,ia=S?.generated_at||null,V=wr(ia),Le=Qa(),K=S?.me||null,I=s("leaderboard.me_label"),Ee=s("leaderboard.anon_label"),Te=s("leaderboard.period.week"),Ae=s("leaderboard.period.month"),Me=s("leaderboard.period.total"),Pe=N==="month"?Ae:N==="total"?Me:Te,q=c.useMemo(()=>{const t=Array.isArray(S?.entries)?S.entries:[];return or({entries:t,me:K,meLabel:I})},[S?.entries,K,I]),z=c.useMemo(()=>sr(K?.rank,_),[K?.rank,_]),la=z!=null&&z===P,da=c.useCallback(()=>{z!=null&&M(z)},[z]),ca=async()=>{_e(!0);try{La(!0),ta(!0),await Ea(()=>Ta(C))}catch(t){console.warn("[tokentracker] sync:",t)}finally{_e(!1)}},{canPrev:Ke,canNext:Re}=tr({page:P,totalPages:U}),J=Array.isArray(q)&&q.length!==0;let O=null;v.loading&&!J?O=e.jsx(cr,{rows:_}):v.error&&!J?O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v.error})}):J?O=e.jsxs(Ba,{sensors:qe,collisionDetection:Da,modifiers:[Ha],onDragEnd:Je,children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-full w-full text-left text-sm sm:min-w-max",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(Ge,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:s("leaderboard.column.rank")}),e.jsx("th",{className:d(He,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:s("leaderboard.column.user")}),e.jsx("th",{className:"px-3 sm:px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",children:s("leaderboard.column.total")}),e.jsx("th",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",title:"Based on estimated API pricing, not actual billing",children:s("leaderboard.column.est_cost")}),e.jsx($a,{items:re,strategy:Ua,children:B.map(t=>e.jsx(mr,{id:t.key,thClassName:"hidden sm:table-cell px-3 sm:px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap align-middle",children:e.jsx(ir,{iconSrc:t.icon,label:s(t.copyKey)})},t.key))})]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:q.map((t,u)=>{if(t?.is_ellipsis){const E=4+B.length;return e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:E,className:"px-4 py-2 text-center text-oai-gray-400 dark:text-oai-gray-600 bg-white dark:bg-oai-gray-950 select-none tracking-[0.4em] text-xs",children:"···"})},`ellipsis-${u}`)}const w=!!t?.is_me,A=typeof t?.user_id=="string"?t.user_id:null,F=ge(t?.display_name),ma=be(F)?Ee:F,L=w?I:ma,G=!!A,Ie=G?{role:"button",tabIndex:0,onClick:G?()=>Y(A):void 0,onKeyDown:G?E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),Y(A))}:void 0,"aria-label":s("leaderboard.profile_modal.row_aria",{name:L})}:{};if(w){const E=!!t?.is_pinned;return e.jsxs("tr",{...Ie,className:d("bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",E?"border-t border-b border-oai-brand-300/40 dark:border-oai-brand-500/20":"border-y border-oai-brand-300/40 dark:border-oai-brand-500/30",G&&"cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsx("td",{className:d(le(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400",E&&"before:absolute before:left-0 before:top-[15%] before:h-[70%] before:w-[3px] before:rounded-r before:bg-oai-brand-500 dark:before:bg-oai-brand-400"),children:e.jsx($e,{rank:t?.rank,placeholder:ae})}),e.jsx("td",{className:de(!0),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:d("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&"gh-avatar-frame"),children:[e.jsx("span",{className:d("inline-flex rounded-full p-px",t?.github_url&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(Z,{avatarUrl:t?.avatar_url,displayName:L,seed:pe(t,L)})}),t?.github_url&&e.jsx(Oe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:L}),e.jsx(ie,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-medium text-oai-black dark:text-oai-white whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",children:e.jsx(xe,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 font-medium text-oai-brand-600 dark:text-oai-brand-400 whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",title:"Based on estimated API pricing, not actual billing",children:ue(t?.estimated_cost_usd,p,j)}),e.jsx(De,{entry:t,isMe:!0,orderedColumns:B})]},`row-${t?.rank}-${L}${E?"-pin":""}`)}return e.jsxs("tr",{...Ie,className:d("group transition-colors",G&&"cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsx("td",{className:d(le(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx($e,{rank:t?.rank,placeholder:ae})}),e.jsx("td",{className:de(!1),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:d("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&"gh-avatar-frame"),children:[e.jsx("span",{className:d("inline-flex rounded-full p-px",t?.github_url&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(Z,{avatarUrl:t?.avatar_url,displayName:L,seed:pe(t,L)})}),t?.github_url&&e.jsx(Oe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:L}),e.jsx(ie,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-semibold text-oai-gray-800 dark:text-oai-gray-200 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",children:e.jsx(xe,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",title:"Based on estimated API pricing, not actual billing",children:ue(t?.estimated_cost_usd,p,j)}),e.jsx(De,{entry:t,isMe:!1,orderedColumns:B})]},`row-${t?.rank}-${L}`)})})]})}),e.jsx("div",{className:"flex flex-col py-1.5 sm:hidden",children:q.map((t,u)=>{const w=ge(t?.display_name),A=be(w)?Ee:w;return e.jsx(Lr,{entry:t,entryIdx:u,name:t?.is_me?I:A,meLabel:I,currency:p,rate:j,orderedColumns:B,placeholder:ae,onOpenProfile:Y},`mobile-${t?.rank??"ellipsis"}-${u}`)})})]}):O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("leaderboard.empty")})});let se=null;return typeof U=="number"?se=na.map((t,u)=>t==null?e.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:s("leaderboard.pagination.ellipsis")},`ellipsis-${u}`):e.jsx("button",{className:d("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",t===P?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"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"),onClick:()=>M(t),disabled:v.loading,children:String(t)},`page-${t}`)):se=e.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("leaderboard.pagination.page_unknown",{page:String(P)})}),e.jsxs("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:[e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-4 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-3.5 sm:mb-8 sm:grid-cols-[minmax(0,1fr)_auto] sm:gap-4",children:[e.jsx("h1",{className:"col-start-1 row-start-1 min-w-0 whitespace-nowrap text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:col-span-2 sm:row-start-1 sm:text-4xl",children:s("leaderboard.title")}),e.jsxs("p",{className:"col-span-2 row-start-2 hidden text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:block sm:row-start-2 sm:text-base",children:[N==="total"?s("leaderboard.range.total"):Se&&Ce?s("leaderboard.range",{period:Pe,from:Se,to:Ce}):s("leaderboard.range_loading",{period:Pe}),V&&e.jsx("time",{dateTime:V.dateTime,title:s("leaderboard.generated_at",{ts:V.exact}),className:"ml-2 hidden border-l border-oai-gray-200 pl-2 text-xs text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400 sm:inline-block",children:s("leaderboard.generated_at",{ts:V.display})})]}),e.jsx("div",{className:"col-start-2 row-start-1 inline-flex h-9 shrink-0 items-center rounded-full border border-oai-gray-200 p-1 dark:border-oai-gray-800 sm:col-start-1 sm:row-start-3 sm:justify-self-start",children:["week","month","total"].map(t=>{const u=N===t;return e.jsxs("button",{onClick:()=>oa(t),disabled:v.loading,className:d("px-3 sm:px-4 h-7 text-sm font-medium rounded-full flex items-center justify-center transition-colors relative",u?"text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200"),children:[e.jsx("span",{className:"relative z-10",children:t==="week"?Te:t==="month"?Ae:Me}),u&&e.jsx(Ka.div,{layoutId:"leaderboard-period-active-bg",className:"absolute inset-0 bg-oai-gray-200 dark:bg-oai-gray-800 rounded-full z-0",transition:{type:"spring",stiffness:380,damping:30}})]},t)})}),e.jsxs("div",{className:"col-span-2 row-start-2 mb-0 flex w-full min-w-0 items-center justify-between sm:justify-end gap-2.5 sm:col-span-1 sm:col-start-2 sm:row-start-3 sm:mb-0 sm:w-auto sm:shrink-0",children:[e.jsx(jr,{communityStats:Le,onClick:()=>je(!0)}),e.jsx(hr,{me:K,totalEntries:sa,meLabel:I,onOpenProfile:K?.user_id?()=>Y(K.user_id):void 0,onJumpToMe:da,canJump:z!=null&&!la&&!v.loading,className:"shrink-0"})]})]}),!r&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:s("leaderboard.signin_prompt")}),e.jsx("button",{onClick:i,className:"shrink-0 whitespace-nowrap self-start sm:self-auto px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 transition-colors",children:s("leaderboard.signin_button")})]}),g&&ee&&!ra&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:s("leaderboard.sync_prompt")}),e.jsx("button",{onClick:ca,disabled:Ne,className:"shrink-0 whitespace-nowrap self-start sm:self-auto px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 disabled:opacity-50 transition-colors",children:Ne?s("leaderboard.sync_button.busy"):s("leaderboard.sync_button.idle")})]}),e.jsxs("div",{className:"sm:rounded-xl sm:border sm:border-oai-gray-200 sm:dark:border-oai-gray-800 sm:overflow-hidden border-none bg-transparent",children:[v.error&&J?e.jsx("div",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-3",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v.error})}):null,O,e.jsxs("div",{className:"flex flex-col gap-3 sm:border-t border-oai-gray-200 px-4 py-3 sm:flex-row sm:items-center sm:justify-end sm:gap-x-4 sm:px-6 dark:border-oai-gray-800 border-none mt-2.5 sm:mt-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:justify-start",children:[e.jsx("label",{htmlFor:"leaderboard-page-size",className:"whitespace-nowrap",children:s("leaderboard.pagination.page_size_label")}),e.jsx(Pa,{id:"leaderboard-page-size",value:_,onValueChange:t=>ea(Number(t)),disabled:v.loading,ariaLabel:s("leaderboard.pagination.page_size_label"),options:ce.map(t=>({value:t,label:String(t)})),align:"end",className:"px-3 py-1 text-oai-gray-700 dark:text-oai-gray-300"})]}),e.jsx("div",{className:"hidden h-5 w-px bg-oai-gray-200 dark:bg-oai-gray-800 sm:block","aria-hidden":"true"}),e.jsxs("div",{className:"flex w-full items-center justify-between sm:w-auto sm:justify-end gap-1.5",children:[e.jsx("button",{className:d("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Ke&&!v.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>M(t=>Math.max(1,t-1)),disabled:!Ke||v.loading,children:s("leaderboard.pagination.prev")}),e.jsxs("span",{className:"text-xs font-semibold tabular-nums text-oai-gray-500 dark:text-oai-gray-455 px-2 sm:hidden",children:[P," / ",U||"?"]}),e.jsx("div",{className:"hidden sm:flex items-center gap-1",children:se}),e.jsx("button",{className:d("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Re&&!v.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>M(t=>t+1),disabled:!Re||v.loading,children:s("leaderboard.pagination.next")})]})]})]})]})}),e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("p",{children:s("landing.v2.footer.line")}),e.jsx("a",{href:"https://github.com/xiufengsun/TokenTracker",className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:s("landing.v2.nav.github")})]})}),e.jsxs(c.Suspense,{fallback:null,children:[e.jsx(fr,{isOpen:!!ke,userId:ke,period:N,accessToken:C,onClose:Qe}),e.jsx(yr,{isOpen:Xe,onClose:()=>je(!1),communityStats:Le})]})]})}export{Zr as LeaderboardPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m as re,I as ce,a as ge,r as o,c as a,j as e,e as h}from"./__vite-browser-external-sJsF0ioo.js";const ue=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],me=re("arrow-left",ue);const xe=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],he=re("mail",xe),be=e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),fe=e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),pe={google:be,github:fe},ye={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function we(i){return ye[i]||String(i||"").replace(/-/g," ")}function ke(i){if(typeof i=="string"&&i.trim())return i.trim();if(i&&typeof i=="object"){if(typeof i.token=="string"&&i.token.trim())return i.token.trim();if(typeof i.otp=="string"&&i.otp.trim())return i.otp.trim()}return""}function je({title:i,subtitle:H,className:ae="",onSuccess:S,hideLogo:D=!1,initialMode:p="signin",tokenFromUrl:P="",initialEmail:y="",initialCode:v=""}){ce();const{enabled:w,signedIn:j,refreshUser:E,signInWithPassword:G,signUp:Z,signInWithOAuth:T,getPublicAuthConfig:V,sendResetPasswordEmail:$,exchangeResetPasswordToken:U,resetPassword:W}=ge(),[n,u]=o.useState(p),[c,k]=o.useState(y),[m,N]=o.useState(""),[A,L]=o.useState(""),[M,te]=o.useState(""),[q,z]=o.useState(v),[_,x]=o.useState(!1),[J,s]=o.useState(null),[C,b]=o.useState(null),[F,O]=o.useState(!1),[oe,se]=o.useState(!!(p!=="signin"||y)),[I,K]=o.useState(!0),[R,Q]=o.useState([]),[X,ie]=o.useState(8);o.useEffect(()=>{p&&u(p)},[p]),o.useEffect(()=>{y&&k(y)},[y]),o.useEffect(()=>{v&&z(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return K(!0),(async()=>{const{data:t,error:l}=await V();if(r){if(l||!t)Q(["google","github"]);else{const d=Array.isArray(t.oAuthProviders)?t.oAuthProviders:[],f=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];Q([...d,...f]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&ie(t.passwordMinLength)}K(!1)}})(),()=>{r=!1}},[w,V]),o.useEffect(()=>{j&&S&&S()},[j,S]);const Y=o.useMemo(()=>typeof window>"u"?"":!!window.webkit?.messageHandlers?.nativeOAuth?`${window.location.origin}/auth/callback`:`${window.location.origin}/`,[]),ee=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),x(!0);try{const{error:t}=await T(r,Y);t&&s(t.message||String(t))}finally{x(!1)}},[T,Y]);o.useEffect(()=>{if(!w||I||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),l=t.get("native")==="1",d=t.get("provider");l&&d&&[...R].includes(d)&&B(d)},[w,I,j,R,B]);const ne=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{if(n==="signup"){const{data:l,error:d}=await Z({email:c.trim(),password:m,name:M.trim()||void 0});if(d){s(d.message||String(d));return}if(l?.requireEmailVerification){b(a("login.verify_email_pending")),u("signin");return}await E();return}const{error:t}=await G({email:c.trim(),password:m});if(t){s(t.message||String(t));return}await E()}finally{x(!1)}},[n,c,m,M,Z,G,E]),le=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{const t=c.trim(),{error:l}=await $({email:t,redirectTo:ee});if(l){s(l.message||String(l));return}k(t),b(a("reset_password.request.sent")),u("reset_confirm")}finally{x(!1)}},[c,ee,$]),de=o.useCallback(async r=>{if(r.preventDefault(),s(null),m!==A){s(a("reset_password.error.password_mismatch"));return}x(!0);try{let t=P;if(!t){const{data:d,error:f}=await U({email:c.trim(),code:q.trim()});if(f){s(f.message||String(f));return}if(t=ke(d),!t){s(a("reset_password.error.missing_token"));return}}const{error:l}=await W({newPassword:m,otp:t});if(l){s(l.message||String(l));return}O(!0),b(a("reset_password.success"))}finally{x(!1)}},[q,A,c,U,m,W,P]);if(!w)return null;const g=n==="reset_email"||n==="reset_confirm";return e.jsxs("div",{className:h("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",ae),children:[g&&e.jsxs("button",{type:"button",onClick:()=>{u("signin"),b(null),s(null),O(!1),N(""),L("")},className:"flex items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors mb-4 focus:outline-none",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:h("mb-6",g?"text-left":"text-center"),children:[!D&&!g&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white font-oai tracking-tight",children:a("shared.app_name")})]}),e.jsx("h2",{className:h("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(D||g)&&"text-base font-bold md:text-lg"),children:g?a("reset_password.title"):i||a("login_modal.subtitle")}),!g&&H&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px] mx-auto",children:H}),g&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px]",children:C&&n==="reset_confirm"&&!F?C:a("reset_password.subtitle")})]}),C&&(!g||F)&&e.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:C}),J&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:J}),n==="reset_email"&&e.jsxs("form",{onSubmit:le,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.request.submit")})]}),n==="reset_confirm"&&(F?e.jsx("button",{type:"button",onClick:()=>{u("signin"),O(!1),b(null),s(null),N(""),L("")},className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors text-center shadow-sm",children:a("reset_password.success_cta")}):e.jsxs("form",{onSubmit:de,className:"space-y-3",children:[!P&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email-confirm",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-code",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.code")}),e.jsx("input",{id:"card-reset-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:q,onChange:r=>z(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.new_password")}),e.jsx("input",{id:"card-reset-password",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:m,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.confirm_password")}),e.jsx("input",{id:"card-reset-password-confirm",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:A,onChange:r=>L(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.reset.submit")})]})),!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2.5 mb-5",children:I?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"}),e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"})]}):R.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:h("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[pe[r]||null,a("login.oauth.continue",{provider:we(r)})]},r))}),oe?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login_modal.divider_email")})})]}),e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[e.jsx("button",{type:"button",className:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{u("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{u("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:ne,className:"space-y-3",children:[n==="signup"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.name")}),e.jsx("input",{id:"card-name",type:"text",autoComplete:"name",value:M,onChange:r=>te(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:a("login.field.name_placeholder")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-email",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.password")}),e.jsx("input",{id:"card-password",type:"password",autoComplete:n==="signup"?"new-password":"current-password",required:!0,minLength:n==="signup"?X:void 0,value:m,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),n==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:a("login.password_hint",{min:String(X)})}),n==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{u("reset_email"),s(null),b(null)},className:"text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white no-underline bg-transparent border-0 p-0 cursor-pointer focus:outline-none",children:a("login.forgot_password")})})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:n==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login.divider")})})]}),e.jsxs("button",{type:"button",onClick:()=>se(!0),className:h("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[e.jsx(he,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{je as L};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m as L,W as se,af as oe,r as n,ag as le,ah as ne,ai as de,S as q,c as r,j as e,e as g,aj as ce,a4 as V,X as pe}from"./__vite-browser-external-sJsF0ioo.js";import{u as me,T as F,S as xe}from"./Controls-VDvgw_ed.js";import{P as be}from"./ProviderIcon-DqqwXu3b.js";import{B as W,C as _,a as ue,b as ge}from"./skins-C8EyB85e.js";import{n as he,p as fe,C as X}from"./ClawdAnimated-CtX8cne4.js";import{F as $}from"./FadeIn-CEJfaKnL.js";import{L as ye}from"./link-2-CWHBxVuk.js";import{L as Y}from"./loader-circle-9l5p9Dwa.js";import{Z as ke}from"./zap-Vx_j5oJN.js";import{T as ve}from"./trash-CVdV1bBR.js";import{D as je,a as we,b as Ne,c as Ce,d as Se,e as Pe}from"./DialogTitle-BWYdq4TT.js";import{D as Ie}from"./DialogDescription-DRQEfAWH.js";import{D as ze}from"./DialogClose-8pTCallP.js";import"./Card-BRWOMoBk.js";import"./react-xH4nkyuj.js";import"./use-reduced-motion-BfdrKOsS.js";import"./composite-CSBcryzA.js";import"./store-DneqOW0h.js";const Ae=[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]],De=L("file-archive",Ae);const Te=[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],_e=L("monitor-up",Te);const Be=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Le=L("upload",Be),Ee={visible:!1,character:"clawd",size:"medium",botColor:"auto"};function Oe(){const t=se()&&oe(),[a,o]=n.useState(Ee);n.useEffect(()=>{if(!t)return;const c=le(l=>{o({visible:!!l.visible,character:he(l.character),size:["small","medium","large"].includes(l.size)?l.size:"medium",botColor:W.includes(l.botColor)?l.botColor:"auto"})});return ne(),c},[t]);const s=n.useCallback((c,l)=>{o(x=>({...x,[c]:l})),t&&de(c,l)},[t]);return{available:t,settings:a,setSetting:s}}const v=[{id:"clawd",displayName:"Clawd",nameKey:"pet.character.clawd",spriteVersionNumber:1,custom:!1},{id:"bot",displayName:"Bot",nameKey:"pet.character.bot",spriteVersionNumber:1,custom:!1},{id:"sprout",displayName:"Sprout",nameKey:"pet.character.sprout",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/sprout/spritesheet.webp"},{id:"byte",displayName:"Byte",nameKey:"pet.character.byte",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/byte/spritesheet.webp"},{id:"ember",displayName:"Ember",nameKey:"pet.character.ember",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/ember/spritesheet.webp"}];async function I(t){const a=await t.json().catch(()=>null);if(!t.ok||a?.ok===!1)throw new Error(a?.error||`Pet request failed with HTTP ${t.status}`);return a}async function Me(){const t=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),a=await I(t),o=new Set(Array.isArray(a.hiddenBuiltinIds)?a.hiddenBuiltinIds:[]);return[...v.filter(s=>!s.assetUrl||!o.has(s.id)),...Array.isArray(a.pets)?a.pets:[]]}async function E(t){const a=await q();return I(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function Ke(t){return E({action:"install_url",url:t})}async function H(t){const a=await q();return I(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...a},cache:"no-store",body:t}))}function Re(t){return E({action:"remove",id:t})}async function Ue(){const t=await fetch("/functions/tokentracker-pets?scope=codex",{headers:{Accept:"application/json"},cache:"no-store"}),a=await I(t);return{importable:Array.isArray(a.importable)?a.importable:[],codexDetected:a.codexDetected===!0}}function Ve(t){return E({action:"import_codex",ids:t})}let B=v;function Fe(){const[t,a]=n.useState(B),[o,s]=n.useState(!0),[c,l]=n.useState(!1),x=n.useCallback(async()=>{s(!0);try{const b=await Me();return B=b,a(b),l(!0),b}catch{return B=v,a(v),l(!1),v}finally{s(!1)}},[]);return n.useEffect(()=>{x()},[x]),{pets:t,loading:o,available:c,refresh:x}}const $e={clawd:"from-oai-amber-50 dark:from-orange-950/70",bot:"from-oai-brand-50 dark:from-teal-950/70",sprout:"from-oai-brand-100 dark:from-emerald-950/70",byte:"from-oai-gray-200 dark:from-slate-800/70",ember:"from-orange-100 dark:from-orange-950/80"};function He(){const t=r("pet.import.subtitle"),a="codex-pets.net",o=t.indexOf(a);return o<0?t:e.jsxs(e.Fragment,{children:[t.slice(0,o),e.jsx("a",{href:"https://codex-pets.net",target:"_blank",rel:"noreferrer",className:"underline decoration-oai-gray-400 underline-offset-2 transition-colors hover:text-oai-black dark:decoration-oai-gray-500 dark:hover:text-white",children:a}),t.slice(o+a.length)]})}const j=[{id:"idle-living",labelKey:"pet.state.calm"},{id:"working-thinking",labelKey:"pet.state.focus"},{id:"working-juggling",labelKey:"pet.state.multitask"},{id:"working-wizard",labelKey:"pet.state.streak"},{id:"happy",labelKey:"pet.state.celebrate"},{id:"sleeping",labelKey:"pet.state.rest"}];function Z({character:t,selected:a,onSelect:o,onRemove:s,removeDisabled:c}){const l=t.nameKey?r(t.nameKey):t.displayName;return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:o,"aria-pressed":a,className:g("relative w-full overflow-hidden rounded-xl border p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",a?"border-oai-brand-500/40 bg-white dark:border-oai-brand-500/25 dark:bg-oai-gray-900/80":"border-oai-gray-200/80 bg-white/55 hover:border-oai-gray-400 dark:border-oai-gray-800 dark:bg-oai-gray-950/55 dark:hover:border-oai-gray-600"),children:[e.jsx("div",{className:g("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",$e[t.id]||"from-oai-gray-200/80 dark:from-oai-gray-800/70")}),e.jsxs("div",{className:"relative flex items-center gap-2.5",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center",children:e.jsx(X,{state:"idle-living",character:t.id,pet:t,size:44})}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-oai-black dark:text-white",children:l}),t.spriteVersionNumber===2?e.jsx("span",{className:"shrink-0 rounded border border-oai-gray-300/80 px-1 text-[9px] font-semibold text-oai-gray-500 dark:border-oai-gray-600 dark:text-oai-gray-400",children:r("pet.format.v2")}):null,a?e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-oai-brand-500","aria-hidden":!0}):null]})]})]}),s?e.jsx("button",{type:"button",disabled:c,onClick:s,"aria-label":`${r("pet.import.remove")} · ${l}`,className:g("absolute right-1.5 top-1.5 flex h-6 w-6 items-center justify-center rounded-md border border-oai-gray-200/90 bg-white/95 text-oai-gray-500 transition-opacity hover:text-red-600 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-40 dark:border-oai-gray-700 dark:bg-oai-gray-900/95 dark:text-oai-gray-400 dark:hover:text-red-400","opacity-0 group-hover:opacity-100"),children:e.jsx(ve,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function qe({value:t,onChange:a}){const o={auto:r("pet.bot.color.auto"),bleu:r("pet.bot.color.bleu"),turquoise:r("pet.bot.color.turquoise"),vert:r("pet.bot.color.vert"),ambre:r("pet.bot.color.ambre"),rose:r("pet.bot.color.rose"),violet:r("pet.bot.color.violet")};return e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-1.5 rounded-full border border-black/5 bg-white/65 px-2.5 py-1.5 backdrop-blur-md dark:border-white/10 dark:bg-black/20",role:"radiogroup","aria-label":r("pet.bot.color"),children:W.map(s=>{const c=(t||"auto")===s;return e.jsx("button",{type:"button",role:"radio","aria-checked":c,"aria-label":o[s],title:o[s],onClick:()=>a(s),className:g("h-4 w-4 rounded-full border transition-transform duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",c?"scale-125 border-oai-black shadow-sm dark:border-white":"border-black/15 hover:scale-110 dark:border-white/25"),style:s==="auto"?{background:`linear-gradient(135deg, ${_.get(ue).hex} 0 50%, ${_.get(ge).hex} 50% 100%)`}:{background:_.get(s)?.hex}},s)})})}function We({pet:t,state:a,onStateChange:o,botColor:s,onBotColorChange:c}){const[l,x]=n.useState(null),b=n.useRef(null),h=j.find(function(d){return d.id===a}),p=r(h?.labelKey||"pet.state.calm");return e.jsxs("section",{className:"relative flex min-h-[400px] flex-col overflow-hidden bg-oai-gray-50 dark:bg-oai-gray-950 sm:min-h-[440px] lg:min-h-[480px]",onPointerMove:m=>{if(t?.spriteVersionNumber!==2||!b.current)return;const d=b.current.getBoundingClientRect(),w=m.clientX-(d.left+d.width/2),N=m.clientY-(d.top+d.height/2),y=(Math.atan2(w,-N)*180/Math.PI+360)%360;x(Math.round(y/22.5)%16)},onPointerLeave:()=>x(null),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.16] dark:opacity-[0.12]",style:{backgroundImage:"radial-gradient(currentColor 0.7px, transparent 0.7px)",backgroundSize:"14px 14px"},"aria-hidden":!0}),e.jsxs("div",{className:"relative flex items-center justify-between gap-3 px-5 pt-5",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.preview.states")}),e.jsxs("div",{className:"flex items-center gap-2",children:[fe(t?.id)==="vector"?e.jsx(qe,{value:s,onChange:c}):null,e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-black/5 bg-white/65 px-3 py-1.5 text-[11px] font-medium text-oai-gray-600 backdrop-blur-md dark:border-white/10 dark:bg-black/20 dark:text-oai-gray-300",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500","aria-hidden":!0}),p]})]})]}),e.jsx("div",{className:"relative flex flex-1 items-center justify-center px-6 py-5",children:e.jsx("div",{ref:b,className:"relative flex h-52 w-52 items-center justify-center sm:h-56 sm:w-56 lg:h-64 lg:w-64",children:e.jsx("div",{className:"origin-bottom lg:scale-[1.18]",children:e.jsx(X,{state:a,character:t?.id||"clawd",pet:t,size:190,lookDirectionIndex:l,botColor:s})})})}),e.jsx("div",{className:"relative border-t border-oai-gray-200/70 bg-white/85 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-950/85",children:e.jsx("div",{className:"grid grid-cols-3 gap-1","aria-label":r("pet.preview.states"),children:j.map(m=>e.jsxs("button",{type:"button",onClick:()=>o(m.id),"aria-pressed":a===m.id,className:g("flex min-h-10 flex-col items-center justify-center gap-1 rounded-lg px-1.5 text-xs transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500",a===m.id?"font-semibold text-oai-black dark:text-white":"font-medium text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[e.jsx("span",{children:r(m.labelKey)}),e.jsx("span",{className:g("h-1 w-1 rounded-full transition-colors duration-200",a===m.id?"bg-oai-black dark:bg-white":"bg-transparent"),"aria-hidden":!0})]},m.id))})})]})}function Xe({pets:t,busy:a,error:o,onImport:s,onClose:c}){const[l,x]=n.useState(()=>new Set),b=p=>x(m=>{const d=new Set(m);return d.has(p)?d.delete(p):d.add(p),d}),h=t.length!==0&&l.size===t.length;return e.jsx(je,{open:!0,onOpenChange:p=>{!p&&!a&&c()},children:e.jsxs(we,{children:[e.jsx(Ne,{className:"fixed inset-0 z-50 bg-black/15 backdrop-blur-md dark:bg-black/40 animate-tt-fade-in"}),e.jsx(Ce,{className:"fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6",children:e.jsxs(Se,{className:"relative flex max-h-[86vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-oai-gray-200/50 bg-white/95 shadow-2xl backdrop-blur-2xl dark:border-white/10 dark:bg-oai-gray-900/95 animate-tt-modal",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-oai-gray-200/70 px-5 py-4 dark:border-oai-gray-800",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(Pe,{className:"text-base font-semibold",children:r("pet.codex.title")}),e.jsx(Ie,{className:"mt-0.5 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.codex.subtitle")})]}),e.jsx(ze,{type:"button",disabled:a,"aria-label":r("pet.codex.close"),className:"shrink-0 rounded-full border border-oai-gray-200/60 p-1.5 text-oai-gray-500 transition-colors hover:text-oai-black disabled:opacity-40 dark:border-oai-gray-800/60 dark:text-oai-gray-400 dark:hover:text-white",children:e.jsx(pe,{size:16})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[t.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-oai-gray-400 dark:text-oai-gray-500",children:r("pet.codex.empty")}):e.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:t.map(p=>e.jsx(Z,{character:p,selected:l.has(p.id),onSelect:()=>b(p.id)},p.id))}),o?e.jsx("p",{role:"alert",className:"mt-3 text-xs text-red-600 dark:text-red-400",children:o}):null]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-oai-gray-200/70 px-5 py-3 dark:border-oai-gray-800",children:[e.jsx("button",{type:"button",disabled:a||t.length===0,onClick:()=>x(h?new Set:new Set(t.map(p=>p.id))),className:"text-xs font-medium text-oai-gray-500 underline-offset-2 hover:underline disabled:opacity-40 dark:text-oai-gray-400",children:r("pet.codex.select_all")}),e.jsxs("button",{type:"button",disabled:a||l.size===0,onClick:()=>s([...l]),className:"flex h-9 items-center gap-1.5 rounded-lg bg-oai-black px-4 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[a?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,l.size>0?`${r("pet.codex.import")} · ${l.size}`:r("pet.codex.import")]})]})]})})]})})}function xt(){const{available:t,settings:a,setSetting:o}=Oe(),{pets:s,loading:c,available:l,refresh:x}=Fe(),[b,h]=n.useState(""),[p,m]=n.useState(""),[d,w]=n.useState(!1),[N,y]=n.useState([]),[G,z]=n.useState(!1),[C,O]=n.useState(!1),[J,A]=n.useState(""),[Q,M]=n.useState("idle-living"),[K,ee]=n.useState(!0),k=a.character||"clawd",D=me(),R=D.settings?.menuBarIconStyle==="pet",te=s.find(i=>i.id===k)||s[0],S=d?{kind:"busy",text:r("pet.import.busy")}:p?{kind:"error",text:p}:null,U=N.length!==0;n.useEffect(()=>{!c&&s.length>0&&!s.some(i=>i.id===k)&&o("character","clawd")},[c,s,k,o]);async function P(i,u=r("pet.import.success")){w(!0),m("");try{const f=await i();await x(),ce(),f?.pet?.id&&o("character",f.pet.id),V({title:u,timeout:4e3}),h("")}catch(f){m(f?.message||r("pet.import.failed"))}finally{w(!1)}}const T=n.useCallback(async()=>{if(!l){y([]);return}try{const i=await Ue();y(i.importable)}catch{y([])}},[l]);n.useEffect(()=>{T()},[T]);async function ae(i){O(!0),A("");try{return await Ve(i),await x(),await T(),V({title:r("pet.codex.imported"),timeout:4e3}),!0}catch(u){return A(u?.message||r("pet.import.failed")),!1}finally{O(!1)}}n.useEffect(()=>{if(!K)return;const i=window.setInterval(()=>{M(u=>{const f=j.findIndex(ie=>ie.id===u);return j[(f+1)%j.length].id})},5e3);return()=>window.clearInterval(i)},[K]);const re=[{value:"small",label:r("pet.size.small")},{value:"medium",label:r("pet.size.medium")},{value:"large",label:r("pet.size.large")}];return e.jsx("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-14 pt-8 sm:pt-10",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[e.jsx($,{y:12,children:e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:r("pet.page.title")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.page.subtitle")})]})}),e.jsx($,{y:12,delay:.04,children:e.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-oai-gray-200 bg-white/75 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 lg:grid lg:grid-cols-[1.12fr_0.88fr]",children:[e.jsx(We,{pet:te,state:Q,onStateChange:i=>{ee(!1),M(i)},botColor:a.botColor,onBotColorChange:i=>o("botColor",i)}),e.jsxs("aside",{className:"flex flex-col border-t border-oai-gray-200 p-5 dark:border-oai-gray-800 lg:min-h-[480px] lg:border-l lg:border-t-0",children:[e.jsxs("section",{"aria-labelledby":"pet-character-title",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"pet-character-title",className:"text-sm font-semibold",children:r("pet.characters.title")}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.characters.subtitle")})]}),e.jsx("div",{className:"mt-4 grid max-h-72 grid-cols-2 gap-2 overflow-y-auto pr-1 -mr-1",children:s.map(i=>e.jsx(Z,{character:i,selected:k===i.id,onSelect:()=>o("character",i.id),removeDisabled:d,onRemove:l&&i.id!=="clawd"&&i.id!=="bot"?()=>P(async()=>(await Re(i.id),k===i.id&&o("character","clawd"),null),r("pet.import.removed")):void 0},i.id))}),D.available?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 rounded-xl border border-oai-gray-200/70 bg-oai-gray-50/60 px-3 py-2.5 dark:border-oai-gray-800 dark:bg-oai-gray-900/40",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold",children:r("pet.menubar.title")}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.menubar.hint")})]}),e.jsx(F,{checked:R,onChange:()=>D.setSetting("menuBarIconStyle",R?"clawd":"pet"),ariaLabel:r("pet.menubar.title")})]}):null]}),l?e.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800","aria-labelledby":"pet-import-title",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"h-4 w-4 shrink-0 text-oai-gray-500","aria-hidden":!0}),e.jsx("h2",{id:"pet-import-title",className:"text-sm font-semibold",children:r("pet.import.title")})]}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:e.jsx(He,{})}),e.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:i=>{i.preventDefault(),!d&&b.trim()&&P(()=>Ke(b))},children:[e.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[e.jsx(ye,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{value:b,onChange:i=>h(i.target.value),"aria-label":r("pet.import.url_label"),placeholder:"codex-pets.net/#/pets/…",className:"h-9 w-full rounded-lg border border-oai-gray-200 bg-white pl-9 pr-3 text-xs outline-none focus:border-oai-brand-500 dark:border-oai-gray-700 dark:bg-oai-gray-950"})]}),e.jsxs("button",{type:"submit",disabled:d||!b.trim(),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-oai-black px-3.5 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[d?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,r("pet.import.add")]})]}),e.jsxs("div",{className:g("mt-2 grid gap-2",U?"grid-cols-2":"grid-cols-1"),children:[U?e.jsxs("button",{type:"button",disabled:d||C,onClick:()=>{A(""),z(!0)},className:g("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",(d||C)&&"pointer-events-none opacity-40"),children:[e.jsx(be,{provider:"codex",size:14,className:"fill-current"}),r("pet.codex.browse")]}):null,e.jsxs("label",{onDragOver:i=>i.preventDefault(),onDrop:i=>{if(i.preventDefault(),d)return;const u=i.dataTransfer?.files?.[0];u&&P(()=>H(u))},className:g("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",d&&"pointer-events-none opacity-40"),children:[e.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("pet.import.zip"),e.jsx("input",{type:"file",accept:".zip,.codex-pet.zip,application/zip",className:"sr-only",disabled:d,onChange:i=>{const u=i.target.files?.[0];u&&P(()=>H(u)),i.target.value=""}})]})]}),S?e.jsx("p",{role:S.kind==="error"?"alert":"status",className:g("mt-2 text-xs",S.kind==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400"),children:S.text}):null,G?e.jsx(Xe,{pets:N,busy:C,error:J,onClose:()=>{C||z(!1)},onImport:async i=>{await ae(i)&&z(!1)}}):null]}):null,e.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4 text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75,"aria-hidden":!0}),e.jsx("h2",{className:"text-sm font-semibold",children:r("pet.controls.title")})]}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm font-medium",children:r("pet.controls.show")}),e.jsx(F,{checked:a.visible,onChange:()=>o("visible",!a.visible),disabled:!t,ariaLabel:r("pet.controls.show")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm font-medium",children:r("pet.controls.size")}),e.jsx("div",{className:"shrink-0",children:e.jsx(xe,{options:re,value:a.size,onChange:i=>o("size",i),disabled:!t})})]})]})]}),t?null:e.jsxs("div",{className:"mt-6 flex gap-2 rounded-xl bg-oai-gray-100 p-3 text-xs leading-relaxed text-oai-gray-500 dark:bg-oai-gray-800/70 dark:text-oai-gray-400",children:[e.jsx(ke,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),r("pet.controls.native_only")]})]})]})})]})})})}export{xt as PetPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-sJsF0ioo.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 ge,r as u,an as pe,aS as he,at as me,au as be,a7 as X,aT as fe,aU as xe,u as ye,d as H,$ as ve,I as Q,n as D,aV as V,aW as ke,aX as je,V as ee,aY as Se,q as we,aZ as Ne,a_ as Ce,a$ as Ee,b0 as Pe,b1 as Ae,b2 as Oe,b3 as Le,b4 as te,L as _e,R as Te,b5 as Ie,b6 as Ge,a4 as B,_ as Re,h as Ue,f as De,b7 as Me,b8 as He,aw as Fe}from"./__vite-browser-external-sJsF0ioo.js";import{a as $e,b as K,s as Ve,K as Be,P as Ke,D as ze,c as qe,S as We,v as Ye,u as Ze,C as Je}from"./sortable.esm-BUPRsWL6.js";import{a as Xe}from"./modifiers.esm-Cwj0l9Zb.js";import{d as z,l as q,u as Qe,b as W}from"./use-limits-display-prefs-BACCRUMZ.js";import{P as et}from"./ProviderIcon-DqqwXu3b.js";import{m as ne}from"./react-xH4nkyuj.js";import{a as O,T as k,b,S as G,u as R}from"./Controls-VDvgw_ed.js";import{P as tt,u as nt,a as at}from"./use-session-efficiency-pref-BTm6RoSm.js";import{C as st}from"./check-DNq_ySSn.js";import{C as it}from"./copy-DHRrNtRb.js";import{A as ae}from"./index-21lDN4rA.js";import{u as ot}from"./useCurrency-CFjvWawL.js";import{u as rt}from"./useTokenFormat-Cf81HqWi.js";import{S as F}from"./Select-Cr9wq8mD.js";import{I as lt}from"./info-dv3Y0z8Q.js";import{C as ct}from"./ConfirmModal-ZZXg_OLV.js";import{A as dt}from"./arrow-up-right-BLDQog1A.js";import{D as ut}from"./download-CluyujgG.js";import{i as gt}from"./host-mode-Bc_iTzHk.js";import"./Card-BRWOMoBk.js";import"./ToolbarRootContext-DhpHv55w.js";import"./composite-CSBcryzA.js";import"./SelectItemText-BWnP4yuq.js";import"./DialogTitle-BWYdq4TT.js";import"./store-DneqOW0h.js";import"./DialogDescription-DRQEfAWH.js";const pt=[["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"}]],ht=I("flask-conical",pt);const mt=[["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"}]],bt=I("grip-vertical",mt);const ft=[["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"}]],xt=I("languages",ft);const yt=[["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"}]],vt=I("log-out",yt);const kt=[["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"}]],jt=I("palette",kt);const St=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],wt=I("user-round",St),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}=Ze({id:e}),h={transform:Je.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(bt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),z(e)?t.jsx(et,{provider:z(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=$e(K(Ke,{activationConstraint:{distance:6}}),K(Be,{coordinateGetter:Ve})),l=({active:c,over:d})=>{d&&c.id!==d.id&&o(c.id,d.id)};return t.jsx(ze,{sensors:r,collisionDetection:qe,modifiers:[Xe],onDragEnd:l,children:t.jsx(We,{items:a,strategy:Ye,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(()=>pe()),r=a&&s&&he(),l=u.useCallback(async()=>{const c=!i;if(me(c),o(c),!!c)try{await be(()=>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,U]=u.useState(null),T=u.useMemo(()=>At(e),[e]),ce=u.useMemo(()=>Ot(e),[e]),de=u.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),ue=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:ce,githubError:E,githubInput:f,githubUrl:w,loadSetters:ue,nameInput:v,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:p,setEditingGithub:x,setEditingName:m,setGithubError:U,setGithubInput:S,setGithubUrl:N,setNameInput:j,setProfileLoading:l,setProfileSaving:d,setPublicProfileOn:s,setShowGithubOn:y,showGithubOn:A,userId:de}}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 fe({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 xe({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 Ut(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Dt(e,a){const s=u.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:u.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function 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=ge(),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=Dt(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:Ut(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function se({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(se,{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(se,{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 ie({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(tt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function oe({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(ie,{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 Kt({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(oe,{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 zt({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(oe,{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(ie,{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}=ye();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(Kt,{name:e}),t.jsx(zt,{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(st,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(it,{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(vt,{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:ke},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:je},{value:"system",label:n("settings.appearance.theme.system"),Icon:ee}]}function nn(){return[{value:Ne,label:n("settings.appearance.language.system")},{value:Ce,label:n("settings.appearance.language.english")},{value:Ee,label:n("settings.appearance.language.chinese")},{value:Pe,label:n("settings.appearance.language.traditional_chinese")},{value:Ae,label:n("settings.appearance.language.japanese")},{value:Oe,label:n("settings.appearance.language.korean")},{value:Le,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(xt,{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=Se().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===we)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(lt,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function cn(){const{theme:e,setTheme:a}=ve(),{locale:s,setLocale:i}=Q(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:d}=ot(),{mode:h,setMode:p,unitSystem:g,setUnitSystem:m}=rt();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:D.COMPACT,label:n("settings.appearance.token_format.compact")},{value:D.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!==D.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}=nt(),{enabled:s,toggle:i}=at(),{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(_e,{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(dt,{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(Te,{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(ut,{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="0.97.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:Ie,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(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(ct,{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 re="/functions/tokentracker-proxy-config",fn="/functions/tokentracker-proxy-test",xn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function le(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(re,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return le(a)}async function J(){const{getLocalApiAuthHeaders:e}=await Re(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-sJsF0ioo.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(!gt()){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(re,{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=le(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=Qe(),{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]=Ue(),g=De(),m=h.get("section"),j=Object.values(C).includes(m)&&(m!==C.NATIVE_APP||a)&&(m!==C.NETWORK||r)?m:C.APPEARANCE,A=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:jt,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:Me,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:He,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(Fe,{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:ht,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:U})=>{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(U,{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 +0,0 @@
|
|
|
1
|
-
import{m as ft,r as i,v as xa,j as e,X as Le,c as r,e as se,ax as ua,ay as yt,t as bt,az as kt,aA as wt,E as vt,aB as jt,aC as Nt,aD as Ct,aE as St,w as _t,aF as It,aG as Lt,aH as Rt,aI as Pt,a3 as Bt,a as Dt,aJ as Et,an as Tt,G as At,B as X,R as Ot,d as $t,aK as Mt,a4 as W}from"./__vite-browser-external-sJsF0ioo.js";import{L as Ut,I as ha}from"./LocalOnlyNotice-DKIxuBP0.js";import{C as Ft}from"./Card-BRWOMoBk.js";import{C as da}from"./ConfirmModal-ZZXg_OLV.js";import{S as zt}from"./SegmentedControl-iHtWKWtc.js";import{I as Ra}from"./info-dv3Y0z8Q.js";import{P as ve}from"./ProviderIcon-DqqwXu3b.js";import{m as wa}from"./react-xH4nkyuj.js";import{u as Vt}from"./useCurrency-CFjvWawL.js";import{E as ma}from"./external-link-Cf12tdLf.js";import{L as Y}from"./loader-circle-9l5p9Dwa.js";import{M as Pa}from"./monitor-smartphone-B-9at3iV.js";import{C as Re}from"./check-DNq_ySSn.js";import{T as pa}from"./trash-CVdV1bBR.js";import{A as Kt}from"./index-21lDN4rA.js";import{u as qt}from"./use-reduced-motion-BfdrKOsS.js";import{u as Ht,k as Gt,l as Wt,m as Qt,n as Xt,o as Jt,p as Yt,q as Zt,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-BWnP4yuq.js";import{t as er,u as $a,a as ar}from"./composite-CSBcryzA.js";import{u as tr,C as fa}from"./ToolbarRootContext-DhpHv55w.js";import{g as rr,a as sr,p as nr,m as ir,b as or,d as lr,c as dr,e as cr,f as ur,s as mr,i as gr,u as va,h as ja,r as xr,j as Na,k as Ca,l as Sa,n as hr,o as pr}from"./skills-api-B7lb1cjO.js";import{F as fr}from"./flame-CJEYinxo.js";import{S as ga}from"./search-Ut41Fw1G.js";import{P as Ma}from"./plus-C_CTQjDD.js";import{D as Ua}from"./download-CluyujgG.js";import{P as Fa,a as za,b as Va,c as Ka,d as qa}from"./PopoverPopup-DWIMb8D6.js";import"./arrow-up-right-BLDQog1A.js";import"./DialogTitle-BWYdq4TT.js";import"./store-DneqOW0h.js";import"./DialogDescription-DRQEfAWH.js";const yr=[["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"}]],ya=ft("circle-arrow-up",yr),Ha=i.forwardRef(function(s,d){const{render:l,className:p,style:g,...x}=s,v={open:Ht().useState("open")};return xa("span",s,{state:v,ref:d,props:[{"aria-hidden":!0,children:"▼"},x],stateAttributesMapping:er})}),br="tt:hint:dismissed:";function Ga(a){return br+a}function kr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ga(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(Ga(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 Wa(a){return{checked(s){return a.indeterminate?{}:s?{[jr]:""}:{[Nr]:""}},...Gt}}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 Qa=i.createContext(void 0);function Br(){const a=i.useContext(Qa);if(a===void 0)throw new Error(yt(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}=Wt(),{disabled:B,name:fe,setDirty:_,setFilled:U,setFocused:q,setTouched:E,state:Z,validationMode:J,validityData:je,validation:ce}=Qt(),Pe=Sr(),{labelId:He,registerControlId:Be,getDescriptionProps:De}=Xt(),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=Jt({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}=bt({disabled:D,native:K}),ae=S?.validation??ce,[T,Se]=Yt({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;Zt(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=kt(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]),tr(T,()=>{S||(ne(ee),_(T!==je.initialValue),ae.change(T))});const Xe=wt({checked:T,disabled:D,form:y,name:j?void 0:ee,id:K?void 0:ie,required:P,ref:ia,style:ee?Ct:St,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=_t(It,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)||""}:vt,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=Wa(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),Nt(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&&jt(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(Qa.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}=ar(v),u=i.useRef(null),j={...y,transitionStatus:N};Lt({batch:!0,enabled:!v,open:v,ref:u,onComplete(){v||I(!1)}});const C={...Wa(y),...Rt},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 Xa(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=Xa(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=Xa(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(Kt,{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=qt(),{currency:N,rate:I}=Vt(),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:Pt(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:Bt(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 Ja(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function Kr(a){return Ja(a).split("/").filter(Boolean).pop()||""}function qr(a){if(a.repoOwner||a.repoName)return"";const s=Ja(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Ia(a){const s=Kr(a.directory);return s?`dir:${s}`:""}function Ya(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 Ya(d))s.add(l);return s}function aa(a){return`install:${na(a)}`}function La(a){return`remove:${a.id||a.directory}`}function Za(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===Za(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(Mt,{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(Ha,{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=$t.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(Ft,{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=Dt()||{},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 rr();if(ae.current!==t)return;const o={skills:n.skills||[],targets:n.targets||[]};x(o);const h=Et();!s||!Tt()||!h||typeof d!="function"||(async()=>{try{const b=await d();if(!b||ae.current!==t)return;const[w]=await Promise.allSettled([sr(b),nr({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:ir(o.skills,ke,h)})}catch{}})()},[d,s]),ge=i.useCallback(async()=>{const t=await or();I(t.repos||[])},[]),G=i.useCallback(async({force:t=!1}={})=>{De(!0);try{const n=await lr({force:t});y(n.skills||[])}finally{De(!1)}},[]),xe=i.useCallback(async({force:t=!1}={})=>{We(!0);try{const n=await dr({force:t});$e(n.skills||[])}finally{We(!1)}},[]),A=i.useCallback(async()=>{try{const t=await cr();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 ur(),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&&!At())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Ut,{})});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 gr(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 xr(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(Za(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})}))},et=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})})},at=new Set((g.skills||[]).map(t=>t.id).filter(Boolean)),la=Object.entries(ue).filter(([t,n])=>n&&at.has(t)).map(([t])=>t),tt=la.length,rt=()=>{la.length&&Ee(la)},st=()=>{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 mr(t);f(n.skills||[])}catch(n){L(n?.message||r("skills.error.generic"))}finally{ce.current=!1,je("")}}},nt=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 pr({owner:n,name:o,branch:"main",enabled:!0}),B(""),await ge(),await G()})},it=async t=>{await F(`repo:${t.owner}/${t.name}`,async()=>{await hr(t.owner,t.name),await ge(),await G()})},le=g.targets||[],ot=le.filter(ba),be=g.skills||[],lt=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]),dt=U!=="all",re=i.useMemo(()=>E&&be.find(t=>(t.id||t.directory)===E)||null,[be,E]),ct=i.useCallback(()=>{q("all"),K("")},[]),ut=i.useCallback(t=>{Z(n=>{const o=t?.id||t?.directory||null;return n===o?null:o})},[]),mt=i.useCallback(()=>Z(null),[]),gt=i.useCallback(t=>{const n=na(t).toLowerCase(),o=Ia(t),h=(g.skills||[]).find(b=>{const w=Ya(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]),xt=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})}),ht=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=xt;else if(l==="my")Ze=be.length?e.jsx(Zr,{items:lt,totalCount:be.length,targets:le,agentOptions:le,agentFilter:U,onAgentFilter:q,anyFilter:dt,onClearFilters:ct,searchQuery:M,onSearchQuery:K,searchPlaceholder:r("skills.my.placeholder"),selectedId:E,onSelect:ut,onToggleTarget:k,busyKey:J,updates:ue,selectedIds:ie,onToggleSelect:oe,onClearSelection:z,onBulkSync:Ie,onBulkRemove:ze,updateCount:tt,onUpdateAll:rt}):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=ht: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:ot,defaultTargets:_a,onInstall:oa,onManage:gt})},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:nt,onRemove:it})}):null,pt=!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,pt]})}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(Ot,{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(zt,{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(fr,{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(Ha,{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:et,onClose:mt,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:st})]})}export{Ds as SkillsPage,Gr as buildLocallyInstalledKeys};
|