@iksnerd/blazon 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +375 -0
  2. package/dist/chunks/{site-builder-BOQjoDbM.js → site-builder-C8g2sfUv.js} +3519 -3712
  3. package/dist/cli/commands/approvals.d.ts +1 -1
  4. package/dist/cli/commands/approvals.d.ts.map +1 -1
  5. package/dist/cli/commands/mcp-check.d.ts +7 -4
  6. package/dist/cli/commands/mcp-check.d.ts.map +1 -1
  7. package/dist/cli/errors.d.ts +3 -1
  8. package/dist/cli/errors.d.ts.map +1 -1
  9. package/dist/cli/folder-first.d.ts +7 -0
  10. package/dist/cli/folder-first.d.ts.map +1 -0
  11. package/dist/cli/index.js +1098 -965
  12. package/dist/cli/operations.d.ts.map +1 -1
  13. package/dist/cli/where.d.ts +2 -0
  14. package/dist/cli/where.d.ts.map +1 -1
  15. package/dist/core/assets/representations.d.ts +44 -0
  16. package/dist/core/assets/representations.d.ts.map +1 -0
  17. package/dist/core/assets/scanner.d.ts.map +1 -1
  18. package/dist/core/assets/sidecar.d.ts.map +1 -1
  19. package/dist/core/brand/export.d.ts +13 -5
  20. package/dist/core/brand/export.d.ts.map +1 -1
  21. package/dist/core/brand/schema.d.ts +68 -0
  22. package/dist/core/brand/schema.d.ts.map +1 -1
  23. package/dist/core/checker/approvals.d.ts +5 -0
  24. package/dist/core/checker/approvals.d.ts.map +1 -1
  25. package/dist/core/checker/catalogue.d.ts +31 -7
  26. package/dist/core/checker/catalogue.d.ts.map +1 -1
  27. package/dist/core/checker/font-meta.d.ts.map +1 -1
  28. package/dist/core/checker/review.d.ts +19 -1
  29. package/dist/core/checker/review.d.ts.map +1 -1
  30. package/dist/core/docs/directives.d.ts +10 -0
  31. package/dist/core/docs/directives.d.ts.map +1 -1
  32. package/dist/core/docs/parser.d.ts.map +1 -1
  33. package/dist/core/font-roles.d.ts +11 -0
  34. package/dist/core/font-roles.d.ts.map +1 -0
  35. package/dist/core/index.d.ts.map +1 -1
  36. package/dist/core/init/from-site/fonts.d.ts.map +1 -1
  37. package/dist/core/logo/colorways.d.ts +29 -0
  38. package/dist/core/logo/colorways.d.ts.map +1 -0
  39. package/dist/core/logo/misuse.d.ts +18 -0
  40. package/dist/core/logo/misuse.d.ts.map +1 -0
  41. package/dist/core/mcp-config.d.ts +7 -0
  42. package/dist/core/mcp-config.d.ts.map +1 -1
  43. package/dist/core/read/can.d.ts +2 -1
  44. package/dist/core/read/can.d.ts.map +1 -1
  45. package/dist/core/read/fonts.d.ts +2 -6
  46. package/dist/core/read/fonts.d.ts.map +1 -1
  47. package/dist/core/read/logo.d.ts +3 -3
  48. package/dist/core/read/logo.d.ts.map +1 -1
  49. package/dist/core/read/lookup.d.ts +2 -2
  50. package/dist/core/read/lookup.d.ts.map +1 -1
  51. package/dist/core/read/theme.d.ts +1 -1
  52. package/dist/core/read/theme.d.ts.map +1 -1
  53. package/dist/core/tokens/alias.d.ts +5 -3
  54. package/dist/core/tokens/alias.d.ts.map +1 -1
  55. package/dist/core/tokens/contexts.d.ts +11 -3
  56. package/dist/core/tokens/contexts.d.ts.map +1 -1
  57. package/dist/core/tokens/formatters/json.d.ts +4 -1
  58. package/dist/core/tokens/formatters/json.d.ts.map +1 -1
  59. package/dist/core/tokens/key-lines.d.ts.map +1 -1
  60. package/dist/core/tokens/merge.d.ts.map +1 -1
  61. package/dist/core/tokens/resolver/compile.d.ts.map +1 -1
  62. package/dist/core/tokens/resolver/parse.d.ts.map +1 -1
  63. package/dist/core/tokens/resolver/sources.d.ts.map +1 -1
  64. package/dist/core/tokens/walk.d.ts.map +1 -1
  65. package/dist/index.js +34 -34
  66. package/dist/plugins/host/call.d.ts.map +1 -1
  67. package/dist/plugins/roles/roles.d.ts.map +1 -1
  68. package/dist/server/plugin.d.ts.map +1 -1
  69. package/dist/types/assets.d.ts +19 -1
  70. package/dist/types/assets.d.ts.map +1 -1
  71. package/dist/types/parsed.d.ts +8 -0
  72. package/dist/types/parsed.d.ts.map +1 -1
  73. package/dist/types/tokens.d.ts +12 -0
  74. package/dist/types/tokens.d.ts.map +1 -1
  75. package/dist/ui/assets/index-b4HhGGrn.js +82 -0
  76. package/dist/ui/assets/index-pE1ku5gt.css +2 -0
  77. package/dist/ui/index.html +2 -2
  78. package/mcp/dist/index.js +4 -4
  79. package/package.json +3 -2
  80. package/plugins/blazon.brand-deck/README.md +1 -1
  81. package/plugins/blazon.brand-deck/bin/blazon-blazon.brand-deck./360/237/224/214 +106 -13
  82. package/plugins/blazon.favicons/bin/blazon-blazon.favicons./360/237/224/214 +120 -12
  83. package/plugins/blazon.logo-geometry/bin/blazon-blazon.logo-geometry./360/237/224/214 +45 -1
  84. package/plugins/blazon.logo-kit/bin/blazon-blazon.logo-kit./360/237/224/214 +45 -1
  85. package/plugins/blazon.office-template/bin/blazon-blazon.office-template./360/237/224/214 +66 -3
  86. package/plugins/blazon.platform-tokens/README.md +1 -1
  87. package/plugins/blazon.press-kit/README.md +17 -9
  88. package/plugins/blazon.press-kit/bin/blazon-blazon.press-kit./360/237/224/214 +621 -101
  89. package/plugins/blazon.social-cards/bin/blazon-blazon.social-cards./360/237/224/214 +59 -3
  90. package/plugins/shipped.lock +8 -8
  91. package/dist/ui/assets/index-Biy1hkeq.css +0 -2
  92. package/dist/ui/assets/index-dkJG6W9p.js +0 -82
package/dist/cli/index.js CHANGED
@@ -1,241 +1,242 @@
1
- import { $t as e, A as t, An as n, At as r, C as i, D as a, Dt as o, E as s, Et as c, Ft as l, G as u, Ht as d, It as f, K as p, Kt as m, Lt as h, M as g, Nt as _, O as v, Ot as y, Pt as b, R as x, Rt as S, S as ee, St as C, T as w, Tt as te, Ut as T, Vt as ne, W as re, Wt as ie, Zt as ae, _ as oe, _n as se, _t as ce, a as le, b as ue, bn as de, bt as fe, c as pe, cn as me, d as he, dn as ge, en as _e, f as ve, fn as ye, g as be, gn as xe, gt as Se, h as Ce, hn as we, ht as Te, i as Ee, in as De, j as Oe, jn as ke, k as Ae, l as je, ln as Me, m as Ne, mn as E, mt as D, nn as Pe, p as Fe, pn as Ie, q as Le, rn as Re, s as ze, t as Be, tn as Ve, u as He, un as Ue, ut as We, v as Ge, vn as Ke, vt as qe, w as Je, x as Ye, xt as Xe, y as Ze, yt as Qe, z as $e, zt as et } from "../chunks/site-builder-BOQjoDbM.js";
1
+ import { A as e, At as t, B as n, Bt as r, C as i, D as a, Dt as o, E as s, Et as c, G as l, Gt as u, Ht as d, It as f, J as p, Jt as m, K as h, Lt as g, M as _, N as v, Nt as y, O as ee, Ot as b, Pt as x, Rn as te, Rt as S, S as C, Sn as w, St as ne, T as re, Tt as ie, Ut as ae, Vt as oe, Wt as se, Xt as ce, Yt as le, _ as ue, _n as de, _t as fe, a as pe, an as me, b as he, bn as ge, bt as _e, c as ve, cn as ye, d as be, dt as xe, f as Se, fn as Ce, g as we, gn as Te, gt as Ee, h as De, hn as Oe, ht as T, i as ke, in as Ae, j as je, k as E, l as Me, m as Ne, mn as Pe, on as Fe, p as Ie, pn as Le, q as Re, qt as ze, rn as Be, s as Ve, sn as He, t as Ue, tn as We, u as Ge, v as Ke, vn as D, vt as qe, w as Je, wn as Ye, x as Xe, xn as Ze, xt as Qe, y as $e, yn as et, yt as tt, z as nt, zn as rt, zt as it } from "../chunks/site-builder-C8g2sfUv.js";
2
2
  import O from "node:path";
3
3
  import k from "node:fs";
4
- import { spawn as tt } from "node:child_process";
5
- import nt from "node:os";
6
- import { preview as rt } from "vite";
7
- import { cac as it } from "cac";
4
+ import { spawn as at } from "node:child_process";
5
+ import ot from "node:os";
6
+ import { preview as st } from "vite";
7
+ import { cac as ct } from "cac";
8
8
  import * as A from "@clack/prompts";
9
9
  // src/cli/errors.ts
10
10
  var j = class extends Error {
11
11
  fix;
12
12
  code;
13
+ hint;
13
14
  constructor(e, t, n = "error") {
14
15
  super(e), this.fix = t, this.code = n;
15
16
  }
16
- }, M = class extends j {}, at = (e) => new M(`port ${e} is in use`, "Pick another with --port, or leave out --strict-port to take the next free one.", "port-in-use"), ot = (e) => e.replace(/^./, (e) => e.toLowerCase()).replace(/\.$/, "");
17
- function st(e, t, n) {
18
- return `blazon${e ? ` ${e}` : ""}: ${t}${n ? `\n ${n}` : ""}`;
17
+ }, M = class extends j {}, lt = (e) => new M(`port ${e} is in use`, "Pick another with --port, or leave out --strict-port to take the next free one.", "port-in-use"), ut = (e) => e.replace(/^./, (e) => e.toLowerCase()).replace(/\.$/, "");
18
+ function dt(e, t, n, r) {
19
+ return `blazon${e ? ` ${e}` : ""}: ${t}${n ? `\n ${n}` : ""}${r ? `\n ${r}` : ""}`;
19
20
  }
20
- var ct = (e, t) => t ? `${e}; ${ot(t)}` : e, lt;
21
- function ut(e) {
22
- lt = e;
21
+ var ft = (e, t) => t ? `${e}; ${ut(t)}` : e, pt;
22
+ function mt(e) {
23
+ pt = e;
23
24
  }
24
- function dt(e) {
25
- console.error(e.replace(/^blazon(?: [a-z]+)*:/, (e) => s.red(e)));
25
+ function ht(e) {
26
+ console.error(e.replace(/^blazon(?: [a-z]+)*:/, (e) => a.red(e)));
26
27
  }
27
- var ft = (e, t, n) => ({
28
+ var gt = (e, t, n) => ({
28
29
  code: e,
29
30
  message: t,
30
31
  ...n !== void 0 && { fix: n }
31
32
  });
32
- function pt(e, t, n) {
33
- lt !== void 0 && process.stdout.write(`${JSON.stringify({
34
- command: lt,
33
+ function _t(e, t, n) {
34
+ pt !== void 0 && process.stdout.write(`${JSON.stringify({
35
+ command: pt,
35
36
  passed: !1,
36
- error: ft(e, t, n)
37
+ error: gt(e, t, n)
37
38
  })}\n`);
38
39
  }
39
40
  function N(e, t, n = {}) {
40
- return dt(e), n.stack && console.error(n.stack), pt(t, n.json ?? e.replace(/^blazon(?: [a-z]+)?: /, ""), n.fix), process.exit(2);
41
+ return ht(e), n.stack && console.error(n.stack), _t(t, n.json ?? e.replace(/^blazon(?: [a-z]+)?: /, ""), n.fix), process.exit(2);
41
42
  }
42
- var mt = (e) => e.replace(/`([^`]*)`/g, "\"$1\"").replace(/^./, (e) => e.toLowerCase()), ht = (e) => e instanceof Error && e.name === "CACError";
43
+ var vt = (e) => e.replace(/`([^`]*)`/g, "\"$1\"").replace(/^./, (e) => e.toLowerCase()), yt = (e) => e instanceof Error && e.name === "CACError";
43
44
  function P(e, t, n) {
44
45
  let r = t instanceof j ? t.fix : void 0;
45
- if (t instanceof M) return N(st(e, t.message, r), t.code, {
46
+ if (t instanceof M) return N(dt(e, t.message, r, t.hint), t.code, {
46
47
  stack: n ? t.stack : void 0,
47
- json: ct(t.message, r),
48
+ json: ft(t.message, r),
48
49
  fix: r
49
50
  });
50
51
  let i = t instanceof Error ? t.message : String(t);
51
- return console.error(), dt(st(e, i, r ?? (n || t instanceof j ? void 0 : s.dim("Run again with --debug for the stack.")))), n && t instanceof Error && t.stack && console.error(t.stack), pt(t instanceof j ? t.code : "error", ct(i, r), r), process.exit(1);
52
+ return console.error(), ht(dt(e, i, r ?? (n || t instanceof j ? void 0 : a.dim("Run again with --debug for the stack.")))), n && t instanceof Error && t.stack && console.error(t.stack), _t(t instanceof j ? t.code : "error", ft(i, r), r), process.exit(1);
52
53
  }
53
54
  // src/cli/where.ts
54
55
  function F(e, t = process.cwd()) {
55
56
  let n = O.relative(t, O.resolve(t, e));
56
57
  return n === "" ? "" : n.startsWith("..") || O.isAbsolute(n) ? O.resolve(t, e) : n.split(O.sep).join("/");
57
58
  }
58
- var I = (e, t) => e ? `${e}/${t}` : t, gt = (e) => /^[\w./@%+=:,-]+$/.test(e) ? e : `'${e.replace(/'/g, "'\\''")}'`, L = (e, t) => `blazon ${e}${t ? ` ${gt(t)}` : ""}`, _t = (e) => k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory() ?? !1, vt = (e) => `Run ${L("init", F(e))} to start a brand book there`;
59
- function yt(e) {
60
- if (!_t(e)) throw new M(`no folder "${e}"`, `${vt(e)}.`, "no-folder");
59
+ var I = (e, t) => e ? `${e}/${t}` : t, bt = (e) => /^[\w./@%+=:,-]+$/.test(e) ? e : `'${e.replace(/'/g, "'\\''")}'`, L = (e, t) => `blazon ${e}${t ? ` ${bt(t)}` : ""}`, xt = (e) => k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory() ?? !1, St = (e) => `Run ${L("init", F(e))} to start a brand book there`;
60
+ function Ct(e) {
61
+ if (!xt(e)) throw new M(`no folder "${e}"`, `${St(e)}.`, "no-folder");
61
62
  }
62
- function bt(e, t) {
63
- if (!_t(O.resolve(e, t))) throw new M(`no tokens folder (${t.replace(/^\.\//, "").replace(/\/$/, "")}) in "${e}"`, `${vt(e)}, or set tokensDir in blazon.json.`, "no-tokens-folder");
63
+ function wt(e, t) {
64
+ if (!xt(O.resolve(e, t))) throw new M(`no tokens folder (${t.replace(/^\.\//, "").replace(/\/$/, "")}) in "${e}"`, `${St(e)}, or set tokensDir in blazon.json.`, "no-tokens-folder");
64
65
  }
65
66
  async function R(e, t) {
66
- yt(e);
67
- let n = await _e(e, t);
68
- return bt(e, n.tokensDir), n;
67
+ Ct(e);
68
+ let n = await Ae(e, t);
69
+ return wt(e, n.tokensDir), n;
69
70
  }
70
71
  // src/cli/commands/dev.ts
71
- var xt = /* @__PURE__ */ ke({ runDev: () => St });
72
- async function St(e = process.cwd(), t, n = {}) {
72
+ var Tt = /* @__PURE__ */ rt({ runDev: () => Et });
73
+ async function Et(e = process.cwd(), t, n = {}) {
73
74
  let r = await R(e, t ? { port: t } : void 0);
74
75
  try {
75
- await Ee(r, e, n);
76
+ await ke(r, e, n);
76
77
  } catch (e) {
77
- throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? at(r.port) : e;
78
+ throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? lt(r.port) : e;
78
79
  }
79
80
  }
80
81
  // src/cli/commands/check.ts
81
- var Ct = class extends j {
82
+ var Dt = class extends j {
82
83
  findings;
83
84
  constructor(e, t, n, r = "check-failed") {
84
85
  super(e, n, r), this.findings = t;
85
86
  }
86
- }, wt = (e) => e?.plugins === !1, Tt = (e) => e?.plugin === void 0 ? [] : [e.plugin].flat();
87
- function Et(e) {
87
+ }, Ot = (e) => e?.plugins === !1, kt = (e) => e?.plugin === void 0 ? [] : [e.plugin].flat();
88
+ function At(e) {
88
89
  return e.context ? `${e.path} (${e.context})` : e.path;
89
90
  }
90
- var Dt = 5;
91
- function Ot(e) {
92
- let t = e.slice(0, Dt).join(", ");
93
- return e.length > Dt ? `${t} and ${e.length - Dt} more` : t;
91
+ var jt = 5;
92
+ function Mt(e) {
93
+ let t = e.slice(0, jt).join(", ");
94
+ return e.length > jt ? `${t} and ${e.length - jt} more` : t;
94
95
  }
95
- var kt = (e) => e.path.split("/")[0];
96
- function At(e, t) {
97
- let n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = e.filter((e) => e.code === "page-review-pending");
98
- for (let t of e) t.code === "starter-file-unchanged" && i.set(kt(t), [...i.get(kt(t)) ?? [], t]), t.code === "review-pending" && a.set(t.message, [...a.get(t.message) ?? [], t]);
96
+ var Nt = (e) => e.path.split("/")[0];
97
+ function Pt(e, t) {
98
+ let n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = e.filter((e) => e.code === "page-review-pending");
99
+ for (let t of e) t.code === "starter-file-unchanged" && i.set(Nt(t), [...i.get(Nt(t)) ?? [], t]), t.code === "review-pending" && o.set(t.message, [...o.get(t.message) ?? [], t]);
99
100
  for (let c of e) {
100
101
  if (r.has(c)) continue;
101
- let e = c.code === "starter-file-unchanged" ? i.get(kt(c)) : void 0, l = c.code === "review-pending" ? a.get(c.message) : void 0;
102
- if (c.code === "page-review-pending" && o.length > 1) o.forEach((e) => r.add(e)), n.push(`${s.bold(`page-review-pending (${o.length} pages)`)}: ${Ot(o.map(Et))}: show assets still marked needs-review ${s.dim("[page-review-pending]")}`);
102
+ let e = c.code === "starter-file-unchanged" ? i.get(Nt(c)) : void 0, l = c.code === "review-pending" ? o.get(c.message) : void 0;
103
+ if (c.code === "page-review-pending" && s.length > 1) s.forEach((e) => r.add(e)), n.push(`${a.bold(`page-review-pending (${s.length} pages)`)}: ${Mt(s.map(At))}: show assets still marked needs-review ${a.dim("[page-review-pending]")}`);
103
104
  else if (e && e.length > 1) {
104
105
  e.forEach((e) => r.add(e));
105
- let t = kt(c), i = e.map((e) => e.path.slice(t.length + 1));
106
- n.push(`${s.bold(`${t}/`)}: ${e.length} files are still the starter's text (${Ot(i)}) ${s.dim("[starter-file-unchanged]")}`);
107
- } else if (l && l.length > 1) l.forEach((e) => r.add(e)), n.push(`${s.bold(`review-pending (${l.length})`)}: ${Ot(l.map(Et))}: ${c.message} ${s.dim("[review-pending]")}`);
106
+ let t = Nt(c), i = e.map((e) => e.path.slice(t.length + 1));
107
+ n.push(`${a.bold(`${t}/`)}: ${e.length} files are still the starter's text (${Mt(i)}) ${a.dim("[starter-file-unchanged]")}`);
108
+ } else if (l && l.length > 1) l.forEach((e) => r.add(e)), n.push(`${a.bold(`review-pending (${l.length})`)}: ${Mt(l.map(At))}: ${c.message} ${a.dim("[review-pending]")}`);
108
109
  else {
109
- let e = be(c, t), r = e === void 0 ? s.bold(Et(c)) : c.path === c.file ? s.bold(e) : `${s.bold(e)} ${Et(c)}`;
110
- n.push(`${r}: ${c.message} ${s.dim(`[${c.code}]`)}`);
110
+ let e = ue(c, t), r = e === void 0 ? a.bold(At(c)) : c.path === c.file ? a.bold(e) : `${a.bold(e)} ${At(c)}`;
111
+ n.push(`${r}: ${c.message} ${a.dim(`[${c.code}]`)}`);
111
112
  }
112
113
  }
113
114
  return n;
114
115
  }
115
- function jt(e, t = "") {
116
- for (let n of At(e.errors, t)) console.log(` ${s.bgRed(s.white(" ERROR "))} ${n}`);
117
- for (let n of At(e.warnings, t)) console.log(` ${s.bgYellow(s.black(" WARN "))} ${n}`);
118
- for (let n of At(e.infos, t)) console.log(` ${s.bgCyan(s.black(" NOTE "))} ${n}`);
116
+ function Ft(e, t = "") {
117
+ for (let n of Pt(e.errors, t)) console.log(` ${a.bgRed(a.white(" ERROR "))} ${n}`);
118
+ for (let n of Pt(e.warnings, t)) console.log(` ${a.bgYellow(a.black(" WARN "))} ${n}`);
119
+ for (let n of Pt(e.infos, t)) console.log(` ${a.bgCyan(a.black(" NOTE "))} ${n}`);
119
120
  }
120
- var Mt = 5;
121
- function Nt(e, t = "") {
122
- e.infos.filter((e) => e.code === "starter-file-unchanged").length < Mt || (console.log(s.bold("Next:")), console.log(` 1. Edit ${s.cyan(I(t, "tokens/colors.json"))} with your colors`), console.log(` 2. Run ${s.cyan(L("dev", t))} to see the book`), console.log(` 3. Replace blazon's artwork in ${s.cyan(I(t, "assets/"))} and the text in ${s.cyan(I(t, "docs/"))}`), console.log());
121
+ var It = 5;
122
+ function Lt(e, t = "") {
123
+ e.infos.filter((e) => e.code === "starter-file-unchanged").length < It || (console.log(a.bold("Next:")), console.log(` 1. Edit ${a.cyan(I(t, "tokens/colors.json"))} with your colors`), console.log(` 2. Run ${a.cyan(L("dev", t))} to see the book`), console.log(` 3. Replace blazon's artwork in ${a.cyan(I(t, "assets/"))} and the text in ${a.cyan(I(t, "docs/"))}`), console.log());
123
124
  }
124
- var Pt = 3;
125
- function Ft(e, t = "") {
125
+ var Rt = 3;
126
+ function zt(e, t = "") {
126
127
  let n = /* @__PURE__ */ new Map();
127
128
  for (let t of e.errors) {
128
- let e = Ge(t);
129
+ let e = $e(t);
129
130
  e && !n.has(`${t.code}\n${e}`) && n.set(`${t.code}\n${e}`, {
130
131
  code: t.code,
131
132
  fix: e
132
133
  });
133
134
  }
134
- let r = [...n.values()].slice(0, Pt);
135
- console.log(s.bold("Next:")), r.forEach(({ code: e, fix: t }, n) => console.log(` ${n + 1}. ${s.cyan(e)}: ${t}`)), console.log(` ${r.length + 1}. Run ${s.cyan(L("check", t))} again`), console.log();
136
- }
137
- function It(e, t = process.cwd()) {
138
- let n = r(e.findings);
139
- if (n.all.length === 0) return;
140
- let i = F(t);
141
- if (console.log(), jt(n, i), console.log(), n.errors.length > 0) throw new Ct(`blazon check found ${n.errors.length} error(s)`, e.findings, `Fix them, or run ${L("check", i)} for details.`);
142
- }
143
- async function Lt(e = process.cwd(), t = !1, n) {
144
- let a = await R(e);
145
- console.log(s.cyan("\n[blazon] Checking design tokens..."));
146
- let o = await D(a, e);
147
- o.findings.push(...qe(e)), wt(n) || await i(o, a, e, new Ze(a, e, { named: Tt(n) }));
148
- let c = r(o.findings, { strict: t });
149
- if (c.all.length === 0) return console.log(s.green(`\n ✔ ${o.tokens.items.length} tokens, no findings.\n`)), {
150
- findings: c.all,
135
+ let r = [...n.values()].slice(0, Rt);
136
+ console.log(a.bold("Next:")), r.forEach(({ code: e, fix: t }, n) => console.log(` ${n + 1}. ${a.cyan(e)}: ${t}`)), console.log(` ${r.length + 1}. Run ${a.cyan(L("check", t))} again`), console.log();
137
+ }
138
+ function Bt(e, n = process.cwd()) {
139
+ let r = t(e.findings);
140
+ if (r.all.length === 0) return;
141
+ let i = F(n);
142
+ if (console.log(), Ft(r, i), console.log(), r.errors.length > 0) throw new Dt(`blazon check found ${r.errors.length} error(s)`, e.findings, `Fix them, or run ${L("check", i)} for details.`);
143
+ }
144
+ async function Vt(e = process.cwd(), n = !1, r) {
145
+ let i = await R(e);
146
+ console.log(a.cyan("\n[blazon] Checking design tokens..."));
147
+ let o = await T(i, e);
148
+ o.findings.push(...tt(e)), Ot(r) || await Je(o, i, e, new he(i, e, { named: kt(r) }));
149
+ let s = t(o.findings, { strict: n });
150
+ if (s.all.length === 0) return console.log(a.green(`\n ✔ ${o.tokens.items.length} tokens, no findings.\n`)), {
151
+ findings: s.all,
151
152
  passed: !0
152
153
  };
153
- let l = [
154
- c.errors.length > 0 && `${c.errors.length} error(s)`,
155
- c.warnings.length > 0 && `${c.warnings.length} warning(s)`,
156
- c.infos.length > 0 && `${c.infos.length} note(s)`
157
- ].filter(Boolean), u = c.errors.length + c.warnings.length > 0 ? `${c.errors.length} error(s) and ${c.warnings.length} warning(s)${c.infos.length > 0 ? ` and ${c.infos.length} note(s)` : ""}` : l.join(" and "), d = F(e);
158
- return console.log(`\nFound ${u}:\n`), jt(c, d), console.log(), c.errors.length > 0 ? Ft(c, d) : Nt(c, d), c.passed ? (console.log(c.warnings.length > 0 ? s.yellow("✔ Check passed with warnings.\n") : s.green("✔ Check passed.\n")), {
159
- findings: c.all,
154
+ let c = [
155
+ s.errors.length > 0 && `${s.errors.length} error(s)`,
156
+ s.warnings.length > 0 && `${s.warnings.length} warning(s)`,
157
+ s.infos.length > 0 && `${s.infos.length} note(s)`
158
+ ].filter(Boolean), l = s.errors.length + s.warnings.length > 0 ? `${s.errors.length} error(s) and ${s.warnings.length} warning(s)${s.infos.length > 0 ? ` and ${s.infos.length} note(s)` : ""}` : c.join(" and "), u = F(e);
159
+ return console.log(`\nFound ${l}:\n`), Ft(s, u), console.log(), s.errors.length > 0 ? zt(s, u) : Lt(s, u), s.passed ? (console.log(s.warnings.length > 0 ? a.yellow("✔ Check passed with warnings.\n") : a.green("✔ Check passed.\n")), {
160
+ findings: s.all,
160
161
  passed: !0
161
- }) : (console.error(s.red(`✖ Check failed${t ? " (--strict treats warnings as errors)" : ""}.\n`)), {
162
- findings: c.all,
162
+ }) : (console.error(a.red(`✖ Check failed${n ? " (--strict treats warnings as errors)" : ""}.\n`)), {
163
+ findings: s.all,
163
164
  passed: !1
164
165
  });
165
166
  }
166
167
  // src/cli/commands/build.ts
167
- async function Rt(e = process.cwd(), t, n) {
168
- let a = await R(e, t ? { outDir: t } : void 0), o = await D(a, e);
169
- o.findings.push(...qe(e));
170
- let c = new Ze(a, e, { named: Tt(n) });
171
- wt(n) || await i(o, a, e, c), It(o, e);
172
- let { siteOutDir: l } = await Be(a, e, { data: o }), u = wt(n) ? [] : await ee(o, a, e, c, l);
173
- if (u.length === 0) return { findings: o.findings };
174
- let d = r(u);
175
- if (console.log(), jt(d, F(e)), console.log(), d.errors.length > 0) throw new Ct(`a build plugin reported ${d.errors.length} error(s)`, [...o.findings, ...u], "The site is built; the plugin's findings above say what to fix.", "plugin-failed");
176
- return console.log(s.dim(" Build plugins finished.")), { findings: [...o.findings, ...u] };
168
+ async function Ht(e = process.cwd(), n, r) {
169
+ let o = await R(e, n ? { outDir: n } : void 0), s = await T(o, e);
170
+ s.findings.push(...tt(e));
171
+ let c = new he(o, e, { named: kt(r) });
172
+ Ot(r) || await Je(s, o, e, c), Bt(s, e);
173
+ let { siteOutDir: l } = await Ue(o, e, { data: s }), u = Ot(r) ? [] : await i(s, o, e, c, l);
174
+ if (u.length === 0) return { findings: s.findings };
175
+ let d = t(u);
176
+ if (console.log(), Ft(d, F(e)), console.log(), d.errors.length > 0) throw new Dt(`a build plugin reported ${d.errors.length} error(s)`, [...s.findings, ...u], "The site is built; the plugin's findings above say what to fix.", "plugin-failed");
177
+ return console.log(a.dim(" Build plugins finished.")), { findings: [...s.findings, ...u] };
177
178
  }
178
179
  // src/cli/commands/tokens.ts
179
- async function zt(e = process.cwd(), t) {
180
- let n = await R(e);
181
- console.log(s.cyan("\n[blazon] Compiling design tokens..."));
182
- let a = await D(n, e);
183
- a.findings.push(...qe(e));
184
- let o = new Ze(n, e, { named: Tt(t) });
185
- wt(t) || await i(a, n, e, o), It(a, e);
186
- let c = await Te(a, n, e);
180
+ async function Ut(e = process.cwd(), n) {
181
+ let r = await R(e);
182
+ console.log(a.cyan("\n[blazon] Compiling design tokens..."));
183
+ let o = await T(r, e);
184
+ o.findings.push(...tt(e));
185
+ let s = new he(r, e, { named: kt(n) });
186
+ Ot(n) || await Je(o, r, e, s), Bt(o, e);
187
+ let c = await Ee(o, r, e);
187
188
  for (let e of [
188
189
  c.cssPath,
189
190
  c.typographyPath,
190
191
  c.tsPath,
191
192
  c.jsonPath
192
- ]) e && console.log(` ${s.green("✔")} Emitted ${s.bold(e)}`);
193
+ ]) e && console.log(` ${a.green("✔")} Emitted ${a.bold(e)}`);
193
194
  console.log();
194
- let l = wt(t) ? [] : await ee(a, n, e, o);
195
- if (l.length === 0) return { findings: a.findings };
196
- let u = r(l);
197
- if (jt(u, F(e)), console.log(), u.errors.length > 0) throw new Ct(`a build plugin reported ${u.errors.length} error(s)`, [...a.findings, ...l], "The token files are written; the plugin's findings above say what to fix.", "plugin-failed");
198
- return { findings: [...a.findings, ...l] };
195
+ let l = Ot(n) ? [] : await i(o, r, e, s);
196
+ if (l.length === 0) return { findings: o.findings };
197
+ let u = t(l);
198
+ if (Ft(u, F(e)), console.log(), u.errors.length > 0) throw new Dt(`a build plugin reported ${u.errors.length} error(s)`, [...o.findings, ...l], "The token files are written; the plugin's findings above say what to fix.", "plugin-failed");
199
+ return { findings: [...o.findings, ...l] };
199
200
  }
200
201
  // src/core/drift/compare.ts
201
- var Bt = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Vt = /^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/i, Ht = (e) => e.trim().toLowerCase().replace(/\s+/g, " ");
202
- function Ut(e) {
202
+ var Wt = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Gt = /^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/i, Kt = (e) => e.trim().toLowerCase().replace(/\s+/g, " ");
203
+ function qt(e) {
203
204
  let t = e.trim();
204
- if (!Bt.test(t)) return Ht(t);
205
+ if (!Wt.test(t)) return Kt(t);
205
206
  let n = t.slice(1).toLowerCase();
206
207
  return `#${n.length <= 4 ? [...n].map((e) => e + e).join("") : n}`;
207
208
  }
208
- function Wt(e) {
209
- let t = e.trim().match(Vt);
210
- return t ? `${Number(t[1])}${t[2].toLowerCase()}` : Ht(e);
209
+ function Jt(e) {
210
+ let t = e.trim().match(Gt);
211
+ return t ? `${Number(t[1])}${t[2].toLowerCase()}` : Kt(e);
211
212
  }
212
- function Gt(e, t) {
213
- return e === "color" ? Ut(t) : e === "dimension" ? Wt(t) : Ht(t);
213
+ function Yt(e, t) {
214
+ return e === "color" ? qt(t) : e === "dimension" ? Jt(t) : Kt(t);
214
215
  }
215
- var Kt = /\/\*[\s\S]*?\*\//g, qt = /([^{}]*)\{([^{}]*)\}/g, Jt = /(--[A-Za-z0-9_-]+)\s*:\s*([^;]*?)\s*(?:;|$)/g, Yt = /(^|,)\s*(:root|html)\s*(,|$)/, Xt = /^var\(\s*(--[A-Za-z0-9_-]+)\s*\)$/;
216
- function Zt(e) {
216
+ var Xt = /\/\*[\s\S]*?\*\//g, Zt = /([^{}]*)\{([^{}]*)\}/g, Qt = /(--[A-Za-z0-9_-]+)\s*:\s*([^;]*?)\s*(?:;|$)/g, $t = /(^|,)\s*(:root|html)\s*(,|$)/, en = /^var\(\s*(--[A-Za-z0-9_-]+)\s*\)$/;
217
+ function tn(e) {
217
218
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
218
- for (let r of e.replace(Kt, "").matchAll(qt)) {
219
- let e = Yt.test(r[1].trim()) ? t : n;
220
- for (let t of r[2].matchAll(Jt)) e.set(t[1], t[2]);
219
+ for (let r of e.replace(Xt, "").matchAll(Zt)) {
220
+ let e = $t.test(r[1].trim()) ? t : n;
221
+ for (let t of r[2].matchAll(Qt)) e.set(t[1], t[2]);
221
222
  }
222
223
  let r = new Map([...n, ...t]);
223
224
  for (let [e, t] of r) {
224
225
  let n = t, i = /* @__PURE__ */ new Set([e]);
225
- for (let e = n.match(Xt); e && r.has(e[1]) && !i.has(e[1]); e = n.match(Xt)) i.add(e[1]), n = r.get(e[1]);
226
+ for (let e = n.match(en); e && r.has(e[1]) && !i.has(e[1]); e = n.match(en)) i.add(e[1]), n = r.get(e[1]);
226
227
  r.set(e, n);
227
228
  }
228
229
  return r;
229
230
  }
230
- function Qt(e, t, n) {
231
- let r = Gt(e.type, String(e.value)), i = n.get(t);
231
+ function nn(e, t, n) {
232
+ let r = Yt(e.type, String(e.value)), i = n.get(t);
232
233
  if (i === void 0) return {
233
234
  path: e.path,
234
235
  cssVar: t,
235
236
  status: "missing",
236
237
  expected: r
237
238
  };
238
- let a = Gt(e.type, i);
239
+ let a = Yt(e.type, i);
239
240
  return {
240
241
  path: e.path,
241
242
  cssVar: t,
@@ -244,21 +245,21 @@ function Qt(e, t, n) {
244
245
  actual: a
245
246
  };
246
247
  }
247
- var $t = 1e4;
248
- function en(e) {
248
+ var rn = 1e4;
249
+ function an(e) {
249
250
  let t = e instanceof Error ? e.message : String(e), n = e instanceof Error ? e.cause : void 0;
250
251
  return n instanceof Error && n.message && n.message !== t ? `${t}: ${n.message}` : t;
251
252
  }
252
- async function tn(e) {
253
+ async function on(e) {
253
254
  let t;
254
255
  try {
255
256
  t = await fetch(e, {
256
- signal: AbortSignal.timeout($t),
257
+ signal: AbortSignal.timeout(rn),
257
258
  redirect: "follow"
258
259
  });
259
260
  } catch (t) {
260
261
  let n = t instanceof Error && (t.name === "TimeoutError" || t.name === "AbortError");
261
- throw Error(`could not fetch ${e}: ${n ? `no answer in ${$t / 1e3} s` : en(t)}`, { cause: t });
262
+ throw Error(`could not fetch ${e}: ${n ? `no answer in ${rn / 1e3} s` : an(t)}`, { cause: t });
262
263
  }
263
264
  if (!t.ok) throw Error(`could not fetch ${e}: ${t.status} ${t.statusText}`.trim());
264
265
  let n = [], r = 0;
@@ -272,10 +273,10 @@ async function tn(e) {
272
273
  }
273
274
  return Buffer.concat(n);
274
275
  }
275
- async function nn(e) {
276
- return (await tn(e)).toString("utf8");
276
+ async function sn(e) {
277
+ return (await on(e)).toString("utf8");
277
278
  }
278
- function rn(e, t) {
279
+ function cn(e, t) {
279
280
  let n = [];
280
281
  for (let [r] of e.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<link\b[^>]*>/gi)) {
281
282
  let e = (e) => r.match(RegExp(`\\s${e}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i")), i = e("rel"), a = e("href");
@@ -286,12 +287,12 @@ function rn(e, t) {
286
287
  }
287
288
  return n;
288
289
  }
289
- async function an(e) {
290
+ async function ln(e) {
290
291
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(e)) {
291
292
  if (!/^https?:\/\//i.test(e)) throw Error(`${e} is not an http(s) address or a file`);
292
- let t = rn(await nn(e), e).slice(0, 20);
293
+ let t = cn(await sn(e), e).slice(0, 20);
293
294
  return {
294
- css: (await Promise.all(t.map(nn))).join("\n"),
295
+ css: (await Promise.all(t.map(sn))).join("\n"),
295
296
  sources: t
296
297
  };
297
298
  }
@@ -307,60 +308,60 @@ async function an(e) {
307
308
  sources: [t]
308
309
  };
309
310
  }
310
- async function on(e) {
311
+ async function un(e) {
311
312
  if (!/^https?:\/\//i.test(e)) throw Error(`${e} is not an http(s) address`);
312
- let t = await nn(e), n = rn(t, e).slice(0, 20);
313
+ let t = await sn(e), n = cn(t, e).slice(0, 20);
313
314
  return {
314
315
  html: t,
315
- css: (await Promise.all(n.map(nn))).join("\n"),
316
+ css: (await Promise.all(n.map(sn))).join("\n"),
316
317
  sources: n
317
318
  };
318
319
  }
319
320
  // src/core/init/from-site/tree.ts
320
- var sn = (e) => typeof e == "object" && !!e && "$value" in e;
321
- function cn(e) {
321
+ var dn = (e) => typeof e == "object" && !!e && "$value" in e;
322
+ function fn(e) {
322
323
  return JSON.parse(k.readFileSync(e, "utf-8"));
323
324
  }
324
- function ln(e, t) {
325
+ function pn(e, t) {
325
326
  k.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
326
327
  }
327
- var un = (e) => ({ "dev.blazon": e });
328
- function dn(e, t = []) {
328
+ var mn = (e) => ({ "dev.blazon": e });
329
+ function hn(e, t = []) {
329
330
  let n = [];
330
- for (let [r, i] of Object.entries(e)) !r.startsWith("$") && typeof i == "object" && i && (sn(i) ? n.push([...t, r].join(".")) : n.push(...dn(i, [...t, r])));
331
+ for (let [r, i] of Object.entries(e)) !r.startsWith("$") && typeof i == "object" && i && (dn(i) ? n.push([...t, r].join(".")) : n.push(...hn(i, [...t, r])));
331
332
  return n;
332
333
  }
333
- var fn = (e, t) => {
334
+ var gn = (e, t) => {
334
335
  let n = e;
335
336
  for (let e of t.split(".")) {
336
337
  if (typeof n != "object" || !n) return;
337
338
  n = n[e];
338
339
  }
339
- return sn(n) ? n : void 0;
340
- }, pn = (e) => [...JSON.stringify(e).matchAll(/\{([A-Za-z0-9_.-]+)\}/g)].map((e) => e[1]);
341
- function mn(e, t) {
340
+ return dn(n) ? n : void 0;
341
+ }, _n = (e) => [...JSON.stringify(e).matchAll(/\{([A-Za-z0-9_.-]+)\}/g)].map((e) => e[1]);
342
+ function vn(e, t) {
342
343
  return k.existsSync(e) ? k.readdirSync(e, { withFileTypes: !0 }).flatMap((n) => {
343
344
  let r = O.join(e, n.name);
344
- return n.isDirectory() ? mn(r, t) : t.some((e) => n.name.endsWith(e)) ? [r] : [];
345
+ return n.isDirectory() ? vn(r, t) : t.some((e) => n.name.endsWith(e)) ? [r] : [];
345
346
  }) : [];
346
347
  }
347
- function hn(e, t) {
348
+ function yn(e, t) {
348
349
  let n = t.split("."), r = [e];
349
350
  for (let e of n.slice(0, -1)) r.push(r.at(-1)[e]);
350
351
  delete r.at(-1)[n.at(-1)];
351
352
  for (let e = r.length - 1; e >= 2 && !Object.keys(r[e]).some((e) => !e.startsWith("$")); e--) delete r[e - 1][n[e - 1]];
352
353
  }
353
354
  // src/core/init/from-site/clean-colors.ts
354
- function gn(e) {
355
+ function bn(e) {
355
356
  let { tree: t, destDir: n, picks: r, starterColors: i, siteColors: a, note: o, review: s, source: c, result: l } = e, u = (e, n) => {
356
- let r = fn(t, `${e}.${n}`)?.$value, o = typeof r == "string" ? r.match(/^\{(.+)\}$/)?.[1] : void 0;
357
+ let r = gn(t, `${e}.${n}`)?.$value, o = typeof r == "string" ? r.match(/^\{(.+)\}$/)?.[1] : void 0;
357
358
  return o && i.has(o) && !a.has(o) ? o : void 0;
358
359
  }, d = (e, n, r, i = {}) => {
359
- let [a, c] = e.split("."), u = fn(t, e), d = String(u.$value);
360
+ let [a, c] = e.split("."), u = gn(t, e), d = String(u.$value);
360
361
  t[a][c] = {
361
362
  $value: `{${n}}`,
362
363
  ...typeof u.$description == "string" && { $description: u.$description },
363
- $extensions: un({
364
+ $extensions: mn({
364
365
  ...i,
365
366
  review: r ? {
366
367
  ...s,
@@ -391,20 +392,20 @@ function gn(e) {
391
392
  let [n, r] = e.split("."), i = p(t);
392
393
  i && u(n, r) && d(e, f(i), "", { source: c(`:root { ${i.cssVar} }`, i.exact ? i.cssVar : void 0) });
393
394
  }
394
- let m = t.color, { color: h, ...g } = t, _ = new Set(pn(g));
395
- for (let e of mn(O.join(n, "tokens"), [".json"])) if (O.basename(e) !== "colors.json") for (let t of pn(cn(e))) _.add(t);
396
- let v = [O.join(n, "blazon.json"), ...mn(O.join(n, "docs"), [".md", ".mdx"])].filter((e) => k.existsSync(e)).map((e) => k.readFileSync(e, "utf-8")).join("\n");
395
+ let m = t.color, { color: h, ...g } = t, _ = new Set(_n(g));
396
+ for (let e of vn(O.join(n, "tokens"), [".json"])) if (O.basename(e) !== "colors.json") for (let t of _n(fn(e))) _.add(t);
397
+ let v = [O.join(n, "blazon.json"), ...vn(O.join(n, "docs"), [".md", ".mdx"])].filter((e) => k.existsSync(e)).map((e) => k.readFileSync(e, "utf-8")).join("\n");
397
398
  for (let e of v.matchAll(/(?<![\w.-])color(?:\.[A-Za-z0-9_-]+)+/g)) _.add(e[0]);
398
399
  let y = [..._];
399
400
  for (; y.length > 0;) {
400
- let e = fn(t, y.pop());
401
- for (let t of e ? pn(e.$value) : []) _.has(t) || (_.add(t), y.push(t));
401
+ let e = gn(t, y.pop());
402
+ for (let t of e ? _n(e.$value) : []) _.has(t) || (_.add(t), y.push(t));
402
403
  }
403
- for (let e of [...i].filter((e) => !a.has(e) && !_.has(e))) fn({ color: m }, e) && (hn({ color: m }, e), l.removed.push(`${e} (a starter color nothing uses)`));
404
+ for (let e of [...i].filter((e) => !a.has(e) && !_.has(e))) gn({ color: m }, e) && (yn({ color: m }, e), l.removed.push(`${e} (a starter color nothing uses)`));
404
405
  }
405
406
  // src/core/init/palette.ts
406
- var _n = "#ffffff", vn = "#0b1120";
407
- function yn(e) {
407
+ var xn = "#ffffff", Sn = "#0b1120";
408
+ function Cn(e) {
408
409
  let t = e.trim().match(/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i);
409
410
  if (!t) return;
410
411
  let n = t[1].length === 3 ? [...t[1]].map((e) => e + e).join("") : t[1];
@@ -414,38 +415,38 @@ function yn(e) {
414
415
  4
415
416
  ].map((e) => parseInt(n.slice(e, e + 2), 16) / 255);
416
417
  }
417
- var bn = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
418
- function xn(e) {
419
- let t = yn(e);
418
+ var wn = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
419
+ function Tn(e) {
420
+ let t = Cn(e);
420
421
  if (!t) throw Error(`not a hex color: ${e}`);
421
422
  return t;
422
423
  }
423
- function Sn(e) {
424
- let [t, n, r] = xn(e).map(bn);
424
+ function En(e) {
425
+ let [t, n, r] = Tn(e).map(wn);
425
426
  return .2126 * t + .7152 * n + .0722 * r;
426
427
  }
427
428
  function z(e, t) {
428
- let [n, r] = [Sn(e), Sn(t)];
429
+ let [n, r] = [En(e), En(t)];
429
430
  return (Math.max(n, r) + .05) / (Math.min(n, r) + .05);
430
431
  }
431
- var Cn = (e) => e >= 7 ? "AAA" : e >= 4.5 ? "AA" : e >= 3 ? "AA-large" : "fail";
432
- function wn(e) {
433
- let t = z(e, _n), n = z(e, vn);
432
+ var Dn = (e) => e >= 7 ? "AAA" : e >= 4.5 ? "AA" : e >= 3 ? "AA-large" : "fail";
433
+ function On(e) {
434
+ let t = z(e, xn), n = z(e, Sn);
434
435
  return {
435
436
  onWhite: {
436
437
  ratio: t,
437
- level: Cn(t)
438
+ level: Dn(t)
438
439
  },
439
440
  onNearBlack: {
440
441
  ratio: n,
441
- level: Cn(n)
442
+ level: Dn(n)
442
443
  },
443
444
  carriesWhiteText: t >= 4.5
444
445
  };
445
446
  }
446
- var Tn = "#1E1F21", En = "#F2F0EB";
447
- function Dn(e) {
448
- let t = z(e, Tn), n = z(e, En);
447
+ var kn = "#1E1F21", An = "#F2F0EB";
448
+ function jn(e) {
449
+ let t = z(e, kn), n = z(e, An);
449
450
  return t >= n ? {
450
451
  ink: "graphite",
451
452
  ratio: t,
@@ -457,42 +458,42 @@ function Dn(e) {
457
458
  };
458
459
  }
459
460
  // src/core/init/vocabulary.ts
460
- var On = "color.signal.orange", kn = "color.signal.primary", An = "color.signal.hazard", jn = (e) => typeof e == "object" && !!e && "$value" in e;
461
+ var Mn = "color.signal.orange", Nn = "color.signal.primary", Pn = "color.signal.hazard", Fn = (e) => typeof e == "object" && !!e && "$value" in e;
461
462
  function B(e, t) {
462
463
  let n = e;
463
464
  for (let e of t.split(".")) {
464
465
  if (typeof n != "object" || !n) return;
465
466
  n = n[e];
466
467
  }
467
- return jn(n) ? n : void 0;
468
+ return Fn(n) ? n : void 0;
468
469
  }
469
- function Mn(e, t) {
470
+ function In(e, t) {
470
471
  let n = e.$extensions ??= {}, r = n["dev.blazon"] ??= {};
471
472
  r.review === void 0 && (r.review = {
472
473
  status: "needs-review",
473
474
  note: t
474
475
  });
475
476
  }
476
- function Nn(e, t) {
477
+ function Ln(e, t) {
477
478
  let n = [], r = e.color, i = r?.signal, a = i?.orange;
478
- if (!i || !jn(a)) throw Error(`${On} is not in the tokens`);
479
+ if (!i || !Fn(a)) throw Error(`${Mn} is not in the tokens`);
479
480
  let o = {};
480
481
  for (let [e, t] of Object.entries(i)) o[e === "orange" ? "primary" : e] = t;
481
482
  r.signal = o;
482
- let s = JSON.parse(JSON.stringify(e).split(`{${On}}`).join(`{${kn}}`));
483
+ let s = JSON.parse(JSON.stringify(e).split(`{${Mn}}`).join(`{${Nn}}`));
483
484
  for (let t of Object.keys(e)) e[t] = s[t];
484
- let c = B(e, kn);
485
+ let c = B(e, Nn);
485
486
  c.$value = t, c.$description = "Primary signal color";
486
- let l = Pn(e, t, `{${kn}}`);
487
+ let l = Rn(e, t, `{${Nn}}`);
487
488
  n.push(...l.hints);
488
- let u = B(e, An);
489
- return u && (Mn(u, "Still blazon's hazard yellow: it was not chosen to go with your primary. Set the brand's own, or remove it."), n.push(`${An} is still blazon's hazard yellow and is marked needs-review: set the brand's own or remove it`)), {
489
+ let u = B(e, Pn);
490
+ return u && (In(u, "Still blazon's hazard yellow: it was not chosen to go with your primary. Set the brand's own, or remove it."), n.push(`${Pn} is still blazon's hazard yellow and is marked needs-review: set the brand's own or remove it`)), {
490
491
  hints: n,
491
492
  label: l.label
492
493
  };
493
494
  }
494
- function Pn(e, t, n, r = !1) {
495
- let i = [], a = z(t, Tn), o = z(t, En), s = B(e, "text.onSignal"), c = a < 4.5 && o >= 4.5 && s !== void 0;
495
+ function Rn(e, t, n, r = !1) {
496
+ let i = [], a = z(t, kn), o = z(t, An), s = B(e, "text.onSignal"), c = a < 4.5 && o >= 4.5 && s !== void 0;
496
497
  if (c ? (s.$value = "{color.base.bone}", s.$description = "Labels on the brand color are bone", i.push(`Labels on ${t} are bone, because graphite is ${a.toFixed(1)}:1 there; blazon's hazard yellow has no label pair now`)) : a < 4.5 && i.push(`Neither graphite (${a.toFixed(1)}:1) nor bone (${o.toFixed(1)}:1) reaches AA (4.5:1) as a label on ${t}: blazon check will report text.onSignal, so choose a lighter or darker color`), c || r) {
497
498
  let t = e.text?.$extensions?.["dev.blazon"];
498
499
  for (let e of t?.pairs ?? []) e.bg === "{color.signal.*}" && (e.bg = n);
@@ -502,16 +503,16 @@ function Pn(e, t, n, r = !1) {
502
503
  label: c ? "bone" : "graphite"
503
504
  };
504
505
  }
505
- var Fn = (e) => JSON.parse(k.readFileSync(e, "utf-8")), In = (e, t) => k.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
506
- function Ln(e, t) {
506
+ var zn = (e) => JSON.parse(k.readFileSync(e, "utf-8")), Bn = (e, t) => k.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
507
+ function Vn(e, t) {
507
508
  return [...t, ...Array.isArray(e) ? e.filter((e) => typeof e == "object" && !!e) : []];
508
509
  }
509
- var Rn = ["blazon-graphite", "blazon-bone"], zn = [...Rn, "blazon-mark"];
510
+ var Hn = ["blazon-graphite", "blazon-bone"], Un = [...Hn, "blazon-mark"];
510
511
  // src/core/init/shared/hex.ts
511
- function Bn(e) {
512
+ function Wn(e) {
512
513
  let t = e.trim();
513
514
  if (/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)) return {
514
- hex: Ut(t),
515
+ hex: qt(t),
515
516
  exact: !0
516
517
  };
517
518
  let n = t.match(/^rgba?\(\s*([\d.]+)(%?)[\s,]+([\d.]+)%?[\s,]+([\d.]+)%?(?:\s*[,/]\s*([\d.]+)(%?))?\s*\)$/i);
@@ -527,12 +528,12 @@ function Bn(e) {
527
528
  };
528
529
  }
529
530
  // src/core/init/from-site/colors.ts
530
- var Vn = 40, Hn = /brand|primary|secondary|accent|background|foreground|surface/i;
531
- function Un(e) {
531
+ var Gn = 40, Kn = /brand|primary|secondary|accent|background|foreground|surface/i;
532
+ function qn(e) {
532
533
  let t = [], n = /* @__PURE__ */ new Set();
533
534
  for (let [r, i] of e) {
534
- if (!Hn.test(r)) continue;
535
- let e = Bn(i);
535
+ if (!Kn.test(r)) continue;
536
+ let e = Wn(i);
536
537
  if (!e || e.hex.length !== 7) continue;
537
538
  let a = r.slice(2).toLowerCase().split(/[-_]+/).filter(Boolean);
538
539
  a.length > 1 && (a[0] === "color" || a[0] === "colors") && (a = a.slice(1)), a.length > 1 && a.at(-1) === "foreground" || a.length > 1 && a.at(-2) === "on" && /^(dark|light)$/.test(a.at(-1)) || a.length === 0 || n.has(a.join(".")) || (n.add(a.join(".")), t.push({
@@ -541,20 +542,20 @@ function Un(e) {
541
542
  segments: a
542
543
  }));
543
544
  }
544
- return t.slice(0, Vn);
545
+ return t.slice(0, Gn);
545
546
  }
546
- function Wn(e, t, n = []) {
547
+ function Jn(e, t, n = []) {
547
548
  let r = e.filter((e) => e.segments.includes(t)).sort((e, n) => Number(e.segments.at(-1) !== t) - Number(n.segments.at(-1) !== t) || e.segments.length - n.segments.length)[0];
548
549
  return r || t !== "secondary" ? r : e.find((e) => !n.includes(e) && e.segments.includes("brand") && !e.segments.some((e) => /light|dark|strong|hero|raised|navy|background|foreground|surface/.test(e)));
549
550
  }
550
551
  // src/core/init/from-site/context.ts
551
- var Gn = (...e) => e.join("/");
552
+ var Yn = (...e) => e.join("/");
552
553
  // src/core/init/from-site/sections/colors.ts
553
- function Kn(e, t) {
554
- let { destDir: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = Un(r).filter((e) => !t?.has(e.cssVar));
554
+ function Xn(e, t) {
555
+ let { destDir: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = qn(r).filter((e) => !t?.has(e.cssVar));
555
556
  if (l.length === 0) i.missing.push("no brand color: no custom property named brand, primary, secondary, accent, background, foreground or surface holds a hex or rgb() color");
556
- else if (c(Gn("tokens", "colors.json"))) {
557
- let e = O.join(n, "tokens", "colors.json"), t = cn(e), r = t.color ??= {}, c = new Set(dn(r, ["color"])), u = /* @__PURE__ */ new Set(), d = new Set(l.map((e) => e.segments.join(".")));
557
+ else if (c(Yn("tokens", "colors.json"))) {
558
+ let e = O.join(n, "tokens", "colors.json"), t = fn(e), r = t.color ??= {}, c = new Set(hn(r, ["color"])), u = /* @__PURE__ */ new Set(), d = new Set(l.map((e) => e.segments.join(".")));
558
559
  for (let e of l) {
559
560
  let t = e.segments;
560
561
  [...d].some((e) => e.startsWith(`${t.join(".")}.`)) && (t = [...t, "base"]);
@@ -563,37 +564,37 @@ function Kn(e, t) {
563
564
  let t = n[r];
564
565
  if (t === void 0) {
565
566
  let t = {};
566
- e === 0 && (t.$extensions = un({ review: o }), a = !0), n[r] = t, n = t;
567
- } else if (sn(t) || typeof t != "object" || !t) {
567
+ e === 0 && (t.$extensions = mn({ review: o }), a = !0), n[r] = t, n = t;
568
+ } else if (dn(t) || typeof t != "object" || !t) {
568
569
  c = !1;
569
570
  break;
570
571
  } else n = t;
571
572
  }
572
573
  let l = t.at(-1);
573
- !c || typeof n[l] == "object" && n[l] !== null && !sn(n[l]) ? i.missing.push(`${e.cssVar} was not written: color.${t.join(".")} clashes with a starter token`) : (n[l] = {
574
+ !c || typeof n[l] == "object" && n[l] !== null && !dn(n[l]) ? i.missing.push(`${e.cssVar} was not written: color.${t.join(".")} clashes with a starter token`) : (n[l] = {
574
575
  $value: e.hex,
575
- $extensions: un({
576
+ $extensions: mn({
576
577
  source: s(`:root { ${e.cssVar} }`, e.exact ? e.cssVar : void 0),
577
578
  ...a ? {} : { review: o }
578
579
  })
579
580
  }, e.segments = t, u.add(e));
580
581
  }
581
- let f = new Set([...u].map((e) => `color.${e.segments.join(".")}`)), p = Wn(l, "primary"), m = t.interactive, h = fn(t, "interactive.primary");
582
+ let f = new Set([...u].map((e) => `color.${e.segments.join(".")}`)), p = Jn(l, "primary"), m = t.interactive, h = gn(t, "interactive.primary");
582
583
  if (!p) i.missing.push("no primary color: interactive.primary keeps the starter's value");
583
584
  else if (m && h) {
584
585
  let e = `color.${p.segments.join(".")}`;
585
586
  m.primary = {
586
587
  $value: `{${e}}`,
587
588
  ...typeof h.$description == "string" && { $description: h.$description },
588
- $extensions: un({
589
+ $extensions: mn({
589
590
  source: s(`:root { ${p.cssVar} }`, p.exact ? p.cssVar : void 0),
590
591
  review: o
591
592
  })
592
593
  }, i.repointed.push(`interactive.primary to {${e}}`);
593
- let n = Pn(t, p.hex, `{${e}}`, !0);
594
+ let n = Rn(t, p.hex, `{${e}}`, !0);
594
595
  for (let e of n.hints) i.missing.push(e);
595
596
  } else i.missing.push("interactive.primary was not found in tokens/colors.json, so the primary color was not set");
596
- gn({
597
+ bn({
597
598
  tree: t,
598
599
  destDir: n,
599
600
  picks: [...u],
@@ -603,11 +604,11 @@ function Kn(e, t) {
603
604
  review: o,
604
605
  source: s,
605
606
  result: i
606
- }), ln(e, t), i.written.push(Gn("tokens", "colors.json"));
607
+ }), pn(e, t), i.written.push(Yn("tokens", "colors.json"));
607
608
  }
608
609
  }
609
610
  // src/core/init/from-site/html.ts
610
- function qn(e) {
611
+ function Zn(e) {
611
612
  return e.replace(/&amp;/g, "&").replace(/&quot;/g, "\"").replace(/&#0?39;|&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim().split(/ [|:–—-] /)[0].trim();
612
613
  }
613
614
  var V = (e, t) => {
@@ -620,36 +621,36 @@ function H(e, t) {
620
621
  if (e) return e;
621
622
  }
622
623
  }
623
- function Jn(e) {
624
+ function Qn(e) {
624
625
  let t = H(e, "og:site_name") ?? H(e, "application-name");
625
626
  if (t) return t;
626
627
  let n = e.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i);
627
- return (n ? qn(n[1]) : "") || void 0;
628
+ return (n ? Zn(n[1]) : "") || void 0;
628
629
  }
629
- async function Yn(e, t) {
630
+ async function $n(e, t) {
630
631
  let n = (e.match(/<link\b[^>]*>/gi) ?? []).find((e) => V(e, "rel")?.toLowerCase() === "manifest"), r = n && V(n, "href");
631
632
  if (r) try {
632
633
  let e = new URL(r, t);
633
634
  if (e.protocol !== "http:" && e.protocol !== "https:") return;
634
- let n = JSON.parse(await nn(e.href)), i = typeof n.short_name == "string" ? n.short_name.trim() : "", a = typeof n.name == "string" ? qn(n.name) : "";
635
+ let n = JSON.parse(await sn(e.href)), i = typeof n.short_name == "string" ? n.short_name.trim() : "", a = typeof n.name == "string" ? Zn(n.name) : "";
635
636
  return i || a || void 0;
636
637
  } catch {
637
638
  return;
638
639
  }
639
640
  }
640
641
  // src/core/init/from-site/sections/config.ts
641
- async function Xn(e, t, n) {
642
- let { destDir: r, url: i, page: a, result: o, mayChange: s } = e, { fontUrls: c } = n, l = "blazon.json", u = H(a.html, "og:site_name") ?? H(a.html, "application-name") ?? await Yn(a.html, i) ?? Jn(a.html), d = H(a.html, "description");
642
+ async function er(e, t, n) {
643
+ let { destDir: r, url: i, page: a, result: o, mayChange: s } = e, { fontUrls: c } = n, l = "blazon.json", u = H(a.html, "og:site_name") ?? H(a.html, "application-name") ?? await $n(a.html, i) ?? Qn(a.html), d = H(a.html, "description");
643
644
  u || o.missing.push("no <title> on the page: the config title keeps the folder name");
644
645
  let f = !1;
645
646
  if ((u || d || t.single || t.onLight || c.length > 0) && s(l)) {
646
- let e = O.join(r, l), n = Fn(e);
647
+ let e = O.join(r, l), n = zn(e);
647
648
  u && (n.title = u), d && (n.description = d);
648
649
  let i = t.single ?? (t.onLight ? {
649
650
  onLight: t.onLight,
650
651
  ...t.onDark ? { onDark: t.onDark } : {}
651
652
  } : void 0);
652
- i && (n.logo = i), c.length > 0 && (n.fonts = Ln(n.fonts, c)), In(e, n), o.written.push(l), f = !!i;
653
+ i && (n.logo = i), c.length > 0 && (n.fonts = Vn(n.fonts, c)), Bn(e, n), o.written.push(l), f = !!i;
653
654
  }
654
655
  return {
655
656
  title: u,
@@ -658,23 +659,23 @@ async function Xn(e, t, n) {
658
659
  };
659
660
  }
660
661
  // src/core/init/from-site/sections/directives.ts
661
- var Zn = /^[ \t]*<!--\s*blazon:tokens\b([^>]*?)-->[ \t]*\r?\n?/gm;
662
- function Qn(t) {
663
- let { destDir: n, created: r, result: i } = t, a = O.join(n, "docs");
664
- if (!k.existsSync(a)) return;
665
- let o = m(e(O.join(n, "tokens"), n), "--").items, s = (e) => o.some((t) => t.path === e || t.path.startsWith(`${e}.`));
666
- for (let e of k.readdirSync(a).filter((e) => e.endsWith(".md"))) {
662
+ var tr = /^[ \t]*<!--\s*blazon:tokens\b([^>]*?)-->[ \t]*\r?\n?/gm;
663
+ function nr(e) {
664
+ let { destDir: t, created: n, result: r } = e, i = O.join(t, "docs");
665
+ if (!k.existsSync(i)) return;
666
+ let a = ce(Be(O.join(t, "tokens"), t), "--").items, o = (e) => a.some((t) => t.path === e || t.path.startsWith(`${e}.`));
667
+ for (let e of k.readdirSync(i).filter((e) => e.endsWith(".md"))) {
667
668
  let t = `docs/${e}`;
668
- if (!r.has(t)) continue;
669
- let n = O.join(a, e), o = k.readFileSync(n, "utf-8"), c = [], l = o.replace(Zn, (e, t) => {
670
- let n = t.split(/\s+/).filter(Boolean), r = n.filter(s);
671
- return c.push(...n.filter((e) => !s(e))), r.length === n.length ? e : r.length === 0 ? "" : `<!-- blazon:tokens ${r.join(" ")} -->\n`;
669
+ if (!n.has(t)) continue;
670
+ let a = O.join(i, e), s = k.readFileSync(a, "utf-8"), c = [], l = s.replace(tr, (e, t) => {
671
+ let n = t.split(/\s+/).filter(Boolean), r = n.filter(o);
672
+ return c.push(...n.filter((e) => !o(e))), r.length === n.length ? e : r.length === 0 ? "" : `<!-- blazon:tokens ${r.join(" ")} -->\n`;
672
673
  }).replace(/\n{3,}/g, "\n\n");
673
- l !== o && (k.writeFileSync(n, l), i.removed.push(`${c.join(", ")} in ${t} (the site has no such token to show)`));
674
+ l !== s && (k.writeFileSync(a, l), r.removed.push(`${c.join(", ")} in ${t} (the site has no such token to show)`));
674
675
  }
675
676
  }
676
677
  // src/core/init/shared/google-fonts.ts
677
- var $n = [
678
+ var rr = [
678
679
  "Inter",
679
680
  "Roboto",
680
681
  "Open Sans",
@@ -692,12 +693,12 @@ var $n = [
692
693
  "Playfair Display",
693
694
  "JetBrains Mono"
694
695
  ];
695
- function er(e) {
696
- let t = $n.find((t) => t.toLowerCase() === e.toLowerCase());
696
+ function ir(e) {
697
+ let t = rr.find((t) => t.toLowerCase() === e.toLowerCase());
697
698
  return t ? `https://fonts.googleapis.com/css2?family=${t.replace(/ /g, "+")}:wght@400;500;600;700&display=swap` : void 0;
698
699
  }
699
700
  // src/core/init/from-site/fonts.ts
700
- var tr = /* @__PURE__ */ new Set([
701
+ var ar = /* @__PURE__ */ new Set([
701
702
  "serif",
702
703
  "sans-serif",
703
704
  "monospace",
@@ -717,19 +718,55 @@ var tr = /* @__PURE__ */ new Set([
717
718
  "-apple-system",
718
719
  "blinkmacsystemfont",
719
720
  "segoe ui"
720
- ]), nr = /* @__PURE__ */ new Set([
721
+ ]), or = /* @__PURE__ */ new Set([
721
722
  "serif",
722
723
  "sans-serif",
723
724
  "monospace",
724
725
  "cursive",
725
726
  "fantasy"
726
- ]);
727
- function rr(e) {
728
- let t = [], n = "", r = "";
729
- for (let i of e) r ? i === r ? r = "" : n += i : i === "\"" || i === "'" ? r = i : i === "," ? (t.push(n.trim()), n = "") : n += i;
727
+ ]), sr = /[0-9a-fA-F]/, cr = /[\n\r\f]/;
728
+ function lr(e, t) {
729
+ if (!sr.test(e[t])) return {
730
+ text: e[t],
731
+ next: t + 1
732
+ };
733
+ let n = "", r = t;
734
+ for (; n.length < 6 && r < e.length && sr.test(e[r]);) n += e[r++];
735
+ e.startsWith("\r\n", r) ? r += 2 : r < e.length && /\s/.test(e[r]) && (r += 1);
736
+ let i = parseInt(n, 16);
737
+ return {
738
+ text: i !== 0 && i <= 1114111 && (i < 55296 || i > 57343) ? String.fromCodePoint(i) : "�",
739
+ next: r
740
+ };
741
+ }
742
+ function ur(e) {
743
+ let t = [], n = "", r = "bare", i = "", a = 0, o = 0;
744
+ for (; o < e.length;) {
745
+ let s = e[o];
746
+ if (r === "string") {
747
+ if (s === i) r = "bare", o++;
748
+ else if (cr.test(s)) r = "bare";
749
+ else if (s === "\\") {
750
+ if (o + 1 >= e.length) o++;
751
+ else if (e.startsWith("\r\n", o + 1)) o += 3;
752
+ else if (cr.test(e[o + 1])) o += 2;
753
+ else {
754
+ let t = lr(e, o + 1);
755
+ n += t.text, o = t.next;
756
+ }
757
+ } else n += s, o++;
758
+ } else if (r === "call") n += s, o++, i ? s === "\\" && o < e.length ? n += e[o++] : s === i && (i = "") : s === "\"" || s === "'" ? i = s : s === "(" ? a++ : s === ")" && --a === 0 && (r = "bare");
759
+ else if (s === "\"" || s === "'") r = "string", i = s, o++;
760
+ else if (s === "(") r = "call", i = "", a = 1, n += s, o++;
761
+ else if (s === ",") t.push(n.trim()), n = "", o++;
762
+ else if (s === "\\" && o + 1 < e.length && !cr.test(e[o + 1])) {
763
+ let t = lr(e, o + 1);
764
+ n += t.text, o = t.next;
765
+ } else n += s, o++;
766
+ }
730
767
  return t.push(n.trim()), t.filter(Boolean);
731
768
  }
732
- function ir(e, t, n) {
769
+ function dr(e, t, n) {
733
770
  let r;
734
771
  for (let i of e.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/([^{}]*)\{([^{}]*)\}/g)) {
735
772
  let e = i[1].split(",").map((e) => e.trim().toLowerCase()).find((e) => n.test(e));
@@ -741,7 +778,7 @@ function ir(e, t, n) {
741
778
  let e = t.get(c[1]);
742
779
  o = e ?? c[2] ?? "", e !== void 0 && (s = c[1]);
743
780
  }
744
- let l = rr(o), u = l.find((e) => !tr.has(e.toLowerCase()) && !e.startsWith("var("));
781
+ let l = ur(o), u = l.find((e) => !ar.has(e.toLowerCase()) && !e.startsWith("var("));
745
782
  u && (r = {
746
783
  family: u,
747
784
  stack: l,
@@ -751,21 +788,21 @@ function ir(e, t, n) {
751
788
  }
752
789
  return r;
753
790
  }
754
- function ar(e) {
755
- let t = e.stack.find((e) => nr.has(e.toLowerCase()));
791
+ function fr(e) {
792
+ let t = e.stack.find((e) => or.has(e.toLowerCase()));
756
793
  return [e.family, (t ?? "sans-serif").toLowerCase()];
757
794
  }
758
795
  // src/core/init/from-site/sections/fonts.ts
759
- function or(e) {
760
- let { destDir: t, page: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = ir(n.css, r, /^(body|html)$/), u = ir(n.css, r, /^h[1-6]$/), d = [];
796
+ function pr(e) {
797
+ let { destDir: t, page: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = dr(n.css, r, /^(body|html)$/), u = dr(n.css, r, /^h[1-6]$/), d = [];
761
798
  if (!l && !u) i.missing.push("no font: no body or heading rule in the stylesheets names a font-family");
762
- else if (c(Gn("tokens", "typography.json"))) {
763
- let e = O.join(t, "tokens", "typography.json"), n = cn(e), r = (n.font ??= {}).family ??= {}, c = l ?? u, f = [["body", c], ["display", u ?? c]];
799
+ else if (c(Yn("tokens", "typography.json"))) {
800
+ let e = O.join(t, "tokens", "typography.json"), n = fn(e), r = (n.font ??= {}).family ??= {}, c = l ?? u, f = [["body", c], ["display", u ?? c]];
764
801
  for (let [e, t] of f) {
765
- let n = er(t.family);
802
+ let n = ir(t.family);
766
803
  n ? d.includes(n) || d.push(n) : i.missing.push(`the font ${t.family} is not one blazon knows a stylesheet for: add its stylesheet to fonts in blazon.json`), r[e] = {
767
- $value: ar(t),
768
- $extensions: un({
804
+ $value: fr(t),
805
+ $extensions: mn({
769
806
  source: s(t.cssVar ? `${t.locator}, from ${t.cssVar}` : t.locator),
770
807
  review: n ? o : {
771
808
  status: "needs-review",
@@ -775,23 +812,23 @@ function or(e) {
775
812
  };
776
813
  }
777
814
  let p = r.mono;
778
- p && Mn(p, `${a} Still blazon's mono font: the site's stylesheets named no monospace font. Set the brand's own.`), ln(e, n), i.written.push(Gn("tokens", "typography.json"));
815
+ p && In(p, `${a} Still blazon's mono font: the site's stylesheets named no monospace font. Set the brand's own.`), pn(e, n), i.written.push(Yn("tokens", "typography.json"));
779
816
  }
780
817
  return { fontUrls: d };
781
818
  }
782
819
  // src/core/init/from-site/sections/intro.ts
783
- var sr = (e) => e.length === 1 && e[0] === "logo", cr = (e) => e.length < 2 ? e.join("") : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
784
- function lr(e) {
820
+ var mr = (e) => e.length === 1 && e[0] === "logo", hr = (e) => e.length < 2 ? e.join("") : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
821
+ function gr(e) {
785
822
  let { url: t, date: n, result: r } = e, i = {
786
823
  colors: r.written.includes("tokens/colors.json"),
787
824
  fonts: r.written.includes("tokens/typography.json"),
788
825
  logo: r.written.some((e) => e.startsWith("assets/logos/"))
789
826
  }, a = Object.entries(i).filter(([, e]) => e).map(([e]) => e), o = Object.entries(i).filter(([, e]) => !e).map(([e]) => e);
790
827
  if (a.length === 0) return `Nothing could be read from ${t} on ${n}: it gave no brand colors, no fonts and no logo. This brand book is still blazon's own starter, so replace its colors, fonts and logo with the brand's.`;
791
- let s = `The ${cr(a)} in this brand book ${sr(a) ? "was" : "were"} read from ${t} on ${n}. They are what the site shows today, so the brand owner needs to confirm them before anyone relies on them.`;
792
- return o.length === 0 ? s : `${s} The ${cr(o)} ${sr(o) ? "was" : "were"} not found, so ${sr(o) ? "it is" : "they are"} still blazon's own starter: replace ${sr(o) ? "it" : "them"}.`;
828
+ let s = `The ${hr(a)} in this brand book ${mr(a) ? "was" : "were"} read from ${t} on ${n}. They are what the site shows today, so the brand owner needs to confirm them before anyone relies on them.`;
829
+ return o.length === 0 ? s : `${s} The ${hr(o)} ${mr(o) ? "was" : "were"} not found, so ${mr(o) ? "it is" : "they are"} still blazon's own starter: replace ${mr(o) ? "it" : "them"}.`;
793
830
  }
794
- function ur(e, t, n) {
831
+ function _r(e, t, n) {
795
832
  let { destDir: r, url: i, created: a, result: o } = e, s = "docs/01-principles.md";
796
833
  if (a.has(s) && k.existsSync(O.join(r, s))) {
797
834
  let a = t ?? new URL(i).hostname.replace(/^www\./, ""), c = [
@@ -806,19 +843,19 @@ function ur(e, t, n) {
806
843
  `# ${a}`,
807
844
  "",
808
845
  ...n ? [n, ""] : [],
809
- lr(e),
846
+ gr(e),
810
847
  ""
811
848
  ];
812
849
  k.writeFileSync(O.join(r, s), c.join("\n")), o.written.push(s);
813
850
  }
814
851
  }
815
852
  // src/core/init/shared/svg.ts
816
- function dr(e) {
853
+ function vr(e) {
817
854
  let t = e.replace(/<script\b[\s\S]*?<\/script>/gi, "").replace(/\son\w+\s*=\s*(?:"[^"]*"|'[^']*')/gi, "").replace(/(href\s*=\s*["'])\s*javascript:[^"']*/gi, "$1#");
818
855
  return /<svg\b[^>]*\sxmlns\s*=/i.test(t) || (t = t.replace(/<svg\b/i, "<svg xmlns=\"http://www.w3.org/2000/svg\"")), `${t.trim()}\n`;
819
856
  }
820
857
  // src/core/init/from-site/logo.ts
821
- function fr(e, t) {
858
+ function yr(e, t) {
822
859
  let n = e.replace(/<!--[\s\S]*?-->/g, "").match(/<header\b[^>]*>([\s\S]*?)<\/header>/i)?.[1];
823
860
  if (!n) return;
824
861
  let r = [];
@@ -867,7 +904,7 @@ function fr(e, t) {
867
904
  locator: "header img"
868
905
  } : void 0;
869
906
  }
870
- function pr(e, t) {
907
+ function br(e, t) {
871
908
  let n = [];
872
909
  for (let [r] of e.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<link\b[^>]*>/gi)) {
873
910
  let e = (V(r, "rel") ?? "").toLowerCase().split(/\s+/), i = e.includes("apple-touch-icon") || e.includes("apple-touch-icon-precomposed");
@@ -888,14 +925,14 @@ function pr(e, t) {
888
925
  }
889
926
  return n.find((e) => e.svg) ?? n.find((e) => e.apple) ?? n[0];
890
927
  }
891
- function mr(e) {
928
+ function xr(e) {
892
929
  let t = new URL(e).hostname.replace(/^www\./, "");
893
930
  return /^[\d.]+$/.test(t) || t.includes(":") || t.startsWith("[") ? "site" : t.split(".")[0].replace(/[^a-z0-9-]/gi, "-").toLowerCase() || "site";
894
931
  }
895
932
  // src/core/init/from-site/sections/logo.ts
896
- async function hr(e) {
897
- let { destDir: t, url: n, date: r, page: i, result: a, note: o, review: s } = e, c = {}, l = mr(n), u = (e, i, c) => {
898
- ln(O.join(t, e.replace(/\.[a-z]+$/, ".json")), {
933
+ async function Sr(e) {
934
+ let { destDir: t, url: n, date: r, page: i, result: a, note: o, review: s } = e, c = {}, l = xr(n), u = (e, i, c) => {
935
+ pn(O.join(t, e.replace(/\.[a-z]+$/, ".json")), {
899
936
  description: o,
900
937
  ...c,
901
938
  source: {
@@ -907,24 +944,24 @@ async function hr(e) {
907
944
  }, d = (e, n) => {
908
945
  let r = O.join(t, e), i = [e, e.replace(/\.[a-z]+$/, ".json")].filter((e) => k.existsSync(O.join(t, e)));
909
946
  return i.length > 0 ? (a.missing.push(`${i.join(" and ")} already existed, so ${i.length > 1 ? "they were" : "it was"} kept as ${i.length > 1 ? "they were" : "it was"}, and no logo was written to ${e}`), !1) : (k.mkdirSync(O.dirname(r), { recursive: !0 }), k.writeFileSync(r, n), a.written.push(e), !0);
910
- }, f = fr(i.html, n), p, m = "";
947
+ }, f = yr(i.html, n), p, m = "";
911
948
  if (f?.kind === "inline") p = f.svg, m = f.locator;
912
949
  else if (f?.kind === "url") {
913
950
  try {
914
- p = (await tn(f.url)).toString("utf8"), m = `${f.locator} (${f.url})`;
951
+ p = (await on(f.url)).toString("utf8"), m = `${f.locator} (${f.url})`;
915
952
  } catch (e) {
916
953
  a.missing.push(`the header logo could not be read: ${e instanceof Error ? e.message : String(e)}`);
917
954
  }
918
955
  p !== void 0 && !/<svg\b/i.test(p) && (p = void 0, a.missing.push(`${f.url} is not an SVG`));
919
956
  }
920
957
  let h;
921
- if (p === void 0 && (h = pr(i.html, n), h?.svg)) try {
922
- p = (await tn(h.url)).toString("utf8"), m = `${h.locator} (${h.url})`, /<svg\b/i.test(p) || (p = void 0);
958
+ if (p === void 0 && (h = br(i.html, n), h?.svg)) try {
959
+ p = (await on(h.url)).toString("utf8"), m = `${h.locator} (${h.url})`, /<svg\b/i.test(p) || (p = void 0);
923
960
  } catch (e) {
924
961
  a.missing.push(`the icon could not be read: ${e instanceof Error ? e.message : String(e)}`);
925
962
  }
926
963
  if (p !== void 0) {
927
- let e = dr(p);
964
+ let e = vr(p);
928
965
  if (/<use\b/i.test(e) && !/<symbol\b/i.test(e) && a.missing.push("the logo uses <use> to point at a sprite elsewhere on the page, so it may draw nothing: check it"), /currentColor/i.test(e)) {
929
966
  let t = `assets/logos/${l}.svg`, n = `assets/logos/${l}-white.svg`;
930
967
  d(t, e.replace(/currentColor/gi, "#111111")) && (u(t, m, {
@@ -951,7 +988,7 @@ async function hr(e) {
951
988
  ].includes(h.ext)) a.missing.push(`only a ${h.ext} icon was found (${h.url}), which blazon cannot show: no logo was written`);
952
989
  else try {
953
990
  let e = `assets/logos/${l}${h.ext === ".jpeg" ? ".jpg" : h.ext}`;
954
- d(e, await tn(h.url)) && (u(e, h.locator, { title: "Site icon" }), c.single = `./${e}`, a.missing.push(`no SVG logo was found: ${e} is the site's raster icon (${h.url}), not a logo, so replace it with the real one`));
991
+ d(e, await on(h.url)) && (u(e, h.locator, { title: "Site icon" }), c.single = `./${e}`, a.missing.push(`no SVG logo was found: ${e} is the site's raster icon (${h.url}), not a logo, so replace it with the real one`));
955
992
  } catch (e) {
956
993
  a.missing.push(`the icon could not be read: ${e instanceof Error ? e.message : String(e)}`);
957
994
  }
@@ -959,28 +996,28 @@ async function hr(e) {
959
996
  return c;
960
997
  }
961
998
  // src/core/init/from-site/sections/placeholder.ts
962
- function gr(e, t, n) {
999
+ function Cr(e, t, n) {
963
1000
  let { destDir: r, created: i, result: a } = e, o = t.single ?? t.onLight;
964
1001
  if (n && o) {
965
- let e = O.join(r, `assets/logos/${Rn[0]}.json`), t = O.join(r, o.replace(/^\.\//, "").replace(/\.[a-z]+$/, ".json"));
966
- if (i.has(`assets/logos/${Rn[0]}.json`) && k.existsSync(e) && k.existsSync(t)) {
967
- let { description: n, background: i, ...a } = cn(e), s = cn(t), c = k.readFileSync(O.join(r, o.replace(/^\.\//, "")), "utf-8").match(/<svg\b[^>]*>/i)?.[0] ?? "", l = c.match(/viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+[\d.]+[\s,]+([\d.]+)/i)?.[1] ?? c.match(/\sheight\s*=\s*["']?([\d.]+)/i)?.[1];
1002
+ let e = O.join(r, `assets/logos/${Hn[0]}.json`), t = O.join(r, o.replace(/^\.\//, "").replace(/\.[a-z]+$/, ".json"));
1003
+ if (i.has(`assets/logos/${Hn[0]}.json`) && k.existsSync(e) && k.existsSync(t)) {
1004
+ let { description: n, background: i, ...a } = fn(e), s = fn(t), c = k.readFileSync(O.join(r, o.replace(/^\.\//, "")), "utf-8").match(/<svg\b[^>]*>/i)?.[0] ?? "", l = c.match(/viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+[\d.]+[\s,]+([\d.]+)/i)?.[1] ?? c.match(/\sheight\s*=\s*["']?([\d.]+)/i)?.[1];
968
1005
  l && Number(l) > 0 && (a.clearSpace = {
969
1006
  value: Math.max(1, Math.round(Number(l) * .3 * 100) / 100),
970
1007
  unit: "px"
971
1008
  });
972
1009
  for (let [e, t] of Object.entries(a)) s[e] ??= t;
973
- s.description = `${String(s.description)} Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.`, ln(t, s);
1010
+ s.description = `${String(s.description)} Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.`, pn(t, s);
974
1011
  }
975
- for (let e of zn) for (let t of ["svg", "json"]) {
1012
+ for (let e of Un) for (let t of ["svg", "json"]) {
976
1013
  let n = `assets/logos/${e}.${t}`;
977
1014
  i.has(n) && (k.rmSync(O.join(r, n), { force: !0 }), a.removed.push(`${n} (blazon's own logo)`));
978
1015
  }
979
1016
  }
980
1017
  }
981
1018
  // src/core/init/from-site/apply.ts
982
- async function _r(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
983
- let a = r.toISOString().slice(0, 10), o = i.page ?? await on(t), s = {
1019
+ async function wr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
1020
+ let a = r.toISOString().slice(0, 10), o = i.page ?? await un(t), s = {
984
1021
  written: [],
985
1022
  missing: [],
986
1023
  removed: [],
@@ -991,7 +1028,7 @@ async function _r(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
991
1028
  date: a,
992
1029
  created: n,
993
1030
  page: o,
994
- vars: Zt(o.css),
1031
+ vars: tn(o.css),
995
1032
  result: s,
996
1033
  note: c,
997
1034
  review: {
@@ -1005,23 +1042,23 @@ async function _r(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
1005
1042
  }),
1006
1043
  mayChange: (e) => n.has(e) ? !0 : (s.missing.push(`${e} already existed, so it was kept as it was`), !1)
1007
1044
  };
1008
- Kn(l, i.skipVars);
1009
- let u = or(l), d = await hr(l), { title: f, description: p, configLogo: m } = await Xn(l, d, u);
1010
- return gr(l, d, m), ur(l, f, p), Qn(l), s;
1045
+ Xn(l, i.skipVars);
1046
+ let u = pr(l), d = await Sr(l), { title: f, description: p, configLogo: m } = await er(l, d, u);
1047
+ return Cr(l, d, m), _r(l, f, p), nr(l), s;
1011
1048
  }
1012
1049
  // src/core/init/from-site/inspect.ts
1013
- async function vr(e) {
1014
- let t = await on(e), n = Zt(t.css), r = Un(n), i = ir(t.css, n, /^(body|html)$/), a = ir(t.css, n, /^h[1-6]$/), o = [];
1050
+ async function Tr(e) {
1051
+ let t = await un(e), n = tn(t.css), r = qn(n), i = dr(t.css, n, /^(body|html)$/), a = dr(t.css, n, /^h[1-6]$/), o = [];
1015
1052
  i && o.push({
1016
1053
  family: i.family,
1017
1054
  role: "body",
1018
- stylesheet: !!er(i.family)
1055
+ stylesheet: !!ir(i.family)
1019
1056
  }), a && a.family.toLowerCase() !== i?.family.toLowerCase() && o.push({
1020
1057
  family: a.family,
1021
1058
  role: "headings",
1022
- stylesheet: !!er(a.family)
1059
+ stylesheet: !!ir(a.family)
1023
1060
  });
1024
- let s = fr(t.html, e), c = pr(t.html, e), l = s ? `${s.kind === "inline" ? "an inline SVG" : `an SVG image (${s.url})`} in the page header` : c ? `the site icon (${c.url})${c.svg ? "" : `, a ${c.ext} image, not an SVG logo`}` : void 0, u = H(t.html, "og:site_name") ?? H(t.html, "application-name") ?? await Yn(t.html, e) ?? Jn(t.html), d = [];
1061
+ let s = yr(t.html, e), c = br(t.html, e), l = s ? `${s.kind === "inline" ? "an inline SVG" : `an SVG image (${s.url})`} in the page header` : c ? `the site icon (${c.url})${c.svg ? "" : `, a ${c.ext} image, not an SVG logo`}` : void 0, u = H(t.html, "og:site_name") ?? H(t.html, "application-name") ?? await $n(t.html, e) ?? Qn(t.html), d = [];
1025
1062
  return r.length === 0 && d.push("no brand colors: no custom property named brand, primary, secondary, accent, background, foreground or surface holds a hex or rgb() color"), o.length === 0 && d.push("no font: no body or heading rule names a font-family"), l || d.push("no logo: no SVG in the header and no icon link on the page"), u || d.push("no site name: the brand name stays as you typed it"), {
1026
1063
  page: t,
1027
1064
  name: u,
@@ -1036,23 +1073,23 @@ async function vr(e) {
1036
1073
  };
1037
1074
  }
1038
1075
  // src/core/init/answers.ts
1039
- var yr = [
1076
+ var Er = [
1040
1077
  ".svg",
1041
1078
  ".png",
1042
1079
  ".jpg",
1043
1080
  ".jpeg",
1044
1081
  ".webp"
1045
- ], br = (e) => e.trim() ? { value: e.trim() } : { hint: "A name cannot be empty." }, xr = (e) => e.trim().length <= 240 ? { value: e.trim() } : { hint: "Keep the description to one sentence, 240 characters at most." };
1046
- function Sr(e) {
1047
- let t = e.trim(), n = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t) ? Bn(t.startsWith("#") ? t : `#${t}`) : void 0;
1082
+ ], Dr = (e) => e.trim() ? { value: e.trim() } : { hint: "A name cannot be empty." }, Or = (e) => e.trim().length <= 240 ? { value: e.trim() } : { hint: "Keep the description to one sentence, 240 characters at most." };
1083
+ function kr(e) {
1084
+ let t = e.trim(), n = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t) ? Wn(t.startsWith("#") ? t : `#${t}`) : void 0;
1048
1085
  return n ? { value: n.hex } : { hint: "Give the color as hex, for example #2563eb or #26e." };
1049
1086
  }
1050
- var Cr = (e) => /^[A-Za-z0-9][A-Za-z0-9 -]{0,60}$/.test(e.trim()) ? { value: e.trim() } : { hint: "Give a font family name, for example Inter or DM Sans." };
1051
- function wr(e, t = process.cwd()) {
1087
+ var Ar = (e) => /^[A-Za-z0-9][A-Za-z0-9 -]{0,60}$/.test(e.trim()) ? { value: e.trim() } : { hint: "Give a font family name, for example Inter or DM Sans." };
1088
+ function jr(e, t = process.cwd()) {
1052
1089
  let n = O.resolve(t, e.trim());
1053
- return yr.includes(O.extname(n).toLowerCase()) ? !k.existsSync(n) || !k.statSync(n).isFile() ? { hint: `There is no file at ${n}. Check the path, or press Enter to skip the logo.` } : { value: n } : { hint: "The logo must be an SVG or PNG file (JPG and WebP also work)." };
1090
+ return Er.includes(O.extname(n).toLowerCase()) ? !k.existsSync(n) || !k.statSync(n).isFile() ? { hint: `There is no file at ${n}. Check the path, or press Enter to skip the logo.` } : { value: n } : { hint: "The logo must be an SVG or PNG file (JPG and WebP also work)." };
1054
1091
  }
1055
- function Tr(e) {
1092
+ function Mr(e) {
1056
1093
  let t = k.readFileSync(e), n = O.extname(e).toLowerCase() === ".svg";
1057
1094
  return {
1058
1095
  bytes: t.length,
@@ -1060,20 +1097,20 @@ function Tr(e) {
1060
1097
  usesCurrentColor: n && /currentColor/i.test(t.toString("utf8"))
1061
1098
  };
1062
1099
  }
1063
- var Er = (e) => /^https?:\/\/[^\s/]/i.test(e);
1064
- function Dr(e, t, n) {
1100
+ var Nr = (e) => /^https?:\/\/[^\s/]/i.test(e);
1101
+ function Pr(e, t, n) {
1065
1102
  let r = {
1066
1103
  set: [],
1067
1104
  hints: [],
1068
1105
  files: []
1069
- }, i = (e) => r.hints.push(`${e} already existed, so it was kept as it was`), a = O.join(e, "blazon.json"), o = n.has("blazon.json") ? Fn(a) : void 0, s = o === void 0 ? void 0 : JSON.stringify(o), c = (e) => (o === void 0 && i(`blazon.json (${e} not set)`), o !== void 0);
1106
+ }, i = (e) => r.hints.push(`${e} already existed, so it was kept as it was`), a = O.join(e, "blazon.json"), o = n.has("blazon.json") ? zn(a) : void 0, s = o === void 0 ? void 0 : JSON.stringify(o), c = (e) => (o === void 0 && i(`blazon.json (${e} not set)`), o !== void 0);
1070
1107
  if (t.name !== void 0 && c("name") && (o.title = t.name, r.set.push(`name "${t.name}"`)), t.description && c("description") && (o.description = t.description, r.set.push("description")), t.color !== void 0) {
1071
1108
  let a = O.join(e, "tokens", "colors.json");
1072
1109
  if (!n.has("tokens/colors.json")) i("tokens/colors.json");
1073
1110
  else {
1074
1111
  let e = JSON.parse(k.readFileSync(a, "utf-8"));
1075
1112
  if (B(e, "color.signal.orange")) {
1076
- let n = Nn(e, t.color);
1113
+ let n = Ln(e, t.color);
1077
1114
  k.writeFileSync(a, `${JSON.stringify(e, null, 2)}\n`), r.files.push("tokens/colors.json"), r.set.push(`primary color ${t.color} (color.signal.primary, which interactive.primary uses)`), r.hints.push(...n.hints);
1078
1115
  } else r.hints.push("color.signal.orange was not found in tokens/colors.json, so the color was not set");
1079
1116
  }
@@ -1086,9 +1123,9 @@ function Dr(e, t, n) {
1086
1123
  if (n && i) {
1087
1124
  n.$value = [t.font, "sans-serif"], i.$value = [t.font, "sans-serif"];
1088
1125
  let s = B(e, "font.family.mono");
1089
- s && Mn(s, "Still blazon's mono font: it was not chosen to go with your font. Set the brand's own."), k.writeFileSync(a, `${JSON.stringify(e, null, 2)}\n`), r.files.push("tokens/typography.json");
1090
- let l = er(t.font);
1091
- l && c("font stylesheet") ? (o.fonts = Ln(o.fonts, [l]), r.set.push(`font ${t.font} (font.family.display and font.family.body)`)) : l || (r.set.push(`font ${t.font} (font.family.display and font.family.body)`), r.hints.push(`${t.font} is not a font blazon knows a stylesheet for: add its stylesheet to fonts in blazon.json`)), r.hints.push("font.family.mono and the type scale are still blazon's: set the brand's own");
1126
+ s && In(s, "Still blazon's mono font: it was not chosen to go with your font. Set the brand's own."), k.writeFileSync(a, `${JSON.stringify(e, null, 2)}\n`), r.files.push("tokens/typography.json");
1127
+ let l = ir(t.font);
1128
+ l && c("font stylesheet") ? (o.fonts = Vn(o.fonts, [l]), r.set.push(`font ${t.font} (font.family.display and font.family.body)`)) : l || (r.set.push(`font ${t.font} (font.family.display and font.family.body)`), r.hints.push(`${t.font} is not a font blazon knows a stylesheet for: add its stylesheet to fonts in blazon.json`)), r.hints.push("font.family.mono and the type scale are still blazon's: set the brand's own");
1092
1129
  } else r.hints.push("font.family.display and font.family.body were not found in tokens/typography.json, so the font was not set");
1093
1130
  }
1094
1131
  }
@@ -1098,25 +1135,25 @@ function Dr(e, t, n) {
1098
1135
  for (let e of l) i(`assets/logos/${e}`);
1099
1136
  r.hints.push(`the logo ${t.logo} was not copied: pick another file name, or remove the existing file`);
1100
1137
  } else {
1101
- let e = O.join(c, `${Rn[0]}.json`), i = {};
1102
- if (n.has(`assets/logos/${Rn[0]}.json`) && k.existsSync(e)) {
1138
+ let e = O.join(c, `${Hn[0]}.json`), i = {};
1139
+ if (n.has(`assets/logos/${Hn[0]}.json`) && k.existsSync(e)) {
1103
1140
  let { description: t, background: n, ...r } = JSON.parse(k.readFileSync(e, "utf-8"));
1104
1141
  i = r;
1105
1142
  }
1106
- for (let e of zn) for (let t of ["svg", "json"]) n.has(`assets/logos/${e}.${t}`) && k.rmSync(O.join(c, `${e}.${t}`), { force: !0 });
1143
+ for (let e of Un) for (let t of ["svg", "json"]) n.has(`assets/logos/${e}.${t}`) && k.rmSync(O.join(c, `${e}.${t}`), { force: !0 });
1107
1144
  k.mkdirSync(c, { recursive: !0 });
1108
1145
  let l = k.readFileSync(t.logo);
1109
- k.writeFileSync(O.join(c, a), a.toLowerCase().endsWith(".svg") ? dr(l.toString("utf8")) : l), k.writeFileSync(O.join(c, `${s}.json`), `${JSON.stringify({
1146
+ k.writeFileSync(O.join(c, a), a.toLowerCase().endsWith(".svg") ? vr(l.toString("utf8")) : l), k.writeFileSync(O.join(c, `${s}.json`), `${JSON.stringify({
1110
1147
  title: "Logo",
1111
1148
  description: "The brand's logo. Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.",
1112
1149
  ...i
1113
1150
  }, null, 2)}\n`), o.logo = `./assets/logos/${a}`, r.files.push(`assets/logos/${a}`, `assets/logos/${s}.json`), r.set.push(`logo ${a}`);
1114
1151
  }
1115
1152
  }
1116
- return o !== void 0 && JSON.stringify(o) !== s && (In(a, o), r.files.push("blazon.json")), r;
1153
+ return o !== void 0 && JSON.stringify(o) !== s && (Bn(a, o), r.files.push("blazon.json")), r;
1117
1154
  }
1118
1155
  // src/core/init/prompts.ts
1119
- var Or = class extends Error {
1156
+ var Fr = class extends Error {
1120
1157
  constructor() {
1121
1158
  super("cancelled"), this.name = "PromptCancelled";
1122
1159
  }
@@ -1130,33 +1167,33 @@ function U(e, t) {
1130
1167
  }).join("\n");
1131
1168
  }
1132
1169
  var W = () => Math.max(30, (process.stdout.columns ?? 80) - 6);
1133
- function kr(e) {
1134
- if (A.isCancel(e)) throw new Or();
1170
+ function Ir(e) {
1171
+ if (A.isCancel(e)) throw new Fr();
1135
1172
  return e;
1136
1173
  }
1137
- function Ar() {
1174
+ function Lr() {
1138
1175
  return {
1139
1176
  intro: (e) => A.intro(e),
1140
1177
  outro: (e) => A.outro(e),
1141
1178
  cancel: (e) => A.cancel(e),
1142
- text: async (e) => kr(await A.text({
1179
+ text: async (e) => Ir(await A.text({
1143
1180
  message: e.message,
1144
1181
  placeholder: e.placeholder,
1145
1182
  defaultValue: e.defaultValue,
1146
1183
  validate: e.validate && ((t) => e.validate(t ?? ""))
1147
1184
  })) ?? "",
1148
- select: async (e) => kr(await A.select({
1185
+ select: async (e) => Ir(await A.select({
1149
1186
  message: e.message,
1150
1187
  options: e.options,
1151
1188
  initialValue: e.initialValue
1152
1189
  })),
1153
- multiselect: async (e) => kr(await A.multiselect({
1190
+ multiselect: async (e) => Ir(await A.multiselect({
1154
1191
  message: e.message,
1155
1192
  options: e.options,
1156
1193
  initialValues: e.initialValues,
1157
1194
  required: !1
1158
1195
  })),
1159
- confirm: async (e) => kr(await A.confirm({
1196
+ confirm: async (e) => Ir(await A.confirm({
1160
1197
  message: e.message,
1161
1198
  initialValue: e.initialValue
1162
1199
  })),
@@ -1180,15 +1217,15 @@ function Ar() {
1180
1217
  };
1181
1218
  }
1182
1219
  // src/cli/init-ui.ts
1183
- function jr(e = process.env, t = !!process.stdout.isTTY) {
1184
- let n = w(e, t, []);
1220
+ function Rr(e = process.env, t = !!process.stdout.isTTY) {
1221
+ let n = s(e, t, []);
1185
1222
  return {
1186
1223
  color: n,
1187
1224
  truecolor: n && /^(truecolor|24bit)$/i.test(e.COLORTERM ?? "")
1188
1225
  };
1189
1226
  }
1190
- function Mr(e, t) {
1191
- let [n, r, i] = (yn(e) ?? [
1227
+ function zr(e, t) {
1228
+ let [n, r, i] = (Cn(e) ?? [
1192
1229
  0,
1193
1230
  0,
1194
1231
  0
@@ -1197,62 +1234,62 @@ function Mr(e, t) {
1197
1234
  let a = (e) => Math.round(e / 255 * 5);
1198
1235
  return `\x1b[48;5;${16 + 36 * a(n) + 6 * a(r) + a(i)}m`;
1199
1236
  }
1200
- function Nr(e, t, n = 2) {
1201
- return t.color ? `${Mr(e, t)}${" ".repeat(n)}\x1b[0m` : `[${e}]`;
1237
+ function Br(e, t, n = 2) {
1238
+ return t.color ? `${zr(e, t)}${" ".repeat(n)}\x1b[0m` : `[${e}]`;
1202
1239
  }
1203
- var Pr = {
1240
+ var Vr = {
1204
1241
  AAA: "AAA",
1205
1242
  AA: "AA",
1206
1243
  "AA-large": "AA for large text only",
1207
1244
  fail: "below AA"
1208
- }, Fr = (e) => `${e.toFixed(1)}:1`;
1209
- function Ir(e, t, n = wn(e)) {
1245
+ }, Hr = (e) => `${e.toFixed(1)}:1`;
1246
+ function Ur(e, t, n = On(e)) {
1210
1247
  let r = (e) => e === "AAA" || e === "AA" ? "yes" : "no";
1211
1248
  return [
1212
- `${Nr(e, t, 4)} ${e}`,
1213
- `AA for text on white: ${r(n.onWhite.level)} (${Fr(n.onWhite.ratio)}, ${Pr[n.onWhite.level]})`,
1214
- `AA for text on near-black: ${r(n.onNearBlack.level)} (${Fr(n.onNearBlack.ratio)}, ${Pr[n.onNearBlack.level]})`
1249
+ `${Br(e, t, 4)} ${e}`,
1250
+ `AA for text on white: ${r(n.onWhite.level)} (${Hr(n.onWhite.ratio)}, ${Vr[n.onWhite.level]})`,
1251
+ `AA for text on near-black: ${r(n.onNearBlack.level)} (${Hr(n.onNearBlack.ratio)}, ${Vr[n.onNearBlack.level]})`
1215
1252
  ];
1216
1253
  }
1217
- function Lr(e) {
1218
- let { ink: t, ratio: n, aa: r } = Dn(e);
1254
+ function Wr(e) {
1255
+ let { ink: t, ratio: n, aa: r } = jn(e);
1219
1256
  return r ? `Labels on ${e} will be ${t} (${n.toFixed(1)}:1).` : `Neither graphite nor bone reaches AA (4.5:1) as a label on ${e} (best is ${t} at ${n.toFixed(1)}:1). blazon check will report it; a lighter or darker color fixes that.`;
1220
1257
  }
1221
- var Rr = (e, t, n) => `${e} of ${t} ${n}`;
1222
- function zr(e) {
1258
+ var Gr = (e, t, n) => `${e} of ${t} ${n}`;
1259
+ function Kr(e) {
1223
1260
  return e < 1024 ? `${e} bytes` : `${(e / 1024).toFixed(1)} KB`;
1224
1261
  }
1225
1262
  // src/cli/init-flow.ts
1226
- var Br = 4;
1263
+ var qr = 4;
1227
1264
  function G(e, t, n, r) {
1228
- return e.log.message(r.color ? s.dim(n) : n), t;
1265
+ return e.log.message(r.color ? a.dim(n) : n), t;
1229
1266
  }
1230
- function Vr(e) {
1267
+ function Jr(e) {
1231
1268
  return (t) => {
1232
1269
  if (t.trim() === "") return;
1233
1270
  let n = e(t);
1234
1271
  return "hint" in n ? n.hint : void 0;
1235
1272
  };
1236
1273
  }
1237
- var Hr = (e, t) => {
1274
+ var Yr = (e, t) => {
1238
1275
  let n = t.trim() === "" ? void 0 : e(t);
1239
1276
  return n && "value" in n ? n.value : void 0;
1240
1277
  };
1241
- async function Ur(e) {
1278
+ async function Xr(e) {
1242
1279
  let { prompter: t, look: n } = e, r = {};
1243
- t.intro(n.color ? s.bold(`blazon init ${s.dim(e.dir)}`) : `blazon init ${e.dir}`), e.kept && t.log.warn(`${e.kept} starter ${e.kept === 1 ? "file is" : "files are"} already in this folder and ${e.kept === 1 ? "is" : "are"} kept as ${e.kept === 1 ? "it is" : "they are"}. Only missing files are added.`), t.log.step(Rr(1, Br, "Brand"));
1280
+ t.intro(n.color ? a.bold(`blazon init ${a.dim(e.dir)}`) : `blazon init ${e.dir}`), e.kept && t.log.warn(`${e.kept} starter ${e.kept === 1 ? "file is" : "files are"} already in this folder and ${e.kept === 1 ? "is" : "are"} kept as ${e.kept === 1 ? "it is" : "they are"}. Only missing files are added.`), t.log.step(Gr(1, qr, "Brand"));
1244
1281
  let i = (await t.text({
1245
1282
  message: G(t, "Brand name", "The title of the brand book. Enter keeps the name taken from the folder.", n),
1246
1283
  placeholder: "from the folder name",
1247
1284
  validate: () => void 0
1248
1285
  })).trim();
1249
1286
  i && (r.name = i);
1250
- let a = (await t.text({
1287
+ let o = (await t.text({
1251
1288
  message: G(t, "One-line description", "What the brand is, in a sentence. It goes in the config and opens the intro page. Enter skips it.", n),
1252
1289
  placeholder: "what the brand is, in one sentence",
1253
- validate: (e) => "hint" in xr(e) ? "Keep it to one sentence, 240 characters at most." : void 0
1290
+ validate: (e) => "hint" in Or(e) ? "Keep it to one sentence, 240 characters at most." : void 0
1254
1291
  })).trim();
1255
- if (a && (r.description = a), await t.select({
1292
+ if (o && (r.description = o), await t.select({
1256
1293
  message: G(t, "Where should the colors, fonts and logo come from?", "Reading a live site fills them in for you to review before anything is written.", n),
1257
1294
  options: [{
1258
1295
  value: "manual",
@@ -1264,36 +1301,36 @@ async function Ur(e) {
1264
1301
  hint: "you review what was found first"
1265
1302
  }]
1266
1303
  }) === "site") {
1267
- let n = await Wr(e);
1304
+ let n = await Zr(e);
1268
1305
  if (n) return {
1269
1306
  answers: r,
1270
1307
  site: n
1271
1308
  };
1272
1309
  t.log.info("Nothing from a site will be written. Giving the values here instead.");
1273
1310
  }
1274
- t.log.step(Rr(2, Br, "Colors"));
1275
- let o = Hr(Sr, (await t.text({
1311
+ t.log.step(Gr(2, qr, "Colors"));
1312
+ let s = Yr(kr, (await t.text({
1276
1313
  message: G(t, "Primary color", "Hex, for example #2563eb. Buttons and links use it. Enter keeps the orange it starts with.", n),
1277
1314
  placeholder: "#2563eb",
1278
- validate: Vr(Sr)
1315
+ validate: Jr(kr)
1279
1316
  })).trim());
1280
- o && (r.color = o, t.log.info(Ir(o, n).join("\n")), t.log.info(Lr(o))), t.log.step(Rr(3, Br, "Type"));
1281
- let c = Hr(Cr, (await t.text({
1317
+ s && (r.color = s, t.log.info(Ur(s, n).join("\n")), t.log.info(Wr(s))), t.log.step(Gr(3, qr, "Type"));
1318
+ let c = Yr(Ar, (await t.text({
1282
1319
  message: G(t, "Font family", "A Google Fonts name, for example Inter. Enter keeps the fonts it starts with.", n),
1283
1320
  placeholder: "Inter",
1284
- validate: Vr(Cr)
1321
+ validate: Jr(Ar)
1285
1322
  })).trim());
1286
- c && (r.font = c, er(c) ? t.log.success(`${c} is on Google Fonts. Its stylesheet will be added to fonts in blazon.json.`) : t.log.warn(`${c} is not in blazon's short list of Google Fonts, so only the font name is written. Add its stylesheet to fonts in blazon.json.`)), t.log.step(Rr(4, Br, "Logo"));
1287
- let l = Hr((e) => wr(e), (await t.text({
1323
+ c && (r.font = c, ir(c) ? t.log.success(`${c} is on Google Fonts. Its stylesheet will be added to fonts in blazon.json.`) : t.log.warn(`${c} is not in blazon's short list of Google Fonts, so only the font name is written. Add its stylesheet to fonts in blazon.json.`)), t.log.step(Gr(4, qr, "Logo"));
1324
+ let l = Yr((e) => jr(e), (await t.text({
1288
1325
  message: G(t, "Logo file", "The path to an SVG or PNG. Enter skips it and keeps the logo it starts with.", n),
1289
1326
  placeholder: "./logo.svg",
1290
- validate: Vr((e) => wr(e))
1327
+ validate: Jr((e) => jr(e))
1291
1328
  })).trim());
1292
1329
  if (l) {
1293
1330
  r.logo = l;
1294
- let e = Tr(l), n = O.basename(l);
1331
+ let e = Mr(l), n = O.basename(l);
1295
1332
  t.log.info([
1296
- `${n}: ${e.svg ? "SVG" : "raster image"}, ${zr(e.bytes)}.`,
1333
+ `${n}: ${e.svg ? "SVG" : "raster image"}, ${Kr(e.bytes)}.`,
1297
1334
  "It will be copied to assets/logos/ and replace the starter's placeholder.",
1298
1335
  ...e.usesCurrentColor ? ["It draws in currentColor, so it takes the text color of the page it is on."] : [],
1299
1336
  ...e.svg ? [] : ["A raster logo cannot be recolored; an SVG is better if you have one."]
@@ -1301,13 +1338,13 @@ async function Ur(e) {
1301
1338
  }
1302
1339
  return { answers: r };
1303
1340
  }
1304
- async function Wr(e) {
1305
- let { prompter: t, look: n } = e, r = e.inspect ?? vr;
1341
+ async function Zr(e) {
1342
+ let { prompter: t, look: n } = e, r = e.inspect ?? Tr;
1306
1343
  for (;;) {
1307
1344
  let i = (await t.text({
1308
1345
  message: G(t, "Website address", "Blazon reads its stylesheets and page. It sends no cookies and runs none of the site's scripts.", n),
1309
1346
  placeholder: "https://example.com (leave empty to enter the values by hand)",
1310
- validate: (e) => e.trim() === "" || Er(e.trim()) ? void 0 : "Give the full address, starting with http:// or https://, or leave it empty to enter the values by hand."
1347
+ validate: (e) => e.trim() === "" || Nr(e.trim()) ? void 0 : "Give the full address, starting with http:// or https://, or leave it empty to enter the values by hand."
1311
1348
  })).trim();
1312
1349
  if (i === "") {
1313
1350
  t.log.info("No address given: you can enter the values by hand.");
@@ -1322,7 +1359,7 @@ async function Wr(e) {
1322
1359
  a.error(`Could not read ${i}`), t.log.error(`${e instanceof Error ? e.message : String(e)}\nCheck the address and your connection. The starter is in place, so nothing is lost.`);
1323
1360
  }
1324
1361
  if (o) {
1325
- let t = await Gr(e, i, o);
1362
+ let t = await Qr(e, i, o);
1326
1363
  return t ? {
1327
1364
  url: i,
1328
1365
  findings: o,
@@ -1335,7 +1372,7 @@ async function Wr(e) {
1335
1372
  })) return;
1336
1373
  }
1337
1374
  }
1338
- async function Gr(e, t, n) {
1375
+ async function Qr(e, t, n) {
1339
1376
  let { prompter: r, look: i } = e, a = [];
1340
1377
  n.name && a.push(`Name: ${n.name}`), n.description && a.push(`Description: ${n.description}`);
1341
1378
  for (let e of n.fonts) a.push(`Font (${e.role}): ${e.family}${e.stylesheet ? ", its Google Fonts stylesheet will be added" : ", not in blazon's short list, so add its stylesheet yourself"}`);
@@ -1347,7 +1384,7 @@ async function Gr(e, t, n) {
1347
1384
  message: G(r, "Brand colors found", "Untick any you do not want. Everything written is marked needs-review.", i),
1348
1385
  options: n.colors.map((e) => ({
1349
1386
  value: e.cssVar,
1350
- label: `${Nr(e.hex, i)} ${e.hex} ${e.cssVar}`
1387
+ label: `${Br(e.hex, i)} ${e.hex} ${e.cssVar}`
1351
1388
  })),
1352
1389
  initialValues: n.colors.map((e) => e.cssVar)
1353
1390
  });
@@ -1359,87 +1396,87 @@ async function Gr(e, t, n) {
1359
1396
  }) ? o : void 0;
1360
1397
  }
1361
1398
  // src/cli/commands/init.ts
1362
- var Kr = (e, t, n) => `${e} ${e === 1 ? t : n}`;
1363
- function qr(e, t) {
1399
+ var $r = (e, t, n) => `${e} ${e === 1 ? t : n}`;
1400
+ function ei(e, t) {
1364
1401
  let n = t.map((e) => e.split("/").slice(1));
1365
1402
  if (n.length === 0) return;
1366
- if (e === "docs") return `${Kr(n.length, "page", "pages")}, ${n[0][0]} to ${n[n.length - 1][0]}`;
1367
- if (e === "tokens") return `${Kr(n.length, "file", "files")}: ${n.map((e) => e.join("/")).join(", ")}`;
1403
+ if (e === "docs") return `${$r(n.length, "page", "pages")}, ${n[0][0]} to ${n[n.length - 1][0]}`;
1404
+ if (e === "tokens") return `${$r(n.length, "file", "files")}: ${n.map((e) => e.join("/")).join(", ")}`;
1368
1405
  let r = [...new Set(n.filter((e) => e.length > 1).map((e) => e[0]))];
1369
- return r.length > 0 ? `${Kr(n.length, "file", "files")} in ${Kr(r.length, "folder", "folders")}: ${r.join(", ")}` : `${Kr(n.length, "file", "files")}: ${n.map((e) => e[0]).join(", ")}`;
1406
+ return r.length > 0 ? `${$r(n.length, "file", "files")} in ${$r(r.length, "folder", "folders")}: ${r.join(", ")}` : `${$r(n.length, "file", "files")}: ${n.map((e) => e[0]).join(", ")}`;
1370
1407
  }
1371
- var Jr = /^(brand|book|guidelines|guide)$/i;
1372
- function Yr(e) {
1408
+ var ti = /^(brand|book|guidelines|guide)$/i;
1409
+ function ni(e) {
1373
1410
  let t = O.basename(e).split(/[-_\s]+/).filter(Boolean), n = t.length > 0;
1374
- for (; t.length > 0 && Jr.test(t[t.length - 1]);) t = t.slice(0, -1);
1411
+ for (; t.length > 0 && ti.test(t[t.length - 1]);) t = t.slice(0, -1);
1375
1412
  let r = t.map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
1376
1413
  return r ? `${r} Brand Book` : n ? "Brand Book" : "Blazon Brand Book";
1377
1414
  }
1378
- var Xr = [
1415
+ var ri = [
1379
1416
  [
1380
1417
  "--name",
1381
1418
  "name",
1382
- br
1419
+ Dr
1383
1420
  ],
1384
1421
  [
1385
1422
  "--description",
1386
1423
  "description",
1387
- xr
1424
+ Or
1388
1425
  ],
1389
1426
  [
1390
1427
  "--color",
1391
1428
  "color",
1392
- Sr
1429
+ kr
1393
1430
  ],
1394
1431
  [
1395
1432
  "--font",
1396
1433
  "font",
1397
- Cr
1434
+ Ar
1398
1435
  ],
1399
1436
  [
1400
1437
  "--logo",
1401
1438
  "logo",
1402
- (e) => wr(e)
1439
+ (e) => jr(e)
1403
1440
  ]
1404
1441
  ];
1405
- async function Zr(e = ".", t = {}) {
1442
+ async function ii(e = ".", t = {}) {
1406
1443
  if (t.from !== void 0 && !/^https?:\/\/[^\s/]/i.test(t.from)) {
1407
1444
  let e = `--from needs an http(s) address, got ${JSON.stringify(t.from)}`;
1408
- return console.error(s.red(`blazon init: ${e}`)), t.failure?.({
1445
+ return console.error(a.red(`blazon init: ${e}`)), t.failure?.({
1409
1446
  code: "invalid-option-value",
1410
1447
  message: e
1411
1448
  }), 2;
1412
1449
  }
1413
1450
  let n = {};
1414
- for (let [e, r, i] of Xr) {
1415
- let a = t[r];
1416
- if (a === void 0) continue;
1417
- let o = i(String(a));
1418
- if ("hint" in o) return console.error(s.red(`blazon init: ${e}: ${o.hint}`)), t.failure?.({
1451
+ for (let [e, r, i] of ri) {
1452
+ let o = t[r];
1453
+ if (o === void 0) continue;
1454
+ let s = i(String(o));
1455
+ if ("hint" in s) return console.error(a.red(`blazon init: ${e}: ${s.hint}`)), t.failure?.({
1419
1456
  code: "invalid-option-value",
1420
- message: `${e}: ${o.hint}`
1457
+ message: `${e}: ${s.hint}`
1421
1458
  }), 2;
1422
- n[r] = o.value;
1459
+ n[r] = s.value;
1423
1460
  }
1424
1461
  let r = O.resolve(process.cwd(), e), i = c();
1425
1462
  if (!k.existsSync(i)) throw Error(`Template directory not found at ${i}`);
1426
- let a = t.tty ?? !!(process.stdin.isTTY && process.stdout.isTTY), o = [
1463
+ let o = t.tty ?? !!(process.stdin.isTTY && process.stdout.isTTY), s = [
1427
1464
  t.from,
1428
1465
  t.name,
1429
1466
  t.description,
1430
1467
  t.color,
1431
1468
  t.font,
1432
1469
  t.logo
1433
- ].some((e) => e !== void 0), l = a && !o && !t.yes && t.input !== !1, u = l ? t.prompter ?? Ar() : void 0, d = t.look ?? jr(process.env, a);
1434
- l || console.log(s.cyan(`\n✨ Initializing Blazon Brand Book in ${s.bold(r)}...\n`));
1435
- let f = O.join(r, "blazon.json"), p = k.existsSync(f), m = te(r, i), h = m.kept, g = m.written.map((e) => O.relative(r, e).split(O.sep).join("/")).sort(), _ = new Set(g);
1470
+ ].some((e) => e !== void 0), l = o && !s && !t.yes && t.input !== !1, u = l ? t.prompter ?? Lr() : void 0, d = t.look ?? Rr(process.env, o);
1471
+ l || console.log(a.cyan(`\n✨ Initializing Blazon Brand Book in ${a.bold(r)}...\n`));
1472
+ let f = O.join(r, "blazon.json"), p = k.existsSync(f), m = ie(r, i), h = m.kept, g = m.written.map((e) => O.relative(r, e).split(O.sep).join("/")).sort(), _ = new Set(g);
1436
1473
  t.report?.({
1437
1474
  dir: r,
1438
1475
  created: g,
1439
1476
  kept: h.map((e) => O.relative(r, e).split(O.sep).join("/")).sort()
1440
- }), !p && k.existsSync(f) && In(f, {
1441
- ...Fn(f),
1442
- title: Yr(r),
1477
+ }), !p && k.existsSync(f) && Bn(f, {
1478
+ ...zn(f),
1479
+ title: ni(r),
1443
1480
  description: "Brand guidelines, built from design tokens"
1444
1481
  });
1445
1482
  let v = [];
@@ -1448,66 +1485,66 @@ async function Zr(e = ".", t = {}) {
1448
1485
  "assets",
1449
1486
  "docs"
1450
1487
  ]) {
1451
- let t = qr(e, g.filter((t) => t.startsWith(`${e}/`)));
1488
+ let t = ei(e, g.filter((t) => t.startsWith(`${e}/`)));
1452
1489
  t && v.push(`${e}/ (${t})`);
1453
1490
  }
1454
1491
  g.includes("blazon.json") && v.push("blazon.json"), g.includes("blazon.resolver.json") && v.push("blazon.resolver.json");
1455
1492
  let y = { answers: n };
1456
1493
  if (u) try {
1457
- y = await Ur({
1494
+ y = await Xr({
1458
1495
  prompter: u,
1459
1496
  look: d,
1460
1497
  dir: r,
1461
1498
  kept: h.length
1462
1499
  });
1463
1500
  } catch (e) {
1464
- if (e instanceof Or) return u.cancel("Stopped. The starter was copied as it is, and nothing else was changed."), 130;
1501
+ if (e instanceof Fr) return u.cancel("Stopped. The starter was copied as it is, and nothing else was changed."), 130;
1465
1502
  throw e;
1466
1503
  }
1467
1504
  else {
1468
- for (let e of v) console.log(` ${s.green("✔")} Created ${e}`);
1469
- h.length > 0 && console.log(` ${s.yellow("!")} ${h.length} starter files were already here and are kept as they are`), console.log();
1505
+ for (let e of v) console.log(` ${a.green("✔")} Created ${e}`);
1506
+ h.length > 0 && console.log(` ${a.yellow("!")} ${h.length} starter files were already here and are kept as they are`), console.log();
1470
1507
  }
1471
- let b = y.site?.url ?? t.from, x = 0, S, ee = u?.spinner();
1472
- if (ee?.start("Writing the brand book"), b !== void 0) try {
1473
- if (S = await _r(r, b, _, /* @__PURE__ */ new Date(), {
1508
+ let ee = y.site?.url ?? t.from, b = 0, x, te = u?.spinner();
1509
+ if (te?.start("Writing the brand book"), ee !== void 0) try {
1510
+ if (x = await wr(r, ee, _, /* @__PURE__ */ new Date(), {
1474
1511
  page: y.site?.findings.page,
1475
1512
  skipVars: y.site?.skipVars
1476
1513
  }), !u) {
1477
- console.log(s.bold(`Read from ${b}:`));
1478
- for (let e of S.written) console.log(` ${s.green("✔")} Wrote ${e}`);
1479
- for (let e of S.removed) console.log(` ${s.green("✔")} Removed ${e}`);
1480
- for (let e of S.repointed) console.log(` ${s.green("✔")} Re-pointed ${e}`);
1481
- for (let e of S.missing) console.log(` ${s.yellow("!")} ${e}`);
1482
- console.log(s.dim("\n All of it is marked needs-review: it is a starting point, so confirm it with the brand owner.\n"));
1514
+ console.log(a.bold(`Read from ${ee}:`));
1515
+ for (let e of x.written) console.log(` ${a.green("✔")} Wrote ${e}`);
1516
+ for (let e of x.removed) console.log(` ${a.green("✔")} Removed ${e}`);
1517
+ for (let e of x.repointed) console.log(` ${a.green("✔")} Re-pointed ${e}`);
1518
+ for (let e of x.missing) console.log(` ${a.yellow("!")} ${e}`);
1519
+ console.log(a.dim("\n All of it is marked needs-review: it is a starting point, so confirm it with the brand owner.\n"));
1483
1520
  }
1484
1521
  } catch (e) {
1485
1522
  let n = e instanceof Error ? e.message : String(e);
1486
1523
  t.failure?.({
1487
1524
  code: "site-unreadable",
1488
1525
  message: n
1489
- }), u ? u.log.error(`Could not read ${b}: ${n}\nThe starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.`) : (console.error(s.red(`blazon init: ${n}`)), console.error(s.dim(" The starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.\n"))), x = 2;
1526
+ }), u ? u.log.error(`Could not read ${ee}: ${n}\nThe starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.`) : (console.error(a.red(`blazon init: ${n}`)), console.error(a.dim(" The starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.\n"))), b = 2;
1490
1527
  }
1491
- let C;
1528
+ let S;
1492
1529
  try {
1493
- C = Dr(r, y.answers, _);
1530
+ S = Pr(r, y.answers, _);
1494
1531
  } catch (e) {
1495
- throw ee?.error("Could not write the brand book"), e;
1496
- }
1497
- ee?.stop("Wrote the brand book");
1498
- let w = (e) => d.color ? s.cyan(e) : e, T = F(r), ne = [
1499
- `Run ${w(L("dev", T))} to see the book`,
1500
- `Replace blazon's artwork in ${w(I(T, "assets/"))} and the text in ${w(I(T, "docs/"))}`,
1501
- `Run ${w(L("check", T))} to see what is left`,
1502
- `Point a coding agent at ${w(I(T, "AGENTS.md"))}: it is the guide for editing this brand`
1532
+ throw te?.error("Could not write the brand book"), e;
1533
+ }
1534
+ te?.stop("Wrote the brand book");
1535
+ let C = (e) => d.color ? a.cyan(e) : e, w = F(r), ne = [
1536
+ `Run ${C(L("dev", w))} to see the book`,
1537
+ `Replace blazon's artwork in ${C(I(w, "assets/"))} and the text in ${C(I(w, "docs/"))}`,
1538
+ `Run ${C(L("check", w))} to see what is left`,
1539
+ `Point a coding agent at ${C(I(w, "AGENTS.md"))}: it is the guide for editing this brand`
1503
1540
  ];
1504
- S && !S.written.some((e) => e.startsWith("assets/logos/")) && ne.splice(1, 0, `Add your logo: the book still shows blazon's own. Put it in ${w(I(T, "assets/logos/"))} and point ${w("logo")} in ${w(I(T, "blazon.json"))} at it`);
1505
- let re = w(I(T, "tokens/colors.json")), ie = C.set.some((e) => e.startsWith("primary color")) ? `Finish the palette in ${re}: the primary color is set, the rest is still blazon's` : S?.written.includes("tokens/colors.json") ? `Confirm the colors read from the site in ${re} with the brand owner` : `Edit ${re} with your colors`;
1541
+ x && !x.written.some((e) => e.startsWith("assets/logos/")) && ne.splice(1, 0, `Add your logo: the book still shows blazon's own. Put it in ${C(I(w, "assets/logos/"))} and point ${C("logo")} in ${C(I(w, "blazon.json"))} at it`);
1542
+ let re = C(I(w, "tokens/colors.json")), ae = S.set.some((e) => e.startsWith("primary color")) ? `Finish the palette in ${re}: the primary color is set, the rest is still blazon's` : x?.written.includes("tokens/colors.json") ? `Confirm the colors read from the site in ${re} with the brand owner` : `Edit ${re} with your colors`;
1506
1543
  if (u) {
1507
1544
  let e = [...v.map((e) => `Created ${e}`)];
1508
- S && e.push(`Read from ${b}: ${S.written.length} files written, ${S.removed.length} starter files removed`, ...S.missing.map((e) => `Not found: ${e}`));
1509
- for (let t of C.set) e.push(`Set ${t}`);
1510
- e.push(...C.hints.map((e) => `Note: ${e}`)), u.note(e.join("\n"), "What was written"), x === 0 && u.note(ne.map((e, t) => `${t + 1}. ${e}`).join("\n"), "Next steps");
1545
+ x && e.push(`Read from ${ee}: ${x.written.length} files written, ${x.removed.length} starter files removed`, ...x.missing.map((e) => `Not found: ${e}`));
1546
+ for (let t of S.set) e.push(`Set ${t}`);
1547
+ e.push(...S.hints.map((e) => `Note: ${e}`)), u.note(e.join("\n"), "What was written"), b === 0 && u.note(ne.map((e, t) => `${t + 1}. ${e}`).join("\n"), "Next steps");
1511
1548
  let n;
1512
1549
  try {
1513
1550
  n = t.dev ?? await u.confirm({
@@ -1515,20 +1552,20 @@ async function Zr(e = ".", t = {}) {
1515
1552
  initialValue: !1
1516
1553
  });
1517
1554
  } catch (e) {
1518
- if (!(e instanceof Or)) throw e;
1519
- return u.cancel("Stopped. Everything above was written."), x === 0 ? 130 : x;
1555
+ if (!(e instanceof Fr)) throw e;
1556
+ return u.cancel("Stopped. Everything above was written."), b === 0 ? 130 : b;
1520
1557
  }
1521
- return u.outro(n ? "Starting blazon dev. Press Ctrl-C to stop it." : `Done. Run ${w(L("dev", T))} when you are ready.`), n && await (t.startDev ?? Qr)(r), x;
1558
+ return u.outro(n ? "Starting blazon dev. Press Ctrl-C to stop it." : `Done. Run ${C(L("dev", w))} when you are ready.`), n && await (t.startDev ?? ai)(r), b;
1522
1559
  }
1523
- for (let e of C.hints) console.log(` ${s.yellow("!")} ${e}`);
1524
- return C.set.length > 0 && console.log(` ${s.green("✔")} Set ${C.set.join(", ")}\n`), x === 0 && (console.log(s.bold("Next steps:")), console.log(` 1. ${ie}`), ne.forEach((e, t) => console.log(` ${t + 2}. ${e}`))), console.log(), t.dev && await (t.startDev ?? Qr)(r), x;
1560
+ for (let e of S.hints) console.log(` ${a.yellow("!")} ${e}`);
1561
+ return S.set.length > 0 && console.log(` ${a.green("✔")} Set ${S.set.join(", ")}\n`), b === 0 && (console.log(a.bold("Next steps:")), console.log(` 1. ${ae}`), ne.forEach((e, t) => console.log(` ${t + 2}. ${e}`))), console.log(), t.dev && await (t.startDev ?? ai)(r), b;
1525
1562
  }
1526
- async function Qr(e) {
1527
- let { runDev: t } = await Promise.resolve().then(() => xt);
1563
+ async function ai(e) {
1564
+ let { runDev: t } = await Promise.resolve().then(() => Tt);
1528
1565
  await t(e);
1529
1566
  }
1530
1567
  // src/server/preview-guard.ts
1531
- function $r(e) {
1568
+ function oi(e) {
1532
1569
  return (t, n, r) => {
1533
1570
  let i;
1534
1571
  try {
@@ -1538,25 +1575,25 @@ function $r(e) {
1538
1575
  }
1539
1576
  if (i.includes("\0")) return r();
1540
1577
  let a = O.join(e, O.normalize(`/${i}`));
1541
- if (Pe(Ve(e), Ve(a))) return r();
1578
+ if (Fe(me(e), me(a))) return r();
1542
1579
  n.statusCode = 403, n.setHeader("Content-Type", "text/plain"), n.end("blazon preview serves only files inside the built site: this path is a link that leaves it");
1543
1580
  };
1544
1581
  }
1545
- var ei = (e) => ({
1582
+ var si = (e) => ({
1546
1583
  name: "blazon-site-link-guard",
1547
1584
  configurePreviewServer(t) {
1548
- t.middlewares.use($r(e));
1585
+ t.middlewares.use(oi(e));
1549
1586
  }
1550
1587
  });
1551
1588
  // src/cli/commands/preview.ts
1552
- async function ti(e = process.cwd(), t, n = {}) {
1553
- yt(e);
1554
- let r = await _e(e, t ? { port: t } : void 0), i = O.resolve(e, r.outDir);
1589
+ async function ci(e = process.cwd(), t, n = {}) {
1590
+ Ct(e);
1591
+ let r = await Ae(e, t ? { port: t } : void 0), i = O.resolve(e, r.outDir);
1555
1592
  if (!k.existsSync(O.join(i, "index.html"))) throw new M(`no built site at "${i}"`, `Run ${L("build", F(e))} first.`, "no-built-site");
1556
- let a;
1593
+ let o;
1557
1594
  try {
1558
- a = await rt({
1559
- plugins: [le(), ei(i)],
1595
+ o = await st({
1596
+ plugins: [pe(), si(i)],
1560
1597
  build: { outDir: i },
1561
1598
  preview: {
1562
1599
  port: r.port,
@@ -1566,61 +1603,61 @@ async function ti(e = process.cwd(), t, n = {}) {
1566
1603
  }
1567
1604
  });
1568
1605
  } catch (e) {
1569
- throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? at(r.port) : e;
1606
+ throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? lt(r.port) : e;
1570
1607
  }
1571
- let o = a.resolvedUrls, c = o?.local[0] || `http://localhost:${r.port}/`;
1572
- console.log(`\n ${s.bold(s.blue("blazon preview"))}`), console.log(` ${s.dim("➜")} ${s.bold("Local:")} ${s.cyan(c)}`);
1573
- for (let e of o?.network ?? []) console.log(` ${s.dim("➜")} ${s.bold("Network:")} ${s.cyan(e)}`);
1574
- return console.log(` ${s.dim("➜")} ${s.bold("Dist:")} ${s.dim(i)}\n`), a;
1608
+ let s = o.resolvedUrls, c = s?.local[0] || `http://localhost:${r.port}/`;
1609
+ console.log(`\n ${a.bold(a.blue("blazon preview"))}`), console.log(` ${a.dim("➜")} ${a.bold("Local:")} ${a.cyan(c)}`);
1610
+ for (let e of s?.network ?? []) console.log(` ${a.dim("➜")} ${a.bold("Network:")} ${a.cyan(e)}`);
1611
+ return console.log(` ${a.dim("➜")} ${a.bold("Dist:")} ${a.dim(i)}\n`), o;
1575
1612
  }
1576
1613
  // src/plugins/roles/check-cases.ts
1577
- var ni = "docs/manual/12-plugins.md (\"What a plugin can look at, and where it writes\")";
1578
- function ri(e) {
1579
- let t = O.basename(e), n = se(t) ?? t.replace(/^blazon-/, "");
1580
- return xe(n) ? n : void 0;
1614
+ var li = "docs/manual/12-plugins.md (\"What a plugin can look at, and where it writes\")";
1615
+ function ui(e) {
1616
+ let t = O.basename(e), n = Ze(t) ?? t.replace(/^blazon-/, "");
1617
+ return ge(n) ? n : void 0;
1581
1618
  }
1582
- function ii(e, t) {
1619
+ function di(e, t) {
1583
1620
  return k.readdirSync(e, { recursive: !0 }).filter((n) => O.join(e, n) !== t && !O.join(e, n).startsWith(t + O.sep)).sort();
1584
1621
  }
1585
- function ai(e) {
1586
- let n = ri(e);
1587
- return async (e, r) => {
1588
- let i = t(e), a = i.answers.join(" or "), o = i.stdoutLimit ?? 65536, s = [], c = {
1622
+ function fi(t) {
1623
+ let n = ui(t);
1624
+ return async (t, r) => {
1625
+ let i = je(t), a = i.answers.join(" or "), o = i.stdoutLimit ?? 65536, s = [], c = {
1589
1626
  exit: `a valid request is answered with exit ${a}`,
1590
1627
  limit: `the answer is at most ${o} bytes`,
1591
- shape: `the answer is one the ${e} role accepts: a findings list of at most 500, each with the plugin's code, a severity, a path and a message`,
1628
+ shape: `the answer is one the ${t} role accepts: a findings list of at most 500, each with the plugin's code, a severity, a path and a message`,
1592
1629
  folder: "the plugin writes into out_dir and nothing beside it"
1593
- }, l = JSON.parse(Ae()[e]), u = k.mkdtempSync(O.join(nt.tmpdir(), "blazon-plugin-check-")), d = O.join(u, "tokens"), f = O.join(d, n ?? "plugin");
1630
+ }, l = JSON.parse(e()[t]), u = k.mkdtempSync(O.join(ot.tmpdir(), "blazon-plugin-check-")), d = O.join(u, "tokens"), f = O.join(d, n ?? "plugin");
1594
1631
  try {
1595
- e === "build" && (k.mkdirSync(O.join(u, "site")), k.mkdirSync(f, { recursive: !0 }), Object.assign(l, {
1632
+ t === "build" && (k.mkdirSync(O.join(u, "site")), k.mkdirSync(f, { recursive: !0 }), Object.assign(l, {
1596
1633
  site_dir: O.join(u, "site"),
1597
1634
  tokens_dir: d,
1598
1635
  out_dir: f
1599
1636
  }));
1600
- let t = await r(Buffer.from(JSON.stringify(l)), o), p = !t.answered && t.breakReason.startsWith("output over the limit");
1601
- p ? s.push(g(6, c.exit, e, {
1637
+ let e = await r(Buffer.from(JSON.stringify(l)), o), p = !e.answered && e.breakReason.startsWith("output over the limit");
1638
+ p ? s.push(v(6, c.exit, t, {
1602
1639
  skipped: !0,
1603
1640
  detail: "the output went over the limit before the plugin exited (case 7)"
1604
- })) : t.answered && i.answers.includes(t.code) ? s.push(g(6, c.exit, e, { passed: !0 })) : t.answered && t.code === 1 ? s.push(g(6, c.exit, e, { detail: `got exit 1, and exit 1 is a break in blazon: the ${e} role defines only ${a}, so blazon reports the plugin as failed and counts it toward its breaker. Exit 2 with the reason on the first line when the plugin cannot answer` })) : s.push(g(6, c.exit, e, { detail: t.answered ? `got exit ${t.code}` : `a break: ${t.breakReason}` }));
1605
- let m = i.stdoutLimit === void 0 ? "the core's limit, which the role does not raise" : `the ${e} role's limit (stdout_limit_bytes)`;
1606
- if (s.push(p ? g(7, c.limit, e, { detail: `the plugin printed more than ${o} bytes, ${m}` }) : g(7, c.limit, e, { passed: !0 })), !t.answered || t.code !== 0) s.push(g(8, c.shape, e, {
1641
+ })) : e.answered && i.answers.includes(e.code) ? s.push(v(6, c.exit, t, { passed: !0 })) : e.answered && e.code === 1 ? s.push(v(6, c.exit, t, { detail: `got exit 1, and exit 1 is a break in blazon: the ${t} role defines only ${a}, so blazon reports the plugin as failed and counts it toward its breaker. Exit 2 with the reason on the first line when the plugin cannot answer` })) : s.push(v(6, c.exit, t, { detail: e.answered ? `got exit ${e.code}` : `a break: ${e.breakReason}` }));
1642
+ let m = i.stdoutLimit === void 0 ? "the core's limit, which the role does not raise" : `the ${t} role's limit (stdout_limit_bytes)`;
1643
+ if (s.push(p ? v(7, c.limit, t, { detail: `the plugin printed more than ${o} bytes, ${m}` }) : v(7, c.limit, t, { passed: !0 })), !e.answered || e.code !== 0) s.push(v(8, c.shape, t, {
1607
1644
  skipped: !0,
1608
1645
  detail: "the plugin did not answer with exit 0"
1609
1646
  }));
1610
- else if (n === void 0) s.push(g(8, c.shape, e, {
1647
+ else if (n === void 0) s.push(v(8, c.shape, t, {
1611
1648
  skipped: !0,
1612
1649
  detail: "the program's file name is not blazon-<plugin name>, so the check does not know the plugin's code prefix"
1613
1650
  }));
1614
1651
  else {
1615
- let r = ue(e, n, t.stdout, []);
1616
- s.push("problem" in r ? g(8, c.shape, e, { detail: r.problem }) : g(8, c.shape, e, { passed: !0 }));
1652
+ let r = Xe(t, n, e.stdout, []);
1653
+ s.push("problem" in r ? v(8, c.shape, t, { detail: r.problem }) : v(8, c.shape, t, { passed: !0 }));
1617
1654
  }
1618
- if (e === "build") {
1619
- let t = ii(d, f);
1620
- s.push(t.length === 0 ? g(9, c.folder, e, { passed: !0 }) : g(9, c.folder, e, {
1655
+ if (t === "build") {
1656
+ let e = di(d, f);
1657
+ s.push(e.length === 0 ? v(9, c.folder, t, { passed: !0 }) : v(9, c.folder, t, {
1621
1658
  passed: !0,
1622
1659
  warning: !0,
1623
- detail: `it wrote ${t.map((e) => `tokens_dir/${e}`).join(", ")}. Blazon empties only out_dir before a build, so a file beside it is never cleaned and can collide with another plugin's. Blazon has no folder for a plugin's own state yet, so this is a warning; see ${ni}`
1660
+ detail: `it wrote ${e.map((e) => `tokens_dir/${e}`).join(", ")}. Blazon empties only out_dir before a build, so a file beside it is never cleaned and can collide with another plugin's. Blazon has no folder for a plugin's own state yet, so this is a warning; see ${li}`
1624
1661
  }));
1625
1662
  }
1626
1663
  } finally {
@@ -1633,30 +1670,30 @@ function ai(e) {
1633
1670
  };
1634
1671
  }
1635
1672
  // src/cli/commands/plugin.ts
1636
- var oi = {
1673
+ var pi = {
1637
1674
  plugin: "usage: blazon plugin check <program> [--core] | blazon plugin pin <path> [--name <plugin name>] | blazon plugin profile",
1638
1675
  check: "usage: blazon plugin check <program> [--core]",
1639
1676
  pin: "usage: blazon plugin pin <path> [--name <plugin name> [--digest <digest>] [--entry <path>]]"
1640
1677
  };
1641
- function si(e) {
1642
- let t = e.warning ? s.yellow("warn") : e.passed ? s.green("ok ") : e.skipped ? s.dim("skip") : s.red("FAIL"), n = e.role ? `${e.role}: ` : "", r = e.detail ? ` (${e.detail})` : "";
1678
+ function mi(e) {
1679
+ let t = e.warning ? a.yellow("warn") : e.passed ? a.green("ok ") : e.skipped ? a.dim("skip") : a.red("FAIL"), n = e.role ? `${e.role}: ` : "", r = e.detail ? ` (${e.detail})` : "";
1643
1680
  return ` ${t} ${e.case} ${n}${e.name}${r}`;
1644
1681
  }
1645
- async function ci(e, t = {}) {
1646
- if (!e) throw new M(oi.check, void 0, "missing-argument");
1647
- let n = t.core === !0;
1648
- t.json || (console.log(`${v.host} plugin check: host ${v.host}, adopts: ${v.adopts.length > 0 ? v.adopts.join(", ") : "none"}`), n && console.log("core cases only (1 to 5): no role cases, no layout line"));
1649
- let r = await Oe({
1650
- ...n ? {} : { approvals: await li(e) },
1651
- host: v.host,
1652
- profile: a,
1653
- program: e,
1682
+ async function hi(t, n = {}) {
1683
+ if (!t) throw new M(pi.check, void 0, "missing-argument");
1684
+ let r = n.core === !0;
1685
+ n.json || (console.log(`${E.host} plugin check: host ${E.host}, adopts: ${E.adopts.length > 0 ? E.adopts.join(", ") : "none"}`), r && console.log("core cases only (1 to 5): no role cases, no layout line"));
1686
+ let i = await _({
1687
+ ...r ? {} : { approvals: await gi(t) },
1688
+ host: E.host,
1689
+ profile: ee,
1690
+ program: t,
1654
1691
  validate: !1,
1655
- requests: Ae(),
1656
- ...n ? {} : { roleCases: ai(e) }
1657
- }), i = r.filter((e) => e.warning).length, o = r.filter((e) => !e.passed && !e.skipped), c = n ? void 0 : Ke(O.resolve(e));
1658
- if (t.json) {
1659
- let e = (e) => e.warning ? "warn" : e.passed ? "ok" : e.skipped ? "skip" : "fail", t = r.map((t) => ({
1692
+ requests: e(),
1693
+ ...r ? {} : { roleCases: fi(t) }
1694
+ }), o = i.filter((e) => e.warning).length, s = i.filter((e) => !e.passed && !e.skipped), c = r ? void 0 : w(O.resolve(t));
1695
+ if (n.json) {
1696
+ let e = (e) => e.warning ? "warn" : e.passed ? "ok" : e.skipped ? "skip" : "fail", t = i.map((t) => ({
1660
1697
  case: t.case,
1661
1698
  name: t.name,
1662
1699
  role: t.role,
@@ -1665,128 +1702,129 @@ async function ci(e, t = {}) {
1665
1702
  }));
1666
1703
  return process.stdout.write(`${JSON.stringify({
1667
1704
  command: "plugin check",
1668
- passed: o.length === 0 && !c,
1669
- host: v.host,
1670
- adopts: v.adopts,
1671
- ...n ? { core: !0 } : {},
1705
+ passed: s.length === 0 && !c,
1706
+ host: E.host,
1707
+ adopts: E.adopts,
1708
+ ...r ? { core: !0 } : {},
1672
1709
  cases: t,
1673
1710
  ...c ? { layout: c } : {}
1674
- })}\n`), o.length === 0 && !c ? 0 : 1;
1711
+ })}\n`), s.length === 0 && !c ? 0 : 1;
1675
1712
  }
1676
- for (let e of r) console.log(si(e));
1677
- return c && console.log(` ${s.red("FAIL")} layout: ${c}`), o.length > 0 ? console.log(s.red(`\n${o.length} case${o.length === 1 ? "" : "s"} failed`)) : console.log(c ? s.red("\nFailed: the file name does not follow the layout of a shipped plugin") : s.green(`\nPassed${i > 0 ? `, with ${i} warning${i === 1 ? "" : "s"}` : ""}`)), o.length === 0 && !c ? 0 : 1;
1713
+ for (let e of i) console.log(mi(e));
1714
+ return c && console.log(` ${a.red("FAIL")} layout: ${c}`), s.length > 0 ? console.log(a.red(`\n${s.length} case${s.length === 1 ? "" : "s"} failed`)) : console.log(c ? a.red("\nFailed: the file name does not follow the layout of a shipped plugin") : a.green(`\nPassed${o > 0 ? `, with ${o} warning${o === 1 ? "" : "s"}` : ""}`)), s.length === 0 && !c ? 0 : 1;
1678
1715
  }
1679
- async function li(e) {
1716
+ async function gi(e) {
1680
1717
  let t;
1681
1718
  try {
1682
1719
  t = (await R(process.cwd())).plugins ?? [];
1683
1720
  } catch {
1684
1721
  return;
1685
1722
  }
1686
- let n = O.basename(e), r = se(n) ?? n.replace(/^blazon-/, "");
1723
+ let n = O.basename(e), r = Ze(n) ?? n.replace(/^blazon-/, "");
1687
1724
  return t.flatMap((e, t) => e.name === r ? [{
1688
1725
  key: `plugins[${t}].env`,
1689
1726
  approved: e.env ?? []
1690
1727
  }] : []);
1691
1728
  }
1692
- function ui(e, t = {}, n = process.cwd()) {
1693
- if (!e) throw new M(oi.pin, void 0, "missing-argument");
1694
- if (!t.name && (t.digest || t.entry)) throw new M(`--digest and --entry say what to record, so they need --name; ${oi.pin}`, void 0, "conflicting-options");
1729
+ function _i(e, t = {}, r = process.cwd()) {
1730
+ if (!e) throw new M(pi.pin, void 0, "missing-argument");
1731
+ if (!t.name && (t.digest || t.entry)) throw new M(`--digest and --entry say what to record, so they need --name; ${pi.pin}`, void 0, "conflicting-options");
1695
1732
  if (!k.existsSync(e)) return console.error(`blazon plugin pin: there is nothing at ${e}.`), 2;
1696
1733
  try {
1697
1734
  if (t.name) {
1698
- let r = $e(n, t.name, e, {
1735
+ let i = n(r, t.name, e, {
1699
1736
  digest: t.digest,
1700
1737
  entry: t.entry
1701
1738
  });
1702
- return console.log(`pinned ${t.name}: ${r.digest} (${r.source}) in ${x}`), 0;
1739
+ return console.log(`pinned ${t.name}: ${i.digest} (${i.source}) in ${nt}`), 0;
1703
1740
  }
1704
- let r = k.lstatSync(e);
1705
- return console.log(r.isDirectory() && !r.isSymbolicLink() ? p(e) : u(e)), 0;
1741
+ let i = k.lstatSync(e);
1742
+ return console.log(i.isDirectory() && !i.isSymbolicLink() ? Re(e) : h(e)), 0;
1706
1743
  } catch (t) {
1707
- return console.error(t instanceof re ? t.message : `cannot read ${e}: ${t instanceof Error ? t.message : String(t)}`), 1;
1744
+ return console.error(t instanceof l ? t.message : `cannot read ${e}: ${t instanceof Error ? t.message : String(t)}`), 1;
1708
1745
  }
1709
1746
  }
1710
- function di() {
1711
- return console.log(JSON.stringify(v, null, 2)), 0;
1747
+ function vi() {
1748
+ return console.log(JSON.stringify(E, null, 2)), 0;
1712
1749
  }
1713
- async function fi(e, t, n = {}) {
1714
- if (e === "check") return ci(t, {
1750
+ async function yi(e, t, n = {}) {
1751
+ if (e === "check") return hi(t, {
1715
1752
  json: n.json,
1716
1753
  core: n.core
1717
1754
  });
1718
- if (e === "pin") return ui(t, n);
1719
- if (e === "profile") return di();
1720
- throw new M(oi.plugin, void 0, "missing-argument");
1755
+ if (e === "pin") return _i(t, n);
1756
+ if (e === "profile") return vi();
1757
+ throw new M(pi.plugin, void 0, "missing-argument");
1721
1758
  }
1722
1759
  // src/cli/commands/pin.ts
1723
- function pi(e = process.cwd(), t = {}) {
1724
- yt(e);
1760
+ function bi(e = process.cwd(), t = {}) {
1761
+ Ct(e);
1725
1762
  try {
1726
- let n = t.identity === void 0 ? Xe(e) : Xe(e, t.identity);
1763
+ let n = t.identity === void 0 ? ne(e) : ne(e, t.identity);
1727
1764
  return t.json ? process.stdout.write(`${JSON.stringify({
1728
1765
  command: "pin",
1729
1766
  passed: !0,
1730
1767
  commit: n,
1731
- file: Se
1732
- })}\n`) : console.log(`pinned blazon ${s.bold(n)} in ${Se}; commit the file with the book`), 0;
1768
+ file: fe
1769
+ })}\n`) : console.log(`pinned blazon ${a.bold(n)} in ${fe}; commit the file with the book`), 0;
1733
1770
  } catch (e) {
1734
1771
  if (t.json) throw e;
1735
1772
  return console.error(e instanceof Error ? e.message : String(e)), 1;
1736
1773
  }
1737
1774
  }
1738
1775
  // src/cli/commands/drift.ts
1739
- async function mi(e, t = {}) {
1740
- let n = (e, n, r) => (console.error(st("drift", n, r).replace(/^blazon drift:/, (e) => s.red(e))), t.json && console.log(JSON.stringify({
1776
+ async function xi(e, t = {}) {
1777
+ let n = (e, n, r) => (console.error(dt("drift", n, r).replace(/^blazon drift:/, (e) => a.red(e))), t.json && console.log(JSON.stringify({
1741
1778
  command: "drift",
1742
1779
  passed: !1,
1743
- error: { ...ft(e, ct(n, r), r) }
1780
+ error: { ...gt(e, ft(n, r), r) }
1744
1781
  })), 2);
1745
1782
  if (!e) return n("missing-argument", "needs the address of a page or the path of a CSS file", "Run blazon drift <url-or-css-file>.");
1746
1783
  let r = t.cwd ?? process.cwd();
1747
1784
  if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(e) && !k.existsSync(O.resolve(e))) return n("no-file", `there is no file "${e}"`, "Give the path of a CSS file, or the http(s) address of a page.");
1748
- let i, a;
1785
+ let i, o;
1749
1786
  try {
1750
- let n = await R(r, t.tokens ? { tokensDir: t.tokens } : void 0), o = await D(n, r), s = await an(e);
1787
+ let n = await R(r, t.tokens ? { tokensDir: t.tokens } : void 0), a = await T(n, r), s = await ln(e);
1751
1788
  i = s.sources;
1752
- let c = Zt(s.css);
1753
- a = o.tokens.items.flatMap((e) => {
1789
+ let c = tn(s.css);
1790
+ o = a.tokens.items.flatMap((e) => {
1754
1791
  let t = e.blazon.source?.cssVar;
1755
- return typeof t == "string" ? [Qt(e, t, c)] : [];
1792
+ return typeof t == "string" ? [nn(e, t, c)] : [];
1756
1793
  });
1757
1794
  } catch (e) {
1758
1795
  return n(e instanceof j ? e.code : "error", e instanceof Error ? e.message : String(e), e instanceof j ? e.fix : void 0);
1759
1796
  }
1760
- if (a.length === 0) return n("error", "no token declares a source.cssVar, so there is nothing to compare", "Name the site's custom property in a token's dev.blazon source.cssVar (manual chapter 2).");
1761
- let o = (e) => a.filter((t) => t.status === e).length, c = {
1762
- ok: o("ok"),
1763
- drift: o("drift"),
1764
- missing: o("missing")
1797
+ if (o.length === 0) return n("error", "no token declares a source.cssVar, so there is nothing to compare", "Name the site's custom property in a token's dev.blazon source.cssVar (manual chapter 2).");
1798
+ let s = (e) => o.filter((t) => t.status === e).length, c = {
1799
+ ok: s("ok"),
1800
+ drift: s("drift"),
1801
+ missing: s("missing")
1765
1802
  }, l = +(c.drift + c.missing > 0);
1766
1803
  if (t.json) return console.log(JSON.stringify({
1767
1804
  target: e,
1768
1805
  sources: i,
1769
1806
  summary: c,
1770
- tokens: a
1807
+ tokens: o
1771
1808
  }, null, 2)), l;
1772
- let u = Math.max(...a.map((e) => e.path.length));
1773
- for (let e of a) {
1809
+ let u = Math.max(...o.map((e) => e.path.length));
1810
+ for (let e of o) {
1774
1811
  let t = e.path.padEnd(u);
1775
- e.status === "ok" ? console.log(`${s.green("ok ")} ${t} ${s.dim(e.cssVar)}`) : e.status === "drift" ? console.log(`${s.red("drift ")} ${t} ${e.cssVar}: token ${e.expected}, site ${e.actual}`) : console.log(`${s.yellow("missing")} ${t} ${e.cssVar} is not declared (token ${e.expected})`);
1812
+ e.status === "ok" ? console.log(`${a.green("ok ")} ${t} ${a.dim(e.cssVar)}`) : e.status === "drift" ? console.log(`${a.red("drift ")} ${t} ${e.cssVar}: token ${e.expected}, site ${e.actual}`) : console.log(`${a.yellow("missing")} ${t} ${e.cssVar} is not declared (token ${e.expected})`);
1776
1813
  }
1777
1814
  return console.log(`\n${c.ok} ok, ${c.drift} drifted, ${c.missing} missing`), l;
1778
1815
  }
1779
1816
  // src/cli/commands/approvals.ts
1780
- async function hi(e = process.cwd(), t = {}) {
1781
- let n = await R(e), r = await D(n, e), i = o(r.tokens, r.assets.all, {
1817
+ async function Si(e = process.cwd(), t = {}) {
1818
+ let n = await R(e), r = await T(n, e), i = o(r.tokens, r.assets.all, {
1782
1819
  assetsDir: O.resolve(e, n.assetsDir),
1783
- dirs: ie(n.assets, e)
1784
- }), a = (e) => e.review.value === void 0 ? "not recorded" : e.review.value === e.current ? "recorded" : "stale";
1820
+ dirs: se(n.assets, e)
1821
+ }), s = (e) => e.review.value === void 0 ? "not recorded" : e.review.value === e.current ? "recorded" : "stale";
1785
1822
  if (t.json) {
1786
1823
  let e = i.map((e) => ({
1787
1824
  path: e.path,
1788
1825
  fingerprint: e.current ?? null,
1789
- state: a(e)
1826
+ state: s(e),
1827
+ ...e.files && { files: e.files }
1790
1828
  }));
1791
1829
  return process.stdout.write(`${JSON.stringify({
1792
1830
  command: "approvals",
@@ -1794,62 +1832,63 @@ async function hi(e = process.cwd(), t = {}) {
1794
1832
  approvals: e
1795
1833
  })}\n`), 0;
1796
1834
  }
1797
- if (i.length === 0) return console.log(s.dim("\n No token or asset is marked review.status: ok.\n")), 0;
1835
+ if (i.length === 0) return console.log(a.dim("\n No token or asset is marked review.status: ok.\n")), 0;
1798
1836
  let c = Math.max(...i.map((e) => e.path.length));
1799
1837
  console.log();
1800
1838
  for (let e of i) {
1801
- let t = a(e), n = t === "recorded" ? s.green : t === "stale" ? s.yellow : s.dim;
1802
- console.log(` ${e.path.padEnd(c)} ${(e.current ?? "(no value)").padEnd(12)} ${n(t)}`);
1839
+ let t = s(e), n = t === "recorded" ? a.green : t === "stale" ? a.yellow : a.dim, r = e.files ? ` ${a.dim(e.files.join(", "))}` : "";
1840
+ console.log(` ${e.path.padEnd(c)} ${(e.current ?? "(no value)").padEnd(12)} ${n(t)}${" ".repeat(12 - t.length)}${r}`.trimEnd());
1803
1841
  }
1804
- return console.log(), console.log(s.dim(" Set review.value to the fingerprint once a person has confirmed the value.\n")), 0;
1842
+ return console.log(), console.log(a.dim(" Set review.value to the fingerprint once a person has confirmed the value.\n")), 0;
1805
1843
  }
1806
1844
  // src/cli/commands/cwd.ts
1807
- function gi(e) {
1845
+ function Ci(e) {
1808
1846
  if (e === void 0) return;
1809
1847
  if (typeof e != "string" || e === "") throw new M("--cwd needs a folder", "Give one, such as blazon --cwd ./my-brand check.");
1810
1848
  let t = O.resolve(process.cwd(), e);
1811
- yt(t), process.chdir(t);
1849
+ Ct(t), process.chdir(t);
1812
1850
  }
1813
- function _i(e, t = process.env) {
1851
+ function wi(e, t = process.env) {
1814
1852
  let n = (Array.isArray(e) ? e : e === void 0 ? [] : [e]).map((e) => typeof e == "string" || typeof e == "number" ? String(e) : "");
1815
1853
  if (n.some((e) => e.trim() === "")) throw new M("--allow-dir needs a folder", "Give one, such as blazon dev --allow-dir ../shared.");
1816
- De(Re(n, t, process.cwd()));
1854
+ ye(He(n, t, process.cwd()));
1817
1855
  }
1818
1856
  // src/core/read/lookup.ts
1819
- var K = class extends Error {}, vi = (e) => e.trim().replace(/^\{(.*)\}$/, "$1").trim();
1820
- function yi(e, t) {
1821
- let n = vi(t), r = e.tokens.byPath.get(n);
1822
- if (r) return r;
1823
- let i = E(n, e.tokens.items.map((e) => e.path));
1824
- throw new K(e.tokens.items.some((e) => e.path.startsWith(`${n}.`)) ? `"${n}" is a group, not a token; \`blazon rules ${n}\` shows its rules.` : `no token "${n}"${i ? `; did you mean "${i}"?` : "."}`);
1857
+ var K = class extends Error {}, Ti = (e) => e.trim().replace(/^\{(.*)\}$/, "$1").trim();
1858
+ function Ei(e, t, n) {
1859
+ let r = Ti(t), i = e.tokens.byPath.get(r);
1860
+ if (i) return i;
1861
+ let a = D(r, e.tokens.items.map((e) => e.path));
1862
+ throw new K(e.tokens.items.some((e) => e.path.startsWith(`${r}.`)) ? `"${r}" is a group, not a token; \`blazon rules ${r}\` shows its rules.` : `no token "${r}"${n === void 0 ? "" : ` in theme "${n}"`}${a ? `; did you mean "${a}"?` : "."}`);
1825
1863
  }
1826
1864
  // src/core/read/theme.ts
1827
- var bi = "theme";
1828
- function xi(e) {
1865
+ var Di = "theme";
1866
+ function Oi(e) {
1829
1867
  return e.tokens.modifiers?.find((e) => e.name === "theme")?.contexts ?? [];
1830
1868
  }
1831
- function Si(e, t) {
1832
- let n = e.tokens.modifiers?.find((e) => e.name === bi);
1833
- if (!n) throw new K(`no theme "${t}": this brand has no resolver "${bi}" modifier, so it has no themes.`);
1869
+ function ki(e, t) {
1870
+ let n = e.tokens.modifiers?.find((e) => e.name === Di);
1871
+ if (!n) throw new K(`no theme "${t}": this brand has no resolver "${Di}" modifier, so it has no themes.`);
1834
1872
  if (!n.contexts.includes(t)) throw new K(`no theme "${t}". The themes are ${n.contexts.map((e) => `"${e}"`).join(", ")}.`);
1835
- let r = (e.tokens.contexts ?? []).filter((e) => e.modifier === "theme" && e.context === t), i = C(e.tokens.items, r);
1873
+ let r = (e.tokens.contexts ?? []).filter((e) => e.modifier === "theme" && e.context === t), i = le(e.tokens.items, r), a = m(e.tokens.groupMeta, r);
1836
1874
  return {
1837
1875
  ...e,
1838
1876
  tokens: {
1839
1877
  ...e.tokens,
1840
1878
  items: i,
1879
+ groupMeta: a,
1841
1880
  byPath: new Map(i.map((e) => [e.path, e]))
1842
1881
  }
1843
1882
  };
1844
1883
  }
1845
1884
  // src/core/read/rules.ts
1846
- var Ci = (e) => e.extensions?.["dev.blazon"] ?? {};
1847
- function wi(e, t, n) {
1848
- return Ci(t)[n] === void 0 ? e.tokens.groupMeta.filter((e) => t.path.startsWith(`${e.path}.`) && e.blazon[n] !== void 0).sort((e, t) => t.path.length - e.path.length)[0]?.path : t.path;
1885
+ var Ai = (e) => e.extensions?.["dev.blazon"] ?? {};
1886
+ function ji(e, t, n) {
1887
+ return Ai(t)[n] === void 0 ? e.tokens.groupMeta.filter((e) => t.path.startsWith(`${e.path}.`) && e.blazon[n] !== void 0).sort((e, t) => t.path.length - e.path.length)[0]?.path : t.path;
1849
1888
  }
1850
1889
  var q = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : void 0;
1851
- function Ti(e, t) {
1852
- let n = t.blazon.usage, r = wi(e, t, "usage");
1890
+ function Mi(e, t) {
1891
+ let n = t.blazon.usage, r = ji(e, t, "usage");
1853
1892
  if (!n || typeof n != "object" || r === void 0) return;
1854
1893
  let i = q(n.allow), a = q(n.deny);
1855
1894
  return {
@@ -1858,15 +1897,15 @@ function Ti(e, t) {
1858
1897
  from: r
1859
1898
  };
1860
1899
  }
1861
- function Ei(e, t) {
1862
- let n = t.blazon.logo, r = wi(e, t, "logo"), i = q(n?.deny);
1900
+ function Ni(e, t) {
1901
+ let n = t.blazon.logo, r = ji(e, t, "logo"), i = q(n?.deny);
1863
1902
  if (n && i && r !== void 0) return {
1864
1903
  deny: i,
1865
1904
  ...typeof n.reason == "string" && { reason: n.reason },
1866
1905
  from: r
1867
1906
  };
1868
1907
  }
1869
- function Di(e) {
1908
+ function Pi(e) {
1870
1909
  return e.tokens.groupMeta.flatMap((e) => (e.blazon.pairs ?? []).map((t) => ({
1871
1910
  fg: t.fg,
1872
1911
  bg: t.bg,
@@ -1874,19 +1913,19 @@ function Di(e) {
1874
1913
  from: e.path
1875
1914
  })));
1876
1915
  }
1877
- function Oi(e, t) {
1916
+ function Fi(e, t) {
1878
1917
  let n = [];
1879
- for (let r of Di(e)) h(r.fg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1918
+ for (let r of Pi(e)) S(r.fg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1880
1919
  ...r,
1881
1920
  as: "fg"
1882
- }), h(r.bg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1921
+ }), S(r.bg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1883
1922
  ...r,
1884
1923
  as: "bg"
1885
1924
  });
1886
1925
  return n;
1887
1926
  }
1888
- function ki(e, t) {
1889
- let n = Ci(t).review, r = n ? t.path : wi(e, t, "review"), i = n ?? e.tokens.groupMeta.find((e) => e.path === r)?.blazon.review;
1927
+ function Ii(e, t) {
1928
+ let n = Ai(t).review, r = n ? t.path : ji(e, t, "review"), i = n ?? e.tokens.groupMeta.find((e) => e.path === r)?.blazon.review;
1890
1929
  if (i && r !== void 0) return {
1891
1930
  status: i.status,
1892
1931
  ...i.note && { note: i.note },
@@ -1895,8 +1934,8 @@ function ki(e, t) {
1895
1934
  from: r
1896
1935
  };
1897
1936
  }
1898
- function Ai(e, t) {
1899
- let n = Ti(e, t), r = Ei(e, t), i = ki(e, t), a = t.blazon.role === void 0 ? void 0 : wi(e, t, "role");
1937
+ function Li(e, t) {
1938
+ let n = Mi(e, t), r = Ni(e, t), i = Ii(e, t), a = t.blazon.role === void 0 ? void 0 : ji(e, t, "role");
1900
1939
  return {
1901
1940
  ...t.blazon.role !== void 0 && a !== void 0 && { role: {
1902
1941
  value: t.blazon.role,
@@ -1904,11 +1943,11 @@ function Ai(e, t) {
1904
1943
  } },
1905
1944
  ...n && { usage: n },
1906
1945
  ...r && { logo: r },
1907
- pairs: Oi(e, t),
1946
+ pairs: Fi(e, t),
1908
1947
  ...i && { review: i }
1909
1948
  };
1910
1949
  }
1911
- function ji(e, t, n) {
1950
+ function Ri(e, t, n) {
1912
1951
  let r = n.usage && typeof n.usage == "object" ? {
1913
1952
  ...q(n.usage.allow) && { allow: q(n.usage.allow) },
1914
1953
  ...q(n.usage.deny) && { deny: q(n.usage.deny) }
@@ -1929,37 +1968,37 @@ function ji(e, t, n) {
1929
1968
  };
1930
1969
  return Object.keys(a).length > 2 ? a : void 0;
1931
1970
  }
1932
- function Mi(e, t) {
1933
- let n = vi(t), r = (e) => n === "" || e === n || e.startsWith(`${n}.`);
1971
+ function zi(e, t) {
1972
+ let n = Ti(t), r = (e) => n === "" || e === n || e.startsWith(`${n}.`);
1934
1973
  if (!(n === "" || e.tokens.items.some((e) => r(e.path)))) {
1935
- let t = [...new Set(e.tokens.items.flatMap((e) => e.path.split(".").slice(0, -1).map((e, t, n) => n.slice(0, t + 1).join("."))))], r = E(n, [...t, ...e.tokens.items.map((e) => e.path)]);
1974
+ let t = [...new Set(e.tokens.items.flatMap((e) => e.path.split(".").slice(0, -1).map((e, t, n) => n.slice(0, t + 1).join("."))))], r = D(n, [...t, ...e.tokens.items.map((e) => e.path)]);
1936
1975
  throw new K(`no token or group "${n}"${r ? `; did you mean "${r}"?` : "."}`);
1937
1976
  }
1938
1977
  return [
1939
- ...e.tokens.groupMeta.filter((e) => n !== "" && n.startsWith(`${e.path}.`)).map((e) => ji(e.path, "group", {
1978
+ ...e.tokens.groupMeta.filter((e) => n !== "" && n.startsWith(`${e.path}.`)).map((e) => Ri(e.path, "group", {
1940
1979
  ...e.blazon,
1941
1980
  pairs: void 0
1942
1981
  })).map((e) => e && {
1943
1982
  ...e,
1944
1983
  inherited: !0
1945
1984
  }),
1946
- ...e.tokens.groupMeta.filter((e) => r(e.path)).map((e) => ji(e.path, "group", e.blazon)),
1947
- ...e.tokens.items.filter((e) => r(e.path)).map((e) => ji(e.path, "token", Ci(e)))
1985
+ ...e.tokens.groupMeta.filter((e) => r(e.path)).map((e) => Ri(e.path, "group", e.blazon)),
1986
+ ...e.tokens.items.filter((e) => r(e.path)).map((e) => Ri(e.path, "token", Ai(e)))
1948
1987
  ].filter((e) => e !== void 0);
1949
1988
  }
1950
1989
  // src/core/read/token.ts
1951
- function Ni(e, t) {
1952
- let [n, ...r] = _(t);
1990
+ function Bi(e, t) {
1991
+ let [n, ...r] = y(t);
1953
1992
  return {
1954
1993
  theme: {
1955
1994
  variable: n,
1956
1995
  ...t.parts && { parts: Object.fromEntries(Object.keys(t.parts).map((e, t) => [e, r[t]])) }
1957
1996
  },
1958
- ...t.type === "typography" && { typographyClass: ae(t.path) }
1997
+ ...t.type === "typography" && { typographyClass: We(t.path) }
1959
1998
  };
1960
1999
  }
1961
- function Pi(e, t, n) {
1962
- let r = yi(n === void 0 ? e : Si(e, n), t), i = n === void 0 ? void 0 : yi(e, t), a = (e.tokens.contexts ?? []).flatMap((e) => e.tokens.filter((e) => e.path === r.path).map((t) => ({
2000
+ function Vi(e, t, n) {
2001
+ let r = Ei(n === void 0 ? e : ki(e, n), t, n), i = n === void 0 ? void 0 : Ei(e, t), a = (e.tokens.contexts ?? []).flatMap((e) => e.tokens.filter((e) => e.path === r.path).map((t) => ({
1963
2002
  modifier: e.modifier,
1964
2003
  context: e.context,
1965
2004
  selector: e.selector,
@@ -1976,19 +2015,19 @@ function Pi(e, t, n) {
1976
2015
  ...r.deprecated && { deprecated: r.deprecated },
1977
2016
  ...r.aliasOf && { aliasOf: r.aliasOf },
1978
2017
  ...r.blazon.tier && { tier: r.blazon.tier },
1979
- names: Ni(e, r),
1980
- rules: Ai(e, r),
2018
+ names: Bi(e, r),
2019
+ rules: Li(e, r),
1981
2020
  ...a.length > 0 && { contexts: a },
1982
2021
  sourceFile: r.file.replace(/ \(inline\)$/, "")
1983
2022
  };
1984
2023
  }
1985
2024
  // src/core/read/list.ts
1986
- var Fi = [
2025
+ var Hi = [
1987
2026
  "primitive",
1988
2027
  "semantic",
1989
2028
  "component"
1990
2029
  ];
1991
- function Ii(e) {
2030
+ function Ui(e) {
1992
2031
  let t = /* @__PURE__ */ new Set();
1993
2032
  for (let { path: n } of e.tokens.items) {
1994
2033
  let e = n.split(".");
@@ -1996,25 +2035,25 @@ function Ii(e) {
1996
2035
  }
1997
2036
  return t;
1998
2037
  }
1999
- function Li(e, t) {
2000
- let n = vi(t);
2001
- return !e.tokens.byPath.has(n) && Ii(e).has(n);
2038
+ function Wi(e, t) {
2039
+ let n = Ti(t);
2040
+ return !e.tokens.byPath.has(n) && Ui(e).has(n);
2002
2041
  }
2003
- function Ri(e, t = {}) {
2042
+ function Gi(e, t = {}) {
2043
+ let n;
2044
+ if (t.type !== void 0 && (n = te.find((e) => e === t.type), !n)) throw new K(`no token type "${t.type}"; the types are ${te.join(", ")}.`);
2004
2045
  let r;
2005
- if (t.type !== void 0 && (r = n.find((e) => e === t.type), !r)) throw new K(`no token type "${t.type}"; the types are ${n.join(", ")}.`);
2006
- let i;
2007
- if (t.tier !== void 0 && (i = Fi.find((e) => e === t.tier), !i)) throw new K(`no tier "${t.tier}"; the tiers are ${Fi.join(", ")}.`);
2008
- let a = xi(e), o = t.theme === void 0 ? e : Si(e, t.theme), s;
2046
+ if (t.tier !== void 0 && (r = Hi.find((e) => e === t.tier), !r)) throw new K(`no tier "${t.tier}"; the tiers are ${Hi.join(", ")}.`);
2047
+ let i = Oi(e), a = t.theme === void 0 ? e : ki(e, t.theme), o;
2009
2048
  if (t.group !== void 0) {
2010
- s = vi(t.group);
2011
- let n = Ii(e);
2012
- if (!n.has(s)) {
2013
- let e = E(s, [...n]);
2014
- throw new K(`no group "${s}"${e ? `; did you mean "${e}"?` : "."}`);
2049
+ o = Ti(t.group);
2050
+ let n = Ui(e);
2051
+ if (!n.has(o)) {
2052
+ let e = D(o, [...n]);
2053
+ throw new K(`no group "${o}"${e ? `; did you mean "${e}"?` : "."}`);
2015
2054
  }
2016
2055
  }
2017
- let c = o.tokens.items.filter((e) => (s === void 0 || e.path.startsWith(`${s}.`)) && (r === void 0 || e.type === r) && (i === void 0 || e.blazon.tier === i)).map((n) => {
2056
+ let s = a.tokens.items.filter((e) => (o === void 0 || e.path.startsWith(`${o}.`)) && (n === void 0 || e.type === n) && (r === void 0 || e.blazon.tier === r)).map((n) => {
2018
2057
  let r = t.theme === void 0 ? void 0 : e.tokens.byPath.get(n.path);
2019
2058
  return {
2020
2059
  path: n.path,
@@ -2026,33 +2065,33 @@ function Ri(e, t = {}) {
2026
2065
  };
2027
2066
  });
2028
2067
  return {
2029
- ...s !== void 0 && { group: s },
2030
- ...r && { type: r },
2031
- ...i && { tier: i },
2068
+ ...o !== void 0 && { group: o },
2069
+ ...n && { type: n },
2070
+ ...r && { tier: r },
2032
2071
  ...t.theme !== void 0 && { theme: t.theme },
2033
- ...a.length > 0 && { themes: a },
2034
- tokens: c
2072
+ ...i.length > 0 && { themes: i },
2073
+ tokens: s
2035
2074
  };
2036
2075
  }
2037
2076
  // src/core/operations/limits.ts
2038
- var zi = 4e4, Bi = ["text", "ui"], Vi = l["AA-large"], Hi = [
2077
+ var Ki = 4e4, qi = ["text", "ui"], Ji = f["AA-large"], Yi = [
2039
2078
  "border",
2040
2079
  "icon",
2041
2080
  "interactive"
2042
- ], Ui = [
2081
+ ], Xi = [
2043
2082
  "AAA",
2044
2083
  "AA",
2045
2084
  "AA-large"
2046
2085
  ];
2047
- function Wi(e, t) {
2086
+ function Zi(e, t) {
2048
2087
  let n = [];
2049
2088
  for (let r = t; r && !n.includes(r); r = r.aliasOf ? e.tokens.byPath.get(r.aliasOf) : void 0) n.push(r);
2050
2089
  return n;
2051
2090
  }
2052
- function Gi(e, t, n) {
2053
- for (let r of Wi(e, t)) {
2054
- if (b(r, n)) continue;
2055
- let t = Ti(e, r), i = t.deny?.includes(n) ? `denies "${n}"` : `allows only ${(t.allow ?? []).map((e) => `"${e}"`).join(", ")}, not "${n}"`;
2091
+ function Qi(e, t, n) {
2092
+ for (let r of Zi(e, t)) {
2093
+ if (x(r, n)) continue;
2094
+ let t = Mi(e, r), i = t.deny?.includes(n) ? `denies "${n}"` : `allows only ${(t.allow ?? []).map((e) => `"${e}"`).join(", ")}, not "${n}"`;
2056
2095
  return {
2057
2096
  rule: "usage",
2058
2097
  ok: !1,
@@ -2060,15 +2099,15 @@ function Gi(e, t, n) {
2060
2099
  from: t.from
2061
2100
  };
2062
2101
  }
2063
- let r = Wi(e, t).find((t) => Ti(e, t));
2102
+ let r = Zi(e, t).find((t) => Mi(e, t));
2064
2103
  return {
2065
2104
  rule: "usage",
2066
2105
  ok: !0,
2067
2106
  message: r ? `usage rules on {${r.path}} leave "${n}" open` : `{${t.path}} has no usage rule against "${n}"`
2068
2107
  };
2069
2108
  }
2070
- function Ki(e, t) {
2071
- let n = Hi.map((n) => Gi(e, t, n)), r = Hi.filter((e, t) => n[t].ok);
2109
+ function $i(e, t) {
2110
+ let n = Yi.map((n) => Qi(e, t, n)), r = Yi.filter((e, t) => n[t].ok);
2072
2111
  return r.length > 0 ? {
2073
2112
  rule: "usage",
2074
2113
  ok: !0,
@@ -2080,22 +2119,22 @@ function Ki(e, t) {
2080
2119
  from: n[0].from
2081
2120
  };
2082
2121
  }
2083
- var qi = (e, t) => {
2084
- let n = e.type === "color" ? et(String(e.value)) : void 0;
2122
+ var ea = (e, t) => {
2123
+ let n = e.type === "color" ? r(String(e.value)) : void 0;
2085
2124
  if (!n) throw new K(`{${e.path}} (${t}) is not a color blazon can read: it is ${e.type ?? "untyped"} with the value ${String(e.value)}.`);
2086
2125
  return n;
2087
2126
  };
2088
- function Ji(e, t, n, r = "text", i) {
2127
+ function ta(e, t, n, r = "text", i, a) {
2089
2128
  if (i !== void 0) return {
2090
- ...Ji(Si(e, i), t, n, r),
2129
+ ...ta(ki(e, i), t, n, r, void 0, i),
2091
2130
  theme: i
2092
2131
  };
2093
- if (!Bi.includes(r)) throw new K(`"${String(r)}" is not a role blazon can judge. Use ${Bi.map((e) => `"${e}"`).join(" or ")}.`);
2094
- let a = yi(e, t), o = yi(e, n), s = f(qi(a, "foreground"), qi(o, "background")), c = Ui.find((e) => s >= l[e]) ?? "fail", u = `${s.toFixed(2)}:1`, d = Math.round(s * 100) / 100;
2132
+ if (!qi.includes(r)) throw new K(`"${String(r)}" is not a role blazon can judge. Use ${qi.map((e) => `"${e}"`).join(" or ")}.`);
2133
+ let o = Ei(e, t, a), s = Ei(e, n, a), c = g(ea(o, "foreground"), ea(s, "background")), l = Xi.find((e) => c >= f[e]) ?? "fail", u = `${c.toFixed(2)}:1`, d = Math.round(c * 100) / 100;
2095
2134
  if (r === "ui") {
2096
2135
  let t = [
2097
- Ki(e, a),
2098
- Gi(e, o, "background"),
2136
+ $i(e, o),
2137
+ Qi(e, s, "background"),
2099
2138
  {
2100
2139
  rule: "pairs",
2101
2140
  ok: !0,
@@ -2103,30 +2142,30 @@ function Ji(e, t, n, r = "text", i) {
2103
2142
  },
2104
2143
  {
2105
2144
  rule: "contrast",
2106
- ok: s >= Vi,
2107
- message: `non-text contrast needs ${Vi}:1, this is ${u}`
2145
+ ok: c >= Ji,
2146
+ message: `non-text contrast needs ${Ji}:1, this is ${u}`
2108
2147
  }
2109
2148
  ], n = t.find((e) => !e.ok), i = n ? n.message : t[t.length - 1].message;
2110
2149
  return {
2111
- fg: a.path,
2112
- bg: o.path,
2150
+ fg: o.path,
2151
+ bg: s.path,
2113
2152
  role: r,
2114
2153
  allowed: n === void 0,
2115
2154
  reason: i,
2116
2155
  checks: t,
2117
2156
  contrast: {
2118
2157
  ratio: d,
2119
- level: c,
2120
- threshold: Vi
2158
+ level: l,
2159
+ threshold: Ji
2121
2160
  }
2122
2161
  };
2123
2162
  }
2124
- let p = [Gi(e, a, "text"), Gi(e, o, "background")], m = Di(e), h = S(e.tokens.items, m, a.path, o.path);
2163
+ let p = [Qi(e, o, "text"), Qi(e, s, "background")], m = Pi(e), h = it(e.tokens.items, m, o.path, s.path);
2125
2164
  if (h.length > 0) for (let e of h) {
2126
- let t = l[e.min];
2165
+ let t = f[e.min];
2127
2166
  p.push({
2128
2167
  rule: "pairs",
2129
- ok: s >= t,
2168
+ ok: c >= t,
2130
2169
  message: `pairs on ${e.from} list ${e.fg} on ${e.bg}: ${e.min} needs ${t}:1, this is ${u}`,
2131
2170
  from: e.from
2132
2171
  });
@@ -2134,7 +2173,7 @@ function Ji(e, t, n, r = "text", i) {
2134
2173
  else m.length > 0 ? p.push({
2135
2174
  rule: "pairs",
2136
2175
  ok: !1,
2137
- message: `no pair lists {${a.path}} on {${o.path}}; the brand lists ${m.length} pair${m.length === 1 ? "" : "s"} and only those may sit together. Component tokens are not read for pairs: to allow this pair, declare it in \`pairs\` on a token group (docs/manual/02-tokens.md, "Contrast pairs")`
2176
+ message: `no pair lists {${o.path}} on {${s.path}}; the brand lists ${m.length} pair${m.length === 1 ? "" : "s"} and only those may sit together. Component tokens are not read for pairs: to allow this pair, declare it in \`pairs\` on a token group (docs/manual/02-tokens.md, "Contrast pairs")`
2138
2177
  }) : p.push({
2139
2178
  rule: "pairs",
2140
2179
  ok: !0,
@@ -2143,34 +2182,34 @@ function Ji(e, t, n, r = "text", i) {
2143
2182
  p.push({
2144
2183
  rule: "contrast",
2145
2184
  ok: !0,
2146
- message: `contrast is ${u}${c === "fail" ? ", below every WCAG level" : `, which meets ${c}`} (reported, never a rule of its own)`
2185
+ message: `contrast is ${u}${l === "fail" ? ", below every WCAG level" : `, which meets ${l}`} (reported, never a rule of its own)`
2147
2186
  });
2148
- let g = p.find((e) => !e.ok && e.rule !== "contrast") ?? void 0, _ = g === void 0, v = g ? g.message : (p.find((e) => e.rule === "pairs" && e.from) ?? p[p.length - 1]).message;
2187
+ let _ = p.find((e) => !e.ok && e.rule !== "contrast") ?? void 0, v = _ === void 0, y = _ ? _.message : (p.find((e) => e.rule === "pairs" && e.from) ?? p[p.length - 1]).message;
2149
2188
  return {
2150
- fg: a.path,
2151
- bg: o.path,
2189
+ fg: o.path,
2190
+ bg: s.path,
2152
2191
  role: r,
2153
- allowed: _,
2154
- reason: v,
2192
+ allowed: v,
2193
+ reason: y,
2155
2194
  checks: p,
2156
2195
  contrast: {
2157
2196
  ratio: d,
2158
- level: c
2197
+ level: l
2159
2198
  }
2160
2199
  };
2161
2200
  }
2162
- function Yi(e) {
2201
+ function na(e) {
2163
2202
  if (!e.allowed) return e;
2164
2203
  let { checks: t, ...n } = e;
2165
2204
  return n;
2166
2205
  }
2167
- function Xi(e, t, n = "text", r) {
2206
+ function ra(e, t, n = "text", r) {
2168
2207
  if (t.length === 0) throw new K("give at least one pair.");
2169
2208
  if (t.length > 50) throw new K(`give at most 50 pairs in one call; this call has ${t.length}.`);
2170
- let i = r === void 0 ? e : Si(e, r);
2209
+ let i = r === void 0 ? e : ki(e, r);
2171
2210
  return t.map((e, t) => {
2172
2211
  try {
2173
- let t = Ji(i, e.fg, e.bg, n);
2212
+ let t = ta(i, e.fg, e.bg, n, void 0, r);
2174
2213
  return r === void 0 ? t : {
2175
2214
  ...t,
2176
2215
  theme: r
@@ -2181,20 +2220,20 @@ function Xi(e, t, n = "text", r) {
2181
2220
  });
2182
2221
  }
2183
2222
  // src/core/read/fonts.ts
2184
- function Zi(e, t, n) {
2185
- let r = t.fonts ?? [], i = Ie(t.fonts, n), a = /* @__PURE__ */ new Map();
2223
+ function ia(e, t, n) {
2224
+ let r = t.fonts ?? [], i = de(t.fonts, n), a = /* @__PURE__ */ new Map();
2186
2225
  for (let t of e.tokens.items) {
2187
- let e = t.resolvedValue, n = t.type === "fontFamily" ? (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "string") : void 0, r = t.type === "fontFamily" ? Me(e) : t.type === "typography" && typeof e == "object" && e ? Me(e.fontFamily) : void 0;
2226
+ let e = t.resolvedValue, n = t.type === "fontFamily" ? (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "string") : void 0, r = t.type === "fontFamily" ? Le(e) : t.type === "typography" && typeof e == "object" && e ? Le(e.fontFamily) : void 0;
2188
2227
  if (!r) continue;
2189
2228
  let o = r.toLowerCase(), s = a.get(o);
2190
2229
  s ? (s.tokens.push(t.path), !s.stack && n && (s.stack = n)) : a.set(o, {
2191
2230
  family: r,
2192
2231
  tokens: [t.path],
2193
2232
  ...n && { stack: n },
2194
- system: me.has(o),
2233
+ system: Ce.has(o),
2195
2234
  loaded: i.families.has(o) ? !0 : i.opaque ? null : !1,
2196
2235
  ...t.blazon.webFont !== void 0 && { webFont: t.blazon.webFont },
2197
- ...t.blazon.font && { font: t.blazon.font }
2236
+ ...t.blazon.font && { font: u(t.blazon.font) }
2198
2237
  });
2199
2238
  }
2200
2239
  let o = (t) => e.theme[t] || e.themeTokens?.[t] ? {
@@ -2202,8 +2241,8 @@ function Zi(e, t, n) {
2202
2241
  value: e.theme[t]
2203
2242
  } : void 0;
2204
2243
  return {
2205
- stylesheets: r.filter((e) => !ye(e)),
2206
- files: r.filter(ye).map((e) => ({
2244
+ stylesheets: r.filter((e) => !Te(e)),
2245
+ files: r.filter(Te).map((e) => ({
2207
2246
  family: e.family,
2208
2247
  file: e.file,
2209
2248
  ...e.weight !== void 0 && { weight: e.weight },
@@ -2216,22 +2255,22 @@ function Zi(e, t, n) {
2216
2255
  families: [...a.values()]
2217
2256
  };
2218
2257
  }
2219
- function Qi(e, t) {
2258
+ function aa(e, t) {
2220
2259
  let n = e.stylesheets.map((e) => `/* Stylesheet, not fetched by blazon: ${e.replace(/\*\//g, "*%2F")} */`);
2221
2260
  for (let r of e.files) {
2222
- let e = ge(r.file);
2261
+ let e = Oe(r.file);
2223
2262
  if (!e) {
2224
2263
  n.push(`/* ${r.file.replace(/\*\//g, "*%2F")}: not a font file blazon embeds, so no rule */`);
2225
2264
  continue;
2226
2265
  }
2227
2266
  let i = t === void 0 ? r.file : `${t.endsWith("/") ? t : `${t}/`}${r.file.split("/").pop()}`;
2228
- n.push(Ue(r, `url("${encodeURI(i).replace(/"/g, "%22")}") format("${e}")`, !0));
2267
+ n.push(Pe(r, `url("${encodeURI(i).replace(/"/g, "%22")}") format("${e}")`, !0));
2229
2268
  }
2230
2269
  return n.length === 0 ? "/* The config lists no fonts. */\n" : `${n.join("\n\n")}\n`;
2231
2270
  }
2232
2271
  // src/core/read/logo.ts
2233
- function $i(e, t, n) {
2234
- let r = ne(t), i = O.resolve(n, t.assetsDir), a = ie(t.assets, n), o = (e) => O.relative(n, T(e, i, a)).split(O.sep).join("/"), s = ["onLight", "onDark"].flatMap((t) => {
2272
+ function oa(e, t, n) {
2273
+ let r = oe(t), i = O.resolve(n, t.assetsDir), a = se(t.assets, n), o = (e) => O.relative(n, ae(e, i, a)).split(O.sep).join("/"), s = ["onLight", "onDark"].flatMap((t) => {
2235
2274
  let n = r[t];
2236
2275
  if (!n) return [];
2237
2276
  let i = t === "onLight" ? e.logo?.onLightAsset : e.logo?.onDarkAsset, a = t === "onLight" ? e.logo?.onLightInk : e.logo?.onDarkInk;
@@ -2245,16 +2284,16 @@ function $i(e, t, n) {
2245
2284
  });
2246
2285
  return {
2247
2286
  variants: s,
2248
- assets: e.assets.logos.map((e) => {
2249
- let t = T(e, i, a);
2287
+ assets: [...new Set(e.assets.logos.map((e) => e.id))].map((t) => {
2288
+ let c = ze(e.assets.logos, t), l = c.map((e) => ae(e, i, a));
2250
2289
  return {
2251
- id: e.id,
2252
- file: o(e),
2253
- variants: s.filter((e) => r[e.variant] ? d(O.resolve(n, r[e.variant]), t) : !1).map((e) => e.variant),
2254
- rules: e.meta ?? {}
2290
+ id: t,
2291
+ files: c.map(o),
2292
+ variants: s.filter((e) => r[e.variant] ? l.some((t) => d(O.resolve(n, r[e.variant]), t)) : !1).map((e) => e.variant),
2293
+ rules: c[0].meta ?? {}
2255
2294
  };
2256
2295
  }),
2257
- forbidden: Mi(e, "").flatMap((e) => e.logo ? [{
2296
+ forbidden: zi(e, "").flatMap((e) => e.logo ? [{
2258
2297
  at: e.at,
2259
2298
  deny: e.logo.deny,
2260
2299
  ...e.logo.reason && { reason: e.logo.reason }
@@ -2263,16 +2302,16 @@ function $i(e, t, n) {
2263
2302
  }
2264
2303
  // src/cli/read.ts
2265
2304
  async function J(e) {
2266
- let t = await R(e), n = await D(t, e), r = y(n.findings);
2267
- r.length > 0 && console.error(s.yellow(`blazon: this brand has ${r.length} error(s), so a value below may be wrong; run blazon check.`));
2268
- let { problems: i, mismatch: a } = Qe(e);
2269
- for (let e of i) console.error(s.yellow(`blazon: ${e.message}`));
2270
- return a && console.error(s.yellow(fe(a))), {
2305
+ let t = await R(e), n = await T(t, e), r = b(n.findings);
2306
+ r.length > 0 && console.error(a.yellow(`blazon: this brand has ${r.length} error(s), so a value below may be wrong; run blazon check.`));
2307
+ let { problems: i, mismatch: o } = _e(e);
2308
+ for (let e of i) console.error(a.yellow(`blazon: ${e.message}`));
2309
+ return o && console.error(a.yellow(Qe(o))), {
2271
2310
  config: t,
2272
2311
  data: n
2273
2312
  };
2274
2313
  }
2275
- function ea(e) {
2314
+ function sa(e) {
2276
2315
  try {
2277
2316
  return e();
2278
2317
  } catch (e) {
@@ -2286,12 +2325,12 @@ function Y(e, t, n) {
2286
2325
  ...n
2287
2326
  }, null, 2)}\n`);
2288
2327
  }
2289
- function ta(e, t = " ") {
2328
+ function ca(e, t = " ") {
2290
2329
  let n = e.filter((e) => e[1] !== void 0), r = Math.max(0, ...n.map(([e]) => e.length));
2291
- for (let [e, i] of n) console.log(`${t}${s.dim(e.padEnd(r))} ${i}`);
2330
+ for (let [e, i] of n) console.log(`${t}${a.dim(e.padEnd(r))} ${i}`);
2292
2331
  }
2293
2332
  // src/cli/commands/doctor.ts
2294
- var na = [
2333
+ var la = [
2295
2334
  "blazon.brand-deck",
2296
2335
  "blazon.favicons",
2297
2336
  "blazon.logo-geometry",
@@ -2299,15 +2338,15 @@ var na = [
2299
2338
  "blazon.press-kit",
2300
2339
  "blazon.print-book",
2301
2340
  "blazon.social-cards"
2302
- ], ra = (e) => {
2341
+ ], ua = (e) => {
2303
2342
  try {
2304
2343
  return k.accessSync(e, k.constants.X_OK), k.statSync(e).isFile();
2305
2344
  } catch {
2306
2345
  return !1;
2307
2346
  }
2308
2347
  };
2309
- function ia(e = process.env) {
2310
- if (e.BLAZON_CHROME) return ra(e.BLAZON_CHROME);
2348
+ function da(e = process.env) {
2349
+ if (e.BLAZON_CHROME) return ua(e.BLAZON_CHROME);
2311
2350
  let t = [];
2312
2351
  if (process.platform === "darwin") t.push("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
2313
2352
  else if (process.platform === "win32") for (let n of [
@@ -2316,19 +2355,19 @@ function ia(e = process.env) {
2316
2355
  e.LOCALAPPDATA
2317
2356
  ]) n && t.push(O.join(n, "Google", "Chrome", "Application", "chrome.exe"));
2318
2357
  else t.push("/opt/google/chrome/chrome", ...(e.PATH ?? "").split(O.delimiter).filter(Boolean).flatMap((e) => ["google-chrome", "google-chrome-stable"].map((t) => O.join(e, t))));
2319
- return t.some(ra);
2358
+ return t.some(ua);
2320
2359
  }
2321
- var aa = () => {
2322
- let e = JSON.parse(k.readFileSync(O.join(we(), "package.json"), "utf-8"));
2360
+ var fa = () => {
2361
+ let e = JSON.parse(k.readFileSync(O.join(et(), "package.json"), "utf-8"));
2323
2362
  return {
2324
2363
  nodeVersion: process.version,
2325
2364
  engine: e.engines?.node,
2326
- hostProblem: (e) => Le(e, { final: "dir" }),
2327
- chrome: () => ia(),
2328
- identity: ce()
2365
+ hostProblem: (e) => p(e, { final: "dir" }),
2366
+ chrome: () => da(),
2367
+ identity: qe()
2329
2368
  };
2330
2369
  };
2331
- function oa(e, t) {
2370
+ function pa(e, t) {
2332
2371
  let n = /^>=\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?$/.exec(t.trim()), r = /^v?(\d+)\.(\d+)\.(\d+)/.exec(e);
2333
2372
  if (!n || !r) return;
2334
2373
  let i = [
@@ -2343,14 +2382,14 @@ function oa(e, t) {
2343
2382
  for (let e = 0; e < 3; e++) if (a[e] !== i[e]) return a[e] > i[e];
2344
2383
  return !0;
2345
2384
  }
2346
- function sa(e) {
2385
+ function ma(e) {
2347
2386
  if (!e.engine) return {
2348
2387
  id: "node",
2349
2388
  status: "warn",
2350
2389
  message: `Node ${e.nodeVersion}; blazon's package.json names no engines range to compare`,
2351
2390
  fix: "Reinstall blazon."
2352
2391
  };
2353
- let t = oa(e.nodeVersion, e.engine);
2392
+ let t = pa(e.nodeVersion, e.engine);
2354
2393
  return t === void 0 ? {
2355
2394
  id: "node",
2356
2395
  status: "warn",
@@ -2367,7 +2406,7 @@ function sa(e) {
2367
2406
  fix: `Install Node ${e.engine.replace(/^>=\s*/, "")} or newer, such as with nvm install ${e.engine.replace(/^>=\s*v?(\d+).*$/, "$1")}.`
2368
2407
  };
2369
2408
  }
2370
- async function ca(e) {
2409
+ async function ha(e) {
2371
2410
  try {
2372
2411
  let t = await R(e);
2373
2412
  return {
@@ -2387,14 +2426,14 @@ async function ca(e) {
2387
2426
  } };
2388
2427
  }
2389
2428
  }
2390
- function la(e, t, n) {
2429
+ function ga(e, t, n) {
2391
2430
  let r = t.hostProblem(e);
2392
2431
  if (!r) return {
2393
2432
  id: "plugin-host",
2394
2433
  status: "ok",
2395
2434
  message: `${e} is a folder blazon will run plugins from`
2396
2435
  };
2397
- let i = /written by group or others/.test(r) ? Ye(e) : "Run blazon from a folder under your own home folder that only you can write.";
2436
+ let i = /written by group or others/.test(r) ? C(e) : "Run blazon from a folder under your own home folder that only you can write.";
2398
2437
  return {
2399
2438
  id: "plugin-host",
2400
2439
  status: n > 0 ? "fail" : "warn",
@@ -2402,8 +2441,8 @@ function la(e, t, n) {
2402
2441
  fix: i
2403
2442
  };
2404
2443
  }
2405
- function ua(e, t) {
2406
- let n = [...new Set((t?.plugins ?? []).map((e) => e.name).filter((e) => na.includes(e)))];
2444
+ function _a(e, t) {
2445
+ let n = [...new Set((t?.plugins ?? []).map((e) => e.name).filter((e) => la.includes(e)))];
2407
2446
  return n.length === 0 ? {
2408
2447
  id: "chrome",
2409
2448
  status: "ok",
@@ -2419,44 +2458,44 @@ function ua(e, t) {
2419
2458
  fix: "Install Google Chrome, or set BLAZON_CHROME to a Chrome or Chromium program; or take the plugin out of blazon.json."
2420
2459
  };
2421
2460
  }
2422
- function da(e, t) {
2461
+ function va(e, t) {
2423
2462
  if (!k.existsSync(O.join(e, "blazon.lock"))) return {
2424
2463
  id: "lock",
2425
2464
  status: "ok",
2426
2465
  message: "no blazon.lock: this book is not pinned to a blazon build"
2427
2466
  };
2428
- let n = qe(e, t.identity)[0];
2467
+ let n = tt(e, t.identity)[0];
2429
2468
  return n ? {
2430
2469
  id: "lock",
2431
2470
  status: "fail",
2432
2471
  message: n.message,
2433
- fix: n.fix ?? de[n.code].fix
2472
+ fix: n.fix ?? Ye[n.code].fix
2434
2473
  } : {
2435
2474
  id: "lock",
2436
2475
  status: "ok",
2437
2476
  message: "blazon.lock matches the blazon that is running"
2438
2477
  };
2439
2478
  }
2440
- async function fa(e, t = aa()) {
2441
- let n = await ca(e);
2479
+ async function ya(e, t = fa()) {
2480
+ let n = await ha(e);
2442
2481
  return [
2443
- sa(t),
2482
+ ma(t),
2444
2483
  n.check,
2445
- la(e, t, n.config?.plugins?.length ?? 0),
2446
- ua(t, n.config),
2447
- da(e, t)
2484
+ ga(e, t, n.config?.plugins?.length ?? 0),
2485
+ _a(t, n.config),
2486
+ va(e, t)
2448
2487
  ];
2449
2488
  }
2450
- var pa = {
2451
- ok: s.green,
2452
- warn: s.yellow,
2453
- fail: s.red
2489
+ var ba = {
2490
+ ok: a.green,
2491
+ warn: a.yellow,
2492
+ fail: a.red
2454
2493
  };
2455
- async function ma(e = process.cwd(), t = {}) {
2456
- let n = await fa(e), r = !n.some((e) => e.status === "fail");
2494
+ async function xa(e = process.cwd(), t = {}) {
2495
+ let n = await ya(e), r = !n.some((e) => e.status === "fail");
2457
2496
  if (t.json) return Y("doctor", r, { checks: n }), +!r;
2458
2497
  console.log();
2459
- for (let e of n) console.log(` ${pa[e.status](e.status.padEnd(4))} ${e.id.padEnd(11)} ${e.message}`), e.status !== "ok" && e.fix && console.log(s.dim(` fix: ${e.fix}`));
2498
+ for (let e of n) console.log(` ${ba[e.status](e.status.padEnd(4))} ${e.id.padEnd(11)} ${e.message}`), e.status !== "ok" && e.fix && console.log(a.dim(` fix: ${e.fix}`));
2460
2499
  return console.log(), +!r;
2461
2500
  }
2462
2501
  // src/core/operations/list.ts
@@ -2465,20 +2504,20 @@ var X = {
2465
2504
  destructiveHint: !1,
2466
2505
  idempotentHint: !0,
2467
2506
  openWorldHint: !1
2468
- }, ha = {
2507
+ }, Sa = {
2469
2508
  type: "string",
2470
2509
  description: "The brand folder. Default: the current folder"
2471
- }, ga = (e) => ({
2510
+ }, Ca = (e) => ({
2472
2511
  type: "string",
2473
2512
  maxLength: 200,
2474
2513
  pattern: "^[A-Za-z0-9_][A-Za-z0-9_-]*$",
2475
2514
  description: `${e} in this context of the resolver's theme modifier, such as dark. An unknown theme is refused with the list of themes. Default: the default tokens`
2476
- }), _a = "^[A-Za-z0-9_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_][A-Za-z0-9_-]*)*$", Z = (e, t) => ({
2515
+ }), wa = "^[A-Za-z0-9_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_][A-Za-z0-9_-]*)*$", Z = (e, t) => ({
2477
2516
  type: "object",
2478
2517
  properties: e,
2479
2518
  ...t.length > 0 && { required: t },
2480
2519
  additionalProperties: !1
2481
- }), va = {
2520
+ }), Ta = {
2482
2521
  warnings: {
2483
2522
  type: "array",
2484
2523
  items: { type: "string" },
@@ -2523,7 +2562,7 @@ var X = {
2523
2562
  }, Q = (e, t) => ({
2524
2563
  type: "object",
2525
2564
  properties: {
2526
- ...va,
2565
+ ...Ta,
2527
2566
  ...e
2528
2567
  },
2529
2568
  required: [
@@ -2532,7 +2571,7 @@ var X = {
2532
2571
  ...t
2533
2572
  ],
2534
2573
  additionalProperties: {}
2535
- }), ya = [
2574
+ }), Ea = [
2536
2575
  {
2537
2576
  name: "check_brand",
2538
2577
  title: "Check the brand",
@@ -2638,7 +2677,7 @@ var X = {
2638
2677
  {
2639
2678
  name: "list_tokens",
2640
2679
  title: "List the tokens",
2641
- description: `Lists the design tokens of the brand, or of one group, type or tier, each with its path, type, tier and value, in the order the token files write them. Use it to find a path or to read many values at once. \`tier\` (primitive, semantic or component) keeps to one layer of the brand. \`theme\` gives the values as that theme resolves them, and \`defaultValue\` on a token the theme changes; \`themes\` names the themes the brand has. For a token's CSS variable names and rules use get_token; for the brand's usage rules use get_rules. An answer over ${zi} characters is cut to whole tokens, and \`tokensTotal\` says how many matched: narrow with \`group\`, \`type\` or \`tier\`.`,
2680
+ description: `Lists the design tokens of the brand, or of one group, type or tier, each with its path, type, tier and value, in the order the token files write them. Use it to find a path or to read many values at once. \`tier\` (primitive, semantic or component) keeps to one layer of the brand. \`theme\` gives the values as that theme resolves them, and \`defaultValue\` on a token the theme changes; \`themes\` names the themes the brand has. For a token's CSS variable names and rules use get_token; for the brand's usage rules use get_rules. An answer over ${Ki} characters is cut to whole tokens, and \`tokensTotal\` says how many matched: narrow with \`group\`, \`type\` or \`tier\`.`,
2642
2681
  annotations: X,
2643
2682
  inputSchema: Z({
2644
2683
  group: {
@@ -2659,7 +2698,7 @@ var X = {
2659
2698
  maxLength: 40,
2660
2699
  pattern: "^[A-Za-z0-9_][A-Za-z0-9_-]*$"
2661
2700
  },
2662
- theme: ga("List the values"),
2701
+ theme: Ca("List the values"),
2663
2702
  dir: {
2664
2703
  type: "string",
2665
2704
  description: "The brand folder. Default: the current folder"
@@ -2745,7 +2784,7 @@ var X = {
2745
2784
  },
2746
2785
  {
2747
2786
  property: "theme",
2748
- value: "<name>",
2787
+ value: "name",
2749
2788
  description: "list the values as this context of the resolver's theme modifier resolves them (such as dark), and the default value of each token it changes; exits 2 for an unknown theme"
2750
2789
  }
2751
2790
  ]
@@ -2763,7 +2802,7 @@ var X = {
2763
2802
  pattern: "^[A-Za-z0-9_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_][A-Za-z0-9_-]*)*$",
2764
2803
  description: "The token path, for example color.brand.primary. A path from list_tokens works"
2765
2804
  },
2766
- theme: ga("Read the value"),
2805
+ theme: Ca("Read the value"),
2767
2806
  dir: {
2768
2807
  type: "string",
2769
2808
  description: "The brand folder. Default: the current folder"
@@ -2803,7 +2842,7 @@ var X = {
2803
2842
  summary: "Read one token: its value, type, CSS variable name in theme.css, its usage, pairs and logo rules, and the file it is in. To find a path, use blazon list",
2804
2843
  options: [{
2805
2844
  property: "theme",
2806
- value: "<name>",
2845
+ value: "name",
2807
2846
  description: "read the value as this context of the resolver's theme modifier resolves it (such as dark), and the default value when it differs; exits 2 for an unknown theme"
2808
2847
  }, {
2809
2848
  property: "json",
@@ -2814,7 +2853,7 @@ var X = {
2814
2853
  {
2815
2854
  name: "get_rules",
2816
2855
  title: "Read the brand rules",
2817
- description: `Lists the brand rules (allowed uses, approved color pairs, logo restrictions) of a token or a group of tokens, or of the whole brand when no path is given. The whole brand can be larger than the size limit (${zi} characters): give a path, or read the resource blazon://rules, which is not cut.`,
2856
+ description: `Lists the brand rules (allowed uses, approved color pairs, logo restrictions) of a token or a group of tokens, or of the whole brand when no path is given. The whole brand can be larger than the size limit (${Ki} characters): give a path, or read the resource blazon://rules, which is not cut.`,
2818
2857
  annotations: X,
2819
2858
  inputSchema: Z({
2820
2859
  path: {
@@ -2890,13 +2929,13 @@ var X = {
2890
2929
  fg: {
2891
2930
  type: "string",
2892
2931
  maxLength: 200,
2893
- pattern: _a,
2932
+ pattern: wa,
2894
2933
  description: "The text color token path"
2895
2934
  },
2896
2935
  bg: {
2897
2936
  type: "string",
2898
2937
  maxLength: 200,
2899
- pattern: _a,
2938
+ pattern: wa,
2900
2939
  description: "The background color token path"
2901
2940
  }
2902
2941
  },
@@ -2993,7 +3032,7 @@ var X = {
2993
3032
  },
2994
3033
  {
2995
3034
  property: "theme",
2996
- value: "<name>",
3035
+ value: "name",
2997
3036
  description: "judge the pair in this context of the resolver's theme modifier (such as dark); exits 2 for an unknown theme"
2998
3037
  },
2999
3038
  {
@@ -3110,7 +3149,7 @@ var X = {
3110
3149
  type: "string",
3111
3150
  description: "Only this part of the document, by its dotted path, such as theme.roles"
3112
3151
  },
3113
- dir: ha
3152
+ dir: Sa
3114
3153
  }, []),
3115
3154
  cli: {
3116
3155
  rank: 7,
@@ -3126,10 +3165,47 @@ var X = {
3126
3165
  },
3127
3166
  mcp: !1
3128
3167
  }
3129
- ], ba = (e) => e.filter((e) => e.mcp !== !1), xa = (e) => e.filter((e) => e.cli !== !1).sort((e, t) => e.cli.rank - t.cli.rank);
3168
+ ], Da = (e) => e.filter((e) => e.mcp !== !1), Oa = (e) => e.filter((e) => e.cli !== !1).sort((e, t) => e.cli.rank - t.cli.rank), ka = (e) => {
3169
+ try {
3170
+ return k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory() ?? !1;
3171
+ } catch {
3172
+ return !1;
3173
+ }
3174
+ };
3175
+ function Aa(e) {
3176
+ if (!ka(e)) return !1;
3177
+ let t = O.join(e, "blazon.json");
3178
+ return k.statSync(t, { throwIfNoEntry: !1 })?.isFile() ? !0 : ka(O.join(e, "tokens"));
3179
+ }
3180
+ var ja = /* @__PURE__ */ new Set([
3181
+ "no-folder",
3182
+ "no-tokens-folder",
3183
+ "unknown-token"
3184
+ ]), Ma = (e) => e.map((e) => /^<.*>$/.test(e) ? e : bt(e)).join(" ");
3185
+ function Na(e, t, n, r, i) {
3186
+ if (!(i instanceof j) || !ja.has(i.code)) return;
3187
+ let a = n.map((e) => typeof e == "string" ? e : void 0), o = t.findIndex((e, t) => {
3188
+ let n = a[t];
3189
+ return e === "dir" || n === void 0 || !Aa(n) ? !1 : i.code !== "unknown-token" || i.message.includes(`"${n}"`);
3190
+ });
3191
+ if (o === -1) return;
3192
+ let s = a[o], c = t[o], l = a.filter((e, t) => e !== void 0 && t !== o), u = l.length === 0 ? [`<${c}>`] : [], d = Ma([
3193
+ "blazon",
3194
+ ...e,
3195
+ ...l.length > 0 ? l : u,
3196
+ s
3197
+ ]), f = Ma([
3198
+ "blazon",
3199
+ ...e,
3200
+ ...l.length > 0 || r.has(c) ? [...l, ...u] : [],
3201
+ "--cwd",
3202
+ s
3203
+ ]);
3204
+ return `"${s}" was read as ${c === "path" ? "the path" : `the ${c} (a token path)`}, not a folder; the folder goes last: ${d}, or ${f}`;
3205
+ }
3130
3206
  // src/cli/handlers/rules.ts
3131
- function Sa(e) {
3132
- let t = (e) => s.dim(`(on ${e})`);
3207
+ function Pa(e) {
3208
+ let t = (e) => a.dim(`(on ${e})`);
3133
3209
  return [
3134
3210
  ...e.role ? [`role ${e.role.value} ${t(e.role.from)}`] : [],
3135
3211
  ...e.usage ? [`usage ${[e.usage.deny && `deny ${e.usage.deny.join(", ")}`, e.usage.allow && `allow ${e.usage.allow.join(", ")}`].filter(Boolean).join("; ")} ${t(e.usage.from)}`] : [],
@@ -3138,7 +3214,7 @@ function Sa(e) {
3138
3214
  ...e.review ? [`review ${e.review.status}${e.review.by ? ` by ${e.review.by}` : ""}${e.review.at ? ` on ${e.review.at}` : ""} ${t(e.review.from)}`] : []
3139
3215
  ];
3140
3216
  }
3141
- function Ca(e) {
3217
+ function Fa(e) {
3142
3218
  return [
3143
3219
  ...e.role ? [`role ${e.role}`] : [],
3144
3220
  ...e.usage ? [`usage ${[e.usage.deny && `deny ${e.usage.deny.join(", ")}`, e.usage.allow && `allow ${e.usage.allow.join(", ")}`].filter(Boolean).join("; ")}`] : [],
@@ -3146,51 +3222,51 @@ function Ca(e) {
3146
3222
  ...e.logo ? [`logo deny ${e.logo.deny.join(", ")}${e.logo.reason ? `: ${e.logo.reason}` : ""}`] : []
3147
3223
  ];
3148
3224
  }
3149
- var wa = async ({ path: e }, { dir: t }) => {
3150
- let { data: n } = await J(t), r = vi(e ?? ""), i = r !== "" && n.tokens.byPath.has(r), a = ea(() => i ? {
3225
+ var Ia = async ({ path: e }, { dir: t }) => {
3226
+ let { data: n } = await J(t), r = Ti(e ?? ""), i = r !== "" && n.tokens.byPath.has(r), o = sa(() => i ? {
3151
3227
  path: r,
3152
3228
  kind: "token",
3153
- rules: Ai(n, yi(n, r))
3229
+ rules: Li(n, Ei(n, r))
3154
3230
  } : {
3155
3231
  path: r,
3156
3232
  kind: r === "" ? "brand" : "group",
3157
- entries: Mi(n, r)
3233
+ entries: zi(n, r)
3158
3234
  });
3159
3235
  return {
3160
3236
  command: "rules",
3161
3237
  passed: !0,
3162
3238
  status: 0,
3163
- body: a,
3239
+ body: o,
3164
3240
  text: () => {
3165
- if (console.log(), a.kind === "token") {
3166
- let e = Sa(a.rules);
3167
- console.log(` ${s.bold(a.path)}`), e.length === 0 && console.log(s.dim(" no rules apply to this token"));
3241
+ if (console.log(), o.kind === "token") {
3242
+ let e = Pa(o.rules);
3243
+ console.log(` ${a.bold(o.path)}`), e.length === 0 && console.log(a.dim(" no rules apply to this token"));
3168
3244
  for (let t of e) console.log(` ${t}`);
3169
3245
  } else {
3170
- a.entries.length === 0 && console.log(s.dim(` No rules are written ${r === "" ? "in this brand" : `at or under ${r}`}.`));
3171
- for (let e of a.entries) {
3172
- console.log(` ${s.bold(e.at)} ${s.dim(e.kind === "group" ? "group" : "token")}${e.inherited ? s.dim(", passes its rules down") : ""}`);
3173
- for (let t of Ca(e)) console.log(` ${t}`);
3246
+ o.entries.length === 0 && console.log(a.dim(` No rules are written ${r === "" ? "in this brand" : `at or under ${r}`}.`));
3247
+ for (let e of o.entries) {
3248
+ console.log(` ${a.bold(e.at)} ${a.dim(e.kind === "group" ? "group" : "token")}${e.inherited ? a.dim(", passes its rules down") : ""}`);
3249
+ for (let t of Fa(e)) console.log(` ${t}`);
3174
3250
  }
3175
3251
  }
3176
3252
  console.log();
3177
3253
  }
3178
3254
  };
3179
- }, Ta = async ({ path: e, theme: t }, { dir: n }) => {
3255
+ }, La = async ({ path: e, theme: t }, { dir: n }) => {
3180
3256
  let { data: r } = await J(n);
3181
- if (Li(r, String(e))) throw new M(`"${String(e)}" is a group of tokens, not one token; \`blazon list ${String(e)}\` lists its tokens.`, void 0, "not-a-token");
3182
- let i = ea(() => Pi(r, String(e), t));
3257
+ if (Wi(r, String(e))) throw new M(`"${String(e)}" is a group of tokens, not one token; \`blazon list ${String(e)}\` lists its tokens.`, void 0, "not-a-token");
3258
+ let i = sa(() => Vi(r, String(e), t));
3183
3259
  return {
3184
3260
  command: "get",
3185
3261
  passed: !0,
3186
3262
  status: 0,
3187
3263
  body: { token: i },
3188
- text: () => Ea(i)
3264
+ text: () => Ra(i)
3189
3265
  };
3190
3266
  };
3191
- function Ea(e) {
3267
+ function Ra(e) {
3192
3268
  let { names: t } = e;
3193
- console.log(`\n ${s.bold(e.path)}${e.deprecated ? s.yellow(" deprecated") : ""}`), ta([
3269
+ console.log(`\n ${a.bold(e.path)}${e.deprecated ? a.yellow(" deprecated") : ""}`), ca([
3194
3270
  ["value", String(e.value)],
3195
3271
  ["default", e.defaultValue === void 0 ? void 0 : String(e.defaultValue)],
3196
3272
  ["theme", e.theme],
@@ -3202,15 +3278,15 @@ function Ea(e) {
3202
3278
  ["typography.css", t.typographyClass && `.${t.typographyClass}`],
3203
3279
  ["written in", e.sourceFile]
3204
3280
  ]);
3205
- for (let t of e.contexts ?? []) console.log(` ${s.dim(`${t.modifier}=${t.context}`.padEnd(12))} ${String(t.value)} ${s.dim(t.selector)}`);
3206
- let n = Sa(e.rules);
3207
- console.log(`\n ${s.bold("Rules")}`), n.length === 0 && console.log(s.dim(" none written for this token"));
3281
+ for (let t of e.contexts ?? []) console.log(` ${a.dim(`${t.modifier}=${t.context}`.padEnd(12))} ${String(t.value)} ${a.dim(t.selector)}`);
3282
+ let n = Pa(e.rules);
3283
+ console.log(`\n ${a.bold("Rules")}`), n.length === 0 && console.log(a.dim(" none written for this token"));
3208
3284
  for (let e of n) console.log(` ${e}`);
3209
3285
  console.log();
3210
3286
  }
3211
3287
  // src/cli/handlers/list.ts
3212
- var Da = async ({ group: e, type: t, tier: n, theme: r }, { dir: i }) => {
3213
- let { data: a } = await J(i), o = ea(() => Ri(a, {
3288
+ var za = async ({ group: e, type: t, tier: n, theme: r }, { dir: i }) => {
3289
+ let { data: a } = await J(i), o = sa(() => Gi(a, {
3214
3290
  group: e,
3215
3291
  type: t,
3216
3292
  tier: n,
@@ -3228,23 +3304,23 @@ var Da = async ({ group: e, type: t, tier: n, theme: r }, { dir: i }) => {
3228
3304
  ...o.themes && { themes: o.themes },
3229
3305
  tokens: o.tokens
3230
3306
  },
3231
- text: () => Oa(o)
3307
+ text: () => Ba(o)
3232
3308
  };
3233
3309
  };
3234
- function Oa(e) {
3235
- if (e.tokens.length === 0) return console.log(s.dim(`\n no tokens${e.type ? ` of type ${e.type}` : ""}${e.tier ? ` of tier ${e.tier}` : ""}${e.group ? ` in ${e.group}` : ""}\n`));
3310
+ function Ba(e) {
3311
+ if (e.tokens.length === 0) return console.log(a.dim(`\n no tokens${e.type ? ` of type ${e.type}` : ""}${e.tier ? ` of tier ${e.tier}` : ""}${e.group ? ` in ${e.group}` : ""}\n`));
3236
3312
  let t = Math.max(...e.tokens.map((e) => e.path.length)), n = Math.max(...e.tokens.map((e) => (e.type ?? "").length)), r;
3237
3313
  for (let i of e.tokens) {
3238
3314
  let e = i.path.split(".")[0];
3239
- e !== r && console.log(`\n ${s.dim(e)}`), r = e;
3240
- let a = i.aliasOf ? ` ${s.dim(`-> ${i.aliasOf}`)}` : "", o = i.defaultValue === void 0 ? "" : ` ${s.dim(`(default ${String(i.defaultValue)})`)}`;
3241
- console.log(` ${i.path.padEnd(t)} ${s.dim((i.type ?? "").padEnd(n))} ${String(i.value)}${o}${a}`);
3315
+ e !== r && console.log(`\n ${a.dim(e)}`), r = e;
3316
+ let o = i.aliasOf ? ` ${a.dim(`-> ${i.aliasOf}`)}` : "", s = i.defaultValue === void 0 ? "" : ` ${a.dim(`(default ${String(i.defaultValue)})`)}`;
3317
+ console.log(` ${i.path.padEnd(t)} ${a.dim((i.type ?? "").padEnd(n))} ${String(i.value)}${s}${o}`);
3242
3318
  }
3243
3319
  let i = e.themes ? `; themes: ${e.themes.join(", ")}${e.theme ? ` (showing ${e.theme})` : ""}` : "";
3244
- console.log(`\n ${s.dim(`${e.tokens.length} token${e.tokens.length === 1 ? "" : "s"}; blazon get <path> shows one in full${i}`)}\n`);
3320
+ console.log(`\n ${a.dim(`${e.tokens.length} token${e.tokens.length === 1 ? "" : "s"}; blazon get <path> shows one in full${i}`)}\n`);
3245
3321
  }
3246
3322
  // src/cli/handlers/can.ts
3247
- function ka(e) {
3323
+ function Va(e) {
3248
3324
  return (e === void 0 ? [] : Array.isArray(e) ? e : [e]).map((e) => {
3249
3325
  let t = String(e).split(":");
3250
3326
  if (t.length !== 2 || !t[0] || !t[1]) throw new M(`--pair takes fg:bg, such as text.primary:surface.canvas; got "${String(e)}".`, void 0, "invalid-option-value");
@@ -3254,14 +3330,14 @@ function ka(e) {
3254
3330
  };
3255
3331
  });
3256
3332
  }
3257
- var Aa = async ({ fg: e, bg: t, role: n, theme: r, pairs: i, verbose: a }, { dir: o }) => {
3258
- let s = ka(i), c = e !== void 0 || t !== void 0;
3333
+ var Ha = async ({ fg: e, bg: t, role: n, theme: r, pairs: i, verbose: a }, { dir: o }) => {
3334
+ let s = Va(i), c = e !== void 0 || t !== void 0;
3259
3335
  if (s.length > 0 && c) throw new M("give fg and bg, or --pair, not both.", void 0, "conflicting-options");
3260
3336
  if (s.length === 0 && (e === void 0 || t === void 0)) throw new M("give fg and bg, or one or more --pair fg:bg.", void 0, "missing-argument");
3261
3337
  if (s.length > 50) throw new M(`give at most 50 pairs in one call; this call has ${s.length}.`, void 0, "invalid-option-value");
3262
- let l = a === !1, u = (e) => l ? Yi(e) : e, { data: d } = await J(o), f = n ?? "text";
3338
+ let l = a === !1, u = (e) => l ? na(e) : e, { data: d } = await J(o), f = n ?? "text";
3263
3339
  if (s.length > 0) {
3264
- let e = ea(() => Xi(d, s, f, r)).map(u), t = e.every((e) => e.allowed);
3340
+ let e = sa(() => ra(d, s, f, r)).map(u), t = e.every((e) => e.allowed);
3265
3341
  return {
3266
3342
  command: "can",
3267
3343
  passed: t,
@@ -3270,31 +3346,31 @@ var Aa = async ({ fg: e, bg: t, role: n, theme: r, pairs: i, verbose: a }, { dir
3270
3346
  allowed: t,
3271
3347
  results: e
3272
3348
  },
3273
- text: () => e.forEach((e) => ja(e))
3349
+ text: () => e.forEach((e) => Ua(e))
3274
3350
  };
3275
3351
  }
3276
- let p = u(ea(() => Ji(d, e, t, f, r)));
3352
+ let p = u(sa(() => ta(d, e, t, f, r)));
3277
3353
  return {
3278
3354
  command: "can",
3279
3355
  passed: p.allowed,
3280
3356
  status: +!p.allowed,
3281
3357
  body: p,
3282
- text: () => ja(p)
3358
+ text: () => Ua(p)
3283
3359
  };
3284
3360
  };
3285
- function ja(e) {
3286
- if (console.log(`\n ${e.allowed ? s.green("allowed") : s.red("denied")} ${e.fg} as ${e.role === "ui" ? "a non-text element (--role ui)" : "text"} on ${e.bg}${e.theme ? ` (theme ${e.theme})` : ""}`), console.log(` ${e.reason}`), e.checks && e.checks.length > 1) {
3361
+ function Ua(e) {
3362
+ if (console.log(`\n ${e.allowed ? a.green("allowed") : a.red("denied")} ${e.fg} as ${e.role === "ui" ? "a non-text element (--role ui)" : "text"} on ${e.bg}${e.theme ? ` (theme ${e.theme})` : ""}`), console.log(` ${e.reason}`), e.checks && e.checks.length > 1) {
3287
3363
  console.log();
3288
- for (let t of e.checks) console.log(` ${t.rule === "contrast" && e.role === "text" ? s.dim("info") : t.ok ? s.green("ok ") : s.red("no ")} ${t.message}`);
3364
+ for (let t of e.checks) console.log(` ${t.rule === "contrast" && e.role === "text" ? a.dim("info") : t.ok ? a.green("ok ") : a.red("no ")} ${t.message}`);
3289
3365
  }
3290
3366
  console.log();
3291
3367
  }
3292
3368
  // src/cli/handlers/fonts.ts
3293
- var Ma = async (e, { dir: t }) => {
3294
- let { config: n, data: r } = await J(t), i = Zi(r, n, t);
3369
+ var Wa = async (e, { dir: t }) => {
3370
+ let { config: n, data: r } = await J(t), i = ia(r, n, t);
3295
3371
  if (e.css === !0 || typeof e.base == "string") {
3296
3372
  if (e.css !== !0) throw new M("blazon fonts: --base goes with --css.", "Add --css, or leave --base out.", "conflicting-options");
3297
- let t = Qi(i, typeof e.base == "string" ? e.base : void 0);
3373
+ let t = aa(i, typeof e.base == "string" ? e.base : void 0);
3298
3374
  return {
3299
3375
  command: "fonts",
3300
3376
  passed: !0,
@@ -3311,18 +3387,18 @@ var Ma = async (e, { dir: t }) => {
3311
3387
  passed: !0,
3312
3388
  status: 0,
3313
3389
  body: i,
3314
- text: () => Na(i)
3390
+ text: () => Ga(i)
3315
3391
  };
3316
3392
  };
3317
- function Na(e) {
3318
- console.log(`\n ${s.bold("Loaded")}`), e.stylesheets.length + e.files.length === 0 && console.log(s.dim(" The config lists no fonts."));
3393
+ function Ga(e) {
3394
+ console.log(`\n ${a.bold("Loaded")}`), e.stylesheets.length + e.files.length === 0 && console.log(a.dim(" The config lists no fonts."));
3319
3395
  for (let t of e.stylesheets) console.log(` stylesheet ${t}`);
3320
3396
  for (let t of e.files) console.log(` file ${t.file} ${t.family}${t.weight === void 0 ? "" : `, weight ${t.weight}`}${t.style ? `, ${t.style}` : ""}`);
3321
- console.log(`\n ${s.bold("Named by the tokens")}`);
3322
- for (let [t, n] of Object.entries(e.roles)) console.log(` ${s.dim(t.padEnd(11))} ${n.token ?? ""} ${n.value ?? ""}`);
3397
+ console.log(`\n ${a.bold("Named by the tokens")}`);
3398
+ for (let [t, n] of Object.entries(e.roles)) console.log(` ${a.dim(t.padEnd(11))} ${n.token ?? ""} ${n.value ?? ""}`);
3323
3399
  for (let t of e.families) {
3324
3400
  let e = t.system ? "system font" : t.loaded === !0 ? "loaded" : t.loaded === null ? "maybe loaded by a stylesheet blazon cannot read" : t.webFont === void 0 ? "not loaded" : "not loaded, as the token says";
3325
- console.log(` ${t.family} ${s.dim(`${e}; ${t.tokens.join(", ")}`)}`), t.stack && t.stack.length > 1 && console.log(s.dim(` stack: ${t.stack.join(", ")}`));
3401
+ console.log(` ${t.family} ${a.dim(`${e}; ${t.tokens.join(", ")}`)}`), t.stack && t.stack.length > 1 && console.log(a.dim(` stack: ${t.stack.join(", ")}`)), t.font?.role && console.log(a.dim(` role: ${t.font.role}${t.font.fallbackFor ? `, stands in for ${t.font.fallbackFor}` : ""}`)), t.font?.reason && console.log(a.dim(` why: ${t.font.reason}`));
3326
3402
  }
3327
3403
  console.log();
3328
3404
  }
@@ -3331,22 +3407,22 @@ var $ = (e) => {
3331
3407
  if (typeof e != "object" || !e) return String(e);
3332
3408
  let t = e;
3333
3409
  return t.units === void 0 ? t.value === void 0 ? [t.width !== void 0 && `width ${$(t.width)}`, t.height !== void 0 && `height ${$(t.height)}`].filter(Boolean).join(", ") : `${t.value}${t.unit}` : `${t.units} unit${t.units === 1 ? "" : "s"}`;
3334
- }, Pa = async (e, { dir: t }) => {
3335
- let { config: n, data: r } = await J(t), i = $i(r, n, t);
3410
+ }, Ka = async (e, { dir: t }) => {
3411
+ let { config: n, data: r } = await J(t), i = oa(r, n, t);
3336
3412
  return {
3337
3413
  command: "logo",
3338
3414
  passed: !0,
3339
3415
  status: 0,
3340
3416
  body: i,
3341
- text: () => Fa(i)
3417
+ text: () => qa(i)
3342
3418
  };
3343
3419
  };
3344
- function Fa(e) {
3345
- console.log(`\n ${s.bold("Variants")}`), e.variants.length === 0 && console.log(s.dim(" No logo is configured."));
3346
- for (let t of e.variants) console.log(` ${t.variant.padEnd(8)} ${t.file}${t.found ? "" : s.red(" (not found)")}${t.ink ? ` ink ${t.ink}` : ""}${t.asset ? s.dim(` ${t.asset}`) : ""}`);
3420
+ function qa(e) {
3421
+ console.log(`\n ${a.bold("Variants")}`), e.variants.length === 0 && console.log(a.dim(" No logo is configured."));
3422
+ for (let t of e.variants) console.log(` ${t.variant.padEnd(8)} ${t.file}${t.found ? "" : a.red(" (not found)")}${t.ink ? ` ink ${t.ink}` : ""}${t.asset ? a.dim(` ${t.asset}`) : ""}`);
3347
3423
  for (let t of e.assets) {
3348
3424
  let e = t.rules;
3349
- console.log(`\n ${s.bold(t.id)} ${t.file}${t.variants.length ? s.dim(` used as ${t.variants.join(", ")}`) : ""}`);
3425
+ console.log(`\n ${a.bold(t.id)} ${t.files.join(", ")}${t.variants.length ? a.dim(` used as ${t.variants.join(", ")}`) : ""}`);
3350
3426
  let n = [
3351
3427
  ["lockup", e.lockup],
3352
3428
  ["ink", e.ink],
@@ -3360,18 +3436,18 @@ function Fa(e) {
3360
3436
  ["partnership", e.partnership && `gap ${$(e.partnership.gap)}${e.partnership.dividerHeight ? `, divider ${$(e.partnership.dividerHeight)}` : ""}`],
3361
3437
  ["initiative", e.initiative && `${e.initiative.name}, mark ${e.initiative.mark}, gap ${$(e.initiative.gap)}, ${e.initiative.position ?? "beside"}`]
3362
3438
  ];
3363
- for (let [e, t] of n) t !== void 0 && console.log(` ${s.dim(e.padEnd(12))} ${t}`);
3364
- for (let t of e.do ?? []) console.log(` ${s.dim("do")} ${t}`);
3365
- for (let t of e.dont ?? []) console.log(` ${s.dim("do not")} ${t}`);
3439
+ for (let [e, t] of n) t !== void 0 && console.log(` ${a.dim(e.padEnd(12))} ${t}`);
3440
+ for (let t of e.do ?? []) console.log(` ${a.dim("do")} ${t}`);
3441
+ for (let t of e.dont ?? []) console.log(` ${a.dim("do not")} ${t}`);
3366
3442
  }
3367
3443
  if (e.forbidden.length > 0) {
3368
- console.log(`\n ${s.bold("Forbidden on")}`);
3369
- for (let t of e.forbidden) console.log(` ${t.at} ${t.deny.join(", ")}${t.reason ? ` ${s.dim(t.reason)}` : ""}`);
3444
+ console.log(`\n ${a.bold("Forbidden on")}`);
3445
+ for (let t of e.forbidden) console.log(` ${t.at} ${t.deny.join(", ")}${t.reason ? ` ${a.dim(t.reason)}` : ""}`);
3370
3446
  }
3371
3447
  console.log();
3372
3448
  }
3373
3449
  // src/cli/handlers/brand.ts
3374
- function Ia(e, t) {
3450
+ function Ja(e, t) {
3375
3451
  let n = e;
3376
3452
  for (let e of t.split(".")) {
3377
3453
  if (typeof n != "object" || !n || !Object.prototype.hasOwnProperty.call(n, e)) return;
@@ -3380,15 +3456,15 @@ function Ia(e, t) {
3380
3456
  return n;
3381
3457
  }
3382
3458
  // src/cli/handlers/index.ts
3383
- var La = {
3384
- get_token: Ta,
3385
- list_tokens: Da,
3386
- get_rules: wa,
3387
- can_use: Aa,
3388
- get_fonts: Ma,
3389
- get_logo: Pa,
3459
+ var Ya = {
3460
+ get_token: La,
3461
+ list_tokens: za,
3462
+ get_rules: Ia,
3463
+ can_use: Ha,
3464
+ get_fonts: Wa,
3465
+ get_logo: Ka,
3390
3466
  get_brand: async ({ key: e }, { dir: t }) => {
3391
- let { config: n, data: r } = await J(t), i = We(r, n, t), a = e === void 0 ? i : Ia(i, e);
3467
+ let { config: n, data: r } = await J(t), i = xe(r, n, t), a = e === void 0 ? i : Ja(i, e);
3392
3468
  if (a === void 0) throw new M(`brand.json has no "${String(e)}". Run blazon brand without --key to see the keys.`, void 0, "unknown-key");
3393
3469
  return {
3394
3470
  command: "brand",
@@ -3398,48 +3474,49 @@ var La = {
3398
3474
  text: () => void process.stdout.write(`${JSON.stringify(a, null, 2)}\n`)
3399
3475
  };
3400
3476
  }
3401
- }, Ra = (e) => e.cli, za = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), Ba = xa(ya).filter((e) => Ra(e).options.some((e) => e.property === "json")).map((e) => Ra(e).command[0]);
3402
- function Va(e) {
3403
- let t = Ra(e), n = new Set(e.inputSchema.required ?? []);
3477
+ }, Xa = (e) => e.cli, Za = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), Qa = Oa(Ea).filter((e) => Xa(e).options.some((e) => e.property === "json")).map((e) => Xa(e).command[0]);
3478
+ function $a(e) {
3479
+ let t = Xa(e), n = new Set(e.inputSchema.required ?? []);
3404
3480
  return [...t.command, ...t.positional.map((e) => n.has(e) ? `<${e}>` : `[${e}]`)].join(" ");
3405
3481
  }
3406
- function Ha(e, t) {
3482
+ function eo(e, t) {
3407
3483
  if (t.property === "json") return "--json";
3408
- let n = e.inputSchema.properties[t.property], r = t.flag ?? za(t.property);
3484
+ let n = e.inputSchema.properties[t.property], r = t.flag ?? Za(t.property);
3409
3485
  return n?.type === "boolean" ? `--${r}` : `--${r} <${t.value ?? r}>`;
3410
3486
  }
3411
- var Ua = (e) => (e.flag ?? za(e.property)).replace(/^no-/, "").replace(/-(.)/g, (e, t) => t.toUpperCase()), Wa = (e) => typeof e == "string" && /^\.|[\\/]/.test(e) && !!k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory();
3412
- function Ga(e, t) {
3413
- for (let n of xa(ya)) {
3414
- let r = Ra(n), i = La[n.name];
3487
+ var to = (e) => (e.flag ?? Za(e.property)).replace(/^no-/, "").replace(/-(.)/g, (e, t) => t.toUpperCase()), no = (e) => typeof e == "string" && /^\.|[\\/]/.test(e) && !!k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory();
3488
+ function ro(e, t) {
3489
+ for (let n of Oa(Ea)) {
3490
+ let r = Xa(n), i = Ya[n.name];
3415
3491
  if (!i) throw Error(`operation ${n.name} has a command and no handler`);
3416
- let a = e.command(Va(n), r.summary);
3417
- for (let e of r.options) a.option(Ha(n, e), e.description);
3492
+ let a = e.command($a(n), r.summary);
3493
+ for (let e of r.options) a.option(eo(n, e), e.description);
3418
3494
  a.action(async (...e) => {
3419
- let n = e.pop() ?? {};
3495
+ let a = e.pop() ?? {};
3420
3496
  try {
3421
3497
  let t = {};
3422
3498
  r.positional.forEach((n, r) => t[n] = e[r]);
3423
- for (let e of r.options) e.property !== "json" && (t[e.property] = n[Ua(e)]);
3424
- let a = t.dir;
3425
- r.folder !== void 0 && a === void 0 && Wa(t[r.folder]) && (a = t[r.folder], t[r.folder] = void 0), delete t.dir;
3426
- let o = await i(t, { dir: a ? String(a) : process.cwd() });
3427
- n.json ? Y(o.command, o.passed, o.body) : o.text(), process.exitCode = o.status;
3428
- } catch (e) {
3429
- P(r.command.join(" "), e, t);
3499
+ for (let e of r.options) e.property !== "json" && (t[e.property] = a[to(e)]);
3500
+ let n = t.dir;
3501
+ r.folder !== void 0 && n === void 0 && no(t[r.folder]) && (n = t[r.folder], t[r.folder] = void 0), delete t.dir;
3502
+ let o = await i(t, { dir: n ? String(n) : process.cwd() });
3503
+ a.json ? Y(o.command, o.passed, o.body) : o.text(), process.exitCode = o.status;
3504
+ } catch (i) {
3505
+ let a = Na(r.command, r.positional, e, new Set(n.inputSchema.required ?? []), i);
3506
+ a && i instanceof j && (i.hint = a), P(r.command.join(" "), i, t);
3430
3507
  }
3431
3508
  });
3432
3509
  }
3433
3510
  }
3434
3511
  // src/cli/commands/mcp-check.ts
3435
- var Ka = 3e4, qa = "This check starts blazon-mcp on the brand folder. The server runs blazon with no plugin and a limited environment, and reads the brand files as data. What the brand says reaches your agent as tool results, so check only a brand folder you trust.", Ja = "npm ci && npm run build -w mcp", Ya = (e) => ve(e) ? `cd ${e} && ${Ja}` : je, Xa = () => ba(ya).map((e) => e.name);
3436
- function Za(e) {
3512
+ var io = 3e4, ao = "This check starts blazon-mcp on the brand folder. The server runs blazon with no plugin and a limited environment, and reads the brand files as data. What the brand says reaches your agent as tool results, so check only a brand folder you trust.", oo = "npm ci && npm run build -w mcp", so = (e) => Se(e) ? `cd ${e} && ${oo}` : Me, co = () => Da(Ea).map((e) => e.name);
3513
+ function lo(e) {
3437
3514
  let t = O.join(e, "mcp/dist/index.js"), n = k.existsSync(t);
3438
- return !n && !ve(e) ? {
3515
+ return !n && !Se(e) ? {
3439
3516
  name: "built",
3440
3517
  passed: !1,
3441
- detail: ze,
3442
- fix: je,
3518
+ detail: Ve,
3519
+ fix: Me,
3443
3520
  entry: t
3444
3521
  } : n ? {
3445
3522
  name: "built",
@@ -3450,26 +3527,26 @@ function Za(e) {
3450
3527
  name: "built",
3451
3528
  passed: !1,
3452
3529
  detail: `${t} does not exist: blazon-mcp is not built`,
3453
- fix: Ya(e),
3530
+ fix: so(e),
3454
3531
  entry: t
3455
3532
  };
3456
3533
  }
3457
- var Qa = (e) => {
3534
+ var uo = (e) => {
3458
3535
  try {
3459
3536
  return k.statSync(e).isFile() ? (k.accessSync(e, k.constants.X_OK), !0) : !1;
3460
3537
  } catch {
3461
3538
  return !1;
3462
3539
  }
3463
3540
  };
3464
- function $a(e, t) {
3541
+ function fo(e, t) {
3465
3542
  let n = (t.PATH ?? "").split(O.delimiter).filter(Boolean), r = process.platform === "win32" ? ["", ...(t.PATHEXT ?? ".EXE;.CMD").split(";")].map((t) => e + t) : [e];
3466
- for (let e of n) for (let t of r) if (Qa(O.join(e, t))) return O.join(e, t);
3543
+ for (let e of n) for (let t of r) if (uo(O.join(e, t))) return O.join(e, t);
3467
3544
  }
3468
- function eo(e, t, n) {
3545
+ function po(e, t, n) {
3469
3546
  let r = O.join(n, "bin/blazon.js"), i = k.existsSync(r) ? k.existsSync(O.join(n, "dist/cli/index.js")) ? `export BLAZON_BIN=${r}` : `cd ${n} && npm run build && export BLAZON_BIN=${r}` : "put the blazon program on PATH, or export BLAZON_BIN=<path to the blazon executable>", a = e.BLAZON_BIN;
3470
3547
  if (a) {
3471
- let n = a.includes("/") || a.includes(O.sep) ? O.resolve(t, a) : $a(a, e);
3472
- return n && Qa(n) ? {
3548
+ let n = a.includes("/") || a.includes(O.sep) ? O.resolve(t, a) : fo(a, e);
3549
+ return n && uo(n) ? {
3473
3550
  name: "blazon",
3474
3551
  passed: !0,
3475
3552
  detail: `BLAZON_BIN names ${n}`,
@@ -3483,14 +3560,14 @@ function eo(e, t, n) {
3483
3560
  source: "BLAZON_BIN"
3484
3561
  };
3485
3562
  }
3486
- if (Qa(r)) return {
3563
+ if (uo(r)) return {
3487
3564
  name: "blazon",
3488
3565
  passed: !0,
3489
3566
  detail: `the server runs this package's own ${r}`,
3490
3567
  source: "package",
3491
3568
  path: r
3492
3569
  };
3493
- let o = $a("blazon", e);
3570
+ let o = fo("blazon", e);
3494
3571
  return o ? {
3495
3572
  name: "blazon",
3496
3573
  passed: !0,
@@ -3505,12 +3582,12 @@ function eo(e, t, n) {
3505
3582
  source: "none"
3506
3583
  };
3507
3584
  }
3508
- var to = (e, t = 200) => {
3585
+ var mo = (e, t = 200) => {
3509
3586
  let n = e.trim().split("\n").find((e) => e.trim() !== "") ?? "";
3510
3587
  return n.length > t ? `${n.slice(0, t)}...` : n;
3511
3588
  };
3512
- async function no(e) {
3513
- let { entry: t, brand: n, env: r = process.env, timeoutMs: i = Ka, expect: a = Xa() } = e, o = process.platform !== "win32", s = tt(process.execPath, [
3589
+ async function ho(e) {
3590
+ let { entry: t, brand: n, env: r = process.env, timeoutMs: i = io, expect: a = co() } = e, o = process.platform !== "win32", s = at(process.execPath, [
3514
3591
  t,
3515
3592
  "--brand",
3516
3593
  n
@@ -3542,7 +3619,7 @@ async function no(e) {
3542
3619
  m = setTimeout(() => {
3543
3620
  p = !0, t(/* @__PURE__ */ Error(`no answer within ${i / 1e3} s`));
3544
3621
  }, i);
3545
- }), g = new Promise((e, t) => s.once("close", (e) => t(/* @__PURE__ */ Error(`the server exited (${e ?? "signal"}) before it answered${c ? `: ${to(c)}` : ""}`))));
3622
+ }), g = new Promise((e, t) => s.once("close", (e) => t(/* @__PURE__ */ Error(`the server exited (${e ?? "signal"}) before it answered${c ? `: ${mo(c)}` : ""}`))));
3546
3623
  g.catch(() => void 0), h.catch(() => void 0), u.catch(() => void 0);
3547
3624
  let _ = 0, v = (e, t) => {
3548
3625
  let n = ++_, r = new Promise((e) => d.set(n, e));
@@ -3567,7 +3644,7 @@ async function no(e) {
3567
3644
  version: "0"
3568
3645
  }
3569
3646
  });
3570
- if (e.error) throw Error(`initialize was refused: ${to(e.error.message ?? "")}`);
3647
+ if (e.error) throw Error(`initialize was refused: ${mo(e.error.message ?? "")}`);
3571
3648
  s.stdin.write(`${JSON.stringify({
3572
3649
  jsonrpc: "2.0",
3573
3650
  method: "notifications/initialized"
@@ -3576,8 +3653,8 @@ async function no(e) {
3576
3653
  if (t.error || r.length > 0) return {
3577
3654
  name: "handshake",
3578
3655
  passed: !1,
3579
- detail: t.error ? `tools/list failed: ${to(t.error.message ?? "")}` : `tools/list answered ${n.length} tool(s); missing ${r.join(", ")}`,
3580
- fix: `${Ya(we())} (the server is older than this blazon), then run this check again`,
3656
+ detail: t.error ? `tools/list failed: ${mo(t.error.message ?? "")}` : `tools/list answered ${n.length} tool(s); missing ${r.join(", ")}`,
3657
+ fix: `${so(et())} (the server is older than this blazon), then run this check again`,
3581
3658
  tools: n
3582
3659
  };
3583
3660
  let i = Date.now(), o = await v("tools/call", {
@@ -3587,7 +3664,7 @@ async function no(e) {
3587
3664
  if (o.error || o.result?.isError) return {
3588
3665
  name: "handshake",
3589
3666
  passed: !1,
3590
- detail: `check_brand failed: ${to(o.error?.message ?? l)}`,
3667
+ detail: `check_brand failed: ${mo(o.error?.message ?? l)}`,
3591
3668
  fix: "run blazon check in the brand folder, and make sure the blazon program and the brand folder are the ones the server uses",
3592
3669
  tools: n,
3593
3670
  ms: c
@@ -3606,14 +3683,14 @@ async function no(e) {
3606
3683
  name: "handshake",
3607
3684
  passed: !1,
3608
3685
  detail: `the handshake did not finish: ${e instanceof Error ? e.message : String(e)}${p ? "; the server was killed" : ""}`,
3609
- fix: `${Ya(we())}, then run this check again; on a hang, run the server by hand: node ${t} --brand ${n}`,
3686
+ fix: `${so(et())}, then run this check again; on a hang, run the server by hand: node ${t} --brand ${n}`,
3610
3687
  ms: Date.now() - y
3611
3688
  };
3612
3689
  } finally {
3613
- clearTimeout(m), await ro(s, l, o);
3690
+ clearTimeout(m), await go(s, l, o);
3614
3691
  }
3615
3692
  }
3616
- async function ro(e, t, n) {
3693
+ async function go(e, t, n) {
3617
3694
  let r = (t) => {
3618
3695
  try {
3619
3696
  n && e.pid !== void 0 ? process.kill(-e.pid, t) : e.kill(t);
@@ -3627,38 +3704,94 @@ async function ro(e, t, n) {
3627
3704
  let i;
3628
3705
  await Promise.race([t, new Promise((e) => i = setTimeout(e, 2e3))]), clearTimeout(i), e.exitCode === null && e.signalCode === null ? (r("SIGKILL"), await t) : r("SIGKILL");
3629
3706
  }
3630
- function io(e, t, n, r = nt.homedir()) {
3631
- let i = Fe(e, t, r, process.platform, process.env.APPDATA), a = [], o = [], s = [];
3632
- for (let e of i) {
3633
- let t;
3707
+ var _o = (e) => {
3708
+ try {
3709
+ return k.realpathSync(e);
3710
+ } catch {
3711
+ return O.resolve(e);
3712
+ }
3713
+ };
3714
+ function vo(e, t, n, r) {
3715
+ for (let i of e.args) {
3716
+ if (i.startsWith("-")) continue;
3717
+ let e = i.startsWith("~/") || i.startsWith(`~${O.sep}`) ? O.join(t, i.slice(1)) : i;
3718
+ if (!O.isAbsolute(e) && n === void 0) continue;
3719
+ let a = _o(O.resolve(n ?? "/", e));
3720
+ if (/\.m?js$/.test(a) && (a === r || k.existsSync(a))) return a;
3721
+ }
3722
+ }
3723
+ function yo(e, t, n, r = ot.homedir(), i = et()) {
3724
+ let a = Ie(e, t, r, process.platform, process.env.APPDATA), o = _o(we(i).args[0]), s = [], c = [], l = [], u = [];
3725
+ for (let e of a) {
3726
+ let n;
3634
3727
  try {
3635
- t = k.readFileSync(e.path, "utf8");
3728
+ n = k.readFileSync(e.path, "utf8");
3636
3729
  } catch {
3637
3730
  continue;
3638
3731
  }
3639
- let n = Ne(t, e);
3640
- n === void 0 ? s.push(e.path) : (o.push(e.path), n.includes("blazon") && a.push(e.path));
3732
+ let i = De(n, e);
3733
+ if (i === void 0) {
3734
+ l.push(e.path);
3735
+ continue;
3736
+ }
3737
+ if (c.push(e.path), !i.includes("blazon")) continue;
3738
+ s.push(e.path);
3739
+ let a = e.scope === "project" ? t.find((t) => e.path.startsWith(t + O.sep)) : void 0, d = Ne(n, e, "blazon") ?? [];
3740
+ d.length === 0 && u.push({
3741
+ file: e.path,
3742
+ script: void 0
3743
+ });
3744
+ for (let t of d) u.push({
3745
+ file: e.path,
3746
+ script: vo(t, r, a, o)
3747
+ });
3641
3748
  }
3642
- let c = s.length > 0 ? ` (not valid JSON, skipped: ${s.join(", ")})` : "", l = `blazon mcp --print-config --client ${e} --brand ${n}`;
3643
- return a.length > 0 ? {
3749
+ let d = l.length > 0 ? ` (not valid JSON, skipped: ${l.join(", ")})` : "", f = `blazon mcp --print-config --client ${e} --brand ${n}`;
3750
+ if (s.length === 0) return {
3644
3751
  name: "registered",
3645
- passed: !0,
3752
+ passed: !1,
3646
3753
  advisory: !0,
3647
3754
  client: e,
3648
- detail: `${e} has a server named blazon in ${a.join(", ")}${c}`,
3649
- files: a
3650
- } : {
3755
+ state: "none",
3756
+ found: !1,
3757
+ sameServer: null,
3758
+ detail: `no server named blazon in ${e}'s config; looked in ${c.length > 0 ? c.join(", ") : "no file that exists"}${d}`,
3759
+ fix: f,
3760
+ files: []
3761
+ };
3762
+ let p = {
3651
3763
  name: "registered",
3652
- passed: !1,
3653
3764
  advisory: !0,
3654
3765
  client: e,
3655
- detail: `no server named blazon in ${e}'s config; looked in ${o.length > 0 ? o.join(", ") : "no file that exists"}${c}`,
3656
- fix: l,
3657
- files: []
3766
+ found: !0,
3767
+ files: s,
3768
+ installPath: o
3769
+ }, m = u.find((e) => e.script !== void 0 && e.script !== o);
3770
+ return m?.script === void 0 ? u.some((e) => e.script === void 0) ? {
3771
+ ...p,
3772
+ passed: !1,
3773
+ state: "unknown",
3774
+ sameServer: null,
3775
+ detail: `${e} has a server named blazon in ${s.join(", ")}, but this check could not tell which file it runs; this install's is ${o}, and blazon mcp --print-config prints the command that registers it${d}`,
3776
+ fix: f
3777
+ } : {
3778
+ ...p,
3779
+ passed: !0,
3780
+ state: "same",
3781
+ sameServer: !0,
3782
+ detail: `${e} has a server named blazon in ${s.join(", ")}, and it runs this install's ${o}${d}`
3783
+ } : {
3784
+ ...p,
3785
+ passed: !1,
3786
+ state: "different",
3787
+ sameServer: !1,
3788
+ registeredPath: m.script,
3789
+ detail: `${e} has a server named blazon in ${m.file}, but it runs ${m.script}, not this install's ${o}; blazon mcp --print-config prints the command that registers this install${d}`,
3790
+ fix: f
3658
3791
  };
3659
3792
  }
3660
- async function ao(e) {
3661
- let { client: t, brand: n, env: r = process.env, cwd: i = process.cwd(), home: a = nt.homedir() } = e, o = e.root ?? we(), c = Za(o), l = eo(r, n, o), u = c.passed ? await no({
3793
+ async function bo(e) {
3794
+ let { client: t, brand: n, env: r = process.env, cwd: i = process.cwd(), home: o = ot.homedir() } = e, s = e.root ?? et(), c = lo(s), l = po(r, n, s), u = c.passed ? await ho({
3662
3795
  entry: c.entry,
3663
3796
  brand: n,
3664
3797
  env: r,
@@ -3666,9 +3799,9 @@ async function ao(e) {
3666
3799
  }) : {
3667
3800
  name: "handshake",
3668
3801
  passed: !1,
3669
- detail: `not run: ${ve(o) ? "the server is not built" : "the install is incomplete"}`,
3802
+ detail: `not run: ${Se(s) ? "the server is not built" : "the install is incomplete"}`,
3670
3803
  fix: c.fix
3671
- }, d = io(t, [.../* @__PURE__ */ new Set([i, n])], n, a), { entry: f, ...p } = c, m = [
3804
+ }, d = yo(t, [.../* @__PURE__ */ new Set([i, n])], n, o, s), { entry: f, ...p } = c, m = [
3672
3805
  p,
3673
3806
  l,
3674
3807
  u,
@@ -3679,43 +3812,43 @@ async function ao(e) {
3679
3812
  client: t,
3680
3813
  brand: n,
3681
3814
  runsPlugins: !1,
3682
- trust: qa,
3683
- registered: d.passed,
3815
+ trust: ao,
3816
+ registered: d.found,
3684
3817
  checks: m
3685
3818
  }), +!h;
3686
- console.log(`\n ${s.bold(`blazon-mcp for ${t}, brand ${n}`)}\n ${s.yellow(qa)}\n`);
3819
+ console.log(`\n ${a.bold(`blazon-mcp for ${t}, brand ${n}`)}\n ${a.yellow(ao)}\n`);
3687
3820
  for (let e of m) {
3688
- let t = e.passed ? s.green("ok ") : e.advisory ? s.yellow("finding") : s.red("fail ");
3689
- console.log(` ${t} ${e.name.padEnd(10)} ${e.detail}`), !e.passed && e.fix && console.log(` ${" ".repeat(7)} ${" ".repeat(10)} ${s.dim("fix:")} ${e.fix}`);
3821
+ let t = e.passed ? a.green("ok ") : e.advisory ? a.yellow("finding") : a.red("fail ");
3822
+ console.log(` ${t} ${e.name.padEnd(10)} ${e.detail}`), !e.passed && e.fix && console.log(` ${" ".repeat(7)} ${" ".repeat(10)} ${a.dim("fix:")} ${e.fix}`);
3690
3823
  }
3691
- return console.log(`\n ${h ? s.green("The server is ready.") : s.red("The server is not ready.")}${d.passed ? "" : " It is not registered in this client yet (a finding, not a failure)."}\n`), +!h;
3824
+ return console.log(`\n ${h ? a.green("The server is ready.") : a.red("The server is not ready.")}${d.found ? "" : " It is not registered in this client yet (a finding, not a failure)."}\n`), +!h;
3692
3825
  }
3693
3826
  // src/cli/commands/mcp.ts
3694
- async function oo(e = {}) {
3827
+ async function xo(e = {}) {
3695
3828
  if (e.printConfig && e.check) throw new M("give --print-config or --check, not both. See blazon mcp --help.", void 0, "conflicting-options");
3696
3829
  if (!e.printConfig && !e.check) throw new M("give --print-config to print the config that registers blazon-mcp in a client, or --check to test that it works; neither writes a file. See blazon mcp --help.", void 0, "missing-argument");
3697
3830
  let t = e.client === void 0 ? "claude-code" : e.client;
3698
- if (e.client !== void 0 && !he(e.client)) throw new M(`unknown client "${e.client}"; the clients are ${pe.join(", ")}.`, void 0, "invalid-option-value");
3831
+ if (e.client !== void 0 && !be(e.client)) throw new M(`unknown client "${e.client}"; the clients are ${ve.join(", ")}.`, void 0, "invalid-option-value");
3699
3832
  let n = e.brand === void 0 ? void 0 : O.resolve(process.cwd(), e.brand);
3700
3833
  if (e.check) {
3701
3834
  let r = n ?? process.cwd();
3702
3835
  if (!k.statSync(r, { throwIfNoEntry: !1 })?.isDirectory()) throw new M(`the brand folder ${r} does not exist.`, void 0, "no-folder");
3703
- return ao({
3836
+ return bo({
3704
3837
  client: t,
3705
3838
  brand: r,
3706
3839
  ...e.root && { root: e.root },
3707
3840
  ...e.json && { json: !0 }
3708
3841
  });
3709
3842
  }
3710
- let r = Ce(e.root);
3711
- if (!r.built && !ve(e.root)) return e.json ? Y("mcp", !1, {
3843
+ let r = we(e.root);
3844
+ if (!r.built && !Se(e.root)) return e.json ? Y("mcp", !1, {
3712
3845
  client: t,
3713
3846
  built: !1,
3714
3847
  ...n && { brand: n },
3715
- note: ze,
3848
+ note: Ve,
3716
3849
  snippets: []
3717
- }) : console.error(`\n ${s.yellow(ze)}\n`), 1;
3718
- let i = He(t, r, n);
3850
+ }) : console.error(`\n ${a.yellow(Ve)}\n`), 1;
3851
+ let i = Ge(t, r, n);
3719
3852
  if (e.json) return Y("mcp", !0, {
3720
3853
  client: t,
3721
3854
  built: i.built,
@@ -3723,13 +3856,13 @@ async function oo(e = {}) {
3723
3856
  ...i.note && { note: i.note },
3724
3857
  snippets: i.snippets
3725
3858
  }), 0;
3726
- console.log(`\n ${s.bold(i.title)}`);
3727
- for (let e of i.snippets) console.log(`\n ${s.dim(e.label)}\n\n${e.text.replace(/^/gm, " ")}`);
3728
- return i.note && console.log(`\n ${s.yellow(i.note)}`), console.log(""), 0;
3859
+ console.log(`\n ${a.bold(i.title)}`);
3860
+ for (let e of i.snippets) console.log(`\n ${a.dim(e.label)}\n\n${e.text.replace(/^/gm, " ")}`);
3861
+ return i.note && console.log(`\n ${a.yellow(i.note)}`), console.log(""), 0;
3729
3862
  }
3730
3863
  // src/cli/commands/explain.ts
3731
- function so(e) {
3732
- let t = de[e], n = oe(e);
3864
+ function So(e) {
3865
+ let t = Ye[e], n = Ke(e);
3733
3866
  return {
3734
3867
  code: e,
3735
3868
  severity: t.severity,
@@ -3740,26 +3873,26 @@ function so(e) {
3740
3873
  manual: t.manual
3741
3874
  };
3742
3875
  }
3743
- function co(e) {
3876
+ function Co(e) {
3744
3877
  let [t = "", n] = e.split("#");
3745
3878
  return `RFC ${t.padStart(4, "0")}${n ? `, section ${n}` : ""}`;
3746
3879
  }
3747
- function lo(e) {
3748
- let t = Object.keys(de), n = [];
3880
+ function wo(e) {
3881
+ let t = Object.keys(Ye), n = [];
3749
3882
  for (let r = 0; r < 3; r++) {
3750
- let r = E(e, t);
3883
+ let r = D(e, t);
3751
3884
  if (r === void 0) break;
3752
3885
  n.push(r), t.splice(t.indexOf(r), 1);
3753
3886
  }
3754
3887
  return n;
3755
3888
  }
3756
- function uo(e) {
3757
- let t = e.severity === "error" ? s.red : e.severity === "warning" ? s.yellow : s.dim;
3758
- console.log(`\n ${s.bold(e.code)} ${t(e.severity)}\n`), console.log(` ${e.summary}`), e.fix !== void 0 && console.log(`\n ${s.bold("Fix")} ${e.fix}`), console.log(`\n ${s.bold("Read")} docs/manual/${e.manual}.md, ${co(e.rfc)}\n`);
3889
+ function To(e) {
3890
+ let t = e.severity === "error" ? a.red : e.severity === "warning" ? a.yellow : a.dim;
3891
+ console.log(`\n ${a.bold(e.code)} ${t(e.severity)}\n`), console.log(` ${e.summary}`), e.fix !== void 0 && console.log(`\n ${a.bold("Fix")} ${e.fix}`), console.log(`\n ${a.bold("Read")} docs/manual/${e.manual}.md, ${Co(e.rfc)}\n`);
3759
3892
  }
3760
- function fo(e, t = {}) {
3893
+ function Eo(e, t = {}) {
3761
3894
  if (e === void 0) {
3762
- let e = Object.keys(de).sort().map((e) => so(e));
3895
+ let e = Object.keys(Ye).sort().map((e) => So(e));
3763
3896
  if (t.json) Y("explain", !0, { codes: e });
3764
3897
  else {
3765
3898
  let t = Math.max(...e.map((e) => e.code.length));
@@ -3769,26 +3902,26 @@ function fo(e, t = {}) {
3769
3902
  }
3770
3903
  return 0;
3771
3904
  }
3772
- if (!Object.hasOwn(de, e)) {
3773
- let t = lo(e);
3905
+ if (!Object.hasOwn(Ye, e)) {
3906
+ let t = wo(e);
3774
3907
  throw new M(`unknown code "${e}"`, t.length > 0 ? `Did you mean ${t.map((e) => `"${e}"`).join(", ")}? Run blazon explain to list every code.` : "Run blazon explain to list every code.", "unknown-finding-code");
3775
3908
  }
3776
- let n = so(e);
3777
- return t.json ? Y("explain", !0, n) : uo(n), 0;
3909
+ let n = So(e);
3910
+ return t.json ? Y("explain", !0, n) : To(n), 0;
3778
3911
  }
3779
3912
  // src/cli/options.ts
3780
- var po = (e) => {
3913
+ var Do = (e) => {
3781
3914
  if (e.length === 1) return [`-${e}`];
3782
3915
  let t = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
3783
3916
  return t === e ? [`--${e}`] : [`--${e}`, `--${t}`];
3784
3917
  };
3785
- function mo(e, t) {
3918
+ function Oo(e, t) {
3786
3919
  let n = e.matchedCommand;
3787
3920
  if (!n) return;
3788
3921
  let r = [...n.options, ...e.globalCommand.options].filter((e) => e.required);
3789
3922
  for (let i of r) {
3790
3923
  if (typeof e.options[i.name] == "object") continue;
3791
- let r = i.names.flatMap(po);
3924
+ let r = i.names.flatMap(Do);
3792
3925
  for (let a = 2; a < t.length; a++) {
3793
3926
  let o = t[a], s = r.find((e) => o === e || o.startsWith(`${e}=`));
3794
3927
  if (s === void 0) continue;
@@ -3800,11 +3933,11 @@ function mo(e, t) {
3800
3933
  i.some((e, t) => e === "" && !(i[t - 1] ?? "").startsWith("-")) && N(`blazon ${n.name}: ${n.rawName.includes("[dir]") ? "the folder is an empty name; leave it out to use the current folder" : "an argument is empty"}.`, "empty-value", { fix: "Leave the empty argument out, or give it a value." });
3801
3934
  }
3802
3935
  // src/cli/json.ts
3803
- var ho = [
3936
+ var ko = [
3804
3937
  "error",
3805
3938
  "warning",
3806
3939
  "info"
3807
- ], go = {
3940
+ ], Ao = {
3808
3941
  error: ["error"],
3809
3942
  warning: ["error", "warning"],
3810
3943
  info: [
@@ -3813,23 +3946,23 @@ var ho = [
3813
3946
  "info"
3814
3947
  ]
3815
3948
  };
3816
- async function _o(e, t, n, i = "info", a = process.cwd()) {
3949
+ async function jo(e, n, r, i = "info", a = process.cwd()) {
3817
3950
  let o = console.log;
3818
3951
  console.log = (...e) => console.error(...e);
3819
3952
  let s;
3820
3953
  try {
3821
- s = (await n()).findings;
3954
+ s = (await r()).findings;
3822
3955
  } catch (e) {
3823
- if (!(e instanceof Ct)) throw e;
3956
+ if (!(e instanceof Dt)) throw e;
3824
3957
  s = e.findings;
3825
3958
  } finally {
3826
3959
  console.log = o;
3827
3960
  }
3828
- let c = r(s, { strict: t }), l = {
3961
+ let c = t(s, { strict: n }), l = {
3829
3962
  errors: c.errors.length,
3830
3963
  warnings: c.warnings.length,
3831
3964
  info: c.infos.length
3832
- }, { mismatch: u } = Qe(a), d = u && {
3965
+ }, { mismatch: u } = _e(a), d = u && {
3833
3966
  pinned: u.pinned,
3834
3967
  running: u.running,
3835
3968
  message: u.message
@@ -3837,22 +3970,22 @@ async function _o(e, t, n, i = "info", a = process.cwd()) {
3837
3970
  process.stdout.write(`${JSON.stringify({
3838
3971
  command: e,
3839
3972
  passed: c.passed,
3840
- strict: t,
3973
+ strict: n,
3841
3974
  counts: l,
3842
- brandHasErrors: y(s).length > 0,
3975
+ brandHasErrors: b(s).length > 0,
3843
3976
  ...d && { pinMismatch: d },
3844
- findings: c.all.filter((e) => go[i].includes(e.severity)).map((e) => ({
3977
+ findings: c.all.filter((e) => Ao[i].includes(e.severity)).map((e) => ({
3845
3978
  ...e,
3846
- ...Ge(e) && { fix: Ge(e) }
3979
+ ...$e(e) && { fix: $e(e) }
3847
3980
  }))
3848
3981
  }, null, 2)}\n`), process.exitCode = +!c.passed;
3849
3982
  }
3850
- async function vo(e, t) {
3983
+ async function Mo(e, t) {
3851
3984
  let n = console.log;
3852
3985
  console.log = (...e) => console.error(...e);
3853
3986
  let r, i, a;
3854
3987
  try {
3855
- i = await Zr(e, {
3988
+ i = await ii(e, {
3856
3989
  ...t,
3857
3990
  input: !1,
3858
3991
  report: (e) => r = e,
@@ -3865,18 +3998,18 @@ async function vo(e, t) {
3865
3998
  command: "init",
3866
3999
  passed: i === 0,
3867
4000
  ...r ?? {},
3868
- ...i !== 0 && { error: a ? ft(a.code, a.message) : ft("error", `init did not finish (exit status ${i}); the reason is on standard error`) }
4001
+ ...i !== 0 && { error: a ? gt(a.code, a.message) : gt("error", `init did not finish (exit status ${i}); the reason is on standard error`) }
3869
4002
  };
3870
4003
  return process.stdout.write(`${JSON.stringify(o)}\n`), i;
3871
4004
  }
3872
4005
  // src/cli/help.ts
3873
- var yo = " 0 it did what it was asked (for check, no errors)\n 1 the check found errors (or warnings, with --strict), `blazon can` denied the combination, `blazon doctor` found a failing check, or the command failed\n 2 it was used wrongly: an unknown command or option, an unknown token, a bad port, no brand book in the folder. It did nothing, except `blazon init --from`, which copies the starter and then exits 2 when the site cannot be read", bo = " blazon explain <code> what a finding code means, the fix, and where to read more\n blazon explain list every code", xo = " --cwd <dir> sets the folder every command works from, the same as running blazon there. A folder argument is then relative to it:\n `blazon --cwd ./brands check acme` checks ./brands/acme. A --cwd that is not a folder exits 2.\n `blazon doctor` checks the environment (Node, brand folder, plugin folder safety, Chrome, blazon.lock): one line each, ok, warn or fail, with a fix.", So = {
4006
+ var No = " 0 it did what it was asked (for check, no errors)\n 1 the check found errors (or warnings, with --strict), `blazon can` denied the combination, `blazon doctor` found a failing check, or the command failed\n 2 it was used wrongly: an unknown command or option, an unknown token, a bad port, no brand book in the folder. It did nothing, except `blazon init --from`, which copies the starter and then exits 2 when the site cannot be read", Po = " blazon explain <code> what a finding code means, the fix, and where to read more\n blazon explain list every code", Fo = " --cwd <dir> sets the folder every command works from, the same as running blazon there. A folder argument is then relative to it:\n `blazon --cwd ./brands check acme` checks ./brands/acme. A --cwd that is not a folder exits 2.\n `blazon doctor` checks the environment (Node, brand folder, plugin folder safety, Chrome, blazon.lock): one line each, ok, warn or fail, with a fix.", Io = {
3874
4007
  check: "blazon plugin check <program> [--core] [--json]\n\nStarts the program the way blazon does and runs the protocol's core cases against it, then blazon's own cases for each role it declares and, for a shipped plugin's layout, the file name rule. Prints one line for each case: ok, skip or FAIL.\nIn a project whose config lists the plugin, case 10 also fails when the entry's env does not approve a variable the manifest lists.\nWith --core, only the core cases (1 to 5) run: no role cases, no case 10 and no layout line. Use it to check a plugin against the protocol alone.\n\nExit status:\n 0 every case passed\n 1 a case failed\n 2 no program was given\n\nExample:\n $ blazon plugin check ./blazon-acme.house-style",
3875
4008
  pin: "blazon plugin pin <path> [--name <plugin>] [--digest <digest>] [--entry <path>]\n\nPrints the digest that pins a plugin: sha256: for a file, t1: for a directory.\nWith --name, records the pin in blazon.plugins.lock instead. --digest says what the bytes must be, and the pin is refused when they are not. --entry names the program inside a directory when it is not blazon-<plugin>.\n\nExit status:\n 0 printed, or recorded\n 1 the path is one a host must refuse, or the digest does not match\n 2 no path was given, or --digest or --entry without --name\n\nExample:\n $ blazon plugin pin ./blazon-acme.house-style --name acme.house-style",
3876
4009
  profile: "blazon plugin profile\n\nPrints blazon's profile of the plugin protocol as JSON: the roles it defines and its limits. It is the same for every install.\n\nExit status:\n 0 printed"
3877
4010
  };
3878
- function Co(e, t, n) {
3879
- if (t === "plugin" && n !== void 0 && Object.hasOwn(So, n)) return [{ body: So[n] }];
4011
+ function Lo(e, t, n) {
4012
+ if (t === "plugin" && n !== void 0 && Object.hasOwn(Io, n)) return [{ body: Io[n] }];
3880
4013
  let r = e.map((e) => ({
3881
4014
  ...e,
3882
4015
  body: e.body.replace(/(--no-[a-z-]+[^\n]*?) *\(default: true\)/g, "$1")
@@ -3885,32 +4018,32 @@ function Co(e, t, n) {
3885
4018
  ...r,
3886
4019
  {
3887
4020
  title: "Finding codes",
3888
- body: bo
4021
+ body: Po
3889
4022
  },
3890
4023
  {
3891
4024
  title: "Working folder and environment",
3892
- body: xo
4025
+ body: Fo
3893
4026
  },
3894
4027
  {
3895
4028
  title: "Exit status",
3896
- body: yo
4029
+ body: No
3897
4030
  }
3898
4031
  ] : r;
3899
4032
  }
3900
4033
  // src/cli/index.ts
3901
- function wo(e, t) {
4034
+ function Ro(e, t) {
3902
4035
  if (t === void 0) return;
3903
4036
  let n = String(t), r = /^\d+$/.test(n) ? Number(n) : NaN;
3904
4037
  return r >= 1 && r <= 65535 || N(`blazon ${e}: the port must be a whole number from 1 to 65535, not "${n}".`, "invalid-port", { fix: "Give a whole number from 1 to 65535." }), r;
3905
4038
  }
3906
- var To = (e) => typeof e == "number" ? String(e) : e;
3907
- function Eo(e, t) {
4039
+ var zo = (e) => typeof e == "number" ? String(e) : e;
4040
+ function Bo(e, t) {
3908
4041
  t?.plugins === !1 && t.plugin !== void 0 && N(`blazon ${e}: --no-plugins runs no plugin, so it cannot be used with --plugin.`, "conflicting-options", { fix: "Leave out --no-plugins, or leave out --plugin." });
3909
4042
  }
3910
- function Do(e, t, n) {
3911
- if (t !== void 0) return n || N(`blazon ${e}: --severity cuts the list that --json prints; add --json, or leave --severity out.`, "conflicting-options", { fix: "Add --json, or leave --severity out." }), ho.includes(t) || N(`blazon ${e}: --severity must be error, warning or info, not "${String(t)}".`, "invalid-option-value", { fix: "Use --severity error, warning or info." }), t;
4043
+ function Vo(e, t, n) {
4044
+ if (t !== void 0) return n || N(`blazon ${e}: --severity cuts the list that --json prints; add --json, or leave --severity out.`, "conflicting-options", { fix: "Add --json, or leave --severity out." }), ko.includes(t) || N(`blazon ${e}: --severity must be error, warning or info, not "${String(t)}".`, "invalid-option-value", { fix: "Use --severity error, warning or info." }), t;
3912
4045
  }
3913
- var Oo = (e) => {
4046
+ var Ho = (e) => {
3914
4047
  let [t, n] = e.slice(2).filter((e, t, n) => !e.startsWith("-") && n[t - 1] !== "--cwd" && n[t - 1] !== "--allow-dir");
3915
4048
  if (e.includes("--json") && t !== void 0) return t === "plugin" ? n === "check" ? "plugin check" : void 0 : [
3916
4049
  "check",
@@ -3922,11 +4055,11 @@ var Oo = (e) => {
3922
4055
  "pin",
3923
4056
  "explain",
3924
4057
  "doctor",
3925
- ...Ba,
4058
+ ...Qa,
3926
4059
  "mcp"
3927
4060
  ].includes(t) ? t : void 0;
3928
4061
  };
3929
- function ko(e) {
4062
+ function Uo(e) {
3930
4063
  if (e[2] !== "help") return e;
3931
4064
  let t = e[3];
3932
4065
  return t !== void 0 && !t.startsWith("-") ? [
@@ -3936,58 +4069,58 @@ function ko(e) {
3936
4069
  ...e.slice(4)
3937
4070
  ] : [...e.slice(0, 2), "--help"];
3938
4071
  }
3939
- async function Ao(e = process.argv) {
3940
- let t = ko(e), n = t.includes("--debug");
3941
- ut(Oo(t));
3942
- let r = it("blazon");
4072
+ async function Wo(e = process.argv) {
4073
+ let t = Uo(e), n = t.includes("--debug");
4074
+ mt(Ho(t));
4075
+ let r = ct("blazon");
3943
4076
  if (r.option("--debug", "Show the stack of an error"), r.option("--allow-dir <folder>", "Approve a folder outside the project for an asset category dir (repeat for more; or BLAZON_ALLOW_DIRS)"), r.option("--cwd <dir>", "Work from this folder, as if blazon were run there; a folder argument is then relative to it"), r.command("dev [dir]", "Start interactive Brand Book dev server with HMR").option("-p, --port <port>", "Port number to listen on (default: the port in blazon.json, else 3000)").option("--strict-port", "Exit 2 when the port is in use, instead of taking the next free one").option("--host [address]", "Listen on this address, or on every network interface with no address (default: localhost only)").action(async (e, t) => {
3944
4077
  try {
3945
- await St(e || process.cwd(), wo("dev", t?.port), {
4078
+ await Et(e || process.cwd(), Ro("dev", t?.port), {
3946
4079
  strictPort: t?.strictPort,
3947
- host: To(t?.host)
4080
+ host: zo(t?.host)
3948
4081
  });
3949
4082
  } catch (e) {
3950
4083
  P("dev", e, n);
3951
4084
  }
3952
4085
  }), r.command("build [dir]", "Build static brand book site and compiled design tokens").option("-o, --outDir <dir>", "Output directory for static site").option("--plugin <program>", "Run a plugin program that the config does not allow or the lock does not pin, once, with a warning (repeat for more)").option("--no-plugins", "Run no plugin at all, whatever the config lists: the tokens and the book only (no browser needed)").option("--json", "Print the findings as JSON on standard output; everything else goes to standard error").option("--severity <level>", "With --json: list only the findings at this level or worse (error, warning or info); the counts stay whole").action(async (e, t) => {
3953
4086
  try {
3954
- Eo("build", t);
3955
- let n = Do("build", t?.severity, t?.json), r = () => Rt(e || process.cwd(), t?.outDir === void 0 ? void 0 : O.resolve(process.cwd(), t.outDir), t);
3956
- t?.json ? await _o("build", !1, r, n, e || process.cwd()) : await r();
4087
+ Bo("build", t);
4088
+ let n = Vo("build", t?.severity, t?.json), r = () => Ht(e || process.cwd(), t?.outDir === void 0 ? void 0 : O.resolve(process.cwd(), t.outDir), t);
4089
+ t?.json ? await jo("build", !1, r, n, e || process.cwd()) : await r();
3957
4090
  } catch (e) {
3958
4091
  P("build", e, n);
3959
4092
  }
3960
4093
  }), r.command("tokens [dir]", "Compile design tokens only (theme.css, tokens.ts, tokens.json)").option("--plugin <program>", "Run a plugin program that the config does not allow or the lock does not pin, once, with a warning (repeat for more)").option("--no-plugins", "Run no plugin at all, whatever the config lists: the tokens and the book only (no browser needed)").option("--json", "Print the findings as JSON on standard output; everything else goes to standard error").option("--severity <level>", "With --json: list only the findings at this level or worse (error, warning or info); the counts stay whole").action(async (e, t) => {
3961
4094
  try {
3962
- Eo("tokens", t);
3963
- let n = Do("tokens", t?.severity, t?.json), r = () => zt(e || process.cwd(), t);
3964
- t?.json ? await _o("tokens", !1, r, n, e || process.cwd()) : await r();
4095
+ Bo("tokens", t);
4096
+ let n = Vo("tokens", t?.severity, t?.json), r = () => Ut(e || process.cwd(), t);
4097
+ t?.json ? await jo("tokens", !1, r, n, e || process.cwd()) : await r();
3965
4098
  } catch (e) {
3966
4099
  P("tokens", e, n);
3967
4100
  }
3968
4101
  }), r.command("check [dir]", "Check tokens: aliases, types, usage rules, contrast pairs, duplicates and review flags").option("--strict", "Treat warnings as errors (useful for CI/CD pipelines)").option("--plugin <program>", "Run a plugin program that the config does not allow or the lock does not pin, once, with a warning (repeat for more)").option("--no-plugins", "Run no plugin at all, whatever the config lists: the tokens and the book only (no browser needed)").option("--json", "Print the findings as JSON on standard output; everything else goes to standard error").option("--severity <level>", "With --json: list only the findings at this level or worse (error, warning or info); the counts stay whole").action(async (e, t) => {
3969
4102
  try {
3970
- Eo("check", t);
3971
- let n = Do("check", t?.severity, t?.json), r = () => Lt(e || process.cwd(), t?.strict, t);
3972
- t?.json ? await _o("check", !!t.strict, r, n, e || process.cwd()) : (await r()).passed || (process.exitCode = 1);
4103
+ Bo("check", t);
4104
+ let n = Vo("check", t?.severity, t?.json), r = () => Vt(e || process.cwd(), t?.strict, t);
4105
+ t?.json ? await jo("check", !!t.strict, r, n, e || process.cwd()) : (await r()).passed || (process.exitCode = 1);
3973
4106
  } catch (e) {
3974
4107
  P("check", e, n);
3975
4108
  }
3976
- }), Ga(r, n), r.command("mcp", "Set up blazon-mcp, the MCP server for coding agents: --print-config prints what registers it in a client, --check tests that it works; neither writes a file").option("--print-config", "Print the config that registers blazon-mcp (stdio) in a client").option("--check", "Test that the server is built, finds blazon, answers a real MCP handshake and is registered in the client; runs no plugin").option("--client <client>", "With --print-config or --check: claude-code (default), claude-desktop, cursor or vscode").option("--brand <dir>", "The brand folder: with --print-config, written into the config as an absolute path; with --check, the folder the server starts on").option("--json", "Print the config or the check as JSON on standard output").action(async (e) => {
4109
+ }), ro(r, n), r.command("mcp", "Set up blazon-mcp, the MCP server for coding agents: --print-config prints what registers it in a client, --check tests that it works; neither writes a file").option("--print-config", "Print the config that registers blazon-mcp (stdio) in a client").option("--check", "Test that the server is built, finds blazon, answers a real MCP handshake and is registered in the client; runs no plugin").option("--client <client>", "With --print-config or --check: claude-code (default), claude-desktop, cursor or vscode").option("--brand <dir>", "The brand folder: with --print-config, written into the config as an absolute path; with --check, the folder the server starts on").option("--json", "Print the config or the check as JSON on standard output").action(async (e) => {
3977
4110
  try {
3978
- process.exitCode = await oo(e);
4111
+ process.exitCode = await xo(e);
3979
4112
  } catch (e) {
3980
4113
  P("mcp", e, n);
3981
4114
  }
3982
4115
  }), r.command("drift [target]", "Find tokens that have drifted from the live site: compare each token that names a source.cssVar with a page (http or https address) or a CSS file").option("--json", "Print the findings as JSON").option("--tokens <dir>", "Read the tokens from this folder instead of the one the config names").action(async (e, t) => {
3983
4116
  try {
3984
- process.exitCode = await mi(e, t);
4117
+ process.exitCode = await xi(e, t);
3985
4118
  } catch (e) {
3986
4119
  P("drift", e, n);
3987
4120
  }
3988
4121
  }), r.command("approvals [dir]", "List the tokens and assets marked review ok with the fingerprint of their value today, to record in review.value so `blazon check` sees a later change").option("--json", "Print the list as JSON on standard output").action(async (e, t) => {
3989
4122
  try {
3990
- process.exitCode = await hi(e || process.cwd(), { json: t?.json });
4123
+ process.exitCode = await Si(e || process.cwd(), { json: t?.json });
3991
4124
  } catch (e) {
3992
4125
  P("approvals", e, n);
3993
4126
  }
@@ -3998,72 +4131,72 @@ async function Ao(e = process.argv) {
3998
4131
  "digest",
3999
4132
  "entry"
4000
4133
  ]) r?.[t] !== void 0 && N(`blazon plugin: --${t} is for \`blazon plugin pin\`; \`${e ?? "check"}\` does not take it.`, "conflicting-options", { fix: `Leave out --${t}, or use it with \`blazon plugin pin\`.` });
4001
- e === "profile" && t !== void 0 && N("blazon plugin: `profile` takes no target.", "conflicting-options", { fix: "Run `blazon plugin profile` on its own." }), process.exitCode = await fi(e, t, r);
4134
+ e === "profile" && t !== void 0 && N("blazon plugin: `profile` takes no target.", "conflicting-options", { fix: "Run `blazon plugin profile` on its own." }), process.exitCode = await yi(e, t, r);
4002
4135
  } catch (e) {
4003
4136
  P("plugin", e, n);
4004
4137
  }
4005
4138
  }), r.command("explain [code]", "Explain a finding code: its severity, what it means, the fix and where to read more; with no code, list every code").option("--json", "Print the explanation as JSON on standard output").action((e, t) => {
4006
4139
  try {
4007
- process.exitCode = fo(e, { json: t?.json });
4140
+ process.exitCode = Eo(e, { json: t?.json });
4008
4141
  } catch (e) {
4009
4142
  P("explain", e, n);
4010
4143
  }
4011
4144
  }), r.command("pin [dir]", "Pin the blazon you build with: write blazon.lock with the commit of the blazon that runs this, so check, tokens and build refuse any other").option("--json", "Print the pinned commit as JSON on standard output").action((e, t) => {
4012
4145
  try {
4013
- process.exitCode = pi(e || process.cwd(), { json: t?.json });
4146
+ process.exitCode = bi(e || process.cwd(), { json: t?.json });
4014
4147
  } catch (e) {
4015
4148
  P("pin", e, n);
4016
4149
  }
4017
4150
  }), r.command("init [dir]", "Scaffold a new Blazon brand book and design token structure").option("--from <url>", "Start from a live site: read its stylesheets and page for the brand colors, fonts, logo and title (all marked needs-review)").option("--name <text>", "With `init`: the brand book title, as given").option("--description <text>", "With `init`: one sentence on the brand: the config description").option("--color <hex>", "With `init`: the primary color as hex, with or without the #: #2563eb, 2563eb or #26e").option("--font <family>", "With `init`: the font family, a Google Fonts name").option("--logo <file>", "With `init`: an SVG or PNG file to use as the logo").option("--dev", "With `init`: start `blazon dev` when it is done").option("--json", "Print what init made as JSON on standard output; everything else goes to standard error (never asks)").option("--yes", "With `init`: accept every default and never ask").option("--no-input", "With `init`: same as --yes; implied when stdin or stdout is not a terminal").action(async (e, t) => {
4018
4151
  try {
4019
- t?.json ? (t.dev && N("blazon init: --dev starts a server that never ends, so it cannot be used with --json.", "conflicting-options", { fix: "Leave out --dev, or leave out --json." }), process.exitCode = await vo(e || ".", t)) : process.exitCode = await Zr(e || ".", { ...t });
4152
+ t?.json ? (t.dev && N("blazon init: --dev starts a server that never ends, so it cannot be used with --json.", "conflicting-options", { fix: "Leave out --dev, or leave out --json." }), process.exitCode = await Mo(e || ".", t)) : process.exitCode = await ii(e || ".", { ...t });
4020
4153
  } catch (e) {
4021
4154
  P("init", e, n);
4022
4155
  }
4023
4156
  }), r.command("preview [dir]", "Preview the static production brand book build").option("-p, --port <port>", "Port number to listen on (default: the port in blazon.json, else 3000)").option("--strict-port", "Exit 2 when the port is in use, instead of taking the next free one").option("--host [address]", "Listen on this address, or on every network interface with no address (default: localhost only)").action(async (e, t) => {
4024
4157
  try {
4025
- await ti(e || process.cwd(), wo("preview", t?.port), {
4158
+ await ci(e || process.cwd(), Ro("preview", t?.port), {
4026
4159
  strictPort: t?.strictPort,
4027
- host: To(t?.host)
4160
+ host: zo(t?.host)
4028
4161
  });
4029
4162
  } catch (e) {
4030
4163
  P("preview", e, n);
4031
4164
  }
4032
4165
  }), r.command("doctor", "Check this machine and folder: Node version, brand folder, plugin folder safety, Chrome (if a plugin needs it) and blazon.lock; writes nothing").option("--json", "Print the checks as JSON on standard output").action(async (e) => {
4033
4166
  try {
4034
- process.exitCode = await ma(process.cwd(), { json: e?.json });
4167
+ process.exitCode = await xa(process.cwd(), { json: e?.json });
4035
4168
  } catch (e) {
4036
4169
  P("doctor", e, n);
4037
4170
  }
4038
- }), r.example(" $ blazon init my-brand"), r.example(" $ blazon check my-brand --json"), r.example(" $ blazon build my-brand"), r.example(" $ blazon list ./my-brand --type color"), r.example(" $ blazon get color.brand.primary my-brand --json"), r.example(" $ blazon can text.primary surface.canvas my-brand"), r.help((e) => Co(e, r.matchedCommand?.name, r.args[0])), r.version(Je), t.slice(2).length === 0) return r.outputHelp();
4171
+ }), r.example(" $ blazon init my-brand"), r.example(" $ blazon check my-brand --json"), r.example(" $ blazon build my-brand"), r.example(" $ blazon list ./my-brand --type color"), r.example(" $ blazon get color.brand.primary my-brand --json"), r.example(" $ blazon can text.primary surface.canvas my-brand"), r.help((e) => Lo(e, r.matchedCommand?.name, r.args[0])), r.version(re), t.slice(2).length === 0) return r.outputHelp();
4039
4172
  r.addEventListener("command:*", (e) => {
4040
4173
  if (r.options.help || r.options.version) return;
4041
- let t = String(e.detail), n = E(t, r.commands.map((e) => e.name).filter(Boolean));
4174
+ let t = String(e.detail), n = D(t, r.commands.map((e) => e.name).filter(Boolean));
4042
4175
  N(`blazon: unknown command "${t}"${n ? `; did you mean "${n}"?` : "."} Run blazon --help for the commands.`, "unknown-command", { fix: n ? `Run blazon ${n}, or blazon --help for the commands.` : "Run blazon --help for the commands." });
4043
4176
  });
4044
4177
  try {
4045
- r.parse(t, { run: !1 }), mo(r, t);
4178
+ r.parse(t, { run: !1 }), Oo(r, t);
4046
4179
  try {
4047
- _i(r.options.allowDir), gi(r.options.cwd);
4180
+ wi(r.options.allowDir), Ci(r.options.cwd);
4048
4181
  } catch (e) {
4049
4182
  P(r.matchedCommand?.name ?? "", e, n);
4050
4183
  }
4051
4184
  await r.runMatchedCommand();
4052
4185
  } catch (e) {
4053
- if (!ht(e)) return P("", e, n);
4186
+ if (!yt(e)) return P("", e, n);
4054
4187
  let t = r.matchedCommand?.name, i = t ? `blazon ${t}` : "blazon", [, a = "", o] = /^Unknown option `(-{1,2})([^`]+)`$/.exec(e.message) ?? [], s = n ? e.stack : void 0;
4055
4188
  o !== void 0 && /^\d+$/.test(o) && (t === "dev" || t === "preview") && N(`blazon ${t}: the port must be a whole number from 1 to 65535, not "-${o}".`, "invalid-port", { fix: "Give a whole number from 1 to 65535." }), t === "get" && /^missing required args/i.test(e.message) && N("blazon get: give a token path, such as blazon get color.brand.primary; blazon list shows the token paths.", "missing-argument", {
4056
4189
  stack: s,
4057
4190
  fix: "Run blazon list to see the token paths."
4058
- }), o === void 0 && N(`${i}: ${mt(e.message)}. Run ${i} --help for the options.`, "missing-argument", {
4191
+ }), o === void 0 && N(`${i}: ${vt(e.message)}. Run ${i} --help for the options.`, "missing-argument", {
4059
4192
  stack: s,
4060
4193
  fix: `Run ${i} --help for the options.`
4061
4194
  });
4062
- let c = [...r.matchedCommand?.options ?? [], ...r.globalCommand.options].map((e) => e.name), l = E(o, c);
4195
+ let c = [...r.matchedCommand?.options ?? [], ...r.globalCommand.options].map((e) => e.name), l = D(o, c);
4063
4196
  N(`${i}: unknown option "${a}${o}"${l ? `; did you mean "--${l}"?` : "."} Run ${i} --help for the options.`, "unknown-option", {
4064
4197
  stack: s,
4065
4198
  fix: l ? `Use --${l}, or run ${i} --help for the options.` : `Run ${i} --help for the options.`
4066
4199
  });
4067
4200
  }
4068
4201
  }
4069
- export { Ao as runCli };
4202
+ export { Wo as runCli };