tokentracker-cli 0.77.2 → 0.79.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/README.de.md +21 -0
- package/README.md +21 -0
- package/dashboard/dist/achievements/README.md +9 -0
- package/dashboard/dist/achievements/arctic-code-vault-contributor.png +0 -0
- package/dashboard/dist/achievements/galaxy-brain.png +0 -0
- package/dashboard/dist/achievements/heart-on-your-sleeve.png +0 -0
- package/dashboard/dist/achievements/open-sourcerer.png +0 -0
- package/dashboard/dist/achievements/pair-extraordinaire.png +0 -0
- package/dashboard/dist/achievements/proxima-pioneer.png +0 -0
- package/dashboard/dist/achievements/proxima-staffshipper.png +0 -0
- package/dashboard/dist/achievements/proxima-staffuser.png +0 -0
- package/dashboard/dist/achievements/public-sponsor.png +0 -0
- package/dashboard/dist/achievements/pull-shark.png +0 -0
- package/dashboard/dist/achievements/quickdraw.png +0 -0
- package/dashboard/dist/achievements/starstruck.png +0 -0
- package/dashboard/dist/assets/AchievementBadge-BxETKM1a.js +1 -0
- package/dashboard/dist/assets/AchievementsPage-BnsI7sbt.js +2 -0
- package/dashboard/dist/assets/AchievementsSection-BjKtfATU.js +1 -0
- package/dashboard/dist/assets/{ActivityHeatmap-CH6m_ZJM.js → ActivityHeatmap-B2NacPjc.js} +1 -1
- package/dashboard/dist/assets/BadgeDetailModal-BMNUpuro.js +1 -0
- package/dashboard/dist/assets/{Card-D_aKGDr7.js → Card-Y5og8UqF.js} +1 -1
- package/dashboard/dist/assets/{ClawdAnimated-vRiBiNhb.js → ClawdAnimated-4EGVuTbr.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-CjetJZ-5.js → CommunityStatsModal-DgQ5Cv9h.js} +1 -1
- package/dashboard/dist/assets/ConfirmModal-DNDMMsf7.js +1 -0
- package/dashboard/dist/assets/Controls-BzQP6AmV.js +1 -0
- package/dashboard/dist/assets/DashboardPage-C5nQV_pg.js +19 -0
- package/dashboard/dist/assets/DevicePage-Hc411Mif.js +1 -0
- package/dashboard/dist/assets/{DialogClose-hhTDeRp1.js → DialogClose-DG2e5iky.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-CD7W4GGZ.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-CA5znwms.js → DialogTitle-BlZXQboq.js} +1 -1
- package/dashboard/dist/assets/{FadeIn--ff4ZbC-.js → FadeIn-bR4Q4FyK.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-CTZvanhz.js → HeaderGithubStar-iujOMm58.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-Bg47gNVu.js → IpCheckPage-BVb5O-Nc.js} +4 -4
- package/dashboard/dist/assets/{LandingPage-DZ8Mz38n.js → LandingPage-B5JCSXIZ.js} +1 -1
- package/dashboard/dist/assets/LeaderboardAvatar-C5o48_SY.js +1 -0
- package/dashboard/dist/assets/LeaderboardPage-CNOPBahO.js +2 -0
- package/dashboard/dist/assets/LeaderboardProfileModal-Buo6oZZk.js +73 -0
- package/dashboard/dist/assets/{LeaderboardProfilePage-C4bGXJCE.js → LeaderboardProfilePage-DljcZHf7.js} +3 -3
- package/dashboard/dist/assets/{LimitsPage-BAQ10X55.js → LimitsPage-BOaJ4wfo.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-gtHCn7Mx.js → LocalOnlyNotice-BBxetUgv.js} +1 -1
- package/dashboard/dist/assets/LoginPage-LYriDN1G.js +1 -0
- package/dashboard/dist/assets/PetPage-CPPVItLo.js +1 -0
- package/dashboard/dist/assets/{PopoverPopup-CQxxgUXk.js → PopoverPopup-iP8jGLgj.js} +1 -1
- package/dashboard/dist/assets/ResetPasswordPage-BqAwHe1w.js +1 -0
- package/dashboard/dist/assets/Select-DdpTxWI0.js +1 -0
- package/dashboard/dist/assets/{SelectItemText-2LjzGvo5.js → SelectItemText-Cpno_HPs.js} +1 -1
- package/dashboard/dist/assets/SettingsPage-DtKCHKrt.js +1 -0
- package/dashboard/dist/assets/SkillsPage-D5vXnEab.js +1 -0
- package/dashboard/dist/assets/WidgetsPage-BIPU747m.js +1 -0
- package/dashboard/dist/assets/{WrappedPage-YxshTScX.js → WrappedPage-VfTcO6cY.js} +1 -1
- package/dashboard/dist/assets/{agent-logos-SeuxwQsp.js → agent-logos-sYidWnQM.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-Bm3t-iA0.js → arrow-up-right-Dt35aRs9.js} +1 -1
- package/dashboard/dist/assets/check-B2kgoEGi.js +1 -0
- package/dashboard/dist/assets/{copy-DUNz-xWm.js → copy-BdlX1Dcz.js} +1 -1
- package/dashboard/dist/assets/{download-COSLX73O.js → download-C4750cH0.js} +1 -1
- package/dashboard/dist/assets/flame-cYIuY1Z6.js +1 -0
- package/dashboard/dist/assets/{format-tokens-CR28AiQO.js → format-tokens-Ci6ia4_b.js} +1 -1
- package/dashboard/dist/assets/{info-Cm7V_KDO.js → info-Hy8GSxzK.js} +1 -1
- package/dashboard/dist/assets/{link-2-CYqDGrkv.js → link-2-CHfhV9M_.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-6XAdy2ec.js → loader-circle-OYZpObE-.js} +1 -1
- package/dashboard/dist/assets/main--YQ6HWXP.js +1237 -0
- package/dashboard/dist/assets/main-BY13exWE.css +1 -0
- package/dashboard/dist/assets/{trash-2-DKLewOQb.js → trash-2-DFV8X7qB.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-AdPaun74.js → use-community-stats-BzlENlsN.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-Bau4ykMw.js → use-limits-display-prefs-Bgxvo849.js} +1 -1
- package/dashboard/dist/assets/use-native-settings-Cz5XgWcy.js +1 -0
- package/dashboard/dist/assets/{use-ordered-list-BVaEJaWa.js → use-ordered-list-N591-3J4.js} +2 -2
- package/dashboard/dist/assets/{use-quality-per-dollar-pref-Htlc-uFe.js → use-quality-per-dollar-pref-CW332Qtp.js} +1 -1
- package/dashboard/dist/assets/use-transform-BNrGbsUe.js +1 -0
- package/dashboard/dist/assets/{use-usage-limits-BnzWTJQS.js → use-usage-limits-BL1n1H9j.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-bd6TLRsc.js → useCurrency-B5QegAgS.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-ajoWrfku.js → useScrollLock-CcorrDyq.js} +1 -1
- package/dashboard/dist/assets/zap-C_DbBJ3s.js +1 -0
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +1 -1
- package/src/commands/status.js +119 -12
- package/src/commands/sync.js +158 -83
- package/src/lib/install-resolver.js +1 -0
- package/src/lib/local-api.js +315 -56
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +18 -2
- package/dashboard/dist/assets/ConfirmModal-C6bZw6FZ.js +0 -1
- package/dashboard/dist/assets/Controls-Cj22oGL3.js +0 -1
- package/dashboard/dist/assets/DashboardPage-DPxiQkQw.js +0 -19
- package/dashboard/dist/assets/DevicePage-YAo4ert4.js +0 -1
- package/dashboard/dist/assets/DialogDescription-gxEpcUbJ.js +0 -1
- package/dashboard/dist/assets/LeaderboardAvatar-3T57GKKK.js +0 -1
- package/dashboard/dist/assets/LeaderboardPage-wP_yCU9I.js +0 -2
- package/dashboard/dist/assets/LeaderboardProfileModal-CfVMENby.js +0 -72
- package/dashboard/dist/assets/LoginPage-TXvIBzoW.js +0 -1
- package/dashboard/dist/assets/PetPage-Dj1jrxYe.js +0 -1
- package/dashboard/dist/assets/ResetPasswordPage-tN0tmSfP.js +0 -1
- package/dashboard/dist/assets/Select-DnbHYPS4.js +0 -1
- package/dashboard/dist/assets/SettingsPage-DosKS_L6.js +0 -1
- package/dashboard/dist/assets/SkillsPage-DaCJ25vT.js +0 -1
- package/dashboard/dist/assets/WidgetsPage-CCGemQVD.js +0 -1
- package/dashboard/dist/assets/check-D8Owfjyw.js +0 -1
- package/dashboard/dist/assets/main-BCstrDYE.js +0 -1172
- package/dashboard/dist/assets/main-BYdJ5vWR.css +0 -1
- package/dashboard/dist/assets/use-native-settings-CidwlprT.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a2 as p,r as c,j as e,aP as b}from"./main-BCstrDYE.js";const f={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_VERSION:"0.77.2",VITE_INSFORGE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3OC0xMjM0LTU2NzgtOTBhYi1jZGVmMTIzNDU2NzgiLCJlbWFpbCI6ImFub25AaW5zZm9yZ2UuY29tIiwicm9sZSI6ImFub24iLCJpYXQiOjE3ODExNDU5NDd9.T0auta_IrVIh0uXW1bob5QSnzvsnJmN28r5XkSGEuQY",VITE_INSFORGE_BASE_URL:"https://srctyff5.us-east.insforge.app"};function x(){return b(),`${(f&&"https://srctyff5.us-east.insforge.app"||"https://srctyff5.us-east.insforge.app").replace(/\/$/,"")}/functions/tokentracker-device-flow-grant`}function l(a){return(a||"").toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9-]/g,"")}function k(){const a=p(),[m,u]=c.useState(""),[t,r]=c.useState({kind:"idle",message:""});c.useEffect(()=>{try{const i=new URLSearchParams(window.location.search).get("user_code");i&&u(l(i))}catch{}},[]);async function g(d){if(d?.preventDefault?.(),!a?.signedIn){r({kind:"error",message:"Please sign in first."});return}const i=l(m);if(!/^[A-HJKMNP-Z2-9]{4}-[A-HJKMNP-Z2-9]{4}$/.test(i)){r({kind:"error",message:"Invalid code format. Expected XXXX-XXXX."});return}r({kind:"working",message:"Approving…"});try{const n=await a.getAccessToken?.();if(!n){r({kind:"error",message:"No access token — please sign in again."});return}const s=await fetch(x(),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({user_code:i})}),o=await s.json().catch(()=>({}));s.ok?r({kind:"success",message:o.status==="already_approved"?`Already approved earlier${o.client_info?" ("+o.client_info+")":""}.`:`Approved${o.client_info?" for "+o.client_info:""}. You can close this tab — your CLI will pick it up within a few seconds.`}):s.status===404?r({kind:"error",message:"Code not found. Double-check what your CLI printed."}):s.status===410?r({kind:"error",message:"Code expired. Re-run `tracker device-login` and try again."}):s.status===401?r({kind:"error",message:"Session expired. Sign out, sign in, and try again."}):r({kind:"error",message:o?.error||`Server error (HTTP ${s.status}).`})}catch(n){r({kind:"error",message:`Network error: ${n?.message||n}`})}}return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white dark:bg-oai-gray-950 px-6 py-12",children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-8",children:[e.jsx("h1",{className:"text-2xl font-semibold text-oai-gray-900 dark:text-white mb-2",children:"Approve your CLI"}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mb-6",children:"Type the code your CLI showed you. We'll link it to your account so token usage from that machine flows into your leaderboard profile."}),a?.signedIn?null:e.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 dark:bg-amber-900/20 dark:border-amber-800 p-4 mb-4",children:e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:"Sign in first, then return to this page."})}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400 mb-1",children:"CLI code"}),e.jsx("input",{type:"text",value:m,onChange:d=>u(l(d.target.value)),placeholder:"XXXX-XXXX",spellCheck:!1,autoCapitalize:"characters",maxLength:9,className:"w-full font-mono text-xl tracking-widest text-center rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-900 dark:text-white px-4 py-3 focus:outline-none focus:ring-inset focus:ring-2 focus:ring-emerald-600"})]}),e.jsx("button",{type:"submit",disabled:t.kind==="working"||!a?.signedIn,className:"w-full rounded-md bg-emerald-600 hover:bg-emerald-500 disabled:bg-oai-gray-300 disabled:cursor-not-allowed text-white font-medium py-3 transition-colors",children:t.kind==="working"?"Approving…":"Approve"})]}),t.kind==="success"&&e.jsx("div",{className:"mt-4 rounded-md border border-emerald-200 bg-emerald-50 dark:bg-emerald-900/20 dark:border-emerald-800 p-4",children:e.jsx("p",{className:"text-sm text-emerald-700 dark:text-emerald-300",children:t.message})}),t.kind==="error"&&e.jsx("div",{className:"mt-4 rounded-md border border-red-200 bg-red-50 dark:bg-red-900/20 dark:border-red-800 p-4",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:t.message})})]})})}export{k as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as n,b9 as a}from"./main-BCstrDYE.js";import{u as p}from"./DialogTitle-CA5znwms.js";import{u as c}from"./useScrollLock-ajoWrfku.js";const x=n.forwardRef(function(e,r){const{render:l,className:u,style:m,id:s,...t}=e,{store:i}=p(),o=c(s);return i.useSyncedValueWithCleanup("descriptionElementId",o),a("p",e,{ref:r,props:[{id:o},t]})});export{x as D};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as l,j as c,a0 as h}from"./main-BCstrDYE.js";function x(n){let t=0;const e=String(n??"");for(let r=0;r<e.length;r+=1)t=Math.imul(31,t)+e.charCodeAt(r)|0;return Math.abs(t)%360}function d(n){const t=String(n??"").trim();if(!t)return"?";const e=t.split(/\s+/).filter(Boolean);if(e.length>=2){const r=e[0][0]||"",i=e[1][0]||"";return`${r}${i}`.toUpperCase()}return t.slice(0,2).toUpperCase()}const m={sm:"h-7 w-7 min-h-7 min-w-7 text-[10px]",md:"h-8 w-8 min-h-8 min-w-8 text-[11px]",lg:"h-14 w-14 min-h-14 min-w-14 text-base",xl:"h-[68px] w-[68px] min-h-[68px] min-w-[68px] text-xl"};function g({avatarUrl:n,displayName:t,seed:e,size:r="md",className:i}){const o=m[r]||m.md,f=x(e??t??""),s=typeof n=="string"?n.trim():"",[u,a]=l.useState(!1);return l.useEffect(()=>{a(!1)},[s]),s&&!u?c.jsx("img",{src:s,alt:"",referrerPolicy:"no-referrer",onError:()=>a(!0),className:h("rounded-full object-cover ring-1 ring-white/10",o,i)}):c.jsx("div",{className:h("flex shrink-0 items-center justify-center rounded-full font-semibold text-white ring-1 ring-white/10",o,i),style:{backgroundColor:`hsl(${f} 42% 34%)`},"aria-hidden":!0,children:d(t)})}export{g as L};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeaderboardProfileModal-CfVMENby.js","assets/main-BCstrDYE.js","assets/main-BYdJ5vWR.css","assets/useCurrency-bd6TLRsc.js","assets/LeaderboardAvatar-3T57GKKK.js","assets/ActivityHeatmap-CH6m_ZJM.js","assets/info-Cm7V_KDO.js","assets/arrow-up-right-Bm3t-iA0.js","assets/link-2-CYqDGrkv.js","assets/check-D8Owfjyw.js","assets/DialogTitle-CA5znwms.js","assets/useScrollLock-ajoWrfku.js","assets/CommunityStatsModal-CjetJZ-5.js","assets/format-tokens-CR28AiQO.js","assets/DialogClose-hhTDeRp1.js","assets/DialogDescription-gxEpcUbJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as la,j as e,a0 as d,r as i,N as n,av as da,aw as ca,a1 as ua,a2 as ma,ax as xa,l as ga,n as ba,ay as pa,az as ha,aA as re,aa as ya,aB as fa,h as ka,$ as wa,L as va,Q as ja,am as Ie,O as Na,aC as _a,aD as Sa,aE as Le,aF as Ca,a8 as Be,S as La}from"./main-BCstrDYE.js";import{S as Pa}from"./Select-DnbHYPS4.js";import{a as Ma,C as Ea,u as Aa,b as Ka,c as Pe,D as Ta,d as Ra,S as za,h as Ia,s as Ba,K as Ua,P as Oa}from"./use-ordered-list-BVaEJaWa.js";import{u as $a}from"./useCurrency-bd6TLRsc.js";import{L as te}from"./LeaderboardAvatar-3T57GKKK.js";import{u as Da}from"./use-community-stats-AdPaun74.js";import"./SelectItemText-2LjzGvo5.js";import"./useScrollLock-ajoWrfku.js";import"./check-D8Owfjyw.js";const Fa=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ga=la("arrow-right",Fa),Ya=a=>{let{transform:r}=a;return{...r,y:0}};function D(a,{min:r,max:o,fallback:s}){const c=Number(a);if(!Number.isFinite(c))return s;const l=Math.floor(c);return l<r?r:l>o?o:l}function Ha(a,r){const o=D(r,{min:0,max:1e6,fallback:0}),s=D(a,{min:1,max:Math.max(1,o||1),fallback:1});if(o<=1)return[1];const c=new Set([1,o,s-2,s-1,s,s+1,s+2]),l=Array.from(c).filter(m=>Number.isInteger(m)&&m>=1&&m<=o).sort((m,h)=>m-h),b=[];let p=null;for(const m of l)p!=null&&m-p>1&&b.push(null),b.push(m),p=m;return b}function Wa({page:a,totalPages:r}){const o=typeof r=="number"&&Number.isFinite(r)&&r>=0,s=o?D(r,{min:0,max:1e6,fallback:0}):null,c=D(a,{min:1,max:o?Math.max(1,s||1):1e6,fallback:1}),l=c>1,b=o?c<s:!0;return{canPrev:l,canNext:b,safePage:c,safeTotal:s}}function Va({entries:a,me:r,meLabel:o}){const s=Array.isArray(a)?a:[],c=r&&typeof r.rank=="number"?r.rank:null;return!c||s.some(b=>!!b?.is_me)?s:[{rank:c,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},...s]}function Ja(a,r){const o=Number(a),s=Number(r);return!Number.isFinite(o)||o<1||!Number.isFinite(s)||s<1?null:Math.ceil(o/s)}const Za=new Set(["/brand-logos/cursor.svg","/brand-logos/kimi.svg","/brand-logos/kiro.svg","/brand-logos/copilot.svg","/brand-logos/hermes.svg"]);function qa({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 ${Za.has(a)?"dark:invert":""}`}):null,e.jsx("span",{className:"whitespace-nowrap",children:r})]})}const V=[{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}],Ue="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",Oe="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 oe(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/60")}function ne(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/60")}function j({className:a}){return e.jsx("div",{className:d("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",a)})}function Qa({index:a}){const r=a<3?"w-24":a<8?"w-20":"w-16",o=a<3?"w-16":"w-12",s=a<5?"w-14":"w-10";return e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:d(oe(!1),"!group-hover:bg-transparent"),children:e.jsx(j,{className:"h-4 w-6"})}),e.jsx("td",{className:d(ne(!1),"!group-hover:bg-transparent"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(j,{className:"h-8 w-8 min-w-8 rounded-full"}),e.jsx(j,{className:d("h-4",r)})]})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(j,{className:d("h-4",o)})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(j,{className:"h-4 w-12"})}),V.map(c=>e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(j,{className:d("h-4",s)})},c.key))]})}function Xa({rows:a=10}){return e.jsx("div",{className:"w-full overflow-x-auto",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(Ue,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(j,{className:"h-3.5 w-6"})}),e.jsx("th",{className:d(Oe,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(j,{className:"h-3.5 w-12"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(j,{className:"h-3.5 w-10"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(j,{className:"h-3.5 w-14"})}),V.map(r=>e.jsx("th",{className:"px-4 py-4",children:e.jsx(j,{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(Qa,{index:o},o))})]})})}function er({id:a,thClassName:r,children:o}){const{attributes:s,listeners:c,setNodeRef:l,transform:b,transition:p,isDragging:m}=Ma({id:a}),h=Ea.Transform.toString(b)||"";i.useLayoutEffect(()=>{const y=document.querySelectorAll(`td[data-column-key="${a}"]`),f="0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)";return y.forEach(x=>{x.style.transform=h,x.style.transition=p||"",x.style.zIndex=m?"20":"",x.style.position=h?"relative":"",x.style.boxShadow=m?f:""}),()=>{y.forEach(x=>{x.style.transform="",x.style.transition="",x.style.zIndex="",x.style.position="",x.style.boxShadow=""})}},[a,h,p,m]);const L={transform:h,transition:p,position:h?"relative":void 0,zIndex:m?20:void 0,boxShadow:m?"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:l,style:L,className:d(r,"group/col select-none cursor-grab active:cursor-grabbing touch-none"),...s,...c,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",m&&"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 ar="tokentracker.leaderboard.columnOrder.v1";function rr(a){return Aa(ar,a)}const tr=50;function or(a,r){const o=Number(a),s=Number(r);return!Number.isFinite(o)||o<1||!Number.isFinite(s)||s<1?null:Math.min(100,Math.max(1,Math.ceil(o/s*100)))}function $e(a){return typeof a=="string"?a.trim():""}function nr(a){const r=$e(a);return r?r.toLowerCase()==="anonymous":!0}function sr({me:a,totalEntries:r,meLabel:o,onOpenProfile:s,onJumpToMe:c,canJump:l,className:b}){const p=a&&typeof a.rank=="number"?a.rank:null;if(!p)return null;const m=Number(r)||0,h=or(p,m),L=$e(a?.display_name),y=!L||nr(L)?o||"You":L,f=a?.user_id||y,x=s||(l?c:null),E=typeof x=="function",A=E?"button":"div",J=E?{type:"button",onClick:x,"aria-label":n(s?"leaderboard.summary.view_profile":"leaderboard.summary.jump_to_me")}:{};return e.jsxs(A,{...J,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",E?"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]",b),children:[e.jsx(te,{size:"sm",avatarUrl:a?.avatar_url,displayName:y,seed:f}),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:y}),e.jsxs("span",{className:"text-xs font-bold tabular-nums text-oai-gray-800 dark:text-white",children:["#",p.toLocaleString()]}),h!=null&&h<=tr&&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",h<=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:n("leaderboard.summary.percentile",{p:String(h)})}),E?e.jsx(Ga,{"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 ir=i.lazy(()=>Be(()=>import("./LeaderboardProfileModal-CfVMENby.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(a=>({default:a.LeaderboardProfileModal}))),lr=i.lazy(()=>Be(()=>import("./CommunityStatsModal-CjetJZ-5.js"),__vite__mapDeps([12,1,2,13,10,11,14,15])).then(a=>({default:a.CommunityStatsModal}))),se=[10,20,50,100],ie=20,De="tokentracker:leaderboard:pageSize";function dr(){if(typeof window>"u")return ie;try{const a=window.localStorage.getItem(De),r=Number(a);if(se.includes(r))return r}catch{}return ie}function Me(a,r,o){const s=Number(a);if(!Number.isFinite(s)||s<=0)return"-";const c=Na(r),l=r===La?s:s*o;return l>=1e3?`${c}${Math.round(l).toLocaleString()}`:l>=10?`${c}${Math.round(l)}`:`${c}${l.toFixed(2)}`}function Ee({value:a}){return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sm:hidden",children:ja(a)}),e.jsx("span",{className:"hidden sm:inline",children:Ie(a)})]})}function cr({communityStats:a,onClick:r}){return a.status!=="ready"?null:e.jsxs("button",{type:"button",onClick:r,className:"inline-flex h-9 items-center gap-2.5 rounded-full border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50/50 dark:bg-white/[0.02] backdrop-blur-md px-3.5 select-none text-xs text-oai-gray-500 dark:text-oai-gray-400 hover:border-oai-brand-400 dark:hover:border-oai-brand-500/80 hover:bg-oai-brand-50/40 dark:hover:bg-oai-brand-950/20 transition-all duration-300 active:scale-[0.97] cursor-pointer",title:n("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:Math.round(a.tokenFloor).toLocaleString("en-US")}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:n("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.jsx("span",{className:"font-semibold text-oai-black dark:text-white tabular-nums",children:(Number(a.totalEntries)||0).toLocaleString("en-US")}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.community.devs_chip")})]})]})}function Ae(a,r,o){const s=r?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",c=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/60";return o.map(l=>e.jsx("td",{"data-column-key":l.key,className:d("hidden sm:table-cell px-3 sm:px-4 py-4 whitespace-nowrap text-right tabular-nums",s,c),children:Ie(a?.[l.key])},l.key))}const ur={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 Ke({rank:a,placeholder:r}){const o=ur[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 Te(a){if(typeof a!="string")return null;const r=a.trim().toLowerCase();return r==="week"||r==="month"||r==="total"?r:null}function mr(a){if(!a)return n("shared.error.prefix",{error:n("leaderboard.error.unknown")});const r=a?.message||String(a),o=String(r||"").trim()||n("leaderboard.error.unknown");return n("shared.error.prefix",{error:o})}function Fe(a){return typeof a!="string"?"":a.trim()}function xr(a){const r=Fe(a);return r?r.toLowerCase()==="anonymous":!0}function Re(a,r){const o=typeof a?.user_id=="string"?a.user_id.trim():"";return o||`${a?.rank??""}:${r}`}function ze({githubUrl:a}){return e.jsxs("span",{className:"relative inline-flex items-center group/gh shrink-0",children:[e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":n("leaderboard.github.aria"),className:"text-oai-black hover:text-oai-gray-500 dark:text-white dark:hover:text-oai-gray-400 transition-colors",children:e.jsx(wa,{provider:"GITHUB",size:16})}),e.jsxs("span",{role:"tooltip",className:"invisible opacity-0 group-hover/gh:visible group-hover/gh:opacity-100 absolute right-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:n("leaderboard.github.tooltipAction")}),e.jsxs("span",{className:"block text-oai-gray-300 dark:text-oai-gray-400",children:[n("leaderboard.github.tooltipPrefix")," ",e.jsx(va,{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:n("leaderboard.github.tooltipSettingsLink")}),n("leaderboard.github.tooltipSuffix")]})]})]})}function _r({auth:a,signedIn:r,sessionSoftExpired:o}){const s=da(),c=ca(),{openLoginModal:l}=ua(),{signedIn:b,loading:p,user:m}=ma(),{currency:h,rate:L}=$a(),y=i.useMemo(()=>xa(),[]),f=ga(),x=r&&!o,E=i.useMemo(()=>x&&(typeof a=="function"||typeof a=="string"||a&&typeof a=="object")?a:null,[a,x]),A=x?E:null,J=x&&ba(A),le=n("shared.placeholder.short"),Ge=i.useMemo(()=>V.map(t=>t.key),[]),{order:Z,reorder:de}=rr(Ge),ce=i.useMemo(()=>{const t=new Map;for(const u of V)t.set(u.key,u);return t},[]),F=i.useMemo(()=>Z.map(t=>ce.get(t)).filter(Boolean),[Z,ce]),Ye=Ka(Pe(Oa,{activationConstraint:{distance:6}}),Pe(Ua,{coordinateGetter:Ba})),He=i.useCallback(t=>{const{active:u,over:w}=t;!w||u.id===w.id||de(String(u.id),String(w.id))},[de]),[q,P]=i.useState(1),[N,We]=i.useState(dr),[ue,me]=i.useState(null),[Ve,xe]=i.useState(!1),Q=i.useCallback(t=>{typeof t=="string"&&t.trim()&&me(t.trim())},[]),Je=i.useCallback(()=>me(null),[]),Ze=i.useCallback(t=>{const u=se.includes(t)?t:ie;We(u),P(1);try{window.localStorage.setItem(De,String(u))}catch{}},[]),[ge,qe]=i.useState(0),[Qe,Xe]=i.useState(()=>pa()),[be,pe]=i.useState(!1),v=i.useMemo(()=>{const t=new URLSearchParams(s?.search||"");return Te(t.get("period"))||"total"},[s?.search]),ea=t=>{const u=Te(t);if(!u||u===v)return;const w=new URLSearchParams(s?.search||"");w.set("period",u),P(1),c(`${s?.pathname||"/leaderboard"}?${w.toString()}`,{replace:!0})};i.useEffect(()=>{p||f||b||l()},[b,p,f,l]),i.useEffect(()=>{P(1)},[v]);const G=i.useMemo(()=>(D(q,{min:1,max:1e6,fallback:1})-1)*N,[q,N]),K=i.useMemo(()=>f?"mock":p?"unavailable":b?"cloud":r?"local":y?"public":"unavailable",[p,b,y,f,r]),g=i.useMemo(()=>ha({accessMode:K,baseUrl:y,mockEnabled:f,userId:m?.id||null,period:v,pageSize:N,offset:G}),[m?.id,K,y,G,f,N,v]),[I,B]=i.useState(()=>{const t=re(g);return t?{loading:!1,error:null,data:t.data,contextKey:g}:{loading:!1,error:null,data:null,contextKey:null}});i.useEffect(()=>{if(!y&&!f||!f&&K==="unavailable"){B({loading:!1,error:null,data:null,contextKey:null});return}const t=re(g);let u=!0;return B(t?{loading:!1,error:null,data:t.data,contextKey:g}:{loading:!0,error:null,data:null,contextKey:null}),(async()=>{const w=await ya({userId:m?.id||null,period:v,limit:N,offset:G});u&&(fa(w,{activeContextKey:g,contextKey:g,source:ge>0?"manual-refresh":"page-load"}),B({loading:!1,error:null,data:w,contextKey:g}))})().catch(w=>{if(!u)return;const z=mr(w);B(O=>O.contextKey===g?{...O,loading:!1,error:z}:{loading:!1,error:z,data:null,contextKey:g})}),()=>{u=!1}},[y,K,m?.id,g,G,ge,f,v,N]);const X=i.useMemo(()=>I.contextKey===g?null:re(g),[g,I.contextKey]),k=i.useMemo(()=>I.contextKey===g?I:X?{loading:!1,error:null,data:X.data,contextKey:g}:{loading:!!(y||f)&&K!=="unavailable",error:null,data:null,contextKey:g},[K,y,g,I,f,X]),_=k.data,Y=_?.total_pages??null,aa=_?.total_entries??0,T=_?.page??q,ra=i.useMemo(()=>Ha(T,Y),[T,Y]),he=_?.from||null,ye=_?.to||null,fe=_?.generated_at||null,ke=Da(),M=_?.me||null,H=n("leaderboard.me_label"),ta=n("leaderboard.anon_label"),we=n("leaderboard.period.week"),ve=n("leaderboard.period.month"),je=n("leaderboard.period.total"),Ne=v==="month"?ve:v==="total"?je:we,ee=i.useMemo(()=>{const t=Array.isArray(_?.entries)?_.entries:[];return Va({entries:t,me:M,meLabel:H})},[_?.entries,M,H]),R=i.useMemo(()=>Ja(M?.rank,N),[M?.rank,N]),oa=R!=null&&R===T,na=i.useCallback(()=>{R!=null&&P(R)},[R]),sa=async()=>{pe(!0);try{_a(!0),Xe(!0),await Sa(()=>Le(A));const t=await Le(A);t&&await Ca({accessToken:t,period:v,source:"leaderboard-enable-sync"}),qe(u=>u+1)}catch(t){console.warn("[tokentracker] sync:",t)}finally{pe(!1)}},{canPrev:_e,canNext:Se}=Wa({page:T,totalPages:Y}),W=Array.isArray(ee)&&ee.length!==0;let U=null;k.loading&&!W?U=e.jsx(Xa,{rows:N}):k.error&&!W?U=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:k.error})}):W?U=e.jsx(Ta,{sensors:Ye,collisionDetection:Ra,modifiers:[Ya],onDragEnd:He,children:e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"min-w-full sm: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(Ue,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:n("leaderboard.column.rank")}),e.jsx("th",{className:d(Oe,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:n("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:n("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:n("leaderboard.column.est_cost")}),e.jsx(za,{items:Z,strategy:Ia,children:F.map(t=>e.jsx(er,{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(qa,{iconSrc:t.icon,label:n(t.copyKey)})},t.key))})]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:ee.map((t,u)=>{if(t?.is_ellipsis){const C=4+F.length;return e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:C,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,z=typeof t?.user_id=="string"?t.user_id:null,O=Fe(t?.display_name),ia=xr(O)?ta:O,S=w?H:ia,$=!!z,Ce=$?{role:"button",tabIndex:0,onClick:$?()=>Q(z):void 0,onKeyDown:$?C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),Q(z))}:void 0,"aria-label":n("leaderboard.profile_modal.row_aria",{name:S})}:{};if(w){const C=!!t?.is_pinned;return e.jsxs("tr",{...Ce,className:d("bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",C?"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",$&&"cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsx("td",{className:d(oe(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400",C&&"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(Ke,{rank:t?.rank,placeholder:le})}),e.jsx("td",{className:ne(!0),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(te,{avatarUrl:t?.avatar_url,displayName:S,seed:Re(t,S)}),e.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:S}),t?.github_url&&e.jsx(ze,{githubUrl:t.github_url})]})}),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(Ee,{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:Me(t?.estimated_cost_usd,h,L)}),Ae(t,!0,F)]},`row-${t?.rank}-${S}${C?"-pin":""}`)}return e.jsxs("tr",{...Ce,className:d("group transition-colors",$&&"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(oe(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(Ke,{rank:t?.rank,placeholder:le})}),e.jsx("td",{className:ne(!1),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(te,{avatarUrl:t?.avatar_url,displayName:S,seed:Re(t,S)}),e.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:S}),t?.github_url&&e.jsx(ze,{githubUrl:t.github_url})]})}),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(Ee,{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:Me(t?.estimated_cost_usd,h,L)}),Ae(t,!1,F)]},`row-${t?.rank}-${S}`)})})]})})}):U=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:n("leaderboard.empty")})});let ae=null;return typeof Y=="number"?ae=ra.map((t,u)=>t==null?e.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:n("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===T?"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:()=>P(t),disabled:k.loading,children:String(t)},`page-${t}`)):ae=e.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.pagination.page_unknown",{page:String(T)})}),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-5 sm:mb-6",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-2 sm:mb-3",children:n("leaderboard.title")}),e.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[v==="total"?n("leaderboard.range.total"):he&&ye?n("leaderboard.range",{period:Ne,from:he,to:ye}):n("leaderboard.range_loading",{period:Ne}),fe&&e.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 hidden sm:inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:n("leaderboard.generated_at",{ts:fe})})]})]}),e.jsxs("div",{className:"mb-6 sm:mb-8 flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsx("div",{className:"inline-flex h-9 p-1 border border-oai-gray-200 dark:border-oai-gray-800 rounded-full items-center relative self-start",children:["week","month","total"].map(t=>{const u=v===t;return e.jsxs("button",{onClick:()=>ea(t),disabled:k.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"?we:t==="month"?ve:je}),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:"flex flex-row items-center gap-2.5 self-end sm:self-auto shrink-0 flex-wrap",children:[e.jsx(cr,{communityStats:ke,onClick:()=>xe(!0)}),e.jsx(sr,{me:M,totalEntries:aa,meLabel:H,onOpenProfile:M?.user_id?()=>Q(M.user_id):void 0,onJumpToMe:na,canJump:R!=null&&!oa&&!k.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:n("leaderboard.signin_prompt")}),e.jsx("button",{onClick:l,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:n("leaderboard.signin_button")})]}),x&&J&&!Qe&&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:n("leaderboard.sync_prompt")}),e.jsx("button",{onClick:sa,disabled:be,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:be?n("leaderboard.sync_button.busy"):n("leaderboard.sync_button.idle")})]}),e.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:[k.error&&W?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:k.error})}):null,U,e.jsxs("div",{className:"px-6 py-3 border-t border-oai-gray-200 dark:border-oai-gray-800 flex flex-wrap items-center justify-end gap-x-4 gap-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("label",{htmlFor:"leaderboard-page-size",className:"whitespace-nowrap",children:n("leaderboard.pagination.page_size_label")}),e.jsx(Pa,{id:"leaderboard-page-size",value:N,onValueChange:t=>Ze(Number(t)),disabled:k.loading,ariaLabel:n("leaderboard.pagination.page_size_label"),options:se.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:"h-5 w-px bg-oai-gray-200 dark:bg-oai-gray-800","aria-hidden":"true"}),e.jsx("button",{className:d("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",_e&&!k.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:()=>P(t=>Math.max(1,t-1)),disabled:!_e||k.loading,children:n("leaderboard.pagination.prev")}),e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:ae}),e.jsx("button",{className:d("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",Se&&!k.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:()=>P(t=>t+1),disabled:!Se||k.loading,children:n("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:n("landing.v2.footer.line")}),e.jsx("a",{href:"https://github.com/mm7894215/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:n("landing.v2.nav.github")})]})}),e.jsxs(i.Suspense,{fallback:null,children:[e.jsx(ir,{isOpen:!!ue,userId:ue,period:v,accessToken:A,onClose:Je}),e.jsx(lr,{isOpen:Ve,onClose:()=>xe(!1),communityStats:ke})]})]})}export{_r as LeaderboardPage};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import{c as E,a2 as X,r as g,da as te,j as e,N as i,db as se,aE as oe,dc as ie,a0 as d,dd as ne,aI as le,L as de,s as ce,$ as D,X as xe,Q as G,P as me,an as ge}from"./main-BCstrDYE.js";import{u as pe}from"./useCurrency-bd6TLRsc.js";import{L as Y}from"./LeaderboardAvatar-3T57GKKK.js";import{A as he}from"./ActivityHeatmap-CH6m_ZJM.js";import{A as U}from"./arrow-up-right-Bm3t-iA0.js";import{L as fe}from"./link-2-CYqDGrkv.js";import{C as ue}from"./check-D8Owfjyw.js";import{D as be,a as ye,b as ke,c as je,d as ve,e as Ne}from"./DialogTitle-CA5znwms.js";import"./info-Cm7V_KDO.js";import"./useScrollLock-ajoWrfku.js";const _e=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],we=E("code-xml",_e);const Ae=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],Se=E("heart",Ae),T="tokentracker_anon_id";let v=null;function F(){try{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const r=Math.random()*16|0;return(a==="x"?r:r&3|8).toString(16)})}function H(){if(v)return v;try{let a=localStorage.getItem(T);return a||(a=F(),localStorage.setItem(T,a)),v=a,a}catch{return v=F(),v}}function q({userId:a}){const{signedIn:r,getAccessToken:s}=X(),[t,o]=g.useState(!1),[c,x]=g.useState(0),[l,h]=g.useState(!1),[b,N]=g.useState(!1),[_,L]=g.useState(!1),[w,y]=g.useState([]),[A,k]=g.useState(!1),S=g.useRef(0),u=g.useCallback(async()=>{if(r)try{const n=await s();if(n)return{accessToken:n,anonId:H()}}catch{}return{anonId:H()}},[r,s]);g.useEffect(()=>{let n=!1;return a?(h(!1),(async()=>{const m=await u();try{const p=await te({userId:a,...m});if(n)return;x(Number(p?.count)||0),o(!!p?.liked),h(!0)}catch{if(n)return;x(0),o(!1),h(!0)}})(),()=>{n=!0}):(h(!1),()=>{n=!0})},[a,u]);const j=()=>{L(!0),setTimeout(()=>L(!1),450),k(!0),setTimeout(()=>k(!1),500);const n=["#ff4757","#ff6b81","#ffa502","#70a1ff","#2ed573","#a29bfe"],m=["circle","heart"],p=[];for(let f=0;f<12;f++){const z=(f*30+Math.random()*20-10)*(Math.PI/180),C=45+Math.random()*45,K=Math.cos(z)*C,Q=Math.sin(z)*C-(10+Math.random()*15),V=Math.random()*360-180,J=6+Math.random()*8,ee=n[Math.floor(Math.random()*n.length)],ae=m[Math.floor(Math.random()*m.length)],re=++S.current;p.push({id:re,tx:K,ty:Q,rot:V,size:J,color:ee,shape:ae})}y(f=>[...f,...p]),setTimeout(()=>{y(f=>f.filter(z=>!p.find(C=>C.id===z.id)))},850)},M=async n=>{N(!0);try{const m=await u(),p=await se({userId:a,action:n,...m});p&&Number.isFinite(Number(p.count))&&x(Number(p.count)),p&&typeof p.liked=="boolean"&&o(p.liked)}catch{o(m=>!m),x(m=>n==="like"?Math.max(0,m-1):m+1)}finally{N(!1)}},Z=n=>{n.stopPropagation(),!(!a||!l||b)&&(t?(o(!1),x(m=>Math.max(0,m-1)),M("unlike")):(o(!0),x(m=>m+1),j(),M("like")))};return e.jsxs("div",{className:"relative inline-flex items-center select-none z-10",children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
2
|
-
@keyframes tt-like-pop {
|
|
3
|
-
0% { transform: scale(1); }
|
|
4
|
-
25% { transform: scale(0.75); }
|
|
5
|
-
50% { transform: scale(1.35); }
|
|
6
|
-
75% { transform: scale(0.9); }
|
|
7
|
-
100% { transform: scale(1); }
|
|
8
|
-
}
|
|
9
|
-
@keyframes tt-particle-fly {
|
|
10
|
-
0% {
|
|
11
|
-
transform: translate(0, 0) scale(1) rotate(0deg);
|
|
12
|
-
opacity: 1;
|
|
13
|
-
}
|
|
14
|
-
70% {
|
|
15
|
-
opacity: 0.8;
|
|
16
|
-
}
|
|
17
|
-
100% {
|
|
18
|
-
transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rot));
|
|
19
|
-
opacity: 0;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
@keyframes tt-num-scroll {
|
|
23
|
-
0% { transform: translateY(8px); opacity: 0; }
|
|
24
|
-
100% { transform: translateY(0); opacity: 1; }
|
|
25
|
-
}
|
|
26
|
-
.tt-animate-pop {
|
|
27
|
-
animation: tt-like-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
|
|
28
|
-
}
|
|
29
|
-
.tt-particle {
|
|
30
|
-
position: absolute;
|
|
31
|
-
top: 50%;
|
|
32
|
-
left: 50%;
|
|
33
|
-
margin-top: -6px;
|
|
34
|
-
margin-left: -6px;
|
|
35
|
-
pointer-events: none;
|
|
36
|
-
z-index: 50;
|
|
37
|
-
}
|
|
38
|
-
.tt-num-anim {
|
|
39
|
-
animation: tt-num-scroll 0.25s ease-out forwards;
|
|
40
|
-
}
|
|
41
|
-
`}}),w.map(n=>e.jsx("span",{className:"tt-particle",style:{"--tx":`${n.tx}px`,"--ty":`${n.ty}px`,"--rot":`${n.rot}deg`,width:`${n.size}px`,height:`${n.size}px`,backgroundColor:n.shape==="circle"?n.color:"transparent",borderRadius:n.shape==="circle"?"50%":"0",animation:"tt-particle-fly 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards"},children:n.shape==="heart"&&e.jsx("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:n.color,className:"w-full h-full",children:e.jsx("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"})})},n.id)),e.jsxs("button",{type:"button",onClick:Z,disabled:!l||b,"aria-label":t?i("leaderboard.profile.like.aria_unlike"):i("leaderboard.profile.like.aria_like"),className:`group flex items-center justify-center gap-1.5 h-8 min-w-[48px] px-2.5 rounded-full border transition-all duration-300 outline-none focus-visible:ring-2 focus-visible:ring-rose-500/50 disabled:opacity-60 disabled:cursor-default ${t?"bg-rose-50/60 border-rose-200/80 text-rose-500 dark:bg-rose-950/20 dark:border-rose-900/40 dark:text-rose-400 shadow-sm":"bg-white/80 border-oai-gray-200 text-oai-gray-500 hover:border-rose-200 hover:text-rose-500 hover:bg-rose-50/30 dark:bg-oai-gray-950/50 dark:border-white/10 dark:text-oai-gray-400 dark:hover:border-rose-900/50 dark:hover:text-rose-400 dark:hover:bg-rose-950/5"}`,children:[e.jsx("span",{className:_?"tt-animate-pop":"group-active:scale-90 transition-transform duration-100",children:e.jsx(Se,{size:14,className:`transition-all duration-300 ${t?"fill-rose-500 text-rose-500 dark:fill-rose-400 dark:text-rose-400":"fill-transparent"}`})}),e.jsx("span",{className:`text-[12px] font-bold font-mono tabular-nums tracking-tight ${t?"text-rose-600 dark:text-rose-400":"text-oai-gray-600 dark:text-oai-gray-400"} ${A?"tt-num-anim":""}`,children:l?c:"·"})]})]})}function Me(a,r,s){const t=Number(a);return!Number.isFinite(t)||t<0?"—":t>0&&t<.01?`<${r==="USD"?"$":""}0.01`:me(t,{decimals:2,currency:r,rate:s})}function R(a,r,s){const t=Number(a);if(!Number.isFinite(t)||t<0)return"—";if(t<1e3)return Me(t,r,s);const o=r==="USD"?t:t*(s||1);return`${r==="USD"?"$":""}${G(o,{decimals:1})}`}function $(a){const r=Number(a);return!Number.isFinite(r)||r<=0?"0":G(r,{decimals:1})}function ze(a){const r=Array.isArray(a)?a:[];if(r.length===0)return null;const s=r.map(o=>({day:o.date,total_tokens:o.total_tokens,models:o.models||null})),t=r[r.length-1]?.date;return ce({dailyRows:s,weeks:52,to:t})}const Ce=`
|
|
42
|
-
@keyframes tt-shimmer {
|
|
43
|
-
100% { transform: translateX(100%); }
|
|
44
|
-
}
|
|
45
|
-
.tt-shimmer-bar {
|
|
46
|
-
position: relative;
|
|
47
|
-
overflow: hidden;
|
|
48
|
-
}
|
|
49
|
-
.tt-shimmer-bar::after {
|
|
50
|
-
position: absolute;
|
|
51
|
-
top: 0; right: 0; bottom: 0; left: 0;
|
|
52
|
-
transform: translateX(-100%);
|
|
53
|
-
background-image: linear-gradient(
|
|
54
|
-
90deg,
|
|
55
|
-
rgba(0, 0, 0, 0) 0%,
|
|
56
|
-
rgba(0, 0, 0, 0.02) 20%,
|
|
57
|
-
rgba(0, 0, 0, 0.06) 60%,
|
|
58
|
-
rgba(0, 0, 0, 0) 100%
|
|
59
|
-
);
|
|
60
|
-
animation: tt-shimmer 1.6s infinite;
|
|
61
|
-
content: '';
|
|
62
|
-
}
|
|
63
|
-
.dark .tt-shimmer-bar::after {
|
|
64
|
-
background-image: linear-gradient(
|
|
65
|
-
90deg,
|
|
66
|
-
rgba(255, 255, 255, 0) 0%,
|
|
67
|
-
rgba(255, 255, 255, 0.02) 20%,
|
|
68
|
-
rgba(255, 255, 255, 0.06) 60%,
|
|
69
|
-
rgba(255, 255, 255, 0) 100%
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
`;function Ie({variant:a="modal"}){const r="rounded bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar",s=a==="page";return e.jsxs("div",{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Ce}}),s?e.jsxs("div",{className:"flex items-start gap-5 px-6 sm:px-8 pt-8 pb-7 animate-fade-in",children:[e.jsx("div",{className:"h-[68px] w-[68px] rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start justify-between gap-4 pt-0.5",children:[e.jsxs("div",{className:"min-w-0 space-y-2.5",children:[e.jsx("div",{className:d(r,"h-7 w-48")}),e.jsx("div",{className:d(r,"h-3.5 w-32")})]}),e.jsxs("div",{className:"shrink-0 space-y-1.5 flex flex-col items-end",children:[e.jsx("div",{className:d(r,"h-2.5 w-8")}),e.jsx("div",{className:d(r,"h-7 w-12")})]})]})]}):e.jsxs("div",{className:"flex items-start gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60 animate-fade-in",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2 pt-1",children:[e.jsx("div",{className:d(r,"h-4 w-40")}),e.jsx("div",{className:d(r,"h-3 w-56")})]}),e.jsx("div",{className:d(r,"h-4 w-4 shrink-0 mt-1")})]}),e.jsxs("div",{className:d("space-y-6",s?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"px-6 py-5"),children:[e.jsx("div",{className:"grid grid-cols-4 gap-x-6 gap-y-4",children:Array.from({length:4}).map((t,o)=>e.jsxs("div",{children:[e.jsx("div",{className:d(r,"h-6 w-20")}),e.jsx("div",{className:d(r,"mt-2 h-3 w-14")})]},o))}),e.jsx("div",{className:"space-y-3 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:Array.from({length:3}).map((t,o)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:d(r,"h-3 w-24")}),e.jsx("div",{className:d(r,"h-3 w-44")})]},o))}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:d(r,"h-3 w-44 mb-4")}),e.jsx("div",{className:"grid grid-cols-[repeat(52,1fr)] gap-[2px]",children:Array.from({length:364}).map((t,o)=>e.jsx("div",{className:"aspect-square rounded-[2px] bg-oai-gray-200/40 dark:bg-oai-gray-800/30 tt-shimmer-bar"},o))})]}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:d(r,"h-3 w-28 mb-3")}),e.jsx("div",{className:"space-y-2.5",children:Array.from({length:5}).map((t,o)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:d(r,"h-4 w-4")}),e.jsx("div",{className:d(r,"h-3 w-16")}),e.jsx("div",{className:d(r,"h-[3px] flex-1")}),e.jsx("div",{className:d(r,"h-3 w-12")})]},o))})]})]})]})}function O(a){if(!a)return null;const r=String(a).match(/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})/i);return r?r[1]:null}function B({children:a}){return e.jsx("h3",{className:"text-[11px] uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400 mb-3",children:a})}function I({value:a,label:r}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-black tabular-nums tracking-tight leading-none text-oai-black dark:text-white",style:{fontFamily:'"DIN Alternate-Bold", "DIN Alternate", "DIN Condensed-Bold", "Impact", -apple-system, sans-serif',fontWeight:900},children:a}),e.jsx("div",{className:"mt-1.5 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r})]})}function P({label:a,children:r}){return e.jsxs("div",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"shrink-0 w-28 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"min-w-0 flex-1 text-oai-gray-900 dark:text-oai-gray-100 tabular-nums truncate flex items-baseline gap-2 flex-wrap",children:r})]})}function Le({user:a,onClose:r}){const s=O(a?.github_url);return e.jsxs("div",{className:"flex items-center gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60",children:[e.jsx(Y,{avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"lg",className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:a?.display_name||"—"}),a?.rank?e.jsx("span",{className:d("shrink-0 inline-flex items-center px-2 py-0.5 rounded text-xs font-bold font-mono uppercase tracking-wider border shadow-sm",a.rank===1&&"bg-amber-500/10 text-amber-600 border-amber-500/20 dark:text-amber-400 dark:bg-amber-400/10",a.rank===2&&"bg-slate-500/10 text-slate-600 border-slate-500/20 dark:text-slate-400 dark:bg-slate-400/10",a.rank===3&&"bg-orange-500/10 text-orange-700 border-orange-500/20 dark:text-orange-400 dark:bg-orange-400/10",a.rank>3&&"bg-oai-gray-100 dark:bg-oai-gray-900/60 text-oai-gray-500 dark:text-oai-gray-400 border-oai-gray-200/60 dark:border-oai-gray-800"),children:i("leaderboard.profile_modal.rank",{rank:a.rank})}):null]}),s&&e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-[12px] text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200 transition-colors",children:[e.jsx(D,{provider:"GITHUB",size:11}),e.jsxs("span",{children:["@",s]})]})]}),a?.user_id&&e.jsx("div",{className:"shrink-0 flex items-center justify-center",children:e.jsx(q,{userId:a.user_id})}),r&&e.jsx("button",{type:"button",onClick:r,className:"shrink-0 -mr-1 -mt-1 flex h-8 w-8 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors group","aria-label":i("leaderboard.profile_modal.close"),children:e.jsx(xe,{size:16,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:rotate-90 group-active:scale-90"})})]})}function Pe({user:a}){const r=O(a?.github_url),s=Number(a?.rank)||0,t=s===1?"text-amber-500 dark:text-amber-400":s===2?"text-slate-500 dark:text-slate-300":s===3?"text-orange-600 dark:text-orange-400":"text-oai-gray-400 dark:text-oai-gray-500";return e.jsxs("div",{className:"flex items-center gap-5 px-6 sm:px-8 pt-8 pb-7",children:[e.jsx(Y,{avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"xl",className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0 flex-1 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"truncate text-2xl sm:text-[28px] font-semibold tracking-tight leading-tight text-oai-black dark:text-white",children:a?.display_name||"—"}),a?.user_id&&e.jsx(q,{userId:a.user_id})]}),r?e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white transition-colors",children:[e.jsx(D,{provider:"GITHUB",size:13}),e.jsxs("span",{children:["@",r]})]}):null]}),s?e.jsxs("div",{className:"shrink-0 text-right leading-none",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-oai-gray-400 dark:text-oai-gray-500",children:i("leaderboard.profile.hero.rank_label")}),e.jsx("div",{className:d("mt-1.5 text-3xl font-black tabular-nums tracking-tight",t),children:i("leaderboard.profile_modal.rank",{rank:s})})]}):null]})]})}function $e({data:a}){const r=Array.isArray(a)?a:[];return r.length===0?e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i("leaderboard.profile_modal.providers.none")}):e.jsx("ul",{className:"space-y-2",children:r.map(s=>{const t=Math.max(0,Math.min(1,Number(s?.percent)||0));return e.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"shrink-0 inline-flex items-center justify-center w-4 h-4",children:e.jsx(D,{provider:String(s.source).toUpperCase(),size:14})}),e.jsx("span",{className:"shrink-0 capitalize w-16 text-oai-gray-700 dark:text-oai-gray-300",children:s.source}),e.jsx("span",{className:"flex-1 h-[3px] rounded-full bg-oai-gray-200/60 dark:bg-oai-gray-800/80 overflow-hidden",children:e.jsx("span",{className:"block h-full bg-oai-brand-500 dark:bg-oai-brand-400",style:{width:`${(t*100).toFixed(1)}%`}})}),e.jsx("span",{className:"shrink-0 w-14 text-right tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:$(s.total_tokens)}),e.jsxs("span",{className:"shrink-0 w-10 text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[(t*100).toFixed(0),"%"]})]},s.source)})})}function W({icon:a,label:r,value:s}){const[t,o]=g.useState(!1),c=async()=>{await ge(s)&&(o(!0),setTimeout(()=>o(!1),1600))};return e.jsxs("button",{type:"button",onClick:c,className:d("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",t?"border-emerald-500/30 text-emerald-600 dark:text-emerald-400 bg-emerald-500/[0.06]":"border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-gray-900 dark:hover:text-oai-gray-100 hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[t?e.jsx(ue,{size:13,strokeWidth:2,"aria-hidden":!0}):e.jsx(a,{size:13,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t?i("leaderboard.profile_modal.badge.copied"):r})]})}function De({data:a,currency:r,rate:s,onClose:t,variant:o="modal"}){const{user:c,totals:x,streak:l,best_day:h,models:b,by_provider:N,heatmap:_,period:L}=a,w=o==="page",y=g.useMemo(()=>ze(_),[_]),A=b?.favorite?.model_name,k=Number(b?.count)||0,S=X(),u=!!(S?.user?.id&&c?.user_id&&S.user.id===c.user_id),j=c?.user_id?`https://www.tokentracker.cc/u/${c.user_id}`:null,M=c?.user_id?`[}/functions/tokentracker-embed-svg?user_id=${c.user_id}&theme=dark)](${j}?ref=readme)`:null;return e.jsxs(e.Fragment,{children:[w?e.jsx(Pe,{user:c}):e.jsx(Le,{user:c,onClose:t}),e.jsxs("div",{className:d("space-y-6",w?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"flex-1 min-h-0 overflow-y-auto oai-scrollbar px-6 py-5"),children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-4",children:[e.jsx(I,{value:$(x?.total_tokens),label:i("leaderboard.profile_modal.stat.total_tokens")}),e.jsx(I,{value:R(x?.estimated_cost_usd,r,s),label:i("leaderboard.profile_modal.stat.total_cost")}),e.jsx(I,{value:String(x?.active_days??0),label:i("leaderboard.profile_modal.stat.active_days")}),e.jsx(I,{value:R(x?.avg_per_day_usd,r,s),label:i("leaderboard.profile_modal.stat.avg_per_day")})]}),e.jsxs("dl",{className:"space-y-2 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsxs(P,{label:i("leaderboard.profile_modal.streak.current"),children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:i("leaderboard.profile_modal.streak.days",{count:l?.current_days??0})}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["(max ",l?.longest_days??0,")"]})]}),e.jsx(P,{label:i("leaderboard.profile_modal.best_day.title"),children:h?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:$(h.total_tokens)}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["on ",h.date]})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:i("leaderboard.profile_modal.best_day.none")})}),e.jsx(P,{label:i("leaderboard.profile_modal.models.favorite"),children:A?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30 truncate max-w-[200px] inline-block align-bottom",children:A}),k>1&&e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:i("leaderboard.profile_modal.models.count",{count:k})})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:i("leaderboard.profile_modal.models.none")})})]}),y&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(B,{children:i("leaderboard.profile_modal.heatmap.title")}),e.jsx("div",{className:"min-w-0",children:e.jsx(he,{heatmap:y,hideLegend:!0,embedded:!0})})]}),e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(B,{children:i("leaderboard.profile_modal.providers.title")}),e.jsx($e,{data:N})]}),c?.user_id&&(t||u)&&e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-3",children:[t&&(le()?e.jsxs("a",{href:j,target:"_blank",rel:"noopener noreferrer",onClick:t,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:i("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]}):e.jsxs(de,{to:`/u/${c.user_id}`,onClick:t,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:i("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})),u&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{icon:fe,label:i("leaderboard.profile_modal.badge.copy_url"),value:j}),e.jsx(W,{icon:we,label:i("leaderboard.profile_modal.badge.copy"),value:M})]})]})]})]})}function Ue({userId:a,period:r,accessToken:s,enabled:t=!0}){const[o,c]=g.useState({loading:!1,error:null,data:null});return g.useEffect(()=>{if(!t||!a)return;let x=!0;return c({loading:!0,error:null,data:null}),(async()=>{try{const l=s?await oe(s):null;if(!x)return;const h=await ie({accessToken:l,userId:a,period:r||"week"});if(!x)return;c({loading:!1,error:null,data:h})}catch(l){if(!x)return;l?.status===404?c({loading:!1,error:null,data:null}):c({loading:!1,error:l?.message||String(l),data:null})}})(),()=>{x=!1}},[t,a,r,s]),o}function qe({isOpen:a,onClose:r,userId:s,period:t,accessToken:o}){const{currency:c,rate:x}=pe(),l=Ue({userId:s,period:t,accessToken:o,enabled:a});return e.jsx(be,{open:a,onOpenChange:h=>{h||r?.()},children:e.jsxs(ye,{children:[e.jsx(ke,{className:"cost-modal-backdrop"}),e.jsx(je,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(ve,{className:d("cost-modal-popup","relative w-full max-w-[540px] max-h-[calc(100vh-2rem)] flex flex-col","rounded-2xl bg-white dark:bg-oai-gray-950","shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)]","ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden","dark:border-t dark:border-white/[0.08]"),children:[e.jsx(Ne,{render:e.jsx("h2",{className:"sr-only"}),children:l.data?.user?.display_name||i("leaderboard.profile_modal.loading")}),l.loading&&e.jsx(Ie,{}),!l.loading&&l.error&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:i("leaderboard.profile_modal.error")})}),!l.loading&&!l.error&&!l.data&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:i("leaderboard.profile_modal.empty")})}),!l.loading&&!l.error&&l.data&&e.jsx(De,{data:l.data,currency:c,rate:x,onClose:r})]})})]})})}export{qe as LeaderboardProfileModal,De as ProfileContent,Ie as ProfileSkeleton,Ue as useLeaderboardProfileData};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aw as p,aO as w,a2 as v,r,N as s,j as e,L as y,a5 as j}from"./main-BCstrDYE.js";function N(i){const t=new URLSearchParams(i).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function k(){const i=p(),[t,u]=w(),{enabled:n,loading:f,signedIn:x,refreshUser:g}=v(),c=r.useMemo(()=>N(t.toString()),[t]),[h,d]=r.useState(null);r.useEffect(()=>{const l=t.get("insforge_status"),a=t.get("insforge_type"),m=t.get("insforge_error");l==="success"&&a==="verify_email"?d(s("login.verify_email_success")):l==="error"&&a==="verify_email"&&m&&d(s("shared.error.prefix",{error:m}))},[t]);const o=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!n||f)&&x){if(o){window.location.href="/auth/native-callback";return}i(c,{replace:!0})}},[n,f,x,i,c,o]),r.useEffect(()=>{n&&g()},[n,g]),r.useEffect(()=>{if(o&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[o]);const b=r.useCallback(()=>{u(l=>{const a=new URLSearchParams(l);return a.delete("insforge_status"),a.delete("insforge_type"),a.delete("insforge_error"),a},{replace:!0}),d(null)},[u]);return n?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(y,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[h?e.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",onClick:b,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:s("login.dismiss")})]}):null,e.jsx("div",{className:"border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(j,{hideLogo:!0,title:s("login.title"),subtitle:s("login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{o?window.location.href="/auth/native-callback":i(c,{replace:!0})}})})]})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(y,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:s("login.cloud_only")})})]})}export{k as LoginPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as S,aI as R,d5 as B,r as n,d6 as q,d7 as F,d8 as H,d9 as E,N as i,j as e,a0 as h,b3 as O}from"./main-BCstrDYE.js";import{T as $,b as W}from"./Controls-Cj22oGL3.js";import{n as J,C as M}from"./ClawdAnimated-vRiBiNhb.js";import{F as T}from"./FadeIn--ff4ZbC-.js";import{L as X}from"./link-2-CYqDGrkv.js";import{L as Y}from"./loader-circle-6XAdy2ec.js";import{T as Z}from"./trash-2-DKLewOQb.js";import"./Card-D_aKGDr7.js";const G=[["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"}]],Q=S("file-archive",G);const ee=[["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"}]],te=S("monitor-up",ee);const ae=[["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"}]],re=S("upload",ae);const ie=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],se=S("zap",ie),oe={visible:!1,character:"clawd",size:"medium"};function ne(){const t=R()&&B(),[a,s]=n.useState(oe);n.useEffect(()=>{if(!t)return;const d=q(o=>{s({visible:!!o.visible,character:J(o.character),size:["small","medium","large"].includes(o.size)?o.size:"medium"})});return F(),d},[t]);const l=n.useCallback((d,o)=>{s(x=>({...x,[d]:o})),t&&H(d,o)},[t]);return{available:t,settings:a,setSetting:l}}const y=[{id:"clawd",displayName:"Clawd",nameKey:"pet.character.clawd",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 P(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 le(){const t=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),a=await P(t);return[...y,...Array.isArray(a.pets)?a.pets:[]]}async function _(t){const a=await E();return P(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function de(t){return _({action:"install_url",url:t})}async function I(t){const a=await E();return P(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...a},cache:"no-store",body:t}))}function ce(t){return _({action:"remove",id:t})}let C=y;function pe(){const[t,a]=n.useState(C),[s,l]=n.useState(!0),[d,o]=n.useState(!1),x=n.useCallback(async()=>{l(!0);try{const p=await le();return C=p,a(p),o(!0),p}catch{return C=y,a(y),o(!1),y}finally{l(!1)}},[]);return n.useEffect(()=>{x()},[x]),{pets:t,loading:s,available:d,refresh:x}}const me={clawd:"from-oai-amber-50 dark:from-orange-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 xe(){const t=i("pet.import.subtitle"),a="codex-pets.net",s=t.indexOf(a);return s<0?t:e.jsxs(e.Fragment,{children:[t.slice(0,s),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(s+a.length)]})}const k=[{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 ue({character:t,selected:a,onSelect:s,onRemove:l,removeDisabled:d}){const o=t.nameKey?i(t.nameKey):t.displayName;return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:s,"aria-pressed":a,className:h("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:h("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",me[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(M,{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:o}),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:i("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]})]})]}),l?e.jsx("button",{type:"button",disabled:d,onClick:l,"aria-label":`${i("pet.import.remove")} · ${o}`,className:h("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",a?"opacity-100":"opacity-0 group-hover:opacity-100"),children:e.jsx(Z,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function ge({pet:t,state:a,onStateChange:s}){const[l,d]=n.useState(null),o=n.useRef(null),x=k.find(function(u){return u.id===a}),p=i(x?.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:c=>{if(t?.spriteVersionNumber!==2||!o.current)return;const u=o.current.getBoundingClientRect(),v=c.clientX-(u.left+u.width/2),m=c.clientY-(u.top+u.height/2),j=(Math.atan2(v,-m)*180/Math.PI+360)%360;d(Math.round(j/22.5)%16)},onPointerLeave:()=>d(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:i("pet.preview.states")}),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:o,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(M,{state:a,character:t?.id||"clawd",pet:t,size:190,lookDirectionIndex:l})})})}),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":i("pet.preview.states"),children:k.map(c=>e.jsxs("button",{type:"button",onClick:()=>s(c.id),"aria-pressed":a===c.id,className:h("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===c.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:i(c.labelKey)}),e.jsx("span",{className:h("h-1 w-1 rounded-full transition-colors duration-200",a===c.id?"bg-oai-black dark:bg-white":"bg-transparent"),"aria-hidden":!0})]},c.id))})})]})}function Ne(){const{available:t,settings:a,setSetting:s}=ne(),{pets:l,loading:d,available:o,refresh:x}=pe(),[p,c]=n.useState(""),[u,v]=n.useState(""),[m,j]=n.useState(!1),[L,z]=n.useState("idle-living"),[A,K]=n.useState(!0),f=a.character||"clawd",U=l.find(r=>r.id===f)||l[0],w=m?{kind:"busy",text:i("pet.import.busy")}:u?{kind:"error",text:u}:null;n.useEffect(()=>{!d&&l.length>0&&!l.some(r=>r.id===f)&&s("character","clawd")},[d,l,f,s]);async function N(r,g=i("pet.import.success")){j(!0),v("");try{const b=await r();await x(),b?.pet?.id&&s("character",b.pet.id),O({title:g,timeout:4e3}),c("")}catch(b){v(b?.message||i("pet.import.failed"))}finally{j(!1)}}n.useEffect(()=>{if(!A)return;const r=window.setInterval(()=>{z(g=>{const b=k.findIndex(D=>D.id===g);return k[(b+1)%k.length].id})},5e3);return()=>window.clearInterval(r)},[A]);const V=[{value:"small",label:i("pet.size.small")},{value:"medium",label:i("pet.size.medium")},{value:"large",label:i("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(T,{y:12,children:e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:i("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:i("pet.page.subtitle")})]})}),e.jsx(T,{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(ge,{pet:U,state:L,onStateChange:r=>{K(!1),z(r)}}),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:i("pet.characters.title")}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:i("pet.characters.subtitle")})]}),e.jsx("div",{className:"mt-4 grid grid-cols-2 gap-2",children:l.map(r=>e.jsx(ue,{character:r,selected:f===r.id,onSelect:()=>s("character",r.id),removeDisabled:m,onRemove:o&&r.custom?()=>N(async()=>(await ce(r.id),f===r.id&&s("character","clawd"),null),i("pet.import.removed")):void 0},r.id))})]}),o?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(re,{className:"h-4 w-4 text-oai-gray-500","aria-hidden":!0}),e.jsx("h2",{id:"pet-import-title",className:"text-sm font-semibold",children:i("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(xe,{})}),e.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:r=>{r.preventDefault(),!m&&p.trim()&&N(()=>de(p))},children:[e.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[e.jsx(X,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{value:p,onChange:r=>c(r.target.value),"aria-label":i("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:m||!p.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:[m?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,i("pet.import.add")]})]}),e.jsxs("label",{onDragOver:r=>r.preventDefault(),onDrop:r=>{if(r.preventDefault(),m)return;const g=r.dataTransfer?.files?.[0];g&&N(()=>I(g))},className:h("mt-2 flex h-9 w-full 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",m&&"pointer-events-none opacity-40"),children:[e.jsx(Q,{className:"h-3.5 w-3.5","aria-hidden":!0}),i("pet.import.zip"),e.jsx("input",{type:"file",accept:".zip,.codex-pet.zip,application/zip",className:"sr-only",disabled:m,onChange:r=>{const g=r.target.files?.[0];g&&N(()=>I(g)),r.target.value=""}})]}),w?e.jsx("p",{role:w.kind==="error"?"alert":"status",className:h("mt-2 text-xs",w.kind==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400"),children:w.text}):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(te,{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:i("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:i("pet.controls.show")}),e.jsx($,{checked:a.visible,onChange:()=>s("visible",!a.visible),disabled:!t,ariaLabel:i("pet.controls.show")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm font-medium",children:i("pet.controls.size")}),e.jsx("div",{className:"shrink-0",children:e.jsx(W,{options:V,value:a.size,onChange:r=>s("size",r),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(se,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),i("pet.controls.native_only")]})]})]})})]})})})}export{Ne as PetPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aO as d,a2 as m,r as t,j as e,L as l,N as o,a5 as x}from"./main-BCstrDYE.js";function n(s,a){for(const r of a){const i=s.get(r);if(typeof i=="string"&&i.trim())return i.trim()}return""}function u(){const[s]=d(),{enabled:a}=m(),r=t.useMemo(()=>n(s,["otp","token","reset_token","insforge_token"]),[s]),i=t.useMemo(()=>n(s,["email"]),[s]),c=t.useMemo(()=>n(s,["code"]),[s]);return a?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(l,{to:"/login",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:o("reset_password.back_to_sign_in")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsx("div",{className:"w-full max-w-md border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(x,{hideLogo:!0,initialMode:r?"reset_confirm":"reset_email",tokenFromUrl:r,initialEmail:i,initialCode:c})})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(l,{to:"/login",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:o("reset_password.back_to_sign_in")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:o("login.cloud_only")})})]})}export{u as ResetPasswordPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as v,b8 as l,bI as w,b9 as k,j as e,a0 as x}from"./main-BCstrDYE.js";import{u as j,z as N,s as i,L as C,A as I,S as E,h as R,i as T,C as A,j as L,k as P,l as _,m as z,o as D,n as G}from"./SelectItemText-2LjzGvo5.js";import{C as M}from"./check-D8Owfjyw.js";const O=v.forwardRef(function(t,s){const{render:n,className:p,style:o,...c}=t,{store:r,scrollHandlerRef:d}=j(),{alignItemWithTriggerActive:g}=N(),u=l(r,i.hasScrollArrows),h=l(r,i.openMethod),a=l(r,i.multiple),m={id:`${l(r,i.id)}-list`,role:"listbox","aria-multiselectable":a||void 0,onScroll(b){d.current?.(b.currentTarget)},...g&&{style:C},className:u&&h!=="touch"?I.className:void 0},S=w(b=>{r.set("listElement",b)});return k("div",t,{ref:[s,S],props:[m,c]})}),V="relative inline-flex items-center justify-between gap-2 rounded-lg border border-oai-gray-200 bg-white text-oai-black transition-colors hover:border-oai-gray-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:hover:border-oai-gray-700";function U({value:y,onValueChange:t,options:s=[],ariaLabel:n,id:p,disabled:o=!1,leadingIcon:c=null,className:r="",popupClassName:d="",align:g="start",matchTriggerWidth:u=!1}){const h=s.map(a=>({value:a.value,label:a.label}));return e.jsxs(E,{value:y,items:h,disabled:o,onValueChange:a=>{!o&&a!=null&&t?.(a)},children:[e.jsxs(R,{id:p,"aria-label":n,className:x(V,o&&"cursor-not-allowed opacity-50 hover:border-oai-gray-200 dark:hover:border-oai-gray-800",r),children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[c,e.jsx(T,{className:"truncate"})]}),e.jsx(A,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),e.jsx(L,{children:e.jsx(P,{align:g,side:"bottom",sideOffset:4,className:"z-50",children:e.jsx(_,{className:x("max-h-[min(18rem,var(--available-height))] origin-[var(--transform-origin)] overflow-y-auto","rounded-xl border border-oai-gray-200 bg-white p-1 shadow-lg ring-1 ring-black/[0.04]","dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:ring-white/[0.05]","transition-[opacity,transform] duration-150 ease-out","data-[starting-style]:scale-95 data-[starting-style]:opacity-0","data-[ending-style]:scale-95 data-[ending-style]:opacity-0",u&&"min-w-[var(--anchor-width)]",d),children:e.jsx(O,{role:"listbox","aria-label":n,children:s.map(a=>e.jsxs(z,{value:a.value,disabled:a.disabled,className:({selected:f,disabled:m})=>x("flex w-full cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg py-1.5 pl-1.5 pr-6","text-left text-xs outline-none transition-colors",f?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800/70 dark:text-white":"text-oai-gray-600 hover:bg-oai-gray-50 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800/60",m&&"cursor-not-allowed opacity-50 hover:bg-transparent dark:hover:bg-transparent"),children:[e.jsx("span",{className:"flex w-3.5 shrink-0 items-center justify-center text-oai-gray-500 dark:text-oai-gray-300",children:e.jsx(D,{children:e.jsx(M,{className:"h-3 w-3","aria-hidden":!0})})}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.jsx(G,{children:a.label})})]},String(a.value)))})})})})]})}export{U as S};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as w,r as c,b as te,f as ne,aQ as G,j as t,h as D,$ as ae,a0 as k,N as a,a2 as ie,ay as se,aR as oe,aC as re,aD as le,aE as T,aS as ce,aT as ue,a1 as de,R as C,Z as ge,_ as he,ab as U,aU as pe,aV as me,a7 as be,aW as fe,S as xe,aX as ye,aY as ve,aZ as je,a_ as ke,a$ as Ne,b0 as Se,b1 as we,b2 as Ce,au as Le,b3 as A}from"./main-BCstrDYE.js";import{b as I,l as P,u as Ee,L as _}from"./use-limits-display-prefs-Bau4ykMw.js";import{S as N,T as j,a as x,b as M}from"./Controls-Cj22oGL3.js";import{u as Ge,P as Ae}from"./use-quality-per-dollar-pref-Htlc-uFe.js";import{C as Ie}from"./check-D8Owfjyw.js";import{C as Pe}from"./copy-DUNz-xWm.js";import{u as _e}from"./useCurrency-bd6TLRsc.js";import{S as R}from"./Select-DnbHYPS4.js";import{I as Oe}from"./info-Cm7V_KDO.js";import{u as F}from"./use-native-settings-CidwlprT.js";import{C as De}from"./ConfirmModal-C6bZw6FZ.js";import{D as Te}from"./download-COSLX73O.js";import"./Card-D_aKGDr7.js";import"./SelectItemText-2LjzGvo5.js";import"./useScrollLock-ajoWrfku.js";import"./DialogTitle-CA5znwms.js";import"./DialogDescription-gxEpcUbJ.js";const Ue=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Me=w("activity",Ue);const Re=[["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"}]],Fe=w("grip-vertical",Re);const He=[["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"}]],$e=w("languages",He);const Ve=[["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"}]],Be=w("log-out",Ve),ze=e=>!e.isLayoutDirty&&e.willUpdate(!1);function O(){const e=new Set,n=new WeakMap,i=()=>e.forEach(ze);return{add:s=>{e.add(s),n.set(s,s.addEventListener("willUpdate",i))},remove:s=>{e.delete(s);const o=n.get(s);o&&(o(),n.delete(s)),i()},dirty:i}}const Ze=c.createContext(null);function We(){const e=c.useRef(!1);return te(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function qe(){const e=We(),[n,i]=c.useState(0),s=c.useCallback(()=>{e.current&&i(n+1)},[n]);return[c.useCallback(()=>ne.postRender(s),[s]),n]}const H=e=>e===!0,Ke=e=>H(e===!0)||e==="id",Ye=({children:e,id:n,inherit:i=!0})=>{const s=c.useContext(G),o=c.useContext(Ze),[r,l]=qe(),u=c.useRef(null),g=s.id||o;u.current===null&&(Ke(i)&&g&&(n=n?g+"-"+n:g),u.current={id:n,group:H(i)&&s.group||O()});const p=c.useMemo(()=>({...u.current,forceRender:r}),[l]);return t.jsx(G.Provider,{value:p,children:e})},Qe="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Je({checked:e,onChange:n,ariaLabel:i}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":i,onClick:n,className:k("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:k("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Xe({prefs:e}){const{order:n,visibility:i,toggle:s,moveToward:o}=e,[r,l]=c.useState(null),[u,g]=c.useState(null),p=d=>m=>{l(d),m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",d)},b=d=>m=>{m.preventDefault(),m.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},f=()=>{l(null),g(null)},y=d=>{d.preventDefault(),l(null),g(null)};return t.jsx(Ye,{children:t.jsx("div",{className:"flex flex-col",children:n.map(d=>{const m=i[d]!==!1,h=r===d;return t.jsxs(D.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:p(d),onDragOver:b(d),onDragEnd:f,onDrop:y,className:k("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",h&&"opacity-40"),style:{cursor:h?"grabbing":"grab"},children:[t.jsx(Fe,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),I(d)?t.jsx(ae,{provider:I(d),size:18,className:k("pointer-events-none",Qe)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:P(d)}),t.jsx("div",{onMouseDown:v=>v.stopPropagation(),draggable:!1,children:t.jsx(Je,{checked:m,onChange:()=>s(d),ariaLabel:`${a("limits.settings.toggle_visible")}: ${P(d)}`})})]},d)})})})}function et(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},i=e.profile&&typeof e.profile=="object"?e.profile:{},s=n.full_name||n.name||i.name||n.user_name||n.preferred_username;return typeof s=="string"&&s.trim()?s.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function tt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function nt(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const i=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),s=n.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=i?.[1]||s?.[1];return o?`https://github.com/${o}`:null}function L(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function at(e,n,i){const[s,o]=c.useState(()=>se()),r=n&&i&&oe(),l=c.useCallback(async()=>{const u=!s;if(re(u),o(u),!!u)try{await le(()=>e())}catch(g){L("cloud sync",g)}},[s,e]);return{cloudSyncOn:s,handleCloudSyncToggle:l,showLocalCloudSync:r}}function it(e){const[n,i]=c.useState(!1),[s,o]=c.useState(!1),[r,l]=c.useState(!1),[u,g]=c.useState(!1),[p,b]=c.useState(null),[f,y]=c.useState(!1),[d,m]=c.useState(""),[h,v]=c.useState(!1),[S,E]=c.useState(""),[z,Z]=c.useState(""),[W,q]=c.useState(!1),[K,Y]=c.useState(null),Q=c.useMemo(()=>et(e),[e]),J=c.useMemo(()=>tt(e),[e]),X=c.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),ee=c.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:b,setGithubUrl:E,setProfileLoading:l,setPublicProfileOn:i,setShowGithubOn:v}),[]);return{anonymousOn:s,customDisplayName:p,displayName:Q,editingGithub:W,editingName:f,email:J,githubError:K,githubInput:z,githubUrl:S,loadSetters:ee,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:b,setEditingGithub:q,setEditingName:y,setGithubError:Y,setGithubInput:Z,setGithubUrl:E,setNameInput:m,setProfileLoading:l,setProfileSaving:g,setPublicProfileOn:i,setShowGithubOn:v,showGithubOn:h,userId:X}}function st(e,n,i){c.useEffect(()=>{if(!n)return;let s=!0;return i.setProfileLoading(!0),(async()=>{try{const o=await T({getAccessToken:e});if(!s||!o)return;const r=await ce({accessToken:o});if(!s)return;i.setPublicProfileOn(!!r?.enabled),i.setAnonymousOn(!!r?.anonymous),r?.display_name&&i.setCustomDisplayName(r.display_name),i.setShowGithubOn(!!r?.show_github_url),i.setGithubUrl(r?.github_url||"")}catch(o){L("load public profile",o)}finally{s&&i.setProfileLoading(!1)}})(),()=>{s=!1}},[e,n,i])}function ot(e,n){return c.useCallback(async(i,{label:s,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await T({getAccessToken:e});if(!l)return!1;const u=await ue({accessToken:l,...i});return r?.(u),!0}catch(l){return o?o(l):L(s||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function rt(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function lt(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function ct(e,n){const i=c.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:c.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:i}}function ut(e,n,i){const s=c.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await n({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),i?.()}})},[n,e,i]),o=c.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:s,startEditingName:o}}function dt(e,n){const i=c.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),s=c.useCallback(async()=>{const r=nt(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(a("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||a("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=c.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:s,handleShowGithubToggle:i,startEditingGithub:o}}function gt(){const e=ie(),n=it(e.user),i=at(e.getAccessToken,e.enabled,e.signedIn);st(e.getAccessToken,e.signedIn,n.loadSetters);const s=ot(e.getAccessToken,n),o=ct(n,s),r=ut(n,s,e.refreshDisplayName),l=dt(n,s);return{...e,...i,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:rt(n,{...o,...r}),github:lt(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function $({disabled:e,onCancel:n,onSave:i,saveLabel:s=a("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:i,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:s}),t.jsx("button",{type:"button",onClick:n,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:a("settings.account.cancel")})]})}function ht({nameInput:e,setEditingName:n,setNameInput:i,profileSaving:s,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>i(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&n(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:a("settings.account.displayName")}),t.jsx($,{disabled:s||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:s?a("settings.account.saving"):void 0})]})}function pt({githubError:e,githubInput:n,handleSaveGithub:i,profileSaving:s,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:n,onChange:u=>{l(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&i(),u.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:a("settings.account.githubUrlPlaceholder")}),t.jsx($,{disabled:s,onCancel:()=>{o(!1),r(null)},onSave:i,saveLabel:s?a("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function V({disabled:e=!1,label:n,onClick:i,title:s}){return t.jsxs("button",{type:"button",onClick:i,disabled:e,title:s,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function B({actions:e,editing:n,editor:i,hint:s,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),n?i:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s})]}),n?null:e]})})}function mt({name:e}){const n=e.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(V,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function bt({name:e}){const{anonymousOn:n,customDisplayName:i,displayName:s,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:u,profileLoading:g,profileSaving:p,setEditingName:b,setNameInput:f,startEditingName:y}=e,d=n?a("settings.account.displayNameAnonymousHint"):i||s;return t.jsx(B,{label:a("settings.account.displayName"),editing:o,hint:d,editor:t.jsx(ht,{nameInput:u,setEditingName:b,setNameInput:f,profileSaving:p,handleSaveName:l}),actions:t.jsx(mt,{name:e})})}function ft({github:e}){const{editingGithub:n,githubError:i,githubInput:s,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:u,profileSaving:g,setEditingGithub:p,setGithubError:b,setGithubInput:f,showGithubOn:y,startEditingGithub:d}=e,{enabled:m,toggle:h}=Ge();return t.jsxs(t.Fragment,{children:[t.jsx(B,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(pt,{githubError:i,githubInput:s,handleSaveGithub:r,profileSaving:g,setEditingGithub:p,setGithubError:b,setGithubInput:f}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(V,{label:a("settings.account.edit"),onClick:d}),t.jsx(j,{checked:y,onChange:l,disabled:u||g,ariaLabel:a("settings.account.githubUrl")})]})}),o&&t.jsx(x,{label:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:a("settings.labs.qpd.label")}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:a("qpd.card.badge")})]}),hint:a("settings.labs.qpd.hint"),control:t.jsx(j,{checked:m,onChange:h,ariaLabel:a("settings.labs.qpd.aria")})})]})}function xt(){const{openLoginModal:e}=de();return t.jsx(N,{title:a("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:a("settings.account.signIn")})]})})}function yt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(bt,{name:e}),t.jsx(ft,{github:n})]})}function vt(){const e=gt();return e.enabled?e.signedIn?t.jsxs(N,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(kt,{onSignOut:e.signOut}),children:[t.jsx(jt,{userId:e.userId}),t.jsx(Nt,{settings:e}),t.jsx(St,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(wt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(xt,{}):null}function jt({userId:e}){const[n,i]=C.useState(!1);if(!e)return null;const s=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),i(!0),globalThis.setTimeout(()=>i(!1),1200)}catch{i(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:a("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":a("settings.account.copyUserId"),children:[n?t.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(Pe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function kt({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(Be,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function Nt({settings:e}){return e.showLocalCloudSync?t.jsx(x,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function St({checked:e,disabled:n,onChange:i}){return t.jsx(x,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:i,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function wt({visible:e,name:n,github:i}){return t.jsx(ge,{initial:!1,children:e?t.jsx(D.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(yt,{name:n,github:i})},"public-profile-fields"):null})}function Ct(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:pe},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:me},{value:"system",label:a("settings.appearance.theme.system"),Icon:be}]}function Lt(){return[{value:ye,label:a("settings.appearance.language.system")},{value:ve,label:a("settings.appearance.language.english")},{value:je,label:a("settings.appearance.language.chinese")},{value:ke,label:a("settings.appearance.language.traditional_chinese")},{value:Ne,label:a("settings.appearance.language.japanese")},{value:Se,label:a("settings.appearance.language.korean")},{value:we,label:a("settings.appearance.language.german")}]}function Et(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function Gt(e,n){const i=a(`settings.appearance.currency.rate_source.${e}`),s=Et(n),o=s?a("settings.appearance.currency.rate_updated",{when:s}):a("settings.appearance.currency.rate_never");return`${i} · ${o}`}function At({locale:e,setLocale:n}){const i=Lt();return t.jsx(R,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx($e,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function It({currency:e,setCurrency:n}){const i=fe().map(s=>({value:s.code,label:a(s.labelKey)}));return t.jsx(R,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Pt({currency:e,rate:n,rateSource:i,rateFetchedAt:s}){if(e===xe)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=Gt(i,s);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(Oe,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function _t(){const{theme:e,setTheme:n}=he(),{locale:i,setLocale:s}=U(),{currency:o,rate:r,rateSource:l,rateFetchedAt:u,setCurrency:g}=_e();return t.jsxs(N,{title:a("settings.section.appearance"),children:[t.jsx(x,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(M,{options:Ct(),value:e,onChange:n})}),t.jsx(x,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(At,{locale:i,setLocale:s})}),t.jsx(x,{label:a("settings.appearance.currency.label"),hint:t.jsx(Pt,{currency:o,rate:r,rateSource:l,rateFetchedAt:u}),control:t.jsx(It,{currency:o,setCurrency:g})})]})}function Ot(){const{available:e,settings:n,setSetting:i,runAction:s}=F();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.launchAtLoginSupported!==!1,l=n?.updateStatus||null,u=!!n?.updateBusy,g=!!n?.isSyncing;return t.jsxs(N,{title:a("settings.section.menubar"),children:[r?t.jsx(x,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>i("launchAtLogin",!o),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,t.jsx(x,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>s("syncNow"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Ce,{className:k("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(x,{label:a("settings.menubar.updates"),hint:l||void 0,control:t.jsxs("button",{type:"button",onClick:()=>s("checkForUpdates"),disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function Dt(e,n){function i(r){return r.replace(/^v/,"").split(".").map(Number)}const s=i(e),o=i(n);for(let r=0;r<Math.max(s.length,o.length);r++){const l=s[r]||0,u=o[r]||0;if(l<u)return!0;if(l>u)return!1}return!1}function Tt(){const{available:e,settings:n,runAction:i}=F(),s=e&&n?.version,[o,r]=C.useState(!1),[l,u]=C.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:g}=U(),p="0.77.2",b=async()=>{r(!0);try{const h=await fetch("https://api.github.com/repos/mm7894215/TokenTracker/releases/latest");if(!h.ok)throw new Error("Failed to fetch");const v=await h.json(),S=v.tag_name;Dt(p,S)?u({open:!0,latestVersion:S,htmlUrl:v.html_url}):A({title:a("settings.menubar.updates.upToDate")})}catch(h){console.error("Check updates failed:",h),A({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},f=a("settings.menubar.updates.modalTitle"),y=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),d=a("settings.menubar.updates.modalConfirm"),m=a("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[s?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>i("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:b,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Le,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(Me,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(De,{open:l.open,title:f,description:y,confirmLabel:d,cancelLabel:m,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),u(h=>({...h,open:!1}))},onCancel:()=>u(h=>({...h,open:!1}))})]})}function Ut({prefs:e}){return t.jsx(M,{options:[{value:_.USED,label:a("limits.settings.display_mode_used")},{value:_.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function tn(){const e=Ee();return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.page.subtitle")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(_t,{}),t.jsx(Ot,{}),t.jsx(vt,{}),t.jsx(N,{title:a("settings.section.limits"),action:t.jsx(Ut,{prefs:e}),children:t.jsx(Xe,{prefs:e})})]}),t.jsx(Tt,{})]})})})}export{tn as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as Ye,r as i,j as e,b8 as it,b9 as ca,X as Se,N as r,a0 as Z,ba as ia,bb as _a,bc as ot,bd as lt,be as ha,bf as dt,bg as ct,bh as ut,bi as xa,bj as mt,bk as gt,bl as ht,bm as xt,bn as pt,bo as ft,Z as yt,g as bt,h as pa,am as kt,P as wt,$ as be,bp as vt,bq as jt,br as Nt,bs as Ct,bt as St,bu as _t,l as Lt,T as G,b2 as Pt,bv as oa,R as Rt,bw as It,bx as fa,b3 as Ce,by as ya,bz as ba,bA as $t,bB as ka,bC as wa,bD as Et,bE as Bt}from"./main-BCstrDYE.js";import{L as Tt}from"./LocalOnlyNotice-gtHCn7Mx.js";import{C as Dt}from"./Card-D_aKGDr7.js";import{C as va}from"./ConfirmModal-C6bZw6FZ.js";import{I as La}from"./info-Cm7V_KDO.js";import{u as Mt}from"./useCurrency-bd6TLRsc.js";import{L as ee}from"./loader-circle-6XAdy2ec.js";import{C as _e}from"./check-D8Owfjyw.js";import{T as ua}from"./trash-2-DKLewOQb.js";import{u as Ot,s as Ut,f as Pa,a as Ft,b as zt,c as At,d as Kt,e as Vt,g as qt,S as Ra,h as Ia,i as $a,C as ma,j as Ea,k as Ba,l as Ta,m as Ge,n as We,o as Qe}from"./SelectItemText-2LjzGvo5.js";import{t as Ht,u as la,a as Gt}from"./useScrollLock-ajoWrfku.js";import{D as Da}from"./download-COSLX73O.js";import{P as Ma,a as Oa,b as Ua,c as Fa,d as za,C as Wt}from"./PopoverPopup-CQxxgUXk.js";import"./arrow-up-right-Bm3t-iA0.js";import"./DialogTitle-CA5znwms.js";import"./DialogDescription-gxEpcUbJ.js";const Qt=[["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"}]],Aa=Ye("circle-arrow-up",Qt);const Xt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],da=Ye("external-link",Xt);const Yt=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],Jt=Ye("flame",Yt);const Zt=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ka=Ye("plus",Zt);function ga({id:a,value:s,onChange:l,placeholder:m,disabled:c=!1,type:x="text",label:u,error:g,className:h="",...b}){const o=i.useId(),k=a||o,N=g?`${k}-error`:void 0,C=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${c?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${g?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${h}`;return e.jsxs("div",{className:"w-full",children:[u&&e.jsx("label",{htmlFor:k,className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:u}),e.jsx("input",{id:k,type:x,value:s,onChange:l,placeholder:m,disabled:c,"aria-invalid":g?!0:void 0,"aria-describedby":N,className:C,...b}),g&&e.jsx("p",{id:N,className:"mt-1.5 text-sm text-oai-error",children:g})]})}const Va=i.forwardRef(function(s,l){const{render:m,className:c,style:x,...u}=s,{store:g}=Ot(),b={open:it(g,Ut.open)};return ca("span",s,{state:b,ref:l,props:[{"aria-hidden":!0,children:"▼"},u],stateAttributesMapping:Ht})}),er="tt:hint:dismissed:";function qa(a){return er+a}function ar(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(qa(a))==="1"}catch{return!1}}function tr({id:a,children:s,className:l,ariaLabel:m}){const[c,x]=i.useState(()=>ar(a)),u=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(qa(a),"1")}catch{}x(!0)},[a]);return c?null:e.jsxs("div",{role:"note","aria-label":m||r("hint.dismissible_aria"),className:Z("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",l),children:[e.jsx("button",{type:"button",onClick:u,"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(Se,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(La,{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 rr(a){if(!a)return null;for(const s of a.elements){const l=s.tagName;if(l==="BUTTON"||l==="INPUT"){const m=s;if(m.type==="submit")return m}}return null}let ja=(function(a){return a.checked="data-checked",a.unchecked="data-unchecked",a.indeterminate="data-indeterminate",a.disabled="data-disabled",a.readonly="data-readonly",a.required="data-required",a.valid="data-valid",a.invalid="data-invalid",a.touched="data-touched",a.dirty="data-dirty",a.filled="data-filled",a.focused="data-focused",a})({});function Ha(a){return i.useMemo(()=>({checked(s){return a.indeterminate?{}:s?{[ja.checked]:""}:{[ja.unchecked]:""}},...Pa}),[a.indeterminate])}const sr=i.createContext({disabled:!1});function nr(){return i.useContext(sr)}function ir(a,s,l,m=!0,c){const[x,u]=i.useState(),g=la(c?`${c}-label`:void 0),h=a??s??x;return ia(()=>{const b=a||s||!m?void 0:or(l.current,g);x!==b&&u(b)}),h}function or(a,s){const l=lr(a);if(l)return!l.id&&s&&(l.id=s),l.id||void 0}function lr(a){if(!a)return;const s=a.parentElement;if(s&&s.tagName==="LABEL")return s;const l=a.id;if(l){const c=a.nextElementSibling;if(c&&c.htmlFor===l)return c}const m=a.labels;return m&&m[0]}const dr=i.createContext(void 0);function cr(a=!0){const s=i.useContext(dr);if(s===void 0&&!a)throw new Error(_a(3));return s}const Ga=i.createContext(void 0);function ur(){const a=i.useContext(Ga);if(a===void 0)throw new Error(_a(14));return a}const mr="data-parent",gr=i.forwardRef(function(s,l){const{checked:m,className:c,defaultChecked:x=!1,"aria-labelledby":u,disabled:g=!1,form:h,id:b,indeterminate:o=!1,inputRef:k,name:N,onCheckedChange:w,parent:v=!1,readOnly:y=!1,render:C,required:$=!1,uncheckedValue:U,value:W,nativeButton:F=!1,style:ge,...j}=s,{clearErrors:ae}=Ft(),{disabled:E,name:K,setDirty:Q,setFilled:te,setFocused:z,setTouched:ke,state:we,validationMode:Ue,validityData:Le,validation:Fe}=zt(),ze=nr(),{labelId:D,controlId:re,registerControlId:X,getDescriptionProps:ve}=At(),L=cr(),V=L?.parent,se=V&&L.allValues,I=E||ze.disabled||L?.disabled||g,ne=K??N,P=W??ne,Pe=la(),je=la();let ie=re;se?ie=v?je:`${V.id}-${P}`:b&&(ie=b);let pe={};se&&(v?pe=L.parent.getParentProps():P&&(pe=L.parent.getChildProps(P)));const{checked:Re=m,indeterminate:Ie=o,onCheckedChange:$e,...Ne}=pe,q=L?.value,oe=L?.setValue,fe=L?.defaultValue,le=i.useRef(null),de=ot(()=>Symbol("checkbox-control")),he=i.useRef(!1),{getButtonProps:Je,buttonRef:Ae}=lt({disabled:I,native:F}),ce=L?.validation??Fe,[_,Ze]=Kt({controlled:P&&q&&!v?q.includes(P):Re,default:P&&fe&&!v?fe.includes(P):x,name:"Checkbox",state:"checked"}),Ee=se?!!Re:_,ye=se&&Ie||o;ia(()=>{X!==ha&&(he.current=!0,X(de.current,ie))},[ie,X,de]),i.useEffect(()=>{const f=de.current;return()=>{!he.current||X===ha||(he.current=!1,X(f,void 0))}},[X,de]),Vt(le,Pe,_,void 0,!L&&!I,N);const Y=i.useRef(null),Be=dt(k,Y,ce.inputRef,ce.registerInput),ea=ir(u,D,Y,!F,ie??void 0);ia(()=>{Y.current&&(Y.current.indeterminate=ye,_&&te(!0))},[_,ye,te]),qt(_,()=>{L||(ae(ne),te(_),Q(_!==Le.initialValue),ce.change(_))});const Ke=ct({checked:_,disabled:I,form:h,name:v?void 0:ne,id:F?void 0:ie??void 0,required:$,ref:Be,style:ne?mt:gt,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(f){if(f.nativeEvent.defaultPrevented)return;if(y){f.preventDefault();return}const M=f.currentTarget.checked,ue=ht(xt,f.nativeEvent);if(w?.(M,ue),!ue.isCanceled&&($e?.(M,ue),!ue.isCanceled&&(Ze(M),P&&q&&oe&&!v&&!se))){const me=M?[...q,P]:q.filter(B=>B!==P);oe(me,ue)}},onFocus(){le.current?.focus()}},W!==void 0?{value:(L?_&&W:W)||""}:ut,ve,f=>ce.getValidationProps(I,f));i.useEffect(()=>{if(!V||!P)return;const f=V.disabledStatesRef.current;return f.set(P,I),()=>{f.delete(P)}},[V,I,P]);const Te=i.useMemo(()=>({...we,checked:Ee,disabled:I,readOnly:y,required:$,indeterminate:ye}),[we,Ee,I,y,$,ye]),aa=Ha(Te),ta=ca("span",s,{state:Te,ref:[Ae,le,l,L?.registerControlRef],props:[{id:F?ie??void 0:Pe,role:"checkbox","aria-checked":ye?"mixed":Ee,"aria-readonly":y||void 0,"aria-required":$||void 0,"aria-labelledby":ea,[mr]:v?"":void 0,onFocus(){I||z(!0)},onBlur(){const f=Y.current;f&&(ke(!0),z(!1),Ue==="onBlur"&&ce.commit(L?q:f.checked))},onKeyDown(f){if(f.key!=="Enter"||(f.preventBaseUIHandler(),f.defaultPrevented))return;const M=Y.current?.form??null,ue=f.currentTarget,me=f.nativeEvent,B=f.preventDefault,H=me.preventDefault;let De=!1;f.preventDefault=()=>{De=!0,B.call(f)},me.preventDefault=()=>{De=!0,H.call(me)},H.call(me),xa(ue).queueMicrotask(()=>{f.preventDefault=B,me.preventDefault=H,De||rr(M)?.click()})},onClick(f){if(y||I)return;f.preventDefault();const M=Y.current;M&&M.dispatchEvent(new(xa(M)).PointerEvent("click",{bubbles:!0,shiftKey:f.shiftKey,ctrlKey:f.ctrlKey,altKey:f.altKey,metaKey:f.metaKey}))}},j,Ne,Je,ve,f=>ce.getValidationProps(I,f)],stateAttributesMapping:aa});return e.jsxs(Ga.Provider,{value:Te,children:[ta,!_&&!L&&ne&&!v&&U!==void 0&&e.jsx("input",{type:"hidden",form:h,name:ne,value:U,disabled:I}),e.jsx("input",{...Ke,suppressHydrationWarning:!0})]})}),hr=i.forwardRef(function(s,l){const{render:m,className:c,style:x,keepMounted:u=!1,...g}=s,h=ur(),b=h.checked||h.indeterminate,{mounted:o,transitionStatus:k,setMounted:N}=Gt(b),w=i.useRef(null),v={...h,transitionStatus:k};pt({open:b,ref:w,onComplete(){b||N(!1)}});const C={...Ha(h),...ft,...Pa},$=u||o,U=ca("span",s,{ref:[l,w],state:v,stateAttributesMapping:C,props:g});return $?U:null});function xr(a,s){return`target:${a}:${s}`}function pr(a){return`remove:${a.id||a.directory}`}function Wa(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function fr(a){const s=Wa(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 l=Math.max(1,Math.floor(s/30));return r("skills.usage.months_ago",{months:l})}function yr(a){const s=Wa(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 sa({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 br({skill:a,targets:s,busyKey:l,usage:m,hasUpdate:c,updating:x,onUpdate:u,onClose:g,onToggleTarget:h,onRemove:b}){return e.jsx(yt,{children:a?e.jsx(kr,{skill:a,targets:s,busyKey:l,usage:m,hasUpdate:c,updating:x,onUpdate:u,onClose:g,onToggleTarget:h,onRemove:b},a.id||a.directory):null})}function kr({skill:a,targets:s,busyKey:l,usage:m,hasUpdate:c,updating:x,onUpdate:u,onClose:g,onToggleTarget:h,onRemove:b}){const o=bt(),{currency:k,rate:N}=Mt(),w=i.useRef(null);i.useEffect(()=>{const j=E=>{E.key==="Escape"&&(E.stopPropagation(),g?.())},ae=E=>{const K=E.target;K instanceof Element&&(w.current?.contains(K)||K.closest('[data-skill-row="1"]')||g?.())};return document.addEventListener("keydown",j),document.addEventListener("mousedown",ae),()=>{document.removeEventListener("keydown",j),document.removeEventListener("mousedown",ae)}},[g]);const v=a.name||a.directory,y=!!(a.repoOwner&&a.repoName),C=y?`https://github.com/${a.repoOwner}/${a.repoName}`:null,$=new Set(a.targets||[]),U=l===pr(a),W=fr(m?.lastUsedAt),F=!!(m&&m.invocations>0),ge=o?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(pa.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:o?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:o?0:.15},onClick:g,"aria-hidden":!0}),e.jsxs(pa.aside,{ref:w,role:"complementary","aria-label":v,initial:o?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:o?{opacity:0}:{opacity:0,x:24,scale:.98},transition:ge,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:v,children:v}),y?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(da,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):a.directory&&a.directory!==v?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:g,"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(Se,{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:[c?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(Aa,{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:()=>u?.(a),disabled:x,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:[x?e.jsx(ee,{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.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(sa,{label:r("skills.usage.invocations"),children:kt(m?.invocations||0)}),e.jsx(sa,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:Z("h-1.5 w-1.5 rounded-full",yr(m?.lastUsedAt)),"aria-hidden":!0}),F?W||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(sa,{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(La,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:wt(m?.cost||0,{currency:k,rate:N})})]}),F?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")})]}),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||[]).map(j=>{const ae=$.has(j.id),E=l===xr(a.id,j.id),K=`skill-detail-sync-${a.id||a.directory}-${j.id}`;return e.jsxs("label",{htmlFor:K,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(gr,{id:K,checked:ae,disabled:E,onCheckedChange:Q=>h?.(a,j.id,!!Q),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(hr,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(_e,{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(be,{provider:j.id,size:16})}),e.jsx("span",{className:"flex-1",children:j.label}),E?e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},j.id)})})]})]}),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:()=>b?.(a),disabled:U,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:[U?e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ua,{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 wr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),na=["claude","codex"],O="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"},xe="all",T="skillssh";function Xe(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Qa(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function jr(a){return Qa(a).split("/").filter(Boolean).pop()||""}function Nr(a){if(a.repoOwner||a.repoName)return"";const s=Qa(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Na(a){const s=jr(a.directory);return s?`dir:${s}`:""}function Ca(a){const s=new Set([Xe(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const l=Nr(a);return l&&s.add(l),s}function He(a){return`install:${Xe(a)}`}function Sa(a){return`remove:${a.id||a.directory}`}function Xa(a,s){return`target:${a}:${s}`}function Cr({target:a,state:s,busy:l,onToggle:m}){const c=s==="synced",x=s==="orphan",u=x?r("skills.dot.orphan_aria",{agent:a.label}):c?r("skills.dot.synced_aria",{agent:a.label}):r("skills.dot.off_aria",{agent:a.label});return e.jsxs("button",{type:"button",title:u,"aria-label":u,"aria-pressed":c,disabled:l,onClick:g=>{g.stopPropagation(),m?.(a.id,!c)},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:[l?e.jsx(ee,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:Z("flex h-[18px] w-[18px] items-center justify-center transition",c&&vr[a.id],!c&&!x&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(be,{provider:a.id,size:18})}),x&&!l?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 Sr({skill:a,targets:s,onToggleTarget:l,busyKey:m}){return e.jsx("div",{className:"flex items-center gap-1",onClick:c=>c.stopPropagation(),children:s.map(c=>e.jsx(Cr,{target:c,state:a.targetStates?.[c.id]||"off",busy:m===Xa(a.id,c.id),onToggle:(x,u)=>l?.(a,x,u)},c.id))})}function _r({skill:a,targets:s,selected:l,onSelect:m,selectable:c,checked:x,onToggleSelect:u,onToggleTarget:g,hasUpdate:h,busyKey:b}){const o=a.repoOwner&&a.repoName?`${a.repoOwner}/${a.repoName}`:null,k=o?`${a.directory} · ${o}`:a.directory,N=w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),m?.(a))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":l,"aria-label":r("skills.row.open_details",{name:a.name||a.directory}),onClick:()=>m?.(a),onKeyDown:N,className:Z("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",l?"bg-oai-gray-100 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800/60 dark:ring-oai-gray-800":x?"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:[c?e.jsx("label",{className:"flex shrink-0 items-center",onClick:w=>w.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:x,onChange:w=>u?.(a,w.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:k,children:a.name||a.directory}),h?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(Aa,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Sr,{skill:a,targets:s,onToggleTarget:g,busyKey:b}),e.jsx(Wt,{className:Z("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",l&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),a.description?e.jsx("p",{className:Z("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",c&&"pl-7"),children:a.description}):null]})}function Lr({agentFilter:a,agentOptions:s,onAgentFilter:l,filteredCount:m,totalCount:c,anyFilter:x,onClearFilters:u,searchQuery:g,onSearchQuery:h,searchPlaceholder:b}){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(Ra,{value:a,onValueChange:l,children:[e.jsxs(Ia,{"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($a,{children:o=>o==="all"?r("skills.filter.agent_all"):s.find(k=>k.id===o)?.label||o}),e.jsx(Va,{className:"text-oai-gray-400",children:e.jsx(ma,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ea,{children:e.jsx(Ba,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ta,{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(Ge,{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(We,{children:r("skills.filter.agent_all")}),e.jsx(Qe,{children:e.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(o=>e.jsxs(Ge,{value:o.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(be,{provider:o.id,size:14}),e.jsx(We,{children:o.label})]}),e.jsx(Qe,{children:e.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},o.id))]})})})]}),e.jsxs("div",{className:"relative w-56 max-w-full",children:[e.jsx(oa,{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(ga,{type:"search",value:g,onChange:o=>h(o.target.value),onKeyDown:o=>{o.key==="Escape"&&g&&(o.preventDefault(),h(""))},"aria-label":r("skills.action.search_aria"),placeholder:b,className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:o=>o.preventDefault(),onClick:()=>h(""),"aria-label":r("skills.action.search_clear"),"aria-hidden":!g,tabIndex:g?0:-1,className:Z("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",g?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(Se,{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:m,total:c})}),x?e.jsxs("button",{type:"button",onClick:u,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(Se,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Pr({count:a,targets:s,busy:l,onBulkSync:m,onBulkRemove:c,onClear:x}){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(Ma,{children:[e.jsxs(Oa,{disabled:l,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(Da,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(ma,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Ua,{children:e.jsx(Fa,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(za,{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")}),s.map(u=>e.jsxs("button",{type:"button",onClick:()=>m(u.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(be,{provider:u.id,size:16}),e.jsx("span",{className:"flex-1",children:u.label})]},u.id))]})})})]}),e.jsxs(G,{type:"button",variant:"ghost",size:"sm",disabled:l,onClick:c,children:[e.jsx(ua,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_remove")]}),e.jsxs("button",{type:"button",onClick:x,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(Se,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Rr({items:a,totalCount:s,targets:l,agentOptions:m,agentFilter:c,onAgentFilter:x,anyFilter:u,onClearFilters:g,searchQuery:h,onSearchQuery:b,searchPlaceholder:o,selectedId:k,onSelect:N,onToggleTarget:w,busyKey:v,updates:y,selectedIds:C,onToggleSelect:$,onClearSelection:U,onBulkSync:W,onBulkRemove:F}){const ge=C.size;return e.jsxs("div",{children:[ge>0?e.jsx(Pr,{count:ge,targets:l,busy:v==="batch",onBulkSync:W,onBulkRemove:F,onClear:U}):e.jsx(Lr,{agentFilter:c,agentOptions:m,onAgentFilter:x,filteredCount:a.length,totalCount:s,anyFilter:u,onClearFilters:g,searchQuery:h,onSearchQuery:b,searchPlaceholder:o}),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(G,{type:"button",variant:"secondary",size:"sm",onClick:g,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(j=>e.jsx(_r,{skill:j,targets:l,selected:k===(j.id||j.directory),onSelect:N,selectable:!0,checked:C.has(j.id),onToggleSelect:$,onToggleTarget:w,hasUpdate:!!(j.id&&y?.[j.id]),busyKey:v},j.id||j.key))})]})}const Ir={contentVisibility:"auto",containIntrinsicSize:"0 240px"},$r=Rt.memo(function({skill:s,installed:l,installing:m,allTargets:c,defaultTargets:x,onInstall:u,onManage:g}){const[h,b]=i.useState(()=>(x||[]).filter(y=>c.some(C=>C.id===y))),o=y=>{b(C=>C.includes(y)?C.filter($=>$!==y):[...C,y])},k=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,N=k?`https://github.com/${s.repoOwner}/${s.repoName}`:null,w=s.installs!=null?r("skills.card.installs",{count:Number(s.installs||0).toLocaleString()}):null,v=h.length?h.map(y=>c.find(C=>C.id===y)?.label||y).join(", "):r("skills.action.choose_targets");return e.jsxs(Dt,{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(da,{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}),k||w?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:[N?e.jsxs("a",{href:N,target:"_blank",rel:"noopener noreferrer",onClick:y=>y.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:N,children:[e.jsx("span",{className:"truncate",children:k}),e.jsx(da,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,k&&w?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,w?e.jsx("span",{className:"truncate",children:w}):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:l?e.jsxs(G,{type:"button",variant:"secondary",size:"sm",onClick:()=>g?.(s),className:"w-full",children:[e.jsx(_e,{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:h.length?v:r("skills.target.none")}),e.jsxs(Ma,{children:[e.jsx(Oa,{disabled:m,"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(Ua,{children:e.jsx(Fa,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(za,{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")}),c.map(y=>{const C=h.includes(y.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:()=>o(y.id)}),e.jsx(be,{provider:y.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:y.label})]},y.id)})]})})})]})]}),e.jsxs(G,{type:"button",size:"sm",onClick:()=>u(s,h),disabled:m||h.length===0,className:"w-full",children:[m?e.jsx(ee,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Da,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function Er({repos:a,repoInput:s,onRepoInput:l,busyKey:m,onAdd:c,onRemove:x}){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(ga,{value:s,onChange:u=>l(u.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(G,{type:"button",variant:"secondary",size:"md",onClick:c,disabled:m==="repo:add",className:"shrink-0 whitespace-nowrap",children:[m==="repo:add"?e.jsx(ee,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Ka,{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(u=>{const g=m===`repo:${u.owner}/${u.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:[u.owner,"/",u.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:u.branch})]}),e.jsxs(G,{type:"button",variant:"ghost",size:"sm",disabled:g,onClick:()=>x(u),className:"shrink-0",children:[g?e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ua,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${u.owner}/${u.name}`)})}):null]})}function Br(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Yr(){const[a,s]=i.useState(Br),[l,m]=i.useState({skills:[],targets:[]}),[c,x]=i.useState([]),[u,g]=i.useState([]),[h,b]=i.useState([]),[o,k]=i.useState(xe),[N,w]=i.useState(""),[v,y]=i.useState(""),[C,$]=i.useState(""),[U,W]=i.useState(""),[F,ge]=i.useState(""),[j,ae]=i.useState(!1),[E,K]=i.useState("all"),[Q,te]=i.useState(null),[z,ke]=i.useState(""),[we,Ue]=i.useState(!0),[Le,Fe]=i.useState(!1),[ze,D]=i.useState(""),[re,X]=i.useState(null),[ve,L]=i.useState(null),[V,se]=i.useState(()=>new Set),[I,ne]=i.useState({}),[P,Pe]=i.useState({}),[je,ie]=i.useState([]),[pe,Re]=i.useState(!1),Ie=i.useRef(!1),$e=i.useMemo(()=>{const t=new Set;for(const n of l.skills||[])for(const d of Ca(n))t.add(d);return t},[l.skills]),Ne=i.useCallback(async()=>{const t=await vt();m({skills:t.skills||[],targets:t.targets||[]})},[]),q=i.useCallback(async()=>{const t=await jt();b(t.repos||[])},[]),oe=i.useCallback(async({force:t=!1}={})=>{Fe(!0);try{const n=await Nt({force:t});x(n.skills||[])}finally{Fe(!1)}},[]),fe=i.useCallback(async({force:t=!1}={})=>{Re(!0);try{const n=await Ct({force:t});ie(n.skills||[])}finally{Re(!1)}},[]),le=i.useCallback(async()=>{try{const t=await St();ne(t?.updates||{})}catch{ne({})}},[]),de=i.useCallback(async()=>{try{const t=await _t(),n={};for(const d of t?.skills||[])d.installed&&(d.directory&&(n[String(d.directory).toLowerCase()]=d),n[String(d.skill).toLowerCase()]=d);Pe(n)}catch{Pe({})}},[]),he=i.useCallback(async()=>{Ue(!0),D("");try{await Promise.all([Ne(),q()])}catch(t){D(t?.message||r("skills.error.generic"))}finally{Ue(!1)}},[Ne,q]),Je=i.useCallback(async()=>{await he();const t=n=>D(n?.message||r("skills.error.generic"));a==="my"?(le(),de()):o===O?fe({force:!0}).catch(t):o!==T&&oe({force:!0}).catch(t)},[oe,he,fe,le,de,o,a]);i.useEffect(()=>{he()},[he]),i.useEffect(()=>{if(Ie.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){Ie.current=!0;return}const d=l.skills||[];if(!d.length)return;const p=d.find(S=>S.directory===n||S.id===n);p&&(s("my"),te(p.id||p.directory)),Ie.current=!0,t.delete("skill");const R=t.toString();window.history.replaceState({},"",`${window.location.pathname}${R?`?${R}`:""}${window.location.hash}`)},[l.skills]),i.useEffect(()=>{a==="browse"&&(o===T||o===O||c.length===0&&oe().catch(t=>D(t?.message||r("skills.error.generic"))))},[c.length,oe,o,a]),i.useEffect(()=>{a!=="browse"||o!==O||je.length===0&&fe().catch(t=>D(t?.message||r("skills.error.generic")))},[fe,je.length,o,a]);const Ae=Object.keys(I).length>0,ce=Object.keys(P).length>0;if(i.useEffect(()=>{a==="my"&&(Ae||le(),ce||de())},[a,Ae,ce,le,de]),i.useEffect(()=>{const t=setTimeout(()=>y(N),200);return()=>clearTimeout(t)},[N]),i.useEffect(()=>{const t=setTimeout(()=>W(C),120);return()=>clearTimeout(t)},[C]),i.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("tab");if(a==="my"){if(!n)return;t.delete("tab")}else{if(n===a)return;t.set("tab",a)}const d=t.toString(),p=`${window.location.pathname}${d?`?${d}`:""}${window.location.hash}`;window.history.replaceState({},"",p)},[a]),!wr&&!Lt())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Tt,{})});const _=async(t,n)=>{ke(t),D("");try{await n(),await Ne()}catch(d){D(d?.message||r("skills.error.generic"))}finally{ke("")}},Ze=(t,n)=>{const d=(n&&n.length?n:na).filter(p=>(l.targets||[]).some(R=>R.id===p));_(He(t),async()=>{await fa(t,d);const p=d.map(R=>(l.targets||[]).find(S=>S.id===R)?.label||R).join(", ");Ce({title:r("skills.toast.installed",{name:t.name||t.directory,targets:p||r("skills.target.none")}),timeout:4e3})})},Ee=t=>{X(t)},ye=()=>{const t=re;t&&(X(null),_(Sa(t),async()=>{let n=null;t.managed?n=await ya(t.id):await ba(t.directory,t.targets||[]);const d=!!(n?.trashed&&t.managed&&t.id);Ce({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:d?{onUndo:async()=>{try{await $t(t.id),await Ne()}catch(p){D(p?.message||r("skills.error.generic"))}}}:void 0})}))},Y=(t,n,d)=>_(Xa(t.id,n),async()=>{const p=new Set(t.targets||[]);d?p.add(n):p.delete(n),t.managed?await ka(t.id,Array.from(p)):await wa(t.directory,Array.from(p));const R={name:t.name||t.directory,agent:Ke(n)};Ce({title:d?r("skills.toast.synced_one",R):r("skills.toast.unsynced_one",R),timeout:3e3})}),Be=i.useCallback(()=>se(new Set),[]),ea=i.useCallback((t,n)=>{se(d=>{const p=new Set(d);return n?p.add(t.id):p.delete(t.id),p})},[]),Ke=t=>(l.targets||[]).find(n=>n.id===t)?.label||t,Te=t=>{const n=(l.skills||[]).filter(d=>V.has(d.id));n.length&&_("batch",async()=>{for(const d of n){const p=new Set(d.targets||[]);p.add(t),d.managed?await ka(d.id,Array.from(p)):await wa(d.directory,Array.from(p))}Be(),Ce({title:r("skills.toast.bulk_synced",{count:n.length,agent:Ke(t)}),timeout:4e3})})},aa=()=>{const t=(l.skills||[]).filter(n=>V.has(n.id));t.length&&L(t)},ta=()=>{const t=ve;t&&(L(null),_("batch",async()=>{for(const n of t)n.managed?await ya(n.id):await ba(n.directory,n.targets||[]);Be(),Ce({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},f=t=>{!t?.repoOwner||!t?.repoName||_(He(t),async()=>{await fa({key:t.key,name:t.name,description:t.description,directory:t.sourceDirectory||t.directory,repoOwner:t.repoOwner,repoName:t.repoName,repoBranch:t.repoBranch,readmeUrl:t.readmeUrl},t.targets&&t.targets.length?t.targets:na),await le(),Ce({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},M=async()=>{const t=N.trim();if(!(t.length<2)){ke("search"),D("");try{const n=await It(t);g(n.skills||[])}catch(n){D(n?.message||r("skills.error.generic"))}finally{ke("")}}},ue=async()=>{const t=F.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,d]=t.split("/");if(!n||!d){D(r("skills.repo.invalid"));return}await _("repo:add",async()=>{await Bt({owner:n,name:d,branch:"main",enabled:!0}),ge(""),await q(),await oe()})},me=async t=>{await _(`repo:${t.owner}/${t.name}`,async()=>{await Et(t.owner,t.name),await q(),await oe()})},B=l.targets||[],H=l.skills||[],De=i.useMemo(()=>{const t=E==="all"?H:H.filter(d=>(d.targets||[]).includes(E)),n=U.trim().toLowerCase();return n?t.filter(d=>(d.name||"").toLowerCase().includes(n)||(d.directory||"").toLowerCase().includes(n)||(d.description||"").toLowerCase().includes(n)):t},[H,E,U]),Ya=E!=="all",J=i.useMemo(()=>Q&&H.find(t=>(t.id||t.directory)===Q)||null,[H,Q]),Ja=i.useCallback(()=>{K("all"),$("")},[]),Za=i.useCallback(t=>{te(n=>{const d=t?.id||t?.directory||null;return n===d?null:d})},[]),et=i.useCallback(()=>te(null),[]),at=i.useCallback(t=>{const n=Xe(t).toLowerCase(),d=Na(t),p=(l.skills||[]).find(R=>{const S=Ca(R);return S.has(n)||d&&S.has(d)});p&&te(p.id||p.directory)},[l.skills]);i.useEffect(()=>{a!=="my"&&V.size&&se(new Set)},[a,V.size]),i.useEffect(()=>{Q&&!J&&te(null)},[J,Q]);const Me=i.useMemo(()=>{const t=o===T?u:o===O?je:c,d=o===T||o===O||o===xe?t:t.filter(S=>`${S.repoOwner}/${S.repoName}`===o),p=v.trim().toLowerCase();return(o===T||!p?d:d.filter(S=>(S.name||"").toLowerCase().includes(p)||(S.directory||"").toLowerCase().includes(p)||(S.description||"").toLowerCase().includes(p))).map(S=>{const ra=Xe(S).toLowerCase(),A=Na(S);return{...S,installed:$e.has(ra)||A&&$e.has(A)}})},[v,c,$e,je,u,o]),tt=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(ee,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),rt=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(ee,{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")})]}),Ve=(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 qe;if(we)qe=tt;else if(a==="my")qe=H.length?e.jsx(Rr,{items:De,totalCount:H.length,targets:B,agentOptions:B,agentFilter:E,onAgentFilter:K,anyFilter:Ya,onClearFilters:Ja,searchQuery:C,onSearchQuery:$,searchPlaceholder:r("skills.my.placeholder"),selectedId:Q,onSelect:Za,onToggleTarget:Y,busyKey:z,updates:I,selectedIds:V,onToggleSelect:ea,onClearSelection:Be,onBulkSync:Te,onBulkRemove:aa}):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:[B.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:[...B,...B].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(be,{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:[...B,...B].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(be,{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(G,{type:"button",size:"sm",onClick:()=>s("browse"),children:r("skills.empty.my_cta")})]});else{const t=o===T,n=o===O,d=h.length===0&&!t&&!n,p=Le&&!t&&!n||n&&pe,R=!t&&!n&&(v.trim()!==""||o!==xe),S=()=>{w(""),k(xe)},ra=!d&&!p&&(Me.length>0||R)?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:Me.length})}),R?e.jsxs("button",{type:"button",onClick:S,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(Se,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let A;d?A=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")})}):p?A=rt:t&&N.trim().length<2?A=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")}):Me.length?A=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Me.map(Oe=>e.jsx("div",{style:Ir,children:e.jsx($r,{skill:Oe,installed:!!Oe.installed,installing:z===He(Oe),allTargets:B,defaultTargets:na,onInstall:Ze,onManage:at})},Oe.id||Oe.key))}):R?A=Ve("skills.empty.no_match",e.jsx(G,{type:"button",variant:"secondary",size:"sm",onClick:S,children:r("skills.filter.clear")})):t?A=Ve("skills.empty.search"):n?A=Ve("skills.empty.popular"):A=Ve("skills.empty.browse");const st=d||j?e.jsx("div",{className:"mb-5",children:e.jsx(Er,{repos:h,repoInput:F,onRepoInput:ge,busyKey:z,onAdd:ue,onRemove:me})}):null,nt=!j&&!t&&!n&&h.length<=1&&Me.length>0?e.jsx(tr,{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:()=>ae(!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;qe=e.jsxs(e.Fragment,{children:[st,ra,A,nt]})}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(G,{type:"button",variant:"secondary",size:"sm",onClick:Je,disabled:we||Le||pe,children:[e.jsx(Pt,{className:Z("mr-1.5 h-3.5 w-3.5",(we||Le||pe)&&"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":a===t,onClick:()=>s(t),className:Z("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",a===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))}),ze?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:ze}):null,a==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("div",{role:"tablist","aria-label":r("skills.source.label"),className:"inline-flex h-10 shrink-0 items-center rounded-md border border-oai-gray-200 bg-oai-white p-1 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:[["repo",r("skills.mode.repo"),o!==T&&o!==O],["popular",r("skills.mode.popular"),o===O],["skillssh",r("skills.mode.skillssh"),o===T]].map(([t,n,d])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>{t==="skillssh"?k(T):t==="popular"?k(O):(o===T||o===O)&&k(xe)},className:Z("inline-flex items-center gap-1.5 rounded px-3 py-1 text-sm font-medium transition-colors",d?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-700 dark:text-white":"text-oai-gray-500 hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200"),children:[t==="popular"?e.jsx(Jt,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,n]},t))}),o!==T&&o!==O?e.jsxs(Ra,{value:o,onValueChange:k,children:[e.jsxs(Ia,{"aria-label":r("skills.source.label"),className:"inline-flex h-10 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-3 text-sm 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($a,{children:t=>t===xe?r("skills.source.all"):t}),e.jsx(Va,{className:"text-oai-gray-400",children:e.jsx(ma,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsx(Ea,{children:e.jsx(Ba,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ta,{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(Ge,{value:xe,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(We,{children:r("skills.source.all")}),e.jsx(Qe,{children:e.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),h.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(Ge,{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(We,{children:n}),e.jsx(Qe,{children:e.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(oa,{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(ga,{type:"search",value:N,onChange:t=>w(t.target.value),onKeyDown:t=>{t.key==="Enter"&&o===T&&M()},"aria-label":r("skills.action.search_aria"),placeholder:o===T?r("skills.browse.placeholder_skillssh"):o===O?r("skills.browse.placeholder_popular"):o===xe?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:o}),className:"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"})]}),o===T?e.jsxs(G,{type:"button",onClick:M,disabled:N.trim().length<2||z==="search",className:"focus:!ring-oai-gray-400/30",children:[z==="search"?e.jsx(ee,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(oa,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):o===O?null:e.jsxs(G,{type:"button",variant:"secondary",size:"sm",onClick:()=>ae(t=>!t),"aria-expanded":j,className:"!h-10 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(Ka,{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:h.length})]})]}):null,qe,e.jsx(br,{skill:J,targets:B,busyKey:z,usage:J&&(P[String(J.directory||"").toLowerCase()]||P[String(J.name||"").toLowerCase()])||null,hasUpdate:!!(J?.id&&I?.[J.id]),updating:J?z===He(J):!1,onUpdate:f,onClose:et,onToggleTarget:Y,onRemove:Ee})]})}),e.jsx(va,{open:!!re,title:r("skills.confirm.remove_title",{name:re?.name||re?.directory||""}),description:re?re.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:z===Sa(re||{}),onCancel:()=>X(null),onConfirm:ye}),e.jsx(va,{open:!!ve,title:r("skills.confirm.bulk_remove_title",{count:ve?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:z==="batch",onCancel:()=>L(null),onConfirm:ta})]})}export{Yr as SkillsPage};
|