figma-lupa 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -380,26 +380,26 @@ var require_permessage_deflate = __commonJS({
380
380
  value = value[0];
381
381
  if (key === "client_max_window_bits") {
382
382
  if (value !== true) {
383
- const num2 = +value;
384
- if (!Number.isInteger(num2) || num2 < 8 || num2 > 15) {
383
+ const num3 = +value;
384
+ if (!Number.isInteger(num3) || num3 < 8 || num3 > 15) {
385
385
  throw new TypeError(
386
386
  `Invalid value for parameter "${key}": ${value}`
387
387
  );
388
388
  }
389
- value = num2;
389
+ value = num3;
390
390
  } else if (!this._isServer) {
391
391
  throw new TypeError(
392
392
  `Invalid value for parameter "${key}": ${value}`
393
393
  );
394
394
  }
395
395
  } else if (key === "server_max_window_bits") {
396
- const num2 = +value;
397
- if (!Number.isInteger(num2) || num2 < 8 || num2 > 15) {
396
+ const num3 = +value;
397
+ if (!Number.isInteger(num3) || num3 < 8 || num3 > 15) {
398
398
  throw new TypeError(
399
399
  `Invalid value for parameter "${key}": ${value}`
400
400
  );
401
401
  }
402
- value = num2;
402
+ value = num3;
403
403
  } else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
404
404
  if (value !== true) {
405
405
  throw new TypeError(
@@ -1113,8 +1113,8 @@ var require_receiver = __commonJS({
1113
1113
  return;
1114
1114
  }
1115
1115
  const buf = this.consume(8);
1116
- const num2 = buf.readUInt32BE(0);
1117
- if (num2 > Math.pow(2, 53 - 32) - 1) {
1116
+ const num3 = buf.readUInt32BE(0);
1117
+ if (num3 > Math.pow(2, 53 - 32) - 1) {
1118
1118
  const error62 = this.createError(
1119
1119
  RangeError,
1120
1120
  "Unsupported WebSocket frame: payload length > 2^53 - 1",
@@ -1125,7 +1125,7 @@ var require_receiver = __commonJS({
1125
1125
  cb(error62);
1126
1126
  return;
1127
1127
  }
1128
- this._payloadLength = num2 * Math.pow(2, 32) + buf.readUInt32BE(4);
1128
+ this._payloadLength = num3 * Math.pow(2, 32) + buf.readUInt32BE(4);
1129
1129
  this.haveLength(cb);
1130
1130
  }
1131
1131
  /**
@@ -2257,9 +2257,9 @@ var require_extension = __commonJS({
2257
2257
  return configurations.map((params) => {
2258
2258
  return [extension2].concat(
2259
2259
  Object.keys(params).map((k) => {
2260
- let values = params[k];
2261
- if (!Array.isArray(values)) values = [values];
2262
- return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
2260
+ let values2 = params[k];
2261
+ if (!Array.isArray(values2)) values2 = [values2];
2262
+ return values2.map((v) => v === true ? k : `${k}=${v}`).join("; ");
2263
2263
  })
2264
2264
  ).join("; ");
2265
2265
  }).join(", ");
@@ -3743,7 +3743,7 @@ var init_package = __esm({
3743
3743
  "package.json"() {
3744
3744
  package_default = {
3745
3745
  name: "figma-lupa",
3746
- version: "0.2.2",
3746
+ version: "0.3.0",
3747
3747
  description: "Read-only Figma CLI, MCP server and plugin for pixel-faithful design-to-code with a small context footprint.",
3748
3748
  type: "module",
3749
3749
  license: "GPL-3.0-or-later",
@@ -4258,7 +4258,7 @@ var init_legend = __esm({
4258
4258
  "+N more like \u2191" / "+N more alternating like the 2 above" = siblings with the same structure as the layer(s) just printed; the lines under it give each one's id and its own texts/images.
4259
4259
  "\u2026 +N layers not shown \u2192 get_design #id" = cut by the token budget; fetch that subtree when you need it.
4260
4260
  // lines = designer notes, prototype interactions, component props, exports.
4261
- Codebase: "\u2192 var(--x)" after a colour or font = the project's own variable for that value; "\u2192 .class" after a typography token = its text style class. "// project has: \u2026" = where the project defines that component. A src: outside the assets folder = the project's own icon with the same drawing.
4261
+ Codebase: "\u2192 var(--x)" after a colour or font = the project's own variable for that value; "\u2192 .class" after a typography token = its text style class. Tailwind theme (v4 @theme or v3 tailwind.config): "\u2192 *-grey-200" = that colour's utilities (bg-grey-200, text-grey-200, border-grey-200\u2026), "\u2192 font-sans" = the font utility, "\u2192 text-sm font-medium leading-[20px]" = utility classes for a typography token. "// project has: \u2026" = where the project defines that component, with its props when Lupa can read them (<Button variant="default*|outline"> for React cva/tv variants or string-union props, <.button variant="primary"> <:actions> for Phoenix attrs and slots; * = default). A src: outside the assets folder = the project's own icon with the same drawing; src:<PlusIcon /> (components/icons/plus.tsx) = the project's own icon component; src:<ChevronDown /> from lucide-react or src:<.icon name="hero-x-mark" /> = that icon from the project's icon library (no file written).
4262
4262
  Reproduce exact values (sizes, spacing, colours, type). Before writing any colour, $token or raw (#hex, rgba), look for the codebase's own token with that name or value (Tailwind theme, CSS variables, theme object) and use it; hardcode only when none matches.`;
4263
4263
  }
4264
4264
  });
@@ -4924,9 +4924,9 @@ var init_build = __esm({
4924
4924
  LINE: "line"
4925
4925
  };
4926
4926
  Builder = class {
4927
- constructor(snap, files) {
4927
+ constructor(snap, files2) {
4928
4928
  this.snap = snap;
4929
- this.files = files;
4929
+ this.files = files2;
4930
4930
  this.reg = new Registry(snap);
4931
4931
  }
4932
4932
  reg;
@@ -5053,18 +5053,18 @@ var init_build = __esm({
5053
5053
  if (!raw.layoutMode || raw.graphic) return;
5054
5054
  const L = ir.layout;
5055
5055
  const bv = raw.boundVariables ?? {};
5056
- const num2 = (key) => this.reg.number(raw[key] ?? 0, bv[key]?.id);
5056
+ const num3 = (key) => this.reg.number(raw[key] ?? 0, bv[key]?.id);
5057
5057
  if (raw.layoutMode === "GRID") {
5058
5058
  const tracks = (t, count) => (t?.length ? t : Array.from({ length: count ?? 0 }, () => ({ type: "FLEX", value: 1 }))).map((s) => s.type === "FIXED" ? n(s.value ?? 0) : s.type === "HUG" ? "auto" : `${n(s.value ?? 1)}fr`).join(",");
5059
5059
  L.grid = "";
5060
5060
  L.cols = emptyTracks(raw, "col", tracks(raw.gridColumnSizes, raw.gridColumnCount));
5061
5061
  L.rows = emptyTracks(raw, "row", tracks(raw.gridRowSizes, raw.gridRowCount));
5062
- if (raw.gridColumnGap) L.gap = num2("gridColumnGap");
5063
- if (raw.gridRowGap) L.rowgap = num2("gridRowGap");
5062
+ if (raw.gridColumnGap) L.gap = num3("gridColumnGap");
5063
+ if (raw.gridRowGap) L.rowgap = num3("gridRowGap");
5064
5064
  } else {
5065
5065
  L[raw.layoutMode === "VERTICAL" ? "col" : "row"] = "";
5066
5066
  if (raw.primaryAxisAlignItems === "SPACE_BETWEEN") L.justify = "between";
5067
- else if (raw.itemSpacing) L.gap = num2("itemSpacing");
5067
+ else if (raw.itemSpacing) L.gap = num3("itemSpacing");
5068
5068
  if (raw.layoutWrap) {
5069
5069
  L.wrap = "";
5070
5070
  if (raw.counterAxisSpacing) L.rowgap = this.reg.number(raw.counterAxisSpacing, bv.counterAxisSpacing?.id);
@@ -5080,8 +5080,8 @@ var init_build = __esm({
5080
5080
  const pad = (key, side) => {
5081
5081
  const v = raw[key] ?? 0;
5082
5082
  const w = inset?.[side] ?? 0;
5083
- if (!w || v < w) return num2(key);
5084
- const ref = num2(key);
5083
+ if (!w || v < w) return num3(key);
5084
+ const ref = num3(key);
5085
5085
  return ref.startsWith("$") ? `calc(${ref} - ${n(w)})` : n(v - w);
5086
5086
  };
5087
5087
  const p = sides(pad("paddingTop", 0), pad("paddingRight", 1), pad("paddingBottom", 2), pad("paddingLeft", 3));
@@ -5165,8 +5165,8 @@ var init_build = __esm({
5165
5165
  const full = raw.cornerRadius >= Math.min(raw.w, raw.h) / 2 - 0.01 && Math.min(raw.w, raw.h) > 0;
5166
5166
  S.radius = bv.cornerRadius ? this.reg.number(raw.cornerRadius, bv.cornerRadius.id) : full ? "full" : n(raw.cornerRadius);
5167
5167
  } else if (raw.radii) {
5168
- const keys = ["topLeftRadius", "topRightRadius", "bottomRightRadius", "bottomLeftRadius"];
5169
- S.radius = raw.radii.map((r, i) => this.reg.number(r, bv[keys[i]]?.id)).join(",");
5168
+ const keys2 = ["topLeftRadius", "topRightRadius", "bottomRightRadius", "bottomLeftRadius"];
5169
+ S.radius = raw.radii.map((r, i) => this.reg.number(r, bv[keys2[i]]?.id)).join(",");
5170
5170
  }
5171
5171
  if (raw.cornerSmoothing && S.radius) S.smooth = `${n(raw.cornerSmoothing * 100, 0)}%`;
5172
5172
  }
@@ -5449,7 +5449,7 @@ var init_components = __esm({
5449
5449
  this.diffChildren(inst, def, "", out, keyOf, resized);
5450
5450
  return out;
5451
5451
  }
5452
- diffChildren(a, d, path6, out, keyOf, resized) {
5452
+ diffChildren(a, d, path7, out, keyOf, resized) {
5453
5453
  const defByKey = new Map(d.children.map((c) => [keyOf(c, true), c]));
5454
5454
  const matched = /* @__PURE__ */ new Set();
5455
5455
  const names = pathNames(d.children);
@@ -5460,7 +5460,7 @@ var init_components = __esm({
5460
5460
  const cand = d.children[a.children.indexOf(child)];
5461
5461
  dc = ok(cand) ? cand : d.children.find(ok);
5462
5462
  }
5463
- const p = joinPath(path6, dc ? names.get(dc) ?? dc.name : child.name);
5463
+ const p = joinPath(path7, dc ? names.get(dc) ?? dc.name : child.name);
5464
5464
  if (!dc) {
5465
5465
  out.push({ path: p, changes: ["added"], sub: child });
5466
5466
  continue;
@@ -5471,20 +5471,20 @@ var init_components = __esm({
5471
5471
  for (const dc of d.children) {
5472
5472
  if (matched.has(dc) || dc.hidden) continue;
5473
5473
  if (dc.propRefs?.visible) continue;
5474
- out.push({ path: joinPath(path6, names.get(dc) ?? dc.name), changes: ["hidden"] });
5474
+ out.push({ path: joinPath(path7, names.get(dc) ?? dc.name), changes: ["hidden"] });
5475
5475
  }
5476
5476
  }
5477
- diffNode(a, d, path6, out, keyOf, resized) {
5477
+ diffNode(a, d, path7, out, keyOf, resized) {
5478
5478
  if (a.hidden && !d.hidden) {
5479
- if (!d.propRefs?.visible) out.push({ path: path6, changes: ["hidden"] });
5479
+ if (!d.propRefs?.visible) out.push({ path: path7, changes: ["hidden"] });
5480
5480
  return;
5481
5481
  }
5482
5482
  if (!a.hidden && d.hidden) {
5483
5483
  if (d.propRefs?.visible) {
5484
5484
  const changes2 = this.nodeChanges(a, d, resized);
5485
- if (changes2.length) out.push({ path: path6, changes: changes2 });
5486
- this.diffChildren(a, d, path6, out, keyOf, resized);
5487
- } else out.push({ path: path6, changes: ["shown"], sub: a });
5485
+ if (changes2.length) out.push({ path: path7, changes: changes2 });
5486
+ this.diffChildren(a, d, path7, out, keyOf, resized);
5487
+ } else out.push({ path: path7, changes: ["shown"], sub: a });
5488
5488
  return;
5489
5489
  }
5490
5490
  if (a.hidden) return;
@@ -5498,22 +5498,22 @@ var init_components = __esm({
5498
5498
  if (a.kind === "svg" || !a.children.length) {
5499
5499
  if (a.kind === "svg" && a.style.src !== d.style.src && a.style.src) changes2.push(`src:${a.style.src}`);
5500
5500
  if (a.kind === "svg" && a.style.color !== d.style.color && a.style.color) changes2.push(`color:${a.style.color}`);
5501
- if (changes2.length) out.push({ path: path6, changes: changes2 });
5501
+ if (changes2.length) out.push({ path: path7, changes: changes2 });
5502
5502
  } else if (def) {
5503
5503
  changes2.push(...this.rootChanges(a, def.ir));
5504
- if (changes2.length) out.push({ path: path6, changes: changes2 });
5504
+ if (changes2.length) out.push({ path: path7, changes: changes2 });
5505
5505
  const nested = this.overrides(a, def.ir);
5506
- for (const o2 of nested) out.push({ ...o2, path: joinPath(path6, o2.path) });
5506
+ for (const o2 of nested) out.push({ ...o2, path: joinPath(path7, o2.path) });
5507
5507
  } else {
5508
- out.push({ path: path6, changes: changes2.length ? changes2 : [`swap\u2192${label}`], sub: a });
5508
+ out.push({ path: path7, changes: changes2.length ? changes2 : [`swap\u2192${label}`], sub: a });
5509
5509
  }
5510
5510
  return;
5511
5511
  }
5512
5512
  const changes = this.nodeChanges(a, d, resized);
5513
- const o = { path: path6, changes };
5513
+ const o = { path: path7, changes };
5514
5514
  if (a.runs && JSON.stringify(a.runs) !== JSON.stringify(d.runs)) o.runs = a.runs;
5515
5515
  if (changes.length || o.runs) out.push(o);
5516
- if (a.kind !== "svg") this.diffChildren(a, d, path6, out, keyOf, resized);
5516
+ if (a.kind !== "svg") this.diffChildren(a, d, path7, out, keyOf, resized);
5517
5517
  }
5518
5518
  nodeChanges(a, d, resized) {
5519
5519
  const changes = [];
@@ -5697,12 +5697,12 @@ var init_render = __esm({
5697
5697
  const fonts = this.fonts([...roots, ...[...this.comps.defs.values()].filter((d) => charged.has(d.mainId)).map((d) => d.ir)]);
5698
5698
  if (fonts) head.push(`fonts: ${fonts}`);
5699
5699
  const assets = this.assets(roots);
5700
- const files = this.opts.files;
5701
- if (files) {
5702
- const own2 = files.reused?.size ?? 0;
5703
- const count = (/* @__PURE__ */ new Set([...files.byNode.values(), ...files.byImage.values()])).size - own2;
5700
+ const files2 = this.opts.files;
5701
+ if (files2) {
5702
+ const own2 = files2.reused?.size ?? 0;
5703
+ const count = (/* @__PURE__ */ new Set([...files2.byNode.values(), ...files2.byImage.values()])).size - own2;
5704
5704
  const ownNote = own2 ? ` + ${own2} icon${own2 === 1 ? "" : "s"} the project already has` : "";
5705
- head.push(`assets: ${count} file${count === 1 ? "" : "s"} in ${files.dir}/${ownNote}, named by src: on each layer${files.failures.length ? ` (${files.failures.length} failed \u2192 export_assets)` : ""}`);
5705
+ head.push(`assets: ${count} file${count === 1 ? "" : "s"} in ${files2.dir}/${ownNote}, named by src: on each layer${files2.failures.length ? ` (${files2.failures.length} failed \u2192 export_assets)` : ""}`);
5706
5706
  } else if (assets) head.push(`assets: ${assets} \u2192 export_assets`);
5707
5707
  if (cut) head.push(`budget: tree cut breadth-first at ~${Math.round(this.budgetChars / CHARS_PER_TOKEN)} tokens \u2014 "not shown" markers say how to expand`);
5708
5708
  if (this.snap.stats.truncated) head.push(`warning: snapshot hit the node limit; some layers were not loaded`);
@@ -6041,9 +6041,9 @@ function formatOutline(o) {
6041
6041
  function formatMatches(r) {
6042
6042
  if (!r.matches.length) return "No matches.";
6043
6043
  const out = r.matches.map((m) => {
6044
- const path6 = [m.page, ...m.path].filter(Boolean).join(" \u203A ");
6044
+ const path7 = [m.page, ...m.path].filter(Boolean).join(" \u203A ");
6045
6045
  const text2 = m.text !== void 0 ? ` ${JSON.stringify(m.text)}` : "";
6046
- return `${m.type.toLowerCase()} "${m.name}" #${m.id} ${m.w}\xD7${m.h}${text2} \u2014 ${path6}`;
6046
+ return `${m.type.toLowerCase()} "${m.name}" #${m.id} ${m.w}\xD7${m.h}${text2} \u2014 ${path7}`;
6047
6047
  });
6048
6048
  if (r.truncated) out.push("\u2026 more matches; narrow the query, page or type.");
6049
6049
  return out.join("\n");
@@ -6102,9 +6102,9 @@ function formatTokens(t, format, filter) {
6102
6102
  if (!vars.length) continue;
6103
6103
  lines.push(`${c.name}${c.remote ? " (library)" : ""} \u2014 modes: ${c.modes.map((m) => m.name).join(" | ")}`);
6104
6104
  for (const v of vars) {
6105
- const values = c.modes.map((m) => tokenValue(v.values[m.id], v.type));
6106
- const uniq = new Set(values);
6107
- lines.push(` ${v.name} = ${uniq.size === 1 ? values[0] : values.join(" | ")}${v.web ? ` ${v.web}` : ""}${v.description ? ` \u2014 ${v.description.slice(0, 80)}` : ""}`);
6105
+ const values2 = c.modes.map((m) => tokenValue(v.values[m.id], v.type));
6106
+ const uniq = new Set(values2);
6107
+ lines.push(` ${v.name} = ${uniq.size === 1 ? values2[0] : values2.join(" | ")}${v.web ? ` ${v.web}` : ""}${v.description ? ` \u2014 ${v.description.slice(0, 80)}` : ""}`);
6108
6108
  }
6109
6109
  }
6110
6110
  }
@@ -6141,32 +6141,1654 @@ var init_format = __esm({
6141
6141
  }
6142
6142
  });
6143
6143
 
6144
+ // src/tools/icons.ts
6145
+ import { readdir, readFile as readFile2, stat as stat2 } from "node:fs/promises";
6146
+ import path3 from "node:path";
6147
+ async function exists(p) {
6148
+ try {
6149
+ await stat2(p);
6150
+ return true;
6151
+ } catch {
6152
+ return false;
6153
+ }
6154
+ }
6155
+ async function installed(from, root, pkg) {
6156
+ for (let dir = from; ; dir = path3.dirname(dir)) {
6157
+ const p = path3.join(dir, "node_modules", pkg);
6158
+ if (await exists(p)) return p;
6159
+ if (dir === root || path3.dirname(dir) === dir || !dir.startsWith(root)) return void 0;
6160
+ }
6161
+ }
6162
+ async function files(dir, re) {
6163
+ try {
6164
+ return (await readdir(dir)).filter((f) => re.test(f)).sort().map((f) => path3.join(dir, f));
6165
+ } catch {
6166
+ return [];
6167
+ }
6168
+ }
6169
+ function once(f) {
6170
+ let p;
6171
+ return () => p ??= f();
6172
+ }
6173
+ async function svgFolder(dir, usage) {
6174
+ const out = [];
6175
+ for (const f of await files(dir, /\.svg$/i)) {
6176
+ const svg = await readFile2(f, "utf8").catch(() => "");
6177
+ const points = pointsOf(svg);
6178
+ const name = path3.basename(f, ".svg");
6179
+ if (points) out.push({ usage: usage(name), name, points });
6180
+ }
6181
+ return out;
6182
+ }
6183
+ async function lucideModules(pkgDir, pkg) {
6184
+ const out = [];
6185
+ for (const f of await files(path3.join(pkgDir, "dist/esm/icons"), /\.m?js$/)) {
6186
+ const js = await readFile2(f, "utf8").catch(() => "");
6187
+ const els = [...js.matchAll(/\[\s*"(path|circle|rect|ellipse|line|polyline|polygon)"\s*,\s*\{([^}]*)\}\s*\]/g)];
6188
+ if (!els.length) continue;
6189
+ const body = els.map((m) => `<${m[1]} ${[...m[2].matchAll(/(\w+)\s*:\s*"([^"]*)"/g)].filter((a) => a[1] !== "key").map((a) => `${a[1]}="${a[2]}"`).join(" ")}/>`).join("");
6190
+ const points = pointsOf(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">${body}</svg>`);
6191
+ const name = path3.basename(f).replace(/\.m?js$/, "");
6192
+ if (points) out.push({ usage: `<${pascal(name)} /> from ${pkg}`, name, points });
6193
+ }
6194
+ return out;
6195
+ }
6196
+ async function heroReact(pkgDir) {
6197
+ const out = [];
6198
+ for (const set2 of HERO_SETS) {
6199
+ for (const f of await files(path3.join(pkgDir, set2.dir), /Icon\.js$/)) {
6200
+ const js = await readFile2(f, "utf8").catch(() => "");
6201
+ const ds = [...js.matchAll(/\bd:\s*"([^"]+)"/g)].map((m) => `<path d="${m[1]}"/>`).join("");
6202
+ const size = set2.dir.split("/")[0];
6203
+ const points = pointsOf(`<svg viewBox="0 0 ${size} ${size}" ${set2.stroke ? 'fill="none" stroke="currentColor"' : ""}>${ds}</svg>`);
6204
+ const comp = path3.basename(f, ".js");
6205
+ const name = comp.replace(/Icon$/, "").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
6206
+ if (points) out.push({ usage: `<${comp} /> from @heroicons/react/${set2.dir}`, name, points });
6207
+ }
6208
+ }
6209
+ return out;
6210
+ }
6211
+ async function heroPhoenix(base) {
6212
+ const out = [];
6213
+ for (const set2 of HERO_SETS) out.push(...await svgFolder(path3.join(base, set2.dir), (n2) => `<.icon name="hero-${n2}${set2.suffix}" />`));
6214
+ return out;
6215
+ }
6216
+ function codeIcons(src, file2, phoenix = false) {
6217
+ const out = [];
6218
+ if (!src.includes("<svg")) return out;
6219
+ if (phoenix) {
6220
+ for (const m of src.matchAll(/\bdef\s+(\w+)\(assigns\)[^~]*?~H"""\s*(<svg\b[\s\S]*?<\/svg>)\s*"""/g)) {
6221
+ out.push({ usage: `<.${m[1]} /> (${file2})`, name: kebab(m[1]).replace(/-?icon-?/, ""), svg: plainSvg(m[2]) });
6222
+ }
6223
+ return out;
6224
+ }
6225
+ const defs = [...src.matchAll(/(?:function\s+([A-Z]\w*)|(?:const|let)\s+([A-Z]\w*)\s*(?::[^=]+)?=)/g)];
6226
+ for (const m of src.matchAll(/(?:return|=>)\s*\(?\s*(<svg\b[\s\S]*?<\/svg>)/g)) {
6227
+ const def = defs.filter((d) => d.index < m.index).pop();
6228
+ const name = def?.[1] ?? def?.[2];
6229
+ if (!name || !new RegExp(`export\\b[^\\n]*\\b${name}\\b`).test(src) || out.some((o) => o.usage.startsWith(`<${name} `))) continue;
6230
+ out.push({ usage: `<${name} /> (${file2})`, name: kebab(name.replace(/Icon$/, "")), svg: plainSvg(m[1]) });
6231
+ }
6232
+ return out;
6233
+ }
6234
+ function bracketed(t, open2) {
6235
+ let depth = 0;
6236
+ for (let i = open2; i < t.length; i++) {
6237
+ const c = t[i];
6238
+ if (c === '"' || c === "'" || c === "`") {
6239
+ for (i++; i < t.length && t[i] !== c; i++) if (t[i] === "\\") i++;
6240
+ } else if (c === "[" || c === "{") depth++;
6241
+ else if ((c === "]" || c === "}") && --depth === 0) return t.slice(open2, i + 1);
6242
+ }
6243
+ return t.slice(open2);
6244
+ }
6245
+ async function bannedImports(root, pkgs) {
6246
+ const out = /* @__PURE__ */ new Set();
6247
+ const quoted = (t, p) => t.includes(`'${p}'`) || t.includes(`"${p}"`);
6248
+ const names = [".oxlintrc.json", ".eslintrc", ".eslintrc.json", ".eslintrc.js", ".eslintrc.cjs", "eslint.config.js", "eslint.config.mjs", "eslint.config.cjs", "eslint.config.ts", "biome.json", "biome.jsonc"];
6249
+ for (const n2 of names) {
6250
+ const t = await readFile2(path3.join(root, n2), "utf8").catch(() => "");
6251
+ for (const m of t.matchAll(/(?:no-restricted-imports|noRestrictedImports)["']?\s*[:=]\s*/g)) {
6252
+ const at = m.index + m[0].length;
6253
+ if (t[at] !== "[" && t[at] !== "{") continue;
6254
+ const opts = bracketed(t, at);
6255
+ if (/^\[\s*["']off["']|^\[\s*0\b/.test(opts)) continue;
6256
+ for (const p of pkgs) if (quoted(opts, p)) out.add(p);
6257
+ }
6258
+ }
6259
+ const sg = await readFile2(path3.join(root, "sgconfig.yml"), "utf8").catch(() => "");
6260
+ const dirs = [...(/ruleDirs:\s*((?:\n\s*-\s*.+)+)/.exec(sg)?.[1] ?? "").matchAll(/-\s*["']?([^"'\n]+)/g)].map((m) => m[1].trim());
6261
+ for (const d of dirs) {
6262
+ for (const f of await files(path3.join(root, d), /\.ya?ml$/)) {
6263
+ const t = await readFile2(f, "utf8").catch(() => "");
6264
+ if (/^\s*severity:\s*off\b/m.test(t)) continue;
6265
+ for (const line of t.split("\n").filter((l) => /^\s*(?:-\s*)?pattern:/.test(l))) {
6266
+ for (const p of pkgs) if (/\b(?:from|import|require\s*\()/.test(line) && quoted(line, p)) out.add(p);
6267
+ }
6268
+ }
6269
+ }
6270
+ return out;
6271
+ }
6272
+ async function iconLibraries(root, manifests, own2 = []) {
6273
+ const libs = /* @__PURE__ */ new Map();
6274
+ if (own2.length) {
6275
+ libs.set("project", {
6276
+ name: "project",
6277
+ load: once(async () => own2.flatMap((i) => {
6278
+ const points = pointsOf(i.svg);
6279
+ return points ? [{ usage: i.usage, name: i.name, points }] : [];
6280
+ }))
6281
+ });
6282
+ }
6283
+ const banned = await bannedImports(root, ICON_PACKAGES);
6284
+ const add = (name, load) => {
6285
+ if (!libs.has(name)) libs.set(name, { name, load: once(load) });
6286
+ };
6287
+ const phoenix = manifests.some((m) => path3.basename(m) === "mix.exs");
6288
+ for (const m of manifests) {
6289
+ const dir = path3.dirname(m);
6290
+ const text2 = await readFile2(m, "utf8").catch(() => "");
6291
+ if (path3.basename(m) === "mix.exs") {
6292
+ if (/\{:heroicons\b/.test(text2)) {
6293
+ const base = path3.join(root, "deps/heroicons/optimized");
6294
+ if (await exists(base)) add("heroicons (Phoenix)", () => heroPhoenix(base));
6295
+ }
6296
+ if (/\{:lucide_icons\b/.test(text2)) {
6297
+ const base = path3.join(root, "deps/lucide_icons/priv/node_modules/lucide-static/icons");
6298
+ if (await exists(base)) add("lucide_icons", () => svgFolder(base, (n2) => `<Lucideicons.${n2.replace(/-/g, "_")} />`));
6299
+ }
6300
+ continue;
6301
+ }
6302
+ let deps = {};
6303
+ try {
6304
+ const pkg = JSON.parse(text2);
6305
+ deps = { ...pkg.dependencies, ...pkg.devDependencies };
6306
+ } catch {
6307
+ continue;
6308
+ }
6309
+ for (const pkg of ICON_PACKAGES) {
6310
+ if (!(pkg in deps) || banned.has(pkg)) continue;
6311
+ const at = await installed(dir, root, pkg);
6312
+ if (!at) continue;
6313
+ if (pkg === "lucide-react" || pkg === "lucide-vue-next") add(pkg, () => lucideModules(at, pkg));
6314
+ else if (pkg === "@heroicons/react") add(pkg, () => heroReact(at));
6315
+ else if (pkg === "heroicons" && phoenix) add("heroicons (Phoenix)", () => heroPhoenix(at));
6316
+ else if (pkg === "lucide-static") {
6317
+ add(pkg, () => svgFolder(path3.join(at, "icons"), (n2) => `lucide-static/icons/${n2}.svg`));
6318
+ }
6319
+ }
6320
+ }
6321
+ return [...libs.values()];
6322
+ }
6323
+ async function matchLibraryIcon(libs, svg, layerName = "") {
6324
+ if (!libs.length) return void 0;
6325
+ const p = pointsOf(svg);
6326
+ if (!p) return void 0;
6327
+ const wanted = layerName.split("/").pop().trim().toLowerCase().replace(/icon$/i, "").replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
6328
+ const icons = (await Promise.all(libs.map(async (lib) => (await lib.load()).map((icon) => ({ icon, own: lib.name === "project" }))))).flat();
6329
+ for (const fit of [false, true]) {
6330
+ const a = fit ? fitted(p) : p;
6331
+ let best;
6332
+ for (const { icon, own: own2 } of icons) {
6333
+ if (fit && icon.points.kind !== p.kind) continue;
6334
+ const q = fit ? fitted(icon.points) : icon.points;
6335
+ if (q.box.some((v, i) => Math.abs(v - a.box[i]) > 0.12)) continue;
6336
+ const score = compare(a, q, best?.score);
6337
+ if (score === void 0) continue;
6338
+ const s = score - (icon.name === wanted ? 0.01 : 0) - (own2 ? 0.01 : 0);
6339
+ if (!best || s < best.score) best = { icon, score: s };
6340
+ }
6341
+ if (best) return best.icon;
6342
+ }
6343
+ return void 0;
6344
+ }
6345
+ function fitted(p) {
6346
+ let f = fits.get(p);
6347
+ if (f) return f;
6348
+ const [x0, y0, x1, y1] = p.box;
6349
+ const size = Math.max(x1 - x0, y1 - y0) || 1;
6350
+ const cx = (x0 + x1) / 2;
6351
+ const cy = (y0 + y1) / 2;
6352
+ const xy = p.xy.map((v, i) => (v - (i % 2 ? cy : cx)) / size + 0.5);
6353
+ f = { xy, box: [(x0 - cx) / size + 0.5, (y0 - cy) / size + 0.5, (x1 - cx) / size + 0.5, (y1 - cy) / size + 0.5], kind: p.kind };
6354
+ fits.set(p, f);
6355
+ return f;
6356
+ }
6357
+ function compare(a, b, beat = Infinity) {
6358
+ const d1 = nearest(a.xy, b.xy, MAX_OFFSET + SPREAD);
6359
+ if (!d1) return void 0;
6360
+ const d2 = nearest(b.xy, a.xy, MAX_OFFSET + SPREAD);
6361
+ if (!d2) return void 0;
6362
+ const all = Float64Array.from([...d1, ...d2]).sort();
6363
+ const offset = all[all.length >> 1];
6364
+ const spread = all[all.length - 1] - offset;
6365
+ const maxOffset = a.kind === b.kind && a.kind !== "mixed" ? SAME_KIND_OFFSET : MAX_OFFSET;
6366
+ if (offset > maxOffset || spread > SPREAD) return void 0;
6367
+ const score = spread + offset / 4;
6368
+ return score < beat + 0.01 ? score : void 0;
6369
+ }
6370
+ function nearest(a, b, limit) {
6371
+ const out = [];
6372
+ const lim2 = limit * limit;
6373
+ const stride = 14;
6374
+ for (let s = 0; s < stride; s += 2) {
6375
+ for (let i = s; i < a.length; i += stride) {
6376
+ const x = a[i];
6377
+ const y = a[i + 1];
6378
+ let m = Infinity;
6379
+ for (let j = 0; j < b.length; j += 2) {
6380
+ const dx = b[j] - x;
6381
+ const dy = b[j + 1] - y;
6382
+ const d = dx * dx + dy * dy;
6383
+ if (d < m) m = d;
6384
+ }
6385
+ if (m > lim2) return void 0;
6386
+ out.push(Math.sqrt(m));
6387
+ }
6388
+ }
6389
+ return out;
6390
+ }
6391
+ function pointsOf(svg) {
6392
+ const rootTag = /<svg\b[^>]*>/i.exec(svg)?.[0];
6393
+ if (!rootTag) return void 0;
6394
+ const root = attrs(rootTag);
6395
+ const vb = (root.viewBox ?? `0 0 ${parseFloat(root.width ?? "")} ${parseFloat(root.height ?? "")}`).split(/[\s,]+/).map(Number);
6396
+ const [vx, vy, vw, vh] = vb;
6397
+ if (vb.length !== 4 || !(vw > 0) || !(vh > 0)) return void 0;
6398
+ const size = Math.max(vw, vh);
6399
+ const body = svg.replace(/<(mask|clipPath|defs|title|desc)\b[\s\S]*?<\/\1>/gi, "");
6400
+ const polys = [];
6401
+ let stroked = false;
6402
+ let filled = false;
6403
+ for (const m of body.matchAll(/<(path|rect|circle|ellipse|line|polyline|polygon)\b([^>]*)>/gi)) {
6404
+ const a = attrs(m[2]);
6405
+ const fill = a.fill ?? root.fill ?? "black";
6406
+ const stroke = a.stroke ?? root.stroke ?? "none";
6407
+ if ((fill === "none" || fill === "transparent") && (stroke === "none" || stroke === "transparent")) continue;
6408
+ if (a.opacity === "0" || a.visibility === "hidden" || a.display === "none") continue;
6409
+ const lines = shapeLines(m[1].toLowerCase(), a);
6410
+ if (!lines) return void 0;
6411
+ const t = a.transform ? matrix(a.transform) : void 0;
6412
+ for (const l of lines) polys.push(t ? apply2(t, l) : l);
6413
+ if (stroke !== "none" && stroke !== "transparent") stroked = true;
6414
+ if (fill !== "none" && fill !== "transparent" && !/^(line|polyline)$/i.test(m[1])) filled = true;
6415
+ }
6416
+ const pts = [];
6417
+ let len = 0;
6418
+ for (const l of polys) for (let i = 2; i < l.length; i += 2) len += Math.hypot(l[i] - l[i - 2], l[i + 1] - l[i - 1]);
6419
+ if (!len) return void 0;
6420
+ const step = Math.max(STEP * size, len / MAX_POINTS);
6421
+ for (const l of polys) {
6422
+ pts.push(l[0], l[1]);
6423
+ let carry = 0;
6424
+ for (let i = 2; i < l.length; i += 2) {
6425
+ const x0 = l[i - 2], y0 = l[i - 1], x1 = l[i], y1 = l[i + 1];
6426
+ const seg = Math.hypot(x1 - x0, y1 - y0);
6427
+ let s = step - carry;
6428
+ for (; s <= seg; s += step) pts.push(x0 + (x1 - x0) * s / seg, y0 + (y1 - y0) * s / seg);
6429
+ carry = seg - (s - step);
6430
+ }
6431
+ if (carry > 0) pts.push(l[l.length - 2], l[l.length - 1]);
6432
+ }
6433
+ const xy = new Float64Array(pts.length);
6434
+ const box = [Infinity, Infinity, -Infinity, -Infinity];
6435
+ for (let i = 0; i < pts.length; i += 2) {
6436
+ const x = (pts[i] - vx) / size;
6437
+ const y = (pts[i + 1] - vy) / size;
6438
+ xy[i] = x;
6439
+ xy[i + 1] = y;
6440
+ box[0] = Math.min(box[0], x);
6441
+ box[1] = Math.min(box[1], y);
6442
+ box[2] = Math.max(box[2], x);
6443
+ box[3] = Math.max(box[3], y);
6444
+ }
6445
+ return { xy, box, kind: stroked && filled ? "mixed" : stroked ? "stroke" : "fill" };
6446
+ }
6447
+ function attrs(tag) {
6448
+ const out = {};
6449
+ for (const m of tag.matchAll(/([\w:-]+)\s*=\s*("([^"]*)"|'([^']*)')/g)) out[m[1]] = m[3] ?? m[4] ?? "";
6450
+ for (const d of (out.style ?? "").split(";")) {
6451
+ const [k, v] = d.split(":").map((s) => s?.trim());
6452
+ if (k && v) out[k] = v;
6453
+ }
6454
+ return out;
6455
+ }
6456
+ function shapeLines(tag, a) {
6457
+ const f = (k) => parseFloat(a[k] ?? "0") || 0;
6458
+ switch (tag) {
6459
+ case "path":
6460
+ return a.d ? pathLines(a.d) : void 0;
6461
+ case "rect": {
6462
+ const x = f("x"), y = f("y"), w = f("width"), h = f("height");
6463
+ const r = Math.min(f("rx") || f("ry"), w / 2, h / 2);
6464
+ if (!r) return [[x, y, x + w, y, x + w, y + h, x, y + h, x, y]];
6465
+ return pathLines(`M${x + r} ${y}H${x + w - r}A${r} ${r} 0 0 1 ${x + w} ${y + r}V${y + h - r}A${r} ${r} 0 0 1 ${x + w - r} ${y + h}H${x + r}A${r} ${r} 0 0 1 ${x} ${y + h - r}V${y + r}A${r} ${r} 0 0 1 ${x + r} ${y}Z`);
6466
+ }
6467
+ case "circle":
6468
+ case "ellipse": {
6469
+ const cx = f("cx"), cy = f("cy");
6470
+ const rx = tag === "circle" ? f("r") : f("rx");
6471
+ const ry = tag === "circle" ? f("r") : f("ry");
6472
+ const l = [];
6473
+ for (let k = 0; k <= 48; k++) l.push(cx + rx * Math.cos(k / 48 * 2 * Math.PI), cy + ry * Math.sin(k / 48 * 2 * Math.PI));
6474
+ return [l];
6475
+ }
6476
+ case "line":
6477
+ return [[f("x1"), f("y1"), f("x2"), f("y2")]];
6478
+ default: {
6479
+ const pts = (a.points ?? "").trim().split(/[\s,]+/).map(Number);
6480
+ if (pts.length < 4 || pts.some(Number.isNaN)) return void 0;
6481
+ return [tag === "polygon" ? [...pts, pts[0], pts[1]] : pts];
6482
+ }
6483
+ }
6484
+ }
6485
+ function pathLines(d) {
6486
+ const NUM = /[\s,]*([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/y;
6487
+ const FLAG = /[\s,]*([01])/y;
6488
+ const CMD = /[\s,]*([MmLlHhVvCcSsQqTtAaZz])/y;
6489
+ let i = 0;
6490
+ const read = (re) => {
6491
+ re.lastIndex = i;
6492
+ const m = re.exec(d);
6493
+ if (!m) return void 0;
6494
+ i = re.lastIndex;
6495
+ return m[1];
6496
+ };
6497
+ const out = [];
6498
+ let cur = [];
6499
+ let x = 0, y = 0, sx = 0, sy = 0;
6500
+ let cx = 0, cy = 0;
6501
+ let prev = "";
6502
+ let cmd = "";
6503
+ const num3 = () => {
6504
+ const t = read(NUM);
6505
+ if (t === void 0) throw new Error("bad path");
6506
+ return parseFloat(t);
6507
+ };
6508
+ const flag = () => {
6509
+ const t = read(FLAG);
6510
+ if (t === void 0) throw new Error("bad path");
6511
+ return Number(t);
6512
+ };
6513
+ const lineTo = (nx, ny) => {
6514
+ cur.push(nx, ny);
6515
+ x = nx;
6516
+ y = ny;
6517
+ };
6518
+ const curve = (pts) => {
6519
+ const n2 = pts.length / 2;
6520
+ for (let k = 1; k <= 12; k++) {
6521
+ const t = k / 12;
6522
+ const p = pts.slice();
6523
+ for (let r = n2 - 1; r > 0; r--) for (let j = 0; j < r; j++) {
6524
+ p[2 * j] = p[2 * j] + (p[2 * j + 2] - p[2 * j]) * t;
6525
+ p[2 * j + 1] = p[2 * j + 1] + (p[2 * j + 3] - p[2 * j + 1]) * t;
6526
+ }
6527
+ cur.push(p[0], p[1]);
6528
+ }
6529
+ x = pts[pts.length - 2];
6530
+ y = pts[pts.length - 1];
6531
+ };
6532
+ try {
6533
+ while (!/^[\s,]*$/.test(d.slice(i))) {
6534
+ const c = read(CMD);
6535
+ if (c) cmd = c;
6536
+ else if (!cmd || /z/i.test(cmd)) return void 0;
6537
+ const up = cmd.toUpperCase();
6538
+ const rel = cmd !== up;
6539
+ const ox = rel ? x : 0;
6540
+ const oy = rel ? y : 0;
6541
+ if (up === "Z") {
6542
+ if (cur.length) cur.push(sx, sy);
6543
+ x = sx;
6544
+ y = sy;
6545
+ prev = "Z";
6546
+ continue;
6547
+ }
6548
+ if (ARGS[up] === void 0) return void 0;
6549
+ if (up === "M") {
6550
+ if (cur.length > 2) out.push(cur);
6551
+ x = num3() + ox;
6552
+ y = num3() + oy;
6553
+ sx = x;
6554
+ sy = y;
6555
+ cur = [x, y];
6556
+ cmd = rel ? "l" : "L";
6557
+ } else if (up === "L") lineTo(num3() + ox, num3() + oy);
6558
+ else if (up === "H") lineTo(num3() + ox, y);
6559
+ else if (up === "V") lineTo(x, num3() + oy);
6560
+ else if (up === "C") {
6561
+ const p = [num3() + ox, num3() + oy, num3() + ox, num3() + oy, num3() + ox, num3() + oy];
6562
+ curve([x, y, ...p]);
6563
+ cx = p[2];
6564
+ cy = p[3];
6565
+ } else if (up === "S") {
6566
+ const [rx, ry] = /[CS]/.test(prev) ? [2 * x - cx, 2 * y - cy] : [x, y];
6567
+ const p = [num3() + ox, num3() + oy, num3() + ox, num3() + oy];
6568
+ curve([x, y, rx, ry, ...p]);
6569
+ cx = p[0];
6570
+ cy = p[1];
6571
+ } else if (up === "Q") {
6572
+ const p = [num3() + ox, num3() + oy, num3() + ox, num3() + oy];
6573
+ curve([x, y, ...p]);
6574
+ cx = p[0];
6575
+ cy = p[1];
6576
+ } else if (up === "T") {
6577
+ const [rx, ry] = /[QT]/.test(prev) ? [2 * x - cx, 2 * y - cy] : [x, y];
6578
+ curve([x, y, rx, ry, num3() + ox, num3() + oy]);
6579
+ cx = rx;
6580
+ cy = ry;
6581
+ } else if (up === "A") {
6582
+ const rx = num3(), ry = num3(), rot = num3(), large = flag(), sweep = flag();
6583
+ arc(x, y, rx, ry, rot, large, sweep, num3() + ox, num3() + oy, lineTo);
6584
+ }
6585
+ prev = up;
6586
+ }
6587
+ } catch {
6588
+ return void 0;
6589
+ }
6590
+ if (cur.length > 2) out.push(cur);
6591
+ return out;
6592
+ }
6593
+ function arc(x1, y1, rx, ry, rotDeg, large, sweep, x2, y2, lineTo) {
6594
+ rx = Math.abs(rx);
6595
+ ry = Math.abs(ry);
6596
+ if (!rx || !ry || x1 === x2 && y1 === y2) return lineTo(x2, y2);
6597
+ const phi = rotDeg * Math.PI / 180;
6598
+ const cos = Math.cos(phi), sin = Math.sin(phi);
6599
+ const dx = (x1 - x2) / 2, dy = (y1 - y2) / 2;
6600
+ const x1p = cos * dx + sin * dy, y1p = -sin * dx + cos * dy;
6601
+ const lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
6602
+ if (lambda > 1) {
6603
+ rx *= Math.sqrt(lambda);
6604
+ ry *= Math.sqrt(lambda);
6605
+ }
6606
+ const num3 = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
6607
+ const den = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
6608
+ let k = Math.sqrt(Math.max(0, num3 / den));
6609
+ if (large === sweep) k = -k;
6610
+ const cxp = k * rx * y1p / ry, cyp = -k * ry * x1p / rx;
6611
+ const cx = cos * cxp - sin * cyp + (x1 + x2) / 2;
6612
+ const cy = sin * cxp + cos * cyp + (y1 + y2) / 2;
6613
+ const ang = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
6614
+ const t1 = ang(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
6615
+ let dt = ang((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
6616
+ if (!sweep && dt > 0) dt -= 2 * Math.PI;
6617
+ else if (sweep && dt < 0) dt += 2 * Math.PI;
6618
+ const n2 = Math.max(4, Math.ceil(Math.abs(dt) / (Math.PI / 12)));
6619
+ for (let s = 1; s <= n2; s++) {
6620
+ const t = t1 + dt * s / n2;
6621
+ const ex = rx * Math.cos(t), ey = ry * Math.sin(t);
6622
+ lineTo(cos * ex - sin * ey + cx, sin * ex + cos * ey + cy);
6623
+ }
6624
+ }
6625
+ function matrix(t) {
6626
+ let m = [1, 0, 0, 1, 0, 0];
6627
+ const mul = (a, b) => [
6628
+ a[0] * b[0] + a[2] * b[1],
6629
+ a[1] * b[0] + a[3] * b[1],
6630
+ a[0] * b[2] + a[2] * b[3],
6631
+ a[1] * b[2] + a[3] * b[3],
6632
+ a[0] * b[4] + a[2] * b[5] + a[4],
6633
+ a[1] * b[4] + a[3] * b[5] + a[5]
6634
+ ];
6635
+ for (const f of t.matchAll(/(matrix|translate|scale|rotate)\s*\(([^)]*)\)/g)) {
6636
+ const v = f[2].split(/[\s,]+/).filter(Boolean).map(Number);
6637
+ let n2;
6638
+ if (f[1] === "matrix") n2 = v;
6639
+ else if (f[1] === "translate") n2 = [1, 0, 0, 1, v[0] ?? 0, v[1] ?? 0];
6640
+ else if (f[1] === "scale") n2 = [v[0] ?? 1, 0, 0, v[1] ?? v[0] ?? 1, 0, 0];
6641
+ else {
6642
+ const r = (v[0] ?? 0) * Math.PI / 180;
6643
+ const [c, s, px2, py] = [Math.cos(r), Math.sin(r), v[1] ?? 0, v[2] ?? 0];
6644
+ n2 = [c, s, -s, c, px2 - c * px2 + s * py, py - s * px2 - c * py];
6645
+ }
6646
+ m = mul(m, n2);
6647
+ }
6648
+ return m;
6649
+ }
6650
+ function apply2(m, l) {
6651
+ const out = [];
6652
+ for (let i = 0; i < l.length; i += 2) out.push(m[0] * l[i] + m[2] * l[i + 1] + m[4], m[1] * l[i] + m[3] * l[i + 1] + m[5]);
6653
+ return out;
6654
+ }
6655
+ var pascal, HERO_SETS, kebab, plainSvg, ICON_PACKAGES, fits, MAX_OFFSET, SAME_KIND_OFFSET, SPREAD, STEP, MAX_POINTS, ARGS;
6656
+ var init_icons = __esm({
6657
+ "src/tools/icons.ts"() {
6658
+ "use strict";
6659
+ pascal = (s) => s.replace(/(^|[-_])([a-z0-9])/g, (_, __, c) => c.toUpperCase());
6660
+ HERO_SETS = [
6661
+ { dir: "24/outline", suffix: "", stroke: true },
6662
+ { dir: "24/solid", suffix: "-solid", stroke: false },
6663
+ { dir: "20/solid", suffix: "-mini", stroke: false },
6664
+ { dir: "16/solid", suffix: "-micro", stroke: false }
6665
+ ];
6666
+ kebab = (s) => s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
6667
+ plainSvg = (svg) => svg.replace(/\{\.\.\.[^{}]*\}/g, "").replace(/([\w:-]+)=\{[^{}]*\}/g, '$1="currentColor"');
6668
+ ICON_PACKAGES = ["lucide-react", "lucide-vue-next", "@heroicons/react", "heroicons", "lucide-static"];
6669
+ fits = /* @__PURE__ */ new WeakMap();
6670
+ MAX_OFFSET = 0.09;
6671
+ SAME_KIND_OFFSET = 0.02;
6672
+ SPREAD = 0.025;
6673
+ STEP = 0.02;
6674
+ MAX_POINTS = 240;
6675
+ ARGS = { M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0 };
6676
+ }
6677
+ });
6678
+
6679
+ // src/tools/code-components.ts
6680
+ function values(list, def) {
6681
+ const shown = list.slice(0, MAX_VALUES).map((v) => v === def ? `${v}*` : v);
6682
+ return shown.join("|") + (list.length > MAX_VALUES ? "|\u2026" : "");
6683
+ }
6684
+ function closing(src, open2) {
6685
+ let depth = 0;
6686
+ for (let i = open2; i < src.length; i++) {
6687
+ const c = src[i];
6688
+ if (c === '"' || c === "'" || c === "`") {
6689
+ for (i++; i < src.length && src[i] !== c; i++) if (src[i] === "\\") i++;
6690
+ } else if (c === "/" && src[i + 1] === "/") i = src.indexOf("\n", i) < 0 ? src.length : src.indexOf("\n", i);
6691
+ else if (c === "/" && src[i + 1] === "*") i = src.indexOf("*/", i) < 0 ? src.length : src.indexOf("*/", i) + 1;
6692
+ else if (c === "{") depth++;
6693
+ else if (c === "}" && --depth === 0) return i + 1;
6694
+ }
6695
+ return src.length;
6696
+ }
6697
+ function keys(src, open2) {
6698
+ const end = closing(src, open2);
6699
+ const out = [];
6700
+ let i = open2 + 1;
6701
+ while (i < end - 1) {
6702
+ const m = /^\s*(?:(["'])([^"']*)\1|([\w$-]+))\s*:\s*/.exec(src.slice(i, end));
6703
+ if (!m) break;
6704
+ out.push({ key: m[2] ?? m[3], at: i + m[0].length });
6705
+ let j = i + m[0].length;
6706
+ for (; j < end - 1; j++) {
6707
+ const c = src[j];
6708
+ if (c === "{" || c === "[" || c === "(") {
6709
+ const close = c === "{" ? "}" : c === "[" ? "]" : ")";
6710
+ let d = 0;
6711
+ for (; j < end; j++) {
6712
+ const x = src[j];
6713
+ if (x === '"' || x === "'" || x === "`") {
6714
+ for (j++; j < end && src[j] !== x; j++) if (src[j] === "\\") j++;
6715
+ } else if (x === c) d++;
6716
+ else if (x === close && --d === 0) break;
6717
+ }
6718
+ } else if (c === '"' || c === "'" || c === "`") {
6719
+ for (j++; j < end && src[j] !== c; j++) if (src[j] === "\\") j++;
6720
+ } else if (c === ",") break;
6721
+ }
6722
+ i = j + 1;
6723
+ }
6724
+ return out;
6725
+ }
6726
+ function variantCalls(src) {
6727
+ const out = /* @__PURE__ */ new Map();
6728
+ for (const m of src.matchAll(/(?:const|let)\s+(\w+)\s*=\s*(?:cva|tv)\s*\(/g)) {
6729
+ const v = /\bvariants\s*:\s*\{/.exec(src.slice(m.index));
6730
+ if (!v) continue;
6731
+ const open2 = m.index + v.index + v[0].length - 1;
6732
+ const defaults = /* @__PURE__ */ new Map();
6733
+ const dv = /\bdefaultVariants\s*:\s*\{/.exec(src.slice(m.index));
6734
+ if (dv) {
6735
+ const at = m.index + dv.index + dv[0].length - 1;
6736
+ for (const k of keys(src, at)) {
6737
+ const val = /^\s*(["'])([^"']*)\1/.exec(src.slice(k.at))?.[2] ?? /^\s*(true|false)\b/.exec(src.slice(k.at))?.[1];
6738
+ if (val) defaults.set(k.key, val);
6739
+ }
6740
+ }
6741
+ const props = [];
6742
+ for (const k of keys(src, open2)) {
6743
+ if (src[k.at] !== "{") continue;
6744
+ const opts = keys(src, k.at).map((o) => o.key);
6745
+ if (!opts.length) continue;
6746
+ props.push(opts.every((o) => o === "true" || o === "false") ? k.key : `${k.key}="${values(opts, defaults.get(k.key))}"`);
6747
+ }
6748
+ if (props.length) out.set(m[1], props);
6749
+ }
6750
+ return out;
6751
+ }
6752
+ function reactComponents(src) {
6753
+ const exported = /* @__PURE__ */ new Set();
6754
+ for (const m of src.matchAll(/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class)\s+([A-Z]\w*)/g)) exported.add(m[1]);
6755
+ for (const m of src.matchAll(/export\s*\{([^}]*)\}/g)) {
6756
+ for (const part of m[1].split(",")) {
6757
+ const name = part.trim().split(/\s+as\s+/)[0].trim();
6758
+ if (/^[A-Z]\w*$/.test(name)) exported.add(name);
6759
+ }
6760
+ }
6761
+ const defined = [];
6762
+ for (const m of src.matchAll(/(?:^|\n)\s*(?:export\s+)?(?:default\s+)?(?:function\s+([A-Z]\w*)\s*[(<]|(?:const|let)\s+([A-Z]\w*)\s*(?::[^=]+)?=\s*(?:React\.)?(?:forwardRef|memo|\(|function|<))/g)) {
6763
+ const name = m[1] ?? m[2];
6764
+ if (exported.has(name)) defined.push({ name, at: m.index });
6765
+ }
6766
+ if (!defined.length) return [];
6767
+ const calls = variantCalls(src);
6768
+ const unions = [];
6769
+ for (const m of src.matchAll(/\b(\w+)\??\s*:\s*((?:["'][\w-]+["']\s*\|\s*)+["'][\w-]+["'])/g)) {
6770
+ const opts = [...m[2].matchAll(/["']([\w-]+)["']/g)].map((x) => x[1]);
6771
+ unions.push(`${m[1]}="${values(opts)}"`);
6772
+ }
6773
+ return defined.map(({ name, at }, i) => {
6774
+ const body = src.slice(at, defined[i + 1]?.at ?? src.length);
6775
+ const props = [...calls].filter(([fn]) => new RegExp(`\\b${fn}\\s*\\(`).test(body)).flatMap(([, p]) => p);
6776
+ if (!props.length && defined.length === 1) props.push(...unions);
6777
+ return { name, api: `<${name}${props.length ? ` ${[...new Set(props)].join(" ")}` : ""}>` };
6778
+ });
6779
+ }
6780
+ function elixirList(v) {
6781
+ const w = /^~w[([{<]([^)\]}>]*)[)\]}>]/.exec(v);
6782
+ if (w) return w[1].trim().split(/\s+/).filter(Boolean);
6783
+ const l = /^\[([^\]]*)\]/.exec(v);
6784
+ if (!l) return void 0;
6785
+ const out = [...l[1].matchAll(/(?:"([^"]*)"|:(\w+))/g)].map((m) => m[1] ?? m[2]);
6786
+ return out.length ? out : void 0;
6787
+ }
6788
+ function phoenixComponents(src) {
6789
+ const attrs3 = /* @__PURE__ */ new Map();
6790
+ for (const m of src.matchAll(/^\s*@(\w+)\s+(.+)$/gm)) {
6791
+ const list = elixirList(m[2].trim());
6792
+ if (list) attrs3.set(m[1], list);
6793
+ else if (m[2].trim().startsWith("%{")) {
6794
+ const ks = [...m[2].matchAll(/(?:^%\{|,)\s*(?:(\w+):|"([^"]+)"\s*=>|:(\w+)\s*=>)/g)].map((k) => k[1] ?? k[2] ?? k[3]);
6795
+ if (ks.length) attrs3.set(m[1], ks);
6796
+ }
6797
+ }
6798
+ const resolve = (v) => {
6799
+ v = v.trim();
6800
+ const direct = elixirList(v);
6801
+ if (direct) return direct.filter((x) => x !== "nil");
6802
+ const a = /^(?:Map\.keys\()?@(\w+)\)?/.exec(v);
6803
+ if (a) return attrs3.get(a[1]);
6804
+ const withNil = /^\[nil\s*\|\s*(.+)\]$/.exec(v);
6805
+ return withNil ? resolve(withNil[1]) : void 0;
6806
+ };
6807
+ const out = [];
6808
+ let props = [];
6809
+ let slots = [];
6810
+ let any2 = false;
6811
+ const joined = src.replace(/([,[(])[ \t]*\r?\n\s*/g, (_, c) => c === "," ? ", " : c).replace(/\r?\n\s*(?=[\])])/g, "");
6812
+ for (const line of joined.split("\n")) {
6813
+ const a = /^\s*attr\s+:(\w+)\s*,\s*:(\w+)(.*)$/.exec(line);
6814
+ if (a) {
6815
+ any2 = true;
6816
+ const [, name, type, rest] = a;
6817
+ const vals = /\bvalues:\s*(.+?)(?:,\s*\w+:|\s*$)/.exec(rest)?.[1];
6818
+ const def = /\bdefault:\s*(?:"([^"]*)"|:(\w+))/.exec(rest);
6819
+ const list = vals ? resolve(vals) : void 0;
6820
+ if (list?.length) props.push(`${name}="${values(list, def?.[1] ?? def?.[2])}"`);
6821
+ else if (type === "boolean") props.push(name);
6822
+ continue;
6823
+ }
6824
+ const s = /^\s*slot\s+:(\w+)/.exec(line);
6825
+ if (s) {
6826
+ any2 = true;
6827
+ if (s[1] !== "inner_block") slots.push(`<:${s[1]}>`);
6828
+ continue;
6829
+ }
6830
+ const d = /^\s*(defp?)\s+(\w+)\s*\(/.exec(line);
6831
+ if (d) {
6832
+ if (d[1] === "def" && any2 && !out.some((c) => c.name === d[2])) {
6833
+ out.push({ name: d[2], api: [`<.${d[2]}${props.length ? ` ${props.join(" ")}` : ""}>`, ...slots].join(" ") });
6834
+ }
6835
+ if (d[1] === "defp" || any2) {
6836
+ props = [];
6837
+ slots = [];
6838
+ any2 = false;
6839
+ }
6840
+ }
6841
+ }
6842
+ return out;
6843
+ }
6844
+ var MAX_VALUES;
6845
+ var init_code_components = __esm({
6846
+ "src/tools/code-components.ts"() {
6847
+ "use strict";
6848
+ MAX_VALUES = 8;
6849
+ }
6850
+ });
6851
+
6852
+ // src/tools/tailwind-v3-theme.ts
6853
+ var TAILWIND_V3_THEME;
6854
+ var init_tailwind_v3_theme = __esm({
6855
+ "src/tools/tailwind-v3-theme.ts"() {
6856
+ "use strict";
6857
+ TAILWIND_V3_THEME = {
6858
+ "--color-black": "#000",
6859
+ "--color-white": "#fff",
6860
+ "--color-slate-50": "#f8fafc",
6861
+ "--color-slate-100": "#f1f5f9",
6862
+ "--color-slate-200": "#e2e8f0",
6863
+ "--color-slate-300": "#cbd5e1",
6864
+ "--color-slate-400": "#94a3b8",
6865
+ "--color-slate-500": "#64748b",
6866
+ "--color-slate-600": "#475569",
6867
+ "--color-slate-700": "#334155",
6868
+ "--color-slate-800": "#1e293b",
6869
+ "--color-slate-900": "#0f172a",
6870
+ "--color-slate-950": "#020617",
6871
+ "--color-gray-50": "#f9fafb",
6872
+ "--color-gray-100": "#f3f4f6",
6873
+ "--color-gray-200": "#e5e7eb",
6874
+ "--color-gray-300": "#d1d5db",
6875
+ "--color-gray-400": "#9ca3af",
6876
+ "--color-gray-500": "#6b7280",
6877
+ "--color-gray-600": "#4b5563",
6878
+ "--color-gray-700": "#374151",
6879
+ "--color-gray-800": "#1f2937",
6880
+ "--color-gray-900": "#111827",
6881
+ "--color-gray-950": "#030712",
6882
+ "--color-zinc-50": "#fafafa",
6883
+ "--color-zinc-100": "#f4f4f5",
6884
+ "--color-zinc-200": "#e4e4e7",
6885
+ "--color-zinc-300": "#d4d4d8",
6886
+ "--color-zinc-400": "#a1a1aa",
6887
+ "--color-zinc-500": "#71717a",
6888
+ "--color-zinc-600": "#52525b",
6889
+ "--color-zinc-700": "#3f3f46",
6890
+ "--color-zinc-800": "#27272a",
6891
+ "--color-zinc-900": "#18181b",
6892
+ "--color-zinc-950": "#09090b",
6893
+ "--color-neutral-50": "#fafafa",
6894
+ "--color-neutral-100": "#f5f5f5",
6895
+ "--color-neutral-200": "#e5e5e5",
6896
+ "--color-neutral-300": "#d4d4d4",
6897
+ "--color-neutral-400": "#a3a3a3",
6898
+ "--color-neutral-500": "#737373",
6899
+ "--color-neutral-600": "#525252",
6900
+ "--color-neutral-700": "#404040",
6901
+ "--color-neutral-800": "#262626",
6902
+ "--color-neutral-900": "#171717",
6903
+ "--color-neutral-950": "#0a0a0a",
6904
+ "--color-stone-50": "#fafaf9",
6905
+ "--color-stone-100": "#f5f5f4",
6906
+ "--color-stone-200": "#e7e5e4",
6907
+ "--color-stone-300": "#d6d3d1",
6908
+ "--color-stone-400": "#a8a29e",
6909
+ "--color-stone-500": "#78716c",
6910
+ "--color-stone-600": "#57534e",
6911
+ "--color-stone-700": "#44403c",
6912
+ "--color-stone-800": "#292524",
6913
+ "--color-stone-900": "#1c1917",
6914
+ "--color-stone-950": "#0c0a09",
6915
+ "--color-red-50": "#fef2f2",
6916
+ "--color-red-100": "#fee2e2",
6917
+ "--color-red-200": "#fecaca",
6918
+ "--color-red-300": "#fca5a5",
6919
+ "--color-red-400": "#f87171",
6920
+ "--color-red-500": "#ef4444",
6921
+ "--color-red-600": "#dc2626",
6922
+ "--color-red-700": "#b91c1c",
6923
+ "--color-red-800": "#991b1b",
6924
+ "--color-red-900": "#7f1d1d",
6925
+ "--color-red-950": "#450a0a",
6926
+ "--color-orange-50": "#fff7ed",
6927
+ "--color-orange-100": "#ffedd5",
6928
+ "--color-orange-200": "#fed7aa",
6929
+ "--color-orange-300": "#fdba74",
6930
+ "--color-orange-400": "#fb923c",
6931
+ "--color-orange-500": "#f97316",
6932
+ "--color-orange-600": "#ea580c",
6933
+ "--color-orange-700": "#c2410c",
6934
+ "--color-orange-800": "#9a3412",
6935
+ "--color-orange-900": "#7c2d12",
6936
+ "--color-orange-950": "#431407",
6937
+ "--color-amber-50": "#fffbeb",
6938
+ "--color-amber-100": "#fef3c7",
6939
+ "--color-amber-200": "#fde68a",
6940
+ "--color-amber-300": "#fcd34d",
6941
+ "--color-amber-400": "#fbbf24",
6942
+ "--color-amber-500": "#f59e0b",
6943
+ "--color-amber-600": "#d97706",
6944
+ "--color-amber-700": "#b45309",
6945
+ "--color-amber-800": "#92400e",
6946
+ "--color-amber-900": "#78350f",
6947
+ "--color-amber-950": "#451a03",
6948
+ "--color-yellow-50": "#fefce8",
6949
+ "--color-yellow-100": "#fef9c3",
6950
+ "--color-yellow-200": "#fef08a",
6951
+ "--color-yellow-300": "#fde047",
6952
+ "--color-yellow-400": "#facc15",
6953
+ "--color-yellow-500": "#eab308",
6954
+ "--color-yellow-600": "#ca8a04",
6955
+ "--color-yellow-700": "#a16207",
6956
+ "--color-yellow-800": "#854d0e",
6957
+ "--color-yellow-900": "#713f12",
6958
+ "--color-yellow-950": "#422006",
6959
+ "--color-lime-50": "#f7fee7",
6960
+ "--color-lime-100": "#ecfccb",
6961
+ "--color-lime-200": "#d9f99d",
6962
+ "--color-lime-300": "#bef264",
6963
+ "--color-lime-400": "#a3e635",
6964
+ "--color-lime-500": "#84cc16",
6965
+ "--color-lime-600": "#65a30d",
6966
+ "--color-lime-700": "#4d7c0f",
6967
+ "--color-lime-800": "#3f6212",
6968
+ "--color-lime-900": "#365314",
6969
+ "--color-lime-950": "#1a2e05",
6970
+ "--color-green-50": "#f0fdf4",
6971
+ "--color-green-100": "#dcfce7",
6972
+ "--color-green-200": "#bbf7d0",
6973
+ "--color-green-300": "#86efac",
6974
+ "--color-green-400": "#4ade80",
6975
+ "--color-green-500": "#22c55e",
6976
+ "--color-green-600": "#16a34a",
6977
+ "--color-green-700": "#15803d",
6978
+ "--color-green-800": "#166534",
6979
+ "--color-green-900": "#14532d",
6980
+ "--color-green-950": "#052e16",
6981
+ "--color-emerald-50": "#ecfdf5",
6982
+ "--color-emerald-100": "#d1fae5",
6983
+ "--color-emerald-200": "#a7f3d0",
6984
+ "--color-emerald-300": "#6ee7b7",
6985
+ "--color-emerald-400": "#34d399",
6986
+ "--color-emerald-500": "#10b981",
6987
+ "--color-emerald-600": "#059669",
6988
+ "--color-emerald-700": "#047857",
6989
+ "--color-emerald-800": "#065f46",
6990
+ "--color-emerald-900": "#064e3b",
6991
+ "--color-emerald-950": "#022c22",
6992
+ "--color-teal-50": "#f0fdfa",
6993
+ "--color-teal-100": "#ccfbf1",
6994
+ "--color-teal-200": "#99f6e4",
6995
+ "--color-teal-300": "#5eead4",
6996
+ "--color-teal-400": "#2dd4bf",
6997
+ "--color-teal-500": "#14b8a6",
6998
+ "--color-teal-600": "#0d9488",
6999
+ "--color-teal-700": "#0f766e",
7000
+ "--color-teal-800": "#115e59",
7001
+ "--color-teal-900": "#134e4a",
7002
+ "--color-teal-950": "#042f2e",
7003
+ "--color-cyan-50": "#ecfeff",
7004
+ "--color-cyan-100": "#cffafe",
7005
+ "--color-cyan-200": "#a5f3fc",
7006
+ "--color-cyan-300": "#67e8f9",
7007
+ "--color-cyan-400": "#22d3ee",
7008
+ "--color-cyan-500": "#06b6d4",
7009
+ "--color-cyan-600": "#0891b2",
7010
+ "--color-cyan-700": "#0e7490",
7011
+ "--color-cyan-800": "#155e75",
7012
+ "--color-cyan-900": "#164e63",
7013
+ "--color-cyan-950": "#083344",
7014
+ "--color-sky-50": "#f0f9ff",
7015
+ "--color-sky-100": "#e0f2fe",
7016
+ "--color-sky-200": "#bae6fd",
7017
+ "--color-sky-300": "#7dd3fc",
7018
+ "--color-sky-400": "#38bdf8",
7019
+ "--color-sky-500": "#0ea5e9",
7020
+ "--color-sky-600": "#0284c7",
7021
+ "--color-sky-700": "#0369a1",
7022
+ "--color-sky-800": "#075985",
7023
+ "--color-sky-900": "#0c4a6e",
7024
+ "--color-sky-950": "#082f49",
7025
+ "--color-blue-50": "#eff6ff",
7026
+ "--color-blue-100": "#dbeafe",
7027
+ "--color-blue-200": "#bfdbfe",
7028
+ "--color-blue-300": "#93c5fd",
7029
+ "--color-blue-400": "#60a5fa",
7030
+ "--color-blue-500": "#3b82f6",
7031
+ "--color-blue-600": "#2563eb",
7032
+ "--color-blue-700": "#1d4ed8",
7033
+ "--color-blue-800": "#1e40af",
7034
+ "--color-blue-900": "#1e3a8a",
7035
+ "--color-blue-950": "#172554",
7036
+ "--color-indigo-50": "#eef2ff",
7037
+ "--color-indigo-100": "#e0e7ff",
7038
+ "--color-indigo-200": "#c7d2fe",
7039
+ "--color-indigo-300": "#a5b4fc",
7040
+ "--color-indigo-400": "#818cf8",
7041
+ "--color-indigo-500": "#6366f1",
7042
+ "--color-indigo-600": "#4f46e5",
7043
+ "--color-indigo-700": "#4338ca",
7044
+ "--color-indigo-800": "#3730a3",
7045
+ "--color-indigo-900": "#312e81",
7046
+ "--color-indigo-950": "#1e1b4b",
7047
+ "--color-violet-50": "#f5f3ff",
7048
+ "--color-violet-100": "#ede9fe",
7049
+ "--color-violet-200": "#ddd6fe",
7050
+ "--color-violet-300": "#c4b5fd",
7051
+ "--color-violet-400": "#a78bfa",
7052
+ "--color-violet-500": "#8b5cf6",
7053
+ "--color-violet-600": "#7c3aed",
7054
+ "--color-violet-700": "#6d28d9",
7055
+ "--color-violet-800": "#5b21b6",
7056
+ "--color-violet-900": "#4c1d95",
7057
+ "--color-violet-950": "#2e1065",
7058
+ "--color-purple-50": "#faf5ff",
7059
+ "--color-purple-100": "#f3e8ff",
7060
+ "--color-purple-200": "#e9d5ff",
7061
+ "--color-purple-300": "#d8b4fe",
7062
+ "--color-purple-400": "#c084fc",
7063
+ "--color-purple-500": "#a855f7",
7064
+ "--color-purple-600": "#9333ea",
7065
+ "--color-purple-700": "#7e22ce",
7066
+ "--color-purple-800": "#6b21a8",
7067
+ "--color-purple-900": "#581c87",
7068
+ "--color-purple-950": "#3b0764",
7069
+ "--color-fuchsia-50": "#fdf4ff",
7070
+ "--color-fuchsia-100": "#fae8ff",
7071
+ "--color-fuchsia-200": "#f5d0fe",
7072
+ "--color-fuchsia-300": "#f0abfc",
7073
+ "--color-fuchsia-400": "#e879f9",
7074
+ "--color-fuchsia-500": "#d946ef",
7075
+ "--color-fuchsia-600": "#c026d3",
7076
+ "--color-fuchsia-700": "#a21caf",
7077
+ "--color-fuchsia-800": "#86198f",
7078
+ "--color-fuchsia-900": "#701a75",
7079
+ "--color-fuchsia-950": "#4a044e",
7080
+ "--color-pink-50": "#fdf2f8",
7081
+ "--color-pink-100": "#fce7f3",
7082
+ "--color-pink-200": "#fbcfe8",
7083
+ "--color-pink-300": "#f9a8d4",
7084
+ "--color-pink-400": "#f472b6",
7085
+ "--color-pink-500": "#ec4899",
7086
+ "--color-pink-600": "#db2777",
7087
+ "--color-pink-700": "#be185d",
7088
+ "--color-pink-800": "#9d174d",
7089
+ "--color-pink-900": "#831843",
7090
+ "--color-pink-950": "#500724",
7091
+ "--color-rose-50": "#fff1f2",
7092
+ "--color-rose-100": "#ffe4e6",
7093
+ "--color-rose-200": "#fecdd3",
7094
+ "--color-rose-300": "#fda4af",
7095
+ "--color-rose-400": "#fb7185",
7096
+ "--color-rose-500": "#f43f5e",
7097
+ "--color-rose-600": "#e11d48",
7098
+ "--color-rose-700": "#be123c",
7099
+ "--color-rose-800": "#9f1239",
7100
+ "--color-rose-900": "#881337",
7101
+ "--color-rose-950": "#4c0519",
7102
+ "--text-xs": "0.75rem",
7103
+ "--text-xs--line-height": "1rem",
7104
+ "--text-sm": "0.875rem",
7105
+ "--text-sm--line-height": "1.25rem",
7106
+ "--text-base": "1rem",
7107
+ "--text-base--line-height": "1.5rem",
7108
+ "--text-lg": "1.125rem",
7109
+ "--text-lg--line-height": "1.75rem",
7110
+ "--text-xl": "1.25rem",
7111
+ "--text-xl--line-height": "1.75rem",
7112
+ "--text-2xl": "1.5rem",
7113
+ "--text-2xl--line-height": "2rem",
7114
+ "--text-3xl": "1.875rem",
7115
+ "--text-3xl--line-height": "2.25rem",
7116
+ "--text-4xl": "2.25rem",
7117
+ "--text-4xl--line-height": "2.5rem",
7118
+ "--text-5xl": "3rem",
7119
+ "--text-5xl--line-height": "1",
7120
+ "--text-6xl": "3.75rem",
7121
+ "--text-6xl--line-height": "1",
7122
+ "--text-7xl": "4.5rem",
7123
+ "--text-7xl--line-height": "1",
7124
+ "--text-8xl": "6rem",
7125
+ "--text-8xl--line-height": "1",
7126
+ "--text-9xl": "8rem",
7127
+ "--text-9xl--line-height": "1",
7128
+ "--font-weight-thin": "100",
7129
+ "--font-weight-extralight": "200",
7130
+ "--font-weight-light": "300",
7131
+ "--font-weight-normal": "400",
7132
+ "--font-weight-medium": "500",
7133
+ "--font-weight-semibold": "600",
7134
+ "--font-weight-bold": "700",
7135
+ "--font-weight-extrabold": "800",
7136
+ "--font-weight-black": "900",
7137
+ "--tracking-tighter": "-0.05em",
7138
+ "--tracking-tight": "-0.025em",
7139
+ "--tracking-normal": "0em",
7140
+ "--tracking-wide": "0.025em",
7141
+ "--tracking-wider": "0.05em",
7142
+ "--tracking-widest": "0.1em",
7143
+ "--font-sans": 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
7144
+ "--font-serif": 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
7145
+ "--font-mono": 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
7146
+ };
7147
+ }
7148
+ });
7149
+
7150
+ // src/tools/tailwind-config.ts
7151
+ function configObject(src) {
7152
+ const anchor2 = /(?:module\.exports\s*=|export\s+default)\s*/.exec(src);
7153
+ if (!anchor2) return void 0;
7154
+ let i = anchor2.index + anchor2[0].length;
7155
+ const wrapper = /^[\w$.]+\s*\(\s*/.exec(src.slice(i));
7156
+ if (wrapper) i += wrapper[0].length;
7157
+ if (src[i] === "{") return parseAt(src, i);
7158
+ const name = /^[\w$]+/.exec(src.slice(i))?.[0];
7159
+ const decl = name && new RegExp(`(?:const|let|var)\\s+${name}\\s*(?::[^=\\n]+)?=\\s*(?:[\\w$.]+\\s*\\(\\s*)?\\{`).exec(src);
7160
+ return decl ? parseAt(src, decl.index + decl[0].length - 1) : void 0;
7161
+ }
7162
+ function localObject(src, name) {
7163
+ const m = new RegExp(`(?:const|let|var)\\s+${name}\\s*(?::[^=\\n]+)?=\\s*\\{`).exec(src);
7164
+ return m ? parseAt(src, m.index + m[0].length - 1) : void 0;
7165
+ }
7166
+ function paletteNames(src) {
7167
+ const names = /* @__PURE__ */ new Set();
7168
+ for (const m of src.matchAll(/(?:(?:const|let|var)\s+([\w$]+)\s*=\s*require\(|import\s+([\w$]+)\s+from\s+)\s*["']tailwindcss\/colors(?:\.js)?["']/g)) names.add(m[1] ?? m[2]);
7169
+ return names;
7170
+ }
7171
+ function replacedBy(name, replaced) {
7172
+ return [...replaced].some((p) => name.startsWith(p) && !(p === "--font-" && name.startsWith("--font-weight-")));
7173
+ }
7174
+ function tailwindV3Defaults(replaced) {
7175
+ return Object.entries(TAILWIND_V3_THEME).filter(([k]) => !replacedBy(k, replaced));
7176
+ }
7177
+ function tailwindConfigTheme(src, channel) {
7178
+ const out = { vars: [], replaced: /* @__PURE__ */ new Set() };
7179
+ const root = configObject(src);
7180
+ const theme = get(root, "theme");
7181
+ if (theme?.t !== "obj") return out;
7182
+ const palettes = paletteNames(src);
7183
+ const colorValue = (v) => {
7184
+ const fn = /^(hsl|rgb)a?\(\s*var\(\s*(--[\w-]+)\s*\)\s*(?:\/\s*([^)]*))?\)$/i.exec(v.trim());
7185
+ if (fn) {
7186
+ const ch = channel(fn[2]);
7187
+ if (!ch) return void 0;
7188
+ if (/^(hsl|rgb)a?\(/i.test(ch)) return ch;
7189
+ const alpha = fn[3]?.trim();
7190
+ return `${fn[1].toLowerCase()}(${ch}${alpha && !alpha.includes("<alpha-value>") ? ` / ${alpha}` : ""})`;
7191
+ }
7192
+ const plain = /^var\(\s*(--[\w-]+)\s*\)$/.exec(v.trim());
7193
+ return plain ? channel(plain[1]) : v;
7194
+ };
7195
+ const colors = (prefix, n2, depth = 0) => {
7196
+ if (depth > 6) return;
7197
+ if (n2.t === "str") {
7198
+ const v = colorValue(n2.v);
7199
+ if (v) out.vars.push([prefix, v]);
7200
+ } else if (n2.t === "obj") {
7201
+ for (const [k, x] of n2.props) colors(k === "DEFAULT" ? prefix : `${prefix}-${k}`, x, depth + 1);
7202
+ } else if (n2.t === "ref") {
7203
+ if (palettes.has(n2.path[0]) && n2.path.length > 1) {
7204
+ const base = `--color-${n2.path.slice(1).join("-")}`;
7205
+ for (const [k, v] of Object.entries(TAILWIND_V3_THEME)) {
7206
+ if (k === base || k.startsWith(`${base}-`)) out.vars.push([prefix + k.slice(base.length), v]);
7207
+ }
7208
+ } else if (n2.path.length === 1) {
7209
+ const local = localObject(src, n2.path[0]);
7210
+ if (local) colors(prefix, local, depth + 1);
7211
+ }
7212
+ }
7213
+ };
7214
+ const family = (n2) => {
7215
+ if (n2.t === "str") return n2.v;
7216
+ if (n2.t !== "arr") return void 0;
7217
+ const first = n2.items[0];
7218
+ const list = first?.t === "arr" ? first.items : n2.items;
7219
+ const names = list.flatMap((x) => x.t === "str" ? [/\s/.test(x.v) && !/[",]/.test(x.v) ? `"${x.v}"` : x.v] : []);
7220
+ return names.length ? names.join(", ") : void 0;
7221
+ };
7222
+ const sizes = (key, n2) => {
7223
+ const size = n2.t === "str" ? n2 : n2.t === "arr" ? n2.items[0] : void 0;
7224
+ if (size?.t !== "str") return;
7225
+ out.vars.push([`--text-${key}`, size.v]);
7226
+ const spec = n2.t === "arr" ? n2.items[1] : void 0;
7227
+ if (spec?.t === "str") out.vars.push([`--text-${key}--line-height`, spec.v]);
7228
+ else if (spec?.t === "obj") {
7229
+ for (const [prop2, name] of [["lineHeight", "line-height"], ["letterSpacing", "letter-spacing"], ["fontWeight", "font-weight"]]) {
7230
+ const x = spec.props.get(prop2);
7231
+ if (x?.t === "str") out.vars.push([`--text-${key}--${name}`, x.v]);
7232
+ }
7233
+ }
7234
+ };
7235
+ for (const layer of [theme, get(theme, "extend")]) {
7236
+ if (layer?.t !== "obj") continue;
7237
+ for (const [group, prefix] of GROUPS) {
7238
+ const n2 = layer.props.get(group);
7239
+ if (!n2) continue;
7240
+ if (layer === theme) out.replaced.add(prefix);
7241
+ if (n2.t !== "obj") continue;
7242
+ for (const [k, x] of n2.props) {
7243
+ if (group === "colors") colors(`--color-${k}`, x);
7244
+ else if (k === "DEFAULT") continue;
7245
+ else if (group === "fontSize") sizes(k, x);
7246
+ else if (group === "fontFamily") {
7247
+ const f = family(x);
7248
+ if (f) out.vars.push([`--font-${k}`, f]);
7249
+ } else if (x.t === "str") out.vars.push([`${prefix}${k}`, x.v]);
7250
+ }
7251
+ }
7252
+ }
7253
+ return out;
7254
+ }
7255
+ var OTHER, IDENT, Reader, parseAt, get, GROUPS;
7256
+ var init_tailwind_config = __esm({
7257
+ "src/tools/tailwind-config.ts"() {
7258
+ "use strict";
7259
+ init_tailwind_v3_theme();
7260
+ OTHER = { t: "other" };
7261
+ IDENT = /[\w$]/;
7262
+ Reader = class {
7263
+ constructor(s, i = 0) {
7264
+ this.s = s;
7265
+ this.i = i;
7266
+ }
7267
+ ws() {
7268
+ const s = this.s;
7269
+ for (; ; ) {
7270
+ while (this.i < s.length && /\s/.test(s[this.i])) this.i++;
7271
+ if (s[this.i] === "/" && s[this.i + 1] === "/") {
7272
+ const nl = s.indexOf("\n", this.i);
7273
+ this.i = nl < 0 ? s.length : nl;
7274
+ } else if (s[this.i] === "/" && s[this.i + 1] === "*") {
7275
+ const end = s.indexOf("*/", this.i + 2);
7276
+ this.i = end < 0 ? s.length : end + 2;
7277
+ } else return;
7278
+ }
7279
+ }
7280
+ quoted() {
7281
+ const s = this.s;
7282
+ const q = s[this.i++];
7283
+ let out = "";
7284
+ for (; this.i < s.length && s[this.i] !== q; this.i++) {
7285
+ if (s[this.i] === "\\") this.i++;
7286
+ out += s[this.i] ?? "";
7287
+ }
7288
+ this.i++;
7289
+ return out;
7290
+ }
7291
+ /** Moves to the next `,` or closing bracket at this depth, without consuming it. */
7292
+ skipExpr() {
7293
+ const s = this.s;
7294
+ let depth = 0;
7295
+ for (; this.i < s.length; this.i++) {
7296
+ const c = s[this.i];
7297
+ if (c === '"' || c === "'" || c === "`") this.quoted(), this.i--;
7298
+ else if (c === "/" && (s[this.i + 1] === "/" || s[this.i + 1] === "*")) this.ws(), this.i--;
7299
+ else if (c === "{" || c === "[" || c === "(") depth++;
7300
+ else if (c === "}" || c === "]" || c === ")") {
7301
+ if (depth === 0) return;
7302
+ depth--;
7303
+ } else if (c === "," && depth === 0) return;
7304
+ }
7305
+ }
7306
+ /** A value; anything that isn't a literal, an object, an array or a plain reference is `other`. */
7307
+ value() {
7308
+ this.ws();
7309
+ const s = this.s;
7310
+ const c = s[this.i];
7311
+ let node2 = OTHER;
7312
+ if (c === "{") node2 = this.object();
7313
+ else if (c === "[") {
7314
+ this.i++;
7315
+ const items = [];
7316
+ for (; ; ) {
7317
+ this.ws();
7318
+ if (this.i >= s.length || s[this.i] === "]") break;
7319
+ if (s[this.i] === ",") {
7320
+ this.i++;
7321
+ continue;
7322
+ }
7323
+ const before = this.i;
7324
+ items.push(s.startsWith("...", this.i) ? (this.skipExpr(), OTHER) : this.value());
7325
+ if (this.i === before) this.i++;
7326
+ }
7327
+ this.i++;
7328
+ node2 = { t: "arr", items };
7329
+ } else if (c === '"' || c === "'") node2 = { t: "str", v: this.quoted() };
7330
+ else if (c === "`") {
7331
+ const v = this.quoted();
7332
+ node2 = v.includes("${") ? OTHER : { t: "str", v };
7333
+ } else if (c !== void 0 && /[\d.-]/.test(c)) {
7334
+ const m = /^-?[\d.]+/.exec(s.slice(this.i, this.i + 24));
7335
+ if (m) {
7336
+ this.i += m[0].length;
7337
+ node2 = { t: "str", v: m[0] };
7338
+ }
7339
+ } else if (c !== void 0 && IDENT.test(c)) {
7340
+ const path7 = [];
7341
+ for (; ; ) {
7342
+ const m = /^[\w$]+/.exec(s.slice(this.i, this.i + 80));
7343
+ if (!m) break;
7344
+ path7.push(m[0]);
7345
+ this.i += m[0].length;
7346
+ if (s[this.i] === ".") {
7347
+ this.i++;
7348
+ continue;
7349
+ }
7350
+ const lit = /^\[\s*(["']?)([\w-]+)\1\s*\]/.exec(s.slice(this.i, this.i + 40));
7351
+ if (!lit) break;
7352
+ path7.push(lit[2]);
7353
+ this.i += lit[0].length;
7354
+ if (s[this.i] === ".") this.i++;
7355
+ else break;
7356
+ }
7357
+ node2 = path7.length ? { t: "ref", path: path7 } : OTHER;
7358
+ }
7359
+ this.ws();
7360
+ if (node2 !== OTHER && /^(?:as|satisfies)\s/.test(s.slice(this.i, this.i + 11))) {
7361
+ this.skipExpr();
7362
+ return node2;
7363
+ }
7364
+ if (this.i < s.length && ![",", "}", "]", ")"].includes(s[this.i])) {
7365
+ this.skipExpr();
7366
+ return OTHER;
7367
+ }
7368
+ return node2;
7369
+ }
7370
+ object() {
7371
+ const s = this.s;
7372
+ this.i++;
7373
+ const props = /* @__PURE__ */ new Map();
7374
+ for (; ; ) {
7375
+ this.ws();
7376
+ if (this.i >= s.length || s[this.i] === "}") break;
7377
+ if (s[this.i] === ",") {
7378
+ this.i++;
7379
+ continue;
7380
+ }
7381
+ const before = this.i;
7382
+ let key;
7383
+ if (s[this.i] === '"' || s[this.i] === "'") key = this.quoted();
7384
+ else {
7385
+ const m = /^[\w$-]+/.exec(s.slice(this.i, this.i + 80));
7386
+ if (m) {
7387
+ key = m[0];
7388
+ this.i += m[0].length;
7389
+ }
7390
+ }
7391
+ this.ws();
7392
+ if (key !== void 0 && s[this.i] === ":") {
7393
+ this.i++;
7394
+ props.set(key, this.value());
7395
+ } else if (key !== void 0 && (s[this.i] === "," || s[this.i] === "}")) {
7396
+ props.set(key, { t: "ref", path: [key] });
7397
+ } else this.skipExpr();
7398
+ if (this.i === before) this.i++;
7399
+ }
7400
+ this.i++;
7401
+ return { t: "obj", props };
7402
+ }
7403
+ };
7404
+ parseAt = (src, open2) => new Reader(src, open2).value();
7405
+ get = (n2, key) => n2?.t === "obj" ? n2.props.get(key) : void 0;
7406
+ GROUPS = [
7407
+ ["colors", "--color-"],
7408
+ ["fontFamily", "--font-"],
7409
+ ["fontSize", "--text-"],
7410
+ ["fontWeight", "--font-weight-"],
7411
+ ["letterSpacing", "--tracking-"]
7412
+ ];
7413
+ }
7414
+ });
7415
+
7416
+ // src/tools/tailwind-theme.ts
7417
+ var TAILWIND_THEME;
7418
+ var init_tailwind_theme = __esm({
7419
+ "src/tools/tailwind-theme.ts"() {
7420
+ "use strict";
7421
+ TAILWIND_THEME = {
7422
+ "--color-red-50": "oklch(97.1% 0.013 17.38)",
7423
+ "--color-red-100": "oklch(93.6% 0.032 17.717)",
7424
+ "--color-red-200": "oklch(88.5% 0.062 18.334)",
7425
+ "--color-red-300": "oklch(80.8% 0.114 19.571)",
7426
+ "--color-red-400": "oklch(70.4% 0.191 22.216)",
7427
+ "--color-red-500": "oklch(63.7% 0.237 25.331)",
7428
+ "--color-red-600": "oklch(57.7% 0.245 27.325)",
7429
+ "--color-red-700": "oklch(50.5% 0.213 27.518)",
7430
+ "--color-red-800": "oklch(44.4% 0.177 26.899)",
7431
+ "--color-red-900": "oklch(39.6% 0.141 25.723)",
7432
+ "--color-red-950": "oklch(25.8% 0.092 26.042)",
7433
+ "--color-orange-50": "oklch(98% 0.016 73.684)",
7434
+ "--color-orange-100": "oklch(95.4% 0.038 75.164)",
7435
+ "--color-orange-200": "oklch(90.1% 0.076 70.697)",
7436
+ "--color-orange-300": "oklch(83.7% 0.128 66.29)",
7437
+ "--color-orange-400": "oklch(75% 0.183 55.934)",
7438
+ "--color-orange-500": "oklch(70.5% 0.213 47.604)",
7439
+ "--color-orange-600": "oklch(64.6% 0.222 41.116)",
7440
+ "--color-orange-700": "oklch(55.3% 0.195 38.402)",
7441
+ "--color-orange-800": "oklch(47% 0.157 37.304)",
7442
+ "--color-orange-900": "oklch(40.8% 0.123 38.172)",
7443
+ "--color-orange-950": "oklch(26.6% 0.079 36.259)",
7444
+ "--color-amber-50": "oklch(98.7% 0.022 95.277)",
7445
+ "--color-amber-100": "oklch(96.2% 0.059 95.617)",
7446
+ "--color-amber-200": "oklch(92.4% 0.12 95.746)",
7447
+ "--color-amber-300": "oklch(87.9% 0.169 91.605)",
7448
+ "--color-amber-400": "oklch(82.8% 0.189 84.429)",
7449
+ "--color-amber-500": "oklch(76.9% 0.188 70.08)",
7450
+ "--color-amber-600": "oklch(66.6% 0.179 58.318)",
7451
+ "--color-amber-700": "oklch(55.5% 0.163 48.998)",
7452
+ "--color-amber-800": "oklch(47.3% 0.137 46.201)",
7453
+ "--color-amber-900": "oklch(41.4% 0.112 45.904)",
7454
+ "--color-amber-950": "oklch(27.9% 0.077 45.635)",
7455
+ "--color-yellow-50": "oklch(98.7% 0.026 102.212)",
7456
+ "--color-yellow-100": "oklch(97.3% 0.071 103.193)",
7457
+ "--color-yellow-200": "oklch(94.5% 0.129 101.54)",
7458
+ "--color-yellow-300": "oklch(90.5% 0.182 98.111)",
7459
+ "--color-yellow-400": "oklch(85.2% 0.199 91.936)",
7460
+ "--color-yellow-500": "oklch(79.5% 0.184 86.047)",
7461
+ "--color-yellow-600": "oklch(68.1% 0.162 75.834)",
7462
+ "--color-yellow-700": "oklch(55.4% 0.135 66.442)",
7463
+ "--color-yellow-800": "oklch(47.6% 0.114 61.907)",
7464
+ "--color-yellow-900": "oklch(42.1% 0.095 57.708)",
7465
+ "--color-yellow-950": "oklch(28.6% 0.066 53.813)",
7466
+ "--color-lime-50": "oklch(98.6% 0.031 120.757)",
7467
+ "--color-lime-100": "oklch(96.7% 0.067 122.328)",
7468
+ "--color-lime-200": "oklch(93.8% 0.127 124.321)",
7469
+ "--color-lime-300": "oklch(89.7% 0.196 126.665)",
7470
+ "--color-lime-400": "oklch(84.1% 0.238 128.85)",
7471
+ "--color-lime-500": "oklch(76.8% 0.233 130.85)",
7472
+ "--color-lime-600": "oklch(64.8% 0.2 131.684)",
7473
+ "--color-lime-700": "oklch(53.2% 0.157 131.589)",
7474
+ "--color-lime-800": "oklch(45.3% 0.124 130.933)",
7475
+ "--color-lime-900": "oklch(40.5% 0.101 131.063)",
7476
+ "--color-lime-950": "oklch(27.4% 0.072 132.109)",
7477
+ "--color-green-50": "oklch(98.2% 0.018 155.826)",
7478
+ "--color-green-100": "oklch(96.2% 0.044 156.743)",
7479
+ "--color-green-200": "oklch(92.5% 0.084 155.995)",
7480
+ "--color-green-300": "oklch(87.1% 0.15 154.449)",
7481
+ "--color-green-400": "oklch(79.2% 0.209 151.711)",
7482
+ "--color-green-500": "oklch(72.3% 0.219 149.579)",
7483
+ "--color-green-600": "oklch(62.7% 0.194 149.214)",
7484
+ "--color-green-700": "oklch(52.7% 0.154 150.069)",
7485
+ "--color-green-800": "oklch(44.8% 0.119 151.328)",
7486
+ "--color-green-900": "oklch(39.3% 0.095 152.535)",
7487
+ "--color-green-950": "oklch(26.6% 0.065 152.934)",
7488
+ "--color-emerald-50": "oklch(97.9% 0.021 166.113)",
7489
+ "--color-emerald-100": "oklch(95% 0.052 163.051)",
7490
+ "--color-emerald-200": "oklch(90.5% 0.093 164.15)",
7491
+ "--color-emerald-300": "oklch(84.5% 0.143 164.978)",
7492
+ "--color-emerald-400": "oklch(76.5% 0.177 163.223)",
7493
+ "--color-emerald-500": "oklch(69.6% 0.17 162.48)",
7494
+ "--color-emerald-600": "oklch(59.6% 0.145 163.225)",
7495
+ "--color-emerald-700": "oklch(50.8% 0.118 165.612)",
7496
+ "--color-emerald-800": "oklch(43.2% 0.095 166.913)",
7497
+ "--color-emerald-900": "oklch(37.8% 0.077 168.94)",
7498
+ "--color-emerald-950": "oklch(26.2% 0.051 172.552)",
7499
+ "--color-teal-50": "oklch(98.4% 0.014 180.72)",
7500
+ "--color-teal-100": "oklch(95.3% 0.051 180.801)",
7501
+ "--color-teal-200": "oklch(91% 0.096 180.426)",
7502
+ "--color-teal-300": "oklch(85.5% 0.138 181.071)",
7503
+ "--color-teal-400": "oklch(77.7% 0.152 181.912)",
7504
+ "--color-teal-500": "oklch(70.4% 0.14 182.503)",
7505
+ "--color-teal-600": "oklch(60% 0.118 184.704)",
7506
+ "--color-teal-700": "oklch(51.1% 0.096 186.391)",
7507
+ "--color-teal-800": "oklch(43.7% 0.078 188.216)",
7508
+ "--color-teal-900": "oklch(38.6% 0.063 188.416)",
7509
+ "--color-teal-950": "oklch(27.7% 0.046 192.524)",
7510
+ "--color-cyan-50": "oklch(98.4% 0.019 200.873)",
7511
+ "--color-cyan-100": "oklch(95.6% 0.045 203.388)",
7512
+ "--color-cyan-200": "oklch(91.7% 0.08 205.041)",
7513
+ "--color-cyan-300": "oklch(86.5% 0.127 207.078)",
7514
+ "--color-cyan-400": "oklch(78.9% 0.154 211.53)",
7515
+ "--color-cyan-500": "oklch(71.5% 0.143 215.221)",
7516
+ "--color-cyan-600": "oklch(60.9% 0.126 221.723)",
7517
+ "--color-cyan-700": "oklch(52% 0.105 223.128)",
7518
+ "--color-cyan-800": "oklch(45% 0.085 224.283)",
7519
+ "--color-cyan-900": "oklch(39.8% 0.07 227.392)",
7520
+ "--color-cyan-950": "oklch(30.2% 0.056 229.695)",
7521
+ "--color-sky-50": "oklch(97.7% 0.013 236.62)",
7522
+ "--color-sky-100": "oklch(95.1% 0.026 236.824)",
7523
+ "--color-sky-200": "oklch(90.1% 0.058 230.902)",
7524
+ "--color-sky-300": "oklch(82.8% 0.111 230.318)",
7525
+ "--color-sky-400": "oklch(74.6% 0.16 232.661)",
7526
+ "--color-sky-500": "oklch(68.5% 0.169 237.323)",
7527
+ "--color-sky-600": "oklch(58.8% 0.158 241.966)",
7528
+ "--color-sky-700": "oklch(50% 0.134 242.749)",
7529
+ "--color-sky-800": "oklch(44.3% 0.11 240.79)",
7530
+ "--color-sky-900": "oklch(39.1% 0.09 240.876)",
7531
+ "--color-sky-950": "oklch(29.3% 0.066 243.157)",
7532
+ "--color-blue-50": "oklch(97% 0.014 254.604)",
7533
+ "--color-blue-100": "oklch(93.2% 0.032 255.585)",
7534
+ "--color-blue-200": "oklch(88.2% 0.059 254.128)",
7535
+ "--color-blue-300": "oklch(80.9% 0.105 251.813)",
7536
+ "--color-blue-400": "oklch(70.7% 0.165 254.624)",
7537
+ "--color-blue-500": "oklch(62.3% 0.214 259.815)",
7538
+ "--color-blue-600": "oklch(54.6% 0.245 262.881)",
7539
+ "--color-blue-700": "oklch(48.8% 0.243 264.376)",
7540
+ "--color-blue-800": "oklch(42.4% 0.199 265.638)",
7541
+ "--color-blue-900": "oklch(37.9% 0.146 265.522)",
7542
+ "--color-blue-950": "oklch(28.2% 0.091 267.935)",
7543
+ "--color-indigo-50": "oklch(96.2% 0.018 272.314)",
7544
+ "--color-indigo-100": "oklch(93% 0.034 272.788)",
7545
+ "--color-indigo-200": "oklch(87% 0.065 274.039)",
7546
+ "--color-indigo-300": "oklch(78.5% 0.115 274.713)",
7547
+ "--color-indigo-400": "oklch(67.3% 0.182 276.935)",
7548
+ "--color-indigo-500": "oklch(58.5% 0.233 277.117)",
7549
+ "--color-indigo-600": "oklch(51.1% 0.262 276.966)",
7550
+ "--color-indigo-700": "oklch(45.7% 0.24 277.023)",
7551
+ "--color-indigo-800": "oklch(39.8% 0.195 277.366)",
7552
+ "--color-indigo-900": "oklch(35.9% 0.144 278.697)",
7553
+ "--color-indigo-950": "oklch(25.7% 0.09 281.288)",
7554
+ "--color-violet-50": "oklch(96.9% 0.016 293.756)",
7555
+ "--color-violet-100": "oklch(94.3% 0.029 294.588)",
7556
+ "--color-violet-200": "oklch(89.4% 0.057 293.283)",
7557
+ "--color-violet-300": "oklch(81.1% 0.111 293.571)",
7558
+ "--color-violet-400": "oklch(70.2% 0.183 293.541)",
7559
+ "--color-violet-500": "oklch(60.6% 0.25 292.717)",
7560
+ "--color-violet-600": "oklch(54.1% 0.281 293.009)",
7561
+ "--color-violet-700": "oklch(49.1% 0.27 292.581)",
7562
+ "--color-violet-800": "oklch(43.2% 0.232 292.759)",
7563
+ "--color-violet-900": "oklch(38% 0.189 293.745)",
7564
+ "--color-violet-950": "oklch(28.3% 0.141 291.089)",
7565
+ "--color-purple-50": "oklch(97.7% 0.014 308.299)",
7566
+ "--color-purple-100": "oklch(94.6% 0.033 307.174)",
7567
+ "--color-purple-200": "oklch(90.2% 0.063 306.703)",
7568
+ "--color-purple-300": "oklch(82.7% 0.119 306.383)",
7569
+ "--color-purple-400": "oklch(71.4% 0.203 305.504)",
7570
+ "--color-purple-500": "oklch(62.7% 0.265 303.9)",
7571
+ "--color-purple-600": "oklch(55.8% 0.288 302.321)",
7572
+ "--color-purple-700": "oklch(49.6% 0.265 301.924)",
7573
+ "--color-purple-800": "oklch(43.8% 0.218 303.724)",
7574
+ "--color-purple-900": "oklch(38.1% 0.176 304.987)",
7575
+ "--color-purple-950": "oklch(29.1% 0.149 302.717)",
7576
+ "--color-fuchsia-50": "oklch(97.7% 0.017 320.058)",
7577
+ "--color-fuchsia-100": "oklch(95.2% 0.037 318.852)",
7578
+ "--color-fuchsia-200": "oklch(90.3% 0.076 319.62)",
7579
+ "--color-fuchsia-300": "oklch(83.3% 0.145 321.434)",
7580
+ "--color-fuchsia-400": "oklch(74% 0.238 322.16)",
7581
+ "--color-fuchsia-500": "oklch(66.7% 0.295 322.15)",
7582
+ "--color-fuchsia-600": "oklch(59.1% 0.293 322.896)",
7583
+ "--color-fuchsia-700": "oklch(51.8% 0.253 323.949)",
7584
+ "--color-fuchsia-800": "oklch(45.2% 0.211 324.591)",
7585
+ "--color-fuchsia-900": "oklch(40.1% 0.17 325.612)",
7586
+ "--color-fuchsia-950": "oklch(29.3% 0.136 325.661)",
7587
+ "--color-pink-50": "oklch(97.1% 0.014 343.198)",
7588
+ "--color-pink-100": "oklch(94.8% 0.028 342.258)",
7589
+ "--color-pink-200": "oklch(89.9% 0.061 343.231)",
7590
+ "--color-pink-300": "oklch(82.3% 0.12 346.018)",
7591
+ "--color-pink-400": "oklch(71.8% 0.202 349.761)",
7592
+ "--color-pink-500": "oklch(65.6% 0.241 354.308)",
7593
+ "--color-pink-600": "oklch(59.2% 0.249 0.584)",
7594
+ "--color-pink-700": "oklch(52.5% 0.223 3.958)",
7595
+ "--color-pink-800": "oklch(45.9% 0.187 3.815)",
7596
+ "--color-pink-900": "oklch(40.8% 0.153 2.432)",
7597
+ "--color-pink-950": "oklch(28.4% 0.109 3.907)",
7598
+ "--color-rose-50": "oklch(96.9% 0.015 12.422)",
7599
+ "--color-rose-100": "oklch(94.1% 0.03 12.58)",
7600
+ "--color-rose-200": "oklch(89.2% 0.058 10.001)",
7601
+ "--color-rose-300": "oklch(81% 0.117 11.638)",
7602
+ "--color-rose-400": "oklch(71.2% 0.194 13.428)",
7603
+ "--color-rose-500": "oklch(64.5% 0.246 16.439)",
7604
+ "--color-rose-600": "oklch(58.6% 0.253 17.585)",
7605
+ "--color-rose-700": "oklch(51.4% 0.222 16.935)",
7606
+ "--color-rose-800": "oklch(45.5% 0.188 13.697)",
7607
+ "--color-rose-900": "oklch(41% 0.159 10.272)",
7608
+ "--color-rose-950": "oklch(27.1% 0.105 12.094)",
7609
+ "--color-slate-50": "oklch(98.4% 0.003 247.858)",
7610
+ "--color-slate-100": "oklch(96.8% 0.007 247.896)",
7611
+ "--color-slate-200": "oklch(92.9% 0.013 255.508)",
7612
+ "--color-slate-300": "oklch(86.9% 0.022 252.894)",
7613
+ "--color-slate-400": "oklch(70.4% 0.04 256.788)",
7614
+ "--color-slate-500": "oklch(55.4% 0.046 257.417)",
7615
+ "--color-slate-600": "oklch(44.6% 0.043 257.281)",
7616
+ "--color-slate-700": "oklch(37.2% 0.044 257.287)",
7617
+ "--color-slate-800": "oklch(27.9% 0.041 260.031)",
7618
+ "--color-slate-900": "oklch(20.8% 0.042 265.755)",
7619
+ "--color-slate-950": "oklch(12.9% 0.042 264.695)",
7620
+ "--color-gray-50": "oklch(98.5% 0.002 247.839)",
7621
+ "--color-gray-100": "oklch(96.7% 0.003 264.542)",
7622
+ "--color-gray-200": "oklch(92.8% 0.006 264.531)",
7623
+ "--color-gray-300": "oklch(87.2% 0.01 258.338)",
7624
+ "--color-gray-400": "oklch(70.7% 0.022 261.325)",
7625
+ "--color-gray-500": "oklch(55.1% 0.027 264.364)",
7626
+ "--color-gray-600": "oklch(44.6% 0.03 256.802)",
7627
+ "--color-gray-700": "oklch(37.3% 0.034 259.733)",
7628
+ "--color-gray-800": "oklch(27.8% 0.033 256.848)",
7629
+ "--color-gray-900": "oklch(21% 0.034 264.665)",
7630
+ "--color-gray-950": "oklch(13% 0.028 261.692)",
7631
+ "--color-zinc-50": "oklch(98.5% 0 none)",
7632
+ "--color-zinc-100": "oklch(96.7% 0.001 286.375)",
7633
+ "--color-zinc-200": "oklch(92% 0.004 286.32)",
7634
+ "--color-zinc-300": "oklch(87.1% 0.006 286.286)",
7635
+ "--color-zinc-400": "oklch(70.5% 0.015 286.067)",
7636
+ "--color-zinc-500": "oklch(55.2% 0.016 285.938)",
7637
+ "--color-zinc-600": "oklch(44.2% 0.017 285.786)",
7638
+ "--color-zinc-700": "oklch(37% 0.013 285.805)",
7639
+ "--color-zinc-800": "oklch(27.4% 0.006 286.033)",
7640
+ "--color-zinc-900": "oklch(21% 0.006 285.885)",
7641
+ "--color-zinc-950": "oklch(14.1% 0.005 285.823)",
7642
+ "--color-neutral-50": "oklch(98.5% 0 none)",
7643
+ "--color-neutral-100": "oklch(97% 0 none)",
7644
+ "--color-neutral-200": "oklch(92.2% 0 none)",
7645
+ "--color-neutral-300": "oklch(87% 0 none)",
7646
+ "--color-neutral-400": "oklch(70.8% 0 none)",
7647
+ "--color-neutral-500": "oklch(55.6% 0 none)",
7648
+ "--color-neutral-600": "oklch(43.9% 0 none)",
7649
+ "--color-neutral-700": "oklch(37.1% 0 none)",
7650
+ "--color-neutral-800": "oklch(26.9% 0 none)",
7651
+ "--color-neutral-900": "oklch(20.5% 0 none)",
7652
+ "--color-neutral-950": "oklch(14.5% 0 none)",
7653
+ "--color-stone-50": "oklch(98.5% 0.001 106.423)",
7654
+ "--color-stone-100": "oklch(97% 0.001 106.424)",
7655
+ "--color-stone-200": "oklch(92.3% 0.003 48.717)",
7656
+ "--color-stone-300": "oklch(86.9% 0.005 56.366)",
7657
+ "--color-stone-400": "oklch(70.9% 0.01 56.259)",
7658
+ "--color-stone-500": "oklch(55.3% 0.013 58.071)",
7659
+ "--color-stone-600": "oklch(44.4% 0.011 73.639)",
7660
+ "--color-stone-700": "oklch(37.4% 0.01 67.558)",
7661
+ "--color-stone-800": "oklch(26.8% 0.007 34.298)",
7662
+ "--color-stone-900": "oklch(21.6% 0.006 56.043)",
7663
+ "--color-stone-950": "oklch(14.7% 0.004 49.25)",
7664
+ "--color-mauve-50": "oklch(98.5% 0 none)",
7665
+ "--color-mauve-100": "oklch(96% 0.003 325.6)",
7666
+ "--color-mauve-200": "oklch(92.2% 0.005 325.62)",
7667
+ "--color-mauve-300": "oklch(86.5% 0.012 325.68)",
7668
+ "--color-mauve-400": "oklch(71.1% 0.019 323.02)",
7669
+ "--color-mauve-500": "oklch(54.2% 0.034 322.5)",
7670
+ "--color-mauve-600": "oklch(43.5% 0.029 321.78)",
7671
+ "--color-mauve-700": "oklch(36.4% 0.029 323.89)",
7672
+ "--color-mauve-800": "oklch(26.3% 0.024 320.12)",
7673
+ "--color-mauve-900": "oklch(21.2% 0.019 322.12)",
7674
+ "--color-mauve-950": "oklch(14.5% 0.008 326)",
7675
+ "--color-olive-50": "oklch(98.8% 0.003 106.5)",
7676
+ "--color-olive-100": "oklch(96.6% 0.005 106.5)",
7677
+ "--color-olive-200": "oklch(93% 0.007 106.5)",
7678
+ "--color-olive-300": "oklch(88% 0.011 106.6)",
7679
+ "--color-olive-400": "oklch(73.7% 0.021 106.9)",
7680
+ "--color-olive-500": "oklch(58% 0.031 107.3)",
7681
+ "--color-olive-600": "oklch(46.6% 0.025 107.3)",
7682
+ "--color-olive-700": "oklch(39.4% 0.023 107.4)",
7683
+ "--color-olive-800": "oklch(28.6% 0.016 107.4)",
7684
+ "--color-olive-900": "oklch(22.8% 0.013 107.4)",
7685
+ "--color-olive-950": "oklch(15.3% 0.006 107.1)",
7686
+ "--color-mist-50": "oklch(98.7% 0.002 197.1)",
7687
+ "--color-mist-100": "oklch(96.3% 0.002 197.1)",
7688
+ "--color-mist-200": "oklch(92.5% 0.005 214.3)",
7689
+ "--color-mist-300": "oklch(87.2% 0.007 219.6)",
7690
+ "--color-mist-400": "oklch(72.3% 0.014 214.4)",
7691
+ "--color-mist-500": "oklch(56% 0.021 213.5)",
7692
+ "--color-mist-600": "oklch(45% 0.017 213.2)",
7693
+ "--color-mist-700": "oklch(37.8% 0.015 216)",
7694
+ "--color-mist-800": "oklch(27.5% 0.011 216.9)",
7695
+ "--color-mist-900": "oklch(21.8% 0.008 223.9)",
7696
+ "--color-mist-950": "oklch(14.8% 0.004 228.8)",
7697
+ "--color-taupe-50": "oklch(98.6% 0.002 67.8)",
7698
+ "--color-taupe-100": "oklch(96% 0.002 17.2)",
7699
+ "--color-taupe-200": "oklch(92.2% 0.005 34.3)",
7700
+ "--color-taupe-300": "oklch(86.8% 0.007 39.5)",
7701
+ "--color-taupe-400": "oklch(71.4% 0.014 41.2)",
7702
+ "--color-taupe-500": "oklch(54.7% 0.021 43.1)",
7703
+ "--color-taupe-600": "oklch(43.8% 0.017 39.3)",
7704
+ "--color-taupe-700": "oklch(36.7% 0.016 35.7)",
7705
+ "--color-taupe-800": "oklch(26.8% 0.011 36.5)",
7706
+ "--color-taupe-900": "oklch(21.4% 0.009 43.1)",
7707
+ "--color-taupe-950": "oklch(14.7% 0.004 49.3)",
7708
+ "--color-black": "#000",
7709
+ "--color-white": "#fff",
7710
+ "--text-xs": "0.75rem",
7711
+ "--text-xs--line-height": "calc(1 / 0.75)",
7712
+ "--text-sm": "0.875rem",
7713
+ "--text-sm--line-height": "calc(1.25 / 0.875)",
7714
+ "--text-base": "1rem",
7715
+ "--text-base--line-height": "calc(1.5 / 1)",
7716
+ "--text-lg": "1.125rem",
7717
+ "--text-lg--line-height": "calc(1.75 / 1.125)",
7718
+ "--text-xl": "1.25rem",
7719
+ "--text-xl--line-height": "calc(1.75 / 1.25)",
7720
+ "--text-2xl": "1.5rem",
7721
+ "--text-2xl--line-height": "calc(2 / 1.5)",
7722
+ "--text-3xl": "1.875rem",
7723
+ "--text-3xl--line-height": "calc(2.25 / 1.875)",
7724
+ "--text-4xl": "2.25rem",
7725
+ "--text-4xl--line-height": "calc(2.5 / 2.25)",
7726
+ "--text-5xl": "3rem",
7727
+ "--text-5xl--line-height": "1",
7728
+ "--text-6xl": "3.75rem",
7729
+ "--text-6xl--line-height": "1",
7730
+ "--text-7xl": "4.5rem",
7731
+ "--text-7xl--line-height": "1",
7732
+ "--text-8xl": "6rem",
7733
+ "--text-8xl--line-height": "1",
7734
+ "--text-9xl": "8rem",
7735
+ "--text-9xl--line-height": "1",
7736
+ "--font-weight-thin": "100",
7737
+ "--font-weight-extralight": "200",
7738
+ "--font-weight-light": "300",
7739
+ "--font-weight-normal": "400",
7740
+ "--font-weight-medium": "500",
7741
+ "--font-weight-semibold": "600",
7742
+ "--font-weight-bold": "700",
7743
+ "--font-weight-extrabold": "800",
7744
+ "--font-weight-black": "900",
7745
+ "--tracking-tighter": "-0.05em",
7746
+ "--tracking-tight": "-0.025em",
7747
+ "--tracking-normal": "0em",
7748
+ "--tracking-wide": "0.025em",
7749
+ "--tracking-wider": "0.05em",
7750
+ "--tracking-widest": "0.1em",
7751
+ "--text-shadow-2xs": "0px 1px 0px rgb(0 0 0 / 0.15)",
7752
+ "--text-shadow-xs": "0px 1px 1px rgb(0 0 0 / 0.2)",
7753
+ "--text-shadow-sm": "0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075), 0px 2px 2px rgb(0 0 0 / 0.075)",
7754
+ "--text-shadow-md": "0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1), 0px 2px 4px rgb(0 0 0 / 0.1)",
7755
+ "--text-shadow-lg": "0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1), 0px 4px 8px rgb(0 0 0 / 0.1)"
7756
+ };
7757
+ }
7758
+ });
7759
+
6144
7760
  // src/tools/project.ts
6145
7761
  import { execFile } from "node:child_process";
6146
- import { readdir, readFile as readFile2 } from "node:fs/promises";
7762
+ import { readdir as readdir2, readFile as readFile3 } from "node:fs/promises";
6147
7763
  import os3 from "node:os";
6148
- import path3 from "node:path";
7764
+ import path4 from "node:path";
6149
7765
  import { promisify } from "node:util";
6150
7766
  async function scanProject(root, exclude = [], maxEntries = MAX_ENTRIES) {
6151
- root = path3.resolve(root);
6152
- if (root === path3.parse(root).root || root === os3.homedir()) return void 0;
6153
- const skip = [...new Set(exclude.map((e) => path3.resolve(e)))];
7767
+ root = path4.resolve(root);
7768
+ if (root === path4.parse(root).root || root === os3.homedir()) return void 0;
7769
+ const skip = [...new Set(exclude.map((e) => path4.resolve(e)))];
6154
7770
  const styles = [];
6155
7771
  const svgs = [];
6156
7772
  const comps = [];
6157
- const shown = (p) => path3.relative(process.cwd(), p).split(path3.sep).join("/");
7773
+ const manifests = [];
7774
+ const elixir = [];
7775
+ const twConfigs = [];
7776
+ const shown = (p) => path4.relative(process.cwd(), p).split(path4.sep).join("/");
6158
7777
  let incomplete;
6159
7778
  const sort = (p) => {
6160
- const name = path3.basename(p);
7779
+ const name = path4.basename(p);
6161
7780
  if (STYLE.test(name)) styles.push(p);
6162
7781
  else if (/\.svg$/i.test(name)) svgs.push(p);
6163
7782
  else if (COMPONENT_FILE.test(name)) comps.push(p);
7783
+ else if (name === "package.json" || name === "mix.exs") manifests.push(p);
7784
+ else if (name.endsWith(".ex")) elixir.push(p);
7785
+ else if (/^tailwind\.config\.(js|cjs|mjs|ts)$/.test(name)) twConfigs.push(p);
6164
7786
  };
6165
- const skipped = (p) => skip.some((s) => p === s || p.startsWith(s + path3.sep));
7787
+ const skipped = (p) => skip.some((s) => p === s || p.startsWith(s + path4.sep));
6166
7788
  const tracked = await gitFiles(root);
6167
7789
  if (tracked?.length) {
6168
7790
  for (const p of tracked) {
6169
- const dirs = path3.relative(root, p).split(path3.sep).slice(0, -1);
7791
+ const dirs = path4.relative(root, p).split(path4.sep).slice(0, -1);
6170
7792
  if (!dirs.some((d) => d.startsWith(".") || SKIP_DIRS.has(d)) && !skipped(p)) sort(p);
6171
7793
  }
6172
7794
  } else {
@@ -6180,14 +7802,14 @@ async function scanProject(root, exclude = [], maxEntries = MAX_ENTRIES) {
6180
7802
  }
6181
7803
  let list;
6182
7804
  try {
6183
- list = await readdir(dir, { withFileTypes: true });
7805
+ list = await readdir2(dir, { withFileTypes: true });
6184
7806
  } catch {
6185
7807
  return;
6186
7808
  }
6187
7809
  entries += list.length;
6188
7810
  list.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
6189
7811
  for (const e of list) {
6190
- const p = path3.join(dir, e.name);
7812
+ const p = path4.join(dir, e.name);
6191
7813
  if (e.isDirectory()) {
6192
7814
  if (!e.name.startsWith(".") && !SKIP_DIRS.has(e.name) && !skipped(p)) await walk(p, depth + 1);
6193
7815
  } else if (e.isFile()) sort(p);
@@ -6205,17 +7827,25 @@ async function scanProject(root, exclude = [], maxEntries = MAX_ENTRIES) {
6205
7827
  };
6206
7828
  const vars = /* @__PURE__ */ new Map();
6207
7829
  const classes = /* @__PURE__ */ new Map();
7830
+ let tailwind = false;
7831
+ const theme = /* @__PURE__ */ new Set();
7832
+ const resets = [];
6208
7833
  for (const f of styles.slice(0, MAX_STYLES)) {
6209
7834
  const css = await readText(f, 1e6);
6210
7835
  if (!css) continue;
6211
7836
  const text2 = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
7837
+ if (/@import\s+(?:url\(\s*)?["']tailwindcss(?:\/[\w-]+\.css)?["']|@theme\b/.test(text2)) tailwind = true;
7838
+ for (const block of themeBlocks(text2)) {
7839
+ for (const m of block.matchAll(/(?<=(?:^|[{;])\s*)(--[\w-]+)\s*:/g)) theme.add(m[1]);
7840
+ for (const m of block.matchAll(/(--[\w-]*)\*\s*:\s*initial/g)) resets.push(m[1]);
7841
+ }
6212
7842
  const define = (re) => {
6213
7843
  for (const m of text2.matchAll(re)) if (!vars.has(m[1])) vars.set(m[1], m[2].trim());
6214
7844
  };
6215
7845
  define(/(?<=(?:^|[{;])\s*)(--[\w-]+)\s*:\s*([^;{}]+)/g);
6216
7846
  if (/\.(scss|sass)$/i.test(f)) define(/^\s*(\$[\w-]+)\s*:\s*([^;\n]+)/gm);
6217
7847
  if (/\.less$/i.test(f)) define(/^\s*(@[\w-]+)\s*:\s*([^;\n]+)/gm);
6218
- const stem = slug2(path3.basename(f).replace(/\.[^.]+$/, ""));
7848
+ const stem = slug2(path4.basename(f).replace(/\.[^.]+$/, ""));
6219
7849
  for (const m of text2.matchAll(/(?<=^|[{};])\s*\.(-?[_a-zA-Z][\w-]*)\s*\{([^{}]*)\}/g)) {
6220
7850
  if (!/__|--/.test(m[1])) rules.push({ cls: m[1], decls: m[2], file: shown(f) });
6221
7851
  }
@@ -6226,12 +7856,28 @@ async function scanProject(root, exclude = [], maxEntries = MAX_ENTRIES) {
6226
7856
  }
6227
7857
  }
6228
7858
  }
7859
+ const defaults = /* @__PURE__ */ new Set();
7860
+ if (tailwind) {
7861
+ for (const [k, v] of Object.entries(TAILWIND_THEME)) {
7862
+ if (vars.has(k) || resets.some((r) => k.startsWith(r) && !(r === "--font-" && k.startsWith("--font-weight-")))) continue;
7863
+ vars.set(k, v);
7864
+ theme.add(k);
7865
+ defaults.add(k);
7866
+ }
7867
+ }
7868
+ const utility = (name) => {
7869
+ if (!theme.has(name)) return void 0;
7870
+ const m = /^--(color|font)-([\w-]+)$/.exec(name);
7871
+ if (!m || m[1] === "font" && m[2].startsWith("weight-")) return void 0;
7872
+ return m[1] === "color" ? `*-${m[2]}` : `font-${m[2]}`;
7873
+ };
6229
7874
  const ref = (name, wrap) => {
7875
+ const u = utility(name);
7876
+ if (u) return u;
6230
7877
  const r = name.startsWith("--") ? `var(${name})` : name;
6231
7878
  return wrap ? `${wrap}(${r})` : r;
6232
7879
  };
6233
- const resolved = [];
6234
- for (const [name, value] of vars) {
7880
+ const resolve = (value) => {
6235
7881
  let v = value;
6236
7882
  let alias = false;
6237
7883
  for (let hops = 0; hops < 5; hops++) {
@@ -6241,19 +7887,48 @@ async function scanProject(root, exclude = [], maxEntries = MAX_ENTRIES) {
6241
7887
  v = next;
6242
7888
  alias = true;
6243
7889
  }
6244
- resolved.push([name, v, alias]);
6245
- }
6246
- for (const pass of [true, false]) {
6247
- for (const [name, v, alias] of resolved) {
6248
- if (alias !== pass) continue;
6249
- const c = parseColor(v);
6250
- if (c) add(idx.colors, c.hex, ref(name, c.wrap));
6251
- else if (/font|family|typeface/i.test(name)) {
6252
- const fam = firstFamily(v);
6253
- if (fam && !/^\d|^var\(/.test(fam)) add(idx.fonts, fam, ref(name));
6254
- }
6255
- }
6256
- }
7890
+ return { v, alias };
7891
+ };
7892
+ if (twConfigs.length) {
7893
+ const channel = (name) => resolve(vars.get(name) ?? "").v || void 0;
7894
+ const replaced = /* @__PURE__ */ new Set();
7895
+ const own2 = [];
7896
+ for (const f of twConfigs.slice(0, 8)) {
7897
+ const src = await readText(f, 2e5);
7898
+ if (!src) continue;
7899
+ const c = tailwindConfigTheme(src, channel);
7900
+ c.replaced.forEach((p) => replaced.add(p));
7901
+ own2.push(...c.vars);
7902
+ }
7903
+ const add2 = (k, v, isDefault) => {
7904
+ if (vars.has(k)) return;
7905
+ vars.set(k, v);
7906
+ theme.add(k);
7907
+ if (isDefault) defaults.add(k);
7908
+ };
7909
+ for (const [k, v] of own2) add2(k, v, false);
7910
+ if (!tailwind) for (const [k, v] of tailwindV3Defaults(replaced)) add2(k, v, true);
7911
+ tailwind = true;
7912
+ }
7913
+ const ranked = [];
7914
+ for (const [name, value] of vars) {
7915
+ const { v, alias } = resolve(value);
7916
+ const rank2 = defaults.has(name) ? 3 : utility(name) ? 0 : alias ? 1 : 2;
7917
+ ranked.push({ name, v, rank: rank2 });
7918
+ }
7919
+ ranked.sort((a, b) => a.rank - b.rank);
7920
+ for (const { name, v } of ranked) {
7921
+ const c = parseColor(v);
7922
+ if (c) add(idx.colors, c.hex, ref(name, c.wrap));
7923
+ else if (/font|family|typeface/i.test(name) && !/^--(font-weight|text)-/.test(name)) {
7924
+ const fam = firstFamily(v);
7925
+ if (fam && !/^\d|^var\(/.test(fam)) add(idx.fonts, fam, ref(name));
7926
+ }
7927
+ }
7928
+ if (tailwind) idx.tailwind = tailwindTheme(theme, defaults, (name) => {
7929
+ const raw = vars.get(name);
7930
+ return raw === void 0 ? void 0 : resolve(raw).v;
7931
+ });
6257
7932
  const family = (v) => {
6258
7933
  let x = v?.trim();
6259
7934
  for (let hops = 0; x && hops < 5; hops++) {
@@ -6275,16 +7950,31 @@ async function scanProject(root, exclude = [], maxEntries = MAX_ENTRIES) {
6275
7950
  list.push({ file: shown(f), nums: s.nums });
6276
7951
  idx.icons.set(s.key, list);
6277
7952
  }
6278
- for (const f of comps) {
6279
- let stem = path3.basename(f).replace(/\.[^.]+$/, "");
6280
- if (/^index$/i.test(stem)) stem = path3.basename(path3.dirname(f));
6281
- if (NOT_COMPONENT.test(stem)) continue;
6282
- add(idx.components, slug2(stem), shown(f));
7953
+ const ownIcons = [];
7954
+ for (const [k, f] of comps.entries()) {
7955
+ let stem = path4.basename(f).replace(/\.[^.]+$/, "");
7956
+ if (/^index$/i.test(stem)) stem = path4.basename(path4.dirname(f));
7957
+ if (/\.(test|spec|stories|story)$/i.test(stem)) continue;
7958
+ const text2 = /\.(tsx|jsx)$/i.test(f) && k < MAX_CODE ? await readText(f, 2e5) : void 0;
7959
+ const found = text2 ? reactComponents(text2) : [];
7960
+ if (text2) ownIcons.push(...codeIcons(text2, shown(f)));
7961
+ for (const c of found) add(idx.components, slug2(c.name), `${c.api} (${shown(f)})`);
7962
+ if (!found.some((c) => slug2(c.name) === slug2(stem)) && !NOT_COMPONENT.test(stem)) add(idx.components, slug2(stem), shown(f));
7963
+ }
7964
+ for (const f of elixir.filter((f2) => !/(^|[/\\])test[/\\]/.test(path4.relative(root, f2))).slice(0, MAX_CODE)) {
7965
+ const text2 = await readText(f, 4e5);
7966
+ if (text2) ownIcons.push(...codeIcons(text2, shown(f), true));
7967
+ if (!text2 || !/^\s*(attr|slot)\s+:/m.test(text2)) continue;
7968
+ for (const c of phoenixComponents(text2)) add(idx.components, slug2(c.name), `${c.api} (${shown(f)})`);
6283
7969
  }
6284
7970
  for (const [c, f] of classes) add(idx.components, c.toLowerCase(), `.${c} (${f})`);
7971
+ const rank = (ref2) => /components?[/\\]ui[/\\]|core_components|_ui[/\\]|[/\\]components[/\\]/.test(ref2) ? 0 : /mail|email|stories|example/i.test(ref2) ? 2 : 1;
7972
+ for (const list of idx.components.values()) list.sort((a, b) => rank(a) - rank(b));
7973
+ const libs = await iconLibraries(root, manifests, ownIcons).catch(() => []);
7974
+ if (libs.length) idx.iconLibs = libs;
6285
7975
  if (svgs.length > MAX_SVGS) incomplete ??= `read only the first ${MAX_SVGS} of ${svgs.length} SVG files`;
6286
7976
  if (incomplete) idx.incomplete = `project scan of ${shown(root) || "."} ${incomplete}`;
6287
- const empty = !idx.colors.size && !idx.fonts.size && !idx.icons.size && !idx.components.size && !idx.textStyles.length;
7977
+ const empty = !idx.colors.size && !idx.fonts.size && !idx.icons.size && !idx.components.size && !idx.textStyles.length && !idx.tailwind?.text.length && !idx.iconLibs;
6288
7978
  return empty && !incomplete ? void 0 : idx;
6289
7979
  }
6290
7980
  async function gitFiles(root) {
@@ -6294,7 +7984,7 @@ async function gitFiles(root) {
6294
7984
  maxBuffer: 256 * 1024 * 1024,
6295
7985
  timeout: 1e4
6296
7986
  });
6297
- return stdout.split("\0").filter(Boolean).map((f) => path3.join(root, f));
7987
+ return stdout.split("\0").filter(Boolean).map((f) => path4.join(root, f));
6298
7988
  } catch {
6299
7989
  return void 0;
6300
7990
  }
@@ -6306,12 +7996,76 @@ function withScanNote(text2, idx) {
6306
7996
  ## project scan incomplete
6307
7997
  ${idx.incomplete}: a colour, font, icon or component without a project match may still exist, so search the code before adding a copy`;
6308
7998
  }
7999
+ function themeBlocks(css) {
8000
+ const out = [];
8001
+ for (const m of css.matchAll(/@(?:theme|plugin)\b[^{;]*\{/g)) {
8002
+ let depth = 1;
8003
+ let i = m.index + m[0].length;
8004
+ const start = i;
8005
+ for (; i < css.length && depth; i++) {
8006
+ if (css[i] === "{") depth++;
8007
+ else if (css[i] === "}") depth--;
8008
+ }
8009
+ out.push(css.slice(start, i - 1));
8010
+ }
8011
+ return out;
8012
+ }
8013
+ function lineHeightPx(v, size) {
8014
+ const c = /^calc\(\s*([\d.]+)\s*\/\s*([\d.]+)\s*\)$/.exec(v.trim());
8015
+ return c ? parseFloat(c[1]) / parseFloat(c[2]) * size : px(v, size);
8016
+ }
8017
+ function tailwindTheme(theme, defaults, value) {
8018
+ const out = { text: [], weights: /* @__PURE__ */ new Map(), tracking: /* @__PURE__ */ new Map() };
8019
+ for (const name of theme) {
8020
+ const v = value(name);
8021
+ if (v === void 0) continue;
8022
+ let m;
8023
+ if (m = /^--font-weight-([\w-]+)$/.exec(name)) {
8024
+ const w = parseInt(v, 10);
8025
+ if (w && !out.weights.has(w)) out.weights.set(w, m[1]);
8026
+ } else if (m = /^--tracking-([\w-]+)$/.exec(name)) {
8027
+ const em = /^(-?[\d.]+)em$/.exec(v.trim());
8028
+ if (em && !out.tracking.has(parseFloat(em[1]))) out.tracking.set(parseFloat(em[1]), m[1]);
8029
+ } else if ((m = /^--text-([\w-]+)$/.exec(name)) && !m[1].includes("--")) {
8030
+ const size = /[a-z%]$/i.test(v.trim()) ? px(v, 16) : void 0;
8031
+ if (!size) continue;
8032
+ const lh = value(`${name}--line-height`);
8033
+ const fw = value(`${name}--font-weight`);
8034
+ const ls = value(`${name}--letter-spacing`);
8035
+ out.text.push({
8036
+ cls: `text-${m[1]}`,
8037
+ size,
8038
+ lineHeight: lh === void 0 ? void 0 : lineHeightPx(lh, size),
8039
+ weight: fw === void 0 ? void 0 : parseInt(fw, 10) || void 0,
8040
+ letterSpacing: ls === void 0 ? void 0 : px(ls, size),
8041
+ own: !defaults.has(name)
8042
+ });
8043
+ }
8044
+ }
8045
+ return out;
8046
+ }
8047
+ function tailwindText(tw, t) {
8048
+ const sized = tw.text.filter((x) => Math.abs(x.size - t.size) <= 0.01);
8049
+ const own2 = sized.filter((x) => x.own);
8050
+ return (own2.length ? own2 : sized).map((x) => {
8051
+ const parts = [x.cls];
8052
+ if ((x.weight ?? 400) !== t.weight) parts.push(`font-${tw.weights.get(t.weight) ?? `[${t.weight}]`}`);
8053
+ if (t.italic) parts.push("italic");
8054
+ if (t.lh !== void 0 && (x.lineHeight === void 0 || Math.abs(x.lineHeight - t.lh) > 0.5)) parts.push(`leading-[${num(t.lh)}px]`);
8055
+ if (Math.abs((x.letterSpacing ?? 0) - t.ls) > 0.05) {
8056
+ const named = [...tw.tracking].find(([em]) => Math.abs(em * t.size - t.ls) <= 0.05);
8057
+ parts.push(named ? `tracking-${named[1]}` : `tracking-[${t.lsText ?? `${num(t.ls)}px`}]`);
8058
+ }
8059
+ if (t.transform !== "none") parts.push(t.transform);
8060
+ return parts.join(" ");
8061
+ });
8062
+ }
6309
8063
  function firstFamily(stack) {
6310
8064
  return stack.split(",")[0].trim().replace(/^["']|["']$/g, "").toLowerCase();
6311
8065
  }
6312
8066
  async function readText(file2, max) {
6313
8067
  try {
6314
- const buf = await readFile2(file2);
8068
+ const buf = await readFile3(file2);
6315
8069
  return buf.length > max ? void 0 : buf.toString("utf8");
6316
8070
  } catch {
6317
8071
  return void 0;
@@ -6412,7 +8166,8 @@ function textRefs(idx, spec) {
6412
8166
  const ls = lsm ? lsm[2] === "em" ? parseFloat(lsm[1]) * size : parseFloat(lsm[1]) : 0;
6413
8167
  const transform2 = /\b(uppercase|lowercase|capitalize)\b/.exec(g.rest)?.[1] ?? "none";
6414
8168
  const fam = g.family.toLowerCase();
6415
- return idx.textStyles.filter((t) => {
8169
+ const tw = idx.tailwind ? tailwindText(idx.tailwind, { size, weight: Number(g.weight), italic: !!g.italic, lh, ls, lsText: lsm ? `${lsm[1]}${lsm[2]}` : void 0, transform: transform2 }) : [];
8170
+ const classes = idx.textStyles.filter((t) => {
6416
8171
  if (t.size !== size && Math.abs(t.size - size) > 0.01) return false;
6417
8172
  if (t.weight !== Number(g.weight) || t.italic !== !!g.italic || t.transform !== transform2) return false;
6418
8173
  if (Math.abs(t.letterSpacing - ls) > 0.05) return false;
@@ -6420,7 +8175,8 @@ function textRefs(idx, spec) {
6420
8175
  if (t.lineHeight === "normal") return g.lh === "normal";
6421
8176
  if (lh === void 0) return true;
6422
8177
  return typeof t.lineHeight === "number" && Math.abs(t.lineHeight - lh) <= 0.5;
6423
- }).map((t) => t.ref).slice(0, 3);
8178
+ }).map((t) => t.ref);
8179
+ return [...classes, ...tw].slice(0, 3);
6424
8180
  }
6425
8181
  function normHex(h) {
6426
8182
  const m = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(h.trim());
@@ -6480,28 +8236,28 @@ function parseColor(value) {
6480
8236
  function shapeOf(svg) {
6481
8237
  const rootTag = /<svg\b[^>]*>/i.exec(svg)?.[0];
6482
8238
  if (!rootTag) return void 0;
6483
- const root = attrs(rootTag);
8239
+ const root = attrs2(rootTag);
6484
8240
  const vb = (root.viewBox ?? `0 0 ${parseFloat(root.width ?? "")} ${parseFloat(root.height ?? "")}`).split(/[\s,]+/).map(Number);
6485
8241
  const [vx, vy, vw, vh] = vb;
6486
8242
  if (vb.length !== 4 || !(vw > 0) || !(vh > 0)) return void 0;
6487
8243
  const body = svg.replace(/<(mask|clipPath|defs|title|desc)\b[\s\S]*?<\/\1>/gi, "");
6488
8244
  const scaled = { x: (v) => (v - vx) / vw, y: (v) => (v - vy) / vh, s: (v) => v / vw, r: (v) => v };
6489
- const keys = [];
8245
+ const keys2 = [];
6490
8246
  const nums = [];
6491
8247
  for (const m of body.matchAll(/<(path|rect|circle|ellipse|line|polyline|polygon)\b([^>]*)>/gi)) {
6492
- const a = attrs(m[2]);
8248
+ const a = attrs2(m[2]);
6493
8249
  const fill = a.fill ?? root.fill ?? "black";
6494
8250
  const stroke = a.stroke ?? root.stroke ?? "none";
6495
8251
  if ((fill === "none" || fill === "transparent") && (stroke === "none" || stroke === "transparent")) continue;
6496
8252
  if (a.opacity === "0" || a.visibility === "hidden" || a.display === "none") continue;
6497
8253
  const g = geometry(m[1].toLowerCase(), a);
6498
8254
  if (!g) return void 0;
6499
- keys.push(g.key);
8255
+ keys2.push(g.key);
6500
8256
  for (const [v, axis] of g.vals) nums.push(scaled[axis](v));
6501
8257
  }
6502
- return keys.length ? { key: keys.join("|"), nums } : void 0;
8258
+ return keys2.length ? { key: keys2.join("|"), nums } : void 0;
6503
8259
  }
6504
- function attrs(tag) {
8260
+ function attrs2(tag) {
6505
8261
  const out = {};
6506
8262
  for (const m of tag.matchAll(/([\w:-]+)\s*=\s*("([^"]*)"|'([^']*)')/g)) out[m[1]] = m[3] ?? m[4] ?? "";
6507
8263
  for (const d of (out.style ?? "").split(";")) {
@@ -6565,7 +8321,7 @@ function absolutePath(d) {
6565
8321
  continue;
6566
8322
  }
6567
8323
  const n2 = [];
6568
- for (let k = 0; k < ARGS[up]; k++) {
8324
+ for (let k = 0; k < ARGS2[up]; k++) {
6569
8325
  const s = up === "A" && (k === 3 || k === 4) ? read(FLAG) : read(NUM);
6570
8326
  if (s === void 0) return k === 0 && !c && atEnd() ? { key, vals } : void 0;
6571
8327
  n2.push(Number(s));
@@ -6598,10 +8354,14 @@ function absolutePath(d) {
6598
8354
  }
6599
8355
  return { key, vals };
6600
8356
  }
6601
- var TEXT_PROPS, SKIP_DIRS, STYLE, COMPONENT_FILE, NOT_COMPONENT, MAX_ENTRIES, MAX_MS, MAX_STYLES, MAX_SVGS, WEIGHTS, hex22, pct, ARGS;
8357
+ var TEXT_PROPS, SKIP_DIRS, STYLE, COMPONENT_FILE, NOT_COMPONENT, MAX_ENTRIES, MAX_MS, MAX_STYLES, MAX_SVGS, MAX_CODE, num, WEIGHTS, hex22, pct, ARGS2;
6602
8358
  var init_project = __esm({
6603
8359
  "src/tools/project.ts"() {
6604
8360
  "use strict";
8361
+ init_code_components();
8362
+ init_icons();
8363
+ init_tailwind_config();
8364
+ init_tailwind_theme();
6605
8365
  TEXT_PROPS = /^(font(-[\w-]+)?|line-height|letter-spacing|text-transform|text-decoration[\w-]*|color|-webkit-font-smoothing|-moz-osx-font-smoothing|text-rendering)$/;
6606
8366
  SKIP_DIRS = /* @__PURE__ */ new Set([
6607
8367
  "node_modules",
@@ -6629,10 +8389,12 @@ var init_project = __esm({
6629
8389
  MAX_MS = 2e3;
6630
8390
  MAX_STYLES = 600;
6631
8391
  MAX_SVGS = 3e3;
8392
+ MAX_CODE = 4e3;
8393
+ num = (x) => String(+x.toFixed(2));
6632
8394
  WEIGHTS = { normal: 400, bold: 700, lighter: 300, bolder: 700 };
6633
8395
  hex22 = (v) => Math.round(Math.max(0, Math.min(255, v))).toString(16).padStart(2, "0");
6634
8396
  pct = (s, full) => s.endsWith("%") ? parseFloat(s) / 100 * full : parseFloat(s);
6635
- ARGS = { M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0 };
8397
+ ARGS2 = { M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0 };
6636
8398
  }
6637
8399
  });
6638
8400
 
@@ -9067,8 +10829,8 @@ var init_png = __esm({
9067
10829
  });
9068
10830
 
9069
10831
  // src/tools/media.ts
9070
- import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
9071
- import path4 from "node:path";
10832
+ import { mkdir as mkdir2, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
10833
+ import path5 from "node:path";
9072
10834
  function rasterWaitMs(frozen) {
9073
10835
  return Number(process.env.LUPA_RASTER_WAIT_MS) || (frozen ? 2500 : 1e4);
9074
10836
  }
@@ -9113,9 +10875,9 @@ async function screenshot(bridge, ids, file2, opts) {
9113
10875
  const raster = decodePng(buf);
9114
10876
  if (opts.saveTo) {
9115
10877
  const target = ids.length > 1 || head.roots.length > 1 ? withSuffix(opts.saveTo, slug(root.name) || root.id) : opts.saveTo;
9116
- await mkdir2(path4.dirname(path4.resolve(target)), { recursive: true });
10878
+ await mkdir2(path5.dirname(path5.resolve(target)), { recursive: true });
9117
10879
  await writeFile2(target, buf);
9118
- lines.push(`saved ${path4.resolve(target)} (${raster.width}\xD7${raster.height}px)`);
10880
+ lines.push(`saved ${path5.resolve(target)} (${raster.width}\xD7${raster.height}px)`);
9119
10881
  }
9120
10882
  const parts = tiles(raster);
9121
10883
  const visionScale = scale * parts[0].scale;
@@ -9129,8 +10891,8 @@ async function screenshot(bridge, ids, file2, opts) {
9129
10891
  return { text: lines.join("\n"), images };
9130
10892
  }
9131
10893
  function withSuffix(file2, suffix) {
9132
- const ext = path4.extname(file2) || ".png";
9133
- return `${file2.slice(0, file2.length - path4.extname(file2).length)}-${suffix}${ext}`;
10894
+ const ext = path5.extname(file2) || ".png";
10895
+ return `${file2.slice(0, file2.length - path5.extname(file2).length)}-${suffix}${ext}`;
9134
10896
  }
9135
10897
  function collect(snap, defs = []) {
9136
10898
  const graphics = [];
@@ -9200,7 +10962,7 @@ function fileNamer() {
9200
10962
  }
9201
10963
  async function exportAssets(bridge, ids, file2, opts) {
9202
10964
  if (opts.as !== "auto") {
9203
- const dir = path4.resolve(opts.dir);
10965
+ const dir = path5.resolve(opts.dir);
9204
10966
  await mkdir2(dir, { recursive: true });
9205
10967
  const fileName = fileNamer();
9206
10968
  const lines = [];
@@ -9209,7 +10971,7 @@ async function exportAssets(bridge, ids, file2, opts) {
9209
10971
  for (const b of res2.blobs) {
9210
10972
  const name = fileName(b.name, opts.as);
9211
10973
  const data = b.encoding === "utf8" ? opts.currentColor ? toCurrentColor(b.data) : b.data : Buffer.from(b.data, "base64");
9212
- await writeFile2(path4.join(dir, name), data);
10974
+ await writeFile2(path5.join(dir, name), data);
9213
10975
  lines.push(`${name} \u2190 "${b.name}" #${b.id} ${n(b.w)}\xD7${n(b.h)}${opts.as === "png" ? ` @${opts.scale ?? 2}x` : ""}`);
9214
10976
  }
9215
10977
  for (const e of res2.errors) lines.push(`failed #${e.id}: ${e.error}`);
@@ -9223,10 +10985,10 @@ async function exportAssets(bridge, ids, file2, opts) {
9223
10985
  return res.report;
9224
10986
  }
9225
10987
  async function writeAssets(bridge, snap, file2, opts) {
9226
- const dir = path4.resolve(opts.dir);
10988
+ const dir = path5.resolve(opts.dir);
9227
10989
  await mkdir2(dir, { recursive: true });
9228
10990
  const fileName = fileNamer();
9229
- const rel = (name) => path4.join(opts.dir, name).split(path4.sep).join("/");
10991
+ const rel = (name) => path5.join(opts.dir, name).split(path5.sep).join("/");
9230
10992
  const lines = [];
9231
10993
  const failures = [];
9232
10994
  const fail2 = (line) => {
@@ -9262,13 +11024,14 @@ async function writeAssets(bridge, snap, file2, opts) {
9262
11024
  continue;
9263
11025
  }
9264
11026
  const own3 = opts.project && iconFile(opts.project, svg);
9265
- const name = own3 || fileName(g.base, "svg");
9266
- if (own3) reused.add(own3);
9267
- else await writeFile2(path4.join(dir, name), svg);
11027
+ const lib = !own3 && opts.project?.iconLibs ? (await matchLibraryIcon(opts.project.iconLibs, svg, g.name))?.usage : void 0;
11028
+ const name = own3 || lib || fileName(g.base, "svg");
11029
+ if (own3 || lib) reused.add(name);
11030
+ else await writeFile2(path5.join(dir, name), svg);
9268
11031
  written.set(key, { name, line: lines.length, uses: 1, component: g.component, also: [] });
9269
- byNode.set(g.nodeId, own3 || rel(name));
11032
+ byNode.set(g.nodeId, own3 || lib || rel(name));
9270
11033
  if (g.sig) bySig.set(g.sig, name);
9271
- lines.push(`${name} \u2190 svg "${g.name}" #${g.nodeId} ${n(b.w)}\xD7${n(b.h)}${own3 ? " (the project's own icon: not written)" : ""}`);
11034
+ lines.push(`${name} \u2190 svg "${g.name}" #${g.nodeId} ${n(b.w)}\xD7${n(b.h)}${own3 ? " (the project's own icon: not written)" : lib ? " (from the project's icon library: not written)" : ""}`);
9272
11035
  }
9273
11036
  }
9274
11037
  for (const { g, error: error62 } of failed) {
@@ -9299,7 +11062,7 @@ async function writeAssets(bridge, snap, file2, opts) {
9299
11062
  }
9300
11063
  const buf = Buffer.from(got.data, "base64");
9301
11064
  const name = fileName(img.base, imageExt(buf));
9302
- await writeFile2(path4.join(dir, name), buf);
11065
+ await writeFile2(path5.join(dir, name), buf);
9303
11066
  byImage.set(img.hash, rel(name));
9304
11067
  lines.push(`${name} \u2190 src:${img.hash.slice(0, 10)} "${img.name}" #${img.nodeId}${got.w ? ` ${got.w}\xD7${got.h}px original` : ""}${img.uses > 1 ? ` (used ${img.uses}\xD7)` : ""}`);
9305
11068
  }
@@ -9367,8 +11130,8 @@ function ignoreEdges(a, b, band) {
9367
11130
  }
9368
11131
  }
9369
11132
  }
9370
- async function compare(bridge, root, file2, opts) {
9371
- const actualBuf = typeof opts.image === "string" ? await readFile3(opts.image) : opts.image;
11133
+ async function compare2(bridge, root, file2, opts) {
11134
+ const actualBuf = typeof opts.image === "string" ? await readFile4(opts.image) : opts.image;
9372
11135
  const actual = flatten(decodePng(actualBuf));
9373
11136
  const scale = actual.width / root.w;
9374
11137
  const res = await renderNode(bridge, root, file2, { scale, width: actual.width }, {});
@@ -9410,9 +11173,9 @@ async function compare(bridge, root, file2, opts) {
9410
11173
  if (d.regions.length > 10) lines.push(` \u2026 +${d.regions.length - 10} smaller regions`);
9411
11174
  let strip = sideBySide([a, b, d.diff]);
9412
11175
  if (opts.saveDiff) {
9413
- await mkdir2(path4.dirname(path4.resolve(opts.saveDiff)), { recursive: true });
11176
+ await mkdir2(path5.dirname(path5.resolve(opts.saveDiff)), { recursive: true });
9414
11177
  await writeFile2(opts.saveDiff, encodePng(strip));
9415
- lines.push(`saved ${path4.resolve(opts.saveDiff)}`);
11178
+ lines.push(`saved ${path5.resolve(opts.saveDiff)}`);
9416
11179
  }
9417
11180
  if (strip.width > VISION_MAX_EDGE || strip.height > VISION_MAX_EDGE) {
9418
11181
  const s = Math.min(VISION_MAX_EDGE / strip.width, VISION_MAX_EDGE / strip.height);
@@ -9429,6 +11192,7 @@ var init_media = __esm({
9429
11192
  init_build();
9430
11193
  init_css();
9431
11194
  init_browser();
11195
+ init_icons();
9432
11196
  init_project();
9433
11197
  init_png();
9434
11198
  SVG_FALLBACK_NOTE = "Figma didn't render a PNG (its window is hidden or covered), so this image is Figma's SVG export rendered in Chromium. SVG export can leave out background blur, newer effects and occasionally a stroke: check a region against `lupa design` before changing it. Bring Figma to the front for an exact render.";
@@ -9601,7 +11365,7 @@ ${Object.entries(x.css).map(([k, v]) => `${k}: ${v};`).join("\n")}`).join("\n\n"
9601
11365
  note = `fonts not available to the page: ${page.missingFonts.map((f) => `"${f}"`).join(", ")}. The browser uses fallbacks, so text and the hug boxes around it differ in width. Load the fonts (@font-face or local install) for an exact comparison.`;
9602
11366
  }
9603
11367
  }
9604
- return compare(this.bridge, root, r.file, { image, threshold: o.threshold, saveDiff: o.saveDiff, note });
11368
+ return compare2(this.bridge, root, r.file, { image, threshold: o.threshold, saveDiff: o.saveDiff, note });
9605
11369
  }
9606
11370
  };
9607
11371
  }
@@ -9642,13 +11406,13 @@ var init_util = __esm({
9642
11406
  });
9643
11407
  };
9644
11408
  util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
9645
- const keys = [];
11409
+ const keys2 = [];
9646
11410
  for (const key in object3) {
9647
11411
  if (Object.prototype.hasOwnProperty.call(object3, key)) {
9648
- keys.push(key);
11412
+ keys2.push(key);
9649
11413
  }
9650
11414
  }
9651
- return keys;
11415
+ return keys2;
9652
11416
  };
9653
11417
  util2.find = (arr, checker) => {
9654
11418
  for (const item of arr) {
@@ -10027,8 +11791,8 @@ var init_parseUtil = __esm({
10027
11791
  init_errors();
10028
11792
  init_en();
10029
11793
  makeIssue = (params) => {
10030
- const { data, path: path6, errorMaps, issueData } = params;
10031
- const fullPath = [...path6, ...issueData.path || []];
11794
+ const { data, path: path7, errorMaps, issueData } = params;
11795
+ const fullPath = [...path7, ...issueData.path || []];
10032
11796
  const fullIssue = {
10033
11797
  ...issueData,
10034
11798
  path: fullPath
@@ -10296,9 +12060,9 @@ function mergeValues(a, b) {
10296
12060
  return { valid: false };
10297
12061
  }
10298
12062
  }
10299
- function createZodEnum(values, params) {
12063
+ function createZodEnum(values2, params) {
10300
12064
  return new ZodEnum({
10301
- values,
12065
+ values: values2,
10302
12066
  typeName: ZodFirstPartyTypeKind.ZodEnum,
10303
12067
  ...processCreateParams(params)
10304
12068
  });
@@ -10312,11 +12076,11 @@ var init_types = __esm({
10312
12076
  init_parseUtil();
10313
12077
  init_util();
10314
12078
  ParseInputLazyPath = class {
10315
- constructor(parent, value, path6, key) {
12079
+ constructor(parent, value, path7, key) {
10316
12080
  this._cachedPath = [];
10317
12081
  this.parent = parent;
10318
12082
  this.data = value;
10319
- this._path = path6;
12083
+ this._path = path7;
10320
12084
  this._key = key;
10321
12085
  }
10322
12086
  get path() {
@@ -11976,8 +13740,8 @@ var init_types = __esm({
11976
13740
  if (this._cached !== null)
11977
13741
  return this._cached;
11978
13742
  const shape = this._def.shape();
11979
- const keys = util.objectKeys(shape);
11980
- this._cached = { shape, keys };
13743
+ const keys2 = util.objectKeys(shape);
13744
+ this._cached = { shape, keys: keys2 };
11981
13745
  return this._cached;
11982
13746
  }
11983
13747
  _parse(input2) {
@@ -13022,14 +14786,14 @@ var init_types = __esm({
13022
14786
  }
13023
14787
  return enumValues;
13024
14788
  }
13025
- extract(values, newDef = this._def) {
13026
- return _ZodEnum.create(values, {
14789
+ extract(values2, newDef = this._def) {
14790
+ return _ZodEnum.create(values2, {
13027
14791
  ...this._def,
13028
14792
  ...newDef
13029
14793
  });
13030
14794
  }
13031
- exclude(values, newDef = this._def) {
13032
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
14795
+ exclude(values2, newDef = this._def) {
14796
+ return _ZodEnum.create(this.options.filter((opt) => !values2.includes(opt)), {
13033
14797
  ...this._def,
13034
14798
  ...newDef
13035
14799
  });
@@ -13067,9 +14831,9 @@ var init_types = __esm({
13067
14831
  return this._def.values;
13068
14832
  }
13069
14833
  };
13070
- ZodNativeEnum.create = (values, params) => {
14834
+ ZodNativeEnum.create = (values2, params) => {
13071
14835
  return new ZodNativeEnum({
13072
- values,
14836
+ values: values2,
13073
14837
  typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
13074
14838
  ...processCreateParams(params)
13075
14839
  });
@@ -13667,8 +15431,8 @@ function assert(_) {
13667
15431
  }
13668
15432
  function getEnumValues(entries) {
13669
15433
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
13670
- const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
13671
- return values;
15434
+ const values2 = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
15435
+ return values2;
13672
15436
  }
13673
15437
  function joinValues(array2, separator = "|") {
13674
15438
  return array2.map((val) => stringifyPrimitive(val)).join(separator);
@@ -13754,9 +15518,9 @@ function putProp(target, key, value) {
13754
15518
  else
13755
15519
  target[key] = value;
13756
15520
  }
13757
- function mirrorShape(target, source, keys, wrap) {
15521
+ function mirrorShape(target, source, keys2, wrap) {
13758
15522
  const raw = sourceShape(source);
13759
- for (const key of keys) {
15523
+ for (const key of keys2) {
13760
15524
  const desc = Object.getOwnPropertyDescriptor(raw, key);
13761
15525
  if (!desc.enumerable)
13762
15526
  continue;
@@ -13791,18 +15555,18 @@ function mergeDefs(...defs) {
13791
15555
  function cloneDef(schema) {
13792
15556
  return mergeDefs(schema._zod.def);
13793
15557
  }
13794
- function getElementAtPath(obj, path6) {
13795
- if (!path6)
15558
+ function getElementAtPath(obj, path7) {
15559
+ if (!path7)
13796
15560
  return obj;
13797
- return path6.reduce((acc, key) => acc?.[key], obj);
15561
+ return path7.reduce((acc, key) => acc?.[key], obj);
13798
15562
  }
13799
15563
  function promiseAllObject(promisesObj) {
13800
- const keys = Object.keys(promisesObj);
13801
- const promises = keys.map((key) => promisesObj[key]);
15564
+ const keys2 = Object.keys(promisesObj);
15565
+ const promises = keys2.map((key) => promisesObj[key]);
13802
15566
  return Promise.all(promises).then((results) => {
13803
15567
  const resolvedObj = {};
13804
- for (let i = 0; i < keys.length; i++) {
13805
- resolvedObj[keys[i]] = results[i];
15568
+ for (let i = 0; i < keys2.length; i++) {
15569
+ resolvedObj[keys2[i]] = results[i];
13806
15570
  }
13807
15571
  return resolvedObj;
13808
15572
  });
@@ -13943,15 +15707,15 @@ function pick(schema, mask) {
13943
15707
  }
13944
15708
  function maskedKeys(schema, mask) {
13945
15709
  const raw = sourceShape(schema);
13946
- const keys = [];
15710
+ const keys2 = [];
13947
15711
  for (const key of Reflect.ownKeys(mask)) {
13948
15712
  if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
13949
15713
  throw new Error(`Unrecognized key: "${String(key)}"`);
13950
15714
  }
13951
15715
  if (mask[key])
13952
- keys.push(key);
15716
+ keys2.push(key);
13953
15717
  }
13954
- return keys;
15718
+ return keys2;
13955
15719
  }
13956
15720
  function omit(schema, mask) {
13957
15721
  const currDef = schema._zod.def;
@@ -14053,11 +15817,11 @@ function explicitlyAborted(x, startIndex = 0) {
14053
15817
  }
14054
15818
  return false;
14055
15819
  }
14056
- function prefixIssues(path6, issues) {
15820
+ function prefixIssues(path7, issues) {
14057
15821
  return issues.map((iss) => {
14058
15822
  var _a3;
14059
15823
  (_a3 = iss).path ?? (_a3.path = []);
14060
- iss.path.unshift(path6);
15824
+ iss.path.unshift(path7);
14061
15825
  return iss;
14062
15826
  });
14063
15827
  }
@@ -14590,16 +16354,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
14590
16354
  }
14591
16355
  function formatError(error62, mapper = (issue2) => issue2.message) {
14592
16356
  const fieldErrors = { _errors: [] };
14593
- const processError = (error63, path6 = []) => {
16357
+ const processError = (error63, path7 = []) => {
14594
16358
  for (const issue2 of error63.issues) {
14595
16359
  if (issue2.code === "invalid_union" && issue2.errors.length) {
14596
- issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
16360
+ issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
14597
16361
  } else if (issue2.code === "invalid_key") {
14598
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
16362
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
14599
16363
  } else if (issue2.code === "invalid_element") {
14600
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
16364
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
14601
16365
  } else {
14602
- const fullpath = [...path6, ...issue2.path];
16366
+ const fullpath = [...path7, ...issue2.path];
14603
16367
  if (fullpath.length === 0) {
14604
16368
  fieldErrors._errors.push(mapper(issue2));
14605
16369
  } else {
@@ -14638,17 +16402,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
14638
16402
  }
14639
16403
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
14640
16404
  const result = { errors: [] };
14641
- const processError = (error63, path6 = []) => {
16405
+ const processError = (error63, path7 = []) => {
14642
16406
  var _a3;
14643
16407
  for (const issue2 of error63.issues) {
14644
16408
  if (issue2.code === "invalid_union" && issue2.errors.length) {
14645
- issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
16409
+ issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
14646
16410
  } else if (issue2.code === "invalid_key") {
14647
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
16411
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
14648
16412
  } else if (issue2.code === "invalid_element") {
14649
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
16413
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
14650
16414
  } else {
14651
- const fullpath = [...path6, ...issue2.path];
16415
+ const fullpath = [...path7, ...issue2.path];
14652
16416
  if (fullpath.length === 0) {
14653
16417
  result.errors.push(mapper(issue2));
14654
16418
  continue;
@@ -14687,8 +16451,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
14687
16451
  }
14688
16452
  function toDotPath(_path) {
14689
16453
  const segs = [];
14690
- const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14691
- for (const seg of path6) {
16454
+ const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
16455
+ for (const seg of path7) {
14692
16456
  if (typeof seg === "number")
14693
16457
  segs.push(`[${seg}]`);
14694
16458
  else if (typeof seg === "symbol")
@@ -15861,10 +17625,10 @@ function handlePropertyResult(result, final, key, input2, optin, optout) {
15861
17625
  }
15862
17626
  }
15863
17627
  function normalizeDef(def) {
15864
- const keys = Object.keys(def.shape);
17628
+ const keys2 = Object.keys(def.shape);
15865
17629
  const ownSymbols = Object.getOwnPropertySymbols(def.shape);
15866
17630
  const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
15867
- const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
17631
+ const allKeys = symbolKeys.length ? [...keys2, ...symbolKeys] : keys2;
15868
17632
  for (const k of allKeys) {
15869
17633
  if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
15870
17634
  throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
@@ -15876,8 +17640,8 @@ function normalizeDef(def) {
15876
17640
  allKeys,
15877
17641
  symbolKeys,
15878
17642
  // string-only: handleCatchall matches it against `for...in`, which never yields a symbol
15879
- keySet: new Set(keys),
15880
- numKeys: keys.length,
17643
+ keySet: new Set(keys2),
17644
+ numKeys: keys2.length,
15881
17645
  optionalKeys: new Set(okeys)
15882
17646
  };
15883
17647
  }
@@ -15993,10 +17757,10 @@ function getDiscriminatedOption(union2, value) {
15993
17757
  function discriminatorMap(def) {
15994
17758
  const map2 = /* @__PURE__ */ new Map();
15995
17759
  for (const option of def.options) {
15996
- const values = option._zod.propValues?.[def.discriminator];
15997
- if (!values || values.size === 0)
17760
+ const values2 = option._zod.propValues?.[def.discriminator];
17761
+ if (!values2 || values2.size === 0)
15998
17762
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
15999
- for (const value of values) {
17763
+ for (const value of values2) {
16000
17764
  if (map2.has(value)) {
16001
17765
  if (value !== void 0)
16002
17766
  throw new Error(`Duplicate discriminator value "${String(value)}"`);
@@ -16061,19 +17825,19 @@ function handleIntersectionResults(result, left, right) {
16061
17825
  let unrecIssue;
16062
17826
  const keyIssues = /* @__PURE__ */ new Map();
16063
17827
  const collect2 = (iss, side) => {
16064
- let keys;
17828
+ let keys2;
16065
17829
  if (iss.code === "unrecognized_keys" && !iss.path?.length) {
16066
17830
  unrecIssue ?? (unrecIssue = iss);
16067
- keys = iss.keys;
17831
+ keys2 = iss.keys;
16068
17832
  } else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
16069
17833
  const k = String(iss.path[0]);
16070
17834
  if (!keyIssues.has(k))
16071
17835
  keyIssues.set(k, iss);
16072
- keys = [k];
17836
+ keys2 = [k];
16073
17837
  } else {
16074
17838
  return false;
16075
17839
  }
16076
- for (const k of keys) {
17840
+ for (const k of keys2) {
16077
17841
  if (!unrecKeys.has(k))
16078
17842
  unrecKeys.set(k, {});
16079
17843
  unrecKeys.get(k)[side] = true;
@@ -16978,14 +18742,14 @@ var init_schemas = __esm({
16978
18742
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
16979
18743
  const sh = desc?.get ? desc.get.raw : def.shape ?? {};
16980
18744
  if (sh) {
16981
- const get = () => {
18745
+ const get2 = () => {
16982
18746
  const newSh = { ...sh };
16983
18747
  Object.defineProperty(def, "shape", { value: newSh });
16984
- get.raw = newSh;
18748
+ get2.raw = newSh;
16985
18749
  return newSh;
16986
18750
  };
16987
- get.raw = sh;
16988
- Object.defineProperty(def, "shape", { get });
18751
+ get2.raw = sh;
18752
+ Object.defineProperty(def, "shape", { get: get2 });
16989
18753
  }
16990
18754
  const _normalized = cached(() => normalizeDef(def));
16991
18755
  defineLazyInternal(inst, "propValues", (zod) => {
@@ -17431,11 +19195,11 @@ var init_schemas = __esm({
17431
19195
  return payload;
17432
19196
  }
17433
19197
  const proms = [];
17434
- const values = def.keyType._zod.values;
17435
- if (values && !def.partial) {
19198
+ const values2 = def.keyType._zod.values;
19199
+ if (values2 && !def.partial) {
17436
19200
  payload.value = memo2 ? memo2.alloc(inst, payload, {}, ctx) : {};
17437
19201
  const recordKeys = /* @__PURE__ */ new Set();
17438
- for (const key of values) {
19202
+ for (const key of values2) {
17439
19203
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
17440
19204
  recordKeys.add(typeof key === "number" ? key.toString() : key);
17441
19205
  if (key === "__proto__")
@@ -17521,7 +19285,7 @@ var init_schemas = __esm({
17521
19285
  if (keyResult.issues.length) {
17522
19286
  if (def.mode === "loose") {
17523
19287
  payload.value[key] = input2[key];
17524
- } else if (values) {
19288
+ } else if (values2) {
17525
19289
  unrecognized = unrecognized ?? [];
17526
19290
  unrecognized.push(key);
17527
19291
  } else {
@@ -17650,8 +19414,8 @@ var init_schemas = __esm({
17650
19414
  });
17651
19415
  $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
17652
19416
  $ZodType.init(inst, def);
17653
- const values = getEnumValues(def.entries);
17654
- const valuesSet = new Set(values);
19417
+ const values2 = getEnumValues(def.entries);
19418
+ const valuesSet = new Set(values2);
17655
19419
  inst._zod.values = valuesSet;
17656
19420
  defineLazyInternal(inst, "pattern", (zod) => {
17657
19421
  const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
@@ -17664,7 +19428,7 @@ var init_schemas = __esm({
17664
19428
  }
17665
19429
  payload.issues.push({
17666
19430
  code: "invalid_value",
17667
- values,
19431
+ values: values2,
17668
19432
  input: input2,
17669
19433
  inst
17670
19434
  });
@@ -17673,15 +19437,15 @@ var init_schemas = __esm({
17673
19437
  });
17674
19438
  $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
17675
19439
  $ZodType.init(inst, def);
17676
- const values = new Set(def.values);
17677
- inst._zod.values = values;
19440
+ const values2 = new Set(def.values);
19441
+ inst._zod.values = values2;
17678
19442
  defineLazyInternal(inst, "pattern", (zod) => {
17679
19443
  const vals = zod.def.values;
17680
19444
  return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
17681
19445
  });
17682
19446
  inst._zod.parse = (payload, _ctx) => {
17683
19447
  const input2 = payload.value;
17684
- if (values.has(input2)) {
19448
+ if (values2.has(input2)) {
17685
19449
  return payload;
17686
19450
  }
17687
19451
  payload.issues.push({
@@ -17736,8 +19500,8 @@ var init_schemas = __esm({
17736
19500
  defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
17737
19501
  inst._zod.optout = "optional";
17738
19502
  defineLazyInternal(inst, "values", (zod) => {
17739
- const values = zod.def.innerType._zod.values;
17740
- return values ? /* @__PURE__ */ new Set([...values, void 0]) : void 0;
19503
+ const values2 = zod.def.innerType._zod.values;
19504
+ return values2 ? /* @__PURE__ */ new Set([...values2, void 0]) : void 0;
17741
19505
  });
17742
19506
  defineLazyInternal(inst, "pattern", (zod) => {
17743
19507
  const pattern = zod.def.innerType._zod.pattern;
@@ -27156,13 +28920,13 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
27156
28920
  const def = schema._zod.def;
27157
28921
  doc.write(`if (typeof ${accessor} !== "object" || ${accessor} === null || Array.isArray(${accessor})) return INVALID;`);
27158
28922
  const shape = def.shape;
27159
- const keys = Object.keys(shape);
28923
+ const keys2 = Object.keys(shape);
27160
28924
  const symbolKeys = Object.getOwnPropertySymbols(shape);
27161
- const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
28925
+ const allKeys = symbolKeys.length ? [...keys2, ...symbolKeys] : keys2;
27162
28926
  const keyExpr = (k) => typeof k === "symbol" ? addConstant(ctx, k) : esc(k);
27163
28927
  const propKey = (k) => typeof k === "symbol" ? `[${keyExpr(k)}]` : esc(k);
27164
28928
  const propShape = shape;
27165
- if (keys.includes("__proto__")) {
28929
+ if (keys2.includes("__proto__")) {
27166
28930
  throw new ZodCompileUnsupportedError('object shape key "__proto__"');
27167
28931
  }
27168
28932
  const propOutputs = /* @__PURE__ */ new Map();
@@ -27204,7 +28968,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
27204
28968
  if (catchall) {
27205
28969
  const catchallType = catchall._zod.def.type;
27206
28970
  if (catchallType === "never") {
27207
- const condition = keys.map((k) => `k !== ${esc(k)}`).join(" && ") || "true";
28971
+ const condition = keys2.map((k) => `k !== ${esc(k)}`).join(" && ") || "true";
27208
28972
  doc.write(`for (const k in ${accessor}) {`);
27209
28973
  doc.indented((d) => {
27210
28974
  d.write(`if (${condition}) return INVALID;`);
@@ -27220,7 +28984,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
27220
28984
  const hasConditionalKeys = allKeys.some((k) => mayOmitUndefined(propShape[k]) || dropsWhenAbsent(propShape[k]));
27221
28985
  if (!buildsValue) {
27222
28986
  if (unknownKeysMode === "schema") {
27223
- const knownSet = keys.length > 0 ? addConstant(ctx, new Set(keys)) : null;
28987
+ const knownSet = keys2.length > 0 ? addConstant(ctx, new Set(keys2)) : null;
27224
28988
  doc.write(`for (const k in ${accessor}) {`);
27225
28989
  doc.indented((d) => {
27226
28990
  d.write(`if (k === "__proto__") continue;`);
@@ -27252,7 +29016,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
27252
29016
  }
27253
29017
  }
27254
29018
  if (unknownKeysMode !== "none") {
27255
- const knownSet = keys.length > 0 ? addConstant(ctx, new Set(keys)) : null;
29019
+ const knownSet = keys2.length > 0 ? addConstant(ctx, new Set(keys2)) : null;
27256
29020
  doc.write(`for (const k in ${accessor}) {`);
27257
29021
  doc.indented((d) => {
27258
29022
  d.write(`if (k === "__proto__") continue;`);
@@ -27462,15 +29226,15 @@ function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
27462
29226
  }
27463
29227
  function generateLiteralCheck(doc, ctx, schema, accessor) {
27464
29228
  const def = schema._zod.def;
27465
- const values = def.values;
27466
- if (values.length !== 1) {
27467
- const literalSet = addConstant(ctx, new Set(values));
29229
+ const values2 = def.values;
29230
+ if (values2.length !== 1) {
29231
+ const literalSet = addConstant(ctx, new Set(values2));
27468
29232
  doc.write(`if (!${literalSet}.has(${accessor})) return INVALID;`);
27469
29233
  return accessor;
27470
29234
  }
27471
- const value = values[0];
29235
+ const value = values2[0];
27472
29236
  if (typeof value === "number" && Number.isNaN(value)) {
27473
- const literalSet = addConstant(ctx, new Set(values));
29237
+ const literalSet = addConstant(ctx, new Set(values2));
27474
29238
  doc.write(`if (!${literalSet}.has(${accessor})) return INVALID;`);
27475
29239
  return accessor;
27476
29240
  }
@@ -27490,11 +29254,11 @@ function generateLiteralCheck(doc, ctx, schema, accessor) {
27490
29254
  return accessor;
27491
29255
  }
27492
29256
  function generateEnumCheck(doc, ctx, schema, accessor) {
27493
- const values = schema._zod.values;
27494
- if (!values) {
29257
+ const values2 = schema._zod.values;
29258
+ if (!values2) {
27495
29259
  throw new ZodCompileUnsupportedError("enum schema without enumerated values");
27496
29260
  }
27497
- const enumSet = addConstant(ctx, values);
29261
+ const enumSet = addConstant(ctx, values2);
27498
29262
  doc.write(`if (!${enumSet}.has(${accessor})) return INVALID;`);
27499
29263
  return accessor;
27500
29264
  }
@@ -27643,8 +29407,8 @@ function generateUnionCheck(doc, ctx, schema, accessor) {
27643
29407
  }
27644
29408
  const allLiterals = options.every((opt) => opt._zod.def.type === "literal" && !opt._zod.def.checks?.length);
27645
29409
  if (allLiterals) {
27646
- const values = new Set(options.flatMap((opt) => opt._zod.def.values));
27647
- const valuesConst = addConstant(ctx, values);
29410
+ const values2 = new Set(options.flatMap((opt) => opt._zod.def.values));
29411
+ const valuesConst = addConstant(ctx, values2);
27648
29412
  doc.write(`if (!${valuesConst}.has(${accessor})) return INVALID;`);
27649
29413
  return accessor;
27650
29414
  }
@@ -27681,17 +29445,17 @@ function generateDiscriminatedUnionCheck(doc, ctx, def, accessor) {
27681
29445
  let firstBranch = true;
27682
29446
  const claimed = /* @__PURE__ */ new Set();
27683
29447
  for (const option of def.options) {
27684
- const values = option._zod.propValues?.[def.discriminator];
27685
- if (!values || values.size === 0) {
29448
+ const values2 = option._zod.propValues?.[def.discriminator];
29449
+ if (!values2 || values2.size === 0) {
27686
29450
  throw new ZodCompileUnsupportedError("discriminated union option without static discriminator values");
27687
29451
  }
27688
- for (const value of values) {
29452
+ for (const value of values2) {
27689
29453
  if (claimed.has(value)) {
27690
29454
  throw new ZodCompileUnsupportedError(`duplicate discriminator value ${String(value)}`);
27691
29455
  }
27692
29456
  claimed.add(value);
27693
29457
  }
27694
- const conditions = Array.from(values, (value) => literalEquality(ctx, discVar, value));
29458
+ const conditions = Array.from(values2, (value) => literalEquality(ctx, discVar, value));
27695
29459
  const prefix = firstBranch ? "if" : "else if";
27696
29460
  doc.write(`${prefix} (${conditions.join(" || ")}) {`);
27697
29461
  doc.indented((d) => {
@@ -28846,8 +30610,8 @@ function _set(Class2, valueType, params) {
28846
30610
  });
28847
30611
  }
28848
30612
  // @__NO_SIDE_EFFECTS__
28849
- function _enum(Class2, values, params) {
28850
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
30613
+ function _enum(Class2, values2, params) {
30614
+ const entries = Array.isArray(values2) ? Object.fromEntries(values2.map((v) => [v, v])) : values2;
28851
30615
  return new Class2({
28852
30616
  type: "enum",
28853
30617
  entries,
@@ -29340,8 +31104,8 @@ function compactTypeUnion(schema) {
29340
31104
  if (!option || typeof option !== "object")
29341
31105
  return;
29342
31106
  compactTypeUnion(option);
29343
- const keys = Object.keys(option);
29344
- if (keys.length !== 1 || keys[0] !== "type")
31107
+ const keys2 = Object.keys(option);
31108
+ if (keys2.length !== 1 || keys2[0] !== "type")
29345
31109
  return;
29346
31110
  const type = option.type;
29347
31111
  for (const member of Array.isArray(type) ? type : [type]) {
@@ -29731,8 +31495,8 @@ function stringifyKeyNames(bySchema, json2, visited) {
29731
31495
  }
29732
31496
  const types = Array.isArray(json2.type) ? json2.type : [json2.type];
29733
31497
  const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
29734
- const values = json2.enum ?? (json2.const !== void 0 ? [json2.const] : void 0);
29735
- if (!numericType && !values?.some((v) => typeof v === "number"))
31498
+ const values2 = json2.enum ?? (json2.const !== void 0 ? [json2.const] : void 0);
31499
+ if (!numericType && !values2?.some((v) => typeof v === "number"))
29736
31500
  return json2;
29737
31501
  const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json2;
29738
31502
  if (rest.enum)
@@ -29742,7 +31506,7 @@ function stringifyKeyNames(bySchema, json2, visited) {
29742
31506
  if (!numericType)
29743
31507
  return rest;
29744
31508
  rest.type = "string";
29745
- if (!values)
31509
+ if (!values2)
29746
31510
  rest.pattern = (types.includes("number") ? number : integer).source;
29747
31511
  return rest;
29748
31512
  }
@@ -30009,16 +31773,16 @@ var init_json_schema_processors = __esm({
30009
31773
  };
30010
31774
  enumProcessor = (schema, _ctx, json2, _params) => {
30011
31775
  const def = schema._zod.def;
30012
- const values = getEnumValues(def.entries);
30013
- if (values.length === 0) {
31776
+ const values2 = getEnumValues(def.entries);
31777
+ if (values2.length === 0) {
30014
31778
  json2.not = {};
30015
31779
  return;
30016
31780
  }
30017
- if (values.every((v) => typeof v === "number"))
31781
+ if (values2.every((v) => typeof v === "number"))
30018
31782
  json2.type = "number";
30019
- if (values.every((v) => typeof v === "string"))
31783
+ if (values2.every((v) => typeof v === "string"))
30020
31784
  json2.type = "string";
30021
- json2.enum = values;
31785
+ json2.enum = values2;
30022
31786
  };
30023
31787
  literalProcessor = (schema, ctx, json2, params) => {
30024
31788
  const def = schema._zod.def;
@@ -30976,10 +32740,10 @@ function visit(schema, fnOrHandlers) {
30976
32740
  switch (kind) {
30977
32741
  case "object": {
30978
32742
  const oldShape = def.shape;
30979
- const keys = Object.keys(oldShape);
32743
+ const keys2 = Object.keys(oldShape);
30980
32744
  let changed = false;
30981
32745
  const newShape = {};
30982
- for (const k of keys) {
32746
+ for (const k of keys2) {
30983
32747
  const mapped = run2(oldShape[k]);
30984
32748
  if (mapped !== oldShape[k])
30985
32749
  changed = true;
@@ -31148,11 +32912,11 @@ function isZ4Schema(s) {
31148
32912
  return !!schema._zod;
31149
32913
  }
31150
32914
  function objectFromShape(shape) {
31151
- const values = Object.values(shape);
31152
- if (values.length === 0)
32915
+ const values2 = Object.values(shape);
32916
+ if (values2.length === 0)
31153
32917
  return object({});
31154
- const allV4 = values.every(isZ4Schema);
31155
- const allV3 = values.every((s) => !isZ4Schema(s));
32918
+ const allV4 = values2.every(isZ4Schema);
32919
+ const allV3 = values2.every((s) => !isZ4Schema(s));
31156
32920
  if (allV4)
31157
32921
  return object(shape);
31158
32922
  if (allV3)
@@ -31206,8 +32970,8 @@ function normalizeObjectSchema(schema) {
31206
32970
  const asV3 = schema;
31207
32971
  const asV4 = schema;
31208
32972
  if (!asV3._def && !asV4._zod) {
31209
- const values = Object.values(schema);
31210
- if (values.length > 0 && values.every((v) => typeof v === "object" && v !== null && (v._def !== void 0 || v._zod !== void 0 || typeof v.parse === "function"))) {
32973
+ const values2 = Object.values(schema);
32974
+ if (values2.length > 0 && values2.every((v) => typeof v === "object" && v !== null && (v._def !== void 0 || v._zod !== void 0 || typeof v.parse === "function"))) {
31211
32975
  return objectFromShape(schema);
31212
32976
  }
31213
32977
  }
@@ -31226,11 +32990,11 @@ function normalizeObjectSchema(schema) {
31226
32990
  }
31227
32991
  return void 0;
31228
32992
  }
31229
- function getDotPath(path6) {
31230
- if (path6.length === 0) {
32993
+ function getDotPath(path7) {
32994
+ if (path7.length === 0) {
31231
32995
  return "object root";
31232
32996
  }
31233
- return path6.reduce((acc, seg, index) => {
32997
+ return path7.reduce((acc, seg, index) => {
31234
32998
  if (index === 0) {
31235
32999
  return String(seg);
31236
33000
  }
@@ -31892,8 +33656,8 @@ function set(valueType, params) {
31892
33656
  ...util_exports.normalizeParams(params)
31893
33657
  });
31894
33658
  }
31895
- function _enum2(values, params) {
31896
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
33659
+ function _enum2(values2, params) {
33660
+ const entries = Array.isArray(values2) ? Object.fromEntries(values2.map((v) => [v, v])) : values2;
31897
33661
  return new ZodEnum2({
31898
33662
  type: "enum",
31899
33663
  entries,
@@ -32873,11 +34637,11 @@ var init_schemas3 = __esm({
32873
34637
  inst._zod.processJSONSchema = (ctx, json2, params) => enumProcessor(inst, ctx, json2, params);
32874
34638
  inst.enum = def.entries;
32875
34639
  inst.options = [...inst._zod.values];
32876
- const keys = new Set(Object.keys(def.entries));
32877
- inst.extract = (values, params) => {
34640
+ const keys2 = new Set(Object.keys(def.entries));
34641
+ inst.extract = (values2, params) => {
32878
34642
  const newEntries = {};
32879
- for (const value of values) {
32880
- if (keys.has(value)) {
34643
+ for (const value of values2) {
34644
+ if (keys2.has(value)) {
32881
34645
  newEntries[value] = def.entries[value];
32882
34646
  } else
32883
34647
  throw new Error(`Key ${value} not found in enum`);
@@ -32889,10 +34653,10 @@ var init_schemas3 = __esm({
32889
34653
  entries: newEntries
32890
34654
  });
32891
34655
  };
32892
- inst.exclude = (values, params) => {
34656
+ inst.exclude = (values2, params) => {
32893
34657
  const newEntries = { ...def.entries };
32894
- for (const value of values) {
32895
- if (keys.has(value)) {
34658
+ for (const value of values2) {
34659
+ if (keys2.has(value)) {
32896
34660
  delete newEntries[value];
32897
34661
  } else
32898
34662
  throw new Error(`Key ${value} not found in enum`);
@@ -33168,13 +34932,13 @@ function resolveRef(ref, ctx) {
33168
34932
  if (!ref.startsWith("#")) {
33169
34933
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
33170
34934
  }
33171
- const path6 = ref.slice(1).split("/").filter(Boolean);
33172
- if (path6.length === 0) {
34935
+ const path7 = ref.slice(1).split("/").filter(Boolean);
34936
+ if (path7.length === 0) {
33173
34937
  return ctx.rootSchema;
33174
34938
  }
33175
34939
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
33176
- if (path6[0] === defsKey) {
33177
- const key = path6[1] === void 0 ? void 0 : decodeJSONPointerSegment(path6[1]);
34940
+ if (path7[0] === defsKey) {
34941
+ const key = path7[1] === void 0 ? void 0 : decodeJSONPointerSegment(path7[1]);
33178
34942
  if (!key || !ctx.defs[key]) {
33179
34943
  throw new Error(`Reference not found: ${ref}`);
33180
34944
  }
@@ -33187,8 +34951,8 @@ function checkObjectGuards(objectSchema, guards) {
33187
34951
  const value = payload.value;
33188
34952
  if (typeof value !== "object" || value === null || Array.isArray(value))
33189
34953
  return;
33190
- const keys = Object.getOwnPropertyNames(value);
33191
- if (guards.minProperties !== void 0 && keys.length < guards.minProperties) {
34954
+ const keys2 = Object.getOwnPropertyNames(value);
34955
+ if (guards.minProperties !== void 0 && keys2.length < guards.minProperties) {
33192
34956
  payload.issues.push({
33193
34957
  origin: "object",
33194
34958
  code: "too_small",
@@ -33200,7 +34964,7 @@ function checkObjectGuards(objectSchema, guards) {
33200
34964
  continue: true
33201
34965
  });
33202
34966
  }
33203
- if (guards.maxProperties !== void 0 && keys.length > guards.maxProperties) {
34967
+ if (guards.maxProperties !== void 0 && keys2.length > guards.maxProperties) {
33204
34968
  payload.issues.push({
33205
34969
  origin: "object",
33206
34970
  code: "too_big",
@@ -33213,7 +34977,7 @@ function checkObjectGuards(objectSchema, guards) {
33213
34977
  });
33214
34978
  }
33215
34979
  if (guards.keySchema) {
33216
- for (const key of keys) {
34980
+ for (const key of keys2) {
33217
34981
  const result = guards.keySchema.safeParse(key);
33218
34982
  if (result.success)
33219
34983
  continue;
@@ -33254,9 +35018,9 @@ function canonicalKey(value, seen) {
33254
35018
  }
33255
35019
  return `a${parts2.length}:[${parts2.join(",")}]`;
33256
35020
  }
33257
- const keys = Object.keys(value).sort();
35021
+ const keys2 = Object.keys(value).sort();
33258
35022
  const parts = [];
33259
- for (const k of keys) {
35023
+ for (const k of keys2) {
33260
35024
  const key = canonicalKey(value[k], seen);
33261
35025
  if (key === null)
33262
35026
  return null;
@@ -36620,11 +38384,11 @@ function parseMapDef(def, refs) {
36620
38384
  if (refs.mapStrategy === "record") {
36621
38385
  return parseRecordDef(def, refs);
36622
38386
  }
36623
- const keys = parseDef(def.keyType._def, {
38387
+ const keys2 = parseDef(def.keyType._def, {
36624
38388
  ...refs,
36625
38389
  currentPath: [...refs.currentPath, "items", "items", "0"]
36626
38390
  }) || parseAnyDef(refs);
36627
- const values = parseDef(def.valueType._def, {
38391
+ const values2 = parseDef(def.valueType._def, {
36628
38392
  ...refs,
36629
38393
  currentPath: [...refs.currentPath, "items", "items", "1"]
36630
38394
  }) || parseAnyDef(refs);
@@ -36633,7 +38397,7 @@ function parseMapDef(def, refs) {
36633
38397
  maxItems: 125,
36634
38398
  items: {
36635
38399
  type: "array",
36636
- items: [keys, values],
38400
+ items: [keys2, values2],
36637
38401
  minItems: 2,
36638
38402
  maxItems: 2
36639
38403
  }
@@ -36654,7 +38418,7 @@ function parseNativeEnumDef(def) {
36654
38418
  return typeof object3[object3[key]] !== "number";
36655
38419
  });
36656
38420
  const actualValues = actualKeys.map((key) => object3[key]);
36657
- const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
38421
+ const parsedTypes = Array.from(new Set(actualValues.map((values2) => typeof values2)));
36658
38422
  return {
36659
38423
  type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
36660
38424
  enum: actualValues
@@ -38677,24 +40441,24 @@ var require_scope = __commonJS({
38677
40441
  return;
38678
40442
  return vs.get(keyOrRef);
38679
40443
  }
38680
- scopeRefs(scopeName, values = this._values) {
38681
- return this._reduceValues(values, (name) => {
40444
+ scopeRefs(scopeName, values2 = this._values) {
40445
+ return this._reduceValues(values2, (name) => {
38682
40446
  if (name.scopePath === void 0)
38683
40447
  throw new Error(`CodeGen: name "${name}" has no value`);
38684
40448
  return (0, code_1._)`${scopeName}${name.scopePath}`;
38685
40449
  });
38686
40450
  }
38687
- scopeCode(values = this._values, usedValues, getCode) {
38688
- return this._reduceValues(values, (name) => {
40451
+ scopeCode(values2 = this._values, usedValues, getCode) {
40452
+ return this._reduceValues(values2, (name) => {
38689
40453
  if (name.value === void 0)
38690
40454
  throw new Error(`CodeGen: name "${name}" has no value`);
38691
40455
  return name.value.code;
38692
40456
  }, usedValues, getCode);
38693
40457
  }
38694
- _reduceValues(values, valueCode, usedValues = {}, getCode) {
40458
+ _reduceValues(values2, valueCode, usedValues = {}, getCode) {
38695
40459
  let code = code_1.nil;
38696
- for (const prefix in values) {
38697
- const vs = values[prefix];
40460
+ for (const prefix in values2) {
40461
+ const vs = values2[prefix];
38698
40462
  if (!vs)
38699
40463
  continue;
38700
40464
  const nameSet = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map();
@@ -40437,7 +42201,7 @@ var require_fast_deep_equal = __commonJS({
40437
42201
  if (a === b) return true;
40438
42202
  if (a && b && typeof a == "object" && typeof b == "object") {
40439
42203
  if (a.constructor !== b.constructor) return false;
40440
- var length, i, keys;
42204
+ var length, i, keys2;
40441
42205
  if (Array.isArray(a)) {
40442
42206
  length = a.length;
40443
42207
  if (length != b.length) return false;
@@ -40448,13 +42212,13 @@ var require_fast_deep_equal = __commonJS({
40448
42212
  if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
40449
42213
  if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
40450
42214
  if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
40451
- keys = Object.keys(a);
40452
- length = keys.length;
42215
+ keys2 = Object.keys(a);
42216
+ length = keys2.length;
40453
42217
  if (length !== Object.keys(b).length) return false;
40454
42218
  for (i = length; i-- !== 0; )
40455
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
42219
+ if (!Object.prototype.hasOwnProperty.call(b, keys2[i])) return false;
40456
42220
  for (i = length; i-- !== 0; ) {
40457
- var key = keys[i];
42221
+ var key = keys2[i];
40458
42222
  if (!equal(a[key], b[key])) return false;
40459
42223
  }
40460
42224
  return true;
@@ -41617,16 +43381,16 @@ var require_utils = __commonJS({
41617
43381
  return compressIPv6ZeroRun(expanded);
41618
43382
  }
41619
43383
  function normalizeIPv6(host) {
41620
- const bracketed = host[0] === "[" && host[host.length - 1] === "]";
43384
+ const bracketed2 = host[0] === "[" && host[host.length - 1] === "]";
41621
43385
  const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
41622
- if (hasBracket && !bracketed) return { host, isIPV6: false, error: true };
41623
- let input2 = bracketed ? host.slice(1, -1) : host;
41624
- if (bracketed && isIPvFuture(input2)) {
43386
+ if (hasBracket && !bracketed2) return { host, isIPV6: false, error: true };
43387
+ let input2 = bracketed2 ? host.slice(1, -1) : host;
43388
+ if (bracketed2 && isIPvFuture(input2)) {
41625
43389
  input2 = input2.toLowerCase();
41626
43390
  return { host: `[${input2}]`, escapedHost: input2, isIPV6: false, isIPVFuture: true };
41627
43391
  }
41628
43392
  if (findToken(input2, ":") < 2) {
41629
- return { host, isIPV6: false, error: bracketed };
43393
+ return { host, isIPV6: false, error: bracketed2 };
41630
43394
  }
41631
43395
  let zoneIdentifier = "";
41632
43396
  const zoneSeparator = input2.indexOf("%");
@@ -41651,8 +43415,8 @@ var require_utils = __commonJS({
41651
43415
  }
41652
43416
  return ind;
41653
43417
  }
41654
- function removeDotSegments(path6) {
41655
- let input2 = path6;
43418
+ function removeDotSegments(path7) {
43419
+ let input2 = path7;
41656
43420
  const output2 = [];
41657
43421
  let nextSlash = -1;
41658
43422
  let len = 0;
@@ -41726,11 +43490,11 @@ var require_utils = __commonJS({
41726
43490
  }
41727
43491
  return output2.join("");
41728
43492
  }
41729
- function removeDotSegmentsRelative(path6) {
41730
- if (path6 === "" || path6[0] === "/") {
41731
- return removeDotSegments(path6);
43493
+ function removeDotSegmentsRelative(path7) {
43494
+ if (path7 === "" || path7[0] === "/") {
43495
+ return removeDotSegments(path7);
41732
43496
  }
41733
- const segments = path6.split("/");
43497
+ const segments = path7.split("/");
41734
43498
  const last = segments.length - 1;
41735
43499
  const output2 = [];
41736
43500
  let trailingDirectory = false;
@@ -42093,8 +43857,8 @@ var require_schemes = __commonJS({
42093
43857
  }
42094
43858
  if (wsComponent.resourceName) {
42095
43859
  const queryIndex = wsComponent.resourceName.indexOf("?");
42096
- const path6 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
42097
- wsComponent.path = path6 && path6 !== "/" ? path6 : void 0;
43860
+ const path7 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
43861
+ wsComponent.path = path7 && path7 !== "/" ? path7 : void 0;
42098
43862
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
42099
43863
  wsComponent.resourceName = void 0;
42100
43864
  }
@@ -45333,8 +47097,8 @@ var require_formats = __commonJS({
45333
47097
  "use strict";
45334
47098
  Object.defineProperty(exports, "__esModule", { value: true });
45335
47099
  exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
45336
- function fmtDef(validate2, compare2) {
45337
- return { validate: validate2, compare: compare2 };
47100
+ function fmtDef(validate2, compare3) {
47101
+ return { validate: validate2, compare: compare3 };
45338
47102
  }
45339
47103
  exports.fullFormats = {
45340
47104
  // date: http://tools.ietf.org/html/rfc3339#section-5.6
@@ -47711,7 +49475,7 @@ import { spawn } from "node:child_process";
47711
49475
  import { mkdirSync as mkdirSync2, openSync, writeFileSync as writeFileSync2 } from "node:fs";
47712
49476
  import net from "node:net";
47713
49477
  import os4 from "node:os";
47714
- import path5 from "node:path";
49478
+ import path6 from "node:path";
47715
49479
  import { fileURLToPath as fileURLToPath3 } from "node:url";
47716
49480
  import { parseArgs } from "node:util";
47717
49481
 
@@ -47798,18 +49562,18 @@ function skillsDirs() {
47798
49562
  }
47799
49563
  function linkSkill(skillsDir, source = path.join(packageRoot(), "skills", SKILL)) {
47800
49564
  const link = path.join(skillsDir, SKILL);
47801
- let stat2;
49565
+ let stat3;
47802
49566
  try {
47803
- stat2 = lstatSync(link);
49567
+ stat3 = lstatSync(link);
47804
49568
  } catch {
47805
49569
  }
47806
49570
  let note = "";
47807
- if (stat2?.isSymbolicLink()) {
49571
+ if (stat3?.isSymbolicLink()) {
47808
49572
  const target = path.resolve(skillsDir, readlinkSync(link));
47809
49573
  if (target === source) return `\u2713 Claude skill: ${link} \u2192 ${source}`;
47810
49574
  rmSync(link);
47811
49575
  note = ` (it pointed at ${target})`;
47812
- } else if (stat2) {
49576
+ } else if (stat3) {
47813
49577
  const backup = `${link}.old-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`;
47814
49578
  rmSync(backup, { recursive: true, force: true });
47815
49579
  renameSync(link, backup);
@@ -47973,7 +49737,7 @@ var SPECS = {
47973
49737
  };
47974
49738
  var UsageError = class extends Error {
47975
49739
  };
47976
- function num(v, key, min, max) {
49740
+ function num2(v, key, min, max) {
47977
49741
  const raw = v[key];
47978
49742
  if (raw === void 0) return void 0;
47979
49743
  const x = Number(raw);
@@ -47988,20 +49752,20 @@ function oneOf(v, key, allowed) {
47988
49752
  }
47989
49753
  var str = (v, key) => v[key];
47990
49754
  function imageDir() {
47991
- return path5.join(os4.tmpdir(), "lupa");
49755
+ return path6.join(os4.tmpdir(), "lupa");
47992
49756
  }
47993
49757
  function deliver(v, out, kind) {
47994
49758
  if (!v.images.length) return v.text;
47995
- const base = out ?? path5.join(imageDir(), `${kind}-${Date.now().toString(36)}.png`);
47996
- mkdirSync2(path5.dirname(path5.resolve(base)), { recursive: true });
47997
- const ext = path5.extname(base) || ".png";
47998
- const stem = base.slice(0, base.length - path5.extname(base).length);
47999
- const files = v.images.map((png, i) => {
48000
- const f = path5.resolve(i === 0 ? `${stem}${ext}` : `${stem}-${i + 1}${ext}`);
49759
+ const base = out ?? path6.join(imageDir(), `${kind}-${Date.now().toString(36)}.png`);
49760
+ mkdirSync2(path6.dirname(path6.resolve(base)), { recursive: true });
49761
+ const ext = path6.extname(base) || ".png";
49762
+ const stem = base.slice(0, base.length - path6.extname(base).length);
49763
+ const files2 = v.images.map((png, i) => {
49764
+ const f = path6.resolve(i === 0 ? `${stem}${ext}` : `${stem}-${i + 1}${ext}`);
48001
49765
  writeFileSync2(f, png);
48002
49766
  return f;
48003
49767
  });
48004
- return [v.text, ...files.map((f) => `image: ${f}`)].join("\n");
49768
+ return [v.text, ...files2.map((f) => `image: ${f}`)].join("\n");
48005
49769
  }
48006
49770
  async function run(cmd, v, pos, lupa) {
48007
49771
  const target = pos.length ? pos.join(" ") : void 0;
@@ -48013,9 +49777,9 @@ async function run(cmd, v, pos, lupa) {
48013
49777
  const text2 = await lupa.design({
48014
49778
  target,
48015
49779
  file: file2,
48016
- budget: num(v, "budget", 500, 1e5),
49780
+ budget: num2(v, "budget", 500, 1e5),
48017
49781
  components: oneOf(v, "components", ["auto", "inline", "names"]),
48018
- depth: num(v, "depth", 0, 1e3),
49782
+ depth: num2(v, "depth", 0, 1e3),
48019
49783
  includeHidden: v.hidden === true,
48020
49784
  expandVectors: v.vectors === true,
48021
49785
  assetsDir: str(v, "dir"),
@@ -48029,14 +49793,14 @@ async function run(cmd, v, pos, lupa) {
48029
49793
  ${deliver(await lupa.screenshot({ target, file: file2 }), void 0, "screenshot")}`;
48030
49794
  }
48031
49795
  case "screenshot":
48032
- return deliver(await lupa.screenshot({ target, file: file2, scale: num(v, "scale", 0.1, 4), saveTo: str(v, "full") }), str(v, "out"), "screenshot");
49796
+ return deliver(await lupa.screenshot({ target, file: file2, scale: num2(v, "scale", 0.1, 4), saveTo: str(v, "full") }), str(v, "out"), "screenshot");
48033
49797
  case "assets":
48034
49798
  return lupa.assets({
48035
49799
  target,
48036
49800
  file: file2,
48037
49801
  dir: str(v, "dir"),
48038
49802
  as: oneOf(v, "as", ["auto", "svg", "png"]),
48039
- scale: num(v, "scale", 0.5, 4),
49803
+ scale: num2(v, "scale", 0.5, 4),
48040
49804
  currentColor: v["current-color"] === true
48041
49805
  });
48042
49806
  case "tokens":
@@ -48045,7 +49809,7 @@ ${deliver(await lupa.screenshot({ target, file: file2 }), void 0, "screenshot")}
48045
49809
  if (!target) throw new UsageError("css needs a target (node id or URL)");
48046
49810
  return lupa.css({ target, file: file2 });
48047
49811
  case "outline":
48048
- return lupa.outline({ file: file2, page: str(v, "page"), depth: num(v, "depth", 1, 4) });
49812
+ return lupa.outline({ file: file2, page: str(v, "page"), depth: num2(v, "depth", 1, 4) });
48049
49813
  case "find":
48050
49814
  if (!target) throw new UsageError("find needs a query");
48051
49815
  return lupa.find({
@@ -48055,7 +49819,7 @@ ${deliver(await lupa.screenshot({ target, file: file2 }), void 0, "screenshot")}
48055
49819
  types: v.type?.map((t) => t.toUpperCase()),
48056
49820
  page: str(v, "page"),
48057
49821
  within: str(v, "within"),
48058
- limit: num(v, "limit", 1, 200)
49822
+ limit: num2(v, "limit", 1, 200)
48059
49823
  });
48060
49824
  case "compare": {
48061
49825
  if (!v.url === !v.image) throw new UsageError("compare needs --url (your running page) or --image (a PNG screenshot)");
@@ -48066,7 +49830,7 @@ ${deliver(await lupa.screenshot({ target, file: file2 }), void 0, "screenshot")}
48066
49830
  selector: str(v, "selector"),
48067
49831
  waitFor: str(v, "wait-for"),
48068
49832
  image: str(v, "image"),
48069
- threshold: num(v, "threshold", 0, 1)
49833
+ threshold: num2(v, "threshold", 0, 1)
48070
49834
  });
48071
49835
  return deliver(res, str(v, "out"), "compare");
48072
49836
  }
@@ -48078,7 +49842,7 @@ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
48078
49842
  function spawnHub(port) {
48079
49843
  const dir = imageDir();
48080
49844
  mkdirSync2(dir, { recursive: true });
48081
- const logFile = path5.join(dir, "hub.log");
49845
+ const logFile = path6.join(dir, "hub.log");
48082
49846
  const log = openSync(logFile, "a");
48083
49847
  const entry = fileURLToPath3(import.meta.url);
48084
49848
  spawn(process.execPath, [...process.execArgv, entry, "serve", "--port", String(port)], {
@@ -48179,16 +49943,16 @@ async function runCli(argv, io = { out: (t) => process.stdout.write(`${t}
48179
49943
  ${USAGE}`);
48180
49944
  return 2;
48181
49945
  }
48182
- let values;
49946
+ let values2;
48183
49947
  let positionals;
48184
49948
  try {
48185
- ({ values, positionals } = parseArgs({ args: rest, options: { ...GLOBAL, ...spec }, allowPositionals: true, strict: true }));
49949
+ ({ values: values2, positionals } = parseArgs({ args: rest, options: { ...GLOBAL, ...spec }, allowPositionals: true, strict: true }));
48186
49950
  } catch (e) {
48187
49951
  io.err(`${e.message}
48188
49952
  Run lupa help.`);
48189
49953
  return 2;
48190
49954
  }
48191
- if (values.help) {
49955
+ if (values2.help) {
48192
49956
  io.out(USAGE);
48193
49957
  return 0;
48194
49958
  }
@@ -48197,7 +49961,7 @@ Run lupa help.`);
48197
49961
  return 0;
48198
49962
  }
48199
49963
  if (cmd === "setup") {
48200
- io.out(await setup({ skillsDir: str(values, "skills-dir"), checkBrowser }));
49964
+ io.out(await setup({ skillsDir: str(values2, "skills-dir"), checkBrowser }));
48201
49965
  return 0;
48202
49966
  }
48203
49967
  if (cmd === "update") {
@@ -48209,8 +49973,8 @@ Run lupa help.`);
48209
49973
  let port;
48210
49974
  let idle;
48211
49975
  try {
48212
- port = num(values, "port", 1, 65535) ?? Number(process.env.LUPA_PORT ?? DEFAULT_PORT);
48213
- idle = num(values, "idle", 0, 7 * 24 * 60) ?? 60;
49976
+ port = num2(values2, "port", 1, 65535) ?? Number(process.env.LUPA_PORT ?? DEFAULT_PORT);
49977
+ idle = num2(values2, "idle", 0, 7 * 24 * 60) ?? 60;
48214
49978
  } catch (e) {
48215
49979
  io.err(e.message);
48216
49980
  return 2;
@@ -48232,7 +49996,7 @@ Run lupa help.`);
48232
49996
  if (!bridge) ({ bridge, fresh } = await joinHub(port, (m) => debug && io.err(`[lupa] ${m}`)));
48233
49997
  const lupa = new Lupa(bridge);
48234
49998
  if (fresh) lupa.pluginWaitMs = 8e3;
48235
- io.out(await run(cmd, values, positionals, lupa));
49999
+ io.out(await run(cmd, values2, positionals, lupa));
48236
50000
  for (const line of [...pluginWarnings(bridge.list()), updateNotice()]) if (line) io.err(`lupa: ${line}`);
48237
50001
  return 0;
48238
50002
  } catch (e) {