tokentracker-cli 0.5.80 → 0.5.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/{Card-Cv4eTIKD.js → Card-D89QXio1.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-BLFOnvMn.js → DashboardPage-QTEFpkGt.js} +2 -2
- package/dashboard/dist/assets/{FadeIn-CIeY4GXM.js → FadeIn-Je-IKTCi.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-IsYc44dj.js → IpCheckPage-CmkmxYbi.js} +1 -1
- package/dashboard/dist/assets/LeaderboardPage-k6ZhKD8v.js +5 -0
- package/dashboard/dist/assets/{LeaderboardProfilePage-bt2zrvtb.js → LeaderboardProfilePage-BnGBEWSR.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-CojL1PZS.js → LimitsPage-J7QkP-Qk.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-C2Qp69XI.js → ProviderIcon-W5bQlVZy.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-FSVM_ozY.js → SettingsPage-D78h8ssI.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-CeLvw5tR.js → WidgetsPage-DJLzhtO0.js} +1 -1
- package/dashboard/dist/assets/{download-BK4EqMpL.js → download-DcBCxxpH.js} +1 -1
- package/dashboard/dist/assets/{leaderboard-columns-CxdAz5_V.js → leaderboard-columns-BCCXSWB7.js} +1 -1
- package/dashboard/dist/assets/{main-CPsqG3PW.js → main-CtQnmeNT.js} +188 -188
- package/dashboard/dist/assets/{main-DRf20yyJ.css → main-v7jzPCYG.css} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-C-Y8vFA9.js → use-limits-display-prefs-CUKlkCzX.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-CiHD5lbg.js → use-usage-limits-CDoWAIkh.js} +1 -1
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +1 -1
- package/src/commands/serve.js +14 -4
- package/src/lib/local-api.js +135 -26
- package/src/lib/static-server.js +0 -1
- package/dashboard/dist/assets/LeaderboardPage-Su4flsQc.js +0 -5
package/src/lib/local-api.js
CHANGED
|
@@ -2,6 +2,8 @@ const fs = require("node:fs");
|
|
|
2
2
|
const os = require("node:os");
|
|
3
3
|
const path = require("node:path");
|
|
4
4
|
const { spawn } = require("node:child_process");
|
|
5
|
+
const crypto = require("node:crypto");
|
|
6
|
+
const { DEFAULT_BASE_URL, resolveRuntimeConfig } = require("./runtime-config");
|
|
5
7
|
|
|
6
8
|
const SYNC_TIMEOUT_MS = 120_000;
|
|
7
9
|
const TRACKER_BIN = path.resolve(__dirname, "../../bin/tracker.js");
|
|
@@ -159,6 +161,29 @@ function readProjectQueueData(projectQueuePath) {
|
|
|
159
161
|
return Array.from(seen.values());
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
function isLegacyInclusiveCodexRow(row) {
|
|
165
|
+
if (!row || (row.source !== "codex" && row.source !== "every-code")) return false;
|
|
166
|
+
const inputTokens = Number(row.input_tokens || 0);
|
|
167
|
+
const cachedInputTokens = Number(row.cached_input_tokens || 0);
|
|
168
|
+
const outputTokens = Number(row.output_tokens || 0);
|
|
169
|
+
const totalTokens = Number(row.total_tokens || 0);
|
|
170
|
+
if (!Number.isFinite(inputTokens) || !Number.isFinite(cachedInputTokens)) return false;
|
|
171
|
+
if (cachedInputTokens <= 0 || inputTokens < cachedInputTokens) return false;
|
|
172
|
+
// Legacy Codex queue rows stored input inclusive of cache reads, while
|
|
173
|
+
// total_tokens remained input + output. Canonical rows keep input as pure
|
|
174
|
+
// non-cached input, so cache-heavy legacy rows can be identified by this
|
|
175
|
+
// exact invariant.
|
|
176
|
+
return totalTokens === inputTokens + outputTokens;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function normalizeQueueRow(row) {
|
|
180
|
+
if (!isLegacyInclusiveCodexRow(row)) return row;
|
|
181
|
+
return {
|
|
182
|
+
...row,
|
|
183
|
+
input_tokens: Number(row.input_tokens || 0) - Number(row.cached_input_tokens || 0),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
162
187
|
function readQueueData(queuePath) {
|
|
163
188
|
let raw;
|
|
164
189
|
try {
|
|
@@ -194,7 +219,7 @@ function readQueueData(queuePath) {
|
|
|
194
219
|
const seen = new Map();
|
|
195
220
|
for (const row of parsed) {
|
|
196
221
|
const key = `${row.source || ""}|${row.model || ""}|${row.hour_start || ""}`;
|
|
197
|
-
seen.set(key, row);
|
|
222
|
+
seen.set(key, normalizeQueueRow(row));
|
|
198
223
|
}
|
|
199
224
|
return Array.from(seen.values());
|
|
200
225
|
}
|
|
@@ -361,6 +386,67 @@ function trimOutput(value, max = 4000) {
|
|
|
361
386
|
return t.length <= max ? t : t.slice(t.length - max);
|
|
362
387
|
}
|
|
363
388
|
|
|
389
|
+
function normalizeRemoteHttpBaseUrl(value) {
|
|
390
|
+
if (typeof value !== "string") return null;
|
|
391
|
+
const trimmed = value.trim();
|
|
392
|
+
if (!trimmed) return null;
|
|
393
|
+
try {
|
|
394
|
+
const url = new URL(trimmed);
|
|
395
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
|
396
|
+
url.username = "";
|
|
397
|
+
url.password = "";
|
|
398
|
+
url.hash = "";
|
|
399
|
+
return url.toString().replace(/\/$/, "");
|
|
400
|
+
} catch (_e) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function resolveAllowedInsforgeBaseUrl(value) {
|
|
406
|
+
const requested = normalizeRemoteHttpBaseUrl(value);
|
|
407
|
+
if (!requested) return null;
|
|
408
|
+
|
|
409
|
+
const runtime = resolveRuntimeConfig();
|
|
410
|
+
const allowed = new Set(
|
|
411
|
+
[runtime.baseUrl, DEFAULT_BASE_URL]
|
|
412
|
+
.map((entry) => normalizeRemoteHttpBaseUrl(entry))
|
|
413
|
+
.filter(Boolean),
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
return allowed.has(requested) ? requested : null;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function parseCookieHeader(value) {
|
|
420
|
+
const out = new Map();
|
|
421
|
+
if (typeof value !== "string" || !value.trim()) return out;
|
|
422
|
+
for (const part of value.split(";")) {
|
|
423
|
+
const idx = part.indexOf("=");
|
|
424
|
+
if (idx < 1) continue;
|
|
425
|
+
const key = part.slice(0, idx).trim();
|
|
426
|
+
const rawValue = part.slice(idx + 1).trim();
|
|
427
|
+
if (key) out.set(key, rawValue);
|
|
428
|
+
}
|
|
429
|
+
return out;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function isLoopbackHostname(hostname) {
|
|
433
|
+
return hostname === "127.0.0.1" || hostname === "localhost" || hostname === "::1" || hostname === "[::1]";
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function hasAllowedLoopbackOrigin(headers = {}) {
|
|
437
|
+
const candidates = [headers.origin, headers.referer];
|
|
438
|
+
for (const raw of candidates) {
|
|
439
|
+
if (raw == null || raw === "") continue;
|
|
440
|
+
try {
|
|
441
|
+
const url = new URL(String(raw));
|
|
442
|
+
if (url.protocol !== "http:" || !isLoopbackHostname(url.hostname)) return false;
|
|
443
|
+
} catch (_e) {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
|
|
364
450
|
function readJsonBody(req) {
|
|
365
451
|
return new Promise((resolve, reject) => {
|
|
366
452
|
const chunks = [];
|
|
@@ -526,7 +612,7 @@ function scanClaudeProjects(projectMap) {
|
|
|
526
612
|
// ---------------------------------------------------------------------------
|
|
527
613
|
|
|
528
614
|
function json(res, data, status) {
|
|
529
|
-
res.writeHead(status || 200, { "Content-Type": "application/json"
|
|
615
|
+
res.writeHead(status || 200, { "Content-Type": "application/json" });
|
|
530
616
|
res.end(JSON.stringify(data));
|
|
531
617
|
}
|
|
532
618
|
|
|
@@ -541,6 +627,7 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
541
627
|
// so that both browser and WKWebView share the same login session via the proxy.
|
|
542
628
|
// Persisted to disk so cookies survive server restarts.
|
|
543
629
|
let relayCookies = new Map();
|
|
630
|
+
const localAuthToken = crypto.randomBytes(24).toString("hex");
|
|
544
631
|
const trackerDataDir = path.join(os.homedir(), ".tokentracker", "tracker");
|
|
545
632
|
const cookiePath = path.join(trackerDataDir, "relay-cookies.json");
|
|
546
633
|
|
|
@@ -653,13 +740,40 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
653
740
|
let _nativeAuthPending = false;
|
|
654
741
|
let _nativeAuthExpiry = 0;
|
|
655
742
|
|
|
743
|
+
function isAuthorizedLocalMutation(req) {
|
|
744
|
+
const headerToken = req?.headers?.["x-tokentracker-local-auth"];
|
|
745
|
+
const cookieToken = parseCookieHeader(req?.headers?.cookie).get("tokentracker_local_auth");
|
|
746
|
+
const token = typeof headerToken === "string" && headerToken.trim()
|
|
747
|
+
? headerToken.trim()
|
|
748
|
+
: cookieToken || "";
|
|
749
|
+
if (!token || token !== localAuthToken) return false;
|
|
750
|
+
return hasAllowedLoopbackOrigin(req?.headers || {});
|
|
751
|
+
}
|
|
752
|
+
|
|
656
753
|
return async function handleLocalApi(req, res, url) {
|
|
657
754
|
const p = url.pathname;
|
|
658
755
|
|
|
756
|
+
if (p === "/api/local-auth") {
|
|
757
|
+
if (String(req.method || "GET").toUpperCase() !== "GET") {
|
|
758
|
+
json(res, { error: "Method Not Allowed" }, 405);
|
|
759
|
+
return true;
|
|
760
|
+
}
|
|
761
|
+
res.writeHead(200, {
|
|
762
|
+
"Content-Type": "application/json",
|
|
763
|
+
"Cache-Control": "no-store",
|
|
764
|
+
});
|
|
765
|
+
res.end(JSON.stringify({ token: localAuthToken }));
|
|
766
|
+
return true;
|
|
767
|
+
}
|
|
768
|
+
|
|
659
769
|
// --- Auth bridge: native OAuth flag (WebView ↔ system browser) ---
|
|
660
770
|
if (p === "/api/auth-bridge/verifier") {
|
|
661
771
|
const method = String(req.method || "GET").toUpperCase();
|
|
662
772
|
if (method === "PUT" || method === "POST") {
|
|
773
|
+
if (!isAuthorizedLocalMutation(req)) {
|
|
774
|
+
json(res, { error: "Unauthorized" }, 401);
|
|
775
|
+
return true;
|
|
776
|
+
}
|
|
663
777
|
const body = await readJsonBody(req);
|
|
664
778
|
_nativeAuthPending = Boolean(body?.native);
|
|
665
779
|
_nativeAuthExpiry = Date.now() + 5 * 60 * 1000; // 5 min TTL
|
|
@@ -679,20 +793,8 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
679
793
|
|
|
680
794
|
// --- auth proxy: forward /api/auth/* to InsForge cloud ---
|
|
681
795
|
if (p.startsWith("/api/auth/")) {
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|| process.env.INSFORGE_BASE_URL
|
|
685
|
-
|| "";
|
|
686
|
-
if (!insforgeBase) {
|
|
687
|
-
try {
|
|
688
|
-
const cfgPath = path.join(os.homedir(), ".tokentracker", "tracker", "config.json");
|
|
689
|
-
const cfg = JSON.parse(fs.readFileSync(cfgPath, "utf8"));
|
|
690
|
-
insforgeBase = cfg?.baseUrl || "";
|
|
691
|
-
} catch { /* ignore */ }
|
|
692
|
-
}
|
|
693
|
-
if (!insforgeBase) {
|
|
694
|
-
insforgeBase = DEFAULT_BASE_URL;
|
|
695
|
-
}
|
|
796
|
+
const runtime = resolveRuntimeConfig();
|
|
797
|
+
const insforgeBase = runtime.baseUrl || DEFAULT_BASE_URL;
|
|
696
798
|
try {
|
|
697
799
|
const targetUrl = `${insforgeBase.replace(/\/$/, "")}${p}${url.search || ""}`;
|
|
698
800
|
const proxyHeaders = {};
|
|
@@ -758,6 +860,10 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
758
860
|
json(res, { ok: false, error: "Method Not Allowed" }, 405);
|
|
759
861
|
return true;
|
|
760
862
|
}
|
|
863
|
+
if (!isAuthorizedLocalMutation(req)) {
|
|
864
|
+
json(res, { ok: false, error: "Unauthorized" }, 401);
|
|
865
|
+
return true;
|
|
866
|
+
}
|
|
761
867
|
try {
|
|
762
868
|
let body = {};
|
|
763
869
|
try {
|
|
@@ -769,8 +875,13 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
769
875
|
if (typeof body.deviceToken === "string" && body.deviceToken.trim()) {
|
|
770
876
|
extraEnv.TOKENTRACKER_DEVICE_TOKEN = body.deviceToken.trim();
|
|
771
877
|
}
|
|
772
|
-
if (
|
|
773
|
-
|
|
878
|
+
if (body.insforgeBaseUrl != null) {
|
|
879
|
+
const allowedBaseUrl = resolveAllowedInsforgeBaseUrl(body.insforgeBaseUrl);
|
|
880
|
+
if (!allowedBaseUrl) {
|
|
881
|
+
json(res, { ok: false, error: "Unsupported insforgeBaseUrl override" }, 400);
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
extraEnv.TOKENTRACKER_INSFORGE_BASE_URL = allowedBaseUrl;
|
|
774
885
|
}
|
|
775
886
|
const result = await runSyncCommand(extraEnv);
|
|
776
887
|
try {
|
|
@@ -949,14 +1060,11 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
949
1060
|
const sources = Array.from(bySource.values()).map((s) => {
|
|
950
1061
|
s.models = Array.from(s.models.values())
|
|
951
1062
|
.map((m) => {
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
(m.totals.cache_creation_input_tokens || 0) * (p.cache_write || 0) +
|
|
958
|
-
(m.totals.reasoning_output_tokens || 0) * (p.output || 0)) /
|
|
959
|
-
1_000_000;
|
|
1063
|
+
const cost = computeRowCost({
|
|
1064
|
+
...m.totals,
|
|
1065
|
+
model: m.model,
|
|
1066
|
+
source: s.source,
|
|
1067
|
+
});
|
|
960
1068
|
return { ...m, totals: { ...m.totals, total_cost_usd: cost.toFixed(6) } };
|
|
961
1069
|
})
|
|
962
1070
|
.sort((a, b) => b.totals.total_tokens - a.totals.total_tokens);
|
|
@@ -1119,6 +1227,7 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
1119
1227
|
|
|
1120
1228
|
module.exports = {
|
|
1121
1229
|
createLocalApiHandler,
|
|
1230
|
+
resolveAllowedInsforgeBaseUrl,
|
|
1122
1231
|
resolveQueuePath,
|
|
1123
1232
|
// Exported for cross-consumer tests (pricing + native contract lock).
|
|
1124
1233
|
MODEL_PRICING,
|
package/src/lib/static-server.js
CHANGED
|
@@ -46,7 +46,6 @@ async function serveStaticFile(baseDir, pathname, res) {
|
|
|
46
46
|
"Content-Type": contentType,
|
|
47
47
|
"Content-Length": stat.size,
|
|
48
48
|
"Cache-Control": isHtml ? "no-cache" : "public, max-age=31536000, immutable",
|
|
49
|
-
"Access-Control-Allow-Origin": "*",
|
|
50
49
|
});
|
|
51
50
|
|
|
52
51
|
const stream = fs.createReadStream(filePath);
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{r as i,ad as G,S as Ge,D as d,az as O,aA as Jn,aB as Qn,ah as Zn,ai as er,aC as tr,h as nr,j as rr,B as A,aD as or,am as ar,ax as Nt,a9 as sr,aE as wt,aF as Kt,aG as Gt,aH as ir}from"./main-CPsqG3PW.js";import{P as lr}from"./ProviderIcon-C2Qp69XI.js";import{L as xn,a as mn,b as dt,l as Et,c as jt,d as cr,e as Vt}from"./leaderboard-columns-CxdAz5_V.js";function dr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return i.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const pt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Fe(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function _t(e){return"nodeType"in e}function V(e){var t,n;return e?Fe(e)?e:_t(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Pt(e){const{Document:t}=V(e);return e instanceof t}function nt(e){return Fe(e)?!1:e instanceof V(e).HTMLElement}function vn(e){return e instanceof V(e).SVGElement}function Ue(e){return e?Fe(e)?e.document:_t(e)?Pt(e)?e:nt(e)||vn(e)?e.ownerDocument:document:document:document}const he=pt?i.useLayoutEffect:i.useEffect;function Bt(e){const t=i.useRef(e);return he(()=>{t.current=e}),i.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 ur(){const e=i.useRef(null),t=i.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=i.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Qe(e,t){t===void 0&&(t=[e]);const n=i.useRef(e);return he(()=>{n.current!==e&&(n.current=e)},t),n}function rt(e,t){const n=i.useRef();return i.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function ut(e){const t=Bt(e),n=i.useRef(null),r=i.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function Mt(e){const t=i.useRef();return i.useEffect(()=>{t.current=e},[e]),t.current}let kt={};function ot(e,t){return i.useMemo(()=>{if(t)return t;const n=kt[e]==null?0:kt[e]+1;return kt[e]=n,e+"-"+n},[e,t])}function yn(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((a,s)=>{const l=Object.entries(s);for(const[c,u]of l){const g=a[c];g!=null&&(a[c]=g+e*u)}return a},{...t})}}const ze=yn(1),Ze=yn(-1);function fr(e){return"clientX"in e&&"clientY"in e}function zt(e){if(!e)return!1;const{KeyboardEvent:t}=V(e.target);return t&&e instanceof t}function gr(e){if(!e)return!1;const{TouchEvent:t}=V(e.target);return t&&e instanceof t}function At(e){if(gr(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 fr(e)?{x:e.clientX,y:e.clientY}:null}const et=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[et.Translate.toString(e),et.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),qt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function hr(e){return e.matches(qt)?e:e.querySelector(qt)}const pr={display:"none"};function br(e){let{id:t,value:n}=e;return G.createElement("div",{id:t,style:pr},n)}function xr(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 G.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function mr(){const[e,t]=i.useState("");return{announce:i.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const wn=i.createContext(null);function vr(e){const t=i.useContext(wn);i.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function yr(){const[e]=i.useState(()=>new Set),t=i.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[i.useCallback(r=>{let{type:o,event:a}=r;e.forEach(s=>{var l;return(l=s[o])==null?void 0:l.call(s,a)})},[e]),t]}const wr={draggable:`
|
|
2
|
-
To pick up a draggable item, press the space bar.
|
|
3
|
-
While dragging, use the arrow keys to move the item.
|
|
4
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
5
|
-
`},kr={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 Sr(e){let{announcements:t=kr,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=wr}=e;const{announce:a,announcement:s}=mr(),l=ot("DndLiveRegion"),[c,u]=i.useState(!1);if(i.useEffect(()=>{u(!0)},[]),vr(i.useMemo(()=>({onDragStart(f){let{active:b}=f;a(t.onDragStart({active:b}))},onDragMove(f){let{active:b,over:h}=f;t.onDragMove&&a(t.onDragMove({active:b,over:h}))},onDragOver(f){let{active:b,over:h}=f;a(t.onDragOver({active:b,over:h}))},onDragEnd(f){let{active:b,over:h}=f;a(t.onDragEnd({active:b,over:h}))},onDragCancel(f){let{active:b,over:h}=f;a(t.onDragCancel({active:b,over:h}))}}),[a,t])),!c)return null;const g=G.createElement(G.Fragment,null,G.createElement(br,{id:r,value:o.draggable}),G.createElement(xr,{id:l,announcement:s}));return n?Ge.createPortal(g,n):g}var P;(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"})(P||(P={}));function ft(){}function Jt(e,t){return i.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Cr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return i.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ue=Object.freeze({x:0,y:0});function kn(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Sn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Rr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Qt(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 Cn(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Zt(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 Dr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Zt(t,t.left,t.top),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=kn(Zt(c),o);a.push({id:l,data:{droppableContainer:s,value:u}})}}return a.sort(Sn)},Nr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Qt(t),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=Qt(c),g=o.reduce((b,h,S)=>b+kn(u[S],h),0),f=Number((g/4).toFixed(4));a.push({id:l,data:{droppableContainer:s,value:f}})}}return a.sort(Sn)};function Er(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),a=Math.min(t.top+t.height,e.top+e.height),s=o-r,l=a-n;if(r<o&&n<a){const c=t.width*t.height,u=e.width*e.height,g=s*l,f=g/(c+u-g);return Number(f.toFixed(4))}return 0}const jr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const a of r){const{id:s}=a,l=n.get(s);if(l){const c=Er(l,t);c>0&&o.push({id:s,data:{droppableContainer:a,value:c}})}}return o.sort(Rr)};function Mr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Rn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ue}function Ar(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return o.reduce((s,l)=>({...s,top:s.top+e*l.y,bottom:s.bottom+e*l.y,left:s.left+e*l.x,right:s.right+e*l.x}),{...n})}}const Ir=Ar(1);function Tr(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 Lr(e,t,n){const r=Tr(t);if(!r)return e;const{scaleX:o,scaleY:a,x:s,y:l}=r,c=e.left-s-(1-o)*parseFloat(n),u=e.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),g=o?e.width/o:e.width,f=a?e.height/a:e.height;return{width:g,height:f,top:u,right:c+g,bottom:u+f,left:c}}const Or={ignoreTransform:!1};function We(e,t){t===void 0&&(t=Or);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:g}=V(e).getComputedStyle(e);u&&(n=Lr(n,u,g))}const{top:r,left:o,width:a,height:s,bottom:l,right:c}=n;return{top:r,left:o,width:a,height:s,bottom:l,right:c}}function en(e){return We(e,{ignoreTransform:!0})}function _r(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Pr(e,t){return t===void 0&&(t=V(e).getComputedStyle(e)),t.position==="fixed"}function Br(e,t){t===void 0&&(t=V(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const a=t[o];return typeof a=="string"?n.test(a):!1})}function bt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Pt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!nt(o)||vn(o)||n.includes(o))return n;const a=V(e).getComputedStyle(o);return o!==e&&Br(o,a)&&n.push(o),Pr(o,a)?n:r(o.parentNode)}return e?r(e):n}function Dn(e){const[t]=bt(e,1);return t??null}function St(e){return!pt||!e?null:Fe(e)?e:_t(e)?Pt(e)||e===Ue(e).scrollingElement?window:nt(e)?e:null:null}function Nn(e){return Fe(e)?e.scrollX:e.scrollLeft}function En(e){return Fe(e)?e.scrollY:e.scrollTop}function It(e){return{x:Nn(e),y:En(e)}}var z;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(z||(z={}));function jn(e){return!pt||!e?!1:e===document.scrollingElement}function Mn(e){const t={x:0,y:0},n=jn(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,a=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:o,isLeft:a,isBottom:s,isRight:l,maxScroll:r,minScroll:t}}const zr={x:.2,y:.2};function $r(e,t,n,r,o){let{top:a,left:s,right:l,bottom:c}=n;r===void 0&&(r=10),o===void 0&&(o=zr);const{isTop:u,isBottom:g,isLeft:f,isRight:b}=Mn(e),h={x:0,y:0},S={x:0,y:0},x={height:t.height*o.y,width:t.width*o.x};return!u&&a<=t.top+x.height?(h.y=z.Backward,S.y=r*Math.abs((t.top+x.height-a)/x.height)):!g&&c>=t.bottom-x.height&&(h.y=z.Forward,S.y=r*Math.abs((t.bottom-x.height-c)/x.height)),!b&&l>=t.right-x.width?(h.x=z.Forward,S.x=r*Math.abs((t.right-x.width-l)/x.width)):!f&&s<=t.left+x.width&&(h.x=z.Backward,S.x=r*Math.abs((t.left+x.width-s)/x.width)),{direction:h,speed:S}}function Fr(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}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 An(e){return e.reduce((t,n)=>ze(t,It(n)),ue)}function Ur(e){return e.reduce((t,n)=>t+Nn(n),0)}function Wr(e){return e.reduce((t,n)=>t+En(n),0)}function Xr(e,t){if(t===void 0&&(t=We),!e)return;const{top:n,left:r,bottom:o,right:a}=t(e);Dn(e)&&(o<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Yr=[["x",["left","right"],Ur],["y",["top","bottom"],Wr]];class $t{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=bt(n),o=An(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,s,l]of Yr)for(const c of s)Object.defineProperty(this,c,{get:()=>{const u=l(r),g=o[a]-u;return this.rect[c]+g},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ve{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 Hr(e){const{EventTarget:t}=V(e);return e instanceof t?e:Ue(e)}function Ct(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 se;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(se||(se={}));function tn(e){e.preventDefault()}function Kr(e){e.stopPropagation()}var N;(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"})(N||(N={}));const In={start:[N.Space,N.Enter],cancel:[N.Esc],end:[N.Space,N.Enter,N.Tab]},Gr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case N.Right:return{...n,x:n.x+25};case N.Left:return{...n,x:n.x-25};case N.Down:return{...n,y:n.y+25};case N.Up:return{...n,y:n.y-25}}};class Ft{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 Ve(Ue(n)),this.windowListeners=new Ve(V(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(se.Resize,this.handleCancel),this.windowListeners.add(se.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(se.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&Xr(r),n(ue)}handleKeyDown(t){if(zt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:a=In,coordinateGetter:s=Gr,scrollBehavior:l="smooth"}=o,{code:c}=t;if(a.end.includes(c)){this.handleEnd(t);return}if(a.cancel.includes(c)){this.handleCancel(t);return}const{collisionRect:u}=r.current,g=u?{x:u.left,y:u.top}:ue;this.referenceCoordinates||(this.referenceCoordinates=g);const f=s(t,{active:n,context:r.current,currentCoordinates:g});if(f){const b=Ze(f,g),h={x:0,y:0},{scrollableAncestors:S}=r.current;for(const x of S){const m=t.code,{isTop:w,isRight:C,isLeft:v,isBottom:R,maxScroll:E,minScroll:j}=Mn(x),k=Fr(x),y={x:Math.min(m===N.Right?k.right-k.width/2:k.right,Math.max(m===N.Right?k.left:k.left+k.width/2,f.x)),y:Math.min(m===N.Down?k.bottom-k.height/2:k.bottom,Math.max(m===N.Down?k.top:k.top+k.height/2,f.y))},T=m===N.Right&&!C||m===N.Left&&!v,L=m===N.Down&&!R||m===N.Up&&!w;if(T&&y.x!==f.x){const D=x.scrollLeft+b.x,Y=m===N.Right&&D<=E.x||m===N.Left&&D>=j.x;if(Y&&!b.y){x.scrollTo({left:D,behavior:l});return}Y?h.x=x.scrollLeft-D:h.x=m===N.Right?x.scrollLeft-E.x:x.scrollLeft-j.x,h.x&&x.scrollBy({left:-h.x,behavior:l});break}else if(L&&y.y!==f.y){const D=x.scrollTop+b.y,Y=m===N.Down&&D<=E.y||m===N.Up&&D>=j.y;if(Y&&!b.x){x.scrollTo({top:D,behavior:l});return}Y?h.y=x.scrollTop-D:h.y=m===N.Down?x.scrollTop-E.y:x.scrollTop-j.y,h.y&&x.scrollBy({top:-h.y,behavior:l});break}}this.handleMove(t,ze(Ze(f,this.referenceCoordinates),h))}}}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()}}Ft.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=In,onActivation:o}=t,{active:a}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const l=a.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function nn(e){return!!(e&&"distance"in e)}function rn(e){return!!(e&&"delay"in e)}class Ut{constructor(t,n,r){var o;r===void 0&&(r=Hr(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:a}=t,{target:s}=a;this.props=t,this.events=n,this.document=Ue(s),this.documentListeners=new Ve(this.document),this.listeners=new Ve(r),this.windowListeners=new Ve(V(s)),this.initialCoordinates=(o=At(a))!=null?o:ue,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(se.Resize,this.handleCancel),this.windowListeners.add(se.DragStart,tn),this.windowListeners.add(se.VisibilityChange,this.handleCancel),this.windowListeners.add(se.ContextMenu,tn),this.documentListeners.add(se.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(rn(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(nn(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(se.Click,Kr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(se.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:a}=this,{onMove:s,options:{activationConstraint:l}}=a;if(!o)return;const c=(n=At(t))!=null?n:ue,u=Ze(o,c);if(!r&&l){if(nn(l)){if(l.tolerance!=null&&Ct(u,l.tolerance))return this.handleCancel();if(Ct(u,l.distance))return this.handleStart()}if(rn(l)&&Ct(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}t.cancelable&&t.preventDefault(),s(c)}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===N.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Vr={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Wt extends Ut{constructor(t){const{event:n}=t,r=Ue(n.target);super(t,Vr,r)}}Wt.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 qr={move:{name:"mousemove"},end:{name:"mouseup"}};var Tt;(function(e){e[e.RightClick=2]="RightClick"})(Tt||(Tt={}));class Jr extends Ut{constructor(t){super(t,qr,Ue(t.event.target))}}Jr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Tt.RightClick?!1:(r?.({event:n}),!0)}}];const Rt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Qr extends Ut{constructor(t){super(t,Rt)}static setup(){return window.addEventListener(Rt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Rt.move.name,t)};function t(){}}}Qr.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 qe;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qe||(qe={}));var gt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(gt||(gt={}));function Zr(e){let{acceleration:t,activator:n=qe.Pointer,canScroll:r,draggingRect:o,enabled:a,interval:s=5,order:l=gt.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:g,delta:f,threshold:b}=e;const h=to({delta:f,disabled:!a}),[S,x]=ur(),m=i.useRef({x:0,y:0}),w=i.useRef({x:0,y:0}),C=i.useMemo(()=>{switch(n){case qe.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case qe.DraggableRect:return o}},[n,o,c]),v=i.useRef(null),R=i.useCallback(()=>{const j=v.current;if(!j)return;const k=m.current.x*w.current.x,y=m.current.y*w.current.y;j.scrollBy(k,y)},[]),E=i.useMemo(()=>l===gt.TreeOrder?[...u].reverse():u,[l,u]);i.useEffect(()=>{if(!a||!u.length||!C){x();return}for(const j of E){if(r?.(j)===!1)continue;const k=u.indexOf(j),y=g[k];if(!y)continue;const{direction:T,speed:L}=$r(j,y,C,t,b);for(const D of["x","y"])h[D][T[D]]||(L[D]=0,T[D]=0);if(L.x>0||L.y>0){x(),v.current=j,S(R,s),m.current=L,w.current=T;return}}m.current={x:0,y:0},w.current={x:0,y:0},x()},[t,R,r,x,a,s,JSON.stringify(C),JSON.stringify(h),S,u,E,g,JSON.stringify(b)])}const eo={x:{[z.Backward]:!1,[z.Forward]:!1},y:{[z.Backward]:!1,[z.Forward]:!1}};function to(e){let{delta:t,disabled:n}=e;const r=Mt(t);return rt(o=>{if(n||!r||!o)return eo;const a={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[z.Backward]:o.x[z.Backward]||a.x===-1,[z.Forward]:o.x[z.Forward]||a.x===1},y:{[z.Backward]:o.y[z.Backward]||a.y===-1,[z.Forward]:o.y[z.Forward]||a.y===1}}},[n,t,r])}function no(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return rt(o=>{var a;return t==null?null:(a=r??o)!=null?a:null},[r,t])}function ro(e,t){return i.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,a=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...a]},[]),[e,t])}var tt;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(tt||(tt={}));var Lt;(function(e){e.Optimized="optimized"})(Lt||(Lt={}));const on=new Map;function oo(e,t){let{dragging:n,dependencies:r,config:o}=t;const[a,s]=i.useState(null),{frequency:l,measure:c,strategy:u}=o,g=i.useRef(e),f=m(),b=Qe(f),h=i.useCallback(function(w){w===void 0&&(w=[]),!b.current&&s(C=>C===null?w:C.concat(w.filter(v=>!C.includes(v))))},[b]),S=i.useRef(null),x=rt(w=>{if(f&&!n)return on;if(!w||w===on||g.current!==e||a!=null){const C=new Map;for(let v of e){if(!v)continue;if(a&&a.length>0&&!a.includes(v.id)&&v.rect.current){C.set(v.id,v.rect.current);continue}const R=v.node.current,E=R?new $t(c(R),R):null;v.rect.current=E,E&&C.set(v.id,E)}return C}return w},[e,a,n,f,c]);return i.useEffect(()=>{g.current=e},[e]),i.useEffect(()=>{f||h()},[n,f]),i.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),i.useEffect(()=>{f||typeof l!="number"||S.current!==null||(S.current=setTimeout(()=>{h(),S.current=null},l))},[l,f,h,...r]),{droppableRects:x,measureDroppableContainers:h,measuringScheduled:a!=null};function m(){switch(u){case tt.Always:return!1;case tt.BeforeDragging:return n;default:return!n}}}function Tn(e,t){return rt(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function ao(e,t){return Tn(e,t)}function so(e){let{callback:t,disabled:n}=e;const r=Bt(t),o=i.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return i.useEffect(()=>()=>o?.disconnect(),[o]),o}function xt(e){let{callback:t,disabled:n}=e;const r=Bt(t),o=i.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return i.useEffect(()=>()=>o?.disconnect(),[o]),o}function io(e){return new $t(We(e),e)}function an(e,t,n){t===void 0&&(t=io);const[r,o]=i.useState(null);function a(){o(c=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=c??n)!=null?u:null}const g=t(e);return JSON.stringify(c)===JSON.stringify(g)?c:g})}const s=so({callback(c){if(e)for(const u of c){const{type:g,target:f}=u;if(g==="childList"&&f instanceof HTMLElement&&f.contains(e)){a();break}}}}),l=xt({callback:a});return he(()=>{a(),e?(l?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),s?.disconnect())},[e]),r}function lo(e){const t=Tn(e);return Rn(e,t)}const sn=[];function co(e){const t=i.useRef(e),n=rt(r=>e?r&&r!==sn&&e&&t.current&&e.parentNode===t.current.parentNode?r:bt(e):sn,[e]);return i.useEffect(()=>{t.current=e},[e]),n}function uo(e){const[t,n]=i.useState(null),r=i.useRef(e),o=i.useCallback(a=>{const s=St(a.target);s&&n(l=>l?(l.set(s,It(s)),new Map(l)):null)},[]);return i.useEffect(()=>{const a=r.current;if(e!==a){s(a);const l=e.map(c=>{const u=St(c);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,It(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=e}return()=>{s(e),s(a)};function s(l){l.forEach(c=>{const u=St(c);u?.removeEventListener("scroll",o)})}},[o,e]),i.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,s)=>ze(a,s),ue):An(e):ue,[e,t])}function ln(e,t){t===void 0&&(t=[]);const n=i.useRef(null);return i.useEffect(()=>{n.current=null},t),i.useEffect(()=>{const r=e!==ue;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Ze(e,n.current):ue}function fo(e){i.useEffect(()=>{if(!pt)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 go(e,t){return i.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:a}=r;return n[o]=s=>{a(s,t)},n},{}),[e,t])}function Ln(e){return i.useMemo(()=>e?_r(e):null,[e])}const cn=[];function ho(e,t){t===void 0&&(t=We);const[n]=e,r=Ln(n?V(n):null),[o,a]=i.useState(cn);function s(){a(()=>e.length?e.map(c=>jn(c)?r:new $t(t(c),c)):cn)}const l=xt({callback:s});return he(()=>{l?.disconnect(),s(),e.forEach(c=>l?.observe(c))},[e]),o}function po(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return nt(t)?t:e}function bo(e){let{measure:t}=e;const[n,r]=i.useState(null),o=i.useCallback(u=>{for(const{target:g}of u)if(nt(g)){r(f=>{const b=t(g);return f?{...f,width:b.width,height:b.height}:b});break}},[t]),a=xt({callback:o}),s=i.useCallback(u=>{const g=po(u);a?.disconnect(),g&&a?.observe(g),r(g?t(g):null)},[t,a]),[l,c]=ut(s);return i.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const xo=[{sensor:Wt,options:{}},{sensor:Ft,options:{}}],mo={current:{}},ct={draggable:{measure:en},droppable:{measure:en,strategy:tt.WhileDragging,frequency:Lt.Optimized},dragOverlay:{measure:We}};class Je 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 vo={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Je,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ft},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ct,measureDroppableContainers:ft,windowRect:null,measuringScheduled:!1},yo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ft,draggableNodes:new Map,over:null,measureDroppableContainers:ft},mt=i.createContext(yo),On=i.createContext(vo);function wo(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Je}}}function ko(e,t){switch(t.type){case P.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case P.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 P.DragEnd:case P.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case P.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Je(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case P.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;const s=new Je(e.droppable.containers);return s.set(n,{...a,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case P.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const a=new Je(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function So(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=i.useContext(mt),a=Mt(r),s=Mt(n?.id);return i.useEffect(()=>{if(!t&&!r&&a&&s!=null){if(!zt(a)||document.activeElement===a.target)return;const l=o.get(s);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const g of[c.current,u.current]){if(!g)continue;const f=hr(g);if(f){f.focus();break}}})}},[r,t,o,s,a]),null}function Co(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,a)=>a({transform:o,...r}),n):n}function Ro(e){return i.useMemo(()=>({draggable:{...ct.draggable,...e?.draggable},droppable:{...ct.droppable,...e?.droppable},dragOverlay:{...ct.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Do(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const a=i.useRef(!1),{x:s,y:l}=typeof o=="boolean"?{x:o,y:o}:o;he(()=>{if(!s&&!l||!t){a.current=!1;return}if(a.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const g=n(u),f=Rn(g,r);if(s||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const b=Dn(u);b&&b.scrollBy({top:f.y,left:f.x})}},[t,s,l,r,n])}const _n=i.createContext({...ue,scaleX:1,scaleY:1});var Ne;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ne||(Ne={}));const No=i.memo(function(t){var n,r,o,a;let{id:s,accessibility:l,autoScroll:c=!0,children:u,sensors:g=xo,collisionDetection:f=jr,measuring:b,modifiers:h,...S}=t;const x=i.useReducer(ko,void 0,wo),[m,w]=x,[C,v]=yr(),[R,E]=i.useState(Ne.Uninitialized),j=R===Ne.Initialized,{draggable:{active:k,nodes:y,translate:T},droppable:{containers:L}}=m,D=k!=null?y.get(k):null,Y=i.useRef({initial:null,translated:null}),H=i.useMemo(()=>{var X;return k!=null?{id:k,data:(X=D?.data)!=null?X:mo,rect:Y}:null},[k,D]),ee=i.useRef(null),[ke,Ee]=i.useState(null),[$,je]=i.useState(null),B=Qe(S,Object.values(S)),Me=ot("DndDescribedBy",s),Le=i.useMemo(()=>L.getEnabled(),[L]),F=Ro(b),{droppableRects:_,measureDroppableContainers:te,measuringScheduled:q}=oo(Le,{dragging:j,dependencies:[T.x,T.y],config:F.droppable}),K=no(y,k),Ae=i.useMemo(()=>$?At($):null,[$]),ie=qn(),ne=ao(K,F.draggable.measure);Do({activeNode:k!=null?y.get(k):null,config:ie.layoutShiftCompensation,initialRect:ne,measure:F.draggable.measure});const M=an(K,F.draggable.measure,ne),pe=an(K?K.parentElement:null),re=i.useRef({activatorEvent:null,active:null,activeNode:K,collisionRect:null,collisions:null,droppableRects:_,draggableNodes:y,draggingNode:null,draggingNodeRect:null,droppableContainers:L,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),be=L.getNodeFor((n=re.current.over)==null?void 0:n.id),oe=bo({measure:F.dragOverlay.measure}),xe=(r=oe.nodeRef.current)!=null?r:K,me=j?(o=oe.rect)!=null?o:M:null,Oe=!!(oe.nodeRef.current&&oe.rect),at=lo(Oe?null:M),Xe=Ln(xe?V(xe):null),le=co(j?be??K:null),Ie=ho(le),_e=Co(h,{transform:{x:T.x-at.x,y:T.y-at.y,scaleX:1,scaleY:1},activatorEvent:$,active:H,activeNodeRect:M,containerNodeRect:pe,draggingNodeRect:me,over:re.current.over,overlayNodeRect:oe.rect,scrollableAncestors:le,scrollableAncestorRects:Ie,windowRect:Xe}),Se=Ae?ze(Ae,T):null,Pe=uo(le),p=ln(Pe),I=ln(Pe,[M]),W=ze(_e,p),ve=me?Ir(me,_e):null,Te=H&&ve?f({active:H,collisionRect:ve,droppableRects:_,droppableContainers:Le,pointerCoordinates:Se}):null,ce=Cn(Te,"id"),[ye,Xt]=i.useState(null),Yn=Oe?_e:ze(_e,I),Hn=Mr(Yn,(a=ye?.rect)!=null?a:null,M),vt=i.useRef(null),Yt=i.useCallback((X,J)=>{let{sensor:Q,options:Ce}=J;if(ee.current==null)return;const ae=y.get(ee.current);if(!ae)return;const Z=X.nativeEvent,fe=new Q({active:ee.current,activeNode:ae,event:Z,options:Ce,context:re,onAbort(U){if(!y.get(U))return;const{onDragAbort:ge}=B.current,we={id:U};ge?.(we),C({type:"onDragAbort",event:we})},onPending(U,Re,ge,we){if(!y.get(U))return;const{onDragPending:He}=B.current,De={id:U,constraint:Re,initialCoordinates:ge,offset:we};He?.(De),C({type:"onDragPending",event:De})},onStart(U){const Re=ee.current;if(Re==null)return;const ge=y.get(Re);if(!ge)return;const{onDragStart:we}=B.current,Ye={activatorEvent:Z,active:{id:Re,data:ge.data,rect:Y}};Ge.unstable_batchedUpdates(()=>{we?.(Ye),E(Ne.Initializing),w({type:P.DragStart,initialCoordinates:U,active:Re}),C({type:"onDragStart",event:Ye}),Ee(vt.current),je(Z)})},onMove(U){w({type:P.DragMove,coordinates:U})},onEnd:Be(P.DragEnd),onCancel:Be(P.DragCancel)});vt.current=fe;function Be(U){return async function(){const{active:ge,collisions:we,over:Ye,scrollAdjustedTranslate:He}=re.current;let De=null;if(ge&&He){const{cancelDrop:Ke}=B.current;De={activatorEvent:Z,active:ge,collisions:we,delta:He,over:Ye},U===P.DragEnd&&typeof Ke=="function"&&await Promise.resolve(Ke(De))&&(U=P.DragCancel)}ee.current=null,Ge.unstable_batchedUpdates(()=>{w({type:U}),E(Ne.Uninitialized),Xt(null),Ee(null),je(null),vt.current=null;const Ke=U===P.DragEnd?"onDragEnd":"onDragCancel";if(De){const yt=B.current[Ke];yt?.(De),C({type:Ke,event:De})}})}}},[y]),Kn=i.useCallback((X,J)=>(Q,Ce)=>{const ae=Q.nativeEvent,Z=y.get(Ce);if(ee.current!==null||!Z||ae.dndKit||ae.defaultPrevented)return;const fe={active:Z};X(Q,J.options,fe)===!0&&(ae.dndKit={capturedBy:J.sensor},ee.current=Ce,Yt(Q,J))},[y,Yt]),Ht=ro(g,Kn);fo(g),he(()=>{M&&R===Ne.Initializing&&E(Ne.Initialized)},[M,R]),i.useEffect(()=>{const{onDragMove:X}=B.current,{active:J,activatorEvent:Q,collisions:Ce,over:ae}=re.current;if(!J||!Q)return;const Z={active:J,activatorEvent:Q,collisions:Ce,delta:{x:W.x,y:W.y},over:ae};Ge.unstable_batchedUpdates(()=>{X?.(Z),C({type:"onDragMove",event:Z})})},[W.x,W.y]),i.useEffect(()=>{const{active:X,activatorEvent:J,collisions:Q,droppableContainers:Ce,scrollAdjustedTranslate:ae}=re.current;if(!X||ee.current==null||!J||!ae)return;const{onDragOver:Z}=B.current,fe=Ce.get(ce),Be=fe&&fe.rect.current?{id:fe.id,rect:fe.rect.current,data:fe.data,disabled:fe.disabled}:null,U={active:X,activatorEvent:J,collisions:Q,delta:{x:ae.x,y:ae.y},over:Be};Ge.unstable_batchedUpdates(()=>{Xt(Be),Z?.(U),C({type:"onDragOver",event:U})})},[ce]),he(()=>{re.current={activatorEvent:$,active:H,activeNode:K,collisionRect:ve,collisions:Te,droppableRects:_,draggableNodes:y,draggingNode:xe,draggingNodeRect:me,droppableContainers:L,over:ye,scrollableAncestors:le,scrollAdjustedTranslate:W},Y.current={initial:me,translated:ve}},[H,K,Te,ve,y,xe,me,_,L,ye,le,W]),Zr({...ie,delta:T,draggingRect:ve,pointerCoordinates:Se,scrollableAncestors:le,scrollableAncestorRects:Ie});const Gn=i.useMemo(()=>({active:H,activeNode:K,activeNodeRect:M,activatorEvent:$,collisions:Te,containerNodeRect:pe,dragOverlay:oe,draggableNodes:y,droppableContainers:L,droppableRects:_,over:ye,measureDroppableContainers:te,scrollableAncestors:le,scrollableAncestorRects:Ie,measuringConfiguration:F,measuringScheduled:q,windowRect:Xe}),[H,K,M,$,Te,pe,oe,y,L,_,ye,te,le,Ie,F,q,Xe]),Vn=i.useMemo(()=>({activatorEvent:$,activators:Ht,active:H,activeNodeRect:M,ariaDescribedById:{draggable:Me},dispatch:w,draggableNodes:y,over:ye,measureDroppableContainers:te}),[$,Ht,H,M,w,Me,y,ye,te]);return G.createElement(wn.Provider,{value:v},G.createElement(mt.Provider,{value:Vn},G.createElement(On.Provider,{value:Gn},G.createElement(_n.Provider,{value:Hn},u)),G.createElement(So,{disabled:l?.restoreFocus===!1})),G.createElement(Sr,{...l,hiddenTextDescribedById:Me}));function qn(){const X=ke?.autoScrollEnabled===!1,J=typeof c=="object"?c.enabled===!1:c===!1,Q=j&&!X&&!J;return typeof c=="object"?{...c,enabled:Q}:{enabled:Q}}}),Eo=i.createContext(null),dn="button",jo="Draggable";function Mo(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const a=ot(jo),{activators:s,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:g,draggableNodes:f,over:b}=i.useContext(mt),{role:h=dn,roleDescription:S="draggable",tabIndex:x=0}=o??{},m=c?.id===t,w=i.useContext(m?_n:Eo),[C,v]=ut(),[R,E]=ut(),j=go(s,t),k=Qe(n);he(()=>(f.set(t,{id:t,key:a,node:C,activatorNode:R,data:k}),()=>{const T=f.get(t);T&&T.key===a&&f.delete(t)}),[f,t]);const y=i.useMemo(()=>({role:h,tabIndex:x,"aria-disabled":r,"aria-pressed":m&&h===dn?!0:void 0,"aria-roledescription":S,"aria-describedby":g.draggable}),[r,h,x,m,S,g.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:y,isDragging:m,listeners:r?void 0:j,node:C,over:b,setNodeRef:v,setActivatorNodeRef:E,transform:w}}function Ao(){return i.useContext(On)}const Io="Droppable",To={timeout:25};function Lo(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const a=ot(Io),{active:s,dispatch:l,over:c,measureDroppableContainers:u}=i.useContext(mt),g=i.useRef({disabled:n}),f=i.useRef(!1),b=i.useRef(null),h=i.useRef(null),{disabled:S,updateMeasurementsFor:x,timeout:m}={...To,...o},w=Qe(x??r),C=i.useCallback(()=>{if(!f.current){f.current=!0;return}h.current!=null&&clearTimeout(h.current),h.current=setTimeout(()=>{u(Array.isArray(w.current)?w.current:[w.current]),h.current=null},m)},[m]),v=xt({callback:C,disabled:S||!s}),R=i.useCallback((y,T)=>{v&&(T&&(v.unobserve(T),f.current=!1),y&&v.observe(y))},[v]),[E,j]=ut(R),k=Qe(t);return i.useEffect(()=>{!v||!E.current||(v.disconnect(),f.current=!1,v.observe(E.current))},[E,v]),i.useEffect(()=>(l({type:P.RegisterDroppable,element:{id:r,key:a,disabled:n,node:E,rect:b,data:k}}),()=>l({type:P.UnregisterDroppable,key:a,id:r})),[r]),i.useEffect(()=>{n!==g.current.disabled&&(l({type:P.SetDroppableDisabled,id:r,key:a,disabled:n}),g.current.disabled=n)},[r,a,n,l]),{active:s,rect:b,isOver:c?.id===r,node:E,over:c,setNodeRef:j}}const Oo=e=>{let{transform:t}=e;return{...t,y:0}};function Pn(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function _o(e,t){return e.reduce((n,r,o)=>{const a=t.get(r);return a&&(n[o]=a),n},Array(e.length))}function st(e){return e!==null&&e>=0}function Po(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 Bo(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const it={scaleX:1,scaleY:1},zo=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:a,index:s}=e;const l=(t=n[o])!=null?t:r;if(!l)return null;const c=$o(n,s,o);if(s===o){const u=n[a];return u?{x:o<a?u.left+u.width-(l.left+l.width):u.left-l.left,y:0,...it}:null}return s>o&&s<=a?{x:-l.width-c,y:0,...it}:s<o&&s>=a?{x:l.width+c,y:0,...it}:{x:0,y:0,...it}};function $o(e,t,n){const r=e[t],o=e[t-1],a=e[t+1];return!r||!o&&!a?0:n<t?o?r.left-(o.left+o.width):a.left-(r.left+r.width):a?a.left-(r.left+r.width):r.left-(o.left+o.width)}const Bn=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const a=Pn(t,r,n),s=t[o],l=a[o];return!l||!s?null:{x:l.left-s.left,y:l.top-s.top,scaleX:l.width/s.width,scaleY:l.height/s.height}},zn="Sortable",$n=G.createContext({activeIndex:-1,containerId:zn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Bn,disabled:{draggable:!1,droppable:!1}});function Fo(e){let{children:t,id:n,items:r,strategy:o=Bn,disabled:a=!1}=e;const{active:s,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:g}=Ao(),f=ot(zn,n),b=l.rect!==null,h=i.useMemo(()=>r.map(j=>typeof j=="object"&&"id"in j?j.id:j),[r]),S=s!=null,x=s?h.indexOf(s.id):-1,m=u?h.indexOf(u.id):-1,w=i.useRef(h),C=!Po(h,w.current),v=m!==-1&&x===-1||C,R=Bo(a);he(()=>{C&&S&&g(h)},[C,h,S,g]),i.useEffect(()=>{w.current=h},[h]);const E=i.useMemo(()=>({activeIndex:x,containerId:f,disabled:R,disableTransforms:v,items:h,overIndex:m,useDragOverlay:b,sortedRects:_o(h,c),strategy:o}),[x,f,R.draggable,R.droppable,v,h,m,c,b,o]);return G.createElement($n.Provider,{value:E},t)}const Uo=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Pn(n,r,o).indexOf(t)},Wo=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:a,newIndex:s,previousItems:l,previousContainerId:c,transition:u}=e;return!u||!r||l!==a&&o===s?!1:n?!0:s!==o&&t===c},Xo={duration:200,easing:"ease"},Fn="transform",Yo=et.Transition.toString({property:Fn,duration:0,easing:"linear"}),Ho={roleDescription:"sortable"};function Ko(e){let{disabled:t,index:n,node:r,rect:o}=e;const[a,s]=i.useState(null),l=i.useRef(n);return he(()=>{if(!t&&n!==l.current&&r.current){const c=o.current;if(c){const u=We(r.current,{ignoreTransform:!0}),g={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(g.x||g.y)&&s(g)}}n!==l.current&&(l.current=n)},[t,n,r,o]),i.useEffect(()=>{a&&s(null)},[a]),a}function Go(e){let{animateLayoutChanges:t=Wo,attributes:n,disabled:r,data:o,getNewIndex:a=Uo,id:s,strategy:l,resizeObserverConfig:c,transition:u=Xo}=e;const{items:g,containerId:f,activeIndex:b,disabled:h,disableTransforms:S,sortedRects:x,overIndex:m,useDragOverlay:w,strategy:C}=i.useContext($n),v=Vo(r,h),R=g.indexOf(s),E=i.useMemo(()=>({sortable:{containerId:f,index:R,items:g},...o}),[f,o,R,g]),j=i.useMemo(()=>g.slice(g.indexOf(s)),[g,s]),{rect:k,node:y,isOver:T,setNodeRef:L}=Lo({id:s,data:E,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:j,...c}}),{active:D,activatorEvent:Y,activeNodeRect:H,attributes:ee,setNodeRef:ke,listeners:Ee,isDragging:$,over:je,setActivatorNodeRef:B,transform:Me}=Mo({id:s,data:E,attributes:{...Ho,...n},disabled:v.draggable}),Le=dr(L,ke),F=!!D,_=F&&!S&&st(b)&&st(m),te=!w&&$,q=te&&_?Me:null,Ae=_?q??(l??C)({rects:x,activeNodeRect:H,activeIndex:b,overIndex:m,index:R}):null,ie=st(b)&&st(m)?a({id:s,items:g,activeIndex:b,overIndex:m}):R,ne=D?.id,M=i.useRef({activeId:ne,items:g,newIndex:ie,containerId:f}),pe=g!==M.current.items,re=t({active:D,containerId:f,isDragging:$,isSorting:F,id:s,index:R,items:g,newIndex:M.current.newIndex,previousItems:M.current.items,previousContainerId:M.current.containerId,transition:u,wasDragging:M.current.activeId!=null}),be=Ko({disabled:!re,index:R,node:y,rect:k});return i.useEffect(()=>{F&&M.current.newIndex!==ie&&(M.current.newIndex=ie),f!==M.current.containerId&&(M.current.containerId=f),g!==M.current.items&&(M.current.items=g)},[F,ie,f,g]),i.useEffect(()=>{if(ne===M.current.activeId)return;if(ne&&!M.current.activeId){M.current.activeId=ne;return}const xe=setTimeout(()=>{M.current.activeId=ne},50);return()=>clearTimeout(xe)},[ne]),{active:D,activeIndex:b,attributes:ee,data:E,rect:k,index:R,newIndex:ie,items:g,isOver:T,isSorting:F,isDragging:$,listeners:Ee,node:y,overIndex:m,over:je,setNodeRef:Le,setActivatorNodeRef:B,setDroppableNodeRef:L,setDraggableNodeRef:ke,transform:be??Ae,transition:oe()};function oe(){if(be||pe&&M.current.newIndex===R)return Yo;if(!(te&&!zt(Y)||!u)&&(F||re))return et.Transition.toString({...u,property:Fn})}}function Vo(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 ht(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 qo=[N.Down,N.Right,N.Up,N.Left],Jo=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:a,over:s,scrollableAncestors:l}}=t;if(qo.includes(e.code)){if(e.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const b=o.get(f.id);if(b)switch(e.code){case N.Down:r.top<b.top&&c.push(f);break;case N.Up:r.top>b.top&&c.push(f);break;case N.Left:r.left>b.left&&c.push(f);break;case N.Right:r.left<b.left&&c.push(f);break}});const u=Nr({collisionRect:r,droppableRects:o,droppableContainers:c});let g=Cn(u,"id");if(g===s?.id&&u.length>1&&(g=u[1].id),g!=null){const f=a.get(n.id),b=a.get(g),h=b?o.get(b.id):null,S=b?.node.current;if(S&&h&&f&&b){const m=bt(S).some((j,k)=>l[k]!==j),w=Un(f,b),C=Qo(f,b),v=m||!w?{x:0,y:0}:{x:C?r.width-h.width:0,y:C?r.height-h.height:0},R={x:h.left,y:h.top};return v.x&&v.y?R:Ze(R,v)}}}};function Un(e,t){return!ht(e)||!ht(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Qo(e,t){return!ht(e)||!ht(t)||!Un(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function $e(e,{min:t,max:n,fallback:r}){const o=Number(e);if(!Number.isFinite(o))return r;const a=Math.floor(o);return a<t?t:a>n?n:a}function Zo(e,t){const n=$e(t,{min:0,max:1e6,fallback:0}),r=$e(e,{min:1,max:Math.max(1,n||1),fallback:1});if(n<=1)return[1];const o=new Set([1,n,r-2,r-1,r,r+1,r+2]),a=Array.from(o).filter(c=>Number.isInteger(c)&&c>=1&&c<=n).sort((c,u)=>c-u),s=[];let l=null;for(const c of a)l!=null&&c-l>1&&s.push(null),s.push(c),l=c;return s}function ea({page:e,totalPages:t}){const n=typeof t=="number"&&Number.isFinite(t)&&t>=0,r=n?$e(t,{min:0,max:1e6,fallback:0}):null,o=$e(e,{min:1,max:n?Math.max(1,r||1):1e6,fallback:1}),a=o>1,s=n?o<r:!0;return{canPrev:a,canNext:s,safePage:o,safeTotal:r}}function ta({entries:e,me:t,meLabel:n,limit:r}){const o=$e(r,{min:1,max:1e3,fallback:20}),a=Array.isArray(e)?e.slice(0,o):[],s=t&&typeof t.rank=="number"?t.rank:null,l=a.some(h=>!!h?.is_me);if(!s||l)return a;const c={rank:s,is_me:!0,display_name:n,avatar_url:null,gpt_tokens:t?.gpt_tokens??"0",claude_tokens:t?.claude_tokens??"0",gemini_tokens:t?.gemini_tokens??"0",cursor_tokens:t?.cursor_tokens??"0",opencode_tokens:t?.opencode_tokens??"0",openclaw_tokens:t?.openclaw_tokens??"0",hermes_tokens:t?.hermes_tokens??"0",kiro_tokens:t?.kiro_tokens??"0",copilot_tokens:t?.copilot_tokens??"0",kimi_tokens:t?.kimi_tokens??"0",other_tokens:t?.other_tokens??"0",total_tokens:t?.total_tokens??"0"},u=3,g=4,b=a.filter(h=>!h?.is_me).filter((h,S)=>S!==u).slice();return b.splice(Math.min(g,b.length),0,c),b.slice(0,o)}function de({className:e}){return d.jsx("div",{className:O("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",e)})}function na({index:e}){const t=e<3?"w-24":e<8?"w-20":"w-16",n=e<3?"w-16":"w-12",r=e<5?"w-14":"w-10";return d.jsxs("tr",{className:"group",children:[d.jsx("td",{className:O(Et(!1),"!group-hover:bg-transparent"),children:d.jsx(de,{className:"h-4 w-6"})}),d.jsx("td",{className:O(jt(!1),"!group-hover:bg-transparent"),children:d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx(de,{className:"h-8 w-8 min-w-8 rounded-full"}),d.jsx(de,{className:O("h-4",t)})]})}),d.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:d.jsx(de,{className:O("h-4",n)})}),d.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:d.jsx(de,{className:"h-4 w-12"})}),dt.map(o=>d.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:d.jsx(de,{className:O("h-4",r)})},o.key))]})}function ra({rows:e=10}){return d.jsx("div",{className:"w-full overflow-x-auto",children:d.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[d.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:d.jsxs("tr",{children:[d.jsx("th",{className:O(xn,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:d.jsx(de,{className:"h-3.5 w-6"})}),d.jsx("th",{className:O(mn,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:d.jsx(de,{className:"h-3.5 w-12"})}),d.jsx("th",{className:"px-4 py-4",children:d.jsx(de,{className:"h-3.5 w-10"})}),d.jsx("th",{className:"px-4 py-4",children:d.jsx(de,{className:"h-3.5 w-14"})}),dt.map(t=>d.jsx("th",{className:"px-4 py-4",children:d.jsx(de,{className:"h-3.5 w-12"})},t.key))]})}),d.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:e},(t,n)=>d.jsx(na,{index:n},n))})]})})}function oa({id:e,thClassName:t,children:n}){const{attributes:r,listeners:o,setNodeRef:a,transform:s,transition:l,isDragging:c}=Go({id:e}),u=et.Transform.toString(s)||"";i.useLayoutEffect(()=>{const f=document.querySelectorAll(`td[data-column-key="${e}"]`),b="0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)";return f.forEach(h=>{h.style.transform=u,h.style.transition=l||"",h.style.zIndex=c?"20":"",h.style.position=u?"relative":"",h.style.boxShadow=c?b:""}),()=>{f.forEach(h=>{h.style.transform="",h.style.transition="",h.style.zIndex="",h.style.position="",h.style.boxShadow=""})}},[e,u,l,c]);const g={transform:u,transition:l,position:u?"relative":void 0,zIndex:c?20:void 0,boxShadow:c?"0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)":void 0};return d.jsx("th",{ref:a,style:g,className:O(t,"group/col select-none cursor-grab active:cursor-grabbing touch-none"),...r,...o,children:d.jsxs("div",{className:"flex items-center justify-end gap-2",children:[d.jsx("span",{"aria-hidden":"true",className:O("-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",c&&"opacity-100"),children:d.jsxs("svg",{viewBox:"0 0 8 14",width:"8",height:"14",fill:"currentColor","aria-hidden":"true",children:[d.jsx("circle",{cx:"2",cy:"2",r:"1"}),d.jsx("circle",{cx:"6",cy:"2",r:"1"}),d.jsx("circle",{cx:"2",cy:"7",r:"1"}),d.jsx("circle",{cx:"6",cy:"7",r:"1"}),d.jsx("circle",{cx:"2",cy:"12",r:"1"}),d.jsx("circle",{cx:"6",cy:"12",r:"1"})]})}),n]})})}const Wn="tokentracker.leaderboard.columnOrder.v1";function aa(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Wn);if(!e)return null;const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):null}catch{return null}}function Dt(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Wn,JSON.stringify(e))}catch{}}function un(e,t){if(!e)return t;const n=new Set(t),r=e.filter(a=>n.has(a)),o=t.filter(a=>!r.includes(a));return[...r,...o]}function sa(e){const t=i.useMemo(()=>e.join("|"),[e]),[n,r]=i.useState(()=>un(aa(),e));i.useEffect(()=>{r(s=>{const l=un(s,e);return l.length===s.length&&l.every((u,g)=>u===s[g])?s:(Dt(l),l)})},[t,e]);const o=i.useCallback((s,l)=>{!s||!l||s===l||r(c=>{const u=c.indexOf(s),g=c.indexOf(l);if(u===-1||g===-1)return c;const f=c.slice(),[b]=f.splice(u,1);return f.splice(g,0,b),Dt(f),f})},[]),a=i.useCallback(()=>{Dt(e),r(e)},[e]);return{order:n,reorder:o,reset:a}}const lt=20;function fn(e){const t=Number(e);return!Number.isFinite(t)||t<=0?"-":t>=1e3?`$${Math.round(t).toLocaleString()}`:t>=10?`$${Math.round(t)}`:`$${t.toFixed(2)}`}function gn(e,t,n){const r=t?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",o=t?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60";return n.map(a=>d.jsx("td",{"data-column-key":a.key,className:O("px-4 py-4 whitespace-nowrap text-right tabular-nums",r,o),children:Nt(e?.[a.key])},a.key))}const ia={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 hn({rank:e,placeholder:t}){const n=ia[e];return n?d.jsx("span",{className:O("inline-flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold",n.text,n.badge),children:e}):d.jsx("span",{className:"inline-flex items-center justify-center h-7 w-7 text-sm",children:e??t})}function Ot(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="week"||t==="month"||t==="total"?t:null}function la(e){if(!e)return A("shared.error.prefix",{error:A("leaderboard.error.unknown")});const t=e?.message||String(e),n=String(t||"").trim()||A("leaderboard.error.unknown");return A("shared.error.prefix",{error:n})}function Xn(e){return typeof e!="string"?"":e.trim()}function ca(e){const t=Xn(e);return t?t.toLowerCase()==="anonymous":!0}function da(e,t=""){if(typeof e!="string")return null;const n=e.trim().toLowerCase();if(!n)return null;const r=new URLSearchParams(typeof t=="string"?t:""),o=Ot(r.get("period")),a=o?`?period=${o}`:"";return`/share/pv1-${n}${a}`}function pn(e,t){const n=typeof e?.user_id=="string"?e.user_id.trim():"";return n||`${e?.rank??""}:${t}`}function bn({githubUrl:e}){return d.jsxs("span",{className:"relative inline-flex items-center group/gh shrink-0",children:[d.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",onClick:t=>t.stopPropagation(),"aria-label":A("leaderboard.github.aria"),className:"text-oai-black hover:text-oai-gray-500 dark:text-white dark:hover:text-oai-gray-400 transition-colors",children:d.jsx(lr,{provider:"GITHUB",size:16})}),d.jsxs("span",{role:"tooltip",className:"invisible opacity-0 group-hover/gh:visible group-hover/gh:opacity-100 absolute right-0 bottom-full mb-2 whitespace-nowrap rounded-md bg-oai-black dark:bg-oai-gray-700 px-2.5 py-1.5 text-[11px] 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:[A("leaderboard.github.tooltipPrefix")," ",d.jsx(sr,{to:"/settings",onClick:t=>t.stopPropagation(),className:"underline underline-offset-2 decoration-oai-gray-400 hover:text-oai-brand-300 hover:decoration-oai-brand-300",children:A("leaderboard.github.tooltipSettingsLink")})]})]})}function ha({auth:e,signedIn:t,sessionSoftExpired:n}){const r=Jn(),o=Qn(),{openLoginModal:a}=Zn(),{signedIn:s,loading:l,user:c}=er(),u=i.useMemo(()=>tr(),[]),g=nr(),f=t&&!n,b=i.useMemo(()=>f&&(typeof e=="function"||typeof e=="string"||e&&typeof e=="object")?e:null,[e,f]),h=f?b:null,S=f&&rr(h),x=A("shared.placeholder.short"),m=i.useMemo(()=>dt.map(p=>p.key),[]),{order:w,reorder:C}=sa(m),v=i.useMemo(()=>{const p=new Map;for(const I of dt)p.set(I.key,I);return p},[]),R=i.useMemo(()=>w.map(p=>v.get(p)).filter(Boolean),[w,v]),E=Cr(Jt(Wt,{activationConstraint:{distance:6}}),Jt(Ft,{coordinateGetter:Jo})),j=i.useCallback(p=>{const{active:I,over:W}=p;!W||I.id===W.id||C(String(I.id),String(W.id))},[C]),[k,y]=i.useState(1),[T,L]=i.useState(0),[D,Y]=i.useState(()=>({loading:!1,error:null,data:null})),[H,ee]=i.useState(()=>or()),[ke,Ee]=i.useState(!1),[$,je]=i.useState(!1),B=i.useMemo(()=>{const p=new URLSearchParams(r?.search||"");return Ot(p.get("period"))||"total"},[r?.search]),Me=r?.search||"",Le=p=>{const I=Ot(p);if(!I||I===B)return;const W=new URLSearchParams(r?.search||"");W.set("period",I),y(1),o(`${r?.pathname||"/leaderboard"}?${W.toString()}`,{replace:!0})};i.useEffect(()=>{l||g||s||a()},[s,l,g,a]),i.useEffect(()=>{y(1)},[B]);const F=i.useMemo(()=>($e(k,{min:1,max:1e6,fallback:1})-1)*lt,[k]);i.useEffect(()=>{if(!u&&!g)return;let p=!0;return Y(I=>({...I,loading:!0,error:null})),(async()=>{const I=await ar({userId:c?.id||null,period:B,limit:lt,offset:F});p&&Y({loading:!1,error:null,data:I})})().catch(I=>{p&&Y({loading:!1,error:la(I),data:null})}),()=>{p=!1}},[u,c?.id,F,T,g,B]);const _=D.data,te=_?.total_pages??null,q=_?.page??k,K=i.useMemo(()=>Zo(q,te),[q,te]),Ae=_?.from||null,ie=_?.to||null,ne=_?.generated_at||null,M=_?.me||null,pe=A("leaderboard.me_label"),re=A("leaderboard.anon_label"),be=A("leaderboard.period.week"),oe=A("leaderboard.period.month"),xe=A("leaderboard.period.total"),me=B==="month"?oe:B==="total"?xe:be,Oe=i.useMemo(()=>{const p=Array.isArray(_?.entries)?_.entries:[];return q!==1?p:ta({entries:p,me:M,meLabel:pe,limit:lt})},[q,_?.entries,M,pe]),at=async()=>{Ee(!0);try{ir(!0),ee(!0),await Kt(()=>wt(h));const p=await wt(h);p&&await Gt({accessToken:p}),L(I=>I+1)}catch(p){console.warn("[tokentracker] sync:",p)}finally{Ee(!1)}},Xe=async()=>{je(!0);try{const p=await wt(h);H&&p&&await Kt(()=>Promise.resolve(p)),p&&await Gt({accessToken:p}),L(I=>I+1)}catch(p){console.warn("[tokentracker] refresh:",p)}finally{je(!1)}},{canPrev:le,canNext:Ie}=ea({page:q,totalPages:te}),_e=Array.isArray(Oe)&&Oe.length!==0;let Se=null;D.loading?Se=d.jsx(ra,{rows:lt}):D.error?Se=d.jsx("div",{className:"px-6 py-12 text-center",children:d.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:D.error})}):_e?Se=d.jsx(No,{sensors:E,collisionDetection:Dr,modifiers:[Oo],onDragEnd:j,children:d.jsx("div",{className:"w-full overflow-x-auto",children:d.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[d.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:d.jsxs("tr",{children:[d.jsx("th",{className:O(xn,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:A("leaderboard.column.rank")}),d.jsx("th",{className:O(mn,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:A("leaderboard.column.user")}),d.jsx("th",{className:"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:A("leaderboard.column.total")}),d.jsx("th",{className:"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:"Est. Cost"}),d.jsx(Fo,{items:w,strategy:zo,children:R.map(p=>d.jsx(oa,{id:p.key,thClassName:"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:d.jsx(cr,{iconSrc:p.icon,label:A(p.copyKey)})},p.key))})]})}),d.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Oe.map(p=>{const I=!!p?.is_me,W=typeof p?.user_id=="string"?p.user_id:null,ve=Xn(p?.display_name),Te=ca(ve)?re:ve,ce=I?pe:Te;return!!W&&!I&&!!p?.is_public&&da(W,Me),I?d.jsxs("tr",{className:"border-y border-oai-brand-300/40 dark:border-oai-brand-500/30 bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",children:[d.jsx("td",{className:O(Et(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400"),children:d.jsx(hn,{rank:p?.rank,placeholder:x})}),d.jsx("td",{className:jt(!0),children:d.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(Vt,{avatarUrl:p?.avatar_url,displayName:ce,seed:pn(p,ce)}),d.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:ce}),p?.github_url&&d.jsx(bn,{githubUrl:p.github_url})]})}),d.jsx("td",{className:"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:Nt(p?.total_tokens)}),d.jsx("td",{className:"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:fn(p?.estimated_cost_usd)}),gn(p,!0,R)]},`row-${p?.rank}-${ce}`):d.jsxs("tr",{className:"group transition-colors",children:[d.jsx("td",{className:O(Et(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:d.jsx(hn,{rank:p?.rank,placeholder:x})}),d.jsx("td",{className:jt(!1),children:d.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(Vt,{avatarUrl:p?.avatar_url,displayName:ce,seed:pn(p,ce)}),d.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:ce}),p?.github_url&&d.jsx(bn,{githubUrl:p.github_url})]})}),d.jsx("td",{className:"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:Nt(p?.total_tokens)}),d.jsx("td",{className:"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:fn(p?.estimated_cost_usd)}),gn(p,!1,R)]},`row-${p?.rank}-${ce}`)})})]})})}):Se=d.jsx("div",{className:"px-6 py-12 text-center",children:d.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:A("leaderboard.empty")})});let Pe=null;return typeof te=="number"?Pe=K.map((p,I)=>p==null?d.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:A("leaderboard.pagination.ellipsis")},`ellipsis-${I}`):d.jsx("button",{className:O("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",p===q?"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:()=>y(p),disabled:D.loading,children:String(p)},`page-${p}`)):Pe=d.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:A("leaderboard.pagination.page_unknown",{page:String(q)})}),d.jsxs("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:[d.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:d.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[d.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6 mb-8",children:[d.jsxs("div",{children:[d.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:A("leaderboard.title")}),d.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[B==="total"?A("leaderboard.range.total"):Ae&&ie?A("leaderboard.range",{period:me,from:Ae,to:ie}):A("leaderboard.range_loading",{period:me}),ne&&d.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:A("leaderboard.generated_at",{ts:ne})})]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[f&&S&&d.jsx("div",{className:"inline-flex p-1 border border-oai-gray-200 dark:border-oai-gray-800 rounded-lg",children:d.jsxs("button",{onClick:Xe,disabled:$||D.loading,className:"px-3 py-1.5 text-sm font-medium rounded-md transition-colors text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900 hover:text-oai-black dark:hover:text-white disabled:opacity-50 inline-flex items-center gap-1.5",children:[d.jsxs("svg",{className:O("w-4 h-4",$&&"animate-spin"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M3 12a9 9 0 0 1 15.5-6.5L21 8"}),d.jsx("path",{d:"M21 3v5h-5"}),d.jsx("path",{d:"M21 12a9 9 0 0 1-15.5 6.5L3 16"}),d.jsx("path",{d:"M3 21v-5h5"})]}),$?"Refreshing":"Refresh"]})}),d.jsx("div",{className:"inline-flex p-1 border border-oai-gray-200 dark:border-oai-gray-800 rounded-lg",children:["week","month","total"].map(p=>d.jsx("button",{onClick:()=>Le(p),disabled:D.loading,className:O("px-4 py-1.5 text-sm font-medium rounded-md transition-colors",B===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:text-oai-gray-800 dark:hover:text-oai-gray-200"),children:p==="week"?be:p==="month"?oe:xe},p))})]})]}),!t&&d.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[d.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:"Sign in to join the leaderboard"}),d.jsx("button",{onClick:a,className:"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:"Sign In"})]}),f&&S&&!H&&d.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[d.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:"Enable Cloud Sync to appear in rankings"}),d.jsx("button",{onClick:at,disabled:ke,className:"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:ke?"Syncing...":"Enable & Sync"})]}),d.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:[Se,d.jsxs("div",{className:"px-6 py-3 border-t border-oai-gray-200 dark:border-oai-gray-800 flex flex-wrap items-center justify-between gap-4",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{className:O("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",le&&!D.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:()=>y(p=>Math.max(1,p-1)),disabled:!le||D.loading,children:A("leaderboard.pagination.prev")}),d.jsx("button",{className:O("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",Ie&&!D.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:()=>y(p=>p+1),disabled:!Ie||D.loading,children:A("leaderboard.pagination.next")})]}),d.jsx("div",{className:"flex flex-wrap items-center gap-1",children:Pe})]})]})]})}),d.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:d.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:[d.jsx("p",{children:A("landing.v2.footer.line")}),d.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:A("landing.v2.nav.github")})]})})]})}export{ha as LeaderboardPage};
|