tokentracker-cli 0.5.65 → 0.5.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/dashboard/dist/assets/{Card-CzO2gq_D.js → Card-CmQkSaLn.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-BE7gGFUL.js → DashboardPage-BZt5y5gb.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-CTN2r1YX.js → FadeIn-DuJxITM1.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-D7eagOPA.js → IpCheckPage-DseJuOvq.js} +1 -1
- package/dashboard/dist/assets/LeaderboardPage-CjgASqSw.js +5 -0
- package/dashboard/dist/assets/{LeaderboardProfilePage-f5R4Ny08.js → LeaderboardProfilePage-BTs27wAX.js} +1 -1
- package/dashboard/dist/assets/LimitsPage-Drc8wTon.js +2 -0
- package/dashboard/dist/assets/{SettingsPage-DWr_7D_U.js → SettingsPage-mCnpRVuo.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-OKjKynuO.js → WidgetsPage-qlO-IWyq.js} +1 -1
- package/dashboard/dist/assets/{download-B0JjZrok.js → download-Bk0FNyrl.js} +1 -1
- package/dashboard/dist/assets/leaderboard-columns-DH6pCqaP.js +1 -0
- package/dashboard/dist/assets/{main-DDaoGWcU.js → main-B377b_ow.js} +20 -17
- package/dashboard/dist/assets/main-Cm7tlYw7.css +1 -0
- package/dashboard/dist/assets/use-limits-display-prefs-SzjCvEJq.js +1 -0
- package/dashboard/dist/assets/{use-usage-limits-BLkA4tpF.js → use-usage-limits-BHeInsQY.js} +1 -1
- package/dashboard/dist/brand-logos/copilot.svg +1 -0
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +2 -2
- package/src/commands/status.js +29 -0
- package/src/commands/sync.js +81 -3
- package/src/lib/cursor-config.js +44 -45
- package/src/lib/rollout.js +192 -0
- package/src/lib/runtime-config.js +1 -1
- package/src/lib/usage-limits.js +148 -1
- package/dashboard/dist/assets/LeaderboardPage-B-N6D-VW.js +0 -5
- package/dashboard/dist/assets/LimitsPage-ynP3bW3P.js +0 -1
- package/dashboard/dist/assets/leaderboard-columns-CHbtsVUx.js +0 -1
- package/dashboard/dist/assets/main-DYCIFB2M.css +0 -1
- package/dashboard/dist/assets/use-limits-display-prefs-DPtzcPRA.js +0 -1
package/src/lib/rollout.js
CHANGED
|
@@ -2999,6 +2999,196 @@ async function parseHermesIncremental({ dbPath, cursors, queuePath, onProgress }
|
|
|
2999
2999
|
return { recordsProcessed: rows.length, eventsAggregated, bucketsQueued };
|
|
3000
3000
|
}
|
|
3001
3001
|
|
|
3002
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3003
|
+
// GitHub Copilot CLI — OpenTelemetry JSONL exporter
|
|
3004
|
+
// User must opt in by setting:
|
|
3005
|
+
// COPILOT_OTEL_ENABLED=true
|
|
3006
|
+
// COPILOT_OTEL_EXPORTER_TYPE=file
|
|
3007
|
+
// COPILOT_OTEL_FILE_EXPORTER_PATH=$HOME/.copilot/otel/copilot-otel-...jsonl
|
|
3008
|
+
// We scan the default directory plus the env-overridden path.
|
|
3009
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3010
|
+
|
|
3011
|
+
function resolveCopilotOtelPaths(env = process.env) {
|
|
3012
|
+
const home = require("node:os").homedir();
|
|
3013
|
+
const paths = new Set();
|
|
3014
|
+
const defaultDir = path.join(home, ".copilot", "otel");
|
|
3015
|
+
if (fssync.existsSync(defaultDir)) {
|
|
3016
|
+
try {
|
|
3017
|
+
for (const entry of fssync.readdirSync(defaultDir)) {
|
|
3018
|
+
if (entry.endsWith(".jsonl")) paths.add(path.join(defaultDir, entry));
|
|
3019
|
+
}
|
|
3020
|
+
} catch (_e) {}
|
|
3021
|
+
}
|
|
3022
|
+
const explicit = env.COPILOT_OTEL_FILE_EXPORTER_PATH;
|
|
3023
|
+
if (typeof explicit === "string" && explicit.trim() && fssync.existsSync(explicit)) {
|
|
3024
|
+
paths.add(explicit);
|
|
3025
|
+
}
|
|
3026
|
+
return Array.from(paths).sort();
|
|
3027
|
+
}
|
|
3028
|
+
|
|
3029
|
+
function isCopilotChatSpan(record) {
|
|
3030
|
+
if (!record || record.type !== "span") return false;
|
|
3031
|
+
const opName = record?.attributes?.["gen_ai.operation.name"];
|
|
3032
|
+
if (opName === "chat") return true;
|
|
3033
|
+
if (typeof record.name === "string" && record.name.startsWith("chat ")) return true;
|
|
3034
|
+
return false;
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
function copilotOtelTimeToMs(value) {
|
|
3038
|
+
if (!Array.isArray(value) || value.length < 2) return null;
|
|
3039
|
+
const seconds = Number(value[0]);
|
|
3040
|
+
const nanos = Number(value[1]);
|
|
3041
|
+
if (!Number.isFinite(seconds)) return null;
|
|
3042
|
+
const ns = Number.isFinite(nanos) ? nanos : 0;
|
|
3043
|
+
return Math.round(seconds * 1000 + ns / 1_000_000);
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
function pickCopilotModel(attrs) {
|
|
3047
|
+
const candidates = [attrs?.["gen_ai.response.model"], attrs?.["gen_ai.request.model"]];
|
|
3048
|
+
for (const c of candidates) {
|
|
3049
|
+
if (typeof c === "string" && c.trim()) return c.trim();
|
|
3050
|
+
}
|
|
3051
|
+
return null;
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
async function parseCopilotIncremental({ otelPaths, cursors, queuePath, onProgress, env } = {}) {
|
|
3055
|
+
await ensureDir(path.dirname(queuePath));
|
|
3056
|
+
const copilotState = cursors.copilot && typeof cursors.copilot === "object" ? cursors.copilot : {};
|
|
3057
|
+
const seenIds = new Set(Array.isArray(copilotState.seenIds) ? copilotState.seenIds : []);
|
|
3058
|
+
const fileOffsets =
|
|
3059
|
+
copilotState.fileOffsets && typeof copilotState.fileOffsets === "object"
|
|
3060
|
+
? { ...copilotState.fileOffsets }
|
|
3061
|
+
: {};
|
|
3062
|
+
|
|
3063
|
+
const files = Array.isArray(otelPaths) && otelPaths.length > 0
|
|
3064
|
+
? otelPaths
|
|
3065
|
+
: resolveCopilotOtelPaths(env || process.env);
|
|
3066
|
+
if (files.length === 0) {
|
|
3067
|
+
cursors.copilot = { ...copilotState, seenIds: Array.from(seenIds), fileOffsets, updatedAt: new Date().toISOString() };
|
|
3068
|
+
return { recordsProcessed: 0, eventsAggregated: 0, bucketsQueued: 0 };
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
const hourlyState = normalizeHourlyState(cursors?.hourly);
|
|
3072
|
+
const touchedBuckets = new Set();
|
|
3073
|
+
const cb = typeof onProgress === "function" ? onProgress : null;
|
|
3074
|
+
let recordsProcessed = 0;
|
|
3075
|
+
let eventsAggregated = 0;
|
|
3076
|
+
|
|
3077
|
+
for (let fileIdx = 0; fileIdx < files.length; fileIdx++) {
|
|
3078
|
+
const filePath = files[fileIdx];
|
|
3079
|
+
let stat;
|
|
3080
|
+
try {
|
|
3081
|
+
stat = fssync.statSync(filePath);
|
|
3082
|
+
} catch (_e) {
|
|
3083
|
+
continue;
|
|
3084
|
+
}
|
|
3085
|
+
const prevEntry = fileOffsets[filePath] || {};
|
|
3086
|
+
const prevSize = Number(prevEntry.size) || 0;
|
|
3087
|
+
const prevIno = prevEntry.ino;
|
|
3088
|
+
// Re-read from start if (a) file shrunk (truncate/rewrite in place) or
|
|
3089
|
+
// (b) inode changed (rotator deleted + recreated at same path). Without
|
|
3090
|
+
// the inode check, a rotator producing a same-or-larger file would leave
|
|
3091
|
+
// the old offset stuck and skip the new file's prefix forever.
|
|
3092
|
+
const inodeChanged = typeof prevIno === "number" && prevIno !== stat.ino;
|
|
3093
|
+
const startOffset = stat.size < prevSize || inodeChanged ? 0 : prevSize;
|
|
3094
|
+
if (stat.size <= startOffset) continue;
|
|
3095
|
+
|
|
3096
|
+
let stream;
|
|
3097
|
+
try {
|
|
3098
|
+
stream = fssync.createReadStream(filePath, { encoding: "utf8", start: startOffset });
|
|
3099
|
+
} catch (_e) {
|
|
3100
|
+
continue;
|
|
3101
|
+
}
|
|
3102
|
+
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
|
|
3103
|
+
|
|
3104
|
+
for await (const line of rl) {
|
|
3105
|
+
if (!line || !line.trim()) continue;
|
|
3106
|
+
let record;
|
|
3107
|
+
try {
|
|
3108
|
+
record = JSON.parse(line);
|
|
3109
|
+
} catch (_e) {
|
|
3110
|
+
continue;
|
|
3111
|
+
}
|
|
3112
|
+
recordsProcessed++;
|
|
3113
|
+
if (!isCopilotChatSpan(record)) continue;
|
|
3114
|
+
|
|
3115
|
+
const traceId = record?.traceId || "";
|
|
3116
|
+
const spanId = record?.spanId || "";
|
|
3117
|
+
const dedupKey = traceId && spanId ? `${traceId}:${spanId}` : null;
|
|
3118
|
+
if (dedupKey && seenIds.has(dedupKey)) continue;
|
|
3119
|
+
|
|
3120
|
+
const attrs = record.attributes || {};
|
|
3121
|
+
const inputRaw = toNonNegativeInt(attrs["gen_ai.usage.input_tokens"]);
|
|
3122
|
+
const output = toNonNegativeInt(attrs["gen_ai.usage.output_tokens"]);
|
|
3123
|
+
const cacheRead = toNonNegativeInt(attrs["gen_ai.usage.cache_read.input_tokens"]);
|
|
3124
|
+
const cacheWrite = toNonNegativeInt(attrs["gen_ai.usage.cache_write.input_tokens"]);
|
|
3125
|
+
const reasoning = toNonNegativeInt(attrs["gen_ai.usage.reasoning.output_tokens"]);
|
|
3126
|
+
// OTEL input_tokens INCLUDES cache_read — subtract per project convention
|
|
3127
|
+
const cacheReadClamped = Math.min(cacheRead, inputRaw);
|
|
3128
|
+
const input = Math.max(0, inputRaw - cacheReadClamped);
|
|
3129
|
+
const totalInteresting = input + output + cacheReadClamped + cacheWrite + reasoning;
|
|
3130
|
+
// Drop empty rows unless cache-only
|
|
3131
|
+
if (totalInteresting === 0) continue;
|
|
3132
|
+
|
|
3133
|
+
const tsMs = copilotOtelTimeToMs(record.endTime) || copilotOtelTimeToMs(record.startTime);
|
|
3134
|
+
if (!tsMs) continue;
|
|
3135
|
+
const tsIso = new Date(tsMs).toISOString();
|
|
3136
|
+
const bucketStart = toUtcHalfHourStart(tsIso);
|
|
3137
|
+
if (!bucketStart) continue;
|
|
3138
|
+
|
|
3139
|
+
const model = normalizeModelInput(pickCopilotModel(attrs)) || "github-copilot";
|
|
3140
|
+
|
|
3141
|
+
const delta = {
|
|
3142
|
+
input_tokens: input,
|
|
3143
|
+
cached_input_tokens: cacheReadClamped,
|
|
3144
|
+
cache_creation_input_tokens: cacheWrite,
|
|
3145
|
+
output_tokens: output,
|
|
3146
|
+
reasoning_output_tokens: reasoning,
|
|
3147
|
+
total_tokens: input + output + cacheReadClamped + cacheWrite + reasoning,
|
|
3148
|
+
conversation_count: 1,
|
|
3149
|
+
};
|
|
3150
|
+
|
|
3151
|
+
const bucket = getHourlyBucket(hourlyState, "copilot", model, bucketStart);
|
|
3152
|
+
addTotals(bucket.totals, delta);
|
|
3153
|
+
touchedBuckets.add(bucketKey("copilot", model, bucketStart));
|
|
3154
|
+
eventsAggregated++;
|
|
3155
|
+
if (dedupKey) seenIds.add(dedupKey);
|
|
3156
|
+
|
|
3157
|
+
if (cb) {
|
|
3158
|
+
cb({
|
|
3159
|
+
index: fileIdx + 1,
|
|
3160
|
+
total: files.length,
|
|
3161
|
+
recordsProcessed,
|
|
3162
|
+
eventsAggregated,
|
|
3163
|
+
bucketsQueued: touchedBuckets.size,
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
// Re-stat after readline drains: file may have been appended during the
|
|
3169
|
+
// parse loop. Without this, those new lines would be replayed next run
|
|
3170
|
+
// (dedup catches records with traceId+spanId, but spans missing either
|
|
3171
|
+
// would be double-counted).
|
|
3172
|
+
let postStat = stat;
|
|
3173
|
+
try {
|
|
3174
|
+
postStat = fssync.statSync(filePath);
|
|
3175
|
+
} catch (_e) {}
|
|
3176
|
+
fileOffsets[filePath] = { size: postStat.size, mtimeMs: postStat.mtimeMs, ino: postStat.ino };
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
// Cap dedup set to last 10k IDs to bound state size
|
|
3180
|
+
const seenArr = Array.from(seenIds);
|
|
3181
|
+
const cappedSeen = seenArr.length > 10_000 ? seenArr.slice(seenArr.length - 10_000) : seenArr;
|
|
3182
|
+
|
|
3183
|
+
const bucketsQueued = await enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets });
|
|
3184
|
+
const updatedAt = new Date().toISOString();
|
|
3185
|
+
hourlyState.updatedAt = updatedAt;
|
|
3186
|
+
cursors.hourly = hourlyState;
|
|
3187
|
+
cursors.copilot = { ...copilotState, seenIds: cappedSeen, fileOffsets, updatedAt };
|
|
3188
|
+
|
|
3189
|
+
return { recordsProcessed, eventsAggregated, bucketsQueued };
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3002
3192
|
module.exports = {
|
|
3003
3193
|
listRolloutFiles,
|
|
3004
3194
|
listClaudeProjectFiles,
|
|
@@ -3008,6 +3198,7 @@ module.exports = {
|
|
|
3008
3198
|
resolveKiroDbPath,
|
|
3009
3199
|
resolveKiroJsonlPath,
|
|
3010
3200
|
resolveHermesDbPath,
|
|
3201
|
+
resolveCopilotOtelPaths,
|
|
3011
3202
|
parseRolloutIncremental,
|
|
3012
3203
|
parseClaudeIncremental,
|
|
3013
3204
|
parseGeminiIncremental,
|
|
@@ -3017,4 +3208,5 @@ module.exports = {
|
|
|
3017
3208
|
parseCursorApiIncremental,
|
|
3018
3209
|
parseKiroIncremental,
|
|
3019
3210
|
parseHermesIncremental,
|
|
3211
|
+
parseCopilotIncremental,
|
|
3020
3212
|
};
|
package/src/lib/usage-limits.js
CHANGED
|
@@ -616,6 +616,148 @@ function parseKiroUsageOutput(output, { now = new Date() } = {}) {
|
|
|
616
616
|
};
|
|
617
617
|
}
|
|
618
618
|
|
|
619
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
620
|
+
// GitHub Copilot — `GET https://api.github.com/copilot_internal/user`
|
|
621
|
+
// Reuses the OAuth token from the user's existing Copilot install
|
|
622
|
+
// (`~/.config/github-copilot/{apps,hosts}.json`). No device flow needed.
|
|
623
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
624
|
+
|
|
625
|
+
function readCopilotOauthToken({ home = require("node:os").homedir() } = {}) {
|
|
626
|
+
const candidates = [
|
|
627
|
+
path.join(home, ".config", "github-copilot", "apps.json"),
|
|
628
|
+
path.join(home, ".config", "github-copilot", "hosts.json"),
|
|
629
|
+
];
|
|
630
|
+
// Keys are either "github.com", "github.example.com" (enterprise), or a
|
|
631
|
+
// composite like "github.com:Iv1.b507a08c87ecfe98". We always hit
|
|
632
|
+
// api.github.com, so prefer the public-host token; only fall back to
|
|
633
|
+
// whatever's there if no public-host entry exists.
|
|
634
|
+
let fallback = null;
|
|
635
|
+
for (const filePath of candidates) {
|
|
636
|
+
if (!fs.existsSync(filePath)) continue;
|
|
637
|
+
let parsed;
|
|
638
|
+
try {
|
|
639
|
+
parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
640
|
+
} catch (_e) {
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
if (!parsed || typeof parsed !== "object") continue;
|
|
644
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
645
|
+
if (!value || typeof value !== "object") continue;
|
|
646
|
+
const token = typeof value.oauth_token === "string" ? value.oauth_token : "";
|
|
647
|
+
if (!token) continue;
|
|
648
|
+
const host = String(key).split(":")[0];
|
|
649
|
+
if (host === "github.com") return token;
|
|
650
|
+
if (!fallback) fallback = token;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return fallback;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function copilotRequestHeaders(token) {
|
|
657
|
+
return {
|
|
658
|
+
Authorization: `token ${token}`,
|
|
659
|
+
Accept: "application/json",
|
|
660
|
+
"Editor-Version": "vscode/1.96.2",
|
|
661
|
+
"Editor-Plugin-Version": "copilot-chat/0.26.7",
|
|
662
|
+
"User-Agent": "GitHubCopilotChat/0.26.7",
|
|
663
|
+
"X-Github-Api-Version": "2025-04-01",
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function copilotResetIso(value) {
|
|
668
|
+
if (typeof value !== "string" || !value.trim()) return null;
|
|
669
|
+
const trimmed = value.trim();
|
|
670
|
+
// Accept "YYYY-MM-DD" or full ISO timestamps
|
|
671
|
+
const dateOnly = /^\d{4}-\d{2}-\d{2}$/.test(trimmed);
|
|
672
|
+
const ts = Date.parse(dateOnly ? `${trimmed}T00:00:00Z` : trimmed);
|
|
673
|
+
if (!Number.isFinite(ts)) return null;
|
|
674
|
+
return new Date(ts).toISOString();
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function buildCopilotWindow(snapshot, resetIso) {
|
|
678
|
+
if (!snapshot || typeof snapshot !== "object") return null;
|
|
679
|
+
const entitlement = Number(snapshot.entitlement);
|
|
680
|
+
const remaining = Number(snapshot.remaining);
|
|
681
|
+
const percentRemaining = Number(snapshot.percent_remaining);
|
|
682
|
+
const allZero = (!entitlement || entitlement <= 0) && (!remaining || remaining <= 0) && (!percentRemaining || percentRemaining <= 0);
|
|
683
|
+
if (allZero) return null;
|
|
684
|
+
let usedPercent;
|
|
685
|
+
if (Number.isFinite(percentRemaining)) {
|
|
686
|
+
usedPercent = 100 - percentRemaining;
|
|
687
|
+
} else if (Number.isFinite(entitlement) && entitlement > 0 && Number.isFinite(remaining)) {
|
|
688
|
+
usedPercent = ((entitlement - remaining) / entitlement) * 100;
|
|
689
|
+
} else {
|
|
690
|
+
return null;
|
|
691
|
+
}
|
|
692
|
+
return buildWindow({ usedPercent, resetAt: resetIso });
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function describeCopilotOtelStatus({ home, env = process.env } = {}) {
|
|
696
|
+
const resolvedHome = home || env.HOME || require("node:os").homedir();
|
|
697
|
+
const enabled = String(env.COPILOT_OTEL_ENABLED || "").toLowerCase() === "true";
|
|
698
|
+
const exporterType = String(env.COPILOT_OTEL_EXPORTER_TYPE || "").toLowerCase();
|
|
699
|
+
const explicitPath = typeof env.COPILOT_OTEL_FILE_EXPORTER_PATH === "string"
|
|
700
|
+
? env.COPILOT_OTEL_FILE_EXPORTER_PATH
|
|
701
|
+
: "";
|
|
702
|
+
const defaultDir = path.join(resolvedHome, ".copilot", "otel");
|
|
703
|
+
let hasFiles = false;
|
|
704
|
+
try {
|
|
705
|
+
if (fs.existsSync(defaultDir)) {
|
|
706
|
+
hasFiles = fs.readdirSync(defaultDir).some((entry) => entry.endsWith(".jsonl"));
|
|
707
|
+
}
|
|
708
|
+
} catch (_e) {}
|
|
709
|
+
if (!hasFiles && explicitPath && fs.existsSync(explicitPath)) hasFiles = true;
|
|
710
|
+
return {
|
|
711
|
+
otel_enabled: enabled && (exporterType === "" || exporterType === "file"),
|
|
712
|
+
otel_exporter_type: exporterType || null,
|
|
713
|
+
otel_path: explicitPath || null,
|
|
714
|
+
otel_default_dir: defaultDir,
|
|
715
|
+
otel_has_files: hasFiles,
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
async function fetchCopilotLimits({ home, env = process.env, fetchImpl = fetch } = {}) {
|
|
720
|
+
const otel = describeCopilotOtelStatus({ home, env });
|
|
721
|
+
const token = readCopilotOauthToken({ home: home || (env.HOME || require("node:os").homedir()) });
|
|
722
|
+
if (!token) return { configured: false, ...otel };
|
|
723
|
+
|
|
724
|
+
try {
|
|
725
|
+
const res = await fetchImpl("https://api.github.com/copilot_internal/user", {
|
|
726
|
+
method: "GET",
|
|
727
|
+
headers: copilotRequestHeaders(token),
|
|
728
|
+
});
|
|
729
|
+
if (res.status === 401 || res.status === 403) {
|
|
730
|
+
throw new Error("GitHub Copilot token rejected. Re-authenticate via GitHub Copilot CLI/extension.");
|
|
731
|
+
}
|
|
732
|
+
if (!res.ok) {
|
|
733
|
+
throw new Error(`GitHub Copilot API error: HTTP ${res.status}`);
|
|
734
|
+
}
|
|
735
|
+
const json = await res.json();
|
|
736
|
+
const planName = typeof json?.copilot_plan === "string" && json.copilot_plan
|
|
737
|
+
? json.copilot_plan.charAt(0).toUpperCase() + json.copilot_plan.slice(1)
|
|
738
|
+
: null;
|
|
739
|
+
const resetIso = copilotResetIso(json?.quota_reset_date);
|
|
740
|
+
const snapshots = json?.quota_snapshots || {};
|
|
741
|
+
const premiumWindow = buildCopilotWindow(snapshots.premium_interactions, resetIso);
|
|
742
|
+
const chatWindow = buildCopilotWindow(snapshots.chat, resetIso);
|
|
743
|
+
|
|
744
|
+
if (!premiumWindow && !chatWindow) {
|
|
745
|
+
return { configured: true, error: null, plan_name: planName, primary_window: null, secondary_window: null, ...otel };
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return {
|
|
749
|
+
configured: true,
|
|
750
|
+
error: null,
|
|
751
|
+
plan_name: planName,
|
|
752
|
+
primary_window: premiumWindow,
|
|
753
|
+
secondary_window: chatWindow,
|
|
754
|
+
...otel,
|
|
755
|
+
};
|
|
756
|
+
} catch (error) {
|
|
757
|
+
return { configured: true, error: error?.message || "Unknown error", ...otel };
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
619
761
|
function fetchKiroLimits({ commandRunner, now = new Date() } = {}) {
|
|
620
762
|
if (!isBinaryAvailable("kiro-cli", { commandRunner })) {
|
|
621
763
|
return { configured: false };
|
|
@@ -1072,7 +1214,7 @@ async function getUsageLimits({
|
|
|
1072
1214
|
readCodexAccessToken({ home, env }),
|
|
1073
1215
|
]);
|
|
1074
1216
|
|
|
1075
|
-
const [claudeResult, codexResult, cursor, gemini, kiro, antigravity] = await Promise.all([
|
|
1217
|
+
const [claudeResult, codexResult, cursor, gemini, kiro, antigravity, copilot] = await Promise.all([
|
|
1076
1218
|
claudeToken
|
|
1077
1219
|
? fetchClaudeUsageLimits(claudeToken, { fetchImpl }).then(
|
|
1078
1220
|
(value) => ({ status: "fulfilled", value }),
|
|
@@ -1089,6 +1231,7 @@ async function getUsageLimits({
|
|
|
1089
1231
|
fetchGeminiLimits({ home, env, fetchImpl, commandRunner }),
|
|
1090
1232
|
Promise.resolve().then(() => fetchKiroLimits({ commandRunner, now })),
|
|
1091
1233
|
fetchAntigravityLimits({ commandRunner, requestFn }),
|
|
1234
|
+
fetchCopilotLimits({ home, env, fetchImpl }),
|
|
1092
1235
|
]);
|
|
1093
1236
|
|
|
1094
1237
|
let claude;
|
|
@@ -1129,6 +1272,7 @@ async function getUsageLimits({
|
|
|
1129
1272
|
gemini,
|
|
1130
1273
|
kiro,
|
|
1131
1274
|
antigravity,
|
|
1275
|
+
copilot,
|
|
1132
1276
|
};
|
|
1133
1277
|
|
|
1134
1278
|
cache = { data, fetchedAt: nowMs };
|
|
@@ -1148,4 +1292,7 @@ module.exports = {
|
|
|
1148
1292
|
normalizeAntigravityResponse,
|
|
1149
1293
|
parseListeningPorts,
|
|
1150
1294
|
detectAntigravityProcess,
|
|
1295
|
+
fetchCopilotLimits,
|
|
1296
|
+
readCopilotOauthToken,
|
|
1297
|
+
describeCopilotOtelStatus,
|
|
1151
1298
|
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{r as i,ad as V,S as Ge,D as d,az as _,aA as qn,aB as Jn,ah as Qn,ai as Zn,aC as er,h as tr,j as nr,B as M,aD as rr,am as or,ax as Et,aE as kt,aF as Vt,aG as Gt,aH as ar}from"./main-DDaoGWcU.js";import{L as mn,a as xn,b as ut,l as jt,c as At,d as sr,e as qt}from"./leaderboard-columns-CHbtsVUx.js";function ir(){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 bt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Be(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Pt(e){return"nodeType"in e}function G(e){var t,n;return e?Be(e)?e:Pt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Bt(e){const{Document:t}=G(e);return e instanceof t}function rt(e){return Be(e)?!1:e instanceof G(e).HTMLElement}function vn(e){return e instanceof G(e).SVGElement}function ze(e){return e?Be(e)?e.document:Pt(e)?Bt(e)?e:rt(e)||vn(e)?e.ownerDocument:document:document:document}const xe=bt?i.useLayoutEffect:i.useEffect;function zt(e){const t=i.useRef(e);return xe(()=>{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 lr(){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 Ze(e,t){t===void 0&&(t=[e]);const n=i.useRef(e);return xe(()=>{n.current!==e&&(n.current=e)},t),n}function ot(e,t){const n=i.useRef();return i.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function ft(e){const t=zt(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 St={};function at(e,t){return i.useMemo(()=>{if(t)return t;const n=St[e]==null?0:St[e]+1;return St[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 _e=yn(1),et=yn(-1);function cr(e){return"clientX"in e&&"clientY"in e}function $t(e){if(!e)return!1;const{KeyboardEvent:t}=G(e.target);return t&&e instanceof t}function dr(e){if(!e)return!1;const{TouchEvent:t}=G(e.target);return t&&e instanceof t}function It(e){if(dr(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 cr(e)?{x:e.clientX,y:e.clientY}:null}const tt=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[tt.Translate.toString(e),tt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Jt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function ur(e){return e.matches(Jt)?e:e.querySelector(Jt)}const fr={display:"none"};function gr(e){let{id:t,value:n}=e;return V.createElement("div",{id:t,style:fr},n)}function hr(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 V.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function pr(){const[e,t]=i.useState("");return{announce:i.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const wn=i.createContext(null);function br(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 mr(){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 xr={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
|
-
`},vr={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 yr(e){let{announcements:t=vr,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=xr}=e;const{announce:a,announcement:s}=pr(),l=at("DndLiveRegion"),[c,u]=i.useState(!1);if(i.useEffect(()=>{u(!0)},[]),br(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=V.createElement(V.Fragment,null,V.createElement(gr,{id:r,value:o.draggable}),V.createElement(hr,{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 gt(){}function Qt(e,t){return i.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function wr(){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 de=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 kr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Zt(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 en(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 Sr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=en(t,t.left,t.top),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=kn(en(c),o);a.push({id:l,data:{droppableContainer:s,value:u}})}}return a.sort(Sn)},Cr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Zt(t),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=Zt(c),g=o.reduce((b,h,w)=>b+kn(u[w],h),0),f=Number((g/4).toFixed(4));a.push({id:l,data:{droppableContainer:s,value:f}})}}return a.sort(Sn)};function Dr(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 Rr=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=Dr(l,t);c>0&&o.push({id:s,data:{droppableContainer:a,value:c}})}}return o.sort(kr)};function Nr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Dn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:de}function Er(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 jr=Er(1);function Ar(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 Mr(e,t,n){const r=Ar(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 Ir={ignoreTransform:!1};function $e(e,t){t===void 0&&(t=Ir);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:g}=G(e).getComputedStyle(e);u&&(n=Mr(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 tn(e){return $e(e,{ignoreTransform:!0})}function Tr(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Lr(e,t){return t===void 0&&(t=G(e).getComputedStyle(e)),t.position==="fixed"}function Or(e,t){t===void 0&&(t=G(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 mt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Bt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!rt(o)||vn(o)||n.includes(o))return n;const a=G(e).getComputedStyle(o);return o!==e&&Or(o,a)&&n.push(o),Lr(o,a)?n:r(o.parentNode)}return e?r(e):n}function Rn(e){const[t]=mt(e,1);return t??null}function Ct(e){return!bt||!e?null:Be(e)?e:Pt(e)?Bt(e)||e===ze(e).scrollingElement?window:rt(e)?e:null:null}function Nn(e){return Be(e)?e.scrollX:e.scrollLeft}function En(e){return Be(e)?e.scrollY:e.scrollTop}function Tt(e){return{x:Nn(e),y:En(e)}}var B;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(B||(B={}));function jn(e){return!bt||!e?!1:e===document.scrollingElement}function An(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 _r={x:.2,y:.2};function Pr(e,t,n,r,o){let{top:a,left:s,right:l,bottom:c}=n;r===void 0&&(r=10),o===void 0&&(o=_r);const{isTop:u,isBottom:g,isLeft:f,isRight:b}=An(e),h={x:0,y:0},w={x:0,y:0},m={height:t.height*o.y,width:t.width*o.x};return!u&&a<=t.top+m.height?(h.y=B.Backward,w.y=r*Math.abs((t.top+m.height-a)/m.height)):!g&&c>=t.bottom-m.height&&(h.y=B.Forward,w.y=r*Math.abs((t.bottom-m.height-c)/m.height)),!b&&l>=t.right-m.width?(h.x=B.Forward,w.x=r*Math.abs((t.right-m.width-l)/m.width)):!f&&s<=t.left+m.width&&(h.x=B.Backward,w.x=r*Math.abs((t.left+m.width-s)/m.width)),{direction:h,speed:w}}function Br(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 Mn(e){return e.reduce((t,n)=>_e(t,Tt(n)),de)}function zr(e){return e.reduce((t,n)=>t+Nn(n),0)}function $r(e){return e.reduce((t,n)=>t+En(n),0)}function Fr(e,t){if(t===void 0&&(t=$e),!e)return;const{top:n,left:r,bottom:o,right:a}=t(e);Rn(e)&&(o<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Ur=[["x",["left","right"],zr],["y",["top","bottom"],$r]];class Ft{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=mt(n),o=Mn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,s,l]of Ur)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 qe{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 Xr(e){const{EventTarget:t}=G(e);return e instanceof t?e:ze(e)}function Dt(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 ae;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ae||(ae={}));function nn(e){e.preventDefault()}function Yr(e){e.stopPropagation()}var R;(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"})(R||(R={}));const In={start:[R.Space,R.Enter],cancel:[R.Esc],end:[R.Space,R.Enter,R.Tab]},Wr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case R.Right:return{...n,x:n.x+25};case R.Left:return{...n,x:n.x-25};case R.Down:return{...n,y:n.y+25};case R.Up:return{...n,y:n.y-25}}};class Ut{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 qe(ze(n)),this.windowListeners=new qe(G(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ae.Resize,this.handleCancel),this.windowListeners.add(ae.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ae.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&Fr(r),n(de)}handleKeyDown(t){if($t(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:a=In,coordinateGetter:s=Wr,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}:de;this.referenceCoordinates||(this.referenceCoordinates=g);const f=s(t,{active:n,context:r.current,currentCoordinates:g});if(f){const b=et(f,g),h={x:0,y:0},{scrollableAncestors:w}=r.current;for(const m of w){const x=t.code,{isTop:v,isRight:k,isLeft:y,isBottom:C,maxScroll:N,minScroll:j}=An(m),S=Br(m),D={x:Math.min(x===R.Right?S.right-S.width/2:S.right,Math.max(x===R.Right?S.left:S.left+S.width/2,f.x)),y:Math.min(x===R.Down?S.bottom-S.height/2:S.bottom,Math.max(x===R.Down?S.top:S.top+S.height/2,f.y))},T=x===R.Right&&!k||x===R.Left&&!y,L=x===R.Down&&!C||x===R.Up&&!v;if(T&&D.x!==f.x){const I=m.scrollLeft+b.x,H=x===R.Right&&I<=N.x||x===R.Left&&I>=j.x;if(H&&!b.y){m.scrollTo({left:I,behavior:l});return}H?h.x=m.scrollLeft-I:h.x=x===R.Right?m.scrollLeft-N.x:m.scrollLeft-j.x,h.x&&m.scrollBy({left:-h.x,behavior:l});break}else if(L&&D.y!==f.y){const I=m.scrollTop+b.y,H=x===R.Down&&I<=N.y||x===R.Up&&I>=j.y;if(H&&!b.x){m.scrollTo({top:I,behavior:l});return}H?h.y=m.scrollTop-I:h.y=x===R.Down?m.scrollTop-N.y:m.scrollTop-j.y,h.y&&m.scrollBy({top:-h.y,behavior:l});break}}this.handleMove(t,_e(et(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()}}Ut.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 rn(e){return!!(e&&"distance"in e)}function on(e){return!!(e&&"delay"in e)}class Xt{constructor(t,n,r){var o;r===void 0&&(r=Xr(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=ze(s),this.documentListeners=new qe(this.document),this.listeners=new qe(r),this.windowListeners=new qe(G(s)),this.initialCoordinates=(o=It(a))!=null?o:de,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(ae.Resize,this.handleCancel),this.windowListeners.add(ae.DragStart,nn),this.windowListeners.add(ae.VisibilityChange,this.handleCancel),this.windowListeners.add(ae.ContextMenu,nn),this.documentListeners.add(ae.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(on(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(rn(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(ae.Click,Yr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ae.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=It(t))!=null?n:de,u=et(o,c);if(!r&&l){if(rn(l)){if(l.tolerance!=null&&Dt(u,l.tolerance))return this.handleCancel();if(Dt(u,l.distance))return this.handleStart()}if(on(l)&&Dt(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===R.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Hr={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Yt extends Xt{constructor(t){const{event:n}=t,r=ze(n.target);super(t,Hr,r)}}Yt.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 Kr={move:{name:"mousemove"},end:{name:"mouseup"}};var Lt;(function(e){e[e.RightClick=2]="RightClick"})(Lt||(Lt={}));class Vr extends Xt{constructor(t){super(t,Kr,ze(t.event.target))}}Vr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Lt.RightClick?!1:(r?.({event:n}),!0)}}];const Rt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Gr extends Xt{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(){}}}Gr.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 Je;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Je||(Je={}));var ht;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ht||(ht={}));function qr(e){let{acceleration:t,activator:n=Je.Pointer,canScroll:r,draggingRect:o,enabled:a,interval:s=5,order:l=ht.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:g,delta:f,threshold:b}=e;const h=Qr({delta:f,disabled:!a}),[w,m]=lr(),x=i.useRef({x:0,y:0}),v=i.useRef({x:0,y:0}),k=i.useMemo(()=>{switch(n){case Je.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Je.DraggableRect:return o}},[n,o,c]),y=i.useRef(null),C=i.useCallback(()=>{const j=y.current;if(!j)return;const S=x.current.x*v.current.x,D=x.current.y*v.current.y;j.scrollBy(S,D)},[]),N=i.useMemo(()=>l===ht.TreeOrder?[...u].reverse():u,[l,u]);i.useEffect(()=>{if(!a||!u.length||!k){m();return}for(const j of N){if(r?.(j)===!1)continue;const S=u.indexOf(j),D=g[S];if(!D)continue;const{direction:T,speed:L}=Pr(j,D,k,t,b);for(const I of["x","y"])h[I][T[I]]||(L[I]=0,T[I]=0);if(L.x>0||L.y>0){m(),y.current=j,w(C,s),x.current=L,v.current=T;return}}x.current={x:0,y:0},v.current={x:0,y:0},m()},[t,C,r,m,a,s,JSON.stringify(k),JSON.stringify(h),w,u,N,g,JSON.stringify(b)])}const Jr={x:{[B.Backward]:!1,[B.Forward]:!1},y:{[B.Backward]:!1,[B.Forward]:!1}};function Qr(e){let{delta:t,disabled:n}=e;const r=Mt(t);return ot(o=>{if(n||!r||!o)return Jr;const a={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[B.Backward]:o.x[B.Backward]||a.x===-1,[B.Forward]:o.x[B.Forward]||a.x===1},y:{[B.Backward]:o.y[B.Backward]||a.y===-1,[B.Forward]:o.y[B.Forward]||a.y===1}}},[n,t,r])}function Zr(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return ot(o=>{var a;return t==null?null:(a=r??o)!=null?a:null},[r,t])}function eo(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 nt;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(nt||(nt={}));var Ot;(function(e){e.Optimized="optimized"})(Ot||(Ot={}));const an=new Map;function to(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=x(),b=Ze(f),h=i.useCallback(function(v){v===void 0&&(v=[]),!b.current&&s(k=>k===null?v:k.concat(v.filter(y=>!k.includes(y))))},[b]),w=i.useRef(null),m=ot(v=>{if(f&&!n)return an;if(!v||v===an||g.current!==e||a!=null){const k=new Map;for(let y of e){if(!y)continue;if(a&&a.length>0&&!a.includes(y.id)&&y.rect.current){k.set(y.id,y.rect.current);continue}const C=y.node.current,N=C?new Ft(c(C),C):null;y.rect.current=N,N&&k.set(y.id,N)}return k}return v},[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"||w.current!==null||(w.current=setTimeout(()=>{h(),w.current=null},l))},[l,f,h,...r]),{droppableRects:m,measureDroppableContainers:h,measuringScheduled:a!=null};function x(){switch(u){case nt.Always:return!1;case nt.BeforeDragging:return n;default:return!n}}}function Tn(e,t){return ot(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function no(e,t){return Tn(e,t)}function ro(e){let{callback:t,disabled:n}=e;const r=zt(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=zt(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 oo(e){return new Ft($e(e),e)}function sn(e,t,n){t===void 0&&(t=oo);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=ro({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 xe(()=>{a(),e?(l?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),s?.disconnect())},[e]),r}function ao(e){const t=Tn(e);return Dn(e,t)}const ln=[];function so(e){const t=i.useRef(e),n=ot(r=>e?r&&r!==ln&&e&&t.current&&e.parentNode===t.current.parentNode?r:mt(e):ln,[e]);return i.useEffect(()=>{t.current=e},[e]),n}function io(e){const[t,n]=i.useState(null),r=i.useRef(e),o=i.useCallback(a=>{const s=Ct(a.target);s&&n(l=>l?(l.set(s,Tt(s)),new Map(l)):null)},[]);return i.useEffect(()=>{const a=r.current;if(e!==a){s(a);const l=e.map(c=>{const u=Ct(c);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,Tt(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=Ct(c);u?.removeEventListener("scroll",o)})}},[o,e]),i.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,s)=>_e(a,s),de):Mn(e):de,[e,t])}function cn(e,t){t===void 0&&(t=[]);const n=i.useRef(null);return i.useEffect(()=>{n.current=null},t),i.useEffect(()=>{const r=e!==de;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?et(e,n.current):de}function lo(e){i.useEffect(()=>{if(!bt)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 co(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?Tr(e):null,[e])}const dn=[];function uo(e,t){t===void 0&&(t=$e);const[n]=e,r=Ln(n?G(n):null),[o,a]=i.useState(dn);function s(){a(()=>e.length?e.map(c=>jn(c)?r:new Ft(t(c),c)):dn)}const l=xt({callback:s});return xe(()=>{l?.disconnect(),s(),e.forEach(c=>l?.observe(c))},[e]),o}function fo(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return rt(t)?t:e}function go(e){let{measure:t}=e;const[n,r]=i.useState(null),o=i.useCallback(u=>{for(const{target:g}of u)if(rt(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=fo(u);a?.disconnect(),g&&a?.observe(g),r(g?t(g):null)},[t,a]),[l,c]=ft(s);return i.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const ho=[{sensor:Yt,options:{}},{sensor:Ut,options:{}}],po={current:{}},dt={draggable:{measure:tn},droppable:{measure:tn,strategy:nt.WhileDragging,frequency:Ot.Optimized},dragOverlay:{measure:$e}};class Qe 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 bo={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Qe,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:gt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:dt,measureDroppableContainers:gt,windowRect:null,measuringScheduled:!1},mo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:gt,draggableNodes:new Map,over:null,measureDroppableContainers:gt},vt=i.createContext(mo),On=i.createContext(bo);function xo(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Qe}}}function vo(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 Qe(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 Qe(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 Qe(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function yo(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=i.useContext(vt),a=Mt(r),s=Mt(n?.id);return i.useEffect(()=>{if(!t&&!r&&a&&s!=null){if(!$t(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=ur(g);if(f){f.focus();break}}})}},[r,t,o,s,a]),null}function wo(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,a)=>a({transform:o,...r}),n):n}function ko(e){return i.useMemo(()=>({draggable:{...dt.draggable,...e?.draggable},droppable:{...dt.droppable,...e?.droppable},dragOverlay:{...dt.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function So(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;xe(()=>{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=Dn(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=Rn(u);b&&b.scrollBy({top:f.y,left:f.x})}},[t,s,l,r,n])}const _n=i.createContext({...de,scaleX:1,scaleY:1});var Ee;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ee||(Ee={}));const Co=i.memo(function(t){var n,r,o,a;let{id:s,accessibility:l,autoScroll:c=!0,children:u,sensors:g=ho,collisionDetection:f=Rr,measuring:b,modifiers:h,...w}=t;const m=i.useReducer(vo,void 0,xo),[x,v]=m,[k,y]=mr(),[C,N]=i.useState(Ee.Uninitialized),j=C===Ee.Initialized,{draggable:{active:S,nodes:D,translate:T},droppable:{containers:L}}=x,I=S!=null?D.get(S):null,H=i.useRef({initial:null,translated:null}),O=i.useMemo(()=>{var X;return S!=null?{id:S,data:(X=I?.data)!=null?X:po,rect:H}:null},[S,I]),K=i.useRef(null),[ke,Te]=i.useState(null),[F,je]=i.useState(null),te=Ze(w,Object.values(w)),Se=at("DndDescribedBy",s),q=i.useMemo(()=>L.getEnabled(),[L]),U=ko(b),{droppableRects:se,measureDroppableContainers:ue,measuringScheduled:Y}=to(q,{dragging:j,dependencies:[T.x,T.y],config:U.droppable}),z=Zr(D,S),ne=i.useMemo(()=>F?It(F):null,[F]),fe=Gn(),re=no(z,U.draggable.measure);So({activeNode:S!=null?D.get(S):null,config:fe.layoutShiftCompensation,initialRect:re,measure:U.draggable.measure});const A=sn(z,U.draggable.measure,re),Ce=sn(z?z.parentElement:null),J=i.useRef({activatorEvent:null,active:null,activeNode:z,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:L,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ge=L.getNodeFor((n=J.current.over)==null?void 0:n.id),ie=go({measure:U.dragOverlay.measure}),ve=(r=ie.nodeRef.current)!=null?r:z,ye=j?(o=ie.rect)!=null?o:A:null,Fe=!!(ie.nodeRef.current&&ie.rect),Ue=ao(Fe?null:A),Ae=Ln(ve?G(ve):null),he=so(j?ge??z:null),Le=uo(he),Me=wo(h,{transform:{x:T.x-Ue.x,y:T.y-Ue.y,scaleX:1,scaleY:1},activatorEvent:F,active:O,activeNodeRect:A,containerNodeRect:Ce,draggingNodeRect:ye,over:J.current.over,overlayNodeRect:ie.rect,scrollableAncestors:he,scrollableAncestorRects:Le,windowRect:Ae}),Xe=ne?_e(ne,T):null,st=io(he),Ie=cn(st),Ye=cn(st,[A]),p=_e(Me,Ie),E=ye?jr(ye,Me):null,W=O&&E?f({active:O,collisionRect:E,droppableRects:se,droppableContainers:q,pointerCoordinates:Xe}):null,We=Cn(W,"id"),[pe,le]=i.useState(null),Wt=Fe?Me:_e(Me,Ye),Wn=Nr(Wt,(a=pe?.rect)!=null?a:null,A),yt=i.useRef(null),Ht=i.useCallback((X,Q)=>{let{sensor:Z,options:De}=Q;if(K.current==null)return;const oe=D.get(K.current);if(!oe)return;const ee=X.nativeEvent,be=new Z({active:K.current,activeNode:oe,event:ee,options:De,context:J,onAbort($){if(!D.get($))return;const{onDragAbort:me}=te.current,we={id:$};me?.(we),k({type:"onDragAbort",event:we})},onPending($,Re,me,we){if(!D.get($))return;const{onDragPending:Ke}=te.current,Ne={id:$,constraint:Re,initialCoordinates:me,offset:we};Ke?.(Ne),k({type:"onDragPending",event:Ne})},onStart($){const Re=K.current;if(Re==null)return;const me=D.get(Re);if(!me)return;const{onDragStart:we}=te.current,He={activatorEvent:ee,active:{id:Re,data:me.data,rect:H}};Ge.unstable_batchedUpdates(()=>{we?.(He),N(Ee.Initializing),v({type:P.DragStart,initialCoordinates:$,active:Re}),k({type:"onDragStart",event:He}),Te(yt.current),je(ee)})},onMove($){v({type:P.DragMove,coordinates:$})},onEnd:Oe(P.DragEnd),onCancel:Oe(P.DragCancel)});yt.current=be;function Oe($){return async function(){const{active:me,collisions:we,over:He,scrollAdjustedTranslate:Ke}=J.current;let Ne=null;if(me&&Ke){const{cancelDrop:Ve}=te.current;Ne={activatorEvent:ee,active:me,collisions:we,delta:Ke,over:He},$===P.DragEnd&&typeof Ve=="function"&&await Promise.resolve(Ve(Ne))&&($=P.DragCancel)}K.current=null,Ge.unstable_batchedUpdates(()=>{v({type:$}),N(Ee.Uninitialized),le(null),Te(null),je(null),yt.current=null;const Ve=$===P.DragEnd?"onDragEnd":"onDragCancel";if(Ne){const wt=te.current[Ve];wt?.(Ne),k({type:Ve,event:Ne})}})}}},[D]),Hn=i.useCallback((X,Q)=>(Z,De)=>{const oe=Z.nativeEvent,ee=D.get(De);if(K.current!==null||!ee||oe.dndKit||oe.defaultPrevented)return;const be={active:ee};X(Z,Q.options,be)===!0&&(oe.dndKit={capturedBy:Q.sensor},K.current=De,Ht(Z,Q))},[D,Ht]),Kt=eo(g,Hn);lo(g),xe(()=>{A&&C===Ee.Initializing&&N(Ee.Initialized)},[A,C]),i.useEffect(()=>{const{onDragMove:X}=te.current,{active:Q,activatorEvent:Z,collisions:De,over:oe}=J.current;if(!Q||!Z)return;const ee={active:Q,activatorEvent:Z,collisions:De,delta:{x:p.x,y:p.y},over:oe};Ge.unstable_batchedUpdates(()=>{X?.(ee),k({type:"onDragMove",event:ee})})},[p.x,p.y]),i.useEffect(()=>{const{active:X,activatorEvent:Q,collisions:Z,droppableContainers:De,scrollAdjustedTranslate:oe}=J.current;if(!X||K.current==null||!Q||!oe)return;const{onDragOver:ee}=te.current,be=De.get(We),Oe=be&&be.rect.current?{id:be.id,rect:be.rect.current,data:be.data,disabled:be.disabled}:null,$={active:X,activatorEvent:Q,collisions:Z,delta:{x:oe.x,y:oe.y},over:Oe};Ge.unstable_batchedUpdates(()=>{le(Oe),ee?.($),k({type:"onDragOver",event:$})})},[We]),xe(()=>{J.current={activatorEvent:F,active:O,activeNode:z,collisionRect:E,collisions:W,droppableRects:se,draggableNodes:D,draggingNode:ve,draggingNodeRect:ye,droppableContainers:L,over:pe,scrollableAncestors:he,scrollAdjustedTranslate:p},H.current={initial:ye,translated:E}},[O,z,W,E,D,ve,ye,se,L,pe,he,p]),qr({...fe,delta:T,draggingRect:E,pointerCoordinates:Xe,scrollableAncestors:he,scrollableAncestorRects:Le});const Kn=i.useMemo(()=>({active:O,activeNode:z,activeNodeRect:A,activatorEvent:F,collisions:W,containerNodeRect:Ce,dragOverlay:ie,draggableNodes:D,droppableContainers:L,droppableRects:se,over:pe,measureDroppableContainers:ue,scrollableAncestors:he,scrollableAncestorRects:Le,measuringConfiguration:U,measuringScheduled:Y,windowRect:Ae}),[O,z,A,F,W,Ce,ie,D,L,se,pe,ue,he,Le,U,Y,Ae]),Vn=i.useMemo(()=>({activatorEvent:F,activators:Kt,active:O,activeNodeRect:A,ariaDescribedById:{draggable:Se},dispatch:v,draggableNodes:D,over:pe,measureDroppableContainers:ue}),[F,Kt,O,A,v,Se,D,pe,ue]);return V.createElement(wn.Provider,{value:y},V.createElement(vt.Provider,{value:Vn},V.createElement(On.Provider,{value:Kn},V.createElement(_n.Provider,{value:Wn},u)),V.createElement(yo,{disabled:l?.restoreFocus===!1})),V.createElement(yr,{...l,hiddenTextDescribedById:Se}));function Gn(){const X=ke?.autoScrollEnabled===!1,Q=typeof c=="object"?c.enabled===!1:c===!1,Z=j&&!X&&!Q;return typeof c=="object"?{...c,enabled:Z}:{enabled:Z}}}),Do=i.createContext(null),un="button",Ro="Draggable";function No(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const a=at(Ro),{activators:s,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:g,draggableNodes:f,over:b}=i.useContext(vt),{role:h=un,roleDescription:w="draggable",tabIndex:m=0}=o??{},x=c?.id===t,v=i.useContext(x?_n:Do),[k,y]=ft(),[C,N]=ft(),j=co(s,t),S=Ze(n);xe(()=>(f.set(t,{id:t,key:a,node:k,activatorNode:C,data:S}),()=>{const T=f.get(t);T&&T.key===a&&f.delete(t)}),[f,t]);const D=i.useMemo(()=>({role:h,tabIndex:m,"aria-disabled":r,"aria-pressed":x&&h===un?!0:void 0,"aria-roledescription":w,"aria-describedby":g.draggable}),[r,h,m,x,w,g.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:D,isDragging:x,listeners:r?void 0:j,node:k,over:b,setNodeRef:y,setActivatorNodeRef:N,transform:v}}function Eo(){return i.useContext(On)}const jo="Droppable",Ao={timeout:25};function Mo(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const a=at(jo),{active:s,dispatch:l,over:c,measureDroppableContainers:u}=i.useContext(vt),g=i.useRef({disabled:n}),f=i.useRef(!1),b=i.useRef(null),h=i.useRef(null),{disabled:w,updateMeasurementsFor:m,timeout:x}={...Ao,...o},v=Ze(m??r),k=i.useCallback(()=>{if(!f.current){f.current=!0;return}h.current!=null&&clearTimeout(h.current),h.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),h.current=null},x)},[x]),y=xt({callback:k,disabled:w||!s}),C=i.useCallback((D,T)=>{y&&(T&&(y.unobserve(T),f.current=!1),D&&y.observe(D))},[y]),[N,j]=ft(C),S=Ze(t);return i.useEffect(()=>{!y||!N.current||(y.disconnect(),f.current=!1,y.observe(N.current))},[N,y]),i.useEffect(()=>(l({type:P.RegisterDroppable,element:{id:r,key:a,disabled:n,node:N,rect:b,data:S}}),()=>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:N,over:c,setNodeRef:j}}const Io=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 To(e,t){return e.reduce((n,r,o)=>{const a=t.get(r);return a&&(n[o]=a),n},Array(e.length))}function it(e){return e!==null&&e>=0}function Lo(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 Oo(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const lt={scaleX:1,scaleY:1},_o=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=Po(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,...lt}:null}return s>o&&s<=a?{x:-l.width-c,y:0,...lt}:s<o&&s>=a?{x:l.width+c,y:0,...lt}:{x:0,y:0,...lt}};function Po(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=V.createContext({activeIndex:-1,containerId:zn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Bn,disabled:{draggable:!1,droppable:!1}});function Bo(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}=Eo(),f=at(zn,n),b=l.rect!==null,h=i.useMemo(()=>r.map(j=>typeof j=="object"&&"id"in j?j.id:j),[r]),w=s!=null,m=s?h.indexOf(s.id):-1,x=u?h.indexOf(u.id):-1,v=i.useRef(h),k=!Lo(h,v.current),y=x!==-1&&m===-1||k,C=Oo(a);xe(()=>{k&&w&&g(h)},[k,h,w,g]),i.useEffect(()=>{v.current=h},[h]);const N=i.useMemo(()=>({activeIndex:m,containerId:f,disabled:C,disableTransforms:y,items:h,overIndex:x,useDragOverlay:b,sortedRects:To(h,c),strategy:o}),[m,f,C.draggable,C.droppable,y,h,x,c,b,o]);return V.createElement($n.Provider,{value:N},t)}const zo=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Pn(n,r,o).indexOf(t)},$o=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},Fo={duration:200,easing:"ease"},Fn="transform",Uo=tt.Transition.toString({property:Fn,duration:0,easing:"linear"}),Xo={roleDescription:"sortable"};function Yo(e){let{disabled:t,index:n,node:r,rect:o}=e;const[a,s]=i.useState(null),l=i.useRef(n);return xe(()=>{if(!t&&n!==l.current&&r.current){const c=o.current;if(c){const u=$e(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 Wo(e){let{animateLayoutChanges:t=$o,attributes:n,disabled:r,data:o,getNewIndex:a=zo,id:s,strategy:l,resizeObserverConfig:c,transition:u=Fo}=e;const{items:g,containerId:f,activeIndex:b,disabled:h,disableTransforms:w,sortedRects:m,overIndex:x,useDragOverlay:v,strategy:k}=i.useContext($n),y=Ho(r,h),C=g.indexOf(s),N=i.useMemo(()=>({sortable:{containerId:f,index:C,items:g},...o}),[f,o,C,g]),j=i.useMemo(()=>g.slice(g.indexOf(s)),[g,s]),{rect:S,node:D,isOver:T,setNodeRef:L}=Mo({id:s,data:N,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:j,...c}}),{active:I,activatorEvent:H,activeNodeRect:O,attributes:K,setNodeRef:ke,listeners:Te,isDragging:F,over:je,setActivatorNodeRef:te,transform:Se}=No({id:s,data:N,attributes:{...Xo,...n},disabled:y.draggable}),q=ir(L,ke),U=!!I,se=U&&!w&&it(b)&&it(x),ue=!v&&F,Y=ue&&se?Se:null,ne=se?Y??(l??k)({rects:m,activeNodeRect:O,activeIndex:b,overIndex:x,index:C}):null,fe=it(b)&&it(x)?a({id:s,items:g,activeIndex:b,overIndex:x}):C,re=I?.id,A=i.useRef({activeId:re,items:g,newIndex:fe,containerId:f}),Ce=g!==A.current.items,J=t({active:I,containerId:f,isDragging:F,isSorting:U,id:s,index:C,items:g,newIndex:A.current.newIndex,previousItems:A.current.items,previousContainerId:A.current.containerId,transition:u,wasDragging:A.current.activeId!=null}),ge=Yo({disabled:!J,index:C,node:D,rect:S});return i.useEffect(()=>{U&&A.current.newIndex!==fe&&(A.current.newIndex=fe),f!==A.current.containerId&&(A.current.containerId=f),g!==A.current.items&&(A.current.items=g)},[U,fe,f,g]),i.useEffect(()=>{if(re===A.current.activeId)return;if(re&&!A.current.activeId){A.current.activeId=re;return}const ve=setTimeout(()=>{A.current.activeId=re},50);return()=>clearTimeout(ve)},[re]),{active:I,activeIndex:b,attributes:K,data:N,rect:S,index:C,newIndex:fe,items:g,isOver:T,isSorting:U,isDragging:F,listeners:Te,node:D,overIndex:x,over:je,setNodeRef:q,setActivatorNodeRef:te,setDroppableNodeRef:L,setDraggableNodeRef:ke,transform:ge??ne,transition:ie()};function ie(){if(ge||Ce&&A.current.newIndex===C)return Uo;if(!(ue&&!$t(H)||!u)&&(U||J))return tt.Transition.toString({...u,property:Fn})}}function Ho(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 pt(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 Ko=[R.Down,R.Right,R.Up,R.Left],Vo=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:a,over:s,scrollableAncestors:l}}=t;if(Ko.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 R.Down:r.top<b.top&&c.push(f);break;case R.Up:r.top>b.top&&c.push(f);break;case R.Left:r.left>b.left&&c.push(f);break;case R.Right:r.left<b.left&&c.push(f);break}});const u=Cr({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,w=b?.node.current;if(w&&h&&f&&b){const x=mt(w).some((j,S)=>l[S]!==j),v=Un(f,b),k=Go(f,b),y=x||!v?{x:0,y:0}:{x:k?r.width-h.width:0,y:k?r.height-h.height:0},C={x:h.left,y:h.top};return y.x&&y.y?C:et(C,y)}}}};function Un(e,t){return!pt(e)||!pt(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Go(e,t){return!pt(e)||!pt(t)||!Un(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Pe(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 qo(e,t){const n=Pe(t,{min:0,max:1e6,fallback:0}),r=Pe(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 Jo({page:e,totalPages:t}){const n=typeof t=="number"&&Number.isFinite(t)&&t>=0,r=n?Pe(t,{min:0,max:1e6,fallback:0}):null,o=Pe(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 Qo({entries:e,me:t,meLabel:n,limit:r}){const o=Pe(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",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,w)=>w!==u).slice();return b.splice(Math.min(g,b.length),0,c),b.slice(0,o)}function ce({className:e}){return d.jsx("div",{className:_("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",e)})}function Zo({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:_(jt(!1),"!group-hover:bg-transparent"),children:d.jsx(ce,{className:"h-4 w-6"})}),d.jsx("td",{className:_(At(!1),"!group-hover:bg-transparent"),children:d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx(ce,{className:"h-8 w-8 min-w-8 rounded-full"}),d.jsx(ce,{className:_("h-4",t)})]})}),d.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:d.jsx(ce,{className:_("h-4",n)})}),d.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:d.jsx(ce,{className:"h-4 w-12"})}),ut.map(o=>d.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:d.jsx(ce,{className:_("h-4",r)})},o.key))]})}function ea({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:_(mn,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:d.jsx(ce,{className:"h-3.5 w-6"})}),d.jsx("th",{className:_(xn,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:d.jsx(ce,{className:"h-3.5 w-12"})}),d.jsx("th",{className:"px-4 py-4",children:d.jsx(ce,{className:"h-3.5 w-10"})}),d.jsx("th",{className:"px-4 py-4",children:d.jsx(ce,{className:"h-3.5 w-14"})}),ut.map(t=>d.jsx("th",{className:"px-4 py-4",children:d.jsx(ce,{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(Zo,{index:n},n))})]})})}function ta({id:e,thClassName:t,children:n}){const{attributes:r,listeners:o,setNodeRef:a,transform:s,transition:l,isDragging:c}=Wo({id:e}),u=tt.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:_(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:_("-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 Xn="tokentracker.leaderboard.columnOrder.v1";function na(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Xn);if(!e)return null;const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):null}catch{return null}}function Nt(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Xn,JSON.stringify(e))}catch{}}function fn(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 ra(e){const t=i.useMemo(()=>e.join("|"),[e]),[n,r]=i.useState(()=>fn(na(),e));i.useEffect(()=>{r(s=>{const l=fn(s,e);return l.length===s.length&&l.every((u,g)=>u===s[g])?s:(Nt(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),Nt(f),f})},[]),a=i.useCallback(()=>{Nt(e),r(e)},[e]);return{order:n,reorder:o,reset:a}}const ct=20;function gn(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 hn(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:_("px-4 py-4 whitespace-nowrap text-right tabular-nums",r,o),children:Et(e?.[a.key])},a.key))}const oa={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 pn({rank:e,placeholder:t}){const n=oa[e];return n?d.jsx("span",{className:_("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 _t(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="week"||t==="month"||t==="total"?t:null}function aa(e){if(!e)return M("shared.error.prefix",{error:M("leaderboard.error.unknown")});const t=e?.message||String(e),n=String(t||"").trim()||M("leaderboard.error.unknown");return M("shared.error.prefix",{error:n})}function Yn(e){return typeof e!="string"?"":e.trim()}function sa(e){const t=Yn(e);return t?t.toLowerCase()==="anonymous":!0}function ia(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=_t(r.get("period")),a=o?`?period=${o}`:"";return`/share/pv1-${n}${a}`}function bn(e,t){const n=typeof e?.user_id=="string"?e.user_id.trim():"";return n||`${e?.rank??""}:${t}`}function da({auth:e,signedIn:t,sessionSoftExpired:n}){const r=qn(),o=Jn(),{openLoginModal:a}=Qn(),{signedIn:s,loading:l,user:c}=Zn(),u=i.useMemo(()=>er(),[]),g=tr(),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,w=f&&nr(h),m=M("shared.placeholder.short"),x=i.useMemo(()=>ut.map(p=>p.key),[]),{order:v,reorder:k,reset:y}=ra(x),C=i.useMemo(()=>{const p=new Map;for(const E of ut)p.set(E.key,E);return p},[]),N=i.useMemo(()=>v.map(p=>C.get(p)).filter(Boolean),[v,C]),j=i.useMemo(()=>v.every((p,E)=>p===x[E]),[v,x]),S=wr(Qt(Yt,{activationConstraint:{distance:6}}),Qt(Ut,{coordinateGetter:Vo})),D=i.useCallback(p=>{const{active:E,over:W}=p;!W||E.id===W.id||k(String(E.id),String(W.id))},[k]),[T,L]=i.useState(1),[I,H]=i.useState(0),[O,K]=i.useState(()=>({loading:!1,error:null,data:null})),[ke,Te]=i.useState(()=>rr()),[F,je]=i.useState(!1),[te,Se]=i.useState(!1),q=i.useMemo(()=>{const p=new URLSearchParams(r?.search||"");return _t(p.get("period"))||"total"},[r?.search]),U=r?.search||"",se=p=>{const E=_t(p);if(!E||E===q)return;const W=new URLSearchParams(r?.search||"");W.set("period",E),L(1),o(`${r?.pathname||"/leaderboard"}?${W.toString()}`,{replace:!0})};i.useEffect(()=>{l||g||s||a()},[s,l,g,a]),i.useEffect(()=>{L(1)},[q]);const ue=i.useMemo(()=>(Pe(T,{min:1,max:1e6,fallback:1})-1)*ct,[T]);i.useEffect(()=>{if(!u&&!g)return;let p=!0;return K(E=>({...E,loading:!0,error:null})),(async()=>{const E=await or({userId:c?.id||null,period:q,limit:ct,offset:ue});p&&K({loading:!1,error:null,data:E})})().catch(E=>{p&&K({loading:!1,error:aa(E),data:null})}),()=>{p=!1}},[u,c?.id,ue,I,g,q]);const Y=O.data,z=Y?.total_pages??null,ne=Y?.page??T,fe=i.useMemo(()=>qo(ne,z),[ne,z]),re=Y?.from||null,A=Y?.to||null,Ce=Y?.generated_at||null,J=Y?.me||null,ge=M("leaderboard.me_label"),ie=M("leaderboard.anon_label"),ve=M("leaderboard.period.week"),ye=M("leaderboard.period.month"),Fe=M("leaderboard.period.total"),Ue=q==="month"?ye:q==="total"?Fe:ve,Ae=i.useMemo(()=>{const p=Array.isArray(Y?.entries)?Y.entries:[];return ne!==1?p:Qo({entries:p,me:J,meLabel:ge,limit:ct})},[ne,Y?.entries,J,ge]),he=async()=>{je(!0);try{ar(!0),Te(!0),await Vt(()=>kt(h));const p=await kt(h);p&&await Gt({accessToken:p}),H(E=>E+1)}catch(p){console.warn("[tokentracker] sync:",p)}finally{je(!1)}},Le=async()=>{Se(!0);try{const p=await kt(h);ke&&p&&await Vt(()=>Promise.resolve(p)),p&&await Gt({accessToken:p}),H(E=>E+1)}catch(p){console.warn("[tokentracker] refresh:",p)}finally{Se(!1)}},{canPrev:Me,canNext:Xe}=Jo({page:ne,totalPages:z}),st=Array.isArray(Ae)&&Ae.length!==0;let Ie=null;O.loading?Ie=d.jsx(ea,{rows:ct}):O.error?Ie=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:O.error})}):st?Ie=d.jsx(Co,{sensors:S,collisionDetection:Sr,modifiers:[Io],onDragEnd:D,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:_(mn,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:M("leaderboard.column.rank")}),d.jsx("th",{className:_(xn,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:M("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:M("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(Bo,{items:v,strategy:_o,children:N.map(p=>d.jsx(ta,{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(sr,{iconSrc:p.icon,label:M(p.copyKey)})},p.key))})]})}),d.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Ae.map(p=>{const E=!!p?.is_me,W=typeof p?.user_id=="string"?p.user_id:null,We=Yn(p?.display_name),pe=sa(We)?ie:We,le=E?ge:pe;return!!W&&!E&&!!p?.is_public&&ia(W,U),E?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:_(jt(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400"),children:d.jsx(pn,{rank:p?.rank,placeholder:m})}),d.jsx("td",{className:At(!0),children:d.jsxs("div",{className:"flex min-w-0 max-w-[min(160px,40vw)] items-center gap-4",children:[d.jsx(qt,{avatarUrl:p?.avatar_url,displayName:le,seed:bn(p,le)}),d.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:le})]})}),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:Et(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:gn(p?.estimated_cost_usd)}),hn(p,!0,N)]},`row-${p?.rank}-${le}`):d.jsxs("tr",{className:"group transition-colors",children:[d.jsx("td",{className:_(jt(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:d.jsx(pn,{rank:p?.rank,placeholder:m})}),d.jsx("td",{className:At(!1),children:d.jsxs("div",{className:"flex min-w-0 max-w-[min(160px,40vw)] items-center gap-4",children:[d.jsx(qt,{avatarUrl:p?.avatar_url,displayName:le,seed:bn(p,le)}),d.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:le})]})}),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:Et(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:gn(p?.estimated_cost_usd)}),hn(p,!1,N)]},`row-${p?.rank}-${le}`)})})]})})}):Ie=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:M("leaderboard.empty")})});let Ye=null;return typeof z=="number"?Ye=fe.map((p,E)=>p==null?d.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:M("leaderboard.pagination.ellipsis")},`ellipsis-${E}`):d.jsx("button",{className:_("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",p===ne?"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:()=>L(p),disabled:O.loading,children:String(p)},`page-${p}`)):Ye=d.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:M("leaderboard.pagination.page_unknown",{page:String(ne)})}),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:M("leaderboard.title")}),d.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[q==="total"?M("leaderboard.range.total"):re&&A?M("leaderboard.range",{period:Ue,from:re,to:A}):M("leaderboard.range_loading",{period:Ue}),Ce&&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:M("leaderboard.generated_at",{ts:Ce})})]})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[!j&&d.jsx("button",{onClick:y,title:M("leaderboard.columns.reset_hint"),className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white transition-colors",children:M("leaderboard.columns.reset")}),f&&w&&d.jsx("button",{onClick:Le,disabled:te||O.loading,className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white transition-colors disabled:opacity-50",children:te?"Refreshing...":"↻"}),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:()=>se(p),disabled:O.loading,className:_("px-4 py-1.5 text-sm font-medium rounded-md transition-colors",q===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"?ve:p==="month"?ye:Fe},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&&w&&!ke&&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:he,disabled:F,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:F?"Syncing...":"Enable & Sync"})]}),d.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:[Ie,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:_("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",Me&&!O.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:()=>L(p=>Math.max(1,p-1)),disabled:!Me||O.loading,children:M("leaderboard.pagination.prev")}),d.jsx("button",{className:_("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",Xe&&!O.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:()=>L(p=>p+1),disabled:!Xe||O.loading,children:M("leaderboard.pagination.next")})]}),d.jsx("div",{className:"flex flex-wrap items-center gap-1",children:Ye})]})]})]})}),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:M("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:M("landing.v2.nav.github")})]})})]})}export{da as LeaderboardPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{D as r,az as g,B as x,a9 as y,aL as _}from"./main-DDaoGWcU.js";import{u as j}from"./use-usage-limits-BLkA4tpF.js";import{u as b}from"./use-limits-display-prefs-DPtzcPRA.js";import{C as h}from"./Card-CzO2gq_D.js";import{F as v}from"./FadeIn-CTN2r1YX.js";const k=[3,2,3,3,2,3];function o({className:s}){return r.jsx("div",{className:g("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",s)})}function N(){return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(o,{className:"h-3 w-12 shrink-0"}),r.jsx(o,{className:"flex-1 h-1.5 rounded-full min-w-0"}),r.jsx(o,{className:"h-3 w-[30px] shrink-0"}),r.jsx(o,{className:"h-3 w-6 shrink-0"})]})}function L({bars:s,index:e}){const a=e%3===0?"w-24":e%3===1?"w-20":"w-[4.5rem]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(o,{className:"h-[14px] w-[14px] rounded shrink-0"}),r.jsx(o,{className:g("h-4",a)})]}),Array.from({length:s},(i,l)=>r.jsx(N,{},l))]})}function P(){return r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(o,{className:"h-3.5 w-28"}),k.map((s,e)=>r.jsx(L,{bars:s,index:e},e))]})})}function n(s){if(!s)return null;const e=typeof s=="number"?s*1e3:Date.parse(s);if(!Number.isFinite(e))return null;const a=e-Date.now();if(a<=0)return"now";const i=Math.floor(a/6e4);if(i<60)return`${i}m`;const l=Math.floor(i/60);return l<24?`${l}h`:`${Math.floor(l/24)}d`}function C(s){return s>=90?"bg-red-500":s>=70?"bg-amber-500":"bg-emerald-500"}function t({label:s,pct:e,reset:a}){const i=Math.max(0,Math.min(100,Number(e)||0)),l=Math.round(i),m=i>0&&l===0?Math.max(i,.35):i,d=i>0&&l===0?"<1":String(l);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 w-12 shrink-0",children:s}),r.jsx("div",{className:"flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:r.jsx("div",{className:`${C(l)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${m}%`,minWidth:i>0?"3px":0}})}),r.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-[30px] text-right shrink-0",children:[d,"%"]}),a?r.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:a}):null]})}function c({name:s,icon:e,children:a}){const l=e==="/brand-logos/cursor.svg"||e==="/brand-logos/kiro.svg"?"w-[14px] h-[14px] dark:invert":"w-[14px] h-[14px]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[e?r.jsx("img",{src:e,alt:"",className:l}):null,r.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:s})]}),a]})}const R=["claude","codex","cursor","gemini","kiro","antigravity"];function A(s,e){if(!(i=>i?.configured&&!i.error)(e))return null;switch(s){case"claude":return r.jsxs(c,{name:"Claude",icon:"/brand-logos/claude-code.svg",children:[e.five_hour?r.jsx(t,{label:"5h",pct:e.five_hour.utilization,reset:n(e.five_hour.resets_at)}):null,e.seven_day?r.jsx(t,{label:"7d",pct:e.seven_day.utilization,reset:n(e.seven_day.resets_at)}):null,e.seven_day_opus?r.jsx(t,{label:"Opus",pct:e.seven_day_opus.utilization,reset:n(e.seven_day_opus.resets_at)}):null]},"claude");case"codex":return r.jsxs(c,{name:"Codex",icon:"/brand-logos/codex.svg",children:[e.primary_window?r.jsx(t,{label:"5h",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"7d",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null]},"codex");case"cursor":return r.jsxs(c,{name:"Cursor",icon:"/brand-logos/cursor.svg",children:[e.primary_window?r.jsx(t,{label:"Plan",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"Auto",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(t,{label:"API",pct:e.tertiary_window.used_percent,reset:n(e.tertiary_window.reset_at)}):null]},"cursor");case"gemini":return r.jsxs(c,{name:"Gemini",icon:"/brand-logos/gemini.svg",children:[e.primary_window?r.jsx(t,{label:"Pro",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"Flash",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(t,{label:"Lite",pct:e.tertiary_window.used_percent,reset:n(e.tertiary_window.reset_at)}):null]},"gemini");case"kiro":return r.jsxs(c,{name:"Kiro",icon:"/brand-logos/kiro.svg",children:[e.primary_window?r.jsx(t,{label:"Month",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"Bonus",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null]},"kiro");case"antigravity":return r.jsxs(c,{name:"Antigravity",icon:"/brand-logos/antigravity.svg",children:[e.primary_window?r.jsx(t,{label:"Claude",pct:e.primary_window.used_percent,reset:n(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(t,{label:"G Pro",pct:e.secondary_window.used_percent,reset:n(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(t,{label:"Flash",pct:e.tertiary_window.used_percent,reset:n(e.tertiary_window.reset_at)}):null]},"antigravity");default:return null}}function B({claude:s,codex:e,cursor:a,gemini:i,kiro:l,antigravity:m,order:d,visibility:w}){const f={claude:s,codex:e,cursor:a,gemini:i,kiro:l,antigravity:m},p=(Array.isArray(d)&&d.length>0?d:R).filter(u=>!w||w[u]!==!1).map(u=>A(u,f[u])).filter(Boolean);return p.length===0?null:r.jsx(v,{delay:.15,children:r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:"Usage Limits"}),p]})})})}function z(){const{data:s,error:e,isLoading:a}=j({initialRefresh:!0}),i=b();return r.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:r.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:r.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[r.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:x("nav.limits")}),r.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:x("limits.page.subtitle")})]}),r.jsx(y,{to:"/settings","aria-label":x("limits.page.openSettings"),title:x("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:r.jsx(_,{className:"h-4 w-4","aria-hidden":!0})})]}),a?r.jsx(P,{}):r.jsxs(r.Fragment,{children:[e?r.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:x("shared.error.prefix",{error:e})}):null,r.jsx(B,{claude:s?.claude,codex:s?.codex,cursor:s?.cursor,gemini:s?.gemini,kiro:s?.kiro,antigravity:s?.antigravity,order:i.order,visibility:i.visibility})]})]})})})}export{z as LimitsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ad as l,D as n,az as i}from"./main-DDaoGWcU.js";function y(r){let e=0;const o=String(r??"");for(let a=0;a<o.length;a+=1)e=Math.imul(31,e)+o.charCodeAt(a)|0;return Math.abs(e)%360}function m(r){const e=String(r??"").trim();if(!e)return"?";const o=e.split(/\s+/).filter(Boolean);if(o.length>=2){const a=o[0][0]||"",t=o[1][0]||"";return`${a}${t}`.toUpperCase()}return e.slice(0,2).toUpperCase()}const g={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"};function k({avatarUrl:r,displayName:e,seed:o,size:a="md",className:t}){const d=g[a]||g.md,b=y(o??e??""),s=typeof r=="string"?r.trim():"",[p,c]=l.useState(!1);return l.useEffect(()=>{c(!1)},[s]),s&&!p?n.jsx("img",{src:s,alt:"",referrerPolicy:"no-referrer",onError:()=>c(!0),className:i("rounded-full object-cover ring-1 ring-white/10",d,t)}):n.jsx("div",{className:i("flex shrink-0 items-center justify-center rounded-full font-semibold text-white ring-1 ring-white/10",d,t),style:{backgroundColor:`hsl(${b} 42% 34%)`},"aria-hidden":!0,children:m(e)})}function h({iconSrc:r,label:e}){return n.jsxs("span",{className:"inline-flex items-center gap-3",children:[r?n.jsx("img",{src:r,alt:"",width:16,height:16,className:`h-4 w-4 shrink-0 object-contain opacity-90 ${r==="/brand-logos/cursor.svg"?"dark:invert":""}`}):null,n.jsx("span",{className:"whitespace-nowrap",children:e})]})}const x=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"kiro_tokens",copyKey:"leaderboard.column.kiro",icon:"/brand-logos/kiro.svg"},{key:"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:null},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:null}],w="sticky left-0 z-40 w-[72px] min-w-[72px] max-w-[72px] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4 align-middle",f="sticky left-[72px] z-40 min-w-[140px] max-w-[min(180px,35vw)] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4 align-middle",_="sticky left-[72px] z-40 min-w-[6rem] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4";function v(r){return i("sticky left-0 z-30 w-[72px] min-w-[72px] max-w-[72px] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 whitespace-nowrap",r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function K(r){return i("sticky left-[72px] z-30 min-w-[140px] max-w-[min(180px,35vw)] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 min-w-0",r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function T(r){return i("sticky left-[72px] z-30 min-w-[6rem] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 whitespace-nowrap","bg-white dark:bg-oai-gray-950")}export{w as L,f as a,x as b,K as c,h as d,k as e,T as f,_ as g,v as l};
|