@iksnerd/blazon 0.2.0 → 0.3.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.
package/dist/cli/index.js CHANGED
@@ -1,152 +1,152 @@
1
- import { At as e, Bt as t, C as n, D as r, Dt as i, E as a, F as o, Ft as s, Gt as c, H as l, I as u, It as d, Jt as f, Lt as p, Mt as m, Nt as h, O as g, Ot as _, Qt as v, Rt as y, S as b, St as x, T as S, Tn as C, U as w, V as T, W as ee, Xt as te, Yt as ne, Zt as re, _ as ie, _t as ae, a as oe, an as se, b as ce, bt as le, c as ue, cn as E, d as de, dn as fe, dt as D, f as pe, fn as me, ft as he, g as ge, gt as _e, h as ve, ht as ye, i as be, in as xe, jt as Se, k as O, kt as Ce, l as we, ln as Te, m as Ee, mn as De, mt as Oe, nn as ke, on as Ae, p as je, pt as Me, qt as Ne, rn as Pe, s as Fe, sn as Ie, st as Le, t as Re, u as ze, un as Be, v as Ve, w as He, wn as Ue, wt as k, x as We, xt as Ge, y as Ke } from "../chunks/site-builder-BtGOvjBC.js";
2
- import A from "node:path";
3
- import j from "node:fs";
4
- import { spawn as qe } from "node:child_process";
5
- import Je from "node:os";
6
- import { preview as Ye } from "vite";
7
- import { cac as Xe } from "cac";
8
- import * as M from "@clack/prompts";
1
+ import { $t as e, A as t, At as n, Bt as r, C as i, Ct as a, D as o, Dn as s, Dt as c, E as l, Ft as u, G as d, It as f, Jt as p, K as m, M as h, Mt as g, Nt as _, O as v, On as y, Pt as b, Qt as x, R as S, Rt as ee, S as C, T as w, Tt as T, Ut as te, Vt as ne, W as re, Xt as ie, Zt as ae, _ as oe, _n as se, _t as ce, a as le, an as ue, b as de, bt as fe, c as pe, cn as me, d as he, dn as E, en as ge, f as _e, fn as ve, g as ye, gt as be, h as xe, hn as Se, ht as Ce, i as we, j as Te, jt as Ee, k as De, l as Oe, ln as ke, m as Ae, mn as je, mt as D, on as Me, p as Ne, pn as Pe, q as Fe, s as Ie, sn as Le, t as Re, tn as ze, u as Be, un as Ve, ut as He, v as Ue, vt as We, w as Ge, wt as Ke, x as qe, y as Je, yt as Ye, z as Xe, zt as Ze } from "../chunks/site-builder-CH6OcFSE.js";
2
+ import O from "node:path";
3
+ import k from "node:fs";
4
+ import { spawn as Qe } from "node:child_process";
5
+ import $e from "node:os";
6
+ import { preview as et } from "vite";
7
+ import { cac as tt } from "cac";
8
+ import * as A from "@clack/prompts";
9
9
  // src/cli/errors.ts
10
- var N = class extends Error {
10
+ var j = class extends Error {
11
11
  fix;
12
12
  code;
13
13
  constructor(e, t, n = "error") {
14
14
  super(e), this.fix = t, this.code = n;
15
15
  }
16
- }, P = class extends N {}, Ze = (e) => new P(`port ${e} is in use`, "Pick another with --port, or leave out --strict-port to take the next free one.", "port-in-use"), Qe = (e) => e.replace(/^./, (e) => e.toLowerCase()).replace(/\.$/, "");
17
- function $e(e, t, n) {
16
+ }, M = class extends j {}, nt = (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"), rt = (e) => e.replace(/^./, (e) => e.toLowerCase()).replace(/\.$/, "");
17
+ function it(e, t, n) {
18
18
  return `blazon${e ? ` ${e}` : ""}: ${t}${n ? `\n ${n}` : ""}`;
19
19
  }
20
- var et = (e, t) => t ? `${e}; ${Qe(t)}` : e, tt;
21
- function nt(e) {
22
- tt = e;
20
+ var at = (e, t) => t ? `${e}; ${rt(t)}` : e, ot;
21
+ function st(e) {
22
+ ot = e;
23
23
  }
24
- function rt(e) {
25
- console.error(e.replace(/^blazon(?: [a-z]+)*:/, (e) => n.red(e)));
24
+ function ct(e) {
25
+ console.error(e.replace(/^blazon(?: [a-z]+)*:/, (e) => l.red(e)));
26
26
  }
27
- var it = (e, t, n) => ({
27
+ var lt = (e, t, n) => ({
28
28
  code: e,
29
29
  message: t,
30
30
  ...n !== void 0 && { fix: n }
31
31
  });
32
- function at(e, t, n) {
33
- tt !== void 0 && process.stdout.write(`${JSON.stringify({
34
- command: tt,
32
+ function ut(e, t, n) {
33
+ ot !== void 0 && process.stdout.write(`${JSON.stringify({
34
+ command: ot,
35
35
  passed: !1,
36
- error: it(e, t, n)
36
+ error: lt(e, t, n)
37
37
  })}\n`);
38
38
  }
39
- function F(e, t, n = {}) {
40
- return rt(e), n.stack && console.error(n.stack), at(t, n.json ?? e.replace(/^blazon(?: [a-z]+)?: /, ""), n.fix), process.exit(2);
39
+ function N(e, t, n = {}) {
40
+ return ct(e), n.stack && console.error(n.stack), ut(t, n.json ?? e.replace(/^blazon(?: [a-z]+)?: /, ""), n.fix), process.exit(2);
41
41
  }
42
- var ot = (e) => e.replace(/`([^`]*)`/g, "\"$1\"").replace(/^./, (e) => e.toLowerCase()), st = (e) => e instanceof Error && e.name === "CACError";
43
- function I(e, t, r) {
44
- let i = t instanceof N ? t.fix : void 0;
45
- if (t instanceof P) return F($e(e, t.message, i), t.code, {
46
- stack: r ? t.stack : void 0,
47
- json: et(t.message, i),
48
- fix: i
42
+ var dt = (e) => e.replace(/`([^`]*)`/g, "\"$1\"").replace(/^./, (e) => e.toLowerCase()), ft = (e) => e instanceof Error && e.name === "CACError";
43
+ function P(e, t, n) {
44
+ let r = t instanceof j ? t.fix : void 0;
45
+ if (t instanceof M) return N(it(e, t.message, r), t.code, {
46
+ stack: n ? t.stack : void 0,
47
+ json: at(t.message, r),
48
+ fix: r
49
49
  });
50
- let a = t instanceof Error ? t.message : String(t);
51
- return console.error(), rt($e(e, a, i ?? (r || t instanceof N ? void 0 : n.dim("Run again with --debug for the stack.")))), r && t instanceof Error && t.stack && console.error(t.stack), at(t instanceof N ? t.code : "error", et(a, i), i), process.exit(1);
50
+ let i = t instanceof Error ? t.message : String(t);
51
+ return console.error(), ct(it(e, i, r ?? (n || t instanceof j ? void 0 : l.dim("Run again with --debug for the stack.")))), n && t instanceof Error && t.stack && console.error(t.stack), ut(t instanceof j ? t.code : "error", at(i, r), r), process.exit(1);
52
52
  }
53
53
  // src/cli/where.ts
54
- function L(e, t = process.cwd()) {
55
- let n = A.relative(t, A.resolve(t, e));
56
- return n === "" ? "" : n.startsWith("..") || A.isAbsolute(n) ? A.resolve(t, e) : n.split(A.sep).join("/");
54
+ function F(e, t = process.cwd()) {
55
+ let n = O.relative(t, O.resolve(t, e));
56
+ return n === "" ? "" : n.startsWith("..") || O.isAbsolute(n) ? O.resolve(t, e) : n.split(O.sep).join("/");
57
57
  }
58
- var R = (e, t) => e ? `${e}/${t}` : t, ct = (e) => /^[\w./@%+=:,-]+$/.test(e) ? e : `'${e.replace(/'/g, "'\\''")}'`, z = (e, t) => `blazon ${e}${t ? ` ${ct(t)}` : ""}`, lt = (e) => j.statSync(e, { throwIfNoEntry: !1 })?.isDirectory() ?? !1, ut = (e) => `Run ${z("init", L(e))} to start a brand book there`;
59
- function dt(e) {
60
- if (!lt(e)) throw new P(`no folder "${e}"`, `${ut(e)}.`, "no-folder");
58
+ var I = (e, t) => e ? `${e}/${t}` : t, pt = (e) => /^[\w./@%+=:,-]+$/.test(e) ? e : `'${e.replace(/'/g, "'\\''")}'`, L = (e, t) => `blazon ${e}${t ? ` ${pt(t)}` : ""}`, mt = (e) => k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory() ?? !1, ht = (e) => `Run ${L("init", F(e))} to start a brand book there`;
59
+ function gt(e) {
60
+ if (!mt(e)) throw new M(`no folder "${e}"`, `${ht(e)}.`, "no-folder");
61
61
  }
62
- function ft(e, t) {
63
- if (!lt(A.resolve(e, t))) throw new P(`no tokens folder (${t.replace(/^\.\//, "").replace(/\/$/, "")}) in "${e}"`, `${ut(e)}, or set tokensDir in blazon.json.`, "no-tokens-folder");
62
+ function _t(e, t) {
63
+ if (!mt(O.resolve(e, t))) throw new M(`no tokens folder (${t.replace(/^\.\//, "").replace(/\/$/, "")}) in "${e}"`, `${ht(e)}, or set tokensDir in blazon.json.`, "no-tokens-folder");
64
64
  }
65
- async function B(e, t) {
66
- dt(e);
67
- let n = await f(e, t);
68
- return ft(e, n.tokensDir), n;
65
+ async function R(e, t) {
66
+ gt(e);
67
+ let n = await ae(e, t);
68
+ return _t(e, n.tokensDir), n;
69
69
  }
70
70
  // src/cli/commands/dev.ts
71
- var pt = /* @__PURE__ */ C({ runDev: () => mt });
72
- async function mt(e = process.cwd(), t, n = {}) {
73
- let r = await B(e, t ? { port: t } : void 0);
71
+ var vt = /* @__PURE__ */ y({ runDev: () => yt });
72
+ async function yt(e = process.cwd(), t, n = {}) {
73
+ let r = await R(e, t ? { port: t } : void 0);
74
74
  try {
75
- await be(r, e, n);
75
+ await we(r, e, n);
76
76
  } catch (e) {
77
- throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? Ze(r.port) : e;
77
+ throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? nt(r.port) : e;
78
78
  }
79
79
  }
80
80
  // src/cli/commands/check.ts
81
- var ht = class extends N {
81
+ var bt = class extends j {
82
82
  findings;
83
83
  constructor(e, t, n, r = "check-failed") {
84
84
  super(e, n, r), this.findings = t;
85
85
  }
86
- }, gt = (e) => e?.plugins === !1, _t = (e) => e?.plugin === void 0 ? [] : [e.plugin].flat();
87
- function vt(e) {
86
+ }, xt = (e) => e?.plugins === !1, St = (e) => e?.plugin === void 0 ? [] : [e.plugin].flat();
87
+ function Ct(e) {
88
88
  return e.context ? `${e.path} (${e.context})` : e.path;
89
89
  }
90
- var yt = 5;
91
- function bt(e) {
92
- let t = e.slice(0, yt).join(", ");
93
- return e.length > yt ? `${t} and ${e.length - yt} more` : t;
94
- }
95
- var xt = (e) => e.path.split("/")[0];
96
- function St(e, t) {
97
- let r = [], i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = e.filter((e) => e.code === "page-review-pending");
98
- for (let t of e) t.code === "starter-file-unchanged" && a.set(xt(t), [...a.get(xt(t)) ?? [], t]), t.code === "review-pending" && o.set(t.message, [...o.get(t.message) ?? [], t]);
99
- for (let c of e) {
100
- if (i.has(c)) continue;
101
- let e = c.code === "starter-file-unchanged" ? a.get(xt(c)) : void 0, l = c.code === "review-pending" ? o.get(c.message) : void 0;
102
- if (c.code === "page-review-pending" && s.length > 1) s.forEach((e) => i.add(e)), r.push(`${n.bold(`page-review-pending (${s.length} pages)`)}: ${bt(s.map(vt))}: show assets still marked needs-review ${n.dim("[page-review-pending]")}`);
90
+ var wt = 5;
91
+ function Tt(e) {
92
+ let t = e.slice(0, wt).join(", ");
93
+ return e.length > wt ? `${t} and ${e.length - wt} more` : t;
94
+ }
95
+ var Et = (e) => e.path.split("/")[0];
96
+ function Dt(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(Et(t), [...i.get(Et(t)) ?? [], t]), t.code === "review-pending" && a.set(t.message, [...a.get(t.message) ?? [], t]);
99
+ for (let s of e) {
100
+ if (r.has(s)) continue;
101
+ let e = s.code === "starter-file-unchanged" ? i.get(Et(s)) : void 0, c = s.code === "review-pending" ? a.get(s.message) : void 0;
102
+ if (s.code === "page-review-pending" && o.length > 1) o.forEach((e) => r.add(e)), n.push(`${l.bold(`page-review-pending (${o.length} pages)`)}: ${Tt(o.map(Ct))}: show assets still marked needs-review ${l.dim("[page-review-pending]")}`);
103
103
  else if (e && e.length > 1) {
104
- e.forEach((e) => i.add(e));
105
- let t = xt(c), a = e.map((e) => e.path.slice(t.length + 1));
106
- r.push(`${n.bold(`${t}/`)}: ${e.length} files are still the starter's text (${bt(a)}) ${n.dim("[starter-file-unchanged]")}`);
107
- } else if (l && l.length > 1) l.forEach((e) => i.add(e)), r.push(`${n.bold(`review-pending (${l.length})`)}: ${bt(l.map(vt))}: ${c.message} ${n.dim("[review-pending]")}`);
104
+ e.forEach((e) => r.add(e));
105
+ let t = Et(s), i = e.map((e) => e.path.slice(t.length + 1));
106
+ n.push(`${l.bold(`${t}/`)}: ${e.length} files are still the starter's text (${Tt(i)}) ${l.dim("[starter-file-unchanged]")}`);
107
+ } else if (c && c.length > 1) c.forEach((e) => r.add(e)), n.push(`${l.bold(`review-pending (${c.length})`)}: ${Tt(c.map(Ct))}: ${s.message} ${l.dim("[review-pending]")}`);
108
108
  else {
109
- let e = je(c, t), i = e === void 0 ? n.bold(vt(c)) : c.path === c.file ? n.bold(e) : `${n.bold(e)} ${vt(c)}`;
110
- r.push(`${i}: ${c.message} ${n.dim(`[${c.code}]`)}`);
109
+ let e = ye(s, t), r = e === void 0 ? l.bold(Ct(s)) : s.path === s.file ? l.bold(e) : `${l.bold(e)} ${Ct(s)}`;
110
+ n.push(`${r}: ${s.message} ${l.dim(`[${s.code}]`)}`);
111
111
  }
112
112
  }
113
- return r;
113
+ return n;
114
114
  }
115
- function Ct(e, t = "") {
116
- for (let r of St(e.errors, t)) console.log(` ${n.bgRed(n.white(" ERROR "))} ${r}`);
117
- for (let r of St(e.warnings, t)) console.log(` ${n.bgYellow(n.black(" WARN "))} ${r}`);
118
- for (let r of St(e.infos, t)) console.log(` ${n.bgCyan(n.black(" NOTE "))} ${r}`);
115
+ function Ot(e, t = "") {
116
+ for (let n of Dt(e.errors, t)) console.log(` ${l.bgRed(l.white(" ERROR "))} ${n}`);
117
+ for (let n of Dt(e.warnings, t)) console.log(` ${l.bgYellow(l.black(" WARN "))} ${n}`);
118
+ for (let n of Dt(e.infos, t)) console.log(` ${l.bgCyan(l.black(" NOTE "))} ${n}`);
119
119
  }
120
- var wt = 5;
121
- function Tt(e, t = "") {
122
- e.infos.filter((e) => e.code === "starter-file-unchanged").length < wt || (console.log(n.bold("Next:")), console.log(` 1. Edit ${n.cyan(R(t, "tokens/colors.json"))} with your colors`), console.log(` 2. Run ${n.cyan(z("dev", t))} to see the book`), console.log(` 3. Replace blazon's artwork in ${n.cyan(R(t, "assets/"))} and the text in ${n.cyan(R(t, "docs/"))}`), console.log());
120
+ var kt = 5;
121
+ function At(e, t = "") {
122
+ e.infos.filter((e) => e.code === "starter-file-unchanged").length < kt || (console.log(l.bold("Next:")), console.log(` 1. Edit ${l.cyan(I(t, "tokens/colors.json"))} with your colors`), console.log(` 2. Run ${l.cyan(L("dev", t))} to see the book`), console.log(` 3. Replace blazon's artwork in ${l.cyan(I(t, "assets/"))} and the text in ${l.cyan(I(t, "docs/"))}`), console.log());
123
123
  }
124
- var Et = 3;
125
- function Dt(e, t = "") {
126
- let r = /* @__PURE__ */ new Map();
124
+ var jt = 3;
125
+ function Mt(e, t = "") {
126
+ let n = /* @__PURE__ */ new Map();
127
127
  for (let t of e.errors) {
128
- let e = ve(t);
129
- e && !r.has(`${t.code}\n${e}`) && r.set(`${t.code}\n${e}`, {
128
+ let e = Ue(t);
129
+ e && !n.has(`${t.code}\n${e}`) && n.set(`${t.code}\n${e}`, {
130
130
  code: t.code,
131
131
  fix: e
132
132
  });
133
133
  }
134
- let i = [...r.values()].slice(0, Et);
135
- console.log(n.bold("Next:")), i.forEach(({ code: e, fix: t }, r) => console.log(` ${r + 1}. ${n.cyan(e)}: ${t}`)), console.log(` ${i.length + 1}. Run ${n.cyan(z("check", t))} again`), console.log();
134
+ let r = [...n.values()].slice(0, jt);
135
+ console.log(l.bold("Next:")), r.forEach(({ code: e, fix: t }, n) => console.log(` ${n + 1}. ${l.cyan(e)}: ${t}`)), console.log(` ${r.length + 1}. Run ${l.cyan(L("check", t))} again`), console.log();
136
136
  }
137
- function Ot(e, t = process.cwd()) {
138
- let n = k(e.findings);
137
+ function Nt(e, t = process.cwd()) {
138
+ let n = c(e.findings);
139
139
  if (n.all.length === 0) return;
140
- let r = L(t);
141
- if (console.log(), Ct(n, r), console.log(), n.errors.length > 0) throw new ht(`blazon check found ${n.errors.length} error(s)`, e.findings, `Fix them, or run ${z("check", r)} for details.`);
142
- }
143
- async function kt(e = process.cwd(), t = !1, r) {
144
- let i = await B(e);
145
- console.log(n.cyan("\n[blazon] Checking design tokens..."));
146
- let a = await D(i, e);
147
- a.findings.push(...ye(e)), gt(r) || await ce(a, i, e, new ge(i, e, { named: _t(r) }));
148
- let o = k(a.findings, { strict: t });
149
- if (o.all.length === 0) return console.log(n.green(`\n ✔ ${a.tokens.items.length} tokens, no findings.\n`)), {
140
+ let r = F(t);
141
+ if (console.log(), Ot(n, r), console.log(), n.errors.length > 0) throw new bt(`blazon check found ${n.errors.length} error(s)`, e.findings, `Fix them, or run ${L("check", r)} for details.`);
142
+ }
143
+ async function Pt(e = process.cwd(), t = !1, n) {
144
+ let r = await R(e);
145
+ console.log(l.cyan("\n[blazon] Checking design tokens..."));
146
+ let a = await D(r, e);
147
+ a.findings.push(...We(e)), xt(n) || await i(a, r, e, new Je(r, e, { named: St(n) }));
148
+ let o = c(a.findings, { strict: t });
149
+ if (o.all.length === 0) return console.log(l.green(`\n ✔ ${a.tokens.items.length} tokens, no findings.\n`)), {
150
150
  findings: o.all,
151
151
  passed: !0
152
152
  };
@@ -154,88 +154,88 @@ async function kt(e = process.cwd(), t = !1, r) {
154
154
  o.errors.length > 0 && `${o.errors.length} error(s)`,
155
155
  o.warnings.length > 0 && `${o.warnings.length} warning(s)`,
156
156
  o.infos.length > 0 && `${o.infos.length} note(s)`
157
- ].filter(Boolean), c = o.errors.length + o.warnings.length > 0 ? `${o.errors.length} error(s) and ${o.warnings.length} warning(s)${o.infos.length > 0 ? ` and ${o.infos.length} note(s)` : ""}` : s.join(" and "), l = L(e);
158
- return console.log(`\nFound ${c}:\n`), Ct(o, l), console.log(), o.errors.length > 0 ? Dt(o, l) : Tt(o, l), o.passed ? (console.log(o.warnings.length > 0 ? n.yellow("✔ Check passed with warnings.\n") : n.green("✔ Check passed.\n")), {
157
+ ].filter(Boolean), u = o.errors.length + o.warnings.length > 0 ? `${o.errors.length} error(s) and ${o.warnings.length} warning(s)${o.infos.length > 0 ? ` and ${o.infos.length} note(s)` : ""}` : s.join(" and "), d = F(e);
158
+ return console.log(`\nFound ${u}:\n`), Ot(o, d), console.log(), o.errors.length > 0 ? Mt(o, d) : At(o, d), o.passed ? (console.log(o.warnings.length > 0 ? l.yellow("✔ Check passed with warnings.\n") : l.green("✔ Check passed.\n")), {
159
159
  findings: o.all,
160
160
  passed: !0
161
- }) : (console.error(n.red(`✖ Check failed${t ? " (--strict treats warnings as errors)" : ""}.\n`)), {
161
+ }) : (console.error(l.red(`✖ Check failed${t ? " (--strict treats warnings as errors)" : ""}.\n`)), {
162
162
  findings: o.all,
163
163
  passed: !1
164
164
  });
165
165
  }
166
166
  // src/cli/commands/build.ts
167
- async function At(e = process.cwd(), t, r) {
168
- let i = await B(e, t ? { outDir: t } : void 0), a = await D(i, e);
169
- a.findings.push(...ye(e));
170
- let o = new ge(i, e, { named: _t(r) });
171
- gt(r) || await ce(a, i, e, o), Ot(a, e);
172
- let { siteOutDir: s } = await Re(i, e, { data: a }), c = gt(r) ? [] : await Ke(a, i, e, o, s);
173
- if (c.length === 0) return { findings: a.findings };
174
- let l = k(c);
175
- if (console.log(), Ct(l, L(e)), console.log(), l.errors.length > 0) throw new ht(`a build plugin reported ${l.errors.length} error(s)`, [...a.findings, ...c], "The site is built; the plugin's findings above say what to fix.", "plugin-failed");
176
- return console.log(n.dim(" Build plugins finished.")), { findings: [...a.findings, ...c] };
167
+ async function Ft(e = process.cwd(), t, n) {
168
+ let r = await R(e, t ? { outDir: t } : void 0), a = await D(r, e);
169
+ a.findings.push(...We(e));
170
+ let o = new Je(r, e, { named: St(n) });
171
+ xt(n) || await i(a, r, e, o), Nt(a, e);
172
+ let { siteOutDir: s } = await Re(r, e, { data: a }), u = xt(n) ? [] : await C(a, r, e, o, s);
173
+ if (u.length === 0) return { findings: a.findings };
174
+ let d = c(u);
175
+ if (console.log(), Ot(d, F(e)), console.log(), d.errors.length > 0) throw new bt(`a build plugin reported ${d.errors.length} error(s)`, [...a.findings, ...u], "The site is built; the plugin's findings above say what to fix.", "plugin-failed");
176
+ return console.log(l.dim(" Build plugins finished.")), { findings: [...a.findings, ...u] };
177
177
  }
178
178
  // src/cli/commands/tokens.ts
179
- async function jt(e = process.cwd(), t) {
180
- let r = await B(e);
181
- console.log(n.cyan("\n[blazon] Compiling design tokens..."));
182
- let i = await D(r, e);
183
- i.findings.push(...ye(e));
184
- let a = new ge(r, e, { named: _t(t) });
185
- gt(t) || await ce(i, r, e, a), Ot(i, e);
186
- let o = await he(i, r, e);
179
+ async function It(e = process.cwd(), t) {
180
+ let n = await R(e);
181
+ console.log(l.cyan("\n[blazon] Compiling design tokens..."));
182
+ let r = await D(n, e);
183
+ r.findings.push(...We(e));
184
+ let a = new Je(n, e, { named: St(t) });
185
+ xt(t) || await i(r, n, e, a), Nt(r, e);
186
+ let o = await Ce(r, n, e);
187
187
  for (let e of [
188
188
  o.cssPath,
189
189
  o.typographyPath,
190
190
  o.tsPath,
191
191
  o.jsonPath
192
- ]) e && console.log(` ${n.green("✔")} Emitted ${n.bold(e)}`);
192
+ ]) e && console.log(` ${l.green("✔")} Emitted ${l.bold(e)}`);
193
193
  console.log();
194
- let s = gt(t) ? [] : await Ke(i, r, e, a);
195
- if (s.length === 0) return { findings: i.findings };
196
- let c = k(s);
197
- if (Ct(c, L(e)), console.log(), c.errors.length > 0) throw new ht(`a build plugin reported ${c.errors.length} error(s)`, [...i.findings, ...s], "The token files are written; the plugin's findings above say what to fix.", "plugin-failed");
198
- return { findings: [...i.findings, ...s] };
194
+ let s = xt(t) ? [] : await C(r, n, e, a);
195
+ if (s.length === 0) return { findings: r.findings };
196
+ let u = c(s);
197
+ if (Ot(u, F(e)), console.log(), u.errors.length > 0) throw new bt(`a build plugin reported ${u.errors.length} error(s)`, [...r.findings, ...s], "The token files are written; the plugin's findings above say what to fix.", "plugin-failed");
198
+ return { findings: [...r.findings, ...s] };
199
199
  }
200
200
  // src/core/drift/compare.ts
201
- var Mt = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Nt = /^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/i, Pt = (e) => e.trim().toLowerCase().replace(/\s+/g, " ");
202
- function Ft(e) {
201
+ var Lt = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Rt = /^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/i, zt = (e) => e.trim().toLowerCase().replace(/\s+/g, " ");
202
+ function Bt(e) {
203
203
  let t = e.trim();
204
- if (!Mt.test(t)) return Pt(t);
204
+ if (!Lt.test(t)) return zt(t);
205
205
  let n = t.slice(1).toLowerCase();
206
206
  return `#${n.length <= 4 ? [...n].map((e) => e + e).join("") : n}`;
207
207
  }
208
- function It(e) {
209
- let t = e.trim().match(Nt);
210
- return t ? `${Number(t[1])}${t[2].toLowerCase()}` : Pt(e);
208
+ function Vt(e) {
209
+ let t = e.trim().match(Rt);
210
+ return t ? `${Number(t[1])}${t[2].toLowerCase()}` : zt(e);
211
211
  }
212
- function Lt(e, t) {
213
- return e === "color" ? Ft(t) : e === "dimension" ? It(t) : Pt(t);
212
+ function Ht(e, t) {
213
+ return e === "color" ? Bt(t) : e === "dimension" ? Vt(t) : zt(t);
214
214
  }
215
- var Rt = /\/\*[\s\S]*?\*\//g, zt = /([^{}]*)\{([^{}]*)\}/g, Bt = /(--[A-Za-z0-9_-]+)\s*:\s*([^;]*?)\s*(?:;|$)/g, Vt = /(^|,)\s*(:root|html)\s*(,|$)/, Ht = /^var\(\s*(--[A-Za-z0-9_-]+)\s*\)$/;
216
- function Ut(e) {
215
+ var Ut = /\/\*[\s\S]*?\*\//g, Wt = /([^{}]*)\{([^{}]*)\}/g, Gt = /(--[A-Za-z0-9_-]+)\s*:\s*([^;]*?)\s*(?:;|$)/g, Kt = /(^|,)\s*(:root|html)\s*(,|$)/, qt = /^var\(\s*(--[A-Za-z0-9_-]+)\s*\)$/;
216
+ function Jt(e) {
217
217
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
218
- for (let r of e.replace(Rt, "").matchAll(zt)) {
219
- let e = Vt.test(r[1].trim()) ? t : n;
220
- for (let t of r[2].matchAll(Bt)) e.set(t[1], t[2]);
218
+ for (let r of e.replace(Ut, "").matchAll(Wt)) {
219
+ let e = Kt.test(r[1].trim()) ? t : n;
220
+ for (let t of r[2].matchAll(Gt)) e.set(t[1], t[2]);
221
221
  }
222
222
  let r = new Map([...n, ...t]);
223
223
  for (let [e, t] of r) {
224
224
  let n = t, i = /* @__PURE__ */ new Set([e]);
225
- for (let e = n.match(Ht); e && r.has(e[1]) && !i.has(e[1]); e = n.match(Ht)) i.add(e[1]), n = r.get(e[1]);
225
+ for (let e = n.match(qt); e && r.has(e[1]) && !i.has(e[1]); e = n.match(qt)) i.add(e[1]), n = r.get(e[1]);
226
226
  r.set(e, n);
227
227
  }
228
228
  return r;
229
229
  }
230
- function Wt(e, t, n) {
231
- let r = Lt(e.type, String(e.value)), i = n.get(t);
230
+ function Yt(e, t, n) {
231
+ let r = Ht(e.type, String(e.value)), i = n.get(t);
232
232
  if (i === void 0) return {
233
233
  path: e.path,
234
234
  cssVar: t,
235
235
  status: "missing",
236
236
  expected: r
237
237
  };
238
- let a = Lt(e.type, i);
238
+ let a = Ht(e.type, i);
239
239
  return {
240
240
  path: e.path,
241
241
  cssVar: t,
@@ -244,21 +244,21 @@ function Wt(e, t, n) {
244
244
  actual: a
245
245
  };
246
246
  }
247
- var Gt = 1e4;
248
- function Kt(e) {
247
+ var Xt = 1e4;
248
+ function Zt(e) {
249
249
  let t = e instanceof Error ? e.message : String(e), n = e instanceof Error ? e.cause : void 0;
250
250
  return n instanceof Error && n.message && n.message !== t ? `${t}: ${n.message}` : t;
251
251
  }
252
- async function qt(e) {
252
+ async function Qt(e) {
253
253
  let t;
254
254
  try {
255
255
  t = await fetch(e, {
256
- signal: AbortSignal.timeout(Gt),
256
+ signal: AbortSignal.timeout(Xt),
257
257
  redirect: "follow"
258
258
  });
259
259
  } catch (t) {
260
260
  let n = t instanceof Error && (t.name === "TimeoutError" || t.name === "AbortError");
261
- throw Error(`could not fetch ${e}: ${n ? `no answer in ${Gt / 1e3} s` : Kt(t)}`, { cause: t });
261
+ throw Error(`could not fetch ${e}: ${n ? `no answer in ${Xt / 1e3} s` : Zt(t)}`, { cause: t });
262
262
  }
263
263
  if (!t.ok) throw Error(`could not fetch ${e}: ${t.status} ${t.statusText}`.trim());
264
264
  let n = [], r = 0;
@@ -272,10 +272,10 @@ async function qt(e) {
272
272
  }
273
273
  return Buffer.concat(n);
274
274
  }
275
- async function Jt(e) {
276
- return (await qt(e)).toString("utf8");
275
+ async function $t(e) {
276
+ return (await Qt(e)).toString("utf8");
277
277
  }
278
- function Yt(e, t) {
278
+ function en(e, t) {
279
279
  let n = [];
280
280
  for (let [r] of e.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<link\b[^>]*>/gi)) {
281
281
  let e = (e) => r.match(RegExp(`\\s${e}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i")), i = e("rel"), a = e("href");
@@ -286,19 +286,19 @@ function Yt(e, t) {
286
286
  }
287
287
  return n;
288
288
  }
289
- async function Xt(e) {
289
+ async function tn(e) {
290
290
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(e)) {
291
291
  if (!/^https?:\/\//i.test(e)) throw Error(`${e} is not an http(s) address or a file`);
292
- let t = Yt(await Jt(e), e).slice(0, 20);
292
+ let t = en(await $t(e), e).slice(0, 20);
293
293
  return {
294
- css: (await Promise.all(t.map(Jt))).join("\n"),
294
+ css: (await Promise.all(t.map($t))).join("\n"),
295
295
  sources: t
296
296
  };
297
297
  }
298
- let t = A.resolve(e), n;
298
+ let t = O.resolve(e), n;
299
299
  try {
300
- if (j.statSync(t).size > 5242880) throw Error(`${t} is larger than 5 MB`);
301
- n = j.readFileSync(t, "utf8");
300
+ if (k.statSync(t).size > 5242880) throw Error(`${t} is larger than 5 MB`);
301
+ n = k.readFileSync(t, "utf8");
302
302
  } catch (e) {
303
303
  throw Error(e instanceof Error && e.message.endsWith("5 MB") ? e.message : `could not read ${t}: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
304
304
  }
@@ -307,60 +307,60 @@ async function Xt(e) {
307
307
  sources: [t]
308
308
  };
309
309
  }
310
- async function Zt(e) {
310
+ async function nn(e) {
311
311
  if (!/^https?:\/\//i.test(e)) throw Error(`${e} is not an http(s) address`);
312
- let t = await Jt(e), n = Yt(t, e).slice(0, 20);
312
+ let t = await $t(e), n = en(t, e).slice(0, 20);
313
313
  return {
314
314
  html: t,
315
- css: (await Promise.all(n.map(Jt))).join("\n"),
315
+ css: (await Promise.all(n.map($t))).join("\n"),
316
316
  sources: n
317
317
  };
318
318
  }
319
319
  // src/core/init/from-site/tree.ts
320
- var Qt = (e) => typeof e == "object" && !!e && "$value" in e;
321
- function $t(e) {
322
- return JSON.parse(j.readFileSync(e, "utf-8"));
320
+ var rn = (e) => typeof e == "object" && !!e && "$value" in e;
321
+ function an(e) {
322
+ return JSON.parse(k.readFileSync(e, "utf-8"));
323
323
  }
324
- function en(e, t) {
325
- j.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
324
+ function on(e, t) {
325
+ k.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
326
326
  }
327
- var tn = (e) => ({ "dev.blazon": e });
328
- function nn(e, t = []) {
327
+ var sn = (e) => ({ "dev.blazon": e });
328
+ function cn(e, t = []) {
329
329
  let n = [];
330
- for (let [r, i] of Object.entries(e)) !r.startsWith("$") && typeof i == "object" && i && (Qt(i) ? n.push([...t, r].join(".")) : n.push(...nn(i, [...t, r])));
330
+ for (let [r, i] of Object.entries(e)) !r.startsWith("$") && typeof i == "object" && i && (rn(i) ? n.push([...t, r].join(".")) : n.push(...cn(i, [...t, r])));
331
331
  return n;
332
332
  }
333
- var rn = (e, t) => {
333
+ var ln = (e, t) => {
334
334
  let n = e;
335
335
  for (let e of t.split(".")) {
336
336
  if (typeof n != "object" || !n) return;
337
337
  n = n[e];
338
338
  }
339
- return Qt(n) ? n : void 0;
340
- }, an = (e) => [...JSON.stringify(e).matchAll(/\{([A-Za-z0-9_.-]+)\}/g)].map((e) => e[1]);
341
- function on(e, t) {
342
- return j.existsSync(e) ? j.readdirSync(e, { withFileTypes: !0 }).flatMap((n) => {
343
- let r = A.join(e, n.name);
344
- return n.isDirectory() ? on(r, t) : t.some((e) => n.name.endsWith(e)) ? [r] : [];
339
+ return rn(n) ? n : void 0;
340
+ }, un = (e) => [...JSON.stringify(e).matchAll(/\{([A-Za-z0-9_.-]+)\}/g)].map((e) => e[1]);
341
+ function dn(e, t) {
342
+ return k.existsSync(e) ? k.readdirSync(e, { withFileTypes: !0 }).flatMap((n) => {
343
+ let r = O.join(e, n.name);
344
+ return n.isDirectory() ? dn(r, t) : t.some((e) => n.name.endsWith(e)) ? [r] : [];
345
345
  }) : [];
346
346
  }
347
- function sn(e, t) {
347
+ function fn(e, t) {
348
348
  let n = t.split("."), r = [e];
349
349
  for (let e of n.slice(0, -1)) r.push(r.at(-1)[e]);
350
350
  delete r.at(-1)[n.at(-1)];
351
351
  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
352
  }
353
353
  // src/core/init/from-site/clean-colors.ts
354
- function cn(e) {
354
+ function pn(e) {
355
355
  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 = rn(t, `${e}.${n}`)?.$value, o = typeof r == "string" ? r.match(/^\{(.+)\}$/)?.[1] : void 0;
356
+ let r = ln(t, `${e}.${n}`)?.$value, o = typeof r == "string" ? r.match(/^\{(.+)\}$/)?.[1] : void 0;
357
357
  return o && i.has(o) && !a.has(o) ? o : void 0;
358
358
  }, d = (e, n, r, i = {}) => {
359
- let [a, c] = e.split("."), u = rn(t, e), d = String(u.$value);
359
+ let [a, c] = e.split("."), u = ln(t, e), d = String(u.$value);
360
360
  t[a][c] = {
361
361
  $value: `{${n}}`,
362
362
  ...typeof u.$description == "string" && { $description: u.$description },
363
- $extensions: tn({
363
+ $extensions: sn({
364
364
  ...i,
365
365
  review: r ? {
366
366
  ...s,
@@ -391,20 +391,20 @@ function cn(e) {
391
391
  let [n, r] = e.split("."), i = p(t);
392
392
  i && u(n, r) && d(e, f(i), "", { source: c(`:root { ${i.cssVar} }`, i.exact ? i.cssVar : void 0) });
393
393
  }
394
- let m = t.color, { color: h, ...g } = t, _ = new Set(an(g));
395
- for (let e of on(A.join(n, "tokens"), [".json"])) if (A.basename(e) !== "colors.json") for (let t of an($t(e))) _.add(t);
396
- let v = [A.join(n, "blazon.json"), ...on(A.join(n, "docs"), [".md", ".mdx"])].filter((e) => j.existsSync(e)).map((e) => j.readFileSync(e, "utf-8")).join("\n");
394
+ let m = t.color, { color: h, ...g } = t, _ = new Set(un(g));
395
+ for (let e of dn(O.join(n, "tokens"), [".json"])) if (O.basename(e) !== "colors.json") for (let t of un(an(e))) _.add(t);
396
+ let v = [O.join(n, "blazon.json"), ...dn(O.join(n, "docs"), [".md", ".mdx"])].filter((e) => k.existsSync(e)).map((e) => k.readFileSync(e, "utf-8")).join("\n");
397
397
  for (let e of v.matchAll(/(?<![\w.-])color(?:\.[A-Za-z0-9_-]+)+/g)) _.add(e[0]);
398
398
  let y = [..._];
399
399
  for (; y.length > 0;) {
400
- let e = rn(t, y.pop());
401
- for (let t of e ? an(e.$value) : []) _.has(t) || (_.add(t), y.push(t));
400
+ let e = ln(t, y.pop());
401
+ for (let t of e ? un(e.$value) : []) _.has(t) || (_.add(t), y.push(t));
402
402
  }
403
- for (let e of [...i].filter((e) => !a.has(e) && !_.has(e))) rn({ color: m }, e) && (sn({ color: m }, e), l.removed.push(`${e} (a starter color nothing uses)`));
403
+ for (let e of [...i].filter((e) => !a.has(e) && !_.has(e))) ln({ color: m }, e) && (fn({ color: m }, e), l.removed.push(`${e} (a starter color nothing uses)`));
404
404
  }
405
405
  // src/core/init/palette.ts
406
- var ln = "#ffffff", un = "#0b1120";
407
- function dn(e) {
406
+ var mn = "#ffffff", hn = "#0b1120";
407
+ function gn(e) {
408
408
  let t = e.trim().match(/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i);
409
409
  if (!t) return;
410
410
  let n = t[1].length === 3 ? [...t[1]].map((e) => e + e).join("") : t[1];
@@ -414,38 +414,38 @@ function dn(e) {
414
414
  4
415
415
  ].map((e) => parseInt(n.slice(e, e + 2), 16) / 255);
416
416
  }
417
- var fn = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
418
- function pn(e) {
419
- let t = dn(e);
417
+ var _n = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
418
+ function vn(e) {
419
+ let t = gn(e);
420
420
  if (!t) throw Error(`not a hex color: ${e}`);
421
421
  return t;
422
422
  }
423
- function mn(e) {
424
- let [t, n, r] = pn(e).map(fn);
423
+ function yn(e) {
424
+ let [t, n, r] = vn(e).map(_n);
425
425
  return .2126 * t + .7152 * n + .0722 * r;
426
426
  }
427
- function V(e, t) {
428
- let [n, r] = [mn(e), mn(t)];
427
+ function z(e, t) {
428
+ let [n, r] = [yn(e), yn(t)];
429
429
  return (Math.max(n, r) + .05) / (Math.min(n, r) + .05);
430
430
  }
431
- var hn = (e) => e >= 7 ? "AAA" : e >= 4.5 ? "AA" : e >= 3 ? "AA-large" : "fail";
432
- function gn(e) {
433
- let t = V(e, ln), n = V(e, un);
431
+ var bn = (e) => e >= 7 ? "AAA" : e >= 4.5 ? "AA" : e >= 3 ? "AA-large" : "fail";
432
+ function xn(e) {
433
+ let t = z(e, mn), n = z(e, hn);
434
434
  return {
435
435
  onWhite: {
436
436
  ratio: t,
437
- level: hn(t)
437
+ level: bn(t)
438
438
  },
439
439
  onNearBlack: {
440
440
  ratio: n,
441
- level: hn(n)
441
+ level: bn(n)
442
442
  },
443
443
  carriesWhiteText: t >= 4.5
444
444
  };
445
445
  }
446
- var _n = "#1E1F21", vn = "#F2F0EB";
447
- function yn(e) {
448
- let t = V(e, _n), n = V(e, vn);
446
+ var Sn = "#1E1F21", Cn = "#F2F0EB";
447
+ function wn(e) {
448
+ let t = z(e, Sn), n = z(e, Cn);
449
449
  return t >= n ? {
450
450
  ink: "graphite",
451
451
  ratio: t,
@@ -457,42 +457,42 @@ function yn(e) {
457
457
  };
458
458
  }
459
459
  // src/core/init/vocabulary.ts
460
- var bn = "color.signal.orange", xn = "color.signal.primary", Sn = "color.signal.hazard", Cn = (e) => typeof e == "object" && !!e && "$value" in e;
461
- function H(e, t) {
460
+ var Tn = "color.signal.orange", En = "color.signal.primary", Dn = "color.signal.hazard", On = (e) => typeof e == "object" && !!e && "$value" in e;
461
+ function B(e, t) {
462
462
  let n = e;
463
463
  for (let e of t.split(".")) {
464
464
  if (typeof n != "object" || !n) return;
465
465
  n = n[e];
466
466
  }
467
- return Cn(n) ? n : void 0;
467
+ return On(n) ? n : void 0;
468
468
  }
469
- function wn(e, t) {
469
+ function kn(e, t) {
470
470
  let n = e.$extensions ??= {}, r = n["dev.blazon"] ??= {};
471
471
  r.review === void 0 && (r.review = {
472
472
  status: "needs-review",
473
473
  note: t
474
474
  });
475
475
  }
476
- function Tn(e, t) {
476
+ function An(e, t) {
477
477
  let n = [], r = e.color, i = r?.signal, a = i?.orange;
478
- if (!i || !Cn(a)) throw Error(`${bn} is not in the tokens`);
478
+ if (!i || !On(a)) throw Error(`${Tn} is not in the tokens`);
479
479
  let o = {};
480
480
  for (let [e, t] of Object.entries(i)) o[e === "orange" ? "primary" : e] = t;
481
481
  r.signal = o;
482
- let s = JSON.parse(JSON.stringify(e).split(`{${bn}}`).join(`{${xn}}`));
482
+ let s = JSON.parse(JSON.stringify(e).split(`{${Tn}}`).join(`{${En}}`));
483
483
  for (let t of Object.keys(e)) e[t] = s[t];
484
- let c = H(e, xn);
484
+ let c = B(e, En);
485
485
  c.$value = t, c.$description = "Primary signal color";
486
- let l = En(e, t, `{${xn}}`);
486
+ let l = jn(e, t, `{${En}}`);
487
487
  n.push(...l.hints);
488
- let u = H(e, Sn);
489
- return u && (wn(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(`${Sn} is still blazon's hazard yellow and is marked needs-review: set the brand's own or remove it`)), {
488
+ let u = B(e, Dn);
489
+ return u && (kn(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(`${Dn} is still blazon's hazard yellow and is marked needs-review: set the brand's own or remove it`)), {
490
490
  hints: n,
491
491
  label: l.label
492
492
  };
493
493
  }
494
- function En(e, t, n, r = !1) {
495
- let i = [], a = V(t, _n), o = V(t, vn), s = H(e, "text.onSignal"), c = a < 4.5 && o >= 4.5 && s !== void 0;
494
+ function jn(e, t, n, r = !1) {
495
+ let i = [], a = z(t, Sn), o = z(t, Cn), s = B(e, "text.onSignal"), c = a < 4.5 && o >= 4.5 && s !== void 0;
496
496
  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
497
  let t = e.text?.$extensions?.["dev.blazon"];
498
498
  for (let e of t?.pairs ?? []) e.bg === "{color.signal.*}" && (e.bg = n);
@@ -502,16 +502,16 @@ function En(e, t, n, r = !1) {
502
502
  label: c ? "bone" : "graphite"
503
503
  };
504
504
  }
505
- var Dn = (e) => JSON.parse(j.readFileSync(e, "utf-8")), On = (e, t) => j.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
506
- function kn(e, t) {
505
+ var Mn = (e) => JSON.parse(k.readFileSync(e, "utf-8")), Nn = (e, t) => k.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
506
+ function Pn(e, t) {
507
507
  return [...t, ...Array.isArray(e) ? e.filter((e) => typeof e == "object" && !!e) : []];
508
508
  }
509
- var An = ["blazon-graphite", "blazon-bone"], jn = [...An, "blazon-mark"];
509
+ var Fn = ["blazon-graphite", "blazon-bone"], In = [...Fn, "blazon-mark"];
510
510
  // src/core/init/shared/hex.ts
511
- function Mn(e) {
511
+ function Ln(e) {
512
512
  let t = e.trim();
513
513
  if (/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)) return {
514
- hex: Ft(t),
514
+ hex: Bt(t),
515
515
  exact: !0
516
516
  };
517
517
  let n = t.match(/^rgba?\(\s*([\d.]+)(%?)[\s,]+([\d.]+)%?[\s,]+([\d.]+)%?(?:\s*[,/]\s*([\d.]+)(%?))?\s*\)$/i);
@@ -527,12 +527,12 @@ function Mn(e) {
527
527
  };
528
528
  }
529
529
  // src/core/init/from-site/colors.ts
530
- var Nn = 40, Pn = /brand|primary|secondary|accent|background|foreground|surface/i;
531
- function Fn(e) {
530
+ var Rn = 40, zn = /brand|primary|secondary|accent|background|foreground|surface/i;
531
+ function Bn(e) {
532
532
  let t = [], n = /* @__PURE__ */ new Set();
533
533
  for (let [r, i] of e) {
534
- if (!Pn.test(r)) continue;
535
- let e = Mn(i);
534
+ if (!zn.test(r)) continue;
535
+ let e = Ln(i);
536
536
  if (!e || e.hex.length !== 7) continue;
537
537
  let a = r.slice(2).toLowerCase().split(/[-_]+/).filter(Boolean);
538
538
  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 +541,20 @@ function Fn(e) {
541
541
  segments: a
542
542
  }));
543
543
  }
544
- return t.slice(0, Nn);
544
+ return t.slice(0, Rn);
545
545
  }
546
- function In(e, t, n = []) {
546
+ function Vn(e, t, n = []) {
547
547
  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
548
  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
549
  }
550
550
  // src/core/init/from-site/context.ts
551
- var Ln = (...e) => e.join("/");
551
+ var Hn = (...e) => e.join("/");
552
552
  // src/core/init/from-site/sections/colors.ts
553
- function Rn(e, t) {
554
- let { destDir: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = Fn(r).filter((e) => !t?.has(e.cssVar));
553
+ function Un(e, t) {
554
+ let { destDir: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = Bn(r).filter((e) => !t?.has(e.cssVar));
555
555
  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(Ln("tokens", "colors.json"))) {
557
- let e = A.join(n, "tokens", "colors.json"), t = $t(e), r = t.color ??= {}, c = new Set(nn(r, ["color"])), u = /* @__PURE__ */ new Set(), d = new Set(l.map((e) => e.segments.join(".")));
556
+ else if (c(Hn("tokens", "colors.json"))) {
557
+ let e = O.join(n, "tokens", "colors.json"), t = an(e), r = t.color ??= {}, c = new Set(cn(r, ["color"])), u = /* @__PURE__ */ new Set(), d = new Set(l.map((e) => e.segments.join(".")));
558
558
  for (let e of l) {
559
559
  let t = e.segments;
560
560
  [...d].some((e) => e.startsWith(`${t.join(".")}.`)) && (t = [...t, "base"]);
@@ -563,37 +563,37 @@ function Rn(e, t) {
563
563
  let t = n[r];
564
564
  if (t === void 0) {
565
565
  let t = {};
566
- e === 0 && (t.$extensions = tn({ review: o }), a = !0), n[r] = t, n = t;
567
- } else if (Qt(t) || typeof t != "object" || !t) {
566
+ e === 0 && (t.$extensions = sn({ review: o }), a = !0), n[r] = t, n = t;
567
+ } else if (rn(t) || typeof t != "object" || !t) {
568
568
  c = !1;
569
569
  break;
570
570
  } else n = t;
571
571
  }
572
572
  let l = t.at(-1);
573
- !c || typeof n[l] == "object" && n[l] !== null && !Qt(n[l]) ? i.missing.push(`${e.cssVar} was not written: color.${t.join(".")} clashes with a starter token`) : (n[l] = {
573
+ !c || typeof n[l] == "object" && n[l] !== null && !rn(n[l]) ? i.missing.push(`${e.cssVar} was not written: color.${t.join(".")} clashes with a starter token`) : (n[l] = {
574
574
  $value: e.hex,
575
- $extensions: tn({
575
+ $extensions: sn({
576
576
  source: s(`:root { ${e.cssVar} }`, e.exact ? e.cssVar : void 0),
577
577
  ...a ? {} : { review: o }
578
578
  })
579
579
  }, e.segments = t, u.add(e));
580
580
  }
581
- let f = new Set([...u].map((e) => `color.${e.segments.join(".")}`)), p = In(l, "primary"), m = t.interactive, h = rn(t, "interactive.primary");
581
+ let f = new Set([...u].map((e) => `color.${e.segments.join(".")}`)), p = Vn(l, "primary"), m = t.interactive, h = ln(t, "interactive.primary");
582
582
  if (!p) i.missing.push("no primary color: interactive.primary keeps the starter's value");
583
583
  else if (m && h) {
584
584
  let e = `color.${p.segments.join(".")}`;
585
585
  m.primary = {
586
586
  $value: `{${e}}`,
587
587
  ...typeof h.$description == "string" && { $description: h.$description },
588
- $extensions: tn({
588
+ $extensions: sn({
589
589
  source: s(`:root { ${p.cssVar} }`, p.exact ? p.cssVar : void 0),
590
590
  review: o
591
591
  })
592
592
  }, i.repointed.push(`interactive.primary to {${e}}`);
593
- let n = En(t, p.hex, `{${e}}`, !0);
593
+ let n = jn(t, p.hex, `{${e}}`, !0);
594
594
  for (let e of n.hints) i.missing.push(e);
595
595
  } else i.missing.push("interactive.primary was not found in tokens/colors.json, so the primary color was not set");
596
- cn({
596
+ pn({
597
597
  tree: t,
598
598
  destDir: n,
599
599
  picks: [...u],
@@ -603,53 +603,53 @@ function Rn(e, t) {
603
603
  review: o,
604
604
  source: s,
605
605
  result: i
606
- }), en(e, t), i.written.push(Ln("tokens", "colors.json"));
606
+ }), on(e, t), i.written.push(Hn("tokens", "colors.json"));
607
607
  }
608
608
  }
609
609
  // src/core/init/from-site/html.ts
610
- function zn(e) {
610
+ function Wn(e) {
611
611
  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
612
  }
613
- var U = (e, t) => {
613
+ var V = (e, t) => {
614
614
  let n = e.match(RegExp(`\\s${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
615
615
  return n ? n[1] ?? n[2] ?? n[3] : void 0;
616
616
  };
617
- function W(e, t) {
618
- for (let n of e.match(/<meta\b[^>]*>/gi) ?? []) if ((U(n, "property") ?? U(n, "name"))?.toLowerCase() === t) {
619
- let e = U(n, "content")?.replace(/&amp;/g, "&").trim();
617
+ function H(e, t) {
618
+ for (let n of e.match(/<meta\b[^>]*>/gi) ?? []) if ((V(n, "property") ?? V(n, "name"))?.toLowerCase() === t) {
619
+ let e = V(n, "content")?.replace(/&amp;/g, "&").trim();
620
620
  if (e) return e;
621
621
  }
622
622
  }
623
- function Bn(e) {
624
- let t = W(e, "og:site_name") ?? W(e, "application-name");
623
+ function Gn(e) {
624
+ let t = H(e, "og:site_name") ?? H(e, "application-name");
625
625
  if (t) return t;
626
626
  let n = e.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i);
627
- return (n ? zn(n[1]) : "") || void 0;
627
+ return (n ? Wn(n[1]) : "") || void 0;
628
628
  }
629
- async function Vn(e, t) {
630
- let n = (e.match(/<link\b[^>]*>/gi) ?? []).find((e) => U(e, "rel")?.toLowerCase() === "manifest"), r = n && U(n, "href");
629
+ async function Kn(e, t) {
630
+ let n = (e.match(/<link\b[^>]*>/gi) ?? []).find((e) => V(e, "rel")?.toLowerCase() === "manifest"), r = n && V(n, "href");
631
631
  if (r) try {
632
632
  let e = new URL(r, t);
633
633
  if (e.protocol !== "http:" && e.protocol !== "https:") return;
634
- let n = JSON.parse(await Jt(e.href)), i = typeof n.short_name == "string" ? n.short_name.trim() : "", a = typeof n.name == "string" ? zn(n.name) : "";
634
+ let n = JSON.parse(await $t(e.href)), i = typeof n.short_name == "string" ? n.short_name.trim() : "", a = typeof n.name == "string" ? Wn(n.name) : "";
635
635
  return i || a || void 0;
636
636
  } catch {
637
637
  return;
638
638
  }
639
639
  }
640
640
  // src/core/init/from-site/sections/config.ts
641
- async function Hn(e, t, n) {
642
- let { destDir: r, url: i, page: a, result: o, mayChange: s } = e, { fontUrls: c } = n, l = "blazon.json", u = W(a.html, "og:site_name") ?? W(a.html, "application-name") ?? await Vn(a.html, i) ?? Bn(a.html), d = W(a.html, "description");
641
+ async function qn(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 Kn(a.html, i) ?? Gn(a.html), d = H(a.html, "description");
643
643
  u || o.missing.push("no <title> on the page: the config title keeps the folder name");
644
644
  let f = !1;
645
645
  if ((u || d || t.single || t.onLight || c.length > 0) && s(l)) {
646
- let e = A.join(r, l), n = Dn(e);
646
+ let e = O.join(r, l), n = Mn(e);
647
647
  u && (n.title = u), d && (n.description = d);
648
648
  let i = t.single ?? (t.onLight ? {
649
649
  onLight: t.onLight,
650
650
  ...t.onDark ? { onDark: t.onDark } : {}
651
651
  } : void 0);
652
- i && (n.logo = i), c.length > 0 && (n.fonts = kn(n.fonts, c)), On(e, n), o.written.push(l), f = !!i;
652
+ i && (n.logo = i), c.length > 0 && (n.fonts = Pn(n.fonts, c)), Nn(e, n), o.written.push(l), f = !!i;
653
653
  }
654
654
  return {
655
655
  title: u,
@@ -658,23 +658,23 @@ async function Hn(e, t, n) {
658
658
  };
659
659
  }
660
660
  // src/core/init/from-site/sections/directives.ts
661
- var Un = /^[ \t]*<!--\s*blazon:tokens\b([^>]*?)-->[ \t]*\r?\n?/gm;
662
- function Wn(e) {
663
- let { destDir: n, created: r, result: i } = e, a = A.join(n, "docs");
664
- if (!j.existsSync(a)) return;
665
- let o = t(Ne(A.join(n, "tokens"), n), "--").items, s = (e) => o.some((t) => t.path === e || t.path.startsWith(`${e}.`));
666
- for (let e of j.readdirSync(a).filter((e) => e.endsWith(".md"))) {
661
+ var Jn = /^[ \t]*<!--\s*blazon:tokens\b([^>]*?)-->[ \t]*\r?\n?/gm;
662
+ function Yn(e) {
663
+ let { destDir: t, created: n, result: r } = e, i = O.join(t, "docs");
664
+ if (!k.existsSync(i)) return;
665
+ let a = te(ie(O.join(t, "tokens"), t), "--").items, o = (e) => a.some((t) => t.path === e || t.path.startsWith(`${e}.`));
666
+ for (let e of k.readdirSync(i).filter((e) => e.endsWith(".md"))) {
667
667
  let t = `docs/${e}`;
668
- if (!r.has(t)) continue;
669
- let n = A.join(a, e), o = j.readFileSync(n, "utf-8"), c = [], l = o.replace(Un, (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`;
668
+ if (!n.has(t)) continue;
669
+ let a = O.join(i, e), s = k.readFileSync(a, "utf-8"), c = [], l = s.replace(Jn, (e, t) => {
670
+ let n = t.split(/\s+/).filter(Boolean), r = n.filter(o);
671
+ return c.push(...n.filter((e) => !o(e))), r.length === n.length ? e : r.length === 0 ? "" : `<!-- blazon:tokens ${r.join(" ")} -->\n`;
672
672
  }).replace(/\n{3,}/g, "\n\n");
673
- l !== o && (j.writeFileSync(n, l), i.removed.push(`${c.join(", ")} in ${t} (the site has no such token to show)`));
673
+ l !== s && (k.writeFileSync(a, l), r.removed.push(`${c.join(", ")} in ${t} (the site has no such token to show)`));
674
674
  }
675
675
  }
676
676
  // src/core/init/shared/google-fonts.ts
677
- var Gn = [
677
+ var Xn = [
678
678
  "Inter",
679
679
  "Roboto",
680
680
  "Open Sans",
@@ -692,12 +692,12 @@ var Gn = [
692
692
  "Playfair Display",
693
693
  "JetBrains Mono"
694
694
  ];
695
- function Kn(e) {
696
- let t = Gn.find((t) => t.toLowerCase() === e.toLowerCase());
695
+ function Zn(e) {
696
+ let t = Xn.find((t) => t.toLowerCase() === e.toLowerCase());
697
697
  return t ? `https://fonts.googleapis.com/css2?family=${t.replace(/ /g, "+")}:wght@400;500;600;700&display=swap` : void 0;
698
698
  }
699
699
  // src/core/init/from-site/fonts.ts
700
- var qn = /* @__PURE__ */ new Set([
700
+ var Qn = /* @__PURE__ */ new Set([
701
701
  "serif",
702
702
  "sans-serif",
703
703
  "monospace",
@@ -717,19 +717,19 @@ var qn = /* @__PURE__ */ new Set([
717
717
  "-apple-system",
718
718
  "blinkmacsystemfont",
719
719
  "segoe ui"
720
- ]), Jn = /* @__PURE__ */ new Set([
720
+ ]), $n = /* @__PURE__ */ new Set([
721
721
  "serif",
722
722
  "sans-serif",
723
723
  "monospace",
724
724
  "cursive",
725
725
  "fantasy"
726
726
  ]);
727
- function Yn(e) {
727
+ function er(e) {
728
728
  let t = [], n = "", r = "";
729
729
  for (let i of e) r ? i === r ? r = "" : n += i : i === "\"" || i === "'" ? r = i : i === "," ? (t.push(n.trim()), n = "") : n += i;
730
730
  return t.push(n.trim()), t.filter(Boolean);
731
731
  }
732
- function Xn(e, t, n) {
732
+ function tr(e, t, n) {
733
733
  let r;
734
734
  for (let i of e.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/([^{}]*)\{([^{}]*)\}/g)) {
735
735
  let e = i[1].split(",").map((e) => e.trim().toLowerCase()).find((e) => n.test(e));
@@ -741,7 +741,7 @@ function Xn(e, t, n) {
741
741
  let e = t.get(c[1]);
742
742
  o = e ?? c[2] ?? "", e !== void 0 && (s = c[1]);
743
743
  }
744
- let l = Yn(o), u = l.find((e) => !qn.has(e.toLowerCase()) && !e.startsWith("var("));
744
+ let l = er(o), u = l.find((e) => !Qn.has(e.toLowerCase()) && !e.startsWith("var("));
745
745
  u && (r = {
746
746
  family: u,
747
747
  stack: l,
@@ -751,21 +751,21 @@ function Xn(e, t, n) {
751
751
  }
752
752
  return r;
753
753
  }
754
- function Zn(e) {
755
- let t = e.stack.find((e) => Jn.has(e.toLowerCase()));
754
+ function nr(e) {
755
+ let t = e.stack.find((e) => $n.has(e.toLowerCase()));
756
756
  return [e.family, (t ?? "sans-serif").toLowerCase()];
757
757
  }
758
758
  // src/core/init/from-site/sections/fonts.ts
759
- function Qn(e) {
760
- let { destDir: t, page: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = Xn(n.css, r, /^(body|html)$/), u = Xn(n.css, r, /^h[1-6]$/), d = [];
759
+ function rr(e) {
760
+ let { destDir: t, page: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = tr(n.css, r, /^(body|html)$/), u = tr(n.css, r, /^h[1-6]$/), d = [];
761
761
  if (!l && !u) i.missing.push("no font: no body or heading rule in the stylesheets names a font-family");
762
- else if (c(Ln("tokens", "typography.json"))) {
763
- let e = A.join(t, "tokens", "typography.json"), n = $t(e), r = (n.font ??= {}).family ??= {}, c = l ?? u, f = [["body", c], ["display", u ?? c]];
762
+ else if (c(Hn("tokens", "typography.json"))) {
763
+ let e = O.join(t, "tokens", "typography.json"), n = an(e), r = (n.font ??= {}).family ??= {}, c = l ?? u, f = [["body", c], ["display", u ?? c]];
764
764
  for (let [e, t] of f) {
765
- let n = Kn(t.family);
765
+ let n = Zn(t.family);
766
766
  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: Zn(t),
768
- $extensions: tn({
767
+ $value: nr(t),
768
+ $extensions: sn({
769
769
  source: s(t.cssVar ? `${t.locator}, from ${t.cssVar}` : t.locator),
770
770
  review: n ? o : {
771
771
  status: "needs-review",
@@ -775,25 +775,25 @@ function Qn(e) {
775
775
  };
776
776
  }
777
777
  let p = r.mono;
778
- p && wn(p, `${a} Still blazon's mono font: the site's stylesheets named no monospace font. Set the brand's own.`), en(e, n), i.written.push(Ln("tokens", "typography.json"));
778
+ p && kn(p, `${a} Still blazon's mono font: the site's stylesheets named no monospace font. Set the brand's own.`), on(e, n), i.written.push(Hn("tokens", "typography.json"));
779
779
  }
780
780
  return { fontUrls: d };
781
781
  }
782
782
  // src/core/init/from-site/sections/intro.ts
783
- var $n = (e) => e.length === 1 && e[0] === "logo", er = (e) => e.length < 2 ? e.join("") : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
784
- function tr(e) {
783
+ var ir = (e) => e.length === 1 && e[0] === "logo", ar = (e) => e.length < 2 ? e.join("") : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
784
+ function or(e) {
785
785
  let { url: t, date: n, result: r } = e, i = {
786
786
  colors: r.written.includes("tokens/colors.json"),
787
787
  fonts: r.written.includes("tokens/typography.json"),
788
788
  logo: r.written.some((e) => e.startsWith("assets/logos/"))
789
789
  }, a = Object.entries(i).filter(([, e]) => e).map(([e]) => e), o = Object.entries(i).filter(([, e]) => !e).map(([e]) => e);
790
790
  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 ${er(a)} in this brand book ${$n(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 ${er(o)} ${$n(o) ? "was" : "were"} not found, so ${$n(o) ? "it is" : "they are"} still blazon's own starter: replace ${$n(o) ? "it" : "them"}.`;
791
+ let s = `The ${ar(a)} in this brand book ${ir(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 ${ar(o)} ${ir(o) ? "was" : "were"} not found, so ${ir(o) ? "it is" : "they are"} still blazon's own starter: replace ${ir(o) ? "it" : "them"}.`;
793
793
  }
794
- function nr(e, t, n) {
794
+ function sr(e, t, n) {
795
795
  let { destDir: r, url: i, created: a, result: o } = e, s = "docs/01-principles.md";
796
- if (a.has(s) && j.existsSync(A.join(r, s))) {
796
+ if (a.has(s) && k.existsSync(O.join(r, s))) {
797
797
  let a = t ?? new URL(i).hostname.replace(/^www\./, ""), c = [
798
798
  "---",
799
799
  "title: Introduction",
@@ -806,24 +806,24 @@ function nr(e, t, n) {
806
806
  `# ${a}`,
807
807
  "",
808
808
  ...n ? [n, ""] : [],
809
- tr(e),
809
+ or(e),
810
810
  ""
811
811
  ];
812
- j.writeFileSync(A.join(r, s), c.join("\n")), o.written.push(s);
812
+ k.writeFileSync(O.join(r, s), c.join("\n")), o.written.push(s);
813
813
  }
814
814
  }
815
815
  // src/core/init/shared/svg.ts
816
- function rr(e) {
816
+ function cr(e) {
817
817
  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
818
  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
819
  }
820
820
  // src/core/init/from-site/logo.ts
821
- function ir(e, t) {
821
+ function lr(e, t) {
822
822
  let n = e.replace(/<!--[\s\S]*?-->/g, "").match(/<header\b[^>]*>([\s\S]*?)<\/header>/i)?.[1];
823
823
  if (!n) return;
824
824
  let r = [];
825
825
  for (let e of n.matchAll(/<a\b([^>]*)>([\s\S]*?)<\/a>/gi)) {
826
- let n = U(`<a${e[1]}>`, "href");
826
+ let n = V(`<a${e[1]}>`, "href");
827
827
  if (n !== void 0) try {
828
828
  let i = new URL(n.trim(), t);
829
829
  i.origin === new URL(t).origin && i.pathname === "/" && r.push(e[2]);
@@ -831,7 +831,7 @@ function ir(e, t) {
831
831
  }
832
832
  let i = (e) => e.match(/<svg\b[\s\S]*?<\/svg>/i)?.[0], a = (e) => {
833
833
  for (let n of e.matchAll(/<img\b[^>]*>/gi)) {
834
- let e = U(n[0], "src");
834
+ let e = V(n[0], "src");
835
835
  if (e && /\.svg(?:[?#]|$)/i.test(e)) try {
836
836
  let n = new URL(e.trim(), t);
837
837
  if (n.protocol === "http:" || n.protocol === "https:") return n.href;
@@ -867,16 +867,16 @@ function ir(e, t) {
867
867
  locator: "header img"
868
868
  } : void 0;
869
869
  }
870
- function ar(e, t) {
870
+ function ur(e, t) {
871
871
  let n = [];
872
872
  for (let [r] of e.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<link\b[^>]*>/gi)) {
873
- let e = (U(r, "rel") ?? "").toLowerCase().split(/\s+/), i = e.includes("apple-touch-icon") || e.includes("apple-touch-icon-precomposed");
873
+ let e = (V(r, "rel") ?? "").toLowerCase().split(/\s+/), i = e.includes("apple-touch-icon") || e.includes("apple-touch-icon-precomposed");
874
874
  if (!i && !e.includes("icon")) continue;
875
- let a = U(r, "href");
875
+ let a = V(r, "href");
876
876
  if (a) try {
877
877
  let o = new URL(a.trim(), t);
878
878
  if (o.protocol !== "http:" && o.protocol !== "https:") continue;
879
- let s = A.extname(o.pathname).toLowerCase() || (U(r, "type") === "image/svg+xml" ? ".svg" : ".png");
879
+ let s = O.extname(o.pathname).toLowerCase() || (V(r, "type") === "image/svg+xml" ? ".svg" : ".png");
880
880
  n.push({
881
881
  url: o.href,
882
882
  svg: s === ".svg",
@@ -888,14 +888,14 @@ function ar(e, t) {
888
888
  }
889
889
  return n.find((e) => e.svg) ?? n.find((e) => e.apple) ?? n[0];
890
890
  }
891
- function or(e) {
891
+ function dr(e) {
892
892
  let t = new URL(e).hostname.replace(/^www\./, "");
893
893
  return /^[\d.]+$/.test(t) || t.includes(":") || t.startsWith("[") ? "site" : t.split(".")[0].replace(/[^a-z0-9-]/gi, "-").toLowerCase() || "site";
894
894
  }
895
895
  // src/core/init/from-site/sections/logo.ts
896
- async function sr(e) {
897
- let { destDir: t, url: n, date: r, page: i, result: a, note: o, review: s } = e, c = {}, l = or(n), u = (e, i, c) => {
898
- en(A.join(t, e.replace(/\.[a-z]+$/, ".json")), {
896
+ async function fr(e) {
897
+ let { destDir: t, url: n, date: r, page: i, result: a, note: o, review: s } = e, c = {}, l = dr(n), u = (e, i, c) => {
898
+ on(O.join(t, e.replace(/\.[a-z]+$/, ".json")), {
899
899
  description: o,
900
900
  ...c,
901
901
  source: {
@@ -905,26 +905,26 @@ async function sr(e) {
905
905
  review: s
906
906
  }), a.written.push(e.replace(/\.[a-z]+$/, ".json"));
907
907
  }, d = (e, n) => {
908
- let r = A.join(t, e), i = [e, e.replace(/\.[a-z]+$/, ".json")].filter((e) => j.existsSync(A.join(t, e)));
909
- 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) : (j.mkdirSync(A.dirname(r), { recursive: !0 }), j.writeFileSync(r, n), a.written.push(e), !0);
910
- }, f = ir(i.html, n), p, m = "";
908
+ let r = O.join(t, e), i = [e, e.replace(/\.[a-z]+$/, ".json")].filter((e) => k.existsSync(O.join(t, e)));
909
+ 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 = lr(i.html, n), p, m = "";
911
911
  if (f?.kind === "inline") p = f.svg, m = f.locator;
912
912
  else if (f?.kind === "url") {
913
913
  try {
914
- p = (await qt(f.url)).toString("utf8"), m = `${f.locator} (${f.url})`;
914
+ p = (await Qt(f.url)).toString("utf8"), m = `${f.locator} (${f.url})`;
915
915
  } catch (e) {
916
916
  a.missing.push(`the header logo could not be read: ${e instanceof Error ? e.message : String(e)}`);
917
917
  }
918
918
  p !== void 0 && !/<svg\b/i.test(p) && (p = void 0, a.missing.push(`${f.url} is not an SVG`));
919
919
  }
920
920
  let h;
921
- if (p === void 0 && (h = ar(i.html, n), h?.svg)) try {
922
- p = (await qt(h.url)).toString("utf8"), m = `${h.locator} (${h.url})`, /<svg\b/i.test(p) || (p = void 0);
921
+ if (p === void 0 && (h = ur(i.html, n), h?.svg)) try {
922
+ p = (await Qt(h.url)).toString("utf8"), m = `${h.locator} (${h.url})`, /<svg\b/i.test(p) || (p = void 0);
923
923
  } catch (e) {
924
924
  a.missing.push(`the icon could not be read: ${e instanceof Error ? e.message : String(e)}`);
925
925
  }
926
926
  if (p !== void 0) {
927
- let e = rr(p);
927
+ let e = cr(p);
928
928
  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
929
  let t = `assets/logos/${l}.svg`, n = `assets/logos/${l}-white.svg`;
930
930
  d(t, e.replace(/currentColor/gi, "#111111")) && (u(t, m, {
@@ -951,7 +951,7 @@ async function sr(e) {
951
951
  ].includes(h.ext)) a.missing.push(`only a ${h.ext} icon was found (${h.url}), which blazon cannot show: no logo was written`);
952
952
  else try {
953
953
  let e = `assets/logos/${l}${h.ext === ".jpeg" ? ".jpg" : h.ext}`;
954
- d(e, await qt(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`));
954
+ d(e, await Qt(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
955
  } catch (e) {
956
956
  a.missing.push(`the icon could not be read: ${e instanceof Error ? e.message : String(e)}`);
957
957
  }
@@ -959,28 +959,28 @@ async function sr(e) {
959
959
  return c;
960
960
  }
961
961
  // src/core/init/from-site/sections/placeholder.ts
962
- function cr(e, t, n) {
962
+ function pr(e, t, n) {
963
963
  let { destDir: r, created: i, result: a } = e, o = t.single ?? t.onLight;
964
964
  if (n && o) {
965
- let e = A.join(r, `assets/logos/${An[0]}.json`), t = A.join(r, o.replace(/^\.\//, "").replace(/\.[a-z]+$/, ".json"));
966
- if (i.has(`assets/logos/${An[0]}.json`) && j.existsSync(e) && j.existsSync(t)) {
967
- let { description: n, background: i, ...a } = $t(e), s = $t(t), c = j.readFileSync(A.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];
965
+ let e = O.join(r, `assets/logos/${Fn[0]}.json`), t = O.join(r, o.replace(/^\.\//, "").replace(/\.[a-z]+$/, ".json"));
966
+ if (i.has(`assets/logos/${Fn[0]}.json`) && k.existsSync(e) && k.existsSync(t)) {
967
+ let { description: n, background: i, ...a } = an(e), s = an(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
968
  l && Number(l) > 0 && (a.clearSpace = {
969
969
  value: Math.max(1, Math.round(Number(l) * .3 * 100) / 100),
970
970
  unit: "px"
971
971
  });
972
972
  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.`, en(t, s);
973
+ s.description = `${String(s.description)} Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.`, on(t, s);
974
974
  }
975
- for (let e of jn) for (let t of ["svg", "json"]) {
975
+ for (let e of In) for (let t of ["svg", "json"]) {
976
976
  let n = `assets/logos/${e}.${t}`;
977
- i.has(n) && (j.rmSync(A.join(r, n), { force: !0 }), a.removed.push(`${n} (blazon's own logo)`));
977
+ i.has(n) && (k.rmSync(O.join(r, n), { force: !0 }), a.removed.push(`${n} (blazon's own logo)`));
978
978
  }
979
979
  }
980
980
  }
981
981
  // src/core/init/from-site/apply.ts
982
- async function lr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
983
- let a = r.toISOString().slice(0, 10), o = i.page ?? await Zt(t), s = {
982
+ async function mr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
983
+ let a = r.toISOString().slice(0, 10), o = i.page ?? await nn(t), s = {
984
984
  written: [],
985
985
  missing: [],
986
986
  removed: [],
@@ -991,7 +991,7 @@ async function lr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
991
991
  date: a,
992
992
  created: n,
993
993
  page: o,
994
- vars: Ut(o.css),
994
+ vars: Jt(o.css),
995
995
  result: s,
996
996
  note: c,
997
997
  review: {
@@ -1005,27 +1005,27 @@ async function lr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
1005
1005
  }),
1006
1006
  mayChange: (e) => n.has(e) ? !0 : (s.missing.push(`${e} already existed, so it was kept as it was`), !1)
1007
1007
  };
1008
- Rn(l, i.skipVars);
1009
- let u = Qn(l), d = await sr(l), { title: f, description: p, configLogo: m } = await Hn(l, d, u);
1010
- return cr(l, d, m), nr(l, f, p), Wn(l), s;
1008
+ Un(l, i.skipVars);
1009
+ let u = rr(l), d = await fr(l), { title: f, description: p, configLogo: m } = await qn(l, d, u);
1010
+ return pr(l, d, m), sr(l, f, p), Yn(l), s;
1011
1011
  }
1012
1012
  // src/core/init/from-site/inspect.ts
1013
- async function ur(e) {
1014
- let t = await Zt(e), n = Ut(t.css), r = Fn(n), i = Xn(t.css, n, /^(body|html)$/), a = Xn(t.css, n, /^h[1-6]$/), o = [];
1013
+ async function hr(e) {
1014
+ let t = await nn(e), n = Jt(t.css), r = Bn(n), i = tr(t.css, n, /^(body|html)$/), a = tr(t.css, n, /^h[1-6]$/), o = [];
1015
1015
  i && o.push({
1016
1016
  family: i.family,
1017
1017
  role: "body",
1018
- stylesheet: !!Kn(i.family)
1018
+ stylesheet: !!Zn(i.family)
1019
1019
  }), a && a.family.toLowerCase() !== i?.family.toLowerCase() && o.push({
1020
1020
  family: a.family,
1021
1021
  role: "headings",
1022
- stylesheet: !!Kn(a.family)
1022
+ stylesheet: !!Zn(a.family)
1023
1023
  });
1024
- let s = ir(t.html, e), c = ar(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 = W(t.html, "og:site_name") ?? W(t.html, "application-name") ?? await Vn(t.html, e) ?? Bn(t.html), d = [];
1024
+ let s = lr(t.html, e), c = ur(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 Kn(t.html, e) ?? Gn(t.html), d = [];
1025
1025
  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
1026
  page: t,
1027
1027
  name: u,
1028
- description: W(t.html, "description"),
1028
+ description: H(t.html, "description"),
1029
1029
  colors: r.map((e) => ({
1030
1030
  cssVar: e.cssVar,
1031
1031
  hex: e.hex
@@ -1036,92 +1036,92 @@ async function ur(e) {
1036
1036
  };
1037
1037
  }
1038
1038
  // src/core/init/answers.ts
1039
- var dr = [
1039
+ var gr = [
1040
1040
  ".svg",
1041
1041
  ".png",
1042
1042
  ".jpg",
1043
1043
  ".jpeg",
1044
1044
  ".webp"
1045
- ], fr = (e) => e.trim() ? { value: e.trim() } : { hint: "A name cannot be empty." }, pr = (e) => e.trim().length <= 240 ? { value: e.trim() } : { hint: "Keep the description to one sentence, 240 characters at most." };
1046
- function mr(e) {
1047
- let t = e.trim(), n = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t) ? Mn(t.startsWith("#") ? t : `#${t}`) : void 0;
1045
+ ], _r = (e) => e.trim() ? { value: e.trim() } : { hint: "A name cannot be empty." }, vr = (e) => e.trim().length <= 240 ? { value: e.trim() } : { hint: "Keep the description to one sentence, 240 characters at most." };
1046
+ function yr(e) {
1047
+ let t = e.trim(), n = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t) ? Ln(t.startsWith("#") ? t : `#${t}`) : void 0;
1048
1048
  return n ? { value: n.hex } : { hint: "Give the color as hex, for example #2563eb or #26e." };
1049
1049
  }
1050
- var hr = (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 gr(e, t = process.cwd()) {
1052
- let n = A.resolve(t, e.trim());
1053
- return dr.includes(A.extname(n).toLowerCase()) ? !j.existsSync(n) || !j.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)." };
1050
+ var br = (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 xr(e, t = process.cwd()) {
1052
+ let n = O.resolve(t, e.trim());
1053
+ return gr.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
1054
  }
1055
- function _r(e) {
1056
- let t = j.readFileSync(e), n = A.extname(e).toLowerCase() === ".svg";
1055
+ function Sr(e) {
1056
+ let t = k.readFileSync(e), n = O.extname(e).toLowerCase() === ".svg";
1057
1057
  return {
1058
1058
  bytes: t.length,
1059
1059
  svg: n,
1060
1060
  usesCurrentColor: n && /currentColor/i.test(t.toString("utf8"))
1061
1061
  };
1062
1062
  }
1063
- var vr = (e) => /^https?:\/\/[^\s/]/i.test(e);
1064
- function yr(e, t, n) {
1063
+ var Cr = (e) => /^https?:\/\/[^\s/]/i.test(e);
1064
+ function wr(e, t, n) {
1065
1065
  let r = {
1066
1066
  set: [],
1067
1067
  hints: [],
1068
1068
  files: []
1069
- }, i = (e) => r.hints.push(`${e} already existed, so it was kept as it was`), a = A.join(e, "blazon.json"), o = n.has("blazon.json") ? Dn(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);
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") ? Mn(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
1070
  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
- let a = A.join(e, "tokens", "colors.json");
1071
+ let a = O.join(e, "tokens", "colors.json");
1072
1072
  if (!n.has("tokens/colors.json")) i("tokens/colors.json");
1073
1073
  else {
1074
- let e = JSON.parse(j.readFileSync(a, "utf-8"));
1075
- if (H(e, "color.signal.orange")) {
1076
- let n = Tn(e, t.color);
1077
- j.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);
1074
+ let e = JSON.parse(k.readFileSync(a, "utf-8"));
1075
+ if (B(e, "color.signal.orange")) {
1076
+ let n = An(e, t.color);
1077
+ 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
1078
  } else r.hints.push("color.signal.orange was not found in tokens/colors.json, so the color was not set");
1079
1079
  }
1080
1080
  }
1081
1081
  if (t.font !== void 0) {
1082
- let a = A.join(e, "tokens", "typography.json");
1082
+ let a = O.join(e, "tokens", "typography.json");
1083
1083
  if (!n.has("tokens/typography.json")) i("tokens/typography.json");
1084
1084
  else {
1085
- let e = JSON.parse(j.readFileSync(a, "utf-8")), n = H(e, "font.family.display"), i = H(e, "font.family.body");
1085
+ let e = JSON.parse(k.readFileSync(a, "utf-8")), n = B(e, "font.family.display"), i = B(e, "font.family.body");
1086
1086
  if (n && i) {
1087
1087
  n.$value = [t.font, "sans-serif"], i.$value = [t.font, "sans-serif"];
1088
- let s = H(e, "font.family.mono");
1089
- s && wn(s, "Still blazon's mono font: it was not chosen to go with your font. Set the brand's own."), j.writeFileSync(a, `${JSON.stringify(e, null, 2)}\n`), r.files.push("tokens/typography.json");
1090
- let l = Kn(t.font);
1091
- l && c("font stylesheet") ? (o.fonts = kn(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");
1088
+ let s = B(e, "font.family.mono");
1089
+ s && kn(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 = Zn(t.font);
1091
+ l && c("font stylesheet") ? (o.fonts = Pn(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
1092
  } 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
1093
  }
1094
1094
  }
1095
1095
  if (t.logo !== void 0 && c("logo")) {
1096
- let a = A.basename(t.logo).replace(/[^A-Za-z0-9._-]/g, "-"), s = a.replace(/\.[^.]+$/, ""), c = A.join(e, "assets", "logos"), l = [a, `${s}.json`].filter((e) => !n.has(`assets/logos/${e}`) && j.existsSync(A.join(c, e)));
1096
+ let a = O.basename(t.logo).replace(/[^A-Za-z0-9._-]/g, "-"), s = a.replace(/\.[^.]+$/, ""), c = O.join(e, "assets", "logos"), l = [a, `${s}.json`].filter((e) => !n.has(`assets/logos/${e}`) && k.existsSync(O.join(c, e)));
1097
1097
  if (l.length) {
1098
1098
  for (let e of l) i(`assets/logos/${e}`);
1099
1099
  r.hints.push(`the logo ${t.logo} was not copied: pick another file name, or remove the existing file`);
1100
1100
  } else {
1101
- let e = A.join(c, `${An[0]}.json`), i = {};
1102
- if (n.has(`assets/logos/${An[0]}.json`) && j.existsSync(e)) {
1103
- let { description: t, background: n, ...r } = JSON.parse(j.readFileSync(e, "utf-8"));
1101
+ let e = O.join(c, `${Fn[0]}.json`), i = {};
1102
+ if (n.has(`assets/logos/${Fn[0]}.json`) && k.existsSync(e)) {
1103
+ let { description: t, background: n, ...r } = JSON.parse(k.readFileSync(e, "utf-8"));
1104
1104
  i = r;
1105
1105
  }
1106
- for (let e of jn) for (let t of ["svg", "json"]) n.has(`assets/logos/${e}.${t}`) && j.rmSync(A.join(c, `${e}.${t}`), { force: !0 });
1107
- j.mkdirSync(c, { recursive: !0 });
1108
- let l = j.readFileSync(t.logo);
1109
- j.writeFileSync(A.join(c, a), a.toLowerCase().endsWith(".svg") ? rr(l.toString("utf8")) : l), j.writeFileSync(A.join(c, `${s}.json`), `${JSON.stringify({
1106
+ for (let e of In) for (let t of ["svg", "json"]) n.has(`assets/logos/${e}.${t}`) && k.rmSync(O.join(c, `${e}.${t}`), { force: !0 });
1107
+ k.mkdirSync(c, { recursive: !0 });
1108
+ let l = k.readFileSync(t.logo);
1109
+ k.writeFileSync(O.join(c, a), a.toLowerCase().endsWith(".svg") ? cr(l.toString("utf8")) : l), k.writeFileSync(O.join(c, `${s}.json`), `${JSON.stringify({
1110
1110
  title: "Logo",
1111
1111
  description: "The brand's logo. Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.",
1112
1112
  ...i
1113
1113
  }, null, 2)}\n`), o.logo = `./assets/logos/${a}`, r.files.push(`assets/logos/${a}`, `assets/logos/${s}.json`), r.set.push(`logo ${a}`);
1114
1114
  }
1115
1115
  }
1116
- return o !== void 0 && JSON.stringify(o) !== s && (On(a, o), r.files.push("blazon.json")), r;
1116
+ return o !== void 0 && JSON.stringify(o) !== s && (Nn(a, o), r.files.push("blazon.json")), r;
1117
1117
  }
1118
1118
  // src/core/init/prompts.ts
1119
- var br = class extends Error {
1119
+ var Tr = class extends Error {
1120
1120
  constructor() {
1121
1121
  super("cancelled"), this.name = "PromptCancelled";
1122
1122
  }
1123
1123
  };
1124
- function G(e, t) {
1124
+ function U(e, t) {
1125
1125
  return e.split("\n").map((e) => {
1126
1126
  if (e.length <= t || e.includes("\x1B")) return e;
1127
1127
  let n = [], r = "";
@@ -1129,66 +1129,66 @@ function G(e, t) {
1129
1129
  return n.push(r), n.join("\n");
1130
1130
  }).join("\n");
1131
1131
  }
1132
- var xr = () => Math.max(30, (process.stdout.columns ?? 80) - 6);
1133
- function Sr(e) {
1134
- if (M.isCancel(e)) throw new br();
1132
+ var W = () => Math.max(30, (process.stdout.columns ?? 80) - 6);
1133
+ function Er(e) {
1134
+ if (A.isCancel(e)) throw new Tr();
1135
1135
  return e;
1136
1136
  }
1137
- function Cr() {
1137
+ function Dr() {
1138
1138
  return {
1139
- intro: (e) => M.intro(e),
1140
- outro: (e) => M.outro(e),
1141
- cancel: (e) => M.cancel(e),
1142
- text: async (e) => Sr(await M.text({
1139
+ intro: (e) => A.intro(e),
1140
+ outro: (e) => A.outro(e),
1141
+ cancel: (e) => A.cancel(e),
1142
+ text: async (e) => Er(await A.text({
1143
1143
  message: e.message,
1144
1144
  placeholder: e.placeholder,
1145
1145
  defaultValue: e.defaultValue,
1146
1146
  validate: e.validate && ((t) => e.validate(t ?? ""))
1147
1147
  })) ?? "",
1148
- select: async (e) => Sr(await M.select({
1148
+ select: async (e) => Er(await A.select({
1149
1149
  message: e.message,
1150
1150
  options: e.options,
1151
1151
  initialValue: e.initialValue
1152
1152
  })),
1153
- multiselect: async (e) => Sr(await M.multiselect({
1153
+ multiselect: async (e) => Er(await A.multiselect({
1154
1154
  message: e.message,
1155
1155
  options: e.options,
1156
1156
  initialValues: e.initialValues,
1157
1157
  required: !1
1158
1158
  })),
1159
- confirm: async (e) => Sr(await M.confirm({
1159
+ confirm: async (e) => Er(await A.confirm({
1160
1160
  message: e.message,
1161
1161
  initialValue: e.initialValue
1162
1162
  })),
1163
1163
  spinner: () => {
1164
- let e = M.spinner();
1164
+ let e = A.spinner();
1165
1165
  return {
1166
1166
  start: (t) => e.start(t),
1167
1167
  stop: (t) => e.stop(t),
1168
1168
  error: (t) => e.error(t)
1169
1169
  };
1170
1170
  },
1171
- note: (e, t) => M.note(e, t),
1171
+ note: (e, t) => A.note(e, t),
1172
1172
  log: {
1173
- message: (e) => M.log.message(G(e, xr())),
1174
- info: (e) => M.log.info(G(e, xr())),
1175
- success: (e) => M.log.success(G(e, xr())),
1176
- warn: (e) => M.log.warn(G(e, xr())),
1177
- error: (e) => M.log.error(G(e, xr())),
1178
- step: (e) => M.log.step(G(e, xr()))
1173
+ message: (e) => A.log.message(U(e, W())),
1174
+ info: (e) => A.log.info(U(e, W())),
1175
+ success: (e) => A.log.success(U(e, W())),
1176
+ warn: (e) => A.log.warn(U(e, W())),
1177
+ error: (e) => A.log.error(U(e, W())),
1178
+ step: (e) => A.log.step(U(e, W()))
1179
1179
  }
1180
1180
  };
1181
1181
  }
1182
1182
  // src/cli/init-ui.ts
1183
- function wr(e = process.env, t = !!process.stdout.isTTY) {
1184
- let n = b(e, t, []);
1183
+ function Or(e = process.env, t = !!process.stdout.isTTY) {
1184
+ let n = w(e, t, []);
1185
1185
  return {
1186
1186
  color: n,
1187
1187
  truecolor: n && /^(truecolor|24bit)$/i.test(e.COLORTERM ?? "")
1188
1188
  };
1189
1189
  }
1190
- function Tr(e, t) {
1191
- let [n, r, i] = (dn(e) ?? [
1190
+ function kr(e, t) {
1191
+ let [n, r, i] = (gn(e) ?? [
1192
1192
  0,
1193
1193
  0,
1194
1194
  0
@@ -1197,63 +1197,63 @@ function Tr(e, t) {
1197
1197
  let a = (e) => Math.round(e / 255 * 5);
1198
1198
  return `\x1b[48;5;${16 + 36 * a(n) + 6 * a(r) + a(i)}m`;
1199
1199
  }
1200
- function Er(e, t, n = 2) {
1201
- return t.color ? `${Tr(e, t)}${" ".repeat(n)}\x1b[0m` : `[${e}]`;
1200
+ function Ar(e, t, n = 2) {
1201
+ return t.color ? `${kr(e, t)}${" ".repeat(n)}\x1b[0m` : `[${e}]`;
1202
1202
  }
1203
- var Dr = {
1203
+ var jr = {
1204
1204
  AAA: "AAA",
1205
1205
  AA: "AA",
1206
1206
  "AA-large": "AA for large text only",
1207
1207
  fail: "below AA"
1208
- }, Or = (e) => `${e.toFixed(1)}:1`;
1209
- function kr(e, t, n = gn(e)) {
1208
+ }, Mr = (e) => `${e.toFixed(1)}:1`;
1209
+ function Nr(e, t, n = xn(e)) {
1210
1210
  let r = (e) => e === "AAA" || e === "AA" ? "yes" : "no";
1211
1211
  return [
1212
- `${Er(e, t, 4)} ${e}`,
1213
- `AA for text on white: ${r(n.onWhite.level)} (${Or(n.onWhite.ratio)}, ${Dr[n.onWhite.level]})`,
1214
- `AA for text on near-black: ${r(n.onNearBlack.level)} (${Or(n.onNearBlack.ratio)}, ${Dr[n.onNearBlack.level]})`
1212
+ `${Ar(e, t, 4)} ${e}`,
1213
+ `AA for text on white: ${r(n.onWhite.level)} (${Mr(n.onWhite.ratio)}, ${jr[n.onWhite.level]})`,
1214
+ `AA for text on near-black: ${r(n.onNearBlack.level)} (${Mr(n.onNearBlack.ratio)}, ${jr[n.onNearBlack.level]})`
1215
1215
  ];
1216
1216
  }
1217
- function Ar(e) {
1218
- let { ink: t, ratio: n, aa: r } = yn(e);
1217
+ function Pr(e) {
1218
+ let { ink: t, ratio: n, aa: r } = wn(e);
1219
1219
  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
1220
  }
1221
- var jr = (e, t, n) => `${e} of ${t} ${n}`;
1222
- function Mr(e) {
1221
+ var Fr = (e, t, n) => `${e} of ${t} ${n}`;
1222
+ function Ir(e) {
1223
1223
  return e < 1024 ? `${e} bytes` : `${(e / 1024).toFixed(1)} KB`;
1224
1224
  }
1225
1225
  // src/cli/init-flow.ts
1226
- var Nr = 4;
1227
- function K(e, t, r, i) {
1228
- return e.log.message(i.color ? n.dim(r) : r), t;
1226
+ var Lr = 4;
1227
+ function G(e, t, n, r) {
1228
+ return e.log.message(r.color ? l.dim(n) : n), t;
1229
1229
  }
1230
- function Pr(e) {
1230
+ function Rr(e) {
1231
1231
  return (t) => {
1232
1232
  if (t.trim() === "") return;
1233
1233
  let n = e(t);
1234
1234
  return "hint" in n ? n.hint : void 0;
1235
1235
  };
1236
1236
  }
1237
- var Fr = (e, t) => {
1237
+ var zr = (e, t) => {
1238
1238
  let n = t.trim() === "" ? void 0 : e(t);
1239
1239
  return n && "value" in n ? n.value : void 0;
1240
1240
  };
1241
- async function Ir(e) {
1242
- let { prompter: t, look: r } = e, i = {};
1243
- t.intro(r.color ? n.bold(`blazon init ${n.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(jr(1, Nr, "Brand"));
1244
- let a = (await t.text({
1245
- message: K(t, "Brand name", "The title of the brand book. Enter keeps the name taken from the folder.", r),
1241
+ async function Br(e) {
1242
+ let { prompter: t, look: n } = e, r = {};
1243
+ t.intro(n.color ? l.bold(`blazon init ${l.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(Fr(1, Lr, "Brand"));
1244
+ let i = (await t.text({
1245
+ message: G(t, "Brand name", "The title of the brand book. Enter keeps the name taken from the folder.", n),
1246
1246
  placeholder: "from the folder name",
1247
1247
  validate: () => void 0
1248
1248
  })).trim();
1249
- a && (i.name = a);
1250
- let o = (await t.text({
1251
- message: K(t, "One-line description", "What the brand is, in a sentence. It goes in the config and opens the intro page. Enter skips it.", r),
1249
+ i && (r.name = i);
1250
+ let a = (await t.text({
1251
+ 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
1252
  placeholder: "what the brand is, in one sentence",
1253
- validate: (e) => "hint" in pr(e) ? "Keep it to one sentence, 240 characters at most." : void 0
1253
+ validate: (e) => "hint" in vr(e) ? "Keep it to one sentence, 240 characters at most." : void 0
1254
1254
  })).trim();
1255
- if (o && (i.description = o), await t.select({
1256
- message: K(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.", r),
1255
+ if (a && (r.description = a), await t.select({
1256
+ 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
1257
  options: [{
1258
1258
  value: "manual",
1259
1259
  label: "I will give them here",
@@ -1264,50 +1264,50 @@ async function Ir(e) {
1264
1264
  hint: "you review what was found first"
1265
1265
  }]
1266
1266
  }) === "site") {
1267
- let n = await Lr(e);
1267
+ let n = await Vr(e);
1268
1268
  if (n) return {
1269
- answers: i,
1269
+ answers: r,
1270
1270
  site: n
1271
1271
  };
1272
1272
  t.log.info("Nothing from a site will be written. Giving the values here instead.");
1273
1273
  }
1274
- t.log.step(jr(2, Nr, "Colors"));
1275
- let s = Fr(mr, (await t.text({
1276
- message: K(t, "Primary color", "Hex, for example #2563eb. Buttons and links use it. Enter keeps the orange it starts with.", r),
1274
+ t.log.step(Fr(2, Lr, "Colors"));
1275
+ let o = zr(yr, (await t.text({
1276
+ message: G(t, "Primary color", "Hex, for example #2563eb. Buttons and links use it. Enter keeps the orange it starts with.", n),
1277
1277
  placeholder: "#2563eb",
1278
- validate: Pr(mr)
1278
+ validate: Rr(yr)
1279
1279
  })).trim());
1280
- s && (i.color = s, t.log.info(kr(s, r).join("\n")), t.log.info(Ar(s))), t.log.step(jr(3, Nr, "Type"));
1281
- let c = Fr(hr, (await t.text({
1282
- message: K(t, "Font family", "A Google Fonts name, for example Inter. Enter keeps the fonts it starts with.", r),
1280
+ o && (r.color = o, t.log.info(Nr(o, n).join("\n")), t.log.info(Pr(o))), t.log.step(Fr(3, Lr, "Type"));
1281
+ let s = zr(br, (await t.text({
1282
+ message: G(t, "Font family", "A Google Fonts name, for example Inter. Enter keeps the fonts it starts with.", n),
1283
1283
  placeholder: "Inter",
1284
- validate: Pr(hr)
1284
+ validate: Rr(br)
1285
1285
  })).trim());
1286
- c && (i.font = c, Kn(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(jr(4, Nr, "Logo"));
1287
- let l = Fr((e) => gr(e), (await t.text({
1288
- message: K(t, "Logo file", "The path to an SVG or PNG. Enter skips it and keeps the logo it starts with.", r),
1286
+ s && (r.font = s, Zn(s) ? t.log.success(`${s} is on Google Fonts. Its stylesheet will be added to fonts in blazon.json.`) : t.log.warn(`${s} 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(Fr(4, Lr, "Logo"));
1287
+ let c = zr((e) => xr(e), (await t.text({
1288
+ message: G(t, "Logo file", "The path to an SVG or PNG. Enter skips it and keeps the logo it starts with.", n),
1289
1289
  placeholder: "./logo.svg",
1290
- validate: Pr((e) => gr(e))
1290
+ validate: Rr((e) => xr(e))
1291
1291
  })).trim());
1292
- if (l) {
1293
- i.logo = l;
1294
- let e = _r(l), n = A.basename(l);
1292
+ if (c) {
1293
+ r.logo = c;
1294
+ let e = Sr(c), n = O.basename(c);
1295
1295
  t.log.info([
1296
- `${n}: ${e.svg ? "SVG" : "raster image"}, ${Mr(e.bytes)}.`,
1296
+ `${n}: ${e.svg ? "SVG" : "raster image"}, ${Ir(e.bytes)}.`,
1297
1297
  "It will be copied to assets/logos/ and replace the starter's placeholder.",
1298
1298
  ...e.usesCurrentColor ? ["It draws in currentColor, so it takes the text color of the page it is on."] : [],
1299
1299
  ...e.svg ? [] : ["A raster logo cannot be recolored; an SVG is better if you have one."]
1300
1300
  ].join("\n"));
1301
1301
  }
1302
- return { answers: i };
1302
+ return { answers: r };
1303
1303
  }
1304
- async function Lr(e) {
1305
- let { prompter: t, look: n } = e, r = e.inspect ?? ur;
1304
+ async function Vr(e) {
1305
+ let { prompter: t, look: n } = e, r = e.inspect ?? hr;
1306
1306
  for (;;) {
1307
1307
  let i = (await t.text({
1308
- message: K(t, "Website address", "Blazon reads its stylesheets and page. It sends no cookies and runs none of the site's scripts.", n),
1308
+ 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
1309
  placeholder: "https://example.com (leave empty to enter the values by hand)",
1310
- validate: (e) => e.trim() === "" || vr(e.trim()) ? void 0 : "Give the full address, starting with http:// or https://, or leave it empty to enter the values by hand."
1310
+ validate: (e) => e.trim() === "" || Cr(e.trim()) ? void 0 : "Give the full address, starting with http:// or https://, or leave it empty to enter the values by hand."
1311
1311
  })).trim();
1312
1312
  if (i === "") {
1313
1313
  t.log.info("No address given: you can enter the values by hand.");
@@ -1322,7 +1322,7 @@ async function Lr(e) {
1322
1322
  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
1323
  }
1324
1324
  if (o) {
1325
- let t = await Rr(e, i, o);
1325
+ let t = await Hr(e, i, o);
1326
1326
  return t ? {
1327
1327
  url: i,
1328
1328
  findings: o,
@@ -1335,7 +1335,7 @@ async function Lr(e) {
1335
1335
  })) return;
1336
1336
  }
1337
1337
  }
1338
- async function Rr(e, t, n) {
1338
+ async function Hr(e, t, n) {
1339
1339
  let { prompter: r, look: i } = e, a = [];
1340
1340
  n.name && a.push(`Name: ${n.name}`), n.description && a.push(`Description: ${n.description}`);
1341
1341
  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"}`);
@@ -1344,10 +1344,10 @@ async function Rr(e, t, n) {
1344
1344
  let o = /* @__PURE__ */ new Set();
1345
1345
  if (n.colors.length > 0) {
1346
1346
  let e = await r.multiselect({
1347
- message: K(r, "Brand colors found", "Untick any you do not want. Everything written is marked needs-review.", i),
1347
+ message: G(r, "Brand colors found", "Untick any you do not want. Everything written is marked needs-review.", i),
1348
1348
  options: n.colors.map((e) => ({
1349
1349
  value: e.cssVar,
1350
- label: `${Er(e.hex, i)} ${e.hex} ${e.cssVar}`
1350
+ label: `${Ar(e.hex, i)} ${e.hex} ${e.cssVar}`
1351
1351
  })),
1352
1352
  initialValues: n.colors.map((e) => e.cssVar)
1353
1353
  });
@@ -1359,70 +1359,70 @@ async function Rr(e, t, n) {
1359
1359
  }) ? o : void 0;
1360
1360
  }
1361
1361
  // src/cli/commands/init.ts
1362
- var zr = (e, t, n) => `${e} ${e === 1 ? t : n}`;
1363
- function Br(e, t) {
1362
+ var Ur = (e, t, n) => `${e} ${e === 1 ? t : n}`;
1363
+ function Wr(e, t) {
1364
1364
  let n = t.map((e) => e.split("/").slice(1));
1365
1365
  if (n.length === 0) return;
1366
- if (e === "docs") return `${zr(n.length, "page", "pages")}, ${n[0][0]} to ${n[n.length - 1][0]}`;
1367
- if (e === "tokens") return `${zr(n.length, "file", "files")}: ${n.map((e) => e.join("/")).join(", ")}`;
1366
+ if (e === "docs") return `${Ur(n.length, "page", "pages")}, ${n[0][0]} to ${n[n.length - 1][0]}`;
1367
+ if (e === "tokens") return `${Ur(n.length, "file", "files")}: ${n.map((e) => e.join("/")).join(", ")}`;
1368
1368
  let r = [...new Set(n.filter((e) => e.length > 1).map((e) => e[0]))];
1369
- return r.length > 0 ? `${zr(n.length, "file", "files")} in ${zr(r.length, "folder", "folders")}: ${r.join(", ")}` : `${zr(n.length, "file", "files")}: ${n.map((e) => e[0]).join(", ")}`;
1369
+ return r.length > 0 ? `${Ur(n.length, "file", "files")} in ${Ur(r.length, "folder", "folders")}: ${r.join(", ")}` : `${Ur(n.length, "file", "files")}: ${n.map((e) => e[0]).join(", ")}`;
1370
1370
  }
1371
- var Vr = /^(brand|book|guidelines|guide)$/i;
1372
- function Hr(e) {
1373
- let t = A.basename(e).split(/[-_\s]+/).filter(Boolean), n = t.length > 0;
1374
- for (; t.length > 0 && Vr.test(t[t.length - 1]);) t = t.slice(0, -1);
1371
+ var Gr = /^(brand|book|guidelines|guide)$/i;
1372
+ function Kr(e) {
1373
+ let t = O.basename(e).split(/[-_\s]+/).filter(Boolean), n = t.length > 0;
1374
+ for (; t.length > 0 && Gr.test(t[t.length - 1]);) t = t.slice(0, -1);
1375
1375
  let r = t.map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
1376
1376
  return r ? `${r} Brand Book` : n ? "Brand Book" : "Blazon Brand Book";
1377
1377
  }
1378
- var Ur = [
1378
+ var qr = [
1379
1379
  [
1380
1380
  "--name",
1381
1381
  "name",
1382
- fr
1382
+ _r
1383
1383
  ],
1384
1384
  [
1385
1385
  "--description",
1386
1386
  "description",
1387
- pr
1387
+ vr
1388
1388
  ],
1389
1389
  [
1390
1390
  "--color",
1391
1391
  "color",
1392
- mr
1392
+ yr
1393
1393
  ],
1394
1394
  [
1395
1395
  "--font",
1396
1396
  "font",
1397
- hr
1397
+ br
1398
1398
  ],
1399
1399
  [
1400
1400
  "--logo",
1401
1401
  "logo",
1402
- (e) => gr(e)
1402
+ (e) => xr(e)
1403
1403
  ]
1404
1404
  ];
1405
- async function Wr(e = ".", t = {}) {
1405
+ async function Jr(e = ".", t = {}) {
1406
1406
  if (t.from !== void 0 && !/^https?:\/\/[^\s/]/i.test(t.from)) {
1407
1407
  let e = `--from needs an http(s) address, got ${JSON.stringify(t.from)}`;
1408
- return console.error(n.red(`blazon init: ${e}`)), t.failure?.({
1408
+ return console.error(l.red(`blazon init: ${e}`)), t.failure?.({
1409
1409
  code: "invalid-option-value",
1410
1410
  message: e
1411
1411
  }), 2;
1412
1412
  }
1413
- let r = {};
1414
- for (let [e, i, a] of Ur) {
1415
- let o = t[i];
1416
- if (o === void 0) continue;
1417
- let s = a(String(o));
1418
- if ("hint" in s) return console.error(n.red(`blazon init: ${e}: ${s.hint}`)), t.failure?.({
1413
+ let n = {};
1414
+ for (let [e, r, i] of qr) {
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(l.red(`blazon init: ${e}: ${o.hint}`)), t.failure?.({
1419
1419
  code: "invalid-option-value",
1420
- message: `${e}: ${s.hint}`
1420
+ message: `${e}: ${o.hint}`
1421
1421
  }), 2;
1422
- r[i] = s.value;
1422
+ n[r] = o.value;
1423
1423
  }
1424
- let i = A.resolve(process.cwd(), e), a = Ge();
1425
- if (!j.existsSync(a)) throw Error(`Template directory not found at ${a}`);
1424
+ let r = O.resolve(process.cwd(), e), i = Ke();
1425
+ if (!k.existsSync(i)) throw Error(`Template directory not found at ${i}`);
1426
1426
  let o = t.tty ?? !!(process.stdin.isTTY && process.stdout.isTTY), s = [
1427
1427
  t.from,
1428
1428
  t.name,
@@ -1430,233 +1430,233 @@ async function Wr(e = ".", t = {}) {
1430
1430
  t.color,
1431
1431
  t.font,
1432
1432
  t.logo
1433
- ].some((e) => e !== void 0), c = o && !s && !t.yes && t.input !== !1, l = c ? t.prompter ?? Cr() : void 0, u = t.look ?? wr(process.env, o);
1434
- c || console.log(n.cyan(`\n✨ Initializing Blazon Brand Book in ${n.bold(i)}...\n`));
1435
- let d = A.join(i, "blazon.json"), f = j.existsSync(d), p = le(i, a), m = p.kept, h = p.written.map((e) => A.relative(i, e).split(A.sep).join("/")).sort(), g = new Set(h);
1433
+ ].some((e) => e !== void 0), c = o && !s && !t.yes && t.input !== !1, u = c ? t.prompter ?? Dr() : void 0, d = t.look ?? Or(process.env, o);
1434
+ c || console.log(l.cyan(`\n✨ Initializing Blazon Brand Book in ${l.bold(r)}...\n`));
1435
+ let f = O.join(r, "blazon.json"), p = k.existsSync(f), m = a(r, i), h = m.kept, g = m.written.map((e) => O.relative(r, e).split(O.sep).join("/")).sort(), _ = new Set(g);
1436
1436
  t.report?.({
1437
- dir: i,
1438
- created: h,
1439
- kept: m.map((e) => A.relative(i, e).split(A.sep).join("/")).sort()
1440
- }), !f && j.existsSync(d) && On(d, {
1441
- ...Dn(d),
1442
- title: Hr(i),
1437
+ dir: r,
1438
+ created: g,
1439
+ kept: h.map((e) => O.relative(r, e).split(O.sep).join("/")).sort()
1440
+ }), !p && k.existsSync(f) && Nn(f, {
1441
+ ...Mn(f),
1442
+ title: Kr(r),
1443
1443
  description: "Brand guidelines, built from design tokens"
1444
1444
  });
1445
- let _ = [];
1445
+ let v = [];
1446
1446
  for (let e of [
1447
1447
  "tokens",
1448
1448
  "assets",
1449
1449
  "docs"
1450
1450
  ]) {
1451
- let t = Br(e, h.filter((t) => t.startsWith(`${e}/`)));
1452
- t && _.push(`${e}/ (${t})`);
1453
- }
1454
- h.includes("blazon.json") && _.push("blazon.json"), h.includes("blazon.resolver.json") && _.push("blazon.resolver.json");
1455
- let v = { answers: r };
1456
- if (l) try {
1457
- v = await Ir({
1458
- prompter: l,
1459
- look: u,
1460
- dir: i,
1461
- kept: m.length
1451
+ let t = Wr(e, g.filter((t) => t.startsWith(`${e}/`)));
1452
+ t && v.push(`${e}/ (${t})`);
1453
+ }
1454
+ g.includes("blazon.json") && v.push("blazon.json"), g.includes("blazon.resolver.json") && v.push("blazon.resolver.json");
1455
+ let y = { answers: n };
1456
+ if (u) try {
1457
+ y = await Br({
1458
+ prompter: u,
1459
+ look: d,
1460
+ dir: r,
1461
+ kept: h.length
1462
1462
  });
1463
1463
  } catch (e) {
1464
- if (e instanceof br) return l.cancel("Stopped. The starter was copied as it is, and nothing else was changed."), 130;
1464
+ if (e instanceof Tr) return u.cancel("Stopped. The starter was copied as it is, and nothing else was changed."), 130;
1465
1465
  throw e;
1466
1466
  }
1467
1467
  else {
1468
- for (let e of _) console.log(` ${n.green("✔")} Created ${e}`);
1469
- m.length > 0 && console.log(` ${n.yellow("!")} ${m.length} starter files were already here and are kept as they are`), console.log();
1470
- }
1471
- let y = v.site?.url ?? t.from, b = 0, x, S = l?.spinner();
1472
- if (S?.start("Writing the brand book"), y !== void 0) try {
1473
- if (x = await lr(i, y, g, /* @__PURE__ */ new Date(), {
1474
- page: v.site?.findings.page,
1475
- skipVars: v.site?.skipVars
1476
- }), !l) {
1477
- console.log(n.bold(`Read from ${y}:`));
1478
- for (let e of x.written) console.log(` ${n.green("✔")} Wrote ${e}`);
1479
- for (let e of x.removed) console.log(` ${n.green("✔")} Removed ${e}`);
1480
- for (let e of x.repointed) console.log(` ${n.green("✔")} Re-pointed ${e}`);
1481
- for (let e of x.missing) console.log(` ${n.yellow("!")} ${e}`);
1482
- console.log(n.dim("\n All of it is marked needs-review: it is a starting point, so confirm it with the brand owner.\n"));
1468
+ for (let e of v) console.log(` ${l.green("✔")} Created ${e}`);
1469
+ h.length > 0 && console.log(` ${l.yellow("!")} ${h.length} starter files were already here and are kept as they are`), console.log();
1470
+ }
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 mr(r, b, _, /* @__PURE__ */ new Date(), {
1474
+ page: y.site?.findings.page,
1475
+ skipVars: y.site?.skipVars
1476
+ }), !u) {
1477
+ console.log(l.bold(`Read from ${b}:`));
1478
+ for (let e of S.written) console.log(` ${l.green("✔")} Wrote ${e}`);
1479
+ for (let e of S.removed) console.log(` ${l.green("✔")} Removed ${e}`);
1480
+ for (let e of S.repointed) console.log(` ${l.green("✔")} Re-pointed ${e}`);
1481
+ for (let e of S.missing) console.log(` ${l.yellow("!")} ${e}`);
1482
+ console.log(l.dim("\n All of it is marked needs-review: it is a starting point, so confirm it with the brand owner.\n"));
1483
1483
  }
1484
1484
  } catch (e) {
1485
- let r = e instanceof Error ? e.message : String(e);
1485
+ let n = e instanceof Error ? e.message : String(e);
1486
1486
  t.failure?.({
1487
1487
  code: "site-unreadable",
1488
- message: r
1489
- }), l ? l.log.error(`Could not read ${y}: ${r}\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(n.red(`blazon init: ${r}`)), console.error(n.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;
1488
+ 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(l.red(`blazon init: ${n}`)), console.error(l.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;
1490
1490
  }
1491
1491
  let C;
1492
1492
  try {
1493
- C = yr(i, v.answers, g);
1493
+ C = wr(r, y.answers, _);
1494
1494
  } catch (e) {
1495
- throw S?.error("Could not write the brand book"), e;
1496
- }
1497
- S?.stop("Wrote the brand book");
1498
- let w = (e) => u.color ? n.cyan(e) : e, T = L(i), ee = [
1499
- `Run ${w(z("dev", T))} to see the book`,
1500
- `Replace blazon's artwork in ${w(R(T, "assets/"))} and the text in ${w(R(T, "docs/"))}`,
1501
- `Run ${w(z("check", T))} to see what is left`,
1502
- `Point a coding agent at ${w(R(T, "AGENTS.md"))}: it is the guide for editing this brand`
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 ? l.cyan(e) : e, T = F(r), te = [
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`
1503
1503
  ];
1504
- x && !x.written.some((e) => e.startsWith("assets/logos/")) && ee.splice(1, 0, `Add your logo: the book still shows blazon's own. Put it in ${w(R(T, "assets/logos/"))} and point ${w("logo")} in ${w(R(T, "blazon.json"))} at it`);
1505
- let te = w(R(T, "tokens/colors.json")), ne = C.set.some((e) => e.startsWith("primary color")) ? `Finish the palette in ${te}: 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 ${te} with the brand owner` : `Edit ${te} with your colors`;
1506
- if (l) {
1507
- let e = [..._.map((e) => `Created ${e}`)];
1508
- x && e.push(`Read from ${y}: ${x.written.length} files written, ${x.removed.length} starter files removed`, ...x.missing.map((e) => `Not found: ${e}`));
1504
+ S && !S.written.some((e) => e.startsWith("assets/logos/")) && te.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 ne = w(I(T, "tokens/colors.json")), re = C.set.some((e) => e.startsWith("primary color")) ? `Finish the palette in ${ne}: 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 ${ne} with the brand owner` : `Edit ${ne} with your colors`;
1506
+ if (u) {
1507
+ 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
1509
  for (let t of C.set) e.push(`Set ${t}`);
1510
- e.push(...C.hints.map((e) => `Note: ${e}`)), l.note(e.join("\n"), "What was written"), b === 0 && l.note(ee.map((e, t) => `${t + 1}. ${e}`).join("\n"), "Next steps");
1510
+ e.push(...C.hints.map((e) => `Note: ${e}`)), u.note(e.join("\n"), "What was written"), x === 0 && u.note(te.map((e, t) => `${t + 1}. ${e}`).join("\n"), "Next steps");
1511
1511
  let n;
1512
1512
  try {
1513
- n = t.dev ?? await l.confirm({
1513
+ n = t.dev ?? await u.confirm({
1514
1514
  message: "Start the dev server now?",
1515
1515
  initialValue: !1
1516
1516
  });
1517
1517
  } catch (e) {
1518
- if (!(e instanceof br)) throw e;
1519
- return l.cancel("Stopped. Everything above was written."), b === 0 ? 130 : b;
1518
+ if (!(e instanceof Tr)) throw e;
1519
+ return u.cancel("Stopped. Everything above was written."), x === 0 ? 130 : x;
1520
1520
  }
1521
- return l.outro(n ? "Starting blazon dev. Press Ctrl-C to stop it." : `Done. Run ${w(z("dev", T))} when you are ready.`), n && await (t.startDev ?? Gr)(i), b;
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 ?? Yr)(r), x;
1522
1522
  }
1523
- for (let e of C.hints) console.log(` ${n.yellow("!")} ${e}`);
1524
- return C.set.length > 0 && console.log(` ${n.green("✔")} Set ${C.set.join(", ")}\n`), b === 0 && (console.log(n.bold("Next steps:")), console.log(` 1. ${ne}`), ee.forEach((e, t) => console.log(` ${t + 2}. ${e}`))), console.log(), t.dev && await (t.startDev ?? Gr)(i), b;
1523
+ for (let e of C.hints) console.log(` ${l.yellow("!")} ${e}`);
1524
+ return C.set.length > 0 && console.log(` ${l.green("✔")} Set ${C.set.join(", ")}\n`), x === 0 && (console.log(l.bold("Next steps:")), console.log(` 1. ${re}`), te.forEach((e, t) => console.log(` ${t + 2}. ${e}`))), console.log(), t.dev && await (t.startDev ?? Yr)(r), x;
1525
1525
  }
1526
- async function Gr(e) {
1527
- let { runDev: t } = await Promise.resolve().then(() => pt);
1526
+ async function Yr(e) {
1527
+ let { runDev: t } = await Promise.resolve().then(() => vt);
1528
1528
  await t(e);
1529
1529
  }
1530
1530
  // src/server/preview-guard.ts
1531
- function Kr(e) {
1532
- return (t, n, r) => {
1533
- let i;
1531
+ function Xr(t) {
1532
+ return (n, r, i) => {
1533
+ let a;
1534
1534
  try {
1535
- i = decodeURIComponent((t.url ?? "").split("?")[0]);
1535
+ a = decodeURIComponent((n.url ?? "").split("?")[0]);
1536
1536
  } catch {
1537
- return r();
1537
+ return i();
1538
1538
  }
1539
- if (i.includes("\0")) return r();
1540
- let a = A.join(e, A.normalize(`/${i}`));
1541
- if (te(ne(e), ne(a))) return r();
1542
- 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");
1539
+ if (a.includes("\0")) return i();
1540
+ let o = O.join(t, O.normalize(`/${a}`));
1541
+ if (e(x(t), x(o))) return i();
1542
+ r.statusCode = 403, r.setHeader("Content-Type", "text/plain"), r.end("blazon preview serves only files inside the built site: this path is a link that leaves it");
1543
1543
  };
1544
1544
  }
1545
- var qr = (e) => ({
1545
+ var Zr = (e) => ({
1546
1546
  name: "blazon-site-link-guard",
1547
1547
  configurePreviewServer(t) {
1548
- t.middlewares.use(Kr(e));
1548
+ t.middlewares.use(Xr(e));
1549
1549
  }
1550
1550
  });
1551
1551
  // src/cli/commands/preview.ts
1552
- async function Jr(e = process.cwd(), t, r = {}) {
1553
- dt(e);
1554
- let i = await f(e, t ? { port: t } : void 0), a = A.resolve(e, i.outDir);
1555
- if (!j.existsSync(A.join(a, "index.html"))) throw new P(`no built site at "${a}"`, `Run ${z("build", L(e))} first.`, "no-built-site");
1556
- let o;
1552
+ async function Qr(e = process.cwd(), t, n = {}) {
1553
+ gt(e);
1554
+ let r = await ae(e, t ? { port: t } : void 0), i = O.resolve(e, r.outDir);
1555
+ 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;
1557
1557
  try {
1558
- o = await Ye({
1559
- plugins: [oe(), qr(a)],
1560
- build: { outDir: a },
1558
+ a = await et({
1559
+ plugins: [le(), Zr(i)],
1560
+ build: { outDir: i },
1561
1561
  preview: {
1562
- port: i.port,
1563
- strictPort: r.strictPort ?? !1,
1564
- host: r.host ?? "localhost",
1562
+ port: r.port,
1563
+ strictPort: n.strictPort ?? !1,
1564
+ host: n.host ?? "localhost",
1565
1565
  open: !1
1566
1566
  }
1567
1567
  });
1568
1568
  } catch (e) {
1569
- throw r.strictPort && e instanceof Error && /already in use/.test(e.message) ? Ze(i.port) : e;
1569
+ throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? nt(r.port) : e;
1570
1570
  }
1571
- let s = o.resolvedUrls, c = s?.local[0] || `http://localhost:${i.port}/`;
1572
- console.log(`\n ${n.bold(n.blue("blazon preview"))}`), console.log(` ${n.dim("➜")} ${n.bold("Local:")} ${n.cyan(c)}`);
1573
- for (let e of s?.network ?? []) console.log(` ${n.dim("➜")} ${n.bold("Network:")} ${n.cyan(e)}`);
1574
- return console.log(` ${n.dim("➜")} ${n.bold("Dist:")} ${n.dim(a)}\n`), o;
1571
+ let o = a.resolvedUrls, s = o?.local[0] || `http://localhost:${r.port}/`;
1572
+ console.log(`\n ${l.bold(l.blue("blazon preview"))}`), console.log(` ${l.dim("➜")} ${l.bold("Local:")} ${l.cyan(s)}`);
1573
+ for (let e of o?.network ?? []) console.log(` ${l.dim("➜")} ${l.bold("Network:")} ${l.cyan(e)}`);
1574
+ return console.log(` ${l.dim("➜")} ${l.bold("Dist:")} ${l.dim(i)}\n`), a;
1575
1575
  }
1576
1576
  // src/plugins/roles/check-cases.ts
1577
- var Yr = "docs/manual/12-plugins.md (\"What a plugin can look at, and where it writes\")";
1578
- function Xr(e) {
1579
- let t = A.basename(e), n = fe(t) ?? t.replace(/^blazon-/, "");
1580
- return Be(n) ? n : void 0;
1581
- }
1582
- function Zr(e, t) {
1583
- return j.readdirSync(e, { recursive: !0 }).filter((n) => A.join(e, n) !== t && !A.join(e, n).startsWith(t + A.sep)).sort();
1584
- }
1585
- function Qr(e) {
1586
- let t = Xr(e);
1587
- return async (e, n) => {
1588
- let i = r(e), o = i.answers.join(" or "), s = i.stdoutLimit ?? 65536, c = [], l = {
1589
- exit: `a valid request is answered with exit ${o}`,
1590
- limit: `the answer is at most ${s} bytes`,
1577
+ var $r = "docs/manual/12-plugins.md (\"What a plugin can look at, and where it writes\")";
1578
+ function ei(e) {
1579
+ let t = O.basename(e), n = je(t) ?? t.replace(/^blazon-/, "");
1580
+ return Pe(n) ? n : void 0;
1581
+ }
1582
+ function ti(e, t) {
1583
+ return k.readdirSync(e, { recursive: !0 }).filter((n) => O.join(e, n) !== t && !O.join(e, n).startsWith(t + O.sep)).sort();
1584
+ }
1585
+ function ni(e) {
1586
+ let n = ei(e);
1587
+ return async (e, r) => {
1588
+ let i = t(e), a = i.answers.join(" or "), o = i.stdoutLimit ?? 65536, s = [], c = {
1589
+ exit: `a valid request is answered with exit ${a}`,
1590
+ limit: `the answer is at most ${o} bytes`,
1591
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`,
1592
1592
  folder: "the plugin writes into out_dir and nothing beside it"
1593
- }, u = JSON.parse(a()[e]), d = j.mkdtempSync(A.join(Je.tmpdir(), "blazon-plugin-check-")), f = A.join(d, "tokens"), p = A.join(f, t ?? "plugin");
1593
+ }, l = JSON.parse(De()[e]), u = k.mkdtempSync(O.join($e.tmpdir(), "blazon-plugin-check-")), d = O.join(u, "tokens"), f = O.join(d, n ?? "plugin");
1594
1594
  try {
1595
- e === "build" && (j.mkdirSync(A.join(d, "site")), j.mkdirSync(p, { recursive: !0 }), Object.assign(u, {
1596
- site_dir: A.join(d, "site"),
1597
- tokens_dir: f,
1598
- out_dir: p
1595
+ e === "build" && (k.mkdirSync(O.join(u, "site")), k.mkdirSync(f, { recursive: !0 }), Object.assign(l, {
1596
+ site_dir: O.join(u, "site"),
1597
+ tokens_dir: d,
1598
+ out_dir: f
1599
1599
  }));
1600
- let r = await n(Buffer.from(JSON.stringify(u)), s), a = !r.answered && r.breakReason.startsWith("output over the limit");
1601
- a ? c.push(O(6, l.exit, e, {
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(h(6, c.exit, e, {
1602
1602
  skipped: !0,
1603
1603
  detail: "the output went over the limit before the plugin exited (case 7)"
1604
- })) : r.answered && i.answers.includes(r.code) ? c.push(O(6, l.exit, e, { passed: !0 })) : r.answered && r.code === 1 ? c.push(O(6, l.exit, e, { detail: `got exit 1, and exit 1 is a break in blazon: the ${e} role defines only ${o}, 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` })) : c.push(O(6, l.exit, e, { detail: r.answered ? `got exit ${r.code}` : `a break: ${r.breakReason}` }));
1604
+ })) : t.answered && i.answers.includes(t.code) ? s.push(h(6, c.exit, e, { passed: !0 })) : t.answered && t.code === 1 ? s.push(h(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(h(6, c.exit, e, { detail: t.answered ? `got exit ${t.code}` : `a break: ${t.breakReason}` }));
1605
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 (c.push(a ? O(7, l.limit, e, { detail: `the plugin printed more than ${s} bytes, ${m}` }) : O(7, l.limit, e, { passed: !0 })), !r.answered || r.code !== 0) c.push(O(8, l.shape, e, {
1606
+ if (s.push(p ? h(7, c.limit, e, { detail: `the plugin printed more than ${o} bytes, ${m}` }) : h(7, c.limit, e, { passed: !0 })), !t.answered || t.code !== 0) s.push(h(8, c.shape, e, {
1607
1607
  skipped: !0,
1608
1608
  detail: "the plugin did not answer with exit 0"
1609
1609
  }));
1610
- else if (t === void 0) c.push(O(8, l.shape, e, {
1610
+ else if (n === void 0) s.push(h(8, c.shape, e, {
1611
1611
  skipped: !0,
1612
1612
  detail: "the program's file name is not blazon-<plugin name>, so the check does not know the plugin's code prefix"
1613
1613
  }));
1614
1614
  else {
1615
- let n = ie(e, t, r.stdout, []);
1616
- c.push("problem" in n ? O(8, l.shape, e, { detail: n.problem }) : O(8, l.shape, e, { passed: !0 }));
1615
+ let r = de(e, n, t.stdout, []);
1616
+ s.push("problem" in r ? h(8, c.shape, e, { detail: r.problem }) : h(8, c.shape, e, { passed: !0 }));
1617
1617
  }
1618
1618
  if (e === "build") {
1619
- let t = Zr(f, p);
1620
- c.push(t.length === 0 ? O(9, l.folder, e, { passed: !0 }) : O(9, l.folder, e, {
1619
+ let t = ti(d, f);
1620
+ s.push(t.length === 0 ? h(9, c.folder, e, { passed: !0 }) : h(9, c.folder, e, {
1621
1621
  passed: !0,
1622
1622
  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 ${Yr}`
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 ${$r}`
1624
1624
  }));
1625
1625
  }
1626
1626
  } finally {
1627
- j.rmSync(d, {
1627
+ k.rmSync(u, {
1628
1628
  recursive: !0,
1629
1629
  force: !0
1630
1630
  });
1631
1631
  }
1632
- return c;
1632
+ return s;
1633
1633
  };
1634
1634
  }
1635
1635
  // src/cli/commands/plugin.ts
1636
- var $r = {
1636
+ var ri = {
1637
1637
  plugin: "usage: blazon plugin check <program> [--core] | blazon plugin pin <path> [--name <plugin name>] | blazon plugin profile",
1638
1638
  check: "usage: blazon plugin check <program> [--core]",
1639
1639
  pin: "usage: blazon plugin pin <path> [--name <plugin name> [--digest <digest>] [--entry <path>]]"
1640
1640
  };
1641
- function ei(e) {
1642
- let t = e.warning ? n.yellow("warn") : e.passed ? n.green("ok ") : e.skipped ? n.dim("skip") : n.red("FAIL"), r = e.role ? `${e.role}: ` : "", i = e.detail ? ` (${e.detail})` : "";
1643
- return ` ${t} ${e.case} ${r}${e.name}${i}`;
1644
- }
1645
- async function ti(e, t = {}) {
1646
- if (!e) throw new P($r.check, void 0, "missing-argument");
1647
- let r = t.core === !0;
1648
- t.json || (console.log(`${S.host} plugin check: host ${S.host}, adopts: ${S.adopts.length > 0 ? S.adopts.join(", ") : "none"}`), r && console.log("core cases only (1 to 5): no role cases, no layout line"));
1649
- let i = await g({
1650
- ...r ? {} : { approvals: await ni(e) },
1651
- host: S.host,
1652
- profile: He,
1641
+ function ii(e) {
1642
+ let t = e.warning ? l.yellow("warn") : e.passed ? l.green("ok ") : e.skipped ? l.dim("skip") : l.red("FAIL"), n = e.role ? `${e.role}: ` : "", r = e.detail ? ` (${e.detail})` : "";
1643
+ return ` ${t} ${e.case} ${n}${e.name}${r}`;
1644
+ }
1645
+ async function ai(e, t = {}) {
1646
+ if (!e) throw new M(ri.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 Te({
1650
+ ...n ? {} : { approvals: await oi(e) },
1651
+ host: v.host,
1652
+ profile: o,
1653
1653
  program: e,
1654
1654
  validate: !1,
1655
- requests: a(),
1656
- ...r ? {} : { roleCases: Qr(e) }
1657
- }), o = i.filter((e) => e.warning).length, s = i.filter((e) => !e.passed && !e.skipped), c = r ? void 0 : me(A.resolve(e));
1655
+ requests: De(),
1656
+ ...n ? {} : { roleCases: ni(e) }
1657
+ }), i = r.filter((e) => e.warning).length, a = r.filter((e) => !e.passed && !e.skipped), s = n ? void 0 : Se(O.resolve(e));
1658
1658
  if (t.json) {
1659
- let e = (e) => e.warning ? "warn" : e.passed ? "ok" : e.skipped ? "skip" : "fail", t = i.map((t) => ({
1659
+ let e = (e) => e.warning ? "warn" : e.passed ? "ok" : e.skipped ? "skip" : "fail", t = r.map((t) => ({
1660
1660
  case: t.case,
1661
1661
  name: t.name,
1662
1662
  role: t.role,
@@ -1665,128 +1665,128 @@ async function ti(e, t = {}) {
1665
1665
  }));
1666
1666
  return process.stdout.write(`${JSON.stringify({
1667
1667
  command: "plugin check",
1668
- passed: s.length === 0 && !c,
1669
- host: S.host,
1670
- adopts: S.adopts,
1671
- ...r ? { core: !0 } : {},
1668
+ passed: a.length === 0 && !s,
1669
+ host: v.host,
1670
+ adopts: v.adopts,
1671
+ ...n ? { core: !0 } : {},
1672
1672
  cases: t,
1673
- ...c ? { layout: c } : {}
1674
- })}\n`), s.length === 0 && !c ? 0 : 1;
1673
+ ...s ? { layout: s } : {}
1674
+ })}\n`), a.length === 0 && !s ? 0 : 1;
1675
1675
  }
1676
- for (let e of i) console.log(ei(e));
1677
- return c && console.log(` ${n.red("FAIL")} layout: ${c}`), s.length > 0 ? console.log(n.red(`\n${s.length} case${s.length === 1 ? "" : "s"} failed`)) : console.log(c ? n.red("\nFailed: the file name does not follow the layout of a shipped plugin") : n.green(`\nPassed${o > 0 ? `, with ${o} warning${o === 1 ? "" : "s"}` : ""}`)), s.length === 0 && !c ? 0 : 1;
1676
+ for (let e of r) console.log(ii(e));
1677
+ return s && console.log(` ${l.red("FAIL")} layout: ${s}`), a.length > 0 ? console.log(l.red(`\n${a.length} case${a.length === 1 ? "" : "s"} failed`)) : console.log(s ? l.red("\nFailed: the file name does not follow the layout of a shipped plugin") : l.green(`\nPassed${i > 0 ? `, with ${i} warning${i === 1 ? "" : "s"}` : ""}`)), a.length === 0 && !s ? 0 : 1;
1678
1678
  }
1679
- async function ni(e) {
1679
+ async function oi(e) {
1680
1680
  let t;
1681
1681
  try {
1682
- t = (await B(process.cwd())).plugins ?? [];
1682
+ t = (await R(process.cwd())).plugins ?? [];
1683
1683
  } catch {
1684
1684
  return;
1685
1685
  }
1686
- let n = A.basename(e), r = fe(n) ?? n.replace(/^blazon-/, "");
1686
+ let n = O.basename(e), r = je(n) ?? n.replace(/^blazon-/, "");
1687
1687
  return t.flatMap((e, t) => e.name === r ? [{
1688
1688
  key: `plugins[${t}].env`,
1689
1689
  approved: e.env ?? []
1690
1690
  }] : []);
1691
1691
  }
1692
- function ri(e, t = {}, n = process.cwd()) {
1693
- if (!e) throw new P($r.pin, void 0, "missing-argument");
1694
- if (!t.name && (t.digest || t.entry)) throw new P(`--digest and --entry say what to record, so they need --name; ${$r.pin}`, void 0, "conflicting-options");
1695
- if (!j.existsSync(e)) return console.error(`blazon plugin pin: there is nothing at ${e}.`), 2;
1692
+ function si(e, t = {}, n = process.cwd()) {
1693
+ if (!e) throw new M(ri.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; ${ri.pin}`, void 0, "conflicting-options");
1695
+ if (!k.existsSync(e)) return console.error(`blazon plugin pin: there is nothing at ${e}.`), 2;
1696
1696
  try {
1697
1697
  if (t.name) {
1698
- let r = u(n, t.name, e, {
1698
+ let r = Xe(n, t.name, e, {
1699
1699
  digest: t.digest,
1700
1700
  entry: t.entry
1701
1701
  });
1702
- return console.log(`pinned ${t.name}: ${r.digest} (${r.source}) in ${o}`), 0;
1702
+ return console.log(`pinned ${t.name}: ${r.digest} (${r.source}) in ${S}`), 0;
1703
1703
  }
1704
- let r = j.lstatSync(e);
1705
- return console.log(r.isDirectory() && !r.isSymbolicLink() ? w(e) : l(e)), 0;
1704
+ let r = k.lstatSync(e);
1705
+ return console.log(r.isDirectory() && !r.isSymbolicLink() ? m(e) : d(e)), 0;
1706
1706
  } catch (t) {
1707
- return console.error(t instanceof T ? t.message : `cannot read ${e}: ${t instanceof Error ? t.message : String(t)}`), 1;
1707
+ return console.error(t instanceof re ? t.message : `cannot read ${e}: ${t instanceof Error ? t.message : String(t)}`), 1;
1708
1708
  }
1709
1709
  }
1710
- function ii() {
1711
- return console.log(JSON.stringify(S, null, 2)), 0;
1710
+ function ci() {
1711
+ return console.log(JSON.stringify(v, null, 2)), 0;
1712
1712
  }
1713
- async function ai(e, t, n = {}) {
1714
- if (e === "check") return ti(t, {
1713
+ async function li(e, t, n = {}) {
1714
+ if (e === "check") return ai(t, {
1715
1715
  json: n.json,
1716
1716
  core: n.core
1717
1717
  });
1718
- if (e === "pin") return ri(t, n);
1719
- if (e === "profile") return ii();
1720
- throw new P($r.plugin, void 0, "missing-argument");
1718
+ if (e === "pin") return si(t, n);
1719
+ if (e === "profile") return ci();
1720
+ throw new M(ri.plugin, void 0, "missing-argument");
1721
1721
  }
1722
1722
  // src/cli/commands/pin.ts
1723
- function oi(e = process.cwd(), t = {}) {
1724
- dt(e);
1723
+ function ui(e = process.cwd(), t = {}) {
1724
+ gt(e);
1725
1725
  try {
1726
- let r = t.identity === void 0 ? _e(e) : _e(e, t.identity);
1726
+ let n = t.identity === void 0 ? Ye(e) : Ye(e, t.identity);
1727
1727
  return t.json ? process.stdout.write(`${JSON.stringify({
1728
1728
  command: "pin",
1729
1729
  passed: !0,
1730
- commit: r,
1731
- file: Me
1732
- })}\n`) : console.log(`pinned blazon ${n.bold(r)} in ${Me}; commit the file with the book`), 0;
1730
+ commit: n,
1731
+ file: be
1732
+ })}\n`) : console.log(`pinned blazon ${l.bold(n)} in ${be}; commit the file with the book`), 0;
1733
1733
  } catch (e) {
1734
1734
  if (t.json) throw e;
1735
1735
  return console.error(e instanceof Error ? e.message : String(e)), 1;
1736
1736
  }
1737
1737
  }
1738
1738
  // src/cli/commands/drift.ts
1739
- async function si(e, t = {}) {
1740
- let r = (e, r, i) => (console.error($e("drift", r, i).replace(/^blazon drift:/, (e) => n.red(e))), t.json && console.log(JSON.stringify({
1739
+ async function di(e, t = {}) {
1740
+ let n = (e, n, r) => (console.error(it("drift", n, r).replace(/^blazon drift:/, (e) => l.red(e))), t.json && console.log(JSON.stringify({
1741
1741
  command: "drift",
1742
1742
  passed: !1,
1743
- error: { ...it(e, et(r, i), i) }
1743
+ error: { ...lt(e, at(n, r), r) }
1744
1744
  })), 2);
1745
- if (!e) return r("missing-argument", "needs the address of a page or the path of a CSS file", "Run blazon drift <url-or-css-file>.");
1746
- let i = t.cwd ?? process.cwd();
1747
- if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(e) && !j.existsSync(A.resolve(e))) return r("no-file", `there is no file "${e}"`, "Give the path of a CSS file, or the http(s) address of a page.");
1748
- let a, o;
1745
+ 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
+ let r = t.cwd ?? process.cwd();
1747
+ 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;
1749
1749
  try {
1750
- let n = await B(i, t.tokens ? { tokensDir: t.tokens } : void 0), r = await D(n, i), s = await Xt(e);
1751
- a = s.sources;
1752
- let c = Ut(s.css);
1753
- o = r.tokens.items.flatMap((e) => {
1750
+ let n = await R(r, t.tokens ? { tokensDir: t.tokens } : void 0), o = await D(n, r), s = await tn(e);
1751
+ i = s.sources;
1752
+ let c = Jt(s.css);
1753
+ a = o.tokens.items.flatMap((e) => {
1754
1754
  let t = e.blazon.source?.cssVar;
1755
- return typeof t == "string" ? [Wt(e, t, c)] : [];
1755
+ return typeof t == "string" ? [Yt(e, t, c)] : [];
1756
1756
  });
1757
1757
  } catch (e) {
1758
- return r(e instanceof N ? e.code : "error", e instanceof Error ? e.message : String(e), e instanceof N ? e.fix : void 0);
1759
- }
1760
- if (o.length === 0) return r("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 s = (e) => o.filter((t) => t.status === e).length, c = {
1762
- ok: s("ok"),
1763
- drift: s("drift"),
1764
- missing: s("missing")
1765
- }, l = +(c.drift + c.missing > 0);
1758
+ return n(e instanceof j ? e.code : "error", e instanceof Error ? e.message : String(e), e instanceof j ? e.fix : void 0);
1759
+ }
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, s = {
1762
+ ok: o("ok"),
1763
+ drift: o("drift"),
1764
+ missing: o("missing")
1765
+ }, c = +(s.drift + s.missing > 0);
1766
1766
  if (t.json) return console.log(JSON.stringify({
1767
1767
  target: e,
1768
- sources: a,
1769
- summary: c,
1770
- tokens: o
1771
- }, null, 2)), l;
1772
- let u = Math.max(...o.map((e) => e.path.length));
1773
- for (let e of o) {
1768
+ sources: i,
1769
+ summary: s,
1770
+ tokens: a
1771
+ }, null, 2)), c;
1772
+ let u = Math.max(...a.map((e) => e.path.length));
1773
+ for (let e of a) {
1774
1774
  let t = e.path.padEnd(u);
1775
- e.status === "ok" ? console.log(`${n.green("ok ")} ${t} ${n.dim(e.cssVar)}`) : e.status === "drift" ? console.log(`${n.red("drift ")} ${t} ${e.cssVar}: token ${e.expected}, site ${e.actual}`) : console.log(`${n.yellow("missing")} ${t} ${e.cssVar} is not declared (token ${e.expected})`);
1775
+ e.status === "ok" ? console.log(`${l.green("ok ")} ${t} ${l.dim(e.cssVar)}`) : e.status === "drift" ? console.log(`${l.red("drift ")} ${t} ${e.cssVar}: token ${e.expected}, site ${e.actual}`) : console.log(`${l.yellow("missing")} ${t} ${e.cssVar} is not declared (token ${e.expected})`);
1776
1776
  }
1777
- return console.log(`\n${c.ok} ok, ${c.drift} drifted, ${c.missing} missing`), l;
1777
+ return console.log(`\n${s.ok} ok, ${s.drift} drifted, ${s.missing} missing`), c;
1778
1778
  }
1779
1779
  // src/cli/commands/approvals.ts
1780
- async function ci(e = process.cwd(), t = {}) {
1781
- let r = await B(e), i = await D(r, e), a = x(i.tokens, i.assets.all, {
1782
- assetsDir: A.resolve(e, r.assetsDir),
1783
- dirs: y(r.assets, e)
1784
- }), o = (e) => e.review.value === void 0 ? "not recorded" : e.review.value === e.current ? "recorded" : "stale";
1780
+ async function fi(e = process.cwd(), t = {}) {
1781
+ let n = await R(e), r = await D(n, e), i = T(r.tokens, r.assets.all, {
1782
+ assetsDir: O.resolve(e, n.assetsDir),
1783
+ dirs: ne(n.assets, e)
1784
+ }), a = (e) => e.review.value === void 0 ? "not recorded" : e.review.value === e.current ? "recorded" : "stale";
1785
1785
  if (t.json) {
1786
- let e = a.map((e) => ({
1786
+ let e = i.map((e) => ({
1787
1787
  path: e.path,
1788
1788
  fingerprint: e.current ?? null,
1789
- state: o(e)
1789
+ state: a(e)
1790
1790
  }));
1791
1791
  return process.stdout.write(`${JSON.stringify({
1792
1792
  command: "approvals",
@@ -1794,60 +1794,60 @@ async function ci(e = process.cwd(), t = {}) {
1794
1794
  approvals: e
1795
1795
  })}\n`), 0;
1796
1796
  }
1797
- if (a.length === 0) return console.log(n.dim("\n No token or asset is marked review.status: ok.\n")), 0;
1798
- let s = Math.max(...a.map((e) => e.path.length));
1797
+ if (i.length === 0) return console.log(l.dim("\n No token or asset is marked review.status: ok.\n")), 0;
1798
+ let o = Math.max(...i.map((e) => e.path.length));
1799
1799
  console.log();
1800
- for (let e of a) {
1801
- let t = o(e), r = t === "recorded" ? n.green : t === "stale" ? n.yellow : n.dim;
1802
- console.log(` ${e.path.padEnd(s)} ${(e.current ?? "(no value)").padEnd(12)} ${r(t)}`);
1800
+ for (let e of i) {
1801
+ let t = a(e), n = t === "recorded" ? l.green : t === "stale" ? l.yellow : l.dim;
1802
+ console.log(` ${e.path.padEnd(o)} ${(e.current ?? "(no value)").padEnd(12)} ${n(t)}`);
1803
1803
  }
1804
- return console.log(), console.log(n.dim(" Set review.value to the fingerprint once a person has confirmed the value.\n")), 0;
1804
+ return console.log(), console.log(l.dim(" Set review.value to the fingerprint once a person has confirmed the value.\n")), 0;
1805
1805
  }
1806
1806
  // src/cli/commands/cwd.ts
1807
- function li(e) {
1807
+ function pi(e) {
1808
1808
  if (e === void 0) return;
1809
- if (typeof e != "string" || e === "") throw new P("--cwd needs a folder", "Give one, such as blazon --cwd ./my-brand check.");
1810
- let t = A.resolve(process.cwd(), e);
1811
- dt(t), process.chdir(t);
1809
+ if (typeof e != "string" || e === "") throw new M("--cwd needs a folder", "Give one, such as blazon --cwd ./my-brand check.");
1810
+ let t = O.resolve(process.cwd(), e);
1811
+ gt(t), process.chdir(t);
1812
1812
  }
1813
- function ui(e, t = process.env) {
1813
+ function mi(e, t = process.env) {
1814
1814
  let n = (Array.isArray(e) ? e : e === void 0 ? [] : [e]).map((e) => typeof e == "string" || typeof e == "number" ? String(e) : "");
1815
- if (n.some((e) => e.trim() === "")) throw new P("--allow-dir needs a folder", "Give one, such as blazon dev --allow-dir ../shared.");
1816
- v(re(n, t, process.cwd()));
1815
+ if (n.some((e) => e.trim() === "")) throw new M("--allow-dir needs a folder", "Give one, such as blazon dev --allow-dir ../shared.");
1816
+ ze(ge(n, t, process.cwd()));
1817
1817
  }
1818
1818
  // src/core/read/lookup.ts
1819
- var q = class extends Error {}, di = (e) => e.trim().replace(/^\{(.*)\}$/, "$1").trim();
1820
- function fi(e, t) {
1821
- let n = di(t), r = e.tokens.byPath.get(n);
1819
+ var K = class extends Error {}, hi = (e) => e.trim().replace(/^\{(.*)\}$/, "$1").trim();
1820
+ function gi(e, t) {
1821
+ let n = hi(t), r = e.tokens.byPath.get(n);
1822
1822
  if (r) return r;
1823
1823
  let i = E(n, e.tokens.items.map((e) => e.path));
1824
- throw new q(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}"?` : "."}`);
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}"?` : "."}`);
1825
1825
  }
1826
1826
  // src/core/read/rules.ts
1827
- var pi = (e) => e.extensions?.["dev.blazon"] ?? {};
1828
- function mi(e, t, n) {
1829
- return pi(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;
1827
+ var _i = (e) => e.extensions?.["dev.blazon"] ?? {};
1828
+ function vi(e, t, n) {
1829
+ return _i(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;
1830
1830
  }
1831
- var J = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : void 0;
1832
- function hi(e, t) {
1833
- let n = t.blazon.usage, r = mi(e, t, "usage");
1831
+ var q = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : void 0;
1832
+ function yi(e, t) {
1833
+ let n = t.blazon.usage, r = vi(e, t, "usage");
1834
1834
  if (!n || typeof n != "object" || r === void 0) return;
1835
- let i = J(n.allow), a = J(n.deny);
1835
+ let i = q(n.allow), a = q(n.deny);
1836
1836
  return {
1837
1837
  ...i && { allow: i },
1838
1838
  ...a && { deny: a },
1839
1839
  from: r
1840
1840
  };
1841
1841
  }
1842
- function gi(e, t) {
1843
- let n = t.blazon.logo, r = mi(e, t, "logo"), i = J(n?.deny);
1842
+ function bi(e, t) {
1843
+ let n = t.blazon.logo, r = vi(e, t, "logo"), i = q(n?.deny);
1844
1844
  if (n && i && r !== void 0) return {
1845
1845
  deny: i,
1846
1846
  ...typeof n.reason == "string" && { reason: n.reason },
1847
1847
  from: r
1848
1848
  };
1849
1849
  }
1850
- function _i(e) {
1850
+ function xi(e) {
1851
1851
  return e.tokens.groupMeta.flatMap((e) => (e.blazon.pairs ?? []).map((t) => ({
1852
1852
  fg: t.fg,
1853
1853
  bg: t.bg,
@@ -1855,19 +1855,19 @@ function _i(e) {
1855
1855
  from: e.path
1856
1856
  })));
1857
1857
  }
1858
- function vi(e, t) {
1858
+ function Si(e, t) {
1859
1859
  let n = [];
1860
- for (let r of _i(e)) Se(r.fg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1860
+ for (let r of xi(e)) b(r.fg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1861
1861
  ...r,
1862
1862
  as: "fg"
1863
- }), Se(r.bg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1863
+ }), b(r.bg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1864
1864
  ...r,
1865
1865
  as: "bg"
1866
1866
  });
1867
1867
  return n;
1868
1868
  }
1869
- function yi(e, t) {
1870
- let n = pi(t).review, r = n ? t.path : mi(e, t, "review"), i = n ?? e.tokens.groupMeta.find((e) => e.path === r)?.blazon.review;
1869
+ function Ci(e, t) {
1870
+ let n = _i(t).review, r = n ? t.path : vi(e, t, "review"), i = n ?? e.tokens.groupMeta.find((e) => e.path === r)?.blazon.review;
1871
1871
  if (i && r !== void 0) return {
1872
1872
  status: i.status,
1873
1873
  ...i.note && { note: i.note },
@@ -1876,8 +1876,8 @@ function yi(e, t) {
1876
1876
  from: r
1877
1877
  };
1878
1878
  }
1879
- function bi(e, t) {
1880
- let n = hi(e, t), r = gi(e, t), i = yi(e, t), a = t.blazon.role === void 0 ? void 0 : mi(e, t, "role");
1879
+ function wi(e, t) {
1880
+ let n = yi(e, t), r = bi(e, t), i = Ci(e, t), a = t.blazon.role === void 0 ? void 0 : vi(e, t, "role");
1881
1881
  return {
1882
1882
  ...t.blazon.role !== void 0 && a !== void 0 && { role: {
1883
1883
  value: t.blazon.role,
@@ -1885,15 +1885,15 @@ function bi(e, t) {
1885
1885
  } },
1886
1886
  ...n && { usage: n },
1887
1887
  ...r && { logo: r },
1888
- pairs: vi(e, t),
1888
+ pairs: Si(e, t),
1889
1889
  ...i && { review: i }
1890
1890
  };
1891
1891
  }
1892
- function xi(e, t, n) {
1892
+ function Ti(e, t, n) {
1893
1893
  let r = n.usage && typeof n.usage == "object" ? {
1894
- ...J(n.usage.allow) && { allow: J(n.usage.allow) },
1895
- ...J(n.usage.deny) && { deny: J(n.usage.deny) }
1896
- } : void 0, i = J(n.logo?.deny), a = {
1894
+ ...q(n.usage.allow) && { allow: q(n.usage.allow) },
1895
+ ...q(n.usage.deny) && { deny: q(n.usage.deny) }
1896
+ } : void 0, i = q(n.logo?.deny), a = {
1897
1897
  at: e,
1898
1898
  kind: t,
1899
1899
  ...typeof n.role == "string" && { role: n.role },
@@ -1910,37 +1910,37 @@ function xi(e, t, n) {
1910
1910
  };
1911
1911
  return Object.keys(a).length > 2 ? a : void 0;
1912
1912
  }
1913
- function Si(e, t) {
1914
- let n = di(t), r = (e) => n === "" || e === n || e.startsWith(`${n}.`);
1913
+ function Ei(e, t) {
1914
+ let n = hi(t), r = (e) => n === "" || e === n || e.startsWith(`${n}.`);
1915
1915
  if (!(n === "" || e.tokens.items.some((e) => r(e.path)))) {
1916
1916
  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)]);
1917
- throw new q(`no token or group "${n}"${r ? `; did you mean "${r}"?` : "."}`);
1917
+ throw new K(`no token or group "${n}"${r ? `; did you mean "${r}"?` : "."}`);
1918
1918
  }
1919
1919
  return [
1920
- ...e.tokens.groupMeta.filter((e) => n !== "" && n.startsWith(`${e.path}.`)).map((e) => xi(e.path, "group", {
1920
+ ...e.tokens.groupMeta.filter((e) => n !== "" && n.startsWith(`${e.path}.`)).map((e) => Ti(e.path, "group", {
1921
1921
  ...e.blazon,
1922
1922
  pairs: void 0
1923
1923
  })).map((e) => e && {
1924
1924
  ...e,
1925
1925
  inherited: !0
1926
1926
  }),
1927
- ...e.tokens.groupMeta.filter((e) => r(e.path)).map((e) => xi(e.path, "group", e.blazon)),
1928
- ...e.tokens.items.filter((e) => r(e.path)).map((e) => xi(e.path, "token", pi(e)))
1927
+ ...e.tokens.groupMeta.filter((e) => r(e.path)).map((e) => Ti(e.path, "group", e.blazon)),
1928
+ ...e.tokens.items.filter((e) => r(e.path)).map((e) => Ti(e.path, "token", _i(e)))
1929
1929
  ].filter((e) => e !== void 0);
1930
1930
  }
1931
1931
  // src/core/read/token.ts
1932
- function Ci(e, t) {
1933
- let [n, ...r] = i(t);
1932
+ function Di(e, t) {
1933
+ let [r, ...i] = n(t);
1934
1934
  return {
1935
1935
  theme: {
1936
- variable: n,
1937
- ...t.parts && { parts: Object.fromEntries(Object.keys(t.parts).map((e, t) => [e, r[t]])) }
1936
+ variable: r,
1937
+ ...t.parts && { parts: Object.fromEntries(Object.keys(t.parts).map((e, t) => [e, i[t]])) }
1938
1938
  },
1939
- ...t.type === "typography" && { typographyClass: c(t.path) }
1939
+ ...t.type === "typography" && { typographyClass: p(t.path) }
1940
1940
  };
1941
1941
  }
1942
- function wi(e, t) {
1943
- let n = fi(e, t), r = (e.tokens.contexts ?? []).flatMap((e) => e.tokens.filter((e) => e.path === n.path).map((t) => ({
1942
+ function Oi(e, t) {
1943
+ let n = gi(e, t), r = (e.tokens.contexts ?? []).flatMap((e) => e.tokens.filter((e) => e.path === n.path).map((t) => ({
1944
1944
  modifier: e.modifier,
1945
1945
  context: e.context,
1946
1946
  selector: e.selector,
@@ -1955,14 +1955,14 @@ function wi(e, t) {
1955
1955
  ...n.deprecated && { deprecated: n.deprecated },
1956
1956
  ...n.aliasOf && { aliasOf: n.aliasOf },
1957
1957
  ...n.blazon.tier && { tier: n.blazon.tier },
1958
- names: Ci(e, n),
1959
- rules: bi(e, n),
1958
+ names: Di(e, n),
1959
+ rules: wi(e, n),
1960
1960
  ...r.length > 0 && { contexts: r },
1961
1961
  sourceFile: n.file.replace(/ \(inline\)$/, "")
1962
1962
  };
1963
1963
  }
1964
1964
  // src/core/read/list.ts
1965
- function Ti(e) {
1965
+ function ki(e) {
1966
1966
  let t = /* @__PURE__ */ new Set();
1967
1967
  for (let { path: n } of e.tokens.items) {
1968
1968
  let e = n.split(".");
@@ -1970,20 +1970,20 @@ function Ti(e) {
1970
1970
  }
1971
1971
  return t;
1972
1972
  }
1973
- function Ei(e, t) {
1974
- let n = di(t);
1975
- return !e.tokens.byPath.has(n) && Ti(e).has(n);
1973
+ function Ai(e, t) {
1974
+ let n = hi(t);
1975
+ return !e.tokens.byPath.has(n) && ki(e).has(n);
1976
1976
  }
1977
- function Di(e, t = {}) {
1977
+ function ji(e, t = {}) {
1978
1978
  let n;
1979
- if (t.type !== void 0 && (n = Ue.find((e) => e === t.type), !n)) throw new q(`no token type "${t.type}"; the types are ${Ue.join(", ")}.`);
1979
+ if (t.type !== void 0 && (n = s.find((e) => e === t.type), !n)) throw new K(`no token type "${t.type}"; the types are ${s.join(", ")}.`);
1980
1980
  let r;
1981
1981
  if (t.group !== void 0) {
1982
- r = di(t.group);
1983
- let n = Ti(e);
1982
+ r = hi(t.group);
1983
+ let n = ki(e);
1984
1984
  if (!n.has(r)) {
1985
1985
  let e = E(r, [...n]);
1986
- throw new q(`no group "${r}"${e ? `; did you mean "${e}"?` : "."}`);
1986
+ throw new K(`no group "${r}"${e ? `; did you mean "${e}"?` : "."}`);
1987
1987
  }
1988
1988
  }
1989
1989
  let i = e.tokens.items.filter((e) => (r === void 0 || e.path.startsWith(`${r}.`)) && (n === void 0 || e.type === n)).map((e) => ({
@@ -1999,24 +1999,24 @@ function Di(e, t = {}) {
1999
1999
  };
2000
2000
  }
2001
2001
  // src/core/read/can.ts
2002
- var Oi = ["text", "ui"], ki = Ce["AA-large"], Ai = [
2002
+ var Mi = ["text", "ui"], Ni = g["AA-large"], Pi = [
2003
2003
  "border",
2004
2004
  "icon",
2005
2005
  "interactive"
2006
- ], ji = [
2006
+ ], Fi = [
2007
2007
  "AAA",
2008
2008
  "AA",
2009
2009
  "AA-large"
2010
2010
  ];
2011
- function Mi(e, t) {
2011
+ function Ii(e, t) {
2012
2012
  let n = [];
2013
2013
  for (let r = t; r && !n.includes(r); r = r.aliasOf ? e.tokens.byPath.get(r.aliasOf) : void 0) n.push(r);
2014
2014
  return n;
2015
2015
  }
2016
- function Ni(e, t, n) {
2017
- for (let r of Mi(e, t)) {
2018
- if (_(r, n)) continue;
2019
- let t = hi(e, r), i = t.deny?.includes(n) ? `denies "${n}"` : `allows only ${(t.allow ?? []).map((e) => `"${e}"`).join(", ")}, not "${n}"`;
2016
+ function Li(e, t, n) {
2017
+ for (let r of Ii(e, t)) {
2018
+ if (Ee(r, n)) continue;
2019
+ let t = yi(e, r), i = t.deny?.includes(n) ? `denies "${n}"` : `allows only ${(t.allow ?? []).map((e) => `"${e}"`).join(", ")}, not "${n}"`;
2020
2020
  return {
2021
2021
  rule: "usage",
2022
2022
  ok: !1,
@@ -2024,15 +2024,15 @@ function Ni(e, t, n) {
2024
2024
  from: t.from
2025
2025
  };
2026
2026
  }
2027
- let r = Mi(e, t).find((t) => hi(e, t));
2027
+ let r = Ii(e, t).find((t) => yi(e, t));
2028
2028
  return {
2029
2029
  rule: "usage",
2030
2030
  ok: !0,
2031
2031
  message: r ? `usage rules on {${r.path}} leave "${n}" open` : `{${t.path}} has no usage rule against "${n}"`
2032
2032
  };
2033
2033
  }
2034
- function Pi(e, t) {
2035
- let n = Ai.map((n) => Ni(e, t, n)), r = Ai.filter((e, t) => n[t].ok);
2034
+ function Ri(e, t) {
2035
+ let n = Pi.map((n) => Li(e, t, n)), r = Pi.filter((e, t) => n[t].ok);
2036
2036
  return r.length > 0 ? {
2037
2037
  rule: "usage",
2038
2038
  ok: !0,
@@ -2044,12 +2044,12 @@ function Pi(e, t) {
2044
2044
  from: n[0].from
2045
2045
  };
2046
2046
  }
2047
- var Fi = "theme";
2048
- function Ii(e, t) {
2049
- let n = e.tokens.modifiers?.find((e) => e.name === Fi);
2050
- if (!n) throw new q(`no theme "${t}": this brand has no resolver "${Fi}" modifier, so it has no themes.`);
2051
- if (!n.contexts.includes(t)) throw new q(`no theme "${t}". The themes are ${n.contexts.map((e) => `"${e}"`).join(", ")}.`);
2052
- let r = (e.tokens.contexts ?? []).filter((e) => e.modifier === "theme" && e.context === t), i = ae(e.tokens.items, r);
2047
+ var zi = "theme";
2048
+ function Bi(e, t) {
2049
+ let n = e.tokens.modifiers?.find((e) => e.name === zi);
2050
+ if (!n) throw new K(`no theme "${t}": this brand has no resolver "${zi}" modifier, so it has no themes.`);
2051
+ if (!n.contexts.includes(t)) throw new K(`no theme "${t}". The themes are ${n.contexts.map((e) => `"${e}"`).join(", ")}.`);
2052
+ let r = (e.tokens.contexts ?? []).filter((e) => e.modifier === "theme" && e.context === t), i = fe(e.tokens.items, r);
2053
2053
  return {
2054
2054
  ...e,
2055
2055
  tokens: {
@@ -2059,22 +2059,22 @@ function Ii(e, t) {
2059
2059
  }
2060
2060
  };
2061
2061
  }
2062
- var Li = (e, t) => {
2063
- let n = e.type === "color" ? h(String(e.value)) : void 0;
2064
- if (!n) throw new q(`{${e.path}} (${t}) is not a color blazon can read: it is ${e.type ?? "untyped"} with the value ${String(e.value)}.`);
2062
+ var Vi = (e, t) => {
2063
+ let n = e.type === "color" ? f(String(e.value)) : void 0;
2064
+ 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)}.`);
2065
2065
  return n;
2066
2066
  };
2067
- function Ri(t, n, r, i = "text", a) {
2068
- if (a !== void 0) return {
2069
- ...Ri(Ii(t, a), n, r, i),
2070
- theme: a
2067
+ function Hi(e, t, n, r = "text", i) {
2068
+ if (i !== void 0) return {
2069
+ ...Hi(Bi(e, i), t, n, r),
2070
+ theme: i
2071
2071
  };
2072
- if (!Oi.includes(i)) throw new q(`"${String(i)}" is not a role blazon can judge. Use ${Oi.map((e) => `"${e}"`).join(" or ")}.`);
2073
- let o = fi(t, n), s = fi(t, r), c = e(Li(o, "foreground"), Li(s, "background")), l = ji.find((e) => c >= Ce[e]) ?? "fail", u = `${c.toFixed(2)}:1`, d = Math.round(c * 100) / 100;
2074
- if (i === "ui") {
2075
- let e = [
2076
- Pi(t, o),
2077
- Ni(t, s, "background"),
2072
+ if (!Mi.includes(r)) throw new K(`"${String(r)}" is not a role blazon can judge. Use ${Mi.map((e) => `"${e}"`).join(" or ")}.`);
2073
+ let a = gi(e, t), o = gi(e, n), s = _(Vi(a, "foreground"), Vi(o, "background")), c = Fi.find((e) => s >= g[e]) ?? "fail", l = `${s.toFixed(2)}:1`, d = Math.round(s * 100) / 100;
2074
+ if (r === "ui") {
2075
+ let t = [
2076
+ Ri(e, a),
2077
+ Li(e, o, "background"),
2078
2078
  {
2079
2079
  rule: "pairs",
2080
2080
  ok: !0,
@@ -2082,38 +2082,38 @@ function Ri(t, n, r, i = "text", a) {
2082
2082
  },
2083
2083
  {
2084
2084
  rule: "contrast",
2085
- ok: c >= ki,
2086
- message: `non-text contrast needs ${ki}:1, this is ${u}`
2085
+ ok: s >= Ni,
2086
+ message: `non-text contrast needs ${Ni}:1, this is ${l}`
2087
2087
  }
2088
- ], n = e.find((e) => !e.ok), r = n ? n.message : e[e.length - 1].message;
2088
+ ], n = t.find((e) => !e.ok), i = n ? n.message : t[t.length - 1].message;
2089
2089
  return {
2090
- fg: o.path,
2091
- bg: s.path,
2092
- role: i,
2090
+ fg: a.path,
2091
+ bg: o.path,
2092
+ role: r,
2093
2093
  allowed: n === void 0,
2094
- reason: r,
2095
- checks: e,
2094
+ reason: i,
2095
+ checks: t,
2096
2096
  contrast: {
2097
2097
  ratio: d,
2098
- level: l,
2099
- threshold: ki
2098
+ level: c,
2099
+ threshold: Ni
2100
2100
  }
2101
2101
  };
2102
2102
  }
2103
- let f = [Ni(t, o, "text"), Ni(t, s, "background")], p = _i(t), h = m(t.tokens.items, p, o.path, s.path);
2104
- if (h.length > 0) for (let e of h) {
2105
- let t = Ce[e.min];
2103
+ let f = [Li(e, a, "text"), Li(e, o, "background")], p = xi(e), m = u(e.tokens.items, p, a.path, o.path);
2104
+ if (m.length > 0) for (let e of m) {
2105
+ let t = g[e.min];
2106
2106
  f.push({
2107
2107
  rule: "pairs",
2108
- ok: c >= t,
2109
- message: `pairs on ${e.from} list ${e.fg} on ${e.bg}: ${e.min} needs ${t}:1, this is ${u}`,
2108
+ ok: s >= t,
2109
+ message: `pairs on ${e.from} list ${e.fg} on ${e.bg}: ${e.min} needs ${t}:1, this is ${l}`,
2110
2110
  from: e.from
2111
2111
  });
2112
2112
  }
2113
2113
  else p.length > 0 ? f.push({
2114
2114
  rule: "pairs",
2115
2115
  ok: !1,
2116
- message: `no pair lists {${o.path}} on {${s.path}}; the brand lists ${p.length} pair${p.length === 1 ? "" : "s"} and only those may sit together`
2116
+ message: `no pair lists {${a.path}} on {${o.path}}; the brand lists ${p.length} pair${p.length === 1 ? "" : "s"} and only those may sit together`
2117
2117
  }) : f.push({
2118
2118
  rule: "pairs",
2119
2119
  ok: !0,
@@ -2122,34 +2122,34 @@ function Ri(t, n, r, i = "text", a) {
2122
2122
  f.push({
2123
2123
  rule: "contrast",
2124
2124
  ok: !0,
2125
- message: `contrast is ${u}${l === "fail" ? ", below every WCAG level" : `, which meets ${l}`} (reported, never a rule of its own)`
2125
+ message: `contrast is ${l}${c === "fail" ? ", below every WCAG level" : `, which meets ${c}`} (reported, never a rule of its own)`
2126
2126
  });
2127
- let g = f.find((e) => !e.ok && e.rule !== "contrast") ?? void 0, _ = g === void 0, v = g ? g.message : (f.find((e) => e.rule === "pairs" && e.from) ?? f[f.length - 1]).message;
2127
+ let h = f.find((e) => !e.ok && e.rule !== "contrast") ?? void 0, v = h === void 0, y = h ? h.message : (f.find((e) => e.rule === "pairs" && e.from) ?? f[f.length - 1]).message;
2128
2128
  return {
2129
- fg: o.path,
2130
- bg: s.path,
2131
- role: i,
2132
- allowed: _,
2133
- reason: v,
2129
+ fg: a.path,
2130
+ bg: o.path,
2131
+ role: r,
2132
+ allowed: v,
2133
+ reason: y,
2134
2134
  checks: f,
2135
2135
  contrast: {
2136
2136
  ratio: d,
2137
- level: l
2137
+ level: c
2138
2138
  }
2139
2139
  };
2140
2140
  }
2141
2141
  // src/core/read/fonts.ts
2142
- function zi(e, t, n) {
2143
- let r = t.fonts ?? [], i = Ie(t.fonts, n), a = /* @__PURE__ */ new Map();
2142
+ function Ui(e, t, n) {
2143
+ let r = t.fonts ?? [], i = Ve(t.fonts, n), a = /* @__PURE__ */ new Map();
2144
2144
  for (let t of e.tokens.items) {
2145
- let e = t.resolvedValue, n = t.type === "fontFamily" ? (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "string") : void 0, r = t.type === "fontFamily" ? Pe(e) : t.type === "typography" && typeof e == "object" && e ? Pe(e.fontFamily) : void 0;
2145
+ 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;
2146
2146
  if (!r) continue;
2147
2147
  let o = r.toLowerCase(), s = a.get(o);
2148
2148
  s ? (s.tokens.push(t.path), !s.stack && n && (s.stack = n)) : a.set(o, {
2149
2149
  family: r,
2150
2150
  tokens: [t.path],
2151
2151
  ...n && { stack: n },
2152
- system: ke.has(o),
2152
+ system: ue.has(o),
2153
2153
  loaded: i.families.has(o) ? !0 : i.opaque ? null : !1,
2154
2154
  ...t.blazon.webFont !== void 0 && { webFont: t.blazon.webFont },
2155
2155
  ...t.blazon.font && { font: t.blazon.font }
@@ -2160,8 +2160,8 @@ function zi(e, t, n) {
2160
2160
  value: e.theme[t]
2161
2161
  } : void 0;
2162
2162
  return {
2163
- stylesheets: r.filter((e) => !Ae(e)),
2164
- files: r.filter(Ae).map((e) => ({
2163
+ stylesheets: r.filter((e) => !ke(e)),
2164
+ files: r.filter(ke).map((e) => ({
2165
2165
  family: e.family,
2166
2166
  file: e.file,
2167
2167
  ...e.weight !== void 0 && { weight: e.weight },
@@ -2174,45 +2174,45 @@ function zi(e, t, n) {
2174
2174
  families: [...a.values()]
2175
2175
  };
2176
2176
  }
2177
- function Bi(e, t) {
2177
+ function Wi(e, t) {
2178
2178
  let n = e.stylesheets.map((e) => `/* Stylesheet, not fetched by blazon: ${e.replace(/\*\//g, "*%2F")} */`);
2179
2179
  for (let r of e.files) {
2180
- let e = se(r.file);
2180
+ let e = me(r.file);
2181
2181
  if (!e) {
2182
2182
  n.push(`/* ${r.file.replace(/\*\//g, "*%2F")}: not a font file blazon embeds, so no rule */`);
2183
2183
  continue;
2184
2184
  }
2185
2185
  let i = t === void 0 ? r.file : `${t.endsWith("/") ? t : `${t}/`}${r.file.split("/").pop()}`;
2186
- n.push(xe(r, `url("${encodeURI(i).replace(/"/g, "%22")}") format("${e}")`, !0));
2186
+ n.push(Le(r, `url("${encodeURI(i).replace(/"/g, "%22")}") format("${e}")`, !0));
2187
2187
  }
2188
2188
  return n.length === 0 ? "/* The config lists no fonts. */\n" : `${n.join("\n\n")}\n`;
2189
2189
  }
2190
2190
  // src/core/read/logo.ts
2191
- function Vi(e, t, n) {
2192
- let r = s(t), i = A.resolve(n, t.assetsDir), a = y(t.assets, n), o = (e) => A.relative(n, p(e, i, a)).split(A.sep).join("/"), c = ["onLight", "onDark"].flatMap((t) => {
2193
- let n = r[t];
2191
+ function Gi(e, t, n) {
2192
+ let i = ee(t), a = O.resolve(n, t.assetsDir), o = ne(t.assets, n), s = (e) => O.relative(n, r(e, a, o)).split(O.sep).join("/"), c = ["onLight", "onDark"].flatMap((t) => {
2193
+ let n = i[t];
2194
2194
  if (!n) return [];
2195
- let i = t === "onLight" ? e.logo?.onLightAsset : e.logo?.onDarkAsset, a = t === "onLight" ? e.logo?.onLightInk : e.logo?.onDarkInk;
2195
+ let r = t === "onLight" ? e.logo?.onLightAsset : e.logo?.onDarkAsset, a = t === "onLight" ? e.logo?.onLightInk : e.logo?.onDarkInk;
2196
2196
  return [{
2197
2197
  variant: t,
2198
2198
  file: n,
2199
2199
  found: !!(t === "onLight" ? e.logo?.onLight : e.logo?.onDark),
2200
- ...i && { asset: i },
2200
+ ...r && { asset: r },
2201
2201
  ...a && { ink: a }
2202
2202
  }];
2203
2203
  });
2204
2204
  return {
2205
2205
  variants: c,
2206
2206
  assets: e.assets.logos.map((e) => {
2207
- let t = p(e, i, a);
2207
+ let t = r(e, a, o);
2208
2208
  return {
2209
2209
  id: e.id,
2210
- file: o(e),
2211
- variants: c.filter((e) => r[e.variant] ? d(A.resolve(n, r[e.variant]), t) : !1).map((e) => e.variant),
2210
+ file: s(e),
2211
+ variants: c.filter((e) => i[e.variant] ? Ze(O.resolve(n, i[e.variant]), t) : !1).map((e) => e.variant),
2212
2212
  rules: e.meta ?? {}
2213
2213
  };
2214
2214
  }),
2215
- forbidden: Si(e, "").flatMap((e) => e.logo ? [{
2215
+ forbidden: Ei(e, "").flatMap((e) => e.logo ? [{
2216
2216
  at: e.at,
2217
2217
  deny: e.logo.deny,
2218
2218
  ...e.logo.reason && { reason: e.logo.reason }
@@ -2220,33 +2220,33 @@ function Vi(e, t, n) {
2220
2220
  };
2221
2221
  }
2222
2222
  // src/cli/read.ts
2223
- async function Y(e) {
2224
- let t = await B(e), r = await D(t, e), { errors: i } = k(r.findings);
2225
- return i.length > 0 && console.error(n.yellow(`blazon: this brand has ${i.length} error(s), so a value below may be wrong; run blazon check.`)), {
2223
+ async function J(e) {
2224
+ let t = await R(e), n = await D(t, e), { errors: r } = c(n.findings);
2225
+ return r.length > 0 && console.error(l.yellow(`blazon: this brand has ${r.length} error(s), so a value below may be wrong; run blazon check.`)), {
2226
2226
  config: t,
2227
- data: r
2227
+ data: n
2228
2228
  };
2229
2229
  }
2230
- function Hi(e) {
2230
+ function Ki(e) {
2231
2231
  try {
2232
2232
  return e();
2233
2233
  } catch (e) {
2234
- throw e instanceof q ? new P(e.message, void 0, "unknown-token") : e;
2234
+ throw e instanceof K ? new M(e.message, void 0, "unknown-token") : e;
2235
2235
  }
2236
2236
  }
2237
- function Ui(e, t, n) {
2237
+ function Y(e, t, n) {
2238
2238
  process.stdout.write(`${JSON.stringify({
2239
2239
  command: e,
2240
2240
  passed: t,
2241
2241
  ...n
2242
2242
  }, null, 2)}\n`);
2243
2243
  }
2244
- function Wi(e, t = " ") {
2245
- let r = e.filter((e) => e[1] !== void 0), i = Math.max(0, ...r.map(([e]) => e.length));
2246
- for (let [e, a] of r) console.log(`${t}${n.dim(e.padEnd(i))} ${a}`);
2244
+ function qi(e, t = " ") {
2245
+ let n = e.filter((e) => e[1] !== void 0), r = Math.max(0, ...n.map(([e]) => e.length));
2246
+ for (let [e, i] of n) console.log(`${t}${l.dim(e.padEnd(r))} ${i}`);
2247
2247
  }
2248
2248
  // src/cli/commands/doctor.ts
2249
- var Gi = [
2249
+ var Ji = [
2250
2250
  "blazon.brand-deck",
2251
2251
  "blazon.favicons",
2252
2252
  "blazon.logo-geometry",
@@ -2254,36 +2254,36 @@ var Gi = [
2254
2254
  "blazon.press-kit",
2255
2255
  "blazon.print-book",
2256
2256
  "blazon.social-cards"
2257
- ], Ki = (e) => {
2257
+ ], Yi = (e) => {
2258
2258
  try {
2259
- return j.accessSync(e, j.constants.X_OK), j.statSync(e).isFile();
2259
+ return k.accessSync(e, k.constants.X_OK), k.statSync(e).isFile();
2260
2260
  } catch {
2261
2261
  return !1;
2262
2262
  }
2263
2263
  };
2264
- function qi(e = process.env) {
2265
- if (e.BLAZON_CHROME) return Ki(e.BLAZON_CHROME);
2264
+ function Xi(e = process.env) {
2265
+ if (e.BLAZON_CHROME) return Yi(e.BLAZON_CHROME);
2266
2266
  let t = [];
2267
2267
  if (process.platform === "darwin") t.push("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
2268
2268
  else if (process.platform === "win32") for (let n of [
2269
2269
  e.PROGRAMFILES,
2270
2270
  e["PROGRAMFILES(X86)"],
2271
2271
  e.LOCALAPPDATA
2272
- ]) n && t.push(A.join(n, "Google", "Chrome", "Application", "chrome.exe"));
2273
- else t.push("/opt/google/chrome/chrome", ...(e.PATH ?? "").split(A.delimiter).filter(Boolean).flatMap((e) => ["google-chrome", "google-chrome-stable"].map((t) => A.join(e, t))));
2274
- return t.some(Ki);
2272
+ ]) n && t.push(O.join(n, "Google", "Chrome", "Application", "chrome.exe"));
2273
+ 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))));
2274
+ return t.some(Yi);
2275
2275
  }
2276
- var Ji = () => {
2277
- let e = JSON.parse(j.readFileSync(A.join(Te(), "package.json"), "utf-8"));
2276
+ var Zi = () => {
2277
+ let e = JSON.parse(k.readFileSync(O.join(ve(), "package.json"), "utf-8"));
2278
2278
  return {
2279
2279
  nodeVersion: process.version,
2280
2280
  engine: e.engines?.node,
2281
- hostProblem: (e) => ee(e, { final: "dir" }),
2282
- chrome: () => qi(),
2283
- identity: Oe()
2281
+ hostProblem: (e) => Fe(e, { final: "dir" }),
2282
+ chrome: () => Xi(),
2283
+ identity: ce()
2284
2284
  };
2285
2285
  };
2286
- function Yi(e, t) {
2286
+ function Qi(e, t) {
2287
2287
  let n = /^>=\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?$/.exec(t.trim()), r = /^v?(\d+)\.(\d+)\.(\d+)/.exec(e);
2288
2288
  if (!n || !r) return;
2289
2289
  let i = [
@@ -2298,14 +2298,14 @@ function Yi(e, t) {
2298
2298
  for (let e = 0; e < 3; e++) if (a[e] !== i[e]) return a[e] > i[e];
2299
2299
  return !0;
2300
2300
  }
2301
- function Xi(e) {
2301
+ function $i(e) {
2302
2302
  if (!e.engine) return {
2303
2303
  id: "node",
2304
2304
  status: "warn",
2305
2305
  message: `Node ${e.nodeVersion}; blazon's package.json names no engines range to compare`,
2306
2306
  fix: "Reinstall blazon."
2307
2307
  };
2308
- let t = Yi(e.nodeVersion, e.engine);
2308
+ let t = Qi(e.nodeVersion, e.engine);
2309
2309
  return t === void 0 ? {
2310
2310
  id: "node",
2311
2311
  status: "warn",
@@ -2322,9 +2322,9 @@ function Xi(e) {
2322
2322
  fix: `Install Node ${e.engine.replace(/^>=\s*/, "")} or newer, such as with nvm install ${e.engine.replace(/^>=\s*v?(\d+).*$/, "$1")}.`
2323
2323
  };
2324
2324
  }
2325
- async function Zi(e) {
2325
+ async function ea(e) {
2326
2326
  try {
2327
- let t = await B(e);
2327
+ let t = await R(e);
2328
2328
  return {
2329
2329
  check: {
2330
2330
  id: "brand",
@@ -2338,18 +2338,18 @@ async function Zi(e) {
2338
2338
  id: "brand",
2339
2339
  status: "fail",
2340
2340
  message: e instanceof Error ? e.message : String(e),
2341
- fix: e instanceof N && e.fix ? e.fix : "Fix the error in blazon.json, then run blazon doctor again."
2341
+ fix: e instanceof j && e.fix ? e.fix : "Fix the error in blazon.json, then run blazon doctor again."
2342
2342
  } };
2343
2343
  }
2344
2344
  }
2345
- function Qi(e, t, n) {
2345
+ function ta(e, t, n) {
2346
2346
  let r = t.hostProblem(e);
2347
2347
  if (!r) return {
2348
2348
  id: "plugin-host",
2349
2349
  status: "ok",
2350
2350
  message: `${e} is a folder blazon will run plugins from`
2351
2351
  };
2352
- let i = /written by group or others/.test(r) ? Ve(e) : "Run blazon from a folder under your own home folder that only you can write.";
2352
+ let i = /written by group or others/.test(r) ? qe(e) : "Run blazon from a folder under your own home folder that only you can write.";
2353
2353
  return {
2354
2354
  id: "plugin-host",
2355
2355
  status: n > 0 ? "fail" : "warn",
@@ -2357,8 +2357,8 @@ function Qi(e, t, n) {
2357
2357
  fix: i
2358
2358
  };
2359
2359
  }
2360
- function $i(e, t) {
2361
- let n = [...new Set((t?.plugins ?? []).map((e) => e.name).filter((e) => Gi.includes(e)))];
2360
+ function na(e, t) {
2361
+ let n = [...new Set((t?.plugins ?? []).map((e) => e.name).filter((e) => Ji.includes(e)))];
2362
2362
  return n.length === 0 ? {
2363
2363
  id: "chrome",
2364
2364
  status: "ok",
@@ -2374,53 +2374,53 @@ function $i(e, t) {
2374
2374
  fix: "Install Google Chrome, or set BLAZON_CHROME to a Chrome or Chromium program; or take the plugin out of blazon.json."
2375
2375
  };
2376
2376
  }
2377
- function ea(e, t) {
2378
- if (!j.existsSync(A.join(e, "blazon.lock"))) return {
2377
+ function ra(e, t) {
2378
+ if (!k.existsSync(O.join(e, "blazon.lock"))) return {
2379
2379
  id: "lock",
2380
2380
  status: "ok",
2381
2381
  message: "no blazon.lock: this book is not pinned to a blazon build"
2382
2382
  };
2383
- let n = ye(e, t.identity)[0];
2383
+ let n = We(e, t.identity)[0];
2384
2384
  return n ? {
2385
2385
  id: "lock",
2386
2386
  status: "fail",
2387
2387
  message: n.message,
2388
- fix: n.fix ?? De[n.code].fix
2388
+ fix: n.fix ?? se[n.code].fix
2389
2389
  } : {
2390
2390
  id: "lock",
2391
2391
  status: "ok",
2392
2392
  message: "blazon.lock matches the blazon that is running"
2393
2393
  };
2394
2394
  }
2395
- async function ta(e, t = Ji()) {
2396
- let n = await Zi(e);
2395
+ async function ia(e, t = Zi()) {
2396
+ let n = await ea(e);
2397
2397
  return [
2398
- Xi(t),
2398
+ $i(t),
2399
2399
  n.check,
2400
- Qi(e, t, n.config?.plugins?.length ?? 0),
2401
- $i(t, n.config),
2402
- ea(e, t)
2400
+ ta(e, t, n.config?.plugins?.length ?? 0),
2401
+ na(t, n.config),
2402
+ ra(e, t)
2403
2403
  ];
2404
2404
  }
2405
- var na = {
2406
- ok: n.green,
2407
- warn: n.yellow,
2408
- fail: n.red
2405
+ var aa = {
2406
+ ok: l.green,
2407
+ warn: l.yellow,
2408
+ fail: l.red
2409
2409
  };
2410
- async function ra(e = process.cwd(), t = {}) {
2411
- let r = await ta(e), i = !r.some((e) => e.status === "fail");
2412
- if (t.json) return Ui("doctor", i, { checks: r }), +!i;
2410
+ async function oa(e = process.cwd(), t = {}) {
2411
+ let n = await ia(e), r = !n.some((e) => e.status === "fail");
2412
+ if (t.json) return Y("doctor", r, { checks: n }), +!r;
2413
2413
  console.log();
2414
- for (let e of r) console.log(` ${na[e.status](e.status.padEnd(4))} ${e.id.padEnd(11)} ${e.message}`), e.status !== "ok" && e.fix && console.log(n.dim(` fix: ${e.fix}`));
2415
- return console.log(), +!i;
2414
+ for (let e of n) console.log(` ${aa[e.status](e.status.padEnd(4))} ${e.id.padEnd(11)} ${e.message}`), e.status !== "ok" && e.fix && console.log(l.dim(` fix: ${e.fix}`));
2415
+ return console.log(), +!r;
2416
2416
  }
2417
2417
  // src/core/operations/limits.ts
2418
- var ia = 4e4, X = {
2418
+ var sa = 4e4, X = {
2419
2419
  readOnlyHint: !0,
2420
2420
  destructiveHint: !1,
2421
2421
  idempotentHint: !0,
2422
2422
  openWorldHint: !1
2423
- }, aa = {
2423
+ }, ca = {
2424
2424
  type: "string",
2425
2425
  description: "The brand folder. Default: the current folder"
2426
2426
  }, Z = (e, t) => ({
@@ -2428,7 +2428,7 @@ var ia = 4e4, X = {
2428
2428
  properties: e,
2429
2429
  ...t.length > 0 && { required: t },
2430
2430
  additionalProperties: !1
2431
- }), oa = {
2431
+ }), la = {
2432
2432
  warnings: {
2433
2433
  type: "array",
2434
2434
  items: { type: "string" },
@@ -2449,7 +2449,7 @@ var ia = 4e4, X = {
2449
2449
  }, Q = (e, t) => ({
2450
2450
  type: "object",
2451
2451
  properties: {
2452
- ...oa,
2452
+ ...la,
2453
2453
  ...e
2454
2454
  },
2455
2455
  required: [
@@ -2458,11 +2458,11 @@ var ia = 4e4, X = {
2458
2458
  ...t
2459
2459
  ],
2460
2460
  additionalProperties: {}
2461
- }), sa = [
2461
+ }), ua = [
2462
2462
  {
2463
2463
  name: "check_brand",
2464
2464
  title: "Check the brand",
2465
- description: "Runs blazon check on the brand, without plugins, and returns its findings and counts. `passed` is false when the brand has errors, and values read from such a brand can be wrong. Returns at most `limit` findings (default 50, at most 500); `counts` stay whole. Not for reading a value: use get_token.",
2465
+ description: "Runs blazon check on the brand, without plugins, and returns its findings and counts. Plugins in blazon.json do not run, so the counts can be lower than `blazon check` prints; `pluginsSkipped` and `warnings` name them. `passed` is false when the brand has errors, and values read from such a brand can be wrong. Returns at most `limit` findings (default 50, at most 500); `counts` stay whole. Not for reading a value: use get_token.",
2466
2466
  annotations: X,
2467
2467
  inputSchema: Z({
2468
2468
  severity: {
@@ -2541,6 +2541,11 @@ var ia = 4e4, X = {
2541
2541
  findingsTotal: {
2542
2542
  description: "How many findings there are before `limit` cut the list",
2543
2543
  type: "number"
2544
+ },
2545
+ pluginsSkipped: {
2546
+ type: "array",
2547
+ items: { type: "string" },
2548
+ description: "The plugins blazon.json lists, which did not run because the server never starts a plugin, so `blazon check` can report more findings than `counts`. Absent when the config lists none"
2544
2549
  }
2545
2550
  }, [
2546
2551
  "passed",
@@ -2559,7 +2564,7 @@ var ia = 4e4, X = {
2559
2564
  {
2560
2565
  name: "list_tokens",
2561
2566
  title: "List the tokens",
2562
- description: `Lists the design tokens of the brand, or of one group, or of one type, each with its path, type and value, in the order the token files write them. Use it to find a path or to read many values at once. For a token's CSS variable names and rules use get_token; for the brand's usage rules use get_rules. An answer over ${ia} characters is cut to whole tokens, and \`tokensTotal\` says how many matched: narrow with \`group\` or \`type\`.`,
2567
+ description: `Lists the design tokens of the brand, or of one group, or of one type, each with its path, type and value, in the order the token files write them. Use it to find a path or to read many values at once. For a token's CSS variable names and rules use get_token; for the brand's usage rules use get_rules. An answer over ${sa} characters is cut to whole tokens, and \`tokensTotal\` says how many matched: narrow with \`group\` or \`type\`.`,
2563
2568
  annotations: X,
2564
2569
  inputSchema: Z({
2565
2570
  group: {
@@ -2683,7 +2688,7 @@ var ia = 4e4, X = {
2683
2688
  {
2684
2689
  name: "get_rules",
2685
2690
  title: "Read the brand rules",
2686
- 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 (${ia} characters): give a path, or read the resource blazon://rules, which is not cut.`,
2691
+ 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 (${sa} characters): give a path, or read the resource blazon://rules, which is not cut.`,
2687
2692
  annotations: X,
2688
2693
  inputSchema: Z({
2689
2694
  path: {
@@ -2931,7 +2936,7 @@ var ia = 4e4, X = {
2931
2936
  type: "string",
2932
2937
  description: "Only this part of the document, by its dotted path, such as theme.roles"
2933
2938
  },
2934
- dir: aa
2939
+ dir: ca
2935
2940
  }, []),
2936
2941
  cli: {
2937
2942
  rank: 7,
@@ -2947,10 +2952,10 @@ var ia = 4e4, X = {
2947
2952
  },
2948
2953
  mcp: !1
2949
2954
  }
2950
- ], ca = (e) => e.filter((e) => e.mcp !== !1), la = (e) => e.filter((e) => e.cli !== !1).sort((e, t) => e.cli.rank - t.cli.rank);
2955
+ ], da = (e) => e.filter((e) => e.mcp !== !1), fa = (e) => e.filter((e) => e.cli !== !1).sort((e, t) => e.cli.rank - t.cli.rank);
2951
2956
  // src/cli/handlers/rules.ts
2952
- function ua(e) {
2953
- let t = (e) => n.dim(`(on ${e})`);
2957
+ function pa(e) {
2958
+ let t = (e) => l.dim(`(on ${e})`);
2954
2959
  return [
2955
2960
  ...e.role ? [`role ${e.role.value} ${t(e.role.from)}`] : [],
2956
2961
  ...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)}`] : [],
@@ -2959,7 +2964,7 @@ function ua(e) {
2959
2964
  ...e.review ? [`review ${e.review.status}${e.review.by ? ` by ${e.review.by}` : ""}${e.review.at ? ` on ${e.review.at}` : ""} ${t(e.review.from)}`] : []
2960
2965
  ];
2961
2966
  }
2962
- function da(e) {
2967
+ function ma(e) {
2963
2968
  return [
2964
2969
  ...e.role ? [`role ${e.role}`] : [],
2965
2970
  ...e.usage ? [`usage ${[e.usage.deny && `deny ${e.usage.deny.join(", ")}`, e.usage.allow && `allow ${e.usage.allow.join(", ")}`].filter(Boolean).join("; ")}`] : [],
@@ -2967,51 +2972,51 @@ function da(e) {
2967
2972
  ...e.logo ? [`logo deny ${e.logo.deny.join(", ")}${e.logo.reason ? `: ${e.logo.reason}` : ""}`] : []
2968
2973
  ];
2969
2974
  }
2970
- var fa = async ({ path: e }, { dir: t }) => {
2971
- let { data: r } = await Y(t), i = di(e ?? ""), a = i !== "" && r.tokens.byPath.has(i), o = Hi(() => a ? {
2972
- path: i,
2975
+ var ha = async ({ path: e }, { dir: t }) => {
2976
+ let { data: n } = await J(t), r = hi(e ?? ""), i = r !== "" && n.tokens.byPath.has(r), a = Ki(() => i ? {
2977
+ path: r,
2973
2978
  kind: "token",
2974
- rules: bi(r, fi(r, i))
2979
+ rules: wi(n, gi(n, r))
2975
2980
  } : {
2976
- path: i,
2977
- kind: i === "" ? "brand" : "group",
2978
- entries: Si(r, i)
2981
+ path: r,
2982
+ kind: r === "" ? "brand" : "group",
2983
+ entries: Ei(n, r)
2979
2984
  });
2980
2985
  return {
2981
2986
  command: "rules",
2982
2987
  passed: !0,
2983
2988
  status: 0,
2984
- body: o,
2989
+ body: a,
2985
2990
  text: () => {
2986
- if (console.log(), o.kind === "token") {
2987
- let e = ua(o.rules);
2988
- console.log(` ${n.bold(o.path)}`), e.length === 0 && console.log(n.dim(" no rules apply to this token"));
2991
+ if (console.log(), a.kind === "token") {
2992
+ let e = pa(a.rules);
2993
+ console.log(` ${l.bold(a.path)}`), e.length === 0 && console.log(l.dim(" no rules apply to this token"));
2989
2994
  for (let t of e) console.log(` ${t}`);
2990
2995
  } else {
2991
- o.entries.length === 0 && console.log(n.dim(` No rules are written ${i === "" ? "in this brand" : `at or under ${i}`}.`));
2992
- for (let e of o.entries) {
2993
- console.log(` ${n.bold(e.at)} ${n.dim(e.kind === "group" ? "group" : "token")}${e.inherited ? n.dim(", passes its rules down") : ""}`);
2994
- for (let t of da(e)) console.log(` ${t}`);
2996
+ a.entries.length === 0 && console.log(l.dim(` No rules are written ${r === "" ? "in this brand" : `at or under ${r}`}.`));
2997
+ for (let e of a.entries) {
2998
+ console.log(` ${l.bold(e.at)} ${l.dim(e.kind === "group" ? "group" : "token")}${e.inherited ? l.dim(", passes its rules down") : ""}`);
2999
+ for (let t of ma(e)) console.log(` ${t}`);
2995
3000
  }
2996
3001
  }
2997
3002
  console.log();
2998
3003
  }
2999
3004
  };
3000
- }, pa = async ({ path: e }, { dir: t }) => {
3001
- let { data: n } = await Y(t);
3002
- if (Ei(n, String(e))) throw new P(`"${String(e)}" is a group of tokens, not one token; \`blazon list ${String(e)}\` lists its tokens.`, void 0, "not-a-token");
3003
- let r = Hi(() => wi(n, String(e)));
3005
+ }, ga = async ({ path: e }, { dir: t }) => {
3006
+ let { data: n } = await J(t);
3007
+ if (Ai(n, 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");
3008
+ let r = Ki(() => Oi(n, String(e)));
3004
3009
  return {
3005
3010
  command: "get",
3006
3011
  passed: !0,
3007
3012
  status: 0,
3008
3013
  body: { token: r },
3009
- text: () => ma(r)
3014
+ text: () => _a(r)
3010
3015
  };
3011
3016
  };
3012
- function ma(e) {
3017
+ function _a(e) {
3013
3018
  let { names: t } = e;
3014
- console.log(`\n ${n.bold(e.path)}${e.deprecated ? n.yellow(" deprecated") : ""}`), Wi([
3019
+ console.log(`\n ${l.bold(e.path)}${e.deprecated ? l.yellow(" deprecated") : ""}`), qi([
3015
3020
  ["value", String(e.value)],
3016
3021
  ["type", e.type],
3017
3022
  ["alias of", e.aliasOf && `{${e.aliasOf}}`],
@@ -3021,15 +3026,15 @@ function ma(e) {
3021
3026
  ["typography.css", t.typographyClass && `.${t.typographyClass}`],
3022
3027
  ["written in", e.sourceFile]
3023
3028
  ]);
3024
- for (let t of e.contexts ?? []) console.log(` ${n.dim(`${t.modifier}=${t.context}`.padEnd(12))} ${String(t.value)} ${n.dim(t.selector)}`);
3025
- let r = ua(e.rules);
3026
- console.log(`\n ${n.bold("Rules")}`), r.length === 0 && console.log(n.dim(" none written for this token"));
3027
- for (let e of r) console.log(` ${e}`);
3029
+ for (let t of e.contexts ?? []) console.log(` ${l.dim(`${t.modifier}=${t.context}`.padEnd(12))} ${String(t.value)} ${l.dim(t.selector)}`);
3030
+ let n = pa(e.rules);
3031
+ console.log(`\n ${l.bold("Rules")}`), n.length === 0 && console.log(l.dim(" none written for this token"));
3032
+ for (let e of n) console.log(` ${e}`);
3028
3033
  console.log();
3029
3034
  }
3030
3035
  // src/cli/handlers/list.ts
3031
- var ha = async ({ group: e, type: t }, { dir: n }) => {
3032
- let { data: r } = await Y(n), i = Hi(() => Di(r, {
3036
+ var va = async ({ group: e, type: t }, { dir: n }) => {
3037
+ let { data: r } = await J(n), i = Ki(() => ji(r, {
3033
3038
  group: e,
3034
3039
  type: t
3035
3040
  }));
@@ -3042,44 +3047,44 @@ var ha = async ({ group: e, type: t }, { dir: n }) => {
3042
3047
  ...i.type && { type: i.type },
3043
3048
  tokens: i.tokens
3044
3049
  },
3045
- text: () => ga(i)
3050
+ text: () => ya(i)
3046
3051
  };
3047
3052
  };
3048
- function ga(e) {
3049
- if (e.tokens.length === 0) return console.log(n.dim(`\n no tokens${e.type ? ` of type ${e.type}` : ""}${e.group ? ` in ${e.group}` : ""}\n`));
3050
- let t = Math.max(...e.tokens.map((e) => e.path.length)), r = Math.max(...e.tokens.map((e) => (e.type ?? "").length)), i;
3051
- for (let a of e.tokens) {
3052
- let e = a.path.split(".")[0];
3053
- e !== i && console.log(`\n ${n.dim(e)}`), i = e;
3054
- let o = a.aliasOf ? ` ${n.dim(`-> ${a.aliasOf}`)}` : "";
3055
- console.log(` ${a.path.padEnd(t)} ${n.dim((a.type ?? "").padEnd(r))} ${String(a.value)}${o}`);
3053
+ function ya(e) {
3054
+ if (e.tokens.length === 0) return console.log(l.dim(`\n no tokens${e.type ? ` of type ${e.type}` : ""}${e.group ? ` in ${e.group}` : ""}\n`));
3055
+ let t = Math.max(...e.tokens.map((e) => e.path.length)), n = Math.max(...e.tokens.map((e) => (e.type ?? "").length)), r;
3056
+ for (let i of e.tokens) {
3057
+ let e = i.path.split(".")[0];
3058
+ e !== r && console.log(`\n ${l.dim(e)}`), r = e;
3059
+ let a = i.aliasOf ? ` ${l.dim(`-> ${i.aliasOf}`)}` : "";
3060
+ console.log(` ${i.path.padEnd(t)} ${l.dim((i.type ?? "").padEnd(n))} ${String(i.value)}${a}`);
3056
3061
  }
3057
- console.log(`\n ${n.dim(`${e.tokens.length} token${e.tokens.length === 1 ? "" : "s"}; blazon get <path> shows one in full`)}\n`);
3062
+ console.log(`\n ${l.dim(`${e.tokens.length} token${e.tokens.length === 1 ? "" : "s"}; blazon get <path> shows one in full`)}\n`);
3058
3063
  }
3059
3064
  // src/cli/handlers/can.ts
3060
- var _a = async ({ fg: e, bg: t, role: n, theme: r }, { dir: i }) => {
3061
- let { data: a } = await Y(i), o = Hi(() => Ri(a, e, t, n ?? "text", r));
3065
+ var ba = async ({ fg: e, bg: t, role: n, theme: r }, { dir: i }) => {
3066
+ let { data: a } = await J(i), o = Ki(() => Hi(a, e, t, n ?? "text", r));
3062
3067
  return {
3063
3068
  command: "can",
3064
3069
  passed: o.allowed,
3065
3070
  status: +!o.allowed,
3066
3071
  body: o,
3067
- text: () => va(o)
3072
+ text: () => xa(o)
3068
3073
  };
3069
3074
  };
3070
- function va(e) {
3071
- if (console.log(`\n ${e.allowed ? n.green("allowed") : n.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.length > 1) {
3075
+ function xa(e) {
3076
+ if (console.log(`\n ${e.allowed ? l.green("allowed") : l.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.length > 1) {
3072
3077
  console.log();
3073
- for (let t of e.checks) console.log(` ${t.rule === "contrast" && e.role === "text" ? n.dim("info") : t.ok ? n.green("ok ") : n.red("no ")} ${t.message}`);
3078
+ for (let t of e.checks) console.log(` ${t.rule === "contrast" && e.role === "text" ? l.dim("info") : t.ok ? l.green("ok ") : l.red("no ")} ${t.message}`);
3074
3079
  }
3075
3080
  console.log();
3076
3081
  }
3077
3082
  // src/cli/handlers/fonts.ts
3078
- var ya = async (e, { dir: t }) => {
3079
- let { config: n, data: r } = await Y(t), i = zi(r, n, t);
3083
+ var Sa = async (e, { dir: t }) => {
3084
+ let { config: n, data: r } = await J(t), i = Ui(r, n, t);
3080
3085
  if (e.css === !0 || typeof e.base == "string") {
3081
- if (e.css !== !0) throw new P("blazon fonts: --base goes with --css.", "Add --css, or leave --base out.", "conflicting-options");
3082
- let t = Bi(i, typeof e.base == "string" ? e.base : void 0);
3086
+ if (e.css !== !0) throw new M("blazon fonts: --base goes with --css.", "Add --css, or leave --base out.", "conflicting-options");
3087
+ let t = Wi(i, typeof e.base == "string" ? e.base : void 0);
3083
3088
  return {
3084
3089
  command: "fonts",
3085
3090
  passed: !0,
@@ -3096,18 +3101,18 @@ var ya = async (e, { dir: t }) => {
3096
3101
  passed: !0,
3097
3102
  status: 0,
3098
3103
  body: i,
3099
- text: () => ba(i)
3104
+ text: () => Ca(i)
3100
3105
  };
3101
3106
  };
3102
- function ba(e) {
3103
- console.log(`\n ${n.bold("Loaded")}`), e.stylesheets.length + e.files.length === 0 && console.log(n.dim(" The config lists no fonts."));
3107
+ function Ca(e) {
3108
+ console.log(`\n ${l.bold("Loaded")}`), e.stylesheets.length + e.files.length === 0 && console.log(l.dim(" The config lists no fonts."));
3104
3109
  for (let t of e.stylesheets) console.log(` stylesheet ${t}`);
3105
3110
  for (let t of e.files) console.log(` file ${t.file} ${t.family}${t.weight === void 0 ? "" : `, weight ${t.weight}`}${t.style ? `, ${t.style}` : ""}`);
3106
- console.log(`\n ${n.bold("Named by the tokens")}`);
3107
- for (let [t, r] of Object.entries(e.roles)) console.log(` ${n.dim(t.padEnd(11))} ${r.token ?? ""} ${r.value ?? ""}`);
3111
+ console.log(`\n ${l.bold("Named by the tokens")}`);
3112
+ for (let [t, n] of Object.entries(e.roles)) console.log(` ${l.dim(t.padEnd(11))} ${n.token ?? ""} ${n.value ?? ""}`);
3108
3113
  for (let t of e.families) {
3109
3114
  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";
3110
- console.log(` ${t.family} ${n.dim(`${e}; ${t.tokens.join(", ")}`)}`), t.stack && t.stack.length > 1 && console.log(n.dim(` stack: ${t.stack.join(", ")}`));
3115
+ console.log(` ${t.family} ${l.dim(`${e}; ${t.tokens.join(", ")}`)}`), t.stack && t.stack.length > 1 && console.log(l.dim(` stack: ${t.stack.join(", ")}`));
3111
3116
  }
3112
3117
  console.log();
3113
3118
  }
@@ -3116,23 +3121,23 @@ var $ = (e) => {
3116
3121
  if (typeof e != "object" || !e) return String(e);
3117
3122
  let t = e;
3118
3123
  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"}`;
3119
- }, xa = async (e, { dir: t }) => {
3120
- let { config: n, data: r } = await Y(t), i = Vi(r, n, t);
3124
+ }, wa = async (e, { dir: t }) => {
3125
+ let { config: n, data: r } = await J(t), i = Gi(r, n, t);
3121
3126
  return {
3122
3127
  command: "logo",
3123
3128
  passed: !0,
3124
3129
  status: 0,
3125
3130
  body: i,
3126
- text: () => Sa(i)
3131
+ text: () => Ta(i)
3127
3132
  };
3128
3133
  };
3129
- function Sa(e) {
3130
- console.log(`\n ${n.bold("Variants")}`), e.variants.length === 0 && console.log(n.dim(" No logo is configured."));
3131
- for (let t of e.variants) console.log(` ${t.variant.padEnd(8)} ${t.file}${t.found ? "" : n.red(" (not found)")}${t.ink ? ` ink ${t.ink}` : ""}${t.asset ? n.dim(` ${t.asset}`) : ""}`);
3134
+ function Ta(e) {
3135
+ console.log(`\n ${l.bold("Variants")}`), e.variants.length === 0 && console.log(l.dim(" No logo is configured."));
3136
+ for (let t of e.variants) console.log(` ${t.variant.padEnd(8)} ${t.file}${t.found ? "" : l.red(" (not found)")}${t.ink ? ` ink ${t.ink}` : ""}${t.asset ? l.dim(` ${t.asset}`) : ""}`);
3132
3137
  for (let t of e.assets) {
3133
3138
  let e = t.rules;
3134
- console.log(`\n ${n.bold(t.id)} ${t.file}${t.variants.length ? n.dim(` used as ${t.variants.join(", ")}`) : ""}`);
3135
- let r = [
3139
+ console.log(`\n ${l.bold(t.id)} ${t.file}${t.variants.length ? l.dim(` used as ${t.variants.join(", ")}`) : ""}`);
3140
+ let n = [
3136
3141
  ["lockup", e.lockup],
3137
3142
  ["ink", e.ink],
3138
3143
  ["background", e.background],
@@ -3145,18 +3150,18 @@ function Sa(e) {
3145
3150
  ["partnership", e.partnership && `gap ${$(e.partnership.gap)}${e.partnership.dividerHeight ? `, divider ${$(e.partnership.dividerHeight)}` : ""}`],
3146
3151
  ["initiative", e.initiative && `${e.initiative.name}, mark ${e.initiative.mark}, gap ${$(e.initiative.gap)}, ${e.initiative.position ?? "beside"}`]
3147
3152
  ];
3148
- for (let [e, t] of r) t !== void 0 && console.log(` ${n.dim(e.padEnd(12))} ${t}`);
3149
- for (let t of e.do ?? []) console.log(` ${n.dim("do")} ${t}`);
3150
- for (let t of e.dont ?? []) console.log(` ${n.dim("do not")} ${t}`);
3153
+ for (let [e, t] of n) t !== void 0 && console.log(` ${l.dim(e.padEnd(12))} ${t}`);
3154
+ for (let t of e.do ?? []) console.log(` ${l.dim("do")} ${t}`);
3155
+ for (let t of e.dont ?? []) console.log(` ${l.dim("do not")} ${t}`);
3151
3156
  }
3152
3157
  if (e.forbidden.length > 0) {
3153
- console.log(`\n ${n.bold("Forbidden on")}`);
3154
- for (let t of e.forbidden) console.log(` ${t.at} ${t.deny.join(", ")}${t.reason ? ` ${n.dim(t.reason)}` : ""}`);
3158
+ console.log(`\n ${l.bold("Forbidden on")}`);
3159
+ for (let t of e.forbidden) console.log(` ${t.at} ${t.deny.join(", ")}${t.reason ? ` ${l.dim(t.reason)}` : ""}`);
3155
3160
  }
3156
3161
  console.log();
3157
3162
  }
3158
3163
  // src/cli/handlers/brand.ts
3159
- function Ca(e, t) {
3164
+ function Ea(e, t) {
3160
3165
  let n = e;
3161
3166
  for (let e of t.split(".")) {
3162
3167
  if (typeof n != "object" || !n || !Object.prototype.hasOwnProperty.call(n, e)) return;
@@ -3165,16 +3170,16 @@ function Ca(e, t) {
3165
3170
  return n;
3166
3171
  }
3167
3172
  // src/cli/handlers/index.ts
3168
- var wa = {
3169
- get_token: pa,
3170
- list_tokens: ha,
3171
- get_rules: fa,
3172
- can_use: _a,
3173
- get_fonts: ya,
3174
- get_logo: xa,
3173
+ var Da = {
3174
+ get_token: ga,
3175
+ list_tokens: va,
3176
+ get_rules: ha,
3177
+ can_use: ba,
3178
+ get_fonts: Sa,
3179
+ get_logo: wa,
3175
3180
  get_brand: async ({ key: e }, { dir: t }) => {
3176
- let { config: n, data: r } = await Y(t), i = Le(r, n, t), a = e === void 0 ? i : Ca(i, e);
3177
- if (a === void 0) throw new P(`brand.json has no "${String(e)}". Run blazon brand without --key to see the keys.`, void 0, "unknown-key");
3181
+ let { config: n, data: r } = await J(t), i = He(r, n, t), a = e === void 0 ? i : Ea(i, e);
3182
+ 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");
3178
3183
  return {
3179
3184
  command: "brand",
3180
3185
  passed: !0,
@@ -3183,21 +3188,21 @@ var wa = {
3183
3188
  text: () => void process.stdout.write(`${JSON.stringify(a, null, 2)}\n`)
3184
3189
  };
3185
3190
  }
3186
- }, Ta = (e) => e.cli, Ea = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), Da = la(sa).filter((e) => Ta(e).options.some((e) => e.property === "json")).map((e) => Ta(e).command[0]);
3187
- function Oa(e) {
3188
- let t = Ta(e), n = new Set(e.inputSchema.required ?? []);
3191
+ }, Oa = (e) => e.cli, ka = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), Aa = fa(ua).filter((e) => Oa(e).options.some((e) => e.property === "json")).map((e) => Oa(e).command[0]);
3192
+ function ja(e) {
3193
+ let t = Oa(e), n = new Set(e.inputSchema.required ?? []);
3189
3194
  return [...t.command, ...t.positional.map((e) => n.has(e) ? `<${e}>` : `[${e}]`)].join(" ");
3190
3195
  }
3191
- function ka(e, t) {
3192
- return t.property === "json" ? "--json" : e.inputSchema.properties[t.property]?.type === "boolean" ? `--${Ea(t.property)}` : `--${Ea(t.property)} <${t.value ?? Ea(t.property)}>`;
3196
+ function Ma(e, t) {
3197
+ return t.property === "json" ? "--json" : e.inputSchema.properties[t.property]?.type === "boolean" ? `--${ka(t.property)}` : `--${ka(t.property)} <${t.value ?? ka(t.property)}>`;
3193
3198
  }
3194
- var Aa = (e) => typeof e == "string" && /^\.|[\\/]/.test(e) && !!j.statSync(e, { throwIfNoEntry: !1 })?.isDirectory();
3195
- function ja(e, t) {
3196
- for (let n of la(sa)) {
3197
- let r = Ta(n), i = wa[n.name];
3199
+ var Na = (e) => typeof e == "string" && /^\.|[\\/]/.test(e) && !!k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory();
3200
+ function Pa(e, t) {
3201
+ for (let n of fa(ua)) {
3202
+ let r = Oa(n), i = Da[n.name];
3198
3203
  if (!i) throw Error(`operation ${n.name} has a command and no handler`);
3199
- let a = e.command(Oa(n), r.summary);
3200
- for (let e of r.options) a.option(ka(n, e), e.description);
3204
+ let a = e.command(ja(n), r.summary);
3205
+ for (let e of r.options) a.option(Ma(n, e), e.description);
3201
3206
  a.action(async (...e) => {
3202
3207
  let n = e.pop() ?? {};
3203
3208
  try {
@@ -3205,20 +3210,26 @@ function ja(e, t) {
3205
3210
  r.positional.forEach((n, r) => t[n] = e[r]);
3206
3211
  for (let e of r.options) e.property !== "json" && (t[e.property] = n[e.property]);
3207
3212
  let a = t.dir;
3208
- r.folder !== void 0 && a === void 0 && Aa(t[r.folder]) && (a = t[r.folder], t[r.folder] = void 0), delete t.dir;
3213
+ r.folder !== void 0 && a === void 0 && Na(t[r.folder]) && (a = t[r.folder], t[r.folder] = void 0), delete t.dir;
3209
3214
  let o = await i(t, { dir: a ? String(a) : process.cwd() });
3210
- n.json ? Ui(o.command, o.passed, o.body) : o.text(), process.exitCode = o.status;
3215
+ n.json ? Y(o.command, o.passed, o.body) : o.text(), process.exitCode = o.status;
3211
3216
  } catch (e) {
3212
- I(r.command.join(" "), e, t);
3217
+ P(r.command.join(" "), e, t);
3213
3218
  }
3214
3219
  });
3215
3220
  }
3216
3221
  }
3217
3222
  // src/cli/commands/mcp-check.ts
3218
- var Ma = 3e4, Na = "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.", Pa = "npm ci && npm run build -w mcp", Fa = () => ca(sa).map((e) => e.name);
3219
- function Ia(e) {
3220
- let t = A.join(e, "mcp/dist/index.js");
3221
- return j.existsSync(t) ? {
3223
+ var Fa = 3e4, Ia = "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.", La = "npm ci && npm run build -w mcp", Ra = (e) => _e(e) ? `cd ${e} && ${La}` : Oe, za = () => da(ua).map((e) => e.name);
3224
+ function Ba(e) {
3225
+ let t = O.join(e, "mcp/dist/index.js"), n = k.existsSync(t);
3226
+ return !n && !_e(e) ? {
3227
+ name: "built",
3228
+ passed: !1,
3229
+ detail: Ie,
3230
+ fix: Oe,
3231
+ entry: t
3232
+ } : n ? {
3222
3233
  name: "built",
3223
3234
  passed: !0,
3224
3235
  detail: `${t} exists`,
@@ -3227,26 +3238,26 @@ function Ia(e) {
3227
3238
  name: "built",
3228
3239
  passed: !1,
3229
3240
  detail: `${t} does not exist: blazon-mcp is not built`,
3230
- fix: `cd ${e} && ${Pa}`,
3241
+ fix: Ra(e),
3231
3242
  entry: t
3232
3243
  };
3233
3244
  }
3234
- var La = (e) => {
3245
+ var Va = (e) => {
3235
3246
  try {
3236
- return j.statSync(e).isFile() ? (j.accessSync(e, j.constants.X_OK), !0) : !1;
3247
+ return k.statSync(e).isFile() ? (k.accessSync(e, k.constants.X_OK), !0) : !1;
3237
3248
  } catch {
3238
3249
  return !1;
3239
3250
  }
3240
3251
  };
3241
- function Ra(e, t) {
3242
- let n = (t.PATH ?? "").split(A.delimiter).filter(Boolean), r = process.platform === "win32" ? ["", ...(t.PATHEXT ?? ".EXE;.CMD").split(";")].map((t) => e + t) : [e];
3243
- for (let e of n) for (let t of r) if (La(A.join(e, t))) return A.join(e, t);
3252
+ function Ha(e, t) {
3253
+ let n = (t.PATH ?? "").split(O.delimiter).filter(Boolean), r = process.platform === "win32" ? ["", ...(t.PATHEXT ?? ".EXE;.CMD").split(";")].map((t) => e + t) : [e];
3254
+ for (let e of n) for (let t of r) if (Va(O.join(e, t))) return O.join(e, t);
3244
3255
  }
3245
- function za(e, t, n) {
3246
- let r = A.join(n, "bin/blazon.js"), i = j.existsSync(r) ? j.existsSync(A.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;
3256
+ function Ua(e, t, n) {
3257
+ 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;
3247
3258
  if (a) {
3248
- let n = a.includes("/") || a.includes(A.sep) ? A.resolve(t, a) : Ra(a, e);
3249
- return n && La(n) ? {
3259
+ let n = a.includes("/") || a.includes(O.sep) ? O.resolve(t, a) : Ha(a, e);
3260
+ return n && Va(n) ? {
3250
3261
  name: "blazon",
3251
3262
  passed: !0,
3252
3263
  detail: `BLAZON_BIN names ${n}`,
@@ -3260,7 +3271,14 @@ function za(e, t, n) {
3260
3271
  source: "BLAZON_BIN"
3261
3272
  };
3262
3273
  }
3263
- let o = Ra("blazon", e);
3274
+ if (Va(r)) return {
3275
+ name: "blazon",
3276
+ passed: !0,
3277
+ detail: `the server runs this package's own ${r}`,
3278
+ source: "package",
3279
+ path: r
3280
+ };
3281
+ let o = Ha("blazon", e);
3264
3282
  return o ? {
3265
3283
  name: "blazon",
3266
3284
  passed: !0,
@@ -3275,12 +3293,12 @@ function za(e, t, n) {
3275
3293
  source: "none"
3276
3294
  };
3277
3295
  }
3278
- var Ba = (e, t = 200) => {
3296
+ var Wa = (e, t = 200) => {
3279
3297
  let n = e.trim().split("\n").find((e) => e.trim() !== "") ?? "";
3280
3298
  return n.length > t ? `${n.slice(0, t)}...` : n;
3281
3299
  };
3282
- async function Va(e) {
3283
- let { entry: t, brand: n, env: r = process.env, timeoutMs: i = Ma, expect: a = Fa() } = e, o = process.platform !== "win32", s = qe(process.execPath, [
3300
+ async function Ga(e) {
3301
+ let { entry: t, brand: n, env: r = process.env, timeoutMs: i = Fa, expect: a = za() } = e, o = process.platform !== "win32", s = Qe(process.execPath, [
3284
3302
  t,
3285
3303
  "--brand",
3286
3304
  n
@@ -3312,7 +3330,7 @@ async function Va(e) {
3312
3330
  m = setTimeout(() => {
3313
3331
  p = !0, t(/* @__PURE__ */ Error(`no answer within ${i / 1e3} s`));
3314
3332
  }, i);
3315
- }), g = new Promise((e, t) => s.once("close", (e) => t(/* @__PURE__ */ Error(`the server exited (${e ?? "signal"}) before it answered${c ? `: ${Ba(c)}` : ""}`))));
3333
+ }), g = new Promise((e, t) => s.once("close", (e) => t(/* @__PURE__ */ Error(`the server exited (${e ?? "signal"}) before it answered${c ? `: ${Wa(c)}` : ""}`))));
3316
3334
  g.catch(() => void 0), h.catch(() => void 0), u.catch(() => void 0);
3317
3335
  let _ = 0, v = (e, t) => {
3318
3336
  let n = ++_, r = new Promise((e) => d.set(n, e));
@@ -3337,7 +3355,7 @@ async function Va(e) {
3337
3355
  version: "0"
3338
3356
  }
3339
3357
  });
3340
- if (e.error) throw Error(`initialize was refused: ${Ba(e.error.message ?? "")}`);
3358
+ if (e.error) throw Error(`initialize was refused: ${Wa(e.error.message ?? "")}`);
3341
3359
  s.stdin.write(`${JSON.stringify({
3342
3360
  jsonrpc: "2.0",
3343
3361
  method: "notifications/initialized"
@@ -3346,8 +3364,8 @@ async function Va(e) {
3346
3364
  if (t.error || r.length > 0) return {
3347
3365
  name: "handshake",
3348
3366
  passed: !1,
3349
- detail: t.error ? `tools/list failed: ${Ba(t.error.message ?? "")}` : `tools/list answered ${n.length} tool(s); missing ${r.join(", ")}`,
3350
- fix: `cd ${Te()} && ${Pa} (the build is older than this blazon), then run this check again`,
3367
+ detail: t.error ? `tools/list failed: ${Wa(t.error.message ?? "")}` : `tools/list answered ${n.length} tool(s); missing ${r.join(", ")}`,
3368
+ fix: `${Ra(ve())} (the server is older than this blazon), then run this check again`,
3351
3369
  tools: n
3352
3370
  };
3353
3371
  let i = Date.now(), o = await v("tools/call", {
@@ -3357,7 +3375,7 @@ async function Va(e) {
3357
3375
  if (o.error || o.result?.isError) return {
3358
3376
  name: "handshake",
3359
3377
  passed: !1,
3360
- detail: `check_brand failed: ${Ba(o.error?.message ?? l)}`,
3378
+ detail: `check_brand failed: ${Wa(o.error?.message ?? l)}`,
3361
3379
  fix: "run blazon check in the brand folder, and make sure the blazon program and the brand folder are the ones the server uses",
3362
3380
  tools: n,
3363
3381
  ms: c
@@ -3376,14 +3394,14 @@ async function Va(e) {
3376
3394
  name: "handshake",
3377
3395
  passed: !1,
3378
3396
  detail: `the handshake did not finish: ${e instanceof Error ? e.message : String(e)}${p ? "; the server was killed" : ""}`,
3379
- fix: `cd ${Te()} && ${Pa}, then run this check again; on a hang, run the server by hand: node ${t} --brand ${n}`,
3397
+ fix: `${Ra(ve())}, then run this check again; on a hang, run the server by hand: node ${t} --brand ${n}`,
3380
3398
  ms: Date.now() - y
3381
3399
  };
3382
3400
  } finally {
3383
- clearTimeout(m), await Ha(s, l, o);
3401
+ clearTimeout(m), await Ka(s, l, o);
3384
3402
  }
3385
3403
  }
3386
- async function Ha(e, t, n) {
3404
+ async function Ka(e, t, n) {
3387
3405
  let r = (t) => {
3388
3406
  try {
3389
3407
  n && e.pid !== void 0 ? process.kill(-e.pid, t) : e.kill(t);
@@ -3397,16 +3415,16 @@ async function Ha(e, t, n) {
3397
3415
  let i;
3398
3416
  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");
3399
3417
  }
3400
- function Ua(e, t, n, r = Je.homedir()) {
3401
- let i = ze(e, t, r, process.platform, process.env.APPDATA), a = [], o = [], s = [];
3418
+ function qa(e, t, n, r = $e.homedir()) {
3419
+ let i = Ne(e, t, r, process.platform, process.env.APPDATA), a = [], o = [], s = [];
3402
3420
  for (let e of i) {
3403
3421
  let t;
3404
3422
  try {
3405
- t = j.readFileSync(e.path, "utf8");
3423
+ t = k.readFileSync(e.path, "utf8");
3406
3424
  } catch {
3407
3425
  continue;
3408
3426
  }
3409
- let n = de(t, e);
3427
+ let n = Ae(t, e);
3410
3428
  n === void 0 ? s.push(e.path) : (o.push(e.path), n.includes("blazon") && a.push(e.path));
3411
3429
  }
3412
3430
  let c = s.length > 0 ? ` (not valid JSON, skipped: ${s.join(", ")})` : "", l = `blazon mcp --print-config --client ${e} --brand ${n}`;
@@ -3427,70 +3445,79 @@ function Ua(e, t, n, r = Je.homedir()) {
3427
3445
  files: []
3428
3446
  };
3429
3447
  }
3430
- async function Wa(e) {
3431
- let { client: t, brand: r, env: i = process.env, cwd: a = process.cwd(), home: o = Je.homedir() } = e, s = Te(), c = Ia(s), l = za(i, r, s), u = c.passed ? await Va({
3432
- entry: c.entry,
3433
- brand: r,
3434
- env: i,
3448
+ async function Ja(e) {
3449
+ let { client: t, brand: n, env: r = process.env, cwd: i = process.cwd(), home: a = $e.homedir() } = e, o = e.root ?? ve(), s = Ba(o), c = Ua(r, n, o), u = s.passed ? await Ga({
3450
+ entry: s.entry,
3451
+ brand: n,
3452
+ env: r,
3435
3453
  ...e.timeoutMs !== void 0 && { timeoutMs: e.timeoutMs }
3436
3454
  }) : {
3437
3455
  name: "handshake",
3438
3456
  passed: !1,
3439
- detail: "not run: the server is not built",
3440
- fix: c.fix
3441
- }, d = Ua(t, [.../* @__PURE__ */ new Set([a, r])], r, o), { entry: f, ...p } = c, m = [
3457
+ detail: `not run: ${_e(o) ? "the server is not built" : "the install is incomplete"}`,
3458
+ fix: s.fix
3459
+ }, d = qa(t, [.../* @__PURE__ */ new Set([i, n])], n, a), { entry: f, ...p } = s, m = [
3442
3460
  p,
3443
- l,
3461
+ c,
3444
3462
  u,
3445
3463
  d
3446
3464
  ], h = m.filter((e) => !e.advisory).every((e) => e.passed);
3447
- if (e.json) return Ui("mcp", h, {
3465
+ if (e.json) return Y("mcp", h, {
3448
3466
  mode: "check",
3449
3467
  client: t,
3450
- brand: r,
3468
+ brand: n,
3451
3469
  runsPlugins: !1,
3452
- trust: Na,
3470
+ trust: Ia,
3453
3471
  registered: d.passed,
3454
3472
  checks: m
3455
3473
  }), +!h;
3456
- console.log(`\n ${n.bold(`blazon-mcp for ${t}, brand ${r}`)}\n ${n.yellow(Na)}\n`);
3474
+ console.log(`\n ${l.bold(`blazon-mcp for ${t}, brand ${n}`)}\n ${l.yellow(Ia)}\n`);
3457
3475
  for (let e of m) {
3458
- let t = e.passed ? n.green("ok ") : e.advisory ? n.yellow("finding") : n.red("fail ");
3459
- console.log(` ${t} ${e.name.padEnd(10)} ${e.detail}`), !e.passed && e.fix && console.log(` ${" ".repeat(7)} ${" ".repeat(10)} ${n.dim("fix:")} ${e.fix}`);
3476
+ let t = e.passed ? l.green("ok ") : e.advisory ? l.yellow("finding") : l.red("fail ");
3477
+ console.log(` ${t} ${e.name.padEnd(10)} ${e.detail}`), !e.passed && e.fix && console.log(` ${" ".repeat(7)} ${" ".repeat(10)} ${l.dim("fix:")} ${e.fix}`);
3460
3478
  }
3461
- return console.log(`\n ${h ? n.green("The server is ready.") : n.red("The server is not ready.")}${d.passed ? "" : " It is not registered in this client yet (a finding, not a failure)."}\n`), +!h;
3479
+ return console.log(`\n ${h ? l.green("The server is ready.") : l.red("The server is not ready.")}${d.passed ? "" : " It is not registered in this client yet (a finding, not a failure)."}\n`), +!h;
3462
3480
  }
3463
3481
  // src/cli/commands/mcp.ts
3464
- async function Ga(e = {}) {
3465
- if (e.printConfig && e.check) throw new P("give --print-config or --check, not both. See blazon mcp --help.", void 0, "conflicting-options");
3466
- if (!e.printConfig && !e.check) throw new P("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");
3482
+ async function Ya(e = {}) {
3483
+ if (e.printConfig && e.check) throw new M("give --print-config or --check, not both. See blazon mcp --help.", void 0, "conflicting-options");
3484
+ 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");
3467
3485
  let t = e.client === void 0 ? "claude-code" : e.client;
3468
- if (e.client !== void 0 && !we(e.client)) throw new P(`unknown client "${e.client}"; the clients are ${Fe.join(", ")}.`, void 0, "invalid-option-value");
3469
- let r = e.brand === void 0 ? void 0 : A.resolve(process.cwd(), e.brand);
3486
+ 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");
3487
+ let n = e.brand === void 0 ? void 0 : O.resolve(process.cwd(), e.brand);
3470
3488
  if (e.check) {
3471
- let n = r ?? process.cwd();
3472
- if (!j.statSync(n, { throwIfNoEntry: !1 })?.isDirectory()) throw new P(`the brand folder ${n} does not exist.`, void 0, "no-folder");
3473
- return Wa({
3489
+ let r = n ?? process.cwd();
3490
+ if (!k.statSync(r, { throwIfNoEntry: !1 })?.isDirectory()) throw new M(`the brand folder ${r} does not exist.`, void 0, "no-folder");
3491
+ return Ja({
3474
3492
  client: t,
3475
- brand: n,
3493
+ brand: r,
3494
+ ...e.root && { root: e.root },
3476
3495
  ...e.json && { json: !0 }
3477
3496
  });
3478
3497
  }
3479
- let i = ue(t, pe(), r);
3480
- if (e.json) return Ui("mcp", !0, {
3498
+ let r = xe(e.root);
3499
+ if (!r.built && !_e(e.root)) return e.json ? Y("mcp", !1, {
3500
+ client: t,
3501
+ built: !1,
3502
+ ...n && { brand: n },
3503
+ note: Ie,
3504
+ snippets: []
3505
+ }) : console.error(`\n ${l.yellow(Ie)}\n`), 1;
3506
+ let i = Be(t, r, n);
3507
+ if (e.json) return Y("mcp", !0, {
3481
3508
  client: t,
3482
3509
  built: i.built,
3483
- ...r && { brand: r },
3510
+ ...n && { brand: n },
3484
3511
  ...i.note && { note: i.note },
3485
3512
  snippets: i.snippets
3486
3513
  }), 0;
3487
- console.log(`\n ${n.bold(i.title)}`);
3488
- for (let e of i.snippets) console.log(`\n ${n.dim(e.label)}\n\n${e.text.replace(/^/gm, " ")}`);
3489
- return i.note && console.log(`\n ${n.yellow(i.note)}`), console.log(""), 0;
3514
+ console.log(`\n ${l.bold(i.title)}`);
3515
+ for (let e of i.snippets) console.log(`\n ${l.dim(e.label)}\n\n${e.text.replace(/^/gm, " ")}`);
3516
+ return i.note && console.log(`\n ${l.yellow(i.note)}`), console.log(""), 0;
3490
3517
  }
3491
3518
  // src/cli/commands/explain.ts
3492
- function Ka(e) {
3493
- let t = De[e], n = Ee(e);
3519
+ function Xa(e) {
3520
+ let t = se[e], n = oe(e);
3494
3521
  return {
3495
3522
  code: e,
3496
3523
  severity: t.severity,
@@ -3501,12 +3528,12 @@ function Ka(e) {
3501
3528
  manual: t.manual
3502
3529
  };
3503
3530
  }
3504
- function qa(e) {
3531
+ function Za(e) {
3505
3532
  let [t = "", n] = e.split("#");
3506
3533
  return `RFC ${t.padStart(4, "0")}${n ? `, section ${n}` : ""}`;
3507
3534
  }
3508
- function Ja(e) {
3509
- let t = Object.keys(De), n = [];
3535
+ function Qa(e) {
3536
+ let t = Object.keys(se), n = [];
3510
3537
  for (let r = 0; r < 3; r++) {
3511
3538
  let r = E(e, t);
3512
3539
  if (r === void 0) break;
@@ -3514,14 +3541,14 @@ function Ja(e) {
3514
3541
  }
3515
3542
  return n;
3516
3543
  }
3517
- function Ya(e) {
3518
- let t = e.severity === "error" ? n.red : e.severity === "warning" ? n.yellow : n.dim;
3519
- console.log(`\n ${n.bold(e.code)} ${t(e.severity)}\n`), console.log(` ${e.summary}`), e.fix !== void 0 && console.log(`\n ${n.bold("Fix")} ${e.fix}`), console.log(`\n ${n.bold("Read")} docs/manual/${e.manual}.md, ${qa(e.rfc)}\n`);
3544
+ function $a(e) {
3545
+ let t = e.severity === "error" ? l.red : e.severity === "warning" ? l.yellow : l.dim;
3546
+ console.log(`\n ${l.bold(e.code)} ${t(e.severity)}\n`), console.log(` ${e.summary}`), e.fix !== void 0 && console.log(`\n ${l.bold("Fix")} ${e.fix}`), console.log(`\n ${l.bold("Read")} docs/manual/${e.manual}.md, ${Za(e.rfc)}\n`);
3520
3547
  }
3521
- function Xa(e, t = {}) {
3548
+ function eo(e, t = {}) {
3522
3549
  if (e === void 0) {
3523
- let e = Object.keys(De).sort().map((e) => Ka(e));
3524
- if (t.json) Ui("explain", !0, { codes: e });
3550
+ let e = Object.keys(se).sort().map((e) => Xa(e));
3551
+ if (t.json) Y("explain", !0, { codes: e });
3525
3552
  else {
3526
3553
  let t = Math.max(...e.map((e) => e.code.length));
3527
3554
  console.log();
@@ -3530,42 +3557,42 @@ function Xa(e, t = {}) {
3530
3557
  }
3531
3558
  return 0;
3532
3559
  }
3533
- if (!Object.hasOwn(De, e)) {
3534
- let t = Ja(e);
3535
- throw new P(`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");
3560
+ if (!Object.hasOwn(se, e)) {
3561
+ let t = Qa(e);
3562
+ 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");
3536
3563
  }
3537
- let n = Ka(e);
3538
- return t.json ? Ui("explain", !0, n) : Ya(n), 0;
3564
+ let n = Xa(e);
3565
+ return t.json ? Y("explain", !0, n) : $a(n), 0;
3539
3566
  }
3540
3567
  // src/cli/options.ts
3541
- var Za = (e) => {
3568
+ var to = (e) => {
3542
3569
  if (e.length === 1) return [`-${e}`];
3543
3570
  let t = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
3544
3571
  return t === e ? [`--${e}`] : [`--${e}`, `--${t}`];
3545
3572
  };
3546
- function Qa(e, t) {
3573
+ function no(e, t) {
3547
3574
  let n = e.matchedCommand;
3548
3575
  if (!n) return;
3549
3576
  let r = [...n.options, ...e.globalCommand.options].filter((e) => e.required);
3550
3577
  for (let i of r) {
3551
3578
  if (typeof e.options[i.name] == "object") continue;
3552
- let r = i.names.flatMap(Za);
3579
+ let r = i.names.flatMap(to);
3553
3580
  for (let a = 2; a < t.length; a++) {
3554
3581
  let o = t[a], s = r.find((e) => o === e || o.startsWith(`${e}=`));
3555
3582
  if (s === void 0) continue;
3556
3583
  let c = o === s ? t[a + 1] : o.slice(s.length + 1);
3557
- if (c !== void 0 && (c === "" && F(`blazon ${n.name}: ${s} needs a value, not an empty one.`, "empty-value", { fix: `Give ${s} a value, or leave it out.` }), i.name !== "port")) for (let t of i.names) t in e.options && (e.options[t] = c);
3584
+ if (c !== void 0 && (c === "" && N(`blazon ${n.name}: ${s} needs a value, not an empty one.`, "empty-value", { fix: `Give ${s} a value, or leave it out.` }), i.name !== "port")) for (let t of i.names) t in e.options && (e.options[t] = c);
3558
3585
  }
3559
3586
  }
3560
3587
  let i = t.slice(2);
3561
- i.some((e, t) => e === "" && !(i[t - 1] ?? "").startsWith("-")) && F(`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." });
3588
+ 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." });
3562
3589
  }
3563
3590
  // src/cli/json.ts
3564
- var $a = [
3591
+ var ro = [
3565
3592
  "error",
3566
3593
  "warning",
3567
3594
  "info"
3568
- ], eo = {
3595
+ ], io = {
3569
3596
  error: ["error"],
3570
3597
  warning: ["error", "warning"],
3571
3598
  info: [
@@ -3574,19 +3601,19 @@ var $a = [
3574
3601
  "info"
3575
3602
  ]
3576
3603
  };
3577
- async function to(e, t, n, r = "info") {
3604
+ async function ao(e, t, n, r = "info") {
3578
3605
  let i = console.log;
3579
3606
  console.log = (...e) => console.error(...e);
3580
3607
  let a;
3581
3608
  try {
3582
3609
  a = (await n()).findings;
3583
3610
  } catch (e) {
3584
- if (!(e instanceof ht)) throw e;
3611
+ if (!(e instanceof bt)) throw e;
3585
3612
  a = e.findings;
3586
3613
  } finally {
3587
3614
  console.log = i;
3588
3615
  }
3589
- let o = k(a, { strict: t }), s = {
3616
+ let o = c(a, { strict: t }), s = {
3590
3617
  errors: o.errors.length,
3591
3618
  warnings: o.warnings.length,
3592
3619
  info: o.infos.length
@@ -3596,18 +3623,18 @@ async function to(e, t, n, r = "info") {
3596
3623
  passed: o.passed,
3597
3624
  strict: t,
3598
3625
  counts: s,
3599
- findings: o.all.filter((e) => eo[r].includes(e.severity)).map((e) => ({
3626
+ findings: o.all.filter((e) => io[r].includes(e.severity)).map((e) => ({
3600
3627
  ...e,
3601
- ...ve(e) && { fix: ve(e) }
3628
+ ...Ue(e) && { fix: Ue(e) }
3602
3629
  }))
3603
3630
  }, null, 2)}\n`), process.exitCode = +!o.passed;
3604
3631
  }
3605
- async function no(e, t) {
3632
+ async function oo(e, t) {
3606
3633
  let n = console.log;
3607
3634
  console.log = (...e) => console.error(...e);
3608
3635
  let r, i, a;
3609
3636
  try {
3610
- i = await Wr(e, {
3637
+ i = await Jr(e, {
3611
3638
  ...t,
3612
3639
  input: !1,
3613
3640
  report: (e) => r = e,
@@ -3620,18 +3647,18 @@ async function no(e, t) {
3620
3647
  command: "init",
3621
3648
  passed: i === 0,
3622
3649
  ...r ?? {},
3623
- ...i !== 0 && { error: a ? it(a.code, a.message) : it("error", `init did not finish (exit status ${i}); the reason is on standard error`) }
3650
+ ...i !== 0 && { error: a ? lt(a.code, a.message) : lt("error", `init did not finish (exit status ${i}); the reason is on standard error`) }
3624
3651
  };
3625
3652
  return process.stdout.write(`${JSON.stringify(o)}\n`), i;
3626
3653
  }
3627
3654
  // src/cli/help.ts
3628
- var ro = " 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", io = " blazon explain <code> what a finding code means, the fix, and where to read more\n blazon explain list every code", ao = " --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.", oo = {
3655
+ var so = " 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", co = " blazon explain <code> what a finding code means, the fix, and where to read more\n blazon explain list every code", lo = " --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.", uo = {
3629
3656
  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",
3630
3657
  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",
3631
3658
  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"
3632
3659
  };
3633
- function so(e, t, n) {
3634
- if (t === "plugin" && n !== void 0 && Object.hasOwn(oo, n)) return [{ body: oo[n] }];
3660
+ function fo(e, t, n) {
3661
+ if (t === "plugin" && n !== void 0 && Object.hasOwn(uo, n)) return [{ body: uo[n] }];
3635
3662
  let r = e.map((e) => ({
3636
3663
  ...e,
3637
3664
  body: e.body.replace(/(--no-[a-z-]+[^\n]*?) *\(default: true\)/g, "$1")
@@ -3640,32 +3667,32 @@ function so(e, t, n) {
3640
3667
  ...r,
3641
3668
  {
3642
3669
  title: "Finding codes",
3643
- body: io
3670
+ body: co
3644
3671
  },
3645
3672
  {
3646
3673
  title: "Working folder and environment",
3647
- body: ao
3674
+ body: lo
3648
3675
  },
3649
3676
  {
3650
3677
  title: "Exit status",
3651
- body: ro
3678
+ body: so
3652
3679
  }
3653
3680
  ] : r;
3654
3681
  }
3655
3682
  // src/cli/index.ts
3656
- function co(e, t) {
3683
+ function po(e, t) {
3657
3684
  if (t === void 0) return;
3658
3685
  let n = String(t), r = /^\d+$/.test(n) ? Number(n) : NaN;
3659
- return r >= 1 && r <= 65535 || F(`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;
3686
+ 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;
3660
3687
  }
3661
- var lo = (e) => typeof e == "number" ? String(e) : e;
3662
- function uo(e, t) {
3663
- t?.plugins === !1 && t.plugin !== void 0 && F(`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." });
3688
+ var mo = (e) => typeof e == "number" ? String(e) : e;
3689
+ function ho(e, t) {
3690
+ 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." });
3664
3691
  }
3665
- function fo(e, t, n) {
3666
- if (t !== void 0) return n || F(`blazon ${e}: --severity cuts the list that --json prints; add --json, or leave --severity out.`, "conflicting-options", { fix: "Add --json, or leave --severity out." }), $a.includes(t) || F(`blazon ${e}: --severity must be error, warning or info, not "${String(t)}".`, "invalid-option-value", { fix: "Use --severity error, warning or info." }), t;
3692
+ function go(e, t, n) {
3693
+ 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." }), ro.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;
3667
3694
  }
3668
- var po = (e) => {
3695
+ var _o = (e) => {
3669
3696
  let [t, n] = e.slice(2).filter((e, t, n) => !e.startsWith("-") && n[t - 1] !== "--cwd" && n[t - 1] !== "--allow-dir");
3670
3697
  if (e.includes("--json") && t !== void 0) return t === "plugin" ? n === "check" ? "plugin check" : void 0 : [
3671
3698
  "check",
@@ -3677,11 +3704,11 @@ var po = (e) => {
3677
3704
  "pin",
3678
3705
  "explain",
3679
3706
  "doctor",
3680
- ...Da,
3707
+ ...Aa,
3681
3708
  "mcp"
3682
3709
  ].includes(t) ? t : void 0;
3683
3710
  };
3684
- function mo(e) {
3711
+ function vo(e) {
3685
3712
  if (e[2] !== "help") return e;
3686
3713
  let t = e[3];
3687
3714
  return t !== void 0 && !t.startsWith("-") ? [
@@ -3691,134 +3718,134 @@ function mo(e) {
3691
3718
  ...e.slice(4)
3692
3719
  ] : [...e.slice(0, 2), "--help"];
3693
3720
  }
3694
- async function ho(e = process.argv) {
3695
- let t = mo(e), n = t.includes("--debug");
3696
- nt(po(t));
3697
- let r = Xe("blazon");
3721
+ async function yo(e = process.argv) {
3722
+ let t = vo(e), n = t.includes("--debug");
3723
+ st(_o(t));
3724
+ let r = tt("blazon");
3698
3725
  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) => {
3699
3726
  try {
3700
- await mt(e || process.cwd(), co("dev", t?.port), {
3727
+ await yt(e || process.cwd(), po("dev", t?.port), {
3701
3728
  strictPort: t?.strictPort,
3702
- host: lo(t?.host)
3729
+ host: mo(t?.host)
3703
3730
  });
3704
3731
  } catch (e) {
3705
- I("dev", e, n);
3732
+ P("dev", e, n);
3706
3733
  }
3707
3734
  }), 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) => {
3708
3735
  try {
3709
- uo("build", t);
3710
- let n = fo("build", t?.severity, t?.json), r = () => At(e || process.cwd(), t?.outDir === void 0 ? void 0 : A.resolve(process.cwd(), t.outDir), t);
3711
- t?.json ? await to("build", !1, r, n) : await r();
3736
+ ho("build", t);
3737
+ let n = go("build", t?.severity, t?.json), r = () => Ft(e || process.cwd(), t?.outDir === void 0 ? void 0 : O.resolve(process.cwd(), t.outDir), t);
3738
+ t?.json ? await ao("build", !1, r, n) : await r();
3712
3739
  } catch (e) {
3713
- I("build", e, n);
3740
+ P("build", e, n);
3714
3741
  }
3715
3742
  }), 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) => {
3716
3743
  try {
3717
- uo("tokens", t);
3718
- let n = fo("tokens", t?.severity, t?.json), r = () => jt(e || process.cwd(), t);
3719
- t?.json ? await to("tokens", !1, r, n) : await r();
3744
+ ho("tokens", t);
3745
+ let n = go("tokens", t?.severity, t?.json), r = () => It(e || process.cwd(), t);
3746
+ t?.json ? await ao("tokens", !1, r, n) : await r();
3720
3747
  } catch (e) {
3721
- I("tokens", e, n);
3748
+ P("tokens", e, n);
3722
3749
  }
3723
3750
  }), 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) => {
3724
3751
  try {
3725
- uo("check", t);
3726
- let n = fo("check", t?.severity, t?.json), r = () => kt(e || process.cwd(), t?.strict, t);
3727
- t?.json ? await to("check", !!t.strict, r, n) : (await r()).passed || (process.exitCode = 1);
3752
+ ho("check", t);
3753
+ let n = go("check", t?.severity, t?.json), r = () => Pt(e || process.cwd(), t?.strict, t);
3754
+ t?.json ? await ao("check", !!t.strict, r, n) : (await r()).passed || (process.exitCode = 1);
3728
3755
  } catch (e) {
3729
- I("check", e, n);
3756
+ P("check", e, n);
3730
3757
  }
3731
- }), ja(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) => {
3758
+ }), Pa(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) => {
3732
3759
  try {
3733
- process.exitCode = await Ga(e);
3760
+ process.exitCode = await Ya(e);
3734
3761
  } catch (e) {
3735
- I("mcp", e, n);
3762
+ P("mcp", e, n);
3736
3763
  }
3737
3764
  }), 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) => {
3738
3765
  try {
3739
- process.exitCode = await si(e, t);
3766
+ process.exitCode = await di(e, t);
3740
3767
  } catch (e) {
3741
- I("drift", e, n);
3768
+ P("drift", e, n);
3742
3769
  }
3743
3770
  }), 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) => {
3744
3771
  try {
3745
- process.exitCode = await ci(e || process.cwd(), { json: t?.json });
3772
+ process.exitCode = await fi(e || process.cwd(), { json: t?.json });
3746
3773
  } catch (e) {
3747
- I("approvals", e, n);
3774
+ P("approvals", e, n);
3748
3775
  }
3749
3776
  }), r.command("plugin [action] [target]", "Plugins: `check <program>` checks that a program follows the plugin protocol, `pin <path>` prints the digest that pins it, `profile` prints the profile blazon enforces").option("--name <name>", "With `pin`: record the pin in blazon.plugins.lock under this plugin name").option("--digest <digest>", "With `pin --name`: the digest you vouch for; the bytes must be those").option("--entry <path>", "With `pin --name` on a directory: the program inside it, when it is not blazon-<name>").option("--json", "With `check`: print the cases as JSON on standard output").option("--core", "With `check`: run only the core cases of the protocol (1 to 5), not blazon's role cases or the layout of a shipped plugin").action(async (e, t, r) => {
3750
3777
  try {
3751
- if (r?.json && e !== "check" && F("blazon plugin: --json is for `blazon plugin check`; `pin` prints a digest and `profile` prints JSON already.", "conflicting-options", { fix: "Leave out --json, or use it with `blazon plugin check`." }), r?.core && e !== "check" && F("blazon plugin: --core is for `blazon plugin check`; `pin` and `profile` run no cases.", "conflicting-options", { fix: "Leave out --core, or use it with `blazon plugin check`." }), e !== "pin") for (let t of [
3778
+ if (r?.json && e !== "check" && N("blazon plugin: --json is for `blazon plugin check`; `pin` prints a digest and `profile` prints JSON already.", "conflicting-options", { fix: "Leave out --json, or use it with `blazon plugin check`." }), r?.core && e !== "check" && N("blazon plugin: --core is for `blazon plugin check`; `pin` and `profile` run no cases.", "conflicting-options", { fix: "Leave out --core, or use it with `blazon plugin check`." }), e !== "pin") for (let t of [
3752
3779
  "name",
3753
3780
  "digest",
3754
3781
  "entry"
3755
- ]) r?.[t] !== void 0 && F(`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\`.` });
3756
- e === "profile" && t !== void 0 && F("blazon plugin: `profile` takes no target.", "conflicting-options", { fix: "Run `blazon plugin profile` on its own." }), process.exitCode = await ai(e, t, r);
3782
+ ]) 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\`.` });
3783
+ 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 li(e, t, r);
3757
3784
  } catch (e) {
3758
- I("plugin", e, n);
3785
+ P("plugin", e, n);
3759
3786
  }
3760
3787
  }), 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) => {
3761
3788
  try {
3762
- process.exitCode = Xa(e, { json: t?.json });
3789
+ process.exitCode = eo(e, { json: t?.json });
3763
3790
  } catch (e) {
3764
- I("explain", e, n);
3791
+ P("explain", e, n);
3765
3792
  }
3766
3793
  }), 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) => {
3767
3794
  try {
3768
- process.exitCode = oi(e || process.cwd(), { json: t?.json });
3795
+ process.exitCode = ui(e || process.cwd(), { json: t?.json });
3769
3796
  } catch (e) {
3770
- I("pin", e, n);
3797
+ P("pin", e, n);
3771
3798
  }
3772
3799
  }), 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) => {
3773
3800
  try {
3774
- t?.json ? (t.dev && F("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 no(e || ".", t)) : process.exitCode = await Wr(e || ".", { ...t });
3801
+ 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 oo(e || ".", t)) : process.exitCode = await Jr(e || ".", { ...t });
3775
3802
  } catch (e) {
3776
- I("init", e, n);
3803
+ P("init", e, n);
3777
3804
  }
3778
3805
  }), 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) => {
3779
3806
  try {
3780
- await Jr(e || process.cwd(), co("preview", t?.port), {
3807
+ await Qr(e || process.cwd(), po("preview", t?.port), {
3781
3808
  strictPort: t?.strictPort,
3782
- host: lo(t?.host)
3809
+ host: mo(t?.host)
3783
3810
  });
3784
3811
  } catch (e) {
3785
- I("preview", e, n);
3812
+ P("preview", e, n);
3786
3813
  }
3787
3814
  }), 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) => {
3788
3815
  try {
3789
- process.exitCode = await ra(process.cwd(), { json: e?.json });
3816
+ process.exitCode = await oa(process.cwd(), { json: e?.json });
3790
3817
  } catch (e) {
3791
- I("doctor", e, n);
3818
+ P("doctor", e, n);
3792
3819
  }
3793
- }), 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) => so(e, r.matchedCommand?.name, r.args[0])), r.version(We), t.slice(2).length === 0) return r.outputHelp();
3820
+ }), 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) => fo(e, r.matchedCommand?.name, r.args[0])), r.version(Ge), t.slice(2).length === 0) return r.outputHelp();
3794
3821
  r.addEventListener("command:*", (e) => {
3795
3822
  if (r.options.help || r.options.version) return;
3796
3823
  let t = String(e.detail), n = E(t, r.commands.map((e) => e.name).filter(Boolean));
3797
- F(`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." });
3824
+ 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." });
3798
3825
  });
3799
3826
  try {
3800
- r.parse(t, { run: !1 }), Qa(r, t);
3827
+ r.parse(t, { run: !1 }), no(r, t);
3801
3828
  try {
3802
- ui(r.options.allowDir), li(r.options.cwd);
3829
+ mi(r.options.allowDir), pi(r.options.cwd);
3803
3830
  } catch (e) {
3804
- I(r.matchedCommand?.name ?? "", e, n);
3831
+ P(r.matchedCommand?.name ?? "", e, n);
3805
3832
  }
3806
3833
  await r.runMatchedCommand();
3807
3834
  } catch (e) {
3808
- if (!st(e)) return I("", e, n);
3835
+ if (!ft(e)) return P("", e, n);
3809
3836
  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;
3810
- o !== void 0 && /^\d+$/.test(o) && (t === "dev" || t === "preview") && F(`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) && F("blazon get: give a token path, such as blazon get color.brand.primary; blazon list shows the token paths.", "missing-argument", {
3837
+ 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", {
3811
3838
  stack: s,
3812
3839
  fix: "Run blazon list to see the token paths."
3813
- }), o === void 0 && F(`${i}: ${ot(e.message)}. Run ${i} --help for the options.`, "missing-argument", {
3840
+ }), o === void 0 && N(`${i}: ${dt(e.message)}. Run ${i} --help for the options.`, "missing-argument", {
3814
3841
  stack: s,
3815
3842
  fix: `Run ${i} --help for the options.`
3816
3843
  });
3817
3844
  let c = [...r.matchedCommand?.options ?? [], ...r.globalCommand.options].map((e) => e.name), l = E(o, c);
3818
- F(`${i}: unknown option "${a}${o}"${l ? `; did you mean "--${l}"?` : "."} Run ${i} --help for the options.`, "unknown-option", {
3845
+ N(`${i}: unknown option "${a}${o}"${l ? `; did you mean "--${l}"?` : "."} Run ${i} --help for the options.`, "unknown-option", {
3819
3846
  stack: s,
3820
3847
  fix: l ? `Use --${l}, or run ${i} --help for the options.` : `Run ${i} --help for the options.`
3821
3848
  });
3822
3849
  }
3823
3850
  }
3824
- export { ho as runCli };
3851
+ export { yo as runCli };