🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

tokentracker-cli

Package Overview
Dependencies
Maintainers
1
Versions
305
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tokentracker-cli - npm Package Compare versions

Comparing version
0.82.0
to
0.82.1
dashboard/dist/assets/__vite-browser-external-Cd947_ni.css

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

+1
import{k as o,R as N,j as r}from"./__vite-browser-external-CHbEWSwX.js";import{Z as $}from"./zap-DjGiVr-_.js";import{F as A}from"./flame-DCV1yyCQ.js";const j=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],E=o("blocks",j);const L=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],C=o("brain",L);const T=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],z=o("calendar-days",T);const B=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],R=o("crown",B);const q=[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]],H=o("feather",q);const D=[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]],F=o("folder-git-2",D);const I=[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]],G=o("footprints",I);const V=[["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"}]],S=o("heart",V);const Z=[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]],O=o("medal",Z);const P=[["path",{d:"M18 5h4",key:"1lhgn2"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],X=o("moon-star",P);const K=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],U=o("rocket",K);const W=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Y=o("shield-check",W);const J=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Q=o("trending-up",J),f=[{id:"token_titan",scope:"cloud",icon:R,format:"tokens",art:"/achievements/token-titan.png"},{id:"big_day",scope:"cloud",icon:$,format:"tokens",art:"/achievements/big-day.png"},{id:"wordsmith",scope:"cloud",icon:H,format:"tokens",art:"/achievements/wordsmith.png"},{id:"marathoner",scope:"cloud",icon:G,format:"days",art:"/achievements/marathoner.png"},{id:"streak",scope:"cloud",icon:A,format:"days",art:"/achievements/streak.png"},{id:"weekend_warrior",scope:"cloud",icon:z,format:"days",art:"/achievements/weekend-warrior.png"},{id:"momentum",scope:"cloud",icon:Q,format:"multiplier",art:"/achievements/momentum.png"},{id:"polyglot",scope:"cloud",icon:C,format:"count",art:"/achievements/polyglot.png"},{id:"trendsetter",scope:"cloud",icon:U,format:"count",art:"/achievements/trendsetter.png"},{id:"multitool",scope:"cloud",icon:E,format:"count",art:"/achievements/multitool.png"},{id:"podium",scope:"cloud",icon:O,format:"rank",art:"/achievements/podium.png"},{id:"veteran",scope:"cloud",icon:Y,format:"days",art:"/achievements/veteran.png"},{id:"project_hopper",scope:"local",icon:F,format:"count",art:"/achievements/project-hopper.png"},{id:"project_devotion",scope:"local",icon:S,format:"tokens",art:"/achievements/project-devotion.png"},{id:"night_owl",scope:"local",icon:X,format:"count",art:"/achievements/night-owl.png"}],u=new Map(f.map(e=>[e.id,e])),m=new Map(f.map((e,a)=>[e.id,a]));function de(e,a){return`achievements.badge.${e}.${a}`}function ee(e){return[...e||[]].sort((a,t)=>{const c=(t?.tier||0)-(a?.tier||0);return c!==0?c:(m.get(a?.id)??99)-(m.get(t?.id)??99)})}function re(e){const a=(e||[]).filter(t=>t&&(t.tier||0)>=1&&u.has(t.id));return a.length===0?null:ee(a)[0]}const v={1:"bronze",2:"silver",3:"gold",4:"diamond"},ie=["bronze","silver","gold","diamond"],ae={bronze:{rim:["#a06a44","#5c3a22"],face:["#d29a6c","#96602f"],glyph:"#3f2817",ring:"#e8c3a0",sheen:"rgba(255, 236, 220, 0.45)",label:"#a06a44"},silver:{rim:["#aab3bb","#67707b"],face:["#dde2e7","#9ba5ae"],glyph:"#39424b",ring:"#f2f5f7",sheen:"rgba(255, 255, 255, 0.55)",label:"#8b959f"},gold:{rim:["#c9971c","#8a6508"],face:["#f2ca52","#cf9c26"],glyph:"#5c430e",ring:"#ffe9a8",sheen:"rgba(255, 248, 214, 0.55)",label:"#b8860b"},diamond:{rim:["#62b1e0","#7c6fd9"],face:["#c8ecf6","#84b4ea"],glyph:"#27496d",ring:"#eafcff",sheen:"rgba(255, 255, 255, 0.65)",label:"#5a9bd8"}},y={rim:["#a8ada9","#7c817d"],face:["#cdd2ce","#a3a8a4"],glyph:"#6a706c",ring:"#dde1de",sheen:"rgba(255, 255, 255, 0.25)",label:"#8b908c"};function te(e,a=!1){return a||!e||e<1?y:ae[v[Math.min(e,4)]]||y}function se(e){return v[e]||null}const g={xs:18,sm:24,md:44,xl:88,lg:108},k={xs:.75,sm:1,md:1.5,xl:2,lg:2};function le({badgeId:e,tier:a=0,size:t="md",locked:c=!1,label:i,className:M=""}){const s=u.get(e),h=c||!a||a<1,n=te(a,h),d=t==="fill",l=d?"100%":g[t]||g.md,b=d?4:k[t]||k.md,[_,x]=N.useState(!1),p=s?.icon||null,w=!!s?.art&&!_;return r.jsx("span",{role:i?"img":void 0,"aria-label":i||void 0,"aria-hidden":i?void 0:!0,className:`inline-flex shrink-0 rounded-full ${M}`,style:{width:l,height:l,padding:b,background:`linear-gradient(135deg, ${n.rim[0]} 0%, ${n.ring} 42%, ${n.rim[1]} 100%)`,boxShadow:d||t==="md"||t==="xl"||t==="lg"?"0 0 0 1px rgba(10, 15, 12, 0.06), 0 1px 2px rgba(10, 15, 12, 0.08)":void 0},children:w?r.jsx("img",{src:s.art,alt:"",draggable:!1,loading:"lazy",onError:()=>x(!0),className:"h-full w-full rounded-full object-cover",style:h?{filter:"grayscale(1)",opacity:.55}:void 0}):r.jsx("span",{className:"flex h-full w-full items-center justify-center rounded-full",style:{background:`linear-gradient(145deg, ${n.face[0]}, ${n.face[1]})`},children:p?r.jsx(p,{size:d?64:Math.round(l*.5),color:n.glyph,strokeWidth:2}):null})})}export{le as A,f as B,S as H,Q as T,ae as a,de as b,u as c,ie as d,re as h,te as p,ee as s,se as t};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BadgeDetailModal-rPrkKVBY.js","assets/__vite-browser-external-CHbEWSwX.js","assets/__vite-browser-external-Cd947_ni.css","assets/AchievementBadge-CkmyCQlm.js","assets/zap-DjGiVr-_.js","assets/flame-DCV1yyCQ.js","assets/use-transform-DgEhM1tE.js","assets/AchievementsSection-CLA812Vd.js","assets/format-tokens-BN3gD2gw.js","assets/DialogTitle-qsUpNlJa.js","assets/useScrollLock-DdUQVKDA.js"])))=>i.map(i=>d[i]);
import{r as l,z as x,A as f,E as v,j as e,c,L as p,R as g,e as y,F as b,G as k,_ as j}from"./__vite-browser-external-CHbEWSwX.js";import{A as w}from"./AchievementsSection-CLA812Vd.js";import{B as h}from"./AchievementBadge-CkmyCQlm.js";import"./format-tokens-BN3gD2gw.js";import"./zap-DjGiVr-_.js";import"./flame-DCV1yyCQ.js";function N({enabled:a=!0}={}){const[n,t]=l.useState({status:"loading",achievements:[],error:null}),s=l.useMemo(()=>x(),[]);return l.useEffect(()=>{if(!a){t({status:"disabled",achievements:[],error:null});return}let i=!1;return t(r=>({...r,status:"loading"})),f({timeZone:s,tzOffsetMinutes:v()}).then(r=>{i||t({status:"ready",achievements:Array.isArray(r?.achievements)?r.achievements:[],error:null})}).catch(r=>{i||t({status:"error",achievements:[],error:r})}),()=>{i=!0}},[a,s]),n}const A=g.lazy(()=>j(()=>import("./BadgeDetailModal-rPrkKVBY.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])));function I({authLoading:a,authEnabled:n,authUserId:t,mockEnabled:s}){if(s)return{authLoading:!1,signedIn:!0,userId:"mock-user"};const i=!!(n&&t);return{authLoading:!!a,signedIn:i,userId:i?t:null}}function B(){const a=y(),[n,t]=l.useState({status:"loading",achievements:[],userId:null}),s=b(),{authLoading:i,signedIn:r,userId:o}=I({authLoading:a?.loading,authEnabled:a?.enabled,authUserId:a?.user?.id,mockEnabled:s});return l.useEffect(()=>{if(i){t({status:"loading",achievements:[],userId:null});return}if(!r){t({status:"signed-out",achievements:[],userId:null});return}let d=!1;return t({status:"loading",achievements:[],userId:o}),(async()=>{try{const u=s?null:await a.getAccessToken?.(),m=await k({accessToken:u,userId:o});if(d)return;t({status:"ready",achievements:Array.isArray(m?.badges)?m.badges:[],userId:o})}catch{d||t({status:"error",achievements:[],userId:o})}})(),()=>{d=!0}},[i,s,r,o]),{...n,signedIn:r,settled:_({authLoading:i,signedIn:r,userId:o,state:n})}}function _({authLoading:a,signedIn:n,userId:t,state:s}){return a?!1:n?s.userId===t&&(s.status==="ready"||s.status==="error"):s.status==="signed-out"}function E(){return e.jsx("div",{className:"mx-0 grid animate-pulse grid-cols-[repeat(3,max-content)] justify-between gap-y-7 sm:-mx-2 sm:grid-cols-[repeat(4,max-content)] lg:grid-cols-[repeat(5,max-content)]","aria-hidden":!0,children:Array.from({length:h.length}).map((a,n)=>e.jsxs("div",{className:"flex w-[6.75rem] flex-col items-center px-0 pb-3 pt-4 sm:w-[7.75rem]",children:[e.jsx("div",{className:"h-[108px] w-[108px] rounded-full bg-oai-gray-200 dark:bg-oai-gray-800"}),e.jsx("div",{className:"mt-3 h-3 w-16 rounded bg-oai-gray-200 dark:bg-oai-gray-800"}),e.jsx("div",{className:"mt-2 h-2 w-10 rounded bg-oai-gray-100 dark:bg-oai-gray-800/60"})]},n))})}function z(){const a=N(),n=B(),[t,s]=l.useState(null),i=a.status==="loading"||!n.settled,r=l.useMemo(()=>[...n.achievements||[],...a.achievements||[]],[n.achievements,a.achievements]),o=l.useMemo(()=>r.filter(u=>(u?.tier||0)>=1).length,[r]),d=h.length;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-4xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-7 flex items-baseline justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:c("achievements.page.title")}),e.jsx("p",{className:"mt-1.5 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:c("achievements.page.local_note")})]}),!i&&e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsxs("div",{className:"font-mono text-2xl font-semibold leading-none tabular-nums text-oai-black dark:text-white",children:[o,e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-600",children:["/",d]})]}),e.jsx("div",{className:"mt-2 h-1 w-24 overflow-hidden rounded-full bg-oai-gray-200 dark:bg-oai-gray-800",children:e.jsx("div",{className:"h-full rounded-full bg-oai-brand-600 transition-[width] duration-500",style:{width:`${Math.round(o/d*100)}%`}})})]})]}),!n.signedIn&&!i&&e.jsxs("div",{className:"mb-6 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 rounded-xl border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 dark:border-oai-gray-800 dark:bg-oai-gray-900/60",children:[e.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:c("achievements.signin.prompt")}),e.jsx(p,{to:"/login",className:"shrink-0 rounded-lg bg-oai-brand-600 px-3 py-1.5 text-sm font-medium text-white transition-colors duration-200 hover:bg-oai-brand-700 active:scale-[0.98]",children:c("achievements.signin.action")})]}),i?e.jsx(E,{}):e.jsxs(e.Fragment,{children:[e.jsx(w,{achievements:r,isOwn:!0,columns:"wide",size:"lg",animateIn:!0,onSelect:s}),e.jsxs("p",{className:"mt-10 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:[c("achievements.page.suggest")," ",e.jsx("a",{href:"https://github.com/mm7894215/TokenTracker/issues",target:"_blank",rel:"noopener noreferrer",className:"underline decoration-oai-gray-300 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:decoration-oai-gray-500 dark:decoration-oai-gray-600 dark:hover:text-oai-gray-300",children:c("achievements.page.suggest_link")})]})]})]})}),t&&e.jsx(g.Suspense,{fallback:null,children:e.jsx(A,{badge:t,onClose:()=>s(null)})})]})}export{_ as cloudBadgesSettled,z as default,I as resolveCloudBadgeIdentity};
import{k as _,w as $,j as s,c as l,x as C}from"./__vite-browser-external-CHbEWSwX.js";import{B as x,s as b,b as T,t as B,A as E,a as L}from"./AchievementBadge-CkmyCQlm.js";import{f as I}from"./format-tokens-BN3gD2gw.js";const D=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],F=_("hard-drive",D);function G(r,i){const t=Number(i)||0;switch(r){case"tokens":return I(t);case"rank":return`#${Math.round(t)}`;case"multiplier":return`${(Math.round(t*10)/10).toString()}×`;default:return Math.round(t).toLocaleString()}}function H(r){if(!r)return 0;const i=Number(r.next_threshold),t=Number(r.metric_value??r.value);if(!Number.isFinite(i)||i<=0)return r.tier>=4?1:0;if(!Number.isFinite(t)||t<=0)return 0;const n=r.lower_is_better?i/t:t/i;return Math.max(0,Math.min(1,n))}function S(r){const i=r?.achieved||{},t=Object.values(i).map(n=>n?Date.parse(n):NaN).filter(n=>Number.isFinite(n));return t.length>0?Math.max(...t):null}function V({achievements:r,isOwn:i=!1,scope:t,onSelect:n,size:m="xl",columns:v="default",animateIn:y=!1,className:k=""}){const N=$(),u=y&&!N,p=new Map;for(const e of Array.isArray(r)?r:[])e&&e.id&&p.set(e.id,e);const g=t?x.filter(e=>e.scope===t):x;let c;if(i){const e=g.map(a=>({entry:a,record:p.get(a.id)||{id:a.id,tier:0}})),o=b(e.filter(a=>(a.record.tier||0)>=1).map(a=>({...a,id:a.entry.id,tier:a.record.tier}))),h=e.filter(a=>(a.record.tier||0)<1);c=[...o,...h]}else c=b(g.map(e=>({entry:e,record:p.get(e.id)})).filter(e=>e.record&&(e.record.tier||0)>=1).map(e=>({...e,id:e.entry.id,tier:e.record.tier}))).map(({entry:e,record:o})=>({entry:e,record:o}));if(c.length===0)return null;const j=v==="wide"?"grid-cols-[repeat(3,max-content)] sm:grid-cols-[repeat(4,max-content)] lg:grid-cols-[repeat(5,max-content)]":"grid-cols-[repeat(3,max-content)] sm:grid-cols-[repeat(4,max-content)]",w=m==="lg"?"mx-0 sm:-mx-2":"-mx-2 sm:-mx-4",M=m==="lg"?"px-0":"px-1";return s.jsx("div",{className:`${w} grid justify-between gap-y-7 ${j} ${k}`,children:c.map(({entry:e,record:o},h)=>{const a=(o.tier||0)>=1,f=l(T(e.id,"name")),d=a?B(o.tier):null,A=H(o);return s.jsxs(C.button,{type:"button",initial:u?{opacity:0,y:16,scale:.9}:!1,animate:u?{opacity:1,y:0,scale:1}:void 0,whileTap:u?{scale:.97}:void 0,transition:{delay:.05+h*.035,duration:.45,ease:[.16,1,.3,1]},onClick:n?()=>n({...o,id:e.id}):void 0,className:`group flex w-[6.75rem] flex-col items-center rounded-xl ${M} pb-3 pt-4 text-center transition-[background-color,transform] duration-200 ease-out hover:bg-oai-gray-50 active:scale-[0.97] dark:hover:bg-oai-gray-900/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60 sm:w-[7.75rem]`,"aria-label":l("achievements.badge.aria",{name:f,tier:d?l(`achievements.tier.${d}`):l("achievements.modal.locked")}),children:[s.jsx(E,{badgeId:e.id,tier:o.tier,locked:!a,size:m,className:"transition-transform duration-200 ease-out group-hover:-translate-y-0.5 group-hover:scale-105"}),s.jsxs("span",{className:"mt-2.5 flex w-full items-center justify-center gap-1",children:[s.jsx("span",{title:f,className:"min-w-0 truncate text-xs font-medium leading-tight text-oai-gray-800 dark:text-oai-gray-200",children:f}),e.scope==="local"&&s.jsx("span",{title:l("achievements.page.local_note"),"aria-label":l("achievements.scope.local"),className:"inline-flex shrink-0 text-oai-gray-400 dark:text-oai-gray-500",children:s.jsx(F,{size:11,strokeWidth:2,"aria-hidden":!0})})]}),s.jsx("span",{className:"mt-1 flex h-4 w-full items-center justify-center",children:a?s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.08em]",style:{color:L[d]?.label},children:l(`achievements.tier.${d}`)}):i?s.jsx("span",{className:"h-[3px] w-14 overflow-hidden rounded-full bg-oai-gray-200 dark:bg-oai-gray-800",children:s.jsx("span",{className:"block h-full rounded-full bg-oai-brand/70",style:{width:`${Math.round(A*100)}%`}})}):null})]},e.id)})})}export{V as A,H as b,G as f,S as l};
import{r as s,j as t,R as g,x as v,H as f,P as x}from"./__vite-browser-external-CHbEWSwX.js";function C(a){const e=[...a];for(let o=e.length-1;o>0;o--){const i=Math.floor(Math.random()*(o+1));[e[o],e[i]]=[e[i],e[o]]}return e}function j(a,e){const o=C(a),i=Array.from({length:e},()=>[]);o.forEach((r,m)=>{i[m%e].push(r)});const c=Math.max(...i.map(r=>r.length));return i.forEach(r=>{for(;r.length<c;)r.push(o[Math.floor(Math.random()*o.length)])}),i}const w=g.memo(function({logos:e,index:o,currentTime:i,onHoverChange:c}){const[r,m]=s.useState(!1),l=4e3,p=o*400,n=(i+p)%(l*e.length),d=Math.floor(n/l),u=e[d],h=y=>{m(y),c(y)};return t.jsxs("div",{className:"relative flex flex-col items-center",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:[t.jsx(v.div,{className:"relative h-8 w-8 sm:h-10 sm:w-10 md:h-12 md:w-12 overflow-hidden",initial:{opacity:0,y:50},animate:{opacity:1,y:0},transition:{delay:o*.1,duration:.5,ease:"easeOut"},children:t.jsx(f,{mode:"wait",children:t.jsx(v.div,{className:"absolute inset-0 flex items-center justify-center",initial:{y:"18%",opacity:0,filter:"blur(4px)"},animate:{y:"0%",opacity:1,filter:"blur(0px)",transition:{type:"tween",ease:[.22,1,.36,1],duration:.9}},exit:{y:"-18%",opacity:0,filter:"blur(4px)",transition:{type:"tween",ease:[.4,0,1,1],duration:.55}},children:t.jsx(x,{provider:u.provider,size:24,className:"object-contain"})},`${u.id}-${d}`)})}),t.jsx(f,{children:r&&t.jsx(v.span,{className:"pointer-events-none absolute -bottom-7 z-10 whitespace-nowrap rounded bg-oai-gray-800 px-2 py-0.5 text-xs font-medium text-oai-gray-100 shadow-lg ring-1 ring-oai-gray-700",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:u.name})})]})});function L({logos:a,columnCount:e=2}){const[o,i]=s.useState([]),[c,r]=s.useState(0),[m,l]=s.useState(!1);s.useEffect(()=>{i(j(a,e))},[a,e]),s.useEffect(()=>{if(m)return;const n=setInterval(()=>r(d=>d+100),100);return()=>clearInterval(n)},[m]);const p=s.useCallback(n=>{l(n)},[]);return t.jsx("div",{className:"flex gap-2.5 sm:gap-4 text-oai-gray-200",children:o.map((n,d)=>t.jsx(w,{logos:n,index:d,currentTime:c,onHoverChange:p},d))})}const M=[{id:1,name:"Claude Code",provider:"claude"},{id:2,name:"Codex",provider:"codex"},{id:3,name:"Cursor",provider:"cursor"},{id:4,name:"Gemini",provider:"gemini"},{id:5,name:"Antigravity",provider:"antigravity"},{id:6,name:"Kiro",provider:"kiro"},{id:7,name:"OpenCode",provider:"opencode"},{id:8,name:"OpenClaw",provider:"openclaw"},{id:9,name:"Every Code",provider:"every-code"},{id:10,name:"Hermes",provider:"hermes"},{id:11,name:"GitHub Copilot",provider:"copilot"},{id:12,name:"Kimi",provider:"kimi"},{id:13,name:"CodeBuddy",provider:"codebuddy"},{id:14,name:"WorkBuddy",provider:"workbuddy"},{id:15,name:"Grok",provider:"grok"},{id:16,name:"oh-my-pi",provider:"omp"},{id:17,name:"Pi",provider:"pi"},{id:18,name:"Craft",provider:"craft"},{id:19,name:"Kilo CLI",provider:"kilo-cli"},{id:20,name:"Kilo Code",provider:"kilocode"},{id:21,name:"Roo Code",provider:"roocode"},{id:22,name:"Zed",provider:"zed"},{id:23,name:"Goose",provider:"goose"},{id:24,name:"Droid",provider:"droid"},{id:25,name:"Mimo",provider:"mimo"},{id:26,name:"ZCode",provider:"zcode"},{id:27,name:"AnythingLLM",provider:"anythingllm"}];export{M as A,L};
import{k as o}from"./__vite-browser-external-CHbEWSwX.js";const t=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],a=o("arrow-up-right",t);export{a as A};
import{bS as De,bT as _e,bU as Ie,bV as Me,bW as Te,bX as be,bY as ye,bZ as Ve,b_ as $e,b$ as Oe,c0 as Re,c1 as Be,c2 as Pe,c3 as Ke,c4 as Xe,c5 as Le,c6 as Ce,c7 as Fe,c8 as G,c9 as Ge,ca as We,a0 as ze,cb as Ue,w as Ye,r as C,j as a,x as X,cc as Ze,c as h,b as ve,X as He}from"./__vite-browser-external-CHbEWSwX.js";import{c as je,A as qe,p as Je,b as U,t as le,a as V,d as Qe}from"./AchievementBadge-CkmyCQlm.js";import{u as et,a as z}from"./use-transform-DgEhM1tE.js";import{l as ce,f as ue,b as tt}from"./AchievementsSection-CLA812Vd.js";import{D as nt,a as rt,b as at,c as st,d as it,e as ot}from"./DialogTitle-qsUpNlJa.js";import"./zap-DjGiVr-_.js";import"./flame-DCV1yyCQ.js";import"./format-tokens-BN3gD2gw.js";import"./useScrollLock-DdUQVKDA.js";const lt=(e,t,n)=>{const r=t-e;return((n-e)%r+r)%r+e};function Ne(e,t){return De(e)?e[lt(0,e.length,t)]:e}class ct{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>t.finished))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let r=0;r<this.animations.length;r++)this.animations[r][t]=n}attachTimeline(t){const n=this.animations.map(r=>r.attachTimeline(t));return()=>{n.forEach((r,s)=>{r&&r(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return de(this.animations,"duration")}get iterationDuration(){return de(this.animations,"iterationDuration")}runAll(t){this.animations.forEach(n=>n[t]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function de(e,t){let n=0;for(let r=0;r<e.length;r++){const s=e[r][t];s!==null&&s>n&&(n=s)}return n}class ut extends ct{then(t,n){return this.finished.finally(t).then(()=>{})}}function dt(e,t){return e in t}class ft extends _e{constructor(){super(...arguments),this.type="object"}readValueFromInstance(t,n){if(dt(n,t)){const r=t[n];if(typeof r=="string"||typeof r=="number")return r}}getBaseTargetFromProps(){}removeValueFromRenderState(t,n){delete n.output[t]}measureInstanceViewportBox(){return Ie()}build(t,n){Object.assign(t.output,n)}renderInstance(t,{output:n}){Object.assign(t,n)}sortInstanceNodePosition(){return 0}}function Y(e){return typeof e=="object"&&!Array.isArray(e)}function ke(e,t,n,r){return e==null?[]:typeof e=="string"&&Y(t)?Me(e,n,r):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(s=>s!=null):[e]}function mt(e,t,n){return e*(t+1)+n*t}function fe(e,t,n,r){return typeof t=="number"?t:t.startsWith("-")||t.startsWith("+")?Math.max(0,e+parseFloat(t)):t==="<"?n:t.startsWith("<")?Math.max(0,n+parseFloat(t.slice(1))):r.get(t)??e}function pt(e,t,n){for(let r=0;r<e.length;r++){const s=e[r];s.at>t&&s.at<n&&(be(e,s),r--)}}function ht(e,t,n,r,s,c){pt(e,s,c);for(let i=0;i<t.length;i++)e.push({value:t[i],at:Te(s,c,r[i]),easing:Ne(n,i)})}function gt(e,t,n=0){const r=t+1+t*n;for(let s=0;s<e.length;s++)e[s]=e[s]/r}function xt(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}const bt="easeInOut",yt=20;function vt(e,{defaultTransition:t={},...n}={},r,s){const c=t.duration||.3,i=new Map,m=new Map,f={},p=new Map;let g=0,u=0,x=0;for(let N=0;N<e.length;N++){const k=e[N];if(typeof k=="string"){p.set(k,u);continue}else if(!Array.isArray(k)){p.set(k.name,fe(u,k.at,g,p));continue}let[E,y,v={}]=k;v.at!==void 0&&(u=fe(u,v.at,g,p));let j=0;const I=(w,M,A,o=0,l=0)=>{const d=jt(w),{delay:D=0,times:b=Ve(d),type:R=t.type||"keyframes",repeat:B,repeatType:W,repeatDelay:Z=0,...Se}=M;let{ease:_=t.ease||"easeOut",duration:S}=M;const H=typeof D=="function"?D(o,l):D,q=d.length,J=Be(R)?R:s?.[R||"keyframes"];if(q<=2&&J){let $=100;if(q===2&&wt(d)){const P=d[1]-d[0];$=Math.abs(P)}const O={...t,...Se};S!==void 0&&(O.duration=Pe(S));const F=$e(O,$,J);_=F.ease,S=F.duration}S??(S=c);const Q=u+H;b.length===1&&b[0]===0&&(b[1]=1);const ee=b.length-d.length;if(ee>0&&Oe(b,ee),d.length===1&&d.unshift(null),B&&B<yt){const $=S>0?Z/S:0;S=mt(S,B,Z);const O=[...d],F=[...b];_=Array.isArray(_)?[..._]:[_];const P=[..._],ne=W==="reverse"||W==="mirror";let re=O,ae=P;ne&&(re=[...O].reverse(),W==="reverse"&&(ae=[...P].reverse().map(T=>typeof T=="function"?Re(T):T)));for(let T=0;T<B;T++){const se=ne&&T%2===0,ie=se?re:O,Ee=se?ae:P,oe=(T+1)*(1+$);$>0&&(d.push(d[d.length-1]),b.push(oe),_.push("linear")),d.push(...ie);for(let K=0;K<ie.length;K++)b.push(F[K]+oe),_.push(K===0?"linear":Ne(Ee,K-1))}gt(b,B,$)}const te=Q+S;ht(A,d,_,b,Q,te),j=Math.max(H+S,j),x=Math.max(te,x)};if(ye(E)){const w=me(E,m);I(y,v,pe("default",w))}else{const w=ke(E,y,r,f),M=w.length;for(let A=0;A<M;A++){y=y,v=v;const o=w[A],l=me(o,m);for(const d in y)I(y[d],Nt(v,d),pe(d,l),A,M)}}g=u,u+=j}return m.forEach((N,k)=>{for(const E in N){const y=N[E];y.sort(xt);const v=[],j=[],I=[];for(let o=0;o<y.length;o++){const{at:l,value:d,easing:D}=y[o];v.push(d),j.push(Ke(0,x,l)),I.push(D||"easeOut")}j[0]!==0&&(j.unshift(0),v.unshift(v[0]),I.unshift(bt)),j[j.length-1]!==1&&(j.push(1),v.push(null)),i.has(k)||i.set(k,{keyframes:{},transition:{}});const w=i.get(k);w.keyframes[E]=v;const{type:M,...A}=t;w.transition[E]={...A,duration:x,ease:I,times:j,...n}}}),i}function me(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function pe(e,t){return t[e]||(t[e]=[]),t[e]}function jt(e){return Array.isArray(e)?e:[e]}function Nt(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}const kt=e=>typeof e=="number",wt=e=>e.every(kt);function At(e){const t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=Xe(e)&&!Le(e)?new Ce(t):new Fe(t);n.mount(e),G.set(e,n)}function St(e){const t={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},n=new ft(t);n.mount(e),G.set(e,n)}function Et(e,t){return ye(e)||typeof e=="number"||typeof e=="string"&&!Y(t)}function we(e,t,n,r){const s=[];if(Et(e,t))s.push(Ge(e,Y(t)&&t.default||t,n&&(n.default||n)));else{if(e==null)return s;const c=ke(e,t,r),i=c.length;for(let m=0;m<i;m++){const f=c[m],p=f instanceof Element?At:St;G.has(f)||p(f);const g=G.get(f),u={...n};"delay"in u&&typeof u.delay=="function"&&(u.delay=u.delay(m,i)),s.push(...We(g,{...t,transition:u},{}))}}return s}function Dt(e,t,n){const r=[],s=e.map(i=>{if(Array.isArray(i)&&typeof i[0]=="function"){const m=i[0],f=ze(0);return f.on("change",m),i.length===1?[f,[0,1]]:i.length===2?[f,[0,1],i[1]]:[f,i[1],i[2]]}return i});return vt(s,t,n,{spring:Ue}).forEach(({keyframes:i,transition:m},f)=>{r.push(...we(f,i,m))}),r}function _t(e){return Array.isArray(e)&&e.some(Array.isArray)}function It(e={}){const{scope:t,reduceMotion:n,skipAnimations:r}=e;function s(c,i,m){let f=[],p;const g={};if(n!==void 0&&(g.reduceMotion=n),r!==void 0&&(g.skipAnimations=r),_t(c)){const{onComplete:x,...N}=i||{};typeof x=="function"&&(p=x),f=Dt(c,{...g,...N},t)}else{const{onComplete:x,...N}=m||{};typeof x=="function"&&(p=x),f=we(c,i,{...g,...N},t)}const u=new ut(f);return p&&u.finished.then(p),t&&(t.animations.push(u),u.finished.then(()=>{be(t.animations,u)})),u}return s}const L=It(),he=8;function Mt({badgeId:e,tier:t,locked:n=!1,size:r=176,backLines:s=[],label:c}){const i=et(0),m=Ye(),f=C.useRef(null),p=C.useRef(null),g=C.useRef(!1),u=Je(t,n),x=je.get(e)?.icon||null,N=z(i,o=>`${(o%360+360)%360/360*160-80}%`),k=z(i,o=>`${80-(o%360+360)%360/360*160}%`),E=z(i,o=>{const l=Math.abs(Math.sin(o*Math.PI/180));return Math.max(0,(l-.35)/.65)*.3}),y=()=>{p.current?.stop?.(),p.current=null};C.useEffect(()=>{if(m||g.current)return;let o=!1;i.set(-360);const l=L(i,0,{duration:.9,ease:[.16,1,.3,1]});return p.current=l,l.then(()=>{o||g.current||(p.current=L(i,[0,-14,14,0],{duration:4.5,repeat:1/0,ease:"easeInOut"}))}),()=>{o=!0,y()}},[m,i]);const v=o=>{const l=i.get();if(m){const b=Math.round(l/180)*180;p.current=L(i,b,{duration:.2,ease:"easeOut"});return}const d=l+o*.35,D=Math.round(d/180)*180;p.current=L(i,D,{type:"spring",velocity:o,stiffness:58,damping:13.5,mass:1})},j=o=>{g.current=!0,y(),o.currentTarget.setPointerCapture?.(o.pointerId),f.current={pointerId:o.pointerId,startX:o.clientX,startRot:i.get(),samples:[{t:o.timeStamp,x:o.clientX}]}},I=o=>{const l=f.current;!l||l.pointerId!==o.pointerId||(i.set(l.startRot+(o.clientX-l.startX)*.55),l.samples.push({t:o.timeStamp,x:o.clientX}),l.samples.length>5&&l.samples.shift())},w=o=>{const l=f.current;if(!l||l.pointerId!==o.pointerId)return;f.current=null;const d=l.samples[0],D=l.samples[l.samples.length-1],b=D.t-d.t,R=b>0?(D.x-d.x)*.55*1e3/b:0;v(R)},M=o=>{if(o.key!=="ArrowLeft"&&o.key!=="ArrowRight")return;o.preventDefault(),g.current=!0,y();const l=o.key==="ArrowRight"?30:-30;p.current=L(i,i.get()+l,{duration:.15,ease:"easeOut"})},A={backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"};return a.jsx("div",{role:"img","aria-label":c,tabIndex:0,onPointerDown:j,onPointerMove:I,onPointerUp:w,onPointerCancel:w,onKeyDown:M,className:"inline-flex cursor-grab select-none items-center justify-center outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60 rounded-full active:cursor-grabbing",style:{perspective:900,touchAction:"pan-y"},children:a.jsxs("div",{className:"relative",style:{transform:"rotateX(-8deg)",transformStyle:"preserve-3d"},children:[a.jsxs(X.div,{className:"relative",style:{rotateY:i,transformStyle:"preserve-3d",width:r,height:r},children:[[-3,-1.5,0,1.5,3].map(o=>a.jsx("div",{"aria-hidden":!0,className:"absolute inset-0 rounded-full",style:{transform:`translateZ(${o}px)`,background:u.rim[1]}},o)),a.jsxs("div",{className:"absolute inset-0 overflow-hidden rounded-full",style:{...A,transform:`translateZ(${he/2}px)`},children:[a.jsx(qe,{badgeId:e,tier:t,locked:n,size:"fill",className:"brightness-105 saturate-[1.08]"}),a.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{background:"radial-gradient(circle at 30% 20%, rgba(255,255,255,0.45), rgba(255,255,255,0) 42%), linear-gradient(172deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0) 38%, rgba(0,0,0,0.08) 100%)",boxShadow:"inset 0 3px 7px rgba(255,255,255,0.5), inset 0 -3px 8px rgba(0,0,0,0.15)"}}),a.jsx(X.div,{"aria-hidden":!0,className:"pointer-events-none absolute inset-0",style:{x:N,background:"linear-gradient(105deg, transparent 34%, rgba(255,255,255,0.5) 50%, transparent 66%)"}}),a.jsx(X.div,{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{opacity:E,background:"rgba(8, 12, 10, 0.9)"}})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-1 overflow-hidden rounded-full px-6 text-center",style:{...A,transform:`rotateY(180deg) translateZ(${he/2}px)`,background:`linear-gradient(145deg, ${u.face[0]}, ${u.face[1]})`,boxShadow:`inset 0 0 0 6px ${u.rim[1]}, inset 0 0 0 7.5px rgba(255,255,255,0.22), inset 0 3px 7px rgba(255,255,255,0.4), inset 0 -4px 12px rgba(0,0,0,0.22)`},children:[a.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{background:"repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06) 0px, rgba(255,255,255,0.06) 1px, transparent 1px, transparent 4px)"}}),x?a.jsx(x,{"aria-hidden":!0,size:Math.round(r*.62),strokeWidth:1.1,color:u.glyph,className:"pointer-events-none absolute opacity-[0.13]",style:{filter:"drop-shadow(0 1px 0 rgba(255,255,255,0.3)) drop-shadow(0 -1px 0 rgba(0,0,0,0.35))"}}):null,a.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{background:"radial-gradient(circle at 70% 20%, rgba(255,255,255,0.4), rgba(255,255,255,0) 44%), linear-gradient(188deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 38%, rgba(0,0,0,0.10) 100%)"}}),s.map((o,l)=>a.jsx("div",{className:`font-mono tabular-nums ${l===0?"text-[10px] uppercase tracking-[0.18em]":l===1?"text-lg font-bold":"text-[11px]"}`,style:{color:u.glyph,textShadow:"0 1px 0 rgba(255,255,255,0.28), 0 -1px 0 rgba(0,0,0,0.3)"},children:o},`${l}-${o}`)),a.jsx(X.div,{"aria-hidden":!0,className:"pointer-events-none absolute inset-0",style:{x:k,background:"linear-gradient(105deg, transparent 34%, rgba(255,255,255,0.45) 50%, transparent 66%)"}}),a.jsx(X.div,{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{opacity:E,background:"rgba(8, 12, 10, 0.9)"}})]})]}),a.jsx("div",{"aria-hidden":!0,className:"absolute left-1/2 h-3 w-3/5 rounded-[100%] bg-black/20 blur-md dark:bg-black/45",style:{bottom:-20,transform:"translateX(-50%)"}})]})})}function Ae(e){if(!e)return null;const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleDateString():null}function Tt(e){const t=Number(e);return!Number.isSafeInteger(t)||t<1?null:String(t).padStart(6,"0")}function Vt(e,t,n){if(t?.scope!=="cloud"||!n)return null;const r=Number(e?.serials?.[n]);return Number.isSafeInteger(r)&&r>=1?r:null}function $t({badge:e}){return a.jsx("div",{className:"flex items-center gap-1",children:Qe.map((t,n)=>{const r=(e.tier||0)>=n+1,s=Ae(e.achieved?.[t]),c=V[t];return a.jsx("span",{title:s?`${h(`achievements.tier.${t}`)} · ${s}`:h(`achievements.tier.${t}`),className:"inline-flex h-2 w-8 rounded-full",style:r?{background:`linear-gradient(120deg, ${c.rim[0]} 0%, ${c.ring} 55%, ${c.rim[1]} 100%)`,boxShadow:"inset 0 1px 1px rgba(255,255,255,0.4), 0 0 0 1px rgba(10,15,12,0.05)"}:void 0,children:!r&&a.jsx("span",{className:"h-full w-full rounded-full bg-oai-gray-200 dark:bg-oai-gray-800"})},t)})})}function ge({badge:e,onClose:t}){const n=je.get(e.id),r=h(U(e.id,"name")),s=(e.tier||0)>=1,c=s?le(e.tier):null,i=Ae(s?e.achieved?.[c]||(ce(e)?new Date(ce(e)).toISOString():null):null),m=ue(n?.format,e.metric_value),f=tt(e),p=e.tier<4?le((e.tier||0)+1):null,g=Vt(e,n,c),u=Tt(g),x=u?[h("achievements.modal.achieved_label"),h("achievements.modal.issue_number",{number:u}),i||r]:[s?h("achievements.modal.achieved_label"):h("achievements.modal.locked"),s?m:"···",s&&i?i:r];return a.jsxs("div",{className:"flex flex-col items-center px-6 pb-6 pt-5 text-center",children:[a.jsxs("div",{className:"flex w-full items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[a.jsx("h2",{className:"truncate text-lg font-semibold tracking-tight text-oai-black dark:text-white",children:r}),a.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:h(U(e.id,"desc"))})]}),a.jsx("button",{type:"button",onClick:t,"aria-label":h("achievements.modal.close"),className:"shrink-0 rounded-md p-1.5 text-oai-gray-400 transition-colors hover:bg-oai-gray-100 hover:text-oai-gray-700 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200",children:a.jsx(He,{size:16})})]}),a.jsx("div",{className:"mt-5 mb-7",children:a.jsx(Mt,{badgeId:e.id,tier:e.tier,locked:!s,backLines:x,label:h("achievements.modal.coin_aria",{name:r})})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"rounded-full px-2.5 py-0.5 text-[11px] font-semibold uppercase tracking-wide",style:s?{background:`linear-gradient(120deg, ${V[c].rim[0]} 0%, ${V[c].ring} 55%, ${V[c].rim[1]} 100%)`,color:V[c].glyph,textShadow:"0 1px 0 rgba(255,255,255,0.35)",boxShadow:"inset 0 1px 1px rgba(255,255,255,0.4), 0 0 0 1px rgba(10,15,12,0.06)"}:{background:"rgba(128,134,130,0.75)",color:"rgba(250,250,250,0.95)"},children:s?h(`achievements.tier.${c}`):h("achievements.modal.locked")}),s&&i?a.jsx("span",{className:"text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:i}):null]}),a.jsxs("dl",{className:"mt-5 w-full space-y-3 border-t border-oai-gray-200/70 pt-4 text-left dark:border-oai-gray-800/60",children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-3 text-sm",children:[a.jsx("dt",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:h("achievements.modal.value_label")}),a.jsx("dd",{className:"font-mono font-semibold tabular-nums text-oai-black dark:text-white",children:m})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[a.jsx("span",{children:e.tier>=4?h("achievements.modal.max_tier"):h("achievements.modal.progress_to_next",{tier:h(`achievements.tier.${p}`)})}),e.tier<4&&e.next_threshold!=null?a.jsxs("span",{className:"font-mono tabular-nums",children:[m," ",e.lower_is_better?"→":"/"," ",ue(n?.format,e.next_threshold)]}):null]}),a.jsx("div",{className:"mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-oai-gray-200 dark:bg-oai-gray-800",children:a.jsx("div",{className:"h-full rounded-full transition-[width] duration-500",style:{width:`${Math.round((e.tier>=4?1:f)*100)}%`,background:s?`linear-gradient(90deg, ${V[c].rim[0]} 0%, ${V[c].ring} 55%, ${V[c].rim[1]} 100%)`:"rgba(128,134,130,0.75)",boxShadow:s?"inset 0 1px 1px rgba(255,255,255,0.35)":void 0}})})]}),a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[a.jsx("span",{children:h("achievements.modal.tier_history")}),a.jsx($t,{badge:e})]})]})]})}const xe=ve("relative w-full max-w-[380px] 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]");function Gt({badge:e,onClose:t}){const n=Ze(),r=!!e;return C.useEffect(()=>{if(!n||!r)return;const s=c=>{c.key==="Escape"&&(c.stopPropagation(),t?.())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[n,r,t]),r?n?a.jsxs("div",{className:"fixed inset-0 z-[120] flex items-center justify-center p-4",children:[a.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-[2px]",onClick:t,"aria-hidden":!0}),a.jsx("div",{className:xe,children:a.jsx(ge,{badge:e,onClose:t})})]}):a.jsx(nt,{open:!0,onOpenChange:s=>{s||t?.()},children:a.jsxs(rt,{children:[a.jsx(at,{className:"cost-modal-backdrop z-[110]"}),a.jsx(st,{className:"fixed inset-0 z-[120] flex items-center justify-center p-4",children:a.jsxs(it,{className:ve("cost-modal-popup",xe),children:[a.jsx(ot,{render:a.jsx("h2",{className:"sr-only"}),children:h(U(e.id,"name"))}),a.jsx(ge,{badge:e,onClose:t})]})})]})}):null}export{Gt as BadgeDetailModal,Vt as currentBadgeIssueNumber,Gt as default,Tt as formatIssueNumber};
import{j as r}from"./__vite-browser-external-CHbEWSwX.js";function t({children:i,title:a,subtitle:o,className:s="",bodyClassName:d=""}){return r.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${s}`,children:[(a||o)&&r.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[a&&r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:a}),o&&r.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:o})]}),r.jsx("div",{className:`p-5 ${d}`,children:i})]})}export{t as C};
import{k as c}from"./__vite-browser-external-CHbEWSwX.js";const e=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=c("check",e);export{t as C};
import{r,j as f}from"./__vite-browser-external-CHbEWSwX.js";function p(e){const n=String(e||"").trim().toLowerCase();return/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/.test(n)?n:"clawd"}const C=.84;function L(e){return p(e)==="clawd"?C:1}const z={idle:{row:0,durations:[280,110,110,140,140,320]},"running-right":{row:1,durations:[120,120,120,120,120,120,120,220]},"running-left":{row:2,durations:[120,120,120,120,120,120,120,220]},waving:{row:3,durations:[140,140,140,280]},jumping:{row:4,durations:[140,140,140,140,280]},failed:{row:5,durations:[140,140,140,140,140,140,140,240]},waiting:{row:6,durations:[150,150,150,150,150,260]},running:{row:7,durations:[120,120,120,120,120,220]},review:{row:8,durations:[150,150,150,150,150,280]}};function T(e){return["error","disconnected","working-overheated"].includes(e)?"failed":["happy","waking","mini-happy","jumping"].includes(e)?"jumping":["working-typing","working-ultrathink","working-juggling","running"].includes(e)?"running":["working-thinking","working-wizard","review"].includes(e)?"review":["sleeping","idle-doze","mini-sleep","waiting"].includes(e)?"waiting":["mini-peek","waving"].includes(e)?"waving":e==="running-left"||e==="running-right"?e:"idle"}function V(){const[e,n]=r.useState(()=>typeof document>"u"?!0:document.visibilityState!=="hidden");return r.useEffect(()=>{if(typeof document>"u")return;const t=()=>n(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),e}function _(){const[e,n]=r.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return r.useEffect(()=>{if(typeof window.matchMedia!="function")return;const t=window.matchMedia("(prefers-reduced-motion: reduce)"),i=o=>n(o.matches);return t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function I({character:e,pet:n=null,state:t="idle-living",dragState:i=null,size:o=48,className:d="",lookDirectionIndex:u=null}){const l=p(e),g=i==="running-left"||i==="running-right"?i:T(t),a=z[g],s=n?.spriteVersionNumber===2?2:1,w=s===2?11:9,c=s===2&&g==="idle"&&Number.isInteger(u)?(u%16+16)%16:null,h=c==null?a.row:9+Math.floor(c/8),m=c==null?null:c%8,k=_(),y=V(),[b,S]=r.useState(0);r.useEffect(()=>{if(S(0),k||!y||c!=null)return;let M=!1,x=0;const E=$=>{x=window.setTimeout(()=>{if(M)return;const j=($+1)%a.durations.length;S(j),E(j)},a.durations[$])};return E(0),()=>{M=!0,window.clearTimeout(x)}},[c,k,y,a]);const A=r.useMemo(()=>({width:o*(192/208),height:o,backgroundImage:`url(${n?.assetUrl||`/pets/${l}/spritesheet.webp`})`,backgroundRepeat:"no-repeat",backgroundSize:`800% ${w*100}%`,backgroundPosition:`${(m??b)/7*100}% ${h/(w-1)*100}%`,imageRendering:"pixelated"}),[w,m,h,b,l,n?.assetUrl,o]);return f.jsx("div",{"aria-hidden":"true",className:`pet-atlas-animated ${d}`,style:A})}const R={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},v=new Map;async function P(e){if(v.has(e))return v.get(e);if(typeof fetch!="function")return null;let n;try{n=await fetch(`/clawd/${e}`)}catch{return null}if(!n.ok)return null;const i=(await n.text()).replace(/<svg([^>]*)>/,(o,d)=>`<svg${d.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return v.set(e,i),i}function H({state:e="idle-living",size:n=48,className:t=""}){const[i,o]=r.useState(""),d=r.useRef(null),l=N()?"static-base":e,g=R[l]||R["static-base"];return r.useEffect(()=>{let a=!1;return P(g).then(s=>{!a&&s&&o(s)}),()=>{a=!0}},[g]),r.useEffect(()=>{const a=d.current?.querySelector("svg");if(a)try{const s=a.getBBox();s.width>0&&s.height>0&&a.setAttribute("viewBox",`${s.x-2} ${s.y-2} ${s.width+4} ${s.height+4}`)}catch{}},[i]),f.jsx("div",{ref:d,"aria-hidden":"true",className:`clawd-animated ${t}`,style:{width:n,height:n,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:i}})}function B({state:e="idle-living",size:n=48,className:t="",character:i="clawd",pet:o=null,lookDirectionIndex:d=null}){const u=p(i);return u!=="clawd"?f.jsx(I,{character:u,pet:o,state:e,size:n,className:t,lookDirectionIndex:d}):f.jsx(H,{state:e,size:n*L(u),className:t})}function N(){const[e,n]=r.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return r.useEffect(()=>{if(typeof window.matchMedia!="function")return;const t=window.matchMedia("(prefers-reduced-motion: reduce)"),i=o=>n(o.matches);return t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}export{B as C,p as n};
import{k as L,j as e,Q as R,l as P,r as D,c as n,X as z,x as M,i as S,P as K}from"./__vite-browser-external-CHbEWSwX.js";import{A as U,W as B}from"./icons-DhvcZGBX.js";import{u as F}from"./useTokenFormat-BLfmNxg5.js";import{D as G,T as W}from"./TrendMonitor-C-acyVP7.js";import{T as V}from"./AchievementBadge-CkmyCQlm.js";import{T as X}from"./terminal-Bwl-eNY6.js";import{D as Y,a as Z,b as H,c as q,d as Q,e as J}from"./DialogTitle-qsUpNlJa.js";import{D as ee}from"./DialogDescription-D0X0v38O.js";import"./useCurrency-QqSMR7Ba.js";import"./PopoverPopup-BuSDh9-C.js";import"./useScrollLock-DdUQVKDA.js";import"./SelectItemText-Ca7gf5A0.js";import"./zap-DjGiVr-_.js";import"./flame-DCV1yyCQ.js";const ae=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],te=L("trending-down",ae),O=10,_={input:"var(--community-token-input)",cache_read:"var(--community-token-cache-read)",cache_write:"var(--community-token-cache-write)",output:"var(--community-token-output)",reasoning:"var(--community-token-reasoning)"},re={CLAUDE:"var(--community-claude)",CODEX:"var(--community-codex)",GEMINI:"var(--community-gemini)",CURSOR:"var(--community-cursor)",OPENCODE:"var(--community-opencode)",HERMES:"var(--community-hermes)",KIMI:"var(--community-kimi)",MIMO:"var(--community-mimo)",COPILOT:"var(--community-copilot)",KIRO:"var(--community-kiro)",GROK:"var(--community-grok)",DEEPSEEK:"var(--community-deepseek)",ZCODE:"var(--community-zcode)",WORKBUDDY:"var(--community-workbuddy)",MINIMAX:"var(--community-minimax)",DROID:"var(--community-droid)"};function ie(t){return re[String(t||"").toUpperCase()]||"var(--community-muted)"}const se=[[/claude|fable|opus|sonnet|haiku/,"CLAUDE"],[/gpt|codex|o3|o4/,"CODEX"],[/gemini/,"GEMINI"],[/composer|cursor/,"CURSOR"],[/kimi/,"KIMI"],[/mimo/,"MIMO"],[/copilot/,"COPILOT"],[/kiro/,"KIRO"],[/grok/,"GROK"],[/deepseek/,"DEEPSEEK"],[/glm/,"ZCODE"],[/hy3/,"WORKBUDDY"],[/minimax/,"MINIMAX"]],g=["overview","providers","community","models"];function oe(t){const s=String(t||"").toLowerCase(),a=se.find(([i])=>i.test(s));return a?a[1]:""}function u(t){const s=Number(t);return Number.isFinite(s)?`${s.toFixed(1)}%`:"—"}function p(t){return S(Number(t)||0)}function ne(t){return t?new Date(`${t}T00:00:00Z`).toLocaleDateString(void 0,{month:"short",day:"numeric",timeZone:"UTC"}):""}function k(){return e.jsx("div",{className:"flex h-full min-h-40 items-center justify-center text-xs text-oai-gray-400",children:n("leaderboard.community.modal.no_data")})}function b({children:t,detail:s}){return e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-4",children:[e.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:t}),s?e.jsx("span",{className:"text-xs text-oai-gray-400",children:s}):null]})}function C({value:t,label:s}){const a=Number(t);if(!Number.isFinite(a))return null;const i=Math.sign(a)!==-1,r=i?V:te;return e.jsxs("span",{className:`inline-flex items-center gap-1 text-xs font-medium tabular-nums ${i?"text-emerald-600 dark:text-emerald-400":"text-rose-600 dark:text-rose-400"}`,title:s,children:[e.jsx(r,{className:"size-3","aria-hidden":"true"}),i?"+":"",a.toFixed(1),"%"]})}function j({label:t,value:s,title:a,delta:i,deltaLabel:r}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-medium text-oai-gray-500 dark:text-oai-gray-400",children:t}),e.jsxs("div",{className:"mt-1 flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"truncate text-xl font-semibold leading-none tracking-tight text-oai-black tabular-nums dark:text-white",title:a,children:s}),e.jsx(C,{value:i,label:r})]})]})}function I({fillWidth:t,share:s,color:a="var(--oai-blue)",ariaLabel:i,dataAttrs:r,children:o}){return e.jsxs("div",{...r,className:"group relative grid min-h-11 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 overflow-hidden px-2.5 transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 opacity-[0.15] transition-opacity group-hover:opacity-[0.22] dark:opacity-[0.24] dark:group-hover:opacity-[0.32]",style:{width:`${t}%`,backgroundColor:a},role:"progressbar","aria-label":i,"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":Number(s)||0}),o]})}function A({rank:t,provider:s,name:a,fillWidth:i,share:r,tokens:o,tokensTitle:l,dataAttrs:c}){return e.jsxs(I,{fillWidth:i,share:r,color:ie(s),ariaLabel:`${a} ${u(r)}`,dataAttrs:c,children:[e.jsxs("div",{className:"relative flex min-w-0 items-center gap-2.5",children:[e.jsx("span",{className:`w-5 shrink-0 text-xs tabular-nums ${t<=3?"font-semibold text-oai-gray-700 dark:text-oai-gray-200":"text-oai-gray-400"}`,children:t}),e.jsx("span",{className:"grid size-6 shrink-0 place-items-center text-oai-gray-700 dark:text-oai-gray-200",children:e.jsx(K,{provider:s,size:15})}),e.jsx("span",{className:"truncate text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200",title:a,children:a})]}),e.jsxs("div",{className:"relative min-w-[4.5rem] text-right",children:[e.jsx("div",{className:"text-xs font-semibold text-oai-black tabular-nums dark:text-white",title:l,children:o}),e.jsx("div",{className:"text-xs text-oai-gray-500 tabular-nums dark:text-oai-gray-400",children:u(r)})]})]})}function le({rows:t,formatTokensTooltip:s}){return t.length?e.jsxs("div",{className:"mt-7",children:[e.jsx(b,{children:n("leaderboard.community.modal.token_mix")}),e.jsx("div",{className:"flex h-1.5 overflow-hidden bg-oai-gray-100 dark:bg-oai-gray-800",children:t.map(a=>e.jsx("div",{style:{width:`${Math.max(Number(a.share)||0,0)}%`,backgroundColor:_[a.key]||"var(--community-muted)"},title:`${n(`leaderboard.community.modal.token_mix.${a.key}`)} · ${u(a.share)}`},a.key))}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-x-5 gap-y-1.5",children:t.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",title:s(a.tokens),children:[e.jsx("span",{className:"size-2",style:{backgroundColor:_[a.key]||"var(--community-muted)"}}),n(`leaderboard.community.modal.token_mix.${a.key}`),e.jsx("span",{className:"tabular-nums text-oai-gray-700 dark:text-oai-gray-200",children:u(a.share)})]},a.key))})]}):null}function f({label:t,value:s,title:a,delta:i,deltaLabel:r,className:o=""}){return e.jsxs("div",{className:`min-w-0 ${o}`,children:[e.jsx("div",{className:"truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t}),e.jsxs("div",{className:"mt-1 flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"truncate text-base font-semibold leading-none tracking-tight tabular-nums text-oai-black dark:text-white",title:a,children:s}),e.jsx(C,{value:i,label:r})]})]})}function de({trendRows:t,activeDevelopers30d:s,developerGrowthPct:a,formatTokens:i,formatTokensTooltip:r}){if(!t.length)return null;const o=t.reduce((m,h)=>m+h.value,0),l=t.reduce((m,h)=>m.value<h.value?h:m,t[0]),c=o/t.length;return e.jsxs("div",{className:"mt-5 grid grid-cols-3 divide-x divide-oai-gray-100 border-y border-oai-gray-100 py-3.5 dark:divide-oai-gray-800/80 dark:border-oai-gray-800/80",children:[e.jsx(f,{className:"pr-4",label:n("leaderboard.community.modal.daily_average"),value:i(c),title:r(c)}),e.jsx(f,{className:"px-4",label:`${n("leaderboard.community.modal.peak_day")} · ${l.day}`,value:i(l.value),title:r(l.value)}),e.jsx(f,{className:"pl-4",label:n("leaderboard.community.modal.active_30d"),value:p(s),title:Number(s).toLocaleString(),delta:a,deltaLabel:n("leaderboard.community.modal.vs_previous_week")})]})}function me({trendRows:t,mix:s,activeDevelopers30d:a,developerGrowthPct:i,formatTokens:r,formatTokensTooltip:o}){return!t.length&&!s.length?e.jsx(k,{}):e.jsxs("div",{children:[e.jsx(b,{detail:n("leaderboard.community.modal.utc_note"),children:n("leaderboard.community.modal.community_activity")}),e.jsx(W,{embedded:!0,rows:t,from:t[0]?.day,to:t.at(-1)?.day,chartHeightClass:"h-44"}),e.jsx(de,{trendRows:t,activeDevelopers30d:a,developerGrowthPct:i,formatTokens:r,formatTokensTooltip:o}),e.jsx(le,{rows:s,formatTokensTooltip:o})]})}function ce({rows:t,maxShare:s,formatTokens:a,formatTokensTooltip:i}){return t.length?e.jsx("div",{className:"space-y-0.5",children:t.map((r,o)=>e.jsx(A,{rank:o+1,dataAttrs:{"data-provider-rank":o+1,"data-provider-name":r.name},provider:String(r.name).toUpperCase(),name:r.name,fillWidth:Math.max((Number(r.share)||0)/s*100,2),share:r.share,tokens:a(r.tokens),tokensTitle:i(r.tokens)},r.name))}):e.jsx(k,{})}function xe({rows:t,maxShare:s,formatTokens:a,formatTokensTooltip:i}){return t.length?e.jsx("div",{className:"space-y-0.5",children:t.map((r,o)=>{const l=Number(r.share)||0;return e.jsx(A,{rank:o+1,dataAttrs:{"data-model-rank":o+1,"data-model-name":r.name},provider:oe(r.name),name:r.name,fillWidth:Math.max(l/s*100,2),share:l,tokens:a(r.tokens),tokensTitle:i(r.tokens)},r.name)})}):e.jsx(k,{})}function ue({name:t}){const s=String(t||"").toLowerCase();return s==="darwin"?e.jsx(U,{className:"size-3.5"}):s==="win32"?e.jsx(B,{className:"size-3.5"}):e.jsx(X,{className:"size-4","aria-hidden":"true"})}const he=.175,ye=.3;function ge({bands:t,formatTokensTooltip:s}){const a=t.reduce((r,o)=>Math.max(r,Number(o.developer_share)||0),0)||1,i=r=>`${n(`leaderboard.community.modal.band.${r.key}`)} · ${n("leaderboard.community.modal.developer_count",{count:p(r.developers)})} (${s(r.tokens)})`;return e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-2 border-b border-oai-gray-200 dark:border-oai-gray-800",children:t.map((r,o)=>{const l=Number(r.developer_share)||0,c=Math.max(l/a*80,2);return e.jsxs("div",{className:"relative h-32 min-w-0 flex-1",title:i(r),children:[e.jsx("div",{role:"progressbar","aria-label":n("leaderboard.community.modal.developer_share_title",{share:u(l)}),"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":l,className:"absolute inset-x-0 bottom-0",style:{height:`${c}%`,backgroundColor:"var(--oai-blue)",opacity:ye+o*he}}),e.jsx("div",{className:"absolute inset-x-0 text-center text-xs font-medium tabular-nums text-oai-gray-700 dark:text-oai-gray-200",style:{bottom:`calc(${c}% + 4px)`},children:u(l)})]},r.key)})}),e.jsx("div",{className:"mt-2 flex gap-2",children:t.map(r=>e.jsxs("div",{className:"min-w-0 flex-1 text-center",title:i(r),children:[e.jsx("div",{className:"truncate text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200",children:n(`leaderboard.community.modal.band.${r.key}`)}),e.jsx("div",{className:"truncate text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:p(r.developers)})]},r.key))})]})}function pe({bands:t,platforms:s,formatTokensTooltip:a}){return!t.length&&!s.length?e.jsx(k,{}):e.jsxs("div",{className:"space-y-8",children:[t.length?e.jsxs("div",{children:[e.jsx(b,{children:n("leaderboard.community.modal.usage_distribution")}),e.jsx(ge,{bands:t,formatTokensTooltip:a})]}):null,s.length?e.jsxs("div",{children:[e.jsx(b,{children:n("leaderboard.community.modal.platforms")}),e.jsx("div",{className:"space-y-0.5",children:s.map(i=>e.jsxs(I,{fillWidth:Math.max(Number(i.share)||0,1),share:i.share,ariaLabel:`${n(`leaderboard.community.modal.platform.${i.name}`)} ${u(i.share)}`,children:[e.jsxs("div",{className:"relative flex min-w-0 items-center gap-2.5",children:[e.jsx("span",{className:"grid size-6 shrink-0 place-items-center text-oai-gray-700 dark:text-oai-gray-200",children:e.jsx(ue,{name:i.name})}),e.jsx("span",{className:"truncate text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200",children:n(`leaderboard.community.modal.platform.${i.name}`)})]}),e.jsxs("div",{className:"relative min-w-[4.5rem] text-right",children:[e.jsx("div",{className:"text-xs font-semibold text-oai-black tabular-nums dark:text-white",children:u(i.share)}),e.jsx("div",{className:"text-xs text-oai-gray-500 tabular-nums dark:text-oai-gray-400",title:Number(i.machines||0).toLocaleString(),children:n("leaderboard.community.modal.machine_count",{count:p(i.machines)})})]})]},i.name))})]}):null]})}function ve({isOpen:t,onClose:s,communityStats:a}){const{formatTokens:i,formatTokensTooltip:r}=F(),[o,l]=D.useState("overview"),c=a?.status==="ready",m=D.useMemo(()=>{if(!c)return null;const d=(Array.isArray(a.providers)?a.providers:[]).slice(0,O),x=(Array.isArray(a.topModels)?a.topModels:[]).slice(0,O),y=v=>v.reduce((E,$)=>Math.max(E,Number($.share)||0),0)||1;return{providers:d,models:x,providersMaxShare:y(d),modelsMaxShare:y(x),trendRows:(Array.isArray(a.dailyGrowth)?a.dailyGrowth:[]).map(v=>({day:ne(v.day),value:Number(v.tokens)||0})),mix:Array.isArray(a.tokenMix)?a.tokenMix:[],bands:Array.isArray(a.userDistribution)?a.userDistribution:[],platforms:Array.isArray(a.platforms)?a.platforms:[]}},[c,a]);if(!m)return null;const h=Number(a.tokenFloor)||0,N=Number(a.activeDevelopersTotal)||Number(a.totalEntries)||0,w=Number(a.tokens30d)||0,T=d=>{if(d.key!=="ArrowRight"&&d.key!=="ArrowLeft")return;d.preventDefault();const x=d.key==="ArrowRight"?1:-1,y=g[(g.indexOf(o)+x+g.length)%g.length];l(y),d.currentTarget.querySelector(`[data-tab-id="${y}"]`)?.focus()};return e.jsx(Y,{open:t,onOpenChange:d=>!d&&s(),children:e.jsxs(Z,{children:[e.jsx(H,{className:"fixed inset-0 z-[100] bg-black/50 backdrop-blur-[3px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),e.jsx(q,{className:"fixed inset-0 z-[101] flex items-center justify-center p-2 sm:p-5",children:e.jsxs(Q,{className:"relative flex h-[min(42rem,92vh)] w-full max-w-xl flex-col overflow-hidden rounded-2xl bg-white shadow-2xl ring-1 ring-black/10 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-3 data-[ending-style]:scale-[0.98] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-3 data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:ring-white/10",children:[e.jsxs("header",{"data-testid":"community-metrics-header",className:"shrink-0 px-5 pt-5 sm:px-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(J,{className:"text-lg font-semibold tracking-[-0.02em] text-oai-black dark:text-white",children:n("leaderboard.community.modal.title")}),e.jsx(ee,{className:"sr-only",children:n("leaderboard.community.modal.description")})]}),e.jsx(G,{className:"-mr-1 -mt-1 grid size-8 place-items-center rounded-full text-oai-gray-400 transition-colors hover:bg-black/5 hover:text-oai-black dark:hover:bg-white/10 dark:hover:text-white","aria-label":n("shared.dialog.close"),children:e.jsx(z,{className:"size-4"})})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-x-5",children:[e.jsx(j,{label:n("leaderboard.community.modal.total_tokens"),value:i(h),title:r(h)}),e.jsx(j,{label:n("leaderboard.community.modal.tokens_30d"),value:i(w),title:r(w),delta:a.tokenGrowthPct,deltaLabel:n("leaderboard.community.modal.vs_previous_week")}),e.jsx(j,{label:n("leaderboard.community.modal.contributors"),value:p(N),title:N.toLocaleString()})]}),e.jsx("div",{className:"mt-4 flex items-end overflow-x-auto border-b border-oai-gray-100 dark:border-oai-gray-900",role:"tablist","aria-label":n("leaderboard.community.modal.views"),onKeyDown:T,children:g.map(d=>{const x=o===d;return e.jsxs("button",{type:"button",role:"tab","data-tab-id":d,"aria-selected":x,tabIndex:x?0:-1,onClick:()=>l(d),className:`relative mr-5 h-10 shrink-0 text-sm font-medium transition-colors last:mr-0 ${x?"text-oai-black dark:text-white":"text-oai-gray-500 hover:text-oai-gray-700 dark:text-oai-gray-400 dark:hover:text-oai-gray-200"}`,children:[n(`leaderboard.community.modal.tab.${d}`),x?e.jsx(M.span,{layoutId:"community-metrics-tab-underline",className:"absolute inset-x-0 -bottom-px h-0.5 rounded-full bg-oai-black dark:bg-white",transition:{type:"spring",stiffness:420,damping:34}}):null]},d)})})]}),e.jsx("div",{"data-testid":"community-metrics-content",className:"min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:e.jsxs(M.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.18,ease:[.16,1,.3,1]},className:"h-full",children:[o==="overview"?e.jsx(me,{trendRows:m.trendRows,mix:m.mix,activeDevelopers30d:Number(a.activeDevelopers30d)||0,developerGrowthPct:a.developerGrowthPct,formatTokens:i,formatTokensTooltip:r}):null,o==="providers"?e.jsx(ce,{rows:m.providers,maxShare:m.providersMaxShare,formatTokens:i,formatTokensTooltip:r}):null,o==="community"?e.jsx(pe,{bands:m.bands,platforms:m.platforms,formatTokensTooltip:r}):null,o==="models"?e.jsx(xe,{rows:m.models,maxShare:m.modelsMaxShare,formatTokens:i,formatTokensTooltip:r}):null]},o)})]})})]})})}function Ee(t){return e.jsx(R,{mode:P.COMPACT,children:e.jsx(ve,{...t})})}export{Ee as CommunityStatsModal};
import{j as a,B as i,b as x}from"./__vite-browser-external-CHbEWSwX.js";import{D as p,a as m,b as y,c as b,d as f,e as u}from"./DialogTitle-qsUpNlJa.js";import{D as h}from"./DialogDescription-D0X0v38O.js";function _({open:r,title:l,description:t,confirmLabel:o,cancelLabel:n,destructive:d=!1,busy:e=!1,onConfirm:c,onCancel:s}){return a.jsx(p,{open:r,onOpenChange:g=>{!g&&!e&&s?.()},children:a.jsxs(m,{children:[a.jsx(y,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),a.jsx(b,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:a.jsxs(f,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[a.jsx(u,{className:"text-base font-semibold text-oai-black dark:text-white",children:l}),t?a.jsx(h,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:t}):null,a.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[a.jsx(i,{type:"button",variant:"secondary",size:"sm",disabled:e,onClick:()=>s?.(),children:n}),a.jsx(i,{type:"button",size:"sm",disabled:e,onClick:()=>c?.(),className:x(d&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:o})]})]})})]})})}export{_ as C};
import{k as c}from"./__vite-browser-external-CHbEWSwX.js";const e=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],t=c("copy",e);export{t as C};

Sorry, the diff of this file is too big to display

import{e as p,r as c,j as e,h as b}from"./__vite-browser-external-CHbEWSwX.js";const f={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_VERSION:"0.82.1",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};
import{r as n,y as a}from"./__vite-browser-external-CHbEWSwX.js";import{u as p}from"./DialogTitle-qsUpNlJa.js";import{u as c}from"./useScrollLock-DdUQVKDA.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};
import{aC as s,aD as v,r as l,aE as W,y as w,aF as B,aG as V,j as I,aH as A,aI as ee,aJ as te,aK as ne,aL as oe,aM as se,aN as re}from"./__vite-browser-external-CHbEWSwX.js";import{F as Y,P as $,p as j,C as E,c as ae,a as ie,b as le,d as de,I as ue,e as pe,f as ce,g as ge,h as fe,i as me,j as Se,s as Ce,k as Pe,l as Oe,u as Re}from"./useScrollLock-DdUQVKDA.js";function Ee(){return new Y({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new $,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function he(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:Ee(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:v,inactiveTriggerProps:v,popupProps:v}}function Ie(e,t,o=!1){return new Y({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:o,onOpenChange:void 0})}const D=s(e=>e.triggerIdProp??e.activeTriggerId),U=s(e=>e.openProp??e.open),H=s(e=>(e.popupElement?.id??e.floatingId)||void 0);function G(e,t){return t!==void 0&&U(e)&&D(e)===t}function xe(e,t){return G(e,t)?!0:t!==void 0&&U(e)&&D(e)==null&&e.triggerCount===1}const ye={open:U,mounted:s(e=>e.mounted),transitionStatus:s(e=>e.transitionStatus),floatingRootContext:s(e=>e.floatingRootContext),triggerCount:s(e=>e.triggerCount),preventUnmountingOnClose:s(e=>e.preventUnmountingOnClose),payload:s(e=>e.payload),activeTriggerId:D,activeTriggerElement:s(e=>e.mounted?e.activeTriggerElement:null),popupId:H,isTriggerActive:s((e,t)=>t!==void 0&&D(e)===t),isOpenedByTrigger:s((e,t)=>G(e,t)),isMountedByTrigger:s((e,t)=>t!==void 0&&D(e)===t&&e.mounted),triggerProps:s((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),triggerPopupId:s((e,t)=>xe(e,t)?H(e):void 0),popupProps:s(e=>e.popupProps),popupElement:s(e=>e.popupElement),positionerElement:s(e=>e.positionerElement)},q=l.createContext(!1),z=l.createContext(void 0);function T(e){const t=l.useContext(z);if(e===!1&&t===void 0)throw new Error(W(27));return t}const ve={...j,...B},Le=l.forwardRef(function(t,o){const{render:r,className:d,style:a,forceRender:p=!1,...c}=t,{store:i}=T(),n=i.useState("open"),m=i.useState("nested"),C=i.useState("mounted"),S=i.useState("transitionStatus");return w("div",t,{state:{open:n,transitionStatus:S},ref:[i.context.backdropRef,o],stateAttributesMapping:ve,props:[{role:"presentation",hidden:!C,style:{userSelect:"none",WebkitUserSelect:"none"}},c],enabled:p||!m})});let Te=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),De=(function(e){return e[e.open=E.open]="open",e[e.closed=E.closed]="closed",e[e.startingStyle=E.startingStyle]="startingStyle",e[e.endingStyle=E.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Q=l.createContext(void 0);function X(){const e=l.useContext(Q);if(e===void 0)throw new Error(W(26));return e}const we={...j,...B,nestedDialogOpen(e){return e?{[De.nestedDialogOpen]:""}:null}},_e=l.forwardRef(function(t,o){const{render:r,className:d,style:a,finalFocus:p,initialFocus:c,...i}=t,{store:n}=T(),m=n.useState("descriptionElementId"),C=n.useState("disablePointerDismissal"),S=n.useState("floatingRootContext"),O=n.useState("popupProps"),P=n.useState("modal"),R=n.useState("mounted"),h=n.useState("nested"),f=n.useState("nestedOpenDialogCount"),g=n.useState("open"),L=n.useState("openMethod"),x=n.useState("titleElementId"),u=n.useState("transitionStatus"),b=n.useState("role"),k=S.useState("floatingId"),M=i.id??k;X(),V({open:g,ref:n.context.popupRef,onComplete(){g&&n.context.onOpenChangeComplete?.(!0)}});const F=c===void 0?ae(n.context.popupRef):c,N=f>0,y=n.useStateSetter("popupElement"),Z=w("div",t,{state:{open:g,nested:h,transitionStatus:u,nestedDialogOpen:N},props:[O,{id:M,"aria-labelledby":x??void 0,"aria-describedby":m??void 0,role:b,...ie,hidden:!R,onKeyDown(_){le.has(_.key)&&_.stopPropagation()},style:{[Te.nestedDialogs]:f}},i],ref:[o,n.context.popupRef,y],stateAttributesMapping:we});return I.jsx(de,{context:S,openInteractionType:L,disabled:!R,closeOnFocusOut:!C,initialFocus:F,returnFocus:p,modal:P!==!1,restoreFocus:"popup",children:Z})}),He=l.forwardRef(function(t,o){const{keepMounted:r=!1,...d}=t,{store:a}=T(),p=a.useState("mounted"),c=a.useState("modal"),i=a.useState("open");return p||r?I.jsx(Q.Provider,{value:r,children:I.jsxs(A,{ref:o,...d,children:[p&&c===!0&&I.jsx(ue,{ref:a.context.internalBackdropRef,inert:ee(!i)}),t.children]})}):null});function be(e){const{store:t,actionsRef:o}=e,r=t.useState("open");pe(t,r),ce(t);const{forceUnmount:d}=ge(r,t),a=l.useCallback(()=>{t.setOpen(!1,te(ne))},[t]);l.useImperativeHandle(o,()=>({unmount:d,close:a}),[d,a])}function ke({store:e,parentContext:t,isDrawer:o}){const r=e.useState("open"),d=e.useState("disablePointerDismissal"),a=e.useState("modal"),p=e.useState("popupElement"),c=e.useState("floatingRootContext"),[i,n]=l.useState(0),[m,C]=l.useState(0),S=i===0,O=fe(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:a==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(f){if(!e.context.outsidePressEnabledRef.current||"button"in f&&f.button!==0||"touches"in f&&f.touches.length!==1)return!1;const g=oe(f);return S&&!d?a&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===g||e.context.backdropRef.current===g||se(g,p)&&!g?.hasAttribute("data-base-ui-portal"):!0:!1},escapeKey:S});me(r&&a===!0,p),e.useContextCallback("onNestedDialogOpen",(f,g)=>{n(f),C(g)}),e.useContextCallback("onNestedDialogClose",()=>{n(0),C(0)}),l.useEffect(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(i+1,m+(o?1:0)),t?.onNestedDialogClose&&!r&&t.onNestedDialogClose(),()=>{t?.onNestedDialogClose&&r&&t.onNestedDialogClose()}),[o,r,i,m,t]);const P=O.reference??v,R=O.trigger??v,h=O.floating??v;return Se(e,{activeTriggerProps:P,inactiveTriggerProps:R,popupProps:h,nestedOpenDialogCount:i,nestedOpenDrawerCount:m}),null}const Me={...ye,modal:s(e=>e.modal),nested:s(e=>e.nested),nestedOpenDialogCount:s(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:s(e=>e.nestedOpenDrawerCount),disablePointerDismissal:s(e=>e.disablePointerDismissal),openMethod:s(e=>e.openMethod),descriptionElementId:s(e=>e.descriptionElementId),titleElementId:s(e=>e.titleElementId),viewportElement:s(e=>e.viewportElement),role:s(e=>e.role)};class K extends re{constructor(t,o,r=!1){const d=new $,a=Fe(t);a.floatingRootContext=Ie(d,o,r),super(a,{popupRef:l.createRef(),backdropRef:l.createRef(),internalBackdropRef:l.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:d,onOpenChange:void 0,onOpenChangeComplete:void 0},Me)}setOpen=(t,o)=>{if(o.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&o.trigger==null&&this.state.activeTriggerId!=null&&(o.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,o),o.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(t,o);const r={open:t};Ce(r,t,o.trigger),this.update(r)};static useStore(t,o){return Pe(t,(d,a)=>new K(o,d,a),!0).store}}function Fe(e={}){return{...he(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function Ne(e,t="dialog"){const{children:o,open:r,defaultOpen:d=!1,onOpenChange:a,onOpenChangeComplete:p,disablePointerDismissal:c=!1,modal:i=!0,actionsRef:n,handle:m,triggerId:C,defaultTriggerId:S=null}=e,O=t==="drawer",P=t==="alert-dialog",R=P?!0:i,h=P||c,f=P?"alertdialog":"dialog",g=T(!0),x={modal:R,disablePointerDismissal:h,nested:!!g,role:f},u=K.useStore(m?.store,{open:d,openProp:r,activeTriggerId:S,triggerIdProp:C,...x});Oe(()=>{const y=r===void 0&&u.state.open===!1&&d===!0?{open:!0,activeTriggerId:S}:null;P?u.update(y?{...x,...y}:x):y&&u.update(y)}),u.useControlledProp("openProp",r),u.useControlledProp("triggerIdProp",C),u.useSyncedValues(x),u.useContextCallback("onOpenChange",a),u.useContextCallback("onOpenChangeComplete",p);const b=u.useState("open"),k=u.useState("mounted"),M=u.useState("payload");be({store:u,actionsRef:n});const F=b||k,N=l.useMemo(()=>({store:u}),[u]);return I.jsx(q.Provider,{value:!1,children:I.jsxs(z.Provider,{value:N,children:[F&&I.jsx(ke,{store:u,parentContext:g?.store.context,isDrawer:O}),typeof o=="function"?o({payload:M}):o]})})}function Je(e){const t=l.useContext(q)?"drawer":"dialog";return Ne(e,t)}let J=(function(e){return e[e.open=E.open]="open",e[e.closed=E.closed]="closed",e[e.startingStyle=E.startingStyle]="startingStyle",e[e.endingStyle=E.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Be={...j,...B,nested(e){return e?{[J.nested]:""}:null},nestedDialogOpen(e){return e?{[J.nestedDialogOpen]:""}:null}},We=l.forwardRef(function(t,o){const{render:r,className:d,style:a,children:p,...c}=t,i=X(),{store:n}=T(),m=n.useState("open"),C=n.useState("nested"),S=n.useState("transitionStatus"),O=n.useState("nestedOpenDialogCount"),P=n.useState("mounted"),R=n.useStateSetter("viewportElement"),h=O>0;return w("div",t,{enabled:i||P,state:{open:m,nested:C,transitionStatus:S,nestedDialogOpen:h},ref:[o,R],stateAttributesMapping:Be,props:[{role:"presentation",hidden:!P,style:{pointerEvents:m?void 0:"none"},children:p},c]})}),Ye=l.forwardRef(function(t,o){const{render:r,className:d,style:a,id:p,...c}=t,{store:i}=T(),n=Re(p);return i.useSyncedValueWithCleanup("titleElementId",n),w("h2",t,{ref:o,props:[{id:n},c]})});export{Je as D,He as a,Le as b,We as c,_e as d,Ye as e,Ie as f,he as g,ye as p,T as u};
import{k as o}from"./__vite-browser-external-CHbEWSwX.js";const a=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],e=o("download",a);export{e as D};
import{w as d,j as n,x as a}from"./__vite-browser-external-CHbEWSwX.js";function v({children:i,delay:t=0,duration:o=.35,y:e=12,className:s="",once:r=!0}){return d()?n.jsx("div",{className:s,children:i}):n.jsx(a.div,{initial:{opacity:0,y:e},animate:{opacity:1,y:0},transition:{duration:o,delay:t,ease:[.16,1,.3,1]},className:s,children:i})}function x({children:i,staggerDelay:t=.1,initialDelay:o=0,className:e=""}){return d()?n.jsx("div",{className:e,children:i}):n.jsx(a.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:t,delayChildren:o}}},className:e,children:i})}function h({children:i,className:t="",y:o=12}){return d()?n.jsx("div",{className:t,children:i}):n.jsx(a.div,{variants:{hidden:{opacity:0,y:o},visible:{opacity:1,y:0,transition:{duration:.35,ease:[.16,1,.3,1]}}},className:t,children:i})}export{v as F,x as S,h as a};
import{k as c}from"./__vite-browser-external-CHbEWSwX.js";const e=[["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"}]],a=c("flame",e);export{a as F};
import{i as r}from"./__vite-browser-external-CHbEWSwX.js";function n(o){const t=Number(o)||0;return t>=1e12?`${Number((t/1e12).toFixed(2)).toString()}T`:r(t)}export{n as f};
import{r as s,s as c,j as t}from"./__vite-browser-external-CHbEWSwX.js";function u({repo:r="mm7894215/TokenTracker"}){const[a,o]=s.useState(null);return s.useEffect(()=>{if(typeof window>"u")return;const n=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,i=typeof document<"u"&&(document.documentElement?.classList.contains("screenshot-capture")||document.body?.classList.contains("screenshot-capture"));c({prefersReducedMotion:n,screenshotCapture:i})&&fetch(`https://api.github.com/repos/${r}`).then(e=>e.json()).then(e=>{e&&typeof e.stargazers_count=="number"&&o(e.stargazers_count)}).catch(()=>{})},[r]),t.jsxs("a",{href:`https://github.com/${r}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-2 px-3 py-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 transition-colors no-underline",children:[t.jsx("svg",{height:"16",viewBox:"0 0 16 16",width:"16",className:"shrink-0 fill-oai-gray-700 dark:fill-oai-gray-300",children:t.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),t.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap",children:"Star"}),a!==null&&t.jsx("span",{className:"text-xs font-semibold text-oai-gray-900 dark:text-oai-white tabular-nums whitespace-nowrap",children:a})]})}export{u as H};
import{j as r}from"./__vite-browser-external-CHbEWSwX.js";function e({className:n}){return r.jsx("svg",{viewBox:"0 0 384 512",className:n,fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"})})}function o({className:n}){return r.jsx("svg",{viewBox:"0 0 16 16",className:n,fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})})}function t({className:n}){return r.jsx("svg",{viewBox:"0 0 24 24",className:n,fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M3 5.46 10.2 4.5v6.92H3V5.46Zm0 13.08 7.2.96v-6.84H3v5.88Zm8.04 1.08L21 21V12.46h-9.96v7.16ZM11.04 4.38 21 3v8.46h-9.96V4.38Z"})})}export{e as A,o as G,t as W};
import{k as o}from"./__vite-browser-external-CHbEWSwX.js";const c=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],t=o("info",c);export{t as I};
import{r as ge,c as t,j as n}from"./__vite-browser-external-CHbEWSwX.js";const Ge=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),j=Ge?"/proxy/ipcheck":"https://ip.net.coffee",fe="claude_ip_history",Se=6,Ue=["CN","HK","MO","RU","KP","IR","SY","CU","BY","VE"],ze={CN:"Asia/Shanghai",TW:"Asia/Taipei",HK:"Asia/Hong_Kong",MO:"Asia/Macau",JP:"Asia/Tokyo",KR:"Asia/Seoul",SG:"Asia/Singapore",MY:"Asia/Kuala_Lumpur",TH:"Asia/Bangkok",VN:"Asia/Ho_Chi_Minh",ID:"Asia/Jakarta",PH:"Asia/Manila",IN:"Asia/Kolkata",PK:"Asia/Karachi",BD:"Asia/Dhaka",IR:"Asia/Tehran",IL:"Asia/Jerusalem",AE:"Asia/Dubai",SA:"Asia/Riyadh",TR:"Europe/Istanbul",RU:"Europe/Moscow",UA:"Europe/Kyiv",GB:"Europe/London",IE:"Europe/Dublin",FR:"Europe/Paris",DE:"Europe/Berlin",IT:"Europe/Rome",ES:"Europe/Madrid",PT:"Europe/Lisbon",NL:"Europe/Amsterdam",BE:"Europe/Brussels",CH:"Europe/Zurich",AT:"Europe/Vienna",SE:"Europe/Stockholm",NO:"Europe/Oslo",DK:"Europe/Copenhagen",FI:"Europe/Helsinki",PL:"Europe/Warsaw",CZ:"Europe/Prague",GR:"Europe/Athens",RO:"Europe/Bucharest",US:"America/Los_Angeles",CA:"America/Toronto",MX:"America/Mexico_City",BR:"America/Sao_Paulo",AR:"America/Argentina/Buenos_Aires",CL:"America/Santiago",AU:"Australia/Sydney",NZ:"Pacific/Auckland",ZA:"Africa/Johannesburg",EG:"Africa/Cairo",NG:"Africa/Lagos",KE:"Africa/Nairobi"},We={CN:["zh"],TW:["zh"],HK:["zh","en"],MO:["zh","en"],JP:["ja"],KR:["ko"],TH:["th"],VN:["vi"],SG:["en","zh","ms","ta"],MY:["ms","en","zh","ta"],ID:["id","en"],PH:["en","tl","fil"],IN:["en","hi"],PK:["ur","en"],BD:["bn","en"],LK:["si","ta","en"],NP:["ne","en"],US:["en"],GB:["en"],IE:["en","ga"],AU:["en"],NZ:["en","mi"],CA:["en","fr"],DE:["de"],AT:["de"],CH:["de","fr","it","rm"],BE:["nl","fr","de"],FR:["fr"],IT:["it"],ES:["es","ca","gl","eu"],PT:["pt"],NL:["nl","fy"],LU:["lb","fr","de"],SE:["sv"],NO:["no","nb","nn"],DK:["da"],FI:["fi","sv"],IS:["is","en"],PL:["pl"],CZ:["cs"],SK:["sk"],HU:["hu"],RO:["ro"],BG:["bg"],GR:["el"],RU:["ru"],UA:["uk","ru"],BY:["be","ru"],TR:["tr"],IL:["he","ar","en"],SA:["ar"],AE:["ar","en"],EG:["ar"],IR:["fa"],IQ:["ar","ku"],ZA:["en","af","zu","xh"],KE:["en","sw"],NG:["en"],ET:["am","en"],BR:["pt"],AR:["es"],MX:["es"],CL:["es"],CO:["es"],PE:["es"],VE:["es"]},Be={jp:"Japan",tw:"Taiwan",hk:"Hong Kong",sg:"Singapore",us:"United States",de:"Germany",kr:"South Korea",fr:"France",nl:"Netherlands",gb:"United Kingdom",au:"Australia",ca:"Canada",br:"Brazil",in:"India"};function Z(p){return!!p&&p.includes(":")}function Ke(p){return!Z(p)||p.length<=20?p:p.substring(0,18)+"..."}function w(p){return p==null?"":String(p).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function B(p){if(!p||!/^[a-zA-Z]{2}$/.test(p))return"";const b=p.toLowerCase();return`<img src="${b==="cn"?`${j}/favicons/cn.png`:b==="tw"?`${j}/favicons/flags/tw.png`:`${j}/favicons/flags/${b}.png`}" alt="${b}" class="inline-block h-4 w-auto align-[-2px]" onerror="this.onerror=null;this.style.display='none'">`}function Fe(p){if(!p)return"";const b=String(p).trim();if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(b)){const S=b.split(".");return S[0]+"."+S[1]+".*.*"}if(b.includes("…")){const S=b.lastIndexOf("…");return b.substring(0,S+1)+"*"}if(b.includes(":")){const S=b.split(":");if(S.length>=2)return S[0]+":"+S[1]+":*"}return b}function Ve(p){if(!p)return null;try{const S=new Intl.DateTimeFormat("en-US",{timeZone:p,timeZoneName:"longOffset"}).formatToParts(new Date).find(q=>q.type==="timeZoneName");if(!S)return null;if(S.value==="GMT"||S.value==="UTC")return 0;const M=S.value.match(/GMT([+-])(\d{1,2}):?(\d{0,2})/);return M?(M[1]==="+"?1:-1)*(parseInt(M[2],10)*60+parseInt(M[3]||"0",10)):null}catch{return null}}function Ye(p){if(p==null)return"";const b=p>=0?"+":"-",S=Math.abs(p),M=Math.floor(S/60),D=S%60;return"UTC"+b+M+(D?":"+String(D).padStart(2,"0"):"")}const Te={safe:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",warn:"bg-amber-50 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300",danger:"bg-red-50 text-red-700 dark:bg-red-500/15 dark:text-red-300",info:"bg-blue-50 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300",neutral:"bg-oai-gray-100 text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-400"};function Je(){const p=ge.useRef(null),[b,S]=ge.useState(!1);ge.useEffect(()=>{const _=p.current;if(!_)return;const C=a=>_.querySelector(`#${a}`);let se=!1;const e={unknown:t("ipcheck.common.unknown"),failed:t("ipcheck.ip.failed"),regionAccessible:t("ipcheck.trust.region.accessible"),regionWarnTitle:a=>t("ipcheck.trust.region_warn.title",{region:a}),regionWarnBody:t("ipcheck.trust.region_warn.body"),regionRestrictedText:t("ipcheck.trust.text.restricted"),noData:t("ipcheck.trust.no_data"),noIp:t("ipcheck.trust.no_ip"),noScore:t("ipcheck.trust.no_score"),score:{pristine:t("ipcheck.trust.label.pristine"),clean:t("ipcheck.trust.label.clean"),good:t("ipcheck.trust.label.good"),neutral:t("ipcheck.trust.label.neutral"),suspicious:t("ipcheck.trust.label.suspicious"),unreachable:t("ipcheck.trust.label.unreachable")},scoreText:{excellent:t("ipcheck.trust.text.excellent"),great:t("ipcheck.trust.text.great"),minor:t("ipcheck.trust.text.minor"),moderate:t("ipcheck.trust.text.moderate"),severe:t("ipcheck.trust.text.severe")},propsRegion:t("ipcheck.props.region"),propsCity:t("ipcheck.props.city"),propsType:t("ipcheck.props.type"),propsAsn:t("ipcheck.props.asn"),propsOrg:t("ipcheck.props.org"),propsResidential:t("ipcheck.props.residential"),propsDatacenter:t("ipcheck.props.datacenter"),secVpn:t("ipcheck.security.vpn"),secProxy:t("ipcheck.security.proxy"),secTor:t("ipcheck.security.tor"),secCrawler:t("ipcheck.security.crawler"),secAbuser:t("ipcheck.security.abuser"),secProxyFlag:t("ipcheck.security.proxy_flag"),secCrawlerYes:t("ipcheck.security.crawler_yes"),secCrawlerNo:t("ipcheck.security.crawler_no"),secAbuserYes:t("ipcheck.security.abuser_yes"),secAbuserNo:t("ipcheck.security.abuser_no"),secClean:t("ipcheck.security.clean"),availSvc:t("ipcheck.avail.svc_row"),availLat:{normal:t("ipcheck.avail.latency.normal"),good:t("ipcheck.avail.latency.good"),slow:t("ipcheck.avail.latency.slow"),unreachable:t("ipcheck.avail.latency.unreachable")},availSvcStatus:{none:t("ipcheck.avail.svc.none"),minor:t("ipcheck.avail.svc.minor"),major:t("ipcheck.avail.svc.major"),critical:t("ipcheck.avail.svc.critical"),maintenance:t("ipcheck.avail.svc.maintenance"),other:t("ipcheck.avail.svc.other")},dnsStatus:t("ipcheck.dns.status"),dnsOutlet:t("ipcheck.dns.outlet"),dnsOutletIp:t("ipcheck.dns.outlet_ip"),dnsIsp:t("ipcheck.dns.isp"),dnsLeaked:t("ipcheck.dns.leaked"),dnsNoLeak:t("ipcheck.dns.no_leak"),dnsEncrypted:t("ipcheck.dns.encrypted"),dnsCnTag:t("ipcheck.dns.cn_tag"),udpStatus:t("ipcheck.udp.status"),udpOutlet:t("ipcheck.udp.outlet"),udpOutletIp:t("ipcheck.udp.outlet_ip"),udpOrigin:t("ipcheck.udp.origin"),udpDisabled:t("ipcheck.udp.disabled"),udpNoLeak:t("ipcheck.udp.no_leak"),udpLeaked:t("ipcheck.udp.leaked"),udpAnomaly:t("ipcheck.udp.anomaly"),devTz:t("ipcheck.device.tz"),devLang:t("ipcheck.device.lang"),devOs:t("ipcheck.device.os"),devTouch:t("ipcheck.device.touch"),devNet:t("ipcheck.device.net"),devDnt:t("ipcheck.device.dnt"),devWebglRender:t("ipcheck.device.webgl_render"),devCanvasFp:t("ipcheck.device.canvas_fp"),devWebglFp:t("ipcheck.device.webgl_fp"),devMatch:t("ipcheck.device.match"),devMismatch:t("ipcheck.device.mismatch"),devLocal:t("ipcheck.device.local"),devEstSuffix:t("ipcheck.device.estimate_suffix"),devDiffEqual:t("ipcheck.device.diff_equal"),devDiffAhead:a=>t("ipcheck.device.diff_ahead",{h:a}),devDiffBehind:a=>t("ipcheck.device.diff_behind",{h:a}),devLangExpected:t("ipcheck.device.lang_expected"),devTouchYes:t("ipcheck.device.touch_yes"),devTouchNo:t("ipcheck.device.touch_no"),devDntOn:t("ipcheck.device.dnt_on"),devDntOff:t("ipcheck.device.dnt_off"),devDntUnset:t("ipcheck.device.dnt_unset"),devNetUnsupported:t("ipcheck.device.net_unsupported"),devUnsupported:t("ipcheck.device.unsupported"),histEmpty:t("ipcheck.history.empty"),histCurrent:t("ipcheck.history.current"),histLoading:t("ipcheck.ip.loading")};function f(a,i="neutral"){return`<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${Te[i]||Te.neutral}">${a}</span>`}function J(a,i,r){return a===!0?f(i,"danger"):a===!1?f(r,"safe"):f(e.unknown,"neutral")}function he(a){if(!a)return`<span class="text-oai-gray-400 dark:text-oai-gray-500">${w(e.failed)}</span>`;const i=w(a);return Z(a)?`<span class="ip-mask-target truncate" title="${i}">${w(Ke(a))}</span>`:`<span class="ip-mask-target">${i}</span>`}function K(a){return a?`<span class="ip-link">${he(a)}</span>`:`<span class="text-oai-gray-400 dark:text-oai-gray-500">${w(e.failed)}</span>`}function d(a,i,r=!1){let u=i;return i===void 0?r?u=`<div class="inline-flex items-center gap-1.5 text-xs text-oai-gray-400">
<svg class="animate-spin-subtle h-3.5 w-3.5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="3"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</div>`:u='<span class="block h-3 w-20 rounded bg-oai-gray-100 dark:bg-oai-gray-800 shimmer"></span>':u=`<div class="animate-scale-up-fade">${i}</div>`,`<div class="flex items-center justify-between py-2.5 gap-3">
<span class="text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0">${a}</span>
<span class="text-sm font-medium text-oai-black dark:text-white text-right min-w-0">${u}</span>
</div>`}function re(a){return a.map(i=>d(i,void 0)).join("")}function oe(){return'<div class="h-7 w-44 rounded bg-oai-gray-100 dark:bg-oai-gray-800 shimmer"></div>'}function ce(){return'<div class="h-3 w-52 mt-2 rounded bg-oai-gray-100 dark:bg-oai-gray-800 shimmer"></div>'}function _e(a){return a>=95?{text:e.score.pristine,variant:"safe"}:a>=80?{text:e.score.clean,variant:"safe"}:a>=50?{text:e.score.good,variant:"info"}:a>=25?{text:e.score.neutral,variant:"warn"}:{text:e.score.suspicious,variant:"danger"}}const m={ip:null,ippure:null,ipapis:null,claudeGeo:null,claudeRisk:null,cfGeo:"",scoreAnimId:null,lastScore:0};function xe(){const a=(m.claudeRisk?.countryCode||"").toUpperCase();return!a||!Ue.includes(a)?null:t(`ipcheck.region.${a}`)}function le(){const a=C("ipv6Warn");a&&a.classList.remove("hidden")}function te(a,i){const r=C(a);r&&(r.textContent=i||"",r.classList.remove("animate-pulse","bg-oai-gray-200","dark:bg-oai-gray-800","w-52","h-3","mt-2","rounded"))}const Le={gaugeScore:'<span class="block h-8 w-16 rounded bg-oai-gray-100 dark:bg-oai-gray-800 shimmer"></span>',ipAddrCN:oe(),ipGeoCN:ce(),ipAddr:oe(),ipGeo:ce(),ipAddrClaude:oe(),ipGeoClaude:ce(),propsContent:re([e.propsRegion,e.propsCity,e.propsType,e.propsAsn,e.propsOrg]),securityContent:re([e.secVpn,e.secProxy,e.secTor,e.secCrawler,e.secAbuser]),claudeAvailContent:d("claude.ai",void 0,!0)+d("anthropic.com",void 0,!0),dnsLeakContent:d(e.dnsStatus,void 0,!0)+d(e.dnsOutletIp,void 0,!0),udpLeakContent:d(e.udpStatus,void 0,!0)+d(e.udpOutletIp,void 0,!0),deviceContent:re([e.devTz,e.devLang,e.devOs,e.devTouch,e.devNet,e.devDnt,e.devWebglRender,e.devCanvasFp]),ipHistoryContent:`<span class="text-sm text-oai-gray-400 dark:text-oai-gray-500">${e.histLoading}</span>`};Object.entries(Le).forEach(([a,i])=>{const r=C(a);r&&(r.innerHTML=i)});let ye=!1;function Ne(a){if(!a)return;a.dataset.realText||(a.dataset.realText=(a.textContent||"").trim());const i=a.dataset.realText,r=ye?Fe(i):i;a.textContent!==r&&(a.textContent=r)}function ke(){_.querySelectorAll(".ip-link, .ip-mask-target").forEach(Ne)}const ve=new MutationObserver(()=>requestAnimationFrame(ke));["ipHeroCN","ipHero","ipHeroClaude","ipHistoryContent","dnsLeakContent","udpLeakContent"].forEach(a=>{const i=C(a);i&&ve.observe(i,{childList:!0,subtree:!0})}),_.__setMaskOn=a=>{ye=!!a,ke()};async function $e(){try{const r=(await(await fetch("https://1.1.1.1/cdn-cgi/trace",{signal:AbortSignal.timeout(5e3)})).text()).match(/ip=([^\n]+)/);r&&(m.ip=r[1].trim())}catch{}}async function je(){try{const i=await(await fetch("https://claude.ai/cdn-cgi/trace",{cache:"no-store",signal:AbortSignal.timeout(8e3)})).text(),r=Object.fromEntries(i.trim().split(`
`).map(u=>u.split("=")));return{ip:r.ip||null,loc:r.loc?.toLowerCase()||null}}catch{return null}}async function Me(){try{const r=(await(await fetch("https://2026.ip138.com/",{signal:AbortSignal.timeout(5e3)})).text()).match(/(\d+\.\d+\.\d+\.\d+)/);if(r)return{ip:r[1]}}catch{}try{const r=(await(await fetch("https://my.ip.cn/",{signal:AbortSignal.timeout(5e3)})).text()).match(/(\d+\.\d+\.\d+\.\d+)/);if(r)return{ip:r[1]}}catch{}return null}async function Ee(a,i,r,u){const g=C(a),o=C(i);if(!(!g||!o)){if(!r){g.innerHTML=`<span class="text-oai-gray-400 dark:text-oai-gray-500">${e.failed}</span>`,o.textContent="";return}Z(r)&&le(),g.innerHTML=`${B(u)+" "}${K(r)}`;try{const l=await fetch(`${j}/api/geoip/${r}`,{signal:AbortSignal.timeout(5e3)});if(l.ok){const h=await l.json(),s=[h.country,h.region,h.city,h.isp].filter(Boolean).join(" · "),x=h.country_code||u||"";g.innerHTML=`${B(x)} ${K(r)}`,te(i,s)}}catch{}}}function Ie(){const a=m.ippure,i=m.claudeRisk,r=m.claudeGeo,u=m.ipapis,g=i?.asn||a?.asn||"",o=i?.asOrganization||a?.asOrganization||u?.company?.name||"",l=xe(),h=!!(i&&i.ip);let s,x=null;h?l?(s=0,x=e.regionRestrictedText):s=typeof i.trust_score=="number"?i.trust_score:null:s=null;const v=C("gaugePointer"),c=C("gaugeScore"),P=C("gaugeText");if(s===null)c.innerHTML=`<span class="text-4xl font-bold tracking-tight tabular-nums text-oai-gray-400 dark:text-oai-gray-500">—</span> ${f(e.noData,"neutral")}`,v.style.left="0%",v.style.opacity="0.3",v.style.borderColor="",v.style.boxShadow="",P.textContent=h?e.noScore:e.noIp;else{const A=l?{text:e.score.unreachable,variant:"danger"}:_e(s),L=s>=50?"text-emerald-500":s>=25?"text-amber-500":"text-red-500",X=s>=50?"#10b981":s>=25?"#f59e0b":"#ef4444";if(m.lastScore!==s){m.scoreAnimId&&cancelAnimationFrame(m.scoreAnimId);const Q=m.lastScore||0;m.lastScore=s;const de=performance.now(),ee=800,ne=ue=>{const N=ue-de,k=Math.min(N/ee,1),$=k*(2-k),I=Math.round(Q+(s-Q)*$),Y=I>=50?"text-emerald-500":I>=25?"text-amber-500":"text-red-500";c&&(c.innerHTML=`<span class="text-4xl font-bold tracking-tight tabular-nums ${Y}">${I}</span> ${f(A.text,A.variant)}`),k<1?m.scoreAnimId=requestAnimationFrame(ne):m.scoreAnimId=null};m.scoreAnimId=requestAnimationFrame(ne)}else c.innerHTML=`<span class="text-4xl font-bold tracking-tight tabular-nums ${L}">${s}</span> ${f(A.text,A.variant)}`;requestAnimationFrame(()=>{requestAnimationFrame(()=>{v&&(v.style.left=Math.min(s,100)+"%",v.style.opacity="1",v.style.borderColor=X,v.style.boxShadow=`0 0 10px ${X}80, 0 2px 6px rgba(0,0,0,0.15)`)})}),P.textContent=x||(s>=95?e.scoreText.excellent:s>=80?e.scoreText.great:s>=50?e.scoreText.minor:s>=25?e.scoreText.moderate:e.scoreText.severe)}const y=C("statusDotClaude");if(y){let A,L;s===null?(A="animate-ping absolute inline-flex h-full w-full rounded-full bg-oai-gray-300 dark:bg-oai-gray-600 opacity-75",L="relative inline-flex h-2 w-2 rounded-full bg-oai-gray-400 dark:bg-oai-gray-500"):l||s<25?(A="animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75",L="relative inline-flex h-2 w-2 rounded-full bg-red-500"):s<50?(A="animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75",L="relative inline-flex h-2 w-2 rounded-full bg-amber-500"):(A="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75",L="relative inline-flex h-2 w-2 rounded-full bg-emerald-500"),y.innerHTML=`<span class="${A}"></span><span class="${L}"></span>`}const H=C("regionWarn");H&&(l?(H.innerHTML=`<span class="font-medium">⚠️ ${e.regionWarnTitle(l)}</span><br><span class="text-[13px] font-normal mt-1 block opacity-90">${e.regionWarnBody}</span>`,H.classList.remove("hidden")):H.classList.add("hidden"));const G=C("claudeRegionSupportRow"),F=C("claudeRegionSupport");if(G&&F)if(l)G.classList.add("hidden");else{const A=!!(i&&i.ip),L=!!(i&&i.countryCode);F.innerHTML=!A||!L?f(e.unknown,"neutral"):f(e.regionAccessible,"safe"),G.classList.remove("hidden")}const U=i?.isResidential??(u?!u.is_datacenter:null),O=u?.company?.type||"",z=r?.country||i?.country||"",W=r?.city||i?.city||"";let T;if(U===!0?T=f(e.propsResidential,"safe"):U===!1?T=f(e.propsDatacenter,"warn"):T=f(e.unknown,"neutral"),O){const L={hosting:"Hosting",isp:"ISP",business:"Business",education:"Education"}[O]||w(O);T+=` <span class="text-xs text-oai-gray-500 dark:text-oai-gray-400">${L}</span>`}C("propsContent").innerHTML=d(e.propsRegion,z?w(z):f(e.unknown,"neutral"))+d(e.propsCity,W?w(W):f(e.unknown,"neutral"))+d(e.propsType,T)+d(e.propsAsn,g?`<span class="font-mono tabular-nums">AS${w(g)}</span>`:f(e.unknown,"neutral"))+d(e.propsOrg,o?w(o):f(e.unknown,"neutral"));const E=u||{};C("securityContent").innerHTML=d(e.secVpn,J(E.is_vpn,e.secVpn,e.secClean))+d(e.secProxy,J(E.is_proxy,e.secProxyFlag,e.secClean))+d(e.secTor,J(E.is_tor,e.secTor,e.secClean))+d(e.secCrawler,J(E.is_crawler,e.secCrawlerYes,e.secCrawlerNo))+d(e.secAbuser,J(E.is_abuser,e.secAbuserYes,e.secAbuserNo))}async function Re(){const a=C("dnsLeakContent");if(!a)return;a.innerHTML=d(e.dnsStatus,void 0,!0)+d(e.dnsOutletIp,void 0,!0);const i=Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2);for(let s=1;s<=2;s++)await new Promise(x=>{const v=new Image,c=setTimeout(x,2e3);v.onload=v.onerror=()=>{clearTimeout(c),x()},v.src=`http://${i}-${s}.d.ip.net.coffee/pixel.gif?_=${Date.now()}`});await new Promise(s=>setTimeout(s,1500));let r=[];for(let s=0;s<2;s++){try{const x=await fetch(`${j}/api/dns/result/${i}`,{signal:AbortSignal.timeout(3e3)});if(x.ok&&(r=(await x.json()).dns_servers||[],r.length>0))break}catch{}s===0&&await new Promise(x=>setTimeout(x,1500))}if(r.length===0){a.innerHTML=d(e.dnsStatus,f(e.dnsEncrypted,"safe"));return}const u=(m.claudeRisk?.country||"").toLowerCase(),g=u.includes("china")||u.includes("中国");let o=null,l=!1;for(const s of r){let x=null;try{const y=await fetch(`${j}/api/geoip/${s}`,{signal:AbortSignal.timeout(3e3)});y.ok&&(x=await y.json())}catch{}const v=x?.country_code||"",c=x?.isp||"";if(v==="cn"&&!g){o={ip:s,cc:v,isp:c,leaked:!0},l=!0;break}o||(o={ip:s,cc:v,isp:c,leaked:!1})}let h=d(e.dnsStatus,l?f(e.dnsLeaked,"warn"):f(e.dnsNoLeak,"safe"));if(o){const s=`${B(o.cc)} <span class="ip-mask-target ${o.leaked?"text-amber-600 dark:text-amber-400 font-medium":""}">${w(o.ip)}</span>${o.leaked?" "+f(e.dnsCnTag,"warn"):""}`;h+=d(e.dnsOutlet,s),o.isp&&(h+=d(e.dnsIsp,`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal truncate inline-block max-w-[12rem] align-bottom">${w(o.isp)}</span>`))}a.innerHTML=h}async function He(){const a=C("udpLeakContent");if(!a)return;a.innerHTML=d(e.udpStatus,void 0,!0)+d(e.udpOutletIp,void 0,!0);const i=new Set;try{const y=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.cloudflare.com:3478"}]});y.createDataChannel("");const H=await y.createOffer();await y.setLocalDescription(H),await new Promise(G=>{const F=setTimeout(()=>{y.close(),G()},5e3);y.onicecandidate=U=>{if(!U.candidate){clearTimeout(F),y.close(),G();return}const O=U.candidate.candidate.match(/([0-9]{1,3}\.){3}[0-9]{1,3}/);if(O){const W=O[0];!W.startsWith("0.")&&!W.startsWith("127.")&&W!=="0.0.0.0"&&i.add(W)}const z=U.candidate.candidate.match(/([a-f0-9]{1,4}:){2,7}[a-f0-9]{1,4}/i);z&&i.add(z[0])}})}catch{}const r=m.claudeRisk?.ip||"",u=[...i],g=u.filter(y=>!Z(y)&&!y.startsWith("192.168.")&&!y.startsWith("10.")&&!y.startsWith("172.")&&!y.startsWith("198.18.")&&!y.startsWith("198.19.")&&!y.startsWith("100.64.")&&!y.startsWith("127.")&&!y.startsWith("0."));if(g.length===0&&u.length===0){a.innerHTML=d(e.udpStatus,f(e.udpDisabled,"safe"));return}if(g.length===0){a.innerHTML=d(e.udpStatus,f(e.udpNoLeak,"safe"));return}let o=g.find(y=>y===r)||g[0];const l=new Set(g).size>1,h=o===r,s=l&&!h;let x=d(e.udpStatus,s?f(e.udpLeaked,"warn"):f(e.udpNoLeak,"safe")),v="",c="";try{const y=await fetch(`${j}/api/geoip/${o}`,{signal:AbortSignal.timeout(5e3)});if(y.ok){const H=await y.json();v=H.country_code||"",c=H.country||""}}catch{}const P=`${B(v)} <span class="${s?"text-amber-600 dark:text-amber-400 font-medium":""}">${he(o)}</span>${h?"":s?" "+f(e.udpAnomaly,"warn"):""}`;x+=d(e.udpOutlet,P),c&&(x+=d(e.udpOrigin,`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${w(c)}</span>`)),a.innerHTML=x}async function be(){const a=C("claudeAvailContent");if(!a)return;a.innerHTML=d("claude.ai",void 0,!0)+d("anthropic.com",void 0,!0);const i=[{name:"claude.ai",url:"https://claude.ai/cdn-cgi/trace"},{name:"anthropic.com",url:"https://www.anthropic.com/favicon.ico"}],r=await Promise.allSettled(i.map(async o=>{const l=performance.now();try{return await fetch(o.url,{mode:"no-cors",signal:AbortSignal.timeout(6e3)}),{name:o.name,ms:Math.round(performance.now()-l),ok:!0}}catch{return{name:o.name,ms:-1,ok:!1}}})),u=xe();let g="";r.forEach(o=>{const l=o.value;if(u)g+=d(l.name,f(e.availLat.unreachable,"danger"));else if(l.ok){const h=l.ms<250?"safe":l.ms<500?"info":"warn",s=l.ms<250?e.availLat.normal:l.ms<500?e.availLat.good:e.availLat.slow;g+=d(l.name,`${f(s,h)} <span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${l.ms}ms</span>`)}else g+=d(l.name,f(e.availLat.unreachable,"danger"))});try{const o=await fetch(`${j}/claude/status.json`,{signal:AbortSignal.timeout(3e3)});if(o.ok){const h=(await o.json()).overall_indicator||"none",s=e.availSvcStatus[h]||e.availSvcStatus.other,x={none:"safe",minor:"warn",major:"danger",critical:"danger",maintenance:"warn"};g+=d(e.availSvc,f(s,x[h]||"warn"))}}catch{}a.innerHTML=g}_.__detectClaudeAvail=be;function Oe(){const a=Intl.DateTimeFormat().resolvedOptions().timeZone||e.unknown,i=-(new Date().getTimezoneOffset()/60),r="UTC"+(i>=0?"+":"")+i,u=m.claudeRisk,g=(u?.countryCode||"").toUpperCase(),o=u?.timezone||ze[g]||"",l=!!u?.timezone,h=Ve(o),s=-new Date().getTimezoneOffset();let x=null;o&&h!=null&&(x=Math.abs(h-s)<=60);let v;const c=w(a),P=w(o);if(x===!0)v=`${f(e.devMatch,"safe")} <span class="text-xs text-oai-gray-500 dark:text-oai-gray-400">${c} (${r})</span>`;else if(x===!1){const N=Ye(h),k=Math.round((h-s)/60),$=k===0?e.devDiffEqual:k>0?e.devDiffAhead(k):e.devDiffBehind(-k),I=l?P:`${P} ${e.devEstSuffix}`;v=`${f(e.devMismatch,"warn")}<br><span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${e.devLocal} ${c} (${r})<br>Claude ${I} (${N}) · ${$}</span>`}else v=`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${c} (${r})</span>`;const y=navigator.languages||[navigator.language],H=y.join(", ")||e.unknown,G=(y[0]||"").split("-")[0].toLowerCase(),F=We[g]||[],U=G&&F.length?F.includes(G):null;let O;const z=w(H),W=w(F.join(" / "));U===!0?O=`${f(e.devMatch,"safe")} <span class="text-xs text-oai-gray-500 dark:text-oai-gray-400">${z}</span>`:U===!1?O=`${f(e.devMismatch,"warn")}<br><span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${e.devLocal} ${z}<br>${e.devLangExpected} ${W}</span>`:O=`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${z}</span>`;const T=navigator.userAgent;let E=e.unknown,A=e.unknown;T.includes("Windows")?E="Windows":T.includes("Mac OS")?E="macOS":T.includes("iPhone")||T.includes("iPad")?E="iOS":T.includes("Android")?E="Android":T.includes("Linux")&&(E="Linux"),T.includes("Edg/")?A="Edge "+(T.match(/Edg\/([\d.]+)/)||[])[1]:T.includes("Chrome/")?A="Chrome "+(T.match(/Chrome\/([\d.]+)/)||[])[1]:T.includes("Firefox/")?A="Firefox "+(T.match(/Firefox\/([\d.]+)/)||[])[1]:T.includes("Safari/")&&!T.includes("Chrome")&&(A="Safari "+(T.match(/Version\/([\d.]+)/)||[])[1]);let L=e.devUnsupported;try{const N=document.createElement("canvas"),k=N.getContext("webgl")||N.getContext("experimental-webgl");if(k){const $=k.getExtension("WEBGL_debug_renderer_info");$&&(L=k.getParameter($.UNMASKED_RENDERER_WEBGL))}}catch{}let X=e.devUnsupported;try{const N=document.createElement("canvas"),k=N.getContext("webgl")||N.getContext("experimental-webgl");if(k){const $=k.getExtension("WEBGL_debug_renderer_info"),I=$?k.getParameter($.UNMASKED_VENDOR_WEBGL):"",Y=$?k.getParameter($.UNMASKED_RENDERER_WEBGL):"",Ce=I+"~"+Y+"~"+k.getParameter(k.VERSION)+"~"+k.getParameter(k.SHADING_LANGUAGE_VERSION);let ie=0;for(let pe=0;pe<Ce.length;pe++)ie=(ie<<5)-ie+Ce.charCodeAt(pe)|0;X=(ie>>>0).toString(16).toUpperCase()}}catch{}let Q=e.devUnsupported;try{const N=document.createElement("canvas");N.width=200,N.height=50;const k=N.getContext("2d");k.textBaseline="top",k.font="14px Arial",k.fillStyle="#f60",k.fillRect(50,0,100,50),k.fillStyle="#069",k.fillText("net.coffee",2,15),k.fillStyle="rgba(102,204,0,0.7)",k.fillText("canvas fp",4,30);const $=N.toDataURL();let I=0;for(let Y=0;Y<$.length;Y++)I=(I<<5)-I+$.charCodeAt(Y)|0;Q=(I>>>0).toString(16).toUpperCase()}catch{}const de=navigator.maxTouchPoints>0,ee=navigator.connection||navigator.mozConnection||navigator.webkitConnection,ne=ee?ee.effectiveType||ee.type||e.unknown:e.devNetUnsupported,ue=navigator.doNotTrack==="1"?e.devDntOn:navigator.doNotTrack==="0"?e.devDntOff:e.devDntUnset;C("deviceContent").innerHTML=d(e.devTz,v)+d(e.devLang,O)+d(e.devOs,`${w(E)} <span class="text-oai-gray-400 dark:text-oai-gray-500">/</span> ${w(A)}`)+d(e.devTouch,de?f(e.devTouchYes,"info"):f(e.devTouchNo,"neutral"))+d(e.devNet,`<span class="font-mono uppercase">${w(ne)}</span>`)+d(e.devDnt,w(ue))+d(e.devWebglRender,`<span class="text-xs font-normal text-oai-gray-600 dark:text-oai-gray-400 break-all">${w(L)}</span>`)+d(e.devCanvasFp,`<span class="font-mono text-oai-gray-700 dark:text-oai-gray-300">${w(Q)}</span>`)+d(e.devWebglFp,`<span class="font-mono text-oai-gray-700 dark:text-oai-gray-300">${w(X)}</span>`)}function we(){try{return JSON.parse(localStorage.getItem(fe))||[]}catch{return[]}}function Pe(){const a=m.claudeRisk?.ip||"",i=(m.claudeRisk?.countryCode||"").toLowerCase(),r=m.claudeRisk?.city||"";if(!a){ae();return}const u=we(),g=new Date,o={ip:a,cc:i,geo:r,time:g.toISOString()};if(u.length>0){const l=u[0],h=(g-new Date(l.time))/(1e3*60*60);if(l.ip===a&&h<24){ae();return}}u.unshift(o),u.length>Se&&(u.length=Se),localStorage.setItem(fe,JSON.stringify(u)),ae()}function ae(){const a=C("ipHistoryContent");if(!a)return;const i=we();if(i.length===0){a.innerHTML=`<span class="text-sm text-oai-gray-500 dark:text-oai-gray-400">${e.histEmpty}</span>`;return}a.innerHTML=`<ul class="divide-y divide-oai-gray-100 dark:divide-oai-gray-800">${i.map((r,u)=>{const g=new Date(r.time),o=`${g.getMonth()+1}-${g.getDate()} ${String(g.getHours()).padStart(2,"0")}:${String(g.getMinutes()).padStart(2,"0")}`,l=u===0;return`<li class="flex items-center justify-between py-3 gap-4">
<div class="flex items-center gap-2 min-w-0">
<span class="text-sm ${l?"text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400"}">${o}</span>
${l?`<span class="inline-flex items-center rounded-full bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300 px-1.5 py-0.5 text-[10px] font-medium">${w(e.histCurrent)}</span>`:""}
</div>
<div class="flex items-center gap-2 text-sm font-medium text-oai-black dark:text-white min-w-0">
${B(r.cc)}
${K(r.ip)}
${r.geo?`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal truncate">${w(r.geo)}</span>`:""}
</div>
</li>`}).join("")}</ul>`}_.__clearIPHistory=()=>{localStorage.removeItem(fe),ae()};async function De(){const[,a,i]=await Promise.allSettled([$e(),Me(),je()]);if(se)return;const r=a.status==="fulfilled"?a.value:null,u=i.status==="fulfilled"?i.value:null,g=[];g.push(Ee("ipAddrCN","ipGeoCN",r?.ip,"cn")),g.push((async()=>{const o=C("ipAddr"),l=C("ipGeo");if(!m.ip){o&&(o.innerHTML=`<span class="text-oai-gray-400 dark:text-oai-gray-500">${e.failed}</span>`),l&&(l.textContent="");return}Z(m.ip)&&le(),o&&(o.innerHTML=K(m.ip));try{const h=await fetch(`${j}/api/geoip/${m.ip}`,{signal:AbortSignal.timeout(5e3)});if(h.ok){const s=await h.json(),x=(s.country_code||"").toLowerCase();m.ippure={ip:m.ip,country:s.country,countryCode:(s.country_code||"").toUpperCase(),region:s.region,city:s.city},m.cfGeo=[s.country,s.region,s.city,s.isp].filter(Boolean).join(" · "),o&&(o.innerHTML=`${B(x)} ${K(m.ip)}`),te("ipGeo",m.cfGeo)}}catch{}})()),g.push((async()=>{const o=u?.ip,l=C("ipAddrClaude"),h=C("ipGeoClaude");if(!o){l&&(l.innerHTML=`<span class="text-oai-gray-400 dark:text-oai-gray-500">${e.failed}</span>`),h&&(h.textContent="");return}Z(o)&&le(),l&&(l.innerHTML=`${B(u.loc||"")} ${K(o)}`);const[s,x]=await Promise.allSettled([fetch(`${j}/api/iprisk/${o}`,{signal:AbortSignal.timeout(1e4)}),fetch(`${j}/api/geoip/${o}`,{signal:AbortSignal.timeout(5e3)})]);let v=!1;if(x.status==="fulfilled"&&x.value.ok)try{const c=await x.value.json();if(c.country){m.claudeGeo={country:c.country,region:c.region,city:c.city,isp:c.isp,country_code:c.country_code};const P=[c.country,c.region,c.city,c.isp].filter(Boolean).join(" · ");l&&(l.innerHTML=`${B(c.country_code||u.loc||"")} ${K(o)}`),te("ipGeoClaude",P),v=!0}}catch{}if(!v&&u.loc&&(l&&(l.innerHTML=`${B(u.loc)} ${K(o)}`),te("ipGeoClaude",Be[u.loc]||u.loc.toUpperCase())),s.status==="fulfilled"&&s.value.ok){const c=await s.value.json();m.ipapis={is_datacenter:c.is_datacenter,is_vpn:c.is_vpn,is_proxy:c.is_proxy,is_tor:c.is_tor,is_crawler:c.is_crawler,is_abuser:c.is_abuser,is_mobile:c.is_mobile,company:{type:c.company_type,name:c.company_name},abuser_score:c.abuser_score,datacenter_name:c.datacenter_name},m.claudeRisk={ip:o,asn:c.asn,asOrganization:c.asOrganization,country:c.country,countryCode:c.countryCode,region:c.region,city:c.city,isResidential:c.isResidential,isBroadcast:c.isBroadcast,trust_score:c.trust_score,timezone:c.timezone}}})()),await Promise.allSettled(g),!se&&(Ie(),Promise.allSettled([Re(),He(),be()]),Oe(),Pe())}return De(),()=>{se=!0,ve.disconnect(),m.scoreAnimId&&cancelAnimationFrame(m.scoreAnimId),delete _.__setMaskOn,delete _.__clearIPHistory,delete _.__detectClaudeAvail}},[]);const M=_=>{S(_),p.current?.__setMaskOn?.(_)},D=()=>p.current?.__clearIPHistory?.(),q=()=>p.current?.__detectClaudeAvail?.(),R={__html:""};return n.jsx("div",{ref:p,className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:n.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:n.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[n.jsxs("div",{className:"flex items-start justify-between gap-4 mb-8",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:t("ipcheck.page.title")}),n.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base max-w-3xl text-pretty",children:t("ipcheck.page.subtitle")})]}),n.jsxs("label",{className:"shrink-0 inline-flex items-center gap-2.5 cursor-pointer select-none group",children:[n.jsx("div",{className:"text-oai-gray-400 group-hover:text-oai-gray-600 dark:text-oai-gray-500 dark:group-hover:text-oai-gray-300 transition-colors duration-200",children:b?n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4.5 w-4.5 animate-scale-up-fade",children:[n.jsx("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),n.jsx("path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}),n.jsx("path",{d:"M6.61 6.61A13.52 13.52 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}),n.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}):n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4.5 w-4.5 animate-scale-up-fade",children:[n.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),n.jsx("span",{className:"text-xs font-medium text-oai-gray-500 group-hover:text-oai-gray-700 dark:text-oai-gray-400 dark:group-hover:text-oai-gray-200 transition-colors duration-200",children:t("ipcheck.mask.toggle")}),n.jsxs("span",{className:"relative inline-block w-9 h-5",children:[n.jsx("input",{type:"checkbox",checked:b,onChange:_=>M(_.target.checked),className:"peer sr-only"}),n.jsx("span",{className:"absolute inset-0 rounded-full bg-oai-gray-200 dark:bg-oai-gray-800 peer-checked:bg-oai-brand-500 transition-colors duration-200"}),n.jsx("span",{className:"absolute top-0.5 left-0.5 h-4 w-4 rounded-full bg-white shadow-sm transition-transform duration-200 peer-checked:translate-x-4"})]})]})]}),n.jsx("div",{id:"ipv6Warn",className:"hidden mb-4 rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-500/30 dark:bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",children:t("ipcheck.ipv6.warn")}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.jsx(me,{id:"CN",label:t("ipcheck.ip.cn"),icon:null,className:"animate-fade-in-up stagger-1"}),n.jsx(me,{id:"",label:t("ipcheck.ip.cloudflare"),icon:n.jsx("img",{src:`${j}/favicons/cloudflare.webp`,alt:"",className:"h-4 w-4"}),className:"animate-fade-in-up stagger-2"}),n.jsx(me,{id:"Claude",label:t("ipcheck.ip.claude"),icon:n.jsx("img",{src:`${j}/favicons/claude.webp`,alt:"",className:"h-4 w-4"}),statusDot:!0,className:"animate-fade-in-up stagger-3"})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[n.jsx(V,{title:t("ipcheck.trust.title"),subtitle:t("ipcheck.trust.subtitle"),className:"animate-fade-in-up stagger-4",children:n.jsxs("div",{className:"px-1 py-2",children:[n.jsx("div",{className:"flex items-baseline justify-between mb-2 gap-3",children:n.jsx("div",{id:"gaugeScore",className:"flex items-baseline gap-2 min-h-[2.5rem]",dangerouslySetInnerHTML:R})}),n.jsx("div",{id:"gaugeText",className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mb-4 min-h-[1rem]"}),n.jsxs("div",{children:[n.jsxs("div",{className:"relative",children:[n.jsx("div",{className:"h-1.5 rounded-full",style:{background:"linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #10b981 100%)"}}),n.jsx("span",{id:"gaugePointer",className:"absolute top-1/2 -translate-y-1/2 h-3.5 w-3.5 rounded-full bg-white dark:bg-oai-gray-900 border-2 border-oai-gray-300 dark:border-oai-gray-700 shadow-[0_2px_6px_rgba(0,0,0,0.15)] dark:shadow-[0_2px_6px_rgba(0,0,0,0.4)] -translate-x-1/2 transition-[left,border-color] duration-700 ease-out",style:{left:"0%"}})]}),n.jsxs("div",{className:"mt-2 flex justify-between text-[10px] uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 font-medium",children:[n.jsx("span",{children:t("ipcheck.trust.gauge.low")}),n.jsx("span",{className:"tracking-normal",children:"25"}),n.jsx("span",{className:"tracking-normal",children:"50"}),n.jsx("span",{className:"tracking-normal",children:"75"}),n.jsx("span",{children:t("ipcheck.trust.gauge.high")})]})]}),n.jsx("div",{id:"regionWarn",className:"hidden mt-4 rounded-lg border border-red-200 bg-red-50 dark:border-red-500/30 dark:bg-red-500/10 px-3 py-2 text-xs text-red-800 dark:text-red-300"}),n.jsxs("div",{id:"claudeRegionSupportRow",className:"hidden mt-4 pt-4 border-t border-oai-gray-100 dark:border-oai-gray-800 flex items-center justify-between",children:[n.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:t("ipcheck.trust.region_support")}),n.jsx("span",{id:"claudeRegionSupport",className:"text-sm font-medium text-oai-black dark:text-white",dangerouslySetInnerHTML:R})]})]})}),n.jsx(V,{title:t("ipcheck.props.title"),className:"animate-fade-in-up stagger-4",children:n.jsx("div",{id:"propsContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})}),n.jsx(V,{title:t("ipcheck.security.title"),className:"animate-fade-in-up stagger-4",children:n.jsx("div",{id:"securityContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[n.jsx(V,{title:n.jsxs("span",{className:"flex items-center gap-1.5",children:[t("ipcheck.avail.title"),n.jsx(Ze,{text:t("ipcheck.avail.tooltip")})]}),action:n.jsx(Ae,{label:t("ipcheck.avail.refresh"),onClick:q}),className:"animate-fade-in-up stagger-5",children:n.jsx("div",{id:"claudeAvailContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})}),n.jsx(V,{title:t("ipcheck.dns.title"),className:"animate-fade-in-up stagger-5",children:n.jsx("div",{id:"dnsLeakContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})}),n.jsx(V,{title:t("ipcheck.udp.title"),className:"animate-fade-in-up stagger-5",children:n.jsx("div",{id:"udpLeakContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})})]}),n.jsx(V,{title:t("ipcheck.device.title"),className:"animate-fade-in-up stagger-6",children:n.jsx("div",{id:"deviceContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})}),n.jsx(V,{title:t("ipcheck.history.title"),subtitle:t("ipcheck.history.subtitle"),action:n.jsx(Ae,{label:t("ipcheck.history.clear"),onClick:D}),className:"animate-fade-in-up stagger-6",children:n.jsx("div",{id:"ipHistoryContent",dangerouslySetInnerHTML:R})})]})]})})})}function V({title:p,subtitle:b,action:S,children:M,className:D=""}){return n.jsxs("section",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 sm:p-6 transition-colors duration-200 ${D}`,children:[n.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:p}),b?n.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:b}):null]}),S]}),M]})}function Ae({label:p,onClick:b}){return n.jsx("button",{type:"button",onClick:b,className:"shrink-0 inline-flex h-7 items-center px-2.5 rounded-md text-xs font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-200 dark:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:p})}function Ze({text:p}){return n.jsxs("span",{className:"relative inline-flex items-center group",children:[n.jsx("svg",{viewBox:"0 0 16 16",className:"h-3.5 w-3.5 text-oai-gray-400 dark:text-oai-gray-500",fill:"currentColor","aria-hidden":!0,children:n.jsx("path",{d:"M8 1.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13zM7.25 6.75a.75.75 0 0 1 1.5 0V11a.75.75 0 0 1-1.5 0V6.75zM8 4a.85.85 0 1 1 0 1.7A.85.85 0 0 1 8 4z"})}),n.jsx("span",{className:"pointer-events-none absolute left-1/2 top-full z-10 mt-1.5 -translate-x-1/2 w-56 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-2 text-[11px] font-normal text-white opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-relaxed shadow-lg origin-top",children:p})]})}function me({id:p,label:b,icon:S,statusDot:M,className:D=""}){const q=`ipAddr${p}`,R=`ipGeo${p}`;return n.jsxs("article",{id:`ipHero${p}`,className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 sm:p-6 cursor-default transition-colors duration-200 ${D}`,children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] uppercase tracking-wider font-medium text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:[S,n.jsx("span",{children:b}),M?n.jsxs("span",{id:`statusDot${p}`,className:"relative inline-flex h-2 w-2 ml-1.5","aria-hidden":!0,children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-oai-gray-300 dark:bg-oai-gray-600 opacity-75"}),n.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-oai-gray-400 dark:bg-oai-gray-500"})]}):null]}),n.jsx("div",{id:q,className:"text-xl sm:text-2xl font-semibold text-oai-black dark:text-white flex items-center gap-2 min-h-[2rem]",dangerouslySetInnerHTML:{__html:""}}),n.jsx("div",{id:R,className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 truncate min-h-[1rem]"})]})}export{Je as default};

Sorry, the diff of this file is too big to display

import{R as l,j as c,b as h}from"./__vite-browser-external-CHbEWSwX.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};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeaderboardProfileModal-HATS5y64.js","assets/__vite-browser-external-CHbEWSwX.js","assets/__vite-browser-external-Cd947_ni.css","assets/provider-display-BvvK0p2x.js","assets/useCurrency-QqSMR7Ba.js","assets/useTokenFormat-BLfmNxg5.js","assets/terminal-Bwl-eNY6.js","assets/info-DoeeLajS.js","assets/LeaderboardAvatar-BTIhp_Eo.js","assets/AchievementBadge-CkmyCQlm.js","assets/zap-DjGiVr-_.js","assets/flame-DCV1yyCQ.js","assets/AchievementsSection-CLA812Vd.js","assets/format-tokens-BN3gD2gw.js","assets/arrow-up-right-B1yj6nxk.js","assets/link-2-C4RnhbaI.js","assets/check-Dvngccc0.js","assets/DialogTitle-qsUpNlJa.js","assets/useScrollLock-DdUQVKDA.js","assets/CommunityStatsModal-BDgJ6Rdv.js","assets/icons-DhvcZGBX.js","assets/TrendMonitor-C-acyVP7.js","assets/PopoverPopup-BuSDh9-C.js","assets/SelectItemText-Ca7gf5A0.js","assets/DialogDescription-D0X0v38O.js"])))=>i.map(i=>d[i]);
import{k as ma,j as e,R as xa,c as n,b as d,r as c,ar as ua,u as ga,U as ba,e as pa,as as ha,F as fa,at as ya,au as ka,av as wa,aw as se,g as ja,ax as va,x as Na,P as pe,L as _a,ay as Sa,i as Ca,az as La,aA as Ma,a8 as Ie,aB as Aa,_ as Fe,v as Ta}from"./__vite-browser-external-CHbEWSwX.js";import{S as Ea}from"./Select-DE6DMSrS.js";import{u as Pa,C as Ka,a as Ra,b as za,c as Be,D as Ia,d as Ba,S as $a,h as Ua,s as Da,K as Oa,P as Fa}from"./use-ordered-list-XWE9dLyL.js";import{u as Ga}from"./useCurrency-QqSMR7Ba.js";import{u as X}from"./useTokenFormat-BLfmNxg5.js";import{L as Z}from"./LeaderboardAvatar-BTIhp_Eo.js";import{s as Ha,c as Ya,A as Wa,t as Va,b as Ja}from"./AchievementBadge-CkmyCQlm.js";import{u as Za}from"./use-community-stats-C0cLdfhQ.js";import"./SelectItemText-Ca7gf5A0.js";import"./useScrollLock-DdUQVKDA.js";import"./check-Dvngccc0.js";import"./zap-DjGiVr-_.js";import"./flame-DCV1yyCQ.js";const qa=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Xa=ma("arrow-right",qa),Qa=a=>{let{transform:r}=a;return{...r,y:0}};function H(a,{min:r,max:o,fallback:s}){const l=Number(a);if(!Number.isFinite(l))return s;const i=Math.floor(l);return i<r?r:i>o?o:i}function er(a,r){const o=H(r,{min:0,max:1e6,fallback:0}),s=H(a,{min:1,max:Math.max(1,o||1),fallback:1});if(o<=1)return[1];const l=new Set([1,o,s-2,s-1,s,s+1,s+2]),i=Array.from(l).filter(u=>Number.isInteger(u)&&u>=1&&u<=o).sort((u,p)=>u-p),m=[];let b=null;for(const u of i)b!=null&&u-b>1&&m.push(null),m.push(u),b=u;return m}function ar({page:a,totalPages:r}){const o=typeof r=="number"&&Number.isFinite(r)&&r>=0,s=o?H(r,{min:0,max:1e6,fallback:0}):null,l=H(a,{min:1,max:o?Math.max(1,s||1):1e6,fallback:1}),i=l>1,m=o?l<s:!0;return{canPrev:i,canNext:m,safePage:l,safeTotal:s}}function rr({entries:a,me:r,meLabel:o}){const s=Array.isArray(a)?a:[],l=r&&typeof r.rank=="number"?r.rank:null;return!l||s.some(m=>!!m?.is_me)?s:[{rank:l,is_me:!0,is_pinned:!0,user_id:r?.user_id??null,display_name:o,avatar_url:r?.avatar_url??null,github_url:null,is_public:!1,gpt_tokens:r?.gpt_tokens??"0",claude_tokens:r?.claude_tokens??"0",gemini_tokens:r?.gemini_tokens??"0",cursor_tokens:r?.cursor_tokens??"0",opencode_tokens:r?.opencode_tokens??"0",openclaw_tokens:r?.openclaw_tokens??"0",hermes_tokens:r?.hermes_tokens??"0",kiro_tokens:r?.kiro_tokens??"0",copilot_tokens:r?.copilot_tokens??"0",kimi_tokens:r?.kimi_tokens??"0",other_tokens:r?.other_tokens??"0",total_tokens:r?.total_tokens??"0",estimated_cost_usd:r?.estimated_cost_usd??null,badges:Array.isArray(r?.badges)?r.badges:[]},...s]}function tr(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 or=new Set(["/brand-logos/cursor.svg","/brand-logos/kimi.svg","/brand-logos/kiro.svg","/brand-logos/copilot.svg","/brand-logos/hermes.svg"]);function sr({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 ${or.has(a)?"dark:invert":""}`}):null,e.jsx("span",{className:"whitespace-nowrap",children:r})]})}const ne=xa.memo(function({badges:r,max:o=3,className:s=""}){const l=Ha((r||[]).filter(i=>i&&Ya.has(i.id)&&(i.tier||0)>=1)).slice(0,o);return l.length===0?null:e.jsx("span",{className:`pointer-events-none inline-flex shrink-0 items-center ${s}`,children:l.map((i,m)=>e.jsx("span",{title:n("achievements.mini.tooltip",{name:n(Ja(i.id,"name")),tier:n(`achievements.tier.${Va(i.tier)}`)}),style:{zIndex:l.length-m},className:`pointer-events-auto relative inline-flex ${m>0?"-ml-1.5":""}`,children:e.jsx(Wa,{badgeId:i.id,tier:i.tier,size:"xs",className:"rounded-full ring-[1.5px] ring-white dark:ring-oai-gray-950"})},i.id))})}),q=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"kiro_tokens",copyKey:"leaderboard.column.kiro",icon:"/brand-logos/kiro.svg"},{key:"copilot_tokens",copyKey:"leaderboard.column.copilot",icon:"/brand-logos/copilot.svg"},{key:"kimi_tokens",copyKey:"leaderboard.column.kimi",icon:"/brand-logos/kimi.svg"},{key:"opencode_tokens",copyKey:"leaderboard.column.opencode",icon:"/brand-logos/opencode.svg"},{key:"openclaw_tokens",copyKey:"leaderboard.column.openclaw",icon:"/brand-logos/openclaw.svg"},{key:"hermes_tokens",copyKey:"leaderboard.column.hermes",icon:"/brand-logos/hermes.svg"},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:null}],Ge="sticky left-0 z-40 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] bg-white dark:bg-oai-gray-950 px-2.5 sm:px-4 py-4 align-middle",He="sticky left-[55px] sm:left-[71px] z-40 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-3 sm:px-4 py-4 align-middle";function ie(a){return d("sticky left-0 z-30 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] px-2.5 sm:px-4 py-4 whitespace-nowrap",a?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function le(a){return d("sticky left-[55px] sm:left-[71px] z-30 hover:z-50 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 px-3 sm:px-4 py-4 min-w-0",a?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function y({className:a}){return e.jsx("div",{className:d("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",a)})}function nr({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(ie(!1),"!group-hover:bg-transparent"),children:e.jsx(y,{className:"h-4 w-6"})}),e.jsx("td",{className:d(le(!1),"!group-hover:bg-transparent"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(y,{className:"h-8 w-8 min-w-8 rounded-full"}),e.jsx(y,{className:d("h-4",r)})]})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:d("h-4",o)})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:"h-4 w-12"})}),q.map(l=>e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:d("h-4",s)})},l.key))]})}function ir({index:a}){const r=a<3?"w-24":a<8?"w-20":"w-16",o=a%3===0?3:a%3===1?2:1;return e.jsxs("div",{className:"mx-0 my-1 rounded-xl bg-white dark:bg-oai-gray-950 border border-oai-gray-100 dark:border-oai-gray-800/60 px-3.5 py-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(y,{className:"h-4 w-3 shrink-0 rounded"}),e.jsx(y,{className:"h-9 w-9 shrink-0 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(y,{className:d("h-4",r)}),e.jsx(y,{className:"mt-2 h-3.5 w-20"})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx(y,{className:"ml-auto h-3 w-8"}),e.jsx(y,{className:"mt-1.5 ml-auto h-4 w-14"})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-oai-gray-100 pt-2.5 dark:border-oai-gray-800/70",children:Array.from({length:o},(s,l)=>e.jsx(y,{className:"h-5 w-12 rounded-full"},l))})]})}function lr({rows:a=10}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(Ge,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(y,{className:"h-3.5 w-6"})}),e.jsx("th",{className:d(He,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(y,{className:"h-3.5 w-12"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-10"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-14"})}),q.map(r=>e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-12"})},r.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:a},(r,o)=>e.jsx(nr,{index:o},o))})]})}),e.jsx("div",{className:"flex flex-col py-1 sm:hidden",children:Array.from({length:a},(r,o)=>e.jsx(ir,{index:o},o))})]})}function dr({id:a,thClassName:r,children:o}){const{attributes:s,listeners:l,setNodeRef:i,transform:m,transition:b,isDragging:u}=Pa({id:a}),p=Ka.Transform.toString(m)||"";c.useLayoutEffect(()=>{const f=document.querySelectorAll(`td[data-column-key="${a}"]`),h="0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)";return f.forEach(g=>{g.style.transform=p,g.style.transition=b||"",g.style.zIndex=u?"20":"",g.style.position=p?"relative":"",g.style.boxShadow=u?h:""}),()=>{f.forEach(g=>{g.style.transform="",g.style.transition="",g.style.zIndex="",g.style.position="",g.style.boxShadow=""})}},[a,p,b,u]);const j={transform:p,transition:b,position:p?"relative":void 0,zIndex:u?20:void 0,boxShadow:u?"0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)":void 0};return e.jsx("th",{ref:i,style:j,className:d(r,"group/col select-none cursor-grab active:cursor-grabbing touch-none"),...s,...l,children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:d("-mr-1 inline-flex h-4 w-3 shrink-0 items-center justify-center text-oai-gray-400 dark:text-oai-gray-600","opacity-0 transition-opacity duration-150 group-hover/col:opacity-100",u&&"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 cr="tokentracker.leaderboard.columnOrder.v1";function mr(a){return Ra(cr,a)}const xr=50;function ur(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 Ye(a){return typeof a=="string"?a.trim():""}function gr(a){const r=Ye(a);return r?r.toLowerCase()==="anonymous":!0}function br({me:a,totalEntries:r,meLabel:o,onOpenProfile:s,onJumpToMe:l,canJump:i,className:m}){const b=a&&typeof a.rank=="number"?a.rank:null;if(!b)return null;const u=Number(r)||0,p=ur(b,u),j=Ye(a?.display_name),f=!j||gr(j)?o||"You":j,h=a?.user_id||f,g=s||(i?l:null),A=typeof g=="function",_=A?"button":"div",Q=A?{type:"button",onClick:g,"aria-label":n(s?"leaderboard.summary.view_profile":"leaderboard.summary.jump_to_me")}:{};return e.jsxs(_,{...Q,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",A?"border-oai-gray-200 hover:border-oai-brand-400 dark:border-oai-gray-800 dark:hover:border-oai-brand-500/80 bg-oai-gray-50/50 dark:bg-white/[0.02] backdrop-blur-md hover:bg-oai-brand-50/40 dark:hover:bg-oai-brand-950/20 active:scale-[0.97] dark:ring-1 dark:ring-white/[0.04] dark:hover:ring-white/[0.08]":"border-oai-gray-100 dark:border-oai-gray-800/60 bg-oai-gray-50/20 dark:bg-white/[0.01] backdrop-blur-sm dark:ring-1 dark:ring-white/[0.02]",m),children:[e.jsx(Z,{size:"sm",avatarUrl:a?.avatar_url,displayName:f,seed:h}),e.jsx("span",{className:"hidden sm:inline max-w-[120px] truncate text-xs font-semibold text-oai-black dark:text-oai-gray-200 group-hover:text-oai-brand-600 dark:group-hover:text-oai-brand-400 transition-colors",children:f}),e.jsxs("span",{className:"text-xs font-bold tabular-nums text-oai-gray-800 dark:text-white",children:["#",b.toLocaleString()]}),p!=null&&p<=xr&&e.jsx("span",{className:d("hidden sm:inline-flex items-center rounded-full px-2 py-0.5 text-[9px] font-extrabold tracking-wider tabular-nums uppercase transition-colors duration-300 ring-1",p<=10?"bg-amber-500/10 text-amber-600 dark:bg-amber-500/15 dark:text-amber-400 ring-amber-500/20":"bg-oai-brand-100/50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-400 ring-oai-brand-500/10"),children:n("leaderboard.summary.percentile",{p:String(p)})}),A?e.jsx(Xa,{"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 pr=c.lazy(()=>Fe(()=>import("./LeaderboardProfileModal-HATS5y64.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])).then(a=>({default:a.LeaderboardProfileModal}))),hr=c.lazy(()=>Fe(()=>import("./CommunityStatsModal-BDgJ6Rdv.js"),__vite__mapDeps([19,1,2,20,5,21,17,18,4,6,22,23,9,10,11,24])).then(a=>({default:a.CommunityStatsModal}))),de=[10,20,50,100],ce=20,We="tokentracker:leaderboard:pageSize";function fr(){if(typeof window>"u")return ce;try{const a=window.localStorage.getItem(We),r=Number(a);if(de.includes(r))return r}catch{}return ce}function me(a,r,o){const s=Number(a);if(!Number.isFinite(s)||s<=0)return"-";const l=Sa(r),i=r===Ta?s:s*o;return i>=1e3?`${l}${Math.round(i).toLocaleString()}`:i>=10?`${l}${Math.round(i)}`:`${l}${i.toFixed(2)}`}function xe({value:a}){const{formatTokens:r,formatTokensTooltip:o}=X();return e.jsx("span",{title:o(a),children:r(a)})}function yr({communityStats:a,onClick:r}){const{formatTokens:o,formatTokensTooltip:s}=X();return a.status!=="ready"?null:e.jsxs("button",{type:"button",onClick:r,className:"inline-flex min-w-0 max-w-full flex-1 items-center gap-1.5 whitespace-nowrap rounded-xl border border-oai-gray-200 bg-oai-gray-50/50 px-2.5 py-2 text-xs text-oai-gray-500 backdrop-blur-md transition-all duration-300 hover:border-oai-brand-400 hover:bg-oai-brand-50/40 active:scale-[0.97] dark:border-oai-gray-800 dark:bg-white/[0.02] dark:text-oai-gray-400 dark:hover:border-oai-brand-500/80 dark:hover:bg-oai-brand-950/20 sm:h-9 sm:flex-none sm:gap-2.5 sm:rounded-full sm:px-3.5 sm:py-0",title: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:e.jsx("span",{title:s(a.tokenFloor),children:o(a.tokenFloor)})}),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.jsxs("span",{className:"font-semibold text-oai-black dark:text-white tabular-nums",children:[e.jsx("span",{className:"sm:hidden",children:Ca(a.totalEntries)}),e.jsx("span",{className:"hidden sm:inline",children:(Number(a.totalEntries)||0).toLocaleString("en-US")})]}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.community.devs_chip")})]})]})}function $e({entry:a,isMe:r,orderedColumns:o}){const{formatTokens:s,formatTokensTooltip:l}=X(),i=r?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",m=r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900";return o.map(b=>e.jsx("td",{"data-column-key":b.key,title:l(a?.[b.key]),className:d("hidden sm:table-cell px-3 sm:px-4 py-4 whitespace-nowrap text-right tabular-nums",i,m),children:s(a?.[b.key])},b.key))}function kr(a){return a?.key==="gpt_tokens"?"CODEX":a?.key==="claude_tokens"?"CLAUDE":(a?.icon?.split("/").pop()||"").replace(/\.svg$/i,"").toUpperCase()||"OTHER"}const wr={1:"ring-2 ring-amber-400 dark:ring-amber-500/80 shadow-[0_0_8px_rgba(245,158,11,0.25)]",2:"ring-2 ring-slate-350 dark:ring-slate-450 shadow-[0_0_8px_rgba(148,163,184,0.2)]",3:"ring-2 ring-orange-400 dark:ring-orange-500/70 shadow-[0_0_8px_rgba(249,115,22,0.25)]"};function jr({rank:a,placeholder:r}){return a===1?e.jsx("span",{className:"text-base font-extrabold italic text-amber-500 dark:text-amber-400 tracking-tighter",children:"1"}):a===2?e.jsx("span",{className:"text-base font-extrabold italic text-slate-400 dark:text-slate-350 tracking-tighter",children:"2"}):a===3?e.jsx("span",{className:"text-base font-extrabold italic text-orange-500 dark:text-orange-400 tracking-tighter",children:"3"}):e.jsx("span",{className:"text-[13px] font-bold tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:a==null?r:`#${a}`})}function vr({githubUrl:a}){return e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":"GitHub profile",className:"absolute bottom-0 right-0 translate-x-1 translate-y-1 flex h-4.5 w-4.5 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 shadow border border-oai-gray-100 dark:border-oai-gray-800 transition-transform active:scale-110",children:e.jsx(pe,{provider:"GITHUB",size:11})})}function Nr({entry:a,orderedColumns:r}){const{formatTokens:o,formatTokensTooltip:s}=X(),l=r.filter(i=>{const m=Number(a?.[i.key]);return Number.isFinite(m)&&m>0});return l.length===0?null:e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-x-1.5 gap-y-2 border-t border-oai-gray-100/70 pt-3 dark:border-oai-gray-800/60",children:l.map(i=>{const m=n(i.copyKey);return e.jsxs("span",{title:m,"aria-label":`${m}: ${s(a?.[i.key])}`,className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-oai-gray-50/80 dark:bg-oai-gray-900/60 px-2 py-0.5 border border-oai-gray-100/80 dark:border-oai-gray-800/40 text-[10px] font-medium text-oai-gray-600 dark:text-oai-gray-300 transition-colors",children:[e.jsx(pe,{provider:kr(i),size:12,className:"shrink-0 opacity-90"}),e.jsx("span",{className:"tabular-nums",children:o(a?.[i.key])})]},i.key)})})}function _r({entry:a,entryIdx:r,name:o,meLabel:s,currency:l,rate:i,orderedColumns:m,placeholder:b,onOpenProfile:u}){if(a?.is_ellipsis)return e.jsx("div",{"aria-hidden":"true",className:"px-4 py-2 text-center text-xs tracking-[0.4em] text-oai-gray-400 dark:text-oai-gray-600",children:"···"},`mobile-ellipsis-${r}`);const p=!!a?.is_me,j=!p&&ge(a?.display_name),f=typeof a?.user_id=="string"?a.user_id:null,h=!!f,g=p?s:o,A=_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),u(f))};return e.jsxs("div",{role:h?"button":void 0,tabIndex:h?0:void 0,onClick:h?()=>u(f):void 0,onKeyDown:h?A:void 0,"aria-label":h?n("leaderboard.profile_modal.row_aria",{name:g}):void 0,className:d("relative mx-0 my-1 rounded-xl px-3.5 py-3 transition-all duration-200 border shadow-sm select-none",p?"bg-gradient-to-br from-oai-brand-50/70 via-oai-brand-50/20 to-transparent dark:from-oai-brand-950/20 dark:via-oai-brand-950/5 dark:to-transparent border-oai-brand-200/60 dark:border-oai-brand-500/25":j?"bg-white/90 dark:bg-oai-gray-950/90 border-oai-gray-100/70 dark:border-oai-gray-800/40":"bg-white dark:bg-oai-gray-950 border-oai-gray-100 dark:border-oai-gray-800/60",h&&"cursor-pointer hover:border-oai-gray-200 dark:hover:border-oai-gray-700/80 active:scale-[0.985] active:bg-oai-gray-50/60 dark:active:bg-oai-gray-900/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"flex w-5 shrink-0 items-center justify-center",children:e.jsx(jr,{rank:a?.rank,placeholder:b})}),e.jsxs("span",{className:"relative inline-flex shrink-0",children:[e.jsx("span",{className:d("inline-flex rounded-full p-0.5 transition-all duration-300",wr[a?.rank]||"ring-1 ring-oai-gray-200 dark:ring-oai-gray-800/80",j&&"opacity-60 grayscale-[15%]"),children:e.jsx(Z,{size:"md",avatarUrl:a?.avatar_url,displayName:g,seed:be(a,g)})}),a?.github_url&&e.jsx(vr,{githubUrl:a.github_url})]}),e.jsxs("div",{className:"min-w-0 flex-1 pl-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:d("min-w-0 truncate text-sm tracking-tight",p?"font-semibold text-oai-black dark:text-oai-white":j?"font-normal text-oai-gray-400 dark:text-oai-gray-500":"font-medium text-oai-gray-800 dark:text-oai-gray-200"),children:g}),e.jsx(ne,{badges:a?.badges,className:"shrink-0 scale-95"})]}),e.jsxs("div",{className:"mt-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:n("leaderboard.column.est_cost")}),e.jsx("span",{className:d("ml-1 tabular-nums font-medium",j?"text-oai-gray-400/80 dark:text-oai-gray-500/80":"text-oai-gray-600 dark:text-oai-gray-300"),children:me(a?.estimated_cost_usd,l,i)})]})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.08em] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.column.total")}),e.jsx("div",{className:d("mt-0.5 text-sm font-semibold tabular-nums tracking-tight",p?"text-oai-black dark:text-oai-white":j?"text-oai-gray-400 dark:text-oai-gray-500":"text-oai-gray-800 dark:text-oai-gray-200"),children:e.jsx(xe,{value:a?.total_tokens})})]})]}),e.jsx(Nr,{entry:a,orderedColumns:m})]},`mobile-row-${a?.rank}-${g}`)}const Sr={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 Ue({rank:a,placeholder:r}){const o=Sr[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 De(a){if(typeof a!="string")return null;const r=a.trim().toLowerCase();return r==="week"||r==="month"||r==="total"?r:null}function Cr(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 ue(a){return typeof a!="string"?"":a.trim()}function ge(a){const r=ue(a);return r?r.toLowerCase()==="anonymous":!0}function be(a,r){const o=typeof a?.user_id=="string"?a.user_id.trim():"";return o||`${a?.rank??""}:${r}`}function Oe({githubUrl:a}){return e.jsxs("span",{className:"absolute left-1/2 top-full -translate-x-1/2 -translate-y-1/2 inline-flex group/gh",children:[e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":n("leaderboard.github.aria"),className:"flex h-4 w-4 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 transition-transform hover:scale-110",children:e.jsx(pe,{provider:"GITHUB",size:14})}),e.jsxs("span",{role:"tooltip",className:"invisible opacity-0 group-hover/gh:visible group-hover/gh:opacity-100 absolute left-0 bottom-full mb-2 whitespace-nowrap rounded-md bg-oai-black dark:bg-oai-gray-700 px-2.5 py-1.5 text-[11px] leading-relaxed text-white shadow-lg transition-opacity duration-150 z-50 before:content-[''] before:absolute before:inset-x-0 before:top-full before:h-2.5",children:[e.jsx("span",{className:"block",children: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(_a,{to:"/settings",onClick:r=>r.stopPropagation(),className:"text-white underline underline-offset-2 decoration-oai-gray-400 hover:text-oai-brand-300 hover:decoration-oai-brand-300",children:n("leaderboard.github.tooltipSettingsLink")})," ",n("leaderboard.github.tooltipSuffix")]})]})]})}function Fr({auth:a,signedIn:r,sessionSoftExpired:o}){const s=ua(),l=ga(),{openLoginModal:i}=ba(),{signedIn:m,loading:b,user:u}=pa(),{currency:p,rate:j}=Ga(),f=c.useMemo(()=>ha(),[]),h=fa(),g=r&&!o,A=c.useMemo(()=>g&&(typeof a=="function"||typeof a=="string"||a&&typeof a=="object")?a:null,[a,g]),_=g?A:null,Q=g&&ya(_),ee=n("shared.placeholder.short"),Ve=c.useMemo(()=>q.map(t=>t.key),[]),{order:ae,reorder:he}=mr(Ve),fe=c.useMemo(()=>{const t=new Map;for(const x of q)t.set(x.key,x);return t},[]),B=c.useMemo(()=>ae.map(t=>fe.get(t)).filter(Boolean),[ae,fe]),Je=za(Be(Fa,{activationConstraint:{distance:6}}),Be(Oa,{coordinateGetter:Da})),Ze=c.useCallback(t=>{const{active:x,over:w}=t;!w||x.id===w.id||he(String(x.id),String(w.id))},[he]),[re,E]=c.useState(1),[S,qe]=c.useState(fr),[ye,ke]=c.useState(null),[Xe,we]=c.useState(!1),Y=c.useCallback(t=>{typeof t=="string"&&t.trim()&&ke(t.trim())},[]),Qe=c.useCallback(()=>ke(null),[]),ea=c.useCallback(t=>{const x=de.includes(t)?t:ce;qe(x),E(1);try{window.localStorage.setItem(We,String(x))}catch{}},[]),[je,aa]=c.useState(0),[ra,ta]=c.useState(()=>ka()),[ve,Ne]=c.useState(!1),N=c.useMemo(()=>{const t=new URLSearchParams(s?.search||"");return De(t.get("period"))||"total"},[s?.search]),oa=t=>{const x=De(t);if(!x||x===N)return;const w=new URLSearchParams(s?.search||"");w.set("period",x),E(1),l(`${s?.pathname||"/leaderboard"}?${w.toString()}`,{replace:!0})};c.useEffect(()=>{b||h||m||i()},[m,b,h,i]),c.useEffect(()=>{E(1)},[N]);const W=c.useMemo(()=>(H(re,{min:1,max:1e6,fallback:1})-1)*S,[re,S]),R=c.useMemo(()=>h?"mock":b?"unavailable":m?"cloud":r?"local":f?"public":"unavailable",[b,m,f,h,r]),k=c.useMemo(()=>wa({accessMode:R,baseUrl:f,mockEnabled:h,userId:u?.id||null,period:N,pageSize:S,offset:W}),[u?.id,R,f,W,h,S,N]),[$,U]=c.useState(()=>{const t=se(k);return t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!1,error:null,data:null,contextKey:null}});c.useEffect(()=>{if(!f&&!h||!h&&R==="unavailable"){U({loading:!1,error:null,data:null,contextKey:null});return}const t=se(k);let x=!0;return U(t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!0,error:null,data:null,contextKey:null}),(async()=>{const w=await ja({userId:u?.id||null,period:N,limit:S,offset:W});x&&(va(w,{activeContextKey:k,contextKey:k,source:je>0?"manual-refresh":"page-load"}),U({loading:!1,error:null,data:w,contextKey:k}))})().catch(w=>{if(!x)return;const T=Cr(w);U(F=>F.contextKey===k?{...F,loading:!1,error:T}:{loading:!1,error:T,data:null,contextKey:k})}),()=>{x=!1}},[f,R,u?.id,k,W,je,h,N,S]);const te=c.useMemo(()=>$.contextKey===k?null:se(k),[k,$.contextKey]),v=c.useMemo(()=>$.contextKey===k?$:te?{loading:!1,error:null,data:te.data,contextKey:k}:{loading:!!(f||h)&&R!=="unavailable",error:null,data:null,contextKey:k},[R,f,k,$,h,te]),C=v.data,D=C?.total_pages??null,sa=C?.total_entries??0,P=C?.page??re,na=c.useMemo(()=>er(P,D),[P,D]),_e=C?.from||null,Se=C?.to||null,Ce=C?.generated_at||null,Le=Za(),K=C?.me||null,z=n("leaderboard.me_label"),Me=n("leaderboard.anon_label"),Ae=n("leaderboard.period.week"),Te=n("leaderboard.period.month"),Ee=n("leaderboard.period.total"),Pe=N==="month"?Te:N==="total"?Ee:Ae,V=c.useMemo(()=>{const t=Array.isArray(C?.entries)?C.entries:[];return rr({entries:t,me:K,meLabel:z})},[C?.entries,K,z]),I=c.useMemo(()=>tr(K?.rank,S),[K?.rank,S]),ia=I!=null&&I===P,la=c.useCallback(()=>{I!=null&&E(I)},[I]),da=async()=>{Ne(!0);try{La(!0),ta(!0),await Ma(()=>Ie(_));const t=await Ie(_);t&&await Aa({accessToken:t,period:N,source:"leaderboard-enable-sync"}),aa(x=>x+1)}catch(t){console.warn("[tokentracker] sync:",t)}finally{Ne(!1)}},{canPrev:Ke,canNext:Re}=ar({page:P,totalPages:D}),J=Array.isArray(V)&&V.length!==0;let O=null;v.loading&&!J?O=e.jsx(lr,{rows:S}):v.error&&!J?O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v.error})}):J?O=e.jsxs(Ia,{sensors:Je,collisionDetection:Ba,modifiers:[Qa],onDragEnd:Ze,children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-full w-full text-left text-sm sm:min-w-max",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(Ge,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:n("leaderboard.column.rank")}),e.jsx("th",{className:d(He,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children: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($a,{items:ae,strategy:Ua,children:B.map(t=>e.jsx(dr,{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(sr,{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:V.map((t,x)=>{if(t?.is_ellipsis){const M=4+B.length;return e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:M,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-${x}`)}const w=!!t?.is_me,T=typeof t?.user_id=="string"?t.user_id:null,F=ue(t?.display_name),ca=ge(F)?Me:F,L=w?z:ca,G=!!T,ze=G?{role:"button",tabIndex:0,onClick:G?()=>Y(T):void 0,onKeyDown:G?M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),Y(T))}:void 0,"aria-label":n("leaderboard.profile_modal.row_aria",{name:L})}:{};if(w){const M=!!t?.is_pinned;return e.jsxs("tr",{...ze,className:d("bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",M?"border-t border-b border-oai-brand-300/40 dark:border-oai-brand-500/20":"border-y border-oai-brand-300/40 dark:border-oai-brand-500/30",G&&"cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsx("td",{className:d(ie(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400",M&&"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(Ue,{rank:t?.rank,placeholder:ee})}),e.jsx("td",{className:le(!0),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:d("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&"gh-avatar-frame"),children:[e.jsx("span",{className:d("inline-flex rounded-full p-px",t?.github_url&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(Z,{avatarUrl:t?.avatar_url,displayName:L,seed:be(t,L)})}),t?.github_url&&e.jsx(Oe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:L}),e.jsx(ne,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-medium text-oai-black dark:text-oai-white whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",children:e.jsx(xe,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 font-medium text-oai-brand-600 dark:text-oai-brand-400 whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",title:"Based on estimated API pricing, not actual billing",children:me(t?.estimated_cost_usd,p,j)}),e.jsx($e,{entry:t,isMe:!0,orderedColumns:B})]},`row-${t?.rank}-${L}${M?"-pin":""}`)}return e.jsxs("tr",{...ze,className:d("group transition-colors",G&&"cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsx("td",{className:d(ie(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(Ue,{rank:t?.rank,placeholder:ee})}),e.jsx("td",{className:le(!1),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:d("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&"gh-avatar-frame"),children:[e.jsx("span",{className:d("inline-flex rounded-full p-px",t?.github_url&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(Z,{avatarUrl:t?.avatar_url,displayName:L,seed:be(t,L)})}),t?.github_url&&e.jsx(Oe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:L}),e.jsx(ne,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-semibold text-oai-gray-800 dark:text-oai-gray-200 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",children:e.jsx(xe,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",title:"Based on estimated API pricing, not actual billing",children:me(t?.estimated_cost_usd,p,j)}),e.jsx($e,{entry:t,isMe:!1,orderedColumns:B})]},`row-${t?.rank}-${L}`)})})]})}),e.jsx("div",{className:"flex flex-col py-1.5 sm:hidden",children:V.map((t,x)=>{const w=ue(t?.display_name),T=ge(w)?Me:w;return e.jsx(_r,{entry:t,entryIdx:x,name:t?.is_me?z:T,meLabel:z,currency:p,rate:j,orderedColumns:B,placeholder:ee,onOpenProfile:Y},`mobile-${t?.rank??"ellipsis"}-${x}`)})})]}):O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.empty")})});let oe=null;return typeof D=="number"?oe=na.map((t,x)=>t==null?e.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.pagination.ellipsis")},`ellipsis-${x}`):e.jsx("button",{className:d("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",t===P?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white"),onClick:()=>E(t),disabled:v.loading,children:String(t)},`page-${t}`)):oe=e.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.pagination.page_unknown",{page:String(P)})}),e.jsxs("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:[e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-4 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-3.5 sm:mb-8 sm:grid-cols-[minmax(0,1fr)_auto] sm:gap-4",children:[e.jsx("h1",{className:"col-start-1 row-start-1 min-w-0 whitespace-nowrap text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:col-span-2 sm:row-start-1 sm:text-4xl",children:n("leaderboard.title")}),e.jsxs("p",{className:"col-span-2 row-start-2 hidden text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:block sm:row-start-2 sm:text-base",children:[N==="total"?n("leaderboard.range.total"):_e&&Se?n("leaderboard.range",{period:Pe,from:_e,to:Se}):n("leaderboard.range_loading",{period:Pe}),Ce&&e.jsx("span",{className:"ml-2 hidden border-l border-oai-gray-200 pl-2 text-xs text-oai-gray-400 dark:border-oai-gray-800 dark:text-oai-gray-500 sm:inline-block",children:n("leaderboard.generated_at",{ts:Ce})})]}),e.jsx("div",{className:"col-start-2 row-start-1 inline-flex h-9 shrink-0 items-center rounded-full border border-oai-gray-200 p-1 dark:border-oai-gray-800 sm:col-start-1 sm:row-start-3 sm:justify-self-start",children:["week","month","total"].map(t=>{const x=N===t;return e.jsxs("button",{onClick:()=>oa(t),disabled:v.loading,className:d("px-3 sm:px-4 h-7 text-sm font-medium rounded-full flex items-center justify-center transition-colors relative",x?"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"?Ae:t==="month"?Te:Ee}),x&&e.jsx(Na.div,{layoutId:"leaderboard-period-active-bg",className:"absolute inset-0 bg-oai-gray-200 dark:bg-oai-gray-800 rounded-full z-0",transition:{type:"spring",stiffness:380,damping:30}})]},t)})}),e.jsxs("div",{className:"col-span-2 row-start-2 mb-0 flex w-full min-w-0 items-center justify-between sm:justify-end gap-2.5 sm:col-span-1 sm:col-start-2 sm:row-start-3 sm:mb-0 sm:w-auto sm:shrink-0",children:[e.jsx(yr,{communityStats:Le,onClick:()=>we(!0)}),e.jsx(br,{me:K,totalEntries:sa,meLabel:z,onOpenProfile:K?.user_id?()=>Y(K.user_id):void 0,onJumpToMe:la,canJump:I!=null&&!ia&&!v.loading,className:"shrink-0"})]})]}),!r&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.signin_prompt")}),e.jsx("button",{onClick:i,className:"shrink-0 whitespace-nowrap self-start sm:self-auto px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 transition-colors",children:n("leaderboard.signin_button")})]}),g&&Q&&!ra&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.sync_prompt")}),e.jsx("button",{onClick:da,disabled:ve,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:ve?n("leaderboard.sync_button.busy"):n("leaderboard.sync_button.idle")})]}),e.jsxs("div",{className:"sm:rounded-xl sm:border sm:border-oai-gray-200 sm:dark:border-oai-gray-800 sm:overflow-hidden border-none bg-transparent",children:[v.error&&J?e.jsx("div",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-3",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v.error})}):null,O,e.jsxs("div",{className:"flex flex-col gap-3 sm:border-t border-oai-gray-200 px-4 py-3 sm:flex-row sm:items-center sm:justify-end sm:gap-x-4 sm:px-6 dark:border-oai-gray-800 border-none mt-2.5 sm:mt-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:justify-start",children:[e.jsx("label",{htmlFor:"leaderboard-page-size",className:"whitespace-nowrap",children:n("leaderboard.pagination.page_size_label")}),e.jsx(Ea,{id:"leaderboard-page-size",value:S,onValueChange:t=>ea(Number(t)),disabled:v.loading,ariaLabel:n("leaderboard.pagination.page_size_label"),options:de.map(t=>({value:t,label:String(t)})),align:"end",className:"px-3 py-1 text-oai-gray-700 dark:text-oai-gray-300"})]}),e.jsx("div",{className:"hidden h-5 w-px bg-oai-gray-200 dark:bg-oai-gray-800 sm:block","aria-hidden":"true"}),e.jsxs("div",{className:"flex w-full items-center justify-between sm:w-auto sm:justify-end gap-1.5",children:[e.jsx("button",{className:d("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Ke&&!v.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>E(t=>Math.max(1,t-1)),disabled:!Ke||v.loading,children:n("leaderboard.pagination.prev")}),e.jsxs("span",{className:"text-xs font-semibold tabular-nums text-oai-gray-500 dark:text-oai-gray-455 px-2 sm:hidden",children:[P," / ",D||"?"]}),e.jsx("div",{className:"hidden sm:flex items-center gap-1",children:oe}),e.jsx("button",{className:d("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Re&&!v.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>E(t=>t+1),disabled:!Re||v.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(c.Suspense,{fallback:null,children:[e.jsx(pr,{isOpen:!!ye,userId:ye,period:N,accessToken:_,onClose:Qe}),e.jsx(hr,{isOpen:Xe,onClose:()=>we(!1),communityStats:Le})]})]})}export{Fr as LeaderboardPage};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BadgeDetailModal-rPrkKVBY.js","assets/__vite-browser-external-CHbEWSwX.js","assets/__vite-browser-external-Cd947_ni.css","assets/AchievementBadge-CkmyCQlm.js","assets/zap-DjGiVr-_.js","assets/flame-DCV1yyCQ.js","assets/use-transform-DgEhM1tE.js","assets/AchievementsSection-CLA812Vd.js","assets/format-tokens-BN3gD2gw.js","assets/DialogTitle-qsUpNlJa.js","assets/useScrollLock-DdUQVKDA.js"])))=>i.map(i=>d[i]);
import{k as te,e as O,r as h,a6 as se,j as e,c as n,a7 as ie,a8 as oe,a9 as ne,b as c,aa as le,N as de,L as ce,R as W,Q as me,l as xe,ab as ge,P as $,X as pe,i as he,_ as ue,ac as fe,ad as be}from"./__vite-browser-external-CHbEWSwX.js";import{A as ye,f as ke}from"./provider-display-BvvK0p2x.js";import{u as ve}from"./useCurrency-QqSMR7Ba.js";import{u as G}from"./useTokenFormat-BLfmNxg5.js";import{L as X}from"./LeaderboardAvatar-BTIhp_Eo.js";import{H as je,A as Y,s as Ne,c as _e,b as we,t as Ae,h as Se}from"./AchievementBadge-CkmyCQlm.js";import{A as ze}from"./AchievementsSection-CLA812Vd.js";import{A as B}from"./arrow-up-right-B1yj6nxk.js";import{L as Ce}from"./link-2-C4RnhbaI.js";import{C as Me}from"./check-Dvngccc0.js";import{D as Ie,a as Pe,b as De,c as Le,d as Te,e as $e}from"./DialogTitle-qsUpNlJa.js";import"./terminal-Bwl-eNY6.js";import"./info-DoeeLajS.js";import"./zap-DjGiVr-_.js";import"./flame-DCV1yyCQ.js";import"./format-tokens-BN3gD2gw.js";import"./useScrollLock-DdUQVKDA.js";const Be=[["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"}]],Ue=te("code-xml",Be),U="tokentracker_anon_id";let A=null;function R(){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 F(){if(A)return A;try{let a=localStorage.getItem(U);return a||(a=R(),localStorage.setItem(U,a)),A=a,a}catch{return A=R(),A}}function K({userId:a}){const{signedIn:r,getAccessToken:i}=O(),[t,s]=h.useState(!1),[l,x]=h.useState(0),[o,g]=h.useState(!1),[f,b]=h.useState(!1),[S,z]=h.useState(!1),[C,D]=h.useState([]),[j,N]=h.useState(!1),M=h.useRef(0),y=h.useCallback(async()=>{if(r)try{const d=await i();if(d)return{accessToken:d,anonId:F()}}catch{}return{anonId:F()}},[r,i]);h.useEffect(()=>{let d=!1;return a?(g(!1),(async()=>{const m=await y();try{const p=await se({userId:a,...m});if(d)return;x(Number(p?.count)||0),s(!!p?.liked),g(!0)}catch{if(d)return;x(0),s(!1),g(!0)}})(),()=>{d=!0}):(g(!1),()=>{d=!0})},[a,y]);const k=()=>{z(!0),setTimeout(()=>z(!1),450),N(!0),setTimeout(()=>N(!1),500);const d=["#ff4757","#ff6b81","#ffa502","#70a1ff","#2ed573","#a29bfe"],m=["circle","heart"],p=[];for(let u=0;u<12;u++){const v=(u*30+Math.random()*20-10)*(Math.PI/180),I=45+Math.random()*45,V=Math.cos(v)*I,Z=Math.sin(v)*I-(10+Math.random()*15),Q=Math.random()*360-180,J=6+Math.random()*8,ee=d[Math.floor(Math.random()*d.length)],ae=m[Math.floor(Math.random()*m.length)],re=++M.current;p.push({id:re,tx:V,ty:Z,rot:Q,size:J,color:ee,shape:ae})}D(u=>[...u,...p]),setTimeout(()=>{D(u=>u.filter(v=>!p.find(I=>I.id===v.id)))},850)},_=async d=>{b(!0);try{const m=await y(),p=await ie({userId:a,action:d,...m});p&&Number.isFinite(Number(p.count))&&x(Number(p.count)),p&&typeof p.liked=="boolean"&&s(p.liked)}catch{s(m=>!m),x(m=>d==="like"?Math.max(0,m-1):m+1)}finally{b(!1)}},w=d=>{d.stopPropagation(),!(!a||!o||f)&&(t?(s(!1),x(m=>Math.max(0,m-1)),_("unlike")):(s(!0),x(m=>m+1),k(),_("like")))};return e.jsxs("div",{className:"relative inline-flex items-center select-none z-10",children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:`
@keyframes tt-like-pop {
0% { transform: scale(1); }
25% { transform: scale(0.75); }
50% { transform: scale(1.35); }
75% { transform: scale(0.9); }
100% { transform: scale(1); }
}
@keyframes tt-particle-fly {
0% {
transform: translate(0, 0) scale(1) rotate(0deg);
opacity: 1;
}
70% {
opacity: 0.8;
}
100% {
transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rot));
opacity: 0;
}
}
@keyframes tt-num-scroll {
0% { transform: translateY(8px); opacity: 0; }
100% { transform: translateY(0); opacity: 1; }
}
.tt-animate-pop {
animation: tt-like-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.tt-particle {
position: absolute;
top: 50%;
left: 50%;
margin-top: -6px;
margin-left: -6px;
pointer-events: none;
z-index: 50;
}
.tt-num-anim {
animation: tt-num-scroll 0.25s ease-out forwards;
}
`}}),C.map(d=>e.jsx("span",{className:"tt-particle",style:{"--tx":`${d.tx}px`,"--ty":`${d.ty}px`,"--rot":`${d.rot}deg`,width:`${d.size}px`,height:`${d.size}px`,backgroundColor:d.shape==="circle"?d.color:"transparent",borderRadius:d.shape==="circle"?"50%":"0",animation:"tt-particle-fly 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards"},children:d.shape==="heart"&&e.jsx("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:d.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"})})},d.id)),e.jsxs("button",{type:"button",onClick:w,disabled:!o||f,"aria-label":t?n("leaderboard.profile.like.aria_unlike"):n("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:S?"tt-animate-pop":"group-active:scale-90 transition-transform duration-100",children:e.jsx(je,{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"} ${j?"tt-num-anim":""}`,children:o?l:"·"})]})]})}function Re({badge:a,badgeLabel:r,className:i="",...t}){return e.jsxs("div",{className:`relative inline-flex shrink-0 ${i}`,children:[e.jsx(X,{...t}),a?e.jsx("span",{className:"absolute -bottom-1 -right-1 inline-flex rounded-full ring-2 ring-white dark:ring-oai-gray-950",children:e.jsx(Y,{badgeId:a.id,tier:a.tier,size:"sm",label:r})}):null]})}function Fe({badges:a,isOwn:r=!1,onSelect:i,className:t=""}){const s=Ne((Array.isArray(a)?a:[]).filter(l=>l&&_e.has(l.id))).filter(l=>r||(l.tier||0)>=1);return s.length===0?null:e.jsx("div",{className:`flex flex-wrap items-center pr-2.5 ${t}`,children:s.map((l,x)=>{const o=(l.tier||0)>=1,g=n(we(l.id,"name")),f=o?n(`achievements.tier.${Ae(l.tier)}`):n("achievements.modal.locked");return e.jsx("button",{type:"button",onClick:i?()=>i(l):void 0,title:`${g} · ${f}`,"aria-label":n("achievements.badge.aria",{name:g,tier:f}),style:{zIndex:s.length-x},className:"group relative shrink-0 -mr-2.5 rounded-full transition-transform duration-200 ease-out hover:z-30 hover:-translate-y-1 active:scale-95 focus-visible:z-30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60",children:e.jsx(Y,{badgeId:l.id,tier:l.tier,locked:!o,size:"md",className:"rounded-full ring-2 ring-white transition-shadow duration-200 group-hover:shadow-md dark:ring-oai-gray-950"})},l.id)})})}const He=W.lazy(()=>ue(()=>import("./BadgeDetailModal-rPrkKVBY.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])));function Ee(a,r,i){const t=Number(a);return!Number.isFinite(t)||t<0?"—":t>0&&t<.01?`<${r==="USD"?"$":""}0.01`:fe(t,{decimals:2,currency:r,rate:i})}function H(a,r,i){const t=Number(a);if(!Number.isFinite(t)||t<0)return"—";if(t<1e3)return Ee(t,r,i);const s=r==="USD"?t:t*(i||1);return`${r==="USD"?"$":""}${he(s,{decimals:1})}`}function Oe(a){const r=Array.isArray(a)?a:[];if(r.length===0)return null;const i=r.map(s=>({day:s.date,total_tokens:s.total_tokens,models:s.models||null})),t=r[r.length-1]?.date;return ge({dailyRows:i,weeks:52,to:t})}const We=`
@keyframes tt-shimmer {
100% { transform: translateX(100%); }
}
.tt-shimmer-bar {
position: relative;
overflow: hidden;
}
.tt-shimmer-bar::after {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
transform: translateX(-100%);
background-image: linear-gradient(
90deg,
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.02) 20%,
rgba(0, 0, 0, 0.06) 60%,
rgba(0, 0, 0, 0) 100%
);
animation: tt-shimmer 1.6s infinite;
content: '';
}
.dark .tt-shimmer-bar::after {
background-image: linear-gradient(
90deg,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 0.02) 20%,
rgba(255, 255, 255, 0.06) 60%,
rgba(255, 255, 255, 0) 100%
);
}
`;function Ge({variant:a="modal"}){const r="rounded bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar",i=a==="page";return e.jsxs("div",{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:We}}),i?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:c(r,"h-7 w-48")}),e.jsx("div",{className:c(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:c(r,"h-2.5 w-8")}),e.jsx("div",{className:c(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:c(r,"h-4 w-40")}),e.jsx("div",{className:c(r,"h-3 w-56")})]}),e.jsx("div",{className:c(r,"h-4 w-4 shrink-0 mt-1")})]}),e.jsxs("div",{className:c("space-y-6",i?"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,s)=>e.jsxs("div",{children:[e.jsx("div",{className:c(r,"h-6 w-20")}),e.jsx("div",{className:c(r,"mt-2 h-3 w-14")})]},s))}),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,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-3 w-24")}),e.jsx("div",{className:c(r,"h-3 w-44")})]},s))}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(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,s)=>e.jsx("div",{className:"aspect-square rounded-[2px] bg-oai-gray-200/40 dark:bg-oai-gray-800/30 tt-shimmer-bar"},s))})]}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-28 mb-3")}),e.jsx("div",{className:"space-y-2.5",children:Array.from({length:5}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-4 w-4")}),e.jsx("div",{className:c(r,"h-3 w-16")}),e.jsx("div",{className:c(r,"h-[3px] flex-1")}),e.jsx("div",{className:c(r,"h-3 w-12")})]},s))})]})]})]})}function q(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 L({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 P({value:a,label:r,title:i}){return e.jsxs("div",{children:[e.jsx("div",{title:i,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 T({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 Xe({user:a,onClose:r}){const i=q(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(X,{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:c("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:n("leaderboard.profile_modal.rank",{rank:a.rank})}):null]}),i&&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($,{provider:"GITHUB",size:11}),e.jsxs("span",{children:["@",i]})]})]}),a?.user_id&&e.jsx("div",{className:"shrink-0 flex items-center justify-center",children:e.jsx(K,{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":n("leaderboard.profile_modal.close"),children:e.jsx(pe,{size:16,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:rotate-90 group-active:scale-90"})})]})}function Ye({user:a,topBadge:r}){const i=q(a?.github_url),t=Number(a?.rank)||0,s=t===1?"text-amber-500 dark:text-amber-400":t===2?"text-slate-500 dark:text-slate-300":t===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(Re,{badge:r,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 rounded-full"}),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(K,{userId:a.user_id})]}),i?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($,{provider:"GITHUB",size:13}),e.jsxs("span",{children:["@",i]})]}):null]}),t?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:n("leaderboard.profile.hero.rank_label")}),e.jsx("div",{className:c("mt-1.5 text-3xl font-black tabular-nums tracking-tight",s),children:n("leaderboard.profile_modal.rank",{rank:t})})]}):null]})]})}function Ke({data:a}){const{formatTokens:r,formatTokensTooltip:i}=G(),t=Array.isArray(a)?a:[];return t.length===0?e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.profile_modal.providers.none")}):e.jsx("ul",{className:"space-y-2",children:t.map(s=>{const l=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($,{provider:String(s.source).toUpperCase(),size:14})}),e.jsx("span",{className:"w-20 shrink-0 text-oai-gray-700 dark:text-oai-gray-300",children:ke(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:`${(l*100).toFixed(1)}%`}})}),e.jsx("span",{title:i(s.total_tokens),className:"shrink-0 w-14 text-right tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:r(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:[(l*100).toFixed(0),"%"]})]},s.source)})})}function E({icon:a,label:r,value:i}){const[t,s]=h.useState(!1),l=async()=>{await be(i)&&(s(!0),setTimeout(()=>s(!1),1600))};return e.jsxs("button",{type:"button",onClick:l,className:c("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(Me,{size:13,strokeWidth:2,"aria-hidden":!0}):e.jsx(a,{size:13,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t?n("leaderboard.profile_modal.badge.copied"):r})]})}function qe({data:a,currency:r,rate:i,onClose:t,variant:s="modal"}){const{formatTokens:l,formatTokensTooltip:x}=G(),{user:o,totals:g,streak:f,best_day:b,models:S,by_provider:z,heatmap:C,period:D}=a,j=s==="page",N=h.useMemo(()=>Oe(C),[C]),M=S?.favorite?.model_name,y=Number(S?.count)||0,k=Array.isArray(a.badges)?a.badges:[],[_,w]=h.useState(null),d=O(),m=!!(d?.user?.id&&o?.user_id&&d.user.id===o.user_id),p=o?.user_id?`https://www.tokentracker.cc/u/${o.user_id}`:null,u=o?.user_id?`[![My AI coding usage](${le()}/functions/tokentracker-embed-svg?user_id=${o.user_id}&theme=dark)](${p}?ref=readme)`:null;return e.jsxs(e.Fragment,{children:[j?e.jsx(Ye,{user:o,topBadge:Se(k)}):e.jsx(Xe,{user:o,onClose:t}),e.jsxs("div",{className:c("space-y-6",j?"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(P,{value:l(g?.total_tokens),title:x(g?.total_tokens),label:n("leaderboard.profile_modal.stat.total_tokens")}),e.jsx(P,{value:H(g?.estimated_cost_usd,r,i),label:n("leaderboard.profile_modal.stat.total_cost")}),e.jsx(P,{value:String(g?.active_days??0),label:n("leaderboard.profile_modal.stat.active_days")}),e.jsx(P,{value:H(g?.avg_per_day_usd,r,i),label:n("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(T,{label:n("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:n("leaderboard.profile_modal.streak.days",{count:f?.current_days??0})}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["(max ",f?.longest_days??0,")"]})]}),e.jsx(T,{label:n("leaderboard.profile_modal.best_day.title"),children:b?e.jsxs(e.Fragment,{children:[e.jsx("span",{title:x(b.total_tokens),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:l(b.total_tokens)}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["on ",b.date]})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:n("leaderboard.profile_modal.best_day.none")})}),e.jsx(T,{label:n("leaderboard.profile_modal.models.favorite"),children:M?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:M}),y>1&&e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:n("leaderboard.profile_modal.models.count",{count:y})})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:n("leaderboard.profile_modal.models.none")})})]}),(m||k.some(v=>(v?.tier||0)>=1))&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(L,{children:n("achievements.section.title")}),j?e.jsx(ze,{achievements:k,isOwn:m&&!!a.badges_include_unearned,scope:"cloud",onSelect:w}):e.jsx(Fe,{badges:k,isOwn:m&&!!a.badges_include_unearned,onSelect:w})]}),N&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(L,{children:n("leaderboard.profile_modal.heatmap.title")}),e.jsx("div",{className:"min-w-0",children:e.jsx(ye,{heatmap:N,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(L,{children:n("leaderboard.profile_modal.providers.title")}),e.jsx(Ke,{data:z})]}),o?.user_id&&(t||m)&&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&&(de()?e.jsxs("a",{href:p,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:n("leaderboard.profile_modal.view_full")}),e.jsx(B,{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(ce,{to:`/u/${o.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:n("leaderboard.profile_modal.view_full")}),e.jsx(B,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})),m&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{icon:Ce,label:n("leaderboard.profile_modal.badge.copy_url"),value:p}),e.jsx(E,{icon:Ue,label:n("leaderboard.profile_modal.badge.copy"),value:u})]})]})]}),_&&e.jsx(W.Suspense,{fallback:null,children:e.jsx(He,{badge:_,onClose:()=>w(null)})})]})}function Ve({userId:a,period:r,accessToken:i,enabled:t=!0}){const[s,l]=h.useState({loading:!1,error:null,data:null});return h.useEffect(()=>{if(!t||!a)return;let x=!0;return l({loading:!0,error:null,data:null}),(async()=>{try{const o=i?await oe(i):null;if(!x)return;const g=await ne({accessToken:o,userId:a,period:r||"week"});if(!x)return;l({loading:!1,error:null,data:g})}catch(o){if(!x)return;o?.status===404?l({loading:!1,error:null,data:null}):l({loading:!1,error:o?.message||String(o),data:null})}})(),()=>{x=!1}},[t,a,r,i]),s}function pa({isOpen:a,onClose:r,userId:i,period:t,accessToken:s}){const{currency:l,rate:x}=ve(),o=Ve({userId:i,period:t,accessToken:s,enabled:a});return e.jsx(Ie,{open:a,onOpenChange:g=>{g||r?.()},children:e.jsxs(Pe,{children:[e.jsx(De,{className:"cost-modal-backdrop"}),e.jsx(Le,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(Te,{className:c("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($e,{render:e.jsx("h2",{className:"sr-only"}),children:o.data?.user?.display_name||n("leaderboard.profile_modal.loading")}),o.loading&&e.jsx(Ge,{}),!o.loading&&o.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:n("leaderboard.profile_modal.error")})}),!o.loading&&!o.error&&!o.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:n("leaderboard.profile_modal.empty")})}),!o.loading&&!o.error&&o.data&&e.jsx(me,{mode:xe.COMPACT,children:e.jsx(qe,{data:o.data,currency:l,rate:x,onClose:r})})]})})]})})}export{pa as LeaderboardProfileModal,qe as ProfileContent,Ge as ProfileSkeleton,Ve as useLeaderboardProfileData};
import{r as _,j as p,S as xe,U as ge,e as ve,N as be,L as Tt,V as we,c as Y,W as ye}from"./__vite-browser-external-CHbEWSwX.js";import{u as ke}from"./useCurrency-QqSMR7Ba.js";import{H as Me}from"./HeaderGithubStar-Er3o6s3b.js";import{useLeaderboardProfileData as _e,ProfileSkeleton as Ce,ProfileContent as Se}from"./LeaderboardProfileModal-HATS5y64.js";import{D as Te}from"./download-HHcFs0Ff.js";import"./provider-display-BvvK0p2x.js";import"./useTokenFormat-BLfmNxg5.js";import"./terminal-Bwl-eNY6.js";import"./info-DoeeLajS.js";import"./LeaderboardAvatar-BTIhp_Eo.js";import"./AchievementBadge-CkmyCQlm.js";import"./zap-DjGiVr-_.js";import"./flame-DCV1yyCQ.js";import"./AchievementsSection-CLA812Vd.js";import"./format-tokens-BN3gD2gw.js";import"./arrow-up-right-B1yj6nxk.js";import"./link-2-C4RnhbaI.js";import"./check-Dvngccc0.js";import"./DialogTitle-qsUpNlJa.js";import"./useScrollLock-DdUQVKDA.js";function $e(t){let e=t.replace("#","");return e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255]}function Re(t,e,a){t/=255,e/=255,a/=255;const r=Math.max(t,e,a),o=Math.min(t,e,a),n=r-o;let i=0;const u=r===0?0:n/r;return n!==0&&(r===t?i=((e-a)/n+6)%6:r===e?i=(a-t)/n+2:i=(t-e)/n+4,i/=6),[i,u,r]}function Fe(t,e,a){const r=Math.floor(t*6),o=t*6-r,n=a*(1-e),i=a*(1-o*e),u=a*(1-(1-o)*e);let l=0,c=0,h=0;switch(r%6){case 0:l=a,c=u,h=n;break;case 1:l=i,c=a,h=n;break;case 2:l=n,c=a,h=u;break;case 3:l=n,c=i,h=a;break;case 4:l=u,c=n,h=a;break;case 5:l=a,c=n,h=i;break}return[Math.round(l*255),Math.round(c*255),Math.round(h*255)]}const Ie=66,Oe=66,Pe=1500,Ae=1,$t=16,je=16,Ee=8,Le=96,Ne=2,We={name:"chromatic",modes:{dark:{colors:["#000000","#aae8ff","#c5fe9e","#f7888d","#0d0d0d","#fffdc3","#007cff"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:1.6,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.26,vigOpacity:.6,shaderOpacity:1},light:{colors:["#ffffff","#ffffff","#ffffff","#ffb3b3","#adadad","#f5ff70","#007cff"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.24,vigOpacity:.16,shaderOpacity:1}}},Be={name:"silver",modes:{dark:{colors:["#000000","#dedede","#747270","#e5e5e5","#0d0d0d","#ffffff","#e6e6e6"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.26,vigOpacity:.6,shaderOpacity:.88},light:{colors:["#f6f6f6","#ffffff","#ffffff","#f7f7f7","#c9c9c9","#d0d0d0","#d1d1d1"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.2,vigOpacity:.26,shaderOpacity:1}}},ze={name:"gold",modes:{dark:{colors:["#000000","#ffffff","#ffffff","#f7d488","#0d0d0d","#fffdc3","#ffffff"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.26,vigOpacity:.6,shaderOpacity:.92},light:{colors:["#fff8e1","#fffbe0","#ffffff","#fff6d6","#d2c7a7","#dcd2bc","#f9f7e5"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.22,vigOpacity:.24,shaderOpacity:1}}},Xt={chromatic:We,silver:Be,gold:ze},He=`
attribute vec2 a_position;
void main() { gl_Position = vec4(a_position, 0.0, 1.0); }
`,Ge=`
precision highp float;
uniform vec2 u_resolution;
uniform float u_time;
uniform vec3 u_color1, u_color2, u_color3, u_color4, u_color5, u_color6, u_color7;
uniform float u_alpha1, u_alpha2, u_alpha3, u_alpha4, u_alpha5, u_alpha6, u_alpha7;
uniform float u_intensity, u_scale, u_direction;
uniform float u_softness, u_distortion, u_complexity, u_shape;
uniform float u_vignette, u_vigOpacity, u_blur, u_shaderOpacity;
vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec2 mod289v2(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec3 permute(vec3 x) { return mod289((x * 34.0 + 1.0) * x); }
float snoise(vec2 v) {
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
-0.577350269189626, 0.024390243902439);
vec2 i = floor(v + dot(v, C.yy));
vec2 x0 = v - i + dot(i, C.xx);
vec2 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
vec4 x12 = x0.xyxy + C.xxzz;
x12.xy -= i1;
i = mod289v2(i);
vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));
vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);
m = m * m; m = m * m;
vec3 x_ = 2.0 * fract(p * C.www) - 1.0;
vec3 h = abs(x_) - 0.5;
vec3 ox = floor(x_ + 0.5);
vec3 a0 = x_ - ox;
m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
vec3 g;
g.x = a0.x * x0.x + h.x * x0.y;
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
return 130.0 * dot(m, g);
}
float fbm(vec2 p, float oct) {
float val = 0.0, amp = 0.5;
int n = int(oct);
for (int i = 0; i < 7; i++) {
if (i >= n) break;
val += amp * snoise(p);
p *= 2.0;
amp *= 0.5;
}
return val;
}
float nfbm(vec2 p) { return fbm(p, 3.0 + u_complexity * 4.0); }
/* 5-stop palette used by effect 1 (Plasma) — direct port of \`palette\` from
* the canonical engine. Stops at t = 0, 0.25, 0.5, 0.75, 1.0. */
vec3 palette(float t) {
t = clamp(t, 0.0, 1.0);
t = t * t * (3.0 - 2.0 * t);
float k = 64.0;
float w1 = u_alpha1 * exp(-k * t * t);
float w2 = u_alpha2 * exp(-k * (t - 0.25) * (t - 0.25));
float w3 = u_alpha3 * exp(-k * (t - 0.5) * (t - 0.5));
float w4 = u_alpha4 * exp(-k * (t - 0.75) * (t - 0.75));
float w5 = u_alpha5 * exp(-k * (t - 1.0) * (t - 1.0));
float total = w1 + w2 + w3 + w4 + w5 + 0.0001;
return (u_color1 * w1 + u_color2 * w2 + u_color3 * w3 +
u_color4 * w4 + u_color5 * w5) / total;
}
/* Per-pixel alpha that re-introduces transparency when the user dials any
* palette stop's alpha below 1. Same \`paletteAlpha\` from the canonical
* engine. With every preset shipping all-1 alphas, this returns ~1 for every
* pixel — but mirroring it keeps custom-preset behaviour identical. */
float paletteAlpha(float t) {
t = clamp(t, 0.0, 1.0);
t = t * t * (3.0 - 2.0 * t);
float k = 64.0;
float w1 = u_alpha1 * exp(-k * t * t);
float w2 = u_alpha2 * exp(-k * (t - 0.25) * (t - 0.25));
float w3 = u_alpha3 * exp(-k * (t - 0.5) * (t - 0.5));
float w4 = u_alpha4 * exp(-k * (t - 0.75) * (t - 0.75));
float w5 = u_alpha5 * exp(-k * (t - 1.0) * (t - 1.0));
float totalW = w1 + w2 + w3 + w4 + w5 + 0.0001;
float rawW = exp(-k * t * t)
+ exp(-k * (t - 0.25) * (t - 0.25))
+ exp(-k * (t - 0.5) * (t - 0.5))
+ exp(-k * (t - 0.75) * (t - 0.75))
+ exp(-k * (t - 1.0) * (t - 1.0))
+ 0.0001;
return totalW / rawW;
}
vec2 warp(vec2 p, float t) {
float str = u_distortion * 2.0;
return vec2(
nfbm(p + vec2(t * 0.1, 0.0)),
nfbm(p + vec2(0.0, t * 0.12) + 5.0)
) * str;
}
/* Plasma: four sine bands warped by an FBM field, mapped through the
* 5-stop palette. Identical to effect 1 in the canonical engine. */
vec3 computeEffect(vec2 uv, float aspect, float t, float dist, float cpx) {
vec2 p = (uv - 0.5) * u_scale;
p.x *= aspect;
p += vec2(cos(u_direction), sin(u_direction)) * t * 0.15;
float freq = 3.0 + cpx * 8.0;
float val = 0.0;
val += sin(p.x * freq + t);
val += sin(p.y * freq + t * 1.3);
val += sin((p.x + p.y) * freq * 0.7 + t * 0.7);
val += sin(length(p) * freq * 0.8 - t * 1.5);
vec2 w = warp(p, t);
val += (w.x + w.y) * dist;
val = val * 0.2 * u_intensity + 0.5;
return palette(clamp(val, 0.0, 1.0));
}
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution;
float aspect = u_resolution.x / u_resolution.y;
float t = u_time; // JS already multiplied u_time by preset.speed.
float dist = u_distortion;
float cpx = u_complexity;
/* 5-tap cross blur (center + cardinal offsets). The chromatic/silver/gold
* presets all ship with blur=1 so this path is always active. 5 taps
* instead of the canonical engine's 9 saves ~44% fragment work; the
* perceptual difference is nil because the output is already soft from
* the plasma's low spatial frequency and CSS blur on reflections. */
vec3 col;
if (u_blur < 0.01) {
col = computeEffect(uv, aspect, t, dist, cpx);
} else {
float r = u_blur * 0.02;
col = computeEffect(uv, aspect, t, dist, cpx) * 0.4;
col += computeEffect(uv + vec2( r, 0.0), aspect, t, dist, cpx) * 0.15;
col += computeEffect(uv + vec2(-r, 0.0), aspect, t, dist, cpx) * 0.15;
col += computeEffect(uv + vec2(0.0, r), aspect, t, dist, cpx) * 0.15;
col += computeEffect(uv + vec2(0.0, -r), aspect, t, dist, cpx) * 0.15;
}
/* Gamma punch — adds the contrast pop that defines the chromatic
* highlights. From the canonical engine: \`col = pow(col, vec3(1.3))\`. */
col = pow(col, vec3(1.3));
/* Vignette — soft edge darkening so corners read as recessed. The 40-px
* scale at the bottom of the formula is hard-coded in the canonical
* engine; we keep it for visual parity. */
float edgeDist = min(min(uv.x, 1.0 - uv.x), min(uv.y, 1.0 - uv.y));
float vigPx = 40.0 / min(u_resolution.x, u_resolution.y);
float vigRange = vigPx * (1.0 + u_vignette * 3.0);
float vig = edgeDist * edgeDist / (vigRange * vigRange);
vig = smoothstep(0.0, 1.0, vig);
col *= mix(1.0, vig, u_vignette * u_vigOpacity);
/* Per-pixel alpha. With all-1 alphas the formula collapses to ~1 but the
* computation matches the canonical engine so custom presets behave the
* same. */
float colorAlpha = (u_alpha1 + u_alpha2 + u_alpha3 + u_alpha4 + u_alpha5) / 5.0;
if (colorAlpha < 0.999) {
vec3 c1d = col - u_color1, c2d = col - u_color2, c3d = col - u_color3,
c4d = col - u_color4, c5d = col - u_color5;
float prox1 = exp(-8.0 * dot(c1d, c1d));
float prox2 = exp(-8.0 * dot(c2d, c2d));
float prox3 = exp(-8.0 * dot(c3d, c3d));
float prox4 = exp(-8.0 * dot(c4d, c4d));
float prox5 = exp(-8.0 * dot(c5d, c5d));
float pTotal = prox1 + prox2 + prox3 + prox4 + prox5 + 0.0001;
colorAlpha = (prox1 * u_alpha1 + prox2 * u_alpha2 + prox3 * u_alpha3 +
prox4 * u_alpha4 + prox5 * u_alpha5) / pTotal;
}
float alpha = colorAlpha;
/* Touch the unused-at-effect-1 uniforms so GL drivers that complain about
* declared-but-unread uniforms (some Mali / Adreno builds do) keep them
* live. The contribution is provably zero. */
alpha += 0.0 * (u_softness + u_shape +
u_alpha6 + u_alpha7 +
u_color6.x + u_color7.x);
gl_FragColor = vec4(col, alpha * u_shaderOpacity);
}
`;function Rt(t,e,a){const r=t.createShader(e);if(!r)throw new Error("metal-fx: gl.createShader returned null");if(t.shaderSource(r,a),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS)){const o=t.getShaderInfoLog(r);throw t.deleteShader(r),new Error(`metal-fx: shader compile failed: ${o??"(no info log)"}`)}return r}function De(t,e,a){const r=t.createProgram();if(!r)throw new Error("metal-fx: gl.createProgram returned null");if(t.attachShader(r,e),t.attachShader(r,a),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS)){const o=t.getProgramInfoLog(r);throw t.deleteProgram(r),new Error(`metal-fx: program link failed: ${o??"(no info log)"}`)}return r}const Yt=140,Kt=40,Zt=1.6,Jt=1.3;let s=null,bt=null;function Ue(t){bt=t}const qe=["u_resolution","u_time","u_color1","u_color2","u_color3","u_color4","u_color5","u_color6","u_color7","u_alpha1","u_alpha2","u_alpha3","u_alpha4","u_alpha5","u_alpha6","u_alpha7","u_intensity","u_scale","u_direction","u_softness","u_distortion","u_complexity","u_shape","u_vignette","u_vigOpacity","u_blur","u_shaderOpacity"];function Ft(t){t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA);const e=Rt(t,t.VERTEX_SHADER,He),a=Rt(t,t.FRAGMENT_SHADER,Ge),r=De(t,e,a);t.useProgram(r);const o=t.createBuffer();if(!o)throw new Error("metal-fx: gl.createBuffer returned null");t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),t.STATIC_DRAW);const n=t.getAttribLocation(r,"a_position");t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0);const i={};for(const u of qe)i[u]=t.getUniformLocation(r,u);return{program:r,buffer:o,uniforms:i}}function te(){if(s)return s;const t=Math.min(Ne,typeof window<"u"&&window.devicePixelRatio||1),e=Math.round(Le*t),a=typeof OffscreenCanvas<"u";let r,o;if(a)r=new OffscreenCanvas(e,e),o=r.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,antialias:!1});else{const h=document.createElement("canvas");h.width=e,h.height=e,o=h.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,antialias:!1,preserveDrawingBuffer:!0})??h.getContext("experimental-webgl"),r=h}if(!o)throw new Error("metal-fx: WebGL not supported");const{program:n,buffer:i,uniforms:u}=Ft(o),l=h=>{h.preventDefault(),s&&(s.contextLost=!0)},c=()=>{if(!s)return;const h=Ft(s.gl);s.program=h.program,s.buffer=h.buffer,s.uniforms=h.uniforms,s.presetDirty=!0,s.contextLost=!1,bt?.()};return r.addEventListener("webglcontextlost",l,!1),r.addEventListener("webglcontextrestored",c,!1),s={glCanvas:r,gl:o,program:n,buffer:i,uniforms:u,preset:Xt.chromatic.modes.dark,presetDirty:!0,contextLost:!1,useOffscreen:a,frameBitmap:null,startMs:performance.now(),pausedMs:0,pausedAtMs:null,rafId:0,dpr:t,instances:new Set,frameCount:0,glowQueue:[],glowIdx:0,glowSkip:0,glowPixels:new Uint8Array(e*e*4),glowPixelsW:e,glowPixelsH:e},s}function Ve(){var t;if(!s)return;const{gl:e,program:a,buffer:r,frameBitmap:o}=s;try{o?.close(),e.deleteBuffer(r),e.deleteProgram(a),(t=e.getExtension("WEBGL_lose_context"))==null||t.loseContext()}catch{}s=null}let It=0;function dt(){if(!s)return;const t=performance.now();if(t-It<Pe)return;It=t;const{gl:e,glCanvas:a}=s,r=a.width,o=a.height;(s.glowPixelsW!==r||s.glowPixelsH!==o)&&(s.glowPixelsW=r,s.glowPixelsH=o,s.glowPixels=new Uint8Array(r*o*4)),e.readPixels(0,0,r,o,e.RGBA,e.UNSIGNED_BYTE,s.glowPixels)}const K={bx:0,by:0};function kt(t,e,a){if(!s)return K.bx=0,K.by=0,K;const{glCanvas:r}=s,o=r.width,n=r.height,i=t.dpr,u=t.cssWidth*i,l=t.cssHeight*i,c=Yt*i,h=Kt*i;let f=u*(o/c)/t.shaderScale,d=l*(n/h)/t.shaderScale;f>o&&(f=o),d>n&&(d=n);const g=(o-f)/2,x=(n-d)/2,m=g+e/t.cssWidth*f,F=x+a/t.cssHeight*d;return K.bx=Math.round(m),K.by=Math.round(n-1-F),K}const G={r:0,g:0,b:0,lum:0,count:0};function ee(t,e,a,r,o,n){const i=Math.max(1,n|0),u=Math.max(0,r-i),l=Math.min(e,r+i+1),c=Math.max(0,o-i),h=Math.min(a,o+i+1);G.r=0,G.g=0,G.b=0,G.lum=0,G.count=0;for(let f=c;f<h;f++){const d=f*e;for(let g=u;g<l;g++){const x=(d+g)*4;G.r+=t[x],G.g+=t[x+1],G.b+=t[x+2],G.lum+=(.2126*t[x]+.7152*t[x+1]+.0722*t[x+2])/255,G.count++}}return G}const R={r:255,g:255,b:255};function Ot(t,e,a,r){if(!s)return 0;dt();const o=kt(t,e,a),n=ee(s.glowPixels,s.glowPixelsW,s.glowPixelsH,o.bx,o.by,r);return n.count>0?n.lum/n.count:0}function Qe(t,e,a,r){if(!s)return R.r=255,R.g=255,R.b=255,R;dt();const o=kt(t,e,a),n=ee(s.glowPixels,s.glowPixelsW,s.glowPixelsH,o.bx,o.by,r);return n.count===0?(R.r=255,R.g=255,R.b=255,R):(R.r=n.r/n.count,R.g=n.g/n.count,R.b=n.b/n.count,R)}function Xe(t,e,a,r){if(!s)return R.r=255,R.g=255,R.b=255,R;dt();const o=kt(t,e,a),{glowPixels:n,glowPixelsW:i,glowPixelsH:u}=s,l=Math.max(1,r|0),c=Math.max(0,o.bx-l),h=Math.min(i,o.bx+l+1),f=Math.max(0,o.by-l),d=Math.min(u,o.by+l+1);let g=-1;R.r=255,R.g=255,R.b=255;for(let x=f;x<d;x++){const m=x*i;for(let F=c;F<h;F++){const b=(m+F)*4,P=n[b],j=n[b+1],L=n[b+2],C=Math.max(P,j,L),E=Math.min(P,j,L),z=(C>0?(C-E)/C:0)*(.35+.65*(C/255));z>g&&(g=z,R.r=P,R.g=j,R.b=L)}}return R}Ue(()=>{s&&s.instances.size>0&&s.pausedAtMs===null&&nt()});typeof document<"u"&&document.addEventListener("visibilitychange",()=>{!s||s.pausedAtMs!==null||s.contextLost||(document.hidden?oe():s.instances.size>0&&nt())});function Ye(t){const e=te(),a=t.hostCanvas.getContext("2d",{alpha:!0});if(!a)throw new Error("metal-fx: canvas 2D context unavailable");const r=t.scale??1,o={canvas:t.hostCanvas,ctx:a,cssWidth:t.cssWidth,cssHeight:t.cssHeight,cornerRadius:t.cornerRadius,kind:t.kind,ringCssPx:t.ringCssPx??(t.kind==="circle"?2:1)*r,shaderScale:t.shaderScale??(t.kind==="circle"?Jt:Zt)*r,opacityMul:t.opacityMul??1,visible:!0,paused:t.paused??!1,everCopied:!1,dpr:typeof window<"u"&&window.devicePixelRatio||1,scale:r,onAfterFrame:t.onAfterFrame,onFirstCopy:t.onFirstCopy};return ae(o),e.instances.add(o),e.rafId===0&&e.pausedAtMs===null&&nt(),o}function Ke(t){if(!s)return;s.instances.delete(t);const e=s.glowQueue.indexOf(t);e!==-1&&s.glowQueue.splice(e,1),s.instances.size===0&&(oe(),Ve())}function Ze(t){s&&(s.glowQueue.includes(t)||s.glowQueue.push(t))}function Je(t){if(!s)return;const e=s.glowQueue.indexOf(t);e!==-1&&s.glowQueue.splice(e,1)}function rt(t,e){let a=!1;e.cssWidth!==void 0&&e.cssWidth!==t.cssWidth&&(t.cssWidth=e.cssWidth,a=!0),e.cssHeight!==void 0&&e.cssHeight!==t.cssHeight&&(t.cssHeight=e.cssHeight,a=!0),e.cornerRadius!==void 0&&(t.cornerRadius=e.cornerRadius),e.scale!==void 0&&(t.scale=e.scale),e.kind!==void 0&&e.kind!==t.kind&&(t.kind=e.kind,e.shaderScale===void 0&&(t.shaderScale=(e.kind==="circle"?Jt:Zt)*t.scale),e.ringCssPx===void 0&&(t.ringCssPx=(e.kind==="circle"?2:1)*t.scale)),e.shaderScale!==void 0&&(t.shaderScale=e.shaderScale),e.ringCssPx!==void 0&&(t.ringCssPx=e.ringCssPx),e.opacityMul!==void 0&&(t.opacityMul=e.opacityMul),e.paused!==void 0&&e.paused!==t.paused&&(t.paused=e.paused,!e.paused&&s&&s.rafId===0&&s.pausedAtMs===null&&!s.contextLost&&nt()),a&&ae(t)}function ta(t,e){t.visible=e,e&&s&&s.rafId===0&&s.pausedAtMs===null&&!s.contextLost&&nt()}function ea(t,e){const a=te();a.preset=Xt[t].modes[e],a.presetDirty=!0}let wt=null;function aa(t){wt=t}function ae(t){t.dpr=typeof window<"u"&&window.devicePixelRatio||1;const e=Math.max(1,Math.round(t.cssWidth*t.dpr)),a=Math.max(1,Math.round(t.cssHeight*t.dpr));t.canvas.width!==e&&(t.canvas.width=e),t.canvas.height!==a&&(t.canvas.height=a)}function ra(t){const{ctx:e,dpr:a,canvas:r}=t,o=t.ringCssPx*a,n=r.width,i=r.height,u=Math.max(0,(t.cornerRadius-t.ringCssPx)*a);e.save(),e.globalCompositeOperation="destination-out",e.fillStyle="#000",e.beginPath(),e.roundRect(o,o,n-2*o,i-2*o,u),e.fill(),e.restore()}function oa(t){var e;if(!s)return;const a=s.frameBitmap??s.glCanvas,r=t.dpr,o=t.canvas.width,n=t.canvas.height;if(o<1||n<1)return;const i=s.glCanvas.width,u=s.glCanvas.height,l=Yt*r,c=Kt*r;let h=o*(i/l)/t.shaderScale,f=n*(u/c)/t.shaderScale;h>i&&(h=i),f>u&&(f=u);const d=Math.max(0,(i-h)/2),g=Math.max(0,(u-f)/2);if(t.ctx.clearRect(0,0,o,n),t.opacityMul<1&&(t.ctx.globalAlpha=t.opacityMul),t.ctx.drawImage(a,d,g,h,f,0,0,o,n),t.opacityMul<1&&(t.ctx.globalAlpha=1),ra(t),t.onFirstCopy){const x=t.onFirstCopy;t.onFirstCopy=void 0,x()}(e=t.onAfterFrame)==null||e.call(t)}function na(){if(!s)return;const{gl:t,uniforms:e,preset:a,glCanvas:r}=s;e.u_resolution&&t.uniform2f(e.u_resolution,r.width,r.height);for(let o=0;o<7;o++){const n=e[`u_color${o+1}`];if(n){const[u,l,c]=$e(a.colors[o]);t.uniform3f(n,u,l,c)}const i=e[`u_alpha${o+1}`];i&&t.uniform1f(i,a.alphas[o])}e.u_intensity&&t.uniform1f(e.u_intensity,a.intensity),e.u_scale&&t.uniform1f(e.u_scale,a.scale),e.u_direction&&t.uniform1f(e.u_direction,a.direction*Math.PI/180),e.u_softness&&t.uniform1f(e.u_softness,a.softness),e.u_distortion&&t.uniform1f(e.u_distortion,a.distortion),e.u_complexity&&t.uniform1f(e.u_complexity,a.complexity),e.u_shape&&t.uniform1f(e.u_shape,a.shape),e.u_vignette&&t.uniform1f(e.u_vignette,a.vignette),e.u_vigOpacity&&t.uniform1f(e.u_vigOpacity,a.vigOpacity),e.u_blur&&t.uniform1f(e.u_blur,a.blur),e.u_shaderOpacity&&t.uniform1f(e.u_shaderOpacity,a.shaderOpacity),s.presetDirty=!1}function ia(t){if(!s)return;const{gl:e,uniforms:a,preset:r,glCanvas:o}=s,n=(t-s.startMs-s.pausedMs)/1e3*r.speed;e.viewport(0,0,o.width,o.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),s.presetDirty&&na(),a.u_time&&e.uniform1f(a.u_time,n),e.drawArrays(e.TRIANGLES,0,6),s.frameCount++}let Pt=0;function re(t){var e;if(!s)return;if(s.contextLost){s.rafId=0;return}let a=!1;for(const r of s.instances)if(r.visible&&(!r.paused||!r.everCopied)){a=!0;break}if(!a){s.rafId=0;return}if(s.rafId=requestAnimationFrame(re),!(t-Pt<Ie)){Pt=t,ia(t),s.useOffscreen&&(s.glowQueue.length>0&&dt(),(e=s.frameBitmap)==null||e.close(),s.frameBitmap=s.glCanvas.transferToImageBitmap());for(const r of s.instances)r.visible&&(r.paused&&r.everCopied||(oa(r),r.everCopied=!0));if(wt&&s.glowQueue.length>0&&++s.glowSkip%Ae===0){const r=s.glowQueue;s.glowIdx>=r.length&&(s.glowIdx=0);const o=r[s.glowIdx];o.visible&&!o.paused&&wt(o,t),s.glowIdx++}}}function nt(){!s||s.rafId!==0||(s.rafId=requestAnimationFrame(re))}function oe(){s&&(s.rafId!==0&&cancelAnimationFrame(s.rafId),s.rafId=0)}const lt={linear:t=>t,smoothstep:t=>t*t*(3-2*t)};function Z(t,e,a,r=lt.linear){return{from:t,to:e,dur:a,ease:r,startMs:-1,val:t,done:!1}}function J(t,e){t.startMs=e,t.val=t.from,t.done=!1}function At(t,e){if(t.done||t.startMs<0)return t.val;const a=Math.min(1,(e-t.startMs)/t.dur);return t.val=t.from+(t.to-t.from)*t.ease(a),a>=1&&(t.done=!0),t.val}const sa=1.5,it=1/3,la=4*it,ca=2*it,da=2*it,ua=1.35*it,ha=13*it;function Mt(t,e,a){const r=Math.max(0,Math.min(a,Math.min(t,e)/2));return 2*Math.max(0,t-2*r)+2*Math.max(0,e-2*r)+2*Math.PI*r}function _t(t,e,a,r){return r==="circle"?2*Math.PI*Math.max(0,Math.min(a,Math.min(t,e)/2)):Mt(t,e,a)}function ot(t,e,a,r,o,n,i,u){const l=u||{x:0,y:0},c=Math.max(0,Math.min(r,Math.min(e,a)/2));if(i==="circle"){const b=2*Math.PI*c;if(b<=1e-4)return l.x=e*.5,l.y=a*.5,l;t=(t%b+b)%b;const P=-Math.PI/2+t/b*Math.PI*2,j=Math.max(0,c-o+n);return l.x=e*.5+j*Math.cos(P),l.y=a*.5+j*Math.sin(P),l}const h=Math.max(0,e-2*c),f=Math.max(0,a-2*c),d=Math.PI*c/2,g=2*(h+f)+4*d;t=(t%g+g)%g;const x=Math.max(0,c-o+n);let m=t;if(m<h)return l.x=c+m,l.y=o-n,l;if(m-=h,m<d){const b=-Math.PI/2+(d>0?m/d:0)*(Math.PI/2);return l.x=e-c+x*Math.cos(b),l.y=c+x*Math.sin(b),l}if(m-=d,m<f)return l.x=e-o+n,l.y=c+m,l;if(m-=f,m<d){const b=(d>0?m/d:0)*(Math.PI/2);return l.x=e-c+x*Math.cos(b),l.y=a-c+x*Math.sin(b),l}if(m-=d,m<h)return l.x=e-c-m,l.y=a-o+n,l;if(m-=h,m<d){const b=Math.PI/2+(d>0?m/d:0)*(Math.PI/2);return l.x=c+x*Math.cos(b),l.y=a-c+x*Math.sin(b),l}if(m-=d,m<f)return l.x=o-n,l.y=a-c-m,l;m-=f;const F=Math.PI+(d>0?m/d:0)*(Math.PI/2);return l.x=c+x*Math.cos(F),l.y=c+x*Math.sin(F),l}function jt(t,e){const a=t*2/e;let r="";for(let o=0;o<=e;o++){const n=-t+o*a;r+=(o===0?"M ":"L ")+n.toFixed(3)+" 0 "}return r}const ft={x:0,y:0},pt={x:0,y:0};function fa(t,e,a,r,o,n){return ot(t-.1,e,a,r,o,0,n,ft),ot(t+.1,e,a,r,o,0,n,pt),Math.atan2(pt.y-ft.y,pt.x-ft.x)}function Et(t,e,a){const r=Math.max(0,Math.min(1,(a-t)/(e-t)));return r*r*(3-2*r)}function pa(t){const e=_t(t.width,t.height,t.cornerRadius,t.kind),a=sa*(t.scale??1),r=[];for(let o=0;o<$t;o++){const n=o/$t*e,i=ot(n,t.width,t.height,t.cornerRadius,a,0,t.kind);r.push({x:i.x,y:i.y,arc:n})}return r}function ma(t,e){const{width:a,height:r,cornerRadius:o}=t,n=t.scale??1,i=t.kind==="circle"?2:1,u=Math.max(0,o-i),l=(-200*n).toFixed(0),c=l,h=(540*n).toFixed(0),f=(440*n).toFixed(0),d=`x="${l}" y="${c}" width="${h}" height="${f}"`,g=`${d} filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"`,x=F=>(F*n).toFixed(3),m=F=>(F*n).toFixed(3);return["<defs>",`<filter id="${e}_bXl" ${g}><feGaussianBlur stdDeviation="${m(8.4)}"/></filter>`,`<filter id="${e}_bLg" ${g}><feGaussianBlur stdDeviation="${m(4.8)}"/></filter>`,`<filter id="${e}_bMd" ${g}><feGaussianBlur stdDeviation="${m(2.1)}"/></filter>`,`<filter id="${e}_bSm" ${g}><feGaussianBlur stdDeviation="${m(.9)}"/></filter>`,`<filter id="${e}_ebO" ${g}><feGaussianBlur stdDeviation="${m(da)}"/></filter>`,`<filter id="${e}_ebC" ${g}><feGaussianBlur stdDeviation="${m(ua)}"/></filter>`,`<radialGradient id="${e}_fg" cx="0.5" cy="0.5" r="0.5"><stop offset="0" stop-color="white"/><stop offset="0.30" stop-color="white"/><stop offset="0.65" stop-color="#404040"/><stop offset="1" stop-color="black"/></radialGradient>`,`<mask id="${e}_fm" maskUnits="userSpaceOnUse" ${d}><rect ${d} fill="black"/><circle id="${e}_fc" cx="0" cy="0" r="${(ha*n).toFixed(3)}" fill="url(#${e}_fg)"/></mask>`,`<mask id="${e}_rm" maskUnits="userSpaceOnUse" ${d}><rect ${d} fill="#808080"/><rect x="0" y="0" width="${a}" height="${r}" rx="${o}" ry="${o}" fill="white"/><rect x="${i}" y="${i}" width="${a-i*2}" height="${r-i*2}" rx="${u}" ry="${u}" fill="black"/></mask>`,"</defs>",`<g id="${e}_h" mask="url(#${e}_rm)" opacity="0">`,`<rect ${d} fill="none" pointer-events="none"/>`,`<g id="${e}_hI" stroke="white">`,`<path id="${e}_pXl" stroke-width="${x(26.4)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.385" filter="url(#${e}_bXl)"/>`,`<path id="${e}_pLg" stroke-width="${x(15.6)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.595" filter="url(#${e}_bLg)"/>`,`<path id="${e}_pMd" stroke-width="${x(7.2)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.70" filter="url(#${e}_bMd)"/>`,`<path id="${e}_pSm" stroke-width="${x(3)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.70" filter="url(#${e}_bSm)"/>`,"</g></g>",`<g id="${e}_e" mask="url(#${e}_rm)" opacity="0">`,`<rect ${d} fill="none" pointer-events="none"/>`,`<g mask="url(#${e}_fm)">`,`<g id="${e}_eI" stroke="white">`,`<path id="${e}_eO" stroke-width="${x(la)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.85" filter="url(#${e}_ebO)"/>`,`<path id="${e}_eC" stroke-width="${x(ca)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="1.0" filter="url(#${e}_ebC)"/>`,"</g></g></g>"].join("")}const xa=.00875,Lt=.08,Nt=.32,ga=.05,va=3e3,Wt=.85,st=.34,mt=1500,ba=15,wa=.0075,ya=120,ka=1.5,Ma=7.8,_a=9.13952,Ca=1,Sa=1/3,Ta=.8,$a=3.51,Bt=2e3,xt=400,Ra=2.625,Fa=1.008,Ia=.31,ne=140,ie=40,se=20;let Oa=0;const q={x:0,y:0};function zt(t,e){const a=`mfxg_${++Oa}`,r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","metal-fx-glow-svg"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${e.width} ${e.height}`),r.innerHTML=ma(e,a),t.appendChild(r);const o=b=>r.querySelector(`#${a}_${b}`),n=o("h"),i=o("hI"),u=o("e"),l=o("eI"),c=o("fc"),h=_t(e.width,e.height,e.cornerRadius,e.kind)/Mt(ne,ie,se),f=Math.max(1,Ma*h),d=Math.max(.6,_a*Sa*h),g=jt(f,je),x=jt(d,Ee),m=[o("pXl"),o("pLg"),o("pMd"),o("pSm")],F=[o("eO"),o("eC")];for(const b of m)b.setAttribute("d",g);for(const b of F)b.setAttribute("d",x);return i.style.transformOrigin="0 0",l.style.transformOrigin="0 0",i.style.willChange="transform",l.style.willChange="transform",i.style.transition="transform 100ms linear",l.style.transition="transform 100ms linear",n.style.willChange="opacity",u.style.willChange="opacity",n.style.transition="opacity 100ms linear",u.style.transition="opacity 100ms linear",c.style.willChange="transform",{svg:r,haloGroup:n,haloInner:i,extraGroup:u,extraInner:l,fadeCircle:c,width:e.width,height:e.height,cornerRadius:e.cornerRadius,kind:e.kind,scale:e.scale??1,perim:pa(e),currentIdx:0,appearedAt:0,glowOpacity:0,relocTween:null,relocNextIdx:-1,wanderS:0,wanderTargetS:0,wanderFrames:0,tintFrom:{r:255,g:255,b:255},tintTarget:{r:255,g:255,b:255},tintTween:null,tintHoldUntil:0,lastHaloStroke:"",lastExtraStroke:""}}function Pa(t,e,a,r,o="dark"){var n;const{width:i,height:u,cornerRadius:l,perim:c}=t;if(c.length===0)return;const h=2;let f=-1,d=t.currentIdx,g=0;for(let v=0;v<c.length;v++){const M=c[v],S=Ot(e,M.x,M.y,h);S>f&&(f=S,d=v),v===t.currentIdx&&(g=S)}const x=t.appearedAt>0&&a-t.appearedAt<va,m=st+(Wt-st)*Et(Lt,Nt,g),F=!x&&f-g>ga;if(!t.relocTween||t.relocTween.done)if(t.appearedAt===0)t.currentIdx=d,t.appearedAt=a,t.wanderS=0,t.wanderTargetS=0,t.wanderFrames=0,t.relocTween=Z(0,m,mt,lt.smoothstep),J(t.relocTween,a);else if((n=t.relocTween)!=null&&n.done&&t.relocTween.to===0){t.currentIdx=t.relocNextIdx,t.appearedAt=a,t.wanderS=0,t.wanderTargetS=0,t.wanderFrames=0;const v=c[t.currentIdx],M=Ot(e,v.x,v.y,h),S=st+(Wt-st)*Et(Lt,Nt,M);t.relocTween=Z(0,S,mt,lt.smoothstep),J(t.relocTween,a)}else F?(t.relocNextIdx=d,t.relocTween=Z(t.glowOpacity,0,mt,lt.smoothstep),J(t.relocTween,a)):t.glowOpacity+=(m-t.glowOpacity)*xa;t.relocTween&&(t.glowOpacity=At(t.relocTween,a)),t.glowOpacity=Math.max(0,Math.min(1,t.glowOpacity));const b=_t(i,u,l,t.kind)/Mt(ne,ie,se),P=ba*b;t.wanderFrames++>=ya&&(t.wanderTargetS=(Math.random()*2-1)*P,t.wanderFrames=0),t.wanderS+=(t.wanderTargetS-t.wanderS)*wa;const j=c[t.currentIdx].arc+t.wanderS,L=ka*t.scale;ot(j,i,u,l,L,0,t.kind,q);const C=q.x,E=q.y,z=fa(j,i,u,l,L,t.kind),X=`translate(${C.toFixed(3)}px,${E.toFixed(3)}px) rotate(${z.toFixed(4)}rad)`;t.haloInner.style.transform=X;const N=Ca*b*t.scale;ot(j,i,u,l,L,N,t.kind,q),t.extraInner.style.transform=`translate(${q.x.toFixed(3)}px,${q.y.toFixed(3)}px) rotate(${z.toFixed(4)}rad)`,t.fadeCircle.style.transform=`translate(${q.x.toFixed(3)}px,${q.y.toFixed(3)}px)`;const $=o==="light",k=$?Xe(e,C,E,h):Qe(e,C,E,h);t.tintTween?t.tintTween.done&&($?(t.tintFrom={r:t.tintFrom.r+(t.tintTarget.r-t.tintFrom.r)*t.tintTween.val,g:t.tintFrom.g+(t.tintTarget.g-t.tintFrom.g)*t.tintTween.val,b:t.tintFrom.b+(t.tintTarget.b-t.tintFrom.b)*t.tintTween.val},t.tintTarget={...k},t.tintTween=Z(0,1,xt),J(t.tintTween,a)):a>=t.tintHoldUntil&&(t.tintFrom={...t.tintTarget},t.tintTarget={...k},t.tintTween=Z(0,1,xt),J(t.tintTween,a),t.tintHoldUntil=a+Bt)):(t.tintFrom={...k},t.tintTarget={...k},t.tintTween=Z(0,1,xt),J(t.tintTween,a),t.tintHoldUntil=$?0:a+Bt),At(t.tintTween,a);const I=t.tintTween.val;let W,B,H;if($)W=Math.round(t.tintFrom.r+(t.tintTarget.r-t.tintFrom.r)*I),B=Math.round(t.tintFrom.g+(t.tintTarget.g-t.tintFrom.g)*I),H=Math.round(t.tintFrom.b+(t.tintTarget.b-t.tintFrom.b)*I);else{const v=t.tintFrom.r+(t.tintTarget.r-t.tintFrom.r)*I,M=t.tintFrom.g+(t.tintTarget.g-t.tintFrom.g)*I,S=t.tintFrom.b+(t.tintTarget.b-t.tintFrom.b)*I,O=Math.max(v,M,S)||1;W=Math.round(255*(v/O)),B=Math.round(255*(M/O)),H=Math.round(255*(S/O))}const y=`rgb(${W},${B},${H})`;if(y!==t.lastHaloStroke&&(t.lastHaloStroke=y,t.haloInner.style.stroke=y),$){const v=Re(W,B,H),[M,S,O]=Fe(v[0],Math.min(1,v[1]*Ra),Math.max(Ia,v[2]*Fa)),D=`rgb(${M},${S},${O})`;D!==t.lastExtraStroke&&(t.lastExtraStroke=D,t.extraInner.style.stroke=D)}else t.lastExtraStroke!=="#ffffff"&&(t.lastExtraStroke="#ffffff",t.extraInner.style.stroke="#ffffff");const w=Math.max(0,Math.min(1,r));t.haloGroup.style.opacity=(t.glowOpacity*Ta*w).toFixed(3),t.extraGroup.style.opacity=Math.min(1,t.glowOpacity*$a*w).toFixed(3)}const yt=12,Ht=32,Gt=1,Dt=.55,Aa=1,ja=1,Ea=.85,La=0,Na=1.3,Ut=3.6,Wa=.7,Ba=1,za=.52,Ha=1,Ga=.044,Da=235,Ua=2.535,qa=.7,Va=.5,Qa=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Xa(t,e){const a=Math.max(t.left-e.right,e.left-t.right,0),r=Math.max(t.top-e.bottom,e.top-t.bottom,0);return Math.sqrt(a*a+r*r)}function Ya(t,e,a,r){return!(Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top)<a||Math.max(t.left-e.right,e.left-t.right,0)>r)}function Ka(t,e,a,r){return Math.min(t.right,e.right)-Math.max(t.left,e.left)<a?!1:Math.max(t.top-e.bottom,e.top-t.bottom,0)<=r}function Q(t,e,a,r,o,n){const i=Math.max(0,Math.min(n,r*.5,o*.5)),u=t.roundRect;if(typeof u=="function"){u.call(t,e,a,r,o,i);return}t.moveTo(e+i,a),t.lineTo(e+r-i,a),t.quadraticCurveTo(e+r,a,e+r,a+i),t.lineTo(e+r,a+o-i),t.quadraticCurveTo(e+r,a+o,e+r-i,a+o),t.lineTo(e+i,a+o),t.quadraticCurveTo(e,a+o,e,a+o-i),t.lineTo(e,a+i),t.quadraticCurveTo(e,a,e+i,a)}function le(t,e,a,r,o){if(!o.flipX&&!o.flipY){t.drawImage(e,0,0,a,r,o.x,o.y,o.w,o.h);return}t.save(),o.flipX&&(t.translate(o.x+o.w,0),t.scale(-1,1)),o.flipY&&(t.translate(0,o.y+o.h),t.scale(1,-1)),t.drawImage(e,0,0,a,r,o.flipX?0:o.x,o.flipY?0:o.y,o.w,o.h),t.restore()}const Za=4;function Ja(t,e,a,r,o,n,i){if(r<=2*i||o<=2*i){t.beginPath(),Q(t,e,a,r,o,n),t.clip();return}t.beginPath(),Q(t,e,a,r,o,n),Q(t,e+i,a+i,r-2*i,o-2*i,Math.max(0,n-i)),t.clip("evenodd")}function tr(t,e,a,r,o,n,i,u,l,c,h){const f=Math.max(1,Math.round((yt+Za*3)*h));let d=Math.max(0,i),g=!0;for(let x=0;x<3&&d>1e-4;x++){const m=Math.min(1,d);t.save(),Ja(t,c.x,c.y,c.w,c.h,c.r,f),t.globalCompositeOperation=g?"source-over":"lighter",g=!1,t.globalAlpha=m,le(t,e,a,r,l),t.globalAlpha=1,t.globalCompositeOperation="destination-in",t.fillStyle=u,t.fillRect(0,0,o,n),t.restore(),d-=m}}function ce(t,e,a,r,o,n,i){const u=i|0;if(u<1||r<=2*u||o<=2*u){t.beginPath(),Q(t,e,a,r,o,n),t.clip();return}t.beginPath(),Q(t,e,a,r,o,n),Q(t,e+u,a+u,r-2*u,o-2*u,Math.max(0,n-u)),t.clip("evenodd")}function er(t,e,a,r,o,n,i,u,l,c,h,f){let d=u*h,g=!0;for(let x=0;x<3&&d>1e-4;x++){const m=Math.min(1,d);t.save(),ce(t,i.x,i.y,i.w,i.h,i.r,l),t.globalCompositeOperation=g?"source-over":"lighter",g=!1,t.globalAlpha=m,le(t,e,a,r,f),t.globalAlpha=1,t.globalCompositeOperation="destination-in",t.fillStyle=c,t.fillRect(0,0,o,n),t.restore(),d-=m}}function ar(t,e,a,r,o,n,i,u){const l=t.createLinearGradient(r,o,n,i);l.addColorStop(0,`rgba(255,255,255,${u.toFixed(3)})`),l.addColorStop(.5,`rgba(255,255,255,${(u*.45).toFixed(3)})`),l.addColorStop(1,"rgba(255,255,255,0)"),t.save(),ce(t,e.x,e.y,e.w,e.h,e.r,a),t.globalCompositeOperation="lighter",t.lineWidth=a*2,t.strokeStyle=l,t.beginPath(),Q(t,e.x,e.y,e.w,e.h,e.r),t.stroke(),t.restore()}function de(t){const e=getComputedStyle(t),a=[parseFloat(e.borderTopLeftRadius)||0,parseFloat(e.borderTopRightRadius)||0,parseFloat(e.borderBottomRightRadius)||0,parseFloat(e.borderBottomLeftRadius)||0].filter(r=>r>0);return a.length?Math.min.apply(null,a):0}function ue(t){const e=getComputedStyle(t),a=Math.max(parseFloat(e.borderTopWidth)||0,parseFloat(e.borderRightWidth)||0,parseFloat(e.borderBottomWidth)||0,parseFloat(e.borderLeftWidth)||0);let r=0,o=0;const n=e.boxShadow;if(n&&n!=="none"){const u=n.replace(/rgba?\([^)]*\)/g,h=>h.replace(/,/g,"\0")).split(/,\s*/);let l=1/0,c=1/0;for(const h of u){const f=h.match(/-?\d+(?:\.\d+)?px/g);if(!f||f.length<4)continue;const d=parseFloat(f[3]);d>0&&(/\binset\b/.test(h)?d<l&&(l=d):d<c&&(c=d))}Number.isFinite(l)&&(r=l),Number.isFinite(c)&&(o=c)}const i=Math.max(a,o);return{width:Math.max(a,r,o)||1,outerCssPx:i}}function qt(t){t.cornerRadius=de(t.el);const e=ue(t.el);t.hairlineWidth=e.width,t.hairlineOuterCssPx=e.outerCssPx}function rr(t){typeof ResizeObserver<"u"&&(t.resizeObserver=new ResizeObserver(()=>qt(t)),t.resizeObserver.observe(t.el)),typeof MutationObserver<"u"&&(t.mutationObserver=new MutationObserver(()=>qt(t)),t.mutationObserver.observe(t.el,{attributes:!0,attributeFilter:["style","class"]}))}function or(t){var e,a;(e=t.resizeObserver)==null||e.disconnect(),t.resizeObserver=null,(a=t.mutationObserver)==null||a.disconnect(),t.mutationObserver=null}const tt=new Set;function nr(t,e,a){if(typeof document>"u"||Qa.has(t.tagName))return null;for(const g of tt)if(g.el===t)return g;const r=document.createElement("div");r.setAttribute("data-metal-fx-reflection",""),r.setAttribute("aria-hidden","true");const o=document.createElement("canvas");o.className="metal-fx-reflection-canvas";const n=o.getContext("2d",{alpha:!0});if(!n)return null;const i=document.createElement("canvas");i.className="metal-fx-reflection-stroke-canvas";const u=i.getContext("2d",{alpha:!0});if(!u)return null;r.appendChild(o),r.appendChild(i);const l=getComputedStyle(t);let c=!1;l.position==="static"&&(t.style.position="relative",c=!0);let h=!1;l.isolation!=="isolate"&&(t.style.isolation="isolate",h=!0),t.setAttribute("data-metal-fx-reflect-host",""),t.insertBefore(r,t.firstChild);const f=ue(t),d={el:t,anchor:e,anchorEl:a,wrap:r,canvas:o,ctx:n,strokeCanvas:i,strokeCtx:u,cornerRadius:de(t),hairlineWidth:f.width,hairlineOuterCssPx:f.outerCssPx,appliedPositionRelative:c,appliedIsolation:h,resizeObserver:null,mutationObserver:null};return rr(d),tt.add(d),d}function ir(t){for(const e of tt)if(e.el===t){or(e),e.canvas.width=0,e.canvas.height=0,e.strokeCanvas.width=0,e.strokeCanvas.height=0,e.wrap.parentNode===e.el&&e.el.removeChild(e.wrap),e.el.removeAttribute("data-metal-fx-reflect-host"),e.appliedPositionRelative&&(e.el.style.position=""),e.appliedIsolation&&(e.el.style.isolation=""),tt.delete(e);return}}function sr(){if(tt.size===0)return;const t=typeof window<"u"&&window.devicePixelRatio||1,e=new Map;for(const a of tt){const r=a.el.getBoundingClientRect();let o=e.get(a.anchorEl);if(o||(o=a.anchorEl.getBoundingClientRect(),e.set(a.anchorEl,o)),r.width<1||r.height<1||o.width<1||o.height<1)continue;if(!Ya(o,r,Gt,Ht)&&!Ka(o,r,Gt,Ht)){a.canvas.width!==1&&(a.canvas.width=1,a.canvas.height=1),a.strokeCanvas.width!==1&&(a.strokeCanvas.width=1,a.strokeCanvas.height=1);continue}const n=a.anchor.canvas,i=n.width|0,u=n.height|0;if(i<4||u<4)continue;const l=(o.left+o.right)*.5,c=(o.top+o.bottom)*.5,h=(r.left+r.right)*.5,f=(r.top+r.bottom)*.5,d=l-h,g=c-f,x=Math.max(o.left-r.right,r.left-o.right,0),m=Math.max(o.top-r.bottom,r.top-o.bottom,0),F=x>=m,b=Xa(o,r);let P=1-Math.min(1,b/yt);P=P*P*(3-2*P);const j=Dt+(Aa-Dt)*P,L=Math.min(Ut,j*Na*Wa),C=a.anchor.scale??1,E=Math.max(Ba*C,a.hairlineWidth),z=Math.max(1,Math.round(E*t)),X=Math.max(1,Math.round(Math.max(Ha*C,a.hairlineWidth)*t)),N=a.hairlineOuterCssPx;a.wrap.style.inset=`${-N}px`,a.wrap.style.borderRadius=`${Math.max(0,a.cornerRadius)}px`;const $=Math.max(1,Math.round((r.width+N*2)*t)),k=Math.max(1,Math.round((r.height+N*2)*t));a.canvas.width!==$&&(a.canvas.width=$),a.canvas.height!==k&&(a.canvas.height=k),a.strokeCanvas.width!==$&&(a.strokeCanvas.width=$),a.strokeCanvas.height!==k&&(a.strokeCanvas.height=k);const I=a.ctx;I.setTransform(1,0,0,1,0,0),I.clearRect(0,0,$,k);const W=a.strokeCtx;W.setTransform(1,0,0,1,0,0),W.clearRect(0,0,$,k);const B=Math.min(yt*t,Math.max($,k));let H,y,w,v;F?(H=d>0?$:0,w=d>0?$-B:B,y=k*.5,v=k*.5):(y=g>0?k:0,v=g>0?k-B:B,H=$*.5,w=$*.5);const M=I.createLinearGradient(H,y,w,v);M.addColorStop(0,`rgba(0,0,0,${ja})`),M.addColorStop(.5,`rgba(0,0,0,${Ea})`),M.addColorStop(1,`rgba(0,0,0,${La})`);const S=i/t,O=Math.max(1,Math.round(Da*Math.max(.1,S/140)*t));let D,U,T,A,V=!1,Ct=!1;if(F){const at=Math.max(o.top,r.top),ht=Math.min(o.bottom,r.bottom);V=!0,D=d>0?$-O:0,U=Math.round((at-r.top+N)*t),T=O,A=Math.max(1,Math.round((ht-at)*t))}else{const at=Math.max(o.left,r.left),ht=Math.min(o.right,r.right);Ct=!0,D=Math.round((at-r.left+N)*t),U=g>0?k-O:0,T=Math.max(1,Math.round((ht-at)*t)),A=O}const St={x:D,y:U,w:T,h:A,flipX:V,flipY:Ct},ut={x:0,y:0,w:$,h:k,r:Math.max(0,a.cornerRadius*t)},me=Math.min(Ut,L*Ua*qa*Va);tr(I,n,i,u,$,k,me,M,St,ut,t),er(W,n,i,u,$,k,ut,L,z,M,za,St),ar(W,ut,X,H,y,w,v,Math.min(.85,Ga*L)),I.globalCompositeOperation="source-over",W.globalCompositeOperation="source-over"}}let gt=!1,Vt=0;function lr(){gt||(gt=!0,!(typeof requestAnimationFrame>"u")&&requestAnimationFrame(t=>{gt=!1,!(t-Vt<Oe)&&(Vt=t,sr())}))}const Qt="metal-fx-styles",cr=`
.metal-fx-root {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
isolation: isolate;
overflow: visible;
background: #272727;
color: #f8f8f8;
}
.metal-fx-root[data-theme='light'] {
background: #ffffff;
color: #1d1d1d;
}
.metal-fx-root::before {
content: '';
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
z-index: 2;
box-shadow: inset 0 0 50px 0 rgba(255, 255, 255, 0.02);
}
.metal-fx-root[data-theme='light']::before {
box-shadow: inset 0 0 50px 0 rgba(0, 0, 0, 0.02);
}
.metal-fx-root::after {
content: '';
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
z-index: 4;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.metal-fx-root[data-theme='light']::after {
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
/* Circle variant gets a thicker outer rim than the button variant. */
.metal-fx-root[data-variant='circle']::after {
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1);
}
.metal-fx-root[data-theme='light'][data-variant='circle']::after {
box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.06);
}
.metal-fx-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
z-index: 0;
pointer-events: none;
border-radius: inherit;
}
/* The inner spacer — defines the inset geometry where the metal ring meets
the interior (3 px for Button, 1-2 px for Circle) and carries the Circle dark
hairline ('box-shadow: inset' rules below). Intentionally transparent so
the wrapper's background propagates through to the punched shader centre,
giving consumers a single surface tone to override. See "Single-surface
background" in the file header for the rationale. */
.metal-fx-inner {
position: absolute;
inset: 3px;
border-radius: inherit;
z-index: 1;
pointer-events: none;
}
.metal-fx-root[data-variant='button'][data-shape='pill'] .metal-fx-inner {
border-radius: calc(var(--mfx-radius, 20px) - 3px);
}
.metal-fx-root[data-variant='button'][data-shape='circle'] .metal-fx-inner {
border-radius: calc(var(--mfx-radius, 16px) - 3px);
}
.metal-fx-root[data-variant='circle'][data-shape='pill'] .metal-fx-inner {
inset: 0;
border-radius: var(--mfx-radius, 20px);
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
.metal-fx-root[data-variant='circle'][data-shape='circle'] .metal-fx-inner {
inset: 0;
border-radius: var(--mfx-radius, 16px);
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
/* Circle-variant hairline alpha — light mode.
Source-of-truth: index.html L2261-2267. The 0.45-alpha black inset that
reads as a single-pixel frame against the dark interior is too heavy
on a #ffffff inner: it ends up looking like a hard 2-px black ring
against the iridescent shader. Suppressed entirely (alpha 0) — the
shader's own iridescent rim already defines the silhouette in light
mode, so an extra dark hairline only competes with it. The rule is
kept (rather than deleted) as a tunable hook in case a future variant
wants to re-introduce a soft edge. NOTE: we keep the dark-mode inset
and border-radius values because — unlike index.html — our renderer
does NOT overscan the canvas in light mode, so there is no 1-px gap
between inner element and shader to compensate for. */
.metal-fx-root[data-theme='light'][data-variant='circle'][data-shape='pill'] .metal-fx-inner,
.metal-fx-root[data-theme='light'][data-variant='circle'][data-shape='circle'] .metal-fx-inner {
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0);
}
/* ─── Combined glow SVG (z=3) ──────────────────────────────────────────────
Single SVG per instance that holds BOTH the wide-halo group
(#mfx_haloTravel) and the catch-light group (#mfx_extraTravel), exactly
mirroring canonical's _buildGlowSvgInner (index.html L8078). One
mix-blend-mode: screen lifts the combined composite onto the shader
ring; per-frame opacity attributes on each inner group still drive the
independent fade-in / fade-out cycles for the halo and the catch-light.
Why a single SVG: the circle variant anchors halo + catch-light at the same
perimeter point, so they overlap in the bright zone. Two separately-
screened SVGs would double-screen the overlap (A + B + C - AB - AC -
BC + ABC instead of A + B + C - AB - AC once both groups composite
in source-over inside one SVG and then screen against the host once).
That overlap looked muted versus canonical specifically on the circle
variant where both layers travel together.
Source-of-truth opacity: #btnGlowSvg drops to 0.7 in dark and 0.2746 in
light (index.html L632/L643). */
.metal-fx-glow-svg {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
overflow: visible;
z-index: 3;
pointer-events: none;
opacity: 0.7;
}
.metal-fx-root[data-theme='light'] .metal-fx-glow-svg {
/* Light-mode 1-px overscan mirrors .btn-glow-svg in metal.html so the
halo stays glued to the visible silhouette (the shader ring there sits
1 px outside the host's padding box). */
inset: -1px;
width: calc(100% + 2px);
height: calc(100% + 2px);
mix-blend-mode: multiply;
/* Source-of-truth: html[data-theme="light"] #btnGlowSvg { opacity: 0.2746 }
→ −35 % from 0.4225 from the original 0.7 dark-mode opacity. */
opacity: 0.2746;
filter: saturate(5.355) brightness(0.78);
}
/* Circle light-mode small variants (e.g. 36×36 send button): the geometrically
shrunk halo loses density when multiplied against #ffffff. Mirror the
canonical override at index.html L2316 — bump saturation + drop brightness
so the small glow holds together visually. */
.metal-fx-root[data-variant='circle'][data-shape='circle'][data-theme='light'] .metal-fx-glow-svg {
filter: saturate(7.5) brightness(0.6);
}
/* The wrapped child — hoisted into z=5 so it sits above every overlay, with
normalized chrome so consumer button styles don't fight the metal frame. */
.metal-fx-content {
position: relative;
z-index: 5;
display: inline-flex;
align-items: center;
justify-content: center;
width: 100%;
pointer-events: none;
}
.metal-fx-content > * {
pointer-events: auto;
}
.metal-fx-root[data-normalize='true'] .metal-fx-content > * {
background: transparent !important;
border: 0 !important;
outline: 0 !important;
box-shadow: none !important;
/* Sizing: we deliberately DO NOT force \`width: 100%; height: 100%\` on the
child here. That used to be the contract ("the wrapper is the visible
button surface; the child stretches to fill it"), but it created a cyclic
percentage dependency: the wrapper is \`inline-flex\` with no intrinsic
size, .metal-fx-content is \`width/height: 100%\` of the wrapper, and the
child was \`100%\` of .metal-fx-content. With nothing breaking the cycle,
icon-only / class-sized children collapsed.
The new contract: the child sizes itself (intrinsic content, CSS class,
or inline style — all work), and the wrapper's \`inline-flex\` wraps it
tightly. Consumers who want a metal frame BIGGER than the child (e.g.
padding around an icon) size <MetalFx style={{ width, height }}> AND
explicitly set width/height on the child to fill (or accept that the
child renders at its intrinsic size, centered).
Typography is intentionally NOT touched. We used to apply
\`color: inherit; font: inherit;\` here to "match" the wrapper, but
\`font: inherit\` is a shorthand that overrides font-family, font-size,
font-weight, AND line-height on the child — which (a) shrank the
button height (line-height changes propagate through the flex
content box) and (b) scaled em-based icons / font-icons inside the
child to whatever the wrapper inherited. The wrapper now stays out
of the child's typography entirely; consumers who want typographic
normalization can apply it themselves on the child element. */
}
[data-metal-fx-reflection] {
position: absolute;
inset: 0;
pointer-events: none;
border-radius: inherit;
overflow: hidden;
z-index: 0;
isolation: isolate;
}
.metal-fx-reflection-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
filter: blur(4px) saturate(1.2) brightness(1.58);
}
.metal-fx-reflection-stroke-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
filter: saturate(1.35) brightness(1.75);
}
/* Hosts that participate as reflection targets need positioning + isolation
so the wrap composites only against the host (not the parent stack). The
wrap injects these inline as well, but stating them here keeps reflections
working on hosts that already have other inline styles applied. */
[data-metal-fx-reflect-host] {
isolation: isolate;
}
`;let vt=!1;function dr(){if(vt||typeof document>"u")return;if(document.getElementById(Qt)){vt=!0;return}const t=document.createElement("style");t.id=Qt,t.textContent=cr,document.head.appendChild(t),vt=!0}dr();const ur={position:"absolute",inset:0,width:"100%",height:"100%"},hr={position:"absolute",inset:3},fr={position:"absolute",inset:0,pointerEvents:"none",zIndex:3,borderRadius:"inherit"},ct=new Map;aa((t,e)=>{const a=ct.get(t);a&&Pa(a.handles,t,e,t.opacityMul,a.themeRef.current)});function pr(t){const[e,a]=_.useState(()=>t!=="auto"?t:typeof window>"u"||!window.matchMedia||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return _.useEffect(()=>{if(t!=="auto"){a(t);return}if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>a(r.matches?"dark":"light");return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[t]),e}const he=_.forwardRef(function({children:t,variant:e="button",preset:a="chromatic",theme:r="auto",strength:o=1,paused:n=!1,borderRadius:i,normalizeHostStyles:u=!0,reflectionTargets:l,disableGlow:c=!1,shaderScale:h,ringCssPx:f,scale:d=1,className:g,style:x,...m},F){const b=_.useRef(null),P=_.useRef(null),j=_.useRef(null),L=_.useRef(null),C=_.useRef(null),E=_.useRef(null),z=_.useRef("dark"),X=_.useRef(0),[N,$]=_.useState(!1),k=pr(r);z.current=k;const I=e==="circle"?"circle":"pill",W=!c;_.useImperativeHandle(F,()=>b.current,[]);const B=(y,w)=>{if(I==="circle")return Math.min(y,w)/2;const v=typeof i=="number"?i:(()=>{var M;const S=(M=L.current)==null?void 0:M.firstElementChild;if(S){const O=parseFloat(getComputedStyle(S).borderTopLeftRadius);if(Number.isFinite(O)&&O>0)return O}return X.current})();return Math.min(v,Math.min(y,w)/2)};_.useEffect(()=>{ea(a,k)},[a,k]),_.useEffect(()=>{const y=C.current;y&&rt(y,{paused:n})},[n]),_.useEffect(()=>{const y=C.current;if(!y)return;const w={};h!==void 0&&(w.shaderScale=h),f!==void 0&&(w.ringCssPx=f),d!==void 0&&(w.scale=d),Object.keys(w).length>0&&rt(y,w)},[h,f,d]),_.useLayoutEffect(()=>{const y=P.current,w=b.current,v=j.current;if(!y||!w)return;{const T=getComputedStyle(w),A=parseFloat(T.borderTopLeftRadius);X.current=Number.isFinite(A)?A:0}const M=()=>{const T=w.getBoundingClientRect(),A=Math.max(1,Math.round(T.width)),V=Math.max(1,Math.round(T.height));return{cssWidth:A,cssHeight:V,cornerRadius:B(A,V)}},S=M();C.current=Ye({hostCanvas:y,cssWidth:S.cssWidth,cssHeight:S.cssHeight,cornerRadius:S.cornerRadius,kind:I,paused:n,shaderScale:h,ringCssPx:f,scale:d,onFirstCopy:()=>$(!0)}),w.style.setProperty("--mfx-radius",`${S.cornerRadius}px`),w.style.borderRadius=`${S.cornerRadius}px`,v&&(E.current=zt(v,{width:S.cssWidth,height:S.cssHeight,cornerRadius:S.cornerRadius,kind:I,scale:d}));let O=0;const D=new ResizeObserver(()=>{O===0&&(O=requestAnimationFrame(()=>{O=0;const T=M(),A=C.current;A&&(rt(A,{cssWidth:T.cssWidth,cssHeight:T.cssHeight,cornerRadius:T.cornerRadius}),w.style.setProperty("--mfx-radius",`${T.cornerRadius}px`),w.style.borderRadius=`${T.cornerRadius}px`,v&&(v.innerHTML="",E.current=zt(v,{width:T.cssWidth,height:T.cssHeight,cornerRadius:T.cornerRadius,kind:I,scale:d}),A&&E.current&&ct.set(A,{handles:E.current,themeRef:z})))}))});D.observe(w);let U=null;return typeof IntersectionObserver<"u"&&(U=new IntersectionObserver(T=>{const A=C.current;if(A)for(const V of T)ta(A,V.isIntersecting)},{rootMargin:"64px"}),U.observe(w)),C.current&&E.current&&(ct.set(C.current,{handles:E.current,themeRef:z}),Ze(C.current)),()=>{D.disconnect(),U?.disconnect(),O!==0&&cancelAnimationFrame(O);const T=C.current;T&&(ct.delete(T),Je(T),Ke(T)),C.current=null,E.current=null,v&&(v.innerHTML="")}},[I]),_.useEffect(()=>{const y=C.current;y&&rt(y,{opacityMul:Math.max(0,Math.min(1,o))})},[o,e]),_.useEffect(()=>{const y=C.current,w=b.current;if(!y||!w||!l||k!=="dark")return;y.onAfterFrame=lr;const v=l.flatMap(M=>M.current?[M.current]:[]);for(const M of v)nr(M,y,w);return()=>{y.onAfterFrame=void 0;for(const M of v)ir(M)}},[l,k]),_.useEffect(()=>{const y=b.current,w=C.current;if(!y||!w)return;const v=B(w.cssWidth,w.cssHeight);rt(w,{cornerRadius:v}),y.style.setProperty("--mfx-radius",`${v}px`),y.style.borderRadius=`${v}px`},[i,k,e,I]);const H=_.useMemo(()=>({...x,"--mfx-strength":String(Math.min(1,Math.max(0,o))),opacity:N?1:0,visibility:N?"visible":"hidden",transition:N?"opacity 0.15s ease-out":"none"}),[x,o,N]);return p.jsxs("div",{...m,ref:b,className:g?`metal-fx-root ${g}`:"metal-fx-root","data-variant":e,"data-shape":I,"data-theme":k,"data-paused":n?"true":void 0,"data-normalize":u?"true":"false",style:H,children:[p.jsx("canvas",{ref:P,className:"metal-fx-canvas",style:ur}),p.jsx("div",{className:"metal-fx-inner","aria-hidden":"true",style:hr}),p.jsx("div",{ref:j,"aria-hidden":"true",style:{...fr,display:W?void 0:"none"}}),p.jsx("div",{ref:L,className:"metal-fx-content",children:t})]})});he.displayName="MetalFx";const et=18;function fe(){return p.jsxs("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"4"}),p.jsx("path",{d:"M12 2v2"}),p.jsx("path",{d:"M12 20v2"}),p.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),p.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),p.jsx("path",{d:"M2 12h2"}),p.jsx("path",{d:"M20 12h2"}),p.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),p.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function pe(){return p.jsx("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function mr(){return p.jsxs("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),p.jsx("path",{d:"M8 21h8"}),p.jsx("path",{d:"M12 17v4"})]})}const xr=[{value:"light",label:"Light",Icon:fe},{value:"dark",label:"Dark",Icon:pe},{value:"system",label:"System",Icon:mr}];function gr(t){return t==="dark"?pe:fe}function vr({theme:t,resolvedTheme:e,onSetTheme:a,className:r="",direction:o="down",align:n="right"}){const[i,u]=_.useState(!1),l=_.useRef(null),c=_.useCallback(()=>u(!1),[]);_.useEffect(()=>{if(!i)return;const f=d=>{l.current&&!l.current.contains(d.target)&&c()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i,c]),_.useEffect(()=>{if(!i)return;const f=d=>{d.key==="Escape"&&c()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[i,c]);const h=gr(e);return p.jsxs("div",{ref:l,className:`relative ${r}`,children:[p.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":i,onClick:()=>u(f=>!f),className:"flex items-center justify-center w-9 h-9 rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors",children:p.jsx(h,{})}),i&&p.jsx("div",{className:`absolute z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg ${o==="up"?"bottom-full mb-1":"top-full mt-1"} ${n==="left"?"left-0":"right-0"}`,children:xr.map(({value:f,label:d,Icon:g})=>{const x=t===f;return p.jsxs("button",{type:"button",onClick:()=>{a(f),c()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-sm transition-colors ${x?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"}`,children:[p.jsx(g,{}),p.jsx("span",{children:d})]},f)})})]})}const br="https://github.com/mm7894215/TokenTracker/releases/latest";function Br({auth:t,signedIn:e,sessionSoftExpired:a,userId:r}){const{currency:o,rate:n}=ke(),{theme:i,resolvedTheme:u,setTheme:l}=xe(),{openLoginModal:c}=ge(),{signedIn:h,loading:f}=ve(),d=!be(),g=e&&!a,x=_.useMemo(()=>g&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,g]),m=_e({userId:r,period:"total",accessToken:x});return p.jsxs("div",{className:"flex flex-col min-h-screen bg-oai-gray-50 dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-oai antialiased transition-colors duration-200",children:[p.jsx("header",{className:"sticky top-0 z-50 w-full px-4 pt-4 pb-2 transition-all duration-300 pointer-events-none",children:p.jsxs("div",{className:"mx-auto max-w-3xl rounded-2xl border border-oai-gray-200/50 dark:border-white/10 bg-white/75 dark:bg-oai-gray-950/60 backdrop-blur-xl shadow-[0_8px_30px_rgb(0,0,0,0.04)] dark:shadow-[0_8px_30px_rgb(0,0,0,0.3)] flex h-14 items-center justify-between px-3 sm:px-4 pointer-events-auto transition-all duration-300",children:[p.jsxs("div",{className:"flex items-center gap-4",children:[p.jsxs(Tt,{to:"/",className:"flex items-center gap-3 no-underline outline-none rounded-md focus-visible:ring-2 focus-visible:ring-indigo-500 transition-opacity hover:opacity-80 active:scale-95",children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),p.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),p.jsx("div",{className:"hidden sm:block scale-90 origin-left opacity-90 hover:opacity-100 transition-opacity",children:p.jsx(Me,{})})]}),p.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[p.jsxs(Tt,{to:"/leaderboard",className:"group no-underline inline-flex items-center gap-1.5 h-8 px-3 text-xs font-bold rounded-full border border-oai-gray-200 dark:border-white/10 bg-transparent text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-white/5 hover:text-oai-black dark:hover:text-white transition-all duration-200 active:scale-95 shadow-sm",children:[p.jsx(we,{size:13,strokeWidth:2.5,"aria-hidden":!0,className:"transition-transform duration-150 ease-out group-hover:scale-110 group-hover:rotate-6"}),p.jsx("span",{children:Y("leaderboard.profile.nav.back")})]}),d&&p.jsx(he,{variant:"button",preset:"chromatic",theme:"dark",borderRadius:9999,disableGlow:!0,className:"!bg-black",children:p.jsxs("a",{href:br,target:"_blank",rel:"noopener noreferrer",className:"group no-underline inline-flex h-8 items-center gap-1.5 px-3 text-xs font-bold rounded-full bg-black text-white transition-transform duration-200 active:scale-[0.98]",children:[p.jsx(Te,{size:13,strokeWidth:2.5,"aria-hidden":!0,className:"transition-transform duration-150 ease-out group-hover:translate-y-0.5"}),p.jsx("span",{className:"hidden sm:inline",children:Y("leaderboard.profile.nav.download")})]})}),f?p.jsx("div",{className:"h-8 w-16 animate-pulse rounded-full bg-oai-gray-200 dark:bg-white/10","aria-hidden":!0}):h?p.jsx(ye,{}):p.jsx("button",{type:"button",onClick:c,className:"inline-flex h-8 min-w-[76px] items-center justify-center px-3 text-xs font-bold rounded-full border border-oai-gray-200 dark:border-white/10 bg-transparent text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-white/5 hover:text-oai-black dark:hover:text-white transition-all duration-200 active:scale-95 shadow-sm select-none",children:Y("header.auth.sign_in_aria")})]})]})}),p.jsx("main",{className:"flex-1 px-4 pt-4 pb-10 sm:pt-6 sm:pb-16",children:p.jsx("div",{className:"mx-auto max-w-3xl",children:p.jsxs("div",{className:"rounded-2xl bg-white dark:bg-oai-gray-950 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden shadow-sm dark:shadow-none",children:[m.loading&&p.jsx(Ce,{variant:"page"}),!m.loading&&m.error&&p.jsx("div",{className:"px-6 py-16 text-center",children:p.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:Y("leaderboard.profile_modal.error")})}),!m.loading&&!m.error&&!m.data&&p.jsx("div",{className:"px-6 py-16 text-center",children:p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:Y("leaderboard.profile_modal.empty")})}),!m.loading&&!m.error&&m.data&&p.jsx(Se,{data:m.data,currency:o,rate:n,variant:"page"})]})})}),p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 px-4 transition-colors duration-200",children:p.jsxs("div",{className:"mx-auto flex max-w-3xl items-center justify-between text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[p.jsx("p",{children:Y("landing.v2.footer.line")}),p.jsx(vr,{theme:i,resolvedTheme:u,onSetTheme:l,direction:"up",align:"right"})]})})]})}export{Br as LeaderboardProfilePage};
import{c as r}from"./__vite-browser-external-CHbEWSwX.js";const t=["claude","codex","cursor","gemini","kimi","kiro","grok","copilot","antigravity","zcode","opencodeGo"],e={claude:"CLAUDE",codex:"CODEX",cursor:"CURSOR",gemini:"GEMINI",kimi:"KIMI",kiro:"KIRO",grok:"GROK",copilot:"COPILOT",antigravity:"ANTIGRAVITY",zcode:"ZCODE",opencodeGo:"OPENCODE"};function c(i){return e[i]||null}function n(i){switch(i){case"claude":return r("limits.provider.claude");case"codex":return r("limits.provider.codex");case"cursor":return r("limits.provider.cursor");case"gemini":return r("limits.provider.gemini");case"kimi":return r("limits.provider.kimi");case"kiro":return r("limits.provider.kiro");case"grok":return r("limits.provider.grok");case"copilot":return r("limits.provider.copilot");case"antigravity":return r("limits.provider.antigravity");case"zcode":return r("limits.provider.zcode");case"opencodeGo":return r("limits.provider.opencode_go");default:return String(i||"")}}export{t as L,c as a,n as l};
import{k as G,j as t,b as $,c as r,ae as H,r as b,P as ee,af as te,R as ae,F as ie,L as re,ag as ne,w as oe,o as se,x as C,ah as le}from"./__vite-browser-external-CHbEWSwX.js";import{P as B,c as de,r as v,a as ce,u as ue,b as me,s as xe}from"./use-usage-limits-B_NbJCPh.js";import{L as m,u as pe}from"./use-limits-display-prefs-B-zzSXHf.js";import{C as W}from"./Card-D4wKdGxL.js";import{F as ge}from"./FadeIn-D_skMXdS.js";import{L as fe,l as N,a as he}from"./limits-providers-Db3iK5TG.js";import{L as be}from"./LocalOnlyNotice-Dc1CtgPN.js";import"./arrow-up-right-B1yj6nxk.js";import"./download-HHcFs0Ff.js";const ye=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],ke=G("bell-off",ye);const ve=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],je=G("bell",ve),Ne=[3,2,3,3,2,2,3];function g({className:e}){return t.jsx("div",{className:$("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",e)})}function we(){return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(g,{className:"h-3 w-12 shrink-0"}),t.jsx(g,{className:"flex-1 h-1.5 rounded-full min-w-0"}),t.jsx(g,{className:"h-3 w-[30px] shrink-0"}),t.jsx(g,{className:"h-3 w-6 shrink-0"})]})}function _e({bars:e,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(g,{className:"h-[14px] w-[14px] rounded shrink-0"}),t.jsx(g,{className:$("h-4",i)})]}),Array.from({length:e},(o,n)=>t.jsx(we,{},n))]})}function Me(){return t.jsx(W,{children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx(g,{className:"h-3.5 w-28"}),Ne.map((e,a)=>t.jsx(_e,{bars:e,index:a},a))]})})}const I=100;function T(e){const a=Date.parse(e);return Number.isFinite(a)?a:null}function Ee(e){return Math.max(0,Math.min(I,Math.round(e)))}function Ie(e){return new Intl.DateTimeFormat(H(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(e))}function Le(e,a,i){if(e==null||e>=a)return I;const o=a-e,n=a-i;return Ee(n/o*I)}function Pe(e){const a=e.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function Oe(e,{now:a}={}){if(!e||typeof e!="object")return null;const i=Pe(e);if(i===void 0)return null;const o=Array.isArray(e.credits)?e.credits:[],n=a instanceof Date?a.getTime():Number(a??Date.now()),s=[];for(const c of o){const d=T(c?.expires_at);if(d==null)continue;const l=s.length+1;s.push({key:`reset-${l}`,label:r("limits.codex_reset_bank.row_label",{index:l}),expiresAt:Ie(d),expiresMs:d,percent:Le(T(c?.granted_at),d,n)})}return i===0?null:s.length>0?{kind:"rows",availableCount:i??s.length,rows:s}:i>0?{kind:"count_only",availableCount:i,rows:[]}:null}const Se="shrink-0 text-oai-black dark:text-oai-white";function Re(e){const a=v(e);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const o=Math.floor(i/6e4);if(o<60)return`${o}m`;const n=Math.floor(o/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function Ce(e,a){const i=a===m.REMAINING?100-e:e;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function k(e,a="used_percent"){return e?a==="utilization"?e.utilization:e.used_percent:null}function j(e,a="reset_at"){return e?a==="resets_at"?e.resets_at:e.reset_at:null}function w(e){const a=Math.max(0,Math.min(100,Number(e)||0)),i=Math.round(a);return a>0&&i===0?r("limits.bar.sub_one_percent"):String(i)}function _(e){const a=Number(e);return Number.isFinite(a)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:a>=100?0:2}).format(a):null}function Te(e){if(!e||typeof e!="object")return null;const a=_(e.used_credits),i=_(e.limit_credits),o=_(e.remaining_credits);return!a||!i||!o?null:r("limits.codex_credits.detail",{used:a,limit:i,remaining:o})}function Ae(e,a){return de({usedPercent:k(e.window,e.pctField),windowSeconds:ce(e,e.window),resetMs:v(j(e.window,e.resetField)),mode:a})}function U(e){return Number.isFinite(e)?new Intl.DateTimeFormat(H(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(e)):null}function De(e,a,i){const o=[K(e,a,i)],n=v(j(e.window,e.resetField)),s=U(n);if(s&&o.push(r("limits.hover.resets_at",{time:s})),e.key==="credits"){const c=Te(e.window);c&&o.push(c)}return o.join(`
`)}function z({text:e}){return e?t.jsx("div",{role:"tooltip",className:"pointer-events-none absolute bottom-full left-1/2 z-10 mb-2 w-max max-w-[260px] -translate-x-1/2 whitespace-pre-line rounded-xl border border-oai-gray-200/50 dark:border-oai-gray-800/50 bg-white/90 dark:bg-oai-gray-900/90 backdrop-blur-md px-2.5 py-1.5 text-[10.5px] leading-snug text-oai-gray-700 dark:text-oai-gray-200 shadow-xl opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:e}):null}function Fe({label:e,pct:a,reset:i,mode:o=m.USED,pacePercent:n=null,paceOver:s=!1,title:c=null}){const d=Math.max(0,Math.min(100,Number(a)||0)),l=o===m.REMAINING?100-d:d,u=Math.round(l),x=l>0&&u===0?Math.max(l,.35):l;let f=String(u);l>0&&u===0&&(f=r("limits.bar.sub_one_percent"));const h=n==null?null:Math.max(0,Math.min(100,n));return t.jsxs("div",{className:"group relative flex items-center gap-2",children:[t.jsx(z,{text:c}),t.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:e}),t.jsxs("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[t.jsx("div",{className:`${Ce(l,o)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${x}%`,minWidth:l>0?"3px":0}}),h!=null&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${h}% - 3px)`,width:"6px"}}),t.jsx("div",{className:`absolute top-0 h-full ${s?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${h}% - 1px)`,width:"2px"}})]})]}),t.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:[f,"%"]}),i&&t.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:i})]})}function K(e,a,i){const o=e.label??r(e.labelKey),n=i===m.REMAINING,s=l=>n?100-l:l;if(a.expectedPercent==null){const l=Math.max(0,Math.min(100,Number(k(e.window,e.pctField))||0)),u=w(s(l));return n?r("limits.explain.remaining",{label:o,used:u}):r("limits.explain.used",{label:o,used:u})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:o,eta:a.runsOutEta});const l=w(s(a.projectedEnd??100));return r(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:o,pct:l})}const c=Math.max(0,Math.min(100,Number(k(e.window,e.pctField))||0)),d=w(s(a.projectedEnd??c));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:o,pct:d})}function Ge({rows:e,mode:a}){if(e.length===0)return null;const i=a===m.REMAINING;return t.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[e.map(({spec:o,pace:n})=>{const s=U(v(j(o.window,o.resetField)));return t.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[K(o,n,a),s?t.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",r("limits.hover.resets_at",{time:s})]}):null]},o.key)}),t.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(i?"limits.explain.body_remaining":"limits.explain.body")})]})}function A(e){if(!e)return null;const a=Date.now()-new Date(e).getTime();if(a<0)return null;const i=Math.floor(a/6e4);if(i<1)return r("shared.time.now");if(i<60)return r("shared.time.m_ago",{n:i});const o=Math.floor(i/60);if(o<24)return r("shared.time.h_ago",{n:o});const n=Math.floor(o/24);return r("shared.time.d_ago",{n})}const D={live:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-emerald-500",pulse:"bg-emerald-400"},stale:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"},cached:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"}};function M({label:e,age:a=null,tone:i="live",tooltip:o=null}){const n=D[i]||D.live,s=i==="live";return t.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:c=>c.stopPropagation(),children:[t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold uppercase tracking-wider border leading-normal ${n.surface}`,children:[s?t.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[t.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${n.pulse} opacity-75`}),t.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${n.dot}`})]}):t.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n.dot}`}),e,a?t.jsxs(t.Fragment,{children:[" · ",a]}):null]}),o?t.jsxs("span",{className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-2 -translate-x-1/2 w-48 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-1.5 text-[10px] font-normal text-white text-center opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-normal shadow-lg origin-bottom border border-oai-gray-800 dark:border-oai-gray-700",children:[o,t.jsx("span",{className:"absolute left-1/2 top-full -translate-x-1/2 border-4 border-transparent border-t-oai-gray-900 dark:border-t-oai-gray-800"})]}):null]})}function L({name:e,providerId:a,children:i,expandable:o=!1,expanded:n=!1,onToggle:s,badge:c=null}){const d=he(a),l=t.jsxs("div",{className:"flex items-center gap-1.5",children:[d?t.jsx(ee,{provider:d,size:14,className:Se}):null,t.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:e}),c]});return o?t.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:s,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s?.())},className:"flex flex-col gap-1.5 -mx-1.5 px-1.5 py-1 rounded-lg cursor-pointer transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 aria-expanded:bg-oai-gray-50 dark:aria-expanded:bg-oai-gray-800/40",children:[l,i]}):t.jsxs("div",{className:"flex flex-col gap-1.5",children:[l,i]})}const $e=fe;function y({children:e,tone:a="neutral"}){const i=a==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return t.jsx("div",{className:`text-[11px] leading-snug ${i}`,children:e})}function He({rows:e,mode:a,extra:i=null}){const o=e.length===0&&!i;return t.jsxs(t.Fragment,{children:[e.map(({spec:n,pace:s})=>t.jsx(Fe,{label:n.label??r(n.labelKey),pct:k(n.window,n.pctField),reset:Re(j(n.window,n.resetField)),mode:a,pacePercent:s.pacePercent,paceOver:s.paceOver,title:De(n,s,a)},n.key)),o?t.jsx(y,{children:r("limits.status.no_data")}):null,i]})}function Be(e){if(!Number.isFinite(e.expiresMs))return null;const a=Math.floor((e.expiresMs-Date.now())/864e5);return a<0?null:a===0?r("limits.reset_bank.hover_detail_today",{date:e.expiresAt}):r("limits.reset_bank.hover_detail",{date:e.expiresAt,days:a})}function We({row:e}){const a=Math.max(0,Math.min(100,Number(e.percent)||0));return t.jsxs("div",{className:"group relative flex items-center gap-2","data-reset-bank-row":"",children:[t.jsx(z,{text:Be(e)}),t.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:e.label}),t.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:t.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${a}%`,minWidth:a>0?"3px":0}})}),t.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:e.expiresAt})]})}function Ue({model:e}){const a=e.kind==="count_only"?r("limits.codex_reset_bank.count_only",{count:e.availableCount}):null;return t.jsxs("div",{className:"mt-1 flex flex-col gap-1","data-reset-bank-section":e.kind,children:[t.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codex_reset_bank.title")}),a?t.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:a}):e.rows.map(i=>t.jsx(We,{row:i},i.key))]})}function ze(e,a){if(e==="codex_meta"){const i=Oe(a.reset_credits);return i?t.jsx(Ue,{model:i}):null}return e==="kimi_parallel"&&a.parallel_limit?t.jsx(y,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})}):e==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?t.jsx(Xe,{defaultDir:a.otel_default_dir}):null}function Ke(e,a,i,o,n,s,c=null){const d=B[e];if(!d)return null;const l=d.windows(a).filter(x=>x.window).map(x=>({spec:x,pace:Ae(x,o)})),u=ze(d.extra,a);return t.jsxs(L,{name:i,providerId:e,expandable:l.length>0,expanded:n,onToggle:s,badge:c,children:[t.jsx(He,{mode:o,rows:l,extra:u}),n?t.jsx(Ge,{rows:l,mode:o}):null]},e)}function Ve(e,a,i,o,n){if(!B[e])return null;if(!a?.configured)return t.jsxs(L,{name:N(e),providerId:e,children:[t.jsx(y,{children:r("limits.status.not_connected")}),e==="opencodeGo"?t.jsx(F,{}):null]},e);if(a.error)return t.jsxs(L,{name:N(e),providerId:e,children:[t.jsx(y,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),e==="opencodeGo"?t.jsx(F,{}):null]},e);const s=N(e),c=a.plan_label?`${s} ${a.plan_label}`:s;let d=null;if(e==="antigravity")if(a.cached){const u=A(a.cached_at);d=t.jsx(M,{label:r("limits.label.antigravity_cached"),age:u,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else d=t.jsx(M,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});const l=a.provenance;return l?.stale&&!d&&(d=t.jsx(M,{label:r("limits.provenance.stale"),age:A(l.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:l.source,confidence:l.confidence})})),Ke(e,a,c,i,o,n,d)}function Xe({defaultDir:e}){const[a,i]=b.useState(!1),n=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${e||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
`),s=async c=>{c.stopPropagation();try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1600)}catch{}};return t.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[t.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:r("limits.copilot.otelHint.title")}),t.jsx("div",{className:"mt-0.5 leading-snug",children:r("limits.copilot.otelHint.body")}),t.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:n}),t.jsx("button",{type:"button",onClick:s,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:a?r("limits.copilot.otelHint.copied"):r("limits.copilot.otelHint.copy")})]})}function E({n:e,children:a}){return t.jsxs("li",{className:"flex gap-2.5",children:[t.jsx("span",{className:"mt-[1px] flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-oai-brand/15 text-[9px] font-semibold text-oai-brand",children:e}),t.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:a})]})}function Ye(){return t.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",className:"h-2.5 w-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M4.5 2.75h4.75V7.5M9.25 2.75 3 9"})})}function F(){const[e,a]=b.useState(!1),i=['export OPENCODE_GO_AUTH_COOKIE="..."','# Optional: export OPENCODE_GO_WORKSPACE_ID="wrk_..." (Only if auto-discovery fails)'].join(`
`),o=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return t.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[t.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.opencodeGo.setupHint.title")}),t.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.opencodeGo.setupHint.subtitle")}),t.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[t.jsxs(E,{n:"1",children:[t.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),t.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),t.jsx(Ye,{})]})]}),t.jsxs(E,{n:"2",children:[t.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")}),t.jsxs("ul",{className:"mt-1 space-y-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:[t.jsx("li",{children:r("limits.opencodeGo.setupHint.step2_workspace")}),t.jsx("li",{children:r("limits.opencodeGo.setupHint.step2_cookie")})]})]}),t.jsxs(E,{n:"3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:r("limits.opencodeGo.setupHint.step3")}),t.jsx("button",{type:"button",onClick:o,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:e?r("limits.opencodeGo.setupHint.copied"):r("limits.opencodeGo.setupHint.copy")})]}),t.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),t.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.opencodeGo.setupHint.note_app")})]})]})]})}function qe(e){const[a,i]=b.useState(0);return b.useLayoutEffect(()=>{const o=e.current;if(!o)return;const n=o.querySelectorAll("[data-limit-label]");let s=0,c=null;if(n.length>0)try{c=document.createElement("canvas").getContext("2d")}catch{c=null}if(c){const l=window.getComputedStyle(n[0]);c.font=`${l.fontStyle} ${l.fontWeight} ${l.fontSize} ${l.fontFamily}`;for(const u of n)s=Math.max(s,c.measureText(u.textContent).width)}const d=Math.ceil(s);i(l=>l===d?l:d)}),a}function Je({claude:e,codex:a,cursor:i,gemini:o,kimi:n,kiro:s,grok:c,antigravity:d,copilot:l,zcode:u,opencodeGo:x,order:f,visibility:h,displayMode:V}){const X={claude:e,codex:a,cursor:i,gemini:o,kimi:n,kiro:s,grok:c,antigravity:d,copilot:l,zcode:u,opencodeGo:x},P=b.useRef(null),O=qe(P),[Y,q]=b.useState(null),J=Array.isArray(f)&&f.length>0?f:$e,S=V===m.REMAINING?m.REMAINING:m.USED,Q=S===m.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used"),R=J.filter(p=>!h||h[p]!==!1).map(p=>Ve(p,X[p],S,Y===p,()=>q(Z=>Z===p?null:p))).filter(Boolean);return t.jsx(ge,{delay:.15,children:t.jsx(W,{children:t.jsxs("div",{ref:P,className:"flex flex-col gap-3",style:O>0?{"--tt-limits-label-w":`${O}px`}:void 0,children:[t.jsxs("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:[r("limits.panel.title"),r("limits.panel.mode_separator"),Q]}),R.length>0?R:t.jsx(y,{children:r("limits.status.all_hidden")})]})})})}const Qe=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Ze="x-apple.systempreferences:com.apple.preference.notifications";function et(){const e=oe(),a=se(),i=r("limits.alert.blocked"),o=a?C.button:C.div;return t.jsxs(o,{type:a?"button":void 0,onClick:a?()=>le({type:"action",name:"openURL",value:Ze}):void 0,initial:e?!1:{opacity:0,x:14,scale:.9},animate:{opacity:1,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:18},title:i,className:`relative hidden sm:inline-flex min-w-0 max-w-[360px] items-center gap-1.5 rounded-full border border-amber-300/70 bg-amber-50 px-3 py-1.5 text-xs text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300 ${a?"cursor-pointer transition-colors hover:bg-amber-100 dark:hover:bg-amber-500/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/60":""}`,children:[t.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[t.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),t.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-amber-500"})]}),t.jsx("span",{className:"truncate",children:i}),t.jsx("span",{"aria-hidden":!0,className:"absolute left-full top-1/2 -translate-y-1/2 border-[5px] border-transparent border-l-amber-300/80 dark:border-l-amber-500/40"})]})}function ct(){const e=te(),{data:a,error:i,isLoading:o}=ue(e?{initialRefresh:!0,initialState:e,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),n=pe(),s=me();return ae.useEffect(()=>{s.enabled&&a&&xe(a)},[s.enabled,a]),!Qe&&!ie()?t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx(be,{})}):t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:t.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[t.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:r("nav.limits")}),t.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:r("limits.page.subtitle")})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.enabled&&s.permissionBlocked?t.jsx(et,{}):null,t.jsx("button",{type:"button",onClick:()=>{s.setEnabled(!s.enabled)},"aria-label":s.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:s.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 ${s.enabled&&s.permissionBlocked?"text-amber-600 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"}`,children:s.enabled?t.jsx(je,{className:"h-4 w-4","aria-hidden":!0}):t.jsx(ke,{className:"h-4 w-4","aria-hidden":!0})}),t.jsx(re,{to:"/settings","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(ne,{className:"h-4 w-4","aria-hidden":!0})})]})]}),o?t.jsx(Me,{}):t.jsxs(t.Fragment,{children:[i?t.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:r("shared.error.prefix",{error:i})}):null,t.jsx(Je,{claude:a?.claude,codex:a?.codex,cursor:a?.cursor,gemini:a?.gemini,kimi:a?.kimi,kiro:a?.kiro,grok:a?.grok,antigravity:a?.antigravity,copilot:a?.copilot,zcode:a?.zcode,opencodeGo:a?.opencodeGo,order:n.order,visibility:n.visibility,displayMode:n.displayMode})]})]})})})}export{ct as LimitsPage};
import{k as e}from"./__vite-browser-external-CHbEWSwX.js";const o=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],t=e("link-2",o);export{t as L};
import{k as e}from"./__vite-browser-external-CHbEWSwX.js";const o=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],a=e("loader-circle",o);export{a as L};
import{j as e,c as t}from"./__vite-browser-external-CHbEWSwX.js";import{A as r}from"./arrow-up-right-B1yj6nxk.js";import{D as o}from"./download-HHcFs0Ff.js";const i="https://github.com/mm7894215/TokenTracker/releases/latest";function c(){const a=()=>{try{window.location.href="tokentracker://open"}catch{}};return e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-20 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-white",children:t("local_only.title")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:t("local_only.body")}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("button",{type:"button",onClick:a,className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium bg-oai-gray-900 text-white hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:[e.jsx("span",{children:t("local_only.open_app")}),e.jsx(r,{size:14,strokeWidth:2,"aria-hidden":!0})]}),e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900 transition-colors",children:[e.jsx(o,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t("local_only.download")})]})]})]})})}export{c as L};
import{u as p,d as w,e as v,r,c as s,j as e,L as y,f as j}from"./__vite-browser-external-CHbEWSwX.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};
import{k as P,N as F,al as H,r as n,am as O,an as $,ao as W,ap as K,c as i,j as e,b,aq as Z}from"./__vite-browser-external-CHbEWSwX.js";import{u as J,T as E,S as X}from"./use-native-settings-CIHg16YZ.js";import{n as Y,C as _}from"./ClawdAnimated-BzfSSyf4.js";import{F as L}from"./FadeIn-D_skMXdS.js";import{L as G}from"./link-2-C4RnhbaI.js";import{L as Q}from"./loader-circle-Cz7QNoOj.js";import{Z as ee}from"./zap-DjGiVr-_.js";import{T as te}from"./trash-2-Ceor8aI2.js";import"./Card-D4wKdGxL.js";const ae=[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]],re=P("file-archive",ae);const ie=[["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"}]],se=P("monitor-up",ie);const oe=[["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"}]],ne=P("upload",oe),le={visible:!1,character:"clawd",size:"medium"};function de(){const t=F()&&H(),[a,s]=n.useState(le);n.useEffect(()=>{if(!t)return;const d=O(o=>{s({visible:!!o.visible,character:Y(o.character),size:["small","medium","large"].includes(o.size)?o.size:"medium"})});return $(),d},[t]);const l=n.useCallback((d,o)=>{s(x=>({...x,[d]:o})),t&&W(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 z(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 ce(){const t=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),a=await z(t);return[...y,...Array.isArray(a.pets)?a.pets:[]]}async function B(t){const a=await K();return z(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function me(t){return B({action:"install_url",url:t})}async function M(t){const a=await K();return z(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...a},cache:"no-store",body:t}))}function pe(t){return B({action:"remove",id:t})}let C=y;function xe(){const[t,a]=n.useState(C),[s,l]=n.useState(!0),[d,o]=n.useState(!1),x=n.useCallback(async()=>{l(!0);try{const m=await ce();return C=m,a(m),o(!0),m}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 ue={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 ge(){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 be({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:b("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:b("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",ue[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(_,{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:b("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(te,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function he({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}),m=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),p=c.clientY-(u.top+u.height/2),j=(Math.atan2(v,-p)*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}),m]})]}),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(_,{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:b("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:b("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 Pe(){const{available:t,settings:a,setSetting:s}=de(),{pets:l,loading:d,available:o,refresh:x}=xe(),[m,c]=n.useState(""),[u,v]=n.useState(""),[p,j]=n.useState(!1),[U,A]=n.useState("idle-living"),[I,V]=n.useState(!0),f=a.character||"clawd",S=J(),T=S.settings?.menuBarIconStyle==="pet",D=l.find(r=>r.id===f)||l[0],w=p?{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 h=await r();await x(),h?.pet?.id&&s("character",h.pet.id),Z({title:g,timeout:4e3}),c("")}catch(h){v(h?.message||i("pet.import.failed"))}finally{j(!1)}}n.useEffect(()=>{if(!I)return;const r=window.setInterval(()=>{A(g=>{const h=k.findIndex(q=>q.id===g);return k[(h+1)%k.length].id})},5e3);return()=>window.clearInterval(r)},[I]);const R=[{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(L,{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(L,{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(he,{pet:D,state:U,onStateChange:r=>{V(!1),A(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(be,{character:r,selected:f===r.id,onSelect:()=>s("character",r.id),removeDisabled:p,onRemove:o&&r.custom?()=>N(async()=>(await pe(r.id),f===r.id&&s("character","clawd"),null),i("pet.import.removed")):void 0},r.id))}),S.available?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 rounded-xl border border-oai-gray-200/70 bg-oai-gray-50/60 px-3 py-2.5 dark:border-oai-gray-800 dark:bg-oai-gray-900/40",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold",children:i("pet.menubar.title")}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:i("pet.menubar.hint")})]}),e.jsx(E,{checked:T,onChange:()=>S.setSetting("menuBarIconStyle",T?"clawd":"pet"),ariaLabel:i("pet.menubar.title")})]}):null]}),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(ne,{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(ge,{})}),e.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:r=>{r.preventDefault(),!p&&m.trim()&&N(()=>me(m))},children:[e.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[e.jsx(G,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{value:m,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:p||!m.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:[p?e.jsx(Q,{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(),p)return;const g=r.dataTransfer?.files?.[0];g&&N(()=>M(g))},className:b("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",p&&"pointer-events-none opacity-40"),children:[e.jsx(re,{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:p,onChange:r=>{const g=r.target.files?.[0];g&&N(()=>M(g)),r.target.value=""}})]}),w?e.jsx("p",{role:w.kind==="error"?"alert":"status",className:b("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(se,{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(E,{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(X,{options:R,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(ee,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),i("pet.controls.native_only")]})]})]})})]})})})}export{Pe as PetPage};
import{k as Xe,aP as Ue,bu as Ke,bv as le,bw as We,K as ne,aO as ge,r as m,bx as $,by as me,bz as he,bA as oe,aL as be,bB as qe,bC as we,aM as Q,aJ as J,bD as W,Y as ue,aE as pe,aN as Qe,bE as Ee,bF as ze,bG as Je,bH as $e,bI as Te,aC as q,j as Y,aK as Ze,aD as Me,aT as et,bJ as tt,bK as nt,bL as ot,bM as st,aQ as rt,y as Le,bN as it,bO as ye,aH as at,bP as ct,bQ as lt,aI as ut,aG as ft,bR as dt,aF as pt}from"./__vite-browser-external-CHbEWSwX.js";import{n as Pe,o as Ae,q as He,r as ve,v as se,P as gt,w as mt,k as ht,s as Et,x as Tt,y as Pt,e as vt,f as Ct,g as bt,h as Rt,a as Be,j as St,u as Ot,z as It,A as Mt,t as yt,B as xt,I as Ft,D as kt,c as wt,d as Lt,b as At,p as Ht}from"./useScrollLock-DdUQVKDA.js";import{f as Bt,p as Dt,g as Nt}from"./DialogTitle-qsUpNlJa.js";import{r as _t,t as jt,v as Yt,w as Gt,x as Vt,y as Xt,z as Ut,A as Kt}from"./SelectItemText-Ca7gf5A0.js";const Wt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Tn=Xe("chevron-right",Wt);function qt(e,n){return n!=null&&!Pe(n)?0:typeof e=="function"?e():e}function Ce(e,n,t){const l=qt(e,t);return typeof l=="number"?l:l?.[n]}function xe(e){return typeof e=="function"?e():e}function De(e,n){return n||e==="click"||e==="mousedown"}function Qt(e){return e?.includes("mouse")&&e!=="mousedown"}class Re{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new le,this.restTimeout=new le,this.handleCloseOptions=void 0}static create(){return new Re}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const fe=new WeakMap;function de(e){if(!e.performedPointerEventsMutation)return;const n=e.pointerEventsScopeElement;n&&fe.get(n)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),fe.delete(n)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Ne(e,n){const{scopeElement:t,referenceElement:l,floatingElement:i}=n,o=fe.get(t);o&&o!==e&&de(o),de(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=t,e.pointerEventsReferenceElement=l,e.pointerEventsFloatingElement=i,fe.set(t,e),t.style.pointerEvents="none",l.style.pointerEvents="auto",i.style.pointerEvents="auto"}function _e(e){const n=e.context.dataRef.current,t=Ue(()=>n.hoverInteractionState??Re.create()).current;return n.hoverInteractionState||(n.hoverInteractionState=t),Ke(n.hoverInteractionState.disposeEffect),n.hoverInteractionState}function zt(e,n={}){const{enabled:t=!0,closeDelay:l=0,nodeId:i}=n,o="rootStore"in e?e.rootStore:e,p=o.useState("open"),E=o.useState("floatingElement"),S=o.useState("domReferenceElement"),{dataRef:c}=o.context,r=Ae(),O=He(),h=_e(o),j=We(),u=ne(()=>De(c.current.openEvent?.type,h.interactedInside)),B=ne(()=>Qt(c.current.openEvent?.type)),g=ne(()=>{de(h)});ge(()=>{p||(h.pointerType=void 0,h.restTimeoutPending=!1,h.interactedInside=!1,g())},[p,h,g]),m.useEffect(()=>g,[g]),ge(()=>{if(t&&p&&h.handleCloseOptions?.blockPointerEvents&&B()&&$(S)&&E){const x=S,a=E,d=me(E),F=r?.nodesRef.current.find(b=>b.id===O)?.context?.elements.floating;F&&(F.style.pointerEvents="");const H=h.pointerEventsScopeElement!==a?h.pointerEventsScopeElement:null,P=F!==a?F:null,C=h.handleCloseOptions?.getScope?.()??H??P??x.closest("[data-rootownerid]")??d.body;return Ne(h,{scopeElement:C,referenceElement:x,floatingElement:a}),()=>{g()}}},[t,p,S,E,h,B,r,O,g]),m.useEffect(()=>{if(!t)return;function x(){return!!(r&&O&&ve(r.nodesRef.current,O).length>0)}function a(b){const M=Ce(l,"close",h.pointerType),N=()=>{o.setOpen(!1,J(W,b)),r?.events.emit("floating.closed",b)};M?h.openChangeTimeout.start(M,N):(h.openChangeTimeout.clear(),N())}function d(b){const M=be(b);if(!qe(M)){h.interactedInside=!1;return}h.interactedInside=M?.closest("[aria-haspopup]")!=null}function F(){h.openChangeTimeout.clear(),j.clear(),r?.events.off("floating.closed",P),g()}function H(b){if(x()&&r){r.events.on("floating.closed",P);return}if(we(b.relatedTarget,o.context.triggerElements))return;const M=c.current.floatingContext?.nodeId??i,N=b.relatedTarget;if(!(r&&M&&$(N)&&ve(r.nodesRef.current,M,!1).some(X=>Q(X.context?.elements.floating,N)))){if(h.handler){h.handler(b);return}g(),B()&&!u()&&a(b)}}function P(b){!r||!O||x()||j.start(0,()=>{r.events.off("floating.closed",P),o.setOpen(!1,J(W,b)),r.events.emit("floating.closed",b)})}const C=E;return he(C&&oe(C,"mouseenter",F),C&&oe(C,"mouseleave",H),C&&oe(C,"pointerdown",d,!0),()=>{r?.events.off("floating.closed",P)})},[t,E,o,c,l,i,B,u,g,h,r,O,j])}const Jt={current:null};function $t(e,n={}){const{enabled:t=!0,delay:l=0,handleClose:i=null,mouseOnly:o=!1,restMs:p=0,move:E=!0,triggerElementRef:S=Jt,externalTree:c,isActiveTrigger:r=!0,getHandleCloseContext:O,isClosing:h,shouldOpen:j}=n,u="rootStore"in e?e.rootStore:e,{dataRef:B,events:g}=u.context,x=Ae(c),a=_e(u),d=m.useRef(!1),F=se(i),H=se(l),P=se(p),C=se(t),b=se(j),M=se(h),N=ne(()=>De(B.current.openEvent?.type,a.interactedInside)),V=ne(()=>b.current?.()!==!1),X=ne((s,T,L)=>{const R=u.context.triggerElements;if(R.hasElement(T))return!s||!Q(s,T);if(!$(L))return!1;const f=L;return R.hasMatchingElement(A=>Q(A,f))&&(!s||!Q(s,f))}),_=ne(()=>{if(!a.handler)return;me(u.select("domReferenceElement")).removeEventListener("mousemove",a.handler),a.handler=void 0}),w=ne(()=>{de(a)});return r&&(a.handleCloseOptions=F.current?.__options),m.useEffect(()=>_,[_]),m.useEffect(()=>{if(!t)return;function s(T){T.open?d.current=!1:(d.current=T.reason===W,_(),a.openChangeTimeout.clear(),a.restTimeout.clear(),a.blockMouseMove=!0,a.restTimeoutPending=!1)}return g.on("openchange",s),()=>{g.off("openchange",s)}},[t,g,a,_]),m.useEffect(()=>{if(!t)return;function s(f,A=!0){const D=Ce(H.current,"close",a.pointerType);D?a.openChangeTimeout.start(D,()=>{u.setOpen(!1,J(W,f)),x?.events.emit("floating.closed",f)}):A&&(a.openChangeTimeout.clear(),u.setOpen(!1,J(W,f)),x?.events.emit("floating.closed",f))}const T=S.current??(r?u.select("domReferenceElement"):null);if(!$(T))return;function L(f){if(a.openChangeTimeout.clear(),a.blockMouseMove=!1,o&&!Pe(a.pointerType))return;const A=xe(P.current),D=Ce(H.current,"open",a.pointerType),G=be(f),U=f.currentTarget??null,I=u.select("domReferenceElement");let k=U;if($(G)&&!u.context.triggerElements.hasElement(G)){for(const Ie of u.context.triggerElements.elements())if(Q(Ie,G)){k=Ie;break}}$(U)&&$(I)&&!u.context.triggerElements.hasElement(U)&&Q(U,I)&&(k=I);const v=k==null?!1:X(I,k,G),z=u.select("open"),Z=M.current?.()??u.select("transitionStatus")==="ending",K=!z&&Z&&d.current,ee=!v&&$(k)&&$(I)&&Q(I,k)&&K,te=A>0&&!D,Ve=v&&(z||K)||ee,Oe=!z||v;if(Ve){V()&&u.setOpen(!0,J(W,f,k));return}te||(D?a.openChangeTimeout.start(D,()=>{Oe&&V()&&u.setOpen(!0,J(W,f,k))}):Oe&&V()&&u.setOpen(!0,J(W,f,k)))}function R(f){if(N()){w();return}_();const A=u.select("domReferenceElement"),D=me(A);a.restTimeout.clear(),a.restTimeoutPending=!1;const G=B.current.floatingContext??O?.();if(we(f.relatedTarget,u.context.triggerElements))return;if(F.current&&G){u.select("open")||a.openChangeTimeout.clear();const I=S.current;a.handler=F.current({...G,tree:x,x:f.clientX,y:f.clientY,onClose(){w(),_(),C.current&&!N()&&I===u.select("domReferenceElement")&&s(f,!0)}}),D.addEventListener("mousemove",a.handler),a.handler(f);return}(a.pointerType!=="touch"||!Q(u.select("floatingElement"),f.relatedTarget))&&s(f)}return E?he(oe(T,"mousemove",L,{once:!0}),oe(T,"mouseenter",L),oe(T,"mouseleave",R)):he(oe(T,"mouseenter",L),oe(T,"mouseleave",R))},[_,w,B,H,u,t,F,a,r,X,N,o,E,P,S,x,C,O,M,V]),m.useMemo(()=>{if(!t)return;function s(T){a.pointerType=T.pointerType}return{onPointerDown:s,onPointerEnter:s,onMouseMove(T){const{nativeEvent:L}=T,R=T.currentTarget,f=u.select("domReferenceElement"),A=u.select("open"),D=X(f,R,T.target);if(o&&!Pe(a.pointerType))return;if(A&&D&&a.handleCloseOptions?.blockPointerEvents){const I=u.select("floatingElement");if(I){const k=a.handleCloseOptions?.getScope?.()??R.ownerDocument.body;Ne(a,{scopeElement:k,referenceElement:R,floatingElement:I})}}const G=xe(P.current);if(A&&!D||G===0||!D&&a.restTimeoutPending&&T.movementX**2+T.movementY**2<2)return;a.restTimeout.clear();function U(){if(a.restTimeoutPending=!1,N())return;const I=u.select("open");!a.blockMouseMove&&(!I||D)&&V()&&u.setOpen(!0,J(W,L,R))}a.pointerType==="touch"?ue.flushSync(()=>{U()}):D&&A?U():(a.restTimeoutPending=!0,a.restTimeout.start(G,U))}}},[t,a,N,X,o,u,P,V])}const Fe=.1,Zt=Fe*Fe,y=.5;function ie(e,n,t,l,i,o){return l>=n!=o>=n&&e<=(i-t)*(n-l)/(o-l)+t}function ae(e,n,t,l,i,o,p,E,S,c){let r=!1;return ie(e,n,t,l,i,o)&&(r=!r),ie(e,n,i,o,p,E)&&(r=!r),ie(e,n,p,E,S,c)&&(r=!r),ie(e,n,S,c,t,l)&&(r=!r),r}function en(e,n,t){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function ce(e,n,t,l,i,o){const p=Math.min(t,i),E=Math.max(t,i),S=Math.min(l,o),c=Math.max(l,o);return e>=p&&e<=E&&n>=S&&n<=c}function tn(e={}){const{blockPointerEvents:n=!1}=e,t=new le,l=({x:i,y:o,placement:p,elements:E,onClose:S,nodeId:c,tree:r})=>{const O=p?.split("-")[0];let h=!1,j=null,u=null,B=typeof performance<"u"?performance.now():0;function g(a,d){const F=performance.now(),H=F-B;if(j===null||u===null||H===0)return j=a,u=d,B=F,!1;const P=a-j,C=d-u,b=P*P+C*C,M=H*H*Zt;return j=a,u=d,B=F,b<M}function x(){t.clear(),S()}return function(d){t.clear();const F=E.domReference,H=E.floating;if(!F||!H||O==null||i==null||o==null)return;const{clientX:P,clientY:C}=d,b=be(d),M=d.type==="mouseleave",N=Q(H,b),V=Q(F,b);if(N&&(h=!0,!M))return;if(V&&(h=!1,!M)){h=!0;return}if(M&&$(d.relatedTarget)&&Q(H,d.relatedTarget))return;function X(){return!!(r&&ve(r.nodesRef.current,c).length>0)}function _(){X()||x()}if(X())return;const w=F.getBoundingClientRect(),s=H.getBoundingClientRect(),T=i>s.right-s.width/2,L=o>s.bottom-s.height/2,R=s.width>w.width,f=s.height>w.height,A=(R?w:s).left,D=(R?w:s).right,G=(f?w:s).top,U=(f?w:s).bottom;if(O==="top"&&o>=w.bottom-1||O==="bottom"&&o<=w.top+1||O==="left"&&i>=w.right-1||O==="right"&&i<=w.left+1){_();return}let I=!1;switch(O){case"top":I=ce(P,C,A,w.top+1,D,s.bottom-1);break;case"bottom":I=ce(P,C,A,s.top+1,D,w.bottom-1);break;case"left":I=ce(P,C,s.right-1,U,w.left+1,G);break;case"right":I=ce(P,C,w.right-1,U,s.left+1,G);break}if(I)return;if(h&&!en(P,C,w)){_();return}if(!M&&g(P,C)){_();return}let k=!1;switch(O){case"top":{const v=R?y/2:y*4,z=R||T?i+v:i-v,Z=R?i-v:T?i+v:i-v,K=o+y+1,ee=T||R?s.bottom-y:s.top,te=T?R?s.bottom-y:s.top:s.bottom-y;k=ae(P,C,z,K,Z,K,s.left,ee,s.right,te);break}case"bottom":{const v=R?y/2:y*4,z=R||T?i+v:i-v,Z=R?i-v:T?i+v:i-v,K=o-y,ee=T||R?s.top+y:s.bottom,te=T?R?s.top+y:s.bottom:s.top+y;k=ae(P,C,z,K,Z,K,s.left,ee,s.right,te);break}case"left":{const v=f?y/2:y*4,z=f||L?o+v:o-v,Z=f?o-v:L?o+v:o-v,K=i+y+1,ee=L||f?s.right-y:s.left,te=L?f?s.right-y:s.left:s.right-y;k=ae(P,C,ee,s.top,te,s.bottom,K,z,K,Z);break}case"right":{const v=f?y/2:y*4,z=f||L?o+v:o-v,Z=f?o-v:L?o+v:o-v,K=i-y,ee=L||f?s.left+y:s.right,te=L?f?s.left+y:s.right:s.left+y;k=ae(P,C,K,z,K,Z,ee,s.top,te,s.bottom);break}}k?h||t.start(40,_):_()}};return l.__options={...e,blockPointerEvents:n},l}const je=m.createContext(void 0);function re(e){const n=m.useContext(je);if(n===void 0&&!e)throw new Error(pe(47));return n}function nn(){return{...Nt(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const on={...Dt,disabled:q(e=>e.disabled),instantType:q(e=>e.instantType),openMethod:q(e=>e.openMethod),openChangeReason:q(e=>e.openChangeReason),modal:q(e=>e.modal),focusManagerModal:q(e=>e.focusManagerModal),stickIfOpen:q(e=>e.stickIfOpen),titleElementId:q(e=>e.titleElementId),descriptionElementId:q(e=>e.descriptionElementId),openOnHover:q(e=>e.openOnHover),closeDelay:q(e=>e.closeDelay),hasViewport:q(e=>e.hasViewport)};class Se extends Qe{constructor(n,t,l=!1){const i={...nn(),...n},o=new gt;i.open&&n?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=Bt(o,t,l),super(i,{popupRef:m.createRef(),backdropRef:m.createRef(),internalBackdropRef:m.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:m.createRef(),beforeContentFocusGuardRef:m.createRef(),stickIfOpenTimeout:new le,triggerElements:o},on)}setOpen=(n,t)=>{const l=t.reason===W,i=t.reason===Ee&&t.event.detail===0,o=!n&&(t.reason===ze||t.reason==null),p=mt(t),E=this.select("activeTriggerId");if(!n&&t.reason===Je&&t.trigger==null&&E!=null&&(t.trigger=this.context.triggerElements.getById(E)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(n,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(n,t);const S=()=>{const c={open:n,openChangeReason:t.reason};Et(c,n,t.trigger,p()),this.update(c)};l?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start($e,()=>{this.set("stickIfOpen",!1)}),ue.flushSync(S)):S(),i||o?this.set("instantType",i?"click":"dismiss"):t.reason===Te?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(n,t){const{store:l,internalStore:i}=ht(n,(o,p)=>new Se(t,o,p));return m.useEffect(()=>i?.disposeEffect(),[i]),l}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function ke({props:e}){const{children:n,open:t,defaultOpen:l=!1,onOpenChange:i,onOpenChangeComplete:o,modal:p=!1,handle:E,triggerId:S,defaultTriggerId:c=null}=e,r=Se.useStore(E?.store,{modal:p,open:l,openProp:t,activeTriggerId:c,triggerIdProp:S});Pt(r,t,l,c),r.useControlledProp("openProp",t),r.useControlledProp("triggerIdProp",S);const O=r.useState("open"),h=r.useState("mounted"),j=r.useState("payload"),u=He()!=null;r.useContextCallback("onOpenChange",i),r.useContextCallback("onOpenChangeComplete",o),vt(r,O),Ct(r);const{forceUnmount:B}=bt(O,r,()=>{r.update({stickIfOpen:!0,openChangeReason:null})});r.useSyncedValues({modal:p,nested:u}),m.useEffect(()=>{O||r.context.stickIfOpenTimeout.clear()},[r,O]);const g=m.useCallback(()=>{r.setOpen(!1,J(Ze))},[r]);m.useImperativeHandle(e.actionsRef,()=>({unmount:B,close:g}),[B,g]);const x=O||h,a=m.useMemo(()=>({store:r}),[r]);return Y.jsxs(je.Provider,{value:a,children:[x&&Y.jsx(sn,{store:r,modal:p}),typeof n=="function"?n({payload:j}):n]})}function Pn(e){return re(!0)?Y.jsx(ke,{props:e}):Y.jsx(Tt,{children:Y.jsx(ke,{props:e})})}function sn({store:e,modal:n}){const t=e.useState("floatingRootContext"),l=Rt(t,{outsidePressEvent:{mouse:n==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),i=l.reference??Me,o=l.trigger??Me,p=m.useMemo(()=>et(Be,l.floating),[l.floating]);return St(e,{activeTriggerProps:i,inactiveTriggerProps:o,popupProps:p}),null}const rn=300;function an(e,n){const t=m.useRef(null);function l(o){ue.flushSync(()=>{e.setOpen(!1,J(Te,o.nativeEvent,o.currentTarget))}),st(t.current)?.focus()}function i(o){const p=e.select("positionerElement");if(p&&tt(o,p))e.context.beforeContentFocusGuardRef.current?.focus();else{ue.flushSync(()=>{e.setOpen(!1,J(Te,o.nativeEvent,o.currentTarget))});let E=nt(e.context.triggerFocusTargetRef.current||n.current);for(;E!==null&&Q(p,E);){const S=E;if(E=ot(E),E===S)break}E?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:l,handleFocusTargetFocus:i}}const vn=m.forwardRef(function(n,t){const{render:l,className:i,style:o,disabled:p=!1,nativeButton:E=!0,handle:S,payload:c,openOnHover:r=!1,delay:O=rn,closeDelay:h=0,id:j,...u}=n,B=re(!0),g=S?.store??B?.store;if(!g)throw new Error(pe(74));const x=Ot(j),a=g.useState("isTriggerActive",x),d=g.useState("floatingRootContext"),F=g.useState("isOpenedByTrigger",x),H=g.useState("triggerPopupId",x),P=m.useRef(null),{registerTrigger:C,isMountedByThisTrigger:b}=It(x,P,g,{payload:c,disabled:p,openOnHover:r,closeDelay:h}),M=g.useState("openChangeReason"),N=g.useState("stickIfOpen"),V=g.useState("openMethod"),X=g.useState("focusManagerModal"),_=$t(d,{enabled:!p&&d!=null&&r&&(V!=="touch"||M!==Ee),mouseOnly:!0,move:!1,handleClose:tn(),restMs:O,delay:{close:h},triggerElementRef:P,isActiveTrigger:a,isClosing:()=>g.select("transitionStatus")==="ending"}),w=_t(d,{enabled:d!=null,stickIfOpen:N}),s=jt(()=>g.select("open"),k=>{g.set("openMethod",k)}),T=g.useState("triggerProps",b),{getButtonProps:L,buttonRef:R}=rt({disabled:p,native:E}),f={open(k){return k&&M===Ee?Mt.open(k):yt.open(k)}},{preFocusGuardRef:A,handlePreFocusGuardFocus:D,handleFocusTargetFocus:G}=an(g,P),I=Le("button",n,{state:{disabled:p,open:F},ref:[R,t,C,P],props:[w.reference,_,T,s,{[it]:"",id:x,"aria-haspopup":"dialog","aria-expanded":F,"aria-controls":H},u,L],stateAttributesMapping:f});return b&&!X?Y.jsxs(m.Fragment,{children:[Y.jsx(ye,{ref:A,onFocus:D}),Y.jsx(m.Fragment,{children:I},x),Y.jsx(ye,{ref:g.context.triggerFocusTargetRef,onFocus:G})]}):Y.jsx(m.Fragment,{children:I},x)}),Ye=m.createContext(void 0);function cn(){const e=m.useContext(Ye);if(e===void 0)throw new Error(pe(45));return e}const Cn=m.forwardRef(function(n,t){const{keepMounted:l=!1,...i}=n,{store:o}=re();return o.useState("mounted")||l?Y.jsx(Ye.Provider,{value:l,children:Y.jsx(at,{ref:t,...i})}):null}),Ge=m.createContext(void 0);function ln(){const e=m.useContext(Ge);if(!e)throw new Error(pe(46));return e}const bn=m.forwardRef(function(n,t){const{render:l,className:i,style:o,anchor:p,positionMethod:E="absolute",side:S="bottom",align:c="center",sideOffset:r=0,alignOffset:O=0,collisionBoundary:h="clipping-ancestors",collisionPadding:j=5,arrowPadding:u=5,sticky:B=!1,disableAnchorTracking:g=!1,collisionAvoidance:x=ct,...a}=n,{store:d}=re(),F=cn(),H=xt(),P=d.useState("floatingRootContext"),C=d.useState("mounted"),b=d.useState("open"),M=d.useState("openChangeReason"),N=d.useState("activeTriggerElement"),V=d.useState("modal"),X=d.useState("openMethod"),_=d.useState("positionerElement"),w=d.useState("instantType"),s=d.useState("transitionStatus"),T=d.useState("hasViewport"),L=m.useRef(null),R=lt(_,!1,!1),f=Yt({anchor:p,floatingRootContext:P,positionMethod:E,mounted:C,side:S,sideOffset:r,align:c,alignOffset:O,arrowPadding:u,collisionBoundary:h,collisionPadding:j,sticky:B,disableAnchorTracking:g,keepMounted:F,nodeId:H,collisionAvoidance:x,adaptiveOrigin:T?Xt:void 0}),A=P.useState("domReferenceElement");ge(()=>{const I=A,k=L.current;if(I&&(L.current=I),k&&I&&I!==k){d.set("instantType",void 0);const v=new AbortController;return R(()=>{d.set("instantType","trigger-change")},v.signal),()=>{v.abort()}}},[A,R,d]),Gt(b&&V===!0&&M!==W,X==="touch",_,N);const D=m.useCallback(I=>{d.set("positionerElement",I)},[d]),G={open:b,side:f.side,align:f.align,anchorHidden:f.anchorHidden,instant:w},U=Vt(n,G,{styles:f.positionerStyles,transitionStatus:s,props:a,refs:[t,D],hidden:!C,inert:!b});return Y.jsxs(Ge.Provider,{value:f,children:[C&&V===!0&&M!==W&&Y.jsx(Ft,{ref:d.context.internalBackdropRef,inert:ut(!b),cutout:N}),Y.jsx(kt,{id:H,children:U})]})}),un=m.createContext(void 0);function fn(){const[e,n]=m.useState(0),t=ne(()=>(n(i=>i+1),()=>{n(i=>Math.max(0,i-1))}));return{context:m.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}function dn(e){const{value:n,children:t}=e;return Y.jsx(un.Provider,{value:n,children:t})}const pn={...Ht,...pt},Rn=m.forwardRef(function(n,t){const{render:l,className:i,style:o,initialFocus:p,finalFocus:E,...S}=n,{store:c}=re(),r=ln(),O=Ut()!=null,{context:h,hasClosePart:j}=fn(),u=c.useState("open"),B=c.useState("openMethod"),g=c.useState("instantType"),x=c.useState("transitionStatus"),a=c.useState("popupProps"),d=c.useState("titleElementId"),F=c.useState("descriptionElementId"),H=c.useState("modal"),P=c.useState("mounted"),C=c.useState("openChangeReason"),b=c.useState("activeTriggerElement"),M=c.useState("floatingRootContext"),N=M.useState("floatingId"),V=c.useState("disabled"),X=c.useState("openOnHover"),_=c.useState("closeDelay"),w=S.id??N;ft({open:u,ref:c.context.popupRef,onComplete(){u&&c.context.onOpenChangeComplete?.(!0)}}),zt(M,{enabled:X&&!V,closeDelay:_});const s=p===void 0?wt(c.context.popupRef):p,T=H!==!1&&j;c.useSyncedValue("focusManagerModal",T);const L=m.useCallback(A=>{c.set("popupElement",A)},[c]),R={open:u,side:r.side,align:r.align,instant:g,transitionStatus:x},f=Le("div",n,{state:R,ref:[t,c.context.popupRef,L],props:[a,{id:w,role:"dialog",...Be,"aria-labelledby":d,"aria-describedby":F,onKeyDown(A){O&&At.has(A.key)&&A.stopPropagation()}},Kt(x),S],stateAttributesMapping:pn});return Y.jsx(Lt,{context:M,openInteractionType:B,modal:T,disabled:!P||C===W,initialFocus:s,returnFocus:E,restoreFocus:"popup",previousFocusableElement:dt(b)?b:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:Y.jsx(dn,{value:h,children:f})})});export{Tn as C,Pn as P,vn as a,Cn as b,bn as c,Rn as d};
import{k as Ne,r as i,j as e,c as n,S as Ie,ab as He,ac as Ge,X as Oe,Y as qe}from"./__vite-browser-external-CHbEWSwX.js";import{u as Ke}from"./useCurrency-QqSMR7Ba.js";import{u as Ee}from"./useTokenFormat-BLfmNxg5.js";import{M as Ze,T as Ve}from"./terminal-Bwl-eNY6.js";import{I as Je}from"./info-DoeeLajS.js";const Qe=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],et=Ne("pause",Qe);const tt=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],at=Ne("play",tt);const rt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],ot=Ne("rotate-ccw",rt),te={emerald:{light:["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],dark:["#2d333b","#065f46","#059669","#10b981","#34d399"],gridColor:{light:"rgba(16, 185, 129, 0.12)",dark:"rgba(52, 211, 153, 0.08)"}},ocean:{light:["#f1f5f9","#93c5fd","#60a5fa","#3b82f6","#1d4ed8"],dark:["#1e293b","#1e3a8a","#2563eb","#3b82f6","#60a5fa"],gridColor:{light:"rgba(59, 130, 246, 0.12)",dark:"rgba(96, 165, 250, 0.08)"}},neon:{light:["#faf5ff","#ebd5ff","#c084fc","#a855f7","#7e22ce"],dark:["#2e1065","#581c87","#8b5cf6","#a855f7","#c084fc"],gridColor:{light:"rgba(168, 85, 247, 0.12)",dark:"rgba(192, 132, 252, 0.08)"}},amber:{light:["#fffbeb","#fde68a","#f59e0b","#d97706","#b45309"],dark:["#451a03","#78350f","#b45309","#d97706","#f59e0b"],gridColor:{light:"rgba(245, 158, 11, 0.12)",dark:"rgba(245, 158, 11, 0.08)"}}};function nt(s,x){const h=/^#([0-9a-f]{6})$/i.exec(s);if(!h)return s;const c=parseInt(h[1],16),v=c>>16&255,D=c>>8&255,Y=c&255,R=T=>Math.max(0,Math.min(255,Math.round(T*x)));return`rgb(${R(v)}, ${R(D)}, ${R(Y)})`}function O(s,x,h,c,v){const D=Math.cos(c),Y=Math.sin(c),R=s*D-x*Y,T=s*Y+x*D,E=h,S=Math.cos(v),$=Math.sin(v),q=R,p=T*S-E*$,k=T*$+E*S;return{x:q,y:p,z:k}}function st(s,x,h,c,v){return O(s,x,h,c,v)}function Ae(s,x,h=c=>Number(c).toLocaleString()){const c=h(x);if(s>=4){const v=Math.floor(Math.random()*3)+1;return n(`heatmap.3d.voxel.joke.${v}`,{value:c})}else return s===3?n("heatmap.3d.voxel.level3",{value:c}):s===2?n("heatmap.3d.voxel.level2",{value:c}):s===1?n("heatmap.3d.voxel.level1",{value:c}):n("heatmap.3d.voxel.level0")}function Se({weeks:s,palette:x="auto",isDark:h=!1,interactive:c=!1,autoRotateInit:v=!1,onResetViewRef:D=null}){const{formatTokens:Y,formatTokensTooltip:R}=Ee(),T=te[x]||(x==="auto"?te.emerald:null),E=T?h?T.dark:T.light:Array.isArray(x)?x:h?te.emerald.dark:te.emerald.light,S=T?h?T.gridColor.dark:T.gridColor.light:h?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",$=-.2,q=.88,[p,k]=i.useState({yaw:$,pitch:q}),[ce,K]=i.useState(v),[he,L]=i.useState(1),C=c?13:10.5,fe=i.useMemo(()=>{const t=[],r=s.length;if(r===0||!c)return[];for(let l=0;l<=7;l++){const o=(l-3.5)*C,d=O(-r/2*C,o,0,p.yaw,p.pitch),u=O(r/2*C,o,0,p.yaw,p.pitch);t.push({d:`M${d.x},${d.y} L${u.x},${u.y}`,key:`horiz-${l}`})}for(let l=0;l<=r;l+=4){const o=(l-r/2)*C,d=O(o,-3.5*C,0,p.yaw,p.pitch),u=O(o,3.5*C,0,p.yaw,p.pitch);t.push({d:`M${d.x},${d.y} L${u.x},${u.y}`,key:`vert-${l}`})}if(r%4!==0){const l=(r-r/2)*C,o=O(l,-3.5*C,0,p.yaw,p.pitch),d=O(l,3.5*C,0,p.yaw,p.pitch);t.push({d:`M${o.x},${o.y} L${d.x},${d.y}`,key:"vert-last"})}return t},[s.length,p,C,c]);i.useEffect(()=>{D&&(D.current={reset:()=>{k({yaw:$,pitch:q}),K(!1),L(1),be()},toggleAutoRotate:t=>{K(t)}})},[D]);const Z=i.useRef(null),I=i.useRef(null),F=i.useRef(!1),de=i.useRef({x:0,y:0}),V=i.useRef({yaw:$,pitch:q}),U=i.useRef({x:0,y:0}),oe=i.useRef({x:0,y:0,time:0}),ne=i.useRef(null),[ge,ye]=i.useState(0),J=i.useRef(null),se=i.useRef(!0);i.useEffect(()=>(se.current=!0,()=>{se.current=!1}),[]);const be=()=>{J.current&&cancelAnimationFrame(J.current),ye(0);const t=performance.now(),r=1200,l=o=>{if(!se.current)return;const d=o-t,u=Math.min(1,d/r),j=1-Math.pow(1-u,3);ye(j),u<1?J.current=requestAnimationFrame(l):J.current=null};J.current=requestAnimationFrame(l)};i.useEffect(()=>(be(),()=>{J.current&&cancelAnimationFrame(J.current)}),[c]),i.useEffect(()=>{if(!ce||F.current||typeof window>"u"||typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;let r;const l=()=>{if(typeof document<"u"&&document.visibilityState==="hidden"){r=requestAnimationFrame(l);return}k(o=>({yaw:o.yaw+.002,pitch:o.pitch})),r=requestAnimationFrame(l)};return r=requestAnimationFrame(l),()=>cancelAnimationFrame(r)},[ce]);const me=(t,r)=>{c&&(F.current=!0,de.current={x:t,y:r},V.current={yaw:p.yaw,pitch:p.pitch},U.current={x:0,y:0},oe.current={x:t,y:r,time:performance.now()},ne.current&&cancelAnimationFrame(ne.current))},X=(t,r)=>{if(!F.current)return;const l=t-de.current.x,o=r-de.current.y,d=performance.now(),u=d-oe.current.time;u>0&&(U.current={x:(t-oe.current.x)/u,y:(r-oe.current.y)/u}),oe.current={x:t,y:r,time:d};const j=.005,f=V.current.yaw-l*j,g=Math.PI/2.3,P=Math.max(-g,Math.min(g,V.current.pitch-o*j));k({yaw:f,pitch:P})},ve=()=>{if(!F.current)return;F.current=!1;let t=-U.current.x*12,r=-U.current.y*12;const l=.95,o=()=>{F.current||(t*=l,r*=l,!(Math.abs(t)<.01&&Math.abs(r)<.01)&&(k(d=>{const u=d.yaw+t*.005,j=Math.PI/2.3,f=Math.max(-j,Math.min(j,d.pitch+r*.005));return{yaw:u,pitch:f}}),ne.current=requestAnimationFrame(o)))};ne.current=requestAnimationFrame(o)},[y,xe]=i.useState(null),[Q,pe]=i.useState({x:0,y:0,shiftX:0}),b=i.useRef(null);i.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]),i.useEffect(()=>{if(!c||!I.current)return;const t=l=>{l.preventDefault();const o=-l.deltaY*.0025;L(d=>{const u=d+o;return Math.max(.5,Math.min(3,u))})},r=I.current;return r.addEventListener("wheel",t,{passive:!1}),()=>{r.removeEventListener("wheel",t)}},[c]);const z=i.useMemo(()=>{const t=[];return s.forEach((r,l)=>{(Array.isArray(r)?r:[]).forEach((o,d)=>{o&&t.push({key:o.day||`${l}-${d}`,col:l,row:d,level:o.level||0,value:o.value||0,day:o.day,models:o.models||null})})}),t},[s]),ke=C-(c?1.8:1.5),we=c?38:28,ee=t=>Math.max(1.8,Number(t)/4*we),ae=i.useMemo(()=>{if(z.length===0)return[];const t=s.length;return z.map(r=>{const l=ee(r.level),o=Math.sqrt(Math.pow(r.col-t/2,2)+Math.pow(r.row-3.5,2)),d=Math.sqrt(Math.pow(t/2,2)+Math.pow(3.5,2)),u=o/d*.4,j=Math.min(1,Math.max(0,(ge-u)*(1/.6))),f=l*j,g=(r.col-t/2)*C,P=(r.row-3.5)*C,N=ke/2,G=[{x:g-N,y:P-N,z:0},{x:g+N,y:P-N,z:0},{x:g+N,y:P+N,z:0},{x:g-N,y:P+N,z:0},{x:g-N,y:P-N,z:f},{x:g+N,y:P-N,z:f},{x:g+N,y:P+N,z:f},{x:g-N,y:P+N,z:f}].map(W=>O(W.x,W.y,W.z,p.yaw,p.pitch)),ue=O(g,P,f/2,p.yaw,p.pitch),Le=[{name:"top",indices:[4,5,6,7],scale:1,normal:[0,0,1]},{name:"bottom",indices:[3,2,1,0],scale:.4,normal:[0,0,-1]},{name:"left",indices:[3,0,4,7],scale:.55,normal:[-1,0,0]},{name:"right",indices:[1,2,6,5],scale:.75,normal:[1,0,0]},{name:"front",indices:[0,1,5,4],scale:.85,normal:[0,-1,0]},{name:"back",indices:[2,3,7,6],scale:.65,normal:[0,1,0]}],Pe=E[Math.min(4,Math.max(0,Number(r.level)||0))],ze=[],De=.35,Ye=-.4,Ue=.83;return Le.forEach(W=>{const je=st(W.normal[0],W.normal[1],W.normal[2],p.yaw,p.pitch);if(je.z>.001){const Me=G[W.indices[0]],Te=G[W.indices[1]],_e=G[W.indices[2]],$e=G[W.indices[3]],Xe=`M${Me.x},${Me.y} L${Te.x},${Te.y} L${_e.x},${_e.y} L${$e.x},${$e.y} Z`,Be=je.x*De+je.y*Ye+je.z*Ue,We=h?.18:0,Fe=W.scale*(.82+.28*Math.max(0,Be))+We;ze.push({name:W.name,d:Xe,fill:nt(Pe,Fe)})}}),{...r,centerProj:ue,renderedFaces:ze}})},[z,p,E,s.length,ge,C,ke,we]),le=i.useMemo(()=>[...ae].sort((t,r)=>t.centerProj.z-r.centerProj.z),[ae]),_=i.useMemo(()=>{if(le.length===0)return{minX:-100,minY:-100,maxX:100,maxY:100};let t=1/0,r=1/0,l=-1/0,o=-1/0;return le.forEach(d=>{const u=C*2,j=d.centerProj.x,f=d.centerProj.y;j-u<t&&(t=j-u),j+u>l&&(l=j+u),f-u<r&&(r=f-u),f+u>o&&(o=f+u)}),{minX:t,minY:r,maxX:l,maxY:o}},[le,C]),A=12,a=_.maxX-_.minX+A*2,m=_.maxY-_.minY+A*2,M=a/he,w=m/he,B=_.minX-A+(a-M)/2,H=_.minY-A+(m-w)/2,ie=`${B} ${H} ${M} ${w}`;return z.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:n("heatmap.empty")}):e.jsxs("div",{ref:I,className:`relative select-none outline-none ${c?"cursor-grab active:cursor-grabbing w-full h-full flex items-center justify-center":"w-full overflow-hidden flex justify-center"}`,onMouseDown:t=>{if(!c)return;me(t.clientX,t.clientY);const r=o=>X(o.clientX,o.clientY),l=()=>{ve(),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",l)},onTouchStart:t=>{!c||t.touches.length===0||me(t.touches[0].clientX,t.touches[0].clientY)},onTouchMove:t=>{!c||t.touches.length===0||X(t.touches[0].clientX,t.touches[0].clientY)},onTouchEnd:()=>{c&&ve()},children:[e.jsxs("svg",{ref:Z,viewBox:ie,width:c?"95%":"100%",height:c?"95%":"auto",role:"img","aria-label":n("heatmap.iso.aria")||"3D interactive activity heatmap",style:{display:"block",width:"100%",height:"auto",maxWidth:c?"none":`${a}px`,maxHeight:c?"78vh":"none"},className:"transition-transform duration-300 ease-out",children:[c&&fe.map(t=>e.jsx("path",{d:t.d,fill:"none",stroke:S,strokeWidth:.25,strokeDasharray:"1.5 2.5",strokeLinecap:"round"},t.key)),le.map(t=>{const r=y&&y.key===t.key;return e.jsxs("g",{onMouseEnter:l=>{if(b.current&&(clearTimeout(b.current),b.current=null),xe(t),c&&Z.current){const o=O((t.col-s.length/2)*C,(t.row-3.5)*C,ee(t.level),p.yaw,p.pitch);let d=0,u=0;const j=Z.current;if(I.current&&typeof j.createSVGPoint=="function"&&typeof j.getScreenCTM=="function")try{const N=j.createSVGPoint();N.x=o.x,N.y=o.y;const re=j.getScreenCTM();if(re){const G=N.matrixTransform(re),ue=I.current.getBoundingClientRect();d=G.x-ue.left,u=G.y-ue.top}}catch{const re=j.getBoundingClientRect(),G=_.maxX-_.minX+A*2,ue=_.maxY-_.minY+A*2;d=(o.x-(_.minX-A))/G*re.width,u=(o.y-(_.minY-A))/ue*re.height}else{const N=j.getBoundingClientRect(),re=_.maxX-_.minX+A*2,G=_.maxY-_.minY+A*2;d=(o.x-(_.minX-A))/re*N.width,u=(o.y-(_.minY-A))/G*N.height}const f=140;let g=0;const P=I.current?I.current.getBoundingClientRect().width:j.getBoundingClientRect().width;d<f?g=f-d:d>P-f&&(g=P-f-d),pe({x:d,y:u,shiftX:g})}},onMouseLeave:()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{xe(null)},150)},className:"transition-all duration-200",style:{filter:r?"brightness(1.15) drop-shadow(0 4px 6px rgba(0,0,0,0.15))":"none",cursor:c?"pointer":"default"},children:[!c&&t.day&&e.jsx("title",{children:`${t.day}: ${R(t.value)} tokens`}),t.renderedFaces.map((l,o)=>e.jsx("path",{d:l.d,fill:l.fill,stroke:l.fill,strokeWidth:.25,strokeLinejoin:"round"},o))]},t.key)})]}),c&&y&&e.jsxs("div",{onMouseEnter:()=>{b.current&&(clearTimeout(b.current),b.current=null)},onMouseLeave:()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{xe(null)},150)},className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out",style:{left:`${Q.x}px`,top:`${Q.y}px`},children:[e.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${Q.shiftX}px))`},children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:y.day}),(()=>{const t=y.level===0?h?"#9ca3af":"#6b7280":E[y.level];return e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:t+"22",color:t,border:`1px solid ${t}44`},children:["Level ",y.level]})})()]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{title:R(y.value),className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:Y(y.value)}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),y.models&&Object.keys(y.models).length>0?e.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 scrollbar-thin",children:Object.entries(y.models).map(([t,r])=>({name:t,val:Number(r)})).sort((t,r)=>r.val-t.val).map(({name:t,val:r})=>{const l=Number(y.value)||1,o=Math.round(r/l*100);return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[e.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:t,children:t}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{title:R(r),className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:Y(r)}),e.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[o,"%"]})]})]}),e.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${o}%`,backgroundColor:E[4],boxShadow:`0 0 4px ${E[4]}55`}})})]},t)})})]}):e.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:Ae(y.level,y.value,Y)})]})]}),e.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]})]})}const lt=12,it=3,ct=26,dt=["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],mt=["#121212","#065f46","#059669","#10b981","#34d399"];function xt(s){if(typeof s!="string")return null;const x=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s.trim());if(!x)return null;const h=new Date(Date.UTC(Number(x[1]),Number(x[2])-1,Number(x[3])));return Number.isFinite(h.getTime())?h:null}function Re(s,x){return new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()+x))}function ut(s,x){return Math.floor((Date.UTC(x.getUTCFullYear(),x.getUTCMonth(),x.getUTCDate())-Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()))/864e5)}function pt(s,x){const h=x==="mon"?1:0,c=s.getUTCDay();return Re(s,-((c-h+7)%7))}function ht(s,x,h,c){if(!s)return[];const v=xt(x)||new Date,D=[];for(let S=11;S>=0;S-=1)D.push(new Date(Date.UTC(v.getUTCFullYear(),v.getUTCMonth()-S,1)));const Y=pt(v,h),R=Re(Y,-(s-1)*7),T=[],E=new Set;for(const S of D){const $=Math.floor(ut(R,S)/7);$<0||$>=s||E.has($)||(E.add($),T.push({label:c[S.getUTCMonth()],index:$}))}return T}function jt({heatmap:s,timeZoneLabel:x,timeZoneShortLabel:h,hideLegend:c=!1,embedded:v=!1}){const{resolvedTheme:D}=Ie(),{currency:Y,rate:R}=Ke(),{formatTokens:T,formatTokensTooltip:E}=Ee(),S=D==="dark",$=S?mt:dt,q=i.useRef(null),p=i.useRef(null),[k,ce]=i.useState(null),[K,he]=i.useState({x:0,y:0,shiftX:0,flipY:!1}),L=i.useRef(null);i.useEffect(()=>()=>{L.current&&clearTimeout(L.current)},[]);const[C,fe]=i.useState(!1),[Z,I]=i.useState(!1),[F,de]=i.useState(!1),V=i.useRef(null),[U,oe]=i.useState("emerald"),ne=[n("heatmap.month.jan"),n("heatmap.month.feb"),n("heatmap.month.mar"),n("heatmap.month.apr"),n("heatmap.month.may"),n("heatmap.month.jun"),n("heatmap.month.jul"),n("heatmap.month.aug"),n("heatmap.month.sep"),n("heatmap.month.oct"),n("heatmap.month.nov"),n("heatmap.month.dec")],ge=(a,m)=>{if(!m||!m.day)return;L.current&&(clearTimeout(L.current),L.current=null),ce(m);const M=a.currentTarget.getBoundingClientRect(),w=typeof window<"u"?window.innerWidth:1024,B=M.left+M.width/2,H=M.top<300,ie=H?M.bottom:M.top,t=140;let r=0;B<t?r=t-B:B>w-t&&(r=w-t-B),he({x:B,y:ie,shiftX:r,flipY:H})},ye=()=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{ce(null)},150)},J=()=>{I(!1),fe(!0)},se=()=>{I(!0)},be=a=>{a.target===a.currentTarget&&Z&&(fe(!1),I(!1))};i.useEffect(()=>{if(!C||Z)return;const a=m=>{m.key==="Escape"&&se()};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[C,Z]);const me=i.useMemo(()=>({emerald:{accentText:"text-emerald-500 dark:text-emerald-400",accentBg:"bg-emerald-500/10 dark:bg-emerald-400/10",accentBorder:"border-emerald-500/20 dark:border-emerald-400/15",hoverBorder:"hover:border-emerald-500/30 dark:hover:border-emerald-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(16,185,129,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(52,211,153,0.25)]",rawColor:"#10b981"},ocean:{accentText:"text-blue-500 dark:text-blue-400",accentBg:"bg-blue-500/10 dark:bg-blue-400/10",accentBorder:"border-blue-500/20 dark:border-blue-400/15",hoverBorder:"hover:border-blue-500/30 dark:hover:border-blue-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(59,130,246,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(96,165,250,0.25)]",rawColor:"#3b82f6"},neon:{accentText:"text-purple-500 dark:text-purple-400",accentBg:"bg-purple-500/10 dark:bg-purple-400/10",accentBorder:"border-purple-500/20 dark:border-purple-400/15",hoverBorder:"hover:border-purple-500/30 dark:hover:border-purple-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(168,85,247,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(192,132,252,0.25)]",rawColor:"#a855f7"},amber:{accentText:"text-amber-500 dark:text-amber-400",accentBg:"bg-amber-500/10 dark:bg-amber-400/10",accentBorder:"border-amber-500/20 dark:border-amber-400/15",hoverBorder:"hover:border-amber-500/30 dark:hover:border-amber-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(245,158,11,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(245,158,11,0.25)]",rawColor:"#f59e0b"}}),[]),X=me[U]||me.emerald,ve=te[U]?S?te[U].dark:te[U].light:S?te.emerald.dark:te.emerald.light,[y,xe]=i.useState(()=>{if(v)return"2d";try{return window.localStorage?.getItem("tt:heatmap-view")==="3d"?"3d":"2d"}catch{return"2d"}});i.useEffect(()=>{if(!v)try{window.localStorage?.setItem("tt:heatmap-view",y)}catch{}},[y,v]),i.useEffect(()=>{if(y!=="2d")return;const a=q.current;a&&(a.scrollLeft=a.scrollWidth)},[s?.weeks,y]),i.useEffect(()=>{const a=q.current;if(!a)return;const m=()=>{L.current&&(clearTimeout(L.current),L.current=null),ce(null)};return a.addEventListener("scroll",m),()=>a.removeEventListener("scroll",m)},[]);const Q=s?.week_starts_on==="mon"?"mon":"sun",pe=i.useMemo(()=>{const a=Array.isArray(s?.weeks)?s.weeks:[];if(!a.length)return{weeks:[]};const m=[];for(const M of a)for(const w of Array.isArray(M)?M:[])w?.day&&m.push({day:w.day,total_tokens:w.total_tokens??w.value??0,billable_total_tokens:w.billable_total_tokens??w.value??w.total_tokens??0,models:w.models??null});return He({dailyRows:m,weeks:Math.max(52,a.length),to:s?.to,weekStartsOn:Q})},[s?.to,s?.weeks,Q]),b=pe?.weeks||[],z=i.useMemo(()=>{let a=0,m=0,M={day:"无数据",value:0},w=0,B=0;const H=[];b.forEach(f=>{(Array.isArray(f)?f:[]).forEach(g=>{g&&g.day&&H.push(g)})}),H.sort((f,g)=>f.day.localeCompare(g.day)),H.forEach(f=>{const g=Number(f.value)||0;a+=g,g>0?(m++,w++,w>B&&(B=w)):w=0,g>M.value&&(M={day:f.day,value:g})});const ie=H.length||365,t=(m/ie*100).toFixed(1);let r="heatmap.3d.modal.ai.eval.default",l="heatmap.3d.modal.ai.title.default";a>=15e6?(l="heatmap.3d.modal.ai.title.peak",r="heatmap.3d.modal.ai.eval.peak"):a>=5e6?(l="heatmap.3d.modal.ai.title.heavy",r="heatmap.3d.modal.ai.eval.heavy"):a>=1e6?(l="heatmap.3d.modal.ai.title.core",r="heatmap.3d.modal.ai.eval.core"):a>=2e4&&(l="heatmap.3d.modal.ai.title.steady",r="heatmap.3d.modal.ai.eval.steady");const o=s?.total_cost_usd,d=Number(o),j=o!=null&&(typeof o!="string"||o.trim()!=="")&&Number.isFinite(d)?d:a/15e5;return{totalTokens:a,activeDays:m,activeRate:t,maxSingleDay:M,maxStreak:B,aiEvaluationTitleKey:l,aiEvaluationKey:r,totalCostUsd:j}},[b,s?.total_cost_usd]),Ce=i.useMemo(()=>Ge(z.totalCostUsd,{currency:Y,rate:R}),[z.totalCostUsd,Y,R]),ke=Q==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(a=>n(`heatmap.day.${a.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(a=>n(`heatmap.day.${a.toLowerCase()}`)),we=i.useMemo(()=>ht(b.length,pe?.to,Q,ne),[pe?.to,b.length,Q,ne]);if(!b.length)return e.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:n("heatmap.empty")});const ee=v?10:lt,ae=v?2:it,le=v?22:ct,_=le+b.length*ee+Math.max(0,b.length-1)*ae,A=`${le}px repeat(${b.length}, ${ee}px)`;return e.jsxs("div",{ref:p,className:v?"relative":"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[!v&&e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:n("heatmap.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{role:"tablist","aria-label":"Heatmap view",className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[10px]",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":y==="2d",onClick:()=>xe("2d"),className:y==="2d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:n("heatmap.view.2d")}),e.jsx("button",{type:"button",role:"tab","aria-selected":y==="3d",onClick:()=>xe("3d"),className:y==="3d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:n("heatmap.view.3d")})]}),e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-450",children:h||n("heatmap.legend.utc")})]})]}),y==="3d"&&e.jsxs("div",{onClick:J,className:"cursor-pointer group relative overflow-hidden rounded-lg hover:border-oai-gray-350 dark:hover:border-oai-gray-700 border border-transparent transition-all",title:n("heatmap.3d.hover_tip"),children:[e.jsx(Se,{weeks:b,isDark:S,palette:U}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-oai-gray-900/5 to-transparent pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity flex items-end justify-center pb-2",children:e.jsxs("span",{className:"text-[10px] bg-white/95 dark:bg-oai-gray-900/95 shadow border border-oai-gray-200/60 dark:border-oai-gray-800/80 px-2.5 py-1 rounded-full font-medium text-oai-gray-500 dark:text-oai-gray-400 flex items-center gap-1 transform translate-y-2 group-hover:translate-y-0 transition-transform duration-200",children:[e.jsx(Ze,{size:9}),n("heatmap.3d.hover_tip")]})})]}),y==="2d"&&e.jsx("div",{ref:q,className:`overflow-x-auto overflow-y-hidden heatmap-scroll-thin${v?"":" pb-1"}`,children:e.jsxs("div",{style:{minWidth:_},children:[e.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:A,columnGap:ae},children:[e.jsx("span",{}),we.map(a=>e.jsx("span",{style:{gridColumnStart:a.index+2},className:"whitespace-nowrap",children:a.label},`${a.label}-${a.index}`))]}),e.jsxs("div",{className:"grid",style:{gridTemplateColumns:A,columnGap:ae},children:[e.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${ee}px)`,rowGap:ae},children:ke.map(a=>e.jsx("span",{className:"leading-none",children:a},a))}),e.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${ee}px)`,gap:ae},children:b.map((a,m)=>(Array.isArray(a)?a:[]).map((M,w)=>{if(!M)return null;const B=M.day||`e-${m}-${w}`,H=Number(M.level)||0,ie=$[H]||$[0];return e.jsx("span",{onMouseEnter:t=>ge(t,M),onMouseLeave:ye,className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10 cursor-pointer",style:{width:ee,height:ee,background:ie}},B)}))})]})]})}),!c&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:n("heatmap.legend.less")}),e.jsx("div",{className:"flex gap-0.5",children:$.map((a,m)=>e.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:a}},m))}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:n("heatmap.legend.more")})]}),C&&e.jsx("div",{onAnimationEnd:be,onClick:a=>{a.target===a.currentTarget&&se()},className:`fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40 ${Z?"animate-tt-fade-out":"animate-tt-fade-in"}`,children:e.jsxs("div",{className:`relative w-full max-w-6xl h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden ${Z?"animate-tt-modal-exit":"animate-tt-modal"}`,children:[e.jsx("button",{type:"button",onClick:se,className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 transition-all duration-300",children:e.jsx(Oe,{size:16})}),e.jsxs("div",{className:"w-full md:w-[340px] border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:X.rawColor}}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:X.rawColor}})]}),e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:"3D Insight"})]}),e.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:n("heatmap.3d.modal.title")}),e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:n("heatmap.3d.modal.desc")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[e.jsxs("div",{className:"flex flex-col gap-1 relative group cursor-help",children:[e.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:n("heatmap.3d.modal.stats.precision_total_tokens")}),e.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[E(z.totalTokens)," Tokens"]})]})}),e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.total_tokens")}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:T(z.totalTokens,{decimals:2})}),e.jsx("div",{className:"opacity-30 group-hover:opacity-60 transition-opacity",children:e.jsx("svg",{width:"24",height:"10",viewBox:"0 0 24 10",fill:"none",children:e.jsx("path",{d:"M1 9C3 7 5 7 7 4C9 1 11 0 13 2C15 4 17 0 23 0",stroke:X.rawColor,strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.estimated_cost")}),e.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:Ce})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.active_rate_days")}),e.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[z.activeRate,"% ",e.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",z.activeDays,"D)"]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.max_streak")}),e.jsxs("span",{className:"text-xl font-black text-amber-500 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[z.maxStreak," ",e.jsx("span",{className:"text-[10px] font-bold text-amber-500/80 font-mono",children:n("heatmap.3d.modal.stats.days_suffix")})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 col-span-2 relative group cursor-help",children:[e.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:n("heatmap.3d.modal.stats.precision_peak_value")}),e.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[z.maxSingleDay.value>0?E(z.maxSingleDay.value):n("heatmap.3d.modal.stats.no_data")," Tokens"]}),e.jsx("span",{className:"text-[8px] text-zinc-400 dark:text-zinc-500 mt-0.5",children:z.maxSingleDay.day!=="无数据"?z.maxSingleDay.day:n("heatmap.3d.modal.stats.no_data")})]})}),e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.peak_day")}),e.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[z.maxSingleDay.value>0?T(z.maxSingleDay.value,{decimals:2}):n("heatmap.3d.modal.stats.no_data")," ",e.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",z.maxSingleDay.day!=="无数据"?z.maxSingleDay.day:n("heatmap.3d.modal.stats.no_data"),")"]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2.5 py-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[e.jsx(Ve,{size:11,style:{color:X.rawColor}}),e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:X.rawColor},children:n(z.aiEvaluationTitleKey)})]}),e.jsxs("div",{className:"pl-3.5 border-l-2 relative transition-all duration-300 group",style:{borderColor:X.rawColor},children:[e.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:X.rawColor}}),e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:n(z.aiEvaluationKey)})]})]}),e.jsx("div",{className:"mt-auto border-t border-zinc-200/50 dark:border-zinc-800/50 pt-4 select-none",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.legend.title")}),e.jsx("span",{className:"text-[10px] font-medium text-zinc-500 dark:text-zinc-400",children:n(`heatmap.3d.modal.palette.${U}`)})]}),e.jsx("div",{className:"flex gap-1",children:ve.map((a,m)=>e.jsx("div",{className:"flex-1 h-1 rounded-[2px]",style:{backgroundColor:a},title:`Level ${m}`},m))})]})})]}),e.jsxs("div",{className:"flex-1 h-full relative flex items-center justify-center overflow-hidden p-4",children:[e.jsx("div",{className:"absolute top-1/4 left-1/3 w-96 h-96 rounded-full blur-[130px] pointer-events-none -translate-x-1/2 -translate-y-1/2 transition-all duration-500",style:{backgroundColor:X.rawColor+"15"}}),e.jsx("div",{className:"absolute bottom-1/4 right-1/3 w-80 h-80 rounded-full blur-[120px] pointer-events-none translate-x-1/2 translate-y-1/2 bg-purple-500/[0.04] dark:bg-purple-500/[0.08]"}),e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 flex items-center gap-3 p-1.5 backdrop-blur-md bg-white/70 dark:bg-oai-gray-900/75 border border-oai-gray-200/60 dark:border-oai-gray-800/80 rounded-full shadow-lg z-30 select-none",children:[e.jsx("div",{className:"flex items-center gap-1.5 px-2",children:Object.keys(me).map(a=>{const m=U===a;return e.jsx("button",{type:"button",onClick:()=>oe(a),title:n(`heatmap.3d.modal.palette.${a}`),className:`w-3.5 h-3.5 rounded-full transition-all duration-200 relative hover:scale-125 ${a==="emerald"?"bg-[#10b981]":a==="ocean"?"bg-[#3b82f6]":a==="neon"?"bg-[#a855f7]":"bg-[#f59e0b]"}`,children:m&&e.jsx("span",{className:"absolute inset-0 rounded-full ring-2 ring-offset-1 ring-offset-white dark:ring-offset-oai-gray-900 ring-oai-gray-900 dark:ring-white scale-110"})},a)})}),e.jsx("div",{className:"w-[1px] h-4 bg-oai-gray-200 dark:bg-oai-gray-800"}),e.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[e.jsx("button",{type:"button",onClick:()=>{const a=!F;de(a),V.current&&V.current.toggleAutoRotate(a)},title:F?n("heatmap.3d.modal.control.pause"):n("heatmap.3d.modal.control.play"),className:`p-1.5 rounded-full transition-all duration-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 ${F?X.accentText:"text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250"}`,children:F?e.jsx(et,{size:12}):e.jsx(at,{size:12})}),e.jsx("button",{type:"button",onClick:()=>{de(!1),V.current&&V.current.reset()},title:n("heatmap.3d.modal.control.reset"),className:"p-1.5 rounded-full text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-all duration-200",children:e.jsx(ot,{size:12})})]})]}),e.jsx(Se,{weeks:b,isDark:S,interactive:!0,palette:U,autoRotateInit:F,onResetViewRef:V}),e.jsxs("div",{className:"absolute bottom-4 right-4 flex items-center gap-1.5 text-[9px] font-bold text-oai-gray-400 bg-white/80 dark:bg-oai-gray-900/80 border border-oai-gray-200/50 dark:border-oai-gray-800/80 rounded-md px-2.5 py-1.5 select-none pointer-events-none backdrop-blur-md shadow-sm",children:[e.jsx(Je,{size:10,className:X.accentText}),e.jsx("span",{children:n("heatmap.3d.modal.footer.tip")})]})]})]})}),k&&!C&&typeof document<"u"&&qe.createPortal(e.jsxs("div",{className:"fixed z-[9999] w-0 h-0 transition-all duration-100 ease-out pointer-events-none",style:{position:"fixed",left:`${K.x}px`,top:`${K.y}px`},children:[e.jsxs("div",{className:`absolute left-0 ${K.flipY?"top-[10px]":"bottom-[10px]"} backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100`,style:{transform:`translateX(calc(-50% + ${K.shiftX}px))`},children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:k.day}),(()=>{const a=k.level===0?S?"#9ca3af":"#6b7280":$[k.level];return e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:a+"22",color:a,border:`1px solid ${a}44`},children:["Level ",k.level]})})()]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{title:E(k.total_tokens??k.value),className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:T(k.total_tokens??k.value)}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),k.models&&Object.keys(k.models).length>0?e.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 oai-scrollbar",children:Object.entries(k.models).map(([a,m])=>({name:a,val:Number(m)})).sort((a,m)=>m.val-a.val).map(({name:a,val:m})=>{const M=Number(k.total_tokens??k.value)||1,w=Math.round(m/M*100);return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[e.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:a,children:a}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{title:E(m),className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:T(m)}),e.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[w,"%"]})]})]}),e.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${w}%`,backgroundColor:$[4],boxShadow:`0 0 4px ${$[4]}55`}})})]},a)})})]}):e.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:Ae(k.level,k.total_tokens??k.value,T)})]})]}),e.jsx("div",{className:`absolute left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 shadow-sm ${K.flipY?"top-[6px] border-l border-t":"bottom-[6px] border-r border-b"} border-oai-gray-200/50 dark:border-oai-gray-800/50`,style:K.flipY?{marginTop:"1px"}:{marginBottom:"1px"}})]}),document.body),e.jsx("style",{children:`
@keyframes tt-fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes tt-fade-out {
from { opacity: 1; }
to { opacity: 0; }
}
@keyframes tt-modal-entrance {
from {
opacity: 0;
transform: scale(0.96) translateY(10px);
}
to {
opacity: 1;
transform: scale(1) translateY(0);
}
}
@keyframes tt-modal-exit {
from {
opacity: 1;
transform: scale(1) translateY(0);
}
to {
opacity: 0;
transform: scale(0.96) translateY(10px);
}
}
.animate-tt-fade-in {
animation: tt-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.animate-tt-fade-out {
animation: tt-fade-out 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.animate-tt-modal {
animation: tt-modal-entrance 0.3s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
}
.animate-tt-modal-exit {
animation: tt-modal-exit 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
`})]})}const ft={anythingllm:"AnythingLLM"};function gt(s){return String(s||"").trim().toLowerCase().replace(/[\s_-]+/g,"")}function Nt(s){const x=String(s||"").trim();if(!x)return"";const h=ft[gt(x)];return h||x.charAt(0).toUpperCase()+x.slice(1)}export{jt as A,Nt as f};
import{d,e as m,r as t,j as e,L as l,c as o,f as x}from"./__vite-browser-external-CHbEWSwX.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};
import{r as v,J as l,K as w,y as k,j as e,b as x}from"./__vite-browser-external-CHbEWSwX.js";import{u as j,a as N,s as i,L as C,b as E,S as I,c as R,d as T,C as L,e as A,f as P,g as _,h as D,i as G,j as M}from"./SelectItemText-Ca7gf5A0.js";import{C as O}from"./check-Dvngccc0.js";const V=v.forwardRef(function(t,s){const{render:n,className:f,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"?E.className:void 0},S=w(b=>{r.set("listElement",b)});return k("div",t,{ref:[s,S],props:[m,c]})}),z="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 J({value:y,onValueChange:t,options:s=[],ariaLabel:n,id:f,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(I,{value:y,items:h,disabled:o,onValueChange:a=>{!o&&a!=null&&t?.(a)},children:[e.jsxs(R,{id:f,"aria-label":n,className:x(z,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(L,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),e.jsx(A,{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(V,{role:"listbox","aria-label":n,children:s.map(a=>e.jsxs(D,{value:a.value,disabled:a.disabled,className:({selected:p,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",p?"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(G,{children:e.jsx(O,{className:"h-3 w-3","aria-hidden":!0})})}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.jsx(M,{children:a.label})})]},String(a.value)))})})})})]})}export{J as S};

Sorry, the diff of this file is too big to display

import{k as w,r as c,a2 as ae,a4 as ie,be as G,j as t,x as U,P as se,b as N,c as a,e as oe,au as re,bf as le,az as ce,aA as ue,a8 as F,bg as de,bh as ge,U as he,R as C,H as pe,S as me,bi as R,l as I,bj as be,bk as fe,M as xe,bl as ye,v as ve,bm as je,bn as ke,bo as Ne,bp as Se,bq as we,br as Ce,bs as Le,L as Ee,b3 as Ae,bt as Ge,aq as P}from"./__vite-browser-external-CHbEWSwX.js";import{u as Ie,L as _}from"./use-limits-display-prefs-B-zzSXHf.js";import{a as O,l as T}from"./limits-providers-Db3iK5TG.js";import{a as k,T as j,b,S as L,u as H}from"./use-native-settings-CIHg16YZ.js";import{P as Pe,u as _e,a as Oe}from"./use-session-efficiency-pref-DUe7bWPZ.js";import{C as Te}from"./check-Dvngccc0.js";import{C as De}from"./copy-D592E6jX.js";import{u as Me}from"./useCurrency-QqSMR7Ba.js";import{u as Ue}from"./useTokenFormat-BLfmNxg5.js";import{S as $}from"./Select-DE6DMSrS.js";import{I as Fe}from"./info-DoeeLajS.js";import{C as Re}from"./ConfirmModal-CjKotIxk.js";import{A as He}from"./arrow-up-right-B1yj6nxk.js";import{D as $e}from"./download-HHcFs0Ff.js";import"./Card-D4wKdGxL.js";import"./SelectItemText-Ca7gf5A0.js";import"./useScrollLock-DdUQVKDA.js";import"./DialogTitle-qsUpNlJa.js";import"./DialogDescription-D0X0v38O.js";const Be=[["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"}]],Ve=w("activity",Be);const ze=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ke=w("grip-vertical",ze);const qe=[["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"}]],Ze=w("languages",qe);const We=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ye=w("log-out",We),Qe=e=>!e.isLayoutDirty&&e.willUpdate(!1);function D(){const e=new Set,n=new WeakMap,i=()=>e.forEach(Qe);return{add:s=>{e.add(s),n.set(s,s.addEventListener("willUpdate",i))},remove:s=>{e.delete(s);const o=n.get(s);o&&(o(),n.delete(s)),i()},dirty:i}}const Je=c.createContext(null);function Xe(){const e=c.useRef(!1);return ae(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function et(){const e=Xe(),[n,i]=c.useState(0),s=c.useCallback(()=>{e.current&&i(n+1)},[n]);return[c.useCallback(()=>ie.postRender(s),[s]),n]}const B=e=>e===!0,tt=e=>B(e===!0)||e==="id",nt=({children:e,id:n,inherit:i=!0})=>{const s=c.useContext(G),o=c.useContext(Je),[r,l]=et(),u=c.useRef(null),g=s.id||o;u.current===null&&(tt(i)&&g&&(n=n?g+"-"+n:g),u.current={id:n,group:B(i)&&s.group||D()});const h=c.useMemo(()=>({...u.current,forceRender:r}),[l]);return t.jsx(G.Provider,{value:h,children:e})},at="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function it({checked:e,onChange:n,ariaLabel:i}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":i,onClick:n,className:N("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:N("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function st({prefs:e}){const{order:n,visibility:i,toggle:s,moveToward:o}=e,[r,l]=c.useState(null),[u,g]=c.useState(null),h=d=>f=>{l(d),f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",d)},m=d=>f=>{f.preventDefault(),f.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},x=()=>{l(null),g(null)},y=d=>{d.preventDefault(),l(null),g(null)};return t.jsx(nt,{children:t.jsx("div",{className:"flex flex-col",children:n.map(d=>{const f=i[d]!==!1,p=r===d;return t.jsxs(U.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:h(d),onDragOver:m(d),onDragEnd:x,onDrop:y,className:N("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",p&&"opacity-40"),style:{cursor:p?"grabbing":"grab"},children:[t.jsx(Ke,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),O(d)?t.jsx(se,{provider:O(d),size:18,className:N("pointer-events-none",at)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:T(d)}),t.jsx("div",{onMouseDown:v=>v.stopPropagation(),draggable:!1,children:t.jsx(it,{checked:f,onChange:()=>s(d),ariaLabel:`${a("limits.settings.toggle_visible")}: ${T(d)}`})})]},d)})})})}function ot(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},i=e.profile&&typeof e.profile=="object"?e.profile:{},s=n.full_name||n.name||i.name||n.user_name||n.preferred_username;return typeof s=="string"&&s.trim()?s.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function rt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function lt(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const i=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),s=n.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=i?.[1]||s?.[1];return o?`https://github.com/${o}`:null}function E(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function ct(e,n,i){const[s,o]=c.useState(()=>re()),r=n&&i&&le(),l=c.useCallback(async()=>{const u=!s;if(ce(u),o(u),!!u)try{await ue(()=>e())}catch(g){E("cloud sync",g)}},[s,e]);return{cloudSyncOn:s,handleCloudSyncToggle:l,showLocalCloudSync:r}}function ut(e){const[n,i]=c.useState(!1),[s,o]=c.useState(!1),[r,l]=c.useState(!1),[u,g]=c.useState(!1),[h,m]=c.useState(null),[x,y]=c.useState(!1),[d,f]=c.useState(""),[p,v]=c.useState(!1),[S,A]=c.useState(""),[q,Z]=c.useState(""),[W,Y]=c.useState(!1),[Q,J]=c.useState(null),X=c.useMemo(()=>ot(e),[e]),ee=c.useMemo(()=>rt(e),[e]),te=c.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),ne=c.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:A,setProfileLoading:l,setPublicProfileOn:i,setShowGithubOn:v}),[]);return{anonymousOn:s,customDisplayName:h,displayName:X,editingGithub:W,editingName:x,email:ee,githubError:Q,githubInput:q,githubUrl:S,loadSetters:ne,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:Y,setEditingName:y,setGithubError:J,setGithubInput:Z,setGithubUrl:A,setNameInput:f,setProfileLoading:l,setProfileSaving:g,setPublicProfileOn:i,setShowGithubOn:v,showGithubOn:p,userId:te}}function dt(e,n,i){c.useEffect(()=>{if(!n)return;let s=!0;return i.setProfileLoading(!0),(async()=>{try{const o=await F({getAccessToken:e});if(!s||!o)return;const r=await de({accessToken:o});if(!s)return;i.setPublicProfileOn(!!r?.enabled),i.setAnonymousOn(!!r?.anonymous),r?.display_name&&i.setCustomDisplayName(r.display_name),i.setShowGithubOn(!!r?.show_github_url),i.setGithubUrl(r?.github_url||"")}catch(o){E("load public profile",o)}finally{s&&i.setProfileLoading(!1)}})(),()=>{s=!1}},[e,n,i])}function gt(e,n){return c.useCallback(async(i,{label:s,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await F({getAccessToken:e});if(!l)return!1;const u=await ge({accessToken:l,...i});return r?.(u),!0}catch(l){return o?o(l):E(s||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function ht(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function pt(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function mt(e,n){const i=c.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:c.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:i}}function bt(e,n,i){const s=c.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await n({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),i?.()}})},[n,e,i]),o=c.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:s,startEditingName:o}}function ft(e,n){const i=c.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),s=c.useCallback(async()=>{const r=lt(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(a("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||a("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=c.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:s,handleShowGithubToggle:i,startEditingGithub:o}}function xt(){const e=oe(),n=ut(e.user),i=ct(e.getAccessToken,e.enabled,e.signedIn);dt(e.getAccessToken,e.signedIn,n.loadSetters);const s=gt(e.getAccessToken,n),o=mt(n,s),r=bt(n,s,e.refreshDisplayName),l=ft(n,s);return{...e,...i,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:ht(n,{...o,...r}),github:pt(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function V({disabled:e,onCancel:n,onSave:i,saveLabel:s=a("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:i,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:s}),t.jsx("button",{type:"button",onClick:n,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:a("settings.account.cancel")})]})}function yt({nameInput:e,setEditingName:n,setNameInput:i,profileSaving:s,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>i(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&n(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:a("settings.account.displayName")}),t.jsx(V,{disabled:s||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:s?a("settings.account.saving"):void 0})]})}function vt({githubError:e,githubInput:n,handleSaveGithub:i,profileSaving:s,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:n,onChange:u=>{l(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&i(),u.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:a("settings.account.githubUrlPlaceholder")}),t.jsx(V,{disabled:s,onCancel:()=>{o(!1),r(null)},onSave:i,saveLabel:s?a("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function z({disabled:e=!1,label:n,onClick:i,title:s}){return t.jsxs("button",{type:"button",onClick:i,disabled:e,title:s,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Pe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function K({actions:e,editing:n,editor:i,hint:s,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),n?i:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s})]}),n?null:e]})})}function jt({name:e}){const n=e.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(z,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function kt({name:e}){const{anonymousOn:n,customDisplayName:i,displayName:s,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:u,profileLoading:g,profileSaving:h,setEditingName:m,setNameInput:x,startEditingName:y}=e,d=n?a("settings.account.displayNameAnonymousHint"):i||s;return t.jsx(K,{label:a("settings.account.displayName"),editing:o,hint:d,editor:t.jsx(yt,{nameInput:u,setEditingName:m,setNameInput:x,profileSaving:h,handleSaveName:l}),actions:t.jsx(jt,{name:e})})}function Nt({github:e}){const{editingGithub:n,githubError:i,githubInput:s,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:u,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:x,showGithubOn:y,startEditingGithub:d}=e;return t.jsx(t.Fragment,{children:t.jsx(K,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(vt,{githubError:i,githubInput:s,handleSaveGithub:r,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:x}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(z,{label:a("settings.account.edit"),onClick:d}),t.jsx(j,{checked:y,onChange:l,disabled:u||g,ariaLabel:a("settings.account.githubUrl")})]})})})}function St(){const{openLoginModal:e}=he();return t.jsx(k,{title:a("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:a("settings.account.signIn")})]})})}function wt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(kt,{name:e}),t.jsx(Nt,{github:n})]})}function Ct(){const e=xt();return e.enabled?e.signedIn?t.jsxs(k,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Et,{onSignOut:e.signOut}),children:[t.jsx(Lt,{userId:e.userId}),t.jsx(At,{settings:e}),t.jsx(Gt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(It,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(St,{}):null}function Lt({userId:e}){const[n,i]=C.useState(!1);if(!e)return null;const s=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),i(!0),globalThis.setTimeout(()=>i(!1),1200)}catch{i(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:a("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":a("settings.account.copyUserId"),children:[n?t.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function Et({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(Ye,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function At({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function Gt({checked:e,disabled:n,onChange:i}){return t.jsx(b,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:i,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function It({visible:e,name:n,github:i}){return t.jsx(pe,{initial:!1,children:e?t.jsx(U.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(wt,{name:n,github:i})},"public-profile-fields"):null})}function Pt(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:be},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:fe},{value:"system",label:a("settings.appearance.theme.system"),Icon:xe}]}function _t(){return[{value:je,label:a("settings.appearance.language.system")},{value:ke,label:a("settings.appearance.language.english")},{value:Ne,label:a("settings.appearance.language.chinese")},{value:Se,label:a("settings.appearance.language.traditional_chinese")},{value:we,label:a("settings.appearance.language.japanese")},{value:Ce,label:a("settings.appearance.language.korean")},{value:Le,label:a("settings.appearance.language.german")}]}function Ot(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function Tt(e,n){const i=a(`settings.appearance.currency.rate_source.${e}`),s=Ot(n),o=s?a("settings.appearance.currency.rate_updated",{when:s}):a("settings.appearance.currency.rate_never");return`${i} · ${o}`}function Dt({locale:e,setLocale:n}){const i=_t();return t.jsx($,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(Ze,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Mt({currency:e,setCurrency:n}){const i=ye().map(s=>({value:s.code,label:a(s.labelKey)}));return t.jsx($,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Ut({currency:e,rate:n,rateSource:i,rateFetchedAt:s}){if(e===ve)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=Tt(i,s);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Ft(){const{theme:e,setTheme:n}=me(),{locale:i,setLocale:s}=R(),{currency:o,rate:r,rateSource:l,rateFetchedAt:u,setCurrency:g}=Me(),{mode:h,setMode:m}=Ue();return t.jsxs(k,{title:a("settings.section.appearance"),children:[t.jsx(b,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(L,{options:Pt(),value:e,onChange:n})}),t.jsx(b,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(Dt,{locale:i,setLocale:s})}),t.jsx(b,{label:a("settings.appearance.currency.label"),hint:t.jsx(Ut,{currency:o,rate:r,rateSource:l,rateFetchedAt:u}),control:t.jsx(Mt,{currency:o,setCurrency:g})}),t.jsx(b,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:t.jsx(L,{options:[{value:I.COMPACT,label:a("settings.appearance.token_format.compact")},{value:I.FULL,label:a("settings.appearance.token_format.full")}],value:h,onChange:m})})]})}function M({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:a(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:a("qpd.card.badge")})]})}function Rt(){const{enabled:e,toggle:n}=_e(),{enabled:i,toggle:s}=Oe();return t.jsxs(k,{title:a("settings.section.labs"),children:[t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:n,ariaLabel:a("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:t.jsx(j,{checked:i,onChange:s,ariaLabel:a("settings.labs.sessions.aria")})})]})}function Ht(){const{available:e,settings:n,setSetting:i,runAction:s}=H();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.launchAtLoginSupported!==!1,l=n?.updateStatus||null,u=!!n?.updateBusy,g=!!n?.isSyncing;return t.jsxs(k,{title:a("settings.section.menubar"),children:[t.jsx(b,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:t.jsxs(Ee,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[a("settings.menubar.appearanceLink"),t.jsx(He,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),r?t.jsx(b,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>i("launchAtLogin",!o),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>s("syncNow"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Ae,{className:N("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(b,{label:a("settings.menubar.updates"),hint:l||void 0,control:t.jsxs("button",{type:"button",onClick:()=>s("checkForUpdates"),disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx($e,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function $t(e,n){function i(r){return r.replace(/^v/,"").split(".").map(Number)}const s=i(e),o=i(n);for(let r=0;r<Math.max(s.length,o.length);r++){const l=s[r]||0,u=o[r]||0;if(l<u)return!0;if(l>u)return!1}return!1}function Bt(){const{available:e,settings:n,runAction:i}=H(),s=e&&n?.version,[o,r]=C.useState(!1),[l,u]=C.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:g}=R(),h="0.82.1",m=async()=>{r(!0);try{const p=await fetch("https://api.github.com/repos/mm7894215/TokenTracker/releases/latest");if(!p.ok)throw new Error("Failed to fetch");const v=await p.json(),S=v.tag_name;$t(h,S)?u({open:!0,latestVersion:S,htmlUrl:v.html_url}):P({title:a("settings.menubar.updates.upToDate")})}catch(p){console.error("Check updates failed:",p),P({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},x=a("settings.menubar.updates.modalTitle"),y=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),d=a("settings.menubar.updates.modalConfirm"),f=a("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[s?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:h})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>i("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCore",{version:h})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:m,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Ge,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(Ve,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(Re,{open:l.open,title:x,description:y,confirmLabel:d,cancelLabel:f,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),u(p=>({...p,open:!1}))},onCancel:()=>u(p=>({...p,open:!1}))})]})}function Vt({prefs:e}){return t.jsx(L,{options:[{value:_.USED,label:a("limits.settings.display_mode_used")},{value:_.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function dn(){const e=Ie();return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.page.subtitle")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ft,{}),t.jsx(Ht,{}),t.jsx(Ct,{}),t.jsx(Rt,{}),t.jsx(k,{title:a("settings.section.limits"),action:t.jsx(Vt,{prefs:e}),children:t.jsx(st,{prefs:e})})]}),t.jsx(Bt,{})]})})})}export{dn as SettingsPage};
import{k as da,r as i,j as e,J as it,y as ca,X as Ce,c as r,b as Z,aO as na,aE as _a,aP as ot,aQ as lt,aR as ha,aS as dt,aT as ct,aD as ut,aU as xa,aV as mt,aW as gt,aJ as ht,aX as xt,aG as pt,aF as ft,H as yt,w as bt,x as pa,aY as kt,ac as wt,P as be,aZ as vt,a_ as jt,a$ as Nt,b0 as St,b1 as Ct,b2 as _t,F as Pt,B as G,b3 as Rt,b4 as ia,R as Lt,b5 as It,b6 as fa,aq as Se,b7 as ya,b8 as ba,b9 as Et,ba as ka,bb as wa,bc as $t,bd as Bt}from"./__vite-browser-external-CHbEWSwX.js";import{L as Tt}from"./LocalOnlyNotice-Dc1CtgPN.js";import{C as Dt}from"./Card-D4wKdGxL.js";import{C as va}from"./ConfirmModal-CjKotIxk.js";import{I as Pa}from"./info-DoeeLajS.js";import{u as Mt}from"./useCurrency-QqSMR7Ba.js";import{L as ee}from"./loader-circle-Cz7QNoOj.js";import{C as _e}from"./check-Dvngccc0.js";import{T as ua}from"./trash-2-Ceor8aI2.js";import{u as Ot,s as Ut,k as Ra,l as Ft,m as zt,n as At,o as Kt,p as Vt,q as qt,S as La,c as Ia,d as Ea,C as ma,e as $a,f as Ba,g as Ta,h as Ge,j as We,i as Qe}from"./SelectItemText-Ca7gf5A0.js";import{t as Ht,u as oa,m as Gt}from"./useScrollLock-DdUQVKDA.js";import{F as Wt}from"./flame-DCV1yyCQ.js";import{D as Da}from"./download-HHcFs0Ff.js";import{P as Ma,a as Oa,b as Ua,c as Fa,d as za,C as Qt}from"./PopoverPopup-BuSDh9-C.js";import"./arrow-up-right-B1yj6nxk.js";import"./DialogTitle-qsUpNlJa.js";import"./DialogDescription-D0X0v38O.js";const Xt=[["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=da("circle-arrow-up",Xt);const Jt=[["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"}]],la=da("external-link",Jt);const Yt=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ka=da("plus",Yt);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,S=`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:S,...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})}),Zt="tt:hint:dismissed:";function qa(a){return Zt+a}function er(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(qa(a))==="1"}catch{return!1}}function ar({id:a,children:s,className:l,ariaLabel:m}){const[c,x]=i.useState(()=>er(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(Ce,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Pa,{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 tr(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]:""}},...Ra}),[a.indeterminate])}const rr=i.createContext({disabled:!1});function sr(){return i.useContext(rr)}function nr(a,s,l,m=!0,c){const[x,u]=i.useState(),g=oa(c?`${c}-label`:void 0),h=a??s??x;return na(()=>{const b=a||s||!m?void 0:ir(l.current,g);x!==b&&u(b)}),h}function ir(a,s){const l=or(a);if(l)return!l.id&&s&&(l.id=s),l.id||void 0}function or(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 lr=i.createContext(void 0);function dr(a=!0){const s=i.useContext(lr);if(s===void 0&&!a)throw new Error(_a(3));return s}const Ga=i.createContext(void 0);function cr(){const a=i.useContext(Ga);if(a===void 0)throw new Error(_a(14));return a}const ur="data-parent",mr=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:S,required:E=!1,uncheckedValue:U,value:W,nativeButton:F=!1,style:ge,...j}=s,{clearErrors:ae}=Ft(),{disabled:$,name:K,setDirty:Q,setFilled:te,setFocused:z,setTouched:ke,state:we,validationMode:Ue,validityData:Pe,validation:Fe}=zt(),ze=sr(),{labelId:D,controlId:re,registerControlId:X,getDescriptionProps:ve}=At(),P=dr(),V=P?.parent,se=V&&P.allValues,I=$||ze.disabled||P?.disabled||g,ne=K??N,R=W??ne,Re=oa(),je=oa();let ie=re;se?ie=v?je:`${V.id}-${R}`:b&&(ie=b);let pe={};se&&(v?pe=P.parent.getParentProps():R&&(pe=P.parent.getChildProps(R)));const{checked:Le=m,indeterminate:Ie=o,onCheckedChange:Ee,...Ne}=pe,q=P?.value,oe=P?.setValue,fe=P?.defaultValue,le=i.useRef(null),de=ot(()=>Symbol("checkbox-control")),he=i.useRef(!1),{getButtonProps:Je,buttonRef:Ae}=lt({disabled:I,native:F}),ce=P?.validation??Fe,[_,Ye]=Kt({controlled:R&&q&&!v?q.includes(R):Le,default:R&&fe&&!v?fe.includes(R):x,name:"Checkbox",state:"checked"}),$e=se?!!Le:_,ye=se&&Ie||o;na(()=>{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,Re,_,void 0,!P&&!I,N);const J=i.useRef(null),Be=dt(k,J,ce.inputRef,ce.registerInput),Ze=nr(u,D,J,!F,ie??void 0);na(()=>{J.current&&(J.current.indeterminate=ye,_&&te(!0))},[_,ye,te]),qt(_,()=>{P||(ae(ne),te(_),Q(_!==Pe.initialValue),ce.change(_))});const Ke=ct({checked:_,disabled:I,form:h,name:v?void 0:ne,id:F?void 0:ie??void 0,required:E,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&&(Ee?.(M,ue),!ue.isCanceled&&(Ye(M),R&&q&&oe&&!v&&!se))){const me=M?[...q,R]:q.filter(B=>B!==R);oe(me,ue)}},onFocus(){le.current?.focus()}},W!==void 0?{value:(P?_&&W:W)||""}:ut,ve,f=>ce.getValidationProps(I,f));i.useEffect(()=>{if(!V||!R)return;const f=V.disabledStatesRef.current;return f.set(R,I),()=>{f.delete(R)}},[V,I,R]);const Te=i.useMemo(()=>({...we,checked:$e,disabled:I,readOnly:y,required:E,indeterminate:ye}),[we,$e,I,y,E,ye]),ea=Ha(Te),aa=ca("span",s,{state:Te,ref:[Ae,le,l,P?.registerControlRef],props:[{id:F?ie??void 0:Re,role:"checkbox","aria-checked":ye?"mixed":$e,"aria-readonly":y||void 0,"aria-required":E||void 0,"aria-labelledby":Ze,[ur]:v?"":void 0,onFocus(){I||z(!0)},onBlur(){const f=J.current;f&&(ke(!0),z(!1),Ue==="onBlur"&&ce.commit(P?q:f.checked))},onKeyDown(f){if(f.key!=="Enter"||(f.preventBaseUIHandler(),f.defaultPrevented))return;const M=J.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||tr(M)?.click()})},onClick(f){if(y||I)return;f.preventDefault();const M=J.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:ea});return e.jsxs(Ga.Provider,{value:Te,children:[aa,!_&&!P&&ne&&!v&&U!==void 0&&e.jsx("input",{type:"hidden",form:h,name:ne,value:U,disabled:I}),e.jsx("input",{...Ke,suppressHydrationWarning:!0})]})}),gr=i.forwardRef(function(s,l){const{render:m,className:c,style:x,keepMounted:u=!1,...g}=s,h=cr(),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 S={...Ha(h),...ft,...Ra},E=u||o,U=ca("span",s,{ref:[l,w],state:v,stateAttributesMapping:S,props:g});return E?U:null});function hr(a,s){return`target:${a}:${s}`}function xr(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 pr(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 fr(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 ra({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 yr({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(br,{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 br({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=$=>{$.key==="Escape"&&($.stopPropagation(),g?.())},ae=$=>{const K=$.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),S=y?`https://github.com/${a.repoOwner}/${a.repoName}`:null,E=new Set(a.targets||[]),U=l===xr(a),W=pr(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:S,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:S,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(la,{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(Ce,{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(ra,{label:r("skills.usage.invocations"),children:kt(m?.invocations||0)}),e.jsx(ra,{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",fr(m?.lastUsedAt)),"aria-hidden":!0}),F?W||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ra,{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(Pa,{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=E.has(j.id),$=l===hr(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(mr,{id:K,checked:ae,disabled:$,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(gr,{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.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 kr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),sa=["claude","codex"],O="popular",wr={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 vr(a){return Qa(a).split("/").filter(Boolean).pop()||""}function jr(a){if(a.repoOwner||a.repoName)return"";const s=Qa(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Na(a){const s=vr(a.directory);return s?`dir:${s}`:""}function Sa(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=jr(a);return l&&s.add(l),s}function He(a){return`install:${Xe(a)}`}function Ca(a){return`remove:${a.id||a.directory}`}function Xa(a,s){return`target:${a}:${s}`}function Nr({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&&wr[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(Nr,{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 Cr({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(Qt,{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 _r({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(La,{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(Ea,{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($a,{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(ia,{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(Ce,{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(Ce,{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(Ce,{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:S,onToggleSelect:E,onClearSelection:U,onBulkSync:W,onBulkRemove:F}){const ge=S.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(_r,{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(Cr,{skill:j,targets:l,selected:k===(j.id||j.directory),onSelect:N,selectable:!0,checked:S.has(j.id),onToggleSelect:E,onToggleTarget:w,hasUpdate:!!(j.id&&y?.[j.id]),busyKey:v},j.id||j.key))})]})}const Lr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},Ir=Lt.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(S=>S.id===y))),o=y=>{b(S=>S.includes(y)?S.filter(E=>E!==y):[...S,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(S=>S.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(la,{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(la,{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 S=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:S,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 $r(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Jr(){const[a,s]=i.useState($r),[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(""),[S,E]=i.useState(""),[U,W]=i.useState(""),[F,ge]=i.useState(""),[j,ae]=i.useState(!1),[$,K]=i.useState("all"),[Q,te]=i.useState(null),[z,ke]=i.useState(""),[we,Ue]=i.useState(!0),[Pe,Fe]=i.useState(!1),[ze,D]=i.useState(""),[re,X]=i.useState(null),[ve,P]=i.useState(null),[V,se]=i.useState(()=>new Set),[I,ne]=i.useState({}),[R,Re]=i.useState({}),[je,ie]=i.useState([]),[pe,Le]=i.useState(!1),Ie=i.useRef(!1),Ee=i.useMemo(()=>{const t=new Set;for(const n of l.skills||[])for(const d of Sa(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}={})=>{Le(!0);try{const n=await St({force:t});ie(n.skills||[])}finally{Le(!1)}},[]),le=i.useCallback(async()=>{try{const t=await Ct();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);Re(n)}catch{Re({})}},[]),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(C=>C.directory===n||C.id===n);p&&(s("my"),te(p.id||p.directory)),Ie.current=!0,t.delete("skill");const L=t.toString();window.history.replaceState({},"",`${window.location.pathname}${L?`?${L}`:""}${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(R).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(S),120);return()=>clearTimeout(t)},[S]),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]),!kr&&!Pt())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("")}},Ye=(t,n)=>{const d=(n&&n.length?n:sa).filter(p=>(l.targets||[]).some(L=>L.id===p));_(He(t),async()=>{await fa(t,d);const p=d.map(L=>(l.targets||[]).find(C=>C.id===L)?.label||L).join(", ");Se({title:r("skills.toast.installed",{name:t.name||t.directory,targets:p||r("skills.target.none")}),timeout:4e3})})},$e=t=>{X(t)},ye=()=>{const t=re;t&&(X(null),_(Ca(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);Se({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:d?{onUndo:async()=>{try{await Et(t.id),await Ne()}catch(p){D(p?.message||r("skills.error.generic"))}}}:void 0})}))},J=(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 L={name:t.name||t.directory,agent:Ke(n)};Se({title:d?r("skills.toast.synced_one",L):r("skills.toast.unsynced_one",L),timeout:3e3})}),Be=i.useCallback(()=>se(new Set),[]),Ze=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(),Se({title:r("skills.toast.bulk_synced",{count:n.length,agent:Ke(t)}),timeout:4e3})})},ea=()=>{const t=(l.skills||[]).filter(n=>V.has(n.id));t.length&&P(t)},aa=()=>{const t=ve;t&&(P(null),_("batch",async()=>{for(const n of t)n.managed?await ya(n.id):await ba(n.directory,n.targets||[]);Be(),Se({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:sa),await le(),Se({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 $t(t.owner,t.name),await q(),await oe()})},B=l.targets||[],H=l.skills||[],De=i.useMemo(()=>{const t=$==="all"?H:H.filter(d=>(d.targets||[]).includes($)),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,$,U]),Ja=$!=="all",Y=i.useMemo(()=>Q&&H.find(t=>(t.id||t.directory)===Q)||null,[H,Q]),Ya=i.useCallback(()=>{K("all"),E("")},[]),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(L=>{const C=Sa(L);return C.has(n)||d&&C.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&&!Y&&te(null)},[Y,Q]);const Me=i.useMemo(()=>{const t=o===T?u:o===O?je:c,d=o===T||o===O||o===xe?t:t.filter(C=>`${C.repoOwner}/${C.repoName}`===o),p=v.trim().toLowerCase();return(o===T||!p?d:d.filter(C=>(C.name||"").toLowerCase().includes(p)||(C.directory||"").toLowerCase().includes(p)||(C.description||"").toLowerCase().includes(p))).map(C=>{const ta=Xe(C).toLowerCase(),A=Na(C);return{...C,installed:Ee.has(ta)||A&&Ee.has(A)}})},[v,c,Ee,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:$,onAgentFilter:K,anyFilter:Ja,onClearFilters:Ya,searchQuery:S,onSearchQuery:E,searchPlaceholder:r("skills.my.placeholder"),selectedId:Q,onSelect:Za,onToggleTarget:J,busyKey:z,updates:I,selectedIds:V,onToggleSelect:Ze,onClearSelection:Be,onBulkSync:Te,onBulkRemove:ea}):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=Pe&&!t&&!n||n&&pe,L=!t&&!n&&(v.trim()!==""||o!==xe),C=()=>{w(""),k(xe)},ta=!d&&!p&&(Me.length>0||L)?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})}),L?e.jsxs("button",{type:"button",onClick:C,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(Ce,{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:Lr,children:e.jsx(Ir,{skill:Oe,installed:!!Oe.installed,installing:z===He(Oe),allTargets:B,defaultTargets:sa,onInstall:Ye,onManage:at})},Oe.id||Oe.key))}):L?A=Ve("skills.empty.no_match",e.jsx(G,{type:"button",variant:"secondary",size:"sm",onClick:C,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(ar,{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,ta,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||Pe||pe,children:[e.jsx(Rt,{className:Z("mr-1.5 h-3.5 w-3.5",(we||Pe||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(Wt,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,n]},t))}),o!==T&&o!==O?e.jsxs(La,{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(Ea,{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($a,{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(ia,{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(ia,{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(yr,{skill:Y,targets:B,busyKey:z,usage:Y&&(R[String(Y.directory||"").toLowerCase()]||R[String(Y.name||"").toLowerCase()])||null,hasUpdate:!!(Y?.id&&I?.[Y.id]),updating:Y?z===He(Y):!1,onUpdate:f,onClose:et,onToggleTarget:J,onRemove:$e})]})}),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===Ca(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:()=>P(null),onConfirm:aa})]})}export{Jr as SkillsPage};
import{k as t}from"./__vite-browser-external-CHbEWSwX.js";const a=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],i=t("maximize-2",a);const e=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],m=t("terminal",e);export{i as M,m as T};
import{k as a}from"./__vite-browser-external-CHbEWSwX.js";const t=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],o=a("trash-2",t);export{o as T};

Sorry, the diff of this file is too big to display

import{r as p,g as N,a as M}from"./__vite-browser-external-CHbEWSwX.js";const D=6e3,S=2500,E=100;function h(t,r){let o;const n=new Promise((a,i)=>{o=setTimeout(()=>i(new Error("landing stats timeout")),r)});return Promise.race([t,n]).finally(()=>{o!=null&&clearTimeout(o)})}const A=5*6e4,P=1440*6e4,k="tokentracker:community-stats:v2";let s=null;function C(t){const r=Number(t?.tokenFloor)||0,o=Number(t?.totalEntries)||0;return!(r>0)||!(o>0)?null:{tokenFloor:r,totalEntries:o,top:Array.isArray(t?.top)?t.top:[],topModels:Array.isArray(t?.topModels)?t.topModels:[],providers:Array.isArray(t?.providers)?t.providers:[],dailyGrowth:Array.isArray(t?.dailyGrowth)?t.dailyGrowth:[],tokenMix:Array.isArray(t?.tokenMix)?t.tokenMix:[],userDistribution:Array.isArray(t?.userDistribution)?t.userDistribution:[],platforms:Array.isArray(t?.platforms)?t.platforms:[],activeDevelopersTotal:Number(t?.activeDevelopersTotal)||0,activeDevelopers30d:Number(t?.activeDevelopers30d)||0,tokens30d:Number(t?.tokens30d)||0,tokenGrowthPct:t?.tokenGrowthPct!=null&&Number.isFinite(Number(t.tokenGrowthPct))?Number(t.tokenGrowthPct):null,developerGrowthPct:t?.developerGrowthPct!=null&&Number.isFinite(Number(t.developerGrowthPct))?Number(t.developerGrowthPct):null,generatedAt:typeof t?.generatedAt=="string"?t.generatedAt:null}}function G(){if(typeof window>"u"||!window.localStorage)return null;try{const t=JSON.parse(window.localStorage.getItem(k)||"null"),r=Number(t?.cachedAt)||0,o=C(t?.data),n=Date.now()-r;return!o||n<0||n>P?null:{data:o,isFresh:n<A}}catch{return null}}function I(t){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(k,JSON.stringify({cachedAt:Date.now(),data:t}))}catch{}}function F(){if(s&&Date.now()-s.at<A)return s.promise;const t=Promise.all([h(N({period:"total",limit:E,offset:0}),D),h(M(),S).catch(()=>null)]);return s={at:Date.now(),promise:t},t.catch(()=>{s?.promise===t&&(s=null)}),t}function O({enabled:t=!0}={}){const[r]=p.useState(()=>G()),[o,n]=p.useState(()=>r?{status:"ready",...r.data}:{status:"loading",tokenFloor:null,totalEntries:null,top:[]});return p.useEffect(()=>{if(!t||r?.isFresh)return;let a=!1,i=null,u=null;const y=async()=>{try{const[l,e]=await F();if(a)return;const c=Array.isArray(l?.entries)?l.entries:[],b=c.reduce((m,T)=>m+(Number(T?.total_tokens)||0),0),d=Number(e?.total_tokens)||0;d>0||(s=null);const w=Number(r?.data?.tokenFloor)||0,f=d>0?d:w>0?w:b;if(!c.length||!(f>0)){n(m=>({...m,status:"error"}));return}const g=Array.isArray(e?.top_models)?e.top_models:r?.data?.topModels||[],_={tokenFloor:f,totalEntries:Number(l?.total_entries)||c.length,top:c.slice(0,3),topModels:g,providers:Array.isArray(e?.providers)?e.providers:[],dailyGrowth:Array.isArray(e?.daily_growth)?e.daily_growth:[],tokenMix:Array.isArray(e?.token_mix)?e.token_mix:[],userDistribution:Array.isArray(e?.user_distribution)?e.user_distribution:[],platforms:Array.isArray(e?.platforms)?e.platforms:[],activeDevelopersTotal:Number(e?.active_developers_total)||0,activeDevelopers30d:Number(e?.active_developers_30d)||0,tokens30d:Number(e?.tokens_30d)||0,tokenGrowthPct:e?.token_growth_pct==null?null:Number(e.token_growth_pct),developerGrowthPct:e?.developer_growth_pct==null?null:Number(e.developer_growth_pct),generatedAt:typeof e?.generated_at=="string"?e.generated_at:null};n({status:"ready",..._}),d>0&&I(_)}catch{a||n(e=>e.status==="ready"?e:{...e,status:"error"})}};return typeof window<"u"&&"requestIdleCallback"in window?i=window.requestIdleCallback(y,{timeout:1500}):u=setTimeout(y,400),()=>{a=!0,i!=null&&typeof window.cancelIdleCallback=="function"&&window.cancelIdleCallback(i),u!=null&&clearTimeout(u)}},[t,r]),o}export{O as u};
import{r as a,o as D,p as K,q as j,t as J}from"./__vite-browser-external-CHbEWSwX.js";import{L as q}from"./limits-providers-Db3iK5TG.js";const p=q,g="tt.limits.providerOrder",E="tt.limits.providerVisibility",h="tt.limits.displayMode",O="tt.limits.updatedAt",M="limitsPreferences",B="limitsDisplayMode",w=Object.freeze({USED:"used",REMAINING:"remaining"}),v=new Set(Object.values(w)),L=new Set([g,E,h,O]);function A(){return[...p]}function b(){return Object.fromEntries(p.map(e=>[e,!0]))}function _(e){const t=[];if(Array.isArray(e))for(const n of e)p.includes(n)&&!t.includes(n)&&t.push(n);for(const n of p)t.includes(n)||t.push(n);return t}function N(e){const t=b();if(!e||typeof e!="object"||Array.isArray(e))return t;for(const n of p)typeof e[n]=="boolean"&&(t[n]=e[n]);return t}function G(e){return v.has(e)?e:w.USED}function y(e){if(e!=null){if(typeof e=="number")return Number.isSafeInteger(e)?e:void 0;if(typeof e=="string"){const t=e.trim();if(t==="")return;const n=Number(t);return Number.isSafeInteger(n)?n:void 0}}}function m(e={}){const t=e&&typeof e=="object"?e:{};return{displayMode:G(t.displayMode),providerOrder:_(t.providerOrder),providerVisibility:N(t.providerVisibility),updatedAt:y(t.updatedAt)}}function F(){if(typeof window>"u")return A();try{const e=window.localStorage.getItem(g);return _(e?JSON.parse(e):void 0)}catch{return A()}}function H(){if(typeof window>"u")return b();try{const e=window.localStorage.getItem(E);return N(e?JSON.parse(e):void 0)}catch{return b()}}function Q(){if(typeof window>"u")return w.USED;try{const e=window.localStorage.getItem(h);return v.has(e)?e:w.USED}catch{return w.USED}}function W(){if(!(typeof window>"u"))try{return y(window.localStorage.getItem(O))}catch{return}}function X(){if(typeof window>"u")return!1;try{for(const e of L)if(window.localStorage.getItem(e)!==null)return!0}catch{return!1}return!1}function S(){return m({displayMode:Q(),providerOrder:F(),providerVisibility:H(),updatedAt:W()})}function Z(e){if(typeof window>"u")return;const t=m(e);try{window.localStorage.setItem(g,JSON.stringify(t.providerOrder)),window.localStorage.setItem(E,JSON.stringify(t.providerVisibility)),window.localStorage.setItem(h,t.displayMode),t.updatedAt===void 0?window.localStorage.removeItem(O):window.localStorage.setItem(O,String(t.updatedAt))}catch(n){console.warn("[tokentracker] limits preferences localStorage write failed:",n)}}function $(e){const t=m(e);return{displayMode:t.displayMode,providerOrder:[...t.providerOrder],providerVisibility:{...t.providerVisibility},updatedAt:t.updatedAt??null}}function ee(...e){let t;for(const s of e){const c=y(s);c!==void 0&&(t=t===void 0?c:Math.max(t,c))}const n=Date.now();return t!==void 0&&n<=t?t+1:n}function te(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function re(e,t){return p.every(n=>e[n]===t[n])}function k(e,t){return e.displayMode===t.displayMode&&te(e.providerOrder,t.providerOrder)&&re(e.providerVisibility,t.providerVisibility)}function ie(e,t){return k(e,t)&&y(e.updatedAt)===y(t.updatedAt)}function V(e,t){const n=y(e.updatedAt),s=y(t.updatedAt);return n!==void 0&&(s===void 0||n>s)}function de(){const[e,t]=a.useState(S),n=a.useRef(e),s=a.useCallback((o,r={})=>{const i=m(o);return n.current=i,t(i),r.writeLocal&&Z(i),i},[]),c=a.useCallback(o=>{D()&&K(M,$(o))},[]),u=a.useCallback(o=>{const r=S(),i=V(r,n.current)?s(r):n.current,d=m(o(i));if(k(i,d))return;const f=ee(r.updatedAt,i.updatedAt),l=s({...d,updatedAt:f},{writeLocal:!0});c(l)},[s,c]),P=a.useCallback(o=>{v.has(o)&&u(r=>({...r,displayMode:o}))},[u]),I=a.useCallback(o=>{if(!v.has(o))return;const r=S();if(r.updatedAt!==void 0){s(r);return}s({...r,displayMode:o,updatedAt:void 0},{writeLocal:!0})},[s]);a.useEffect(()=>{if(!D())return;const o=j(r=>{const i=r?.[M];if(i&&typeof i=="object"){const d=m(i);if(!X()){s(d,{writeLocal:!0});return}const f=S();if(V(d,f))s(d,{writeLocal:!0});else{const l=s(f);ie(d,f)||c(l)}return}I(r?.[B])});return J(),o},[I,s,c]),a.useEffect(()=>{if(typeof window>"u")return;const o=r=>{(r.key===null||L.has(r.key))&&s(S())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[s]);const U=a.useCallback(o=>{p.includes(o)&&u(r=>({...r,providerVisibility:{...r.providerVisibility,[o]:!r.providerVisibility[o]}}))},[u]),x=a.useCallback(o=>{u(r=>{const i=r.providerOrder.indexOf(o);if(i<=0)return r;const d=[...r.providerOrder];return[d[i-1],d[i]]=[d[i],d[i-1]],{...r,providerOrder:d}})},[u]),C=a.useCallback(o=>{u(r=>{const i=r.providerOrder.indexOf(o);if(i<0||i>=r.providerOrder.length-1)return r;const d=[...r.providerOrder];return[d[i],d[i+1]]=[d[i+1],d[i]],{...r,providerOrder:d}})},[u]),R=a.useCallback((o,r)=>{o!==r&&u(i=>{const d=i.providerOrder.indexOf(o),f=i.providerOrder.indexOf(r);if(d<0||f<0)return i;const l=[...i.providerOrder],[z]=l.splice(d,1);return l.splice(f,0,z),{...i,providerOrder:l}})},[u]),Y=a.useCallback(()=>{u(()=>({displayMode:w.USED,providerOrder:A(),providerVisibility:b()}))},[u]),T=a.useMemo(()=>e.providerOrder.filter(o=>e.providerVisibility[o]!==!1),[e.providerOrder,e.providerVisibility]);return{order:e.providerOrder,visibility:e.providerVisibility,displayMode:e.displayMode,setDisplayMode:P,visibleOrdered:T,toggle:U,moveUp:x,moveDown:C,moveToward:R,reset:Y}}export{w as L,de as u};
import{j as a,b as x,r as o,N as g,O as m,q as b,t as u,p as f,I as h}from"./__vite-browser-external-CHbEWSwX.js";import{C as y}from"./Card-D4wKdGxL.js";function j({checked:s,onChange:t,disabled:e,ariaLabel:r}){return a.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":r,onClick:t,disabled:e,className:x("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 disabled:cursor-not-allowed",s?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:a.jsx("span",{className:x("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",s?"translate-x-[18px]":"translate-x-[3px]")})})}function k({label:s,hint:t,control:e}){return a.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s}),t?a.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t}):null]}),a.jsx("div",{className:"shrink-0",children:e})]})}function N({title:s,subtitle:t,action:e,children:r}){return a.jsxs(y,{children:[a.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:s}),t?a.jsx("p",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t}):null]}),e?a.jsx("div",{className:"shrink-0",children:e}):null]}),a.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:r})]})}function w({options:s,value:t,onChange:e,disabled:r=!1}){return a.jsx("div",{className:"inline-flex items-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 p-0.5 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:s.map(({value:l,label:d,Icon:i})=>{const n=t===l;return a.jsxs("button",{type:"button",onClick:()=>e(l),"aria-pressed":n,disabled:r,className:x("inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",n?"bg-white text-oai-black shadow-sm dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[i?a.jsx(i,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,a.jsx("span",{children:d})]},l)})})}function S(){const[s,t]=o.useState(null),e=g()&&m();o.useEffect(()=>{if(!e)return;const i=b(n=>t(n));return u(),i},[e]);const r=o.useCallback((i,n)=>{e&&(t(c=>c&&{...c,[i]:n}),f(i,n))},[e]),l=o.useCallback(i=>{e&&h(i)},[e]),d=o.useCallback(()=>{e&&u()},[e]);return{available:e,settings:s,setSetting:r,runAction:l,refresh:d}}export{w as S,j as T,N as a,k as b,S as u};
import{r as c,R as P,Y as Oe}from"./__vite-browser-external-CHbEWSwX.js";function In(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const tt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function me(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function wt(e){return"nodeType"in e}function B(e){var t,n;return e?me(e)?e:wt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function mt(e){const{Document:t}=B(e);return e instanceof t}function Be(e){return me(e)?!1:e instanceof B(e).HTMLElement}function Vt(e){return e instanceof B(e).SVGElement}function ye(e){return e?me(e)?e.document:wt(e)?mt(e)?e:Be(e)||Vt(e)?e.ownerDocument:document:document:document}const Q=tt?c.useLayoutEffect:c.useEffect;function yt(e){const t=c.useRef(e);return Q(()=>{t.current=e}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Mn(){const e=c.useRef(null),t=c.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=c.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function ke(e,t){t===void 0&&(t=[e]);const n=c.useRef(e);return Q(()=>{n.current!==e&&(n.current=e)},t),n}function Fe(e,t){const n=c.useRef();return c.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Ke(e){const t=yt(e),n=c.useRef(null),r=c.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function ht(e){const t=c.useRef();return c.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function $e(e,t){return c.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function qt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,a)=>{const s=Object.entries(a);for(const[l,u]of s){const f=i[l];f!=null&&(i[l]=f+e*u)}return i},{...t})}}const we=qt(1),ze=qt(-1);function An(e){return"clientX"in e&&"clientY"in e}function xt(e){if(!e)return!1;const{KeyboardEvent:t}=B(e.target);return t&&e instanceof t}function On(e){if(!e)return!1;const{TouchEvent:t}=B(e.target);return t&&e instanceof t}function gt(e){if(On(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return An(e)?{x:e.clientX,y:e.clientY}:null}const _e=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[_e.Translate.toString(e),_e.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Nt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Tn(e){return e.matches(Nt)?e:e.querySelector(Nt)}const Nn={display:"none"};function Ln(e){let{id:t,value:n}=e;return P.createElement("div",{id:t,style:Nn},n)}function kn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return P.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function zn(){const[e,t]=c.useState("");return{announce:c.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Gt=c.createContext(null);function Pn(e){const t=c.useContext(Gt);c.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Bn(){const[e]=c.useState(()=>new Set),t=c.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[c.useCallback(r=>{let{type:o,event:i}=r;e.forEach(a=>{var s;return(s=a[o])==null?void 0:s.call(a,i)})},[e]),t]}const Fn={draggable:`
To pick up a draggable item, press the space bar.
While dragging, use the arrow keys to move the item.
Press space again to drop the item in its new position, or press escape to cancel.
`},$n={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Xn(e){let{announcements:t=$n,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Fn}=e;const{announce:i,announcement:a}=zn(),s=$e("DndLiveRegion"),[l,u]=c.useState(!1);if(c.useEffect(()=>{u(!0)},[]),Pn(c.useMemo(()=>({onDragStart(d){let{active:h}=d;i(t.onDragStart({active:h}))},onDragMove(d){let{active:h,over:g}=d;t.onDragMove&&i(t.onDragMove({active:h,over:g}))},onDragOver(d){let{active:h,over:g}=d;i(t.onDragOver({active:h,over:g}))},onDragEnd(d){let{active:h,over:g}=d;i(t.onDragEnd({active:h,over:g}))},onDragCancel(d){let{active:h,over:g}=d;i(t.onDragCancel({active:h,over:g}))}}),[i,t])),!l)return null;const f=P.createElement(P.Fragment,null,P.createElement(Ln,{id:r,value:o.draggable}),P.createElement(kn,{id:s,announcement:a}));return n?Oe.createPortal(f,n):f}var O;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(O||(O={}));function Qe(){}function uo(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function fo(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const q=Object.freeze({x:0,y:0});function Jt(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Kt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Yn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Lt(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function _t(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function kt(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const ho=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=kt(t,t.left,t.top),i=[];for(const a of r){const{id:s}=a,l=n.get(s);if(l){const u=Jt(kt(l),o);i.push({id:s,data:{droppableContainer:a,value:u}})}}return i.sort(Kt)},jn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Lt(t),i=[];for(const a of r){const{id:s}=a,l=n.get(s);if(l){const u=Lt(l),f=o.reduce((h,g,C)=>h+Jt(u[C],g),0),d=Number((f/4).toFixed(4));i.push({id:s,data:{droppableContainer:a,value:d}})}}return i.sort(Kt)};function Un(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,s=i-n;if(r<o&&n<i){const l=t.width*t.height,u=e.width*e.height,f=a*s,d=f/(l+u-f);return Number(d.toFixed(4))}return 0}const Wn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:a}=i,s=n.get(a);if(s){const l=Un(s,t);l>0&&o.push({id:a,data:{droppableContainer:i,value:l}})}}return o.sort(Yn)};function Hn(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Qt(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:q}function Vn(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((a,s)=>({...a,top:a.top+e*s.y,bottom:a.bottom+e*s.y,left:a.left+e*s.x,right:a.right+e*s.x}),{...n})}}const qn=Vn(1);function Gn(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Jn(e,t,n){const r=Gn(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:s}=r,l=e.left-a-(1-o)*parseFloat(n),u=e.top-s-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),f=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:f,height:d,top:u,right:l+f,bottom:u+d,left:l}}const Kn={ignoreTransform:!1};function xe(e,t){t===void 0&&(t=Kn);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=B(e).getComputedStyle(e);u&&(n=Jn(n,u,f))}const{top:r,left:o,width:i,height:a,bottom:s,right:l}=n;return{top:r,left:o,width:i,height:a,bottom:s,right:l}}function zt(e){return xe(e,{ignoreTransform:!0})}function _n(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Qn(e,t){return t===void 0&&(t=B(e).getComputedStyle(e)),t.position==="fixed"}function Zn(e,t){t===void 0&&(t=B(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function nt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(mt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Be(o)||Vt(o)||n.includes(o))return n;const i=B(e).getComputedStyle(o);return o!==e&&Zn(o,i)&&n.push(o),Qn(o,i)?n:r(o.parentNode)}return e?r(e):n}function Zt(e){const[t]=nt(e,1);return t??null}function lt(e){return!tt||!e?null:me(e)?e:wt(e)?mt(e)||e===ye(e).scrollingElement?window:Be(e)?e:null:null}function en(e){return me(e)?e.scrollX:e.scrollLeft}function tn(e){return me(e)?e.scrollY:e.scrollTop}function vt(e){return{x:en(e),y:tn(e)}}var N;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(N||(N={}));function nn(e){return!tt||!e?!1:e===document.scrollingElement}function rn(e){const t={x:0,y:0},n=nn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,a=e.scrollTop>=r.y,s=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:a,isRight:s,maxScroll:r,minScroll:t}}const er={x:.2,y:.2};function tr(e,t,n,r,o){let{top:i,left:a,right:s,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=er);const{isTop:u,isBottom:f,isLeft:d,isRight:h}=rn(e),g={x:0,y:0},C={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!u&&i<=t.top+v.height?(g.y=N.Backward,C.y=r*Math.abs((t.top+v.height-i)/v.height)):!f&&l>=t.bottom-v.height&&(g.y=N.Forward,C.y=r*Math.abs((t.bottom-v.height-l)/v.height)),!h&&s>=t.right-v.width?(g.x=N.Forward,C.x=r*Math.abs((t.right-v.width-s)/v.width)):!d&&a<=t.left+v.width&&(g.x=N.Backward,C.x=r*Math.abs((t.left+v.width-a)/v.width)),{direction:g,speed:C}}function nr(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:a}=window;return{top:0,left:0,right:i,bottom:a,width:i,height:a}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function on(e){return e.reduce((t,n)=>we(t,vt(n)),q)}function rr(e){return e.reduce((t,n)=>t+en(n),0)}function or(e){return e.reduce((t,n)=>t+tn(n),0)}function ir(e,t){if(t===void 0&&(t=xe),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);Zt(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const sr=[["x",["left","right"],rr],["y",["top","bottom"],or]];class Dt{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=nt(n),o=on(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,a,s]of sr)for(const l of a)Object.defineProperty(this,l,{get:()=>{const u=s(r),f=o[i]-u;return this.rect[l]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Te{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function ar(e){const{EventTarget:t}=B(e);return e instanceof t?e:ye(e)}function ut(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var W;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(W||(W={}));function Pt(e){e.preventDefault()}function cr(e){e.stopPropagation()}var w;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(w||(w={}));const sn={start:[w.Space,w.Enter],cancel:[w.Esc],end:[w.Space,w.Enter,w.Tab]},lr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case w.Right:return{...n,x:n.x+25};case w.Left:return{...n,x:n.x-25};case w.Down:return{...n,y:n.y+25};case w.Up:return{...n,y:n.y-25}}};class an{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Te(ye(n)),this.windowListeners=new Te(B(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(W.Resize,this.handleCancel),this.windowListeners.add(W.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(W.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&ir(r),n(q)}handleKeyDown(t){if(xt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=sn,coordinateGetter:a=lr,scrollBehavior:s="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:u}=r.current,f=u?{x:u.left,y:u.top}:q;this.referenceCoordinates||(this.referenceCoordinates=f);const d=a(t,{active:n,context:r.current,currentCoordinates:f});if(d){const h=ze(d,f),g={x:0,y:0},{scrollableAncestors:C}=r.current;for(const v of C){const p=t.code,{isTop:m,isRight:y,isLeft:b,isBottom:S,maxScroll:R,minScroll:E}=rn(v),x=nr(v),D={x:Math.min(p===w.Right?x.right-x.width/2:x.right,Math.max(p===w.Right?x.left:x.left+x.width/2,d.x)),y:Math.min(p===w.Down?x.bottom-x.height/2:x.bottom,Math.max(p===w.Down?x.top:x.top+x.height/2,d.y))},A=p===w.Right&&!y||p===w.Left&&!b,T=p===w.Down&&!S||p===w.Up&&!m;if(A&&D.x!==d.x){const M=v.scrollLeft+h.x,H=p===w.Right&&M<=R.x||p===w.Left&&M>=E.x;if(H&&!h.y){v.scrollTo({left:M,behavior:s});return}H?g.x=v.scrollLeft-M:g.x=p===w.Right?v.scrollLeft-R.x:v.scrollLeft-E.x,g.x&&v.scrollBy({left:-g.x,behavior:s});break}else if(T&&D.y!==d.y){const M=v.scrollTop+h.y,H=p===w.Down&&M<=R.y||p===w.Up&&M>=E.y;if(H&&!h.x){v.scrollTo({top:M,behavior:s});return}H?g.y=v.scrollTop-M:g.y=p===w.Down?v.scrollTop-R.y:v.scrollTop-E.y,g.y&&v.scrollBy({top:-g.y,behavior:s});break}}this.handleMove(t,we(ze(d,this.referenceCoordinates),g))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}an.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=sn,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const s=i.activatorNode.current;return s&&e.target!==s?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Bt(e){return!!(e&&"distance"in e)}function Ft(e){return!!(e&&"delay"in e)}class Ct{constructor(t,n,r){var o;r===void 0&&(r=ar(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:a}=i;this.props=t,this.events=n,this.document=ye(a),this.documentListeners=new Te(this.document),this.listeners=new Te(r),this.windowListeners=new Te(B(a)),this.initialCoordinates=(o=gt(i))!=null?o:q,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(W.Resize,this.handleCancel),this.windowListeners.add(W.DragStart,Pt),this.windowListeners.add(W.VisibilityChange,this.handleCancel),this.windowListeners.add(W.ContextMenu,Pt),this.documentListeners.add(W.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ft(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Bt(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(W.Click,cr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(W.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:a,options:{activationConstraint:s}}=i;if(!o)return;const l=(n=gt(t))!=null?n:q,u=ze(o,l);if(!r&&s){if(Bt(s)){if(s.tolerance!=null&&ut(u,s.tolerance))return this.handleCancel();if(ut(u,s.distance))return this.handleStart()}if(Ft(s)&&ut(u,s.tolerance))return this.handleCancel();this.handlePending(s,u);return}t.cancelable&&t.preventDefault(),a(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===w.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ur={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class cn extends Ct{constructor(t){const{event:n}=t,r=ye(n.target);super(t,ur,r)}}cn.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const dr={move:{name:"mousemove"},end:{name:"mouseup"}};var pt;(function(e){e[e.RightClick=2]="RightClick"})(pt||(pt={}));class fr extends Ct{constructor(t){super(t,dr,ye(t.event.target))}}fr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===pt.RightClick?!1:(r?.({event:n}),!0)}}];const dt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class hr extends Ct{constructor(t){super(t,dt)}static setup(){return window.addEventListener(dt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(dt.move.name,t)};function t(){}}}hr.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Ne;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ne||(Ne={}));var Ze;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ze||(Ze={}));function gr(e){let{acceleration:t,activator:n=Ne.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:s=Ze.TreeOrder,pointerCoordinates:l,scrollableAncestors:u,scrollableAncestorRects:f,delta:d,threshold:h}=e;const g=pr({delta:d,disabled:!i}),[C,v]=Mn(),p=c.useRef({x:0,y:0}),m=c.useRef({x:0,y:0}),y=c.useMemo(()=>{switch(n){case Ne.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Ne.DraggableRect:return o}},[n,o,l]),b=c.useRef(null),S=c.useCallback(()=>{const E=b.current;if(!E)return;const x=p.current.x*m.current.x,D=p.current.y*m.current.y;E.scrollBy(x,D)},[]),R=c.useMemo(()=>s===Ze.TreeOrder?[...u].reverse():u,[s,u]);c.useEffect(()=>{if(!i||!u.length||!y){v();return}for(const E of R){if(r?.(E)===!1)continue;const x=u.indexOf(E),D=f[x];if(!D)continue;const{direction:A,speed:T}=tr(E,D,y,t,h);for(const M of["x","y"])g[M][A[M]]||(T[M]=0,A[M]=0);if(T.x>0||T.y>0){v(),b.current=E,C(S,a),p.current=T,m.current=A;return}}p.current={x:0,y:0},m.current={x:0,y:0},v()},[t,S,r,v,i,a,JSON.stringify(y),JSON.stringify(g),C,u,R,f,JSON.stringify(h)])}const vr={x:{[N.Backward]:!1,[N.Forward]:!1},y:{[N.Backward]:!1,[N.Forward]:!1}};function pr(e){let{delta:t,disabled:n}=e;const r=ht(t);return Fe(o=>{if(n||!r||!o)return vr;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[N.Backward]:o.x[N.Backward]||i.x===-1,[N.Forward]:o.x[N.Forward]||i.x===1},y:{[N.Backward]:o.y[N.Backward]||i.y===-1,[N.Forward]:o.y[N.Forward]||i.y===1}}},[n,t,r])}function br(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Fe(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function wr(e,t){return c.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,r)}));return[...n,...i]},[]),[e,t])}var Pe;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Pe||(Pe={}));var bt;(function(e){e.Optimized="optimized"})(bt||(bt={}));const $t=new Map;function mr(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=c.useState(null),{frequency:s,measure:l,strategy:u}=o,f=c.useRef(e),d=p(),h=ke(d),g=c.useCallback(function(m){m===void 0&&(m=[]),!h.current&&a(y=>y===null?m:y.concat(m.filter(b=>!y.includes(b))))},[h]),C=c.useRef(null),v=Fe(m=>{if(d&&!n)return $t;if(!m||m===$t||f.current!==e||i!=null){const y=new Map;for(let b of e){if(!b)continue;if(i&&i.length>0&&!i.includes(b.id)&&b.rect.current){y.set(b.id,b.rect.current);continue}const S=b.node.current,R=S?new Dt(l(S),S):null;b.rect.current=R,R&&y.set(b.id,R)}return y}return m},[e,i,n,d,l]);return c.useEffect(()=>{f.current=e},[e]),c.useEffect(()=>{d||g()},[n,d]),c.useEffect(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),c.useEffect(()=>{d||typeof s!="number"||C.current!==null||(C.current=setTimeout(()=>{g(),C.current=null},s))},[s,d,g,...r]),{droppableRects:v,measureDroppableContainers:g,measuringScheduled:i!=null};function p(){switch(u){case Pe.Always:return!1;case Pe.BeforeDragging:return n;default:return!n}}}function ln(e,t){return Fe(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function yr(e,t){return ln(e,t)}function xr(e){let{callback:t,disabled:n}=e;const r=yt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function rt(e){let{callback:t,disabled:n}=e;const r=yt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function Dr(e){return new Dt(xe(e),e)}function Xt(e,t,n){t===void 0&&(t=Dr);const[r,o]=c.useState(null);function i(){o(l=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=l??n)!=null?u:null}const f=t(e);return JSON.stringify(l)===JSON.stringify(f)?l:f})}const a=xr({callback(l){if(e)for(const u of l){const{type:f,target:d}=u;if(f==="childList"&&d instanceof HTMLElement&&d.contains(e)){i();break}}}}),s=rt({callback:i});return Q(()=>{i(),e?(s?.observe(e),a?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),a?.disconnect())},[e]),r}function Cr(e){const t=ln(e);return Qt(e,t)}const Yt=[];function Sr(e){const t=c.useRef(e),n=Fe(r=>e?r&&r!==Yt&&e&&t.current&&e.parentNode===t.current.parentNode?r:nt(e):Yt,[e]);return c.useEffect(()=>{t.current=e},[e]),n}function Rr(e){const[t,n]=c.useState(null),r=c.useRef(e),o=c.useCallback(i=>{const a=lt(i.target);a&&n(s=>s?(s.set(a,vt(a)),new Map(s)):null)},[]);return c.useEffect(()=>{const i=r.current;if(e!==i){a(i);const s=e.map(l=>{const u=lt(l);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,vt(u)]):null}).filter(l=>l!=null);n(s.length?new Map(s):null),r.current=e}return()=>{a(e),a(i)};function a(s){s.forEach(l=>{const u=lt(l);u?.removeEventListener("scroll",o)})}},[o,e]),c.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,a)=>we(i,a),q):on(e):q,[e,t])}function jt(e,t){t===void 0&&(t=[]);const n=c.useRef(null);return c.useEffect(()=>{n.current=null},t),c.useEffect(()=>{const r=e!==q;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ze(e,n.current):q}function Er(e){c.useEffect(()=>{if(!tt)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Ir(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=a=>{i(a,t)},n},{}),[e,t])}function un(e){return c.useMemo(()=>e?_n(e):null,[e])}const Ut=[];function Mr(e,t){t===void 0&&(t=xe);const[n]=e,r=un(n?B(n):null),[o,i]=c.useState(Ut);function a(){i(()=>e.length?e.map(l=>nn(l)?r:new Dt(t(l),l)):Ut)}const s=rt({callback:a});return Q(()=>{s?.disconnect(),a(),e.forEach(l=>s?.observe(l))},[e]),o}function Ar(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Be(t)?t:e}function Or(e){let{measure:t}=e;const[n,r]=c.useState(null),o=c.useCallback(u=>{for(const{target:f}of u)if(Be(f)){r(d=>{const h=t(f);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),i=rt({callback:o}),a=c.useCallback(u=>{const f=Ar(u);i?.disconnect(),f&&i?.observe(f),r(f?t(f):null)},[t,i]),[s,l]=Ke(a);return c.useMemo(()=>({nodeRef:s,rect:n,setRef:l}),[n,s,l])}const Tr=[{sensor:cn,options:{}},{sensor:an,options:{}}],Nr={current:{}},Je={draggable:{measure:zt},droppable:{measure:zt,strategy:Pe.WhileDragging,frequency:bt.Optimized},dragOverlay:{measure:xe}};class Le extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Lr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Le,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Qe},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Je,measureDroppableContainers:Qe,windowRect:null,measuringScheduled:!1},kr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Qe,draggableNodes:new Map,over:null,measureDroppableContainers:Qe},ot=c.createContext(kr),dn=c.createContext(Lr);function zr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Le}}}function Pr(e,t){switch(t.type){case O.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case O.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case O.DragEnd:case O.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case O.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Le(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case O.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Le(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case O.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Le(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Br(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=c.useContext(ot),i=ht(r),a=ht(n?.id);return c.useEffect(()=>{if(!t&&!r&&i&&a!=null){if(!xt(i)||document.activeElement===i.target)return;const s=o.get(a);if(!s)return;const{activatorNode:l,node:u}=s;if(!l.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[l.current,u.current]){if(!f)continue;const d=Tn(f);if(d){d.focus();break}}})}},[r,t,o,a,i]),null}function Fr(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function $r(e){return c.useMemo(()=>({draggable:{...Je.draggable,...e?.draggable},droppable:{...Je.droppable,...e?.droppable},dragOverlay:{...Je.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Xr(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=c.useRef(!1),{x:a,y:s}=typeof o=="boolean"?{x:o,y:o}:o;Q(()=>{if(!a&&!s||!t){i.current=!1;return}if(i.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const f=n(u),d=Qt(f,r);if(a||(d.x=0),s||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=Zt(u);h&&h.scrollBy({top:d.y,left:d.x})}},[t,a,s,r,n])}const fn=c.createContext({...q,scaleX:1,scaleY:1});var ue;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ue||(ue={}));const go=c.memo(function(t){var n,r,o,i;let{id:a,accessibility:s,autoScroll:l=!0,children:u,sensors:f=Tr,collisionDetection:d=Wn,measuring:h,modifiers:g,...C}=t;const v=c.useReducer(Pr,void 0,zr),[p,m]=v,[y,b]=Bn(),[S,R]=c.useState(ue.Uninitialized),E=S===ue.Initialized,{draggable:{active:x,nodes:D,translate:A},droppable:{containers:T}}=p,M=x!=null?D.get(x):null,H=c.useRef({initial:null,translated:null}),V=c.useMemo(()=>{var k;return x!=null?{id:x,data:(k=M?.data)!=null?k:Nr,rect:H}:null},[x,M]),G=c.useRef(null),[De,Xe]=c.useState(null),[F,Ye]=c.useState(null),Z=ke(C,Object.values(C)),Ce=$e("DndDescribedBy",a),je=c.useMemo(()=>T.getEnabled(),[T]),z=$r(h),{droppableRects:ee,measureDroppableContainers:de,measuringScheduled:Se}=mr(je,{dragging:E,dependencies:[A.x,A.y],config:z.droppable}),j=br(D,x),Ue=c.useMemo(()=>F?gt(F):null,[F]),oe=En(),te=yr(j,z.draggable.measure);Xr({activeNode:x!=null?D.get(x):null,config:oe.layoutShiftCompensation,initialRect:te,measure:z.draggable.measure});const I=Xt(j,z.draggable.measure,te),Re=Xt(j?j.parentElement:null),J=c.useRef({activatorEvent:null,active:null,activeNode:j,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),fe=T.getNodeFor((n=J.current.over)==null?void 0:n.id),ne=Or({measure:z.dragOverlay.measure}),he=(r=ne.nodeRef.current)!=null?r:j,ge=E?(o=ne.rect)!=null?o:I:null,St=!!(ne.nodeRef.current&&ne.rect),Rt=Cr(St?null:I),it=un(he?B(he):null),ie=Sr(E?fe??j:null),We=Mr(ie),He=Fr(g,{transform:{x:A.x-Rt.x,y:A.y-Rt.y,scaleX:1,scaleY:1},activatorEvent:F,active:V,activeNodeRect:I,containerNodeRect:Re,draggingNodeRect:ge,over:J.current.over,overlayNodeRect:ne.rect,scrollableAncestors:ie,scrollableAncestorRects:We,windowRect:it}),Et=Ue?we(Ue,A):null,It=Rr(ie),mn=jt(It),yn=jt(It,[I]),ve=we(He,mn),pe=ge?qn(ge,He):null,Ee=V&&pe?d({active:V,collisionRect:pe,droppableRects:ee,droppableContainers:je,pointerCoordinates:Et}):null,Mt=_t(Ee,"id"),[se,At]=c.useState(null),xn=St?He:we(He,yn),Dn=Hn(xn,(i=se?.rect)!=null?i:null,I),st=c.useRef(null),Ot=c.useCallback((k,$)=>{let{sensor:X,options:ae}=$;if(G.current==null)return;const U=D.get(G.current);if(!U)return;const Y=k.nativeEvent,K=new X({active:G.current,activeNode:U,event:Y,options:ae,context:J,onAbort(L){if(!D.get(L))return;const{onDragAbort:_}=Z.current,re={id:L};_?.(re),y({type:"onDragAbort",event:re})},onPending(L,ce,_,re){if(!D.get(L))return;const{onDragPending:Me}=Z.current,le={id:L,constraint:ce,initialCoordinates:_,offset:re};Me?.(le),y({type:"onDragPending",event:le})},onStart(L){const ce=G.current;if(ce==null)return;const _=D.get(ce);if(!_)return;const{onDragStart:re}=Z.current,Ie={activatorEvent:Y,active:{id:ce,data:_.data,rect:H}};Oe.unstable_batchedUpdates(()=>{re?.(Ie),R(ue.Initializing),m({type:O.DragStart,initialCoordinates:L,active:ce}),y({type:"onDragStart",event:Ie}),Xe(st.current),Ye(Y)})},onMove(L){m({type:O.DragMove,coordinates:L})},onEnd:be(O.DragEnd),onCancel:be(O.DragCancel)});st.current=K;function be(L){return async function(){const{active:_,collisions:re,over:Ie,scrollAdjustedTranslate:Me}=J.current;let le=null;if(_&&Me){const{cancelDrop:Ae}=Z.current;le={activatorEvent:Y,active:_,collisions:re,delta:Me,over:Ie},L===O.DragEnd&&typeof Ae=="function"&&await Promise.resolve(Ae(le))&&(L=O.DragCancel)}G.current=null,Oe.unstable_batchedUpdates(()=>{m({type:L}),R(ue.Uninitialized),At(null),Xe(null),Ye(null),st.current=null;const Ae=L===O.DragEnd?"onDragEnd":"onDragCancel";if(le){const at=Z.current[Ae];at?.(le),y({type:Ae,event:le})}})}}},[D]),Cn=c.useCallback((k,$)=>(X,ae)=>{const U=X.nativeEvent,Y=D.get(ae);if(G.current!==null||!Y||U.dndKit||U.defaultPrevented)return;const K={active:Y};k(X,$.options,K)===!0&&(U.dndKit={capturedBy:$.sensor},G.current=ae,Ot(X,$))},[D,Ot]),Tt=wr(f,Cn);Er(f),Q(()=>{I&&S===ue.Initializing&&R(ue.Initialized)},[I,S]),c.useEffect(()=>{const{onDragMove:k}=Z.current,{active:$,activatorEvent:X,collisions:ae,over:U}=J.current;if(!$||!X)return;const Y={active:$,activatorEvent:X,collisions:ae,delta:{x:ve.x,y:ve.y},over:U};Oe.unstable_batchedUpdates(()=>{k?.(Y),y({type:"onDragMove",event:Y})})},[ve.x,ve.y]),c.useEffect(()=>{const{active:k,activatorEvent:$,collisions:X,droppableContainers:ae,scrollAdjustedTranslate:U}=J.current;if(!k||G.current==null||!$||!U)return;const{onDragOver:Y}=Z.current,K=ae.get(Mt),be=K&&K.rect.current?{id:K.id,rect:K.rect.current,data:K.data,disabled:K.disabled}:null,L={active:k,activatorEvent:$,collisions:X,delta:{x:U.x,y:U.y},over:be};Oe.unstable_batchedUpdates(()=>{At(be),Y?.(L),y({type:"onDragOver",event:L})})},[Mt]),Q(()=>{J.current={activatorEvent:F,active:V,activeNode:j,collisionRect:pe,collisions:Ee,droppableRects:ee,draggableNodes:D,draggingNode:he,draggingNodeRect:ge,droppableContainers:T,over:se,scrollableAncestors:ie,scrollAdjustedTranslate:ve},H.current={initial:ge,translated:pe}},[V,j,Ee,pe,D,he,ge,ee,T,se,ie,ve]),gr({...oe,delta:A,draggingRect:pe,pointerCoordinates:Et,scrollableAncestors:ie,scrollableAncestorRects:We});const Sn=c.useMemo(()=>({active:V,activeNode:j,activeNodeRect:I,activatorEvent:F,collisions:Ee,containerNodeRect:Re,dragOverlay:ne,draggableNodes:D,droppableContainers:T,droppableRects:ee,over:se,measureDroppableContainers:de,scrollableAncestors:ie,scrollableAncestorRects:We,measuringConfiguration:z,measuringScheduled:Se,windowRect:it}),[V,j,I,F,Ee,Re,ne,D,T,ee,se,de,ie,We,z,Se,it]),Rn=c.useMemo(()=>({activatorEvent:F,activators:Tt,active:V,activeNodeRect:I,ariaDescribedById:{draggable:Ce},dispatch:m,draggableNodes:D,over:se,measureDroppableContainers:de}),[F,Tt,V,I,m,Ce,D,se,de]);return P.createElement(Gt.Provider,{value:b},P.createElement(ot.Provider,{value:Rn},P.createElement(dn.Provider,{value:Sn},P.createElement(fn.Provider,{value:Dn},u)),P.createElement(Br,{disabled:s?.restoreFocus===!1})),P.createElement(Xn,{...s,hiddenTextDescribedById:Ce}));function En(){const k=De?.autoScrollEnabled===!1,$=typeof l=="object"?l.enabled===!1:l===!1,X=E&&!k&&!$;return typeof l=="object"?{...l,enabled:X}:{enabled:X}}}),Yr=c.createContext(null),Wt="button",jr="Draggable";function Ur(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=$e(jr),{activators:a,activatorEvent:s,active:l,activeNodeRect:u,ariaDescribedById:f,draggableNodes:d,over:h}=c.useContext(ot),{role:g=Wt,roleDescription:C="draggable",tabIndex:v=0}=o??{},p=l?.id===t,m=c.useContext(p?fn:Yr),[y,b]=Ke(),[S,R]=Ke(),E=Ir(a,t),x=ke(n);Q(()=>(d.set(t,{id:t,key:i,node:y,activatorNode:S,data:x}),()=>{const A=d.get(t);A&&A.key===i&&d.delete(t)}),[d,t]);const D=c.useMemo(()=>({role:g,tabIndex:v,"aria-disabled":r,"aria-pressed":p&&g===Wt?!0:void 0,"aria-roledescription":C,"aria-describedby":f.draggable}),[r,g,v,p,C,f.draggable]);return{active:l,activatorEvent:s,activeNodeRect:u,attributes:D,isDragging:p,listeners:r?void 0:E,node:y,over:h,setNodeRef:b,setActivatorNodeRef:R,transform:m}}function Wr(){return c.useContext(dn)}const Hr="Droppable",Vr={timeout:25};function qr(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=$e(Hr),{active:a,dispatch:s,over:l,measureDroppableContainers:u}=c.useContext(ot),f=c.useRef({disabled:n}),d=c.useRef(!1),h=c.useRef(null),g=c.useRef(null),{disabled:C,updateMeasurementsFor:v,timeout:p}={...Vr,...o},m=ke(v??r),y=c.useCallback(()=>{if(!d.current){d.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(m.current)?m.current:[m.current]),g.current=null},p)},[p]),b=rt({callback:y,disabled:C||!a}),S=c.useCallback((D,A)=>{b&&(A&&(b.unobserve(A),d.current=!1),D&&b.observe(D))},[b]),[R,E]=Ke(S),x=ke(t);return c.useEffect(()=>{!b||!R.current||(b.disconnect(),d.current=!1,b.observe(R.current))},[R,b]),c.useEffect(()=>(s({type:O.RegisterDroppable,element:{id:r,key:i,disabled:n,node:R,rect:h,data:x}}),()=>s({type:O.UnregisterDroppable,key:i,id:r})),[r]),c.useEffect(()=>{n!==f.current.disabled&&(s({type:O.SetDroppableDisabled,id:r,key:i,disabled:n}),f.current.disabled=n)},[r,i,n,s]),{active:a,rect:h,isOver:l?.id===r,node:R,over:l,setNodeRef:E}}function hn(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Gr(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Ve(e){return e!==null&&e>=0}function Jr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Kr(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const qe={scaleX:1,scaleY:1},vo=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:a}=e;const s=(t=n[o])!=null?t:r;if(!s)return null;const l=_r(n,a,o);if(a===o){const u=n[i];return u?{x:o<i?u.left+u.width-(s.left+s.width):u.left-s.left,y:0,...qe}:null}return a>o&&a<=i?{x:-s.width-l,y:0,...qe}:a<o&&a>=i?{x:s.width+l,y:0,...qe}:{x:0,y:0,...qe}};function _r(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return!r||!o&&!i?0:n<t?o?r.left-(o.left+o.width):i.left-(r.left+r.width):i?i.left-(r.left+r.width):r.left-(o.left+o.width)}const gn=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=hn(t,r,n),a=t[o],s=i[o];return!s||!a?null:{x:s.left-a.left,y:s.top-a.top,scaleX:s.width/a.width,scaleY:s.height/a.height}},Ge={scaleX:1,scaleY:1},po=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:a}=e;const s=(t=i[n])!=null?t:r;if(!s)return null;if(o===n){const u=i[a];return u?{x:0,y:n<a?u.top+u.height-(s.top+s.height):u.top-s.top,...Ge}:null}const l=Qr(i,o,n);return o>n&&o<=a?{x:0,y:-s.height-l,...Ge}:o<n&&o>=a?{x:0,y:s.height+l,...Ge}:{x:0,y:0,...Ge}};function Qr(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const vn="Sortable",pn=P.createContext({activeIndex:-1,containerId:vn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:gn,disabled:{draggable:!1,droppable:!1}});function bo(e){let{children:t,id:n,items:r,strategy:o=gn,disabled:i=!1}=e;const{active:a,dragOverlay:s,droppableRects:l,over:u,measureDroppableContainers:f}=Wr(),d=$e(vn,n),h=s.rect!==null,g=c.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),C=a!=null,v=a?g.indexOf(a.id):-1,p=u?g.indexOf(u.id):-1,m=c.useRef(g),y=!Jr(g,m.current),b=p!==-1&&v===-1||y,S=Kr(i);Q(()=>{y&&C&&f(g)},[y,g,C,f]),c.useEffect(()=>{m.current=g},[g]);const R=c.useMemo(()=>({activeIndex:v,containerId:d,disabled:S,disableTransforms:b,items:g,overIndex:p,useDragOverlay:h,sortedRects:Gr(g,l),strategy:o}),[v,d,S.draggable,S.droppable,b,g,p,l,h,o]);return P.createElement(pn.Provider,{value:R},t)}const Zr=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return hn(n,r,o).indexOf(t)},eo=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:s,previousContainerId:l,transition:u}=e;return!u||!r||s!==i&&o===a?!1:n?!0:a!==o&&t===l},to={duration:200,easing:"ease"},bn="transform",no=_e.Transition.toString({property:bn,duration:0,easing:"linear"}),ro={roleDescription:"sortable"};function oo(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,a]=c.useState(null),s=c.useRef(n);return Q(()=>{if(!t&&n!==s.current&&r.current){const l=o.current;if(l){const u=xe(r.current,{ignoreTransform:!0}),f={x:l.left-u.left,y:l.top-u.top,scaleX:l.width/u.width,scaleY:l.height/u.height};(f.x||f.y)&&a(f)}}n!==s.current&&(s.current=n)},[t,n,r,o]),c.useEffect(()=>{i&&a(null)},[i]),i}function wo(e){let{animateLayoutChanges:t=eo,attributes:n,disabled:r,data:o,getNewIndex:i=Zr,id:a,strategy:s,resizeObserverConfig:l,transition:u=to}=e;const{items:f,containerId:d,activeIndex:h,disabled:g,disableTransforms:C,sortedRects:v,overIndex:p,useDragOverlay:m,strategy:y}=c.useContext(pn),b=io(r,g),S=f.indexOf(a),R=c.useMemo(()=>({sortable:{containerId:d,index:S,items:f},...o}),[d,o,S,f]),E=c.useMemo(()=>f.slice(f.indexOf(a)),[f,a]),{rect:x,node:D,isOver:A,setNodeRef:T}=qr({id:a,data:R,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:M,activatorEvent:H,activeNodeRect:V,attributes:G,setNodeRef:De,listeners:Xe,isDragging:F,over:Ye,setActivatorNodeRef:Z,transform:Ce}=Ur({id:a,data:R,attributes:{...ro,...n},disabled:b.draggable}),je=In(T,De),z=!!M,ee=z&&!C&&Ve(h)&&Ve(p),de=!m&&F,Se=de&&ee?Ce:null,Ue=ee?Se??(s??y)({rects:v,activeNodeRect:V,activeIndex:h,overIndex:p,index:S}):null,oe=Ve(h)&&Ve(p)?i({id:a,items:f,activeIndex:h,overIndex:p}):S,te=M?.id,I=c.useRef({activeId:te,items:f,newIndex:oe,containerId:d}),Re=f!==I.current.items,J=t({active:M,containerId:d,isDragging:F,isSorting:z,id:a,index:S,items:f,newIndex:I.current.newIndex,previousItems:I.current.items,previousContainerId:I.current.containerId,transition:u,wasDragging:I.current.activeId!=null}),fe=oo({disabled:!J,index:S,node:D,rect:x});return c.useEffect(()=>{z&&I.current.newIndex!==oe&&(I.current.newIndex=oe),d!==I.current.containerId&&(I.current.containerId=d),f!==I.current.items&&(I.current.items=f)},[z,oe,d,f]),c.useEffect(()=>{if(te===I.current.activeId)return;if(te&&!I.current.activeId){I.current.activeId=te;return}const he=setTimeout(()=>{I.current.activeId=te},50);return()=>clearTimeout(he)},[te]),{active:M,activeIndex:h,attributes:G,data:R,rect:x,index:S,newIndex:oe,items:f,isOver:A,isSorting:z,isDragging:F,listeners:Xe,node:D,overIndex:p,over:Ye,setNodeRef:je,setActivatorNodeRef:Z,setDroppableNodeRef:T,setDraggableNodeRef:De,transform:fe??Ue,transition:ne()};function ne(){if(fe||Re&&I.current.newIndex===S)return no;if(!(de&&!xt(H)||!u)&&(z||J))return _e.Transition.toString({...u,property:bn})}}function io(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}function et(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const so=[w.Down,w.Right,w.Up,w.Left],mo=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:s}}=t;if(so.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(e.code){case w.Down:r.top<h.top&&l.push(d);break;case w.Up:r.top>h.top&&l.push(d);break;case w.Left:r.left>h.left&&l.push(d);break;case w.Right:r.left<h.left&&l.push(d);break}});const u=jn({collisionRect:r,droppableRects:o,droppableContainers:l});let f=_t(u,"id");if(f===a?.id&&u.length>1&&(f=u[1].id),f!=null){const d=i.get(n.id),h=i.get(f),g=h?o.get(h.id):null,C=h?.node.current;if(C&&g&&d&&h){const p=nt(C).some((E,x)=>s[x]!==E),m=wn(d,h),y=ao(d,h),b=p||!m?{x:0,y:0}:{x:y?r.width-g.width:0,y:y?r.height-g.height:0},S={x:g.left,y:g.top};return b.x&&b.y?S:ze(S,b)}}}};function wn(e,t){return!et(e)||!et(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function ao(e,t){return!et(e)||!et(t)||!wn(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function co(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>typeof r=="string"):null}catch{return null}}function ft(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Ht(e,t){if(!e)return t;const n=new Set(t),r=e.filter(i=>n.has(i)),o=t.filter(i=>!r.includes(i));return[...r,...o]}function yo(e,t){const n=c.useMemo(()=>t.join("|"),[t]),[r,o]=c.useState(()=>Ht(co(e),t));c.useEffect(()=>{o(s=>{const l=Ht(s,t);return l.length===s.length&&l.every((f,d)=>f===s[d])?s:(ft(e,l),l)})},[n,t,e]);const i=c.useCallback((s,l)=>{!s||!l||s===l||o(u=>{const f=u.indexOf(s),d=u.indexOf(l);if(f===-1||d===-1)return u;const h=u.slice(),[g]=h.splice(f,1);return h.splice(d,0,g),ft(e,h),h})},[e]),a=c.useCallback(()=>{ft(e,t),o(t)},[e,t]);return{order:r,reorder:i,reset:a}}export{_e as C,go as D,an as K,cn as P,bo as S,yo as a,fo as b,uo as c,ho as d,vo as h,mo as s,wo as u,po as v};
import{k as u,r as n}from"./__vite-browser-external-CHbEWSwX.js";const f=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],E=u("pencil",f),i="tt.qualityPerDollar.enabled";function l(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(i)==="1"}catch{return!1}}function y(){const[r,o]=n.useState(l);n.useEffect(()=>{if(typeof window>"u")return;const t=e=>{(e.key===null||e.key===i)&&o(l())};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const a=n.useCallback(t=>{const e=!!t;o(e);try{window.localStorage.setItem(i,e?"1":"0")}catch{}},[]),s=n.useCallback(()=>a(!l()),[a]);return{enabled:r,setEnabled:a,toggle:s}}const d="tt.sessionEfficiency.enabled";function c(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(d)==="1"}catch{return!1}}function g(){const[r,o]=n.useState(c);n.useEffect(()=>{if(typeof window>"u")return;const t=e=>{(e.key===null||e.key===d)&&o(c())};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const a=n.useCallback(t=>{const e=!!t;o(e);try{window.localStorage.setItem(d,e?"1":"0")}catch{}},[]),s=n.useCallback(()=>a(!c()),[a]);return{enabled:r,setEnabled:a,toggle:s}}export{E as P,g as a,y as u};
import{Z as d,$ as l,a0 as A,r as u,a1 as h,a2 as p,a3 as C,a4 as V,a5 as f}from"./__vite-browser-external-CHbEWSwX.js";function x(...t){const e=!Array.isArray(t[0]),n=e?0:-1,o=t[0+n],s=t[1+n],a=t[2+n],r=t[3+n],c=d(s,a,r);return e?c(o):c}function E(t){const e=l(()=>A(t)),{isStatic:n}=u.useContext(h);if(n){const[,o]=u.useState(t);u.useEffect(()=>e.on("change",o),[])}return e}function m(t,e){const n=E(e()),o=()=>n.set(e());return o(),p(()=>{const s=()=>V.preRender(o,!1,!0),a=t.map(r=>r.on("change",s));return()=>{a.forEach(r=>r()),C(o)}}),n}function L(t){f.current=[],t();const e=m(f.current,t);return f.current=void 0,e}function M(t,e,n,o){if(typeof t=="function")return L(t);const a=typeof e=="function"?e:x(e,n,o),r=Array.isArray(t)?i(t,a):i([t],([y])=>a(y)),c=Array.isArray(t)?void 0:t.accelerate;return c&&!c.isTransformed&&typeof e!="function"&&Array.isArray(n)&&o?.clamp!==!1&&(r.accelerate={...c,times:e,keyframes:n,isTransformed:!0}),r}function i(t,e){const n=l(()=>[]);return m(t,()=>{n.length=0;const o=t.length;for(let s=0;s<o;s++)n[s]=t[s].get();return e(n)})}export{M as a,E as u};
import{o as _,ah as K,r as w,c as g,ai as F,aj as M,ak as b}from"./__vite-browser-external-CHbEWSwX.js";import{l as x}from"./limits-providers-Db3iK5TG.js";const S="native:notificationPermission";let E=null;function N(){return typeof window<"u"&&!!window.chrome?.webview}function v(){return _()?E||"unknown":N()?"granted":typeof Notification>"u"?"unsupported":Notification.permission}function L(e){if(typeof window>"u")return()=>{};const t=i=>{const d=i?.detail?.status;typeof d=="string"&&(E=d),e(v())};return window.addEventListener(S,t),e(v()),_()&&K({type:"getNotificationStatus"}),()=>window.removeEventListener(S,t)}async function I(){if(_()){K({type:"requestNotificationPermission"});return}N()||typeof Notification<"u"&&Notification.permission==="default"&&await Notification.requestPermission().catch(()=>"denied")}const p="tt.limitAlerts.enabled";function O(){try{return window.localStorage.getItem(p)==="1"}catch{return!1}}function U(){const[e,t]=w.useState(O),[i,d]=w.useState("unknown");w.useEffect(()=>L(d),[]);const y=w.useCallback(async n=>{const l=!!n;l&&await I();try{window.localStorage.setItem(p,l?"1":"0")}catch{}t(l)},[]);return{enabled:e,setEnabled:y,permissionBlocked:i==="denied"}}function A(e,t){if(!(e>0))return null;const i=(e-t)/e;return Number.isFinite(i)?Math.min(Math.max(i,0),1):null}function z(e,t,i=.03){return e>t+i}function D(e){const t=Math.max(0,Math.floor(e)),i=Math.floor(t/3600);return i>24?`${Math.floor(i/24)}d`:i>0?`${i}h`:`${Math.floor(t/60)}m`}function j(e,t){if(typeof e.windowSeconds=="number")return e.windowSeconds;if(e.windowSecondsField&&t){const i=t[e.windowSecondsField];return typeof i=="number"&&i>0?i:null}return null}function R(e){return e==null?NaN:typeof e=="number"?e*1e3:Date.parse(e)}function C({usedPercent:e,windowSeconds:t,resetMs:i,mode:d,now:y=Date.now()}){const n=Math.min(Math.max(Number(e)||0,0),100)/100,l={pacePercent:null,paceOver:!1,expectedPercent:null,runsOutEta:null,projectedEnd:null};if(!(t>0)||!Number.isFinite(i))return l;const r=Math.max(0,(i-y)/1e3),s=A(t,r);if(s==null)return l;if(l.expectedPercent=Math.round(s*100),l.paceOver=z(n,s),n>=.05){const u=d==="remaining"?1-s:s;l.pacePercent=u*100}if(s>.02&&n>0){const u=t*s,c=n/u,m=n/s;m>=1&&c>0?l.runsOutEta=D((1-n)/c):l.projectedEnd=Math.round(Math.min(m,1)*100)}return l}const T={claude:{windows(e){const t=Array.isArray(e.weekly_scoped)?e.weekly_scoped.map(i=>({key:`scoped-${i.label}`,label:i.label,window:i,pctField:"utilization",resetField:"resets_at",windowSeconds:604800})):[];return[{key:"5h",labelKey:"limits.label.claude_5h",window:e.five_hour,pctField:"utilization",resetField:"resets_at",windowSeconds:5*3600},{key:"7d",labelKey:"limits.label.claude_7d",window:e.seven_day,pctField:"utilization",resetField:"resets_at",windowSeconds:7*86400},{key:"opus",labelKey:"limits.label.claude_opus",window:e.seven_day_opus,pctField:"utilization",resetField:"resets_at",windowSeconds:7*86400},...t]}},codex:{extra:"codex_meta",windows(e){return[{key:"5h",labelKey:"limits.label.codex_5h",window:e.primary_window,windowSecondsField:"limit_window_seconds"},{key:"7d",labelKey:"limits.label.codex_7d",window:e.secondary_window,windowSecondsField:"limit_window_seconds"},{key:"credits",labelKey:"limits.label.codex_credits",window:e.credit_window},{key:"spark-5h",labelKey:"limits.label.codex_spark_5h",window:e.spark_primary_window,windowSecondsField:"limit_window_seconds"},{key:"spark-7d",labelKey:"limits.label.codex_spark_7d",window:e.spark_secondary_window,windowSecondsField:"limit_window_seconds"}]}},cursor:{windows(e){return[{key:"plan",labelKey:"limits.label.cursor_plan",window:e.primary_window},{key:"auto",labelKey:"limits.label.cursor_auto",window:e.secondary_window},{key:"api",labelKey:"limits.label.cursor_api",window:e.tertiary_window}]}},gemini:{windows(e){return[{key:"pro",labelKey:"limits.label.gemini_pro",window:e.primary_window},{key:"flash",labelKey:"limits.label.gemini_flash",window:e.secondary_window},{key:"lite",labelKey:"limits.label.gemini_lite",window:e.tertiary_window}]}},kimi:{extra:"kimi_parallel",windows(e){return[{key:"weekly",labelKey:"limits.label.kimi_weekly",window:e.primary_window,windowSeconds:7*86400},{key:"5h",labelKey:"limits.label.kimi_5h",window:e.secondary_window,windowSeconds:5*3600},{key:"total",labelKey:"limits.label.kimi_total",window:e.tertiary_window}]}},kiro:{windows(e){return[{key:"month",labelKey:"limits.label.kiro_month",window:e.primary_window},{key:"bonus",labelKey:"limits.label.kiro_bonus",window:e.secondary_window}]}},grok:{windows(e){return[{key:"month",labelKey:"limits.label.grok_month",window:e.primary_window},{key:"ondemand",labelKey:"limits.label.grok_ondemand",window:e.secondary_window}]}},antigravity:{windows(e){return[{key:"claude-weekly",labelKey:"limits.label.antigravity_claude_weekly",window:e.primary_window},{key:"claude-5h",labelKey:"limits.label.antigravity_claude_5h",window:e.secondary_window},{key:"gemini-weekly",labelKey:"limits.label.antigravity_gemini_weekly",window:e.tertiary_window},{key:"gemini-5h",labelKey:"limits.label.antigravity_gemini_5h",window:e.quaternary_window}]}},copilot:{extra:"copilot_otel",windows(e){return[{key:"premium",labelKey:"limits.label.copilot_premium",window:e.primary_window},{key:"chat",labelKey:"limits.label.copilot_chat",window:e.secondary_window}]}},zcode:{windows(e){return e.plan_kind==="coding-plan"?[{key:"5h",labelKey:"limits.label.zcode_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.zcode_weekly",window:e.secondary_window},{key:"tools",labelKey:"limits.label.zcode_tools",window:e.tertiary_window}]:[{key:"glm52",labelKey:"limits.label.zcode_glm52",window:e.primary_window},{key:"glm5t",labelKey:"limits.label.zcode_glm5t",window:e.secondary_window}]}},opencodeGo:{windows(e){return[{key:"5h",labelKey:"limits.label.opencode_go_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.opencode_go_weekly",window:e.secondary_window},{key:"monthly",labelKey:"limits.label.opencode_go_monthly",window:e.tertiary_window}]}}},P="tt.limitAlerts.cycles.v1";function $(){try{return JSON.parse(window.localStorage.getItem(P)||"{}")}catch{return{}}}function B(e){try{window.localStorage.setItem(P,JSON.stringify(e))}catch{}}function V(e,{now:t=Date.now()}={}){const i=[],d=T;for(const[y,n]of Object.entries(e||{})){const l=d[y];if(!(!n?.configured||n.error||!l))for(const r of l.windows(n)){if(!r.window)continue;const s=Number(r.pctField==="utilization"?r.window.utilization:r.window.used_percent),u=r.resetField==="resets_at"?r.window.resets_at:r.window.reset_at,c=R(u),m=C({usedPercent:s,windowSeconds:j(r,r.window),resetMs:c,mode:"used",now:t});!m.runsOutEta||!m.paceOver||s<20||!(c>t)||i.push({id:`${y}:${r.key}:${c}`,providerId:y,windowKey:r.key,resetMs:c,usedPercent:s,runsOutEta:m.runsOutEta})}}return i}function q(e){const t=$(),i=V(e);for(const n of i){if(t[n.id])continue;const l=x(n.providerId),r=g("limits.alert.title",{provider:l}),s=g("limits.alert.body",{eta:n.runsOutEta,percent:Math.round(n.usedPercent)});let u=F({title:r,body:s,id:n.id});!u&&typeof Notification<"u"&&Notification.permission==="granted"&&(new Notification(r,{body:s,tag:n.id}),u=!0),u&&(t[n.id]=Date.now())}const d=Date.now()-864e5,y=Object.fromEntries(Object.entries(t).filter(([n,l])=>{const r=Number(n.split(":").at(-1));return Number.isFinite(r)?r>=d:Number(l)>=d}).slice(-100));return B(y),i.length}function W(e){const t=!!e?.initialState,[i,d]=w.useState(()=>t?e?.initialState?.data??null:null),[y,n]=w.useState(()=>t?e?.initialState?.error??null:null),[l,r]=w.useState(!t),s=!!e?.initialRefresh,u=!!e?.publishToPreloadCache;w.useEffect(()=>{if(!(!i||typeof window>"u"))try{window.localStorage.getItem(p)==="1"&&q(i)}catch{}},[i]);const c=w.useCallback((o,a)=>{!u||!o||typeof o!="object"||M(o,{source:a})},[u]),m=w.useCallback(async()=>{try{const o=await b({refresh:!0}),a=o&&typeof o=="object"?o:null;d(a),n(null),c(a,"manual-refresh")}catch(o){n(o?.message||String(o))}},[c]),k=w.useCallback(async()=>{try{const o=await b(),a=o&&typeof o=="object"?o:null;d(a),n(null),c(a,"page-load")}catch(o){n(o?.message||String(o))}},[c]);return w.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const o=15e3;let a=Date.now();const f=()=>{if(document.visibilityState!=="visible")return;const h=Date.now();h-a<o||(a=h,k())};return window.addEventListener("focus",f),document.addEventListener("visibilitychange",f),()=>{window.removeEventListener("focus",f),document.removeEventListener("visibilitychange",f)}},[k]),w.useEffect(()=>{if(t&&!s)return;let o=!1;return(async()=>{try{const a=await b();if(o)return;const f=a&&typeof a=="object"?a:null;d(f),n(null),c(f,"page-load")}catch(a){if(o)return;n(a?.message||String(a))}finally{o||r(!1)}})(),()=>{o=!0}},[t,s,c]),{data:i,error:y,isLoading:l,refresh:m}}export{T as P,j as a,U as b,C as c,R as r,q as s,W as u};
import{r as e,C as t,D as r,v as c}from"./__vite-browser-external-CHbEWSwX.js";const s=Object.freeze({currency:c,rate:1,symbol:"$",rates:{...r},rateSource:"default",rateFetchedAt:null,setCurrency:()=>{}});function a(){return e.useContext(t)??s}export{a as u};
import{cd as Xe,ce as Dt,aP as Ot,aO as H,aR as wt,by as K,cf as Ct,cg as $e,j as Se,ch as ze,r as g,K as V,ci as ot,cj as _t,aS as it,bw as Le,ck as Gt,cl as ct,cm as xt,bA as x,bz as ke,bR as he,cn as Ve,co as le,cp as ae,aM as C,bD as Ut,cq as It,cr as Je,cs as Kt,bO as ut,bJ as lt,bL as Xt,ct as Vt,aL as be,bN as qt,cu as jt,aJ as Pe,bI as $t,cv as Ze,aU as Be,cw as zt,cx as He,bE as Jt,bv as We,bF as Zt,bx as Ie,cy as De,cz as Qt,cA as en,cB as tn,aN as nn,aC as Te,cC as me,cD as rn,aX as sn,aG as on,aD as _e,cE as at,cF as cn,cG as Qe}from"./__vite-browser-external-CHbEWSwX.js";function Fe(e,t,n=!0){return e.filter(s=>s.parentId===t).flatMap(s=>[...!n||s.context?.open?[s]:[],...Fe(e,s.id,n)])}function ft(e,t){let n=[],r=e.find(s=>s.id===t)?.parentId;for(;r;){const s=e.find(o=>o.id===r);r=s?.parentId,s&&(n=n.concat(s))}return n}function un(e){e.preventDefault(),e.stopPropagation()}function ln(e){return"nativeEvent"in e}function an(e){return e.pointerType===""&&e.isTrusted?!0:Xe&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function fn(e){return Dt?!1:!Xe&&e.width===0&&e.height===0||Xe&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function jn(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function dn(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}function Ae(e){const t=Ot(pn,e).current;return t.next=e,H(t.effect),t}function pn(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}let Ne=0;function Ge(e,t={}){const{preventScroll:n=!1,sync:r=!1,shouldFocus:s}=t;cancelAnimationFrame(Ne);function o(){s&&!s()||e?.focus({preventScroll:n})}if(r)return o(),wt;const i=requestAnimationFrame(o);return Ne=i,()=>{Ne===i&&(cancelAnimationFrame(i),Ne=0)}}const Ue={inert:new WeakMap,"aria-hidden":new WeakMap},dt="data-base-ui-inert",qe={inert:new WeakSet,"aria-hidden":new WeakSet};let xe=new WeakMap,Ke=0;function gn(e){return qe[e]}function kt(e){return e?Ct(e)?e.host:kt(e.parentNode):null}const pt=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=kt(n);return e.contains(r)?r:null}).filter(n=>n!=null),gt=e=>{const t=new Set;return e.forEach(n=>{let r=n;for(;r&&!t.has(r);)t.add(r),r=r.parentNode}),t},ht=(e,t,n)=>{const r=[],s=o=>{!o||n.has(o)||Array.from(o.children).forEach(i=>{$e(i)!=="script"&&(t.has(i)?s(i):r.push(i))})};return s(e),r};function hn(e,t,n,r,{mark:s=!0}){let o=null;r?o="inert":n&&(o="aria-hidden");let i=null,u=null;const h=pt(t,e),f=s?ht(t,gt(h),new Set(h)):[],k=[],W=[];if(o){const b=Ue[o],T=gn(o);u=T,i=b;const A=pt(t,Array.from(t.querySelectorAll("[aria-live]"))),P=h.concat(A);ht(t,gt(P),new Set(P)).forEach(y=>{const E=y.getAttribute(o),Z=E!==null&&E!=="false",Y=(b.get(y)||0)+1;b.set(y,Y),k.push(y),Y===1&&Z&&T.add(y),Z||y.setAttribute(o,o==="inert"?"":"true")})}return s&&f.forEach(b=>{const T=(xe.get(b)||0)+1;xe.set(b,T),W.push(b),T===1&&b.setAttribute(dt,"")}),Ke+=1,()=>{i&&k.forEach(b=>{const A=(i.get(b)||0)-1;i.set(b,A),A||(!u?.has(b)&&o&&b.removeAttribute(o),u?.delete(b))}),s&&W.forEach(b=>{const T=(xe.get(b)||0)-1;xe.set(b,T),T||b.removeAttribute(dt)}),Ke-=1,Ke||(Ue.inert=new WeakMap,Ue["aria-hidden"]=new WeakMap,qe.inert=new WeakSet,qe["aria-hidden"]=new WeakSet,xe=new WeakMap)}}function mt(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:s=!0}=t,o=K(e[0]).body;return hn(e,o,n,r,{mark:s})}function Pt(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class mn{nodesRef={current:[]};events=Pt();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const Ft=g.createContext(null),Mt=g.createContext(null),et=()=>g.useContext(Ft)?.id||null,tt=e=>{const t=g.useContext(Mt);return e??t};function $n(e){const t=ze(),n=tt(e),r=et();return H(()=>{if(!t)return;const s={id:t,parentId:r};return n?.addNode(s),()=>{n?.removeNode(s)}},[n,t,r]),t}function zn(e){const{children:t,id:n}=e,r=et();return Se.jsx(Ft.Provider,{value:g.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Jn(e){const{children:t,externalTree:n}=e,r=Ot(()=>n??new mn).current;return Se.jsx(Mt.Provider,{value:r,children:t})}function bn(e,t){const n=Be(be(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const bt=20;let fe=[];function nt(){fe=fe.filter(e=>e.deref()?.isConnected)}function Et(e){nt(),e&&$e(e)!=="body"&&(fe.push(new WeakRef(e)),fe.length>bt&&(fe=fe.slice(-bt)))}function yt(){return nt(),fe[fe.length-1]?.deref()}function En(e){return e?Ze(e)?e:xt(e)[0]||e:null}function Rt(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!e.getAttribute("role")?.includes("dialog"))return;const n=zt(e).filter(s=>{const o=s.getAttribute("data-tabindex")||"";return Ze(s)||s.hasAttribute("data-tabindex")&&!o.startsWith("-")}),r=e.getAttribute("tabindex");n.length===0?r!=="0"&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):(r!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function Zn(e){const{context:t,children:n,disabled:r=!1,initialFocus:s=!0,returnFocus:o=!0,restoreFocus:i=!1,modal:u=!0,closeOnFocusOut:h=!0,openInteractionType:f="",nextFocusableElement:k,previousFocusableElement:W,beforeContentFocusGuardRef:b,externalTree:T,getInsideElements:A}=e,P="rootStore"in t?t.rootStore:t,D=P.useState("open"),y=P.useState("domReferenceElement"),E=P.useState("floatingElement"),{events:Z,dataRef:Y}=P.context,q=V(()=>Y.current.floatingContext?.nodeId),J=s===!1,_=ot(y)&&J,se=Ae(s),F=Ae(o),j=Ae(f),ve=Ae(D),N=tt(T),R=_t(),B=g.useRef(!1),oe=g.useRef(!1),ee=g.useRef(!1),te=g.useRef(null),Ee=g.useRef(""),de=g.useRef(""),pe=g.useRef(null),ye=g.useRef(null),S=it(pe,b,R?.beforeInsideRef),$=it(ye,R?.afterInsideRef),ie=Le(),ce=Le(),Oe=Gt(),Me=R!=null,p=ct(E),ne=V((m=p)=>m?xt(m):[]),Q=V(()=>A?.().filter(m=>m!=null)??[]);g.useEffect(()=>{if(r||!u)return;function m(L){L.key==="Tab"&&C(p,ae(K(p)))&&ne().length===0&&!_&&un(L)}const I=K(p);return x(I,"keydown",m)},[r,p,u,_,ne]),g.useEffect(()=>{if(r||!D)return;const m=K(p);function I(){ee.current=!1}function L(z){const a=be(z),O=Q(),d=C(E,a)||C(y,a)||C(R?.portalNode,a)||O.some(M=>M===a||C(M,a));ee.current=!d,de.current=z.pointerType||"keyboard",a?.closest(`[${qt}]`)&&(oe.current=!0,ce.start(0,()=>{oe.current=!1}))}function G(){de.current="keyboard"}return ke(x(m,"pointerdown",L,!0),x(m,"pointerup",I,!0),x(m,"pointercancel",I,!0),x(m,"keydown",G,!0),I)},[r,E,y,p,D,R,ce,Q]),g.useEffect(()=>{if(r||!h)return;const m=K(p);function I(){oe.current=!0,ce.start(0,()=>{oe.current=!1})}function L(O){const d=be(O);Ze(d)&&(te.current=d)}function G(O){const d=O.relatedTarget,M=O.currentTarget,U=be(O);u&&d==null&&U!=null&&C(E,U)&&Et(U),queueMicrotask(()=>{const w=q(),Re=P.context.triggerElements,c=Q(),l=d?.hasAttribute(Ve("focus-guard"))&&[pe.current,ye.current,R?.beforeInsideRef.current,R?.afterInsideRef.current,R?.beforeOutsideRef.current,R?.afterOutsideRef.current,le(W),le(k)].includes(d),X=!(C(y,d)||C(E,d)||C(d,E)||C(R?.portalNode,d)||c.some(v=>v===d||C(v,d))||d!=null&&Re.hasElement(d)||Re.hasMatchingElement(v=>C(v,d))||l||N&&(Fe(N.nodesRef.current,w).find(v=>C(v.context?.elements.floating,d)||C(v.context?.elements.domReference,d))||ft(N.nodesRef.current,w).find(v=>[v.context?.elements.floating,ct(v.context?.elements.floating)].includes(d)||v.context?.elements.domReference===d)));if(M===y&&p&&Rt(p),i&&M!==y&&!jt(U)&&ae(m)===m.body){if(he(p)&&(p.focus(),i==="popup")){Oe.request(()=>{p.focus()});return}const v=ne(),ue=te.current,we=(ue&&v.includes(ue)?ue:null)||v[v.length-1]||p;he(we)&&we.focus()}if(Y.current.insideReactTree){Y.current.insideReactTree=!1;return}(_||!u)&&d&&X&&!oe.current&&(_||d!==yt())&&(B.current=!0,P.setOpen(!1,Pe($t,O)))})}function z(){ee.current||(Y.current.insideReactTree=!0,ie.start(0,()=>{Y.current.insideReactTree=!1}))}const a=he(y)?y:null;if(!(!E&&!a))return ke(a&&x(a,"focusout",G),a&&x(a,"pointerdown",I),E&&x(E,"focusin",L),E&&x(E,"focusout",G),E&&R&&x(E,"focusout",z,!0))},[r,y,E,p,u,N,R,P,h,i,ne,_,q,Y,ie,ce,Oe,k,W,Q]),g.useEffect(()=>{if(r||!E||!D)return;const m=Array.from(R?.portalNode?.querySelectorAll(`[${Ve("portal")}]`)||[]),L=(N?ft(N.nodesRef.current,q()):[]).find(M=>ot(M.context?.elements.domReference||null))?.context?.elements.domReference,z=[...[E,...m,pe.current,ye.current,R?.beforeOutsideRef.current,R?.afterOutsideRef.current,...Q()],L,le(W),le(k),_?y:null].filter(M=>M!=null),a=mt(z,{ariaHidden:u||_,mark:!1}),O=[E,...m].filter(M=>M!=null),d=mt(O);return()=>{d(),a()}},[D,r,y,E,u,R,_,N,q,k,W,Q]),H(()=>{if(!D||r||!he(p))return;const m=K(p),I=ae(m);queueMicrotask(()=>{const L=se.current,G=typeof L=="function"?L(j.current||""):L;if(G===void 0||G===!1||C(p,I))return;let a=null;const O=()=>(a==null&&(a=ne(p)),a[0]||p);let d;G===!0||G===null?d=O():d=le(G),d=d||O();const M=C(p,ae(m));Ge(d,{preventScroll:d===p,shouldFocus(){if(!ve.current)return!1;if(M)return!0;const U=ae(m);return!(U!==d&&C(p,U))}})})},[r,D,p,ne,se,j,ve]),H(()=>{if(r||!p)return;const m=K(p),I=ae(m),L=j.current==null;Et(I);function G(a){if(a.open||(Ee.current=bn(a.nativeEvent,de.current)),a.reason===Ut&&a.nativeEvent.type==="mouseleave"&&(B.current=!0),a.reason===It)if(a.nested)B.current=!1;else if(an(a.nativeEvent)||fn(a.nativeEvent))B.current=!1;else{let O=!1;K(p).createElement("div").focus({get preventScroll(){return O=!0,!1}}),O?B.current=!1:B.current=!0}}Z.on("openchange",G);function z(){const a=F.current;let O=typeof a=="function"?a(Ee.current):a;if(O===void 0||O===!1)return null;O===null&&(O=!0);const d=y?.isConnected?y:null,M=I?.isConnected&&$e(I)!=="body"?I:null;let U=L?M||d:d||M;return U||(U=yt()||null),typeof O=="boolean"?U:le(O)||U||null}return()=>{Z.off("openchange",G);const a=ae(m),O=Q(),d=C(E,a)||O.some(w=>w===a||C(w,a))||N&&Fe(N.nodesRef.current,q(),!1).some(w=>C(w.context?.elements.floating,a)),M=F.current,U=z();queueMicrotask(()=>{const w=En(U),Re=typeof M!="boolean";M&&!B.current&&he(w)&&(!(!Re&&w!==a&&a!==m.body)||d)&&w.focus({preventScroll:!0}),B.current=!1})}},[r,E,p,F,j,Z,N,y,q,Q]),H(()=>{if(!Je||D||!E)return;const m=ae(K(E));!he(m)||!Kt(m)||C(E,m)&&m.blur()},[D,E]),H(()=>{if(!(r||!R))return R.setFocusManagerState({modal:u,closeOnFocusOut:h,open:D,onOpenChange:P.setOpen,domReference:y}),()=>{R.setFocusManagerState(null)}},[r,R,u,D,P,h,y]),H(()=>{if(!(r||!p))return Rt(p),()=>{queueMicrotask(nt)}},[r,p]);const ge=!r&&(u?!_:!0)&&(Me||u);return Se.jsxs(g.Fragment,{children:[ge&&Se.jsx(ut,{"data-type":"inside",ref:S,onFocus:m=>{if(u){const I=ne();Ge(I[I.length-1])}else R?.portalNode&&(B.current=!1,lt(m,R.portalNode)?Xt(y)?.focus():le(W??R.beforeOutsideRef)?.focus())}}),n,ge&&Se.jsx(ut,{"data-type":"inside",ref:$,onFocus:m=>{u?Ge(ne()[0]):R?.portalNode&&(h&&(B.current=!0),lt(m,R.portalNode)?Vt(y)?.focus():le(k??R.afterOutsideRef)?.focus())}})]})}function yn(){return!1}function Rn(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function Qn(e,t={}){const{enabled:n=!0,escapeKey:r=!0,outsidePress:s=!0,outsidePressEvent:o="sloppy",referencePress:i=yn,bubbles:u,externalTree:h}=t,f="rootStore"in e?e.rootStore:e,k=f.useState("open"),W=f.useState("floatingElement"),{dataRef:b}=f.context,T=tt(h),A=V(typeof s=="function"?s:()=>!1),P=typeof s=="function"?A:s,D=P!==!1,y=V(()=>o),{escapeKey:E,outsidePress:Z}=Rn(u),Y=g.useRef(!1),q=g.useRef(!1),J=g.useRef(!1),_=g.useRef(!1),se=g.useRef(""),F=g.useRef(null),j=Le(),ve=Le(),N=V(()=>{ve.clear(),b.current.insideReactTree=!1}),R=V(S=>{const $=b.current.floatingContext?.nodeId;return(T?Fe(T.nodesRef.current,$):[]).some(ce=>ce.context?.open&&!ce.context.dataRef.current[S])}),B=V(S=>He(S,f.select("floatingElement"))||He(S,f.select("domReferenceElement"))),oe=V(S=>{i()&&f.setOpen(!1,Pe(Jt,S.nativeEvent))}),ee=V(S=>{if(!k||!n||!r||S.key!=="Escape"||_.current||!E&&R("__escapeKeyBubbles"))return;const $=ln(S)?S.nativeEvent:S,ie=Pe(Zt,$);f.setOpen(!1,ie),ie.isCanceled||S.preventDefault(),!E&&!ie.isPropagationAllowed&&S.stopPropagation()}),te=V(()=>{b.current.insideReactTree=!0,ve.start(0,N)}),Ee=V(S=>{if(!k||!n||S.button!==0)return;const $=be(S.nativeEvent);C(f.select("floatingElement"),$)&&(Y.current||(Y.current=!0,q.current=!1))}),de=V(S=>{!k||!n||(S.defaultPrevented||S.nativeEvent.defaultPrevented)&&Y.current&&(q.current=!0)});g.useEffect(()=>{if(!k||!n)return;b.current.__escapeKeyBubbles=E,b.current.__outsidePressBubbles=Z;const S=new We,$=new We;function ie(){S.clear(),_.current=!0}function ce(){S.start(Je?5:0,()=>{_.current=!1})}function Oe(){J.current=!0,$.start(0,()=>{J.current=!1})}function Me(){Y.current=!1,q.current=!1}function p(){const c=se.current,l=c==="pen"||!c?"mouse":c,X=y(),v=typeof X=="function"?X():X;return typeof v=="string"?v:v[l]}function ne(c){const l=p();return l==="intentional"&&c.type!=="click"||l==="sloppy"&&c.type==="click"}function Q(c){const l=b.current.floatingContext?.nodeId,X=T&&Fe(T.nodesRef.current,l).some(v=>He(c,v.context?.elements.floating));return B(c)||X}function ge(c){if(ne(c)){c.type!=="click"&&!B(c)&&($.clear(),J.current=!1),N();return}if(b.current.insideReactTree){N();return}const l=be(c),X=`[${Ve("inert")}]`,v=Ie(l)?l.getRootNode():null,ue=Array.from((Ct(v)?v:K(f.select("floatingElement"))).querySelectorAll(X)),we=f.context.triggerElements;if(l&&(we.hasElement(l)||we.hasMatchingElement(re=>C(re,l))))return;let Ce=Ie(l)?l:null;for(;Ce&&!De(Ce);){const re=Qt(Ce);if(De(re)||!Ie(re))break;Ce=re}if(!(ue.length&&Ie(l)&&!en(l)&&!C(l,f.select("floatingElement"))&&ue.every(re=>!C(Ce,re)))){if(he(l)&&!("touches"in c)){const re=De(l),Ye=tn(l),st=/auto|scroll/,At=re||st.test(Ye.overflowX),Nt=re||st.test(Ye.overflowY),Lt=At&&l.clientWidth>0&&l.scrollWidth>l.clientWidth,Wt=Nt&&l.clientHeight>0&&l.scrollHeight>l.clientHeight,Bt=Ye.direction==="rtl",Yt=Wt&&(Bt?c.offsetX<=l.offsetWidth-l.clientWidth:c.offsetX>l.clientWidth),Ht=Lt&&c.offsetY>l.clientHeight;if(Yt||Ht)return}if(!Q(c)){if(p()==="intentional"&&J.current){$.clear(),J.current=!1;return}typeof P=="function"&&!P(c)||R("__outsidePressBubbles")||(f.setOpen(!1,Pe(It,c)),N())}}}function m(c){p()!=="sloppy"||c.pointerType==="touch"||!f.select("open")||!n||B(c)||ge(c)}function I(c){if(p()!=="sloppy"||!f.select("open")||!n||B(c))return;const l=c.touches[0];l&&(F.current={startTime:Date.now(),startX:l.clientX,startY:l.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},j.start(1e3,()=>{F.current&&(F.current.dismissOnTouchEnd=!1,F.current.dismissOnMouseDown=!1)}))}function L(c,l){const X=be(c);if(!X)return;const v=x(X,c.type,()=>{l(c),v()})}function G(c){se.current="touch",L(c,I)}function z(c){j.clear(),c.type==="pointerdown"&&(se.current=c.pointerType),!(c.type==="mousedown"&&F.current&&!F.current.dismissOnMouseDown)&&L(c,l=>{l.type==="pointerdown"?m(l):ge(l)})}function a(c){if(!Y.current)return;const l=q.current;if(Me(),p()==="intentional"){if(c.type==="pointercancel"){l&&Oe();return}if(!Q(c)){if(l){Oe();return}typeof P=="function"&&!P(c)||($.clear(),J.current=!0,N())}}}function O(c){if(p()!=="sloppy"||!F.current||B(c))return;const l=c.touches[0];if(!l)return;const X=Math.abs(l.clientX-F.current.startX),v=Math.abs(l.clientY-F.current.startY),ue=Math.sqrt(X*X+v*v);ue>5&&(F.current.dismissOnTouchEnd=!0),ue>10&&(ge(c),j.clear(),F.current=null)}function d(c){L(c,O)}function M(c){p()!=="sloppy"||!F.current||B(c)||(F.current.dismissOnTouchEnd&&ge(c),j.clear(),F.current=null)}function U(c){L(c,M)}const w=K(W),Re=ke(r&&ke(x(w,"keydown",ee),x(w,"compositionstart",ie),x(w,"compositionend",ce)),D&&ke(x(w,"click",z,!0),x(w,"pointerdown",z,!0),x(w,"pointerup",a,!0),x(w,"pointercancel",a,!0),x(w,"mousedown",z,!0),x(w,"mouseup",a,!0),x(w,"touchstart",G,!0),x(w,"touchmove",d,!0),x(w,"touchend",U,!0)));return()=>{Re(),S.clear(),$.clear(),Me(),J.current=!1}},[b,W,r,D,P,k,n,E,Z,ee,N,y,R,B,T,f,j]),g.useEffect(N,[P,N]);const pe=g.useMemo(()=>({onKeyDown:ee,onPointerDown:oe,onClick:oe}),[ee,oe]),ye=g.useMemo(()=>({onKeyDown:ee,onPointerDown:de,onMouseDown:de,onClickCapture:te,onMouseDownCapture(S){te(),Ee(S)},onPointerDownCapture(S){te(),Ee(S)},onMouseUpCapture:te,onTouchEndCapture:te,onTouchMoveCapture:te}),[ee,te,Ee,de]);return g.useMemo(()=>n?{reference:pe,floating:ye,trigger:pe}:{},[n,pe,ye])}function Tn(e){const t=g.useRef(!0);t.current&&(t.current=!1,e())}const Sn={open:Te(e=>e.open),transitionStatus:Te(e=>e.transitionStatus),domReferenceElement:Te(e=>e.domReferenceElement),referenceElement:Te(e=>e.positionReference??e.referenceElement),floatingElement:Te(e=>e.floatingElement),floatingId:Te(e=>e.floatingId)};class vn extends nn{constructor(t){const{syncOnly:n,nested:r,onOpenChange:s,triggerElements:o,...i}=t;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:Pt(),nested:r,triggerElements:o},Sn),this.syncOnly=n}syncOpenEvent=(t,n)=>{(!t||!this.state.open||n!=null&&dn(n))&&(this.context.dataRef.current.openEvent=t?n:void 0)};dispatchOpenChange=(t,n)=>{this.syncOpenEvent(t,n.event);const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)};setOpen=(t,n)=>{if(this.syncOnly){this.context.onOpenChange?.(t,n);return}this.dispatchOpenChange(t,n),this.context.onOpenChange?.(t,n)}}function On(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:s,nested:o,onOpenChange:i}=e,u=t.useState("open"),h=t.useState("activeTriggerElement"),f=t.useState(n?"popupElement":"positionerElement"),k=t.context.triggerElements,W=i,b=g.useRef(null);r===void 0&&b.current===null&&(b.current=new vn({open:u,transitionStatus:void 0,referenceElement:h,floatingElement:f,triggerElements:k,onOpenChange:W,floatingId:s,syncOnly:!0,nested:o}));const T=r??b.current;return t.useSyncedValue("floatingId",s),H(()=>{const A={open:u,floatingId:s,referenceElement:h,floatingElement:f};Ie(h)&&(A.domReferenceElement=h),T.state.positionReference===T.state.referenceElement&&(A.positionReference=h),T.update(A)},[u,s,h,f,T]),T.context.onOpenChange=W,T.context.nested=o,T}function wn(e,t=!1,n=!1){const[r,s]=g.useState(e&&t?"idle":void 0),[o,i]=g.useState(e);return e&&!o&&(i(!0),s("starting")),!e&&o&&r!=="ending"&&!n&&s("ending"),!e&&!o&&r==="ending"&&s(void 0),H(()=>{if(!e&&o&&r!=="ending"&&n){const u=me.request(()=>{s("ending")});return()=>{me.cancel(u)}}},[e,o,r,n]),H(()=>{if(!e||t)return;const u=me.request(()=>{s(void 0)});return()=>{me.cancel(u)}},[t,e]),H(()=>{if(!e||!t)return;e&&o&&r!=="idle"&&s("starting");const u=me.request(()=>{s("idle")});return()=>{me.cancel(u)}},[t,e,o,r]),{mounted:o,setMounted:i,transitionStatus:r}}const er={tabIndex:-1,[rn]:""};function tr(e){return t=>t==="touch"?e.current:!0}function nr(e,t,n=!1){const r=ze(),s=et()!=null,o=g.useRef(null);e===void 0&&o.current===null&&(o.current=t(r,s));const i=e??o.current;return On({popupStore:i,treatPopupAsFloatingElement:n,floatingRootContext:i.state.floatingRootContext,floatingId:r,nested:s,onOpenChange:i.setOpen}),{store:i,internalStore:o.current}}function Cn(e,t){const n=g.useRef(null),r=g.useRef(null);return g.useCallback(s=>{if(e===void 0)return;let o=!1;if(n.current!==null){const i=n.current,u=r.current,h=t.context.triggerElements.getById(i);u&&h===u&&(t.context.triggerElements.delete(i),o=!0),n.current=null,r.current=null}if(s!==null&&(n.current=e,r.current=s,t.context.triggerElements.add(e,s),o=!0),o){const i=t.context.triggerElements.size;t.select("open")&&t.state.triggerCount!==i&&t.set("triggerCount",i)}},[t,e])}function rr(e,t,n,r=!1){t?e.preventUnmountingOnClose=!1:r&&(e.preventUnmountingOnClose=!0);const s=n?.id??null;(s||t)&&(e.activeTriggerId=s,e.activeTriggerElement=n??null)}function sr(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function or(e,t,n,r){Tn(()=>{t===void 0&&e.state.open===!1&&n&&(e.state={...e.state,open:!0,activeTriggerId:r,preventUnmountingOnClose:!1})})}function ir(e,t,n,r){const s=n.useState("isMountedByTrigger",e),o=Cn(e,n),i=V(u=>{if(o(u),!u)return;const h=n.select("open"),f=n.select("activeTriggerId");if(f===e){n.update({activeTriggerElement:u,...h?r:null});return}f==null&&h&&n.update({activeTriggerId:e,activeTriggerElement:u,...r})});return H(()=>{s&&n.update({activeTriggerElement:t.current,...r})},[s,n,t,...Object.values(r)]),{registerTrigger:i,isMountedByThisTrigger:s}}function cr(e,t={}){const{closeOnActiveTriggerUnmount:n=!1}=t,r=e.useState("open"),s=e.useState("triggerCount");H(()=>{if(!r){e.state.triggerCount!==0&&e.set("triggerCount",0);return}const o=e.context.triggerElements.size,i={};e.state.triggerCount!==o&&(i.triggerCount=o);const u=e.select("activeTriggerId");let h=null;if(u){const f=e.context.triggerElements.getById(u);f?f!==e.state.activeTriggerElement&&(i.activeTriggerElement=f):h=u}if(!h&&!u&&o===1){const f=e.context.triggerElements.entries().next();if(!f.done){const[k,W]=f.value;i.activeTriggerId=k,i.activeTriggerElement=W}}(i.triggerCount!==void 0||i.activeTriggerId!==void 0||i.activeTriggerElement!==void 0)&&e.update(i),h&&n&&queueMicrotask(()=>{if(e.select("open")&&e.select("activeTriggerId")===h&&!e.context.triggerElements.getById(h)){const f=Pe(sn);e.setOpen(!1,f),f.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[r,e,s,n])}function ur(e,t,n){const{mounted:r,setMounted:s,transitionStatus:o}=wn(e),i=t.useState("preventUnmountingOnClose"),u=e?!1:i;t.useSyncedValues({mounted:r,transitionStatus:o,preventUnmountingOnClose:u});const h=V(()=>{s(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return on({enabled:r&&!e&&!u,open:e,ref:t.context.popupRef,onComplete(){e||h()}}),{forceUnmount:h,transitionStatus:o}}function lr(e,t){e.useSyncedValues(t),H(()=>()=>{e.update({activeTriggerProps:_e,inactiveTriggerProps:_e,popupProps:_e})},[e])}function ar(e,t){H(()=>{!t&&e.state.openMethod!==null&&e.set("openMethod",null)},[t,e]),H(()=>()=>{e.state.openMethod!==null&&e.set("openMethod",null)},[e])}class fr{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elementsSet.delete(r),this.elementsSet.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elementsSet.delete(n),this.idMap.delete(t))}hasElement(t){return this.elementsSet.has(t)}hasMatchingElement(t){for(const n of this.elementsSet)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}let rt=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=at.startingStyle]="startingStyle",e[e.endingStyle=at.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align",e})({}),je=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const xn={[je.popupOpen]:""},In={[je.popupOpen]:"",[je.pressed]:""},kn={[rt.open]:""},Pn={[rt.closed]:""},Fn={[rt.anchorHidden]:""},dr={open(e){return e?xn:null}},pr={open(e){return e?In:null}},gr={open(e){return e?kn:Pn},anchorHidden(e){return e?Fn:null}};function hr(e){return ze(e,"base-ui")}const Mn="ArrowUp",An="ArrowDown",Nn="ArrowLeft",Ln="ArrowRight",Wn="Home",Bn="End",Yn=new Set([Nn,Ln]),Hn=new Set([Mn,An]),Dn=new Set([...Yn,...Hn]),mr=new Set([...Dn,Wn,Bn]),br=g.forwardRef(function(t,n){const{cutout:r,...s}=t;let o;if(r){const i=r.getBoundingClientRect();o=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${i.left}px ${i.top}px,${i.left}px ${i.bottom}px,${i.right}px ${i.bottom}px,${i.right}px ${i.top}px,${i.left}px ${i.top}px)`}return Se.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...s,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})});let Tt={},St={},vt="";function _n(e){if(typeof document>"u")return!1;const t=K(e);return Be(t).innerWidth-t.documentElement.clientWidth>0}function Gn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=K(e),r=n.documentElement,s=n.body,o=Qe(r)?r:s,i=o.style.overflowY,u=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",o.style.overflowY="scroll";const h=o.offsetWidth;o.style.overflowY="hidden";const f=o.offsetWidth;return o.style.overflowY=i,r.style.scrollbarGutter=u,h===f}function Un(e){const t=K(e),n=t.documentElement,r=t.body,s=Qe(n)?n:r,o={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,o)}}function Kn(e){const t=K(e),n=t.documentElement,r=t.body,s=Be(n);let o=0,i=0,u=!1;const h=me.create();if(Je&&(s.visualViewport?.scale??1)!==1)return()=>{};function f(){const T=s.getComputedStyle(n),A=s.getComputedStyle(r),y=(T.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,i=n.scrollLeft,Tt={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},vt=n.style.scrollBehavior,St={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const E=n.scrollHeight>n.clientHeight,Z=n.scrollWidth>n.clientWidth,Y=T.overflowY==="scroll"||A.overflowY==="scroll",q=T.overflowX==="scroll"||A.overflowX==="scroll",J=Math.max(0,s.innerWidth-r.clientWidth),_=Math.max(0,s.innerHeight-r.clientHeight),se=parseFloat(A.marginTop)+parseFloat(A.marginBottom),F=parseFloat(A.marginLeft)+parseFloat(A.marginRight),j=Qe(n)?n:r;if(u=Gn(e),u){n.style.scrollbarGutter=y,j.style.overflowY="hidden",j.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:y,overflowY:"hidden",overflowX:"hidden"}),(E||Y)&&(n.style.overflowY="scroll"),(Z||q)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:se||_?`calc(100dvh - ${se+_}px)`:"100dvh",width:F||J?`calc(100vw - ${F+J}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=o,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function k(){Object.assign(n.style,Tt),Object.assign(r.style,St),u||(n.scrollTop=o,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=vt)}function W(){k(),h.request(f)}f();const b=x(s,"resize",W);return()=>{h.cancel(),k(),typeof s.removeEventListener=="function"&&b()}}class Xn{lockCount=0;restore=null;timeoutLock=We.create();timeoutUnlock=We.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=K(t).documentElement,s=Be(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=wt;return}const o=cn||!_n(t);this.restore=o?Un(t):Kn(t)}}const Vn=new Xn;function Er(e=!0,t=null){H(()=>{if(e)return Vn.acquire(t)},[e,t])}export{pr as A,$n as B,rt as C,zn as D,Ge as E,vn as F,un as G,an as H,br as I,fn as J,fr as P,er as a,mr as b,tr as c,Zn as d,ar as e,cr as f,ur as g,Qn as h,Er as i,lr as j,nr as k,Tn as l,wn as m,jn as n,tt as o,gr as p,et as q,Fe as r,rr as s,dr as t,hr as u,Ae as v,sr as w,Jn as x,or as y,ir as z};
import{r as e,T as r,l as n,m as a,n as s}from"./__vite-browser-external-CHbEWSwX.js";const T=Object.freeze({mode:n.COMPACT,setMode:()=>{},formatTokens:(o,t={})=>s(o,t),formatTokensTooltip:(o,t={})=>a(o,t)});function f(){return e.useContext(r)??T}export{f as u};
import{j as e,c as o,I,M as P,r as u,o as D,R as E,b as M}from"./__vite-browser-external-CHbEWSwX.js";import{S as _}from"./Select-DE6DMSrS.js";import{u as K,T as R}from"./use-native-settings-CIHg16YZ.js";import{F as j,S as G,a as O}from"./FadeIn-D_skMXdS.js";import{A as $}from"./arrow-up-right-B1yj6nxk.js";import{D as z}from"./download-HHcFs0Ff.js";import"./SelectItemText-Ca7gf5A0.js";import"./useScrollLock-DdUQVKDA.js";import"./check-Dvngccc0.js";import"./Card-D4wKdGxL.js";const H=["todayTokens","todayCost"],W=[{id:"todayTokens",label:"Today Tokens",shortLabel:"Tokens",category:"tokens"},{id:"todayCost",label:"Today Cost",shortLabel:"Cost",category:"cost"},{id:"last7dTokens",label:"Last 7 Days",shortLabel:"7d",category:"tokens"},{id:"totalTokens",label:"Total Tokens",shortLabel:"Total",category:"tokens"},{id:"totalCost",label:"Total Cost",shortLabel:"All $",category:"cost"},{id:"claude5h",label:"Claude 5h Limit",shortLabel:"Cl 5h",category:"limits"},{id:"claude7d",label:"Claude 7d Limit",shortLabel:"Cl 7d",category:"limits"},{id:"codex5h",label:"Codex 5h Limit",shortLabel:"Cx 5h",category:"limits"},{id:"codex7d",label:"Codex 7d Limit",shortLabel:"Cx 7d",category:"limits"},{id:"codexCredits",label:"Codex Credit Limit",shortLabel:"Cx Cred",category:"limits"},{id:"codexSpark5h",label:"Codex Spark 5h Limit",shortLabel:"Cx Spark 5h",category:"limits"},{id:"codexSpark7d",label:"Codex Spark 7d Limit",shortLabel:"Cx Spark 7d",category:"limits"},{id:"cursorPlan",label:"Cursor Plan Limit",shortLabel:"Cu Plan",category:"limits"},{id:"cursorAuto",label:"Cursor Auto Limit",shortLabel:"Cu Auto",category:"limits"},{id:"cursorAPI",label:"Cursor API Limit",shortLabel:"Cu API",category:"limits"},{id:"geminiPro",label:"Gemini Pro Limit",shortLabel:"Gm Pro",category:"limits"},{id:"geminiFlash",label:"Gemini Flash Limit",shortLabel:"Gm Flash",category:"limits"},{id:"geminiLite",label:"Gemini Lite Limit",shortLabel:"Gm Lite",category:"limits"},{id:"kimiWeekly",label:"Kimi Weekly Limit",shortLabel:"Km Wk",category:"limits"},{id:"kimi5h",label:"Kimi 5h Limit",shortLabel:"Km 5h",category:"limits"},{id:"kimiTotal",label:"Kimi Total Limit",shortLabel:"Km Tot",category:"limits"},{id:"kiroMonth",label:"Kiro Monthly Limit",shortLabel:"Kr Mo",category:"limits"},{id:"kiroBonus",label:"Kiro Bonus Limit",shortLabel:"Kr Bn",category:"limits"},{id:"copilotPremium",label:"Copilot Premium Limit",shortLabel:"Co Prem",category:"limits"},{id:"copilotChat",label:"Copilot Chat Limit",shortLabel:"Co Chat",category:"limits"},{id:"antigravityClaudeWeekly",label:"Antigravity Claude 7d Limit",shortLabel:"Ag Cl 7d",category:"limits"},{id:"antigravityClaude5h",label:"Antigravity Claude 5h Limit",shortLabel:"Ag Cl 5h",category:"limits"},{id:"antigravityGeminiWeekly",label:"Antigravity Gemini 7d Limit",shortLabel:"Ag Gm 7d",category:"limits"},{id:"antigravityGemini5h",label:"Antigravity Gemini 5h Limit",shortLabel:"Ag Gm 5h",category:"limits"}];function v(t,a=W,r=2){const i=new Set(a.map(n=>n.id)),l=new Set,s=Array.isArray(t)?t.filter(n=>!i.has(n)||l.has(n)?!1:(l.add(n),!0)):[];return(s.length>0?s:H).slice(0,Math.max(1,Number(r)||2))}const U=264,V=124,x="ui-rounded, -apple-system, system-ui",L=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],X={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function Y(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function b({size:t="sm",children:a}){const r=t==="lg",i=r?560:264,l=r?32:22;return e.jsx("div",{className:M("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",r?"py-10 sm:py-14 px-6":"py-6 px-4"),children:e.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:i,aspectRatio:`${U} / ${V}`,borderRadius:l},children:a})})}function Z({size:t="sm"}){const a="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",r=`${a} L264,124 L0,124 Z`,i=`sparkArea-${t}`;return e.jsx(b,{size:t,children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:i,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),e.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),e.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"TODAY"}),e.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:x,children:"203.2M"}),e.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:x,children:"$129.56 ±0%"}),e.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"7 DAYS"}),e.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:x,children:"880.9M"}),e.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:x,children:"$673.61"}),e.jsx("path",{d:r,fill:`url(#${i})`,stroke:"none"}),e.jsx("path",{d:a,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const C=(()=>{const r=[];for(let i=0;i<26;i++)for(let l=0;l<7;l++){const s=Math.sin((i+1)*12.9898+(l+1)*78.233+17)*43758.5453,c=Math.floor(Math.abs(s-Math.floor(s))*100);r.push({w:i,d:l,v:c})}return r})();function S(t,a){return t<18?a?"#262626":"#e5e5e5":t<38?"rgba(10, 132, 255, 0.28)":t<58?"rgba(10, 132, 255, 0.50)":t<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function q(){return e.jsx(b,{children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:C.map(s=>e.jsx("rect",{x:s.w*(7.5+1.2),y:s.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:S(s.v,!0)},`d-${s.w}-${s.d}`))}),e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:C.map(s=>e.jsx("rect",{x:s.w*(7.5+1.2),y:s.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:S(s.v,!1)},`l-${s.w}-${s.d}`))}),e.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:x,children:"10.3B"}),e.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:"tokens · 202 active days"})]})})}function J(){const t=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],a=22,r=28,i=14,l=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((s,c)=>{const n=r+c*a,h=L[c%L.length];return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:s.name}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:x,children:s.value}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:x,children:[s.pct,"%"]}),e.jsx("rect",{x:i,y:n+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:i,y:n+4,width:Math.max(l*(s.pct/100),4),height:"2.8",rx:"1.4",fill:h})]},s.name)})})})}function Q(){const t=[{label:"Claude · 7d",source:"claude",reset:"in 1d",pct:61},{label:"Claude · 5h",source:"claude",reset:"in 4h 28m",pct:4},{label:"Cursor",source:"cursor",reset:"in 25d",pct:51},{label:"Codex · weekly",source:"codex",reset:"in 1d",pct:32}],a=22,r=28,i=14,l=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((s,c)=>{const n=r+c*a,h=X[s.source],y=Y(s.pct/100);return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:s.label}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:x,children:s.reset}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:x,children:[s.pct,"%"]}),e.jsx("rect",{x:i,y:n+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:i,y:n+4,width:Math.max(l*(s.pct/100),4),height:"2.8",rx:"1.4",fill:y})]},s.label)})})})}function ee(t){switch(t.category){case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function te(t,a){switch(t){case"todayTokens":return o("menubar.metric.today_tokens");case"todayCost":return o("menubar.metric.today_cost");case"last7dTokens":return o("menubar.metric.last_7d_tokens");case"totalTokens":return o("menubar.metric.total_tokens");case"totalCost":return o("menubar.metric.total_cost");case"claude5h":return o("menubar.metric.claude_5h");case"claude7d":return o("menubar.metric.claude_7d");case"codex5h":return o("menubar.metric.codex_5h");case"codex7d":return o("menubar.metric.codex_7d");case"codexCredits":return o("menubar.metric.codex_credits");case"codexSpark5h":return o("menubar.metric.codex_spark_5h");case"codexSpark7d":return o("menubar.metric.codex_spark_7d");default:return a}}function ae(t,a){const r=new Set(a.map(l=>l.id)),i=t.filter(l=>r.has(l));for(const l of a){if(i.length>=2)break;i.includes(l.id)||i.push(l.id)}return i.slice(0,2)}function ie({slotConfigs:t,showStats:a}){return e.jsx("div",{className:"flex justify-center rounded-xl bg-gradient-to-b from-oai-gray-100 to-oai-gray-200 px-6 py-8 dark:from-oai-gray-950/80 dark:to-oai-gray-900/80",children:e.jsxs("div",{className:"inline-flex items-stretch rounded-md shadow-[0_1px_3px_rgba(0,0,0,0.18)] ring-1 ring-black/10 dark:ring-white/10 px-3",style:{background:"linear-gradient(180deg, #2c2c2e 0%, #1c1c1e 100%)"},children:[e.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:e.jsx("img",{src:"/clawd/mini/idle-tight.svg",alt:"","aria-hidden":"true",className:"block shrink-0",style:{height:22,width:"auto"},draggable:"false"})}),a?t.map(({slot:r,item:i},l)=>e.jsxs(E.Fragment,{children:[l>0?e.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,e.jsxs("div",{className:M("flex min-w-[52px] flex-col items-center justify-center py-1.5",l===0?"pl-1 pr-2":"px-2"),children:[e.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:i?.previewValue||"--"}),e.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:i?.shortLabel||"Metric"})]})]},r)):null]})})}function se({slot:t,value:a,options:r,disabled:i,onChange:l}){const s=t===0?o("menubar.slot.primary"):o("menubar.slot.secondary");return e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:s}),e.jsx(_,{value:a,disabled:i,ariaLabel:s,onValueChange:c=>l(t,c),options:r.map(c=>({value:c.id,label:c.displayLabel})),matchTriggerWidth:!0,className:"w-full px-3 py-2 text-sm font-medium"})]})}function N({label:t,hint:a,checked:r,disabled:i,onChange:l}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),a?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a}):null]}),e.jsx(R,{checked:r,disabled:i,onChange:l,ariaLabel:t})]})}function re({label:t,hint:a,value:r,options:i,disabled:l,onChange:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),a?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a}):null]}),e.jsx(_,{value:r,disabled:l,ariaLabel:t,onValueChange:s,options:i,className:"shrink-0 px-3 py-2 text-sm font-medium"})]})}function le(){const{available:t,settings:a,setSetting:r}=K(),i=u.useMemo(()=>(Array.isArray(a?.menuBarAvailableItems)?a.menuBarAvailableItems:W).map(m=>({...m,displayLabel:te(m.id,m.label),previewValue:ee(m)})),[a?.menuBarAvailableItems]),l=Number(a?.menuBarMaxItems)||2,s=u.useMemo(()=>v(a?.menuBarItems,i,l),[i,l,a?.menuBarItems]),c=u.useMemo(()=>ae(s,i),[i,s]),n=a?.showStats!==!1,h=d=>{r("menuBarItems",v(d,i,l))},y=(d,m)=>{const g=[...c];g[d===0?1:0]!==m&&(g[d]=m,h(g))},p=[0,1].map(d=>{const m=c[d]||i[d]?.id||"",w=c[d===0?1:0],F=i.filter(f=>f.id===m||f.id!==w),B=i.find(f=>f.id===m);return{slot:d,currentValue:m,options:F,item:B}}),T=["clawd","cat","pet","static"].includes(a?.menuBarIconStyle)?a.menuBarIconStyle:"clawd",k=a?.confettiOnReset!==!1;return e.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-5 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-6",children:[e.jsx(ie,{slotConfigs:p,showStats:n}),e.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:p.map(({slot:d,currentValue:m,options:g})=>e.jsx(se,{slot:d,value:m,options:g,disabled:!t||!n,onChange:y},d))}),e.jsxs("div",{className:"mt-5 divide-y divide-oai-gray-100 border-t border-oai-gray-100 dark:divide-oai-gray-800 dark:border-oai-gray-800",children:[e.jsx(N,{label:o("settings.menubar.showStats"),hint:t?o("settings.menubar.showStatsHint"):o("menubar.native_only"),checked:n,disabled:!t,onChange:()=>r("showStats",!n)}),e.jsx(re,{label:o("settings.menubar.iconStyle"),hint:o("settings.menubar.iconStyleHint"),value:T,disabled:!t,options:[{value:"clawd",label:o("settings.menubar.iconStyle.clawd")},{value:"cat",label:o("settings.menubar.iconStyle.cat")},{value:"pet",label:o("settings.menubar.iconStyle.pet")},{value:"static",label:o("settings.menubar.iconStyle.static")}],onChange:d=>r("menuBarIconStyle",d)}),e.jsx(N,{label:o("settings.menubar.confettiOnReset"),hint:o("settings.menubar.confettiOnResetHint"),checked:k,disabled:!t,onChange:()=>r("confettiOnReset",!k)})]})]})}function oe(){const[t,a]=u.useState("loading");return u.useEffect(()=>{if(typeof window>"u")return;if(D()){a("native");return}const r=(navigator.userAgent||"").toLowerCase(),i=/mac/.test(r)&&!/iphone|ipad/.test(r);a(i?"mac-web":"other")},[]),t}function ne(){const t=oe();return t==="loading"?e.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?e.jsxs("button",{type:"button",onClick:()=>I("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[o("widgets.cta.open_gallery"),e.jsx($,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?e.jsxs("a",{href:"https://github.com/mm7894215/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[e.jsx(z,{className:"h-4 w-4","aria-hidden":"true"}),o("widgets.cta.download")]}):e.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[e.jsx(P,{className:"h-4 w-4","aria-hidden":"true"}),o("widgets.cta.macos_only")]})}const ce=[{id:"summary",Preview:Z,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:q,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:J,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:Q,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function de({Preview:t,nameKey:a,descKey:r}){return e.jsxs("article",{className:"flex h-full flex-col rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[e.jsx(t,{}),e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:o(a)}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:o(r)})]})]})}function A({titleKey:t}){return e.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:o(t)})}function je(){return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[e.jsx(j,{y:12,children:e.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:o("widgets.page.title")}),e.jsx("div",{className:"shrink-0",children:e.jsx(ne,{})})]})}),e.jsx(j,{y:12,delay:.06,children:e.jsxs("section",{"aria-label":o("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[e.jsx(A,{titleKey:"widgets.menubar.section.title"}),e.jsx(le,{})]})}),e.jsxs("section",{"aria-label":o("widgets.gallery.section.title"),children:[e.jsx(A,{titleKey:"widgets.gallery.section.title"}),e.jsx(G,{staggerDelay:.08,initialDelay:.04,children:e.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:ce.map(({id:t,Preview:a,nameKey:r,descKey:i})=>e.jsx(O,{children:e.jsx(de,{Preview:a,nameKey:r,descKey:i})},t))})})]})]})})})}export{je as WidgetsPage};
import{r as l,j as e,i as y}from"./__vite-browser-external-CHbEWSwX.js";function o(a){return Number.isFinite(a)?Math.abs(a)>=1e12?(a/1e12).toFixed(2).replace(/\.?0+$/,"")+"T":y(a,{decimals:2}):"0"}function r({children:a,accent:n=!1,className:i=""}){const c="rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 p-6 bg-white dark:bg-oai-gray-900",d=n?"bg-gradient-to-br from-emerald-50 to-cyan-50 dark:from-emerald-900/30 dark:to-cyan-900/30 border-transparent":"";return e.jsx("div",{className:`${c} ${d} ${i}`,children:a})}function u(){const[a,n]=l.useState(null),[i,c]=l.useState("loading"),[d,g]=l.useState("");if(l.useEffect(()=>{let t=!1;const h=new URLSearchParams(window.location.search).get("year"),p=h?`/functions/tokentracker-wrapped?year=${encodeURIComponent(h)}`:"/functions/tokentracker-wrapped";return fetch(p).then(async s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}).then(s=>{t||(n(s),c(s.totals&&s.totals.tokens>0?"ready":"empty"))}).catch(s=>{t||(g(String(s?.message||s)),c("error"))}),()=>{t=!0}},[]),i==="loading")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center",children:e.jsx("p",{className:"text-oai-gray-500",children:"Loading…"})});if(i==="error")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(r,{children:e.jsxs("p",{className:"text-red-600 dark:text-red-300",children:["Couldn't load Wrapped: ",d]})})});if(i==="empty"||!a)return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(r,{children:e.jsxs("p",{className:"text-oai-gray-500",children:["No data for that year yet. Run ",e.jsx("code",{children:"tracker sync"})," first."]})})});const x=t=>`${(t*100).toFixed(0)}%`;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-white to-oai-gray-50 dark:from-oai-gray-950 dark:to-oai-gray-900 px-6 py-12",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsxs("header",{className:"text-center pb-6",children:[e.jsx("p",{className:"text-sm uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:"TokenTracker Wrapped"}),e.jsx("h1",{className:"text-6xl font-bold text-oai-gray-900 dark:text-white mt-2",children:a.year})]}),e.jsxs(r,{accent:!0,className:"text-center",children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300",children:"Total tokens"}),e.jsx("p",{className:"text-7xl font-bold text-emerald-700 dark:text-emerald-300 mt-2",children:o(a.totals.tokens)}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-4",children:["across ",e.jsx("strong",{children:a.totals.conversations.toLocaleString("en-US")})," conversations,"," ",e.jsx("strong",{children:a.totals.active_days})," active days, and"," ",e.jsx("strong",{children:a.totals.sources})," tools"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs(r,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:"Top tools"}),e.jsx("ul",{className:"space-y-3",children:a.top.sources.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white",children:t.source}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:[o(t.tokens)," · ",x(t.share)]})]},t.source))})]}),e.jsxs(r,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:"Top models"}),e.jsx("ul",{className:"space-y-3",children:a.top.models.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white truncate pr-3",children:t.model}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm whitespace-nowrap",children:[o(t.tokens)," · ",x(t.share)]})]},t.model))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.peak_hour&&e.jsxs(r,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:"Peak hour"}),e.jsxs("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:[String(a.peak_hour.hour).padStart(2,"0"),":00 UTC"]}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:[o(a.peak_hour.tokens)," tokens"]})]}),a.longest_streak&&a.longest_streak.days>0&&e.jsxs(r,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:"Longest streak"}),e.jsxs("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:[a.longest_streak.days," days"]}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:[a.longest_streak.from," → ",a.longest_streak.to]})]})]}),a.top.days.length>0&&e.jsxs(r,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:"Top days"}),e.jsx("ul",{className:"space-y-2",children:a.top.days.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white font-mono text-sm",children:t.day}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:o(t.tokens)})]},t.day))})]}),a.highlights.length>0&&e.jsxs(r,{accent:!0,children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300 mb-3",children:"Highlights"}),e.jsx("ul",{className:"space-y-2 text-oai-gray-800 dark:text-oai-gray-200",children:a.highlights.map((t,m)=>e.jsxs("li",{className:"text-base",children:["· ",t]},m))})]}),e.jsxs("footer",{className:"text-center text-xs text-oai-gray-400 dark:text-oai-gray-500 pt-6",children:["Generated from local queue.jsonl · share with"," ",e.jsx("code",{className:"font-mono",children:"tracker wrapped --json"})]})]})})}export{u as default};
import{k as a}from"./__vite-browser-external-CHbEWSwX.js";const o=[["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"}]],e=a("zap",o);export{e as Z};
+2
-2

@@ -252,4 +252,4 @@ <!doctype html>

</script>
<script type="module" crossorigin src="/assets/__vite-browser-external-Eoyj4eG-.js"></script>
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-C7JwykID.css">
<script type="module" crossorigin src="/assets/__vite-browser-external-CHbEWSwX.js"></script>
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-Cd947_ni.css">
</head>

@@ -256,0 +256,0 @@ <body>

@@ -78,4 +78,4 @@ <!doctype html>

</script>
<script type="module" crossorigin src="/assets/__vite-browser-external-Eoyj4eG-.js"></script>
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-C7JwykID.css">
<script type="module" crossorigin src="/assets/__vite-browser-external-CHbEWSwX.js"></script>
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-Cd947_ni.css">
</head>

@@ -82,0 +82,0 @@ <body>

{
"name": "tokentracker-cli",
"version": "0.82.0",
"version": "0.82.1",
"description": "Local-first AI coding token usage and cost tracker for 27 tools, with a dashboard, desktop pet, widgets, achievements, and native macOS/Windows apps.",

@@ -5,0 +5,0 @@ "main": "src/cli.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import{k as o,R as N,j as r}from"./__vite-browser-external-Eoyj4eG-.js";import{Z as $}from"./zap-DWWma29E.js";import{F as A}from"./flame-vLBOq0X0.js";const j=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],E=o("blocks",j);const L=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],C=o("brain",L);const T=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],z=o("calendar-days",T);const B=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],R=o("crown",B);const q=[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]],H=o("feather",q);const D=[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]],F=o("folder-git-2",D);const I=[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]],G=o("footprints",I);const V=[["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"}]],S=o("heart",V);const Z=[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]],O=o("medal",Z);const P=[["path",{d:"M18 5h4",key:"1lhgn2"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],X=o("moon-star",P);const K=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],U=o("rocket",K);const W=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Y=o("shield-check",W);const J=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Q=o("trending-up",J),f=[{id:"token_titan",scope:"cloud",icon:R,format:"tokens",art:"/achievements/token-titan.png"},{id:"big_day",scope:"cloud",icon:$,format:"tokens",art:"/achievements/big-day.png"},{id:"wordsmith",scope:"cloud",icon:H,format:"tokens",art:"/achievements/wordsmith.png"},{id:"marathoner",scope:"cloud",icon:G,format:"days",art:"/achievements/marathoner.png"},{id:"streak",scope:"cloud",icon:A,format:"days",art:"/achievements/streak.png"},{id:"weekend_warrior",scope:"cloud",icon:z,format:"days",art:"/achievements/weekend-warrior.png"},{id:"momentum",scope:"cloud",icon:Q,format:"multiplier",art:"/achievements/momentum.png"},{id:"polyglot",scope:"cloud",icon:C,format:"count",art:"/achievements/polyglot.png"},{id:"trendsetter",scope:"cloud",icon:U,format:"count",art:"/achievements/trendsetter.png"},{id:"multitool",scope:"cloud",icon:E,format:"count",art:"/achievements/multitool.png"},{id:"podium",scope:"cloud",icon:O,format:"rank",art:"/achievements/podium.png"},{id:"veteran",scope:"cloud",icon:Y,format:"days",art:"/achievements/veteran.png"},{id:"project_hopper",scope:"local",icon:F,format:"count",art:"/achievements/project-hopper.png"},{id:"project_devotion",scope:"local",icon:S,format:"tokens",art:"/achievements/project-devotion.png"},{id:"night_owl",scope:"local",icon:X,format:"count",art:"/achievements/night-owl.png"}],u=new Map(f.map(e=>[e.id,e])),m=new Map(f.map((e,a)=>[e.id,a]));function de(e,a){return`achievements.badge.${e}.${a}`}function ee(e){return[...e||[]].sort((a,t)=>{const c=(t?.tier||0)-(a?.tier||0);return c!==0?c:(m.get(a?.id)??99)-(m.get(t?.id)??99)})}function re(e){const a=(e||[]).filter(t=>t&&(t.tier||0)>=1&&u.has(t.id));return a.length===0?null:ee(a)[0]}const v={1:"bronze",2:"silver",3:"gold",4:"diamond"},ie=["bronze","silver","gold","diamond"],ae={bronze:{rim:["#a06a44","#5c3a22"],face:["#d29a6c","#96602f"],glyph:"#3f2817",ring:"#e8c3a0",sheen:"rgba(255, 236, 220, 0.45)",label:"#a06a44"},silver:{rim:["#aab3bb","#67707b"],face:["#dde2e7","#9ba5ae"],glyph:"#39424b",ring:"#f2f5f7",sheen:"rgba(255, 255, 255, 0.55)",label:"#8b959f"},gold:{rim:["#c9971c","#8a6508"],face:["#f2ca52","#cf9c26"],glyph:"#5c430e",ring:"#ffe9a8",sheen:"rgba(255, 248, 214, 0.55)",label:"#b8860b"},diamond:{rim:["#62b1e0","#7c6fd9"],face:["#c8ecf6","#84b4ea"],glyph:"#27496d",ring:"#eafcff",sheen:"rgba(255, 255, 255, 0.65)",label:"#5a9bd8"}},y={rim:["#a8ada9","#7c817d"],face:["#cdd2ce","#a3a8a4"],glyph:"#6a706c",ring:"#dde1de",sheen:"rgba(255, 255, 255, 0.25)",label:"#8b908c"};function te(e,a=!1){return a||!e||e<1?y:ae[v[Math.min(e,4)]]||y}function se(e){return v[e]||null}const g={xs:18,sm:24,md:44,xl:88,lg:108},k={xs:.75,sm:1,md:1.5,xl:2,lg:2};function le({badgeId:e,tier:a=0,size:t="md",locked:c=!1,label:i,className:M=""}){const s=u.get(e),h=c||!a||a<1,n=te(a,h),d=t==="fill",l=d?"100%":g[t]||g.md,b=d?4:k[t]||k.md,[_,x]=N.useState(!1),p=s?.icon||null,w=!!s?.art&&!_;return r.jsx("span",{role:i?"img":void 0,"aria-label":i||void 0,"aria-hidden":i?void 0:!0,className:`inline-flex shrink-0 rounded-full ${M}`,style:{width:l,height:l,padding:b,background:`linear-gradient(135deg, ${n.rim[0]} 0%, ${n.ring} 42%, ${n.rim[1]} 100%)`,boxShadow:d||t==="md"||t==="xl"||t==="lg"?"0 0 0 1px rgba(10, 15, 12, 0.06), 0 1px 2px rgba(10, 15, 12, 0.08)":void 0},children:w?r.jsx("img",{src:s.art,alt:"",draggable:!1,loading:"lazy",onError:()=>x(!0),className:"h-full w-full rounded-full object-cover",style:h?{filter:"grayscale(1)",opacity:.55}:void 0}):r.jsx("span",{className:"flex h-full w-full items-center justify-center rounded-full",style:{background:`linear-gradient(145deg, ${n.face[0]}, ${n.face[1]})`},children:p?r.jsx(p,{size:d?64:Math.round(l*.5),color:n.glyph,strokeWidth:2}):null})})}export{le as A,f as B,S as H,Q as T,ae as a,de as b,u as c,ie as d,re as h,te as p,ee as s,se as t};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BadgeDetailModal-FyvUrVvF.js","assets/__vite-browser-external-Eoyj4eG-.js","assets/__vite-browser-external-C7JwykID.css","assets/AchievementBadge-D6iPEEbz.js","assets/zap-DWWma29E.js","assets/flame-vLBOq0X0.js","assets/use-transform-lflyghWN.js","assets/AchievementsSection-ah-kG00E.js","assets/format-tokens-C6Pidz3s.js","assets/DialogTitle-z86PHHyk.js","assets/useScrollLock-C2C-Yazq.js"])))=>i.map(i=>d[i]);
import{r as l,z as x,A as f,E as v,j as e,c,L as p,R as g,e as y,F as b,G as k,_ as j}from"./__vite-browser-external-Eoyj4eG-.js";import{A as w}from"./AchievementsSection-ah-kG00E.js";import{B as h}from"./AchievementBadge-D6iPEEbz.js";import"./format-tokens-C6Pidz3s.js";import"./zap-DWWma29E.js";import"./flame-vLBOq0X0.js";function N({enabled:a=!0}={}){const[n,t]=l.useState({status:"loading",achievements:[],error:null}),s=l.useMemo(()=>x(),[]);return l.useEffect(()=>{if(!a){t({status:"disabled",achievements:[],error:null});return}let i=!1;return t(r=>({...r,status:"loading"})),f({timeZone:s,tzOffsetMinutes:v()}).then(r=>{i||t({status:"ready",achievements:Array.isArray(r?.achievements)?r.achievements:[],error:null})}).catch(r=>{i||t({status:"error",achievements:[],error:r})}),()=>{i=!0}},[a,s]),n}const A=g.lazy(()=>j(()=>import("./BadgeDetailModal-FyvUrVvF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])));function I({authLoading:a,authEnabled:n,authUserId:t,mockEnabled:s}){if(s)return{authLoading:!1,signedIn:!0,userId:"mock-user"};const i=!!(n&&t);return{authLoading:!!a,signedIn:i,userId:i?t:null}}function B(){const a=y(),[n,t]=l.useState({status:"loading",achievements:[],userId:null}),s=b(),{authLoading:i,signedIn:r,userId:o}=I({authLoading:a?.loading,authEnabled:a?.enabled,authUserId:a?.user?.id,mockEnabled:s});return l.useEffect(()=>{if(i){t({status:"loading",achievements:[],userId:null});return}if(!r){t({status:"signed-out",achievements:[],userId:null});return}let d=!1;return t({status:"loading",achievements:[],userId:o}),(async()=>{try{const u=s?null:await a.getAccessToken?.(),m=await k({accessToken:u,userId:o});if(d)return;t({status:"ready",achievements:Array.isArray(m?.badges)?m.badges:[],userId:o})}catch{d||t({status:"error",achievements:[],userId:o})}})(),()=>{d=!0}},[i,s,r,o]),{...n,signedIn:r,settled:_({authLoading:i,signedIn:r,userId:o,state:n})}}function _({authLoading:a,signedIn:n,userId:t,state:s}){return a?!1:n?s.userId===t&&(s.status==="ready"||s.status==="error"):s.status==="signed-out"}function E(){return e.jsx("div",{className:"mx-0 grid animate-pulse grid-cols-[repeat(3,max-content)] justify-between gap-y-7 sm:-mx-2 sm:grid-cols-[repeat(4,max-content)] lg:grid-cols-[repeat(5,max-content)]","aria-hidden":!0,children:Array.from({length:h.length}).map((a,n)=>e.jsxs("div",{className:"flex w-[6.75rem] flex-col items-center px-0 pb-3 pt-4 sm:w-[7.75rem]",children:[e.jsx("div",{className:"h-[108px] w-[108px] rounded-full bg-oai-gray-200 dark:bg-oai-gray-800"}),e.jsx("div",{className:"mt-3 h-3 w-16 rounded bg-oai-gray-200 dark:bg-oai-gray-800"}),e.jsx("div",{className:"mt-2 h-2 w-10 rounded bg-oai-gray-100 dark:bg-oai-gray-800/60"})]},n))})}function z(){const a=N(),n=B(),[t,s]=l.useState(null),i=a.status==="loading"||!n.settled,r=l.useMemo(()=>[...n.achievements||[],...a.achievements||[]],[n.achievements,a.achievements]),o=l.useMemo(()=>r.filter(u=>(u?.tier||0)>=1).length,[r]),d=h.length;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-4xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-7 flex items-baseline justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:c("achievements.page.title")}),e.jsx("p",{className:"mt-1.5 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:c("achievements.page.local_note")})]}),!i&&e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsxs("div",{className:"font-mono text-2xl font-semibold leading-none tabular-nums text-oai-black dark:text-white",children:[o,e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-600",children:["/",d]})]}),e.jsx("div",{className:"mt-2 h-1 w-24 overflow-hidden rounded-full bg-oai-gray-200 dark:bg-oai-gray-800",children:e.jsx("div",{className:"h-full rounded-full bg-oai-brand-600 transition-[width] duration-500",style:{width:`${Math.round(o/d*100)}%`}})})]})]}),!n.signedIn&&!i&&e.jsxs("div",{className:"mb-6 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 rounded-xl border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 dark:border-oai-gray-800 dark:bg-oai-gray-900/60",children:[e.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:c("achievements.signin.prompt")}),e.jsx(p,{to:"/login",className:"shrink-0 rounded-lg bg-oai-brand-600 px-3 py-1.5 text-sm font-medium text-white transition-colors duration-200 hover:bg-oai-brand-700 active:scale-[0.98]",children:c("achievements.signin.action")})]}),i?e.jsx(E,{}):e.jsxs(e.Fragment,{children:[e.jsx(w,{achievements:r,isOwn:!0,columns:"wide",size:"lg",animateIn:!0,onSelect:s}),e.jsxs("p",{className:"mt-10 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:[c("achievements.page.suggest")," ",e.jsx("a",{href:"https://github.com/mm7894215/TokenTracker/issues",target:"_blank",rel:"noopener noreferrer",className:"underline decoration-oai-gray-300 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:decoration-oai-gray-500 dark:decoration-oai-gray-600 dark:hover:text-oai-gray-300",children:c("achievements.page.suggest_link")})]})]})]})}),t&&e.jsx(g.Suspense,{fallback:null,children:e.jsx(A,{badge:t,onClose:()=>s(null)})})]})}export{_ as cloudBadgesSettled,z as default,I as resolveCloudBadgeIdentity};
import{k as _,w as $,j as s,c as l,x as C}from"./__vite-browser-external-Eoyj4eG-.js";import{B as x,s as b,b as T,t as B,A as E,a as L}from"./AchievementBadge-D6iPEEbz.js";import{f as I}from"./format-tokens-C6Pidz3s.js";const D=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],F=_("hard-drive",D);function G(r,i){const t=Number(i)||0;switch(r){case"tokens":return I(t);case"rank":return`#${Math.round(t)}`;case"multiplier":return`${(Math.round(t*10)/10).toString()}×`;default:return Math.round(t).toLocaleString()}}function H(r){if(!r)return 0;const i=Number(r.next_threshold),t=Number(r.metric_value??r.value);if(!Number.isFinite(i)||i<=0)return r.tier>=4?1:0;if(!Number.isFinite(t)||t<=0)return 0;const n=r.lower_is_better?i/t:t/i;return Math.max(0,Math.min(1,n))}function S(r){const i=r?.achieved||{},t=Object.values(i).map(n=>n?Date.parse(n):NaN).filter(n=>Number.isFinite(n));return t.length>0?Math.max(...t):null}function V({achievements:r,isOwn:i=!1,scope:t,onSelect:n,size:m="xl",columns:v="default",animateIn:y=!1,className:k=""}){const N=$(),u=y&&!N,p=new Map;for(const e of Array.isArray(r)?r:[])e&&e.id&&p.set(e.id,e);const g=t?x.filter(e=>e.scope===t):x;let c;if(i){const e=g.map(a=>({entry:a,record:p.get(a.id)||{id:a.id,tier:0}})),o=b(e.filter(a=>(a.record.tier||0)>=1).map(a=>({...a,id:a.entry.id,tier:a.record.tier}))),h=e.filter(a=>(a.record.tier||0)<1);c=[...o,...h]}else c=b(g.map(e=>({entry:e,record:p.get(e.id)})).filter(e=>e.record&&(e.record.tier||0)>=1).map(e=>({...e,id:e.entry.id,tier:e.record.tier}))).map(({entry:e,record:o})=>({entry:e,record:o}));if(c.length===0)return null;const j=v==="wide"?"grid-cols-[repeat(3,max-content)] sm:grid-cols-[repeat(4,max-content)] lg:grid-cols-[repeat(5,max-content)]":"grid-cols-[repeat(3,max-content)] sm:grid-cols-[repeat(4,max-content)]",w=m==="lg"?"mx-0 sm:-mx-2":"-mx-2 sm:-mx-4",M=m==="lg"?"px-0":"px-1";return s.jsx("div",{className:`${w} grid justify-between gap-y-7 ${j} ${k}`,children:c.map(({entry:e,record:o},h)=>{const a=(o.tier||0)>=1,f=l(T(e.id,"name")),d=a?B(o.tier):null,A=H(o);return s.jsxs(C.button,{type:"button",initial:u?{opacity:0,y:16,scale:.9}:!1,animate:u?{opacity:1,y:0,scale:1}:void 0,whileTap:u?{scale:.97}:void 0,transition:{delay:.05+h*.035,duration:.45,ease:[.16,1,.3,1]},onClick:n?()=>n({...o,id:e.id}):void 0,className:`group flex w-[6.75rem] flex-col items-center rounded-xl ${M} pb-3 pt-4 text-center transition-[background-color,transform] duration-200 ease-out hover:bg-oai-gray-50 active:scale-[0.97] dark:hover:bg-oai-gray-900/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60 sm:w-[7.75rem]`,"aria-label":l("achievements.badge.aria",{name:f,tier:d?l(`achievements.tier.${d}`):l("achievements.modal.locked")}),children:[s.jsx(E,{badgeId:e.id,tier:o.tier,locked:!a,size:m,className:"transition-transform duration-200 ease-out group-hover:-translate-y-0.5 group-hover:scale-105"}),s.jsxs("span",{className:"mt-2.5 flex w-full items-center justify-center gap-1",children:[s.jsx("span",{title:f,className:"min-w-0 truncate text-xs font-medium leading-tight text-oai-gray-800 dark:text-oai-gray-200",children:f}),e.scope==="local"&&s.jsx("span",{title:l("achievements.page.local_note"),"aria-label":l("achievements.scope.local"),className:"inline-flex shrink-0 text-oai-gray-400 dark:text-oai-gray-500",children:s.jsx(F,{size:11,strokeWidth:2,"aria-hidden":!0})})]}),s.jsx("span",{className:"mt-1 flex h-4 w-full items-center justify-center",children:a?s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.08em]",style:{color:L[d]?.label},children:l(`achievements.tier.${d}`)}):i?s.jsx("span",{className:"h-[3px] w-14 overflow-hidden rounded-full bg-oai-gray-200 dark:bg-oai-gray-800",children:s.jsx("span",{className:"block h-full rounded-full bg-oai-brand/70",style:{width:`${Math.round(A*100)}%`}})}):null})]},e.id)})})}export{V as A,H as b,G as f,S as l};
import{r as s,j as t,R as g,x as v,H as f,P as x}from"./__vite-browser-external-Eoyj4eG-.js";function C(a){const e=[...a];for(let o=e.length-1;o>0;o--){const i=Math.floor(Math.random()*(o+1));[e[o],e[i]]=[e[i],e[o]]}return e}function j(a,e){const o=C(a),i=Array.from({length:e},()=>[]);o.forEach((r,m)=>{i[m%e].push(r)});const c=Math.max(...i.map(r=>r.length));return i.forEach(r=>{for(;r.length<c;)r.push(o[Math.floor(Math.random()*o.length)])}),i}const w=g.memo(function({logos:e,index:o,currentTime:i,onHoverChange:c}){const[r,m]=s.useState(!1),l=4e3,p=o*400,n=(i+p)%(l*e.length),d=Math.floor(n/l),u=e[d],h=y=>{m(y),c(y)};return t.jsxs("div",{className:"relative flex flex-col items-center",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:[t.jsx(v.div,{className:"relative h-8 w-8 sm:h-10 sm:w-10 md:h-12 md:w-12 overflow-hidden",initial:{opacity:0,y:50},animate:{opacity:1,y:0},transition:{delay:o*.1,duration:.5,ease:"easeOut"},children:t.jsx(f,{mode:"wait",children:t.jsx(v.div,{className:"absolute inset-0 flex items-center justify-center",initial:{y:"18%",opacity:0,filter:"blur(4px)"},animate:{y:"0%",opacity:1,filter:"blur(0px)",transition:{type:"tween",ease:[.22,1,.36,1],duration:.9}},exit:{y:"-18%",opacity:0,filter:"blur(4px)",transition:{type:"tween",ease:[.4,0,1,1],duration:.55}},children:t.jsx(x,{provider:u.provider,size:24,className:"object-contain"})},`${u.id}-${d}`)})}),t.jsx(f,{children:r&&t.jsx(v.span,{className:"pointer-events-none absolute -bottom-7 z-10 whitespace-nowrap rounded bg-oai-gray-800 px-2 py-0.5 text-xs font-medium text-oai-gray-100 shadow-lg ring-1 ring-oai-gray-700",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:u.name})})]})});function L({logos:a,columnCount:e=2}){const[o,i]=s.useState([]),[c,r]=s.useState(0),[m,l]=s.useState(!1);s.useEffect(()=>{i(j(a,e))},[a,e]),s.useEffect(()=>{if(m)return;const n=setInterval(()=>r(d=>d+100),100);return()=>clearInterval(n)},[m]);const p=s.useCallback(n=>{l(n)},[]);return t.jsx("div",{className:"flex gap-2.5 sm:gap-4 text-oai-gray-200",children:o.map((n,d)=>t.jsx(w,{logos:n,index:d,currentTime:c,onHoverChange:p},d))})}const M=[{id:1,name:"Claude Code",provider:"claude"},{id:2,name:"Codex",provider:"codex"},{id:3,name:"Cursor",provider:"cursor"},{id:4,name:"Gemini",provider:"gemini"},{id:5,name:"Antigravity",provider:"antigravity"},{id:6,name:"Kiro",provider:"kiro"},{id:7,name:"OpenCode",provider:"opencode"},{id:8,name:"OpenClaw",provider:"openclaw"},{id:9,name:"Every Code",provider:"every-code"},{id:10,name:"Hermes",provider:"hermes"},{id:11,name:"GitHub Copilot",provider:"copilot"},{id:12,name:"Kimi",provider:"kimi"},{id:13,name:"CodeBuddy",provider:"codebuddy"},{id:14,name:"WorkBuddy",provider:"workbuddy"},{id:15,name:"Grok",provider:"grok"},{id:16,name:"oh-my-pi",provider:"omp"},{id:17,name:"Pi",provider:"pi"},{id:18,name:"Craft",provider:"craft"},{id:19,name:"Kilo CLI",provider:"kilo-cli"},{id:20,name:"Kilo Code",provider:"kilocode"},{id:21,name:"Roo Code",provider:"roocode"},{id:22,name:"Zed",provider:"zed"},{id:23,name:"Goose",provider:"goose"},{id:24,name:"Droid",provider:"droid"},{id:25,name:"Mimo",provider:"mimo"},{id:26,name:"ZCode",provider:"zcode"},{id:27,name:"AnythingLLM",provider:"anythingllm"}];export{M as A,L};
import{k as o}from"./__vite-browser-external-Eoyj4eG-.js";const t=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],a=o("arrow-up-right",t);export{a as A};
import{bR as De,bS as _e,bT as Ie,bU as Me,bV as Te,bW as be,bX as ye,bY as Ve,bZ as $e,b_ as Oe,b$ as Re,c0 as Be,c1 as Pe,c2 as Ke,c3 as Xe,c4 as Le,c5 as Ce,c6 as Fe,c7 as G,c8 as Ge,c9 as We,a3 as ze,ca as Ue,w as Ye,r as C,j as a,x as X,cb as Ze,c as h,b as ve,X as He}from"./__vite-browser-external-Eoyj4eG-.js";import{c as je,A as qe,p as Je,b as U,t as le,a as V,d as Qe}from"./AchievementBadge-D6iPEEbz.js";import{u as et,a as z}from"./use-transform-lflyghWN.js";import{l as ce,f as ue,b as tt}from"./AchievementsSection-ah-kG00E.js";import{D as nt,a as rt,b as at,c as st,d as it,e as ot}from"./DialogTitle-z86PHHyk.js";import"./zap-DWWma29E.js";import"./flame-vLBOq0X0.js";import"./format-tokens-C6Pidz3s.js";import"./useScrollLock-C2C-Yazq.js";const lt=(e,t,n)=>{const r=t-e;return((n-e)%r+r)%r+e};function Ne(e,t){return De(e)?e[lt(0,e.length,t)]:e}class ct{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>t.finished))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let r=0;r<this.animations.length;r++)this.animations[r][t]=n}attachTimeline(t){const n=this.animations.map(r=>r.attachTimeline(t));return()=>{n.forEach((r,s)=>{r&&r(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return de(this.animations,"duration")}get iterationDuration(){return de(this.animations,"iterationDuration")}runAll(t){this.animations.forEach(n=>n[t]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function de(e,t){let n=0;for(let r=0;r<e.length;r++){const s=e[r][t];s!==null&&s>n&&(n=s)}return n}class ut extends ct{then(t,n){return this.finished.finally(t).then(()=>{})}}function dt(e,t){return e in t}class ft extends _e{constructor(){super(...arguments),this.type="object"}readValueFromInstance(t,n){if(dt(n,t)){const r=t[n];if(typeof r=="string"||typeof r=="number")return r}}getBaseTargetFromProps(){}removeValueFromRenderState(t,n){delete n.output[t]}measureInstanceViewportBox(){return Ie()}build(t,n){Object.assign(t.output,n)}renderInstance(t,{output:n}){Object.assign(t,n)}sortInstanceNodePosition(){return 0}}function Y(e){return typeof e=="object"&&!Array.isArray(e)}function ke(e,t,n,r){return e==null?[]:typeof e=="string"&&Y(t)?Me(e,n,r):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(s=>s!=null):[e]}function mt(e,t,n){return e*(t+1)+n*t}function fe(e,t,n,r){return typeof t=="number"?t:t.startsWith("-")||t.startsWith("+")?Math.max(0,e+parseFloat(t)):t==="<"?n:t.startsWith("<")?Math.max(0,n+parseFloat(t.slice(1))):r.get(t)??e}function pt(e,t,n){for(let r=0;r<e.length;r++){const s=e[r];s.at>t&&s.at<n&&(be(e,s),r--)}}function ht(e,t,n,r,s,c){pt(e,s,c);for(let i=0;i<t.length;i++)e.push({value:t[i],at:Te(s,c,r[i]),easing:Ne(n,i)})}function gt(e,t,n=0){const r=t+1+t*n;for(let s=0;s<e.length;s++)e[s]=e[s]/r}function xt(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}const bt="easeInOut",yt=20;function vt(e,{defaultTransition:t={},...n}={},r,s){const c=t.duration||.3,i=new Map,m=new Map,f={},p=new Map;let g=0,u=0,x=0;for(let N=0;N<e.length;N++){const k=e[N];if(typeof k=="string"){p.set(k,u);continue}else if(!Array.isArray(k)){p.set(k.name,fe(u,k.at,g,p));continue}let[E,y,v={}]=k;v.at!==void 0&&(u=fe(u,v.at,g,p));let j=0;const I=(w,M,A,o=0,l=0)=>{const d=jt(w),{delay:D=0,times:b=Ve(d),type:R=t.type||"keyframes",repeat:B,repeatType:W,repeatDelay:Z=0,...Se}=M;let{ease:_=t.ease||"easeOut",duration:S}=M;const H=typeof D=="function"?D(o,l):D,q=d.length,J=Be(R)?R:s?.[R||"keyframes"];if(q<=2&&J){let $=100;if(q===2&&wt(d)){const P=d[1]-d[0];$=Math.abs(P)}const O={...t,...Se};S!==void 0&&(O.duration=Pe(S));const F=$e(O,$,J);_=F.ease,S=F.duration}S??(S=c);const Q=u+H;b.length===1&&b[0]===0&&(b[1]=1);const ee=b.length-d.length;if(ee>0&&Oe(b,ee),d.length===1&&d.unshift(null),B&&B<yt){const $=S>0?Z/S:0;S=mt(S,B,Z);const O=[...d],F=[...b];_=Array.isArray(_)?[..._]:[_];const P=[..._],ne=W==="reverse"||W==="mirror";let re=O,ae=P;ne&&(re=[...O].reverse(),W==="reverse"&&(ae=[...P].reverse().map(T=>typeof T=="function"?Re(T):T)));for(let T=0;T<B;T++){const se=ne&&T%2===0,ie=se?re:O,Ee=se?ae:P,oe=(T+1)*(1+$);$>0&&(d.push(d[d.length-1]),b.push(oe),_.push("linear")),d.push(...ie);for(let K=0;K<ie.length;K++)b.push(F[K]+oe),_.push(K===0?"linear":Ne(Ee,K-1))}gt(b,B,$)}const te=Q+S;ht(A,d,_,b,Q,te),j=Math.max(H+S,j),x=Math.max(te,x)};if(ye(E)){const w=me(E,m);I(y,v,pe("default",w))}else{const w=ke(E,y,r,f),M=w.length;for(let A=0;A<M;A++){y=y,v=v;const o=w[A],l=me(o,m);for(const d in y)I(y[d],Nt(v,d),pe(d,l),A,M)}}g=u,u+=j}return m.forEach((N,k)=>{for(const E in N){const y=N[E];y.sort(xt);const v=[],j=[],I=[];for(let o=0;o<y.length;o++){const{at:l,value:d,easing:D}=y[o];v.push(d),j.push(Ke(0,x,l)),I.push(D||"easeOut")}j[0]!==0&&(j.unshift(0),v.unshift(v[0]),I.unshift(bt)),j[j.length-1]!==1&&(j.push(1),v.push(null)),i.has(k)||i.set(k,{keyframes:{},transition:{}});const w=i.get(k);w.keyframes[E]=v;const{type:M,...A}=t;w.transition[E]={...A,duration:x,ease:I,times:j,...n}}}),i}function me(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function pe(e,t){return t[e]||(t[e]=[]),t[e]}function jt(e){return Array.isArray(e)?e:[e]}function Nt(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}const kt=e=>typeof e=="number",wt=e=>e.every(kt);function At(e){const t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=Xe(e)&&!Le(e)?new Ce(t):new Fe(t);n.mount(e),G.set(e,n)}function St(e){const t={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},n=new ft(t);n.mount(e),G.set(e,n)}function Et(e,t){return ye(e)||typeof e=="number"||typeof e=="string"&&!Y(t)}function we(e,t,n,r){const s=[];if(Et(e,t))s.push(Ge(e,Y(t)&&t.default||t,n&&(n.default||n)));else{if(e==null)return s;const c=ke(e,t,r),i=c.length;for(let m=0;m<i;m++){const f=c[m],p=f instanceof Element?At:St;G.has(f)||p(f);const g=G.get(f),u={...n};"delay"in u&&typeof u.delay=="function"&&(u.delay=u.delay(m,i)),s.push(...We(g,{...t,transition:u},{}))}}return s}function Dt(e,t,n){const r=[],s=e.map(i=>{if(Array.isArray(i)&&typeof i[0]=="function"){const m=i[0],f=ze(0);return f.on("change",m),i.length===1?[f,[0,1]]:i.length===2?[f,[0,1],i[1]]:[f,i[1],i[2]]}return i});return vt(s,t,n,{spring:Ue}).forEach(({keyframes:i,transition:m},f)=>{r.push(...we(f,i,m))}),r}function _t(e){return Array.isArray(e)&&e.some(Array.isArray)}function It(e={}){const{scope:t,reduceMotion:n,skipAnimations:r}=e;function s(c,i,m){let f=[],p;const g={};if(n!==void 0&&(g.reduceMotion=n),r!==void 0&&(g.skipAnimations=r),_t(c)){const{onComplete:x,...N}=i||{};typeof x=="function"&&(p=x),f=Dt(c,{...g,...N},t)}else{const{onComplete:x,...N}=m||{};typeof x=="function"&&(p=x),f=we(c,i,{...g,...N},t)}const u=new ut(f);return p&&u.finished.then(p),t&&(t.animations.push(u),u.finished.then(()=>{be(t.animations,u)})),u}return s}const L=It(),he=8;function Mt({badgeId:e,tier:t,locked:n=!1,size:r=176,backLines:s=[],label:c}){const i=et(0),m=Ye(),f=C.useRef(null),p=C.useRef(null),g=C.useRef(!1),u=Je(t,n),x=je.get(e)?.icon||null,N=z(i,o=>`${(o%360+360)%360/360*160-80}%`),k=z(i,o=>`${80-(o%360+360)%360/360*160}%`),E=z(i,o=>{const l=Math.abs(Math.sin(o*Math.PI/180));return Math.max(0,(l-.35)/.65)*.3}),y=()=>{p.current?.stop?.(),p.current=null};C.useEffect(()=>{if(m||g.current)return;let o=!1;i.set(-360);const l=L(i,0,{duration:.9,ease:[.16,1,.3,1]});return p.current=l,l.then(()=>{o||g.current||(p.current=L(i,[0,-14,14,0],{duration:4.5,repeat:1/0,ease:"easeInOut"}))}),()=>{o=!0,y()}},[m,i]);const v=o=>{const l=i.get();if(m){const b=Math.round(l/180)*180;p.current=L(i,b,{duration:.2,ease:"easeOut"});return}const d=l+o*.35,D=Math.round(d/180)*180;p.current=L(i,D,{type:"spring",velocity:o,stiffness:58,damping:13.5,mass:1})},j=o=>{g.current=!0,y(),o.currentTarget.setPointerCapture?.(o.pointerId),f.current={pointerId:o.pointerId,startX:o.clientX,startRot:i.get(),samples:[{t:o.timeStamp,x:o.clientX}]}},I=o=>{const l=f.current;!l||l.pointerId!==o.pointerId||(i.set(l.startRot+(o.clientX-l.startX)*.55),l.samples.push({t:o.timeStamp,x:o.clientX}),l.samples.length>5&&l.samples.shift())},w=o=>{const l=f.current;if(!l||l.pointerId!==o.pointerId)return;f.current=null;const d=l.samples[0],D=l.samples[l.samples.length-1],b=D.t-d.t,R=b>0?(D.x-d.x)*.55*1e3/b:0;v(R)},M=o=>{if(o.key!=="ArrowLeft"&&o.key!=="ArrowRight")return;o.preventDefault(),g.current=!0,y();const l=o.key==="ArrowRight"?30:-30;p.current=L(i,i.get()+l,{duration:.15,ease:"easeOut"})},A={backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"};return a.jsx("div",{role:"img","aria-label":c,tabIndex:0,onPointerDown:j,onPointerMove:I,onPointerUp:w,onPointerCancel:w,onKeyDown:M,className:"inline-flex cursor-grab select-none items-center justify-center outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60 rounded-full active:cursor-grabbing",style:{perspective:900,touchAction:"pan-y"},children:a.jsxs("div",{className:"relative",style:{transform:"rotateX(-8deg)",transformStyle:"preserve-3d"},children:[a.jsxs(X.div,{className:"relative",style:{rotateY:i,transformStyle:"preserve-3d",width:r,height:r},children:[[-3,-1.5,0,1.5,3].map(o=>a.jsx("div",{"aria-hidden":!0,className:"absolute inset-0 rounded-full",style:{transform:`translateZ(${o}px)`,background:u.rim[1]}},o)),a.jsxs("div",{className:"absolute inset-0 overflow-hidden rounded-full",style:{...A,transform:`translateZ(${he/2}px)`},children:[a.jsx(qe,{badgeId:e,tier:t,locked:n,size:"fill",className:"brightness-105 saturate-[1.08]"}),a.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{background:"radial-gradient(circle at 30% 20%, rgba(255,255,255,0.45), rgba(255,255,255,0) 42%), linear-gradient(172deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0) 38%, rgba(0,0,0,0.08) 100%)",boxShadow:"inset 0 3px 7px rgba(255,255,255,0.5), inset 0 -3px 8px rgba(0,0,0,0.15)"}}),a.jsx(X.div,{"aria-hidden":!0,className:"pointer-events-none absolute inset-0",style:{x:N,background:"linear-gradient(105deg, transparent 34%, rgba(255,255,255,0.5) 50%, transparent 66%)"}}),a.jsx(X.div,{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{opacity:E,background:"rgba(8, 12, 10, 0.9)"}})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-1 overflow-hidden rounded-full px-6 text-center",style:{...A,transform:`rotateY(180deg) translateZ(${he/2}px)`,background:`linear-gradient(145deg, ${u.face[0]}, ${u.face[1]})`,boxShadow:`inset 0 0 0 6px ${u.rim[1]}, inset 0 0 0 7.5px rgba(255,255,255,0.22), inset 0 3px 7px rgba(255,255,255,0.4), inset 0 -4px 12px rgba(0,0,0,0.22)`},children:[a.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{background:"repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06) 0px, rgba(255,255,255,0.06) 1px, transparent 1px, transparent 4px)"}}),x?a.jsx(x,{"aria-hidden":!0,size:Math.round(r*.62),strokeWidth:1.1,color:u.glyph,className:"pointer-events-none absolute opacity-[0.13]",style:{filter:"drop-shadow(0 1px 0 rgba(255,255,255,0.3)) drop-shadow(0 -1px 0 rgba(0,0,0,0.35))"}}):null,a.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{background:"radial-gradient(circle at 70% 20%, rgba(255,255,255,0.4), rgba(255,255,255,0) 44%), linear-gradient(188deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 38%, rgba(0,0,0,0.10) 100%)"}}),s.map((o,l)=>a.jsx("div",{className:`font-mono tabular-nums ${l===0?"text-[10px] uppercase tracking-[0.18em]":l===1?"text-lg font-bold":"text-[11px]"}`,style:{color:u.glyph,textShadow:"0 1px 0 rgba(255,255,255,0.28), 0 -1px 0 rgba(0,0,0,0.3)"},children:o},`${l}-${o}`)),a.jsx(X.div,{"aria-hidden":!0,className:"pointer-events-none absolute inset-0",style:{x:k,background:"linear-gradient(105deg, transparent 34%, rgba(255,255,255,0.45) 50%, transparent 66%)"}}),a.jsx(X.div,{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full",style:{opacity:E,background:"rgba(8, 12, 10, 0.9)"}})]})]}),a.jsx("div",{"aria-hidden":!0,className:"absolute left-1/2 h-3 w-3/5 rounded-[100%] bg-black/20 blur-md dark:bg-black/45",style:{bottom:-20,transform:"translateX(-50%)"}})]})})}function Ae(e){if(!e)return null;const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleDateString():null}function Tt(e){const t=Number(e);return!Number.isSafeInteger(t)||t<1?null:String(t).padStart(6,"0")}function Vt(e,t,n){if(t?.scope!=="cloud"||!n)return null;const r=Number(e?.serials?.[n]);return Number.isSafeInteger(r)&&r>=1?r:null}function $t({badge:e}){return a.jsx("div",{className:"flex items-center gap-1",children:Qe.map((t,n)=>{const r=(e.tier||0)>=n+1,s=Ae(e.achieved?.[t]),c=V[t];return a.jsx("span",{title:s?`${h(`achievements.tier.${t}`)} · ${s}`:h(`achievements.tier.${t}`),className:"inline-flex h-2 w-8 rounded-full",style:r?{background:`linear-gradient(120deg, ${c.rim[0]} 0%, ${c.ring} 55%, ${c.rim[1]} 100%)`,boxShadow:"inset 0 1px 1px rgba(255,255,255,0.4), 0 0 0 1px rgba(10,15,12,0.05)"}:void 0,children:!r&&a.jsx("span",{className:"h-full w-full rounded-full bg-oai-gray-200 dark:bg-oai-gray-800"})},t)})})}function ge({badge:e,onClose:t}){const n=je.get(e.id),r=h(U(e.id,"name")),s=(e.tier||0)>=1,c=s?le(e.tier):null,i=Ae(s?e.achieved?.[c]||(ce(e)?new Date(ce(e)).toISOString():null):null),m=ue(n?.format,e.metric_value),f=tt(e),p=e.tier<4?le((e.tier||0)+1):null,g=Vt(e,n,c),u=Tt(g),x=u?[h("achievements.modal.achieved_label"),h("achievements.modal.issue_number",{number:u}),i||r]:[s?h("achievements.modal.achieved_label"):h("achievements.modal.locked"),s?m:"···",s&&i?i:r];return a.jsxs("div",{className:"flex flex-col items-center px-6 pb-6 pt-5 text-center",children:[a.jsxs("div",{className:"flex w-full items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[a.jsx("h2",{className:"truncate text-lg font-semibold tracking-tight text-oai-black dark:text-white",children:r}),a.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:h(U(e.id,"desc"))})]}),a.jsx("button",{type:"button",onClick:t,"aria-label":h("achievements.modal.close"),className:"shrink-0 rounded-md p-1.5 text-oai-gray-400 transition-colors hover:bg-oai-gray-100 hover:text-oai-gray-700 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200",children:a.jsx(He,{size:16})})]}),a.jsx("div",{className:"mt-5 mb-7",children:a.jsx(Mt,{badgeId:e.id,tier:e.tier,locked:!s,backLines:x,label:h("achievements.modal.coin_aria",{name:r})})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"rounded-full px-2.5 py-0.5 text-[11px] font-semibold uppercase tracking-wide",style:s?{background:`linear-gradient(120deg, ${V[c].rim[0]} 0%, ${V[c].ring} 55%, ${V[c].rim[1]} 100%)`,color:V[c].glyph,textShadow:"0 1px 0 rgba(255,255,255,0.35)",boxShadow:"inset 0 1px 1px rgba(255,255,255,0.4), 0 0 0 1px rgba(10,15,12,0.06)"}:{background:"rgba(128,134,130,0.75)",color:"rgba(250,250,250,0.95)"},children:s?h(`achievements.tier.${c}`):h("achievements.modal.locked")}),s&&i?a.jsx("span",{className:"text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:i}):null]}),a.jsxs("dl",{className:"mt-5 w-full space-y-3 border-t border-oai-gray-200/70 pt-4 text-left dark:border-oai-gray-800/60",children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-3 text-sm",children:[a.jsx("dt",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:h("achievements.modal.value_label")}),a.jsx("dd",{className:"font-mono font-semibold tabular-nums text-oai-black dark:text-white",children:m})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[a.jsx("span",{children:e.tier>=4?h("achievements.modal.max_tier"):h("achievements.modal.progress_to_next",{tier:h(`achievements.tier.${p}`)})}),e.tier<4&&e.next_threshold!=null?a.jsxs("span",{className:"font-mono tabular-nums",children:[m," ",e.lower_is_better?"→":"/"," ",ue(n?.format,e.next_threshold)]}):null]}),a.jsx("div",{className:"mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-oai-gray-200 dark:bg-oai-gray-800",children:a.jsx("div",{className:"h-full rounded-full transition-[width] duration-500",style:{width:`${Math.round((e.tier>=4?1:f)*100)}%`,background:s?`linear-gradient(90deg, ${V[c].rim[0]} 0%, ${V[c].ring} 55%, ${V[c].rim[1]} 100%)`:"rgba(128,134,130,0.75)",boxShadow:s?"inset 0 1px 1px rgba(255,255,255,0.35)":void 0}})})]}),a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[a.jsx("span",{children:h("achievements.modal.tier_history")}),a.jsx($t,{badge:e})]})]})]})}const xe=ve("relative w-full max-w-[380px] 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]");function Gt({badge:e,onClose:t}){const n=Ze(),r=!!e;return C.useEffect(()=>{if(!n||!r)return;const s=c=>{c.key==="Escape"&&(c.stopPropagation(),t?.())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[n,r,t]),r?n?a.jsxs("div",{className:"fixed inset-0 z-[120] flex items-center justify-center p-4",children:[a.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-[2px]",onClick:t,"aria-hidden":!0}),a.jsx("div",{className:xe,children:a.jsx(ge,{badge:e,onClose:t})})]}):a.jsx(nt,{open:!0,onOpenChange:s=>{s||t?.()},children:a.jsxs(rt,{children:[a.jsx(at,{className:"cost-modal-backdrop z-[110]"}),a.jsx(st,{className:"fixed inset-0 z-[120] flex items-center justify-center p-4",children:a.jsxs(it,{className:ve("cost-modal-popup",xe),children:[a.jsx(ot,{render:a.jsx("h2",{className:"sr-only"}),children:h(U(e.id,"name"))}),a.jsx(ge,{badge:e,onClose:t})]})})]})}):null}export{Gt as BadgeDetailModal,Vt as currentBadgeIssueNumber,Gt as default,Tt as formatIssueNumber};
import{j as r}from"./__vite-browser-external-Eoyj4eG-.js";function t({children:i,title:a,subtitle:o,className:s="",bodyClassName:d=""}){return r.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${s}`,children:[(a||o)&&r.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[a&&r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:a}),o&&r.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:o})]}),r.jsx("div",{className:`p-5 ${d}`,children:i})]})}export{t as C};
import{k as c}from"./__vite-browser-external-Eoyj4eG-.js";const e=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=c("check",e);export{t as C};
import{r,j as f}from"./__vite-browser-external-Eoyj4eG-.js";function p(e){const n=String(e||"").trim().toLowerCase();return/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/.test(n)?n:"clawd"}const C=.84;function L(e){return p(e)==="clawd"?C:1}const z={idle:{row:0,durations:[280,110,110,140,140,320]},"running-right":{row:1,durations:[120,120,120,120,120,120,120,220]},"running-left":{row:2,durations:[120,120,120,120,120,120,120,220]},waving:{row:3,durations:[140,140,140,280]},jumping:{row:4,durations:[140,140,140,140,280]},failed:{row:5,durations:[140,140,140,140,140,140,140,240]},waiting:{row:6,durations:[150,150,150,150,150,260]},running:{row:7,durations:[120,120,120,120,120,220]},review:{row:8,durations:[150,150,150,150,150,280]}};function T(e){return["error","disconnected","working-overheated"].includes(e)?"failed":["happy","waking","mini-happy","jumping"].includes(e)?"jumping":["working-typing","working-ultrathink","working-juggling","running"].includes(e)?"running":["working-thinking","working-wizard","review"].includes(e)?"review":["sleeping","idle-doze","mini-sleep","waiting"].includes(e)?"waiting":["mini-peek","waving"].includes(e)?"waving":e==="running-left"||e==="running-right"?e:"idle"}function V(){const[e,n]=r.useState(()=>typeof document>"u"?!0:document.visibilityState!=="hidden");return r.useEffect(()=>{if(typeof document>"u")return;const t=()=>n(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),e}function _(){const[e,n]=r.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return r.useEffect(()=>{if(typeof window.matchMedia!="function")return;const t=window.matchMedia("(prefers-reduced-motion: reduce)"),i=o=>n(o.matches);return t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function I({character:e,pet:n=null,state:t="idle-living",dragState:i=null,size:o=48,className:d="",lookDirectionIndex:u=null}){const l=p(e),g=i==="running-left"||i==="running-right"?i:T(t),a=z[g],s=n?.spriteVersionNumber===2?2:1,w=s===2?11:9,c=s===2&&g==="idle"&&Number.isInteger(u)?(u%16+16)%16:null,h=c==null?a.row:9+Math.floor(c/8),m=c==null?null:c%8,k=_(),y=V(),[b,S]=r.useState(0);r.useEffect(()=>{if(S(0),k||!y||c!=null)return;let M=!1,x=0;const E=$=>{x=window.setTimeout(()=>{if(M)return;const j=($+1)%a.durations.length;S(j),E(j)},a.durations[$])};return E(0),()=>{M=!0,window.clearTimeout(x)}},[c,k,y,a]);const A=r.useMemo(()=>({width:o*(192/208),height:o,backgroundImage:`url(${n?.assetUrl||`/pets/${l}/spritesheet.webp`})`,backgroundRepeat:"no-repeat",backgroundSize:`800% ${w*100}%`,backgroundPosition:`${(m??b)/7*100}% ${h/(w-1)*100}%`,imageRendering:"pixelated"}),[w,m,h,b,l,n?.assetUrl,o]);return f.jsx("div",{"aria-hidden":"true",className:`pet-atlas-animated ${d}`,style:A})}const R={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},v=new Map;async function P(e){if(v.has(e))return v.get(e);if(typeof fetch!="function")return null;let n;try{n=await fetch(`/clawd/${e}`)}catch{return null}if(!n.ok)return null;const i=(await n.text()).replace(/<svg([^>]*)>/,(o,d)=>`<svg${d.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return v.set(e,i),i}function H({state:e="idle-living",size:n=48,className:t=""}){const[i,o]=r.useState(""),d=r.useRef(null),l=N()?"static-base":e,g=R[l]||R["static-base"];return r.useEffect(()=>{let a=!1;return P(g).then(s=>{!a&&s&&o(s)}),()=>{a=!0}},[g]),r.useEffect(()=>{const a=d.current?.querySelector("svg");if(a)try{const s=a.getBBox();s.width>0&&s.height>0&&a.setAttribute("viewBox",`${s.x-2} ${s.y-2} ${s.width+4} ${s.height+4}`)}catch{}},[i]),f.jsx("div",{ref:d,"aria-hidden":"true",className:`clawd-animated ${t}`,style:{width:n,height:n,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:i}})}function B({state:e="idle-living",size:n=48,className:t="",character:i="clawd",pet:o=null,lookDirectionIndex:d=null}){const u=p(i);return u!=="clawd"?f.jsx(I,{character:u,pet:o,state:e,size:n,className:t,lookDirectionIndex:d}):f.jsx(H,{state:e,size:n*L(u),className:t})}function N(){const[e,n]=r.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return r.useEffect(()=>{if(typeof window.matchMedia!="function")return;const t=window.matchMedia("(prefers-reduced-motion: reduce)"),i=o=>n(o.matches);return t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}export{B as C,p as n};
import{k as L,j as e,Q as R,l as P,r as D,c as n,X as z,x as M,i as S,P as K}from"./__vite-browser-external-Eoyj4eG-.js";import{A as U,W as B}from"./icons-BaaYJxUN.js";import{u as F}from"./useTokenFormat-BdD057ih.js";import{D as G,T as W}from"./TrendMonitor-DM1_WNfw.js";import{T as V}from"./AchievementBadge-D6iPEEbz.js";import{T as X}from"./terminal-DyicX7lG.js";import{D as Y,a as Z,b as H,c as q,d as Q,e as J}from"./DialogTitle-z86PHHyk.js";import{D as ee}from"./DialogDescription-ahxSNUcB.js";import"./useCurrency-BtHtcsO5.js";import"./PopoverPopup-DX7v1XfE.js";import"./useScrollLock-C2C-Yazq.js";import"./SelectItemText-CCW6JeeN.js";import"./zap-DWWma29E.js";import"./flame-vLBOq0X0.js";const ae=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],te=L("trending-down",ae),O=10,_={input:"var(--community-token-input)",cache_read:"var(--community-token-cache-read)",cache_write:"var(--community-token-cache-write)",output:"var(--community-token-output)",reasoning:"var(--community-token-reasoning)"},re={CLAUDE:"var(--community-claude)",CODEX:"var(--community-codex)",GEMINI:"var(--community-gemini)",CURSOR:"var(--community-cursor)",OPENCODE:"var(--community-opencode)",HERMES:"var(--community-hermes)",KIMI:"var(--community-kimi)",MIMO:"var(--community-mimo)",COPILOT:"var(--community-copilot)",KIRO:"var(--community-kiro)",GROK:"var(--community-grok)",DEEPSEEK:"var(--community-deepseek)",ZCODE:"var(--community-zcode)",WORKBUDDY:"var(--community-workbuddy)",MINIMAX:"var(--community-minimax)",DROID:"var(--community-droid)"};function ie(t){return re[String(t||"").toUpperCase()]||"var(--community-muted)"}const se=[[/claude|fable|opus|sonnet|haiku/,"CLAUDE"],[/gpt|codex|o3|o4/,"CODEX"],[/gemini/,"GEMINI"],[/composer|cursor/,"CURSOR"],[/kimi/,"KIMI"],[/mimo/,"MIMO"],[/copilot/,"COPILOT"],[/kiro/,"KIRO"],[/grok/,"GROK"],[/deepseek/,"DEEPSEEK"],[/glm/,"ZCODE"],[/hy3/,"WORKBUDDY"],[/minimax/,"MINIMAX"]],g=["overview","providers","community","models"];function oe(t){const s=String(t||"").toLowerCase(),a=se.find(([i])=>i.test(s));return a?a[1]:""}function u(t){const s=Number(t);return Number.isFinite(s)?`${s.toFixed(1)}%`:"—"}function p(t){return S(Number(t)||0)}function ne(t){return t?new Date(`${t}T00:00:00Z`).toLocaleDateString(void 0,{month:"short",day:"numeric",timeZone:"UTC"}):""}function k(){return e.jsx("div",{className:"flex h-full min-h-40 items-center justify-center text-xs text-oai-gray-400",children:n("leaderboard.community.modal.no_data")})}function b({children:t,detail:s}){return e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-4",children:[e.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:t}),s?e.jsx("span",{className:"text-xs text-oai-gray-400",children:s}):null]})}function C({value:t,label:s}){const a=Number(t);if(!Number.isFinite(a))return null;const i=Math.sign(a)!==-1,r=i?V:te;return e.jsxs("span",{className:`inline-flex items-center gap-1 text-xs font-medium tabular-nums ${i?"text-emerald-600 dark:text-emerald-400":"text-rose-600 dark:text-rose-400"}`,title:s,children:[e.jsx(r,{className:"size-3","aria-hidden":"true"}),i?"+":"",a.toFixed(1),"%"]})}function j({label:t,value:s,title:a,delta:i,deltaLabel:r}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-medium text-oai-gray-500 dark:text-oai-gray-400",children:t}),e.jsxs("div",{className:"mt-1 flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"truncate text-xl font-semibold leading-none tracking-tight text-oai-black tabular-nums dark:text-white",title:a,children:s}),e.jsx(C,{value:i,label:r})]})]})}function I({fillWidth:t,share:s,color:a="var(--oai-blue)",ariaLabel:i,dataAttrs:r,children:o}){return e.jsxs("div",{...r,className:"group relative grid min-h-11 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 overflow-hidden px-2.5 transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 opacity-[0.15] transition-opacity group-hover:opacity-[0.22] dark:opacity-[0.24] dark:group-hover:opacity-[0.32]",style:{width:`${t}%`,backgroundColor:a},role:"progressbar","aria-label":i,"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":Number(s)||0}),o]})}function A({rank:t,provider:s,name:a,fillWidth:i,share:r,tokens:o,tokensTitle:l,dataAttrs:c}){return e.jsxs(I,{fillWidth:i,share:r,color:ie(s),ariaLabel:`${a} ${u(r)}`,dataAttrs:c,children:[e.jsxs("div",{className:"relative flex min-w-0 items-center gap-2.5",children:[e.jsx("span",{className:`w-5 shrink-0 text-xs tabular-nums ${t<=3?"font-semibold text-oai-gray-700 dark:text-oai-gray-200":"text-oai-gray-400"}`,children:t}),e.jsx("span",{className:"grid size-6 shrink-0 place-items-center text-oai-gray-700 dark:text-oai-gray-200",children:e.jsx(K,{provider:s,size:15})}),e.jsx("span",{className:"truncate text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200",title:a,children:a})]}),e.jsxs("div",{className:"relative min-w-[4.5rem] text-right",children:[e.jsx("div",{className:"text-xs font-semibold text-oai-black tabular-nums dark:text-white",title:l,children:o}),e.jsx("div",{className:"text-xs text-oai-gray-500 tabular-nums dark:text-oai-gray-400",children:u(r)})]})]})}function le({rows:t,formatTokensTooltip:s}){return t.length?e.jsxs("div",{className:"mt-7",children:[e.jsx(b,{children:n("leaderboard.community.modal.token_mix")}),e.jsx("div",{className:"flex h-1.5 overflow-hidden bg-oai-gray-100 dark:bg-oai-gray-800",children:t.map(a=>e.jsx("div",{style:{width:`${Math.max(Number(a.share)||0,0)}%`,backgroundColor:_[a.key]||"var(--community-muted)"},title:`${n(`leaderboard.community.modal.token_mix.${a.key}`)} · ${u(a.share)}`},a.key))}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-x-5 gap-y-1.5",children:t.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",title:s(a.tokens),children:[e.jsx("span",{className:"size-2",style:{backgroundColor:_[a.key]||"var(--community-muted)"}}),n(`leaderboard.community.modal.token_mix.${a.key}`),e.jsx("span",{className:"tabular-nums text-oai-gray-700 dark:text-oai-gray-200",children:u(a.share)})]},a.key))})]}):null}function f({label:t,value:s,title:a,delta:i,deltaLabel:r,className:o=""}){return e.jsxs("div",{className:`min-w-0 ${o}`,children:[e.jsx("div",{className:"truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t}),e.jsxs("div",{className:"mt-1 flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"truncate text-base font-semibold leading-none tracking-tight tabular-nums text-oai-black dark:text-white",title:a,children:s}),e.jsx(C,{value:i,label:r})]})]})}function de({trendRows:t,activeDevelopers30d:s,developerGrowthPct:a,formatTokens:i,formatTokensTooltip:r}){if(!t.length)return null;const o=t.reduce((m,h)=>m+h.value,0),l=t.reduce((m,h)=>m.value<h.value?h:m,t[0]),c=o/t.length;return e.jsxs("div",{className:"mt-5 grid grid-cols-3 divide-x divide-oai-gray-100 border-y border-oai-gray-100 py-3.5 dark:divide-oai-gray-800/80 dark:border-oai-gray-800/80",children:[e.jsx(f,{className:"pr-4",label:n("leaderboard.community.modal.daily_average"),value:i(c),title:r(c)}),e.jsx(f,{className:"px-4",label:`${n("leaderboard.community.modal.peak_day")} · ${l.day}`,value:i(l.value),title:r(l.value)}),e.jsx(f,{className:"pl-4",label:n("leaderboard.community.modal.active_30d"),value:p(s),title:Number(s).toLocaleString(),delta:a,deltaLabel:n("leaderboard.community.modal.vs_previous_week")})]})}function me({trendRows:t,mix:s,activeDevelopers30d:a,developerGrowthPct:i,formatTokens:r,formatTokensTooltip:o}){return!t.length&&!s.length?e.jsx(k,{}):e.jsxs("div",{children:[e.jsx(b,{detail:n("leaderboard.community.modal.utc_note"),children:n("leaderboard.community.modal.community_activity")}),e.jsx(W,{embedded:!0,rows:t,from:t[0]?.day,to:t.at(-1)?.day,chartHeightClass:"h-44"}),e.jsx(de,{trendRows:t,activeDevelopers30d:a,developerGrowthPct:i,formatTokens:r,formatTokensTooltip:o}),e.jsx(le,{rows:s,formatTokensTooltip:o})]})}function ce({rows:t,maxShare:s,formatTokens:a,formatTokensTooltip:i}){return t.length?e.jsx("div",{className:"space-y-0.5",children:t.map((r,o)=>e.jsx(A,{rank:o+1,dataAttrs:{"data-provider-rank":o+1,"data-provider-name":r.name},provider:String(r.name).toUpperCase(),name:r.name,fillWidth:Math.max((Number(r.share)||0)/s*100,2),share:r.share,tokens:a(r.tokens),tokensTitle:i(r.tokens)},r.name))}):e.jsx(k,{})}function xe({rows:t,maxShare:s,formatTokens:a,formatTokensTooltip:i}){return t.length?e.jsx("div",{className:"space-y-0.5",children:t.map((r,o)=>{const l=Number(r.share)||0;return e.jsx(A,{rank:o+1,dataAttrs:{"data-model-rank":o+1,"data-model-name":r.name},provider:oe(r.name),name:r.name,fillWidth:Math.max(l/s*100,2),share:l,tokens:a(r.tokens),tokensTitle:i(r.tokens)},r.name)})}):e.jsx(k,{})}function ue({name:t}){const s=String(t||"").toLowerCase();return s==="darwin"?e.jsx(U,{className:"size-3.5"}):s==="win32"?e.jsx(B,{className:"size-3.5"}):e.jsx(X,{className:"size-4","aria-hidden":"true"})}const he=.175,ye=.3;function ge({bands:t,formatTokensTooltip:s}){const a=t.reduce((r,o)=>Math.max(r,Number(o.developer_share)||0),0)||1,i=r=>`${n(`leaderboard.community.modal.band.${r.key}`)} · ${n("leaderboard.community.modal.developer_count",{count:p(r.developers)})} (${s(r.tokens)})`;return e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-2 border-b border-oai-gray-200 dark:border-oai-gray-800",children:t.map((r,o)=>{const l=Number(r.developer_share)||0,c=Math.max(l/a*80,2);return e.jsxs("div",{className:"relative h-32 min-w-0 flex-1",title:i(r),children:[e.jsx("div",{role:"progressbar","aria-label":n("leaderboard.community.modal.developer_share_title",{share:u(l)}),"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":l,className:"absolute inset-x-0 bottom-0",style:{height:`${c}%`,backgroundColor:"var(--oai-blue)",opacity:ye+o*he}}),e.jsx("div",{className:"absolute inset-x-0 text-center text-xs font-medium tabular-nums text-oai-gray-700 dark:text-oai-gray-200",style:{bottom:`calc(${c}% + 4px)`},children:u(l)})]},r.key)})}),e.jsx("div",{className:"mt-2 flex gap-2",children:t.map(r=>e.jsxs("div",{className:"min-w-0 flex-1 text-center",title:i(r),children:[e.jsx("div",{className:"truncate text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200",children:n(`leaderboard.community.modal.band.${r.key}`)}),e.jsx("div",{className:"truncate text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:p(r.developers)})]},r.key))})]})}function pe({bands:t,platforms:s,formatTokensTooltip:a}){return!t.length&&!s.length?e.jsx(k,{}):e.jsxs("div",{className:"space-y-8",children:[t.length?e.jsxs("div",{children:[e.jsx(b,{children:n("leaderboard.community.modal.usage_distribution")}),e.jsx(ge,{bands:t,formatTokensTooltip:a})]}):null,s.length?e.jsxs("div",{children:[e.jsx(b,{children:n("leaderboard.community.modal.platforms")}),e.jsx("div",{className:"space-y-0.5",children:s.map(i=>e.jsxs(I,{fillWidth:Math.max(Number(i.share)||0,1),share:i.share,ariaLabel:`${n(`leaderboard.community.modal.platform.${i.name}`)} ${u(i.share)}`,children:[e.jsxs("div",{className:"relative flex min-w-0 items-center gap-2.5",children:[e.jsx("span",{className:"grid size-6 shrink-0 place-items-center text-oai-gray-700 dark:text-oai-gray-200",children:e.jsx(ue,{name:i.name})}),e.jsx("span",{className:"truncate text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200",children:n(`leaderboard.community.modal.platform.${i.name}`)})]}),e.jsxs("div",{className:"relative min-w-[4.5rem] text-right",children:[e.jsx("div",{className:"text-xs font-semibold text-oai-black tabular-nums dark:text-white",children:u(i.share)}),e.jsx("div",{className:"text-xs text-oai-gray-500 tabular-nums dark:text-oai-gray-400",title:Number(i.machines||0).toLocaleString(),children:n("leaderboard.community.modal.machine_count",{count:p(i.machines)})})]})]},i.name))})]}):null]})}function ve({isOpen:t,onClose:s,communityStats:a}){const{formatTokens:i,formatTokensTooltip:r}=F(),[o,l]=D.useState("overview"),c=a?.status==="ready",m=D.useMemo(()=>{if(!c)return null;const d=(Array.isArray(a.providers)?a.providers:[]).slice(0,O),x=(Array.isArray(a.topModels)?a.topModels:[]).slice(0,O),y=v=>v.reduce((E,$)=>Math.max(E,Number($.share)||0),0)||1;return{providers:d,models:x,providersMaxShare:y(d),modelsMaxShare:y(x),trendRows:(Array.isArray(a.dailyGrowth)?a.dailyGrowth:[]).map(v=>({day:ne(v.day),value:Number(v.tokens)||0})),mix:Array.isArray(a.tokenMix)?a.tokenMix:[],bands:Array.isArray(a.userDistribution)?a.userDistribution:[],platforms:Array.isArray(a.platforms)?a.platforms:[]}},[c,a]);if(!m)return null;const h=Number(a.tokenFloor)||0,N=Number(a.activeDevelopersTotal)||Number(a.totalEntries)||0,w=Number(a.tokens30d)||0,T=d=>{if(d.key!=="ArrowRight"&&d.key!=="ArrowLeft")return;d.preventDefault();const x=d.key==="ArrowRight"?1:-1,y=g[(g.indexOf(o)+x+g.length)%g.length];l(y),d.currentTarget.querySelector(`[data-tab-id="${y}"]`)?.focus()};return e.jsx(Y,{open:t,onOpenChange:d=>!d&&s(),children:e.jsxs(Z,{children:[e.jsx(H,{className:"fixed inset-0 z-[100] bg-black/50 backdrop-blur-[3px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),e.jsx(q,{className:"fixed inset-0 z-[101] flex items-center justify-center p-2 sm:p-5",children:e.jsxs(Q,{className:"relative flex h-[min(42rem,92vh)] w-full max-w-xl flex-col overflow-hidden rounded-2xl bg-white shadow-2xl ring-1 ring-black/10 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-3 data-[ending-style]:scale-[0.98] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-3 data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:ring-white/10",children:[e.jsxs("header",{"data-testid":"community-metrics-header",className:"shrink-0 px-5 pt-5 sm:px-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(J,{className:"text-lg font-semibold tracking-[-0.02em] text-oai-black dark:text-white",children:n("leaderboard.community.modal.title")}),e.jsx(ee,{className:"sr-only",children:n("leaderboard.community.modal.description")})]}),e.jsx(G,{className:"-mr-1 -mt-1 grid size-8 place-items-center rounded-full text-oai-gray-400 transition-colors hover:bg-black/5 hover:text-oai-black dark:hover:bg-white/10 dark:hover:text-white","aria-label":n("shared.dialog.close"),children:e.jsx(z,{className:"size-4"})})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-x-5",children:[e.jsx(j,{label:n("leaderboard.community.modal.total_tokens"),value:i(h),title:r(h)}),e.jsx(j,{label:n("leaderboard.community.modal.tokens_30d"),value:i(w),title:r(w),delta:a.tokenGrowthPct,deltaLabel:n("leaderboard.community.modal.vs_previous_week")}),e.jsx(j,{label:n("leaderboard.community.modal.contributors"),value:p(N),title:N.toLocaleString()})]}),e.jsx("div",{className:"mt-4 flex items-end overflow-x-auto border-b border-oai-gray-100 dark:border-oai-gray-900",role:"tablist","aria-label":n("leaderboard.community.modal.views"),onKeyDown:T,children:g.map(d=>{const x=o===d;return e.jsxs("button",{type:"button",role:"tab","data-tab-id":d,"aria-selected":x,tabIndex:x?0:-1,onClick:()=>l(d),className:`relative mr-5 h-10 shrink-0 text-sm font-medium transition-colors last:mr-0 ${x?"text-oai-black dark:text-white":"text-oai-gray-500 hover:text-oai-gray-700 dark:text-oai-gray-400 dark:hover:text-oai-gray-200"}`,children:[n(`leaderboard.community.modal.tab.${d}`),x?e.jsx(M.span,{layoutId:"community-metrics-tab-underline",className:"absolute inset-x-0 -bottom-px h-0.5 rounded-full bg-oai-black dark:bg-white",transition:{type:"spring",stiffness:420,damping:34}}):null]},d)})})]}),e.jsx("div",{"data-testid":"community-metrics-content",className:"min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:e.jsxs(M.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.18,ease:[.16,1,.3,1]},className:"h-full",children:[o==="overview"?e.jsx(me,{trendRows:m.trendRows,mix:m.mix,activeDevelopers30d:Number(a.activeDevelopers30d)||0,developerGrowthPct:a.developerGrowthPct,formatTokens:i,formatTokensTooltip:r}):null,o==="providers"?e.jsx(ce,{rows:m.providers,maxShare:m.providersMaxShare,formatTokens:i,formatTokensTooltip:r}):null,o==="community"?e.jsx(pe,{bands:m.bands,platforms:m.platforms,formatTokensTooltip:r}):null,o==="models"?e.jsx(xe,{rows:m.models,maxShare:m.modelsMaxShare,formatTokens:i,formatTokensTooltip:r}):null]},o)})]})})]})})}function Ee(t){return e.jsx(R,{mode:P.COMPACT,children:e.jsx(ve,{...t})})}export{Ee as CommunityStatsModal};
import{j as a,B as i,b as x}from"./__vite-browser-external-Eoyj4eG-.js";import{D as p,a as m,b as y,c as b,d as f,e as u}from"./DialogTitle-z86PHHyk.js";import{D as h}from"./DialogDescription-ahxSNUcB.js";function _({open:r,title:l,description:t,confirmLabel:o,cancelLabel:n,destructive:d=!1,busy:e=!1,onConfirm:c,onCancel:s}){return a.jsx(p,{open:r,onOpenChange:g=>{!g&&!e&&s?.()},children:a.jsxs(m,{children:[a.jsx(y,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),a.jsx(b,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:a.jsxs(f,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[a.jsx(u,{className:"text-base font-semibold text-oai-black dark:text-white",children:l}),t?a.jsx(h,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:t}):null,a.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[a.jsx(i,{type:"button",variant:"secondary",size:"sm",disabled:e,onClick:()=>s?.(),children:n}),a.jsx(i,{type:"button",size:"sm",disabled:e,onClick:()=>c?.(),className:x(d&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:o})]})]})})]})})}export{_ as C};
import{k as c}from"./__vite-browser-external-Eoyj4eG-.js";const e=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],t=c("copy",e);export{t as C};

Sorry, the diff of this file is too big to display

import{e as p,r as c,j as e,h as b}from"./__vite-browser-external-Eoyj4eG-.js";const f={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_VERSION:"0.82.0",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};
import{r as n,y as a}from"./__vite-browser-external-Eoyj4eG-.js";import{u as p}from"./DialogTitle-z86PHHyk.js";import{u as c}from"./useScrollLock-C2C-Yazq.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};
import{aB as s,aC as v,r as l,aD as W,y as w,aE as B,aF as V,j as I,aG as A,aH as ee,aI as te,aJ as ne,aK as oe,aL as se,aM as re}from"./__vite-browser-external-Eoyj4eG-.js";import{F as Y,P as $,p as j,C as E,c as ae,a as ie,b as le,d as de,I as ue,e as pe,f as ce,g as ge,h as fe,i as me,j as Se,s as Ce,k as Pe,l as Oe,u as Re}from"./useScrollLock-C2C-Yazq.js";function Ee(){return new Y({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new $,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function he(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:Ee(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:v,inactiveTriggerProps:v,popupProps:v}}function Ie(e,t,o=!1){return new Y({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:o,onOpenChange:void 0})}const D=s(e=>e.triggerIdProp??e.activeTriggerId),U=s(e=>e.openProp??e.open),H=s(e=>(e.popupElement?.id??e.floatingId)||void 0);function G(e,t){return t!==void 0&&U(e)&&D(e)===t}function xe(e,t){return G(e,t)?!0:t!==void 0&&U(e)&&D(e)==null&&e.triggerCount===1}const ye={open:U,mounted:s(e=>e.mounted),transitionStatus:s(e=>e.transitionStatus),floatingRootContext:s(e=>e.floatingRootContext),triggerCount:s(e=>e.triggerCount),preventUnmountingOnClose:s(e=>e.preventUnmountingOnClose),payload:s(e=>e.payload),activeTriggerId:D,activeTriggerElement:s(e=>e.mounted?e.activeTriggerElement:null),popupId:H,isTriggerActive:s((e,t)=>t!==void 0&&D(e)===t),isOpenedByTrigger:s((e,t)=>G(e,t)),isMountedByTrigger:s((e,t)=>t!==void 0&&D(e)===t&&e.mounted),triggerProps:s((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),triggerPopupId:s((e,t)=>xe(e,t)?H(e):void 0),popupProps:s(e=>e.popupProps),popupElement:s(e=>e.popupElement),positionerElement:s(e=>e.positionerElement)},q=l.createContext(!1),z=l.createContext(void 0);function T(e){const t=l.useContext(z);if(e===!1&&t===void 0)throw new Error(W(27));return t}const ve={...j,...B},Le=l.forwardRef(function(t,o){const{render:r,className:d,style:a,forceRender:p=!1,...c}=t,{store:i}=T(),n=i.useState("open"),m=i.useState("nested"),C=i.useState("mounted"),S=i.useState("transitionStatus");return w("div",t,{state:{open:n,transitionStatus:S},ref:[i.context.backdropRef,o],stateAttributesMapping:ve,props:[{role:"presentation",hidden:!C,style:{userSelect:"none",WebkitUserSelect:"none"}},c],enabled:p||!m})});let Te=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),De=(function(e){return e[e.open=E.open]="open",e[e.closed=E.closed]="closed",e[e.startingStyle=E.startingStyle]="startingStyle",e[e.endingStyle=E.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Q=l.createContext(void 0);function X(){const e=l.useContext(Q);if(e===void 0)throw new Error(W(26));return e}const we={...j,...B,nestedDialogOpen(e){return e?{[De.nestedDialogOpen]:""}:null}},_e=l.forwardRef(function(t,o){const{render:r,className:d,style:a,finalFocus:p,initialFocus:c,...i}=t,{store:n}=T(),m=n.useState("descriptionElementId"),C=n.useState("disablePointerDismissal"),S=n.useState("floatingRootContext"),O=n.useState("popupProps"),P=n.useState("modal"),R=n.useState("mounted"),h=n.useState("nested"),f=n.useState("nestedOpenDialogCount"),g=n.useState("open"),L=n.useState("openMethod"),x=n.useState("titleElementId"),u=n.useState("transitionStatus"),b=n.useState("role"),k=S.useState("floatingId"),M=i.id??k;X(),V({open:g,ref:n.context.popupRef,onComplete(){g&&n.context.onOpenChangeComplete?.(!0)}});const F=c===void 0?ae(n.context.popupRef):c,N=f>0,y=n.useStateSetter("popupElement"),Z=w("div",t,{state:{open:g,nested:h,transitionStatus:u,nestedDialogOpen:N},props:[O,{id:M,"aria-labelledby":x??void 0,"aria-describedby":m??void 0,role:b,...ie,hidden:!R,onKeyDown(_){le.has(_.key)&&_.stopPropagation()},style:{[Te.nestedDialogs]:f}},i],ref:[o,n.context.popupRef,y],stateAttributesMapping:we});return I.jsx(de,{context:S,openInteractionType:L,disabled:!R,closeOnFocusOut:!C,initialFocus:F,returnFocus:p,modal:P!==!1,restoreFocus:"popup",children:Z})}),He=l.forwardRef(function(t,o){const{keepMounted:r=!1,...d}=t,{store:a}=T(),p=a.useState("mounted"),c=a.useState("modal"),i=a.useState("open");return p||r?I.jsx(Q.Provider,{value:r,children:I.jsxs(A,{ref:o,...d,children:[p&&c===!0&&I.jsx(ue,{ref:a.context.internalBackdropRef,inert:ee(!i)}),t.children]})}):null});function be(e){const{store:t,actionsRef:o}=e,r=t.useState("open");pe(t,r),ce(t);const{forceUnmount:d}=ge(r,t),a=l.useCallback(()=>{t.setOpen(!1,te(ne))},[t]);l.useImperativeHandle(o,()=>({unmount:d,close:a}),[d,a])}function ke({store:e,parentContext:t,isDrawer:o}){const r=e.useState("open"),d=e.useState("disablePointerDismissal"),a=e.useState("modal"),p=e.useState("popupElement"),c=e.useState("floatingRootContext"),[i,n]=l.useState(0),[m,C]=l.useState(0),S=i===0,O=fe(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:a==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(f){if(!e.context.outsidePressEnabledRef.current||"button"in f&&f.button!==0||"touches"in f&&f.touches.length!==1)return!1;const g=oe(f);return S&&!d?a&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===g||e.context.backdropRef.current===g||se(g,p)&&!g?.hasAttribute("data-base-ui-portal"):!0:!1},escapeKey:S});me(r&&a===!0,p),e.useContextCallback("onNestedDialogOpen",(f,g)=>{n(f),C(g)}),e.useContextCallback("onNestedDialogClose",()=>{n(0),C(0)}),l.useEffect(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(i+1,m+(o?1:0)),t?.onNestedDialogClose&&!r&&t.onNestedDialogClose(),()=>{t?.onNestedDialogClose&&r&&t.onNestedDialogClose()}),[o,r,i,m,t]);const P=O.reference??v,R=O.trigger??v,h=O.floating??v;return Se(e,{activeTriggerProps:P,inactiveTriggerProps:R,popupProps:h,nestedOpenDialogCount:i,nestedOpenDrawerCount:m}),null}const Me={...ye,modal:s(e=>e.modal),nested:s(e=>e.nested),nestedOpenDialogCount:s(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:s(e=>e.nestedOpenDrawerCount),disablePointerDismissal:s(e=>e.disablePointerDismissal),openMethod:s(e=>e.openMethod),descriptionElementId:s(e=>e.descriptionElementId),titleElementId:s(e=>e.titleElementId),viewportElement:s(e=>e.viewportElement),role:s(e=>e.role)};class K extends re{constructor(t,o,r=!1){const d=new $,a=Fe(t);a.floatingRootContext=Ie(d,o,r),super(a,{popupRef:l.createRef(),backdropRef:l.createRef(),internalBackdropRef:l.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:d,onOpenChange:void 0,onOpenChangeComplete:void 0},Me)}setOpen=(t,o)=>{if(o.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&o.trigger==null&&this.state.activeTriggerId!=null&&(o.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,o),o.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(t,o);const r={open:t};Ce(r,t,o.trigger),this.update(r)};static useStore(t,o){return Pe(t,(d,a)=>new K(o,d,a),!0).store}}function Fe(e={}){return{...he(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function Ne(e,t="dialog"){const{children:o,open:r,defaultOpen:d=!1,onOpenChange:a,onOpenChangeComplete:p,disablePointerDismissal:c=!1,modal:i=!0,actionsRef:n,handle:m,triggerId:C,defaultTriggerId:S=null}=e,O=t==="drawer",P=t==="alert-dialog",R=P?!0:i,h=P||c,f=P?"alertdialog":"dialog",g=T(!0),x={modal:R,disablePointerDismissal:h,nested:!!g,role:f},u=K.useStore(m?.store,{open:d,openProp:r,activeTriggerId:S,triggerIdProp:C,...x});Oe(()=>{const y=r===void 0&&u.state.open===!1&&d===!0?{open:!0,activeTriggerId:S}:null;P?u.update(y?{...x,...y}:x):y&&u.update(y)}),u.useControlledProp("openProp",r),u.useControlledProp("triggerIdProp",C),u.useSyncedValues(x),u.useContextCallback("onOpenChange",a),u.useContextCallback("onOpenChangeComplete",p);const b=u.useState("open"),k=u.useState("mounted"),M=u.useState("payload");be({store:u,actionsRef:n});const F=b||k,N=l.useMemo(()=>({store:u}),[u]);return I.jsx(q.Provider,{value:!1,children:I.jsxs(z.Provider,{value:N,children:[F&&I.jsx(ke,{store:u,parentContext:g?.store.context,isDrawer:O}),typeof o=="function"?o({payload:M}):o]})})}function Je(e){const t=l.useContext(q)?"drawer":"dialog";return Ne(e,t)}let J=(function(e){return e[e.open=E.open]="open",e[e.closed=E.closed]="closed",e[e.startingStyle=E.startingStyle]="startingStyle",e[e.endingStyle=E.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Be={...j,...B,nested(e){return e?{[J.nested]:""}:null},nestedDialogOpen(e){return e?{[J.nestedDialogOpen]:""}:null}},We=l.forwardRef(function(t,o){const{render:r,className:d,style:a,children:p,...c}=t,i=X(),{store:n}=T(),m=n.useState("open"),C=n.useState("nested"),S=n.useState("transitionStatus"),O=n.useState("nestedOpenDialogCount"),P=n.useState("mounted"),R=n.useStateSetter("viewportElement"),h=O>0;return w("div",t,{enabled:i||P,state:{open:m,nested:C,transitionStatus:S,nestedDialogOpen:h},ref:[o,R],stateAttributesMapping:Be,props:[{role:"presentation",hidden:!P,style:{pointerEvents:m?void 0:"none"},children:p},c]})}),Ye=l.forwardRef(function(t,o){const{render:r,className:d,style:a,id:p,...c}=t,{store:i}=T(),n=Re(p);return i.useSyncedValueWithCleanup("titleElementId",n),w("h2",t,{ref:o,props:[{id:n},c]})});export{Je as D,He as a,Le as b,We as c,_e as d,Ye as e,Ie as f,he as g,ye as p,T as u};
import{k as o}from"./__vite-browser-external-Eoyj4eG-.js";const a=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],e=o("download",a);export{e as D};
import{w as d,j as n,x as a}from"./__vite-browser-external-Eoyj4eG-.js";function v({children:i,delay:t=0,duration:o=.35,y:e=12,className:s="",once:r=!0}){return d()?n.jsx("div",{className:s,children:i}):n.jsx(a.div,{initial:{opacity:0,y:e},animate:{opacity:1,y:0},transition:{duration:o,delay:t,ease:[.16,1,.3,1]},className:s,children:i})}function x({children:i,staggerDelay:t=.1,initialDelay:o=0,className:e=""}){return d()?n.jsx("div",{className:e,children:i}):n.jsx(a.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:t,delayChildren:o}}},className:e,children:i})}function h({children:i,className:t="",y:o=12}){return d()?n.jsx("div",{className:t,children:i}):n.jsx(a.div,{variants:{hidden:{opacity:0,y:o},visible:{opacity:1,y:0,transition:{duration:.35,ease:[.16,1,.3,1]}}},className:t,children:i})}export{v as F,x as S,h as a};
import{k as c}from"./__vite-browser-external-Eoyj4eG-.js";const e=[["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"}]],a=c("flame",e);export{a as F};
import{i as r}from"./__vite-browser-external-Eoyj4eG-.js";function n(o){const t=Number(o)||0;return t>=1e12?`${Number((t/1e12).toFixed(2)).toString()}T`:r(t)}export{n as f};
import{r as s,s as c,j as t}from"./__vite-browser-external-Eoyj4eG-.js";function u({repo:r="mm7894215/TokenTracker"}){const[a,o]=s.useState(null);return s.useEffect(()=>{if(typeof window>"u")return;const n=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,i=typeof document<"u"&&(document.documentElement?.classList.contains("screenshot-capture")||document.body?.classList.contains("screenshot-capture"));c({prefersReducedMotion:n,screenshotCapture:i})&&fetch(`https://api.github.com/repos/${r}`).then(e=>e.json()).then(e=>{e&&typeof e.stargazers_count=="number"&&o(e.stargazers_count)}).catch(()=>{})},[r]),t.jsxs("a",{href:`https://github.com/${r}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-2 px-3 py-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 transition-colors no-underline",children:[t.jsx("svg",{height:"16",viewBox:"0 0 16 16",width:"16",className:"shrink-0 fill-oai-gray-700 dark:fill-oai-gray-300",children:t.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),t.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap",children:"Star"}),a!==null&&t.jsx("span",{className:"text-xs font-semibold text-oai-gray-900 dark:text-oai-white tabular-nums whitespace-nowrap",children:a})]})}export{u as H};
import{j as r}from"./__vite-browser-external-Eoyj4eG-.js";function e({className:n}){return r.jsx("svg",{viewBox:"0 0 384 512",className:n,fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"})})}function o({className:n}){return r.jsx("svg",{viewBox:"0 0 16 16",className:n,fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})})}function t({className:n}){return r.jsx("svg",{viewBox:"0 0 24 24",className:n,fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M3 5.46 10.2 4.5v6.92H3V5.46Zm0 13.08 7.2.96v-6.84H3v5.88Zm8.04 1.08L21 21V12.46h-9.96v7.16ZM11.04 4.38 21 3v8.46h-9.96V4.38Z"})})}export{e as A,o as G,t as W};
import{k as o}from"./__vite-browser-external-Eoyj4eG-.js";const c=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],t=o("info",c);export{t as I};
import{r as ge,c as t,j as n}from"./__vite-browser-external-Eoyj4eG-.js";const Ge=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),j=Ge?"/proxy/ipcheck":"https://ip.net.coffee",fe="claude_ip_history",Se=6,Ue=["CN","HK","MO","RU","KP","IR","SY","CU","BY","VE"],ze={CN:"Asia/Shanghai",TW:"Asia/Taipei",HK:"Asia/Hong_Kong",MO:"Asia/Macau",JP:"Asia/Tokyo",KR:"Asia/Seoul",SG:"Asia/Singapore",MY:"Asia/Kuala_Lumpur",TH:"Asia/Bangkok",VN:"Asia/Ho_Chi_Minh",ID:"Asia/Jakarta",PH:"Asia/Manila",IN:"Asia/Kolkata",PK:"Asia/Karachi",BD:"Asia/Dhaka",IR:"Asia/Tehran",IL:"Asia/Jerusalem",AE:"Asia/Dubai",SA:"Asia/Riyadh",TR:"Europe/Istanbul",RU:"Europe/Moscow",UA:"Europe/Kyiv",GB:"Europe/London",IE:"Europe/Dublin",FR:"Europe/Paris",DE:"Europe/Berlin",IT:"Europe/Rome",ES:"Europe/Madrid",PT:"Europe/Lisbon",NL:"Europe/Amsterdam",BE:"Europe/Brussels",CH:"Europe/Zurich",AT:"Europe/Vienna",SE:"Europe/Stockholm",NO:"Europe/Oslo",DK:"Europe/Copenhagen",FI:"Europe/Helsinki",PL:"Europe/Warsaw",CZ:"Europe/Prague",GR:"Europe/Athens",RO:"Europe/Bucharest",US:"America/Los_Angeles",CA:"America/Toronto",MX:"America/Mexico_City",BR:"America/Sao_Paulo",AR:"America/Argentina/Buenos_Aires",CL:"America/Santiago",AU:"Australia/Sydney",NZ:"Pacific/Auckland",ZA:"Africa/Johannesburg",EG:"Africa/Cairo",NG:"Africa/Lagos",KE:"Africa/Nairobi"},We={CN:["zh"],TW:["zh"],HK:["zh","en"],MO:["zh","en"],JP:["ja"],KR:["ko"],TH:["th"],VN:["vi"],SG:["en","zh","ms","ta"],MY:["ms","en","zh","ta"],ID:["id","en"],PH:["en","tl","fil"],IN:["en","hi"],PK:["ur","en"],BD:["bn","en"],LK:["si","ta","en"],NP:["ne","en"],US:["en"],GB:["en"],IE:["en","ga"],AU:["en"],NZ:["en","mi"],CA:["en","fr"],DE:["de"],AT:["de"],CH:["de","fr","it","rm"],BE:["nl","fr","de"],FR:["fr"],IT:["it"],ES:["es","ca","gl","eu"],PT:["pt"],NL:["nl","fy"],LU:["lb","fr","de"],SE:["sv"],NO:["no","nb","nn"],DK:["da"],FI:["fi","sv"],IS:["is","en"],PL:["pl"],CZ:["cs"],SK:["sk"],HU:["hu"],RO:["ro"],BG:["bg"],GR:["el"],RU:["ru"],UA:["uk","ru"],BY:["be","ru"],TR:["tr"],IL:["he","ar","en"],SA:["ar"],AE:["ar","en"],EG:["ar"],IR:["fa"],IQ:["ar","ku"],ZA:["en","af","zu","xh"],KE:["en","sw"],NG:["en"],ET:["am","en"],BR:["pt"],AR:["es"],MX:["es"],CL:["es"],CO:["es"],PE:["es"],VE:["es"]},Be={jp:"Japan",tw:"Taiwan",hk:"Hong Kong",sg:"Singapore",us:"United States",de:"Germany",kr:"South Korea",fr:"France",nl:"Netherlands",gb:"United Kingdom",au:"Australia",ca:"Canada",br:"Brazil",in:"India"};function Z(p){return!!p&&p.includes(":")}function Ke(p){return!Z(p)||p.length<=20?p:p.substring(0,18)+"..."}function w(p){return p==null?"":String(p).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function B(p){if(!p||!/^[a-zA-Z]{2}$/.test(p))return"";const b=p.toLowerCase();return`<img src="${b==="cn"?`${j}/favicons/cn.png`:b==="tw"?`${j}/favicons/flags/tw.png`:`${j}/favicons/flags/${b}.png`}" alt="${b}" class="inline-block h-4 w-auto align-[-2px]" onerror="this.onerror=null;this.style.display='none'">`}function Fe(p){if(!p)return"";const b=String(p).trim();if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(b)){const S=b.split(".");return S[0]+"."+S[1]+".*.*"}if(b.includes("…")){const S=b.lastIndexOf("…");return b.substring(0,S+1)+"*"}if(b.includes(":")){const S=b.split(":");if(S.length>=2)return S[0]+":"+S[1]+":*"}return b}function Ve(p){if(!p)return null;try{const S=new Intl.DateTimeFormat("en-US",{timeZone:p,timeZoneName:"longOffset"}).formatToParts(new Date).find(q=>q.type==="timeZoneName");if(!S)return null;if(S.value==="GMT"||S.value==="UTC")return 0;const M=S.value.match(/GMT([+-])(\d{1,2}):?(\d{0,2})/);return M?(M[1]==="+"?1:-1)*(parseInt(M[2],10)*60+parseInt(M[3]||"0",10)):null}catch{return null}}function Ye(p){if(p==null)return"";const b=p>=0?"+":"-",S=Math.abs(p),M=Math.floor(S/60),D=S%60;return"UTC"+b+M+(D?":"+String(D).padStart(2,"0"):"")}const Te={safe:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",warn:"bg-amber-50 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300",danger:"bg-red-50 text-red-700 dark:bg-red-500/15 dark:text-red-300",info:"bg-blue-50 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300",neutral:"bg-oai-gray-100 text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-400"};function Je(){const p=ge.useRef(null),[b,S]=ge.useState(!1);ge.useEffect(()=>{const _=p.current;if(!_)return;const C=a=>_.querySelector(`#${a}`);let se=!1;const e={unknown:t("ipcheck.common.unknown"),failed:t("ipcheck.ip.failed"),regionAccessible:t("ipcheck.trust.region.accessible"),regionWarnTitle:a=>t("ipcheck.trust.region_warn.title",{region:a}),regionWarnBody:t("ipcheck.trust.region_warn.body"),regionRestrictedText:t("ipcheck.trust.text.restricted"),noData:t("ipcheck.trust.no_data"),noIp:t("ipcheck.trust.no_ip"),noScore:t("ipcheck.trust.no_score"),score:{pristine:t("ipcheck.trust.label.pristine"),clean:t("ipcheck.trust.label.clean"),good:t("ipcheck.trust.label.good"),neutral:t("ipcheck.trust.label.neutral"),suspicious:t("ipcheck.trust.label.suspicious"),unreachable:t("ipcheck.trust.label.unreachable")},scoreText:{excellent:t("ipcheck.trust.text.excellent"),great:t("ipcheck.trust.text.great"),minor:t("ipcheck.trust.text.minor"),moderate:t("ipcheck.trust.text.moderate"),severe:t("ipcheck.trust.text.severe")},propsRegion:t("ipcheck.props.region"),propsCity:t("ipcheck.props.city"),propsType:t("ipcheck.props.type"),propsAsn:t("ipcheck.props.asn"),propsOrg:t("ipcheck.props.org"),propsResidential:t("ipcheck.props.residential"),propsDatacenter:t("ipcheck.props.datacenter"),secVpn:t("ipcheck.security.vpn"),secProxy:t("ipcheck.security.proxy"),secTor:t("ipcheck.security.tor"),secCrawler:t("ipcheck.security.crawler"),secAbuser:t("ipcheck.security.abuser"),secProxyFlag:t("ipcheck.security.proxy_flag"),secCrawlerYes:t("ipcheck.security.crawler_yes"),secCrawlerNo:t("ipcheck.security.crawler_no"),secAbuserYes:t("ipcheck.security.abuser_yes"),secAbuserNo:t("ipcheck.security.abuser_no"),secClean:t("ipcheck.security.clean"),availSvc:t("ipcheck.avail.svc_row"),availLat:{normal:t("ipcheck.avail.latency.normal"),good:t("ipcheck.avail.latency.good"),slow:t("ipcheck.avail.latency.slow"),unreachable:t("ipcheck.avail.latency.unreachable")},availSvcStatus:{none:t("ipcheck.avail.svc.none"),minor:t("ipcheck.avail.svc.minor"),major:t("ipcheck.avail.svc.major"),critical:t("ipcheck.avail.svc.critical"),maintenance:t("ipcheck.avail.svc.maintenance"),other:t("ipcheck.avail.svc.other")},dnsStatus:t("ipcheck.dns.status"),dnsOutlet:t("ipcheck.dns.outlet"),dnsOutletIp:t("ipcheck.dns.outlet_ip"),dnsIsp:t("ipcheck.dns.isp"),dnsLeaked:t("ipcheck.dns.leaked"),dnsNoLeak:t("ipcheck.dns.no_leak"),dnsEncrypted:t("ipcheck.dns.encrypted"),dnsCnTag:t("ipcheck.dns.cn_tag"),udpStatus:t("ipcheck.udp.status"),udpOutlet:t("ipcheck.udp.outlet"),udpOutletIp:t("ipcheck.udp.outlet_ip"),udpOrigin:t("ipcheck.udp.origin"),udpDisabled:t("ipcheck.udp.disabled"),udpNoLeak:t("ipcheck.udp.no_leak"),udpLeaked:t("ipcheck.udp.leaked"),udpAnomaly:t("ipcheck.udp.anomaly"),devTz:t("ipcheck.device.tz"),devLang:t("ipcheck.device.lang"),devOs:t("ipcheck.device.os"),devTouch:t("ipcheck.device.touch"),devNet:t("ipcheck.device.net"),devDnt:t("ipcheck.device.dnt"),devWebglRender:t("ipcheck.device.webgl_render"),devCanvasFp:t("ipcheck.device.canvas_fp"),devWebglFp:t("ipcheck.device.webgl_fp"),devMatch:t("ipcheck.device.match"),devMismatch:t("ipcheck.device.mismatch"),devLocal:t("ipcheck.device.local"),devEstSuffix:t("ipcheck.device.estimate_suffix"),devDiffEqual:t("ipcheck.device.diff_equal"),devDiffAhead:a=>t("ipcheck.device.diff_ahead",{h:a}),devDiffBehind:a=>t("ipcheck.device.diff_behind",{h:a}),devLangExpected:t("ipcheck.device.lang_expected"),devTouchYes:t("ipcheck.device.touch_yes"),devTouchNo:t("ipcheck.device.touch_no"),devDntOn:t("ipcheck.device.dnt_on"),devDntOff:t("ipcheck.device.dnt_off"),devDntUnset:t("ipcheck.device.dnt_unset"),devNetUnsupported:t("ipcheck.device.net_unsupported"),devUnsupported:t("ipcheck.device.unsupported"),histEmpty:t("ipcheck.history.empty"),histCurrent:t("ipcheck.history.current"),histLoading:t("ipcheck.ip.loading")};function f(a,i="neutral"){return`<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${Te[i]||Te.neutral}">${a}</span>`}function J(a,i,r){return a===!0?f(i,"danger"):a===!1?f(r,"safe"):f(e.unknown,"neutral")}function he(a){if(!a)return`<span class="text-oai-gray-400 dark:text-oai-gray-500">${w(e.failed)}</span>`;const i=w(a);return Z(a)?`<span class="ip-mask-target truncate" title="${i}">${w(Ke(a))}</span>`:`<span class="ip-mask-target">${i}</span>`}function K(a){return a?`<span class="ip-link">${he(a)}</span>`:`<span class="text-oai-gray-400 dark:text-oai-gray-500">${w(e.failed)}</span>`}function d(a,i,r=!1){let u=i;return i===void 0?r?u=`<div class="inline-flex items-center gap-1.5 text-xs text-oai-gray-400">
<svg class="animate-spin-subtle h-3.5 w-3.5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="3"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</div>`:u='<span class="block h-3 w-20 rounded bg-oai-gray-100 dark:bg-oai-gray-800 shimmer"></span>':u=`<div class="animate-scale-up-fade">${i}</div>`,`<div class="flex items-center justify-between py-2.5 gap-3">
<span class="text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0">${a}</span>
<span class="text-sm font-medium text-oai-black dark:text-white text-right min-w-0">${u}</span>
</div>`}function re(a){return a.map(i=>d(i,void 0)).join("")}function oe(){return'<div class="h-7 w-44 rounded bg-oai-gray-100 dark:bg-oai-gray-800 shimmer"></div>'}function ce(){return'<div class="h-3 w-52 mt-2 rounded bg-oai-gray-100 dark:bg-oai-gray-800 shimmer"></div>'}function _e(a){return a>=95?{text:e.score.pristine,variant:"safe"}:a>=80?{text:e.score.clean,variant:"safe"}:a>=50?{text:e.score.good,variant:"info"}:a>=25?{text:e.score.neutral,variant:"warn"}:{text:e.score.suspicious,variant:"danger"}}const m={ip:null,ippure:null,ipapis:null,claudeGeo:null,claudeRisk:null,cfGeo:"",scoreAnimId:null,lastScore:0};function xe(){const a=(m.claudeRisk?.countryCode||"").toUpperCase();return!a||!Ue.includes(a)?null:t(`ipcheck.region.${a}`)}function le(){const a=C("ipv6Warn");a&&a.classList.remove("hidden")}function te(a,i){const r=C(a);r&&(r.textContent=i||"",r.classList.remove("animate-pulse","bg-oai-gray-200","dark:bg-oai-gray-800","w-52","h-3","mt-2","rounded"))}const Le={gaugeScore:'<span class="block h-8 w-16 rounded bg-oai-gray-100 dark:bg-oai-gray-800 shimmer"></span>',ipAddrCN:oe(),ipGeoCN:ce(),ipAddr:oe(),ipGeo:ce(),ipAddrClaude:oe(),ipGeoClaude:ce(),propsContent:re([e.propsRegion,e.propsCity,e.propsType,e.propsAsn,e.propsOrg]),securityContent:re([e.secVpn,e.secProxy,e.secTor,e.secCrawler,e.secAbuser]),claudeAvailContent:d("claude.ai",void 0,!0)+d("anthropic.com",void 0,!0),dnsLeakContent:d(e.dnsStatus,void 0,!0)+d(e.dnsOutletIp,void 0,!0),udpLeakContent:d(e.udpStatus,void 0,!0)+d(e.udpOutletIp,void 0,!0),deviceContent:re([e.devTz,e.devLang,e.devOs,e.devTouch,e.devNet,e.devDnt,e.devWebglRender,e.devCanvasFp]),ipHistoryContent:`<span class="text-sm text-oai-gray-400 dark:text-oai-gray-500">${e.histLoading}</span>`};Object.entries(Le).forEach(([a,i])=>{const r=C(a);r&&(r.innerHTML=i)});let ye=!1;function Ne(a){if(!a)return;a.dataset.realText||(a.dataset.realText=(a.textContent||"").trim());const i=a.dataset.realText,r=ye?Fe(i):i;a.textContent!==r&&(a.textContent=r)}function ke(){_.querySelectorAll(".ip-link, .ip-mask-target").forEach(Ne)}const ve=new MutationObserver(()=>requestAnimationFrame(ke));["ipHeroCN","ipHero","ipHeroClaude","ipHistoryContent","dnsLeakContent","udpLeakContent"].forEach(a=>{const i=C(a);i&&ve.observe(i,{childList:!0,subtree:!0})}),_.__setMaskOn=a=>{ye=!!a,ke()};async function $e(){try{const r=(await(await fetch("https://1.1.1.1/cdn-cgi/trace",{signal:AbortSignal.timeout(5e3)})).text()).match(/ip=([^\n]+)/);r&&(m.ip=r[1].trim())}catch{}}async function je(){try{const i=await(await fetch("https://claude.ai/cdn-cgi/trace",{cache:"no-store",signal:AbortSignal.timeout(8e3)})).text(),r=Object.fromEntries(i.trim().split(`
`).map(u=>u.split("=")));return{ip:r.ip||null,loc:r.loc?.toLowerCase()||null}}catch{return null}}async function Me(){try{const r=(await(await fetch("https://2026.ip138.com/",{signal:AbortSignal.timeout(5e3)})).text()).match(/(\d+\.\d+\.\d+\.\d+)/);if(r)return{ip:r[1]}}catch{}try{const r=(await(await fetch("https://my.ip.cn/",{signal:AbortSignal.timeout(5e3)})).text()).match(/(\d+\.\d+\.\d+\.\d+)/);if(r)return{ip:r[1]}}catch{}return null}async function Ee(a,i,r,u){const g=C(a),o=C(i);if(!(!g||!o)){if(!r){g.innerHTML=`<span class="text-oai-gray-400 dark:text-oai-gray-500">${e.failed}</span>`,o.textContent="";return}Z(r)&&le(),g.innerHTML=`${B(u)+" "}${K(r)}`;try{const l=await fetch(`${j}/api/geoip/${r}`,{signal:AbortSignal.timeout(5e3)});if(l.ok){const h=await l.json(),s=[h.country,h.region,h.city,h.isp].filter(Boolean).join(" · "),x=h.country_code||u||"";g.innerHTML=`${B(x)} ${K(r)}`,te(i,s)}}catch{}}}function Ie(){const a=m.ippure,i=m.claudeRisk,r=m.claudeGeo,u=m.ipapis,g=i?.asn||a?.asn||"",o=i?.asOrganization||a?.asOrganization||u?.company?.name||"",l=xe(),h=!!(i&&i.ip);let s,x=null;h?l?(s=0,x=e.regionRestrictedText):s=typeof i.trust_score=="number"?i.trust_score:null:s=null;const v=C("gaugePointer"),c=C("gaugeScore"),P=C("gaugeText");if(s===null)c.innerHTML=`<span class="text-4xl font-bold tracking-tight tabular-nums text-oai-gray-400 dark:text-oai-gray-500">—</span> ${f(e.noData,"neutral")}`,v.style.left="0%",v.style.opacity="0.3",v.style.borderColor="",v.style.boxShadow="",P.textContent=h?e.noScore:e.noIp;else{const A=l?{text:e.score.unreachable,variant:"danger"}:_e(s),L=s>=50?"text-emerald-500":s>=25?"text-amber-500":"text-red-500",X=s>=50?"#10b981":s>=25?"#f59e0b":"#ef4444";if(m.lastScore!==s){m.scoreAnimId&&cancelAnimationFrame(m.scoreAnimId);const Q=m.lastScore||0;m.lastScore=s;const de=performance.now(),ee=800,ne=ue=>{const N=ue-de,k=Math.min(N/ee,1),$=k*(2-k),I=Math.round(Q+(s-Q)*$),Y=I>=50?"text-emerald-500":I>=25?"text-amber-500":"text-red-500";c&&(c.innerHTML=`<span class="text-4xl font-bold tracking-tight tabular-nums ${Y}">${I}</span> ${f(A.text,A.variant)}`),k<1?m.scoreAnimId=requestAnimationFrame(ne):m.scoreAnimId=null};m.scoreAnimId=requestAnimationFrame(ne)}else c.innerHTML=`<span class="text-4xl font-bold tracking-tight tabular-nums ${L}">${s}</span> ${f(A.text,A.variant)}`;requestAnimationFrame(()=>{requestAnimationFrame(()=>{v&&(v.style.left=Math.min(s,100)+"%",v.style.opacity="1",v.style.borderColor=X,v.style.boxShadow=`0 0 10px ${X}80, 0 2px 6px rgba(0,0,0,0.15)`)})}),P.textContent=x||(s>=95?e.scoreText.excellent:s>=80?e.scoreText.great:s>=50?e.scoreText.minor:s>=25?e.scoreText.moderate:e.scoreText.severe)}const y=C("statusDotClaude");if(y){let A,L;s===null?(A="animate-ping absolute inline-flex h-full w-full rounded-full bg-oai-gray-300 dark:bg-oai-gray-600 opacity-75",L="relative inline-flex h-2 w-2 rounded-full bg-oai-gray-400 dark:bg-oai-gray-500"):l||s<25?(A="animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75",L="relative inline-flex h-2 w-2 rounded-full bg-red-500"):s<50?(A="animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75",L="relative inline-flex h-2 w-2 rounded-full bg-amber-500"):(A="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75",L="relative inline-flex h-2 w-2 rounded-full bg-emerald-500"),y.innerHTML=`<span class="${A}"></span><span class="${L}"></span>`}const H=C("regionWarn");H&&(l?(H.innerHTML=`<span class="font-medium">⚠️ ${e.regionWarnTitle(l)}</span><br><span class="text-[13px] font-normal mt-1 block opacity-90">${e.regionWarnBody}</span>`,H.classList.remove("hidden")):H.classList.add("hidden"));const G=C("claudeRegionSupportRow"),F=C("claudeRegionSupport");if(G&&F)if(l)G.classList.add("hidden");else{const A=!!(i&&i.ip),L=!!(i&&i.countryCode);F.innerHTML=!A||!L?f(e.unknown,"neutral"):f(e.regionAccessible,"safe"),G.classList.remove("hidden")}const U=i?.isResidential??(u?!u.is_datacenter:null),O=u?.company?.type||"",z=r?.country||i?.country||"",W=r?.city||i?.city||"";let T;if(U===!0?T=f(e.propsResidential,"safe"):U===!1?T=f(e.propsDatacenter,"warn"):T=f(e.unknown,"neutral"),O){const L={hosting:"Hosting",isp:"ISP",business:"Business",education:"Education"}[O]||w(O);T+=` <span class="text-xs text-oai-gray-500 dark:text-oai-gray-400">${L}</span>`}C("propsContent").innerHTML=d(e.propsRegion,z?w(z):f(e.unknown,"neutral"))+d(e.propsCity,W?w(W):f(e.unknown,"neutral"))+d(e.propsType,T)+d(e.propsAsn,g?`<span class="font-mono tabular-nums">AS${w(g)}</span>`:f(e.unknown,"neutral"))+d(e.propsOrg,o?w(o):f(e.unknown,"neutral"));const E=u||{};C("securityContent").innerHTML=d(e.secVpn,J(E.is_vpn,e.secVpn,e.secClean))+d(e.secProxy,J(E.is_proxy,e.secProxyFlag,e.secClean))+d(e.secTor,J(E.is_tor,e.secTor,e.secClean))+d(e.secCrawler,J(E.is_crawler,e.secCrawlerYes,e.secCrawlerNo))+d(e.secAbuser,J(E.is_abuser,e.secAbuserYes,e.secAbuserNo))}async function Re(){const a=C("dnsLeakContent");if(!a)return;a.innerHTML=d(e.dnsStatus,void 0,!0)+d(e.dnsOutletIp,void 0,!0);const i=Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2);for(let s=1;s<=2;s++)await new Promise(x=>{const v=new Image,c=setTimeout(x,2e3);v.onload=v.onerror=()=>{clearTimeout(c),x()},v.src=`http://${i}-${s}.d.ip.net.coffee/pixel.gif?_=${Date.now()}`});await new Promise(s=>setTimeout(s,1500));let r=[];for(let s=0;s<2;s++){try{const x=await fetch(`${j}/api/dns/result/${i}`,{signal:AbortSignal.timeout(3e3)});if(x.ok&&(r=(await x.json()).dns_servers||[],r.length>0))break}catch{}s===0&&await new Promise(x=>setTimeout(x,1500))}if(r.length===0){a.innerHTML=d(e.dnsStatus,f(e.dnsEncrypted,"safe"));return}const u=(m.claudeRisk?.country||"").toLowerCase(),g=u.includes("china")||u.includes("中国");let o=null,l=!1;for(const s of r){let x=null;try{const y=await fetch(`${j}/api/geoip/${s}`,{signal:AbortSignal.timeout(3e3)});y.ok&&(x=await y.json())}catch{}const v=x?.country_code||"",c=x?.isp||"";if(v==="cn"&&!g){o={ip:s,cc:v,isp:c,leaked:!0},l=!0;break}o||(o={ip:s,cc:v,isp:c,leaked:!1})}let h=d(e.dnsStatus,l?f(e.dnsLeaked,"warn"):f(e.dnsNoLeak,"safe"));if(o){const s=`${B(o.cc)} <span class="ip-mask-target ${o.leaked?"text-amber-600 dark:text-amber-400 font-medium":""}">${w(o.ip)}</span>${o.leaked?" "+f(e.dnsCnTag,"warn"):""}`;h+=d(e.dnsOutlet,s),o.isp&&(h+=d(e.dnsIsp,`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal truncate inline-block max-w-[12rem] align-bottom">${w(o.isp)}</span>`))}a.innerHTML=h}async function He(){const a=C("udpLeakContent");if(!a)return;a.innerHTML=d(e.udpStatus,void 0,!0)+d(e.udpOutletIp,void 0,!0);const i=new Set;try{const y=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.cloudflare.com:3478"}]});y.createDataChannel("");const H=await y.createOffer();await y.setLocalDescription(H),await new Promise(G=>{const F=setTimeout(()=>{y.close(),G()},5e3);y.onicecandidate=U=>{if(!U.candidate){clearTimeout(F),y.close(),G();return}const O=U.candidate.candidate.match(/([0-9]{1,3}\.){3}[0-9]{1,3}/);if(O){const W=O[0];!W.startsWith("0.")&&!W.startsWith("127.")&&W!=="0.0.0.0"&&i.add(W)}const z=U.candidate.candidate.match(/([a-f0-9]{1,4}:){2,7}[a-f0-9]{1,4}/i);z&&i.add(z[0])}})}catch{}const r=m.claudeRisk?.ip||"",u=[...i],g=u.filter(y=>!Z(y)&&!y.startsWith("192.168.")&&!y.startsWith("10.")&&!y.startsWith("172.")&&!y.startsWith("198.18.")&&!y.startsWith("198.19.")&&!y.startsWith("100.64.")&&!y.startsWith("127.")&&!y.startsWith("0."));if(g.length===0&&u.length===0){a.innerHTML=d(e.udpStatus,f(e.udpDisabled,"safe"));return}if(g.length===0){a.innerHTML=d(e.udpStatus,f(e.udpNoLeak,"safe"));return}let o=g.find(y=>y===r)||g[0];const l=new Set(g).size>1,h=o===r,s=l&&!h;let x=d(e.udpStatus,s?f(e.udpLeaked,"warn"):f(e.udpNoLeak,"safe")),v="",c="";try{const y=await fetch(`${j}/api/geoip/${o}`,{signal:AbortSignal.timeout(5e3)});if(y.ok){const H=await y.json();v=H.country_code||"",c=H.country||""}}catch{}const P=`${B(v)} <span class="${s?"text-amber-600 dark:text-amber-400 font-medium":""}">${he(o)}</span>${h?"":s?" "+f(e.udpAnomaly,"warn"):""}`;x+=d(e.udpOutlet,P),c&&(x+=d(e.udpOrigin,`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${w(c)}</span>`)),a.innerHTML=x}async function be(){const a=C("claudeAvailContent");if(!a)return;a.innerHTML=d("claude.ai",void 0,!0)+d("anthropic.com",void 0,!0);const i=[{name:"claude.ai",url:"https://claude.ai/cdn-cgi/trace"},{name:"anthropic.com",url:"https://www.anthropic.com/favicon.ico"}],r=await Promise.allSettled(i.map(async o=>{const l=performance.now();try{return await fetch(o.url,{mode:"no-cors",signal:AbortSignal.timeout(6e3)}),{name:o.name,ms:Math.round(performance.now()-l),ok:!0}}catch{return{name:o.name,ms:-1,ok:!1}}})),u=xe();let g="";r.forEach(o=>{const l=o.value;if(u)g+=d(l.name,f(e.availLat.unreachable,"danger"));else if(l.ok){const h=l.ms<250?"safe":l.ms<500?"info":"warn",s=l.ms<250?e.availLat.normal:l.ms<500?e.availLat.good:e.availLat.slow;g+=d(l.name,`${f(s,h)} <span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${l.ms}ms</span>`)}else g+=d(l.name,f(e.availLat.unreachable,"danger"))});try{const o=await fetch(`${j}/claude/status.json`,{signal:AbortSignal.timeout(3e3)});if(o.ok){const h=(await o.json()).overall_indicator||"none",s=e.availSvcStatus[h]||e.availSvcStatus.other,x={none:"safe",minor:"warn",major:"danger",critical:"danger",maintenance:"warn"};g+=d(e.availSvc,f(s,x[h]||"warn"))}}catch{}a.innerHTML=g}_.__detectClaudeAvail=be;function Oe(){const a=Intl.DateTimeFormat().resolvedOptions().timeZone||e.unknown,i=-(new Date().getTimezoneOffset()/60),r="UTC"+(i>=0?"+":"")+i,u=m.claudeRisk,g=(u?.countryCode||"").toUpperCase(),o=u?.timezone||ze[g]||"",l=!!u?.timezone,h=Ve(o),s=-new Date().getTimezoneOffset();let x=null;o&&h!=null&&(x=Math.abs(h-s)<=60);let v;const c=w(a),P=w(o);if(x===!0)v=`${f(e.devMatch,"safe")} <span class="text-xs text-oai-gray-500 dark:text-oai-gray-400">${c} (${r})</span>`;else if(x===!1){const N=Ye(h),k=Math.round((h-s)/60),$=k===0?e.devDiffEqual:k>0?e.devDiffAhead(k):e.devDiffBehind(-k),I=l?P:`${P} ${e.devEstSuffix}`;v=`${f(e.devMismatch,"warn")}<br><span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${e.devLocal} ${c} (${r})<br>Claude ${I} (${N}) · ${$}</span>`}else v=`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${c} (${r})</span>`;const y=navigator.languages||[navigator.language],H=y.join(", ")||e.unknown,G=(y[0]||"").split("-")[0].toLowerCase(),F=We[g]||[],U=G&&F.length?F.includes(G):null;let O;const z=w(H),W=w(F.join(" / "));U===!0?O=`${f(e.devMatch,"safe")} <span class="text-xs text-oai-gray-500 dark:text-oai-gray-400">${z}</span>`:U===!1?O=`${f(e.devMismatch,"warn")}<br><span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${e.devLocal} ${z}<br>${e.devLangExpected} ${W}</span>`:O=`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal">${z}</span>`;const T=navigator.userAgent;let E=e.unknown,A=e.unknown;T.includes("Windows")?E="Windows":T.includes("Mac OS")?E="macOS":T.includes("iPhone")||T.includes("iPad")?E="iOS":T.includes("Android")?E="Android":T.includes("Linux")&&(E="Linux"),T.includes("Edg/")?A="Edge "+(T.match(/Edg\/([\d.]+)/)||[])[1]:T.includes("Chrome/")?A="Chrome "+(T.match(/Chrome\/([\d.]+)/)||[])[1]:T.includes("Firefox/")?A="Firefox "+(T.match(/Firefox\/([\d.]+)/)||[])[1]:T.includes("Safari/")&&!T.includes("Chrome")&&(A="Safari "+(T.match(/Version\/([\d.]+)/)||[])[1]);let L=e.devUnsupported;try{const N=document.createElement("canvas"),k=N.getContext("webgl")||N.getContext("experimental-webgl");if(k){const $=k.getExtension("WEBGL_debug_renderer_info");$&&(L=k.getParameter($.UNMASKED_RENDERER_WEBGL))}}catch{}let X=e.devUnsupported;try{const N=document.createElement("canvas"),k=N.getContext("webgl")||N.getContext("experimental-webgl");if(k){const $=k.getExtension("WEBGL_debug_renderer_info"),I=$?k.getParameter($.UNMASKED_VENDOR_WEBGL):"",Y=$?k.getParameter($.UNMASKED_RENDERER_WEBGL):"",Ce=I+"~"+Y+"~"+k.getParameter(k.VERSION)+"~"+k.getParameter(k.SHADING_LANGUAGE_VERSION);let ie=0;for(let pe=0;pe<Ce.length;pe++)ie=(ie<<5)-ie+Ce.charCodeAt(pe)|0;X=(ie>>>0).toString(16).toUpperCase()}}catch{}let Q=e.devUnsupported;try{const N=document.createElement("canvas");N.width=200,N.height=50;const k=N.getContext("2d");k.textBaseline="top",k.font="14px Arial",k.fillStyle="#f60",k.fillRect(50,0,100,50),k.fillStyle="#069",k.fillText("net.coffee",2,15),k.fillStyle="rgba(102,204,0,0.7)",k.fillText("canvas fp",4,30);const $=N.toDataURL();let I=0;for(let Y=0;Y<$.length;Y++)I=(I<<5)-I+$.charCodeAt(Y)|0;Q=(I>>>0).toString(16).toUpperCase()}catch{}const de=navigator.maxTouchPoints>0,ee=navigator.connection||navigator.mozConnection||navigator.webkitConnection,ne=ee?ee.effectiveType||ee.type||e.unknown:e.devNetUnsupported,ue=navigator.doNotTrack==="1"?e.devDntOn:navigator.doNotTrack==="0"?e.devDntOff:e.devDntUnset;C("deviceContent").innerHTML=d(e.devTz,v)+d(e.devLang,O)+d(e.devOs,`${w(E)} <span class="text-oai-gray-400 dark:text-oai-gray-500">/</span> ${w(A)}`)+d(e.devTouch,de?f(e.devTouchYes,"info"):f(e.devTouchNo,"neutral"))+d(e.devNet,`<span class="font-mono uppercase">${w(ne)}</span>`)+d(e.devDnt,w(ue))+d(e.devWebglRender,`<span class="text-xs font-normal text-oai-gray-600 dark:text-oai-gray-400 break-all">${w(L)}</span>`)+d(e.devCanvasFp,`<span class="font-mono text-oai-gray-700 dark:text-oai-gray-300">${w(Q)}</span>`)+d(e.devWebglFp,`<span class="font-mono text-oai-gray-700 dark:text-oai-gray-300">${w(X)}</span>`)}function we(){try{return JSON.parse(localStorage.getItem(fe))||[]}catch{return[]}}function Pe(){const a=m.claudeRisk?.ip||"",i=(m.claudeRisk?.countryCode||"").toLowerCase(),r=m.claudeRisk?.city||"";if(!a){ae();return}const u=we(),g=new Date,o={ip:a,cc:i,geo:r,time:g.toISOString()};if(u.length>0){const l=u[0],h=(g-new Date(l.time))/(1e3*60*60);if(l.ip===a&&h<24){ae();return}}u.unshift(o),u.length>Se&&(u.length=Se),localStorage.setItem(fe,JSON.stringify(u)),ae()}function ae(){const a=C("ipHistoryContent");if(!a)return;const i=we();if(i.length===0){a.innerHTML=`<span class="text-sm text-oai-gray-500 dark:text-oai-gray-400">${e.histEmpty}</span>`;return}a.innerHTML=`<ul class="divide-y divide-oai-gray-100 dark:divide-oai-gray-800">${i.map((r,u)=>{const g=new Date(r.time),o=`${g.getMonth()+1}-${g.getDate()} ${String(g.getHours()).padStart(2,"0")}:${String(g.getMinutes()).padStart(2,"0")}`,l=u===0;return`<li class="flex items-center justify-between py-3 gap-4">
<div class="flex items-center gap-2 min-w-0">
<span class="text-sm ${l?"text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400"}">${o}</span>
${l?`<span class="inline-flex items-center rounded-full bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300 px-1.5 py-0.5 text-[10px] font-medium">${w(e.histCurrent)}</span>`:""}
</div>
<div class="flex items-center gap-2 text-sm font-medium text-oai-black dark:text-white min-w-0">
${B(r.cc)}
${K(r.ip)}
${r.geo?`<span class="text-xs text-oai-gray-500 dark:text-oai-gray-400 font-normal truncate">${w(r.geo)}</span>`:""}
</div>
</li>`}).join("")}</ul>`}_.__clearIPHistory=()=>{localStorage.removeItem(fe),ae()};async function De(){const[,a,i]=await Promise.allSettled([$e(),Me(),je()]);if(se)return;const r=a.status==="fulfilled"?a.value:null,u=i.status==="fulfilled"?i.value:null,g=[];g.push(Ee("ipAddrCN","ipGeoCN",r?.ip,"cn")),g.push((async()=>{const o=C("ipAddr"),l=C("ipGeo");if(!m.ip){o&&(o.innerHTML=`<span class="text-oai-gray-400 dark:text-oai-gray-500">${e.failed}</span>`),l&&(l.textContent="");return}Z(m.ip)&&le(),o&&(o.innerHTML=K(m.ip));try{const h=await fetch(`${j}/api/geoip/${m.ip}`,{signal:AbortSignal.timeout(5e3)});if(h.ok){const s=await h.json(),x=(s.country_code||"").toLowerCase();m.ippure={ip:m.ip,country:s.country,countryCode:(s.country_code||"").toUpperCase(),region:s.region,city:s.city},m.cfGeo=[s.country,s.region,s.city,s.isp].filter(Boolean).join(" · "),o&&(o.innerHTML=`${B(x)} ${K(m.ip)}`),te("ipGeo",m.cfGeo)}}catch{}})()),g.push((async()=>{const o=u?.ip,l=C("ipAddrClaude"),h=C("ipGeoClaude");if(!o){l&&(l.innerHTML=`<span class="text-oai-gray-400 dark:text-oai-gray-500">${e.failed}</span>`),h&&(h.textContent="");return}Z(o)&&le(),l&&(l.innerHTML=`${B(u.loc||"")} ${K(o)}`);const[s,x]=await Promise.allSettled([fetch(`${j}/api/iprisk/${o}`,{signal:AbortSignal.timeout(1e4)}),fetch(`${j}/api/geoip/${o}`,{signal:AbortSignal.timeout(5e3)})]);let v=!1;if(x.status==="fulfilled"&&x.value.ok)try{const c=await x.value.json();if(c.country){m.claudeGeo={country:c.country,region:c.region,city:c.city,isp:c.isp,country_code:c.country_code};const P=[c.country,c.region,c.city,c.isp].filter(Boolean).join(" · ");l&&(l.innerHTML=`${B(c.country_code||u.loc||"")} ${K(o)}`),te("ipGeoClaude",P),v=!0}}catch{}if(!v&&u.loc&&(l&&(l.innerHTML=`${B(u.loc)} ${K(o)}`),te("ipGeoClaude",Be[u.loc]||u.loc.toUpperCase())),s.status==="fulfilled"&&s.value.ok){const c=await s.value.json();m.ipapis={is_datacenter:c.is_datacenter,is_vpn:c.is_vpn,is_proxy:c.is_proxy,is_tor:c.is_tor,is_crawler:c.is_crawler,is_abuser:c.is_abuser,is_mobile:c.is_mobile,company:{type:c.company_type,name:c.company_name},abuser_score:c.abuser_score,datacenter_name:c.datacenter_name},m.claudeRisk={ip:o,asn:c.asn,asOrganization:c.asOrganization,country:c.country,countryCode:c.countryCode,region:c.region,city:c.city,isResidential:c.isResidential,isBroadcast:c.isBroadcast,trust_score:c.trust_score,timezone:c.timezone}}})()),await Promise.allSettled(g),!se&&(Ie(),Promise.allSettled([Re(),He(),be()]),Oe(),Pe())}return De(),()=>{se=!0,ve.disconnect(),m.scoreAnimId&&cancelAnimationFrame(m.scoreAnimId),delete _.__setMaskOn,delete _.__clearIPHistory,delete _.__detectClaudeAvail}},[]);const M=_=>{S(_),p.current?.__setMaskOn?.(_)},D=()=>p.current?.__clearIPHistory?.(),q=()=>p.current?.__detectClaudeAvail?.(),R={__html:""};return n.jsx("div",{ref:p,className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:n.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:n.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[n.jsxs("div",{className:"flex items-start justify-between gap-4 mb-8",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:t("ipcheck.page.title")}),n.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base max-w-3xl text-pretty",children:t("ipcheck.page.subtitle")})]}),n.jsxs("label",{className:"shrink-0 inline-flex items-center gap-2.5 cursor-pointer select-none group",children:[n.jsx("div",{className:"text-oai-gray-400 group-hover:text-oai-gray-600 dark:text-oai-gray-500 dark:group-hover:text-oai-gray-300 transition-colors duration-200",children:b?n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4.5 w-4.5 animate-scale-up-fade",children:[n.jsx("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),n.jsx("path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}),n.jsx("path",{d:"M6.61 6.61A13.52 13.52 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}),n.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}):n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4.5 w-4.5 animate-scale-up-fade",children:[n.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),n.jsx("span",{className:"text-xs font-medium text-oai-gray-500 group-hover:text-oai-gray-700 dark:text-oai-gray-400 dark:group-hover:text-oai-gray-200 transition-colors duration-200",children:t("ipcheck.mask.toggle")}),n.jsxs("span",{className:"relative inline-block w-9 h-5",children:[n.jsx("input",{type:"checkbox",checked:b,onChange:_=>M(_.target.checked),className:"peer sr-only"}),n.jsx("span",{className:"absolute inset-0 rounded-full bg-oai-gray-200 dark:bg-oai-gray-800 peer-checked:bg-oai-brand-500 transition-colors duration-200"}),n.jsx("span",{className:"absolute top-0.5 left-0.5 h-4 w-4 rounded-full bg-white shadow-sm transition-transform duration-200 peer-checked:translate-x-4"})]})]})]}),n.jsx("div",{id:"ipv6Warn",className:"hidden mb-4 rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-500/30 dark:bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",children:t("ipcheck.ipv6.warn")}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.jsx(me,{id:"CN",label:t("ipcheck.ip.cn"),icon:null,className:"animate-fade-in-up stagger-1"}),n.jsx(me,{id:"",label:t("ipcheck.ip.cloudflare"),icon:n.jsx("img",{src:`${j}/favicons/cloudflare.webp`,alt:"",className:"h-4 w-4"}),className:"animate-fade-in-up stagger-2"}),n.jsx(me,{id:"Claude",label:t("ipcheck.ip.claude"),icon:n.jsx("img",{src:`${j}/favicons/claude.webp`,alt:"",className:"h-4 w-4"}),statusDot:!0,className:"animate-fade-in-up stagger-3"})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[n.jsx(V,{title:t("ipcheck.trust.title"),subtitle:t("ipcheck.trust.subtitle"),className:"animate-fade-in-up stagger-4",children:n.jsxs("div",{className:"px-1 py-2",children:[n.jsx("div",{className:"flex items-baseline justify-between mb-2 gap-3",children:n.jsx("div",{id:"gaugeScore",className:"flex items-baseline gap-2 min-h-[2.5rem]",dangerouslySetInnerHTML:R})}),n.jsx("div",{id:"gaugeText",className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mb-4 min-h-[1rem]"}),n.jsxs("div",{children:[n.jsxs("div",{className:"relative",children:[n.jsx("div",{className:"h-1.5 rounded-full",style:{background:"linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #10b981 100%)"}}),n.jsx("span",{id:"gaugePointer",className:"absolute top-1/2 -translate-y-1/2 h-3.5 w-3.5 rounded-full bg-white dark:bg-oai-gray-900 border-2 border-oai-gray-300 dark:border-oai-gray-700 shadow-[0_2px_6px_rgba(0,0,0,0.15)] dark:shadow-[0_2px_6px_rgba(0,0,0,0.4)] -translate-x-1/2 transition-[left,border-color] duration-700 ease-out",style:{left:"0%"}})]}),n.jsxs("div",{className:"mt-2 flex justify-between text-[10px] uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 font-medium",children:[n.jsx("span",{children:t("ipcheck.trust.gauge.low")}),n.jsx("span",{className:"tracking-normal",children:"25"}),n.jsx("span",{className:"tracking-normal",children:"50"}),n.jsx("span",{className:"tracking-normal",children:"75"}),n.jsx("span",{children:t("ipcheck.trust.gauge.high")})]})]}),n.jsx("div",{id:"regionWarn",className:"hidden mt-4 rounded-lg border border-red-200 bg-red-50 dark:border-red-500/30 dark:bg-red-500/10 px-3 py-2 text-xs text-red-800 dark:text-red-300"}),n.jsxs("div",{id:"claudeRegionSupportRow",className:"hidden mt-4 pt-4 border-t border-oai-gray-100 dark:border-oai-gray-800 flex items-center justify-between",children:[n.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:t("ipcheck.trust.region_support")}),n.jsx("span",{id:"claudeRegionSupport",className:"text-sm font-medium text-oai-black dark:text-white",dangerouslySetInnerHTML:R})]})]})}),n.jsx(V,{title:t("ipcheck.props.title"),className:"animate-fade-in-up stagger-4",children:n.jsx("div",{id:"propsContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})}),n.jsx(V,{title:t("ipcheck.security.title"),className:"animate-fade-in-up stagger-4",children:n.jsx("div",{id:"securityContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[n.jsx(V,{title:n.jsxs("span",{className:"flex items-center gap-1.5",children:[t("ipcheck.avail.title"),n.jsx(Ze,{text:t("ipcheck.avail.tooltip")})]}),action:n.jsx(Ae,{label:t("ipcheck.avail.refresh"),onClick:q}),className:"animate-fade-in-up stagger-5",children:n.jsx("div",{id:"claudeAvailContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})}),n.jsx(V,{title:t("ipcheck.dns.title"),className:"animate-fade-in-up stagger-5",children:n.jsx("div",{id:"dnsLeakContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})}),n.jsx(V,{title:t("ipcheck.udp.title"),className:"animate-fade-in-up stagger-5",children:n.jsx("div",{id:"udpLeakContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})})]}),n.jsx(V,{title:t("ipcheck.device.title"),className:"animate-fade-in-up stagger-6",children:n.jsx("div",{id:"deviceContent",className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800 pt-1",dangerouslySetInnerHTML:R})}),n.jsx(V,{title:t("ipcheck.history.title"),subtitle:t("ipcheck.history.subtitle"),action:n.jsx(Ae,{label:t("ipcheck.history.clear"),onClick:D}),className:"animate-fade-in-up stagger-6",children:n.jsx("div",{id:"ipHistoryContent",dangerouslySetInnerHTML:R})})]})]})})})}function V({title:p,subtitle:b,action:S,children:M,className:D=""}){return n.jsxs("section",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 sm:p-6 transition-colors duration-200 ${D}`,children:[n.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:p}),b?n.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:b}):null]}),S]}),M]})}function Ae({label:p,onClick:b}){return n.jsx("button",{type:"button",onClick:b,className:"shrink-0 inline-flex h-7 items-center px-2.5 rounded-md text-xs font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-200 dark:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:p})}function Ze({text:p}){return n.jsxs("span",{className:"relative inline-flex items-center group",children:[n.jsx("svg",{viewBox:"0 0 16 16",className:"h-3.5 w-3.5 text-oai-gray-400 dark:text-oai-gray-500",fill:"currentColor","aria-hidden":!0,children:n.jsx("path",{d:"M8 1.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13zM7.25 6.75a.75.75 0 0 1 1.5 0V11a.75.75 0 0 1-1.5 0V6.75zM8 4a.85.85 0 1 1 0 1.7A.85.85 0 0 1 8 4z"})}),n.jsx("span",{className:"pointer-events-none absolute left-1/2 top-full z-10 mt-1.5 -translate-x-1/2 w-56 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-2 text-[11px] font-normal text-white opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-relaxed shadow-lg origin-top",children:p})]})}function me({id:p,label:b,icon:S,statusDot:M,className:D=""}){const q=`ipAddr${p}`,R=`ipGeo${p}`;return n.jsxs("article",{id:`ipHero${p}`,className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 sm:p-6 cursor-default transition-colors duration-200 ${D}`,children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] uppercase tracking-wider font-medium text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:[S,n.jsx("span",{children:b}),M?n.jsxs("span",{id:`statusDot${p}`,className:"relative inline-flex h-2 w-2 ml-1.5","aria-hidden":!0,children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-oai-gray-300 dark:bg-oai-gray-600 opacity-75"}),n.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-oai-gray-400 dark:bg-oai-gray-500"})]}):null]}),n.jsx("div",{id:q,className:"text-xl sm:text-2xl font-semibold text-oai-black dark:text-white flex items-center gap-2 min-h-[2rem]",dangerouslySetInnerHTML:{__html:""}}),n.jsx("div",{id:R,className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 truncate min-h-[1rem]"})]})}export{Je as default};

Sorry, the diff of this file is too big to display

import{R as l,j as c,b as h}from"./__vite-browser-external-Eoyj4eG-.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};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeaderboardProfileModal-DtNEbVH8.js","assets/__vite-browser-external-Eoyj4eG-.js","assets/__vite-browser-external-C7JwykID.css","assets/provider-display-CKbOKeV4.js","assets/useCurrency-BtHtcsO5.js","assets/useTokenFormat-BdD057ih.js","assets/terminal-DyicX7lG.js","assets/info-B46Qt16h.js","assets/LeaderboardAvatar-CaOV_hFE.js","assets/AchievementBadge-D6iPEEbz.js","assets/zap-DWWma29E.js","assets/flame-vLBOq0X0.js","assets/AchievementsSection-ah-kG00E.js","assets/format-tokens-C6Pidz3s.js","assets/arrow-up-right-CT4-gmOS.js","assets/link-2-DeN6MJpT.js","assets/check-B87_qvAg.js","assets/DialogTitle-z86PHHyk.js","assets/useScrollLock-C2C-Yazq.js","assets/CommunityStatsModal-DA3PHLV5.js","assets/icons-BaaYJxUN.js","assets/TrendMonitor-DM1_WNfw.js","assets/PopoverPopup-DX7v1XfE.js","assets/SelectItemText-CCW6JeeN.js","assets/DialogDescription-ahxSNUcB.js"])))=>i.map(i=>d[i]);
import{k as ma,j as e,R as xa,c as n,b as d,r as c,aq as ua,u as ga,U as ba,e as pa,ar as ha,F as fa,as as ya,at as ka,au as wa,av as se,g as ja,aw as va,x as Na,P as pe,L as _a,ax as Sa,i as Ca,ay as La,az as Ma,ab as Ie,aA as Aa,_ as Fe,v as Ta}from"./__vite-browser-external-Eoyj4eG-.js";import{S as Ea}from"./Select-CH2xVU8X.js";import{u as Pa,C as Ka,a as Ra,b as za,c as Be,D as Ia,d as Ba,S as $a,h as Ua,s as Da,K as Oa,P as Fa}from"./use-ordered-list-Dk0p2otw.js";import{u as Ga}from"./useCurrency-BtHtcsO5.js";import{u as X}from"./useTokenFormat-BdD057ih.js";import{L as J}from"./LeaderboardAvatar-CaOV_hFE.js";import{s as Ha,c as Ya,A as Wa,t as Va,b as qa}from"./AchievementBadge-D6iPEEbz.js";import{u as Ja}from"./use-community-stats-CExk3D6G.js";import"./SelectItemText-CCW6JeeN.js";import"./useScrollLock-C2C-Yazq.js";import"./check-B87_qvAg.js";import"./zap-DWWma29E.js";import"./flame-vLBOq0X0.js";const Za=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Xa=ma("arrow-right",Za),Qa=a=>{let{transform:r}=a;return{...r,y:0}};function H(a,{min:r,max:o,fallback:s}){const l=Number(a);if(!Number.isFinite(l))return s;const i=Math.floor(l);return i<r?r:i>o?o:i}function er(a,r){const o=H(r,{min:0,max:1e6,fallback:0}),s=H(a,{min:1,max:Math.max(1,o||1),fallback:1});if(o<=1)return[1];const l=new Set([1,o,s-2,s-1,s,s+1,s+2]),i=Array.from(l).filter(u=>Number.isInteger(u)&&u>=1&&u<=o).sort((u,p)=>u-p),m=[];let b=null;for(const u of i)b!=null&&u-b>1&&m.push(null),m.push(u),b=u;return m}function ar({page:a,totalPages:r}){const o=typeof r=="number"&&Number.isFinite(r)&&r>=0,s=o?H(r,{min:0,max:1e6,fallback:0}):null,l=H(a,{min:1,max:o?Math.max(1,s||1):1e6,fallback:1}),i=l>1,m=o?l<s:!0;return{canPrev:i,canNext:m,safePage:l,safeTotal:s}}function rr({entries:a,me:r,meLabel:o}){const s=Array.isArray(a)?a:[],l=r&&typeof r.rank=="number"?r.rank:null;return!l||s.some(m=>!!m?.is_me)?s:[{rank:l,is_me:!0,is_pinned:!0,user_id:r?.user_id??null,display_name:o,avatar_url:r?.avatar_url??null,github_url:null,is_public:!1,gpt_tokens:r?.gpt_tokens??"0",claude_tokens:r?.claude_tokens??"0",gemini_tokens:r?.gemini_tokens??"0",cursor_tokens:r?.cursor_tokens??"0",opencode_tokens:r?.opencode_tokens??"0",openclaw_tokens:r?.openclaw_tokens??"0",hermes_tokens:r?.hermes_tokens??"0",kiro_tokens:r?.kiro_tokens??"0",copilot_tokens:r?.copilot_tokens??"0",kimi_tokens:r?.kimi_tokens??"0",other_tokens:r?.other_tokens??"0",total_tokens:r?.total_tokens??"0",estimated_cost_usd:r?.estimated_cost_usd??null,badges:Array.isArray(r?.badges)?r.badges:[]},...s]}function tr(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 or=new Set(["/brand-logos/cursor.svg","/brand-logos/kimi.svg","/brand-logos/kiro.svg","/brand-logos/copilot.svg","/brand-logos/hermes.svg"]);function sr({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 ${or.has(a)?"dark:invert":""}`}):null,e.jsx("span",{className:"whitespace-nowrap",children:r})]})}const ne=xa.memo(function({badges:r,max:o=3,className:s=""}){const l=Ha((r||[]).filter(i=>i&&Ya.has(i.id)&&(i.tier||0)>=1)).slice(0,o);return l.length===0?null:e.jsx("span",{className:`pointer-events-none inline-flex shrink-0 items-center ${s}`,children:l.map((i,m)=>e.jsx("span",{title:n("achievements.mini.tooltip",{name:n(qa(i.id,"name")),tier:n(`achievements.tier.${Va(i.tier)}`)}),style:{zIndex:l.length-m},className:`pointer-events-auto relative inline-flex ${m>0?"-ml-1.5":""}`,children:e.jsx(Wa,{badgeId:i.id,tier:i.tier,size:"xs",className:"rounded-full ring-[1.5px] ring-white dark:ring-oai-gray-950"})},i.id))})}),Z=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"kiro_tokens",copyKey:"leaderboard.column.kiro",icon:"/brand-logos/kiro.svg"},{key:"copilot_tokens",copyKey:"leaderboard.column.copilot",icon:"/brand-logos/copilot.svg"},{key:"kimi_tokens",copyKey:"leaderboard.column.kimi",icon:"/brand-logos/kimi.svg"},{key:"opencode_tokens",copyKey:"leaderboard.column.opencode",icon:"/brand-logos/opencode.svg"},{key:"openclaw_tokens",copyKey:"leaderboard.column.openclaw",icon:"/brand-logos/openclaw.svg"},{key:"hermes_tokens",copyKey:"leaderboard.column.hermes",icon:"/brand-logos/hermes.svg"},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:null}],Ge="sticky left-0 z-40 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] bg-white dark:bg-oai-gray-950 px-2.5 sm:px-4 py-4 align-middle",He="sticky left-[55px] sm:left-[71px] z-40 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-3 sm:px-4 py-4 align-middle";function ie(a){return d("sticky left-0 z-30 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] px-2.5 sm:px-4 py-4 whitespace-nowrap",a?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function le(a){return d("sticky left-[55px] sm:left-[71px] z-30 hover:z-50 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 px-3 sm:px-4 py-4 min-w-0",a?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function y({className:a}){return e.jsx("div",{className:d("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",a)})}function nr({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(ie(!1),"!group-hover:bg-transparent"),children:e.jsx(y,{className:"h-4 w-6"})}),e.jsx("td",{className:d(le(!1),"!group-hover:bg-transparent"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(y,{className:"h-8 w-8 min-w-8 rounded-full"}),e.jsx(y,{className:d("h-4",r)})]})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:d("h-4",o)})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:"h-4 w-12"})}),Z.map(l=>e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:d("h-4",s)})},l.key))]})}function ir({index:a}){const r=a<3?"w-24":a<8?"w-20":"w-16",o=a%3===0?3:a%3===1?2:1;return e.jsxs("div",{className:"mx-0 my-1 rounded-xl bg-white dark:bg-oai-gray-950 border border-oai-gray-100 dark:border-oai-gray-800/60 px-3.5 py-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(y,{className:"h-4 w-3 shrink-0 rounded"}),e.jsx(y,{className:"h-9 w-9 shrink-0 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(y,{className:d("h-4",r)}),e.jsx(y,{className:"mt-2 h-3.5 w-20"})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx(y,{className:"ml-auto h-3 w-8"}),e.jsx(y,{className:"mt-1.5 ml-auto h-4 w-14"})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-oai-gray-100 pt-2.5 dark:border-oai-gray-800/70",children:Array.from({length:o},(s,l)=>e.jsx(y,{className:"h-5 w-12 rounded-full"},l))})]})}function lr({rows:a=10}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(Ge,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(y,{className:"h-3.5 w-6"})}),e.jsx("th",{className:d(He,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(y,{className:"h-3.5 w-12"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-10"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-14"})}),Z.map(r=>e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-12"})},r.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:a},(r,o)=>e.jsx(nr,{index:o},o))})]})}),e.jsx("div",{className:"flex flex-col py-1 sm:hidden",children:Array.from({length:a},(r,o)=>e.jsx(ir,{index:o},o))})]})}function dr({id:a,thClassName:r,children:o}){const{attributes:s,listeners:l,setNodeRef:i,transform:m,transition:b,isDragging:u}=Pa({id:a}),p=Ka.Transform.toString(m)||"";c.useLayoutEffect(()=>{const f=document.querySelectorAll(`td[data-column-key="${a}"]`),h="0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)";return f.forEach(g=>{g.style.transform=p,g.style.transition=b||"",g.style.zIndex=u?"20":"",g.style.position=p?"relative":"",g.style.boxShadow=u?h:""}),()=>{f.forEach(g=>{g.style.transform="",g.style.transition="",g.style.zIndex="",g.style.position="",g.style.boxShadow=""})}},[a,p,b,u]);const j={transform:p,transition:b,position:p?"relative":void 0,zIndex:u?20:void 0,boxShadow:u?"0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)":void 0};return e.jsx("th",{ref:i,style:j,className:d(r,"group/col select-none cursor-grab active:cursor-grabbing touch-none"),...s,...l,children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:d("-mr-1 inline-flex h-4 w-3 shrink-0 items-center justify-center text-oai-gray-400 dark:text-oai-gray-600","opacity-0 transition-opacity duration-150 group-hover/col:opacity-100",u&&"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 cr="tokentracker.leaderboard.columnOrder.v1";function mr(a){return Ra(cr,a)}const xr=50;function ur(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 Ye(a){return typeof a=="string"?a.trim():""}function gr(a){const r=Ye(a);return r?r.toLowerCase()==="anonymous":!0}function br({me:a,totalEntries:r,meLabel:o,onOpenProfile:s,onJumpToMe:l,canJump:i,className:m}){const b=a&&typeof a.rank=="number"?a.rank:null;if(!b)return null;const u=Number(r)||0,p=ur(b,u),j=Ye(a?.display_name),f=!j||gr(j)?o||"You":j,h=a?.user_id||f,g=s||(i?l:null),A=typeof g=="function",_=A?"button":"div",Q=A?{type:"button",onClick:g,"aria-label":n(s?"leaderboard.summary.view_profile":"leaderboard.summary.jump_to_me")}:{};return e.jsxs(_,{...Q,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",A?"border-oai-gray-200 hover:border-oai-brand-400 dark:border-oai-gray-800 dark:hover:border-oai-brand-500/80 bg-oai-gray-50/50 dark:bg-white/[0.02] backdrop-blur-md hover:bg-oai-brand-50/40 dark:hover:bg-oai-brand-950/20 active:scale-[0.97] dark:ring-1 dark:ring-white/[0.04] dark:hover:ring-white/[0.08]":"border-oai-gray-100 dark:border-oai-gray-800/60 bg-oai-gray-50/20 dark:bg-white/[0.01] backdrop-blur-sm dark:ring-1 dark:ring-white/[0.02]",m),children:[e.jsx(J,{size:"sm",avatarUrl:a?.avatar_url,displayName:f,seed:h}),e.jsx("span",{className:"hidden sm:inline max-w-[120px] truncate text-xs font-semibold text-oai-black dark:text-oai-gray-200 group-hover:text-oai-brand-600 dark:group-hover:text-oai-brand-400 transition-colors",children:f}),e.jsxs("span",{className:"text-xs font-bold tabular-nums text-oai-gray-800 dark:text-white",children:["#",b.toLocaleString()]}),p!=null&&p<=xr&&e.jsx("span",{className:d("hidden sm:inline-flex items-center rounded-full px-2 py-0.5 text-[9px] font-extrabold tracking-wider tabular-nums uppercase transition-colors duration-300 ring-1",p<=10?"bg-amber-500/10 text-amber-600 dark:bg-amber-500/15 dark:text-amber-400 ring-amber-500/20":"bg-oai-brand-100/50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-400 ring-oai-brand-500/10"),children:n("leaderboard.summary.percentile",{p:String(p)})}),A?e.jsx(Xa,{"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 pr=c.lazy(()=>Fe(()=>import("./LeaderboardProfileModal-DtNEbVH8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])).then(a=>({default:a.LeaderboardProfileModal}))),hr=c.lazy(()=>Fe(()=>import("./CommunityStatsModal-DA3PHLV5.js"),__vite__mapDeps([19,1,2,20,5,21,17,18,4,6,22,23,9,10,11,24])).then(a=>({default:a.CommunityStatsModal}))),de=[10,20,50,100],ce=20,We="tokentracker:leaderboard:pageSize";function fr(){if(typeof window>"u")return ce;try{const a=window.localStorage.getItem(We),r=Number(a);if(de.includes(r))return r}catch{}return ce}function me(a,r,o){const s=Number(a);if(!Number.isFinite(s)||s<=0)return"-";const l=Sa(r),i=r===Ta?s:s*o;return i>=1e3?`${l}${Math.round(i).toLocaleString()}`:i>=10?`${l}${Math.round(i)}`:`${l}${i.toFixed(2)}`}function xe({value:a}){const{formatTokens:r,formatTokensTooltip:o}=X();return e.jsx("span",{title:o(a),children:r(a)})}function yr({communityStats:a,onClick:r}){const{formatTokens:o,formatTokensTooltip:s}=X();return a.status!=="ready"?null:e.jsxs("button",{type:"button",onClick:r,className:"inline-flex min-w-0 max-w-full flex-1 items-center gap-1.5 whitespace-nowrap rounded-xl border border-oai-gray-200 bg-oai-gray-50/50 px-2.5 py-2 text-xs text-oai-gray-500 backdrop-blur-md transition-all duration-300 hover:border-oai-brand-400 hover:bg-oai-brand-50/40 active:scale-[0.97] dark:border-oai-gray-800 dark:bg-white/[0.02] dark:text-oai-gray-400 dark:hover:border-oai-brand-500/80 dark:hover:bg-oai-brand-950/20 sm:h-9 sm:flex-none sm:gap-2.5 sm:rounded-full sm:px-3.5 sm:py-0",title: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:e.jsx("span",{title:s(a.tokenFloor),children:o(a.tokenFloor)})}),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.jsxs("span",{className:"font-semibold text-oai-black dark:text-white tabular-nums",children:[e.jsx("span",{className:"sm:hidden",children:Ca(a.totalEntries)}),e.jsx("span",{className:"hidden sm:inline",children:(Number(a.totalEntries)||0).toLocaleString("en-US")})]}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.community.devs_chip")})]})]})}function $e({entry:a,isMe:r,orderedColumns:o}){const{formatTokens:s,formatTokensTooltip:l}=X(),i=r?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",m=r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900";return o.map(b=>e.jsx("td",{"data-column-key":b.key,title:l(a?.[b.key]),className:d("hidden sm:table-cell px-3 sm:px-4 py-4 whitespace-nowrap text-right tabular-nums",i,m),children:s(a?.[b.key])},b.key))}function kr(a){return a?.key==="gpt_tokens"?"CODEX":a?.key==="claude_tokens"?"CLAUDE":(a?.icon?.split("/").pop()||"").replace(/\.svg$/i,"").toUpperCase()||"OTHER"}const wr={1:"ring-2 ring-amber-400 dark:ring-amber-500/80 shadow-[0_0_8px_rgba(245,158,11,0.25)]",2:"ring-2 ring-slate-350 dark:ring-slate-450 shadow-[0_0_8px_rgba(148,163,184,0.2)]",3:"ring-2 ring-orange-400 dark:ring-orange-500/70 shadow-[0_0_8px_rgba(249,115,22,0.25)]"};function jr({rank:a,placeholder:r}){return a===1?e.jsx("span",{className:"text-base font-extrabold italic text-amber-500 dark:text-amber-400 tracking-tighter",children:"1"}):a===2?e.jsx("span",{className:"text-base font-extrabold italic text-slate-400 dark:text-slate-350 tracking-tighter",children:"2"}):a===3?e.jsx("span",{className:"text-base font-extrabold italic text-orange-500 dark:text-orange-400 tracking-tighter",children:"3"}):e.jsx("span",{className:"text-[13px] font-bold tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:a==null?r:`#${a}`})}function vr({githubUrl:a}){return e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":"GitHub profile",className:"absolute bottom-0 right-0 translate-x-1 translate-y-1 flex h-4.5 w-4.5 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 shadow border border-oai-gray-100 dark:border-oai-gray-800 transition-transform active:scale-110",children:e.jsx(pe,{provider:"GITHUB",size:11})})}function Nr({entry:a,orderedColumns:r}){const{formatTokens:o,formatTokensTooltip:s}=X(),l=r.filter(i=>{const m=Number(a?.[i.key]);return Number.isFinite(m)&&m>0});return l.length===0?null:e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-x-1.5 gap-y-2 border-t border-oai-gray-100/70 pt-3 dark:border-oai-gray-800/60",children:l.map(i=>{const m=n(i.copyKey);return e.jsxs("span",{title:m,"aria-label":`${m}: ${s(a?.[i.key])}`,className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-oai-gray-50/80 dark:bg-oai-gray-900/60 px-2 py-0.5 border border-oai-gray-100/80 dark:border-oai-gray-800/40 text-[10px] font-medium text-oai-gray-600 dark:text-oai-gray-300 transition-colors",children:[e.jsx(pe,{provider:kr(i),size:12,className:"shrink-0 opacity-90"}),e.jsx("span",{className:"tabular-nums",children:o(a?.[i.key])})]},i.key)})})}function _r({entry:a,entryIdx:r,name:o,meLabel:s,currency:l,rate:i,orderedColumns:m,placeholder:b,onOpenProfile:u}){if(a?.is_ellipsis)return e.jsx("div",{"aria-hidden":"true",className:"px-4 py-2 text-center text-xs tracking-[0.4em] text-oai-gray-400 dark:text-oai-gray-600",children:"···"},`mobile-ellipsis-${r}`);const p=!!a?.is_me,j=!p&&ge(a?.display_name),f=typeof a?.user_id=="string"?a.user_id:null,h=!!f,g=p?s:o,A=_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),u(f))};return e.jsxs("div",{role:h?"button":void 0,tabIndex:h?0:void 0,onClick:h?()=>u(f):void 0,onKeyDown:h?A:void 0,"aria-label":h?n("leaderboard.profile_modal.row_aria",{name:g}):void 0,className:d("relative mx-0 my-1 rounded-xl px-3.5 py-3 transition-all duration-200 border shadow-sm select-none",p?"bg-gradient-to-br from-oai-brand-50/70 via-oai-brand-50/20 to-transparent dark:from-oai-brand-950/20 dark:via-oai-brand-950/5 dark:to-transparent border-oai-brand-200/60 dark:border-oai-brand-500/25":j?"bg-white/90 dark:bg-oai-gray-950/90 border-oai-gray-100/70 dark:border-oai-gray-800/40":"bg-white dark:bg-oai-gray-950 border-oai-gray-100 dark:border-oai-gray-800/60",h&&"cursor-pointer hover:border-oai-gray-200 dark:hover:border-oai-gray-700/80 active:scale-[0.985] active:bg-oai-gray-50/60 dark:active:bg-oai-gray-900/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"flex w-5 shrink-0 items-center justify-center",children:e.jsx(jr,{rank:a?.rank,placeholder:b})}),e.jsxs("span",{className:"relative inline-flex shrink-0",children:[e.jsx("span",{className:d("inline-flex rounded-full p-0.5 transition-all duration-300",wr[a?.rank]||"ring-1 ring-oai-gray-200 dark:ring-oai-gray-800/80",j&&"opacity-60 grayscale-[15%]"),children:e.jsx(J,{size:"md",avatarUrl:a?.avatar_url,displayName:g,seed:be(a,g)})}),a?.github_url&&e.jsx(vr,{githubUrl:a.github_url})]}),e.jsxs("div",{className:"min-w-0 flex-1 pl-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:d("min-w-0 truncate text-sm tracking-tight",p?"font-semibold text-oai-black dark:text-oai-white":j?"font-normal text-oai-gray-400 dark:text-oai-gray-500":"font-medium text-oai-gray-800 dark:text-oai-gray-200"),children:g}),e.jsx(ne,{badges:a?.badges,className:"shrink-0 scale-95"})]}),e.jsxs("div",{className:"mt-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:n("leaderboard.column.est_cost")}),e.jsx("span",{className:d("ml-1 tabular-nums font-medium",j?"text-oai-gray-400/80 dark:text-oai-gray-500/80":"text-oai-gray-600 dark:text-oai-gray-300"),children:me(a?.estimated_cost_usd,l,i)})]})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.08em] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.column.total")}),e.jsx("div",{className:d("mt-0.5 text-sm font-semibold tabular-nums tracking-tight",p?"text-oai-black dark:text-oai-white":j?"text-oai-gray-400 dark:text-oai-gray-500":"text-oai-gray-800 dark:text-oai-gray-200"),children:e.jsx(xe,{value:a?.total_tokens})})]})]}),e.jsx(Nr,{entry:a,orderedColumns:m})]},`mobile-row-${a?.rank}-${g}`)}const Sr={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 Ue({rank:a,placeholder:r}){const o=Sr[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 De(a){if(typeof a!="string")return null;const r=a.trim().toLowerCase();return r==="week"||r==="month"||r==="total"?r:null}function Cr(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 ue(a){return typeof a!="string"?"":a.trim()}function ge(a){const r=ue(a);return r?r.toLowerCase()==="anonymous":!0}function be(a,r){const o=typeof a?.user_id=="string"?a.user_id.trim():"";return o||`${a?.rank??""}:${r}`}function Oe({githubUrl:a}){return e.jsxs("span",{className:"absolute left-1/2 top-full -translate-x-1/2 -translate-y-1/2 inline-flex group/gh",children:[e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":n("leaderboard.github.aria"),className:"flex h-4 w-4 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 transition-transform hover:scale-110",children:e.jsx(pe,{provider:"GITHUB",size:14})}),e.jsxs("span",{role:"tooltip",className:"invisible opacity-0 group-hover/gh:visible group-hover/gh:opacity-100 absolute left-0 bottom-full mb-2 whitespace-nowrap rounded-md bg-oai-black dark:bg-oai-gray-700 px-2.5 py-1.5 text-[11px] leading-relaxed text-white shadow-lg transition-opacity duration-150 z-50 before:content-[''] before:absolute before:inset-x-0 before:top-full before:h-2.5",children:[e.jsx("span",{className:"block",children: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(_a,{to:"/settings",onClick:r=>r.stopPropagation(),className:"text-white underline underline-offset-2 decoration-oai-gray-400 hover:text-oai-brand-300 hover:decoration-oai-brand-300",children:n("leaderboard.github.tooltipSettingsLink")})," ",n("leaderboard.github.tooltipSuffix")]})]})]})}function Fr({auth:a,signedIn:r,sessionSoftExpired:o}){const s=ua(),l=ga(),{openLoginModal:i}=ba(),{signedIn:m,loading:b,user:u}=pa(),{currency:p,rate:j}=Ga(),f=c.useMemo(()=>ha(),[]),h=fa(),g=r&&!o,A=c.useMemo(()=>g&&(typeof a=="function"||typeof a=="string"||a&&typeof a=="object")?a:null,[a,g]),_=g?A:null,Q=g&&ya(_),ee=n("shared.placeholder.short"),Ve=c.useMemo(()=>Z.map(t=>t.key),[]),{order:ae,reorder:he}=mr(Ve),fe=c.useMemo(()=>{const t=new Map;for(const x of Z)t.set(x.key,x);return t},[]),B=c.useMemo(()=>ae.map(t=>fe.get(t)).filter(Boolean),[ae,fe]),qe=za(Be(Fa,{activationConstraint:{distance:6}}),Be(Oa,{coordinateGetter:Da})),Je=c.useCallback(t=>{const{active:x,over:w}=t;!w||x.id===w.id||he(String(x.id),String(w.id))},[he]),[re,E]=c.useState(1),[S,Ze]=c.useState(fr),[ye,ke]=c.useState(null),[Xe,we]=c.useState(!1),Y=c.useCallback(t=>{typeof t=="string"&&t.trim()&&ke(t.trim())},[]),Qe=c.useCallback(()=>ke(null),[]),ea=c.useCallback(t=>{const x=de.includes(t)?t:ce;Ze(x),E(1);try{window.localStorage.setItem(We,String(x))}catch{}},[]),[je,aa]=c.useState(0),[ra,ta]=c.useState(()=>ka()),[ve,Ne]=c.useState(!1),N=c.useMemo(()=>{const t=new URLSearchParams(s?.search||"");return De(t.get("period"))||"total"},[s?.search]),oa=t=>{const x=De(t);if(!x||x===N)return;const w=new URLSearchParams(s?.search||"");w.set("period",x),E(1),l(`${s?.pathname||"/leaderboard"}?${w.toString()}`,{replace:!0})};c.useEffect(()=>{b||h||m||i()},[m,b,h,i]),c.useEffect(()=>{E(1)},[N]);const W=c.useMemo(()=>(H(re,{min:1,max:1e6,fallback:1})-1)*S,[re,S]),R=c.useMemo(()=>h?"mock":b?"unavailable":m?"cloud":r?"local":f?"public":"unavailable",[b,m,f,h,r]),k=c.useMemo(()=>wa({accessMode:R,baseUrl:f,mockEnabled:h,userId:u?.id||null,period:N,pageSize:S,offset:W}),[u?.id,R,f,W,h,S,N]),[$,U]=c.useState(()=>{const t=se(k);return t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!1,error:null,data:null,contextKey:null}});c.useEffect(()=>{if(!f&&!h||!h&&R==="unavailable"){U({loading:!1,error:null,data:null,contextKey:null});return}const t=se(k);let x=!0;return U(t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!0,error:null,data:null,contextKey:null}),(async()=>{const w=await ja({userId:u?.id||null,period:N,limit:S,offset:W});x&&(va(w,{activeContextKey:k,contextKey:k,source:je>0?"manual-refresh":"page-load"}),U({loading:!1,error:null,data:w,contextKey:k}))})().catch(w=>{if(!x)return;const T=Cr(w);U(F=>F.contextKey===k?{...F,loading:!1,error:T}:{loading:!1,error:T,data:null,contextKey:k})}),()=>{x=!1}},[f,R,u?.id,k,W,je,h,N,S]);const te=c.useMemo(()=>$.contextKey===k?null:se(k),[k,$.contextKey]),v=c.useMemo(()=>$.contextKey===k?$:te?{loading:!1,error:null,data:te.data,contextKey:k}:{loading:!!(f||h)&&R!=="unavailable",error:null,data:null,contextKey:k},[R,f,k,$,h,te]),C=v.data,D=C?.total_pages??null,sa=C?.total_entries??0,P=C?.page??re,na=c.useMemo(()=>er(P,D),[P,D]),_e=C?.from||null,Se=C?.to||null,Ce=C?.generated_at||null,Le=Ja(),K=C?.me||null,z=n("leaderboard.me_label"),Me=n("leaderboard.anon_label"),Ae=n("leaderboard.period.week"),Te=n("leaderboard.period.month"),Ee=n("leaderboard.period.total"),Pe=N==="month"?Te:N==="total"?Ee:Ae,V=c.useMemo(()=>{const t=Array.isArray(C?.entries)?C.entries:[];return rr({entries:t,me:K,meLabel:z})},[C?.entries,K,z]),I=c.useMemo(()=>tr(K?.rank,S),[K?.rank,S]),ia=I!=null&&I===P,la=c.useCallback(()=>{I!=null&&E(I)},[I]),da=async()=>{Ne(!0);try{La(!0),ta(!0),await Ma(()=>Ie(_));const t=await Ie(_);t&&await Aa({accessToken:t,period:N,source:"leaderboard-enable-sync"}),aa(x=>x+1)}catch(t){console.warn("[tokentracker] sync:",t)}finally{Ne(!1)}},{canPrev:Ke,canNext:Re}=ar({page:P,totalPages:D}),q=Array.isArray(V)&&V.length!==0;let O=null;v.loading&&!q?O=e.jsx(lr,{rows:S}):v.error&&!q?O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v.error})}):q?O=e.jsxs(Ia,{sensors:qe,collisionDetection:Ba,modifiers:[Qa],onDragEnd:Je,children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-full w-full text-left text-sm sm:min-w-max",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(Ge,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:n("leaderboard.column.rank")}),e.jsx("th",{className:d(He,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children: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($a,{items:ae,strategy:Ua,children:B.map(t=>e.jsx(dr,{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(sr,{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:V.map((t,x)=>{if(t?.is_ellipsis){const M=4+B.length;return e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:M,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-${x}`)}const w=!!t?.is_me,T=typeof t?.user_id=="string"?t.user_id:null,F=ue(t?.display_name),ca=ge(F)?Me:F,L=w?z:ca,G=!!T,ze=G?{role:"button",tabIndex:0,onClick:G?()=>Y(T):void 0,onKeyDown:G?M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),Y(T))}:void 0,"aria-label":n("leaderboard.profile_modal.row_aria",{name:L})}:{};if(w){const M=!!t?.is_pinned;return e.jsxs("tr",{...ze,className:d("bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",M?"border-t border-b border-oai-brand-300/40 dark:border-oai-brand-500/20":"border-y border-oai-brand-300/40 dark:border-oai-brand-500/30",G&&"cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsx("td",{className:d(ie(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400",M&&"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(Ue,{rank:t?.rank,placeholder:ee})}),e.jsx("td",{className:le(!0),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:d("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&"gh-avatar-frame"),children:[e.jsx("span",{className:d("inline-flex rounded-full p-px",t?.github_url&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(J,{avatarUrl:t?.avatar_url,displayName:L,seed:be(t,L)})}),t?.github_url&&e.jsx(Oe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:L}),e.jsx(ne,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-medium text-oai-black dark:text-oai-white whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",children:e.jsx(xe,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 font-medium text-oai-brand-600 dark:text-oai-brand-400 whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",title:"Based on estimated API pricing, not actual billing",children:me(t?.estimated_cost_usd,p,j)}),e.jsx($e,{entry:t,isMe:!0,orderedColumns:B})]},`row-${t?.rank}-${L}${M?"-pin":""}`)}return e.jsxs("tr",{...ze,className:d("group transition-colors",G&&"cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsx("td",{className:d(ie(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(Ue,{rank:t?.rank,placeholder:ee})}),e.jsx("td",{className:le(!1),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:d("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&"gh-avatar-frame"),children:[e.jsx("span",{className:d("inline-flex rounded-full p-px",t?.github_url&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(J,{avatarUrl:t?.avatar_url,displayName:L,seed:be(t,L)})}),t?.github_url&&e.jsx(Oe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:L}),e.jsx(ne,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-semibold text-oai-gray-800 dark:text-oai-gray-200 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",children:e.jsx(xe,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",title:"Based on estimated API pricing, not actual billing",children:me(t?.estimated_cost_usd,p,j)}),e.jsx($e,{entry:t,isMe:!1,orderedColumns:B})]},`row-${t?.rank}-${L}`)})})]})}),e.jsx("div",{className:"flex flex-col py-1.5 sm:hidden",children:V.map((t,x)=>{const w=ue(t?.display_name),T=ge(w)?Me:w;return e.jsx(_r,{entry:t,entryIdx:x,name:t?.is_me?z:T,meLabel:z,currency:p,rate:j,orderedColumns:B,placeholder:ee,onOpenProfile:Y},`mobile-${t?.rank??"ellipsis"}-${x}`)})})]}):O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.empty")})});let oe=null;return typeof D=="number"?oe=na.map((t,x)=>t==null?e.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.pagination.ellipsis")},`ellipsis-${x}`):e.jsx("button",{className:d("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",t===P?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white"),onClick:()=>E(t),disabled:v.loading,children:String(t)},`page-${t}`)):oe=e.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.pagination.page_unknown",{page:String(P)})}),e.jsxs("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:[e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-4 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-3.5 sm:mb-8 sm:grid-cols-[minmax(0,1fr)_auto] sm:gap-4",children:[e.jsx("h1",{className:"col-start-1 row-start-1 min-w-0 whitespace-nowrap text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:col-span-2 sm:row-start-1 sm:text-4xl",children:n("leaderboard.title")}),e.jsxs("p",{className:"col-span-2 row-start-2 hidden text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:block sm:row-start-2 sm:text-base",children:[N==="total"?n("leaderboard.range.total"):_e&&Se?n("leaderboard.range",{period:Pe,from:_e,to:Se}):n("leaderboard.range_loading",{period:Pe}),Ce&&e.jsx("span",{className:"ml-2 hidden border-l border-oai-gray-200 pl-2 text-xs text-oai-gray-400 dark:border-oai-gray-800 dark:text-oai-gray-500 sm:inline-block",children:n("leaderboard.generated_at",{ts:Ce})})]}),e.jsx("div",{className:"col-start-2 row-start-1 inline-flex h-9 shrink-0 items-center rounded-full border border-oai-gray-200 p-1 dark:border-oai-gray-800 sm:col-start-1 sm:row-start-3 sm:justify-self-start",children:["week","month","total"].map(t=>{const x=N===t;return e.jsxs("button",{onClick:()=>oa(t),disabled:v.loading,className:d("px-3 sm:px-4 h-7 text-sm font-medium rounded-full flex items-center justify-center transition-colors relative",x?"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"?Ae:t==="month"?Te:Ee}),x&&e.jsx(Na.div,{layoutId:"leaderboard-period-active-bg",className:"absolute inset-0 bg-oai-gray-200 dark:bg-oai-gray-800 rounded-full z-0",transition:{type:"spring",stiffness:380,damping:30}})]},t)})}),e.jsxs("div",{className:"col-span-2 row-start-2 mb-0 flex w-full min-w-0 items-center justify-between sm:justify-end gap-2.5 sm:col-span-1 sm:col-start-2 sm:row-start-3 sm:mb-0 sm:w-auto sm:shrink-0",children:[e.jsx(yr,{communityStats:Le,onClick:()=>we(!0)}),e.jsx(br,{me:K,totalEntries:sa,meLabel:z,onOpenProfile:K?.user_id?()=>Y(K.user_id):void 0,onJumpToMe:la,canJump:I!=null&&!ia&&!v.loading,className:"shrink-0"})]})]}),!r&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.signin_prompt")}),e.jsx("button",{onClick:i,className:"shrink-0 whitespace-nowrap self-start sm:self-auto px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 transition-colors",children:n("leaderboard.signin_button")})]}),g&&Q&&!ra&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.sync_prompt")}),e.jsx("button",{onClick:da,disabled:ve,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:ve?n("leaderboard.sync_button.busy"):n("leaderboard.sync_button.idle")})]}),e.jsxs("div",{className:"sm:rounded-xl sm:border sm:border-oai-gray-200 sm:dark:border-oai-gray-800 sm:overflow-hidden border-none bg-transparent",children:[v.error&&q?e.jsx("div",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-3",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v.error})}):null,O,e.jsxs("div",{className:"flex flex-col gap-3 sm:border-t border-oai-gray-200 px-4 py-3 sm:flex-row sm:items-center sm:justify-end sm:gap-x-4 sm:px-6 dark:border-oai-gray-800 border-none mt-2.5 sm:mt-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:justify-start",children:[e.jsx("label",{htmlFor:"leaderboard-page-size",className:"whitespace-nowrap",children:n("leaderboard.pagination.page_size_label")}),e.jsx(Ea,{id:"leaderboard-page-size",value:S,onValueChange:t=>ea(Number(t)),disabled:v.loading,ariaLabel:n("leaderboard.pagination.page_size_label"),options:de.map(t=>({value:t,label:String(t)})),align:"end",className:"px-3 py-1 text-oai-gray-700 dark:text-oai-gray-300"})]}),e.jsx("div",{className:"hidden h-5 w-px bg-oai-gray-200 dark:bg-oai-gray-800 sm:block","aria-hidden":"true"}),e.jsxs("div",{className:"flex w-full items-center justify-between sm:w-auto sm:justify-end gap-1.5",children:[e.jsx("button",{className:d("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Ke&&!v.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>E(t=>Math.max(1,t-1)),disabled:!Ke||v.loading,children:n("leaderboard.pagination.prev")}),e.jsxs("span",{className:"text-xs font-semibold tabular-nums text-oai-gray-500 dark:text-oai-gray-455 px-2 sm:hidden",children:[P," / ",D||"?"]}),e.jsx("div",{className:"hidden sm:flex items-center gap-1",children:oe}),e.jsx("button",{className:d("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Re&&!v.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>E(t=>t+1),disabled:!Re||v.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(c.Suspense,{fallback:null,children:[e.jsx(pr,{isOpen:!!ye,userId:ye,period:N,accessToken:_,onClose:Qe}),e.jsx(hr,{isOpen:Xe,onClose:()=>we(!1),communityStats:Le})]})]})}export{Fr as LeaderboardPage};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BadgeDetailModal-FyvUrVvF.js","assets/__vite-browser-external-Eoyj4eG-.js","assets/__vite-browser-external-C7JwykID.css","assets/AchievementBadge-D6iPEEbz.js","assets/zap-DWWma29E.js","assets/flame-vLBOq0X0.js","assets/use-transform-lflyghWN.js","assets/AchievementsSection-ah-kG00E.js","assets/format-tokens-C6Pidz3s.js","assets/DialogTitle-z86PHHyk.js","assets/useScrollLock-C2C-Yazq.js"])))=>i.map(i=>d[i]);
import{k as te,e as O,r as h,a9 as se,j as e,c as n,aa as ie,ab as oe,ac as ne,b as c,ad as le,N as de,L as ce,R as W,Q as me,l as xe,ae as ge,P as $,X as pe,i as he,_ as ue,af as fe,ag as be}from"./__vite-browser-external-Eoyj4eG-.js";import{A as ye,f as ke}from"./provider-display-CKbOKeV4.js";import{u as ve}from"./useCurrency-BtHtcsO5.js";import{u as G}from"./useTokenFormat-BdD057ih.js";import{L as X}from"./LeaderboardAvatar-CaOV_hFE.js";import{H as je,A as Y,s as Ne,c as _e,b as we,t as Ae,h as Se}from"./AchievementBadge-D6iPEEbz.js";import{A as ze}from"./AchievementsSection-ah-kG00E.js";import{A as B}from"./arrow-up-right-CT4-gmOS.js";import{L as Ce}from"./link-2-DeN6MJpT.js";import{C as Me}from"./check-B87_qvAg.js";import{D as Ie,a as Pe,b as De,c as Le,d as Te,e as $e}from"./DialogTitle-z86PHHyk.js";import"./terminal-DyicX7lG.js";import"./info-B46Qt16h.js";import"./zap-DWWma29E.js";import"./flame-vLBOq0X0.js";import"./format-tokens-C6Pidz3s.js";import"./useScrollLock-C2C-Yazq.js";const Be=[["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"}]],Ue=te("code-xml",Be),U="tokentracker_anon_id";let A=null;function R(){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 F(){if(A)return A;try{let a=localStorage.getItem(U);return a||(a=R(),localStorage.setItem(U,a)),A=a,a}catch{return A=R(),A}}function K({userId:a}){const{signedIn:r,getAccessToken:i}=O(),[t,s]=h.useState(!1),[l,x]=h.useState(0),[o,g]=h.useState(!1),[f,b]=h.useState(!1),[S,z]=h.useState(!1),[C,D]=h.useState([]),[j,N]=h.useState(!1),M=h.useRef(0),y=h.useCallback(async()=>{if(r)try{const d=await i();if(d)return{accessToken:d,anonId:F()}}catch{}return{anonId:F()}},[r,i]);h.useEffect(()=>{let d=!1;return a?(g(!1),(async()=>{const m=await y();try{const p=await se({userId:a,...m});if(d)return;x(Number(p?.count)||0),s(!!p?.liked),g(!0)}catch{if(d)return;x(0),s(!1),g(!0)}})(),()=>{d=!0}):(g(!1),()=>{d=!0})},[a,y]);const k=()=>{z(!0),setTimeout(()=>z(!1),450),N(!0),setTimeout(()=>N(!1),500);const d=["#ff4757","#ff6b81","#ffa502","#70a1ff","#2ed573","#a29bfe"],m=["circle","heart"],p=[];for(let u=0;u<12;u++){const v=(u*30+Math.random()*20-10)*(Math.PI/180),I=45+Math.random()*45,V=Math.cos(v)*I,Z=Math.sin(v)*I-(10+Math.random()*15),Q=Math.random()*360-180,J=6+Math.random()*8,ee=d[Math.floor(Math.random()*d.length)],ae=m[Math.floor(Math.random()*m.length)],re=++M.current;p.push({id:re,tx:V,ty:Z,rot:Q,size:J,color:ee,shape:ae})}D(u=>[...u,...p]),setTimeout(()=>{D(u=>u.filter(v=>!p.find(I=>I.id===v.id)))},850)},_=async d=>{b(!0);try{const m=await y(),p=await ie({userId:a,action:d,...m});p&&Number.isFinite(Number(p.count))&&x(Number(p.count)),p&&typeof p.liked=="boolean"&&s(p.liked)}catch{s(m=>!m),x(m=>d==="like"?Math.max(0,m-1):m+1)}finally{b(!1)}},w=d=>{d.stopPropagation(),!(!a||!o||f)&&(t?(s(!1),x(m=>Math.max(0,m-1)),_("unlike")):(s(!0),x(m=>m+1),k(),_("like")))};return e.jsxs("div",{className:"relative inline-flex items-center select-none z-10",children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:`
@keyframes tt-like-pop {
0% { transform: scale(1); }
25% { transform: scale(0.75); }
50% { transform: scale(1.35); }
75% { transform: scale(0.9); }
100% { transform: scale(1); }
}
@keyframes tt-particle-fly {
0% {
transform: translate(0, 0) scale(1) rotate(0deg);
opacity: 1;
}
70% {
opacity: 0.8;
}
100% {
transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rot));
opacity: 0;
}
}
@keyframes tt-num-scroll {
0% { transform: translateY(8px); opacity: 0; }
100% { transform: translateY(0); opacity: 1; }
}
.tt-animate-pop {
animation: tt-like-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.tt-particle {
position: absolute;
top: 50%;
left: 50%;
margin-top: -6px;
margin-left: -6px;
pointer-events: none;
z-index: 50;
}
.tt-num-anim {
animation: tt-num-scroll 0.25s ease-out forwards;
}
`}}),C.map(d=>e.jsx("span",{className:"tt-particle",style:{"--tx":`${d.tx}px`,"--ty":`${d.ty}px`,"--rot":`${d.rot}deg`,width:`${d.size}px`,height:`${d.size}px`,backgroundColor:d.shape==="circle"?d.color:"transparent",borderRadius:d.shape==="circle"?"50%":"0",animation:"tt-particle-fly 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards"},children:d.shape==="heart"&&e.jsx("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:d.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"})})},d.id)),e.jsxs("button",{type:"button",onClick:w,disabled:!o||f,"aria-label":t?n("leaderboard.profile.like.aria_unlike"):n("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:S?"tt-animate-pop":"group-active:scale-90 transition-transform duration-100",children:e.jsx(je,{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"} ${j?"tt-num-anim":""}`,children:o?l:"·"})]})]})}function Re({badge:a,badgeLabel:r,className:i="",...t}){return e.jsxs("div",{className:`relative inline-flex shrink-0 ${i}`,children:[e.jsx(X,{...t}),a?e.jsx("span",{className:"absolute -bottom-1 -right-1 inline-flex rounded-full ring-2 ring-white dark:ring-oai-gray-950",children:e.jsx(Y,{badgeId:a.id,tier:a.tier,size:"sm",label:r})}):null]})}function Fe({badges:a,isOwn:r=!1,onSelect:i,className:t=""}){const s=Ne((Array.isArray(a)?a:[]).filter(l=>l&&_e.has(l.id))).filter(l=>r||(l.tier||0)>=1);return s.length===0?null:e.jsx("div",{className:`flex flex-wrap items-center pr-2.5 ${t}`,children:s.map((l,x)=>{const o=(l.tier||0)>=1,g=n(we(l.id,"name")),f=o?n(`achievements.tier.${Ae(l.tier)}`):n("achievements.modal.locked");return e.jsx("button",{type:"button",onClick:i?()=>i(l):void 0,title:`${g} · ${f}`,"aria-label":n("achievements.badge.aria",{name:g,tier:f}),style:{zIndex:s.length-x},className:"group relative shrink-0 -mr-2.5 rounded-full transition-transform duration-200 ease-out hover:z-30 hover:-translate-y-1 active:scale-95 focus-visible:z-30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60",children:e.jsx(Y,{badgeId:l.id,tier:l.tier,locked:!o,size:"md",className:"rounded-full ring-2 ring-white transition-shadow duration-200 group-hover:shadow-md dark:ring-oai-gray-950"})},l.id)})})}const He=W.lazy(()=>ue(()=>import("./BadgeDetailModal-FyvUrVvF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])));function Ee(a,r,i){const t=Number(a);return!Number.isFinite(t)||t<0?"—":t>0&&t<.01?`<${r==="USD"?"$":""}0.01`:fe(t,{decimals:2,currency:r,rate:i})}function H(a,r,i){const t=Number(a);if(!Number.isFinite(t)||t<0)return"—";if(t<1e3)return Ee(t,r,i);const s=r==="USD"?t:t*(i||1);return`${r==="USD"?"$":""}${he(s,{decimals:1})}`}function Oe(a){const r=Array.isArray(a)?a:[];if(r.length===0)return null;const i=r.map(s=>({day:s.date,total_tokens:s.total_tokens,models:s.models||null})),t=r[r.length-1]?.date;return ge({dailyRows:i,weeks:52,to:t})}const We=`
@keyframes tt-shimmer {
100% { transform: translateX(100%); }
}
.tt-shimmer-bar {
position: relative;
overflow: hidden;
}
.tt-shimmer-bar::after {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
transform: translateX(-100%);
background-image: linear-gradient(
90deg,
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.02) 20%,
rgba(0, 0, 0, 0.06) 60%,
rgba(0, 0, 0, 0) 100%
);
animation: tt-shimmer 1.6s infinite;
content: '';
}
.dark .tt-shimmer-bar::after {
background-image: linear-gradient(
90deg,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 0.02) 20%,
rgba(255, 255, 255, 0.06) 60%,
rgba(255, 255, 255, 0) 100%
);
}
`;function Ge({variant:a="modal"}){const r="rounded bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar",i=a==="page";return e.jsxs("div",{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:We}}),i?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:c(r,"h-7 w-48")}),e.jsx("div",{className:c(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:c(r,"h-2.5 w-8")}),e.jsx("div",{className:c(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:c(r,"h-4 w-40")}),e.jsx("div",{className:c(r,"h-3 w-56")})]}),e.jsx("div",{className:c(r,"h-4 w-4 shrink-0 mt-1")})]}),e.jsxs("div",{className:c("space-y-6",i?"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,s)=>e.jsxs("div",{children:[e.jsx("div",{className:c(r,"h-6 w-20")}),e.jsx("div",{className:c(r,"mt-2 h-3 w-14")})]},s))}),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,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-3 w-24")}),e.jsx("div",{className:c(r,"h-3 w-44")})]},s))}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(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,s)=>e.jsx("div",{className:"aspect-square rounded-[2px] bg-oai-gray-200/40 dark:bg-oai-gray-800/30 tt-shimmer-bar"},s))})]}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-28 mb-3")}),e.jsx("div",{className:"space-y-2.5",children:Array.from({length:5}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-4 w-4")}),e.jsx("div",{className:c(r,"h-3 w-16")}),e.jsx("div",{className:c(r,"h-[3px] flex-1")}),e.jsx("div",{className:c(r,"h-3 w-12")})]},s))})]})]})]})}function q(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 L({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 P({value:a,label:r,title:i}){return e.jsxs("div",{children:[e.jsx("div",{title:i,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 T({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 Xe({user:a,onClose:r}){const i=q(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(X,{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:c("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:n("leaderboard.profile_modal.rank",{rank:a.rank})}):null]}),i&&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($,{provider:"GITHUB",size:11}),e.jsxs("span",{children:["@",i]})]})]}),a?.user_id&&e.jsx("div",{className:"shrink-0 flex items-center justify-center",children:e.jsx(K,{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":n("leaderboard.profile_modal.close"),children:e.jsx(pe,{size:16,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:rotate-90 group-active:scale-90"})})]})}function Ye({user:a,topBadge:r}){const i=q(a?.github_url),t=Number(a?.rank)||0,s=t===1?"text-amber-500 dark:text-amber-400":t===2?"text-slate-500 dark:text-slate-300":t===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(Re,{badge:r,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 rounded-full"}),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(K,{userId:a.user_id})]}),i?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($,{provider:"GITHUB",size:13}),e.jsxs("span",{children:["@",i]})]}):null]}),t?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:n("leaderboard.profile.hero.rank_label")}),e.jsx("div",{className:c("mt-1.5 text-3xl font-black tabular-nums tracking-tight",s),children:n("leaderboard.profile_modal.rank",{rank:t})})]}):null]})]})}function Ke({data:a}){const{formatTokens:r,formatTokensTooltip:i}=G(),t=Array.isArray(a)?a:[];return t.length===0?e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.profile_modal.providers.none")}):e.jsx("ul",{className:"space-y-2",children:t.map(s=>{const l=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($,{provider:String(s.source).toUpperCase(),size:14})}),e.jsx("span",{className:"w-20 shrink-0 text-oai-gray-700 dark:text-oai-gray-300",children:ke(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:`${(l*100).toFixed(1)}%`}})}),e.jsx("span",{title:i(s.total_tokens),className:"shrink-0 w-14 text-right tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:r(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:[(l*100).toFixed(0),"%"]})]},s.source)})})}function E({icon:a,label:r,value:i}){const[t,s]=h.useState(!1),l=async()=>{await be(i)&&(s(!0),setTimeout(()=>s(!1),1600))};return e.jsxs("button",{type:"button",onClick:l,className:c("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(Me,{size:13,strokeWidth:2,"aria-hidden":!0}):e.jsx(a,{size:13,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t?n("leaderboard.profile_modal.badge.copied"):r})]})}function qe({data:a,currency:r,rate:i,onClose:t,variant:s="modal"}){const{formatTokens:l,formatTokensTooltip:x}=G(),{user:o,totals:g,streak:f,best_day:b,models:S,by_provider:z,heatmap:C,period:D}=a,j=s==="page",N=h.useMemo(()=>Oe(C),[C]),M=S?.favorite?.model_name,y=Number(S?.count)||0,k=Array.isArray(a.badges)?a.badges:[],[_,w]=h.useState(null),d=O(),m=!!(d?.user?.id&&o?.user_id&&d.user.id===o.user_id),p=o?.user_id?`https://www.tokentracker.cc/u/${o.user_id}`:null,u=o?.user_id?`[![My AI coding usage](${le()}/functions/tokentracker-embed-svg?user_id=${o.user_id}&theme=dark)](${p}?ref=readme)`:null;return e.jsxs(e.Fragment,{children:[j?e.jsx(Ye,{user:o,topBadge:Se(k)}):e.jsx(Xe,{user:o,onClose:t}),e.jsxs("div",{className:c("space-y-6",j?"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(P,{value:l(g?.total_tokens),title:x(g?.total_tokens),label:n("leaderboard.profile_modal.stat.total_tokens")}),e.jsx(P,{value:H(g?.estimated_cost_usd,r,i),label:n("leaderboard.profile_modal.stat.total_cost")}),e.jsx(P,{value:String(g?.active_days??0),label:n("leaderboard.profile_modal.stat.active_days")}),e.jsx(P,{value:H(g?.avg_per_day_usd,r,i),label:n("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(T,{label:n("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:n("leaderboard.profile_modal.streak.days",{count:f?.current_days??0})}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["(max ",f?.longest_days??0,")"]})]}),e.jsx(T,{label:n("leaderboard.profile_modal.best_day.title"),children:b?e.jsxs(e.Fragment,{children:[e.jsx("span",{title:x(b.total_tokens),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:l(b.total_tokens)}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["on ",b.date]})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:n("leaderboard.profile_modal.best_day.none")})}),e.jsx(T,{label:n("leaderboard.profile_modal.models.favorite"),children:M?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:M}),y>1&&e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:n("leaderboard.profile_modal.models.count",{count:y})})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:n("leaderboard.profile_modal.models.none")})})]}),(m||k.some(v=>(v?.tier||0)>=1))&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(L,{children:n("achievements.section.title")}),j?e.jsx(ze,{achievements:k,isOwn:m&&!!a.badges_include_unearned,scope:"cloud",onSelect:w}):e.jsx(Fe,{badges:k,isOwn:m&&!!a.badges_include_unearned,onSelect:w})]}),N&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(L,{children:n("leaderboard.profile_modal.heatmap.title")}),e.jsx("div",{className:"min-w-0",children:e.jsx(ye,{heatmap:N,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(L,{children:n("leaderboard.profile_modal.providers.title")}),e.jsx(Ke,{data:z})]}),o?.user_id&&(t||m)&&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&&(de()?e.jsxs("a",{href:p,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:n("leaderboard.profile_modal.view_full")}),e.jsx(B,{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(ce,{to:`/u/${o.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:n("leaderboard.profile_modal.view_full")}),e.jsx(B,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})),m&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{icon:Ce,label:n("leaderboard.profile_modal.badge.copy_url"),value:p}),e.jsx(E,{icon:Ue,label:n("leaderboard.profile_modal.badge.copy"),value:u})]})]})]}),_&&e.jsx(W.Suspense,{fallback:null,children:e.jsx(He,{badge:_,onClose:()=>w(null)})})]})}function Ve({userId:a,period:r,accessToken:i,enabled:t=!0}){const[s,l]=h.useState({loading:!1,error:null,data:null});return h.useEffect(()=>{if(!t||!a)return;let x=!0;return l({loading:!0,error:null,data:null}),(async()=>{try{const o=i?await oe(i):null;if(!x)return;const g=await ne({accessToken:o,userId:a,period:r||"week"});if(!x)return;l({loading:!1,error:null,data:g})}catch(o){if(!x)return;o?.status===404?l({loading:!1,error:null,data:null}):l({loading:!1,error:o?.message||String(o),data:null})}})(),()=>{x=!1}},[t,a,r,i]),s}function pa({isOpen:a,onClose:r,userId:i,period:t,accessToken:s}){const{currency:l,rate:x}=ve(),o=Ve({userId:i,period:t,accessToken:s,enabled:a});return e.jsx(Ie,{open:a,onOpenChange:g=>{g||r?.()},children:e.jsxs(Pe,{children:[e.jsx(De,{className:"cost-modal-backdrop"}),e.jsx(Le,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(Te,{className:c("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($e,{render:e.jsx("h2",{className:"sr-only"}),children:o.data?.user?.display_name||n("leaderboard.profile_modal.loading")}),o.loading&&e.jsx(Ge,{}),!o.loading&&o.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:n("leaderboard.profile_modal.error")})}),!o.loading&&!o.error&&!o.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:n("leaderboard.profile_modal.empty")})}),!o.loading&&!o.error&&o.data&&e.jsx(me,{mode:xe.COMPACT,children:e.jsx(qe,{data:o.data,currency:l,rate:x,onClose:r})})]})})]})})}export{pa as LeaderboardProfileModal,qe as ProfileContent,Ge as ProfileSkeleton,Ve as useLeaderboardProfileData};
import{r as _,j as p,S as xe,U as ge,e as ve,N as be,L as Tt,V as we,c as Y,W as ye}from"./__vite-browser-external-Eoyj4eG-.js";import{u as ke}from"./useCurrency-BtHtcsO5.js";import{H as Me}from"./HeaderGithubStar-DE1USQbb.js";import{useLeaderboardProfileData as _e,ProfileSkeleton as Ce,ProfileContent as Se}from"./LeaderboardProfileModal-DtNEbVH8.js";import{D as Te}from"./download-DaWsA_Gj.js";import"./provider-display-CKbOKeV4.js";import"./useTokenFormat-BdD057ih.js";import"./terminal-DyicX7lG.js";import"./info-B46Qt16h.js";import"./LeaderboardAvatar-CaOV_hFE.js";import"./AchievementBadge-D6iPEEbz.js";import"./zap-DWWma29E.js";import"./flame-vLBOq0X0.js";import"./AchievementsSection-ah-kG00E.js";import"./format-tokens-C6Pidz3s.js";import"./arrow-up-right-CT4-gmOS.js";import"./link-2-DeN6MJpT.js";import"./check-B87_qvAg.js";import"./DialogTitle-z86PHHyk.js";import"./useScrollLock-C2C-Yazq.js";function $e(t){let e=t.replace("#","");return e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255]}function Re(t,e,a){t/=255,e/=255,a/=255;const r=Math.max(t,e,a),o=Math.min(t,e,a),n=r-o;let i=0;const u=r===0?0:n/r;return n!==0&&(r===t?i=((e-a)/n+6)%6:r===e?i=(a-t)/n+2:i=(t-e)/n+4,i/=6),[i,u,r]}function Fe(t,e,a){const r=Math.floor(t*6),o=t*6-r,n=a*(1-e),i=a*(1-o*e),u=a*(1-(1-o)*e);let l=0,c=0,h=0;switch(r%6){case 0:l=a,c=u,h=n;break;case 1:l=i,c=a,h=n;break;case 2:l=n,c=a,h=u;break;case 3:l=n,c=i,h=a;break;case 4:l=u,c=n,h=a;break;case 5:l=a,c=n,h=i;break}return[Math.round(l*255),Math.round(c*255),Math.round(h*255)]}const Ie=66,Oe=66,Pe=1500,Ae=1,$t=16,je=16,Ee=8,Le=96,Ne=2,We={name:"chromatic",modes:{dark:{colors:["#000000","#aae8ff","#c5fe9e","#f7888d","#0d0d0d","#fffdc3","#007cff"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:1.6,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.26,vigOpacity:.6,shaderOpacity:1},light:{colors:["#ffffff","#ffffff","#ffffff","#ffb3b3","#adadad","#f5ff70","#007cff"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.24,vigOpacity:.16,shaderOpacity:1}}},Be={name:"silver",modes:{dark:{colors:["#000000","#dedede","#747270","#e5e5e5","#0d0d0d","#ffffff","#e6e6e6"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.26,vigOpacity:.6,shaderOpacity:.88},light:{colors:["#f6f6f6","#ffffff","#ffffff","#f7f7f7","#c9c9c9","#d0d0d0","#d1d1d1"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.2,vigOpacity:.26,shaderOpacity:1}}},ze={name:"gold",modes:{dark:{colors:["#000000","#ffffff","#ffffff","#f7d488","#0d0d0d","#fffdc3","#ffffff"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.26,vigOpacity:.6,shaderOpacity:.92},light:{colors:["#fff8e1","#fffbe0","#ffffff","#fff6d6","#d2c7a7","#dcd2bc","#f9f7e5"],alphas:[1,1,1,1,1,1,1],direction:80,speed:1.2,intensity:2,scale:2.5,softness:.18,distortion:.3,complexity:.68,shape:1,blur:1,vignette:.22,vigOpacity:.24,shaderOpacity:1}}},Xt={chromatic:We,silver:Be,gold:ze},He=`
attribute vec2 a_position;
void main() { gl_Position = vec4(a_position, 0.0, 1.0); }
`,Ge=`
precision highp float;
uniform vec2 u_resolution;
uniform float u_time;
uniform vec3 u_color1, u_color2, u_color3, u_color4, u_color5, u_color6, u_color7;
uniform float u_alpha1, u_alpha2, u_alpha3, u_alpha4, u_alpha5, u_alpha6, u_alpha7;
uniform float u_intensity, u_scale, u_direction;
uniform float u_softness, u_distortion, u_complexity, u_shape;
uniform float u_vignette, u_vigOpacity, u_blur, u_shaderOpacity;
vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec2 mod289v2(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec3 permute(vec3 x) { return mod289((x * 34.0 + 1.0) * x); }
float snoise(vec2 v) {
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
-0.577350269189626, 0.024390243902439);
vec2 i = floor(v + dot(v, C.yy));
vec2 x0 = v - i + dot(i, C.xx);
vec2 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
vec4 x12 = x0.xyxy + C.xxzz;
x12.xy -= i1;
i = mod289v2(i);
vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));
vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);
m = m * m; m = m * m;
vec3 x_ = 2.0 * fract(p * C.www) - 1.0;
vec3 h = abs(x_) - 0.5;
vec3 ox = floor(x_ + 0.5);
vec3 a0 = x_ - ox;
m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
vec3 g;
g.x = a0.x * x0.x + h.x * x0.y;
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
return 130.0 * dot(m, g);
}
float fbm(vec2 p, float oct) {
float val = 0.0, amp = 0.5;
int n = int(oct);
for (int i = 0; i < 7; i++) {
if (i >= n) break;
val += amp * snoise(p);
p *= 2.0;
amp *= 0.5;
}
return val;
}
float nfbm(vec2 p) { return fbm(p, 3.0 + u_complexity * 4.0); }
/* 5-stop palette used by effect 1 (Plasma) — direct port of \`palette\` from
* the canonical engine. Stops at t = 0, 0.25, 0.5, 0.75, 1.0. */
vec3 palette(float t) {
t = clamp(t, 0.0, 1.0);
t = t * t * (3.0 - 2.0 * t);
float k = 64.0;
float w1 = u_alpha1 * exp(-k * t * t);
float w2 = u_alpha2 * exp(-k * (t - 0.25) * (t - 0.25));
float w3 = u_alpha3 * exp(-k * (t - 0.5) * (t - 0.5));
float w4 = u_alpha4 * exp(-k * (t - 0.75) * (t - 0.75));
float w5 = u_alpha5 * exp(-k * (t - 1.0) * (t - 1.0));
float total = w1 + w2 + w3 + w4 + w5 + 0.0001;
return (u_color1 * w1 + u_color2 * w2 + u_color3 * w3 +
u_color4 * w4 + u_color5 * w5) / total;
}
/* Per-pixel alpha that re-introduces transparency when the user dials any
* palette stop's alpha below 1. Same \`paletteAlpha\` from the canonical
* engine. With every preset shipping all-1 alphas, this returns ~1 for every
* pixel — but mirroring it keeps custom-preset behaviour identical. */
float paletteAlpha(float t) {
t = clamp(t, 0.0, 1.0);
t = t * t * (3.0 - 2.0 * t);
float k = 64.0;
float w1 = u_alpha1 * exp(-k * t * t);
float w2 = u_alpha2 * exp(-k * (t - 0.25) * (t - 0.25));
float w3 = u_alpha3 * exp(-k * (t - 0.5) * (t - 0.5));
float w4 = u_alpha4 * exp(-k * (t - 0.75) * (t - 0.75));
float w5 = u_alpha5 * exp(-k * (t - 1.0) * (t - 1.0));
float totalW = w1 + w2 + w3 + w4 + w5 + 0.0001;
float rawW = exp(-k * t * t)
+ exp(-k * (t - 0.25) * (t - 0.25))
+ exp(-k * (t - 0.5) * (t - 0.5))
+ exp(-k * (t - 0.75) * (t - 0.75))
+ exp(-k * (t - 1.0) * (t - 1.0))
+ 0.0001;
return totalW / rawW;
}
vec2 warp(vec2 p, float t) {
float str = u_distortion * 2.0;
return vec2(
nfbm(p + vec2(t * 0.1, 0.0)),
nfbm(p + vec2(0.0, t * 0.12) + 5.0)
) * str;
}
/* Plasma: four sine bands warped by an FBM field, mapped through the
* 5-stop palette. Identical to effect 1 in the canonical engine. */
vec3 computeEffect(vec2 uv, float aspect, float t, float dist, float cpx) {
vec2 p = (uv - 0.5) * u_scale;
p.x *= aspect;
p += vec2(cos(u_direction), sin(u_direction)) * t * 0.15;
float freq = 3.0 + cpx * 8.0;
float val = 0.0;
val += sin(p.x * freq + t);
val += sin(p.y * freq + t * 1.3);
val += sin((p.x + p.y) * freq * 0.7 + t * 0.7);
val += sin(length(p) * freq * 0.8 - t * 1.5);
vec2 w = warp(p, t);
val += (w.x + w.y) * dist;
val = val * 0.2 * u_intensity + 0.5;
return palette(clamp(val, 0.0, 1.0));
}
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution;
float aspect = u_resolution.x / u_resolution.y;
float t = u_time; // JS already multiplied u_time by preset.speed.
float dist = u_distortion;
float cpx = u_complexity;
/* 5-tap cross blur (center + cardinal offsets). The chromatic/silver/gold
* presets all ship with blur=1 so this path is always active. 5 taps
* instead of the canonical engine's 9 saves ~44% fragment work; the
* perceptual difference is nil because the output is already soft from
* the plasma's low spatial frequency and CSS blur on reflections. */
vec3 col;
if (u_blur < 0.01) {
col = computeEffect(uv, aspect, t, dist, cpx);
} else {
float r = u_blur * 0.02;
col = computeEffect(uv, aspect, t, dist, cpx) * 0.4;
col += computeEffect(uv + vec2( r, 0.0), aspect, t, dist, cpx) * 0.15;
col += computeEffect(uv + vec2(-r, 0.0), aspect, t, dist, cpx) * 0.15;
col += computeEffect(uv + vec2(0.0, r), aspect, t, dist, cpx) * 0.15;
col += computeEffect(uv + vec2(0.0, -r), aspect, t, dist, cpx) * 0.15;
}
/* Gamma punch — adds the contrast pop that defines the chromatic
* highlights. From the canonical engine: \`col = pow(col, vec3(1.3))\`. */
col = pow(col, vec3(1.3));
/* Vignette — soft edge darkening so corners read as recessed. The 40-px
* scale at the bottom of the formula is hard-coded in the canonical
* engine; we keep it for visual parity. */
float edgeDist = min(min(uv.x, 1.0 - uv.x), min(uv.y, 1.0 - uv.y));
float vigPx = 40.0 / min(u_resolution.x, u_resolution.y);
float vigRange = vigPx * (1.0 + u_vignette * 3.0);
float vig = edgeDist * edgeDist / (vigRange * vigRange);
vig = smoothstep(0.0, 1.0, vig);
col *= mix(1.0, vig, u_vignette * u_vigOpacity);
/* Per-pixel alpha. With all-1 alphas the formula collapses to ~1 but the
* computation matches the canonical engine so custom presets behave the
* same. */
float colorAlpha = (u_alpha1 + u_alpha2 + u_alpha3 + u_alpha4 + u_alpha5) / 5.0;
if (colorAlpha < 0.999) {
vec3 c1d = col - u_color1, c2d = col - u_color2, c3d = col - u_color3,
c4d = col - u_color4, c5d = col - u_color5;
float prox1 = exp(-8.0 * dot(c1d, c1d));
float prox2 = exp(-8.0 * dot(c2d, c2d));
float prox3 = exp(-8.0 * dot(c3d, c3d));
float prox4 = exp(-8.0 * dot(c4d, c4d));
float prox5 = exp(-8.0 * dot(c5d, c5d));
float pTotal = prox1 + prox2 + prox3 + prox4 + prox5 + 0.0001;
colorAlpha = (prox1 * u_alpha1 + prox2 * u_alpha2 + prox3 * u_alpha3 +
prox4 * u_alpha4 + prox5 * u_alpha5) / pTotal;
}
float alpha = colorAlpha;
/* Touch the unused-at-effect-1 uniforms so GL drivers that complain about
* declared-but-unread uniforms (some Mali / Adreno builds do) keep them
* live. The contribution is provably zero. */
alpha += 0.0 * (u_softness + u_shape +
u_alpha6 + u_alpha7 +
u_color6.x + u_color7.x);
gl_FragColor = vec4(col, alpha * u_shaderOpacity);
}
`;function Rt(t,e,a){const r=t.createShader(e);if(!r)throw new Error("metal-fx: gl.createShader returned null");if(t.shaderSource(r,a),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS)){const o=t.getShaderInfoLog(r);throw t.deleteShader(r),new Error(`metal-fx: shader compile failed: ${o??"(no info log)"}`)}return r}function De(t,e,a){const r=t.createProgram();if(!r)throw new Error("metal-fx: gl.createProgram returned null");if(t.attachShader(r,e),t.attachShader(r,a),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS)){const o=t.getProgramInfoLog(r);throw t.deleteProgram(r),new Error(`metal-fx: program link failed: ${o??"(no info log)"}`)}return r}const Yt=140,Kt=40,Zt=1.6,Jt=1.3;let s=null,bt=null;function Ue(t){bt=t}const qe=["u_resolution","u_time","u_color1","u_color2","u_color3","u_color4","u_color5","u_color6","u_color7","u_alpha1","u_alpha2","u_alpha3","u_alpha4","u_alpha5","u_alpha6","u_alpha7","u_intensity","u_scale","u_direction","u_softness","u_distortion","u_complexity","u_shape","u_vignette","u_vigOpacity","u_blur","u_shaderOpacity"];function Ft(t){t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA);const e=Rt(t,t.VERTEX_SHADER,He),a=Rt(t,t.FRAGMENT_SHADER,Ge),r=De(t,e,a);t.useProgram(r);const o=t.createBuffer();if(!o)throw new Error("metal-fx: gl.createBuffer returned null");t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),t.STATIC_DRAW);const n=t.getAttribLocation(r,"a_position");t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0);const i={};for(const u of qe)i[u]=t.getUniformLocation(r,u);return{program:r,buffer:o,uniforms:i}}function te(){if(s)return s;const t=Math.min(Ne,typeof window<"u"&&window.devicePixelRatio||1),e=Math.round(Le*t),a=typeof OffscreenCanvas<"u";let r,o;if(a)r=new OffscreenCanvas(e,e),o=r.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,antialias:!1});else{const h=document.createElement("canvas");h.width=e,h.height=e,o=h.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,antialias:!1,preserveDrawingBuffer:!0})??h.getContext("experimental-webgl"),r=h}if(!o)throw new Error("metal-fx: WebGL not supported");const{program:n,buffer:i,uniforms:u}=Ft(o),l=h=>{h.preventDefault(),s&&(s.contextLost=!0)},c=()=>{if(!s)return;const h=Ft(s.gl);s.program=h.program,s.buffer=h.buffer,s.uniforms=h.uniforms,s.presetDirty=!0,s.contextLost=!1,bt?.()};return r.addEventListener("webglcontextlost",l,!1),r.addEventListener("webglcontextrestored",c,!1),s={glCanvas:r,gl:o,program:n,buffer:i,uniforms:u,preset:Xt.chromatic.modes.dark,presetDirty:!0,contextLost:!1,useOffscreen:a,frameBitmap:null,startMs:performance.now(),pausedMs:0,pausedAtMs:null,rafId:0,dpr:t,instances:new Set,frameCount:0,glowQueue:[],glowIdx:0,glowSkip:0,glowPixels:new Uint8Array(e*e*4),glowPixelsW:e,glowPixelsH:e},s}function Ve(){var t;if(!s)return;const{gl:e,program:a,buffer:r,frameBitmap:o}=s;try{o?.close(),e.deleteBuffer(r),e.deleteProgram(a),(t=e.getExtension("WEBGL_lose_context"))==null||t.loseContext()}catch{}s=null}let It=0;function dt(){if(!s)return;const t=performance.now();if(t-It<Pe)return;It=t;const{gl:e,glCanvas:a}=s,r=a.width,o=a.height;(s.glowPixelsW!==r||s.glowPixelsH!==o)&&(s.glowPixelsW=r,s.glowPixelsH=o,s.glowPixels=new Uint8Array(r*o*4)),e.readPixels(0,0,r,o,e.RGBA,e.UNSIGNED_BYTE,s.glowPixels)}const K={bx:0,by:0};function kt(t,e,a){if(!s)return K.bx=0,K.by=0,K;const{glCanvas:r}=s,o=r.width,n=r.height,i=t.dpr,u=t.cssWidth*i,l=t.cssHeight*i,c=Yt*i,h=Kt*i;let f=u*(o/c)/t.shaderScale,d=l*(n/h)/t.shaderScale;f>o&&(f=o),d>n&&(d=n);const g=(o-f)/2,x=(n-d)/2,m=g+e/t.cssWidth*f,F=x+a/t.cssHeight*d;return K.bx=Math.round(m),K.by=Math.round(n-1-F),K}const G={r:0,g:0,b:0,lum:0,count:0};function ee(t,e,a,r,o,n){const i=Math.max(1,n|0),u=Math.max(0,r-i),l=Math.min(e,r+i+1),c=Math.max(0,o-i),h=Math.min(a,o+i+1);G.r=0,G.g=0,G.b=0,G.lum=0,G.count=0;for(let f=c;f<h;f++){const d=f*e;for(let g=u;g<l;g++){const x=(d+g)*4;G.r+=t[x],G.g+=t[x+1],G.b+=t[x+2],G.lum+=(.2126*t[x]+.7152*t[x+1]+.0722*t[x+2])/255,G.count++}}return G}const R={r:255,g:255,b:255};function Ot(t,e,a,r){if(!s)return 0;dt();const o=kt(t,e,a),n=ee(s.glowPixels,s.glowPixelsW,s.glowPixelsH,o.bx,o.by,r);return n.count>0?n.lum/n.count:0}function Qe(t,e,a,r){if(!s)return R.r=255,R.g=255,R.b=255,R;dt();const o=kt(t,e,a),n=ee(s.glowPixels,s.glowPixelsW,s.glowPixelsH,o.bx,o.by,r);return n.count===0?(R.r=255,R.g=255,R.b=255,R):(R.r=n.r/n.count,R.g=n.g/n.count,R.b=n.b/n.count,R)}function Xe(t,e,a,r){if(!s)return R.r=255,R.g=255,R.b=255,R;dt();const o=kt(t,e,a),{glowPixels:n,glowPixelsW:i,glowPixelsH:u}=s,l=Math.max(1,r|0),c=Math.max(0,o.bx-l),h=Math.min(i,o.bx+l+1),f=Math.max(0,o.by-l),d=Math.min(u,o.by+l+1);let g=-1;R.r=255,R.g=255,R.b=255;for(let x=f;x<d;x++){const m=x*i;for(let F=c;F<h;F++){const b=(m+F)*4,P=n[b],j=n[b+1],L=n[b+2],C=Math.max(P,j,L),E=Math.min(P,j,L),z=(C>0?(C-E)/C:0)*(.35+.65*(C/255));z>g&&(g=z,R.r=P,R.g=j,R.b=L)}}return R}Ue(()=>{s&&s.instances.size>0&&s.pausedAtMs===null&&nt()});typeof document<"u"&&document.addEventListener("visibilitychange",()=>{!s||s.pausedAtMs!==null||s.contextLost||(document.hidden?oe():s.instances.size>0&&nt())});function Ye(t){const e=te(),a=t.hostCanvas.getContext("2d",{alpha:!0});if(!a)throw new Error("metal-fx: canvas 2D context unavailable");const r=t.scale??1,o={canvas:t.hostCanvas,ctx:a,cssWidth:t.cssWidth,cssHeight:t.cssHeight,cornerRadius:t.cornerRadius,kind:t.kind,ringCssPx:t.ringCssPx??(t.kind==="circle"?2:1)*r,shaderScale:t.shaderScale??(t.kind==="circle"?Jt:Zt)*r,opacityMul:t.opacityMul??1,visible:!0,paused:t.paused??!1,everCopied:!1,dpr:typeof window<"u"&&window.devicePixelRatio||1,scale:r,onAfterFrame:t.onAfterFrame,onFirstCopy:t.onFirstCopy};return ae(o),e.instances.add(o),e.rafId===0&&e.pausedAtMs===null&&nt(),o}function Ke(t){if(!s)return;s.instances.delete(t);const e=s.glowQueue.indexOf(t);e!==-1&&s.glowQueue.splice(e,1),s.instances.size===0&&(oe(),Ve())}function Ze(t){s&&(s.glowQueue.includes(t)||s.glowQueue.push(t))}function Je(t){if(!s)return;const e=s.glowQueue.indexOf(t);e!==-1&&s.glowQueue.splice(e,1)}function rt(t,e){let a=!1;e.cssWidth!==void 0&&e.cssWidth!==t.cssWidth&&(t.cssWidth=e.cssWidth,a=!0),e.cssHeight!==void 0&&e.cssHeight!==t.cssHeight&&(t.cssHeight=e.cssHeight,a=!0),e.cornerRadius!==void 0&&(t.cornerRadius=e.cornerRadius),e.scale!==void 0&&(t.scale=e.scale),e.kind!==void 0&&e.kind!==t.kind&&(t.kind=e.kind,e.shaderScale===void 0&&(t.shaderScale=(e.kind==="circle"?Jt:Zt)*t.scale),e.ringCssPx===void 0&&(t.ringCssPx=(e.kind==="circle"?2:1)*t.scale)),e.shaderScale!==void 0&&(t.shaderScale=e.shaderScale),e.ringCssPx!==void 0&&(t.ringCssPx=e.ringCssPx),e.opacityMul!==void 0&&(t.opacityMul=e.opacityMul),e.paused!==void 0&&e.paused!==t.paused&&(t.paused=e.paused,!e.paused&&s&&s.rafId===0&&s.pausedAtMs===null&&!s.contextLost&&nt()),a&&ae(t)}function ta(t,e){t.visible=e,e&&s&&s.rafId===0&&s.pausedAtMs===null&&!s.contextLost&&nt()}function ea(t,e){const a=te();a.preset=Xt[t].modes[e],a.presetDirty=!0}let wt=null;function aa(t){wt=t}function ae(t){t.dpr=typeof window<"u"&&window.devicePixelRatio||1;const e=Math.max(1,Math.round(t.cssWidth*t.dpr)),a=Math.max(1,Math.round(t.cssHeight*t.dpr));t.canvas.width!==e&&(t.canvas.width=e),t.canvas.height!==a&&(t.canvas.height=a)}function ra(t){const{ctx:e,dpr:a,canvas:r}=t,o=t.ringCssPx*a,n=r.width,i=r.height,u=Math.max(0,(t.cornerRadius-t.ringCssPx)*a);e.save(),e.globalCompositeOperation="destination-out",e.fillStyle="#000",e.beginPath(),e.roundRect(o,o,n-2*o,i-2*o,u),e.fill(),e.restore()}function oa(t){var e;if(!s)return;const a=s.frameBitmap??s.glCanvas,r=t.dpr,o=t.canvas.width,n=t.canvas.height;if(o<1||n<1)return;const i=s.glCanvas.width,u=s.glCanvas.height,l=Yt*r,c=Kt*r;let h=o*(i/l)/t.shaderScale,f=n*(u/c)/t.shaderScale;h>i&&(h=i),f>u&&(f=u);const d=Math.max(0,(i-h)/2),g=Math.max(0,(u-f)/2);if(t.ctx.clearRect(0,0,o,n),t.opacityMul<1&&(t.ctx.globalAlpha=t.opacityMul),t.ctx.drawImage(a,d,g,h,f,0,0,o,n),t.opacityMul<1&&(t.ctx.globalAlpha=1),ra(t),t.onFirstCopy){const x=t.onFirstCopy;t.onFirstCopy=void 0,x()}(e=t.onAfterFrame)==null||e.call(t)}function na(){if(!s)return;const{gl:t,uniforms:e,preset:a,glCanvas:r}=s;e.u_resolution&&t.uniform2f(e.u_resolution,r.width,r.height);for(let o=0;o<7;o++){const n=e[`u_color${o+1}`];if(n){const[u,l,c]=$e(a.colors[o]);t.uniform3f(n,u,l,c)}const i=e[`u_alpha${o+1}`];i&&t.uniform1f(i,a.alphas[o])}e.u_intensity&&t.uniform1f(e.u_intensity,a.intensity),e.u_scale&&t.uniform1f(e.u_scale,a.scale),e.u_direction&&t.uniform1f(e.u_direction,a.direction*Math.PI/180),e.u_softness&&t.uniform1f(e.u_softness,a.softness),e.u_distortion&&t.uniform1f(e.u_distortion,a.distortion),e.u_complexity&&t.uniform1f(e.u_complexity,a.complexity),e.u_shape&&t.uniform1f(e.u_shape,a.shape),e.u_vignette&&t.uniform1f(e.u_vignette,a.vignette),e.u_vigOpacity&&t.uniform1f(e.u_vigOpacity,a.vigOpacity),e.u_blur&&t.uniform1f(e.u_blur,a.blur),e.u_shaderOpacity&&t.uniform1f(e.u_shaderOpacity,a.shaderOpacity),s.presetDirty=!1}function ia(t){if(!s)return;const{gl:e,uniforms:a,preset:r,glCanvas:o}=s,n=(t-s.startMs-s.pausedMs)/1e3*r.speed;e.viewport(0,0,o.width,o.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),s.presetDirty&&na(),a.u_time&&e.uniform1f(a.u_time,n),e.drawArrays(e.TRIANGLES,0,6),s.frameCount++}let Pt=0;function re(t){var e;if(!s)return;if(s.contextLost){s.rafId=0;return}let a=!1;for(const r of s.instances)if(r.visible&&(!r.paused||!r.everCopied)){a=!0;break}if(!a){s.rafId=0;return}if(s.rafId=requestAnimationFrame(re),!(t-Pt<Ie)){Pt=t,ia(t),s.useOffscreen&&(s.glowQueue.length>0&&dt(),(e=s.frameBitmap)==null||e.close(),s.frameBitmap=s.glCanvas.transferToImageBitmap());for(const r of s.instances)r.visible&&(r.paused&&r.everCopied||(oa(r),r.everCopied=!0));if(wt&&s.glowQueue.length>0&&++s.glowSkip%Ae===0){const r=s.glowQueue;s.glowIdx>=r.length&&(s.glowIdx=0);const o=r[s.glowIdx];o.visible&&!o.paused&&wt(o,t),s.glowIdx++}}}function nt(){!s||s.rafId!==0||(s.rafId=requestAnimationFrame(re))}function oe(){s&&(s.rafId!==0&&cancelAnimationFrame(s.rafId),s.rafId=0)}const lt={linear:t=>t,smoothstep:t=>t*t*(3-2*t)};function Z(t,e,a,r=lt.linear){return{from:t,to:e,dur:a,ease:r,startMs:-1,val:t,done:!1}}function J(t,e){t.startMs=e,t.val=t.from,t.done=!1}function At(t,e){if(t.done||t.startMs<0)return t.val;const a=Math.min(1,(e-t.startMs)/t.dur);return t.val=t.from+(t.to-t.from)*t.ease(a),a>=1&&(t.done=!0),t.val}const sa=1.5,it=1/3,la=4*it,ca=2*it,da=2*it,ua=1.35*it,ha=13*it;function Mt(t,e,a){const r=Math.max(0,Math.min(a,Math.min(t,e)/2));return 2*Math.max(0,t-2*r)+2*Math.max(0,e-2*r)+2*Math.PI*r}function _t(t,e,a,r){return r==="circle"?2*Math.PI*Math.max(0,Math.min(a,Math.min(t,e)/2)):Mt(t,e,a)}function ot(t,e,a,r,o,n,i,u){const l=u||{x:0,y:0},c=Math.max(0,Math.min(r,Math.min(e,a)/2));if(i==="circle"){const b=2*Math.PI*c;if(b<=1e-4)return l.x=e*.5,l.y=a*.5,l;t=(t%b+b)%b;const P=-Math.PI/2+t/b*Math.PI*2,j=Math.max(0,c-o+n);return l.x=e*.5+j*Math.cos(P),l.y=a*.5+j*Math.sin(P),l}const h=Math.max(0,e-2*c),f=Math.max(0,a-2*c),d=Math.PI*c/2,g=2*(h+f)+4*d;t=(t%g+g)%g;const x=Math.max(0,c-o+n);let m=t;if(m<h)return l.x=c+m,l.y=o-n,l;if(m-=h,m<d){const b=-Math.PI/2+(d>0?m/d:0)*(Math.PI/2);return l.x=e-c+x*Math.cos(b),l.y=c+x*Math.sin(b),l}if(m-=d,m<f)return l.x=e-o+n,l.y=c+m,l;if(m-=f,m<d){const b=(d>0?m/d:0)*(Math.PI/2);return l.x=e-c+x*Math.cos(b),l.y=a-c+x*Math.sin(b),l}if(m-=d,m<h)return l.x=e-c-m,l.y=a-o+n,l;if(m-=h,m<d){const b=Math.PI/2+(d>0?m/d:0)*(Math.PI/2);return l.x=c+x*Math.cos(b),l.y=a-c+x*Math.sin(b),l}if(m-=d,m<f)return l.x=o-n,l.y=a-c-m,l;m-=f;const F=Math.PI+(d>0?m/d:0)*(Math.PI/2);return l.x=c+x*Math.cos(F),l.y=c+x*Math.sin(F),l}function jt(t,e){const a=t*2/e;let r="";for(let o=0;o<=e;o++){const n=-t+o*a;r+=(o===0?"M ":"L ")+n.toFixed(3)+" 0 "}return r}const ft={x:0,y:0},pt={x:0,y:0};function fa(t,e,a,r,o,n){return ot(t-.1,e,a,r,o,0,n,ft),ot(t+.1,e,a,r,o,0,n,pt),Math.atan2(pt.y-ft.y,pt.x-ft.x)}function Et(t,e,a){const r=Math.max(0,Math.min(1,(a-t)/(e-t)));return r*r*(3-2*r)}function pa(t){const e=_t(t.width,t.height,t.cornerRadius,t.kind),a=sa*(t.scale??1),r=[];for(let o=0;o<$t;o++){const n=o/$t*e,i=ot(n,t.width,t.height,t.cornerRadius,a,0,t.kind);r.push({x:i.x,y:i.y,arc:n})}return r}function ma(t,e){const{width:a,height:r,cornerRadius:o}=t,n=t.scale??1,i=t.kind==="circle"?2:1,u=Math.max(0,o-i),l=(-200*n).toFixed(0),c=l,h=(540*n).toFixed(0),f=(440*n).toFixed(0),d=`x="${l}" y="${c}" width="${h}" height="${f}"`,g=`${d} filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"`,x=F=>(F*n).toFixed(3),m=F=>(F*n).toFixed(3);return["<defs>",`<filter id="${e}_bXl" ${g}><feGaussianBlur stdDeviation="${m(8.4)}"/></filter>`,`<filter id="${e}_bLg" ${g}><feGaussianBlur stdDeviation="${m(4.8)}"/></filter>`,`<filter id="${e}_bMd" ${g}><feGaussianBlur stdDeviation="${m(2.1)}"/></filter>`,`<filter id="${e}_bSm" ${g}><feGaussianBlur stdDeviation="${m(.9)}"/></filter>`,`<filter id="${e}_ebO" ${g}><feGaussianBlur stdDeviation="${m(da)}"/></filter>`,`<filter id="${e}_ebC" ${g}><feGaussianBlur stdDeviation="${m(ua)}"/></filter>`,`<radialGradient id="${e}_fg" cx="0.5" cy="0.5" r="0.5"><stop offset="0" stop-color="white"/><stop offset="0.30" stop-color="white"/><stop offset="0.65" stop-color="#404040"/><stop offset="1" stop-color="black"/></radialGradient>`,`<mask id="${e}_fm" maskUnits="userSpaceOnUse" ${d}><rect ${d} fill="black"/><circle id="${e}_fc" cx="0" cy="0" r="${(ha*n).toFixed(3)}" fill="url(#${e}_fg)"/></mask>`,`<mask id="${e}_rm" maskUnits="userSpaceOnUse" ${d}><rect ${d} fill="#808080"/><rect x="0" y="0" width="${a}" height="${r}" rx="${o}" ry="${o}" fill="white"/><rect x="${i}" y="${i}" width="${a-i*2}" height="${r-i*2}" rx="${u}" ry="${u}" fill="black"/></mask>`,"</defs>",`<g id="${e}_h" mask="url(#${e}_rm)" opacity="0">`,`<rect ${d} fill="none" pointer-events="none"/>`,`<g id="${e}_hI" stroke="white">`,`<path id="${e}_pXl" stroke-width="${x(26.4)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.385" filter="url(#${e}_bXl)"/>`,`<path id="${e}_pLg" stroke-width="${x(15.6)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.595" filter="url(#${e}_bLg)"/>`,`<path id="${e}_pMd" stroke-width="${x(7.2)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.70" filter="url(#${e}_bMd)"/>`,`<path id="${e}_pSm" stroke-width="${x(3)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.70" filter="url(#${e}_bSm)"/>`,"</g></g>",`<g id="${e}_e" mask="url(#${e}_rm)" opacity="0">`,`<rect ${d} fill="none" pointer-events="none"/>`,`<g mask="url(#${e}_fm)">`,`<g id="${e}_eI" stroke="white">`,`<path id="${e}_eO" stroke-width="${x(la)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.85" filter="url(#${e}_ebO)"/>`,`<path id="${e}_eC" stroke-width="${x(ca)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="1.0" filter="url(#${e}_ebC)"/>`,"</g></g></g>"].join("")}const xa=.00875,Lt=.08,Nt=.32,ga=.05,va=3e3,Wt=.85,st=.34,mt=1500,ba=15,wa=.0075,ya=120,ka=1.5,Ma=7.8,_a=9.13952,Ca=1,Sa=1/3,Ta=.8,$a=3.51,Bt=2e3,xt=400,Ra=2.625,Fa=1.008,Ia=.31,ne=140,ie=40,se=20;let Oa=0;const q={x:0,y:0};function zt(t,e){const a=`mfxg_${++Oa}`,r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","metal-fx-glow-svg"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${e.width} ${e.height}`),r.innerHTML=ma(e,a),t.appendChild(r);const o=b=>r.querySelector(`#${a}_${b}`),n=o("h"),i=o("hI"),u=o("e"),l=o("eI"),c=o("fc"),h=_t(e.width,e.height,e.cornerRadius,e.kind)/Mt(ne,ie,se),f=Math.max(1,Ma*h),d=Math.max(.6,_a*Sa*h),g=jt(f,je),x=jt(d,Ee),m=[o("pXl"),o("pLg"),o("pMd"),o("pSm")],F=[o("eO"),o("eC")];for(const b of m)b.setAttribute("d",g);for(const b of F)b.setAttribute("d",x);return i.style.transformOrigin="0 0",l.style.transformOrigin="0 0",i.style.willChange="transform",l.style.willChange="transform",i.style.transition="transform 100ms linear",l.style.transition="transform 100ms linear",n.style.willChange="opacity",u.style.willChange="opacity",n.style.transition="opacity 100ms linear",u.style.transition="opacity 100ms linear",c.style.willChange="transform",{svg:r,haloGroup:n,haloInner:i,extraGroup:u,extraInner:l,fadeCircle:c,width:e.width,height:e.height,cornerRadius:e.cornerRadius,kind:e.kind,scale:e.scale??1,perim:pa(e),currentIdx:0,appearedAt:0,glowOpacity:0,relocTween:null,relocNextIdx:-1,wanderS:0,wanderTargetS:0,wanderFrames:0,tintFrom:{r:255,g:255,b:255},tintTarget:{r:255,g:255,b:255},tintTween:null,tintHoldUntil:0,lastHaloStroke:"",lastExtraStroke:""}}function Pa(t,e,a,r,o="dark"){var n;const{width:i,height:u,cornerRadius:l,perim:c}=t;if(c.length===0)return;const h=2;let f=-1,d=t.currentIdx,g=0;for(let v=0;v<c.length;v++){const M=c[v],S=Ot(e,M.x,M.y,h);S>f&&(f=S,d=v),v===t.currentIdx&&(g=S)}const x=t.appearedAt>0&&a-t.appearedAt<va,m=st+(Wt-st)*Et(Lt,Nt,g),F=!x&&f-g>ga;if(!t.relocTween||t.relocTween.done)if(t.appearedAt===0)t.currentIdx=d,t.appearedAt=a,t.wanderS=0,t.wanderTargetS=0,t.wanderFrames=0,t.relocTween=Z(0,m,mt,lt.smoothstep),J(t.relocTween,a);else if((n=t.relocTween)!=null&&n.done&&t.relocTween.to===0){t.currentIdx=t.relocNextIdx,t.appearedAt=a,t.wanderS=0,t.wanderTargetS=0,t.wanderFrames=0;const v=c[t.currentIdx],M=Ot(e,v.x,v.y,h),S=st+(Wt-st)*Et(Lt,Nt,M);t.relocTween=Z(0,S,mt,lt.smoothstep),J(t.relocTween,a)}else F?(t.relocNextIdx=d,t.relocTween=Z(t.glowOpacity,0,mt,lt.smoothstep),J(t.relocTween,a)):t.glowOpacity+=(m-t.glowOpacity)*xa;t.relocTween&&(t.glowOpacity=At(t.relocTween,a)),t.glowOpacity=Math.max(0,Math.min(1,t.glowOpacity));const b=_t(i,u,l,t.kind)/Mt(ne,ie,se),P=ba*b;t.wanderFrames++>=ya&&(t.wanderTargetS=(Math.random()*2-1)*P,t.wanderFrames=0),t.wanderS+=(t.wanderTargetS-t.wanderS)*wa;const j=c[t.currentIdx].arc+t.wanderS,L=ka*t.scale;ot(j,i,u,l,L,0,t.kind,q);const C=q.x,E=q.y,z=fa(j,i,u,l,L,t.kind),X=`translate(${C.toFixed(3)}px,${E.toFixed(3)}px) rotate(${z.toFixed(4)}rad)`;t.haloInner.style.transform=X;const N=Ca*b*t.scale;ot(j,i,u,l,L,N,t.kind,q),t.extraInner.style.transform=`translate(${q.x.toFixed(3)}px,${q.y.toFixed(3)}px) rotate(${z.toFixed(4)}rad)`,t.fadeCircle.style.transform=`translate(${q.x.toFixed(3)}px,${q.y.toFixed(3)}px)`;const $=o==="light",k=$?Xe(e,C,E,h):Qe(e,C,E,h);t.tintTween?t.tintTween.done&&($?(t.tintFrom={r:t.tintFrom.r+(t.tintTarget.r-t.tintFrom.r)*t.tintTween.val,g:t.tintFrom.g+(t.tintTarget.g-t.tintFrom.g)*t.tintTween.val,b:t.tintFrom.b+(t.tintTarget.b-t.tintFrom.b)*t.tintTween.val},t.tintTarget={...k},t.tintTween=Z(0,1,xt),J(t.tintTween,a)):a>=t.tintHoldUntil&&(t.tintFrom={...t.tintTarget},t.tintTarget={...k},t.tintTween=Z(0,1,xt),J(t.tintTween,a),t.tintHoldUntil=a+Bt)):(t.tintFrom={...k},t.tintTarget={...k},t.tintTween=Z(0,1,xt),J(t.tintTween,a),t.tintHoldUntil=$?0:a+Bt),At(t.tintTween,a);const I=t.tintTween.val;let W,B,H;if($)W=Math.round(t.tintFrom.r+(t.tintTarget.r-t.tintFrom.r)*I),B=Math.round(t.tintFrom.g+(t.tintTarget.g-t.tintFrom.g)*I),H=Math.round(t.tintFrom.b+(t.tintTarget.b-t.tintFrom.b)*I);else{const v=t.tintFrom.r+(t.tintTarget.r-t.tintFrom.r)*I,M=t.tintFrom.g+(t.tintTarget.g-t.tintFrom.g)*I,S=t.tintFrom.b+(t.tintTarget.b-t.tintFrom.b)*I,O=Math.max(v,M,S)||1;W=Math.round(255*(v/O)),B=Math.round(255*(M/O)),H=Math.round(255*(S/O))}const y=`rgb(${W},${B},${H})`;if(y!==t.lastHaloStroke&&(t.lastHaloStroke=y,t.haloInner.style.stroke=y),$){const v=Re(W,B,H),[M,S,O]=Fe(v[0],Math.min(1,v[1]*Ra),Math.max(Ia,v[2]*Fa)),D=`rgb(${M},${S},${O})`;D!==t.lastExtraStroke&&(t.lastExtraStroke=D,t.extraInner.style.stroke=D)}else t.lastExtraStroke!=="#ffffff"&&(t.lastExtraStroke="#ffffff",t.extraInner.style.stroke="#ffffff");const w=Math.max(0,Math.min(1,r));t.haloGroup.style.opacity=(t.glowOpacity*Ta*w).toFixed(3),t.extraGroup.style.opacity=Math.min(1,t.glowOpacity*$a*w).toFixed(3)}const yt=12,Ht=32,Gt=1,Dt=.55,Aa=1,ja=1,Ea=.85,La=0,Na=1.3,Ut=3.6,Wa=.7,Ba=1,za=.52,Ha=1,Ga=.044,Da=235,Ua=2.535,qa=.7,Va=.5,Qa=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Xa(t,e){const a=Math.max(t.left-e.right,e.left-t.right,0),r=Math.max(t.top-e.bottom,e.top-t.bottom,0);return Math.sqrt(a*a+r*r)}function Ya(t,e,a,r){return!(Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top)<a||Math.max(t.left-e.right,e.left-t.right,0)>r)}function Ka(t,e,a,r){return Math.min(t.right,e.right)-Math.max(t.left,e.left)<a?!1:Math.max(t.top-e.bottom,e.top-t.bottom,0)<=r}function Q(t,e,a,r,o,n){const i=Math.max(0,Math.min(n,r*.5,o*.5)),u=t.roundRect;if(typeof u=="function"){u.call(t,e,a,r,o,i);return}t.moveTo(e+i,a),t.lineTo(e+r-i,a),t.quadraticCurveTo(e+r,a,e+r,a+i),t.lineTo(e+r,a+o-i),t.quadraticCurveTo(e+r,a+o,e+r-i,a+o),t.lineTo(e+i,a+o),t.quadraticCurveTo(e,a+o,e,a+o-i),t.lineTo(e,a+i),t.quadraticCurveTo(e,a,e+i,a)}function le(t,e,a,r,o){if(!o.flipX&&!o.flipY){t.drawImage(e,0,0,a,r,o.x,o.y,o.w,o.h);return}t.save(),o.flipX&&(t.translate(o.x+o.w,0),t.scale(-1,1)),o.flipY&&(t.translate(0,o.y+o.h),t.scale(1,-1)),t.drawImage(e,0,0,a,r,o.flipX?0:o.x,o.flipY?0:o.y,o.w,o.h),t.restore()}const Za=4;function Ja(t,e,a,r,o,n,i){if(r<=2*i||o<=2*i){t.beginPath(),Q(t,e,a,r,o,n),t.clip();return}t.beginPath(),Q(t,e,a,r,o,n),Q(t,e+i,a+i,r-2*i,o-2*i,Math.max(0,n-i)),t.clip("evenodd")}function tr(t,e,a,r,o,n,i,u,l,c,h){const f=Math.max(1,Math.round((yt+Za*3)*h));let d=Math.max(0,i),g=!0;for(let x=0;x<3&&d>1e-4;x++){const m=Math.min(1,d);t.save(),Ja(t,c.x,c.y,c.w,c.h,c.r,f),t.globalCompositeOperation=g?"source-over":"lighter",g=!1,t.globalAlpha=m,le(t,e,a,r,l),t.globalAlpha=1,t.globalCompositeOperation="destination-in",t.fillStyle=u,t.fillRect(0,0,o,n),t.restore(),d-=m}}function ce(t,e,a,r,o,n,i){const u=i|0;if(u<1||r<=2*u||o<=2*u){t.beginPath(),Q(t,e,a,r,o,n),t.clip();return}t.beginPath(),Q(t,e,a,r,o,n),Q(t,e+u,a+u,r-2*u,o-2*u,Math.max(0,n-u)),t.clip("evenodd")}function er(t,e,a,r,o,n,i,u,l,c,h,f){let d=u*h,g=!0;for(let x=0;x<3&&d>1e-4;x++){const m=Math.min(1,d);t.save(),ce(t,i.x,i.y,i.w,i.h,i.r,l),t.globalCompositeOperation=g?"source-over":"lighter",g=!1,t.globalAlpha=m,le(t,e,a,r,f),t.globalAlpha=1,t.globalCompositeOperation="destination-in",t.fillStyle=c,t.fillRect(0,0,o,n),t.restore(),d-=m}}function ar(t,e,a,r,o,n,i,u){const l=t.createLinearGradient(r,o,n,i);l.addColorStop(0,`rgba(255,255,255,${u.toFixed(3)})`),l.addColorStop(.5,`rgba(255,255,255,${(u*.45).toFixed(3)})`),l.addColorStop(1,"rgba(255,255,255,0)"),t.save(),ce(t,e.x,e.y,e.w,e.h,e.r,a),t.globalCompositeOperation="lighter",t.lineWidth=a*2,t.strokeStyle=l,t.beginPath(),Q(t,e.x,e.y,e.w,e.h,e.r),t.stroke(),t.restore()}function de(t){const e=getComputedStyle(t),a=[parseFloat(e.borderTopLeftRadius)||0,parseFloat(e.borderTopRightRadius)||0,parseFloat(e.borderBottomRightRadius)||0,parseFloat(e.borderBottomLeftRadius)||0].filter(r=>r>0);return a.length?Math.min.apply(null,a):0}function ue(t){const e=getComputedStyle(t),a=Math.max(parseFloat(e.borderTopWidth)||0,parseFloat(e.borderRightWidth)||0,parseFloat(e.borderBottomWidth)||0,parseFloat(e.borderLeftWidth)||0);let r=0,o=0;const n=e.boxShadow;if(n&&n!=="none"){const u=n.replace(/rgba?\([^)]*\)/g,h=>h.replace(/,/g,"\0")).split(/,\s*/);let l=1/0,c=1/0;for(const h of u){const f=h.match(/-?\d+(?:\.\d+)?px/g);if(!f||f.length<4)continue;const d=parseFloat(f[3]);d>0&&(/\binset\b/.test(h)?d<l&&(l=d):d<c&&(c=d))}Number.isFinite(l)&&(r=l),Number.isFinite(c)&&(o=c)}const i=Math.max(a,o);return{width:Math.max(a,r,o)||1,outerCssPx:i}}function qt(t){t.cornerRadius=de(t.el);const e=ue(t.el);t.hairlineWidth=e.width,t.hairlineOuterCssPx=e.outerCssPx}function rr(t){typeof ResizeObserver<"u"&&(t.resizeObserver=new ResizeObserver(()=>qt(t)),t.resizeObserver.observe(t.el)),typeof MutationObserver<"u"&&(t.mutationObserver=new MutationObserver(()=>qt(t)),t.mutationObserver.observe(t.el,{attributes:!0,attributeFilter:["style","class"]}))}function or(t){var e,a;(e=t.resizeObserver)==null||e.disconnect(),t.resizeObserver=null,(a=t.mutationObserver)==null||a.disconnect(),t.mutationObserver=null}const tt=new Set;function nr(t,e,a){if(typeof document>"u"||Qa.has(t.tagName))return null;for(const g of tt)if(g.el===t)return g;const r=document.createElement("div");r.setAttribute("data-metal-fx-reflection",""),r.setAttribute("aria-hidden","true");const o=document.createElement("canvas");o.className="metal-fx-reflection-canvas";const n=o.getContext("2d",{alpha:!0});if(!n)return null;const i=document.createElement("canvas");i.className="metal-fx-reflection-stroke-canvas";const u=i.getContext("2d",{alpha:!0});if(!u)return null;r.appendChild(o),r.appendChild(i);const l=getComputedStyle(t);let c=!1;l.position==="static"&&(t.style.position="relative",c=!0);let h=!1;l.isolation!=="isolate"&&(t.style.isolation="isolate",h=!0),t.setAttribute("data-metal-fx-reflect-host",""),t.insertBefore(r,t.firstChild);const f=ue(t),d={el:t,anchor:e,anchorEl:a,wrap:r,canvas:o,ctx:n,strokeCanvas:i,strokeCtx:u,cornerRadius:de(t),hairlineWidth:f.width,hairlineOuterCssPx:f.outerCssPx,appliedPositionRelative:c,appliedIsolation:h,resizeObserver:null,mutationObserver:null};return rr(d),tt.add(d),d}function ir(t){for(const e of tt)if(e.el===t){or(e),e.canvas.width=0,e.canvas.height=0,e.strokeCanvas.width=0,e.strokeCanvas.height=0,e.wrap.parentNode===e.el&&e.el.removeChild(e.wrap),e.el.removeAttribute("data-metal-fx-reflect-host"),e.appliedPositionRelative&&(e.el.style.position=""),e.appliedIsolation&&(e.el.style.isolation=""),tt.delete(e);return}}function sr(){if(tt.size===0)return;const t=typeof window<"u"&&window.devicePixelRatio||1,e=new Map;for(const a of tt){const r=a.el.getBoundingClientRect();let o=e.get(a.anchorEl);if(o||(o=a.anchorEl.getBoundingClientRect(),e.set(a.anchorEl,o)),r.width<1||r.height<1||o.width<1||o.height<1)continue;if(!Ya(o,r,Gt,Ht)&&!Ka(o,r,Gt,Ht)){a.canvas.width!==1&&(a.canvas.width=1,a.canvas.height=1),a.strokeCanvas.width!==1&&(a.strokeCanvas.width=1,a.strokeCanvas.height=1);continue}const n=a.anchor.canvas,i=n.width|0,u=n.height|0;if(i<4||u<4)continue;const l=(o.left+o.right)*.5,c=(o.top+o.bottom)*.5,h=(r.left+r.right)*.5,f=(r.top+r.bottom)*.5,d=l-h,g=c-f,x=Math.max(o.left-r.right,r.left-o.right,0),m=Math.max(o.top-r.bottom,r.top-o.bottom,0),F=x>=m,b=Xa(o,r);let P=1-Math.min(1,b/yt);P=P*P*(3-2*P);const j=Dt+(Aa-Dt)*P,L=Math.min(Ut,j*Na*Wa),C=a.anchor.scale??1,E=Math.max(Ba*C,a.hairlineWidth),z=Math.max(1,Math.round(E*t)),X=Math.max(1,Math.round(Math.max(Ha*C,a.hairlineWidth)*t)),N=a.hairlineOuterCssPx;a.wrap.style.inset=`${-N}px`,a.wrap.style.borderRadius=`${Math.max(0,a.cornerRadius)}px`;const $=Math.max(1,Math.round((r.width+N*2)*t)),k=Math.max(1,Math.round((r.height+N*2)*t));a.canvas.width!==$&&(a.canvas.width=$),a.canvas.height!==k&&(a.canvas.height=k),a.strokeCanvas.width!==$&&(a.strokeCanvas.width=$),a.strokeCanvas.height!==k&&(a.strokeCanvas.height=k);const I=a.ctx;I.setTransform(1,0,0,1,0,0),I.clearRect(0,0,$,k);const W=a.strokeCtx;W.setTransform(1,0,0,1,0,0),W.clearRect(0,0,$,k);const B=Math.min(yt*t,Math.max($,k));let H,y,w,v;F?(H=d>0?$:0,w=d>0?$-B:B,y=k*.5,v=k*.5):(y=g>0?k:0,v=g>0?k-B:B,H=$*.5,w=$*.5);const M=I.createLinearGradient(H,y,w,v);M.addColorStop(0,`rgba(0,0,0,${ja})`),M.addColorStop(.5,`rgba(0,0,0,${Ea})`),M.addColorStop(1,`rgba(0,0,0,${La})`);const S=i/t,O=Math.max(1,Math.round(Da*Math.max(.1,S/140)*t));let D,U,T,A,V=!1,Ct=!1;if(F){const at=Math.max(o.top,r.top),ht=Math.min(o.bottom,r.bottom);V=!0,D=d>0?$-O:0,U=Math.round((at-r.top+N)*t),T=O,A=Math.max(1,Math.round((ht-at)*t))}else{const at=Math.max(o.left,r.left),ht=Math.min(o.right,r.right);Ct=!0,D=Math.round((at-r.left+N)*t),U=g>0?k-O:0,T=Math.max(1,Math.round((ht-at)*t)),A=O}const St={x:D,y:U,w:T,h:A,flipX:V,flipY:Ct},ut={x:0,y:0,w:$,h:k,r:Math.max(0,a.cornerRadius*t)},me=Math.min(Ut,L*Ua*qa*Va);tr(I,n,i,u,$,k,me,M,St,ut,t),er(W,n,i,u,$,k,ut,L,z,M,za,St),ar(W,ut,X,H,y,w,v,Math.min(.85,Ga*L)),I.globalCompositeOperation="source-over",W.globalCompositeOperation="source-over"}}let gt=!1,Vt=0;function lr(){gt||(gt=!0,!(typeof requestAnimationFrame>"u")&&requestAnimationFrame(t=>{gt=!1,!(t-Vt<Oe)&&(Vt=t,sr())}))}const Qt="metal-fx-styles",cr=`
.metal-fx-root {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
isolation: isolate;
overflow: visible;
background: #272727;
color: #f8f8f8;
}
.metal-fx-root[data-theme='light'] {
background: #ffffff;
color: #1d1d1d;
}
.metal-fx-root::before {
content: '';
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
z-index: 2;
box-shadow: inset 0 0 50px 0 rgba(255, 255, 255, 0.02);
}
.metal-fx-root[data-theme='light']::before {
box-shadow: inset 0 0 50px 0 rgba(0, 0, 0, 0.02);
}
.metal-fx-root::after {
content: '';
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
z-index: 4;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.metal-fx-root[data-theme='light']::after {
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
/* Circle variant gets a thicker outer rim than the button variant. */
.metal-fx-root[data-variant='circle']::after {
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1);
}
.metal-fx-root[data-theme='light'][data-variant='circle']::after {
box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.06);
}
.metal-fx-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
z-index: 0;
pointer-events: none;
border-radius: inherit;
}
/* The inner spacer — defines the inset geometry where the metal ring meets
the interior (3 px for Button, 1-2 px for Circle) and carries the Circle dark
hairline ('box-shadow: inset' rules below). Intentionally transparent so
the wrapper's background propagates through to the punched shader centre,
giving consumers a single surface tone to override. See "Single-surface
background" in the file header for the rationale. */
.metal-fx-inner {
position: absolute;
inset: 3px;
border-radius: inherit;
z-index: 1;
pointer-events: none;
}
.metal-fx-root[data-variant='button'][data-shape='pill'] .metal-fx-inner {
border-radius: calc(var(--mfx-radius, 20px) - 3px);
}
.metal-fx-root[data-variant='button'][data-shape='circle'] .metal-fx-inner {
border-radius: calc(var(--mfx-radius, 16px) - 3px);
}
.metal-fx-root[data-variant='circle'][data-shape='pill'] .metal-fx-inner {
inset: 0;
border-radius: var(--mfx-radius, 20px);
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
.metal-fx-root[data-variant='circle'][data-shape='circle'] .metal-fx-inner {
inset: 0;
border-radius: var(--mfx-radius, 16px);
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
/* Circle-variant hairline alpha — light mode.
Source-of-truth: index.html L2261-2267. The 0.45-alpha black inset that
reads as a single-pixel frame against the dark interior is too heavy
on a #ffffff inner: it ends up looking like a hard 2-px black ring
against the iridescent shader. Suppressed entirely (alpha 0) — the
shader's own iridescent rim already defines the silhouette in light
mode, so an extra dark hairline only competes with it. The rule is
kept (rather than deleted) as a tunable hook in case a future variant
wants to re-introduce a soft edge. NOTE: we keep the dark-mode inset
and border-radius values because — unlike index.html — our renderer
does NOT overscan the canvas in light mode, so there is no 1-px gap
between inner element and shader to compensate for. */
.metal-fx-root[data-theme='light'][data-variant='circle'][data-shape='pill'] .metal-fx-inner,
.metal-fx-root[data-theme='light'][data-variant='circle'][data-shape='circle'] .metal-fx-inner {
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0);
}
/* ─── Combined glow SVG (z=3) ──────────────────────────────────────────────
Single SVG per instance that holds BOTH the wide-halo group
(#mfx_haloTravel) and the catch-light group (#mfx_extraTravel), exactly
mirroring canonical's _buildGlowSvgInner (index.html L8078). One
mix-blend-mode: screen lifts the combined composite onto the shader
ring; per-frame opacity attributes on each inner group still drive the
independent fade-in / fade-out cycles for the halo and the catch-light.
Why a single SVG: the circle variant anchors halo + catch-light at the same
perimeter point, so they overlap in the bright zone. Two separately-
screened SVGs would double-screen the overlap (A + B + C - AB - AC -
BC + ABC instead of A + B + C - AB - AC once both groups composite
in source-over inside one SVG and then screen against the host once).
That overlap looked muted versus canonical specifically on the circle
variant where both layers travel together.
Source-of-truth opacity: #btnGlowSvg drops to 0.7 in dark and 0.2746 in
light (index.html L632/L643). */
.metal-fx-glow-svg {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
overflow: visible;
z-index: 3;
pointer-events: none;
opacity: 0.7;
}
.metal-fx-root[data-theme='light'] .metal-fx-glow-svg {
/* Light-mode 1-px overscan mirrors .btn-glow-svg in metal.html so the
halo stays glued to the visible silhouette (the shader ring there sits
1 px outside the host's padding box). */
inset: -1px;
width: calc(100% + 2px);
height: calc(100% + 2px);
mix-blend-mode: multiply;
/* Source-of-truth: html[data-theme="light"] #btnGlowSvg { opacity: 0.2746 }
→ −35 % from 0.4225 from the original 0.7 dark-mode opacity. */
opacity: 0.2746;
filter: saturate(5.355) brightness(0.78);
}
/* Circle light-mode small variants (e.g. 36×36 send button): the geometrically
shrunk halo loses density when multiplied against #ffffff. Mirror the
canonical override at index.html L2316 — bump saturation + drop brightness
so the small glow holds together visually. */
.metal-fx-root[data-variant='circle'][data-shape='circle'][data-theme='light'] .metal-fx-glow-svg {
filter: saturate(7.5) brightness(0.6);
}
/* The wrapped child — hoisted into z=5 so it sits above every overlay, with
normalized chrome so consumer button styles don't fight the metal frame. */
.metal-fx-content {
position: relative;
z-index: 5;
display: inline-flex;
align-items: center;
justify-content: center;
width: 100%;
pointer-events: none;
}
.metal-fx-content > * {
pointer-events: auto;
}
.metal-fx-root[data-normalize='true'] .metal-fx-content > * {
background: transparent !important;
border: 0 !important;
outline: 0 !important;
box-shadow: none !important;
/* Sizing: we deliberately DO NOT force \`width: 100%; height: 100%\` on the
child here. That used to be the contract ("the wrapper is the visible
button surface; the child stretches to fill it"), but it created a cyclic
percentage dependency: the wrapper is \`inline-flex\` with no intrinsic
size, .metal-fx-content is \`width/height: 100%\` of the wrapper, and the
child was \`100%\` of .metal-fx-content. With nothing breaking the cycle,
icon-only / class-sized children collapsed.
The new contract: the child sizes itself (intrinsic content, CSS class,
or inline style — all work), and the wrapper's \`inline-flex\` wraps it
tightly. Consumers who want a metal frame BIGGER than the child (e.g.
padding around an icon) size <MetalFx style={{ width, height }}> AND
explicitly set width/height on the child to fill (or accept that the
child renders at its intrinsic size, centered).
Typography is intentionally NOT touched. We used to apply
\`color: inherit; font: inherit;\` here to "match" the wrapper, but
\`font: inherit\` is a shorthand that overrides font-family, font-size,
font-weight, AND line-height on the child — which (a) shrank the
button height (line-height changes propagate through the flex
content box) and (b) scaled em-based icons / font-icons inside the
child to whatever the wrapper inherited. The wrapper now stays out
of the child's typography entirely; consumers who want typographic
normalization can apply it themselves on the child element. */
}
[data-metal-fx-reflection] {
position: absolute;
inset: 0;
pointer-events: none;
border-radius: inherit;
overflow: hidden;
z-index: 0;
isolation: isolate;
}
.metal-fx-reflection-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
filter: blur(4px) saturate(1.2) brightness(1.58);
}
.metal-fx-reflection-stroke-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
filter: saturate(1.35) brightness(1.75);
}
/* Hosts that participate as reflection targets need positioning + isolation
so the wrap composites only against the host (not the parent stack). The
wrap injects these inline as well, but stating them here keeps reflections
working on hosts that already have other inline styles applied. */
[data-metal-fx-reflect-host] {
isolation: isolate;
}
`;let vt=!1;function dr(){if(vt||typeof document>"u")return;if(document.getElementById(Qt)){vt=!0;return}const t=document.createElement("style");t.id=Qt,t.textContent=cr,document.head.appendChild(t),vt=!0}dr();const ur={position:"absolute",inset:0,width:"100%",height:"100%"},hr={position:"absolute",inset:3},fr={position:"absolute",inset:0,pointerEvents:"none",zIndex:3,borderRadius:"inherit"},ct=new Map;aa((t,e)=>{const a=ct.get(t);a&&Pa(a.handles,t,e,t.opacityMul,a.themeRef.current)});function pr(t){const[e,a]=_.useState(()=>t!=="auto"?t:typeof window>"u"||!window.matchMedia||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return _.useEffect(()=>{if(t!=="auto"){a(t);return}if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>a(r.matches?"dark":"light");return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[t]),e}const he=_.forwardRef(function({children:t,variant:e="button",preset:a="chromatic",theme:r="auto",strength:o=1,paused:n=!1,borderRadius:i,normalizeHostStyles:u=!0,reflectionTargets:l,disableGlow:c=!1,shaderScale:h,ringCssPx:f,scale:d=1,className:g,style:x,...m},F){const b=_.useRef(null),P=_.useRef(null),j=_.useRef(null),L=_.useRef(null),C=_.useRef(null),E=_.useRef(null),z=_.useRef("dark"),X=_.useRef(0),[N,$]=_.useState(!1),k=pr(r);z.current=k;const I=e==="circle"?"circle":"pill",W=!c;_.useImperativeHandle(F,()=>b.current,[]);const B=(y,w)=>{if(I==="circle")return Math.min(y,w)/2;const v=typeof i=="number"?i:(()=>{var M;const S=(M=L.current)==null?void 0:M.firstElementChild;if(S){const O=parseFloat(getComputedStyle(S).borderTopLeftRadius);if(Number.isFinite(O)&&O>0)return O}return X.current})();return Math.min(v,Math.min(y,w)/2)};_.useEffect(()=>{ea(a,k)},[a,k]),_.useEffect(()=>{const y=C.current;y&&rt(y,{paused:n})},[n]),_.useEffect(()=>{const y=C.current;if(!y)return;const w={};h!==void 0&&(w.shaderScale=h),f!==void 0&&(w.ringCssPx=f),d!==void 0&&(w.scale=d),Object.keys(w).length>0&&rt(y,w)},[h,f,d]),_.useLayoutEffect(()=>{const y=P.current,w=b.current,v=j.current;if(!y||!w)return;{const T=getComputedStyle(w),A=parseFloat(T.borderTopLeftRadius);X.current=Number.isFinite(A)?A:0}const M=()=>{const T=w.getBoundingClientRect(),A=Math.max(1,Math.round(T.width)),V=Math.max(1,Math.round(T.height));return{cssWidth:A,cssHeight:V,cornerRadius:B(A,V)}},S=M();C.current=Ye({hostCanvas:y,cssWidth:S.cssWidth,cssHeight:S.cssHeight,cornerRadius:S.cornerRadius,kind:I,paused:n,shaderScale:h,ringCssPx:f,scale:d,onFirstCopy:()=>$(!0)}),w.style.setProperty("--mfx-radius",`${S.cornerRadius}px`),w.style.borderRadius=`${S.cornerRadius}px`,v&&(E.current=zt(v,{width:S.cssWidth,height:S.cssHeight,cornerRadius:S.cornerRadius,kind:I,scale:d}));let O=0;const D=new ResizeObserver(()=>{O===0&&(O=requestAnimationFrame(()=>{O=0;const T=M(),A=C.current;A&&(rt(A,{cssWidth:T.cssWidth,cssHeight:T.cssHeight,cornerRadius:T.cornerRadius}),w.style.setProperty("--mfx-radius",`${T.cornerRadius}px`),w.style.borderRadius=`${T.cornerRadius}px`,v&&(v.innerHTML="",E.current=zt(v,{width:T.cssWidth,height:T.cssHeight,cornerRadius:T.cornerRadius,kind:I,scale:d}),A&&E.current&&ct.set(A,{handles:E.current,themeRef:z})))}))});D.observe(w);let U=null;return typeof IntersectionObserver<"u"&&(U=new IntersectionObserver(T=>{const A=C.current;if(A)for(const V of T)ta(A,V.isIntersecting)},{rootMargin:"64px"}),U.observe(w)),C.current&&E.current&&(ct.set(C.current,{handles:E.current,themeRef:z}),Ze(C.current)),()=>{D.disconnect(),U?.disconnect(),O!==0&&cancelAnimationFrame(O);const T=C.current;T&&(ct.delete(T),Je(T),Ke(T)),C.current=null,E.current=null,v&&(v.innerHTML="")}},[I]),_.useEffect(()=>{const y=C.current;y&&rt(y,{opacityMul:Math.max(0,Math.min(1,o))})},[o,e]),_.useEffect(()=>{const y=C.current,w=b.current;if(!y||!w||!l||k!=="dark")return;y.onAfterFrame=lr;const v=l.flatMap(M=>M.current?[M.current]:[]);for(const M of v)nr(M,y,w);return()=>{y.onAfterFrame=void 0;for(const M of v)ir(M)}},[l,k]),_.useEffect(()=>{const y=b.current,w=C.current;if(!y||!w)return;const v=B(w.cssWidth,w.cssHeight);rt(w,{cornerRadius:v}),y.style.setProperty("--mfx-radius",`${v}px`),y.style.borderRadius=`${v}px`},[i,k,e,I]);const H=_.useMemo(()=>({...x,"--mfx-strength":String(Math.min(1,Math.max(0,o))),opacity:N?1:0,visibility:N?"visible":"hidden",transition:N?"opacity 0.15s ease-out":"none"}),[x,o,N]);return p.jsxs("div",{...m,ref:b,className:g?`metal-fx-root ${g}`:"metal-fx-root","data-variant":e,"data-shape":I,"data-theme":k,"data-paused":n?"true":void 0,"data-normalize":u?"true":"false",style:H,children:[p.jsx("canvas",{ref:P,className:"metal-fx-canvas",style:ur}),p.jsx("div",{className:"metal-fx-inner","aria-hidden":"true",style:hr}),p.jsx("div",{ref:j,"aria-hidden":"true",style:{...fr,display:W?void 0:"none"}}),p.jsx("div",{ref:L,className:"metal-fx-content",children:t})]})});he.displayName="MetalFx";const et=18;function fe(){return p.jsxs("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"4"}),p.jsx("path",{d:"M12 2v2"}),p.jsx("path",{d:"M12 20v2"}),p.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),p.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),p.jsx("path",{d:"M2 12h2"}),p.jsx("path",{d:"M20 12h2"}),p.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),p.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function pe(){return p.jsx("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function mr(){return p.jsxs("svg",{"aria-hidden":!0,width:et,height:et,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),p.jsx("path",{d:"M8 21h8"}),p.jsx("path",{d:"M12 17v4"})]})}const xr=[{value:"light",label:"Light",Icon:fe},{value:"dark",label:"Dark",Icon:pe},{value:"system",label:"System",Icon:mr}];function gr(t){return t==="dark"?pe:fe}function vr({theme:t,resolvedTheme:e,onSetTheme:a,className:r="",direction:o="down",align:n="right"}){const[i,u]=_.useState(!1),l=_.useRef(null),c=_.useCallback(()=>u(!1),[]);_.useEffect(()=>{if(!i)return;const f=d=>{l.current&&!l.current.contains(d.target)&&c()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i,c]),_.useEffect(()=>{if(!i)return;const f=d=>{d.key==="Escape"&&c()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[i,c]);const h=gr(e);return p.jsxs("div",{ref:l,className:`relative ${r}`,children:[p.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":i,onClick:()=>u(f=>!f),className:"flex items-center justify-center w-9 h-9 rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors",children:p.jsx(h,{})}),i&&p.jsx("div",{className:`absolute z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg ${o==="up"?"bottom-full mb-1":"top-full mt-1"} ${n==="left"?"left-0":"right-0"}`,children:xr.map(({value:f,label:d,Icon:g})=>{const x=t===f;return p.jsxs("button",{type:"button",onClick:()=>{a(f),c()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-sm transition-colors ${x?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"}`,children:[p.jsx(g,{}),p.jsx("span",{children:d})]},f)})})]})}const br="https://github.com/mm7894215/TokenTracker/releases/latest";function Br({auth:t,signedIn:e,sessionSoftExpired:a,userId:r}){const{currency:o,rate:n}=ke(),{theme:i,resolvedTheme:u,setTheme:l}=xe(),{openLoginModal:c}=ge(),{signedIn:h,loading:f}=ve(),d=!be(),g=e&&!a,x=_.useMemo(()=>g&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,g]),m=_e({userId:r,period:"total",accessToken:x});return p.jsxs("div",{className:"flex flex-col min-h-screen bg-oai-gray-50 dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-oai antialiased transition-colors duration-200",children:[p.jsx("header",{className:"sticky top-0 z-50 w-full px-4 pt-4 pb-2 transition-all duration-300 pointer-events-none",children:p.jsxs("div",{className:"mx-auto max-w-3xl rounded-2xl border border-oai-gray-200/50 dark:border-white/10 bg-white/75 dark:bg-oai-gray-950/60 backdrop-blur-xl shadow-[0_8px_30px_rgb(0,0,0,0.04)] dark:shadow-[0_8px_30px_rgb(0,0,0,0.3)] flex h-14 items-center justify-between px-3 sm:px-4 pointer-events-auto transition-all duration-300",children:[p.jsxs("div",{className:"flex items-center gap-4",children:[p.jsxs(Tt,{to:"/",className:"flex items-center gap-3 no-underline outline-none rounded-md focus-visible:ring-2 focus-visible:ring-indigo-500 transition-opacity hover:opacity-80 active:scale-95",children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),p.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),p.jsx("div",{className:"hidden sm:block scale-90 origin-left opacity-90 hover:opacity-100 transition-opacity",children:p.jsx(Me,{})})]}),p.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[p.jsxs(Tt,{to:"/leaderboard",className:"group no-underline inline-flex items-center gap-1.5 h-8 px-3 text-xs font-bold rounded-full border border-oai-gray-200 dark:border-white/10 bg-transparent text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-white/5 hover:text-oai-black dark:hover:text-white transition-all duration-200 active:scale-95 shadow-sm",children:[p.jsx(we,{size:13,strokeWidth:2.5,"aria-hidden":!0,className:"transition-transform duration-150 ease-out group-hover:scale-110 group-hover:rotate-6"}),p.jsx("span",{children:Y("leaderboard.profile.nav.back")})]}),d&&p.jsx(he,{variant:"button",preset:"chromatic",theme:"dark",borderRadius:9999,disableGlow:!0,className:"!bg-black",children:p.jsxs("a",{href:br,target:"_blank",rel:"noopener noreferrer",className:"group no-underline inline-flex h-8 items-center gap-1.5 px-3 text-xs font-bold rounded-full bg-black text-white transition-transform duration-200 active:scale-[0.98]",children:[p.jsx(Te,{size:13,strokeWidth:2.5,"aria-hidden":!0,className:"transition-transform duration-150 ease-out group-hover:translate-y-0.5"}),p.jsx("span",{className:"hidden sm:inline",children:Y("leaderboard.profile.nav.download")})]})}),f?p.jsx("div",{className:"h-8 w-16 animate-pulse rounded-full bg-oai-gray-200 dark:bg-white/10","aria-hidden":!0}):h?p.jsx(ye,{}):p.jsx("button",{type:"button",onClick:c,className:"inline-flex h-8 min-w-[76px] items-center justify-center px-3 text-xs font-bold rounded-full border border-oai-gray-200 dark:border-white/10 bg-transparent text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-white/5 hover:text-oai-black dark:hover:text-white transition-all duration-200 active:scale-95 shadow-sm select-none",children:Y("header.auth.sign_in_aria")})]})]})}),p.jsx("main",{className:"flex-1 px-4 pt-4 pb-10 sm:pt-6 sm:pb-16",children:p.jsx("div",{className:"mx-auto max-w-3xl",children:p.jsxs("div",{className:"rounded-2xl bg-white dark:bg-oai-gray-950 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden shadow-sm dark:shadow-none",children:[m.loading&&p.jsx(Ce,{variant:"page"}),!m.loading&&m.error&&p.jsx("div",{className:"px-6 py-16 text-center",children:p.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:Y("leaderboard.profile_modal.error")})}),!m.loading&&!m.error&&!m.data&&p.jsx("div",{className:"px-6 py-16 text-center",children:p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:Y("leaderboard.profile_modal.empty")})}),!m.loading&&!m.error&&m.data&&p.jsx(Se,{data:m.data,currency:o,rate:n,variant:"page"})]})})}),p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 px-4 transition-colors duration-200",children:p.jsxs("div",{className:"mx-auto flex max-w-3xl items-center justify-between text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[p.jsx("p",{children:Y("landing.v2.footer.line")}),p.jsx(vr,{theme:i,resolvedTheme:u,onSetTheme:l,direction:"up",align:"right"})]})})]})}export{Br as LeaderboardProfilePage};
import{c as r}from"./__vite-browser-external-Eoyj4eG-.js";const t=["claude","codex","cursor","gemini","kimi","kiro","grok","copilot","antigravity","zcode","opencodeGo"],e={claude:"CLAUDE",codex:"CODEX",cursor:"CURSOR",gemini:"GEMINI",kimi:"KIMI",kiro:"KIRO",grok:"GROK",copilot:"COPILOT",antigravity:"ANTIGRAVITY",zcode:"ZCODE",opencodeGo:"OPENCODE"};function c(i){return e[i]||null}function n(i){switch(i){case"claude":return r("limits.provider.claude");case"codex":return r("limits.provider.codex");case"cursor":return r("limits.provider.cursor");case"gemini":return r("limits.provider.gemini");case"kimi":return r("limits.provider.kimi");case"kiro":return r("limits.provider.kiro");case"grok":return r("limits.provider.grok");case"copilot":return r("limits.provider.copilot");case"antigravity":return r("limits.provider.antigravity");case"zcode":return r("limits.provider.zcode");case"opencodeGo":return r("limits.provider.opencode_go");default:return String(i||"")}}export{t as L,c as a,n as l};
import{k as F,j as t,b as G,c as r,ah as $,r as b,P as Z,ai as ee,R as te,F as ae,L as ie,aj as re}from"./__vite-browser-external-Eoyj4eG-.js";import{P as H,c as ne,r as v,a as oe,u as se,b as le,s as de}from"./use-usage-limits-DJXvJ25Q.js";import{L as x,u as ce}from"./use-limits-display-prefs-CRl4uU95.js";import{C as B}from"./Card-C3nLScju.js";import{F as ue}from"./FadeIn-BDWtfIsO.js";import{L as xe,l as w,a as me}from"./limits-providers-13af4PEg.js";import{L as pe}from"./LocalOnlyNotice-si9PMKya.js";import"./arrow-up-right-CT4-gmOS.js";import"./download-DaWsA_Gj.js";const ge=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],fe=F("bell-off",ge);const he=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],be=F("bell",he),ye=[3,2,3,3,2,2,3];function g({className:e}){return t.jsx("div",{className:G("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",e)})}function ke(){return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(g,{className:"h-3 w-12 shrink-0"}),t.jsx(g,{className:"flex-1 h-1.5 rounded-full min-w-0"}),t.jsx(g,{className:"h-3 w-[30px] shrink-0"}),t.jsx(g,{className:"h-3 w-6 shrink-0"})]})}function ve({bars:e,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(g,{className:"h-[14px] w-[14px] rounded shrink-0"}),t.jsx(g,{className:G("h-4",i)})]}),Array.from({length:e},(o,n)=>t.jsx(ke,{},n))]})}function je(){return t.jsx(B,{children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx(g,{className:"h-3.5 w-28"}),ye.map((e,a)=>t.jsx(ve,{bars:e,index:a},a))]})})}const I=100;function C(e){const a=Date.parse(e);return Number.isFinite(a)?a:null}function we(e){return Math.max(0,Math.min(I,Math.round(e)))}function Ne(e){return new Intl.DateTimeFormat($(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(e))}function _e(e,a,i){if(e==null||e>=a)return I;const o=a-e,n=a-i;return we(n/o*I)}function Me(e){const a=e.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function Ee(e,{now:a}={}){if(!e||typeof e!="object")return null;const i=Me(e);if(i===void 0)return null;const o=Array.isArray(e.credits)?e.credits:[],n=a instanceof Date?a.getTime():Number(a??Date.now()),s=[];for(const c of o){const d=C(c?.expires_at);if(d==null)continue;const l=s.length+1;s.push({key:`reset-${l}`,label:r("limits.codex_reset_bank.row_label",{index:l}),expiresAt:Ne(d),expiresMs:d,percent:_e(C(c?.granted_at),d,n)})}return i===0?null:s.length>0?{kind:"rows",availableCount:i??s.length,rows:s}:i>0?{kind:"count_only",availableCount:i,rows:[]}:null}const Ie="shrink-0 text-oai-black dark:text-oai-white";function Le(e){const a=v(e);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const o=Math.floor(i/6e4);if(o<60)return`${o}m`;const n=Math.floor(o/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function Pe(e,a){const i=a===x.REMAINING?100-e:e;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function k(e,a="used_percent"){return e?a==="utilization"?e.utilization:e.used_percent:null}function j(e,a="reset_at"){return e?a==="resets_at"?e.resets_at:e.reset_at:null}function N(e){const a=Math.max(0,Math.min(100,Number(e)||0)),i=Math.round(a);return a>0&&i===0?r("limits.bar.sub_one_percent"):String(i)}function _(e){const a=Number(e);return Number.isFinite(a)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:a>=100?0:2}).format(a):null}function Oe(e){if(!e||typeof e!="object")return null;const a=_(e.used_credits),i=_(e.limit_credits),o=_(e.remaining_credits);return!a||!i||!o?null:r("limits.codex_credits.detail",{used:a,limit:i,remaining:o})}function Se(e,a){return ne({usedPercent:k(e.window,e.pctField),windowSeconds:oe(e,e.window),resetMs:v(j(e.window,e.resetField)),mode:a})}function W(e){return Number.isFinite(e)?new Intl.DateTimeFormat($(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(e)):null}function Re(e,a,i){const o=[z(e,a,i)],n=v(j(e.window,e.resetField)),s=W(n);if(s&&o.push(r("limits.hover.resets_at",{time:s})),e.key==="credits"){const c=Oe(e.window);c&&o.push(c)}return o.join(`
`)}function U({text:e}){return e?t.jsx("div",{role:"tooltip",className:"pointer-events-none absolute bottom-full left-1/2 z-10 mb-2 w-max max-w-[260px] -translate-x-1/2 whitespace-pre-line rounded-xl border border-oai-gray-200/50 dark:border-oai-gray-800/50 bg-white/90 dark:bg-oai-gray-900/90 backdrop-blur-md px-2.5 py-1.5 text-[10.5px] leading-snug text-oai-gray-700 dark:text-oai-gray-200 shadow-xl opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:e}):null}function Ce({label:e,pct:a,reset:i,mode:o=x.USED,pacePercent:n=null,paceOver:s=!1,title:c=null}){const d=Math.max(0,Math.min(100,Number(a)||0)),l=o===x.REMAINING?100-d:d,u=Math.round(l),m=l>0&&u===0?Math.max(l,.35):l;let f=String(u);l>0&&u===0&&(f=r("limits.bar.sub_one_percent"));const h=n==null?null:Math.max(0,Math.min(100,n));return t.jsxs("div",{className:"group relative flex items-center gap-2",children:[t.jsx(U,{text:c}),t.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:e}),t.jsxs("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[t.jsx("div",{className:`${Pe(l,o)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${m}%`,minWidth:l>0?"3px":0}}),h!=null&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${h}% - 3px)`,width:"6px"}}),t.jsx("div",{className:`absolute top-0 h-full ${s?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${h}% - 1px)`,width:"2px"}})]})]}),t.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:[f,"%"]}),i&&t.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:i})]})}function z(e,a,i){const o=e.label??r(e.labelKey),n=i===x.REMAINING,s=l=>n?100-l:l;if(a.expectedPercent==null){const l=Math.max(0,Math.min(100,Number(k(e.window,e.pctField))||0)),u=N(s(l));return n?r("limits.explain.remaining",{label:o,used:u}):r("limits.explain.used",{label:o,used:u})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:o,eta:a.runsOutEta});const l=N(s(a.projectedEnd??100));return r(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:o,pct:l})}const c=Math.max(0,Math.min(100,Number(k(e.window,e.pctField))||0)),d=N(s(a.projectedEnd??c));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:o,pct:d})}function De({rows:e,mode:a}){if(e.length===0)return null;const i=a===x.REMAINING;return t.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[e.map(({spec:o,pace:n})=>{const s=W(v(j(o.window,o.resetField)));return t.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[z(o,n,a),s?t.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",r("limits.hover.resets_at",{time:s})]}):null]},o.key)}),t.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(i?"limits.explain.body_remaining":"limits.explain.body")})]})}function D(e){if(!e)return null;const a=Date.now()-new Date(e).getTime();if(a<0)return null;const i=Math.floor(a/6e4);if(i<1)return r("shared.time.now");if(i<60)return r("shared.time.m_ago",{n:i});const o=Math.floor(i/60);if(o<24)return r("shared.time.h_ago",{n:o});const n=Math.floor(o/24);return r("shared.time.d_ago",{n})}const A={live:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-emerald-500",pulse:"bg-emerald-400"},stale:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"},cached:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"}};function M({label:e,age:a=null,tone:i="live",tooltip:o=null}){const n=A[i]||A.live,s=i==="live";return t.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:c=>c.stopPropagation(),children:[t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold uppercase tracking-wider border leading-normal ${n.surface}`,children:[s?t.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[t.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${n.pulse} opacity-75`}),t.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${n.dot}`})]}):t.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n.dot}`}),e,a?t.jsxs(t.Fragment,{children:[" · ",a]}):null]}),o?t.jsxs("span",{className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-2 -translate-x-1/2 w-48 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-1.5 text-[10px] font-normal text-white text-center opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-normal shadow-lg origin-bottom border border-oai-gray-800 dark:border-oai-gray-700",children:[o,t.jsx("span",{className:"absolute left-1/2 top-full -translate-x-1/2 border-4 border-transparent border-t-oai-gray-900 dark:border-t-oai-gray-800"})]}):null]})}function L({name:e,providerId:a,children:i,expandable:o=!1,expanded:n=!1,onToggle:s,badge:c=null}){const d=me(a),l=t.jsxs("div",{className:"flex items-center gap-1.5",children:[d?t.jsx(Z,{provider:d,size:14,className:Ie}):null,t.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:e}),c]});return o?t.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:s,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s?.())},className:"flex flex-col gap-1.5 -mx-1.5 px-1.5 py-1 rounded-lg cursor-pointer transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 aria-expanded:bg-oai-gray-50 dark:aria-expanded:bg-oai-gray-800/40",children:[l,i]}):t.jsxs("div",{className:"flex flex-col gap-1.5",children:[l,i]})}const Ae=xe;function y({children:e,tone:a="neutral"}){const i=a==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return t.jsx("div",{className:`text-[11px] leading-snug ${i}`,children:e})}function Te({rows:e,mode:a,extra:i=null}){const o=e.length===0&&!i;return t.jsxs(t.Fragment,{children:[e.map(({spec:n,pace:s})=>t.jsx(Ce,{label:n.label??r(n.labelKey),pct:k(n.window,n.pctField),reset:Le(j(n.window,n.resetField)),mode:a,pacePercent:s.pacePercent,paceOver:s.paceOver,title:Re(n,s,a)},n.key)),o?t.jsx(y,{children:r("limits.status.no_data")}):null,i]})}function Fe(e){if(!Number.isFinite(e.expiresMs))return null;const a=Math.floor((e.expiresMs-Date.now())/864e5);return a<0?null:a===0?r("limits.reset_bank.hover_detail_today",{date:e.expiresAt}):r("limits.reset_bank.hover_detail",{date:e.expiresAt,days:a})}function Ge({row:e}){const a=Math.max(0,Math.min(100,Number(e.percent)||0));return t.jsxs("div",{className:"group relative flex items-center gap-2","data-reset-bank-row":"",children:[t.jsx(U,{text:Fe(e)}),t.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:e.label}),t.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:t.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${a}%`,minWidth:a>0?"3px":0}})}),t.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:e.expiresAt})]})}function $e({model:e}){const a=e.kind==="count_only"?r("limits.codex_reset_bank.count_only",{count:e.availableCount}):null;return t.jsxs("div",{className:"mt-1 flex flex-col gap-1","data-reset-bank-section":e.kind,children:[t.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codex_reset_bank.title")}),a?t.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:a}):e.rows.map(i=>t.jsx(Ge,{row:i},i.key))]})}function He(e,a){if(e==="codex_meta"){const i=Ee(a.reset_credits);return i?t.jsx($e,{model:i}):null}return e==="kimi_parallel"&&a.parallel_limit?t.jsx(y,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})}):e==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?t.jsx(Ue,{defaultDir:a.otel_default_dir}):null}function Be(e,a,i,o,n,s,c=null){const d=H[e];if(!d)return null;const l=d.windows(a).filter(m=>m.window).map(m=>({spec:m,pace:Se(m,o)})),u=He(d.extra,a);return t.jsxs(L,{name:i,providerId:e,expandable:l.length>0,expanded:n,onToggle:s,badge:c,children:[t.jsx(Te,{mode:o,rows:l,extra:u}),n?t.jsx(De,{rows:l,mode:o}):null]},e)}function We(e,a,i,o,n){if(!H[e])return null;if(!a?.configured)return t.jsxs(L,{name:w(e),providerId:e,children:[t.jsx(y,{children:r("limits.status.not_connected")}),e==="opencodeGo"?t.jsx(T,{}):null]},e);if(a.error)return t.jsxs(L,{name:w(e),providerId:e,children:[t.jsx(y,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),e==="opencodeGo"?t.jsx(T,{}):null]},e);const s=w(e),c=a.plan_label?`${s} ${a.plan_label}`:s;let d=null;if(e==="antigravity")if(a.cached){const u=D(a.cached_at);d=t.jsx(M,{label:r("limits.label.antigravity_cached"),age:u,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else d=t.jsx(M,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});const l=a.provenance;return l?.stale&&!d&&(d=t.jsx(M,{label:r("limits.provenance.stale"),age:D(l.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:l.source,confidence:l.confidence})})),Be(e,a,c,i,o,n,d)}function Ue({defaultDir:e}){const[a,i]=b.useState(!1),n=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${e||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
`),s=async c=>{c.stopPropagation();try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1600)}catch{}};return t.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[t.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:r("limits.copilot.otelHint.title")}),t.jsx("div",{className:"mt-0.5 leading-snug",children:r("limits.copilot.otelHint.body")}),t.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:n}),t.jsx("button",{type:"button",onClick:s,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:a?r("limits.copilot.otelHint.copied"):r("limits.copilot.otelHint.copy")})]})}function E({n:e,children:a}){return t.jsxs("li",{className:"flex gap-2.5",children:[t.jsx("span",{className:"mt-[1px] flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-oai-brand/15 text-[9px] font-semibold text-oai-brand",children:e}),t.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:a})]})}function ze(){return t.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",className:"h-2.5 w-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M4.5 2.75h4.75V7.5M9.25 2.75 3 9"})})}function T(){const[e,a]=b.useState(!1),i=['export OPENCODE_GO_AUTH_COOKIE="..."','# Optional: export OPENCODE_GO_WORKSPACE_ID="wrk_..." (Only if auto-discovery fails)'].join(`
`),o=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return t.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[t.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.opencodeGo.setupHint.title")}),t.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.opencodeGo.setupHint.subtitle")}),t.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[t.jsxs(E,{n:"1",children:[t.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),t.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),t.jsx(ze,{})]})]}),t.jsxs(E,{n:"2",children:[t.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")}),t.jsxs("ul",{className:"mt-1 space-y-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:[t.jsx("li",{children:r("limits.opencodeGo.setupHint.step2_workspace")}),t.jsx("li",{children:r("limits.opencodeGo.setupHint.step2_cookie")})]})]}),t.jsxs(E,{n:"3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:r("limits.opencodeGo.setupHint.step3")}),t.jsx("button",{type:"button",onClick:o,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:e?r("limits.opencodeGo.setupHint.copied"):r("limits.opencodeGo.setupHint.copy")})]}),t.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),t.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.opencodeGo.setupHint.note_app")})]})]})]})}function Ke(e){const[a,i]=b.useState(0);return b.useLayoutEffect(()=>{const o=e.current;if(!o)return;const n=o.querySelectorAll("[data-limit-label]");let s=0,c=null;if(n.length>0)try{c=document.createElement("canvas").getContext("2d")}catch{c=null}if(c){const l=window.getComputedStyle(n[0]);c.font=`${l.fontStyle} ${l.fontWeight} ${l.fontSize} ${l.fontFamily}`;for(const u of n)s=Math.max(s,c.measureText(u.textContent).width)}const d=Math.ceil(s);i(l=>l===d?l:d)}),a}function Ve({claude:e,codex:a,cursor:i,gemini:o,kimi:n,kiro:s,grok:c,antigravity:d,copilot:l,zcode:u,opencodeGo:m,order:f,visibility:h,displayMode:K}){const V={claude:e,codex:a,cursor:i,gemini:o,kimi:n,kiro:s,grok:c,antigravity:d,copilot:l,zcode:u,opencodeGo:m},P=b.useRef(null),O=Ke(P),[X,Y]=b.useState(null),q=Array.isArray(f)&&f.length>0?f:Ae,S=K===x.REMAINING?x.REMAINING:x.USED,J=S===x.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used"),R=q.filter(p=>!h||h[p]!==!1).map(p=>We(p,V[p],S,X===p,()=>Y(Q=>Q===p?null:p))).filter(Boolean);return t.jsx(ue,{delay:.15,children:t.jsx(B,{children:t.jsxs("div",{ref:P,className:"flex flex-col gap-3",style:O>0?{"--tt-limits-label-w":`${O}px`}:void 0,children:[t.jsxs("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:[r("limits.panel.title"),r("limits.panel.mode_separator"),J]}),R.length>0?R:t.jsx(y,{children:r("limits.status.all_hidden")})]})})})}const Xe=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");function rt(){const e=ee(),{data:a,error:i,isLoading:o}=se(e?{initialRefresh:!0,initialState:e,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),n=ce(),s=le();return te.useEffect(()=>{s.enabled&&a&&de(a)},[s.enabled,a]),!Xe&&!ae()?t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx(pe,{})}):t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:t.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[t.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:r("nav.limits")}),t.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:r("limits.page.subtitle")})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{s.setEnabled(!s.enabled)},"aria-label":s.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:s.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:s.enabled?t.jsx(be,{className:"h-4 w-4","aria-hidden":!0}):t.jsx(fe,{className:"h-4 w-4","aria-hidden":!0})}),t.jsx(ie,{to:"/settings","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(re,{className:"h-4 w-4","aria-hidden":!0})})]})]}),o?t.jsx(je,{}):t.jsxs(t.Fragment,{children:[i?t.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:r("shared.error.prefix",{error:i})}):null,t.jsx(Ve,{claude:a?.claude,codex:a?.codex,cursor:a?.cursor,gemini:a?.gemini,kimi:a?.kimi,kiro:a?.kiro,grok:a?.grok,antigravity:a?.antigravity,copilot:a?.copilot,zcode:a?.zcode,opencodeGo:a?.opencodeGo,order:n.order,visibility:n.visibility,displayMode:n.displayMode})]})]})})})}export{rt as LimitsPage};
import{k as e}from"./__vite-browser-external-Eoyj4eG-.js";const o=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],t=e("link-2",o);export{t as L};
import{k as e}from"./__vite-browser-external-Eoyj4eG-.js";const o=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],a=e("loader-circle",o);export{a as L};
import{j as e,c as t}from"./__vite-browser-external-Eoyj4eG-.js";import{A as r}from"./arrow-up-right-CT4-gmOS.js";import{D as o}from"./download-DaWsA_Gj.js";const i="https://github.com/mm7894215/TokenTracker/releases/latest";function c(){const a=()=>{try{window.location.href="tokentracker://open"}catch{}};return e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-20 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-white",children:t("local_only.title")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:t("local_only.body")}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("button",{type:"button",onClick:a,className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium bg-oai-gray-900 text-white hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:[e.jsx("span",{children:t("local_only.open_app")}),e.jsx(r,{size:14,strokeWidth:2,"aria-hidden":!0})]}),e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900 transition-colors",children:[e.jsx(o,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t("local_only.download")})]})]})]})})}export{c as L};
import{u as p,d as w,e as v,r,c as s,j as e,L as y,f as j}from"./__vite-browser-external-Eoyj4eG-.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};
import{k as P,N as H,ak as O,r as n,al as q,am as $,an as W,ao as K,c as i,j as e,b,ap as Z}from"./__vite-browser-external-Eoyj4eG-.js";import{u as J,T as E,S as X}from"./use-native-settings-Bi6E9dsE.js";import{n as Y,C as _}from"./ClawdAnimated-CLHhE26z.js";import{F as L}from"./FadeIn-BDWtfIsO.js";import{L as G}from"./link-2-DeN6MJpT.js";import{L as Q}from"./loader-circle-ByEuaaSw.js";import{Z as ee}from"./zap-DWWma29E.js";import{T as te}from"./trash-2-CVCC3DtQ.js";import"./Card-C3nLScju.js";const ae=[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]],re=P("file-archive",ae);const ie=[["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"}]],se=P("monitor-up",ie);const oe=[["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"}]],ne=P("upload",oe),le={visible:!1,character:"clawd",size:"medium"};function de(){const t=H()&&O(),[a,s]=n.useState(le);n.useEffect(()=>{if(!t)return;const d=q(o=>{s({visible:!!o.visible,character:Y(o.character),size:["small","medium","large"].includes(o.size)?o.size:"medium"})});return $(),d},[t]);const l=n.useCallback((d,o)=>{s(x=>({...x,[d]:o})),t&&W(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 z(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 ce(){const t=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),a=await z(t);return[...y,...Array.isArray(a.pets)?a.pets:[]]}async function B(t){const a=await K();return z(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function me(t){return B({action:"install_url",url:t})}async function M(t){const a=await K();return z(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...a},cache:"no-store",body:t}))}function pe(t){return B({action:"remove",id:t})}let C=y;function xe(){const[t,a]=n.useState(C),[s,l]=n.useState(!0),[d,o]=n.useState(!1),x=n.useCallback(async()=>{l(!0);try{const m=await ce();return C=m,a(m),o(!0),m}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 ue={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 ge(){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 be({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:b("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:b("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",ue[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(_,{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:b("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(te,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function he({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}),m=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),p=c.clientY-(u.top+u.height/2),j=(Math.atan2(v,-p)*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}),m]})]}),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(_,{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:b("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:b("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 Pe(){const{available:t,settings:a,setSetting:s}=de(),{pets:l,loading:d,available:o,refresh:x}=xe(),[m,c]=n.useState(""),[u,v]=n.useState(""),[p,j]=n.useState(!1),[U,A]=n.useState("idle-living"),[I,V]=n.useState(!0),f=a.character||"clawd",S=J(),T=S.settings?.menuBarIconStyle==="pet",D=l.find(r=>r.id===f)||l[0],w=p?{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 h=await r();await x(),h?.pet?.id&&s("character",h.pet.id),Z({title:g,timeout:4e3}),c("")}catch(h){v(h?.message||i("pet.import.failed"))}finally{j(!1)}}n.useEffect(()=>{if(!I)return;const r=window.setInterval(()=>{A(g=>{const h=k.findIndex(F=>F.id===g);return k[(h+1)%k.length].id})},5e3);return()=>window.clearInterval(r)},[I]);const R=[{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(L,{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(L,{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(he,{pet:D,state:U,onStateChange:r=>{V(!1),A(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(be,{character:r,selected:f===r.id,onSelect:()=>s("character",r.id),removeDisabled:p,onRemove:o&&r.custom?()=>N(async()=>(await pe(r.id),f===r.id&&s("character","clawd"),null),i("pet.import.removed")):void 0},r.id))}),S.available?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 rounded-xl border border-oai-gray-200/70 bg-oai-gray-50/60 px-3 py-2.5 dark:border-oai-gray-800 dark:bg-oai-gray-900/40",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold",children:i("pet.menubar.title")}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:i("pet.menubar.hint")})]}),e.jsx(E,{checked:T,onChange:()=>S.setSetting("menuBarIconStyle",T?"clawd":"pet"),ariaLabel:i("pet.menubar.title")})]}):null]}),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(ne,{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(ge,{})}),e.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:r=>{r.preventDefault(),!p&&m.trim()&&N(()=>me(m))},children:[e.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[e.jsx(G,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{value:m,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:p||!m.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:[p?e.jsx(Q,{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(),p)return;const g=r.dataTransfer?.files?.[0];g&&N(()=>M(g))},className:b("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",p&&"pointer-events-none opacity-40"),children:[e.jsx(re,{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:p,onChange:r=>{const g=r.target.files?.[0];g&&N(()=>M(g)),r.target.value=""}})]}),w?e.jsx("p",{role:w.kind==="error"?"alert":"status",className:b("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(se,{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(E,{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(X,{options:R,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(ee,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),i("pet.controls.native_only")]})]})]})})]})})})}export{Pe as PetPage};
import{k as Xe,aO as Ue,bt as Ke,bu as le,bv as We,K as ne,aN as ge,r as m,bw as $,bx as me,by as he,bz as oe,aK as be,bA as qe,bB as we,aL as z,aI as Q,bC as W,Y as ue,aD as pe,aM as ze,bD as Ee,bE as Je,bF as Qe,bG as $e,bH as Te,aB as q,j as Y,aJ as Ze,aC as Me,aS as et,bI as tt,bJ as nt,bK as ot,bL as st,aP as rt,y as Le,bM as it,bN as ye,aG as at,bO as ct,bP as lt,aH as ut,aF as ft,bQ as dt,aE as pt}from"./__vite-browser-external-Eoyj4eG-.js";import{n as Pe,o as Ae,q as He,r as ve,v as se,P as gt,w as mt,k as ht,s as Et,x as Tt,y as Pt,e as vt,f as Ct,g as bt,h as Rt,a as Be,j as St,u as Ot,z as It,A as Mt,t as yt,B as xt,I as Ft,D as kt,c as wt,d as Lt,b as At,p as Ht}from"./useScrollLock-C2C-Yazq.js";import{f as Bt,p as Dt,g as Nt}from"./DialogTitle-z86PHHyk.js";import{r as _t,t as jt,v as Yt,w as Gt,x as Vt,y as Xt,z as Ut,A as Kt}from"./SelectItemText-CCW6JeeN.js";const Wt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Tn=Xe("chevron-right",Wt);function qt(e,n){return n!=null&&!Pe(n)?0:typeof e=="function"?e():e}function Ce(e,n,t){const l=qt(e,t);return typeof l=="number"?l:l?.[n]}function xe(e){return typeof e=="function"?e():e}function De(e,n){return n||e==="click"||e==="mousedown"}function zt(e){return e?.includes("mouse")&&e!=="mousedown"}class Re{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new le,this.restTimeout=new le,this.handleCloseOptions=void 0}static create(){return new Re}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const fe=new WeakMap;function de(e){if(!e.performedPointerEventsMutation)return;const n=e.pointerEventsScopeElement;n&&fe.get(n)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),fe.delete(n)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Ne(e,n){const{scopeElement:t,referenceElement:l,floatingElement:i}=n,o=fe.get(t);o&&o!==e&&de(o),de(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=t,e.pointerEventsReferenceElement=l,e.pointerEventsFloatingElement=i,fe.set(t,e),t.style.pointerEvents="none",l.style.pointerEvents="auto",i.style.pointerEvents="auto"}function _e(e){const n=e.context.dataRef.current,t=Ue(()=>n.hoverInteractionState??Re.create()).current;return n.hoverInteractionState||(n.hoverInteractionState=t),Ke(n.hoverInteractionState.disposeEffect),n.hoverInteractionState}function Jt(e,n={}){const{enabled:t=!0,closeDelay:l=0,nodeId:i}=n,o="rootStore"in e?e.rootStore:e,p=o.useState("open"),E=o.useState("floatingElement"),S=o.useState("domReferenceElement"),{dataRef:c}=o.context,r=Ae(),O=He(),h=_e(o),j=We(),u=ne(()=>De(c.current.openEvent?.type,h.interactedInside)),B=ne(()=>zt(c.current.openEvent?.type)),g=ne(()=>{de(h)});ge(()=>{p||(h.pointerType=void 0,h.restTimeoutPending=!1,h.interactedInside=!1,g())},[p,h,g]),m.useEffect(()=>g,[g]),ge(()=>{if(t&&p&&h.handleCloseOptions?.blockPointerEvents&&B()&&$(S)&&E){const x=S,a=E,d=me(E),F=r?.nodesRef.current.find(b=>b.id===O)?.context?.elements.floating;F&&(F.style.pointerEvents="");const H=h.pointerEventsScopeElement!==a?h.pointerEventsScopeElement:null,P=F!==a?F:null,C=h.handleCloseOptions?.getScope?.()??H??P??x.closest("[data-rootownerid]")??d.body;return Ne(h,{scopeElement:C,referenceElement:x,floatingElement:a}),()=>{g()}}},[t,p,S,E,h,B,r,O,g]),m.useEffect(()=>{if(!t)return;function x(){return!!(r&&O&&ve(r.nodesRef.current,O).length>0)}function a(b){const M=Ce(l,"close",h.pointerType),N=()=>{o.setOpen(!1,Q(W,b)),r?.events.emit("floating.closed",b)};M?h.openChangeTimeout.start(M,N):(h.openChangeTimeout.clear(),N())}function d(b){const M=be(b);if(!qe(M)){h.interactedInside=!1;return}h.interactedInside=M?.closest("[aria-haspopup]")!=null}function F(){h.openChangeTimeout.clear(),j.clear(),r?.events.off("floating.closed",P),g()}function H(b){if(x()&&r){r.events.on("floating.closed",P);return}if(we(b.relatedTarget,o.context.triggerElements))return;const M=c.current.floatingContext?.nodeId??i,N=b.relatedTarget;if(!(r&&M&&$(N)&&ve(r.nodesRef.current,M,!1).some(X=>z(X.context?.elements.floating,N)))){if(h.handler){h.handler(b);return}g(),B()&&!u()&&a(b)}}function P(b){!r||!O||x()||j.start(0,()=>{r.events.off("floating.closed",P),o.setOpen(!1,Q(W,b)),r.events.emit("floating.closed",b)})}const C=E;return he(C&&oe(C,"mouseenter",F),C&&oe(C,"mouseleave",H),C&&oe(C,"pointerdown",d,!0),()=>{r?.events.off("floating.closed",P)})},[t,E,o,c,l,i,B,u,g,h,r,O,j])}const Qt={current:null};function $t(e,n={}){const{enabled:t=!0,delay:l=0,handleClose:i=null,mouseOnly:o=!1,restMs:p=0,move:E=!0,triggerElementRef:S=Qt,externalTree:c,isActiveTrigger:r=!0,getHandleCloseContext:O,isClosing:h,shouldOpen:j}=n,u="rootStore"in e?e.rootStore:e,{dataRef:B,events:g}=u.context,x=Ae(c),a=_e(u),d=m.useRef(!1),F=se(i),H=se(l),P=se(p),C=se(t),b=se(j),M=se(h),N=ne(()=>De(B.current.openEvent?.type,a.interactedInside)),V=ne(()=>b.current?.()!==!1),X=ne((s,T,L)=>{const R=u.context.triggerElements;if(R.hasElement(T))return!s||!z(s,T);if(!$(L))return!1;const f=L;return R.hasMatchingElement(A=>z(A,f))&&(!s||!z(s,f))}),_=ne(()=>{if(!a.handler)return;me(u.select("domReferenceElement")).removeEventListener("mousemove",a.handler),a.handler=void 0}),w=ne(()=>{de(a)});return r&&(a.handleCloseOptions=F.current?.__options),m.useEffect(()=>_,[_]),m.useEffect(()=>{if(!t)return;function s(T){T.open?d.current=!1:(d.current=T.reason===W,_(),a.openChangeTimeout.clear(),a.restTimeout.clear(),a.blockMouseMove=!0,a.restTimeoutPending=!1)}return g.on("openchange",s),()=>{g.off("openchange",s)}},[t,g,a,_]),m.useEffect(()=>{if(!t)return;function s(f,A=!0){const D=Ce(H.current,"close",a.pointerType);D?a.openChangeTimeout.start(D,()=>{u.setOpen(!1,Q(W,f)),x?.events.emit("floating.closed",f)}):A&&(a.openChangeTimeout.clear(),u.setOpen(!1,Q(W,f)),x?.events.emit("floating.closed",f))}const T=S.current??(r?u.select("domReferenceElement"):null);if(!$(T))return;function L(f){if(a.openChangeTimeout.clear(),a.blockMouseMove=!1,o&&!Pe(a.pointerType))return;const A=xe(P.current),D=Ce(H.current,"open",a.pointerType),G=be(f),U=f.currentTarget??null,I=u.select("domReferenceElement");let k=U;if($(G)&&!u.context.triggerElements.hasElement(G)){for(const Ie of u.context.triggerElements.elements())if(z(Ie,G)){k=Ie;break}}$(U)&&$(I)&&!u.context.triggerElements.hasElement(U)&&z(U,I)&&(k=I);const v=k==null?!1:X(I,k,G),J=u.select("open"),Z=M.current?.()??u.select("transitionStatus")==="ending",K=!J&&Z&&d.current,ee=!v&&$(k)&&$(I)&&z(I,k)&&K,te=A>0&&!D,Ve=v&&(J||K)||ee,Oe=!J||v;if(Ve){V()&&u.setOpen(!0,Q(W,f,k));return}te||(D?a.openChangeTimeout.start(D,()=>{Oe&&V()&&u.setOpen(!0,Q(W,f,k))}):Oe&&V()&&u.setOpen(!0,Q(W,f,k)))}function R(f){if(N()){w();return}_();const A=u.select("domReferenceElement"),D=me(A);a.restTimeout.clear(),a.restTimeoutPending=!1;const G=B.current.floatingContext??O?.();if(we(f.relatedTarget,u.context.triggerElements))return;if(F.current&&G){u.select("open")||a.openChangeTimeout.clear();const I=S.current;a.handler=F.current({...G,tree:x,x:f.clientX,y:f.clientY,onClose(){w(),_(),C.current&&!N()&&I===u.select("domReferenceElement")&&s(f,!0)}}),D.addEventListener("mousemove",a.handler),a.handler(f);return}(a.pointerType!=="touch"||!z(u.select("floatingElement"),f.relatedTarget))&&s(f)}return E?he(oe(T,"mousemove",L,{once:!0}),oe(T,"mouseenter",L),oe(T,"mouseleave",R)):he(oe(T,"mouseenter",L),oe(T,"mouseleave",R))},[_,w,B,H,u,t,F,a,r,X,N,o,E,P,S,x,C,O,M,V]),m.useMemo(()=>{if(!t)return;function s(T){a.pointerType=T.pointerType}return{onPointerDown:s,onPointerEnter:s,onMouseMove(T){const{nativeEvent:L}=T,R=T.currentTarget,f=u.select("domReferenceElement"),A=u.select("open"),D=X(f,R,T.target);if(o&&!Pe(a.pointerType))return;if(A&&D&&a.handleCloseOptions?.blockPointerEvents){const I=u.select("floatingElement");if(I){const k=a.handleCloseOptions?.getScope?.()??R.ownerDocument.body;Ne(a,{scopeElement:k,referenceElement:R,floatingElement:I})}}const G=xe(P.current);if(A&&!D||G===0||!D&&a.restTimeoutPending&&T.movementX**2+T.movementY**2<2)return;a.restTimeout.clear();function U(){if(a.restTimeoutPending=!1,N())return;const I=u.select("open");!a.blockMouseMove&&(!I||D)&&V()&&u.setOpen(!0,Q(W,L,R))}a.pointerType==="touch"?ue.flushSync(()=>{U()}):D&&A?U():(a.restTimeoutPending=!0,a.restTimeout.start(G,U))}}},[t,a,N,X,o,u,P,V])}const Fe=.1,Zt=Fe*Fe,y=.5;function ie(e,n,t,l,i,o){return l>=n!=o>=n&&e<=(i-t)*(n-l)/(o-l)+t}function ae(e,n,t,l,i,o,p,E,S,c){let r=!1;return ie(e,n,t,l,i,o)&&(r=!r),ie(e,n,i,o,p,E)&&(r=!r),ie(e,n,p,E,S,c)&&(r=!r),ie(e,n,S,c,t,l)&&(r=!r),r}function en(e,n,t){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function ce(e,n,t,l,i,o){const p=Math.min(t,i),E=Math.max(t,i),S=Math.min(l,o),c=Math.max(l,o);return e>=p&&e<=E&&n>=S&&n<=c}function tn(e={}){const{blockPointerEvents:n=!1}=e,t=new le,l=({x:i,y:o,placement:p,elements:E,onClose:S,nodeId:c,tree:r})=>{const O=p?.split("-")[0];let h=!1,j=null,u=null,B=typeof performance<"u"?performance.now():0;function g(a,d){const F=performance.now(),H=F-B;if(j===null||u===null||H===0)return j=a,u=d,B=F,!1;const P=a-j,C=d-u,b=P*P+C*C,M=H*H*Zt;return j=a,u=d,B=F,b<M}function x(){t.clear(),S()}return function(d){t.clear();const F=E.domReference,H=E.floating;if(!F||!H||O==null||i==null||o==null)return;const{clientX:P,clientY:C}=d,b=be(d),M=d.type==="mouseleave",N=z(H,b),V=z(F,b);if(N&&(h=!0,!M))return;if(V&&(h=!1,!M)){h=!0;return}if(M&&$(d.relatedTarget)&&z(H,d.relatedTarget))return;function X(){return!!(r&&ve(r.nodesRef.current,c).length>0)}function _(){X()||x()}if(X())return;const w=F.getBoundingClientRect(),s=H.getBoundingClientRect(),T=i>s.right-s.width/2,L=o>s.bottom-s.height/2,R=s.width>w.width,f=s.height>w.height,A=(R?w:s).left,D=(R?w:s).right,G=(f?w:s).top,U=(f?w:s).bottom;if(O==="top"&&o>=w.bottom-1||O==="bottom"&&o<=w.top+1||O==="left"&&i>=w.right-1||O==="right"&&i<=w.left+1){_();return}let I=!1;switch(O){case"top":I=ce(P,C,A,w.top+1,D,s.bottom-1);break;case"bottom":I=ce(P,C,A,s.top+1,D,w.bottom-1);break;case"left":I=ce(P,C,s.right-1,U,w.left+1,G);break;case"right":I=ce(P,C,w.right-1,U,s.left+1,G);break}if(I)return;if(h&&!en(P,C,w)){_();return}if(!M&&g(P,C)){_();return}let k=!1;switch(O){case"top":{const v=R?y/2:y*4,J=R||T?i+v:i-v,Z=R?i-v:T?i+v:i-v,K=o+y+1,ee=T||R?s.bottom-y:s.top,te=T?R?s.bottom-y:s.top:s.bottom-y;k=ae(P,C,J,K,Z,K,s.left,ee,s.right,te);break}case"bottom":{const v=R?y/2:y*4,J=R||T?i+v:i-v,Z=R?i-v:T?i+v:i-v,K=o-y,ee=T||R?s.top+y:s.bottom,te=T?R?s.top+y:s.bottom:s.top+y;k=ae(P,C,J,K,Z,K,s.left,ee,s.right,te);break}case"left":{const v=f?y/2:y*4,J=f||L?o+v:o-v,Z=f?o-v:L?o+v:o-v,K=i+y+1,ee=L||f?s.right-y:s.left,te=L?f?s.right-y:s.left:s.right-y;k=ae(P,C,ee,s.top,te,s.bottom,K,J,K,Z);break}case"right":{const v=f?y/2:y*4,J=f||L?o+v:o-v,Z=f?o-v:L?o+v:o-v,K=i-y,ee=L||f?s.left+y:s.right,te=L?f?s.left+y:s.right:s.left+y;k=ae(P,C,K,J,K,Z,ee,s.top,te,s.bottom);break}}k?h||t.start(40,_):_()}};return l.__options={...e,blockPointerEvents:n},l}const je=m.createContext(void 0);function re(e){const n=m.useContext(je);if(n===void 0&&!e)throw new Error(pe(47));return n}function nn(){return{...Nt(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const on={...Dt,disabled:q(e=>e.disabled),instantType:q(e=>e.instantType),openMethod:q(e=>e.openMethod),openChangeReason:q(e=>e.openChangeReason),modal:q(e=>e.modal),focusManagerModal:q(e=>e.focusManagerModal),stickIfOpen:q(e=>e.stickIfOpen),titleElementId:q(e=>e.titleElementId),descriptionElementId:q(e=>e.descriptionElementId),openOnHover:q(e=>e.openOnHover),closeDelay:q(e=>e.closeDelay),hasViewport:q(e=>e.hasViewport)};class Se extends ze{constructor(n,t,l=!1){const i={...nn(),...n},o=new gt;i.open&&n?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=Bt(o,t,l),super(i,{popupRef:m.createRef(),backdropRef:m.createRef(),internalBackdropRef:m.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:m.createRef(),beforeContentFocusGuardRef:m.createRef(),stickIfOpenTimeout:new le,triggerElements:o},on)}setOpen=(n,t)=>{const l=t.reason===W,i=t.reason===Ee&&t.event.detail===0,o=!n&&(t.reason===Je||t.reason==null),p=mt(t),E=this.select("activeTriggerId");if(!n&&t.reason===Qe&&t.trigger==null&&E!=null&&(t.trigger=this.context.triggerElements.getById(E)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(n,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(n,t);const S=()=>{const c={open:n,openChangeReason:t.reason};Et(c,n,t.trigger,p()),this.update(c)};l?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start($e,()=>{this.set("stickIfOpen",!1)}),ue.flushSync(S)):S(),i||o?this.set("instantType",i?"click":"dismiss"):t.reason===Te?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(n,t){const{store:l,internalStore:i}=ht(n,(o,p)=>new Se(t,o,p));return m.useEffect(()=>i?.disposeEffect(),[i]),l}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function ke({props:e}){const{children:n,open:t,defaultOpen:l=!1,onOpenChange:i,onOpenChangeComplete:o,modal:p=!1,handle:E,triggerId:S,defaultTriggerId:c=null}=e,r=Se.useStore(E?.store,{modal:p,open:l,openProp:t,activeTriggerId:c,triggerIdProp:S});Pt(r,t,l,c),r.useControlledProp("openProp",t),r.useControlledProp("triggerIdProp",S);const O=r.useState("open"),h=r.useState("mounted"),j=r.useState("payload"),u=He()!=null;r.useContextCallback("onOpenChange",i),r.useContextCallback("onOpenChangeComplete",o),vt(r,O),Ct(r);const{forceUnmount:B}=bt(O,r,()=>{r.update({stickIfOpen:!0,openChangeReason:null})});r.useSyncedValues({modal:p,nested:u}),m.useEffect(()=>{O||r.context.stickIfOpenTimeout.clear()},[r,O]);const g=m.useCallback(()=>{r.setOpen(!1,Q(Ze))},[r]);m.useImperativeHandle(e.actionsRef,()=>({unmount:B,close:g}),[B,g]);const x=O||h,a=m.useMemo(()=>({store:r}),[r]);return Y.jsxs(je.Provider,{value:a,children:[x&&Y.jsx(sn,{store:r,modal:p}),typeof n=="function"?n({payload:j}):n]})}function Pn(e){return re(!0)?Y.jsx(ke,{props:e}):Y.jsx(Tt,{children:Y.jsx(ke,{props:e})})}function sn({store:e,modal:n}){const t=e.useState("floatingRootContext"),l=Rt(t,{outsidePressEvent:{mouse:n==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),i=l.reference??Me,o=l.trigger??Me,p=m.useMemo(()=>et(Be,l.floating),[l.floating]);return St(e,{activeTriggerProps:i,inactiveTriggerProps:o,popupProps:p}),null}const rn=300;function an(e,n){const t=m.useRef(null);function l(o){ue.flushSync(()=>{e.setOpen(!1,Q(Te,o.nativeEvent,o.currentTarget))}),st(t.current)?.focus()}function i(o){const p=e.select("positionerElement");if(p&&tt(o,p))e.context.beforeContentFocusGuardRef.current?.focus();else{ue.flushSync(()=>{e.setOpen(!1,Q(Te,o.nativeEvent,o.currentTarget))});let E=nt(e.context.triggerFocusTargetRef.current||n.current);for(;E!==null&&z(p,E);){const S=E;if(E=ot(E),E===S)break}E?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:l,handleFocusTargetFocus:i}}const vn=m.forwardRef(function(n,t){const{render:l,className:i,style:o,disabled:p=!1,nativeButton:E=!0,handle:S,payload:c,openOnHover:r=!1,delay:O=rn,closeDelay:h=0,id:j,...u}=n,B=re(!0),g=S?.store??B?.store;if(!g)throw new Error(pe(74));const x=Ot(j),a=g.useState("isTriggerActive",x),d=g.useState("floatingRootContext"),F=g.useState("isOpenedByTrigger",x),H=g.useState("triggerPopupId",x),P=m.useRef(null),{registerTrigger:C,isMountedByThisTrigger:b}=It(x,P,g,{payload:c,disabled:p,openOnHover:r,closeDelay:h}),M=g.useState("openChangeReason"),N=g.useState("stickIfOpen"),V=g.useState("openMethod"),X=g.useState("focusManagerModal"),_=$t(d,{enabled:!p&&d!=null&&r&&(V!=="touch"||M!==Ee),mouseOnly:!0,move:!1,handleClose:tn(),restMs:O,delay:{close:h},triggerElementRef:P,isActiveTrigger:a,isClosing:()=>g.select("transitionStatus")==="ending"}),w=_t(d,{enabled:d!=null,stickIfOpen:N}),s=jt(()=>g.select("open"),k=>{g.set("openMethod",k)}),T=g.useState("triggerProps",b),{getButtonProps:L,buttonRef:R}=rt({disabled:p,native:E}),f={open(k){return k&&M===Ee?Mt.open(k):yt.open(k)}},{preFocusGuardRef:A,handlePreFocusGuardFocus:D,handleFocusTargetFocus:G}=an(g,P),I=Le("button",n,{state:{disabled:p,open:F},ref:[R,t,C,P],props:[w.reference,_,T,s,{[it]:"",id:x,"aria-haspopup":"dialog","aria-expanded":F,"aria-controls":H},u,L],stateAttributesMapping:f});return b&&!X?Y.jsxs(m.Fragment,{children:[Y.jsx(ye,{ref:A,onFocus:D}),Y.jsx(m.Fragment,{children:I},x),Y.jsx(ye,{ref:g.context.triggerFocusTargetRef,onFocus:G})]}):Y.jsx(m.Fragment,{children:I},x)}),Ye=m.createContext(void 0);function cn(){const e=m.useContext(Ye);if(e===void 0)throw new Error(pe(45));return e}const Cn=m.forwardRef(function(n,t){const{keepMounted:l=!1,...i}=n,{store:o}=re();return o.useState("mounted")||l?Y.jsx(Ye.Provider,{value:l,children:Y.jsx(at,{ref:t,...i})}):null}),Ge=m.createContext(void 0);function ln(){const e=m.useContext(Ge);if(!e)throw new Error(pe(46));return e}const bn=m.forwardRef(function(n,t){const{render:l,className:i,style:o,anchor:p,positionMethod:E="absolute",side:S="bottom",align:c="center",sideOffset:r=0,alignOffset:O=0,collisionBoundary:h="clipping-ancestors",collisionPadding:j=5,arrowPadding:u=5,sticky:B=!1,disableAnchorTracking:g=!1,collisionAvoidance:x=ct,...a}=n,{store:d}=re(),F=cn(),H=xt(),P=d.useState("floatingRootContext"),C=d.useState("mounted"),b=d.useState("open"),M=d.useState("openChangeReason"),N=d.useState("activeTriggerElement"),V=d.useState("modal"),X=d.useState("openMethod"),_=d.useState("positionerElement"),w=d.useState("instantType"),s=d.useState("transitionStatus"),T=d.useState("hasViewport"),L=m.useRef(null),R=lt(_,!1,!1),f=Yt({anchor:p,floatingRootContext:P,positionMethod:E,mounted:C,side:S,sideOffset:r,align:c,alignOffset:O,arrowPadding:u,collisionBoundary:h,collisionPadding:j,sticky:B,disableAnchorTracking:g,keepMounted:F,nodeId:H,collisionAvoidance:x,adaptiveOrigin:T?Xt:void 0}),A=P.useState("domReferenceElement");ge(()=>{const I=A,k=L.current;if(I&&(L.current=I),k&&I&&I!==k){d.set("instantType",void 0);const v=new AbortController;return R(()=>{d.set("instantType","trigger-change")},v.signal),()=>{v.abort()}}},[A,R,d]),Gt(b&&V===!0&&M!==W,X==="touch",_,N);const D=m.useCallback(I=>{d.set("positionerElement",I)},[d]),G={open:b,side:f.side,align:f.align,anchorHidden:f.anchorHidden,instant:w},U=Vt(n,G,{styles:f.positionerStyles,transitionStatus:s,props:a,refs:[t,D],hidden:!C,inert:!b});return Y.jsxs(Ge.Provider,{value:f,children:[C&&V===!0&&M!==W&&Y.jsx(Ft,{ref:d.context.internalBackdropRef,inert:ut(!b),cutout:N}),Y.jsx(kt,{id:H,children:U})]})}),un=m.createContext(void 0);function fn(){const[e,n]=m.useState(0),t=ne(()=>(n(i=>i+1),()=>{n(i=>Math.max(0,i-1))}));return{context:m.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}function dn(e){const{value:n,children:t}=e;return Y.jsx(un.Provider,{value:n,children:t})}const pn={...Ht,...pt},Rn=m.forwardRef(function(n,t){const{render:l,className:i,style:o,initialFocus:p,finalFocus:E,...S}=n,{store:c}=re(),r=ln(),O=Ut()!=null,{context:h,hasClosePart:j}=fn(),u=c.useState("open"),B=c.useState("openMethod"),g=c.useState("instantType"),x=c.useState("transitionStatus"),a=c.useState("popupProps"),d=c.useState("titleElementId"),F=c.useState("descriptionElementId"),H=c.useState("modal"),P=c.useState("mounted"),C=c.useState("openChangeReason"),b=c.useState("activeTriggerElement"),M=c.useState("floatingRootContext"),N=M.useState("floatingId"),V=c.useState("disabled"),X=c.useState("openOnHover"),_=c.useState("closeDelay"),w=S.id??N;ft({open:u,ref:c.context.popupRef,onComplete(){u&&c.context.onOpenChangeComplete?.(!0)}}),Jt(M,{enabled:X&&!V,closeDelay:_});const s=p===void 0?wt(c.context.popupRef):p,T=H!==!1&&j;c.useSyncedValue("focusManagerModal",T);const L=m.useCallback(A=>{c.set("popupElement",A)},[c]),R={open:u,side:r.side,align:r.align,instant:g,transitionStatus:x},f=Le("div",n,{state:R,ref:[t,c.context.popupRef,L],props:[a,{id:w,role:"dialog",...Be,"aria-labelledby":d,"aria-describedby":F,onKeyDown(A){O&&At.has(A.key)&&A.stopPropagation()}},Kt(x),S],stateAttributesMapping:pn});return Y.jsx(Lt,{context:M,openInteractionType:B,modal:T,disabled:!P||C===W,initialFocus:s,returnFocus:E,restoreFocus:"popup",previousFocusableElement:dt(b)?b:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:Y.jsx(dn,{value:h,children:f})})});export{Tn as C,Pn as P,vn as a,Cn as b,bn as c,Rn as d};
import{k as Ne,r as i,j as e,c as n,S as Ie,ae as He,af as Ge,X as Oe,Y as qe}from"./__vite-browser-external-Eoyj4eG-.js";import{u as Ke}from"./useCurrency-BtHtcsO5.js";import{u as Ee}from"./useTokenFormat-BdD057ih.js";import{M as Ze,T as Ve}from"./terminal-DyicX7lG.js";import{I as Je}from"./info-B46Qt16h.js";const Qe=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],et=Ne("pause",Qe);const tt=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],at=Ne("play",tt);const rt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],ot=Ne("rotate-ccw",rt),te={emerald:{light:["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],dark:["#2d333b","#065f46","#059669","#10b981","#34d399"],gridColor:{light:"rgba(16, 185, 129, 0.12)",dark:"rgba(52, 211, 153, 0.08)"}},ocean:{light:["#f1f5f9","#93c5fd","#60a5fa","#3b82f6","#1d4ed8"],dark:["#1e293b","#1e3a8a","#2563eb","#3b82f6","#60a5fa"],gridColor:{light:"rgba(59, 130, 246, 0.12)",dark:"rgba(96, 165, 250, 0.08)"}},neon:{light:["#faf5ff","#ebd5ff","#c084fc","#a855f7","#7e22ce"],dark:["#2e1065","#581c87","#8b5cf6","#a855f7","#c084fc"],gridColor:{light:"rgba(168, 85, 247, 0.12)",dark:"rgba(192, 132, 252, 0.08)"}},amber:{light:["#fffbeb","#fde68a","#f59e0b","#d97706","#b45309"],dark:["#451a03","#78350f","#b45309","#d97706","#f59e0b"],gridColor:{light:"rgba(245, 158, 11, 0.12)",dark:"rgba(245, 158, 11, 0.08)"}}};function nt(s,x){const h=/^#([0-9a-f]{6})$/i.exec(s);if(!h)return s;const c=parseInt(h[1],16),v=c>>16&255,D=c>>8&255,Y=c&255,R=T=>Math.max(0,Math.min(255,Math.round(T*x)));return`rgb(${R(v)}, ${R(D)}, ${R(Y)})`}function O(s,x,h,c,v){const D=Math.cos(c),Y=Math.sin(c),R=s*D-x*Y,T=s*Y+x*D,E=h,S=Math.cos(v),$=Math.sin(v),q=R,p=T*S-E*$,k=T*$+E*S;return{x:q,y:p,z:k}}function st(s,x,h,c,v){return O(s,x,h,c,v)}function Ae(s,x,h=c=>Number(c).toLocaleString()){const c=h(x);if(s>=4){const v=Math.floor(Math.random()*3)+1;return n(`heatmap.3d.voxel.joke.${v}`,{value:c})}else return s===3?n("heatmap.3d.voxel.level3",{value:c}):s===2?n("heatmap.3d.voxel.level2",{value:c}):s===1?n("heatmap.3d.voxel.level1",{value:c}):n("heatmap.3d.voxel.level0")}function Se({weeks:s,palette:x="auto",isDark:h=!1,interactive:c=!1,autoRotateInit:v=!1,onResetViewRef:D=null}){const{formatTokens:Y,formatTokensTooltip:R}=Ee(),T=te[x]||(x==="auto"?te.emerald:null),E=T?h?T.dark:T.light:Array.isArray(x)?x:h?te.emerald.dark:te.emerald.light,S=T?h?T.gridColor.dark:T.gridColor.light:h?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",$=-.2,q=.88,[p,k]=i.useState({yaw:$,pitch:q}),[ce,K]=i.useState(v),[he,L]=i.useState(1),C=c?13:10.5,fe=i.useMemo(()=>{const t=[],r=s.length;if(r===0||!c)return[];for(let l=0;l<=7;l++){const o=(l-3.5)*C,d=O(-r/2*C,o,0,p.yaw,p.pitch),u=O(r/2*C,o,0,p.yaw,p.pitch);t.push({d:`M${d.x},${d.y} L${u.x},${u.y}`,key:`horiz-${l}`})}for(let l=0;l<=r;l+=4){const o=(l-r/2)*C,d=O(o,-3.5*C,0,p.yaw,p.pitch),u=O(o,3.5*C,0,p.yaw,p.pitch);t.push({d:`M${d.x},${d.y} L${u.x},${u.y}`,key:`vert-${l}`})}if(r%4!==0){const l=(r-r/2)*C,o=O(l,-3.5*C,0,p.yaw,p.pitch),d=O(l,3.5*C,0,p.yaw,p.pitch);t.push({d:`M${o.x},${o.y} L${d.x},${d.y}`,key:"vert-last"})}return t},[s.length,p,C,c]);i.useEffect(()=>{D&&(D.current={reset:()=>{k({yaw:$,pitch:q}),K(!1),L(1),be()},toggleAutoRotate:t=>{K(t)}})},[D]);const Z=i.useRef(null),I=i.useRef(null),F=i.useRef(!1),de=i.useRef({x:0,y:0}),V=i.useRef({yaw:$,pitch:q}),U=i.useRef({x:0,y:0}),oe=i.useRef({x:0,y:0,time:0}),ne=i.useRef(null),[ge,ye]=i.useState(0),J=i.useRef(null),se=i.useRef(!0);i.useEffect(()=>(se.current=!0,()=>{se.current=!1}),[]);const be=()=>{J.current&&cancelAnimationFrame(J.current),ye(0);const t=performance.now(),r=1200,l=o=>{if(!se.current)return;const d=o-t,u=Math.min(1,d/r),j=1-Math.pow(1-u,3);ye(j),u<1?J.current=requestAnimationFrame(l):J.current=null};J.current=requestAnimationFrame(l)};i.useEffect(()=>(be(),()=>{J.current&&cancelAnimationFrame(J.current)}),[c]),i.useEffect(()=>{if(!ce||F.current||typeof window>"u"||typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;let r;const l=()=>{if(typeof document<"u"&&document.visibilityState==="hidden"){r=requestAnimationFrame(l);return}k(o=>({yaw:o.yaw+.002,pitch:o.pitch})),r=requestAnimationFrame(l)};return r=requestAnimationFrame(l),()=>cancelAnimationFrame(r)},[ce]);const me=(t,r)=>{c&&(F.current=!0,de.current={x:t,y:r},V.current={yaw:p.yaw,pitch:p.pitch},U.current={x:0,y:0},oe.current={x:t,y:r,time:performance.now()},ne.current&&cancelAnimationFrame(ne.current))},X=(t,r)=>{if(!F.current)return;const l=t-de.current.x,o=r-de.current.y,d=performance.now(),u=d-oe.current.time;u>0&&(U.current={x:(t-oe.current.x)/u,y:(r-oe.current.y)/u}),oe.current={x:t,y:r,time:d};const j=.005,f=V.current.yaw-l*j,g=Math.PI/2.3,P=Math.max(-g,Math.min(g,V.current.pitch-o*j));k({yaw:f,pitch:P})},ve=()=>{if(!F.current)return;F.current=!1;let t=-U.current.x*12,r=-U.current.y*12;const l=.95,o=()=>{F.current||(t*=l,r*=l,!(Math.abs(t)<.01&&Math.abs(r)<.01)&&(k(d=>{const u=d.yaw+t*.005,j=Math.PI/2.3,f=Math.max(-j,Math.min(j,d.pitch+r*.005));return{yaw:u,pitch:f}}),ne.current=requestAnimationFrame(o)))};ne.current=requestAnimationFrame(o)},[y,xe]=i.useState(null),[Q,pe]=i.useState({x:0,y:0,shiftX:0}),b=i.useRef(null);i.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]),i.useEffect(()=>{if(!c||!I.current)return;const t=l=>{l.preventDefault();const o=-l.deltaY*.0025;L(d=>{const u=d+o;return Math.max(.5,Math.min(3,u))})},r=I.current;return r.addEventListener("wheel",t,{passive:!1}),()=>{r.removeEventListener("wheel",t)}},[c]);const z=i.useMemo(()=>{const t=[];return s.forEach((r,l)=>{(Array.isArray(r)?r:[]).forEach((o,d)=>{o&&t.push({key:o.day||`${l}-${d}`,col:l,row:d,level:o.level||0,value:o.value||0,day:o.day,models:o.models||null})})}),t},[s]),ke=C-(c?1.8:1.5),we=c?38:28,ee=t=>Math.max(1.8,Number(t)/4*we),ae=i.useMemo(()=>{if(z.length===0)return[];const t=s.length;return z.map(r=>{const l=ee(r.level),o=Math.sqrt(Math.pow(r.col-t/2,2)+Math.pow(r.row-3.5,2)),d=Math.sqrt(Math.pow(t/2,2)+Math.pow(3.5,2)),u=o/d*.4,j=Math.min(1,Math.max(0,(ge-u)*(1/.6))),f=l*j,g=(r.col-t/2)*C,P=(r.row-3.5)*C,N=ke/2,G=[{x:g-N,y:P-N,z:0},{x:g+N,y:P-N,z:0},{x:g+N,y:P+N,z:0},{x:g-N,y:P+N,z:0},{x:g-N,y:P-N,z:f},{x:g+N,y:P-N,z:f},{x:g+N,y:P+N,z:f},{x:g-N,y:P+N,z:f}].map(W=>O(W.x,W.y,W.z,p.yaw,p.pitch)),ue=O(g,P,f/2,p.yaw,p.pitch),Le=[{name:"top",indices:[4,5,6,7],scale:1,normal:[0,0,1]},{name:"bottom",indices:[3,2,1,0],scale:.4,normal:[0,0,-1]},{name:"left",indices:[3,0,4,7],scale:.55,normal:[-1,0,0]},{name:"right",indices:[1,2,6,5],scale:.75,normal:[1,0,0]},{name:"front",indices:[0,1,5,4],scale:.85,normal:[0,-1,0]},{name:"back",indices:[2,3,7,6],scale:.65,normal:[0,1,0]}],Pe=E[Math.min(4,Math.max(0,Number(r.level)||0))],ze=[],De=.35,Ye=-.4,Ue=.83;return Le.forEach(W=>{const je=st(W.normal[0],W.normal[1],W.normal[2],p.yaw,p.pitch);if(je.z>.001){const Me=G[W.indices[0]],Te=G[W.indices[1]],_e=G[W.indices[2]],$e=G[W.indices[3]],Xe=`M${Me.x},${Me.y} L${Te.x},${Te.y} L${_e.x},${_e.y} L${$e.x},${$e.y} Z`,Be=je.x*De+je.y*Ye+je.z*Ue,We=h?.18:0,Fe=W.scale*(.82+.28*Math.max(0,Be))+We;ze.push({name:W.name,d:Xe,fill:nt(Pe,Fe)})}}),{...r,centerProj:ue,renderedFaces:ze}})},[z,p,E,s.length,ge,C,ke,we]),le=i.useMemo(()=>[...ae].sort((t,r)=>t.centerProj.z-r.centerProj.z),[ae]),_=i.useMemo(()=>{if(le.length===0)return{minX:-100,minY:-100,maxX:100,maxY:100};let t=1/0,r=1/0,l=-1/0,o=-1/0;return le.forEach(d=>{const u=C*2,j=d.centerProj.x,f=d.centerProj.y;j-u<t&&(t=j-u),j+u>l&&(l=j+u),f-u<r&&(r=f-u),f+u>o&&(o=f+u)}),{minX:t,minY:r,maxX:l,maxY:o}},[le,C]),A=12,a=_.maxX-_.minX+A*2,m=_.maxY-_.minY+A*2,M=a/he,w=m/he,B=_.minX-A+(a-M)/2,H=_.minY-A+(m-w)/2,ie=`${B} ${H} ${M} ${w}`;return z.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:n("heatmap.empty")}):e.jsxs("div",{ref:I,className:`relative select-none outline-none ${c?"cursor-grab active:cursor-grabbing w-full h-full flex items-center justify-center":"w-full overflow-hidden flex justify-center"}`,onMouseDown:t=>{if(!c)return;me(t.clientX,t.clientY);const r=o=>X(o.clientX,o.clientY),l=()=>{ve(),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",l)},onTouchStart:t=>{!c||t.touches.length===0||me(t.touches[0].clientX,t.touches[0].clientY)},onTouchMove:t=>{!c||t.touches.length===0||X(t.touches[0].clientX,t.touches[0].clientY)},onTouchEnd:()=>{c&&ve()},children:[e.jsxs("svg",{ref:Z,viewBox:ie,width:c?"95%":"100%",height:c?"95%":"auto",role:"img","aria-label":n("heatmap.iso.aria")||"3D interactive activity heatmap",style:{display:"block",width:"100%",height:"auto",maxWidth:c?"none":`${a}px`,maxHeight:c?"78vh":"none"},className:"transition-transform duration-300 ease-out",children:[c&&fe.map(t=>e.jsx("path",{d:t.d,fill:"none",stroke:S,strokeWidth:.25,strokeDasharray:"1.5 2.5",strokeLinecap:"round"},t.key)),le.map(t=>{const r=y&&y.key===t.key;return e.jsxs("g",{onMouseEnter:l=>{if(b.current&&(clearTimeout(b.current),b.current=null),xe(t),c&&Z.current){const o=O((t.col-s.length/2)*C,(t.row-3.5)*C,ee(t.level),p.yaw,p.pitch);let d=0,u=0;const j=Z.current;if(I.current&&typeof j.createSVGPoint=="function"&&typeof j.getScreenCTM=="function")try{const N=j.createSVGPoint();N.x=o.x,N.y=o.y;const re=j.getScreenCTM();if(re){const G=N.matrixTransform(re),ue=I.current.getBoundingClientRect();d=G.x-ue.left,u=G.y-ue.top}}catch{const re=j.getBoundingClientRect(),G=_.maxX-_.minX+A*2,ue=_.maxY-_.minY+A*2;d=(o.x-(_.minX-A))/G*re.width,u=(o.y-(_.minY-A))/ue*re.height}else{const N=j.getBoundingClientRect(),re=_.maxX-_.minX+A*2,G=_.maxY-_.minY+A*2;d=(o.x-(_.minX-A))/re*N.width,u=(o.y-(_.minY-A))/G*N.height}const f=140;let g=0;const P=I.current?I.current.getBoundingClientRect().width:j.getBoundingClientRect().width;d<f?g=f-d:d>P-f&&(g=P-f-d),pe({x:d,y:u,shiftX:g})}},onMouseLeave:()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{xe(null)},150)},className:"transition-all duration-200",style:{filter:r?"brightness(1.15) drop-shadow(0 4px 6px rgba(0,0,0,0.15))":"none",cursor:c?"pointer":"default"},children:[!c&&t.day&&e.jsx("title",{children:`${t.day}: ${R(t.value)} tokens`}),t.renderedFaces.map((l,o)=>e.jsx("path",{d:l.d,fill:l.fill,stroke:l.fill,strokeWidth:.25,strokeLinejoin:"round"},o))]},t.key)})]}),c&&y&&e.jsxs("div",{onMouseEnter:()=>{b.current&&(clearTimeout(b.current),b.current=null)},onMouseLeave:()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{xe(null)},150)},className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out",style:{left:`${Q.x}px`,top:`${Q.y}px`},children:[e.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${Q.shiftX}px))`},children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:y.day}),(()=>{const t=y.level===0?h?"#9ca3af":"#6b7280":E[y.level];return e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:t+"22",color:t,border:`1px solid ${t}44`},children:["Level ",y.level]})})()]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{title:R(y.value),className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:Y(y.value)}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),y.models&&Object.keys(y.models).length>0?e.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 scrollbar-thin",children:Object.entries(y.models).map(([t,r])=>({name:t,val:Number(r)})).sort((t,r)=>r.val-t.val).map(({name:t,val:r})=>{const l=Number(y.value)||1,o=Math.round(r/l*100);return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[e.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:t,children:t}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{title:R(r),className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:Y(r)}),e.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[o,"%"]})]})]}),e.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${o}%`,backgroundColor:E[4],boxShadow:`0 0 4px ${E[4]}55`}})})]},t)})})]}):e.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:Ae(y.level,y.value,Y)})]})]}),e.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]})]})}const lt=12,it=3,ct=26,dt=["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],mt=["#121212","#065f46","#059669","#10b981","#34d399"];function xt(s){if(typeof s!="string")return null;const x=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s.trim());if(!x)return null;const h=new Date(Date.UTC(Number(x[1]),Number(x[2])-1,Number(x[3])));return Number.isFinite(h.getTime())?h:null}function Re(s,x){return new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()+x))}function ut(s,x){return Math.floor((Date.UTC(x.getUTCFullYear(),x.getUTCMonth(),x.getUTCDate())-Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()))/864e5)}function pt(s,x){const h=x==="mon"?1:0,c=s.getUTCDay();return Re(s,-((c-h+7)%7))}function ht(s,x,h,c){if(!s)return[];const v=xt(x)||new Date,D=[];for(let S=11;S>=0;S-=1)D.push(new Date(Date.UTC(v.getUTCFullYear(),v.getUTCMonth()-S,1)));const Y=pt(v,h),R=Re(Y,-(s-1)*7),T=[],E=new Set;for(const S of D){const $=Math.floor(ut(R,S)/7);$<0||$>=s||E.has($)||(E.add($),T.push({label:c[S.getUTCMonth()],index:$}))}return T}function jt({heatmap:s,timeZoneLabel:x,timeZoneShortLabel:h,hideLegend:c=!1,embedded:v=!1}){const{resolvedTheme:D}=Ie(),{currency:Y,rate:R}=Ke(),{formatTokens:T,formatTokensTooltip:E}=Ee(),S=D==="dark",$=S?mt:dt,q=i.useRef(null),p=i.useRef(null),[k,ce]=i.useState(null),[K,he]=i.useState({x:0,y:0,shiftX:0,flipY:!1}),L=i.useRef(null);i.useEffect(()=>()=>{L.current&&clearTimeout(L.current)},[]);const[C,fe]=i.useState(!1),[Z,I]=i.useState(!1),[F,de]=i.useState(!1),V=i.useRef(null),[U,oe]=i.useState("emerald"),ne=[n("heatmap.month.jan"),n("heatmap.month.feb"),n("heatmap.month.mar"),n("heatmap.month.apr"),n("heatmap.month.may"),n("heatmap.month.jun"),n("heatmap.month.jul"),n("heatmap.month.aug"),n("heatmap.month.sep"),n("heatmap.month.oct"),n("heatmap.month.nov"),n("heatmap.month.dec")],ge=(a,m)=>{if(!m||!m.day)return;L.current&&(clearTimeout(L.current),L.current=null),ce(m);const M=a.currentTarget.getBoundingClientRect(),w=typeof window<"u"?window.innerWidth:1024,B=M.left+M.width/2,H=M.top<300,ie=H?M.bottom:M.top,t=140;let r=0;B<t?r=t-B:B>w-t&&(r=w-t-B),he({x:B,y:ie,shiftX:r,flipY:H})},ye=()=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{ce(null)},150)},J=()=>{I(!1),fe(!0)},se=()=>{I(!0)},be=a=>{a.target===a.currentTarget&&Z&&(fe(!1),I(!1))};i.useEffect(()=>{if(!C||Z)return;const a=m=>{m.key==="Escape"&&se()};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[C,Z]);const me=i.useMemo(()=>({emerald:{accentText:"text-emerald-500 dark:text-emerald-400",accentBg:"bg-emerald-500/10 dark:bg-emerald-400/10",accentBorder:"border-emerald-500/20 dark:border-emerald-400/15",hoverBorder:"hover:border-emerald-500/30 dark:hover:border-emerald-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(16,185,129,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(52,211,153,0.25)]",rawColor:"#10b981"},ocean:{accentText:"text-blue-500 dark:text-blue-400",accentBg:"bg-blue-500/10 dark:bg-blue-400/10",accentBorder:"border-blue-500/20 dark:border-blue-400/15",hoverBorder:"hover:border-blue-500/30 dark:hover:border-blue-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(59,130,246,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(96,165,250,0.25)]",rawColor:"#3b82f6"},neon:{accentText:"text-purple-500 dark:text-purple-400",accentBg:"bg-purple-500/10 dark:bg-purple-400/10",accentBorder:"border-purple-500/20 dark:border-purple-400/15",hoverBorder:"hover:border-purple-500/30 dark:hover:border-purple-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(168,85,247,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(192,132,252,0.25)]",rawColor:"#a855f7"},amber:{accentText:"text-amber-500 dark:text-amber-400",accentBg:"bg-amber-500/10 dark:bg-amber-400/10",accentBorder:"border-amber-500/20 dark:border-amber-400/15",hoverBorder:"hover:border-amber-500/30 dark:hover:border-amber-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(245,158,11,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(245,158,11,0.25)]",rawColor:"#f59e0b"}}),[]),X=me[U]||me.emerald,ve=te[U]?S?te[U].dark:te[U].light:S?te.emerald.dark:te.emerald.light,[y,xe]=i.useState(()=>{if(v)return"2d";try{return window.localStorage?.getItem("tt:heatmap-view")==="3d"?"3d":"2d"}catch{return"2d"}});i.useEffect(()=>{if(!v)try{window.localStorage?.setItem("tt:heatmap-view",y)}catch{}},[y,v]),i.useEffect(()=>{if(y!=="2d")return;const a=q.current;a&&(a.scrollLeft=a.scrollWidth)},[s?.weeks,y]),i.useEffect(()=>{const a=q.current;if(!a)return;const m=()=>{L.current&&(clearTimeout(L.current),L.current=null),ce(null)};return a.addEventListener("scroll",m),()=>a.removeEventListener("scroll",m)},[]);const Q=s?.week_starts_on==="mon"?"mon":"sun",pe=i.useMemo(()=>{const a=Array.isArray(s?.weeks)?s.weeks:[];if(!a.length)return{weeks:[]};const m=[];for(const M of a)for(const w of Array.isArray(M)?M:[])w?.day&&m.push({day:w.day,total_tokens:w.total_tokens??w.value??0,billable_total_tokens:w.billable_total_tokens??w.value??w.total_tokens??0,models:w.models??null});return He({dailyRows:m,weeks:Math.max(52,a.length),to:s?.to,weekStartsOn:Q})},[s?.to,s?.weeks,Q]),b=pe?.weeks||[],z=i.useMemo(()=>{let a=0,m=0,M={day:"无数据",value:0},w=0,B=0;const H=[];b.forEach(f=>{(Array.isArray(f)?f:[]).forEach(g=>{g&&g.day&&H.push(g)})}),H.sort((f,g)=>f.day.localeCompare(g.day)),H.forEach(f=>{const g=Number(f.value)||0;a+=g,g>0?(m++,w++,w>B&&(B=w)):w=0,g>M.value&&(M={day:f.day,value:g})});const ie=H.length||365,t=(m/ie*100).toFixed(1);let r="heatmap.3d.modal.ai.eval.default",l="heatmap.3d.modal.ai.title.default";a>=15e6?(l="heatmap.3d.modal.ai.title.peak",r="heatmap.3d.modal.ai.eval.peak"):a>=5e6?(l="heatmap.3d.modal.ai.title.heavy",r="heatmap.3d.modal.ai.eval.heavy"):a>=1e6?(l="heatmap.3d.modal.ai.title.core",r="heatmap.3d.modal.ai.eval.core"):a>=2e4&&(l="heatmap.3d.modal.ai.title.steady",r="heatmap.3d.modal.ai.eval.steady");const o=s?.total_cost_usd,d=Number(o),j=o!=null&&(typeof o!="string"||o.trim()!=="")&&Number.isFinite(d)?d:a/15e5;return{totalTokens:a,activeDays:m,activeRate:t,maxSingleDay:M,maxStreak:B,aiEvaluationTitleKey:l,aiEvaluationKey:r,totalCostUsd:j}},[b,s?.total_cost_usd]),Ce=i.useMemo(()=>Ge(z.totalCostUsd,{currency:Y,rate:R}),[z.totalCostUsd,Y,R]),ke=Q==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(a=>n(`heatmap.day.${a.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(a=>n(`heatmap.day.${a.toLowerCase()}`)),we=i.useMemo(()=>ht(b.length,pe?.to,Q,ne),[pe?.to,b.length,Q,ne]);if(!b.length)return e.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:n("heatmap.empty")});const ee=v?10:lt,ae=v?2:it,le=v?22:ct,_=le+b.length*ee+Math.max(0,b.length-1)*ae,A=`${le}px repeat(${b.length}, ${ee}px)`;return e.jsxs("div",{ref:p,className:v?"relative":"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[!v&&e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:n("heatmap.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{role:"tablist","aria-label":"Heatmap view",className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[10px]",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":y==="2d",onClick:()=>xe("2d"),className:y==="2d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:n("heatmap.view.2d")}),e.jsx("button",{type:"button",role:"tab","aria-selected":y==="3d",onClick:()=>xe("3d"),className:y==="3d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:n("heatmap.view.3d")})]}),e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-450",children:h||n("heatmap.legend.utc")})]})]}),y==="3d"&&e.jsxs("div",{onClick:J,className:"cursor-pointer group relative overflow-hidden rounded-lg hover:border-oai-gray-350 dark:hover:border-oai-gray-700 border border-transparent transition-all",title:n("heatmap.3d.hover_tip"),children:[e.jsx(Se,{weeks:b,isDark:S,palette:U}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-oai-gray-900/5 to-transparent pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity flex items-end justify-center pb-2",children:e.jsxs("span",{className:"text-[10px] bg-white/95 dark:bg-oai-gray-900/95 shadow border border-oai-gray-200/60 dark:border-oai-gray-800/80 px-2.5 py-1 rounded-full font-medium text-oai-gray-500 dark:text-oai-gray-400 flex items-center gap-1 transform translate-y-2 group-hover:translate-y-0 transition-transform duration-200",children:[e.jsx(Ze,{size:9}),n("heatmap.3d.hover_tip")]})})]}),y==="2d"&&e.jsx("div",{ref:q,className:`overflow-x-auto overflow-y-hidden heatmap-scroll-thin${v?"":" pb-1"}`,children:e.jsxs("div",{style:{minWidth:_},children:[e.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:A,columnGap:ae},children:[e.jsx("span",{}),we.map(a=>e.jsx("span",{style:{gridColumnStart:a.index+2},className:"whitespace-nowrap",children:a.label},`${a.label}-${a.index}`))]}),e.jsxs("div",{className:"grid",style:{gridTemplateColumns:A,columnGap:ae},children:[e.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${ee}px)`,rowGap:ae},children:ke.map(a=>e.jsx("span",{className:"leading-none",children:a},a))}),e.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${ee}px)`,gap:ae},children:b.map((a,m)=>(Array.isArray(a)?a:[]).map((M,w)=>{if(!M)return null;const B=M.day||`e-${m}-${w}`,H=Number(M.level)||0,ie=$[H]||$[0];return e.jsx("span",{onMouseEnter:t=>ge(t,M),onMouseLeave:ye,className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10 cursor-pointer",style:{width:ee,height:ee,background:ie}},B)}))})]})]})}),!c&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:n("heatmap.legend.less")}),e.jsx("div",{className:"flex gap-0.5",children:$.map((a,m)=>e.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:a}},m))}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:n("heatmap.legend.more")})]}),C&&e.jsx("div",{onAnimationEnd:be,onClick:a=>{a.target===a.currentTarget&&se()},className:`fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40 ${Z?"animate-tt-fade-out":"animate-tt-fade-in"}`,children:e.jsxs("div",{className:`relative w-full max-w-6xl h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden ${Z?"animate-tt-modal-exit":"animate-tt-modal"}`,children:[e.jsx("button",{type:"button",onClick:se,className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 transition-all duration-300",children:e.jsx(Oe,{size:16})}),e.jsxs("div",{className:"w-full md:w-[340px] border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:X.rawColor}}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:X.rawColor}})]}),e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:"3D Insight"})]}),e.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:n("heatmap.3d.modal.title")}),e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:n("heatmap.3d.modal.desc")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[e.jsxs("div",{className:"flex flex-col gap-1 relative group cursor-help",children:[e.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:n("heatmap.3d.modal.stats.precision_total_tokens")}),e.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[E(z.totalTokens)," Tokens"]})]})}),e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.total_tokens")}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:T(z.totalTokens,{decimals:2})}),e.jsx("div",{className:"opacity-30 group-hover:opacity-60 transition-opacity",children:e.jsx("svg",{width:"24",height:"10",viewBox:"0 0 24 10",fill:"none",children:e.jsx("path",{d:"M1 9C3 7 5 7 7 4C9 1 11 0 13 2C15 4 17 0 23 0",stroke:X.rawColor,strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.estimated_cost")}),e.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:Ce})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.active_rate_days")}),e.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[z.activeRate,"% ",e.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",z.activeDays,"D)"]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.max_streak")}),e.jsxs("span",{className:"text-xl font-black text-amber-500 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[z.maxStreak," ",e.jsx("span",{className:"text-[10px] font-bold text-amber-500/80 font-mono",children:n("heatmap.3d.modal.stats.days_suffix")})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 col-span-2 relative group cursor-help",children:[e.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:n("heatmap.3d.modal.stats.precision_peak_value")}),e.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[z.maxSingleDay.value>0?E(z.maxSingleDay.value):n("heatmap.3d.modal.stats.no_data")," Tokens"]}),e.jsx("span",{className:"text-[8px] text-zinc-400 dark:text-zinc-500 mt-0.5",children:z.maxSingleDay.day!=="无数据"?z.maxSingleDay.day:n("heatmap.3d.modal.stats.no_data")})]})}),e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.peak_day")}),e.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[z.maxSingleDay.value>0?T(z.maxSingleDay.value,{decimals:2}):n("heatmap.3d.modal.stats.no_data")," ",e.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",z.maxSingleDay.day!=="无数据"?z.maxSingleDay.day:n("heatmap.3d.modal.stats.no_data"),")"]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2.5 py-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[e.jsx(Ve,{size:11,style:{color:X.rawColor}}),e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:X.rawColor},children:n(z.aiEvaluationTitleKey)})]}),e.jsxs("div",{className:"pl-3.5 border-l-2 relative transition-all duration-300 group",style:{borderColor:X.rawColor},children:[e.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:X.rawColor}}),e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:n(z.aiEvaluationKey)})]})]}),e.jsx("div",{className:"mt-auto border-t border-zinc-200/50 dark:border-zinc-800/50 pt-4 select-none",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.legend.title")}),e.jsx("span",{className:"text-[10px] font-medium text-zinc-500 dark:text-zinc-400",children:n(`heatmap.3d.modal.palette.${U}`)})]}),e.jsx("div",{className:"flex gap-1",children:ve.map((a,m)=>e.jsx("div",{className:"flex-1 h-1 rounded-[2px]",style:{backgroundColor:a},title:`Level ${m}`},m))})]})})]}),e.jsxs("div",{className:"flex-1 h-full relative flex items-center justify-center overflow-hidden p-4",children:[e.jsx("div",{className:"absolute top-1/4 left-1/3 w-96 h-96 rounded-full blur-[130px] pointer-events-none -translate-x-1/2 -translate-y-1/2 transition-all duration-500",style:{backgroundColor:X.rawColor+"15"}}),e.jsx("div",{className:"absolute bottom-1/4 right-1/3 w-80 h-80 rounded-full blur-[120px] pointer-events-none translate-x-1/2 translate-y-1/2 bg-purple-500/[0.04] dark:bg-purple-500/[0.08]"}),e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 flex items-center gap-3 p-1.5 backdrop-blur-md bg-white/70 dark:bg-oai-gray-900/75 border border-oai-gray-200/60 dark:border-oai-gray-800/80 rounded-full shadow-lg z-30 select-none",children:[e.jsx("div",{className:"flex items-center gap-1.5 px-2",children:Object.keys(me).map(a=>{const m=U===a;return e.jsx("button",{type:"button",onClick:()=>oe(a),title:n(`heatmap.3d.modal.palette.${a}`),className:`w-3.5 h-3.5 rounded-full transition-all duration-200 relative hover:scale-125 ${a==="emerald"?"bg-[#10b981]":a==="ocean"?"bg-[#3b82f6]":a==="neon"?"bg-[#a855f7]":"bg-[#f59e0b]"}`,children:m&&e.jsx("span",{className:"absolute inset-0 rounded-full ring-2 ring-offset-1 ring-offset-white dark:ring-offset-oai-gray-900 ring-oai-gray-900 dark:ring-white scale-110"})},a)})}),e.jsx("div",{className:"w-[1px] h-4 bg-oai-gray-200 dark:bg-oai-gray-800"}),e.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[e.jsx("button",{type:"button",onClick:()=>{const a=!F;de(a),V.current&&V.current.toggleAutoRotate(a)},title:F?n("heatmap.3d.modal.control.pause"):n("heatmap.3d.modal.control.play"),className:`p-1.5 rounded-full transition-all duration-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 ${F?X.accentText:"text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250"}`,children:F?e.jsx(et,{size:12}):e.jsx(at,{size:12})}),e.jsx("button",{type:"button",onClick:()=>{de(!1),V.current&&V.current.reset()},title:n("heatmap.3d.modal.control.reset"),className:"p-1.5 rounded-full text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-all duration-200",children:e.jsx(ot,{size:12})})]})]}),e.jsx(Se,{weeks:b,isDark:S,interactive:!0,palette:U,autoRotateInit:F,onResetViewRef:V}),e.jsxs("div",{className:"absolute bottom-4 right-4 flex items-center gap-1.5 text-[9px] font-bold text-oai-gray-400 bg-white/80 dark:bg-oai-gray-900/80 border border-oai-gray-200/50 dark:border-oai-gray-800/80 rounded-md px-2.5 py-1.5 select-none pointer-events-none backdrop-blur-md shadow-sm",children:[e.jsx(Je,{size:10,className:X.accentText}),e.jsx("span",{children:n("heatmap.3d.modal.footer.tip")})]})]})]})}),k&&!C&&typeof document<"u"&&qe.createPortal(e.jsxs("div",{className:"fixed z-[9999] w-0 h-0 transition-all duration-100 ease-out pointer-events-none",style:{position:"fixed",left:`${K.x}px`,top:`${K.y}px`},children:[e.jsxs("div",{className:`absolute left-0 ${K.flipY?"top-[10px]":"bottom-[10px]"} backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100`,style:{transform:`translateX(calc(-50% + ${K.shiftX}px))`},children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:k.day}),(()=>{const a=k.level===0?S?"#9ca3af":"#6b7280":$[k.level];return e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:a+"22",color:a,border:`1px solid ${a}44`},children:["Level ",k.level]})})()]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{title:E(k.total_tokens??k.value),className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:T(k.total_tokens??k.value)}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),k.models&&Object.keys(k.models).length>0?e.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 oai-scrollbar",children:Object.entries(k.models).map(([a,m])=>({name:a,val:Number(m)})).sort((a,m)=>m.val-a.val).map(({name:a,val:m})=>{const M=Number(k.total_tokens??k.value)||1,w=Math.round(m/M*100);return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[e.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:a,children:a}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{title:E(m),className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:T(m)}),e.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[w,"%"]})]})]}),e.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${w}%`,backgroundColor:$[4],boxShadow:`0 0 4px ${$[4]}55`}})})]},a)})})]}):e.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:Ae(k.level,k.total_tokens??k.value,T)})]})]}),e.jsx("div",{className:`absolute left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 shadow-sm ${K.flipY?"top-[6px] border-l border-t":"bottom-[6px] border-r border-b"} border-oai-gray-200/50 dark:border-oai-gray-800/50`,style:K.flipY?{marginTop:"1px"}:{marginBottom:"1px"}})]}),document.body),e.jsx("style",{children:`
@keyframes tt-fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes tt-fade-out {
from { opacity: 1; }
to { opacity: 0; }
}
@keyframes tt-modal-entrance {
from {
opacity: 0;
transform: scale(0.96) translateY(10px);
}
to {
opacity: 1;
transform: scale(1) translateY(0);
}
}
@keyframes tt-modal-exit {
from {
opacity: 1;
transform: scale(1) translateY(0);
}
to {
opacity: 0;
transform: scale(0.96) translateY(10px);
}
}
.animate-tt-fade-in {
animation: tt-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.animate-tt-fade-out {
animation: tt-fade-out 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.animate-tt-modal {
animation: tt-modal-entrance 0.3s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
}
.animate-tt-modal-exit {
animation: tt-modal-exit 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
`})]})}const ft={anythingllm:"AnythingLLM"};function gt(s){return String(s||"").trim().toLowerCase().replace(/[\s_-]+/g,"")}function Nt(s){const x=String(s||"").trim();if(!x)return"";const h=ft[gt(x)];return h||x.charAt(0).toUpperCase()+x.slice(1)}export{jt as A,Nt as f};
import{d,e as m,r as t,j as e,L as l,c as o,f as x}from"./__vite-browser-external-Eoyj4eG-.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};
import{r as v,J as l,K as w,y as k,j as e,b as x}from"./__vite-browser-external-Eoyj4eG-.js";import{u as j,a as N,s as i,L as C,b as E,S as I,c as R,d as T,C as L,e as A,f as P,g as _,h as D,i as G,j as M}from"./SelectItemText-CCW6JeeN.js";import{C as O}from"./check-B87_qvAg.js";const V=v.forwardRef(function(t,s){const{render:n,className:f,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"?E.className:void 0},S=w(b=>{r.set("listElement",b)});return k("div",t,{ref:[s,S],props:[m,c]})}),z="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 J({value:y,onValueChange:t,options:s=[],ariaLabel:n,id:f,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(I,{value:y,items:h,disabled:o,onValueChange:a=>{!o&&a!=null&&t?.(a)},children:[e.jsxs(R,{id:f,"aria-label":n,className:x(z,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(L,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),e.jsx(A,{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(V,{role:"listbox","aria-label":n,children:s.map(a=>e.jsxs(D,{value:a.value,disabled:a.disabled,className:({selected:p,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",p?"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(G,{children:e.jsx(O,{className:"h-3 w-3","aria-hidden":!0})})}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.jsx(M,{children:a.label})})]},String(a.value)))})})})})]})}export{J as S};

Sorry, the diff of this file is too big to display

import{k as w,r as c,a5 as ae,a7 as ie,bd as G,j as t,x as U,P as se,b as N,c as a,e as oe,at as re,be as le,ay as ce,az as ue,ab as F,bf as de,bg as ge,U as he,R as C,H as pe,S as me,bh as R,l as I,bi as be,bj as fe,M as xe,bk as ye,v as ve,bl as je,bm as ke,bn as Ne,bo as Se,bp as we,bq as Ce,br as Le,L as Ee,b2 as Ae,bs as Ge,ap as P}from"./__vite-browser-external-Eoyj4eG-.js";import{u as Ie,L as _}from"./use-limits-display-prefs-CRl4uU95.js";import{a as O,l as T}from"./limits-providers-13af4PEg.js";import{a as k,T as j,b,S as L,u as H}from"./use-native-settings-Bi6E9dsE.js";import{P as Pe,u as _e,a as Oe}from"./use-session-efficiency-pref-YAG-OYIh.js";import{C as Te}from"./check-B87_qvAg.js";import{C as De}from"./copy-Dtr68epm.js";import{u as Me}from"./useCurrency-BtHtcsO5.js";import{u as Ue}from"./useTokenFormat-BdD057ih.js";import{S as $}from"./Select-CH2xVU8X.js";import{I as Fe}from"./info-B46Qt16h.js";import{C as Re}from"./ConfirmModal-CTDarLrD.js";import{A as He}from"./arrow-up-right-CT4-gmOS.js";import{D as $e}from"./download-DaWsA_Gj.js";import"./Card-C3nLScju.js";import"./SelectItemText-CCW6JeeN.js";import"./useScrollLock-C2C-Yazq.js";import"./DialogTitle-z86PHHyk.js";import"./DialogDescription-ahxSNUcB.js";const Be=[["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"}]],Ve=w("activity",Be);const ze=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ke=w("grip-vertical",ze);const qe=[["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"}]],Ze=w("languages",qe);const We=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ye=w("log-out",We),Qe=e=>!e.isLayoutDirty&&e.willUpdate(!1);function D(){const e=new Set,n=new WeakMap,i=()=>e.forEach(Qe);return{add:s=>{e.add(s),n.set(s,s.addEventListener("willUpdate",i))},remove:s=>{e.delete(s);const o=n.get(s);o&&(o(),n.delete(s)),i()},dirty:i}}const Je=c.createContext(null);function Xe(){const e=c.useRef(!1);return ae(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function et(){const e=Xe(),[n,i]=c.useState(0),s=c.useCallback(()=>{e.current&&i(n+1)},[n]);return[c.useCallback(()=>ie.postRender(s),[s]),n]}const B=e=>e===!0,tt=e=>B(e===!0)||e==="id",nt=({children:e,id:n,inherit:i=!0})=>{const s=c.useContext(G),o=c.useContext(Je),[r,l]=et(),u=c.useRef(null),g=s.id||o;u.current===null&&(tt(i)&&g&&(n=n?g+"-"+n:g),u.current={id:n,group:B(i)&&s.group||D()});const h=c.useMemo(()=>({...u.current,forceRender:r}),[l]);return t.jsx(G.Provider,{value:h,children:e})},at="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function it({checked:e,onChange:n,ariaLabel:i}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":i,onClick:n,className:N("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:N("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function st({prefs:e}){const{order:n,visibility:i,toggle:s,moveToward:o}=e,[r,l]=c.useState(null),[u,g]=c.useState(null),h=d=>f=>{l(d),f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",d)},m=d=>f=>{f.preventDefault(),f.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},x=()=>{l(null),g(null)},y=d=>{d.preventDefault(),l(null),g(null)};return t.jsx(nt,{children:t.jsx("div",{className:"flex flex-col",children:n.map(d=>{const f=i[d]!==!1,p=r===d;return t.jsxs(U.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:h(d),onDragOver:m(d),onDragEnd:x,onDrop:y,className:N("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",p&&"opacity-40"),style:{cursor:p?"grabbing":"grab"},children:[t.jsx(Ke,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),O(d)?t.jsx(se,{provider:O(d),size:18,className:N("pointer-events-none",at)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:T(d)}),t.jsx("div",{onMouseDown:v=>v.stopPropagation(),draggable:!1,children:t.jsx(it,{checked:f,onChange:()=>s(d),ariaLabel:`${a("limits.settings.toggle_visible")}: ${T(d)}`})})]},d)})})})}function ot(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},i=e.profile&&typeof e.profile=="object"?e.profile:{},s=n.full_name||n.name||i.name||n.user_name||n.preferred_username;return typeof s=="string"&&s.trim()?s.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function rt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function lt(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const i=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),s=n.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=i?.[1]||s?.[1];return o?`https://github.com/${o}`:null}function E(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function ct(e,n,i){const[s,o]=c.useState(()=>re()),r=n&&i&&le(),l=c.useCallback(async()=>{const u=!s;if(ce(u),o(u),!!u)try{await ue(()=>e())}catch(g){E("cloud sync",g)}},[s,e]);return{cloudSyncOn:s,handleCloudSyncToggle:l,showLocalCloudSync:r}}function ut(e){const[n,i]=c.useState(!1),[s,o]=c.useState(!1),[r,l]=c.useState(!1),[u,g]=c.useState(!1),[h,m]=c.useState(null),[x,y]=c.useState(!1),[d,f]=c.useState(""),[p,v]=c.useState(!1),[S,A]=c.useState(""),[q,Z]=c.useState(""),[W,Y]=c.useState(!1),[Q,J]=c.useState(null),X=c.useMemo(()=>ot(e),[e]),ee=c.useMemo(()=>rt(e),[e]),te=c.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),ne=c.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:A,setProfileLoading:l,setPublicProfileOn:i,setShowGithubOn:v}),[]);return{anonymousOn:s,customDisplayName:h,displayName:X,editingGithub:W,editingName:x,email:ee,githubError:Q,githubInput:q,githubUrl:S,loadSetters:ne,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:Y,setEditingName:y,setGithubError:J,setGithubInput:Z,setGithubUrl:A,setNameInput:f,setProfileLoading:l,setProfileSaving:g,setPublicProfileOn:i,setShowGithubOn:v,showGithubOn:p,userId:te}}function dt(e,n,i){c.useEffect(()=>{if(!n)return;let s=!0;return i.setProfileLoading(!0),(async()=>{try{const o=await F({getAccessToken:e});if(!s||!o)return;const r=await de({accessToken:o});if(!s)return;i.setPublicProfileOn(!!r?.enabled),i.setAnonymousOn(!!r?.anonymous),r?.display_name&&i.setCustomDisplayName(r.display_name),i.setShowGithubOn(!!r?.show_github_url),i.setGithubUrl(r?.github_url||"")}catch(o){E("load public profile",o)}finally{s&&i.setProfileLoading(!1)}})(),()=>{s=!1}},[e,n,i])}function gt(e,n){return c.useCallback(async(i,{label:s,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await F({getAccessToken:e});if(!l)return!1;const u=await ge({accessToken:l,...i});return r?.(u),!0}catch(l){return o?o(l):E(s||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function ht(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function pt(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function mt(e,n){const i=c.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:c.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:i}}function bt(e,n,i){const s=c.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await n({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),i?.()}})},[n,e,i]),o=c.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:s,startEditingName:o}}function ft(e,n){const i=c.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),s=c.useCallback(async()=>{const r=lt(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(a("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||a("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=c.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:s,handleShowGithubToggle:i,startEditingGithub:o}}function xt(){const e=oe(),n=ut(e.user),i=ct(e.getAccessToken,e.enabled,e.signedIn);dt(e.getAccessToken,e.signedIn,n.loadSetters);const s=gt(e.getAccessToken,n),o=mt(n,s),r=bt(n,s,e.refreshDisplayName),l=ft(n,s);return{...e,...i,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:ht(n,{...o,...r}),github:pt(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function V({disabled:e,onCancel:n,onSave:i,saveLabel:s=a("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:i,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:s}),t.jsx("button",{type:"button",onClick:n,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:a("settings.account.cancel")})]})}function yt({nameInput:e,setEditingName:n,setNameInput:i,profileSaving:s,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>i(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&n(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:a("settings.account.displayName")}),t.jsx(V,{disabled:s||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:s?a("settings.account.saving"):void 0})]})}function vt({githubError:e,githubInput:n,handleSaveGithub:i,profileSaving:s,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:n,onChange:u=>{l(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&i(),u.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:a("settings.account.githubUrlPlaceholder")}),t.jsx(V,{disabled:s,onCancel:()=>{o(!1),r(null)},onSave:i,saveLabel:s?a("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function z({disabled:e=!1,label:n,onClick:i,title:s}){return t.jsxs("button",{type:"button",onClick:i,disabled:e,title:s,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Pe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function K({actions:e,editing:n,editor:i,hint:s,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),n?i:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s})]}),n?null:e]})})}function jt({name:e}){const n=e.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(z,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function kt({name:e}){const{anonymousOn:n,customDisplayName:i,displayName:s,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:u,profileLoading:g,profileSaving:h,setEditingName:m,setNameInput:x,startEditingName:y}=e,d=n?a("settings.account.displayNameAnonymousHint"):i||s;return t.jsx(K,{label:a("settings.account.displayName"),editing:o,hint:d,editor:t.jsx(yt,{nameInput:u,setEditingName:m,setNameInput:x,profileSaving:h,handleSaveName:l}),actions:t.jsx(jt,{name:e})})}function Nt({github:e}){const{editingGithub:n,githubError:i,githubInput:s,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:u,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:x,showGithubOn:y,startEditingGithub:d}=e;return t.jsx(t.Fragment,{children:t.jsx(K,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(vt,{githubError:i,githubInput:s,handleSaveGithub:r,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:x}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(z,{label:a("settings.account.edit"),onClick:d}),t.jsx(j,{checked:y,onChange:l,disabled:u||g,ariaLabel:a("settings.account.githubUrl")})]})})})}function St(){const{openLoginModal:e}=he();return t.jsx(k,{title:a("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:a("settings.account.signIn")})]})})}function wt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(kt,{name:e}),t.jsx(Nt,{github:n})]})}function Ct(){const e=xt();return e.enabled?e.signedIn?t.jsxs(k,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Et,{onSignOut:e.signOut}),children:[t.jsx(Lt,{userId:e.userId}),t.jsx(At,{settings:e}),t.jsx(Gt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(It,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(St,{}):null}function Lt({userId:e}){const[n,i]=C.useState(!1);if(!e)return null;const s=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),i(!0),globalThis.setTimeout(()=>i(!1),1200)}catch{i(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:a("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":a("settings.account.copyUserId"),children:[n?t.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function Et({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(Ye,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function At({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function Gt({checked:e,disabled:n,onChange:i}){return t.jsx(b,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:i,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function It({visible:e,name:n,github:i}){return t.jsx(pe,{initial:!1,children:e?t.jsx(U.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(wt,{name:n,github:i})},"public-profile-fields"):null})}function Pt(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:be},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:fe},{value:"system",label:a("settings.appearance.theme.system"),Icon:xe}]}function _t(){return[{value:je,label:a("settings.appearance.language.system")},{value:ke,label:a("settings.appearance.language.english")},{value:Ne,label:a("settings.appearance.language.chinese")},{value:Se,label:a("settings.appearance.language.traditional_chinese")},{value:we,label:a("settings.appearance.language.japanese")},{value:Ce,label:a("settings.appearance.language.korean")},{value:Le,label:a("settings.appearance.language.german")}]}function Ot(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function Tt(e,n){const i=a(`settings.appearance.currency.rate_source.${e}`),s=Ot(n),o=s?a("settings.appearance.currency.rate_updated",{when:s}):a("settings.appearance.currency.rate_never");return`${i} · ${o}`}function Dt({locale:e,setLocale:n}){const i=_t();return t.jsx($,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(Ze,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Mt({currency:e,setCurrency:n}){const i=ye().map(s=>({value:s.code,label:a(s.labelKey)}));return t.jsx($,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Ut({currency:e,rate:n,rateSource:i,rateFetchedAt:s}){if(e===ve)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=Tt(i,s);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Ft(){const{theme:e,setTheme:n}=me(),{locale:i,setLocale:s}=R(),{currency:o,rate:r,rateSource:l,rateFetchedAt:u,setCurrency:g}=Me(),{mode:h,setMode:m}=Ue();return t.jsxs(k,{title:a("settings.section.appearance"),children:[t.jsx(b,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(L,{options:Pt(),value:e,onChange:n})}),t.jsx(b,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(Dt,{locale:i,setLocale:s})}),t.jsx(b,{label:a("settings.appearance.currency.label"),hint:t.jsx(Ut,{currency:o,rate:r,rateSource:l,rateFetchedAt:u}),control:t.jsx(Mt,{currency:o,setCurrency:g})}),t.jsx(b,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:t.jsx(L,{options:[{value:I.COMPACT,label:a("settings.appearance.token_format.compact")},{value:I.FULL,label:a("settings.appearance.token_format.full")}],value:h,onChange:m})})]})}function M({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:a(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:a("qpd.card.badge")})]})}function Rt(){const{enabled:e,toggle:n}=_e(),{enabled:i,toggle:s}=Oe();return t.jsxs(k,{title:a("settings.section.labs"),children:[t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:n,ariaLabel:a("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:t.jsx(j,{checked:i,onChange:s,ariaLabel:a("settings.labs.sessions.aria")})})]})}function Ht(){const{available:e,settings:n,setSetting:i,runAction:s}=H();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.launchAtLoginSupported!==!1,l=n?.updateStatus||null,u=!!n?.updateBusy,g=!!n?.isSyncing;return t.jsxs(k,{title:a("settings.section.menubar"),children:[t.jsx(b,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:t.jsxs(Ee,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[a("settings.menubar.appearanceLink"),t.jsx(He,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),r?t.jsx(b,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>i("launchAtLogin",!o),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>s("syncNow"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Ae,{className:N("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(b,{label:a("settings.menubar.updates"),hint:l||void 0,control:t.jsxs("button",{type:"button",onClick:()=>s("checkForUpdates"),disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx($e,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function $t(e,n){function i(r){return r.replace(/^v/,"").split(".").map(Number)}const s=i(e),o=i(n);for(let r=0;r<Math.max(s.length,o.length);r++){const l=s[r]||0,u=o[r]||0;if(l<u)return!0;if(l>u)return!1}return!1}function Bt(){const{available:e,settings:n,runAction:i}=H(),s=e&&n?.version,[o,r]=C.useState(!1),[l,u]=C.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:g}=R(),h="0.82.0",m=async()=>{r(!0);try{const p=await fetch("https://api.github.com/repos/mm7894215/TokenTracker/releases/latest");if(!p.ok)throw new Error("Failed to fetch");const v=await p.json(),S=v.tag_name;$t(h,S)?u({open:!0,latestVersion:S,htmlUrl:v.html_url}):P({title:a("settings.menubar.updates.upToDate")})}catch(p){console.error("Check updates failed:",p),P({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},x=a("settings.menubar.updates.modalTitle"),y=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),d=a("settings.menubar.updates.modalConfirm"),f=a("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[s?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:h})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>i("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCore",{version:h})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:m,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Ge,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(Ve,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(Re,{open:l.open,title:x,description:y,confirmLabel:d,cancelLabel:f,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),u(p=>({...p,open:!1}))},onCancel:()=>u(p=>({...p,open:!1}))})]})}function Vt({prefs:e}){return t.jsx(L,{options:[{value:_.USED,label:a("limits.settings.display_mode_used")},{value:_.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function dn(){const e=Ie();return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.page.subtitle")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ft,{}),t.jsx(Ht,{}),t.jsx(Ct,{}),t.jsx(Rt,{}),t.jsx(k,{title:a("settings.section.limits"),action:t.jsx(Vt,{prefs:e}),children:t.jsx(st,{prefs:e})})]}),t.jsx(Bt,{})]})})})}export{dn as SettingsPage};
import{k as da,r as i,j as e,J as it,y as ca,X as Se,c as r,b as Z,aN as na,aD as _a,aO as ot,aP as lt,aQ as ha,aR as dt,aS as ct,aC as ut,aT as xa,aU as mt,aV as gt,aI as ht,aW as xt,aF as pt,aE as ft,H as yt,w as bt,x as pa,aX as kt,af as wt,P as be,aY as vt,aZ as jt,a_ as Nt,a$ as Ct,b0 as St,b1 as _t,F as Pt,B as W,b2 as Rt,b3 as ia,R as Lt,b4 as It,b5 as fa,ap as Ce,b6 as ya,b7 as ba,b8 as Et,b9 as ka,ba as wa,bb as $t,bc as Bt}from"./__vite-browser-external-Eoyj4eG-.js";import{L as Tt}from"./LocalOnlyNotice-si9PMKya.js";import{C as Dt}from"./Card-C3nLScju.js";import{C as va}from"./ConfirmModal-CTDarLrD.js";import{I as Pa}from"./info-B46Qt16h.js";import{u as Mt}from"./useCurrency-BtHtcsO5.js";import{L as ee}from"./loader-circle-ByEuaaSw.js";import{C as _e}from"./check-B87_qvAg.js";import{T as ua}from"./trash-2-CVCC3DtQ.js";import{u as Ot,s as Ut,k as Ra,l as Ft,m as zt,n as At,o as Kt,p as Vt,q as qt,S as La,c as Ia,d as Ea,C as ma,e as $a,f as Ba,g as Ta,h as We,j as Ge,i as Qe}from"./SelectItemText-CCW6JeeN.js";import{t as Ht,u as oa,m as Wt}from"./useScrollLock-C2C-Yazq.js";import{F as Gt}from"./flame-vLBOq0X0.js";import{D as Da}from"./download-DaWsA_Gj.js";import{P as Ma,a as Oa,b as Ua,c as Fa,d as za,C as Qt}from"./PopoverPopup-DX7v1XfE.js";import"./arrow-up-right-CT4-gmOS.js";import"./DialogTitle-z86PHHyk.js";import"./DialogDescription-ahxSNUcB.js";const Xt=[["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=da("circle-arrow-up",Xt);const Yt=[["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"}]],la=da("external-link",Yt);const Jt=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ka=da("plus",Jt);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})}),Zt="tt:hint:dismissed:";function qa(a){return Zt+a}function er(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(qa(a))==="1"}catch{return!1}}function ar({id:a,children:s,className:l,ariaLabel:m}){const[c,x]=i.useState(()=>er(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(Pa,{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 tr(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]:""}},...Ra}),[a.indeterminate])}const rr=i.createContext({disabled:!1});function sr(){return i.useContext(rr)}function nr(a,s,l,m=!0,c){const[x,u]=i.useState(),g=oa(c?`${c}-label`:void 0),h=a??s??x;return na(()=>{const b=a||s||!m?void 0:ir(l.current,g);x!==b&&u(b)}),h}function ir(a,s){const l=or(a);if(l)return!l.id&&s&&(l.id=s),l.id||void 0}function or(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 lr=i.createContext(void 0);function dr(a=!0){const s=i.useContext(lr);if(s===void 0&&!a)throw new Error(_a(3));return s}const Wa=i.createContext(void 0);function cr(){const a=i.useContext(Wa);if(a===void 0)throw new Error(_a(14));return a}const ur="data-parent",mr=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:E=!1,uncheckedValue:U,value:G,nativeButton:F=!1,style:ge,...j}=s,{clearErrors:ae}=Ft(),{disabled:$,name:K,setDirty:Q,setFilled:te,setFocused:z,setTouched:ke,state:we,validationMode:Ue,validityData:Pe,validation:Fe}=zt(),ze=sr(),{labelId:D,controlId:re,registerControlId:X,getDescriptionProps:ve}=At(),P=dr(),V=P?.parent,se=V&&P.allValues,I=$||ze.disabled||P?.disabled||g,ne=K??N,R=G??ne,Re=oa(),je=oa();let ie=re;se?ie=v?je:`${V.id}-${R}`:b&&(ie=b);let pe={};se&&(v?pe=P.parent.getParentProps():R&&(pe=P.parent.getChildProps(R)));const{checked:Le=m,indeterminate:Ie=o,onCheckedChange:Ee,...Ne}=pe,q=P?.value,oe=P?.setValue,fe=P?.defaultValue,le=i.useRef(null),de=ot(()=>Symbol("checkbox-control")),he=i.useRef(!1),{getButtonProps:Ye,buttonRef:Ae}=lt({disabled:I,native:F}),ce=P?.validation??Fe,[_,Je]=Kt({controlled:R&&q&&!v?q.includes(R):Le,default:R&&fe&&!v?fe.includes(R):x,name:"Checkbox",state:"checked"}),$e=se?!!Le:_,ye=se&&Ie||o;na(()=>{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,Re,_,void 0,!P&&!I,N);const Y=i.useRef(null),Be=dt(k,Y,ce.inputRef,ce.registerInput),Ze=nr(u,D,Y,!F,ie??void 0);na(()=>{Y.current&&(Y.current.indeterminate=ye,_&&te(!0))},[_,ye,te]),qt(_,()=>{P||(ae(ne),te(_),Q(_!==Pe.initialValue),ce.change(_))});const Ke=ct({checked:_,disabled:I,form:h,name:v?void 0:ne,id:F?void 0:ie??void 0,required:E,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&&(Ee?.(M,ue),!ue.isCanceled&&(Je(M),R&&q&&oe&&!v&&!se))){const me=M?[...q,R]:q.filter(B=>B!==R);oe(me,ue)}},onFocus(){le.current?.focus()}},G!==void 0?{value:(P?_&&G:G)||""}:ut,ve,f=>ce.getValidationProps(I,f));i.useEffect(()=>{if(!V||!R)return;const f=V.disabledStatesRef.current;return f.set(R,I),()=>{f.delete(R)}},[V,I,R]);const Te=i.useMemo(()=>({...we,checked:$e,disabled:I,readOnly:y,required:E,indeterminate:ye}),[we,$e,I,y,E,ye]),ea=Ha(Te),aa=ca("span",s,{state:Te,ref:[Ae,le,l,P?.registerControlRef],props:[{id:F?ie??void 0:Re,role:"checkbox","aria-checked":ye?"mixed":$e,"aria-readonly":y||void 0,"aria-required":E||void 0,"aria-labelledby":Ze,[ur]:v?"":void 0,onFocus(){I||z(!0)},onBlur(){const f=Y.current;f&&(ke(!0),z(!1),Ue==="onBlur"&&ce.commit(P?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||tr(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,Ye,ve,f=>ce.getValidationProps(I,f)],stateAttributesMapping:ea});return e.jsxs(Wa.Provider,{value:Te,children:[aa,!_&&!P&&ne&&!v&&U!==void 0&&e.jsx("input",{type:"hidden",form:h,name:ne,value:U,disabled:I}),e.jsx("input",{...Ke,suppressHydrationWarning:!0})]})}),gr=i.forwardRef(function(s,l){const{render:m,className:c,style:x,keepMounted:u=!1,...g}=s,h=cr(),b=h.checked||h.indeterminate,{mounted:o,transitionStatus:k,setMounted:N}=Wt(b),w=i.useRef(null),v={...h,transitionStatus:k};pt({open:b,ref:w,onComplete(){b||N(!1)}});const C={...Ha(h),...ft,...Ra},E=u||o,U=ca("span",s,{ref:[l,w],state:v,stateAttributesMapping:C,props:g});return E?U:null});function hr(a,s){return`target:${a}:${s}`}function xr(a){return`remove:${a.id||a.directory}`}function Ga(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function pr(a){const s=Ga(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 fr(a){const s=Ga(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 ra({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 yr({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(br,{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 br({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=$=>{$.key==="Escape"&&($.stopPropagation(),g?.())},ae=$=>{const K=$.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,E=new Set(a.targets||[]),U=l===xr(a),G=pr(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(la,{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(ra,{label:r("skills.usage.invocations"),children:kt(m?.invocations||0)}),e.jsx(ra,{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",fr(m?.lastUsedAt)),"aria-hidden":!0}),F?G||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ra,{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(Pa,{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=E.has(j.id),$=l===hr(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(mr,{id:K,checked:ae,disabled:$,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(gr,{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.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 kr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),sa=["claude","codex"],O="popular",wr={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 vr(a){return Qa(a).split("/").filter(Boolean).pop()||""}function jr(a){if(a.repoOwner||a.repoName)return"";const s=Qa(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Na(a){const s=vr(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=jr(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 Nr({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&&wr[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 Cr({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(Nr,{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 Sr({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(Cr,{skill:a,targets:s,onToggleTarget:g,busyKey:b}),e.jsx(Qt,{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 _r({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(La,{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(Ea,{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($a,{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(We,{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(Ge,{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(We,{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(Ge,{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(ia,{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(W,{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:E,onClearSelection:U,onBulkSync:G,onBulkRemove:F}){const ge=C.size;return e.jsxs("div",{children:[ge>0?e.jsx(Pr,{count:ge,targets:l,busy:v==="batch",onBulkSync:G,onBulkRemove:F,onClear:U}):e.jsx(_r,{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(W,{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(Sr,{skill:j,targets:l,selected:k===(j.id||j.directory),onSelect:N,selectable:!0,checked:C.has(j.id),onToggleSelect:E,onToggleTarget:w,hasUpdate:!!(j.id&&y?.[j.id]),busyKey:v},j.id||j.key))})]})}const Lr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},Ir=Lt.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(E=>E!==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(la,{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(la,{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(W,{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(W,{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(W,{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(W,{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 $r(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Yr(){const[a,s]=i.useState($r),[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,E]=i.useState(""),[U,G]=i.useState(""),[F,ge]=i.useState(""),[j,ae]=i.useState(!1),[$,K]=i.useState("all"),[Q,te]=i.useState(null),[z,ke]=i.useState(""),[we,Ue]=i.useState(!0),[Pe,Fe]=i.useState(!1),[ze,D]=i.useState(""),[re,X]=i.useState(null),[ve,P]=i.useState(null),[V,se]=i.useState(()=>new Set),[I,ne]=i.useState({}),[R,Re]=i.useState({}),[je,ie]=i.useState([]),[pe,Le]=i.useState(!1),Ie=i.useRef(!1),Ee=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}={})=>{Le(!0);try{const n=await Ct({force:t});ie(n.skills||[])}finally{Le(!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);Re(n)}catch{Re({})}},[]),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]),Ye=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 L=t.toString();window.history.replaceState({},"",`${window.location.pathname}${L?`?${L}`:""}${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(R).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(()=>G(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]),!kr&&!Pt())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("")}},Je=(t,n)=>{const d=(n&&n.length?n:sa).filter(p=>(l.targets||[]).some(L=>L.id===p));_(He(t),async()=>{await fa(t,d);const p=d.map(L=>(l.targets||[]).find(S=>S.id===L)?.label||L).join(", ");Ce({title:r("skills.toast.installed",{name:t.name||t.directory,targets:p||r("skills.target.none")}),timeout:4e3})})},$e=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 Et(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 L={name:t.name||t.directory,agent:Ke(n)};Ce({title:d?r("skills.toast.synced_one",L):r("skills.toast.unsynced_one",L),timeout:3e3})}),Be=i.useCallback(()=>se(new Set),[]),Ze=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})})},ea=()=>{const t=(l.skills||[]).filter(n=>V.has(n.id));t.length&&P(t)},aa=()=>{const t=ve;t&&(P(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:sa),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 $t(t.owner,t.name),await q(),await oe()})},B=l.targets||[],H=l.skills||[],De=i.useMemo(()=>{const t=$==="all"?H:H.filter(d=>(d.targets||[]).includes($)),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,$,U]),Ya=$!=="all",J=i.useMemo(()=>Q&&H.find(t=>(t.id||t.directory)===Q)||null,[H,Q]),Ja=i.useCallback(()=>{K("all"),E("")},[]),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(L=>{const S=Ca(L);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 ta=Xe(S).toLowerCase(),A=Na(S);return{...S,installed:Ee.has(ta)||A&&Ee.has(A)}})},[v,c,Ee,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:$,onAgentFilter:K,anyFilter:Ya,onClearFilters:Ja,searchQuery:C,onSearchQuery:E,searchPlaceholder:r("skills.my.placeholder"),selectedId:Q,onSelect:Za,onToggleTarget:Y,busyKey:z,updates:I,selectedIds:V,onToggleSelect:Ze,onClearSelection:Be,onBulkSync:Te,onBulkRemove:ea}):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(W,{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=Pe&&!t&&!n||n&&pe,L=!t&&!n&&(v.trim()!==""||o!==xe),S=()=>{w(""),k(xe)},ta=!d&&!p&&(Me.length>0||L)?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})}),L?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:Lr,children:e.jsx(Ir,{skill:Oe,installed:!!Oe.installed,installing:z===He(Oe),allTargets:B,defaultTargets:sa,onInstall:Je,onManage:at})},Oe.id||Oe.key))}):L?A=Ve("skills.empty.no_match",e.jsx(W,{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(ar,{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,ta,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(W,{type:"button",variant:"secondary",size:"sm",onClick:Ye,disabled:we||Pe||pe,children:[e.jsx(Rt,{className:Z("mr-1.5 h-3.5 w-3.5",(we||Pe||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(Gt,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,n]},t))}),o!==T&&o!==O?e.jsxs(La,{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(Ea,{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($a,{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(We,{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(Ge,{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(We,{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(Ge,{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(ia,{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(W,{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(ia,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):o===O?null:e.jsxs(W,{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(yr,{skill:J,targets:B,busyKey:z,usage:J&&(R[String(J.directory||"").toLowerCase()]||R[String(J.name||"").toLowerCase()])||null,hasUpdate:!!(J?.id&&I?.[J.id]),updating:J?z===He(J):!1,onUpdate:f,onClose:et,onToggleTarget:Y,onRemove:$e})]})}),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:()=>P(null),onConfirm:aa})]})}export{Yr as SkillsPage};
import{k as t}from"./__vite-browser-external-Eoyj4eG-.js";const a=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],i=t("maximize-2",a);const e=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],m=t("terminal",e);export{i as M,m as T};
import{k as a}from"./__vite-browser-external-Eoyj4eG-.js";const t=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],o=a("trash-2",t);export{o as T};

Sorry, the diff of this file is too big to display

import{r as p,g as N,a as M}from"./__vite-browser-external-Eoyj4eG-.js";const D=6e3,S=2500,E=100;function h(t,r){let o;const n=new Promise((a,i)=>{o=setTimeout(()=>i(new Error("landing stats timeout")),r)});return Promise.race([t,n]).finally(()=>{o!=null&&clearTimeout(o)})}const A=5*6e4,P=1440*6e4,k="tokentracker:community-stats:v2";let s=null;function C(t){const r=Number(t?.tokenFloor)||0,o=Number(t?.totalEntries)||0;return!(r>0)||!(o>0)?null:{tokenFloor:r,totalEntries:o,top:Array.isArray(t?.top)?t.top:[],topModels:Array.isArray(t?.topModels)?t.topModels:[],providers:Array.isArray(t?.providers)?t.providers:[],dailyGrowth:Array.isArray(t?.dailyGrowth)?t.dailyGrowth:[],tokenMix:Array.isArray(t?.tokenMix)?t.tokenMix:[],userDistribution:Array.isArray(t?.userDistribution)?t.userDistribution:[],platforms:Array.isArray(t?.platforms)?t.platforms:[],activeDevelopersTotal:Number(t?.activeDevelopersTotal)||0,activeDevelopers30d:Number(t?.activeDevelopers30d)||0,tokens30d:Number(t?.tokens30d)||0,tokenGrowthPct:t?.tokenGrowthPct!=null&&Number.isFinite(Number(t.tokenGrowthPct))?Number(t.tokenGrowthPct):null,developerGrowthPct:t?.developerGrowthPct!=null&&Number.isFinite(Number(t.developerGrowthPct))?Number(t.developerGrowthPct):null,generatedAt:typeof t?.generatedAt=="string"?t.generatedAt:null}}function G(){if(typeof window>"u"||!window.localStorage)return null;try{const t=JSON.parse(window.localStorage.getItem(k)||"null"),r=Number(t?.cachedAt)||0,o=C(t?.data),n=Date.now()-r;return!o||n<0||n>P?null:{data:o,isFresh:n<A}}catch{return null}}function I(t){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(k,JSON.stringify({cachedAt:Date.now(),data:t}))}catch{}}function F(){if(s&&Date.now()-s.at<A)return s.promise;const t=Promise.all([h(N({period:"total",limit:E,offset:0}),D),h(M(),S).catch(()=>null)]);return s={at:Date.now(),promise:t},t.catch(()=>{s?.promise===t&&(s=null)}),t}function O({enabled:t=!0}={}){const[r]=p.useState(()=>G()),[o,n]=p.useState(()=>r?{status:"ready",...r.data}:{status:"loading",tokenFloor:null,totalEntries:null,top:[]});return p.useEffect(()=>{if(!t||r?.isFresh)return;let a=!1,i=null,u=null;const y=async()=>{try{const[l,e]=await F();if(a)return;const c=Array.isArray(l?.entries)?l.entries:[],b=c.reduce((m,T)=>m+(Number(T?.total_tokens)||0),0),d=Number(e?.total_tokens)||0;d>0||(s=null);const w=Number(r?.data?.tokenFloor)||0,f=d>0?d:w>0?w:b;if(!c.length||!(f>0)){n(m=>({...m,status:"error"}));return}const g=Array.isArray(e?.top_models)?e.top_models:r?.data?.topModels||[],_={tokenFloor:f,totalEntries:Number(l?.total_entries)||c.length,top:c.slice(0,3),topModels:g,providers:Array.isArray(e?.providers)?e.providers:[],dailyGrowth:Array.isArray(e?.daily_growth)?e.daily_growth:[],tokenMix:Array.isArray(e?.token_mix)?e.token_mix:[],userDistribution:Array.isArray(e?.user_distribution)?e.user_distribution:[],platforms:Array.isArray(e?.platforms)?e.platforms:[],activeDevelopersTotal:Number(e?.active_developers_total)||0,activeDevelopers30d:Number(e?.active_developers_30d)||0,tokens30d:Number(e?.tokens_30d)||0,tokenGrowthPct:e?.token_growth_pct==null?null:Number(e.token_growth_pct),developerGrowthPct:e?.developer_growth_pct==null?null:Number(e.developer_growth_pct),generatedAt:typeof e?.generated_at=="string"?e.generated_at:null};n({status:"ready",..._}),d>0&&I(_)}catch{a||n(e=>e.status==="ready"?e:{...e,status:"error"})}};return typeof window<"u"&&"requestIdleCallback"in window?i=window.requestIdleCallback(y,{timeout:1500}):u=setTimeout(y,400),()=>{a=!0,i!=null&&typeof window.cancelIdleCallback=="function"&&window.cancelIdleCallback(i),u!=null&&clearTimeout(u)}},[t,r]),o}export{O as u};
import{r as a,o as D,p as K,q as j,t as J}from"./__vite-browser-external-Eoyj4eG-.js";import{L as q}from"./limits-providers-13af4PEg.js";const p=q,g="tt.limits.providerOrder",E="tt.limits.providerVisibility",h="tt.limits.displayMode",O="tt.limits.updatedAt",M="limitsPreferences",B="limitsDisplayMode",w=Object.freeze({USED:"used",REMAINING:"remaining"}),v=new Set(Object.values(w)),L=new Set([g,E,h,O]);function A(){return[...p]}function b(){return Object.fromEntries(p.map(e=>[e,!0]))}function _(e){const t=[];if(Array.isArray(e))for(const n of e)p.includes(n)&&!t.includes(n)&&t.push(n);for(const n of p)t.includes(n)||t.push(n);return t}function N(e){const t=b();if(!e||typeof e!="object"||Array.isArray(e))return t;for(const n of p)typeof e[n]=="boolean"&&(t[n]=e[n]);return t}function G(e){return v.has(e)?e:w.USED}function y(e){if(e!=null){if(typeof e=="number")return Number.isSafeInteger(e)?e:void 0;if(typeof e=="string"){const t=e.trim();if(t==="")return;const n=Number(t);return Number.isSafeInteger(n)?n:void 0}}}function m(e={}){const t=e&&typeof e=="object"?e:{};return{displayMode:G(t.displayMode),providerOrder:_(t.providerOrder),providerVisibility:N(t.providerVisibility),updatedAt:y(t.updatedAt)}}function F(){if(typeof window>"u")return A();try{const e=window.localStorage.getItem(g);return _(e?JSON.parse(e):void 0)}catch{return A()}}function H(){if(typeof window>"u")return b();try{const e=window.localStorage.getItem(E);return N(e?JSON.parse(e):void 0)}catch{return b()}}function Q(){if(typeof window>"u")return w.USED;try{const e=window.localStorage.getItem(h);return v.has(e)?e:w.USED}catch{return w.USED}}function W(){if(!(typeof window>"u"))try{return y(window.localStorage.getItem(O))}catch{return}}function X(){if(typeof window>"u")return!1;try{for(const e of L)if(window.localStorage.getItem(e)!==null)return!0}catch{return!1}return!1}function S(){return m({displayMode:Q(),providerOrder:F(),providerVisibility:H(),updatedAt:W()})}function Z(e){if(typeof window>"u")return;const t=m(e);try{window.localStorage.setItem(g,JSON.stringify(t.providerOrder)),window.localStorage.setItem(E,JSON.stringify(t.providerVisibility)),window.localStorage.setItem(h,t.displayMode),t.updatedAt===void 0?window.localStorage.removeItem(O):window.localStorage.setItem(O,String(t.updatedAt))}catch(n){console.warn("[tokentracker] limits preferences localStorage write failed:",n)}}function $(e){const t=m(e);return{displayMode:t.displayMode,providerOrder:[...t.providerOrder],providerVisibility:{...t.providerVisibility},updatedAt:t.updatedAt??null}}function ee(...e){let t;for(const s of e){const c=y(s);c!==void 0&&(t=t===void 0?c:Math.max(t,c))}const n=Date.now();return t!==void 0&&n<=t?t+1:n}function te(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function re(e,t){return p.every(n=>e[n]===t[n])}function k(e,t){return e.displayMode===t.displayMode&&te(e.providerOrder,t.providerOrder)&&re(e.providerVisibility,t.providerVisibility)}function ie(e,t){return k(e,t)&&y(e.updatedAt)===y(t.updatedAt)}function V(e,t){const n=y(e.updatedAt),s=y(t.updatedAt);return n!==void 0&&(s===void 0||n>s)}function de(){const[e,t]=a.useState(S),n=a.useRef(e),s=a.useCallback((o,r={})=>{const i=m(o);return n.current=i,t(i),r.writeLocal&&Z(i),i},[]),c=a.useCallback(o=>{D()&&K(M,$(o))},[]),u=a.useCallback(o=>{const r=S(),i=V(r,n.current)?s(r):n.current,d=m(o(i));if(k(i,d))return;const f=ee(r.updatedAt,i.updatedAt),l=s({...d,updatedAt:f},{writeLocal:!0});c(l)},[s,c]),P=a.useCallback(o=>{v.has(o)&&u(r=>({...r,displayMode:o}))},[u]),I=a.useCallback(o=>{if(!v.has(o))return;const r=S();if(r.updatedAt!==void 0){s(r);return}s({...r,displayMode:o,updatedAt:void 0},{writeLocal:!0})},[s]);a.useEffect(()=>{if(!D())return;const o=j(r=>{const i=r?.[M];if(i&&typeof i=="object"){const d=m(i);if(!X()){s(d,{writeLocal:!0});return}const f=S();if(V(d,f))s(d,{writeLocal:!0});else{const l=s(f);ie(d,f)||c(l)}return}I(r?.[B])});return J(),o},[I,s,c]),a.useEffect(()=>{if(typeof window>"u")return;const o=r=>{(r.key===null||L.has(r.key))&&s(S())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[s]);const U=a.useCallback(o=>{p.includes(o)&&u(r=>({...r,providerVisibility:{...r.providerVisibility,[o]:!r.providerVisibility[o]}}))},[u]),x=a.useCallback(o=>{u(r=>{const i=r.providerOrder.indexOf(o);if(i<=0)return r;const d=[...r.providerOrder];return[d[i-1],d[i]]=[d[i],d[i-1]],{...r,providerOrder:d}})},[u]),C=a.useCallback(o=>{u(r=>{const i=r.providerOrder.indexOf(o);if(i<0||i>=r.providerOrder.length-1)return r;const d=[...r.providerOrder];return[d[i],d[i+1]]=[d[i+1],d[i]],{...r,providerOrder:d}})},[u]),R=a.useCallback((o,r)=>{o!==r&&u(i=>{const d=i.providerOrder.indexOf(o),f=i.providerOrder.indexOf(r);if(d<0||f<0)return i;const l=[...i.providerOrder],[z]=l.splice(d,1);return l.splice(f,0,z),{...i,providerOrder:l}})},[u]),Y=a.useCallback(()=>{u(()=>({displayMode:w.USED,providerOrder:A(),providerVisibility:b()}))},[u]),T=a.useMemo(()=>e.providerOrder.filter(o=>e.providerVisibility[o]!==!1),[e.providerOrder,e.providerVisibility]);return{order:e.providerOrder,visibility:e.providerVisibility,displayMode:e.displayMode,setDisplayMode:P,visibleOrdered:T,toggle:U,moveUp:x,moveDown:C,moveToward:R,reset:Y}}export{w as L,de as u};
import{j as a,b as x,r as o,N as g,O as m,q as b,t as u,p as f,I as h}from"./__vite-browser-external-Eoyj4eG-.js";import{C as y}from"./Card-C3nLScju.js";function j({checked:s,onChange:t,disabled:e,ariaLabel:r}){return a.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":r,onClick:t,disabled:e,className:x("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 disabled:cursor-not-allowed",s?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:a.jsx("span",{className:x("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",s?"translate-x-[18px]":"translate-x-[3px]")})})}function k({label:s,hint:t,control:e}){return a.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s}),t?a.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t}):null]}),a.jsx("div",{className:"shrink-0",children:e})]})}function N({title:s,subtitle:t,action:e,children:r}){return a.jsxs(y,{children:[a.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:s}),t?a.jsx("p",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t}):null]}),e?a.jsx("div",{className:"shrink-0",children:e}):null]}),a.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:r})]})}function w({options:s,value:t,onChange:e,disabled:r=!1}){return a.jsx("div",{className:"inline-flex items-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 p-0.5 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:s.map(({value:l,label:d,Icon:i})=>{const n=t===l;return a.jsxs("button",{type:"button",onClick:()=>e(l),"aria-pressed":n,disabled:r,className:x("inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",n?"bg-white text-oai-black shadow-sm dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[i?a.jsx(i,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,a.jsx("span",{children:d})]},l)})})}function S(){const[s,t]=o.useState(null),e=g()&&m();o.useEffect(()=>{if(!e)return;const i=b(n=>t(n));return u(),i},[e]);const r=o.useCallback((i,n)=>{e&&(t(c=>c&&{...c,[i]:n}),f(i,n))},[e]),l=o.useCallback(i=>{e&&h(i)},[e]),d=o.useCallback(()=>{e&&u()},[e]);return{available:e,settings:s,setSetting:r,runAction:l,refresh:d}}export{w as S,j as T,N as a,k as b,S as u};
import{r as c,R as P,Y as Oe}from"./__vite-browser-external-Eoyj4eG-.js";function In(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const tt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function me(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function wt(e){return"nodeType"in e}function B(e){var t,n;return e?me(e)?e:wt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function mt(e){const{Document:t}=B(e);return e instanceof t}function Be(e){return me(e)?!1:e instanceof B(e).HTMLElement}function Vt(e){return e instanceof B(e).SVGElement}function ye(e){return e?me(e)?e.document:wt(e)?mt(e)?e:Be(e)||Vt(e)?e.ownerDocument:document:document:document}const Q=tt?c.useLayoutEffect:c.useEffect;function yt(e){const t=c.useRef(e);return Q(()=>{t.current=e}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Mn(){const e=c.useRef(null),t=c.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=c.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function ke(e,t){t===void 0&&(t=[e]);const n=c.useRef(e);return Q(()=>{n.current!==e&&(n.current=e)},t),n}function Fe(e,t){const n=c.useRef();return c.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Ke(e){const t=yt(e),n=c.useRef(null),r=c.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function ht(e){const t=c.useRef();return c.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function $e(e,t){return c.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function qt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,a)=>{const s=Object.entries(a);for(const[l,u]of s){const f=i[l];f!=null&&(i[l]=f+e*u)}return i},{...t})}}const we=qt(1),ze=qt(-1);function An(e){return"clientX"in e&&"clientY"in e}function xt(e){if(!e)return!1;const{KeyboardEvent:t}=B(e.target);return t&&e instanceof t}function On(e){if(!e)return!1;const{TouchEvent:t}=B(e.target);return t&&e instanceof t}function gt(e){if(On(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return An(e)?{x:e.clientX,y:e.clientY}:null}const _e=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[_e.Translate.toString(e),_e.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Nt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Tn(e){return e.matches(Nt)?e:e.querySelector(Nt)}const Nn={display:"none"};function Ln(e){let{id:t,value:n}=e;return P.createElement("div",{id:t,style:Nn},n)}function kn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return P.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function zn(){const[e,t]=c.useState("");return{announce:c.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Gt=c.createContext(null);function Pn(e){const t=c.useContext(Gt);c.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Bn(){const[e]=c.useState(()=>new Set),t=c.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[c.useCallback(r=>{let{type:o,event:i}=r;e.forEach(a=>{var s;return(s=a[o])==null?void 0:s.call(a,i)})},[e]),t]}const Fn={draggable:`
To pick up a draggable item, press the space bar.
While dragging, use the arrow keys to move the item.
Press space again to drop the item in its new position, or press escape to cancel.
`},$n={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Xn(e){let{announcements:t=$n,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Fn}=e;const{announce:i,announcement:a}=zn(),s=$e("DndLiveRegion"),[l,u]=c.useState(!1);if(c.useEffect(()=>{u(!0)},[]),Pn(c.useMemo(()=>({onDragStart(d){let{active:h}=d;i(t.onDragStart({active:h}))},onDragMove(d){let{active:h,over:g}=d;t.onDragMove&&i(t.onDragMove({active:h,over:g}))},onDragOver(d){let{active:h,over:g}=d;i(t.onDragOver({active:h,over:g}))},onDragEnd(d){let{active:h,over:g}=d;i(t.onDragEnd({active:h,over:g}))},onDragCancel(d){let{active:h,over:g}=d;i(t.onDragCancel({active:h,over:g}))}}),[i,t])),!l)return null;const f=P.createElement(P.Fragment,null,P.createElement(Ln,{id:r,value:o.draggable}),P.createElement(kn,{id:s,announcement:a}));return n?Oe.createPortal(f,n):f}var O;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(O||(O={}));function Qe(){}function uo(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function fo(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const q=Object.freeze({x:0,y:0});function Jt(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Kt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Yn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Lt(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function _t(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function kt(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const ho=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=kt(t,t.left,t.top),i=[];for(const a of r){const{id:s}=a,l=n.get(s);if(l){const u=Jt(kt(l),o);i.push({id:s,data:{droppableContainer:a,value:u}})}}return i.sort(Kt)},jn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Lt(t),i=[];for(const a of r){const{id:s}=a,l=n.get(s);if(l){const u=Lt(l),f=o.reduce((h,g,C)=>h+Jt(u[C],g),0),d=Number((f/4).toFixed(4));i.push({id:s,data:{droppableContainer:a,value:d}})}}return i.sort(Kt)};function Un(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,s=i-n;if(r<o&&n<i){const l=t.width*t.height,u=e.width*e.height,f=a*s,d=f/(l+u-f);return Number(d.toFixed(4))}return 0}const Wn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:a}=i,s=n.get(a);if(s){const l=Un(s,t);l>0&&o.push({id:a,data:{droppableContainer:i,value:l}})}}return o.sort(Yn)};function Hn(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Qt(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:q}function Vn(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((a,s)=>({...a,top:a.top+e*s.y,bottom:a.bottom+e*s.y,left:a.left+e*s.x,right:a.right+e*s.x}),{...n})}}const qn=Vn(1);function Gn(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Jn(e,t,n){const r=Gn(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:s}=r,l=e.left-a-(1-o)*parseFloat(n),u=e.top-s-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),f=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:f,height:d,top:u,right:l+f,bottom:u+d,left:l}}const Kn={ignoreTransform:!1};function xe(e,t){t===void 0&&(t=Kn);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=B(e).getComputedStyle(e);u&&(n=Jn(n,u,f))}const{top:r,left:o,width:i,height:a,bottom:s,right:l}=n;return{top:r,left:o,width:i,height:a,bottom:s,right:l}}function zt(e){return xe(e,{ignoreTransform:!0})}function _n(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Qn(e,t){return t===void 0&&(t=B(e).getComputedStyle(e)),t.position==="fixed"}function Zn(e,t){t===void 0&&(t=B(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function nt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(mt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Be(o)||Vt(o)||n.includes(o))return n;const i=B(e).getComputedStyle(o);return o!==e&&Zn(o,i)&&n.push(o),Qn(o,i)?n:r(o.parentNode)}return e?r(e):n}function Zt(e){const[t]=nt(e,1);return t??null}function lt(e){return!tt||!e?null:me(e)?e:wt(e)?mt(e)||e===ye(e).scrollingElement?window:Be(e)?e:null:null}function en(e){return me(e)?e.scrollX:e.scrollLeft}function tn(e){return me(e)?e.scrollY:e.scrollTop}function vt(e){return{x:en(e),y:tn(e)}}var N;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(N||(N={}));function nn(e){return!tt||!e?!1:e===document.scrollingElement}function rn(e){const t={x:0,y:0},n=nn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,a=e.scrollTop>=r.y,s=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:a,isRight:s,maxScroll:r,minScroll:t}}const er={x:.2,y:.2};function tr(e,t,n,r,o){let{top:i,left:a,right:s,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=er);const{isTop:u,isBottom:f,isLeft:d,isRight:h}=rn(e),g={x:0,y:0},C={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!u&&i<=t.top+v.height?(g.y=N.Backward,C.y=r*Math.abs((t.top+v.height-i)/v.height)):!f&&l>=t.bottom-v.height&&(g.y=N.Forward,C.y=r*Math.abs((t.bottom-v.height-l)/v.height)),!h&&s>=t.right-v.width?(g.x=N.Forward,C.x=r*Math.abs((t.right-v.width-s)/v.width)):!d&&a<=t.left+v.width&&(g.x=N.Backward,C.x=r*Math.abs((t.left+v.width-a)/v.width)),{direction:g,speed:C}}function nr(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:a}=window;return{top:0,left:0,right:i,bottom:a,width:i,height:a}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function on(e){return e.reduce((t,n)=>we(t,vt(n)),q)}function rr(e){return e.reduce((t,n)=>t+en(n),0)}function or(e){return e.reduce((t,n)=>t+tn(n),0)}function ir(e,t){if(t===void 0&&(t=xe),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);Zt(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const sr=[["x",["left","right"],rr],["y",["top","bottom"],or]];class Dt{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=nt(n),o=on(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,a,s]of sr)for(const l of a)Object.defineProperty(this,l,{get:()=>{const u=s(r),f=o[i]-u;return this.rect[l]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Te{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function ar(e){const{EventTarget:t}=B(e);return e instanceof t?e:ye(e)}function ut(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var W;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(W||(W={}));function Pt(e){e.preventDefault()}function cr(e){e.stopPropagation()}var w;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(w||(w={}));const sn={start:[w.Space,w.Enter],cancel:[w.Esc],end:[w.Space,w.Enter,w.Tab]},lr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case w.Right:return{...n,x:n.x+25};case w.Left:return{...n,x:n.x-25};case w.Down:return{...n,y:n.y+25};case w.Up:return{...n,y:n.y-25}}};class an{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Te(ye(n)),this.windowListeners=new Te(B(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(W.Resize,this.handleCancel),this.windowListeners.add(W.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(W.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&ir(r),n(q)}handleKeyDown(t){if(xt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=sn,coordinateGetter:a=lr,scrollBehavior:s="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:u}=r.current,f=u?{x:u.left,y:u.top}:q;this.referenceCoordinates||(this.referenceCoordinates=f);const d=a(t,{active:n,context:r.current,currentCoordinates:f});if(d){const h=ze(d,f),g={x:0,y:0},{scrollableAncestors:C}=r.current;for(const v of C){const p=t.code,{isTop:m,isRight:y,isLeft:b,isBottom:S,maxScroll:R,minScroll:E}=rn(v),x=nr(v),D={x:Math.min(p===w.Right?x.right-x.width/2:x.right,Math.max(p===w.Right?x.left:x.left+x.width/2,d.x)),y:Math.min(p===w.Down?x.bottom-x.height/2:x.bottom,Math.max(p===w.Down?x.top:x.top+x.height/2,d.y))},A=p===w.Right&&!y||p===w.Left&&!b,T=p===w.Down&&!S||p===w.Up&&!m;if(A&&D.x!==d.x){const M=v.scrollLeft+h.x,H=p===w.Right&&M<=R.x||p===w.Left&&M>=E.x;if(H&&!h.y){v.scrollTo({left:M,behavior:s});return}H?g.x=v.scrollLeft-M:g.x=p===w.Right?v.scrollLeft-R.x:v.scrollLeft-E.x,g.x&&v.scrollBy({left:-g.x,behavior:s});break}else if(T&&D.y!==d.y){const M=v.scrollTop+h.y,H=p===w.Down&&M<=R.y||p===w.Up&&M>=E.y;if(H&&!h.x){v.scrollTo({top:M,behavior:s});return}H?g.y=v.scrollTop-M:g.y=p===w.Down?v.scrollTop-R.y:v.scrollTop-E.y,g.y&&v.scrollBy({top:-g.y,behavior:s});break}}this.handleMove(t,we(ze(d,this.referenceCoordinates),g))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}an.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=sn,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const s=i.activatorNode.current;return s&&e.target!==s?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Bt(e){return!!(e&&"distance"in e)}function Ft(e){return!!(e&&"delay"in e)}class Ct{constructor(t,n,r){var o;r===void 0&&(r=ar(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:a}=i;this.props=t,this.events=n,this.document=ye(a),this.documentListeners=new Te(this.document),this.listeners=new Te(r),this.windowListeners=new Te(B(a)),this.initialCoordinates=(o=gt(i))!=null?o:q,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(W.Resize,this.handleCancel),this.windowListeners.add(W.DragStart,Pt),this.windowListeners.add(W.VisibilityChange,this.handleCancel),this.windowListeners.add(W.ContextMenu,Pt),this.documentListeners.add(W.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ft(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Bt(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(W.Click,cr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(W.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:a,options:{activationConstraint:s}}=i;if(!o)return;const l=(n=gt(t))!=null?n:q,u=ze(o,l);if(!r&&s){if(Bt(s)){if(s.tolerance!=null&&ut(u,s.tolerance))return this.handleCancel();if(ut(u,s.distance))return this.handleStart()}if(Ft(s)&&ut(u,s.tolerance))return this.handleCancel();this.handlePending(s,u);return}t.cancelable&&t.preventDefault(),a(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===w.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ur={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class cn extends Ct{constructor(t){const{event:n}=t,r=ye(n.target);super(t,ur,r)}}cn.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const dr={move:{name:"mousemove"},end:{name:"mouseup"}};var pt;(function(e){e[e.RightClick=2]="RightClick"})(pt||(pt={}));class fr extends Ct{constructor(t){super(t,dr,ye(t.event.target))}}fr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===pt.RightClick?!1:(r?.({event:n}),!0)}}];const dt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class hr extends Ct{constructor(t){super(t,dt)}static setup(){return window.addEventListener(dt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(dt.move.name,t)};function t(){}}}hr.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Ne;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ne||(Ne={}));var Ze;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ze||(Ze={}));function gr(e){let{acceleration:t,activator:n=Ne.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:s=Ze.TreeOrder,pointerCoordinates:l,scrollableAncestors:u,scrollableAncestorRects:f,delta:d,threshold:h}=e;const g=pr({delta:d,disabled:!i}),[C,v]=Mn(),p=c.useRef({x:0,y:0}),m=c.useRef({x:0,y:0}),y=c.useMemo(()=>{switch(n){case Ne.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Ne.DraggableRect:return o}},[n,o,l]),b=c.useRef(null),S=c.useCallback(()=>{const E=b.current;if(!E)return;const x=p.current.x*m.current.x,D=p.current.y*m.current.y;E.scrollBy(x,D)},[]),R=c.useMemo(()=>s===Ze.TreeOrder?[...u].reverse():u,[s,u]);c.useEffect(()=>{if(!i||!u.length||!y){v();return}for(const E of R){if(r?.(E)===!1)continue;const x=u.indexOf(E),D=f[x];if(!D)continue;const{direction:A,speed:T}=tr(E,D,y,t,h);for(const M of["x","y"])g[M][A[M]]||(T[M]=0,A[M]=0);if(T.x>0||T.y>0){v(),b.current=E,C(S,a),p.current=T,m.current=A;return}}p.current={x:0,y:0},m.current={x:0,y:0},v()},[t,S,r,v,i,a,JSON.stringify(y),JSON.stringify(g),C,u,R,f,JSON.stringify(h)])}const vr={x:{[N.Backward]:!1,[N.Forward]:!1},y:{[N.Backward]:!1,[N.Forward]:!1}};function pr(e){let{delta:t,disabled:n}=e;const r=ht(t);return Fe(o=>{if(n||!r||!o)return vr;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[N.Backward]:o.x[N.Backward]||i.x===-1,[N.Forward]:o.x[N.Forward]||i.x===1},y:{[N.Backward]:o.y[N.Backward]||i.y===-1,[N.Forward]:o.y[N.Forward]||i.y===1}}},[n,t,r])}function br(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Fe(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function wr(e,t){return c.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,r)}));return[...n,...i]},[]),[e,t])}var Pe;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Pe||(Pe={}));var bt;(function(e){e.Optimized="optimized"})(bt||(bt={}));const $t=new Map;function mr(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=c.useState(null),{frequency:s,measure:l,strategy:u}=o,f=c.useRef(e),d=p(),h=ke(d),g=c.useCallback(function(m){m===void 0&&(m=[]),!h.current&&a(y=>y===null?m:y.concat(m.filter(b=>!y.includes(b))))},[h]),C=c.useRef(null),v=Fe(m=>{if(d&&!n)return $t;if(!m||m===$t||f.current!==e||i!=null){const y=new Map;for(let b of e){if(!b)continue;if(i&&i.length>0&&!i.includes(b.id)&&b.rect.current){y.set(b.id,b.rect.current);continue}const S=b.node.current,R=S?new Dt(l(S),S):null;b.rect.current=R,R&&y.set(b.id,R)}return y}return m},[e,i,n,d,l]);return c.useEffect(()=>{f.current=e},[e]),c.useEffect(()=>{d||g()},[n,d]),c.useEffect(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),c.useEffect(()=>{d||typeof s!="number"||C.current!==null||(C.current=setTimeout(()=>{g(),C.current=null},s))},[s,d,g,...r]),{droppableRects:v,measureDroppableContainers:g,measuringScheduled:i!=null};function p(){switch(u){case Pe.Always:return!1;case Pe.BeforeDragging:return n;default:return!n}}}function ln(e,t){return Fe(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function yr(e,t){return ln(e,t)}function xr(e){let{callback:t,disabled:n}=e;const r=yt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function rt(e){let{callback:t,disabled:n}=e;const r=yt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function Dr(e){return new Dt(xe(e),e)}function Xt(e,t,n){t===void 0&&(t=Dr);const[r,o]=c.useState(null);function i(){o(l=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=l??n)!=null?u:null}const f=t(e);return JSON.stringify(l)===JSON.stringify(f)?l:f})}const a=xr({callback(l){if(e)for(const u of l){const{type:f,target:d}=u;if(f==="childList"&&d instanceof HTMLElement&&d.contains(e)){i();break}}}}),s=rt({callback:i});return Q(()=>{i(),e?(s?.observe(e),a?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),a?.disconnect())},[e]),r}function Cr(e){const t=ln(e);return Qt(e,t)}const Yt=[];function Sr(e){const t=c.useRef(e),n=Fe(r=>e?r&&r!==Yt&&e&&t.current&&e.parentNode===t.current.parentNode?r:nt(e):Yt,[e]);return c.useEffect(()=>{t.current=e},[e]),n}function Rr(e){const[t,n]=c.useState(null),r=c.useRef(e),o=c.useCallback(i=>{const a=lt(i.target);a&&n(s=>s?(s.set(a,vt(a)),new Map(s)):null)},[]);return c.useEffect(()=>{const i=r.current;if(e!==i){a(i);const s=e.map(l=>{const u=lt(l);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,vt(u)]):null}).filter(l=>l!=null);n(s.length?new Map(s):null),r.current=e}return()=>{a(e),a(i)};function a(s){s.forEach(l=>{const u=lt(l);u?.removeEventListener("scroll",o)})}},[o,e]),c.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,a)=>we(i,a),q):on(e):q,[e,t])}function jt(e,t){t===void 0&&(t=[]);const n=c.useRef(null);return c.useEffect(()=>{n.current=null},t),c.useEffect(()=>{const r=e!==q;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ze(e,n.current):q}function Er(e){c.useEffect(()=>{if(!tt)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Ir(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=a=>{i(a,t)},n},{}),[e,t])}function un(e){return c.useMemo(()=>e?_n(e):null,[e])}const Ut=[];function Mr(e,t){t===void 0&&(t=xe);const[n]=e,r=un(n?B(n):null),[o,i]=c.useState(Ut);function a(){i(()=>e.length?e.map(l=>nn(l)?r:new Dt(t(l),l)):Ut)}const s=rt({callback:a});return Q(()=>{s?.disconnect(),a(),e.forEach(l=>s?.observe(l))},[e]),o}function Ar(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Be(t)?t:e}function Or(e){let{measure:t}=e;const[n,r]=c.useState(null),o=c.useCallback(u=>{for(const{target:f}of u)if(Be(f)){r(d=>{const h=t(f);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),i=rt({callback:o}),a=c.useCallback(u=>{const f=Ar(u);i?.disconnect(),f&&i?.observe(f),r(f?t(f):null)},[t,i]),[s,l]=Ke(a);return c.useMemo(()=>({nodeRef:s,rect:n,setRef:l}),[n,s,l])}const Tr=[{sensor:cn,options:{}},{sensor:an,options:{}}],Nr={current:{}},Je={draggable:{measure:zt},droppable:{measure:zt,strategy:Pe.WhileDragging,frequency:bt.Optimized},dragOverlay:{measure:xe}};class Le extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Lr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Le,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Qe},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Je,measureDroppableContainers:Qe,windowRect:null,measuringScheduled:!1},kr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Qe,draggableNodes:new Map,over:null,measureDroppableContainers:Qe},ot=c.createContext(kr),dn=c.createContext(Lr);function zr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Le}}}function Pr(e,t){switch(t.type){case O.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case O.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case O.DragEnd:case O.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case O.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Le(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case O.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Le(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case O.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Le(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Br(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=c.useContext(ot),i=ht(r),a=ht(n?.id);return c.useEffect(()=>{if(!t&&!r&&i&&a!=null){if(!xt(i)||document.activeElement===i.target)return;const s=o.get(a);if(!s)return;const{activatorNode:l,node:u}=s;if(!l.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[l.current,u.current]){if(!f)continue;const d=Tn(f);if(d){d.focus();break}}})}},[r,t,o,a,i]),null}function Fr(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function $r(e){return c.useMemo(()=>({draggable:{...Je.draggable,...e?.draggable},droppable:{...Je.droppable,...e?.droppable},dragOverlay:{...Je.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Xr(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=c.useRef(!1),{x:a,y:s}=typeof o=="boolean"?{x:o,y:o}:o;Q(()=>{if(!a&&!s||!t){i.current=!1;return}if(i.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const f=n(u),d=Qt(f,r);if(a||(d.x=0),s||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=Zt(u);h&&h.scrollBy({top:d.y,left:d.x})}},[t,a,s,r,n])}const fn=c.createContext({...q,scaleX:1,scaleY:1});var ue;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ue||(ue={}));const go=c.memo(function(t){var n,r,o,i;let{id:a,accessibility:s,autoScroll:l=!0,children:u,sensors:f=Tr,collisionDetection:d=Wn,measuring:h,modifiers:g,...C}=t;const v=c.useReducer(Pr,void 0,zr),[p,m]=v,[y,b]=Bn(),[S,R]=c.useState(ue.Uninitialized),E=S===ue.Initialized,{draggable:{active:x,nodes:D,translate:A},droppable:{containers:T}}=p,M=x!=null?D.get(x):null,H=c.useRef({initial:null,translated:null}),V=c.useMemo(()=>{var k;return x!=null?{id:x,data:(k=M?.data)!=null?k:Nr,rect:H}:null},[x,M]),G=c.useRef(null),[De,Xe]=c.useState(null),[F,Ye]=c.useState(null),Z=ke(C,Object.values(C)),Ce=$e("DndDescribedBy",a),je=c.useMemo(()=>T.getEnabled(),[T]),z=$r(h),{droppableRects:ee,measureDroppableContainers:de,measuringScheduled:Se}=mr(je,{dragging:E,dependencies:[A.x,A.y],config:z.droppable}),j=br(D,x),Ue=c.useMemo(()=>F?gt(F):null,[F]),oe=En(),te=yr(j,z.draggable.measure);Xr({activeNode:x!=null?D.get(x):null,config:oe.layoutShiftCompensation,initialRect:te,measure:z.draggable.measure});const I=Xt(j,z.draggable.measure,te),Re=Xt(j?j.parentElement:null),J=c.useRef({activatorEvent:null,active:null,activeNode:j,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),fe=T.getNodeFor((n=J.current.over)==null?void 0:n.id),ne=Or({measure:z.dragOverlay.measure}),he=(r=ne.nodeRef.current)!=null?r:j,ge=E?(o=ne.rect)!=null?o:I:null,St=!!(ne.nodeRef.current&&ne.rect),Rt=Cr(St?null:I),it=un(he?B(he):null),ie=Sr(E?fe??j:null),We=Mr(ie),He=Fr(g,{transform:{x:A.x-Rt.x,y:A.y-Rt.y,scaleX:1,scaleY:1},activatorEvent:F,active:V,activeNodeRect:I,containerNodeRect:Re,draggingNodeRect:ge,over:J.current.over,overlayNodeRect:ne.rect,scrollableAncestors:ie,scrollableAncestorRects:We,windowRect:it}),Et=Ue?we(Ue,A):null,It=Rr(ie),mn=jt(It),yn=jt(It,[I]),ve=we(He,mn),pe=ge?qn(ge,He):null,Ee=V&&pe?d({active:V,collisionRect:pe,droppableRects:ee,droppableContainers:je,pointerCoordinates:Et}):null,Mt=_t(Ee,"id"),[se,At]=c.useState(null),xn=St?He:we(He,yn),Dn=Hn(xn,(i=se?.rect)!=null?i:null,I),st=c.useRef(null),Ot=c.useCallback((k,$)=>{let{sensor:X,options:ae}=$;if(G.current==null)return;const U=D.get(G.current);if(!U)return;const Y=k.nativeEvent,K=new X({active:G.current,activeNode:U,event:Y,options:ae,context:J,onAbort(L){if(!D.get(L))return;const{onDragAbort:_}=Z.current,re={id:L};_?.(re),y({type:"onDragAbort",event:re})},onPending(L,ce,_,re){if(!D.get(L))return;const{onDragPending:Me}=Z.current,le={id:L,constraint:ce,initialCoordinates:_,offset:re};Me?.(le),y({type:"onDragPending",event:le})},onStart(L){const ce=G.current;if(ce==null)return;const _=D.get(ce);if(!_)return;const{onDragStart:re}=Z.current,Ie={activatorEvent:Y,active:{id:ce,data:_.data,rect:H}};Oe.unstable_batchedUpdates(()=>{re?.(Ie),R(ue.Initializing),m({type:O.DragStart,initialCoordinates:L,active:ce}),y({type:"onDragStart",event:Ie}),Xe(st.current),Ye(Y)})},onMove(L){m({type:O.DragMove,coordinates:L})},onEnd:be(O.DragEnd),onCancel:be(O.DragCancel)});st.current=K;function be(L){return async function(){const{active:_,collisions:re,over:Ie,scrollAdjustedTranslate:Me}=J.current;let le=null;if(_&&Me){const{cancelDrop:Ae}=Z.current;le={activatorEvent:Y,active:_,collisions:re,delta:Me,over:Ie},L===O.DragEnd&&typeof Ae=="function"&&await Promise.resolve(Ae(le))&&(L=O.DragCancel)}G.current=null,Oe.unstable_batchedUpdates(()=>{m({type:L}),R(ue.Uninitialized),At(null),Xe(null),Ye(null),st.current=null;const Ae=L===O.DragEnd?"onDragEnd":"onDragCancel";if(le){const at=Z.current[Ae];at?.(le),y({type:Ae,event:le})}})}}},[D]),Cn=c.useCallback((k,$)=>(X,ae)=>{const U=X.nativeEvent,Y=D.get(ae);if(G.current!==null||!Y||U.dndKit||U.defaultPrevented)return;const K={active:Y};k(X,$.options,K)===!0&&(U.dndKit={capturedBy:$.sensor},G.current=ae,Ot(X,$))},[D,Ot]),Tt=wr(f,Cn);Er(f),Q(()=>{I&&S===ue.Initializing&&R(ue.Initialized)},[I,S]),c.useEffect(()=>{const{onDragMove:k}=Z.current,{active:$,activatorEvent:X,collisions:ae,over:U}=J.current;if(!$||!X)return;const Y={active:$,activatorEvent:X,collisions:ae,delta:{x:ve.x,y:ve.y},over:U};Oe.unstable_batchedUpdates(()=>{k?.(Y),y({type:"onDragMove",event:Y})})},[ve.x,ve.y]),c.useEffect(()=>{const{active:k,activatorEvent:$,collisions:X,droppableContainers:ae,scrollAdjustedTranslate:U}=J.current;if(!k||G.current==null||!$||!U)return;const{onDragOver:Y}=Z.current,K=ae.get(Mt),be=K&&K.rect.current?{id:K.id,rect:K.rect.current,data:K.data,disabled:K.disabled}:null,L={active:k,activatorEvent:$,collisions:X,delta:{x:U.x,y:U.y},over:be};Oe.unstable_batchedUpdates(()=>{At(be),Y?.(L),y({type:"onDragOver",event:L})})},[Mt]),Q(()=>{J.current={activatorEvent:F,active:V,activeNode:j,collisionRect:pe,collisions:Ee,droppableRects:ee,draggableNodes:D,draggingNode:he,draggingNodeRect:ge,droppableContainers:T,over:se,scrollableAncestors:ie,scrollAdjustedTranslate:ve},H.current={initial:ge,translated:pe}},[V,j,Ee,pe,D,he,ge,ee,T,se,ie,ve]),gr({...oe,delta:A,draggingRect:pe,pointerCoordinates:Et,scrollableAncestors:ie,scrollableAncestorRects:We});const Sn=c.useMemo(()=>({active:V,activeNode:j,activeNodeRect:I,activatorEvent:F,collisions:Ee,containerNodeRect:Re,dragOverlay:ne,draggableNodes:D,droppableContainers:T,droppableRects:ee,over:se,measureDroppableContainers:de,scrollableAncestors:ie,scrollableAncestorRects:We,measuringConfiguration:z,measuringScheduled:Se,windowRect:it}),[V,j,I,F,Ee,Re,ne,D,T,ee,se,de,ie,We,z,Se,it]),Rn=c.useMemo(()=>({activatorEvent:F,activators:Tt,active:V,activeNodeRect:I,ariaDescribedById:{draggable:Ce},dispatch:m,draggableNodes:D,over:se,measureDroppableContainers:de}),[F,Tt,V,I,m,Ce,D,se,de]);return P.createElement(Gt.Provider,{value:b},P.createElement(ot.Provider,{value:Rn},P.createElement(dn.Provider,{value:Sn},P.createElement(fn.Provider,{value:Dn},u)),P.createElement(Br,{disabled:s?.restoreFocus===!1})),P.createElement(Xn,{...s,hiddenTextDescribedById:Ce}));function En(){const k=De?.autoScrollEnabled===!1,$=typeof l=="object"?l.enabled===!1:l===!1,X=E&&!k&&!$;return typeof l=="object"?{...l,enabled:X}:{enabled:X}}}),Yr=c.createContext(null),Wt="button",jr="Draggable";function Ur(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=$e(jr),{activators:a,activatorEvent:s,active:l,activeNodeRect:u,ariaDescribedById:f,draggableNodes:d,over:h}=c.useContext(ot),{role:g=Wt,roleDescription:C="draggable",tabIndex:v=0}=o??{},p=l?.id===t,m=c.useContext(p?fn:Yr),[y,b]=Ke(),[S,R]=Ke(),E=Ir(a,t),x=ke(n);Q(()=>(d.set(t,{id:t,key:i,node:y,activatorNode:S,data:x}),()=>{const A=d.get(t);A&&A.key===i&&d.delete(t)}),[d,t]);const D=c.useMemo(()=>({role:g,tabIndex:v,"aria-disabled":r,"aria-pressed":p&&g===Wt?!0:void 0,"aria-roledescription":C,"aria-describedby":f.draggable}),[r,g,v,p,C,f.draggable]);return{active:l,activatorEvent:s,activeNodeRect:u,attributes:D,isDragging:p,listeners:r?void 0:E,node:y,over:h,setNodeRef:b,setActivatorNodeRef:R,transform:m}}function Wr(){return c.useContext(dn)}const Hr="Droppable",Vr={timeout:25};function qr(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=$e(Hr),{active:a,dispatch:s,over:l,measureDroppableContainers:u}=c.useContext(ot),f=c.useRef({disabled:n}),d=c.useRef(!1),h=c.useRef(null),g=c.useRef(null),{disabled:C,updateMeasurementsFor:v,timeout:p}={...Vr,...o},m=ke(v??r),y=c.useCallback(()=>{if(!d.current){d.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(m.current)?m.current:[m.current]),g.current=null},p)},[p]),b=rt({callback:y,disabled:C||!a}),S=c.useCallback((D,A)=>{b&&(A&&(b.unobserve(A),d.current=!1),D&&b.observe(D))},[b]),[R,E]=Ke(S),x=ke(t);return c.useEffect(()=>{!b||!R.current||(b.disconnect(),d.current=!1,b.observe(R.current))},[R,b]),c.useEffect(()=>(s({type:O.RegisterDroppable,element:{id:r,key:i,disabled:n,node:R,rect:h,data:x}}),()=>s({type:O.UnregisterDroppable,key:i,id:r})),[r]),c.useEffect(()=>{n!==f.current.disabled&&(s({type:O.SetDroppableDisabled,id:r,key:i,disabled:n}),f.current.disabled=n)},[r,i,n,s]),{active:a,rect:h,isOver:l?.id===r,node:R,over:l,setNodeRef:E}}function hn(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Gr(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Ve(e){return e!==null&&e>=0}function Jr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Kr(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const qe={scaleX:1,scaleY:1},vo=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:a}=e;const s=(t=n[o])!=null?t:r;if(!s)return null;const l=_r(n,a,o);if(a===o){const u=n[i];return u?{x:o<i?u.left+u.width-(s.left+s.width):u.left-s.left,y:0,...qe}:null}return a>o&&a<=i?{x:-s.width-l,y:0,...qe}:a<o&&a>=i?{x:s.width+l,y:0,...qe}:{x:0,y:0,...qe}};function _r(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return!r||!o&&!i?0:n<t?o?r.left-(o.left+o.width):i.left-(r.left+r.width):i?i.left-(r.left+r.width):r.left-(o.left+o.width)}const gn=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=hn(t,r,n),a=t[o],s=i[o];return!s||!a?null:{x:s.left-a.left,y:s.top-a.top,scaleX:s.width/a.width,scaleY:s.height/a.height}},Ge={scaleX:1,scaleY:1},po=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:a}=e;const s=(t=i[n])!=null?t:r;if(!s)return null;if(o===n){const u=i[a];return u?{x:0,y:n<a?u.top+u.height-(s.top+s.height):u.top-s.top,...Ge}:null}const l=Qr(i,o,n);return o>n&&o<=a?{x:0,y:-s.height-l,...Ge}:o<n&&o>=a?{x:0,y:s.height+l,...Ge}:{x:0,y:0,...Ge}};function Qr(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const vn="Sortable",pn=P.createContext({activeIndex:-1,containerId:vn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:gn,disabled:{draggable:!1,droppable:!1}});function bo(e){let{children:t,id:n,items:r,strategy:o=gn,disabled:i=!1}=e;const{active:a,dragOverlay:s,droppableRects:l,over:u,measureDroppableContainers:f}=Wr(),d=$e(vn,n),h=s.rect!==null,g=c.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),C=a!=null,v=a?g.indexOf(a.id):-1,p=u?g.indexOf(u.id):-1,m=c.useRef(g),y=!Jr(g,m.current),b=p!==-1&&v===-1||y,S=Kr(i);Q(()=>{y&&C&&f(g)},[y,g,C,f]),c.useEffect(()=>{m.current=g},[g]);const R=c.useMemo(()=>({activeIndex:v,containerId:d,disabled:S,disableTransforms:b,items:g,overIndex:p,useDragOverlay:h,sortedRects:Gr(g,l),strategy:o}),[v,d,S.draggable,S.droppable,b,g,p,l,h,o]);return P.createElement(pn.Provider,{value:R},t)}const Zr=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return hn(n,r,o).indexOf(t)},eo=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:s,previousContainerId:l,transition:u}=e;return!u||!r||s!==i&&o===a?!1:n?!0:a!==o&&t===l},to={duration:200,easing:"ease"},bn="transform",no=_e.Transition.toString({property:bn,duration:0,easing:"linear"}),ro={roleDescription:"sortable"};function oo(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,a]=c.useState(null),s=c.useRef(n);return Q(()=>{if(!t&&n!==s.current&&r.current){const l=o.current;if(l){const u=xe(r.current,{ignoreTransform:!0}),f={x:l.left-u.left,y:l.top-u.top,scaleX:l.width/u.width,scaleY:l.height/u.height};(f.x||f.y)&&a(f)}}n!==s.current&&(s.current=n)},[t,n,r,o]),c.useEffect(()=>{i&&a(null)},[i]),i}function wo(e){let{animateLayoutChanges:t=eo,attributes:n,disabled:r,data:o,getNewIndex:i=Zr,id:a,strategy:s,resizeObserverConfig:l,transition:u=to}=e;const{items:f,containerId:d,activeIndex:h,disabled:g,disableTransforms:C,sortedRects:v,overIndex:p,useDragOverlay:m,strategy:y}=c.useContext(pn),b=io(r,g),S=f.indexOf(a),R=c.useMemo(()=>({sortable:{containerId:d,index:S,items:f},...o}),[d,o,S,f]),E=c.useMemo(()=>f.slice(f.indexOf(a)),[f,a]),{rect:x,node:D,isOver:A,setNodeRef:T}=qr({id:a,data:R,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:M,activatorEvent:H,activeNodeRect:V,attributes:G,setNodeRef:De,listeners:Xe,isDragging:F,over:Ye,setActivatorNodeRef:Z,transform:Ce}=Ur({id:a,data:R,attributes:{...ro,...n},disabled:b.draggable}),je=In(T,De),z=!!M,ee=z&&!C&&Ve(h)&&Ve(p),de=!m&&F,Se=de&&ee?Ce:null,Ue=ee?Se??(s??y)({rects:v,activeNodeRect:V,activeIndex:h,overIndex:p,index:S}):null,oe=Ve(h)&&Ve(p)?i({id:a,items:f,activeIndex:h,overIndex:p}):S,te=M?.id,I=c.useRef({activeId:te,items:f,newIndex:oe,containerId:d}),Re=f!==I.current.items,J=t({active:M,containerId:d,isDragging:F,isSorting:z,id:a,index:S,items:f,newIndex:I.current.newIndex,previousItems:I.current.items,previousContainerId:I.current.containerId,transition:u,wasDragging:I.current.activeId!=null}),fe=oo({disabled:!J,index:S,node:D,rect:x});return c.useEffect(()=>{z&&I.current.newIndex!==oe&&(I.current.newIndex=oe),d!==I.current.containerId&&(I.current.containerId=d),f!==I.current.items&&(I.current.items=f)},[z,oe,d,f]),c.useEffect(()=>{if(te===I.current.activeId)return;if(te&&!I.current.activeId){I.current.activeId=te;return}const he=setTimeout(()=>{I.current.activeId=te},50);return()=>clearTimeout(he)},[te]),{active:M,activeIndex:h,attributes:G,data:R,rect:x,index:S,newIndex:oe,items:f,isOver:A,isSorting:z,isDragging:F,listeners:Xe,node:D,overIndex:p,over:Ye,setNodeRef:je,setActivatorNodeRef:Z,setDroppableNodeRef:T,setDraggableNodeRef:De,transform:fe??Ue,transition:ne()};function ne(){if(fe||Re&&I.current.newIndex===S)return no;if(!(de&&!xt(H)||!u)&&(z||J))return _e.Transition.toString({...u,property:bn})}}function io(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}function et(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const so=[w.Down,w.Right,w.Up,w.Left],mo=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:s}}=t;if(so.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(e.code){case w.Down:r.top<h.top&&l.push(d);break;case w.Up:r.top>h.top&&l.push(d);break;case w.Left:r.left>h.left&&l.push(d);break;case w.Right:r.left<h.left&&l.push(d);break}});const u=jn({collisionRect:r,droppableRects:o,droppableContainers:l});let f=_t(u,"id");if(f===a?.id&&u.length>1&&(f=u[1].id),f!=null){const d=i.get(n.id),h=i.get(f),g=h?o.get(h.id):null,C=h?.node.current;if(C&&g&&d&&h){const p=nt(C).some((E,x)=>s[x]!==E),m=wn(d,h),y=ao(d,h),b=p||!m?{x:0,y:0}:{x:y?r.width-g.width:0,y:y?r.height-g.height:0},S={x:g.left,y:g.top};return b.x&&b.y?S:ze(S,b)}}}};function wn(e,t){return!et(e)||!et(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function ao(e,t){return!et(e)||!et(t)||!wn(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function co(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>typeof r=="string"):null}catch{return null}}function ft(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Ht(e,t){if(!e)return t;const n=new Set(t),r=e.filter(i=>n.has(i)),o=t.filter(i=>!r.includes(i));return[...r,...o]}function yo(e,t){const n=c.useMemo(()=>t.join("|"),[t]),[r,o]=c.useState(()=>Ht(co(e),t));c.useEffect(()=>{o(s=>{const l=Ht(s,t);return l.length===s.length&&l.every((f,d)=>f===s[d])?s:(ft(e,l),l)})},[n,t,e]);const i=c.useCallback((s,l)=>{!s||!l||s===l||o(u=>{const f=u.indexOf(s),d=u.indexOf(l);if(f===-1||d===-1)return u;const h=u.slice(),[g]=h.splice(f,1);return h.splice(d,0,g),ft(e,h),h})},[e]),a=c.useCallback(()=>{ft(e,t),o(t)},[e,t]);return{order:r,reorder:i,reset:a}}export{_e as C,go as D,an as K,cn as P,bo as S,yo as a,fo as b,uo as c,ho as d,vo as h,mo as s,wo as u,po as v};
import{k as u,r as n}from"./__vite-browser-external-Eoyj4eG-.js";const f=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],E=u("pencil",f),i="tt.qualityPerDollar.enabled";function l(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(i)==="1"}catch{return!1}}function y(){const[r,o]=n.useState(l);n.useEffect(()=>{if(typeof window>"u")return;const t=e=>{(e.key===null||e.key===i)&&o(l())};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const a=n.useCallback(t=>{const e=!!t;o(e);try{window.localStorage.setItem(i,e?"1":"0")}catch{}},[]),s=n.useCallback(()=>a(!l()),[a]);return{enabled:r,setEnabled:a,toggle:s}}const d="tt.sessionEfficiency.enabled";function c(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(d)==="1"}catch{return!1}}function g(){const[r,o]=n.useState(c);n.useEffect(()=>{if(typeof window>"u")return;const t=e=>{(e.key===null||e.key===d)&&o(c())};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const a=n.useCallback(t=>{const e=!!t;o(e);try{window.localStorage.setItem(d,e?"1":"0")}catch{}},[]),s=n.useCallback(()=>a(!c()),[a]);return{enabled:r,setEnabled:a,toggle:s}}export{E as P,g as a,y as u};
import{a1 as d,a2 as l,a3 as A,r as u,a4 as h,a5 as p,a6 as C,a7 as V,a8 as f}from"./__vite-browser-external-Eoyj4eG-.js";function x(...t){const e=!Array.isArray(t[0]),n=e?0:-1,o=t[0+n],s=t[1+n],r=t[2+n],a=t[3+n],c=d(s,r,a);return e?c(o):c}function E(t){const e=l(()=>A(t)),{isStatic:n}=u.useContext(h);if(n){const[,o]=u.useState(t);u.useEffect(()=>e.on("change",o),[])}return e}function m(t,e){const n=E(e()),o=()=>n.set(e());return o(),p(()=>{const s=()=>V.preRender(o,!1,!0),r=t.map(a=>a.on("change",s));return()=>{r.forEach(a=>a()),C(o)}}),n}function L(t){f.current=[],t();const e=m(f.current,t);return f.current=void 0,e}function M(t,e,n,o){if(typeof t=="function")return L(t);const r=typeof e=="function"?e:x(e,n,o),a=Array.isArray(t)?i(t,r):i([t],([y])=>r(y)),c=Array.isArray(t)?void 0:t.accelerate;return c&&!c.isTransformed&&typeof e!="function"&&Array.isArray(n)&&o?.clamp!==!1&&(a.accelerate={...c,times:e,keyframes:n,isTransformed:!0}),a}function i(t,e){const n=l(()=>[]);return m(t,()=>{n.length=0;const o=t.length;for(let s=0;s<o;s++)n[s]=t[s].get();return e(n)})}export{M as a,E as u};
import{r as y,c as h,Z as S,$ as K,a0 as _}from"./__vite-browser-external-Eoyj4eG-.js";import{l as v}from"./limits-providers-13af4PEg.js";const f="tt.limitAlerts.enabled";function E(){try{return window.localStorage.getItem(f)==="1"}catch{return!1}}function R(){const[e,t]=y.useState(E),i=y.useCallback(async w=>{const c=!!w;c&&typeof Notification<"u"&&Notification.permission==="default"&&await Notification.requestPermission().catch(()=>"denied");try{window.localStorage.setItem(f,c?"1":"0")}catch{}t(c)},[]);return{enabled:e,setEnabled:i}}function F(e,t){if(!(e>0))return null;const i=(e-t)/e;return Number.isFinite(i)?Math.min(Math.max(i,0),1):null}function P(e,t,i=.03){return e>t+i}function M(e){const t=Math.max(0,Math.floor(e)),i=Math.floor(t/3600);return i>24?`${Math.floor(i/24)}d`:i>0?`${i}h`:`${Math.floor(t/60)}m`}function x(e,t){if(typeof e.windowSeconds=="number")return e.windowSeconds;if(e.windowSecondsField&&t){const i=t[e.windowSecondsField];return typeof i=="number"&&i>0?i:null}return null}function N(e){return e==null?NaN:typeof e=="number"?e*1e3:Date.parse(e)}function I({usedPercent:e,windowSeconds:t,resetMs:i,mode:w,now:c=Date.now()}){const n=Math.min(Math.max(Number(e)||0,0),100)/100,s={pacePercent:null,paceOver:!1,expectedPercent:null,runsOutEta:null,projectedEnd:null};if(!(t>0)||!Number.isFinite(i))return s;const l=Math.max(0,(i-c)/1e3),r=F(t,l);if(r==null)return s;if(s.expectedPercent=Math.round(r*100),s.paceOver=P(n,r),n>=.05){const u=w==="remaining"?1-r:r;s.pacePercent=u*100}if(r>.02&&n>0){const u=t*r,d=n/u,m=n/r;m>=1&&d>0?s.runsOutEta=M((1-n)/d):s.projectedEnd=Math.round(Math.min(m,1)*100)}return s}const L={claude:{windows(e){const t=Array.isArray(e.weekly_scoped)?e.weekly_scoped.map(i=>({key:`scoped-${i.label}`,label:i.label,window:i,pctField:"utilization",resetField:"resets_at",windowSeconds:604800})):[];return[{key:"5h",labelKey:"limits.label.claude_5h",window:e.five_hour,pctField:"utilization",resetField:"resets_at",windowSeconds:5*3600},{key:"7d",labelKey:"limits.label.claude_7d",window:e.seven_day,pctField:"utilization",resetField:"resets_at",windowSeconds:7*86400},{key:"opus",labelKey:"limits.label.claude_opus",window:e.seven_day_opus,pctField:"utilization",resetField:"resets_at",windowSeconds:7*86400},...t]}},codex:{extra:"codex_meta",windows(e){return[{key:"5h",labelKey:"limits.label.codex_5h",window:e.primary_window,windowSecondsField:"limit_window_seconds"},{key:"7d",labelKey:"limits.label.codex_7d",window:e.secondary_window,windowSecondsField:"limit_window_seconds"},{key:"credits",labelKey:"limits.label.codex_credits",window:e.credit_window},{key:"spark-5h",labelKey:"limits.label.codex_spark_5h",window:e.spark_primary_window,windowSecondsField:"limit_window_seconds"},{key:"spark-7d",labelKey:"limits.label.codex_spark_7d",window:e.spark_secondary_window,windowSecondsField:"limit_window_seconds"}]}},cursor:{windows(e){return[{key:"plan",labelKey:"limits.label.cursor_plan",window:e.primary_window},{key:"auto",labelKey:"limits.label.cursor_auto",window:e.secondary_window},{key:"api",labelKey:"limits.label.cursor_api",window:e.tertiary_window}]}},gemini:{windows(e){return[{key:"pro",labelKey:"limits.label.gemini_pro",window:e.primary_window},{key:"flash",labelKey:"limits.label.gemini_flash",window:e.secondary_window},{key:"lite",labelKey:"limits.label.gemini_lite",window:e.tertiary_window}]}},kimi:{extra:"kimi_parallel",windows(e){return[{key:"weekly",labelKey:"limits.label.kimi_weekly",window:e.primary_window,windowSeconds:7*86400},{key:"5h",labelKey:"limits.label.kimi_5h",window:e.secondary_window,windowSeconds:5*3600},{key:"total",labelKey:"limits.label.kimi_total",window:e.tertiary_window}]}},kiro:{windows(e){return[{key:"month",labelKey:"limits.label.kiro_month",window:e.primary_window},{key:"bonus",labelKey:"limits.label.kiro_bonus",window:e.secondary_window}]}},grok:{windows(e){return[{key:"month",labelKey:"limits.label.grok_month",window:e.primary_window},{key:"ondemand",labelKey:"limits.label.grok_ondemand",window:e.secondary_window}]}},antigravity:{windows(e){return[{key:"claude-weekly",labelKey:"limits.label.antigravity_claude_weekly",window:e.primary_window},{key:"claude-5h",labelKey:"limits.label.antigravity_claude_5h",window:e.secondary_window},{key:"gemini-weekly",labelKey:"limits.label.antigravity_gemini_weekly",window:e.tertiary_window},{key:"gemini-5h",labelKey:"limits.label.antigravity_gemini_5h",window:e.quaternary_window}]}},copilot:{extra:"copilot_otel",windows(e){return[{key:"premium",labelKey:"limits.label.copilot_premium",window:e.primary_window},{key:"chat",labelKey:"limits.label.copilot_chat",window:e.secondary_window}]}},zcode:{windows(e){return e.plan_kind==="coding-plan"?[{key:"5h",labelKey:"limits.label.zcode_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.zcode_weekly",window:e.secondary_window},{key:"tools",labelKey:"limits.label.zcode_tools",window:e.tertiary_window}]:[{key:"glm52",labelKey:"limits.label.zcode_glm52",window:e.primary_window},{key:"glm5t",labelKey:"limits.label.zcode_glm5t",window:e.secondary_window}]}},opencodeGo:{windows(e){return[{key:"5h",labelKey:"limits.label.opencode_go_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.opencode_go_weekly",window:e.secondary_window},{key:"monthly",labelKey:"limits.label.opencode_go_monthly",window:e.tertiary_window}]}}},g="tt.limitAlerts.cycles.v1";function O(){try{return JSON.parse(window.localStorage.getItem(g)||"{}")}catch{return{}}}function z(e){try{window.localStorage.setItem(g,JSON.stringify(e))}catch{}}function A(e,{now:t=Date.now()}={}){const i=[],w=L;for(const[c,n]of Object.entries(e||{})){const s=w[c];if(!(!n?.configured||n.error||!s))for(const l of s.windows(n)){if(!l.window)continue;const r=Number(l.pctField==="utilization"?l.window.utilization:l.window.used_percent),u=l.resetField==="resets_at"?l.window.resets_at:l.window.reset_at,d=N(u),m=I({usedPercent:r,windowSeconds:x(l,l.window),resetMs:d,mode:"used",now:t});!m.runsOutEta||!m.paceOver||r<20||!(d>t)||i.push({id:`${c}:${l.key}:${d}`,providerId:c,windowKey:l.key,resetMs:d,usedPercent:r,runsOutEta:m.runsOutEta})}}return i}function D(e){const t=O(),i=A(e);for(const n of i){if(t[n.id])continue;const s=v(n.providerId),l=h("limits.alert.title",{provider:s}),r=h("limits.alert.body",{eta:n.runsOutEta,percent:Math.round(n.usedPercent)});let u=S({title:l,body:r,id:n.id});!u&&typeof Notification<"u"&&Notification.permission==="granted"&&(new Notification(l,{body:r,tag:n.id}),u=!0),u&&(t[n.id]=Date.now())}const w=Date.now()-864e5,c=Object.fromEntries(Object.entries(t).filter(([n,s])=>{const l=Number(n.split(":").at(-1));return Number.isFinite(l)?l>=w:Number(s)>=w}).slice(-100));return z(c),i.length}function $(e){const t=!!e?.initialState,[i,w]=y.useState(()=>t?e?.initialState?.data??null:null),[c,n]=y.useState(()=>t?e?.initialState?.error??null:null),[s,l]=y.useState(!t),r=!!e?.initialRefresh,u=!!e?.publishToPreloadCache;y.useEffect(()=>{if(!(!i||typeof window>"u"))try{window.localStorage.getItem(f)==="1"&&D(i)}catch{}},[i]);const d=y.useCallback((o,a)=>{!u||!o||typeof o!="object"||K(o,{source:a})},[u]),m=y.useCallback(async()=>{try{const o=await _({refresh:!0}),a=o&&typeof o=="object"?o:null;w(a),n(null),d(a,"manual-refresh")}catch(o){n(o?.message||String(o))}},[d]),p=y.useCallback(async()=>{try{const o=await _(),a=o&&typeof o=="object"?o:null;w(a),n(null),d(a,"page-load")}catch(o){n(o?.message||String(o))}},[d]);return y.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const o=15e3;let a=Date.now();const b=()=>{if(document.visibilityState!=="visible")return;const k=Date.now();k-a<o||(a=k,p())};return window.addEventListener("focus",b),document.addEventListener("visibilitychange",b),()=>{window.removeEventListener("focus",b),document.removeEventListener("visibilitychange",b)}},[p]),y.useEffect(()=>{if(t&&!r)return;let o=!1;return(async()=>{try{const a=await _();if(o)return;const b=a&&typeof a=="object"?a:null;w(b),n(null),d(b,"page-load")}catch(a){if(o)return;n(a?.message||String(a))}finally{o||l(!1)}})(),()=>{o=!0}},[t,r,d]),{data:i,error:c,isLoading:s,refresh:m}}export{L as P,x as a,R as b,I as c,N as r,D as s,$ as u};
import{r as e,C as t,D as r,v as c}from"./__vite-browser-external-Eoyj4eG-.js";const s=Object.freeze({currency:c,rate:1,symbol:"$",rates:{...r},rateSource:"default",rateFetchedAt:null,setCurrency:()=>{}});function a(){return e.useContext(t)??s}export{a as u};
import{cc as Xe,cd as _t,aO as Ot,aN as Y,aQ as wt,bx as U,ce as Ct,cf as $e,j as Se,cg as ze,r as g,K as V,ch as ot,ci as Dt,aR as it,bv as We,cj as Gt,ck as ct,cl as xt,bz as x,by as ke,bQ as he,cm as Ve,cn as le,co as ae,aL as C,bC as Kt,cp as It,cq as Je,cr as Ut,bN as ut,bI as lt,bK as Xt,cs as Vt,aK as be,bM as qt,ct as jt,aI as Pe,bH as $t,cu as Qe,aT as Be,cv as zt,cw as Ye,bD as Jt,bu as Le,bE as Qt,bw as Ie,cx as _e,cy as Zt,cz as en,cA as tn,aM as nn,aB as Te,cB as me,cC as rn,aW as sn,aF as on,aC as De,cD as at,cE as cn,cF as Ze}from"./__vite-browser-external-Eoyj4eG-.js";function Fe(e,t,n=!0){return e.filter(s=>s.parentId===t).flatMap(s=>[...!n||s.context?.open?[s]:[],...Fe(e,s.id,n)])}function ft(e,t){let n=[],r=e.find(s=>s.id===t)?.parentId;for(;r;){const s=e.find(o=>o.id===r);r=s?.parentId,s&&(n=n.concat(s))}return n}function un(e){e.preventDefault(),e.stopPropagation()}function ln(e){return"nativeEvent"in e}function an(e){return e.pointerType===""&&e.isTrusted?!0:Xe&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function fn(e){return _t?!1:!Xe&&e.width===0&&e.height===0||Xe&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function jn(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function dn(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}function Ae(e){const t=Ot(pn,e).current;return t.next=e,Y(t.effect),t}function pn(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}let Ne=0;function Ge(e,t={}){const{preventScroll:n=!1,sync:r=!1,shouldFocus:s}=t;cancelAnimationFrame(Ne);function o(){s&&!s()||e?.focus({preventScroll:n})}if(r)return o(),wt;const i=requestAnimationFrame(o);return Ne=i,()=>{Ne===i&&(cancelAnimationFrame(i),Ne=0)}}const Ke={inert:new WeakMap,"aria-hidden":new WeakMap},dt="data-base-ui-inert",qe={inert:new WeakSet,"aria-hidden":new WeakSet};let xe=new WeakMap,Ue=0;function gn(e){return qe[e]}function kt(e){return e?Ct(e)?e.host:kt(e.parentNode):null}const pt=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=kt(n);return e.contains(r)?r:null}).filter(n=>n!=null),gt=e=>{const t=new Set;return e.forEach(n=>{let r=n;for(;r&&!t.has(r);)t.add(r),r=r.parentNode}),t},ht=(e,t,n)=>{const r=[],s=o=>{!o||n.has(o)||Array.from(o.children).forEach(i=>{$e(i)!=="script"&&(t.has(i)?s(i):r.push(i))})};return s(e),r};function hn(e,t,n,r,{mark:s=!0}){let o=null;r?o="inert":n&&(o="aria-hidden");let i=null,u=null;const h=pt(t,e),f=s?ht(t,gt(h),new Set(h)):[],k=[],L=[];if(o){const b=Ke[o],T=gn(o);u=T,i=b;const A=pt(t,Array.from(t.querySelectorAll("[aria-live]"))),P=h.concat(A);ht(t,gt(P),new Set(P)).forEach(y=>{const E=y.getAttribute(o),Q=E!==null&&E!=="false",H=(b.get(y)||0)+1;b.set(y,H),k.push(y),H===1&&Q&&T.add(y),Q||y.setAttribute(o,o==="inert"?"":"true")})}return s&&f.forEach(b=>{const T=(xe.get(b)||0)+1;xe.set(b,T),L.push(b),T===1&&b.setAttribute(dt,"")}),Ue+=1,()=>{i&&k.forEach(b=>{const A=(i.get(b)||0)-1;i.set(b,A),A||(!u?.has(b)&&o&&b.removeAttribute(o),u?.delete(b))}),s&&L.forEach(b=>{const T=(xe.get(b)||0)-1;xe.set(b,T),T||b.removeAttribute(dt)}),Ue-=1,Ue||(Ke.inert=new WeakMap,Ke["aria-hidden"]=new WeakMap,qe.inert=new WeakSet,qe["aria-hidden"]=new WeakSet,xe=new WeakMap)}}function mt(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:s=!0}=t,o=U(e[0]).body;return hn(e,o,n,r,{mark:s})}function Pt(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class mn{nodesRef={current:[]};events=Pt();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const Ft=g.createContext(null),Mt=g.createContext(null),et=()=>g.useContext(Ft)?.id||null,tt=e=>{const t=g.useContext(Mt);return e??t};function $n(e){const t=ze(),n=tt(e),r=et();return Y(()=>{if(!t)return;const s={id:t,parentId:r};return n?.addNode(s),()=>{n?.removeNode(s)}},[n,t,r]),t}function zn(e){const{children:t,id:n}=e,r=et();return Se.jsx(Ft.Provider,{value:g.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Jn(e){const{children:t,externalTree:n}=e,r=Ot(()=>n??new mn).current;return Se.jsx(Mt.Provider,{value:r,children:t})}function bn(e,t){const n=Be(be(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const bt=20;let fe=[];function nt(){fe=fe.filter(e=>e.deref()?.isConnected)}function Et(e){nt(),e&&$e(e)!=="body"&&(fe.push(new WeakRef(e)),fe.length>bt&&(fe=fe.slice(-bt)))}function yt(){return nt(),fe[fe.length-1]?.deref()}function En(e){return e?Qe(e)?e:xt(e)[0]||e:null}function Rt(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!e.getAttribute("role")?.includes("dialog"))return;const n=zt(e).filter(s=>{const o=s.getAttribute("data-tabindex")||"";return Qe(s)||s.hasAttribute("data-tabindex")&&!o.startsWith("-")}),r=e.getAttribute("tabindex");n.length===0?r!=="0"&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):(r!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function Qn(e){const{context:t,children:n,disabled:r=!1,initialFocus:s=!0,returnFocus:o=!0,restoreFocus:i=!1,modal:u=!0,closeOnFocusOut:h=!0,openInteractionType:f="",nextFocusableElement:k,previousFocusableElement:L,beforeContentFocusGuardRef:b,externalTree:T,getInsideElements:A}=e,P="rootStore"in t?t.rootStore:t,_=P.useState("open"),y=P.useState("domReferenceElement"),E=P.useState("floatingElement"),{events:Q,dataRef:H}=P.context,q=V(()=>H.current.floatingContext?.nodeId),J=s===!1,D=ot(y)&&J,se=Ae(s),F=Ae(o),j=Ae(f),ve=Ae(_),N=tt(T),R=Dt(),B=g.useRef(!1),oe=g.useRef(!1),ee=g.useRef(!1),te=g.useRef(null),Ee=g.useRef(""),de=g.useRef(""),pe=g.useRef(null),ye=g.useRef(null),S=it(pe,b,R?.beforeInsideRef),$=it(ye,R?.afterInsideRef),ie=We(),ce=We(),Oe=Gt(),Me=R!=null,p=ct(E),ne=V((m=p)=>m?xt(m):[]),Z=V(()=>A?.().filter(m=>m!=null)??[]);g.useEffect(()=>{if(r||!u)return;function m(W){W.key==="Tab"&&C(p,ae(U(p)))&&ne().length===0&&!D&&un(W)}const I=U(p);return x(I,"keydown",m)},[r,p,u,D,ne]),g.useEffect(()=>{if(r||!_)return;const m=U(p);function I(){ee.current=!1}function W(z){const a=be(z),O=Z(),d=C(E,a)||C(y,a)||C(R?.portalNode,a)||O.some(M=>M===a||C(M,a));ee.current=!d,de.current=z.pointerType||"keyboard",a?.closest(`[${qt}]`)&&(oe.current=!0,ce.start(0,()=>{oe.current=!1}))}function G(){de.current="keyboard"}return ke(x(m,"pointerdown",W,!0),x(m,"pointerup",I,!0),x(m,"pointercancel",I,!0),x(m,"keydown",G,!0),I)},[r,E,y,p,_,R,ce,Z]),g.useEffect(()=>{if(r||!h)return;const m=U(p);function I(){oe.current=!0,ce.start(0,()=>{oe.current=!1})}function W(O){const d=be(O);Qe(d)&&(te.current=d)}function G(O){const d=O.relatedTarget,M=O.currentTarget,K=be(O);u&&d==null&&K!=null&&C(E,K)&&Et(K),queueMicrotask(()=>{const w=q(),Re=P.context.triggerElements,c=Z(),l=d?.hasAttribute(Ve("focus-guard"))&&[pe.current,ye.current,R?.beforeInsideRef.current,R?.afterInsideRef.current,R?.beforeOutsideRef.current,R?.afterOutsideRef.current,le(L),le(k)].includes(d),X=!(C(y,d)||C(E,d)||C(d,E)||C(R?.portalNode,d)||c.some(v=>v===d||C(v,d))||d!=null&&Re.hasElement(d)||Re.hasMatchingElement(v=>C(v,d))||l||N&&(Fe(N.nodesRef.current,w).find(v=>C(v.context?.elements.floating,d)||C(v.context?.elements.domReference,d))||ft(N.nodesRef.current,w).find(v=>[v.context?.elements.floating,ct(v.context?.elements.floating)].includes(d)||v.context?.elements.domReference===d)));if(M===y&&p&&Rt(p),i&&M!==y&&!jt(K)&&ae(m)===m.body){if(he(p)&&(p.focus(),i==="popup")){Oe.request(()=>{p.focus()});return}const v=ne(),ue=te.current,we=(ue&&v.includes(ue)?ue:null)||v[v.length-1]||p;he(we)&&we.focus()}if(H.current.insideReactTree){H.current.insideReactTree=!1;return}(D||!u)&&d&&X&&!oe.current&&(D||d!==yt())&&(B.current=!0,P.setOpen(!1,Pe($t,O)))})}function z(){ee.current||(H.current.insideReactTree=!0,ie.start(0,()=>{H.current.insideReactTree=!1}))}const a=he(y)?y:null;if(!(!E&&!a))return ke(a&&x(a,"focusout",G),a&&x(a,"pointerdown",I),E&&x(E,"focusin",W),E&&x(E,"focusout",G),E&&R&&x(E,"focusout",z,!0))},[r,y,E,p,u,N,R,P,h,i,ne,D,q,H,ie,ce,Oe,k,L,Z]),g.useEffect(()=>{if(r||!E||!_)return;const m=Array.from(R?.portalNode?.querySelectorAll(`[${Ve("portal")}]`)||[]),W=(N?ft(N.nodesRef.current,q()):[]).find(M=>ot(M.context?.elements.domReference||null))?.context?.elements.domReference,z=[...[E,...m,pe.current,ye.current,R?.beforeOutsideRef.current,R?.afterOutsideRef.current,...Z()],W,le(L),le(k),D?y:null].filter(M=>M!=null),a=mt(z,{ariaHidden:u||D,mark:!1}),O=[E,...m].filter(M=>M!=null),d=mt(O);return()=>{d(),a()}},[_,r,y,E,u,R,D,N,q,k,L,Z]),Y(()=>{if(!_||r||!he(p))return;const m=U(p),I=ae(m);queueMicrotask(()=>{const W=se.current,G=typeof W=="function"?W(j.current||""):W;if(G===void 0||G===!1||C(p,I))return;let a=null;const O=()=>(a==null&&(a=ne(p)),a[0]||p);let d;G===!0||G===null?d=O():d=le(G),d=d||O();const M=C(p,ae(m));Ge(d,{preventScroll:d===p,shouldFocus(){if(!ve.current)return!1;if(M)return!0;const K=ae(m);return!(K!==d&&C(p,K))}})})},[r,_,p,ne,se,j,ve]),Y(()=>{if(r||!p)return;const m=U(p),I=ae(m),W=j.current==null;Et(I);function G(a){if(a.open||(Ee.current=bn(a.nativeEvent,de.current)),a.reason===Kt&&a.nativeEvent.type==="mouseleave"&&(B.current=!0),a.reason===It)if(a.nested)B.current=!1;else if(an(a.nativeEvent)||fn(a.nativeEvent))B.current=!1;else{let O=!1;U(p).createElement("div").focus({get preventScroll(){return O=!0,!1}}),O?B.current=!1:B.current=!0}}Q.on("openchange",G);function z(){const a=F.current;let O=typeof a=="function"?a(Ee.current):a;if(O===void 0||O===!1)return null;O===null&&(O=!0);const d=y?.isConnected?y:null,M=I?.isConnected&&$e(I)!=="body"?I:null;let K=W?M||d:d||M;return K||(K=yt()||null),typeof O=="boolean"?K:le(O)||K||null}return()=>{Q.off("openchange",G);const a=ae(m),O=Z(),d=C(E,a)||O.some(w=>w===a||C(w,a))||N&&Fe(N.nodesRef.current,q(),!1).some(w=>C(w.context?.elements.floating,a)),M=F.current,K=z();queueMicrotask(()=>{const w=En(K),Re=typeof M!="boolean";M&&!B.current&&he(w)&&(!(!Re&&w!==a&&a!==m.body)||d)&&w.focus({preventScroll:!0}),B.current=!1})}},[r,E,p,F,j,Q,N,y,q,Z]),Y(()=>{if(!Je||_||!E)return;const m=ae(U(E));!he(m)||!Ut(m)||C(E,m)&&m.blur()},[_,E]),Y(()=>{if(!(r||!R))return R.setFocusManagerState({modal:u,closeOnFocusOut:h,open:_,onOpenChange:P.setOpen,domReference:y}),()=>{R.setFocusManagerState(null)}},[r,R,u,_,P,h,y]),Y(()=>{if(!(r||!p))return Rt(p),()=>{queueMicrotask(nt)}},[r,p]);const ge=!r&&(u?!D:!0)&&(Me||u);return Se.jsxs(g.Fragment,{children:[ge&&Se.jsx(ut,{"data-type":"inside",ref:S,onFocus:m=>{if(u){const I=ne();Ge(I[I.length-1])}else R?.portalNode&&(B.current=!1,lt(m,R.portalNode)?Xt(y)?.focus():le(L??R.beforeOutsideRef)?.focus())}}),n,ge&&Se.jsx(ut,{"data-type":"inside",ref:$,onFocus:m=>{u?Ge(ne()[0]):R?.portalNode&&(h&&(B.current=!0),lt(m,R.portalNode)?Vt(y)?.focus():le(k??R.afterOutsideRef)?.focus())}})]})}function yn(){return!1}function Rn(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function Zn(e,t={}){const{enabled:n=!0,escapeKey:r=!0,outsidePress:s=!0,outsidePressEvent:o="sloppy",referencePress:i=yn,bubbles:u,externalTree:h}=t,f="rootStore"in e?e.rootStore:e,k=f.useState("open"),L=f.useState("floatingElement"),{dataRef:b}=f.context,T=tt(h),A=V(typeof s=="function"?s:()=>!1),P=typeof s=="function"?A:s,_=P!==!1,y=V(()=>o),{escapeKey:E,outsidePress:Q}=Rn(u),H=g.useRef(!1),q=g.useRef(!1),J=g.useRef(!1),D=g.useRef(!1),se=g.useRef(""),F=g.useRef(null),j=We(),ve=We(),N=V(()=>{ve.clear(),b.current.insideReactTree=!1}),R=V(S=>{const $=b.current.floatingContext?.nodeId;return(T?Fe(T.nodesRef.current,$):[]).some(ce=>ce.context?.open&&!ce.context.dataRef.current[S])}),B=V(S=>Ye(S,f.select("floatingElement"))||Ye(S,f.select("domReferenceElement"))),oe=V(S=>{i()&&f.setOpen(!1,Pe(Jt,S.nativeEvent))}),ee=V(S=>{if(!k||!n||!r||S.key!=="Escape"||D.current||!E&&R("__escapeKeyBubbles"))return;const $=ln(S)?S.nativeEvent:S,ie=Pe(Qt,$);f.setOpen(!1,ie),ie.isCanceled||S.preventDefault(),!E&&!ie.isPropagationAllowed&&S.stopPropagation()}),te=V(()=>{b.current.insideReactTree=!0,ve.start(0,N)}),Ee=V(S=>{if(!k||!n||S.button!==0)return;const $=be(S.nativeEvent);C(f.select("floatingElement"),$)&&(H.current||(H.current=!0,q.current=!1))}),de=V(S=>{!k||!n||(S.defaultPrevented||S.nativeEvent.defaultPrevented)&&H.current&&(q.current=!0)});g.useEffect(()=>{if(!k||!n)return;b.current.__escapeKeyBubbles=E,b.current.__outsidePressBubbles=Q;const S=new Le,$=new Le;function ie(){S.clear(),D.current=!0}function ce(){S.start(Je?5:0,()=>{D.current=!1})}function Oe(){J.current=!0,$.start(0,()=>{J.current=!1})}function Me(){H.current=!1,q.current=!1}function p(){const c=se.current,l=c==="pen"||!c?"mouse":c,X=y(),v=typeof X=="function"?X():X;return typeof v=="string"?v:v[l]}function ne(c){const l=p();return l==="intentional"&&c.type!=="click"||l==="sloppy"&&c.type==="click"}function Z(c){const l=b.current.floatingContext?.nodeId,X=T&&Fe(T.nodesRef.current,l).some(v=>Ye(c,v.context?.elements.floating));return B(c)||X}function ge(c){if(ne(c)){c.type!=="click"&&!B(c)&&($.clear(),J.current=!1),N();return}if(b.current.insideReactTree){N();return}const l=be(c),X=`[${Ve("inert")}]`,v=Ie(l)?l.getRootNode():null,ue=Array.from((Ct(v)?v:U(f.select("floatingElement"))).querySelectorAll(X)),we=f.context.triggerElements;if(l&&(we.hasElement(l)||we.hasMatchingElement(re=>C(re,l))))return;let Ce=Ie(l)?l:null;for(;Ce&&!_e(Ce);){const re=Zt(Ce);if(_e(re)||!Ie(re))break;Ce=re}if(!(ue.length&&Ie(l)&&!en(l)&&!C(l,f.select("floatingElement"))&&ue.every(re=>!C(Ce,re)))){if(he(l)&&!("touches"in c)){const re=_e(l),He=tn(l),st=/auto|scroll/,At=re||st.test(He.overflowX),Nt=re||st.test(He.overflowY),Wt=At&&l.clientWidth>0&&l.scrollWidth>l.clientWidth,Lt=Nt&&l.clientHeight>0&&l.scrollHeight>l.clientHeight,Bt=He.direction==="rtl",Ht=Lt&&(Bt?c.offsetX<=l.offsetWidth-l.clientWidth:c.offsetX>l.clientWidth),Yt=Wt&&c.offsetY>l.clientHeight;if(Ht||Yt)return}if(!Z(c)){if(p()==="intentional"&&J.current){$.clear(),J.current=!1;return}typeof P=="function"&&!P(c)||R("__outsidePressBubbles")||(f.setOpen(!1,Pe(It,c)),N())}}}function m(c){p()!=="sloppy"||c.pointerType==="touch"||!f.select("open")||!n||B(c)||ge(c)}function I(c){if(p()!=="sloppy"||!f.select("open")||!n||B(c))return;const l=c.touches[0];l&&(F.current={startTime:Date.now(),startX:l.clientX,startY:l.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},j.start(1e3,()=>{F.current&&(F.current.dismissOnTouchEnd=!1,F.current.dismissOnMouseDown=!1)}))}function W(c,l){const X=be(c);if(!X)return;const v=x(X,c.type,()=>{l(c),v()})}function G(c){se.current="touch",W(c,I)}function z(c){j.clear(),c.type==="pointerdown"&&(se.current=c.pointerType),!(c.type==="mousedown"&&F.current&&!F.current.dismissOnMouseDown)&&W(c,l=>{l.type==="pointerdown"?m(l):ge(l)})}function a(c){if(!H.current)return;const l=q.current;if(Me(),p()==="intentional"){if(c.type==="pointercancel"){l&&Oe();return}if(!Z(c)){if(l){Oe();return}typeof P=="function"&&!P(c)||($.clear(),J.current=!0,N())}}}function O(c){if(p()!=="sloppy"||!F.current||B(c))return;const l=c.touches[0];if(!l)return;const X=Math.abs(l.clientX-F.current.startX),v=Math.abs(l.clientY-F.current.startY),ue=Math.sqrt(X*X+v*v);ue>5&&(F.current.dismissOnTouchEnd=!0),ue>10&&(ge(c),j.clear(),F.current=null)}function d(c){W(c,O)}function M(c){p()!=="sloppy"||!F.current||B(c)||(F.current.dismissOnTouchEnd&&ge(c),j.clear(),F.current=null)}function K(c){W(c,M)}const w=U(L),Re=ke(r&&ke(x(w,"keydown",ee),x(w,"compositionstart",ie),x(w,"compositionend",ce)),_&&ke(x(w,"click",z,!0),x(w,"pointerdown",z,!0),x(w,"pointerup",a,!0),x(w,"pointercancel",a,!0),x(w,"mousedown",z,!0),x(w,"mouseup",a,!0),x(w,"touchstart",G,!0),x(w,"touchmove",d,!0),x(w,"touchend",K,!0)));return()=>{Re(),S.clear(),$.clear(),Me(),J.current=!1}},[b,L,r,_,P,k,n,E,Q,ee,N,y,R,B,T,f,j]),g.useEffect(N,[P,N]);const pe=g.useMemo(()=>({onKeyDown:ee,onPointerDown:oe,onClick:oe}),[ee,oe]),ye=g.useMemo(()=>({onKeyDown:ee,onPointerDown:de,onMouseDown:de,onClickCapture:te,onMouseDownCapture(S){te(),Ee(S)},onPointerDownCapture(S){te(),Ee(S)},onMouseUpCapture:te,onTouchEndCapture:te,onTouchMoveCapture:te}),[ee,te,Ee,de]);return g.useMemo(()=>n?{reference:pe,floating:ye,trigger:pe}:{},[n,pe,ye])}function Tn(e){const t=g.useRef(!0);t.current&&(t.current=!1,e())}const Sn={open:Te(e=>e.open),transitionStatus:Te(e=>e.transitionStatus),domReferenceElement:Te(e=>e.domReferenceElement),referenceElement:Te(e=>e.positionReference??e.referenceElement),floatingElement:Te(e=>e.floatingElement),floatingId:Te(e=>e.floatingId)};class vn extends nn{constructor(t){const{syncOnly:n,nested:r,onOpenChange:s,triggerElements:o,...i}=t;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:Pt(),nested:r,triggerElements:o},Sn),this.syncOnly=n}syncOpenEvent=(t,n)=>{(!t||!this.state.open||n!=null&&dn(n))&&(this.context.dataRef.current.openEvent=t?n:void 0)};dispatchOpenChange=(t,n)=>{this.syncOpenEvent(t,n.event);const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)};setOpen=(t,n)=>{if(this.syncOnly){this.context.onOpenChange?.(t,n);return}this.dispatchOpenChange(t,n),this.context.onOpenChange?.(t,n)}}function On(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:s,nested:o,onOpenChange:i}=e,u=t.useState("open"),h=t.useState("activeTriggerElement"),f=t.useState(n?"popupElement":"positionerElement"),k=t.context.triggerElements,L=i,b=g.useRef(null);r===void 0&&b.current===null&&(b.current=new vn({open:u,transitionStatus:void 0,referenceElement:h,floatingElement:f,triggerElements:k,onOpenChange:L,floatingId:s,syncOnly:!0,nested:o}));const T=r??b.current;return t.useSyncedValue("floatingId",s),Y(()=>{const A={open:u,floatingId:s,referenceElement:h,floatingElement:f};Ie(h)&&(A.domReferenceElement=h),T.state.positionReference===T.state.referenceElement&&(A.positionReference=h),T.update(A)},[u,s,h,f,T]),T.context.onOpenChange=L,T.context.nested=o,T}function wn(e,t=!1,n=!1){const[r,s]=g.useState(e&&t?"idle":void 0),[o,i]=g.useState(e);return e&&!o&&(i(!0),s("starting")),!e&&o&&r!=="ending"&&!n&&s("ending"),!e&&!o&&r==="ending"&&s(void 0),Y(()=>{if(!e&&o&&r!=="ending"&&n){const u=me.request(()=>{s("ending")});return()=>{me.cancel(u)}}},[e,o,r,n]),Y(()=>{if(!e||t)return;const u=me.request(()=>{s(void 0)});return()=>{me.cancel(u)}},[t,e]),Y(()=>{if(!e||!t)return;e&&o&&r!=="idle"&&s("starting");const u=me.request(()=>{s("idle")});return()=>{me.cancel(u)}},[t,e,o,r]),{mounted:o,setMounted:i,transitionStatus:r}}const er={tabIndex:-1,[rn]:""};function tr(e){return t=>t==="touch"?e.current:!0}function nr(e,t,n=!1){const r=ze(),s=et()!=null,o=g.useRef(null);e===void 0&&o.current===null&&(o.current=t(r,s));const i=e??o.current;return On({popupStore:i,treatPopupAsFloatingElement:n,floatingRootContext:i.state.floatingRootContext,floatingId:r,nested:s,onOpenChange:i.setOpen}),{store:i,internalStore:o.current}}function Cn(e,t){const n=g.useRef(null),r=g.useRef(null);return g.useCallback(s=>{if(e===void 0)return;let o=!1;if(n.current!==null){const i=n.current,u=r.current,h=t.context.triggerElements.getById(i);u&&h===u&&(t.context.triggerElements.delete(i),o=!0),n.current=null,r.current=null}if(s!==null&&(n.current=e,r.current=s,t.context.triggerElements.add(e,s),o=!0),o){const i=t.context.triggerElements.size;t.select("open")&&t.state.triggerCount!==i&&t.set("triggerCount",i)}},[t,e])}function rr(e,t,n,r=!1){t?e.preventUnmountingOnClose=!1:r&&(e.preventUnmountingOnClose=!0);const s=n?.id??null;(s||t)&&(e.activeTriggerId=s,e.activeTriggerElement=n??null)}function sr(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function or(e,t,n,r){Tn(()=>{t===void 0&&e.state.open===!1&&n&&(e.state={...e.state,open:!0,activeTriggerId:r,preventUnmountingOnClose:!1})})}function ir(e,t,n,r){const s=n.useState("isMountedByTrigger",e),o=Cn(e,n),i=V(u=>{if(o(u),!u)return;const h=n.select("open"),f=n.select("activeTriggerId");if(f===e){n.update({activeTriggerElement:u,...h?r:null});return}f==null&&h&&n.update({activeTriggerId:e,activeTriggerElement:u,...r})});return Y(()=>{s&&n.update({activeTriggerElement:t.current,...r})},[s,n,t,...Object.values(r)]),{registerTrigger:i,isMountedByThisTrigger:s}}function cr(e,t={}){const{closeOnActiveTriggerUnmount:n=!1}=t,r=e.useState("open"),s=e.useState("triggerCount");Y(()=>{if(!r){e.state.triggerCount!==0&&e.set("triggerCount",0);return}const o=e.context.triggerElements.size,i={};e.state.triggerCount!==o&&(i.triggerCount=o);const u=e.select("activeTriggerId");let h=null;if(u){const f=e.context.triggerElements.getById(u);f?f!==e.state.activeTriggerElement&&(i.activeTriggerElement=f):h=u}if(!h&&!u&&o===1){const f=e.context.triggerElements.entries().next();if(!f.done){const[k,L]=f.value;i.activeTriggerId=k,i.activeTriggerElement=L}}(i.triggerCount!==void 0||i.activeTriggerId!==void 0||i.activeTriggerElement!==void 0)&&e.update(i),h&&n&&queueMicrotask(()=>{if(e.select("open")&&e.select("activeTriggerId")===h&&!e.context.triggerElements.getById(h)){const f=Pe(sn);e.setOpen(!1,f),f.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[r,e,s,n])}function ur(e,t,n){const{mounted:r,setMounted:s,transitionStatus:o}=wn(e),i=t.useState("preventUnmountingOnClose"),u=e?!1:i;t.useSyncedValues({mounted:r,transitionStatus:o,preventUnmountingOnClose:u});const h=V(()=>{s(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return on({enabled:r&&!e&&!u,open:e,ref:t.context.popupRef,onComplete(){e||h()}}),{forceUnmount:h,transitionStatus:o}}function lr(e,t){e.useSyncedValues(t),Y(()=>()=>{e.update({activeTriggerProps:De,inactiveTriggerProps:De,popupProps:De})},[e])}function ar(e,t){Y(()=>{!t&&e.state.openMethod!==null&&e.set("openMethod",null)},[t,e]),Y(()=>()=>{e.state.openMethod!==null&&e.set("openMethod",null)},[e])}class fr{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elementsSet.delete(r),this.elementsSet.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elementsSet.delete(n),this.idMap.delete(t))}hasElement(t){return this.elementsSet.has(t)}hasMatchingElement(t){for(const n of this.elementsSet)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}let rt=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=at.startingStyle]="startingStyle",e[e.endingStyle=at.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align",e})({}),je=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const xn={[je.popupOpen]:""},In={[je.popupOpen]:"",[je.pressed]:""},kn={[rt.open]:""},Pn={[rt.closed]:""},Fn={[rt.anchorHidden]:""},dr={open(e){return e?xn:null}},pr={open(e){return e?In:null}},gr={open(e){return e?kn:Pn},anchorHidden(e){return e?Fn:null}};function hr(e){return ze(e,"base-ui")}const Mn="ArrowUp",An="ArrowDown",Nn="ArrowLeft",Wn="ArrowRight",Ln="Home",Bn="End",Hn=new Set([Nn,Wn]),Yn=new Set([Mn,An]),_n=new Set([...Hn,...Yn]),mr=new Set([..._n,Ln,Bn]),br=g.forwardRef(function(t,n){const{cutout:r,...s}=t;let o;if(r){const i=r.getBoundingClientRect();o=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${i.left}px ${i.top}px,${i.left}px ${i.bottom}px,${i.right}px ${i.bottom}px,${i.right}px ${i.top}px,${i.left}px ${i.top}px)`}return Se.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...s,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})});let Tt={},St={},vt="";function Dn(e){if(typeof document>"u")return!1;const t=U(e);return Be(t).innerWidth-t.documentElement.clientWidth>0}function Gn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=U(e),r=n.documentElement,s=n.body,o=Ze(r)?r:s,i=o.style.overflowY,u=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",o.style.overflowY="scroll";const h=o.offsetWidth;o.style.overflowY="hidden";const f=o.offsetWidth;return o.style.overflowY=i,r.style.scrollbarGutter=u,h===f}function Kn(e){const t=U(e),n=t.documentElement,r=t.body,s=Ze(n)?n:r,o={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,o)}}function Un(e){const t=U(e),n=t.documentElement,r=t.body,s=Be(n);let o=0,i=0,u=!1;const h=me.create();if(Je&&(s.visualViewport?.scale??1)!==1)return()=>{};function f(){const T=s.getComputedStyle(n),A=s.getComputedStyle(r),y=(T.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,i=n.scrollLeft,Tt={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},vt=n.style.scrollBehavior,St={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const E=n.scrollHeight>n.clientHeight,Q=n.scrollWidth>n.clientWidth,H=T.overflowY==="scroll"||A.overflowY==="scroll",q=T.overflowX==="scroll"||A.overflowX==="scroll",J=Math.max(0,s.innerWidth-r.clientWidth),D=Math.max(0,s.innerHeight-r.clientHeight),se=parseFloat(A.marginTop)+parseFloat(A.marginBottom),F=parseFloat(A.marginLeft)+parseFloat(A.marginRight),j=Ze(n)?n:r;if(u=Gn(e),u){n.style.scrollbarGutter=y,j.style.overflowY="hidden",j.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:y,overflowY:"hidden",overflowX:"hidden"}),(E||H)&&(n.style.overflowY="scroll"),(Q||q)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:se||D?`calc(100dvh - ${se+D}px)`:"100dvh",width:F||J?`calc(100vw - ${F+J}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=o,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function k(){Object.assign(n.style,Tt),Object.assign(r.style,St),u||(n.scrollTop=o,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=vt)}function L(){k(),h.request(f)}f();const b=x(s,"resize",L);return()=>{h.cancel(),k(),typeof s.removeEventListener=="function"&&b()}}class Xn{lockCount=0;restore=null;timeoutLock=Le.create();timeoutUnlock=Le.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=U(t).documentElement,s=Be(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=wt;return}const o=cn||!Dn(t);this.restore=o?Kn(t):Un(t)}}const Vn=new Xn;function Er(e=!0,t=null){Y(()=>{if(e)return Vn.acquire(t)},[e,t])}export{pr as A,$n as B,rt as C,zn as D,Ge as E,vn as F,un as G,an as H,br as I,fn as J,fr as P,er as a,mr as b,tr as c,Qn as d,ar as e,cr as f,ur as g,Zn as h,Er as i,lr as j,nr as k,Tn as l,wn as m,jn as n,tt as o,gr as p,et as q,Fe as r,rr as s,dr as t,hr as u,Ae as v,sr as w,Jn as x,or as y,ir as z};
import{r as e,T as r,l as n,m as a,n as s}from"./__vite-browser-external-Eoyj4eG-.js";const T=Object.freeze({mode:n.COMPACT,setMode:()=>{},formatTokens:(o,t={})=>s(o,t),formatTokensTooltip:(o,t={})=>a(o,t)});function f(){return e.useContext(r)??T}export{f as u};
import{j as e,c as o,I,M as P,r as u,o as D,R as E,b as M}from"./__vite-browser-external-Eoyj4eG-.js";import{S as _}from"./Select-CH2xVU8X.js";import{u as K,T as R}from"./use-native-settings-Bi6E9dsE.js";import{F as j,S as G,a as O}from"./FadeIn-BDWtfIsO.js";import{A as $}from"./arrow-up-right-CT4-gmOS.js";import{D as z}from"./download-DaWsA_Gj.js";import"./SelectItemText-CCW6JeeN.js";import"./useScrollLock-C2C-Yazq.js";import"./check-B87_qvAg.js";import"./Card-C3nLScju.js";const H=["todayTokens","todayCost"],W=[{id:"todayTokens",label:"Today Tokens",shortLabel:"Tokens",category:"tokens"},{id:"todayCost",label:"Today Cost",shortLabel:"Cost",category:"cost"},{id:"last7dTokens",label:"Last 7 Days",shortLabel:"7d",category:"tokens"},{id:"totalTokens",label:"Total Tokens",shortLabel:"Total",category:"tokens"},{id:"totalCost",label:"Total Cost",shortLabel:"All $",category:"cost"},{id:"claude5h",label:"Claude 5h Limit",shortLabel:"Cl 5h",category:"limits"},{id:"claude7d",label:"Claude 7d Limit",shortLabel:"Cl 7d",category:"limits"},{id:"codex5h",label:"Codex 5h Limit",shortLabel:"Cx 5h",category:"limits"},{id:"codex7d",label:"Codex 7d Limit",shortLabel:"Cx 7d",category:"limits"},{id:"codexCredits",label:"Codex Credit Limit",shortLabel:"Cx Cred",category:"limits"},{id:"codexSpark5h",label:"Codex Spark 5h Limit",shortLabel:"Cx Spark 5h",category:"limits"},{id:"codexSpark7d",label:"Codex Spark 7d Limit",shortLabel:"Cx Spark 7d",category:"limits"},{id:"cursorPlan",label:"Cursor Plan Limit",shortLabel:"Cu Plan",category:"limits"},{id:"cursorAuto",label:"Cursor Auto Limit",shortLabel:"Cu Auto",category:"limits"},{id:"cursorAPI",label:"Cursor API Limit",shortLabel:"Cu API",category:"limits"},{id:"geminiPro",label:"Gemini Pro Limit",shortLabel:"Gm Pro",category:"limits"},{id:"geminiFlash",label:"Gemini Flash Limit",shortLabel:"Gm Flash",category:"limits"},{id:"geminiLite",label:"Gemini Lite Limit",shortLabel:"Gm Lite",category:"limits"},{id:"kimiWeekly",label:"Kimi Weekly Limit",shortLabel:"Km Wk",category:"limits"},{id:"kimi5h",label:"Kimi 5h Limit",shortLabel:"Km 5h",category:"limits"},{id:"kimiTotal",label:"Kimi Total Limit",shortLabel:"Km Tot",category:"limits"},{id:"kiroMonth",label:"Kiro Monthly Limit",shortLabel:"Kr Mo",category:"limits"},{id:"kiroBonus",label:"Kiro Bonus Limit",shortLabel:"Kr Bn",category:"limits"},{id:"copilotPremium",label:"Copilot Premium Limit",shortLabel:"Co Prem",category:"limits"},{id:"copilotChat",label:"Copilot Chat Limit",shortLabel:"Co Chat",category:"limits"},{id:"antigravityClaudeWeekly",label:"Antigravity Claude 7d Limit",shortLabel:"Ag Cl 7d",category:"limits"},{id:"antigravityClaude5h",label:"Antigravity Claude 5h Limit",shortLabel:"Ag Cl 5h",category:"limits"},{id:"antigravityGeminiWeekly",label:"Antigravity Gemini 7d Limit",shortLabel:"Ag Gm 7d",category:"limits"},{id:"antigravityGemini5h",label:"Antigravity Gemini 5h Limit",shortLabel:"Ag Gm 5h",category:"limits"}];function v(t,a=W,r=2){const i=new Set(a.map(n=>n.id)),l=new Set,s=Array.isArray(t)?t.filter(n=>!i.has(n)||l.has(n)?!1:(l.add(n),!0)):[];return(s.length>0?s:H).slice(0,Math.max(1,Number(r)||2))}const U=264,V=124,x="ui-rounded, -apple-system, system-ui",L=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],X={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function Y(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function b({size:t="sm",children:a}){const r=t==="lg",i=r?560:264,l=r?32:22;return e.jsx("div",{className:M("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",r?"py-10 sm:py-14 px-6":"py-6 px-4"),children:e.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:i,aspectRatio:`${U} / ${V}`,borderRadius:l},children:a})})}function Z({size:t="sm"}){const a="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",r=`${a} L264,124 L0,124 Z`,i=`sparkArea-${t}`;return e.jsx(b,{size:t,children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:i,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),e.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),e.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"TODAY"}),e.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:x,children:"203.2M"}),e.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:x,children:"$129.56 ±0%"}),e.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"7 DAYS"}),e.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:x,children:"880.9M"}),e.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:x,children:"$673.61"}),e.jsx("path",{d:r,fill:`url(#${i})`,stroke:"none"}),e.jsx("path",{d:a,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const C=(()=>{const r=[];for(let i=0;i<26;i++)for(let l=0;l<7;l++){const s=Math.sin((i+1)*12.9898+(l+1)*78.233+17)*43758.5453,c=Math.floor(Math.abs(s-Math.floor(s))*100);r.push({w:i,d:l,v:c})}return r})();function S(t,a){return t<18?a?"#262626":"#e5e5e5":t<38?"rgba(10, 132, 255, 0.28)":t<58?"rgba(10, 132, 255, 0.50)":t<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function q(){return e.jsx(b,{children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:C.map(s=>e.jsx("rect",{x:s.w*(7.5+1.2),y:s.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:S(s.v,!0)},`d-${s.w}-${s.d}`))}),e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:C.map(s=>e.jsx("rect",{x:s.w*(7.5+1.2),y:s.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:S(s.v,!1)},`l-${s.w}-${s.d}`))}),e.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:x,children:"10.3B"}),e.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:"tokens · 202 active days"})]})})}function J(){const t=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],a=22,r=28,i=14,l=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((s,c)=>{const n=r+c*a,h=L[c%L.length];return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:s.name}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:x,children:s.value}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:x,children:[s.pct,"%"]}),e.jsx("rect",{x:i,y:n+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:i,y:n+4,width:Math.max(l*(s.pct/100),4),height:"2.8",rx:"1.4",fill:h})]},s.name)})})})}function Q(){const t=[{label:"Claude · 7d",source:"claude",reset:"in 1d",pct:61},{label:"Claude · 5h",source:"claude",reset:"in 4h 28m",pct:4},{label:"Cursor",source:"cursor",reset:"in 25d",pct:51},{label:"Codex · weekly",source:"codex",reset:"in 1d",pct:32}],a=22,r=28,i=14,l=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((s,c)=>{const n=r+c*a,h=X[s.source],y=Y(s.pct/100);return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:s.label}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:x,children:s.reset}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:x,children:[s.pct,"%"]}),e.jsx("rect",{x:i,y:n+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:i,y:n+4,width:Math.max(l*(s.pct/100),4),height:"2.8",rx:"1.4",fill:y})]},s.label)})})})}function ee(t){switch(t.category){case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function te(t,a){switch(t){case"todayTokens":return o("menubar.metric.today_tokens");case"todayCost":return o("menubar.metric.today_cost");case"last7dTokens":return o("menubar.metric.last_7d_tokens");case"totalTokens":return o("menubar.metric.total_tokens");case"totalCost":return o("menubar.metric.total_cost");case"claude5h":return o("menubar.metric.claude_5h");case"claude7d":return o("menubar.metric.claude_7d");case"codex5h":return o("menubar.metric.codex_5h");case"codex7d":return o("menubar.metric.codex_7d");case"codexCredits":return o("menubar.metric.codex_credits");case"codexSpark5h":return o("menubar.metric.codex_spark_5h");case"codexSpark7d":return o("menubar.metric.codex_spark_7d");default:return a}}function ae(t,a){const r=new Set(a.map(l=>l.id)),i=t.filter(l=>r.has(l));for(const l of a){if(i.length>=2)break;i.includes(l.id)||i.push(l.id)}return i.slice(0,2)}function ie({slotConfigs:t,showStats:a}){return e.jsx("div",{className:"flex justify-center rounded-xl bg-gradient-to-b from-oai-gray-100 to-oai-gray-200 px-6 py-8 dark:from-oai-gray-950/80 dark:to-oai-gray-900/80",children:e.jsxs("div",{className:"inline-flex items-stretch rounded-md shadow-[0_1px_3px_rgba(0,0,0,0.18)] ring-1 ring-black/10 dark:ring-white/10 px-3",style:{background:"linear-gradient(180deg, #2c2c2e 0%, #1c1c1e 100%)"},children:[e.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:e.jsx("img",{src:"/clawd/mini/idle-tight.svg",alt:"","aria-hidden":"true",className:"block shrink-0",style:{height:22,width:"auto"},draggable:"false"})}),a?t.map(({slot:r,item:i},l)=>e.jsxs(E.Fragment,{children:[l>0?e.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,e.jsxs("div",{className:M("flex min-w-[52px] flex-col items-center justify-center py-1.5",l===0?"pl-1 pr-2":"px-2"),children:[e.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:i?.previewValue||"--"}),e.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:i?.shortLabel||"Metric"})]})]},r)):null]})})}function se({slot:t,value:a,options:r,disabled:i,onChange:l}){const s=t===0?o("menubar.slot.primary"):o("menubar.slot.secondary");return e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:s}),e.jsx(_,{value:a,disabled:i,ariaLabel:s,onValueChange:c=>l(t,c),options:r.map(c=>({value:c.id,label:c.displayLabel})),matchTriggerWidth:!0,className:"w-full px-3 py-2 text-sm font-medium"})]})}function N({label:t,hint:a,checked:r,disabled:i,onChange:l}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),a?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a}):null]}),e.jsx(R,{checked:r,disabled:i,onChange:l,ariaLabel:t})]})}function re({label:t,hint:a,value:r,options:i,disabled:l,onChange:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),a?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a}):null]}),e.jsx(_,{value:r,disabled:l,ariaLabel:t,onValueChange:s,options:i,className:"shrink-0 px-3 py-2 text-sm font-medium"})]})}function le(){const{available:t,settings:a,setSetting:r}=K(),i=u.useMemo(()=>(Array.isArray(a?.menuBarAvailableItems)?a.menuBarAvailableItems:W).map(m=>({...m,displayLabel:te(m.id,m.label),previewValue:ee(m)})),[a?.menuBarAvailableItems]),l=Number(a?.menuBarMaxItems)||2,s=u.useMemo(()=>v(a?.menuBarItems,i,l),[i,l,a?.menuBarItems]),c=u.useMemo(()=>ae(s,i),[i,s]),n=a?.showStats!==!1,h=d=>{r("menuBarItems",v(d,i,l))},y=(d,m)=>{const g=[...c];g[d===0?1:0]!==m&&(g[d]=m,h(g))},p=[0,1].map(d=>{const m=c[d]||i[d]?.id||"",w=c[d===0?1:0],F=i.filter(f=>f.id===m||f.id!==w),B=i.find(f=>f.id===m);return{slot:d,currentValue:m,options:F,item:B}}),T=["clawd","cat","pet","static"].includes(a?.menuBarIconStyle)?a.menuBarIconStyle:"clawd",k=a?.confettiOnReset!==!1;return e.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-5 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-6",children:[e.jsx(ie,{slotConfigs:p,showStats:n}),e.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:p.map(({slot:d,currentValue:m,options:g})=>e.jsx(se,{slot:d,value:m,options:g,disabled:!t||!n,onChange:y},d))}),e.jsxs("div",{className:"mt-5 divide-y divide-oai-gray-100 border-t border-oai-gray-100 dark:divide-oai-gray-800 dark:border-oai-gray-800",children:[e.jsx(N,{label:o("settings.menubar.showStats"),hint:t?o("settings.menubar.showStatsHint"):o("menubar.native_only"),checked:n,disabled:!t,onChange:()=>r("showStats",!n)}),e.jsx(re,{label:o("settings.menubar.iconStyle"),hint:o("settings.menubar.iconStyleHint"),value:T,disabled:!t,options:[{value:"clawd",label:o("settings.menubar.iconStyle.clawd")},{value:"cat",label:o("settings.menubar.iconStyle.cat")},{value:"pet",label:o("settings.menubar.iconStyle.pet")},{value:"static",label:o("settings.menubar.iconStyle.static")}],onChange:d=>r("menuBarIconStyle",d)}),e.jsx(N,{label:o("settings.menubar.confettiOnReset"),hint:o("settings.menubar.confettiOnResetHint"),checked:k,disabled:!t,onChange:()=>r("confettiOnReset",!k)})]})]})}function oe(){const[t,a]=u.useState("loading");return u.useEffect(()=>{if(typeof window>"u")return;if(D()){a("native");return}const r=(navigator.userAgent||"").toLowerCase(),i=/mac/.test(r)&&!/iphone|ipad/.test(r);a(i?"mac-web":"other")},[]),t}function ne(){const t=oe();return t==="loading"?e.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?e.jsxs("button",{type:"button",onClick:()=>I("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[o("widgets.cta.open_gallery"),e.jsx($,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?e.jsxs("a",{href:"https://github.com/mm7894215/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[e.jsx(z,{className:"h-4 w-4","aria-hidden":"true"}),o("widgets.cta.download")]}):e.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[e.jsx(P,{className:"h-4 w-4","aria-hidden":"true"}),o("widgets.cta.macos_only")]})}const ce=[{id:"summary",Preview:Z,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:q,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:J,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:Q,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function de({Preview:t,nameKey:a,descKey:r}){return e.jsxs("article",{className:"flex h-full flex-col rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[e.jsx(t,{}),e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:o(a)}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:o(r)})]})]})}function A({titleKey:t}){return e.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:o(t)})}function je(){return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[e.jsx(j,{y:12,children:e.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:o("widgets.page.title")}),e.jsx("div",{className:"shrink-0",children:e.jsx(ne,{})})]})}),e.jsx(j,{y:12,delay:.06,children:e.jsxs("section",{"aria-label":o("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[e.jsx(A,{titleKey:"widgets.menubar.section.title"}),e.jsx(le,{})]})}),e.jsxs("section",{"aria-label":o("widgets.gallery.section.title"),children:[e.jsx(A,{titleKey:"widgets.gallery.section.title"}),e.jsx(G,{staggerDelay:.08,initialDelay:.04,children:e.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:ce.map(({id:t,Preview:a,nameKey:r,descKey:i})=>e.jsx(O,{children:e.jsx(de,{Preview:a,nameKey:r,descKey:i})},t))})})]})]})})})}export{je as WidgetsPage};
import{r as l,j as e,i as y}from"./__vite-browser-external-Eoyj4eG-.js";function o(a){return Number.isFinite(a)?Math.abs(a)>=1e12?(a/1e12).toFixed(2).replace(/\.?0+$/,"")+"T":y(a,{decimals:2}):"0"}function r({children:a,accent:n=!1,className:i=""}){const c="rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 p-6 bg-white dark:bg-oai-gray-900",d=n?"bg-gradient-to-br from-emerald-50 to-cyan-50 dark:from-emerald-900/30 dark:to-cyan-900/30 border-transparent":"";return e.jsx("div",{className:`${c} ${d} ${i}`,children:a})}function u(){const[a,n]=l.useState(null),[i,c]=l.useState("loading"),[d,g]=l.useState("");if(l.useEffect(()=>{let t=!1;const h=new URLSearchParams(window.location.search).get("year"),p=h?`/functions/tokentracker-wrapped?year=${encodeURIComponent(h)}`:"/functions/tokentracker-wrapped";return fetch(p).then(async s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}).then(s=>{t||(n(s),c(s.totals&&s.totals.tokens>0?"ready":"empty"))}).catch(s=>{t||(g(String(s?.message||s)),c("error"))}),()=>{t=!0}},[]),i==="loading")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center",children:e.jsx("p",{className:"text-oai-gray-500",children:"Loading…"})});if(i==="error")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(r,{children:e.jsxs("p",{className:"text-red-600 dark:text-red-300",children:["Couldn't load Wrapped: ",d]})})});if(i==="empty"||!a)return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(r,{children:e.jsxs("p",{className:"text-oai-gray-500",children:["No data for that year yet. Run ",e.jsx("code",{children:"tracker sync"})," first."]})})});const x=t=>`${(t*100).toFixed(0)}%`;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-white to-oai-gray-50 dark:from-oai-gray-950 dark:to-oai-gray-900 px-6 py-12",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsxs("header",{className:"text-center pb-6",children:[e.jsx("p",{className:"text-sm uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:"TokenTracker Wrapped"}),e.jsx("h1",{className:"text-6xl font-bold text-oai-gray-900 dark:text-white mt-2",children:a.year})]}),e.jsxs(r,{accent:!0,className:"text-center",children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300",children:"Total tokens"}),e.jsx("p",{className:"text-7xl font-bold text-emerald-700 dark:text-emerald-300 mt-2",children:o(a.totals.tokens)}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-4",children:["across ",e.jsx("strong",{children:a.totals.conversations.toLocaleString("en-US")})," conversations,"," ",e.jsx("strong",{children:a.totals.active_days})," active days, and"," ",e.jsx("strong",{children:a.totals.sources})," tools"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs(r,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:"Top tools"}),e.jsx("ul",{className:"space-y-3",children:a.top.sources.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white",children:t.source}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:[o(t.tokens)," · ",x(t.share)]})]},t.source))})]}),e.jsxs(r,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:"Top models"}),e.jsx("ul",{className:"space-y-3",children:a.top.models.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white truncate pr-3",children:t.model}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm whitespace-nowrap",children:[o(t.tokens)," · ",x(t.share)]})]},t.model))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.peak_hour&&e.jsxs(r,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:"Peak hour"}),e.jsxs("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:[String(a.peak_hour.hour).padStart(2,"0"),":00 UTC"]}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:[o(a.peak_hour.tokens)," tokens"]})]}),a.longest_streak&&a.longest_streak.days>0&&e.jsxs(r,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:"Longest streak"}),e.jsxs("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:[a.longest_streak.days," days"]}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:[a.longest_streak.from," → ",a.longest_streak.to]})]})]}),a.top.days.length>0&&e.jsxs(r,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:"Top days"}),e.jsx("ul",{className:"space-y-2",children:a.top.days.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white font-mono text-sm",children:t.day}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:o(t.tokens)})]},t.day))})]}),a.highlights.length>0&&e.jsxs(r,{accent:!0,children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300 mb-3",children:"Highlights"}),e.jsx("ul",{className:"space-y-2 text-oai-gray-800 dark:text-oai-gray-200",children:a.highlights.map((t,m)=>e.jsxs("li",{className:"text-base",children:["· ",t]},m))})]}),e.jsxs("footer",{className:"text-center text-xs text-oai-gray-400 dark:text-oai-gray-500 pt-6",children:["Generated from local queue.jsonl · share with"," ",e.jsx("code",{className:"font-mono",children:"tracker wrapped --json"})]})]})})}export{u as default};
import{k as a}from"./__vite-browser-external-Eoyj4eG-.js";const o=[["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"}]],e=a("zap",o);export{e as Z};

Sorry, the diff of this file is too big to display