tokentracker-cli 0.96.3 → 0.96.4

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.
Files changed (97) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-BX4iBBYM.js → AchievementBadge-CCcvmz6R.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-DRYRuCbh.js → AchievementsPage-C5jdktOK.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-BM_JWWhJ.js → AchievementsSection-BFMtUzn1.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-DxoxXst2.js → BadgeDetailModal-Be8gM7tM.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-BVpFxG8u.js → BotAnimated-CXTGR71z.js} +1 -1
  6. package/dashboard/dist/assets/{Card-BJJs701t.js → Card-CsUsp3CV.js} +1 -1
  7. package/dashboard/dist/assets/{ClawdAnimated-46wPZ_Tc.js → ClawdAnimated-BEjpZjEE.js} +2 -2
  8. package/dashboard/dist/assets/{CommandPalette-B_zkc7IU.js → CommandPalette-CHc_Z1r8.js} +1 -1
  9. package/dashboard/dist/assets/{CommunityStatsModal-M2k5rIf1.js → CommunityStatsModal-Gs6kZ_Mp.js} +1 -1
  10. package/dashboard/dist/assets/{ConfirmModal-DBvOTcAQ.js → ConfirmModal-niHkpv2O.js} +1 -1
  11. package/dashboard/dist/assets/{Controls-BCkjPMSH.js → Controls-X2Z1UNUx.js} +1 -1
  12. package/dashboard/dist/assets/{DashboardPage-3bHhou09.js → DashboardPage-B66s3Exi.js} +1 -1
  13. package/dashboard/dist/assets/{DevicePage-DFBUce8C.js → DevicePage-DQdLdEI8.js} +1 -1
  14. package/dashboard/dist/assets/{DialogClose-kvDd8h3V.js → DialogClose-CCUjTxl8.js} +1 -1
  15. package/dashboard/dist/assets/DialogDescription-CjMjYG3N.js +1 -0
  16. package/dashboard/dist/assets/{DialogTitle-DL5nvD31.js → DialogTitle-CgkUGAag.js} +1 -1
  17. package/dashboard/dist/assets/{FadeIn-B-Bg6SEy.js → FadeIn-D4QD1bPo.js} +1 -1
  18. package/dashboard/dist/assets/{HeaderGithubStar-BExz0hh4.js → HeaderGithubStar-D0my-Z3a.js} +1 -1
  19. package/dashboard/dist/assets/{HoverTooltip-Dj5zemYT.js → HoverTooltip-nSWgrKlK.js} +1 -1
  20. package/dashboard/dist/assets/{IpCheckPage-DN7FuJ_v.js → IpCheckPage-4hfqHAgi.js} +1 -1
  21. package/dashboard/dist/assets/{LandingPage-9dKgSBRy.js → LandingPage-wIc4tVRI.js} +2 -2
  22. package/dashboard/dist/assets/{LeaderboardAvatar-00V95XIg.js → LeaderboardAvatar-DGlN8Vy8.js} +1 -1
  23. package/dashboard/dist/assets/{LeaderboardPage-DkKfUt0Z.js → LeaderboardPage-CybuzE87.js} +2 -2
  24. package/dashboard/dist/assets/{LeaderboardProfileModal-C9sIHBgN.js → LeaderboardProfileModal-D9la3tNd.js} +3 -3
  25. package/dashboard/dist/assets/{LeaderboardProfilePage-BAiLMsEb.js → LeaderboardProfilePage-gxXSeJYb.js} +1 -1
  26. package/dashboard/dist/assets/{LimitsPage-BuenTaHa.js → LimitsPage-CZH3G54Y.js} +1 -1
  27. package/dashboard/dist/assets/{LocalOnlyNotice-CKhY27Lr.js → LocalOnlyNotice-Ckc7zohC.js} +1 -1
  28. package/dashboard/dist/assets/{LoginCard-BbvoBx5N.js → LoginCard-BqeRHqWK.js} +1 -1
  29. package/dashboard/dist/assets/{LoginModal-P7zIkBhO.js → LoginModal-BjH6aIBG.js} +1 -1
  30. package/dashboard/dist/assets/{LoginPage-Bo0bR26x.js → LoginPage-BOyPLNU3.js} +1 -1
  31. package/dashboard/dist/assets/{PetPage-C6i9bSSl.js → PetPage-BXRXG40D.js} +1 -1
  32. package/dashboard/dist/assets/{PopoverPopup-h0gf36vg.js → PopoverPopup-Dad1ZYVd.js} +1 -1
  33. package/dashboard/dist/assets/{ProviderIcon-Dm8fwPdj.js → ProviderIcon-BDmrNJSl.js} +1 -1
  34. package/dashboard/dist/assets/{ResetPasswordPage-DvSJ8kg0.js → ResetPasswordPage-CZpE6qfa.js} +1 -1
  35. package/dashboard/dist/assets/{SegmentedControl-CP7oiGZE.js → SegmentedControl-CE1hrQFi.js} +1 -1
  36. package/dashboard/dist/assets/{Select-iwP92x9C.js → Select-YVj7u6Nv.js} +1 -1
  37. package/dashboard/dist/assets/{SelectItemText-DzljA15_.js → SelectItemText-BMYGgQ3o.js} +1 -1
  38. package/dashboard/dist/assets/{ServiceStatusPage-uD4D0Tid.js → ServiceStatusPage-HehjDbZg.js} +1 -1
  39. package/dashboard/dist/assets/{SessionsPage-Cmb1ssNP.js → SessionsPage-Chvu4YqZ.js} +1 -1
  40. package/dashboard/dist/assets/{SettingsPage-D8ryg1Pv.js → SettingsPage-BXjS7u9_.js} +2 -2
  41. package/dashboard/dist/assets/SkillsPage-q3Rjlj9h.js +1 -0
  42. package/dashboard/dist/assets/{TokenGalaxy-f2djrlUv.js → TokenGalaxy-BqZyj82r.js} +1 -1
  43. package/dashboard/dist/assets/{ToolbarRootContext-CDxCPYLv.js → ToolbarRootContext-Ch8ueI_C.js} +1 -1
  44. package/dashboard/dist/assets/{TrendMonitor-C419X22G.js → TrendMonitor-C2aTL9p1.js} +1 -1
  45. package/dashboard/dist/assets/{WidgetsPage-AYq__pOO.js → WidgetsPage-DYaIai8j.js} +1 -1
  46. package/dashboard/dist/assets/{WrappedPage-Bsm9k5XI.js → WrappedPage-51B0v-Sr.js} +1 -1
  47. package/dashboard/dist/assets/{__vite-browser-external-BDkeh90N.js → __vite-browser-external-Cp7dNuCm.js} +12 -12
  48. package/dashboard/dist/assets/{agent-logos-B6Vg-4_1.js → agent-logos-DXrPSAdX.js} +1 -1
  49. package/dashboard/dist/assets/{arrow-up-right-DIQXwaOD.js → arrow-up-right-BFkf7l0U.js} +1 -1
  50. package/dashboard/dist/assets/{check-CgD_bV39.js → check--N8wmgIJ.js} +1 -1
  51. package/dashboard/dist/assets/{composite-BIgEqWZD.js → composite-zF5Pj94e.js} +1 -1
  52. package/dashboard/dist/assets/{copy-DlM1BHdp.js → copy-BG0JMr6A.js} +1 -1
  53. package/dashboard/dist/assets/{download-CQFG-VIY.js → download-CPFJf-Sf.js} +1 -1
  54. package/dashboard/dist/assets/{external-link-BQyDqGxz.js → external-link-D2yF0kgP.js} +1 -1
  55. package/dashboard/dist/assets/{flame-BamzyXzF.js → flame-l460AFx9.js} +1 -1
  56. package/dashboard/dist/assets/{format-tokens-C4G-_xYt.js → format-tokens-DKO4ljuH.js} +1 -1
  57. package/dashboard/dist/assets/{icons-Ntscvl1a.js → icons-RoxRGkz4.js} +1 -1
  58. package/dashboard/dist/assets/{index-FRIt5mlv.js → index--ouT5L4N.js} +1 -1
  59. package/dashboard/dist/assets/{index-CUrcPqgp.js → index-DhyLCvvv.js} +1 -1
  60. package/dashboard/dist/assets/{index-DGxgsNoQ.js → index-PTJ4368-.js} +1 -1
  61. package/dashboard/dist/assets/{info-CXytWcZi.js → info-DNWMO4Ca.js} +1 -1
  62. package/dashboard/dist/assets/{link-2-Dexoo_jO.js → link-2-DzWXAz1h.js} +1 -1
  63. package/dashboard/dist/assets/{loader-circle-Cn0JHc8t.js → loader-circle-BzGMqXNu.js} +1 -1
  64. package/dashboard/dist/assets/{maximize-2-DLh7gYuP.js → maximize-2-Dkpyk4x3.js} +1 -1
  65. package/dashboard/dist/assets/{modifiers.esm-DOh_xtyt.js → modifiers.esm-lggHUQpW.js} +1 -1
  66. package/dashboard/dist/assets/{monitor-smartphone-CpqS9Ior.js → monitor-smartphone-Ck0-gz9l.js} +1 -1
  67. package/dashboard/dist/assets/{plus-bfQV7nyv.js → plus-qTJpnn43.js} +1 -1
  68. package/dashboard/dist/assets/{provider-display-Bf9pW06U.js → provider-display-psY26qmp.js} +1 -1
  69. package/dashboard/dist/assets/{react-BmFZKA_b.js → react-CYS24KmX.js} +1 -1
  70. package/dashboard/dist/assets/{search-l3jJ2fzC.js → search-CUzE6zxr.js} +1 -1
  71. package/dashboard/dist/assets/{skills-api-CWmLnaxn.js → skills-api-D9SzxPFG.js} +1 -1
  72. package/dashboard/dist/assets/{sortable.esm-DLgyXLHM.js → sortable.esm-Bl2hAUyR.js} +1 -1
  73. package/dashboard/dist/assets/{store-JM-a8ElZ.js → store-mHSJAJtE.js} +1 -1
  74. package/dashboard/dist/assets/{terminal-6aY2Sn8P.js → terminal-BlQNEvn1.js} +1 -1
  75. package/dashboard/dist/assets/{trash-D5oon5pT.js → trash-CHdgmOyk.js} +1 -1
  76. package/dashboard/dist/assets/{use-community-stats-ZWUMFwzc.js → use-community-stats-DUiCs91N.js} +1 -1
  77. package/dashboard/dist/assets/{use-latest-request-guard-BDaXr4gK.js → use-latest-request-guard-ehXfkvuU.js} +1 -1
  78. package/dashboard/dist/assets/{use-limits-display-prefs-yXXToNIc.js → use-limits-display-prefs-CcwwQ0Fq.js} +1 -1
  79. package/dashboard/dist/assets/{use-ordered-list-C6RG8N6c.js → use-ordered-list-CCOtI3Wa.js} +1 -1
  80. package/dashboard/dist/assets/use-reduced-motion-CDlahPqe.js +1 -0
  81. package/dashboard/dist/assets/{use-session-efficiency-pref-DpgZO_Lx.js → use-session-efficiency-pref-CYRDpcc_.js} +1 -1
  82. package/dashboard/dist/assets/{use-transform-D42P7jkd.js → use-transform-btLlTJpj.js} +1 -1
  83. package/dashboard/dist/assets/{use-usage-limits-CV6puFwq.js → use-usage-limits-BGr5sR-c.js} +1 -1
  84. package/dashboard/dist/assets/{useCurrency-GWBmOrCR.js → useCurrency-CNutuEKd.js} +1 -1
  85. package/dashboard/dist/assets/{useTokenFormat-Beybkb0v.js → useTokenFormat-C0bAJFMC.js} +1 -1
  86. package/dashboard/dist/assets/{zap-CEq2616W.js → zap-B2fbyjbc.js} +1 -1
  87. package/dashboard/dist/index.html +1 -1
  88. package/dashboard/dist/ip-check.html +1 -1
  89. package/dashboard/dist/leaderboard.html +1 -1
  90. package/dashboard/dist/share.html +1 -1
  91. package/package.json +1 -1
  92. package/src/lib/local-api.js +5 -0
  93. package/src/lib/pricing/seed-snapshot.json +1 -1
  94. package/src/lib/skills-manager.js +226 -30
  95. package/dashboard/dist/assets/DialogDescription-BMyOicfz.js +0 -1
  96. package/dashboard/dist/assets/SkillsPage-eXI09q03.js +0 -1
  97. package/dashboard/dist/assets/use-reduced-motion-BqDKim_3.js +0 -1
@@ -909,7 +909,12 @@ function listInstalledSkills() {
909
909
  });
910
910
  }
911
911
 
912
- async function installSkill(skillInput, targetIds = ["claude", "codex"]) {
912
+ async function installSkill(
913
+ skillInput,
914
+ targetIds = ["claude", "codex"],
915
+ prefetchedTree = null,
916
+ { expectExistingId = null } = {},
917
+ ) {
913
918
  const skill = {
914
919
  key: String(skillInput?.key || ""),
915
920
  name: String(skillInput?.name || ""),
@@ -939,7 +944,9 @@ async function installSkill(skillInput, targetIds = ["claude", "codex"]) {
939
944
  );
940
945
  }
941
946
 
942
- const { branch, tree } = await getRepoTree({
947
+ // Bulk update hands in the repo tree it already fetched, so N skills from one
948
+ // repo cost one GitHub call instead of N.
949
+ const { branch, tree } = prefetchedTree || await getRepoTree({
943
950
  owner: skill.repoOwner,
944
951
  name: skill.repoName,
945
952
  branch: skill.repoBranch,
@@ -950,9 +957,10 @@ async function installSkill(skillInput, targetIds = ["claude", "codex"]) {
950
957
  if (!files.some((entry) => /(^|\/)SKILL\.md$/i.test(entry.path))) throw new Error("SKILL.md not found in selected directory");
951
958
 
952
959
  const dest = managedSkillPath(installName);
953
- const temp = path.join(dataDir(), "tmp", `${installName}-${Date.now()}`);
954
- removePath(temp);
955
- ensureDir(temp);
960
+ let selectedTargets = targetIds.filter((id) => TARGETS[id]);
961
+ const tempRoot = path.join(dataDir(), "tmp");
962
+ ensureDir(tempRoot);
963
+ const temp = fs.mkdtempSync(path.join(tempRoot, `${installName}-`));
956
964
  try {
957
965
  for (const entry of files) {
958
966
  const relative = entry.path === sourceDir ? path.basename(entry.path) : entry.path.slice(sourceDir.length + 1);
@@ -962,6 +970,17 @@ async function installSkill(skillInput, targetIds = ["claude", "codex"]) {
962
970
  ensureDir(path.dirname(out));
963
971
  fs.writeFileSync(out, await fetchText(githubRawUrl(skill.repoOwner, skill.repoName, branch, entry.path)));
964
972
  }
973
+ // An update must not recreate a skill that was uninstalled while we were
974
+ // downloading, nor overwrite whatever took its install directory in the
975
+ // meantime. Checked here because everything from this point to
976
+ // saveRegistry() is synchronous — no await can interleave a change we would
977
+ // then clobber.
978
+ if (expectExistingId) {
979
+ const current = readRegistry().skills.find((entry) => !entry.trashedAt && entry.id === expectExistingId);
980
+ if (!current) throw new Error("Skill is no longer installed");
981
+ // Another page or API caller may have changed target intent during a download.
982
+ selectedTargets = (current.targets || []).filter((id) => TARGETS[id]);
983
+ }
965
984
  removePath(dest);
966
985
  ensureDir(path.dirname(dest));
967
986
  fs.renameSync(temp, dest);
@@ -973,7 +992,6 @@ async function installSkill(skillInput, targetIds = ["claude", "codex"]) {
973
992
  const skillMarker = findSkillMarker(dest);
974
993
  const skillMd = skillMarker ? fs.readFileSync(skillMarker, "utf8") : "";
975
994
  const metadata = readSkillMetadata(skillMd, skill.name || installName);
976
- const selectedTargets = targetIds.filter((id) => TARGETS[id]);
977
995
  const installed = {
978
996
  id: `${skill.repoOwner}/${skill.repoName}:${sourceDir}`,
979
997
  key: `${skill.repoOwner}/${skill.repoName}:${sourceDir}`,
@@ -992,9 +1010,13 @@ async function installSkill(skillInput, targetIds = ["claude", "codex"]) {
992
1010
  targets: selectedTargets,
993
1011
  };
994
1012
 
995
- registry.skills = registry.skills.filter((entry) => entry.id !== installed.id && entry.directory.toLowerCase() !== installName.toLowerCase());
996
- registry.skills.push(installed);
997
- saveRegistry(registry);
1013
+ // Re-read: the downloads above can take minutes and the registry is shared
1014
+ // with every other mutation path, so the copy fetched before them is stale by
1015
+ // now. Reading here keeps the read/modify/write window down to this block.
1016
+ const latest = readRegistry();
1017
+ latest.skills = latest.skills.filter((entry) => entry.id !== installed.id && entry.directory.toLowerCase() !== installName.toLowerCase());
1018
+ latest.skills.push(installed);
1019
+ saveRegistry(latest);
998
1020
 
999
1021
  for (const id of selectedTargets) syncSkillToTarget(installName, id);
1000
1022
  appendActivity({ action: "install", name: installed.name, directory: installName, targets: selectedTargets, source: `${skill.repoOwner}/${skill.repoName}` });
@@ -1244,20 +1266,89 @@ function updateCachePath() {
1244
1266
  return path.join(dataDir(), "updates-cache.json");
1245
1267
  }
1246
1268
 
1269
+ // checkUpdates() and updateSkills() have to agree on three things: which skills
1270
+ // are candidates, how a cached verdict is keyed, and which tree a skill's
1271
+ // signature comes from. They share these so the badge and the update can never
1272
+ // disagree about the same skill.
1273
+ function managedUpdateCandidates(registry) {
1274
+ return registry.skills.filter(
1275
+ (skill) => !skill.trashedAt && skill.repoOwner && skill.repoName && skill.sourceSignature,
1276
+ );
1277
+ }
1278
+
1279
+ function updateFingerprint(managed) {
1280
+ return managed
1281
+ .map((skill) => `${skill.id}@${skill.sourceSignature}`)
1282
+ .sort()
1283
+ .join("|");
1284
+ }
1285
+
1286
+ // Write the verdicts a round derived, carrying forward the previous map for
1287
+ // anything it could not derive — a repo whose tree failed, everything past a
1288
+ // rate-limited stop. "We could not check" must not render as "nothing is
1289
+ // stale": that clears every badge and with it the way to retry. Returns the
1290
+ // merged map. Entries for skills that are no longer installed are dropped.
1291
+ //
1292
+ // `full` says the round attempted the whole library, which only checkUpdates()
1293
+ // does. An update attempts the ids it was handed, so it may only publish an
1294
+ // entry when the carried map fills in the rest — see the guard below.
1295
+ function writeUpdateCache(verdicts, { full = false } = {}) {
1296
+ const managed = managedUpdateCandidates(readRegistry());
1297
+ const live = new Set(managed.map((skill) => skill.id));
1298
+ const cached = readJson(updateCachePath(), null);
1299
+ const carriedFresh = Boolean(
1300
+ cached &&
1301
+ cached.updates &&
1302
+ typeof cached.updates === "object" &&
1303
+ Number.isFinite(cached.checkedAt) &&
1304
+ Date.now() - cached.checkedAt < UPDATE_CACHE_TTL_MS,
1305
+ );
1306
+ const updates = {};
1307
+ if (carriedFresh) {
1308
+ for (const [id, stale] of Object.entries(cached.updates)) if (live.has(id)) updates[id] = Boolean(stale);
1309
+ }
1310
+ for (const [id, stale] of Object.entries(verdicts)) if (live.has(id)) updates[id] = Boolean(stale);
1311
+
1312
+ // The entry is read back as a verdict for the entire library, and a missing
1313
+ // key reads as "not stale". A partial round that stamped the library
1314
+ // fingerprint would therefore publish silence about skills nobody looked at,
1315
+ // and the next check would hit it. Leave the cache alone instead and let that
1316
+ // check do the work.
1317
+ if (!full && !managed.every((skill) => Object.prototype.hasOwnProperty.call(updates, skill.id))) {
1318
+ return updates;
1319
+ }
1320
+
1321
+ writeJson(updateCachePath(), {
1322
+ fingerprint: updateFingerprint(managed),
1323
+ // A prime inherits the window of the check it built on: it re-derived some
1324
+ // ids, not the library, so it must not restart the hour for the rest.
1325
+ checkedAt: full || !carriedFresh ? Date.now() : cached.checkedAt,
1326
+ updates,
1327
+ });
1328
+ return updates;
1329
+ }
1330
+
1331
+ function groupSkillsByRepo(skills) {
1332
+ const byRepo = new Map();
1333
+ for (const skill of skills) {
1334
+ const branch = skill.repoBranch || "main";
1335
+ const key = `${skill.repoOwner}/${skill.repoName}@${branch}`.toLowerCase();
1336
+ if (!byRepo.has(key)) {
1337
+ byRepo.set(key, { owner: skill.repoOwner, name: skill.repoName, branch, skills: [] });
1338
+ }
1339
+ byRepo.get(key).skills.push(skill);
1340
+ }
1341
+ return Array.from(byRepo.values());
1342
+ }
1343
+
1247
1344
  // Compare each managed GitHub/skills.sh skill's stored source signature against a
1248
1345
  // freshly fetched repo tree. One tree call per repo (skills from the same repo
1249
1346
  // share it), concurrency-limited and cached for an hour so a background check
1250
1347
  // can't trip GitHub's unauthenticated rate limit. Returns { updates: {id:bool} }.
1251
1348
  // Read-only: never mutates the registry or the on-disk skills.
1252
1349
  async function checkUpdates({ force = false } = {}) {
1253
- const registry = readRegistry();
1254
- const managed = registry.skills.filter(
1255
- (skill) => !skill.trashedAt && skill.repoOwner && skill.repoName && skill.sourceSignature,
1256
- );
1257
- const fingerprint = managed
1258
- .map((skill) => `${skill.id}@${skill.sourceSignature}`)
1259
- .sort()
1260
- .join("|");
1350
+ const managed = managedUpdateCandidates(readRegistry());
1351
+ const fingerprint = updateFingerprint(managed);
1261
1352
 
1262
1353
  if (!force) {
1263
1354
  const cached = readJson(updateCachePath(), null);
@@ -1273,18 +1364,8 @@ async function checkUpdates({ force = false } = {}) {
1273
1364
  }
1274
1365
  }
1275
1366
 
1276
- const byRepo = new Map();
1277
- for (const skill of managed) {
1278
- const branch = skill.repoBranch || "main";
1279
- const key = `${skill.repoOwner}/${skill.repoName}@${branch}`.toLowerCase();
1280
- if (!byRepo.has(key)) {
1281
- byRepo.set(key, { owner: skill.repoOwner, name: skill.repoName, branch, skills: [] });
1282
- }
1283
- byRepo.get(key).skills.push(skill);
1284
- }
1285
-
1286
1367
  const updates = {};
1287
- await mapWithConcurrency(Array.from(byRepo.values()), UPDATE_CHECK_CONCURRENCY, async (repo) => {
1368
+ await mapWithConcurrency(groupSkillsByRepo(managed), UPDATE_CHECK_CONCURRENCY, async (repo) => {
1288
1369
  let tree;
1289
1370
  try {
1290
1371
  ({ tree } = await getRepoTree(repo));
@@ -1299,8 +1380,122 @@ async function checkUpdates({ force = false } = {}) {
1299
1380
  });
1300
1381
 
1301
1382
  const checkedAt = Date.now();
1302
- writeJson(updateCachePath(), { fingerprint, checkedAt, updates });
1303
- return { updates, checkedAt, cached: false };
1383
+ return { updates: writeUpdateCache(updates, { full: true }), checkedAt, cached: false };
1384
+ }
1385
+
1386
+ // Re-install managed skills from upstream, grouped by repo like checkUpdates()
1387
+ // so N skills from one repo cost one tree call. Sequential by necessity:
1388
+ // installSkill() read/modify/writes the registry, so parallel installs would
1389
+ // drop each other's entries. Every requested id gets a result row — including
1390
+ // ones that are no longer installed — so updated + skipped + failed always
1391
+ // reconciles with what the caller asked for.
1392
+ async function updateSkills(ids = []) {
1393
+ // An empty or malformed list means "nothing was asked for", never "every
1394
+ // managed skill" — the permissive reading turned one bad request field into a
1395
+ // full re-install of the library.
1396
+ const wanted = new Set(
1397
+ (Array.isArray(ids) ? ids : []).map((id) => String(id || "")).filter(Boolean),
1398
+ );
1399
+ if (!wanted.size) return { results: [], updated: 0, skipped: 0, failed: 0, rateLimited: null };
1400
+ const managed = readRegistry().skills.filter(
1401
+ (skill) => !skill.trashedAt && skill.repoOwner && skill.repoName && wanted.has(skill.id),
1402
+ );
1403
+
1404
+ const results = [];
1405
+ const verdicts = {};
1406
+ let rateLimited = null;
1407
+
1408
+ const known = new Set(managed.map((skill) => skill.id));
1409
+ for (const id of wanted) {
1410
+ if (!known.has(id)) results.push({ id, name: null, ok: false, error: "Skill is no longer installed" });
1411
+ }
1412
+
1413
+ for (const repo of groupSkillsByRepo(managed)) {
1414
+ let branch;
1415
+ let tree;
1416
+ try {
1417
+ ({ branch, tree } = await getRepoTree(repo));
1418
+ } catch (error) {
1419
+ if (error instanceof RateLimitError) {
1420
+ rateLimited = error;
1421
+ break;
1422
+ }
1423
+ for (const skill of repo.skills) {
1424
+ results.push({ id: skill.id, name: skill.name, ok: false, error: error?.message || "Unable to read repository" });
1425
+ }
1426
+ continue;
1427
+ }
1428
+
1429
+ for (const skill of repo.skills) {
1430
+ const sourceDir = skill.sourceDirectory || skill.directory;
1431
+ const fresh = sourceSignatureFromTree(tree, sourceDir);
1432
+ if (skill.sourceSignature && fresh === skill.sourceSignature) {
1433
+ results.push({ id: skill.id, name: skill.name, ok: true, skipped: true });
1434
+ verdicts[skill.id] = false;
1435
+ continue;
1436
+ }
1437
+ // This loop runs for as long as the downloads take, and the registry is
1438
+ // shared with every other mutation path — re-check rather than write back
1439
+ // a skill that was uninstalled while we were working.
1440
+ if (!readRegistry().skills.some((entry) => !entry.trashedAt && entry.id === skill.id)) {
1441
+ results.push({ id: skill.id, name: skill.name, ok: false, error: "Skill is no longer installed" });
1442
+ continue;
1443
+ }
1444
+ try {
1445
+ await installSkill(
1446
+ {
1447
+ key: skill.key,
1448
+ name: skill.name,
1449
+ description: skill.description,
1450
+ // installSkill() wants the repo path, not the flat install name.
1451
+ directory: sourceDir,
1452
+ readmeUrl: skill.readmeUrl,
1453
+ repoOwner: skill.repoOwner,
1454
+ repoName: skill.repoName,
1455
+ repoBranch: branch,
1456
+ },
1457
+ skill.targets || [],
1458
+ { branch, tree },
1459
+ { expectExistingId: skill.id },
1460
+ );
1461
+ results.push({ id: skill.id, name: skill.name, ok: true, skipped: false });
1462
+ if (fresh) verdicts[skill.id] = false;
1463
+ } catch (error) {
1464
+ if (error instanceof RateLimitError) {
1465
+ rateLimited = error;
1466
+ break;
1467
+ }
1468
+ results.push({ id: skill.id, name: skill.name, ok: false, error: error?.message || "Update failed" });
1469
+ if (fresh) verdicts[skill.id] = true;
1470
+ }
1471
+ }
1472
+ if (rateLimited) break;
1473
+ }
1474
+
1475
+ // A rate-limited stop breaks out of both loops, leaving the skill it happened
1476
+ // on and everything after it unreported. Backfill so every requested id comes
1477
+ // back with a row and the counts still reconcile with what was asked for.
1478
+ if (rateLimited) {
1479
+ const reported = new Set(results.map((row) => row.id));
1480
+ const nameById = new Map(managed.map((skill) => [skill.id, skill.name]));
1481
+ for (const id of wanted) {
1482
+ if (reported.has(id)) continue;
1483
+ results.push({ id, name: nameById.get(id) || null, ok: false, error: rateLimited.message });
1484
+ }
1485
+ }
1486
+
1487
+ // Prime the cache from the trees this run already holds, so the refresh that
1488
+ // follows is a cache hit rather than a second tree call per repo. Skipped when
1489
+ // the run derived nothing — there is no fresh verdict to record.
1490
+ if (Object.keys(verdicts).length) writeUpdateCache(verdicts);
1491
+
1492
+ return {
1493
+ results,
1494
+ updated: results.filter((entry) => entry.ok && !entry.skipped).length,
1495
+ skipped: results.filter((entry) => entry.skipped).length,
1496
+ failed: results.filter((entry) => !entry.ok).length,
1497
+ rateLimited: rateLimited ? rateLimited.message : null,
1498
+ };
1304
1499
  }
1305
1500
 
1306
1501
  // skills.sh exposes only /api/search (no leaderboard endpoint), so "Popular" is
@@ -1385,4 +1580,5 @@ module.exports = {
1385
1580
  sourceSignatureFromTree,
1386
1581
  targetList,
1387
1582
  uninstallSkill,
1583
+ updateSkills,
1388
1584
  };
@@ -1 +0,0 @@
1
- import{r as n,v as a}from"./__vite-browser-external-BDkeh90N.js";import{u as p}from"./DialogTitle-DL5nvD31.js";import{u as c}from"./composite-BIgEqWZD.js";const x=n.forwardRef(function(e,r){const{render:l,className:u,style:m,id:s,...t}=e,i=p(),o=c(s);return i.useSyncedValueWithCleanup("descriptionElementId",o),a("p",e,{ref:r,props:[{id:o},t]})});export{x as D};
@@ -1 +0,0 @@
1
- import{m as lt,r as i,v as ma,j as e,X as Re,c as r,e as Z,ax as da,ay as dt,t as ct,az as ut,aA as mt,E as gt,aB as xt,aC as ht,aD as pt,aE as ft,w as yt,aF as bt,aG as kt,aH as wt,aI as vt,a3 as jt,a as Nt,aJ as Ct,an as St,G as _t,B as H,R as It,d as Rt,aK as Lt,a4 as Ie}from"./__vite-browser-external-BDkeh90N.js";import{L as Pt,I as ga}from"./LocalOnlyNotice-CKhY27Lr.js";import{C as Dt}from"./Card-BJJs701t.js";import{C as fa}from"./ConfirmModal-DBvOTcAQ.js";import{S as Bt}from"./SegmentedControl-CP7oiGZE.js";import{I as Sa}from"./info-CXytWcZi.js";import{P as ye}from"./ProviderIcon-Dm8fwPdj.js";import{m as ya}from"./react-BmFZKA_b.js";import{u as Tt}from"./useCurrency-GWBmOrCR.js";import{E as ca}from"./external-link-BQyDqGxz.js";import{L as ee}from"./loader-circle-Cn0JHc8t.js";import{M as _a}from"./monitor-smartphone-CpqS9Ior.js";import{C as Le}from"./check-CgD_bV39.js";import{T as xa}from"./trash-D5oon5pT.js";import{A as Et}from"./index-FRIt5mlv.js";import{u as At}from"./use-reduced-motion-BqDKim_3.js";import{u as Ot,k as $t,l as Mt,m as Ut,n as Ft,o as zt,p as Kt,q as Vt,S as Ia,c as Ra,d as La,e as Pa,f as Da,g as Ba,h as Ze,j as ea,i as aa}from"./SelectItemText-DzljA15_.js";import{t as qt,u as Ta,a as Ht}from"./composite-BIgEqWZD.js";import{u as Gt,C as ha}from"./ToolbarRootContext-CDxCPYLv.js";import{g as Wt,a as Qt,p as Xt,m as Jt,b as Yt,d as Zt,c as er,e as ar,f as tr,s as rr,i as ba,u as ka,h as wa,r as sr,j as va,k as ja,l as nr,n as ir}from"./skills-api-CWmLnaxn.js";import{F as or}from"./flame-BamzyXzF.js";import{S as ua}from"./search-l3jJ2fzC.js";import{P as Ea}from"./plus-bfQV7nyv.js";import{D as Aa}from"./download-CQFG-VIY.js";import{P as Oa,a as $a,b as Ma,c as Ua,d as Fa}from"./PopoverPopup-h0gf36vg.js";import"./arrow-up-right-DIQXwaOD.js";import"./DialogTitle-DL5nvD31.js";import"./store-JM-a8ElZ.js";import"./DialogDescription-BMyOicfz.js";const lr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],za=lt("circle-arrow-up",lr),Ka=i.forwardRef(function(s,d){const{render:o,className:h,style:x,...g}=s,k={open:Ot().useState("open")};return ma("span",s,{state:k,ref:d,props:[{"aria-hidden":!0,children:"▼"},g],stateAttributesMapping:qt})}),dr="tt:hint:dismissed:";function Va(a){return dr+a}function cr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Va(a))==="1"}catch{return!1}}function ur({id:a,children:s,className:d,ariaLabel:o}){const[h,x]=i.useState(()=>cr(a)),g=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Va(a),"1")}catch{}x(!0)},[a]);return h?null:e.jsxs("div",{role:"note","aria-label":o||r("hint.dismissible_aria"),className:Z("relative rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 text-sm text-oai-gray-700","dark:border-oai-gray-800 dark:bg-oai-gray-900/40 dark:text-oai-gray-300",d),children:[e.jsx("button",{type:"button",onClick:g,"aria-label":r("hint.dismiss"),className:"absolute top-2 right-2 inline-flex h-7 w-7 items-center justify-center rounded-md text-oai-gray-500 transition-colors hover:bg-oai-gray-200/70 hover:text-oai-gray-700 focus:outline-none focus:ring-2 focus:ring-oai-blue/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800/70 dark:hover:text-oai-gray-200",children:e.jsx(Re,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Sa,{className:"mt-0.5 h-4 w-4 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:s})]})]})}function mr(a){if(!a)return null;for(const s of a.elements){const d=s.tagName;if(d==="BUTTON"||d==="INPUT"){const o=s;if(o.type==="submit")return o}}return null}const gr="data-checked",xr="data-unchecked";function qa(a){return{checked(s){return a.indeterminate?{}:s?{[gr]:""}:{[xr]:""}},...$t}}const hr=i.createContext({disabled:!1});function pr(){return i.useContext(hr)}function fr(a,s,d,o=!0,h){const[x,g]=i.useState(),c=Ta(h?`${h}-label`:void 0),y=a??s??x;return da(()=>{const k=a||s||!o?void 0:yr(d.current,c);x!==k&&g(k)}),y}function yr(a,s){const d=br(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function br(a){if(!a)return;const s=a.parentElement;if(s&&s.tagName==="LABEL")return s;const d=a.id;if(d){const h=a.nextElementSibling;if(h&&h.htmlFor===d)return h}const o=a.labels;return o&&o[0]}const kr=i.createContext(void 0);function wr(){return i.useContext(kr)}const Ha=i.createContext(void 0);function vr(){const a=i.useContext(Ha);if(a===void 0)throw new Error(dt(14));return a}const jr="data-parent",Nr=i.forwardRef(function(s,d){const{checked:o,className:h,defaultChecked:x=!1,"aria-labelledby":g,disabled:c=!1,form:y,id:k,indeterminate:p=!1,inputRef:C,name:R,onCheckedChange:u,parent:v=!1,readOnly:m=!1,render:S,required:L=!1,uncheckedValue:A,value:O,nativeButton:F=!1,style:oe,...D}=s,{clearErrors:be}=Mt(),{disabled:ue,name:me,setDirty:I,setFilled:$,setFocused:M,setTouched:T,state:G,validationMode:V,validityData:ke,validation:Pe}=Ut(),He=pr(),{labelId:De,registerControlId:Ge,getDescriptionProps:Be}=Ft(),w=wr(),E=w?.allValues===void 0?void 0:w.parent,le=E!==void 0,B=ue||He.disabled||w?.disabled||c,W=me??R,_=O??W,we=Ta(),Te=w?.registerControlId!==Ge,ve=zt({id:k||void 0,enabled:Te}),Ee=F?ve:we;let je={};le&&(v?je=E.getParentProps():_!==void 0&&(je=E.getChildProps(_)));const{checked:ge=o,indeterminate:ra=p,onCheckedChange:Ae,...We}=je,xe=w?.value,ae=i.useRef(null),{getButtonProps:Oe,buttonRef:Ne}=ct({disabled:B,native:F}),Q=w?.validation??Pe,[P,Ce]=Kt({controlled:_!==void 0&&xe!==void 0&&!v?xe.includes(_):ge,default:x,name:"Checkbox",state:"checked"}),te=le?!!ge:P,X=le&&ra||p;Vt(ae,we,P,void 0,!w&&!B,R);const de=E?.registerChildId,re=i.useRef(null),$e=Q.registerInput,Me=w?_:void 0,J=i.useCallback(b=>$e(b,{controlRef:ae,value:Me}),[$e,Me]),sa=ut(C,re,v?void 0:J),na=fr(g,De,re,!F,ve);da(()=>{re.current&&(re.current.indeterminate=X),w||$(P)},[P,X,w,$]),Gt(P,()=>{w||(be(W),I(P!==ke.initialValue),Q.change(P))});const ia=mt({checked:P,disabled:B,form:y,name:v?void 0:W,id:F?void 0:ve,required:L,ref:sa,style:W?pt:ft,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(b){if(b.nativeEvent.defaultPrevented)return;if(m){b.preventDefault();return}const q=b.currentTarget.checked,se=yt(bt,b.nativeEvent);if(u?.(q,se),!se.isCanceled&&(Ae?.(q,se),!se.isCanceled&&(Ce(q),_!==void 0&&w!==void 0&&!v&&!le))){const ne=q?[...w.value,_]:w.value.filter(he=>he!==_);w.setValue(ne,se)}},onClick(b){b.stopPropagation()},onFocus(){ae.current?.focus()}},O!==void 0?{value:(w?P&&O:O)||""}:gt,Be,b=>Q.getValidationProps(B,b));i.useEffect(()=>{if(!E||_===void 0)return;const b=E.disabledStatesRef.current;return b.set(_,B),()=>{b.delete(_)}},[E,B,_]);const Se=i.useMemo(()=>({...G,checked:te,disabled:B,readOnly:m,required:L,indeterminate:X}),[G,te,B,m,L,X]),Ue=qa(Se),Qe=ma("span",s,{state:Se,ref:[Ne,ae,d],props:[{id:Ee,role:"checkbox","aria-checked":X?"mixed":te,"aria-readonly":m||void 0,"aria-required":L||void 0,"aria-labelledby":na,[jr]:v?"":void 0,onFocus(){B||M(!0)},onBlur(){const b=re.current;b&&(T(!0),M(!1),V==="onBlur"&&Q.commit(w?xe:b.checked))},onKeyDown(b){if(b.key!=="Enter"||(b.preventBaseUIHandler(),b.defaultPrevented))return;const q=re.current?.form??null,se=b.currentTarget,ne=b.nativeEvent,he=b.preventDefault,Fe=ne.preventDefault;let ze=!1;b.preventDefault=()=>{ze=!0,he.call(b)},ne.preventDefault=()=>{ze=!0,Fe.call(ne)},Fe.call(ne),ht(se).queueMicrotask(()=>{b.preventDefault=he,ne.preventDefault=Fe,ze||mr(q)?.click()})},onClick(b){if(m||B)return;b.preventDefault();const q=re.current;q&&xt(q,b)}},D,We,Oe,Be,b=>Q.getValidationProps(B,b)],stateAttributesMapping:Ue}),_e=Qe.props.id;return da(()=>{if(!(!de||v||_===void 0||_e===void 0))return de(_,_e)},[de,v,_,_e]),e.jsxs(Ha.Provider,{value:Se,children:[Qe,!P&&!w&&W&&!v&&A!==void 0&&e.jsx("input",{type:"hidden",form:y,name:W,value:A,disabled:B}),e.jsx("input",{...ia,suppressHydrationWarning:!0})]})}),Cr=i.forwardRef(function(s,d){const{render:o,className:h,style:x,keepMounted:g=!1,...c}=s,y=vr(),k=y.checked||y.indeterminate,{mounted:p,transitionStatus:C,setMounted:R}=Ht(k),u=i.useRef(null),v={...y,transitionStatus:C};kt({batch:!0,enabled:!k,open:k,ref:u,onComplete(){k||R(!1)}});const S={...qa(y),...wt},L=g||p,A=ma("span",s,{ref:[d,u],state:v,stateAttributesMapping:S,props:c});return L?A:null});function Sr(a,s){return`target:${a}:${s}`}function _r(a){return`remove:${a.id||a.directory}`}function Ga(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function Ir(a){const s=Ga(a);if(s==null)return null;if(s<=0)return r("skills.usage.today");if(s<30)return r("skills.usage.days_ago",{days:s});const d=Math.max(1,Math.floor(s/30));return r("skills.usage.months_ago",{months:d})}function Rr(a){const s=Ga(a);return s==null?"bg-oai-gray-300 dark:bg-oai-gray-600":s<=7?"bg-emerald-500":s<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function oa({label:a,children:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 text-sm",children:[e.jsx("dt",{className:"flex items-center gap-1 text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:s})]})}function Lr({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){return e.jsx(Et,{children:a?e.jsx(Pr,{skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k},a.id||a.directory):null})}function Pr({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){const p=At(),{currency:C,rate:R}=Tt(),u=i.useRef(null);i.useEffect(()=>{const I=M=>{M.key==="Escape"&&(M.stopPropagation(),c?.())},$=M=>{const T=M.target;T instanceof Element&&(u.current?.contains(T)||T.closest('[data-skill-row="1"]')||c?.())};return document.addEventListener("keydown",I),document.addEventListener("pointerdown",$),()=>{document.removeEventListener("keydown",I),document.removeEventListener("pointerdown",$)}},[c]);const v=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),S=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,L=new Set(a.targets||[]),A=!!(a.readOnly||a.remote),O=!!a.remote,F=Array.isArray(a.deviceSources)?a.deviceSources:[],oe=!O&&(!A||L.has("claude")),D=d===_r(a),be=Ir(o?.lastUsedAt),ue=!!(o&&o.invocations>0),me=p?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(ya.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:p?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:p?0:.15},onClick:c,"aria-hidden":!0}),e.jsxs(ya.aside,{ref:u,role:"complementary","aria-label":v,initial:p?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:p?{opacity:0}:{opacity:0,x:24,scale:.98},transition:me,className:"fixed inset-x-3 bottom-3 top-20 z-30 flex flex-col overflow-hidden rounded-2xl border border-white/40 bg-white/75 shadow-[0_24px_60px_-20px_rgba(15,23,42,0.25)] backdrop-blur-xl backdrop-saturate-150 supports-[backdrop-filter]:bg-white/65 dark:border-white/10 dark:bg-oai-gray-950/70 dark:shadow-[0_24px_60px_-20px_rgba(0,0,0,0.7)] dark:supports-[backdrop-filter]:bg-oai-gray-950/55 lg:inset-auto lg:right-6 lg:top-24 lg:bottom-6 lg:w-[22rem] lg:max-h-[calc(100vh-7.5rem)]",children:[e.jsxs("header",{className:"flex items-center gap-3 border-b border-white/40 bg-gradient-to-b from-white/30 to-transparent px-5 pb-4 pt-5 dark:border-white/10 dark:from-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",title:v,children:v}),m?e.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:"mt-1 inline-flex max-w-full items-center gap-1 truncate text-xs text-oai-gray-500 transition-colors hover:text-oai-black hover:underline dark:text-oai-gray-400 dark:hover:text-white",title:S,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(ca,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):a.directory&&a.directory!==v?e.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:a.directory,children:a.directory}):null]}),e.jsx("button",{type:"button",onClick:c,"aria-label":r("skills.detail.close"),className:"-mr-1 inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-oai-gray-500 transition hover:bg-oai-gray-100 hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(Re,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5",children:[h?e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-sky-50/80 px-3 py-2.5 ring-1 ring-sky-200 dark:bg-sky-950/30 dark:ring-sky-800/60",children:[e.jsx(za,{className:"h-4 w-4 shrink-0 text-sky-600 dark:text-sky-300","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 text-xs text-sky-800 dark:text-sky-200",children:r("skills.update.available")}),e.jsxs("button",{type:"button",onClick:()=>g?.(a),disabled:x,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-sky-600 px-2.5 text-xs font-semibold text-white transition hover:bg-sky-700 focus:outline-none focus:ring-2 focus:ring-sky-400/40 disabled:cursor-not-allowed disabled:opacity-60 dark:bg-sky-500 dark:hover:bg-sky-400",children:[x?e.jsx(ee,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,r("skills.update.action")]})]}):null,a.description?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a.description}):null,A?e.jsx("div",{className:"mt-4 rounded-xl bg-oai-gray-50 px-3 py-2.5 text-xs leading-5 text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-900/60 dark:text-oai-gray-300 dark:ring-oai-gray-800",children:r(O?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed")}):null,a.sourceName?e.jsx("div",{className:"mt-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.source",{source:a.sourceName})}):null,F.length?e.jsxs("section",{className:"mt-5",children:[e.jsx("h3",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.devices_title")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:F.map(I=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 rounded-full bg-oai-gray-100 px-2.5 py-1 text-xs text-oai-gray-700 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-200 dark:ring-oai-gray-700",children:[e.jsx(_a,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:I.name})]},I.id))})]}):null,oe?e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.usage.section_title")}),e.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[e.jsx(oa,{label:r("skills.usage.invocations"),children:vt(o?.invocations||0)}),e.jsx(oa,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:Z("h-1.5 w-1.5 rounded-full",Rr(o?.lastUsedAt)),"aria-hidden":!0}),ue?be||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(oa,{label:e.jsxs(e.Fragment,{children:[r("skills.usage.cost"),e.jsx("span",{title:r("skills.usage.disclaimer"),className:"inline-flex cursor-help text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(Sa,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:jt(o?.cost||0,{currency:C,rate:R})})]}),ue?null:e.jsx("p",{className:"mt-2 text-[11px] leading-4 text-oai-gray-400 dark:text-oai-gray-500",children:r("skills.usage.unused")})]}):null,A?null:e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.sync_section_title")}),e.jsx("div",{children:(s||[]).filter(I=>I.manageable!==!1).map(I=>{const $=L.has(I.id),M=d===Sr(a.id||a.directory,I.id),T=`skill-detail-sync-${a.id||a.directory}-${I.id}`;return e.jsxs("label",{htmlFor:T,className:"-mx-2 flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-oai-black transition-colors hover:bg-oai-gray-100/70 dark:text-white dark:hover:bg-white/[0.05]",children:[e.jsx(Nr,{id:T,checked:$,disabled:M,onCheckedChange:G=>y?.(a,I.id,!!G),className:"peer flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border border-oai-gray-300/80 bg-white/80 shadow-sm transition-colors hover:border-oai-gray-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:border-oai-black data-[checked]:bg-oai-black dark:border-oai-gray-500/60 dark:bg-oai-gray-900/60 dark:hover:border-oai-gray-400 dark:data-[checked]:border-white dark:data-[checked]:bg-white",children:e.jsx(Cr,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(Le,{className:"h-3 w-3",strokeWidth:3.5,"aria-hidden":!0})})}),e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center","aria-hidden":!0,children:e.jsx(ye,{provider:I.id,size:16})}),e.jsx("span",{className:"flex-1",children:I.label}),M?e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},I.id)})})]})]}),A?null:e.jsxs("footer",{className:"border-t border-white/40 bg-white/30 px-5 py-4 dark:border-white/10 dark:bg-white/[0.02]",children:[e.jsxs("button",{type:"button",onClick:()=>k?.(a),disabled:D,className:"inline-flex w-full items-center justify-center gap-2 rounded-lg border border-red-200/70 bg-white px-3 py-2 text-sm font-medium text-red-600 transition hover:border-red-300 hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-red-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-900/60 dark:bg-oai-gray-950 dark:text-red-300 dark:hover:border-red-800 dark:hover:bg-red-950/30",children:[D?e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(xa,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.detail.remove_button")]}),e.jsx("p",{className:"mt-2 text-center text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.remove_confirm_hint")})]})]})]})}const Dr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),la=["claude","codex"],K="popular",Br={claude:"text-orange-500 dark:text-orange-300",codex:"text-emerald-600 dark:text-emerald-300",grok:"text-zinc-700 dark:text-zinc-200",antigravity:"text-violet-600 dark:text-violet-300",gemini:"text-sky-600 dark:text-sky-300",opencode:"text-amber-600 dark:text-amber-300",hermes:"text-indigo-500 dark:text-indigo-300"},ce="all",U="skillssh";function ta(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Wa(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function Tr(a){return Wa(a).split("/").filter(Boolean).pop()||""}function Er(a){if(a.repoOwner||a.repoName)return"";const s=Wa(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Na(a){const s=Tr(a.directory);return s?`dir:${s}`:""}function Qa(a){const s=new Set([ta(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=Er(a);return d&&s.add(d),s}function Ar(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function Or(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Ar(d))for(const o of Qa(d))s.add(o);return s}function Ye(a){return`install:${ta(a)}`}function Ca(a){return`remove:${a.id||a.directory}`}function Xa(a,s){return`target:${a}:${s}`}function fe(a){return a.id||a.directory}function pa(a){return a.manageable!==!1}function $r({target:a,state:s,busy:d,disabled:o,disabledLabel:h,onToggle:x}){const g=s==="synced",c=s==="orphan",y=c?r("skills.dot.orphan_aria",{agent:a.label}):g?r("skills.dot.synced_aria",{agent:a.label}):r("skills.dot.off_aria",{agent:a.label}),k=o&&h?`${y} — ${h}`:y;return e.jsxs("button",{type:"button",title:k,"aria-label":k,"aria-pressed":g,disabled:d||o,onClick:p=>{p.stopPropagation(),x?.(a.id,!g)},className:"relative flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/40 disabled:cursor-not-allowed dark:hover:bg-oai-gray-800/60",children:[d?e.jsx(ee,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:Z("flex h-[18px] w-[18px] items-center justify-center transition",g&&Br[a.id],!g&&!c&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(ye,{provider:a.id,size:18})}),c&&!d?e.jsx("span",{className:"absolute -bottom-px -right-px h-2 w-2 rounded-full bg-amber-500 ring-2 ring-oai-white dark:ring-oai-gray-900","aria-hidden":!0}):null]})}function Mr({skill:a,targets:s,onToggleTarget:d,busyKey:o}){const h=new Set(a.targets||[]),x=!!(a.readOnly||a.remote),g=[];for(const c of s)(x?h.has(c.id):pa(c))&&g.push(c);return e.jsx("div",{className:"flex items-center gap-1",onClick:c=>c.stopPropagation(),children:g.map(c=>e.jsx($r,{target:c,state:a.targetStates?.[c.id]||"off",busy:o===Xa(fe(a),c.id),disabled:x||c.manageable===!1,disabledLabel:r(a.remote?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed"),onToggle:(y,k)=>d?.(a,y,k)},c.id))})}function Ur({skill:a,targets:s,selected:d,onSelect:o,selectable:h,checked:x,onToggleSelect:g,onToggleTarget:c,hasUpdate:y,busyKey:k}){const p=a.repoOwner&&a.repoName?`${a.repoOwner}/${a.repoName}`:null,C=[a.directory,p,a.sourceName].filter(Boolean).join(" · "),R=Array.isArray(a.deviceSources)?a.deviceSources:[],u=[a.remote?r("skills.inventory.remote"):null,a.scope==="plugin"?r("skills.inventory.plugin"):null].filter(Boolean),v=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),o?.(a))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":d,"aria-label":r("skills.row.open_details",{name:a.name||a.directory}),onClick:()=>o?.(a),onKeyDown:v,className:Z("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",d?"bg-oai-gray-100 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800/60 dark:ring-oai-gray-800":x?"bg-oai-gray-50 dark:bg-oai-gray-900/40":"hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[h?e.jsx("label",{className:"flex shrink-0 items-center",onClick:m=>m.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:x,onChange:m=>g?.(a,m.target.checked),"aria-label":r("skills.select.row_aria",{name:a.name||a.directory}),className:"h-4 w-4 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white"})}):null,e.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-oai-black dark:text-white",title:C,children:a.name||a.directory}),u.map(m=>e.jsx("span",{className:"inline-flex shrink-0 rounded-full bg-oai-gray-100 px-1.5 py-0.5 text-[10px] font-semibold text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-300 dark:ring-oai-gray-700",children:m},m)),y?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-semibold text-sky-700 ring-1 ring-sky-200 dark:bg-sky-950/40 dark:text-sky-300 dark:ring-sky-800/60",children:[e.jsx(za,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Mr,{skill:a,targets:s,onToggleTarget:c,busyKey:k}),e.jsx(Lt,{className:Z("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",d&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),a.description?e.jsx("p",{className:Z("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",h&&"pl-7"),children:a.description}):null,a.sourceName||R.length?e.jsxs("div",{className:Z("mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",h&&"pl-7"),children:[a.sourceName?e.jsx("span",{className:"truncate",children:a.sourceName}):null,R.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:R.map(m=>m.name).join(", "),children:[e.jsx(_a,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:R.map(m=>m.name).join(", ")})})]}):null]}):null]})}function Fr({agentFilter:a,agentOptions:s,onAgentFilter:d,filteredCount:o,totalCount:h,anyFilter:x,onClearFilters:g,searchQuery:c,onSearchQuery:y,searchPlaceholder:k}){return e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pt-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsxs(Ia,{value:a,onValueChange:d,children:[e.jsxs(Ra,{"aria-label":r("skills.filter.agent_label"),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200 dark:hover:border-oai-gray-700",children:[e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:[r("skills.filter.agent_label"),":"]}),e.jsx(La,{children:p=>p==="all"?r("skills.filter.agent_all"):s.find(C=>C.id===p)?.label||p}),e.jsx(Ka,{className:"text-oai-gray-400",children:e.jsx(ha,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Pa,{children:e.jsx(Da,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ba,{className:"min-w-[var(--anchor-width)] overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs(Ze,{value:"all",className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ea,{children:r("skills.filter.agent_all")}),e.jsx(aa,{children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(p=>e.jsxs(Ze,{value:p.id,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{provider:p.id,size:14}),e.jsx(ea,{children:p.label})]}),e.jsx(aa,{children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},p.id))]})})})]}),e.jsxs("div",{className:"relative w-56 max-w-full",children:[e.jsx(ua,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(ga,{type:"search",value:c,onChange:p=>y(p.target.value),onKeyDown:p=>{p.key==="Escape"&&c&&(p.preventDefault(),y(""))},"aria-label":r("skills.action.search_aria"),placeholder:k,className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>y(""),"aria-label":r("skills.action.search_clear"),"aria-hidden":!c,tabIndex:c?0:-1,className:Z("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out before:absolute before:-inset-1.5 before:content-[''] hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 motion-reduce:transition-none dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",c?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{role:"status","aria-live":"polite",className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.filter.result_count",{filtered:o,total:h})}),x?e.jsxs("button",{type:"button",onClick:g,className:"shrink-0 inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Re,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function zr({count:a,targets:s,busy:d,onBulkSync:o,onBulkRemove:h,onClear:x}){const g=s.filter(pa);return e.jsxs("div",{role:"toolbar","aria-label":r("skills.select.toolbar_aria"),className:"mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/50",children:[e.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200","aria-live":"polite",children:r("skills.select.count",{count:a})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(Oa,{children:[e.jsxs($a,{disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:[e.jsx(Aa,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(ha,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Ma,{children:e.jsx(Ua,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Fa,{className:"min-w-[200px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.select.bulk_sync_hint")}),g.map(c=>e.jsxs("button",{type:"button",onClick:()=>o(c.id),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx(ye,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(H,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:h,children:[e.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_remove")]}),e.jsxs("button",{type:"button",onClick:x,className:"inline-flex h-7 items-center gap-1 rounded-full px-2 text-[11px] font-medium text-oai-gray-500 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",children:[e.jsx(Re,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Kr({items:a,totalCount:s,targets:d,agentOptions:o,agentFilter:h,onAgentFilter:x,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p,selectedId:C,onSelect:R,onToggleTarget:u,busyKey:v,updates:m,selectedIds:S,onToggleSelect:L,onClearSelection:A,onBulkSync:O,onBulkRemove:F}){const oe=S.size;return e.jsxs("div",{children:[oe>0?e.jsx(zr,{count:oe,targets:d,busy:v==="batch",onBulkSync:O,onBulkRemove:F,onClear:A}):e.jsx(Fr,{agentFilter:h,agentOptions:o,onAgentFilter:x,filteredCount:a.length,totalCount:s,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p}),a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r("skills.empty.no_match")}),e.jsx(H,{type:"button",variant:"secondary",size:"sm",onClick:c,children:r("skills.filter.clear")})]}):e.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(D=>e.jsx(Ur,{skill:D,targets:d,selected:C===(D.id||D.directory),onSelect:R,selectable:!D.readOnly&&!D.remote,checked:S.has(fe(D)),onToggleSelect:L,onToggleTarget:u,hasUpdate:!!(D.id&&m?.[D.id]),busyKey:v},fe(D)))})]})}const Vr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},qr=Rt.memo(function({skill:s,installed:d,installing:o,allTargets:h,defaultTargets:x,onInstall:g,onManage:c}){const[y,k]=i.useState(()=>(x||[]).filter(m=>h.some(S=>S.id===m))),p=m=>{k(S=>S.includes(m)?S.filter(L=>L!==m):[...S,m])},C=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,R=C?`https://github.com/${s.repoOwner}/${s.repoName}`:null,u=s.installs!=null?r("skills.card.installs",{count:Number(s.installs||0).toLocaleString()}):null,v=y.length?y.map(m=>h.find(S=>S.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(Dt,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[s.readmeUrl?e.jsxs("a",{href:s.readmeUrl,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex max-w-full items-center gap-1 truncate text-base font-semibold text-oai-black hover:underline dark:text-white",title:s.readmeUrl,children:[e.jsx("span",{className:"truncate",children:s.name||s.directory}),e.jsx(ca,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:s.name||s.directory}),C||u?e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[R?e.jsxs("a",{href:R,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"inline-flex items-center gap-1 truncate rounded text-oai-gray-500 hover:text-oai-black hover:underline focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",title:R,children:[e.jsx("span",{className:"truncate",children:C}),e.jsx(ca,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,C&&u?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,u?e.jsx("span",{className:"truncate",children:u}):null]}):null]})}),s.description?e.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s.description}):null,e.jsx("div",{className:"mt-auto pt-5",children:d?e.jsxs(H,{type:"button",variant:"secondary",size:"sm",onClick:()=>c?.(s),className:"w-full",children:[e.jsx(Le,{className:"mr-1.5 h-3.5 w-3.5 text-emerald-500 dark:text-emerald-400","aria-hidden":!0}),r("skills.card.manage")]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.card.targets_prefix")}),e.jsx("span",{className:"min-w-0 truncate font-medium text-oai-black dark:text-white",children:y.length?v:r("skills.target.none")}),e.jsxs(Oa,{children:[e.jsx($a,{disabled:o,"aria-label":r("skills.action.choose_targets"),className:"rounded text-xs font-medium text-oai-gray-500 underline decoration-oai-gray-300 decoration-dotted underline-offset-2 transition hover:text-oai-black hover:decoration-oai-gray-500 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:text-oai-gray-400 dark:decoration-oai-gray-600 dark:hover:text-white dark:hover:decoration-oai-gray-400",children:r("skills.card.targets_change")}),e.jsx(Ma,{children:e.jsx(Ua,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Fa,{className:"min-w-[220px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.target.menu_label")}),h.map(m=>{const S=y.includes(m.id);return e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 shrink-0 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white",checked:S,onChange:()=>p(m.id)}),e.jsx(ye,{provider:m.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:m.label})]},m.id)})]})})})]})]}),e.jsxs(H,{type:"button",size:"sm",onClick:()=>g(s,y),disabled:o||y.length===0,className:"w-full",children:[o?e.jsx(ee,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Aa,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function Hr({repos:a,repoInput:s,onRepoInput:d,busyKey:o,onAdd:h,onRemove:x}){return e.jsxs("div",{className:"rounded-lg border border-oai-gray-200 bg-white p-4 dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx(ga,{value:s,onChange:g=>d(g.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(H,{type:"button",variant:"secondary",size:"md",onClick:h,disabled:o==="repo:add",className:"shrink-0 whitespace-nowrap",children:[o==="repo:add"?e.jsx(ee,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Ea,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.repo.add")]})]}),a.length?e.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(g=>{const c=o===`repo:${g.owner}/${g.name}`;return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[g.owner,"/",g.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:g.branch})]}),e.jsxs(H,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>x(g),className:"shrink-0",children:[c?e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(xa,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${g.owner}/${g.name}`)})}):null]})}function Gr(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function js(){const a=Nt()||{},s=!!a.signedIn,d=a.getAccessToken,[o,h]=i.useState(Gr),[x,g]=i.useState({skills:[],targets:[]}),[c,y]=i.useState([]),[k,p]=i.useState([]),[C,R]=i.useState([]),[u,v]=i.useState(ce),[m,S]=i.useState(""),[L,A]=i.useState(""),[O,F]=i.useState(""),[oe,D]=i.useState(""),[be,ue]=i.useState(""),[me,I]=i.useState(!1),[$,M]=i.useState("all"),[T,G]=i.useState(null),[V,ke]=i.useState(""),[Pe,He]=i.useState(!0),[De,Ge]=i.useState(!1),[Be,w]=i.useState(""),[E,le]=i.useState(null),[B,W]=i.useState(null),[_,we]=i.useState(()=>new Set),[Te,ve]=i.useState({}),[Ee,je]=i.useState({}),[ge,ra]=i.useState([]),[Ae,We]=i.useState(!1),xe=i.useRef(!1),ae=i.useRef(0),Oe=i.useMemo(()=>Or(x.skills),[x.skills]),Ne=i.useCallback(async()=>{const t=++ae.current,n=await Wt();if(ae.current!==t)return;const l={skills:n.skills||[],targets:n.targets||[]};g(l);const f=Ct();!s||!St()||!f||typeof d!="function"||(async()=>{try{const j=await d();if(!j||ae.current!==t)return;const[N]=await Promise.allSettled([Qt(j),Xt({accessToken:j,deviceId:f,skills:l.skills})]);if(N.status!=="fulfilled")return;const Ve=N.value;if(ae.current!==t)return;g({targets:l.targets,skills:Jt(l.skills,Ve,f)})}catch{}})()},[d,s]),Q=i.useCallback(async()=>{const t=await Yt();R(t.repos||[])},[]),P=i.useCallback(async({force:t=!1}={})=>{Ge(!0);try{const n=await Zt({force:t});y(n.skills||[])}finally{Ge(!1)}},[]),Ce=i.useCallback(async({force:t=!1}={})=>{We(!0);try{const n=await er({force:t});ra(n.skills||[])}finally{We(!1)}},[]),te=i.useCallback(async()=>{try{const t=await ar();ve(t?.updates||{})}catch{ve({})}},[]),X=i.useCallback(async()=>{try{const t=await tr(),n={};for(const l of t?.skills||[])l.installed&&(l.directory&&(n[String(l.directory).toLowerCase()]=l),n[String(l.skill).toLowerCase()]=l);je(n)}catch{je({})}},[]),de=i.useCallback(async()=>{He(!0),w("");try{await Promise.all([Ne(),Q()])}catch(t){w(t?.message||r("skills.error.generic"))}finally{He(!1)}},[Ne,Q]),re=i.useCallback(async()=>{await de();const t=n=>w(n?.message||r("skills.error.generic"));o==="my"?(te(),X()):u===K?Ce({force:!0}).catch(t):u!==U&&P({force:!0}).catch(t)},[P,de,Ce,te,X,u,o]);i.useEffect(()=>{de()},[de]),i.useEffect(()=>{if(xe.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){xe.current=!0;return}const l=x.skills||[];if(!l.length)return;const f=l.find(N=>N.directory===n||N.id===n);f&&(h("my"),G(f.id||f.directory)),xe.current=!0,t.delete("skill");const j=t.toString();window.history.replaceState({},"",`${window.location.pathname}${j?`?${j}`:""}${window.location.hash}`)},[x.skills]),i.useEffect(()=>{o==="browse"&&(u===U||u===K||c.length===0&&P().catch(t=>w(t?.message||r("skills.error.generic"))))},[c.length,P,u,o]),i.useEffect(()=>{o!=="browse"||u!==K||ge.length===0&&Ce().catch(t=>w(t?.message||r("skills.error.generic")))},[Ce,ge.length,u,o]);const $e=Object.keys(Te).length>0,Me=Object.keys(Ee).length>0;if(i.useEffect(()=>{o==="my"&&($e||te(),Me||X())},[o,$e,Me,te,X]),i.useEffect(()=>{const t=setTimeout(()=>A(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>D(O),120);return()=>clearTimeout(t)},[O]),i.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("tab");if(o==="my"){if(!n)return;t.delete("tab")}else{if(n===o)return;t.set("tab",o)}const l=t.toString(),f=`${window.location.pathname}${l?`?${l}`:""}${window.location.hash}`;window.history.replaceState({},"",f)},[o]),!Dr&&!_t())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Pt,{})});const J=async(t,n)=>{ke(t),w("");try{await n(),await Ne()}catch(l){w(l?.message||r("skills.error.generic"))}finally{ke("")}},sa=(t,n)=>{const l=(n&&n.length?n:la).filter(f=>(x.targets||[]).some(j=>j.id===f));J(Ye(t),async()=>{await ba(t,l);const f=l.map(j=>(x.targets||[]).find(N=>N.id===j)?.label||j).join(", ");Ie({title:r("skills.toast.installed",{name:t.name||t.directory,targets:f||r("skills.target.none")}),timeout:4e3})})},na=t=>{t?.readOnly||t?.remote||le(t)},ia=()=>{const t=E;t&&(le(null),J(Ca(t),async()=>{let n=null;t.managed?n=await ka(t.id):await wa(t.directory,t.targets||[]);const l=!!(n?.trashed&&t.managed&&t.id);Ie({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:l?{onUndo:async()=>{try{await sr(t.id),await Ne()}catch(f){w(f?.message||r("skills.error.generic"))}}}:void 0})}))},Se=(t,n,l)=>t?.readOnly||t?.remote?Promise.resolve():J(Xa(fe(t),n),async()=>{const f=new Set(t.targets||[]);l?f.add(n):f.delete(n),t.managed?await va(t.id,Array.from(f)):await ja(t.directory,Array.from(f));const j={name:t.name||t.directory,agent:_e(n)};Ie({title:l?r("skills.toast.synced_one",j):r("skills.toast.unsynced_one",j),timeout:3e3})}),Ue=i.useCallback(()=>we(new Set),[]),Qe=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const l=fe(t);we(f=>{const j=new Set(f);return n?j.add(l):j.delete(l),j})},[]),_e=t=>(x.targets||[]).find(n=>n.id===t)?.label||t,b=t=>{const n=(x.skills||[]).filter(l=>_.has(fe(l))&&!l.readOnly&&!l.remote);n.length&&J("batch",async()=>{for(const l of n){const f=new Set(l.targets||[]);f.add(t),l.managed?await va(l.id,Array.from(f)):await ja(l.directory,Array.from(f))}Ue(),Ie({title:r("skills.toast.bulk_synced",{count:n.length,agent:_e(t)}),timeout:4e3})})},q=()=>{const t=(x.skills||[]).filter(n=>_.has(fe(n))&&!n.readOnly&&!n.remote);t.length&&W(t)},se=()=>{const t=B;t&&(W(null),J("batch",async()=>{for(const n of t)n.managed?await ka(n.id):await wa(n.directory,n.targets||[]);Ue(),Ie({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},ne=t=>{!t?.repoOwner||!t?.repoName||J(Ye(t),async()=>{await ba({key:t.key,name:t.name,description:t.description,directory:t.sourceDirectory||t.directory,repoOwner:t.repoOwner,repoName:t.repoName,repoBranch:t.repoBranch,readmeUrl:t.readmeUrl},t.targets&&t.targets.length?t.targets:la),await te(),Ie({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},he=async()=>{const t=m.trim();if(!(t.length<2)){ke("search"),w("");try{const n=await rr(t);p(n.skills||[])}catch(n){w(n?.message||r("skills.error.generic"))}finally{ke("")}}},Fe=async()=>{const t=be.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,l]=t.split("/");if(!n||!l){w(r("skills.repo.invalid"));return}await J("repo:add",async()=>{await ir({owner:n,name:l,branch:"main",enabled:!0}),ue(""),await Q(),await P()})},ze=async t=>{await J(`repo:${t.owner}/${t.name}`,async()=>{await nr(t.owner,t.name),await Q(),await P()})},ie=x.targets||[],Ja=ie.filter(pa),pe=x.skills||[],Ya=i.useMemo(()=>{const t=$==="all"?pe:pe.filter(l=>(l.targets||[]).includes($)),n=oe.trim().toLowerCase();return n?t.filter(l=>(l.name||"").toLowerCase().includes(n)||(l.directory||"").toLowerCase().includes(n)||(l.description||"").toLowerCase().includes(n)):t},[pe,$,oe]),Za=$!=="all",Y=i.useMemo(()=>T&&pe.find(t=>(t.id||t.directory)===T)||null,[pe,T]),et=i.useCallback(()=>{M("all"),F("")},[]),at=i.useCallback(t=>{G(n=>{const l=t?.id||t?.directory||null;return n===l?null:l})},[]),tt=i.useCallback(()=>G(null),[]),rt=i.useCallback(t=>{const n=ta(t).toLowerCase(),l=Na(t),f=(x.skills||[]).find(j=>{const N=Qa(j);return N.has(n)||l&&N.has(l)});f&&G(f.id||f.directory)},[x.skills]);i.useEffect(()=>{o!=="my"&&_.size&&we(new Set)},[o,_.size]),i.useEffect(()=>{T&&!Y&&G(null)},[Y,T]);const Ke=i.useMemo(()=>{const t=u===U?k:u===K?ge:c,l=u===U||u===K||u===ce?t:t.filter(N=>`${N.repoOwner}/${N.repoName}`===u),f=L.trim().toLowerCase();return(u===U||!f?l:l.filter(N=>(N.name||"").toLowerCase().includes(f)||(N.directory||"").toLowerCase().includes(f)||(N.description||"").toLowerCase().includes(f))).map(N=>{const Ve=ta(N).toLowerCase(),z=Na(N);return{...N,installed:Oe.has(Ve)||z&&Oe.has(z)}})},[L,c,Oe,ge,k,u]),st=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(ee,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),nt=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(ee,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),e.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.browse.loading_hint")})]}),Xe=(t,n=null)=>e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r(t)}),n]});let Je;if(Pe)Je=st;else if(o==="my")Je=pe.length?e.jsx(Kr,{items:Ya,totalCount:pe.length,targets:ie,agentOptions:ie,agentFilter:$,onAgentFilter:M,anyFilter:Za,onClearFilters:et,searchQuery:O,onSearchQuery:F,searchPlaceholder:r("skills.my.placeholder"),selectedId:T,onSelect:at,onToggleTarget:Se,busyKey:V,updates:Te,selectedIds:_,onToggleSelect:Qe,onClearSelection:Ue,onBulkSync:b,onBulkRemove:q}):e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-800",children:[ie.length>0?e.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)",WebkitMaskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[...ie,...ie].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ye,{provider:t.id,size:30})},`b-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)",WebkitMaskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...ie,...ie].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ye,{provider:t.id,size:30})},`c-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-oai-white to-transparent dark:from-oai-gray-900"}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-oai-white to-transparent dark:from-oai-gray-900"})]}):null,e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.empty.my")}),e.jsx(H,{type:"button",size:"sm",onClick:()=>h("browse"),children:r("skills.empty.my_cta")})]});else{const t=u===U,n=u===K,l=C.length===0&&!t&&!n,f=De&&!t&&!n||n&&Ae,j=!t&&!n&&(L.trim()!==""||u!==ce),N=()=>{S(""),v(ce)},Ve=!l&&!f&&(Ke.length>0||j)?e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 px-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("skills.filter.result_count_browse",{count:Ke.length})}),j?e.jsxs("button",{type:"button",onClick:N,className:"ml-auto inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Re,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let z;l?z=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:e.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:r("skills.browse.empty_sources")})}):f?z=nt:t&&m.trim().length<2?z=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 px-4 py-6 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:r("skills.browse.hint_skillssh")}):Ke.length?z=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Ke.map(qe=>e.jsx("div",{style:Vr,children:e.jsx(qr,{skill:qe,installed:!!qe.installed,installing:V===Ye(qe),allTargets:Ja,defaultTargets:la,onInstall:sa,onManage:rt})},qe.id||qe.key))}):j?z=Xe("skills.empty.no_match",e.jsx(H,{type:"button",variant:"secondary",size:"sm",onClick:N,children:r("skills.filter.clear")})):t?z=Xe("skills.empty.search"):n?z=Xe("skills.empty.popular"):z=Xe("skills.empty.browse");const it=l||me?e.jsx("div",{className:"mb-5",children:e.jsx(Hr,{repos:C,repoInput:be,onRepoInput:ue,busyKey:V,onAdd:Fe,onRemove:ze})}):null,ot=!me&&!t&&!n&&C.length<=1&&Ke.length>0?e.jsx(ur,{id:"skills-browse-intro",className:"mt-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{children:r("skills.browse.add_repo_hint")}),e.jsx("button",{type:"button",onClick:()=>I(!0),className:"rounded font-medium text-oai-gray-700 underline decoration-dotted underline-offset-2 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-200 dark:hover:text-white",children:r("skills.browse.manage_sources")})]})}):null;Je=e.jsxs(e.Fragment,{children:[it,Ve,z,ot]})}return e.jsxs("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:[e.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:r("skills.page.title")}),e.jsxs(H,{type:"button",variant:"secondary",size:"sm",onClick:re,disabled:Pe||De||Ae,children:[e.jsx(It,{className:Z("mr-1.5 h-3.5 w-3.5",(Pe||De||Ae)&&"animate-spin"),"aria-hidden":!0}),r("skills.action.refresh")]})]}),e.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",r("skills.tab.my")],["browse",r("skills.tab.browse")]].map(([t,n])=>e.jsx("button",{type:"button","aria-pressed":o===t,onClick:()=>h(t),className:Z("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",o===t?"border-oai-black text-oai-black dark:border-white dark:text-white":"border-transparent text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:n},t))}),Be?e.jsx("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-200",children:Be}):null,o==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx(Bt,{className:"shrink-0",ariaLabel:r("skills.source.label"),options:[{id:"repo",label:r("skills.mode.repo")},{id:"popular",label:r("skills.mode.popular"),icon:e.jsx(or,{className:"h-3.5 w-3.5","aria-hidden":!0})},{id:"skillssh",label:r("skills.mode.skillssh")}],value:u===U?"skillssh":u===K?"popular":"repo",onChange:t=>{t==="skillssh"?v(U):t==="popular"?v(K):(u===U||u===K)&&v(ce)}}),u!==U&&u!==K?e.jsxs(Ia,{value:u,onValueChange:v,children:[e.jsxs(Ra,{"aria-label":r("skills.source.label"),className:"inline-flex h-8 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs text-oai-black focus:outline-none data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:data-[popup-open]:border-oai-gray-700",children:[e.jsx(La,{children:t=>t===ce?r("skills.source.all"):t}),e.jsx(Ka,{className:"text-oai-gray-400",children:e.jsx(ha,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Pa,{children:e.jsx(Da,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ba,{className:"min-w-[var(--anchor-width)] overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none transition-[opacity,transform] duration-150 ease-out data-[ending-style]:scale-[0.97] data-[ending-style]:opacity-0 data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0 dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs(Ze,{value:ce,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ea,{children:r("skills.source.all")}),e.jsx(aa,{children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),C.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(Ze,{value:n,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ea,{children:n}),e.jsx(aa,{children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ua,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(ga,{type:"search",value:m,onChange:t=>S(t.target.value),onKeyDown:t=>{t.key==="Enter"&&u===U&&he()},"aria-label":r("skills.action.search_aria"),placeholder:u===U?r("skills.browse.placeholder_skillssh"):u===K?r("skills.browse.placeholder_popular"):u===ce?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:u}),className:"h-8 pl-9 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20"})]}),u===U?e.jsxs(H,{type:"button",size:"sm",onClick:he,disabled:m.trim().length<2||V==="search",className:"focus:!ring-oai-gray-400/30",children:[V==="search"?e.jsx(ee,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(ua,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):u===K?null:e.jsxs(H,{type:"button",variant:"secondary",size:"sm",onClick:()=>I(t=>!t),"aria-expanded":me,className:"!h-8 shrink-0 whitespace-nowrap !border-oai-gray-200 dark:!border-oai-gray-800 hover:!border-oai-gray-300 dark:hover:!border-oai-gray-700 hover:!text-oai-black dark:hover:!text-white focus:!ring-oai-gray-400/30",children:[e.jsx(Ea,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.browse.manage_sources"),e.jsx("span",{className:"ml-1.5 rounded bg-oai-gray-100 px-1.5 py-0.5 text-xs font-medium text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:C.length})]})]}):null,Je,e.jsx(Lr,{skill:Y,targets:ie,busyKey:V,usage:Y&&(Ee[String(Y.directory||"").toLowerCase()]||Ee[String(Y.name||"").toLowerCase()])||null,hasUpdate:!!(Y?.id&&Te?.[Y.id]),updating:Y?V===Ye(Y):!1,onUpdate:ne,onClose:tt,onToggleTarget:Se,onRemove:na})]})}),e.jsx(fa,{open:!!E,title:r("skills.confirm.remove_title",{name:E?.name||E?.directory||""}),description:E?E.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:V===Ca(E||{}),onCancel:()=>le(null),onConfirm:ia}),e.jsx(fa,{open:!!B,title:r("skills.confirm.bulk_remove_title",{count:B?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:V==="batch",onCancel:()=>W(null),onConfirm:se})]})}export{js as SkillsPage,Or as buildLocallyInstalledKeys};
@@ -1 +0,0 @@
1
- import{r as o}from"./__vite-browser-external-BDkeh90N.js";import{h as r,i as t,p as s}from"./react-BmFZKA_b.js";function i(){!r.current&&t();const[e]=o.useState(s.current);return e}export{i as u};