@dloizides/logo-kit 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,165 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import fs2 from 'fs';
3
- import path3 from 'path';
3
+ import path5 from 'path';
4
4
  import { PRESETS, contrastRatio } from '@dloizides/design-tokens';
5
5
  import { Resvg } from '@resvg/resvg-js';
6
6
  import { execFileSync } from 'child_process';
7
7
 
8
- // src/core/CvdKind.ts
9
- var CVD_KINDS = ["protan" /* Protan */, "deutan" /* Deutan */, "tritan" /* Tritan */];
10
-
11
- // src/core/colour.ts
12
- var MACHADO = {
13
- ["protan" /* Protan */]: [[0.152286, 1.052583, -0.204868], [0.114503, 0.786281, 0.099216], [-3882e-6, -0.048116, 1.051998]],
14
- ["deutan" /* Deutan */]: [[0.367322, 0.860646, -0.227968], [0.280085, 0.672501, 0.047413], [-0.01182, 0.04294, 0.968881]],
15
- ["tritan" /* Tritan */]: [[1.255528, -0.076749, -0.178779], [-0.078411, 0.930809, 0.147602], [4733e-6, 0.691367, 0.3039]]
16
- };
17
- var HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;
18
- var MAX = 255;
19
- var GAMMA_KNEE = 0.04045;
20
- var LINEAR_KNEE = 31308e-7;
21
- var LAB_KNEE = 8856e-6;
22
- function hexToRgb(hex) {
23
- const match = HEX.exec(hex.trim());
24
- if (!match?.[1]) {
25
- throw new Error(`not a hex colour: ${hex}`);
26
- }
27
- const raw = match[1].length === 3 ? match[1].split("").map((c) => c + c).join("") : match[1];
28
- return [0, 2, 4].map((i) => parseInt(raw.slice(i, i + 2), 16));
29
- }
30
- function rgbToHex(rgb) {
31
- return `#${rgb.map((c) => Math.round(Math.min(MAX, Math.max(0, c))).toString(16).padStart(2, "0")).join("")}`;
32
- }
33
- var toLinear = (c) => {
34
- const s = c / MAX;
35
- return s <= GAMMA_KNEE ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
36
- };
37
- var fromLinear = (l) => {
38
- const v = Math.min(1, Math.max(0, l));
39
- return MAX * (v <= LINEAR_KNEE ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055);
40
- };
41
- function simulateCvd(hex, kind) {
42
- const lin = hexToRgb(hex).map(toLinear);
43
- const out = MACHADO[kind].map((row) => row[0] * (lin[0] ?? 0) + row[1] * (lin[1] ?? 0) + row[2] * (lin[2] ?? 0));
44
- return rgbToHex(out.map(fromLinear));
45
- }
46
- function toLab(hex) {
47
- const [r, g, b] = hexToRgb(hex).map(toLinear);
48
- const xyz = [(0.4124 * r + 0.3576 * g + 0.1805 * b) / 0.95047, 0.2126 * r + 0.7152 * g + 0.0722 * b, (0.0193 * r + 0.1192 * g + 0.9505 * b) / 1.08883];
49
- const f = (t) => t > LAB_KNEE ? Math.cbrt(t) : 7.787 * t + 16 / 116;
50
- const [fx, fy, fz] = xyz.map(f);
51
- return [116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)];
52
- }
53
- function deltaE(a, b) {
54
- const la = toLab(a);
55
- const lb = toLab(b);
56
- return Math.hypot(la[0] - lb[0], la[1] - lb[1], la[2] - lb[2]);
57
- }
58
- function contrast(a, b) {
59
- return contrastRatio(a, b);
60
- }
61
- var HALF = 128;
62
- var ICO_HEADER = 6;
63
- var ICO_ENTRY = 16;
64
- var ICO_MAX_SIDE = 256;
65
- var BITS = 32;
66
- var options = (width, fontFiles) => ({
67
- fitTo: { mode: "width", value: width },
68
- font: { loadSystemFonts: false, fontFiles }
69
- });
70
- function renderSvg(svg2, width, fontFiles = []) {
71
- const img = new Resvg(svg2, options(width, fontFiles)).render();
72
- return { width: img.width, height: img.height, data: new Uint8Array(img.pixels) };
73
- }
74
- function renderPng(svg2, width, fontFiles = []) {
75
- return new Resvg(svg2, options(width, fontFiles)).render().asPng();
76
- }
77
- function alphaMask(bmp) {
78
- const out = new Uint8Array(bmp.width * bmp.height);
79
- for (let i = 0; i < out.length; i++) {
80
- out[i] = (bmp.data[i * 4 + 3] ?? 0) >= HALF ? 1 : 0;
81
- }
82
- return out;
83
- }
84
- function pngSize(png) {
85
- const view = new DataView(png.buffer, png.byteOffset, png.byteLength);
86
- return { width: view.getUint32(16), height: view.getUint32(20) };
87
- }
88
- function buildIco(pngs) {
89
- const header = Buffer.alloc(ICO_HEADER + ICO_ENTRY * pngs.length);
90
- header.writeUInt16LE(1, 2);
91
- header.writeUInt16LE(pngs.length, 4);
92
- let offset = header.length;
93
- pngs.forEach((png, k) => {
94
- const { width, height } = pngSize(png);
95
- const pos = ICO_HEADER + ICO_ENTRY * k;
96
- header.writeUInt8(width >= ICO_MAX_SIDE ? 0 : width, pos);
97
- header.writeUInt8(height >= ICO_MAX_SIDE ? 0 : height, pos + 1);
98
- header.writeUInt16LE(1, pos + 4);
99
- header.writeUInt16LE(BITS, pos + 6);
100
- header.writeUInt32LE(png.length, pos + 8);
101
- header.writeUInt32LE(offset, pos + 12);
102
- offset += png.length;
103
- });
104
- return Buffer.concat([header, ...pngs.map((p) => Buffer.from(p))]);
105
- }
106
-
107
- // src/palette/paletteChecks.ts
108
- var MIN_CONTRAST = 3;
109
- var MIN_CVD_DELTA_E = 10;
110
- var bgOf = (colours) => colours["background"] ?? "#ffffff";
111
- function contrastFailures(palette, roles) {
112
- const out = [];
113
- for (const [mode, colours] of [["light", palette.light], ["dark", palette.dark]]) {
114
- for (const role of roles) {
115
- const hex = colours[role];
116
- if (hex === void 0) {
117
- out.push(`contrast: ${mode} has no colour for "${role}"`);
118
- } else if (contrast(hex, bgOf(colours)) < MIN_CONTRAST) {
119
- out.push(`contrast: ${mode} "${role}" ${hex} is ${contrast(hex, bgOf(colours)).toFixed(2)}:1 on ${bgOf(colours)}`);
120
- }
121
- }
122
- }
123
- return out;
124
- }
125
- function cvdModeFailures(colours, roles, mode) {
126
- const out = [];
127
- const hexes = [...new Set(roles.map((r) => colours[r]).filter((h) => h !== void 0))];
128
- for (const kind of CVD_KINDS) {
129
- const sim = hexes.map((h) => simulateCvd(h, kind));
130
- const bg = simulateCvd(bgOf(colours), kind);
131
- sim.forEach((s, i) => {
132
- if (contrast(s, bg) < MIN_CONTRAST) {
133
- out.push(`cvd: ${mode} ${hexes[i] ?? ""} drops under 3:1 for ${kind}`);
134
- }
135
- sim.slice(i + 1).forEach((t, j) => {
136
- if (deltaE(s, t) < MIN_CVD_DELTA_E) {
137
- out.push(`cvd: ${mode} ${hexes[i] ?? ""} and ${hexes[i + j + 1] ?? ""} look the same for ${kind}`);
138
- }
139
- });
140
- });
141
- }
142
- return out;
143
- }
144
- function cvdFailures(palette, roles) {
145
- return [...cvdModeFailures(palette.light, roles, "light"), ...cvdModeFailures(palette.dark, roles, "dark")];
146
- }
147
-
148
- // src/palette/roles.ts
149
- function rolesOf(mark) {
150
- const roles = [];
151
- for (const layer of mark.layers) {
152
- for (const item of [...layer.paint.light, ...layer.paint.dark]) {
153
- for (const role of [item.fill, item.stroke]) {
154
- if (role !== void 0 && !roles.includes(role)) {
155
- roles.push(role);
156
- }
157
- }
158
- }
159
- }
160
- return roles;
161
- }
162
-
163
8
  // src/core/num.ts
164
9
  var PLACES = 3;
165
10
  function fmt(value) {
@@ -190,9 +35,9 @@ function layerSvg(layer, index, colours, mode, opts = {}) {
190
35
  const items = mode === "dark" /* Dark */ ? layer.paint.dark : layer.paint.light;
191
36
  const rule = layer.evenOdd === true ? ' fill-rule="evenodd"' : "";
192
37
  const len = opts.drawLayers?.has(layer.name) === true ? ' pathLength="1"' : "";
193
- const path5 = (item, head2) => `<path${head2} ${paintAttrs(item, colours, opts.colourOverride)}${rule}${len} d="${layer.d}"/>`;
38
+ const path7 = (item, head2) => `<path${head2} ${paintAttrs(item, colours, opts.colourOverride)}${rule}${len} d="${layer.d}"/>`;
194
39
  const head = ` id="mark-${layer.name}" class="l${index}"`;
195
- const body = items.length === 1 && items[0] ? path5(items[0], head) : `<g${head}>${items.map((item) => path5(item, "")).join("")}</g>`;
40
+ const body = items.length === 1 && items[0] ? path7(items[0], head) : `<g${head}>${items.map((item) => path7(item, "")).join("")}</g>`;
196
41
  const wrapped = opts.microWrap === true ? `<g class="lkm${index}">${body}</g>` : body;
197
42
  return layer.transform !== void 0 ? `<g transform="${layer.transform}">${wrapped}</g>` : wrapped;
198
43
  }
@@ -220,518 +65,712 @@ function placeMark(mark, palette, mode, box) {
220
65
  return `<svg x="${box.x}" y="${box.y}" width="${box.size}" height="${box.size}" viewBox="${mark.viewBox}">${markBody(mark, palette, mode)}</svg>`;
221
66
  }
222
67
 
223
- // src/checks/grid.ts
224
- var GRID = 24;
225
- var SAMPLES = 3;
226
- var MAJORITY = 5;
227
- function maskBox(mask, w, h) {
228
- let x0 = w;
229
- let y0 = h;
230
- let x1 = -1;
231
- let y1 = -1;
232
- for (let y = 0; y < h; y++) {
233
- for (let x = 0; x < w; x++) {
234
- if (mask[y * w + x] === 1) {
235
- x0 = Math.min(x0, x);
236
- y0 = Math.min(y0, y);
237
- x1 = Math.max(x1, x);
238
- y1 = Math.max(y1, y);
239
- }
240
- }
68
+ // src/motion/MotionPreset.ts
69
+ var BOLD_PRESETS = [
70
+ "fly-in" /* FlyIn */,
71
+ "spin-assemble" /* SpinAssemble */,
72
+ "drop-bounce" /* DropBounce */,
73
+ "flip" /* Flip */,
74
+ "slam-shake" /* SlamShake */
75
+ ];
76
+ var INTRO_PRESETS = [
77
+ "draw" /* Draw */,
78
+ "flood" /* Flood */,
79
+ "stagger-rise" /* StaggerRise */,
80
+ "scale-pop" /* ScalePop */,
81
+ "orbit" /* Orbit */,
82
+ "wipe" /* Wipe */,
83
+ "morph-from-circle" /* MorphFromCircle */,
84
+ "sweep" /* Sweep */,
85
+ "pulse" /* Pulse */,
86
+ ...BOLD_PRESETS
87
+ ];
88
+ var MICRO_PRESETS = ["spread" /* Spread */, "pulse" /* Pulse */, "sweep" /* Sweep */];
89
+
90
+ // src/motion/defaults.ts
91
+ var INTRO_CAP_MS = 1200;
92
+ var MICRO_CAP_MS = 300;
93
+ var EASE = "cubic-bezier(0.2,0,0,1)";
94
+ var EASE_IN_FIRST = "cubic-bezier(0,0,0,1)";
95
+ var MARK_TARGET = "@mark";
96
+ var SPREAD_BEAT = { preset: "spread" /* Spread */, durationMs: 300, distance: 1.6 };
97
+ var PRESET_DEFAULTS = {
98
+ ["draw" /* Draw */]: { preset: "draw" /* Draw */, durationMs: 700, stepMs: 120 },
99
+ ["flood" /* Flood */]: { preset: "flood" /* Flood */, durationMs: 500, delayMs: 300, stepMs: 80 },
100
+ ["stagger-rise" /* StaggerRise */]: { preset: "stagger-rise" /* StaggerRise */, durationMs: 600, stepMs: 150, distance: 4 },
101
+ ["scale-pop" /* ScalePop */]: { preset: "scale-pop" /* ScalePop */, durationMs: 500, stepMs: 120 },
102
+ ["orbit" /* Orbit */]: { preset: "orbit" /* Orbit */, durationMs: 800, stepMs: 100 },
103
+ ["wipe" /* Wipe */]: { preset: "wipe" /* Wipe */, durationMs: 700, stepMs: 120 },
104
+ ["morph-from-circle" /* MorphFromCircle */]: { preset: "morph-from-circle" /* MorphFromCircle */, durationMs: 1200, stops: [0, 40, 100] },
105
+ ["sweep" /* Sweep */]: { preset: "sweep" /* Sweep */, durationMs: 600, delayMs: 400, stepMs: 60, share: 0.12, width: 2 },
106
+ ["pulse" /* Pulse */]: { preset: "pulse" /* Pulse */, durationMs: 400, delayMs: 700, layers: [MARK_TARGET], scale: 1.07 },
107
+ ["spread" /* Spread */]: SPREAD_BEAT,
108
+ ["fly-in" /* FlyIn */]: { preset: "fly-in" /* FlyIn */, durationMs: 700, stepMs: 120 },
109
+ ["spin-assemble" /* SpinAssemble */]: { preset: "spin-assemble" /* SpinAssemble */, durationMs: 800, stepMs: 100 },
110
+ ["drop-bounce" /* DropBounce */]: { preset: "drop-bounce" /* DropBounce */, durationMs: 800, stepMs: 100 },
111
+ ["flip" /* Flip */]: { preset: "flip" /* Flip */, durationMs: 700, stepMs: 120 },
112
+ ["slam-shake" /* SlamShake */]: { preset: "slam-shake" /* SlamShake */, durationMs: 800, layers: [MARK_TARGET] }
113
+ };
114
+ var DEFAULT_MOTION_CONFIG = {
115
+ intro: [{ preset: "stagger-rise" /* StaggerRise */, durationMs: 600, stepMs: 150, distance: 4 }],
116
+ micro: [{ preset: "spread" /* Spread */, durationMs: 300, distance: 1.6, easing: EASE }]
117
+ };
118
+
119
+ // src/motion/IdleRecipe.ts
120
+ var IDLE_RECIPES = ["rim-glint" /* RimGlint */, "faces-part" /* FacesPart */, "breath" /* Breath */, "orbit-spark" /* OrbitSpark */];
121
+
122
+ // src/motion/timeline.ts
123
+ function targetsOf(beat, layerNames) {
124
+ if (!beat.layers) {
125
+ return [...layerNames];
241
126
  }
242
- return x1 < 0 ? null : { x: x0, y: y0, w: x1 - x0 + 1, h: y1 - y0 + 1 };
127
+ return beat.layers.includes(MARK_TARGET) ? [MARK_TARGET] : layerNames.filter((n) => beat.layers?.includes(n));
243
128
  }
244
- function normalise(mask, w, h) {
245
- const out = new Uint8Array(GRID * GRID);
246
- const box = maskBox(mask, w, h);
247
- if (!box) {
248
- return out;
249
- }
250
- const side = Math.max(box.w, box.h);
251
- const ox = box.x - (side - box.w) / 2;
252
- const oy = box.y - (side - box.h) / 2;
253
- for (let gy = 0; gy < GRID; gy++) {
254
- for (let gx = 0; gx < GRID; gx++) {
255
- let hits = 0;
256
- for (let s = 0; s < SAMPLES * SAMPLES; s++) {
257
- const px2 = Math.floor(ox + (gx + (s % SAMPLES + 0.5) / SAMPLES) * side / GRID);
258
- const py = Math.floor(oy + (gy + (Math.floor(s / SAMPLES) + 0.5) / SAMPLES) * side / GRID);
259
- hits += px2 >= 0 && py >= 0 && px2 < w && py < h ? mask[py * w + px2] ?? 0 : 0;
260
- }
261
- out[gy * GRID + gx] = hits >= MAJORITY ? 1 : 0;
262
- }
263
- }
264
- return out;
129
+ function schedule(beat, layerNames) {
130
+ return targetsOf(beat, layerNames).map((target, k) => ({ target, delayMs: (beat.delayMs ?? 0) + k * (beat.stepMs ?? 0), durationMs: beat.durationMs }));
265
131
  }
266
- var rot90 = (g) => g.map((_, i) => g[(GRID - 1 - i % GRID) * GRID + Math.floor(i / GRID)] ?? 0);
267
- var mirror = (g) => g.map((_, i) => g[Math.floor(i / GRID) * GRID + (GRID - 1 - i % GRID)] ?? 0);
268
- function orientations(g) {
269
- const out = [];
270
- let cur = g;
271
- for (let k = 0; k < 4; k++) {
272
- out.push(cur, mirror(cur));
273
- cur = rot90(cur);
132
+ function totalMs(beats, layerNames) {
133
+ return Math.max(0, ...beats.flatMap((b) => schedule(b, layerNames).map((s) => s.delayMs + s.durationMs)));
134
+ }
135
+ function fitBeat(beat, n, capMs) {
136
+ const room = capMs - (beat.delayMs ?? 0) - beat.durationMs;
137
+ const step2 = n > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n - 1)))) : beat.stepMs ?? 0;
138
+ return { ...beat, stepMs: step2 };
139
+ }
140
+ function morphClashes(beats, layerNames) {
141
+ const morph = new Set(beats.filter((b) => b.preset === "morph-from-circle" /* MorphFromCircle */).flatMap((b) => targetsOf(b, layerNames)));
142
+ const other = beats.filter((b) => b.preset !== "morph-from-circle" /* MorphFromCircle */ && b.preset !== "sweep" /* Sweep */).flatMap((b) => targetsOf(b, layerNames));
143
+ return other.filter((t) => morph.has(t)).map((t) => `layer "${t}" has morph-from-circle and another preset`);
144
+ }
145
+ function validateMotion(config, layerNames) {
146
+ const introMs = totalMs(config.intro, layerNames);
147
+ const microMs = totalMs(config.micro, layerNames);
148
+ const errors = [
149
+ ...config.intro.filter((b) => !INTRO_PRESETS.includes(b.preset)).map((b) => `unknown intro preset "${b.preset}"`),
150
+ ...config.micro.filter((b) => !MICRO_PRESETS.includes(b.preset)).map((b) => `unknown micro preset "${b.preset}"`),
151
+ ...config.recipeErrors ?? [],
152
+ ...morphClashes(config.intro, layerNames)
153
+ ];
154
+ const warnings = [];
155
+ if (introMs > INTRO_CAP_MS) {
156
+ const message = `intro runs ${introMs} ms, cap ${INTRO_CAP_MS} ms`;
157
+ if (config.allowLongIntro !== void 0) {
158
+ warnings.push(`${message} (allowed: ${config.allowLongIntro})`);
159
+ } else {
160
+ errors.push(message);
161
+ }
274
162
  }
275
- return out;
163
+ if (microMs > MICRO_CAP_MS) {
164
+ errors.push(`micro runs ${microMs} ms, cap ${MICRO_CAP_MS} ms`);
165
+ }
166
+ return { introMs, microMs, errors, warnings };
276
167
  }
277
- var cell = (g, x, y) => x >= 0 && y >= 0 && x < GRID && y < GRID ? g[y * GRID + x] ?? 0 : 0;
278
- function iouAt(a, b, dx, dy) {
279
- let inter = 0;
280
- let union = 0;
281
- for (let i = 0; i < GRID * GRID; i++) {
282
- const va = a[i] ?? 0;
283
- const vb = cell(b, i % GRID + dx, Math.floor(i / GRID) + dy);
284
- inter += va & vb;
285
- union += va | vb;
168
+
169
+ // src/motion/recipes.ts
170
+ var REFERENCE_SIZE = 64;
171
+ var SETTLE_EASE = "cubic-bezier(0.23,1,0.32,1)";
172
+ var fit = (beat) => fitBeat(beat, beat.layers?.length ?? 1, INTRO_CAP_MS);
173
+ var all = (ctx) => [...ctx.roles.base, ...ctx.roles.parts];
174
+ var INTROS = {
175
+ ["rim-then-ink" /* RimThenInk */]: (ctx, k) => [
176
+ { preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 500, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE },
177
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 500, delayMs: 200, easing: EASE_IN_FIRST },
178
+ fit({ preset: "flood" /* Flood */, layers: ctx.roles.parts, durationMs: 400, delayMs: 600, stepMs: 100, easing: EASE })
179
+ ],
180
+ ["phase-wipe" /* PhaseWipe */]: (ctx, k) => [
181
+ { preset: "wipe" /* Wipe */, layers: ctx.roles.base, durationMs: 600, easing: EASE_IN_FIRST },
182
+ fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 400, delayMs: 500, stepMs: 120, distance: 4 * k, easing: EASE })
183
+ ],
184
+ ["faces-settle" /* FacesSettle */]: (ctx, k) => [
185
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
186
+ fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 500, delayMs: 300, stepMs: 150, distance: 6 * k, easing: EASE })
187
+ ],
188
+ ["turn-into-place" /* TurnIntoPlace */]: (ctx) => [fit({ preset: "orbit" /* Orbit */, layers: all(ctx), durationMs: 800, stepMs: 100, easing: EASE })],
189
+ ["grow-from-circles" /* GrowFromCircles */]: (ctx) => [
190
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
191
+ { preset: "morph-from-circle" /* MorphFromCircle */, layers: ctx.roles.parts, durationMs: 800, delayMs: 300, stops: [0, 40, 100], fadeIn: ctx.roles.parts, easing: EASE_IN_FIRST, settleEasing: EASE }
192
+ ],
193
+ ["fly-in" /* FlyIn */]: (ctx) => [fit({ preset: "fly-in" /* FlyIn */, layers: all(ctx), durationMs: 700, stepMs: 100 })],
194
+ ["spin-assemble" /* SpinAssemble */]: (ctx) => [
195
+ { preset: "scale-pop" /* ScalePop */, layers: ctx.roles.base, durationMs: 400 },
196
+ fit({ preset: "spin-assemble" /* SpinAssemble */, layers: ctx.roles.parts, durationMs: 700, delayMs: 200, stepMs: 100 })
197
+ ],
198
+ ["drop-bounce" /* DropBounce */]: (ctx) => [fit({ preset: "drop-bounce" /* DropBounce */, layers: all(ctx), durationMs: 800, stepMs: 100 })],
199
+ ["flip-faces" /* FlipFaces */]: (ctx) => [
200
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
201
+ fit({ preset: "flip" /* Flip */, layers: ctx.roles.parts, durationMs: 700, delayMs: 250, stepMs: 100 })
202
+ ],
203
+ ["slam-shake" /* SlamShake */]: () => [{ preset: "slam-shake" /* SlamShake */, layers: [MARK_TARGET], durationMs: 800 }],
204
+ ["grow-settle" /* GrowSettle */]: (ctx) => [
205
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 360, easing: EASE_IN_FIRST },
206
+ { preset: "morph-from-circle" /* MorphFromCircle */, layers: ctx.roles.parts, durationMs: 700, delayMs: 240, stops: [0, 40, 100], fadeIn: ctx.roles.parts, easing: EASE_IN_FIRST, settleEasing: SETTLE_EASE },
207
+ { preset: "pulse" /* Pulse */, layers: [MARK_TARGET], durationMs: 260, delayMs: 920, scale: 1.04, easing: SETTLE_EASE }
208
+ ]
209
+ };
210
+ var spread = (ctx, k) => ({ preset: "spread" /* Spread */, layers: ctx.roles.parts, durationMs: 300, distance: 1.6 * k, easing: EASE });
211
+ var glint = (ctx, k) => ({ preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 300, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE });
212
+ var MICROS = {
213
+ ["faces-part" /* FacesPart */]: (ctx, k) => [spread(ctx, k)],
214
+ ["breath" /* Breath */]: () => [{ preset: "pulse" /* Pulse */, layers: [MARK_TARGET], durationMs: 300, scale: 1.04, easing: EASE }],
215
+ ["rim-glint" /* RimGlint */]: (ctx, k) => [glint(ctx, k)],
216
+ ["part-and-glint" /* PartAndGlint */]: (ctx, k) => [spread(ctx, k), glint(ctx, k)]
217
+ };
218
+ var run = (table, name, ctx) => {
219
+ const recipe = table[name];
220
+ return recipe ? recipe(ctx, ctx.size / REFERENCE_SIZE) : null;
221
+ };
222
+ function introRecipe(name, ctx) {
223
+ return run(INTROS, name, ctx);
224
+ }
225
+ function microRecipe(name, ctx) {
226
+ return run(MICROS, name, ctx);
227
+ }
228
+
229
+ // src/motion/WordmarkRecipe.ts
230
+ var WORDMARK_RECIPES = [
231
+ "letter-stagger" /* LetterStagger */,
232
+ "slide-from-mark" /* SlideFromMark */,
233
+ "typewriter" /* Typewriter */,
234
+ "mask-wipe" /* MaskWipe */,
235
+ "tracking-settle" /* TrackingSettle */
236
+ ];
237
+
238
+ // src/motion/resolveMotion.ts
239
+ var KINDS = {
240
+ intro: { recipe: introRecipe, fallback: DEFAULT_MOTION_CONFIG.intro },
241
+ micro: { recipe: microRecipe, fallback: DEFAULT_MOTION_CONFIG.micro }
242
+ };
243
+ function resolve(kind, value, ctx) {
244
+ const { recipe, fallback } = KINDS[kind];
245
+ if (typeof value !== "string") {
246
+ return { beats: value ?? fallback };
286
247
  }
287
- return union > 0 ? inter / union : 0;
248
+ const beats = recipe(value, ctx);
249
+ return beats !== null ? { beats } : { beats: [], error: `unknown ${kind} recipe "${value}"` };
288
250
  }
289
- function bestIou(a, b) {
290
- let best = 0;
291
- for (let k = 0; k < 9; k++) {
292
- best = Math.max(best, iouAt(a, b, k % 3 - 1, Math.floor(k / 3) - 1));
251
+ function toWordmark(raw) {
252
+ if (raw === void 0) {
253
+ return void 0;
293
254
  }
294
- return best;
255
+ return typeof raw === "string" ? { recipe: raw, startMs: 0 } : { recipe: raw.recipe, startMs: raw.startMs ?? 0 };
256
+ }
257
+ var known = (list, kind, name) => name === void 0 || list.includes(name) ? [] : [`unknown ${kind} recipe "${name}"`];
258
+ function resolveMotion(raw, layerNames, size) {
259
+ const roles = { base: raw?.roles?.base ?? layerNames.slice(0, 1), parts: raw?.roles?.parts ?? layerNames.slice(1) };
260
+ const ctx = { roles, size };
261
+ const intro = resolve("intro", raw?.intro, ctx);
262
+ const micro = resolve("micro", raw?.micro, ctx);
263
+ const wordmark = toWordmark(raw?.wordmark);
264
+ const errors = [
265
+ ...[...roles.base, ...roles.parts].filter((n) => !layerNames.includes(n)).map((n) => `motion.roles names unknown layer "${n}"`),
266
+ ...[intro.error, micro.error].filter((e) => e !== void 0),
267
+ ...known(WORDMARK_RECIPES, "wordmark", wordmark?.recipe),
268
+ ...known(IDLE_RECIPES, "idle", raw?.idle)
269
+ ];
270
+ return {
271
+ intro: intro.beats,
272
+ micro: micro.beats,
273
+ ...wordmark !== void 0 ? { wordmark } : {},
274
+ ...raw?.idle !== void 0 ? { idle: { recipe: raw.idle } } : {},
275
+ ...raw?.allowLongIntro !== void 0 ? { allowLongIntro: raw.allowLongIntro } : {},
276
+ ...errors.length > 0 ? { recipeErrors: errors } : {}
277
+ };
278
+ }
279
+ function presetOf(id) {
280
+ const preset = PRESETS[id];
281
+ if (!preset) {
282
+ throw new Error(`unknown design-tokens preset "${id}", known: ${Object.keys(PRESETS).join(", ")}`);
283
+ }
284
+ return preset;
285
+ }
286
+ function resolveToken(ref) {
287
+ if (ref.startsWith("#")) {
288
+ return ref;
289
+ }
290
+ const [id = "", ...path7] = ref.split(".");
291
+ let node = presetOf(id);
292
+ for (const key2 of path7) {
293
+ node = typeof node === "object" && node !== null ? node[key2] : void 0;
294
+ }
295
+ if (typeof node !== "string") {
296
+ throw new Error(`token "${ref}" is not a colour`);
297
+ }
298
+ return node;
295
299
  }
296
300
 
297
- // src/checks/visible.ts
298
- var SEEN = 60;
299
- function visibleShare(tile, ink2) {
300
- const mask = alphaMask(ink2);
301
- const ground = [0, 1, 2].map((k) => tile.data[k] ?? 0);
302
- let total = 0;
303
- let seen = 0;
304
- mask.forEach((v, p) => {
305
- if (v === 1) {
306
- total++;
307
- const diff = ground.reduce((s, g, k) => s + Math.abs((tile.data[p * 4 + k] ?? 0) - g), 0);
308
- seen += diff > SEEN ? 1 : 0;
309
- }
310
- });
311
- return total > 0 ? seen / total : 0;
301
+ // src/config/loadBrand.ts
302
+ var DEFAULT_ICONS = { dark: true, share: 0.66, radius: 0.2 };
303
+ var DEFAULT_FONT = "Hanken Grotesk, Arial, sans-serif";
304
+ var DEFAULT_GENERATE = { seed: 1, count: 200 };
305
+ function toLayer(raw) {
306
+ const paint = raw.paint ?? (raw.role !== void 0 ? { light: [{ fill: raw.role }], dark: [{ fill: raw.role }] } : void 0);
307
+ if (!paint) {
308
+ throw new Error(`layer "${raw.name}" needs "role" or "paint"`);
309
+ }
310
+ return { name: raw.name, d: raw.d, paint, ...raw.transform !== void 0 ? { transform: raw.transform } : {}, ...raw.evenOdd === true ? { evenOdd: true } : {} };
311
+ }
312
+ var resolveAll = (refs) => Object.fromEntries(Object.entries(refs).map(([role, ref]) => [role, resolveToken(ref)]));
313
+ function toPalette(raw, name) {
314
+ const light = resolveAll(raw.light);
315
+ const dark = resolveAll(raw.dark);
316
+ const mono = raw.mono !== void 0 ? resolveToken(raw.mono) : light["text"] ?? "#000000";
317
+ return { name, light, dark, mono };
318
+ }
319
+ function parseBrand(raw, baseDir) {
320
+ const firstRef = Object.values(raw.palette.light).find((ref) => !ref.startsWith("#"));
321
+ const small = raw.smallMark;
322
+ const mark = { id: raw.slug, viewBox: raw.mark.viewBox, layers: raw.mark.layers.map(toLayer) };
323
+ return {
324
+ icons: { ...DEFAULT_ICONS, ...raw.icons },
325
+ ...small ? { smallMark: { ...small, light: resolveToken(small.light), dark: resolveToken(small.dark) } } : {},
326
+ name: raw.name,
327
+ slug: raw.slug,
328
+ wordmark: raw.wordmark ?? { fontFamily: DEFAULT_FONT },
329
+ mark,
330
+ palette: toPalette(raw.palette, raw.slug),
331
+ motion: resolveMotion(raw.motion, raw.mark.layers.map((l) => l.name), markSizeOf(mark)),
332
+ generate: raw.generate ?? DEFAULT_GENERATE,
333
+ tokens: raw.tokens ?? firstRef?.split(".")[0] ?? "flier",
334
+ baseDir
335
+ };
336
+ }
337
+ function loadBrand(file) {
338
+ const raw = JSON.parse(fs2.readFileSync(file, "utf8"));
339
+ return parseBrand(raw, path5.dirname(path5.resolve(file)));
312
340
  }
313
341
 
314
- // src/checks/symbols.ts
315
- var svg = (body) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">${body}</svg>`;
316
- var crescentBody = (dx, r) => `<mask id="c"><rect width="100" height="100" fill="#fff"/><circle cx="${50 + dx}" cy="50" r="${r}" fill="#000"/></mask><circle cx="50" cy="50" r="40" mask="url(#c)"/>`;
317
- var starPoints = (cx, cy, r, n, inner) => Array.from({ length: 2 * n }, (_, k) => {
318
- const t = -Math.PI / 2 + Math.PI * k / n;
319
- const rr = k % 2 === 0 ? r : r * inner;
320
- return `${(cx + rr * Math.cos(t)).toFixed(2)},${(cy + rr * Math.sin(t)).toFixed(2)}`;
321
- }).join(" ");
322
- var star5 = (cx, cy, r) => `<polygon points="${starPoints(cx, cy, r, 5, 0.4)}"/>`;
323
- var tri = (deg) => [0, 120, 240].map((a) => {
324
- const t = (deg + a) * Math.PI / 180;
325
- return `${(50 + 45 * Math.cos(t)).toFixed(2)},${(50 + 45 * Math.sin(t)).toFixed(2)}`;
326
- }).join(" ");
327
- var ironArm = (deg) => `<polygon transform="rotate(${deg} 50 50)" points="30,6 70,6 56,44 44,44"/>`;
328
- var SYMBOLS = [
329
- { id: "crescent-star", label: "Crescent and star", silhouettes: [svg(crescentBody(14, 33) + star5(72, 50, 15)), svg(crescentBody(10, 32) + star5(76, 50, 12))] },
330
- { id: "red-crescent", label: "Crescent (Red Crescent emblem)", silhouettes: [svg(crescentBody(14, 33)), svg(crescentBody(10, 32))] },
331
- { id: "latin-cross", label: "Latin cross", silhouettes: [svg('<rect x="42" y="8" width="16" height="84"/><rect x="22" y="28" width="56" height="16"/>')] },
332
- { id: "greek-cross", label: "Greek cross (Red Cross emblem)", silhouettes: [svg('<rect x="38" y="12" width="24" height="76"/><rect x="12" y="38" width="76" height="24"/>')] },
333
- { id: "star-of-david", label: "Star of David", silhouettes: [svg(`<polygon points="${tri(-90)}"/><polygon points="${tri(90)}"/>`)] },
334
- { id: "swastika", label: "Swastika", silhouettes: [svg('<rect x="44" y="15" width="12" height="70"/><rect x="15" y="44" width="70" height="12"/><rect x="44" y="15" width="41" height="12"/><rect x="73" y="44" width="12" height="41"/><rect x="15" y="73" width="41" height="12"/><rect x="15" y="15" width="12" height="41"/>')] },
335
- { id: "hammer-and-sickle", label: "Hammer and sickle", silhouettes: [svg('<path d="M28 28 A30 30 0 1 0 78 60" fill="none" stroke="#000" stroke-width="10"/><g transform="rotate(-45 50 50)"><rect x="46" y="28" width="8" height="58"/><rect x="34" y="20" width="32" height="12"/></g>')] },
336
- { id: "iron-cross", label: "Iron cross", silhouettes: [svg([0, 90, 180, 270].map(ironArm).join("") + '<rect x="42" y="42" width="16" height="16"/>')] },
337
- { id: "celtic-cross", label: "Celtic cross", silhouettes: [svg('<rect x="44" y="8" width="12" height="84"/><rect x="18" y="32" width="64" height="12"/><circle cx="50" cy="38" r="20" fill="none" stroke="#000" stroke-width="7"/>')] },
338
- { id: "ankh", label: "Ankh", silhouettes: [svg('<ellipse cx="50" cy="26" rx="13" ry="17" fill="none" stroke="#000" stroke-width="8"/><rect x="45" y="42" width="10" height="50"/><rect x="24" y="42" width="52" height="10"/>')] },
339
- { id: "pentagram", label: "Five-point star (pentagram)", silhouettes: [svg(star5(50, 52, 46))] },
340
- { id: "yin-yang", label: "Yin and yang", silhouettes: [svg('<path d="M50 5A45 45 0 0 1 50 95A22.5 22.5 0 0 1 50 50A22.5 22.5 0 0 0 50 5Z"/><circle cx="50" cy="27.5" r="7"/>')] },
341
- { id: "orthodox-cross", label: "Orthodox cross", silhouettes: [svg('<rect x="44" y="6" width="12" height="88"/><rect x="36" y="16" width="28" height="8"/><rect x="22" y="32" width="56" height="10"/><rect x="30" y="68" width="40" height="8" transform="rotate(-20 50 72)"/>')] }
342
- ];
342
+ // src/brand/pullBrand.ts
343
+ var normalise = (text) => text.replace(/\r\n/g, "\n");
344
+ function pullBrand(source, dest) {
345
+ loadBrand(source);
346
+ fs2.mkdirSync(path5.dirname(dest), { recursive: true });
347
+ fs2.writeFileSync(dest, fs2.readFileSync(source, "utf8"));
348
+ return dest;
349
+ }
350
+ function brandCopyDrift(copy, source) {
351
+ const drift = (reason) => ({ copy, source, reason });
352
+ if (!fs2.existsSync(source)) {
353
+ return drift("source missing");
354
+ }
355
+ if (!fs2.existsSync(copy)) {
356
+ return drift("copy missing");
357
+ }
358
+ return normalise(fs2.readFileSync(copy, "utf8")) === normalise(fs2.readFileSync(source, "utf8")) ? null : drift("content differs");
359
+ }
343
360
 
344
- // src/checks/lookalike.ts
345
- var LOOKALIKE_THRESHOLD = 0.7;
346
- var RENDER = 96;
347
- var INK = "#000000";
348
- var INK_PALETTE = { light: {}, dark: {}};
349
- var symbolGrids = /* @__PURE__ */ new Map();
350
- function gridOf(svg2) {
351
- const mask = alphaMask(renderSvg(svg2, RENDER));
352
- return { grid: normalise(mask, RENDER, RENDER), mask };
361
+ // src/brand/brandCli.ts
362
+ var BRAND_USAGE = "usage: logo-kit pull-brand <source brand.json> [--out dest] | logo-kit check-brand-copy <copy> --source <source brand.json>";
363
+ function brandCommand(cmd, file, flags2, out) {
364
+ if (cmd === "pull-brand") {
365
+ out(`pulled ${pullBrand(file, flags2.get("out") ?? path5.join("brand", path5.basename(file)))}`);
366
+ return 0;
367
+ }
368
+ if (cmd !== "check-brand-copy") {
369
+ return null;
370
+ }
371
+ const source = flags2.get("source");
372
+ if (source === void 0) {
373
+ out(BRAND_USAGE);
374
+ return 2;
375
+ }
376
+ const drift = brandCopyDrift(file, source);
377
+ out(drift === null ? `brand copy matches ${source}` : `brand copy drift: ${drift.reason} (${file} vs ${source}), run logo-kit pull-brand ${source} --out ${file}`);
378
+ return drift === null ? 0 : 1;
353
379
  }
354
- function gridsFor(id, silhouettes) {
355
- const cached = symbolGrids.get(id);
356
- if (cached) {
357
- return cached;
380
+
381
+ // src/core/CvdKind.ts
382
+ var CVD_KINDS = ["protan" /* Protan */, "deutan" /* Deutan */, "tritan" /* Tritan */];
383
+
384
+ // src/core/colour.ts
385
+ var MACHADO = {
386
+ ["protan" /* Protan */]: [[0.152286, 1.052583, -0.204868], [0.114503, 0.786281, 0.099216], [-3882e-6, -0.048116, 1.051998]],
387
+ ["deutan" /* Deutan */]: [[0.367322, 0.860646, -0.227968], [0.280085, 0.672501, 0.047413], [-0.01182, 0.04294, 0.968881]],
388
+ ["tritan" /* Tritan */]: [[1.255528, -0.076749, -0.178779], [-0.078411, 0.930809, 0.147602], [4733e-6, 0.691367, 0.3039]]
389
+ };
390
+ var HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;
391
+ var MAX = 255;
392
+ var GAMMA_KNEE = 0.04045;
393
+ var LINEAR_KNEE = 31308e-7;
394
+ var LAB_KNEE = 8856e-6;
395
+ function hexToRgb(hex) {
396
+ const match = HEX.exec(hex.trim());
397
+ if (!match?.[1]) {
398
+ throw new Error(`not a hex colour: ${hex}`);
358
399
  }
359
- const grids = silhouettes.map((s) => gridOf(s).grid);
360
- symbolGrids.set(id, grids);
361
- return grids;
400
+ const raw = match[1].length === 3 ? match[1].split("").map((c) => c + c).join("") : match[1];
401
+ return [0, 2, 4].map((i) => parseInt(raw.slice(i, i + 2), 16));
362
402
  }
363
- var scoreAgainst = (grid2, targets) => Math.max(0, ...orientations(grid2).flatMap((o) => targets.map((t) => bestIou(o, t))));
364
- function inkSvg(mark, only) {
365
- const layers = only === void 0 ? mark.layers : mark.layers.filter((_, i) => i === only);
366
- return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${mark.viewBox}">${markBody({ ...mark, layers }, INK_PALETTE, "light" /* Light */, { colourOverride: INK })}</svg>`;
403
+ function rgbToHex(rgb) {
404
+ return `#${rgb.map((c) => Math.round(Math.min(MAX, Math.max(0, c))).toString(16).padStart(2, "0")).join("")}`;
367
405
  }
368
- function crescentWithObject(mark) {
369
- const crescents = gridsFor("red-crescent", SYMBOLS.find((s) => s.id === "red-crescent")?.silhouettes ?? []);
370
- const layers = mark.layers.map((_, i) => gridOf(inkSvg(mark, i)));
371
- let best = 0;
372
- layers.forEach((layer, i) => {
373
- const score = scoreAgainst(layer.grid, crescents);
374
- const box = maskBox(layer.mask, RENDER, RENDER);
375
- const holdsObject = layers.some((other, j) => {
376
- const ob = maskBox(other.mask, RENDER, RENDER);
377
- if (j === i || !ob || !box) {
378
- return false;
379
- }
380
- const cx = ob.x + ob.w / 2;
381
- const cy = ob.y + ob.h / 2;
382
- return cx > box.x && cx < box.x + box.w && cy > box.y && cy < box.y + box.h && layer.mask[Math.floor(cy) * RENDER + Math.floor(cx)] === 0;
383
- });
384
- best = holdsObject ? Math.max(best, score) : best;
385
- });
386
- return best;
406
+ var toLinear = (c) => {
407
+ const s = c / MAX;
408
+ return s <= GAMMA_KNEE ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
409
+ };
410
+ var fromLinear = (l) => {
411
+ const v = Math.min(1, Math.max(0, l));
412
+ return MAX * (v <= LINEAR_KNEE ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055);
413
+ };
414
+ function simulateCvd(hex, kind) {
415
+ const lin = hexToRgb(hex).map(toLinear);
416
+ const out = MACHADO[kind].map((row) => row[0] * (lin[0] ?? 0) + row[1] * (lin[1] ?? 0) + row[2] * (lin[2] ?? 0));
417
+ return rgbToHex(out.map(fromLinear));
387
418
  }
388
- function svgSymbolScores(svg2) {
389
- const whole = gridOf(svg2).grid;
390
- return SYMBOLS.map((s) => ({ symbol: s.id, score: scoreAgainst(whole, gridsFor(s.id, s.silhouettes)) }));
419
+ function toLab(hex) {
420
+ const [r, g, b] = hexToRgb(hex).map(toLinear);
421
+ const xyz = [(0.4124 * r + 0.3576 * g + 0.1805 * b) / 0.95047, 0.2126 * r + 0.7152 * g + 0.0722 * b, (0.0193 * r + 0.1192 * g + 0.9505 * b) / 1.08883];
422
+ const f = (t) => t > LAB_KNEE ? Math.cbrt(t) : 7.787 * t + 16 / 116;
423
+ const [fx, fy, fz] = xyz.map(f);
424
+ return [116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)];
391
425
  }
392
- function symbolScores(mark) {
393
- const scores = svgSymbolScores(inkSvg(mark));
394
- const compound = crescentWithObject(mark);
395
- const cs = scores.find((s) => s.symbol === "crescent-star");
396
- if (cs && compound > cs.score) {
397
- cs.score = compound;
426
+ function deltaE(a, b) {
427
+ const la = toLab(a);
428
+ const lb = toLab(b);
429
+ return Math.hypot(la[0] - lb[0], la[1] - lb[1], la[2] - lb[2]);
430
+ }
431
+ function contrast(a, b) {
432
+ return contrastRatio(a, b);
433
+ }
434
+ var HALF = 128;
435
+ var ICO_HEADER = 6;
436
+ var ICO_ENTRY = 16;
437
+ var ICO_MAX_SIDE = 256;
438
+ var BITS = 32;
439
+ var options = (width, fontFiles) => ({
440
+ fitTo: { mode: "width", value: width },
441
+ font: { loadSystemFonts: false, fontFiles }
442
+ });
443
+ function renderSvg(svg2, width, fontFiles = []) {
444
+ const img = new Resvg(svg2, options(width, fontFiles)).render();
445
+ return { width: img.width, height: img.height, data: new Uint8Array(img.pixels) };
446
+ }
447
+ function renderPng(svg2, width, fontFiles = []) {
448
+ return new Resvg(svg2, options(width, fontFiles)).render().asPng();
449
+ }
450
+ function alphaMask(bmp) {
451
+ const out = new Uint8Array(bmp.width * bmp.height);
452
+ for (let i = 0; i < out.length; i++) {
453
+ out[i] = (bmp.data[i * 4 + 3] ?? 0) >= HALF ? 1 : 0;
398
454
  }
399
- return scores.sort((a, b) => b.score - a.score);
455
+ return out;
400
456
  }
401
- function symbolMatches(mark) {
402
- return symbolScores(mark).filter((s) => s.score >= LOOKALIKE_THRESHOLD);
457
+ function pngSize(png) {
458
+ const view = new DataView(png.buffer, png.byteOffset, png.byteLength);
459
+ return { width: view.getUint32(16), height: view.getUint32(20) };
460
+ }
461
+ function buildIco(pngs) {
462
+ const header = Buffer.alloc(ICO_HEADER + ICO_ENTRY * pngs.length);
463
+ header.writeUInt16LE(1, 2);
464
+ header.writeUInt16LE(pngs.length, 4);
465
+ let offset = header.length;
466
+ pngs.forEach((png, k) => {
467
+ const { width, height } = pngSize(png);
468
+ const pos = ICO_HEADER + ICO_ENTRY * k;
469
+ header.writeUInt8(width >= ICO_MAX_SIDE ? 0 : width, pos);
470
+ header.writeUInt8(height >= ICO_MAX_SIDE ? 0 : height, pos + 1);
471
+ header.writeUInt16LE(1, pos + 4);
472
+ header.writeUInt16LE(BITS, pos + 6);
473
+ header.writeUInt32LE(png.length, pos + 8);
474
+ header.writeUInt32LE(offset, pos + 12);
475
+ offset += png.length;
476
+ });
477
+ return Buffer.concat([header, ...pngs.map((p) => Buffer.from(p))]);
403
478
  }
404
479
 
405
- // src/checks/runChecks.ts
406
- var MIN_LAYER_PX = { 16: 2, 32: 6 };
407
- var MIN_COVER = 0.06;
408
- var MAX_COVER = 0.9;
409
- var MIN_BOX_FILL = 0.12;
410
- var MAX_BOX_FILL = 0.92;
411
- var ONE_COLOUR_SIZE = 64;
412
- var ink = (mask) => mask.reduce((s, v) => s + v, 0);
413
- function legibility(mark, size) {
480
+ // src/palette/paletteChecks.ts
481
+ var MIN_CONTRAST = 3;
482
+ var MIN_CVD_DELTA_E = 10;
483
+ var bgOf = (colours) => colours["background"] ?? "#ffffff";
484
+ function contrastFailures(palette, roles) {
414
485
  const out = [];
415
- const cover = ink(alphaMask(renderSvg(inkSvg(mark), size))) / (size * size);
416
- if (cover < MIN_COVER || cover > MAX_COVER) {
417
- out.push(`legible${size}: ink covers ${(cover * 100).toFixed(0)}% of the ${size} px tile`);
486
+ for (const [mode, colours] of [["light", palette.light], ["dark", palette.dark]]) {
487
+ for (const role of roles) {
488
+ const hex = colours[role];
489
+ if (hex === void 0) {
490
+ out.push(`contrast: ${mode} has no colour for "${role}"`);
491
+ } else if (contrast(hex, bgOf(colours)) < MIN_CONTRAST) {
492
+ out.push(`contrast: ${mode} "${role}" ${hex} is ${contrast(hex, bgOf(colours)).toFixed(2)}:1 on ${bgOf(colours)}`);
493
+ }
494
+ }
495
+ }
496
+ return out;
497
+ }
498
+ function cvdModeFailures(colours, roles, mode) {
499
+ const out = [];
500
+ const hexes = [...new Set(roles.map((r) => colours[r]).filter((h) => h !== void 0))];
501
+ for (const kind of CVD_KINDS) {
502
+ const sim = hexes.map((h) => simulateCvd(h, kind));
503
+ const bg = simulateCvd(bgOf(colours), kind);
504
+ sim.forEach((s, i) => {
505
+ if (contrast(s, bg) < MIN_CONTRAST) {
506
+ out.push(`cvd: ${mode} ${hexes[i] ?? ""} drops under 3:1 for ${kind}`);
507
+ }
508
+ sim.slice(i + 1).forEach((t, j) => {
509
+ if (deltaE(s, t) < MIN_CVD_DELTA_E) {
510
+ out.push(`cvd: ${mode} ${hexes[i] ?? ""} and ${hexes[i + j + 1] ?? ""} look the same for ${kind}`);
511
+ }
512
+ });
513
+ });
418
514
  }
419
- mark.layers.forEach((layer, i) => {
420
- const px2 = ink(alphaMask(renderSvg(inkSvg(mark, i), size)));
421
- if (px2 < (MIN_LAYER_PX[size] ?? 1)) {
422
- out.push(`legible${size}: layer "${layer.name}" is ${px2} px, lost at ${size} px`);
423
- }
424
- });
425
515
  return out;
426
516
  }
427
- function oneColour(mark) {
428
- const mask = alphaMask(renderSvg(inkSvg(mark), ONE_COLOUR_SIZE));
429
- const box = maskBox(mask, ONE_COLOUR_SIZE, ONE_COLOUR_SIZE);
430
- const fill = box ? ink(mask) / (box.w * box.h) : 0;
431
- return fill < MIN_BOX_FILL || fill > MAX_BOX_FILL ? [`oneColour: one colour fills ${(fill * 100).toFixed(0)}% of its box, reads as ${fill > MAX_BOX_FILL ? "a solid block" : "dust"}`] : [];
432
- }
433
- var MIN_REVERSED_SHOWN = 0.9;
434
- function reversed(mark, palette) {
435
- const ink2 = palette.light["background"] ?? "#ffffff";
436
- const bg = palette.dark["background"] ?? "#000000";
437
- const vb = viewBoxOf(mark);
438
- const body = markBody(mark, palette, "light" /* Light */, { colourOverride: ink2 });
439
- const svg2 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${mark.viewBox}"><rect x="${vb.x}" y="${vb.y}" width="${vb.w}" height="${vb.h}" fill="${bg}"/>${body}</svg>`;
440
- const shown = visibleShare(renderSvg(svg2, ONE_COLOUR_SIZE), renderSvg(inkSvg(mark), ONE_COLOUR_SIZE));
441
- const out = contrast(ink2, bg) < MIN_CONTRAST ? [`reversed: ${ink2} on ${bg} is under 3:1`] : [];
442
- return shown < MIN_REVERSED_SHOWN ? [...out, `reversed: only ${(shown * 100).toFixed(0)}% of the mark shows on ${bg}`] : out;
443
- }
444
- function runChecks(mark, palette) {
445
- const roles = rolesOf(mark);
446
- const symbols = symbolMatches(mark).map((m) => `symbol: looks like ${m.symbol} (${m.score.toFixed(2)})`);
447
- const reasons = [...legibility(mark, 16), ...legibility(mark, 32), ...oneColour(mark), ...reversed(mark, palette), ...contrastFailures(palette, roles), ...cvdFailures(palette, roles), ...symbols];
448
- return { pass: reasons.length === 0, reasons };
517
+ function cvdFailures(palette, roles) {
518
+ return [...cvdModeFailures(palette.light, roles, "light"), ...cvdModeFailures(palette.dark, roles, "dark")];
449
519
  }
450
- function checkVariants(seed, variants, palette) {
451
- const report = { seed, count: variants.length, passed: [], dropped: [] };
452
- for (const v of variants) {
453
- const result = runChecks(v.mark, palette);
454
- if (result.pass) {
455
- report.passed.push(v.id);
456
- } else {
457
- report.dropped.push({ id: v.id, recipe: v.recipe, reasons: result.reasons });
520
+
521
+ // src/palette/roles.ts
522
+ function rolesOf(mark) {
523
+ const roles = [];
524
+ for (const layer of mark.layers) {
525
+ for (const item of [...layer.paint.light, ...layer.paint.dark]) {
526
+ for (const role of [item.fill, item.stroke]) {
527
+ if (role !== void 0 && !roles.includes(role)) {
528
+ roles.push(role);
529
+ }
530
+ }
458
531
  }
459
532
  }
460
- return report;
533
+ return roles;
461
534
  }
462
535
 
463
- // src/motion/MotionPreset.ts
464
- var BOLD_PRESETS = [
465
- "fly-in" /* FlyIn */,
466
- "spin-assemble" /* SpinAssemble */,
467
- "drop-bounce" /* DropBounce */,
468
- "flip" /* Flip */,
469
- "slam-shake" /* SlamShake */
470
- ];
471
- var INTRO_PRESETS = [
472
- "draw" /* Draw */,
473
- "flood" /* Flood */,
474
- "stagger-rise" /* StaggerRise */,
475
- "scale-pop" /* ScalePop */,
476
- "orbit" /* Orbit */,
477
- "wipe" /* Wipe */,
478
- "morph-from-circle" /* MorphFromCircle */,
479
- "sweep" /* Sweep */,
480
- "pulse" /* Pulse */,
481
- ...BOLD_PRESETS
482
- ];
483
- var MICRO_PRESETS = ["spread" /* Spread */, "pulse" /* Pulse */, "sweep" /* Sweep */];
484
-
485
- // src/motion/defaults.ts
486
- var INTRO_CAP_MS = 1200;
487
- var MICRO_CAP_MS = 300;
488
- var EASE = "cubic-bezier(0.2,0,0,1)";
489
- var EASE_IN_FIRST = "cubic-bezier(0,0,0,1)";
490
- var MARK_TARGET = "@mark";
491
- var SPREAD_BEAT = { preset: "spread" /* Spread */, durationMs: 300, distance: 1.6 };
492
- var PRESET_DEFAULTS = {
493
- ["draw" /* Draw */]: { preset: "draw" /* Draw */, durationMs: 700, stepMs: 120 },
494
- ["flood" /* Flood */]: { preset: "flood" /* Flood */, durationMs: 500, delayMs: 300, stepMs: 80 },
495
- ["stagger-rise" /* StaggerRise */]: { preset: "stagger-rise" /* StaggerRise */, durationMs: 600, stepMs: 150, distance: 4 },
496
- ["scale-pop" /* ScalePop */]: { preset: "scale-pop" /* ScalePop */, durationMs: 500, stepMs: 120 },
497
- ["orbit" /* Orbit */]: { preset: "orbit" /* Orbit */, durationMs: 800, stepMs: 100 },
498
- ["wipe" /* Wipe */]: { preset: "wipe" /* Wipe */, durationMs: 700, stepMs: 120 },
499
- ["morph-from-circle" /* MorphFromCircle */]: { preset: "morph-from-circle" /* MorphFromCircle */, durationMs: 1200, stops: [0, 40, 100] },
500
- ["sweep" /* Sweep */]: { preset: "sweep" /* Sweep */, durationMs: 600, delayMs: 400, stepMs: 60, share: 0.12, width: 2 },
501
- ["pulse" /* Pulse */]: { preset: "pulse" /* Pulse */, durationMs: 400, delayMs: 700, layers: [MARK_TARGET], scale: 1.07 },
502
- ["spread" /* Spread */]: SPREAD_BEAT,
503
- ["fly-in" /* FlyIn */]: { preset: "fly-in" /* FlyIn */, durationMs: 700, stepMs: 120 },
504
- ["spin-assemble" /* SpinAssemble */]: { preset: "spin-assemble" /* SpinAssemble */, durationMs: 800, stepMs: 100 },
505
- ["drop-bounce" /* DropBounce */]: { preset: "drop-bounce" /* DropBounce */, durationMs: 800, stepMs: 100 },
506
- ["flip" /* Flip */]: { preset: "flip" /* Flip */, durationMs: 700, stepMs: 120 },
507
- ["slam-shake" /* SlamShake */]: { preset: "slam-shake" /* SlamShake */, durationMs: 800, layers: [MARK_TARGET] }
508
- };
509
- var DEFAULT_MOTION_CONFIG = {
510
- intro: [{ preset: "stagger-rise" /* StaggerRise */, durationMs: 600, stepMs: 150, distance: 4 }],
511
- micro: [{ preset: "spread" /* Spread */, durationMs: 300, distance: 1.6, easing: EASE }]
512
- };
513
-
514
- // src/motion/IdleRecipe.ts
515
- var IDLE_RECIPES = ["rim-glint" /* RimGlint */, "faces-part" /* FacesPart */, "breath" /* Breath */, "orbit-spark" /* OrbitSpark */];
516
-
517
- // src/motion/timeline.ts
518
- function targetsOf(beat, layerNames) {
519
- if (!beat.layers) {
520
- return [...layerNames];
536
+ // src/checks/grid.ts
537
+ var GRID = 24;
538
+ var SAMPLES = 3;
539
+ var MAJORITY = 5;
540
+ function maskBox(mask, w, h) {
541
+ let x0 = w;
542
+ let y0 = h;
543
+ let x1 = -1;
544
+ let y1 = -1;
545
+ for (let y = 0; y < h; y++) {
546
+ for (let x = 0; x < w; x++) {
547
+ if (mask[y * w + x] === 1) {
548
+ x0 = Math.min(x0, x);
549
+ y0 = Math.min(y0, y);
550
+ x1 = Math.max(x1, x);
551
+ y1 = Math.max(y1, y);
552
+ }
553
+ }
521
554
  }
522
- return beat.layers.includes(MARK_TARGET) ? [MARK_TARGET] : layerNames.filter((n) => beat.layers?.includes(n));
523
- }
524
- function schedule(beat, layerNames) {
525
- return targetsOf(beat, layerNames).map((target, k) => ({ target, delayMs: (beat.delayMs ?? 0) + k * (beat.stepMs ?? 0), durationMs: beat.durationMs }));
526
- }
527
- function totalMs(beats, layerNames) {
528
- return Math.max(0, ...beats.flatMap((b) => schedule(b, layerNames).map((s) => s.delayMs + s.durationMs)));
529
- }
530
- function fitBeat(beat, n, capMs) {
531
- const room = capMs - (beat.delayMs ?? 0) - beat.durationMs;
532
- const step2 = n > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n - 1)))) : beat.stepMs ?? 0;
533
- return { ...beat, stepMs: step2 };
534
- }
535
- function morphClashes(beats, layerNames) {
536
- const morph = new Set(beats.filter((b) => b.preset === "morph-from-circle" /* MorphFromCircle */).flatMap((b) => targetsOf(b, layerNames)));
537
- const other = beats.filter((b) => b.preset !== "morph-from-circle" /* MorphFromCircle */ && b.preset !== "sweep" /* Sweep */).flatMap((b) => targetsOf(b, layerNames));
538
- return other.filter((t) => morph.has(t)).map((t) => `layer "${t}" has morph-from-circle and another preset`);
555
+ return x1 < 0 ? null : { x: x0, y: y0, w: x1 - x0 + 1, h: y1 - y0 + 1 };
539
556
  }
540
- function validateMotion(config, layerNames) {
541
- const introMs = totalMs(config.intro, layerNames);
542
- const microMs = totalMs(config.micro, layerNames);
543
- const errors = [
544
- ...config.intro.filter((b) => !INTRO_PRESETS.includes(b.preset)).map((b) => `unknown intro preset "${b.preset}"`),
545
- ...config.micro.filter((b) => !MICRO_PRESETS.includes(b.preset)).map((b) => `unknown micro preset "${b.preset}"`),
546
- ...config.recipeErrors ?? [],
547
- ...morphClashes(config.intro, layerNames)
548
- ];
549
- const warnings = [];
550
- if (introMs > INTRO_CAP_MS) {
551
- const message = `intro runs ${introMs} ms, cap ${INTRO_CAP_MS} ms`;
552
- if (config.allowLongIntro !== void 0) {
553
- warnings.push(`${message} (allowed: ${config.allowLongIntro})`);
554
- } else {
555
- errors.push(message);
557
+ function normalise2(mask, w, h) {
558
+ const out = new Uint8Array(GRID * GRID);
559
+ const box = maskBox(mask, w, h);
560
+ if (!box) {
561
+ return out;
562
+ }
563
+ const side = Math.max(box.w, box.h);
564
+ const ox = box.x - (side - box.w) / 2;
565
+ const oy = box.y - (side - box.h) / 2;
566
+ for (let gy = 0; gy < GRID; gy++) {
567
+ for (let gx = 0; gx < GRID; gx++) {
568
+ let hits = 0;
569
+ for (let s = 0; s < SAMPLES * SAMPLES; s++) {
570
+ const px2 = Math.floor(ox + (gx + (s % SAMPLES + 0.5) / SAMPLES) * side / GRID);
571
+ const py = Math.floor(oy + (gy + (Math.floor(s / SAMPLES) + 0.5) / SAMPLES) * side / GRID);
572
+ hits += px2 >= 0 && py >= 0 && px2 < w && py < h ? mask[py * w + px2] ?? 0 : 0;
573
+ }
574
+ out[gy * GRID + gx] = hits >= MAJORITY ? 1 : 0;
556
575
  }
557
576
  }
558
- if (microMs > MICRO_CAP_MS) {
559
- errors.push(`micro runs ${microMs} ms, cap ${MICRO_CAP_MS} ms`);
577
+ return out;
578
+ }
579
+ var rot90 = (g) => g.map((_, i) => g[(GRID - 1 - i % GRID) * GRID + Math.floor(i / GRID)] ?? 0);
580
+ var mirror = (g) => g.map((_, i) => g[Math.floor(i / GRID) * GRID + (GRID - 1 - i % GRID)] ?? 0);
581
+ function orientations(g) {
582
+ const out = [];
583
+ let cur = g;
584
+ for (let k = 0; k < 4; k++) {
585
+ out.push(cur, mirror(cur));
586
+ cur = rot90(cur);
560
587
  }
561
- return { introMs, microMs, errors, warnings };
588
+ return out;
562
589
  }
563
-
564
- // src/motion/recipes.ts
565
- var REFERENCE_SIZE = 64;
566
- var SETTLE_EASE = "cubic-bezier(0.23,1,0.32,1)";
567
- var fit = (beat) => fitBeat(beat, beat.layers?.length ?? 1, INTRO_CAP_MS);
568
- var all = (ctx) => [...ctx.roles.base, ...ctx.roles.parts];
569
- var INTROS = {
570
- ["rim-then-ink" /* RimThenInk */]: (ctx, k) => [
571
- { preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 500, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE },
572
- { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 500, delayMs: 200, easing: EASE_IN_FIRST },
573
- fit({ preset: "flood" /* Flood */, layers: ctx.roles.parts, durationMs: 400, delayMs: 600, stepMs: 100, easing: EASE })
574
- ],
575
- ["phase-wipe" /* PhaseWipe */]: (ctx, k) => [
576
- { preset: "wipe" /* Wipe */, layers: ctx.roles.base, durationMs: 600, easing: EASE_IN_FIRST },
577
- fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 400, delayMs: 500, stepMs: 120, distance: 4 * k, easing: EASE })
578
- ],
579
- ["faces-settle" /* FacesSettle */]: (ctx, k) => [
580
- { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
581
- fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 500, delayMs: 300, stepMs: 150, distance: 6 * k, easing: EASE })
582
- ],
583
- ["turn-into-place" /* TurnIntoPlace */]: (ctx) => [fit({ preset: "orbit" /* Orbit */, layers: all(ctx), durationMs: 800, stepMs: 100, easing: EASE })],
584
- ["grow-from-circles" /* GrowFromCircles */]: (ctx) => [
585
- { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
586
- { preset: "morph-from-circle" /* MorphFromCircle */, layers: ctx.roles.parts, durationMs: 800, delayMs: 300, stops: [0, 40, 100], fadeIn: ctx.roles.parts, easing: EASE_IN_FIRST, settleEasing: EASE }
587
- ],
588
- ["fly-in" /* FlyIn */]: (ctx) => [fit({ preset: "fly-in" /* FlyIn */, layers: all(ctx), durationMs: 700, stepMs: 100 })],
589
- ["spin-assemble" /* SpinAssemble */]: (ctx) => [
590
- { preset: "scale-pop" /* ScalePop */, layers: ctx.roles.base, durationMs: 400 },
591
- fit({ preset: "spin-assemble" /* SpinAssemble */, layers: ctx.roles.parts, durationMs: 700, delayMs: 200, stepMs: 100 })
592
- ],
593
- ["drop-bounce" /* DropBounce */]: (ctx) => [fit({ preset: "drop-bounce" /* DropBounce */, layers: all(ctx), durationMs: 800, stepMs: 100 })],
594
- ["flip-faces" /* FlipFaces */]: (ctx) => [
595
- { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
596
- fit({ preset: "flip" /* Flip */, layers: ctx.roles.parts, durationMs: 700, delayMs: 250, stepMs: 100 })
597
- ],
598
- ["slam-shake" /* SlamShake */]: () => [{ preset: "slam-shake" /* SlamShake */, layers: [MARK_TARGET], durationMs: 800 }],
599
- ["grow-settle" /* GrowSettle */]: (ctx) => [
600
- { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 360, easing: EASE_IN_FIRST },
601
- { preset: "morph-from-circle" /* MorphFromCircle */, layers: ctx.roles.parts, durationMs: 700, delayMs: 240, stops: [0, 40, 100], fadeIn: ctx.roles.parts, easing: EASE_IN_FIRST, settleEasing: SETTLE_EASE },
602
- { preset: "pulse" /* Pulse */, layers: [MARK_TARGET], durationMs: 260, delayMs: 920, scale: 1.04, easing: SETTLE_EASE }
603
- ]
604
- };
605
- var spread = (ctx, k) => ({ preset: "spread" /* Spread */, layers: ctx.roles.parts, durationMs: 300, distance: 1.6 * k, easing: EASE });
606
- var glint = (ctx, k) => ({ preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 300, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE });
607
- var MICROS = {
608
- ["faces-part" /* FacesPart */]: (ctx, k) => [spread(ctx, k)],
609
- ["breath" /* Breath */]: () => [{ preset: "pulse" /* Pulse */, layers: [MARK_TARGET], durationMs: 300, scale: 1.04, easing: EASE }],
610
- ["rim-glint" /* RimGlint */]: (ctx, k) => [glint(ctx, k)],
611
- ["part-and-glint" /* PartAndGlint */]: (ctx, k) => [spread(ctx, k), glint(ctx, k)]
612
- };
613
- var run = (table, name, ctx) => {
614
- const recipe = table[name];
615
- return recipe ? recipe(ctx, ctx.size / REFERENCE_SIZE) : null;
616
- };
617
- function introRecipe(name, ctx) {
618
- return run(INTROS, name, ctx);
590
+ var cell = (g, x, y) => x >= 0 && y >= 0 && x < GRID && y < GRID ? g[y * GRID + x] ?? 0 : 0;
591
+ function iouAt(a, b, dx, dy) {
592
+ let inter = 0;
593
+ let union = 0;
594
+ for (let i = 0; i < GRID * GRID; i++) {
595
+ const va = a[i] ?? 0;
596
+ const vb = cell(b, i % GRID + dx, Math.floor(i / GRID) + dy);
597
+ inter += va & vb;
598
+ union += va | vb;
599
+ }
600
+ return union > 0 ? inter / union : 0;
619
601
  }
620
- function microRecipe(name, ctx) {
621
- return run(MICROS, name, ctx);
602
+ function bestIou(a, b) {
603
+ let best = 0;
604
+ for (let k = 0; k < 9; k++) {
605
+ best = Math.max(best, iouAt(a, b, k % 3 - 1, Math.floor(k / 3) - 1));
606
+ }
607
+ return best;
622
608
  }
623
609
 
624
- // src/motion/WordmarkRecipe.ts
625
- var WORDMARK_RECIPES = [
626
- "letter-stagger" /* LetterStagger */,
627
- "slide-from-mark" /* SlideFromMark */,
628
- "typewriter" /* Typewriter */,
629
- "mask-wipe" /* MaskWipe */,
630
- "tracking-settle" /* TrackingSettle */
610
+ // src/checks/visible.ts
611
+ var SEEN = 60;
612
+ function visibleShare(tile, ink2) {
613
+ const mask = alphaMask(ink2);
614
+ const ground = [0, 1, 2].map((k) => tile.data[k] ?? 0);
615
+ let total = 0;
616
+ let seen = 0;
617
+ mask.forEach((v, p) => {
618
+ if (v === 1) {
619
+ total++;
620
+ const diff = ground.reduce((s, g, k) => s + Math.abs((tile.data[p * 4 + k] ?? 0) - g), 0);
621
+ seen += diff > SEEN ? 1 : 0;
622
+ }
623
+ });
624
+ return total > 0 ? seen / total : 0;
625
+ }
626
+
627
+ // src/checks/symbols.ts
628
+ var svg = (body) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">${body}</svg>`;
629
+ var crescentBody = (dx, r) => `<mask id="c"><rect width="100" height="100" fill="#fff"/><circle cx="${50 + dx}" cy="50" r="${r}" fill="#000"/></mask><circle cx="50" cy="50" r="40" mask="url(#c)"/>`;
630
+ var starPoints = (cx, cy, r, n, inner) => Array.from({ length: 2 * n }, (_, k) => {
631
+ const t = -Math.PI / 2 + Math.PI * k / n;
632
+ const rr = k % 2 === 0 ? r : r * inner;
633
+ return `${(cx + rr * Math.cos(t)).toFixed(2)},${(cy + rr * Math.sin(t)).toFixed(2)}`;
634
+ }).join(" ");
635
+ var star5 = (cx, cy, r) => `<polygon points="${starPoints(cx, cy, r, 5, 0.4)}"/>`;
636
+ var tri = (deg) => [0, 120, 240].map((a) => {
637
+ const t = (deg + a) * Math.PI / 180;
638
+ return `${(50 + 45 * Math.cos(t)).toFixed(2)},${(50 + 45 * Math.sin(t)).toFixed(2)}`;
639
+ }).join(" ");
640
+ var ironArm = (deg) => `<polygon transform="rotate(${deg} 50 50)" points="30,6 70,6 56,44 44,44"/>`;
641
+ var SYMBOLS = [
642
+ { id: "crescent-star", label: "Crescent and star", silhouettes: [svg(crescentBody(14, 33) + star5(72, 50, 15)), svg(crescentBody(10, 32) + star5(76, 50, 12))] },
643
+ { id: "red-crescent", label: "Crescent (Red Crescent emblem)", silhouettes: [svg(crescentBody(14, 33)), svg(crescentBody(10, 32))] },
644
+ { id: "latin-cross", label: "Latin cross", silhouettes: [svg('<rect x="42" y="8" width="16" height="84"/><rect x="22" y="28" width="56" height="16"/>')] },
645
+ { id: "greek-cross", label: "Greek cross (Red Cross emblem)", silhouettes: [svg('<rect x="38" y="12" width="24" height="76"/><rect x="12" y="38" width="76" height="24"/>')] },
646
+ { id: "star-of-david", label: "Star of David", silhouettes: [svg(`<polygon points="${tri(-90)}"/><polygon points="${tri(90)}"/>`)] },
647
+ { id: "swastika", label: "Swastika", silhouettes: [svg('<rect x="44" y="15" width="12" height="70"/><rect x="15" y="44" width="70" height="12"/><rect x="44" y="15" width="41" height="12"/><rect x="73" y="44" width="12" height="41"/><rect x="15" y="73" width="41" height="12"/><rect x="15" y="15" width="12" height="41"/>')] },
648
+ { id: "hammer-and-sickle", label: "Hammer and sickle", silhouettes: [svg('<path d="M28 28 A30 30 0 1 0 78 60" fill="none" stroke="#000" stroke-width="10"/><g transform="rotate(-45 50 50)"><rect x="46" y="28" width="8" height="58"/><rect x="34" y="20" width="32" height="12"/></g>')] },
649
+ { id: "iron-cross", label: "Iron cross", silhouettes: [svg([0, 90, 180, 270].map(ironArm).join("") + '<rect x="42" y="42" width="16" height="16"/>')] },
650
+ { id: "celtic-cross", label: "Celtic cross", silhouettes: [svg('<rect x="44" y="8" width="12" height="84"/><rect x="18" y="32" width="64" height="12"/><circle cx="50" cy="38" r="20" fill="none" stroke="#000" stroke-width="7"/>')] },
651
+ { id: "ankh", label: "Ankh", silhouettes: [svg('<ellipse cx="50" cy="26" rx="13" ry="17" fill="none" stroke="#000" stroke-width="8"/><rect x="45" y="42" width="10" height="50"/><rect x="24" y="42" width="52" height="10"/>')] },
652
+ { id: "pentagram", label: "Five-point star (pentagram)", silhouettes: [svg(star5(50, 52, 46))] },
653
+ { id: "yin-yang", label: "Yin and yang", silhouettes: [svg('<path d="M50 5A45 45 0 0 1 50 95A22.5 22.5 0 0 1 50 50A22.5 22.5 0 0 0 50 5Z"/><circle cx="50" cy="27.5" r="7"/>')] },
654
+ { id: "orthodox-cross", label: "Orthodox cross", silhouettes: [svg('<rect x="44" y="6" width="12" height="88"/><rect x="36" y="16" width="28" height="8"/><rect x="22" y="32" width="56" height="10"/><rect x="30" y="68" width="40" height="8" transform="rotate(-20 50 72)"/>')] }
631
655
  ];
632
656
 
633
- // src/motion/resolveMotion.ts
634
- var KINDS = {
635
- intro: { recipe: introRecipe, fallback: DEFAULT_MOTION_CONFIG.intro },
636
- micro: { recipe: microRecipe, fallback: DEFAULT_MOTION_CONFIG.micro }
637
- };
638
- function resolve(kind, value, ctx) {
639
- const { recipe, fallback } = KINDS[kind];
640
- if (typeof value !== "string") {
641
- return { beats: value ?? fallback };
642
- }
643
- const beats = recipe(value, ctx);
644
- return beats !== null ? { beats } : { beats: [], error: `unknown ${kind} recipe "${value}"` };
657
+ // src/checks/lookalike.ts
658
+ var LOOKALIKE_THRESHOLD = 0.7;
659
+ var RENDER = 96;
660
+ var INK = "#000000";
661
+ var INK_PALETTE = { light: {}, dark: {}};
662
+ var symbolGrids = /* @__PURE__ */ new Map();
663
+ function gridOf(svg2) {
664
+ const mask = alphaMask(renderSvg(svg2, RENDER));
665
+ return { grid: normalise2(mask, RENDER, RENDER), mask };
645
666
  }
646
- function toWordmark(raw) {
647
- if (raw === void 0) {
648
- return void 0;
667
+ function gridsFor(id, silhouettes) {
668
+ const cached = symbolGrids.get(id);
669
+ if (cached) {
670
+ return cached;
649
671
  }
650
- return typeof raw === "string" ? { recipe: raw, startMs: 0 } : { recipe: raw.recipe, startMs: raw.startMs ?? 0 };
672
+ const grids = silhouettes.map((s) => gridOf(s).grid);
673
+ symbolGrids.set(id, grids);
674
+ return grids;
651
675
  }
652
- var known = (list, kind, name) => name === void 0 || list.includes(name) ? [] : [`unknown ${kind} recipe "${name}"`];
653
- function resolveMotion(raw, layerNames, size) {
654
- const roles = { base: raw?.roles?.base ?? layerNames.slice(0, 1), parts: raw?.roles?.parts ?? layerNames.slice(1) };
655
- const ctx = { roles, size };
656
- const intro = resolve("intro", raw?.intro, ctx);
657
- const micro = resolve("micro", raw?.micro, ctx);
658
- const wordmark = toWordmark(raw?.wordmark);
659
- const errors = [
660
- ...[...roles.base, ...roles.parts].filter((n) => !layerNames.includes(n)).map((n) => `motion.roles names unknown layer "${n}"`),
661
- ...[intro.error, micro.error].filter((e) => e !== void 0),
662
- ...known(WORDMARK_RECIPES, "wordmark", wordmark?.recipe),
663
- ...known(IDLE_RECIPES, "idle", raw?.idle)
664
- ];
665
- return {
666
- intro: intro.beats,
667
- micro: micro.beats,
668
- ...wordmark !== void 0 ? { wordmark } : {},
669
- ...raw?.idle !== void 0 ? { idle: { recipe: raw.idle } } : {},
670
- ...raw?.allowLongIntro !== void 0 ? { allowLongIntro: raw.allowLongIntro } : {},
671
- ...errors.length > 0 ? { recipeErrors: errors } : {}
672
- };
676
+ var scoreAgainst = (grid2, targets) => Math.max(0, ...orientations(grid2).flatMap((o) => targets.map((t) => bestIou(o, t))));
677
+ function inkSvg(mark, only) {
678
+ const layers = only === void 0 ? mark.layers : mark.layers.filter((_, i) => i === only);
679
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${mark.viewBox}">${markBody({ ...mark, layers }, INK_PALETTE, "light" /* Light */, { colourOverride: INK })}</svg>`;
673
680
  }
674
- function presetOf(id) {
675
- const preset = PRESETS[id];
676
- if (!preset) {
677
- throw new Error(`unknown design-tokens preset "${id}", known: ${Object.keys(PRESETS).join(", ")}`);
678
- }
679
- return preset;
681
+ function crescentWithObject(mark) {
682
+ const crescents = gridsFor("red-crescent", SYMBOLS.find((s) => s.id === "red-crescent")?.silhouettes ?? []);
683
+ const layers = mark.layers.map((_, i) => gridOf(inkSvg(mark, i)));
684
+ let best = 0;
685
+ layers.forEach((layer, i) => {
686
+ const score = scoreAgainst(layer.grid, crescents);
687
+ const box = maskBox(layer.mask, RENDER, RENDER);
688
+ const holdsObject = layers.some((other, j) => {
689
+ const ob = maskBox(other.mask, RENDER, RENDER);
690
+ if (j === i || !ob || !box) {
691
+ return false;
692
+ }
693
+ const cx = ob.x + ob.w / 2;
694
+ const cy = ob.y + ob.h / 2;
695
+ return cx > box.x && cx < box.x + box.w && cy > box.y && cy < box.y + box.h && layer.mask[Math.floor(cy) * RENDER + Math.floor(cx)] === 0;
696
+ });
697
+ best = holdsObject ? Math.max(best, score) : best;
698
+ });
699
+ return best;
680
700
  }
681
- function resolveToken(ref) {
682
- if (ref.startsWith("#")) {
683
- return ref;
684
- }
685
- const [id = "", ...path5] = ref.split(".");
686
- let node = presetOf(id);
687
- for (const key2 of path5) {
688
- node = typeof node === "object" && node !== null ? node[key2] : void 0;
689
- }
690
- if (typeof node !== "string") {
691
- throw new Error(`token "${ref}" is not a colour`);
701
+ function svgSymbolScores(svg2) {
702
+ const whole = gridOf(svg2).grid;
703
+ return SYMBOLS.map((s) => ({ symbol: s.id, score: scoreAgainst(whole, gridsFor(s.id, s.silhouettes)) }));
704
+ }
705
+ function symbolScores(mark) {
706
+ const scores = svgSymbolScores(inkSvg(mark));
707
+ const compound = crescentWithObject(mark);
708
+ const cs = scores.find((s) => s.symbol === "crescent-star");
709
+ if (cs && compound > cs.score) {
710
+ cs.score = compound;
692
711
  }
693
- return node;
712
+ return scores.sort((a, b) => b.score - a.score);
713
+ }
714
+ function symbolMatches(mark) {
715
+ return symbolScores(mark).filter((s) => s.score >= LOOKALIKE_THRESHOLD);
694
716
  }
695
717
 
696
- // src/config/loadBrand.ts
697
- var DEFAULT_ICONS = { dark: true, share: 0.66, radius: 0.2 };
698
- var DEFAULT_FONT = "Hanken Grotesk, Arial, sans-serif";
699
- var DEFAULT_GENERATE = { seed: 1, count: 200 };
700
- function toLayer(raw) {
701
- const paint = raw.paint ?? (raw.role !== void 0 ? { light: [{ fill: raw.role }], dark: [{ fill: raw.role }] } : void 0);
702
- if (!paint) {
703
- throw new Error(`layer "${raw.name}" needs "role" or "paint"`);
718
+ // src/checks/runChecks.ts
719
+ var MIN_LAYER_PX = { 16: 2, 32: 6 };
720
+ var MIN_COVER = 0.06;
721
+ var MAX_COVER = 0.9;
722
+ var MIN_BOX_FILL = 0.12;
723
+ var MAX_BOX_FILL = 0.92;
724
+ var ONE_COLOUR_SIZE = 64;
725
+ var ink = (mask) => mask.reduce((s, v) => s + v, 0);
726
+ function legibility(mark, size) {
727
+ const out = [];
728
+ const cover = ink(alphaMask(renderSvg(inkSvg(mark), size))) / (size * size);
729
+ if (cover < MIN_COVER || cover > MAX_COVER) {
730
+ out.push(`legible${size}: ink covers ${(cover * 100).toFixed(0)}% of the ${size} px tile`);
704
731
  }
705
- return { name: raw.name, d: raw.d, paint, ...raw.transform !== void 0 ? { transform: raw.transform } : {}, ...raw.evenOdd === true ? { evenOdd: true } : {} };
732
+ mark.layers.forEach((layer, i) => {
733
+ const px2 = ink(alphaMask(renderSvg(inkSvg(mark, i), size)));
734
+ if (px2 < (MIN_LAYER_PX[size] ?? 1)) {
735
+ out.push(`legible${size}: layer "${layer.name}" is ${px2} px, lost at ${size} px`);
736
+ }
737
+ });
738
+ return out;
706
739
  }
707
- var resolveAll = (refs) => Object.fromEntries(Object.entries(refs).map(([role, ref]) => [role, resolveToken(ref)]));
708
- function toPalette(raw, name) {
709
- const light = resolveAll(raw.light);
710
- const dark = resolveAll(raw.dark);
711
- const mono = raw.mono !== void 0 ? resolveToken(raw.mono) : light["text"] ?? "#000000";
712
- return { name, light, dark, mono };
740
+ function oneColour(mark) {
741
+ const mask = alphaMask(renderSvg(inkSvg(mark), ONE_COLOUR_SIZE));
742
+ const box = maskBox(mask, ONE_COLOUR_SIZE, ONE_COLOUR_SIZE);
743
+ const fill = box ? ink(mask) / (box.w * box.h) : 0;
744
+ return fill < MIN_BOX_FILL || fill > MAX_BOX_FILL ? [`oneColour: one colour fills ${(fill * 100).toFixed(0)}% of its box, reads as ${fill > MAX_BOX_FILL ? "a solid block" : "dust"}`] : [];
713
745
  }
714
- function parseBrand(raw, baseDir) {
715
- const firstRef = Object.values(raw.palette.light).find((ref) => !ref.startsWith("#"));
716
- const small = raw.smallMark;
717
- const mark = { id: raw.slug, viewBox: raw.mark.viewBox, layers: raw.mark.layers.map(toLayer) };
718
- return {
719
- icons: { ...DEFAULT_ICONS, ...raw.icons },
720
- ...small ? { smallMark: { ...small, light: resolveToken(small.light), dark: resolveToken(small.dark) } } : {},
721
- name: raw.name,
722
- slug: raw.slug,
723
- wordmark: raw.wordmark ?? { fontFamily: DEFAULT_FONT },
724
- mark,
725
- palette: toPalette(raw.palette, raw.slug),
726
- motion: resolveMotion(raw.motion, raw.mark.layers.map((l) => l.name), markSizeOf(mark)),
727
- generate: raw.generate ?? DEFAULT_GENERATE,
728
- tokens: raw.tokens ?? firstRef?.split(".")[0] ?? "mooncube",
729
- baseDir
730
- };
746
+ var MIN_REVERSED_SHOWN = 0.9;
747
+ function reversed(mark, palette) {
748
+ const ink2 = palette.light["background"] ?? "#ffffff";
749
+ const bg = palette.dark["background"] ?? "#000000";
750
+ const vb = viewBoxOf(mark);
751
+ const body = markBody(mark, palette, "light" /* Light */, { colourOverride: ink2 });
752
+ const svg2 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${mark.viewBox}"><rect x="${vb.x}" y="${vb.y}" width="${vb.w}" height="${vb.h}" fill="${bg}"/>${body}</svg>`;
753
+ const shown = visibleShare(renderSvg(svg2, ONE_COLOUR_SIZE), renderSvg(inkSvg(mark), ONE_COLOUR_SIZE));
754
+ const out = contrast(ink2, bg) < MIN_CONTRAST ? [`reversed: ${ink2} on ${bg} is under 3:1`] : [];
755
+ return shown < MIN_REVERSED_SHOWN ? [...out, `reversed: only ${(shown * 100).toFixed(0)}% of the mark shows on ${bg}`] : out;
731
756
  }
732
- function loadBrand(file) {
733
- const raw = JSON.parse(fs2.readFileSync(file, "utf8"));
734
- return parseBrand(raw, path3.dirname(path3.resolve(file)));
757
+ function runChecks(mark, palette) {
758
+ const roles = rolesOf(mark);
759
+ const symbols = symbolMatches(mark).map((m) => `symbol: looks like ${m.symbol} (${m.score.toFixed(2)})`);
760
+ const reasons = [...legibility(mark, 16), ...legibility(mark, 32), ...oneColour(mark), ...reversed(mark, palette), ...contrastFailures(palette, roles), ...cvdFailures(palette, roles), ...symbols];
761
+ return { pass: reasons.length === 0, reasons };
762
+ }
763
+ function checkVariants(seed, variants, palette) {
764
+ const report = { seed, count: variants.length, passed: [], dropped: [] };
765
+ for (const v of variants) {
766
+ const result = runChecks(v.mark, palette);
767
+ if (result.pass) {
768
+ report.passed.push(v.id);
769
+ } else {
770
+ report.dropped.push({ id: v.id, recipe: v.recipe, reasons: result.reasons });
771
+ }
772
+ }
773
+ return report;
735
774
  }
736
775
 
737
776
  // src/core/path.ts
@@ -1247,17 +1286,17 @@ var HEADERS = [[360, 40], [1280, 56]];
1247
1286
  var ICONS = [["apple-touch-icon.png", 180, false], ["icon-192.png", 192, true], ["icon-512.png", 512, true], ["icon-512-maskable.png", 512, false]];
1248
1287
  function writer(brand, outDir) {
1249
1288
  const files = [];
1250
- const fonts = brand.wordmark.fontFile !== void 0 ? [path3.resolve(brand.baseDir, brand.wordmark.fontFile)] : [];
1289
+ const fonts = brand.wordmark.fontFile !== void 0 ? [path5.resolve(brand.baseDir, brand.wordmark.fontFile)] : [];
1251
1290
  fs2.mkdirSync(outDir, { recursive: true });
1252
1291
  return {
1253
1292
  files,
1254
1293
  svg: (file, body, width, height) => {
1255
- fs2.writeFileSync(path3.join(outDir, file), body);
1294
+ fs2.writeFileSync(path5.join(outDir, file), body);
1256
1295
  files.push({ file, width, height });
1257
1296
  },
1258
1297
  png: (file, body, width) => {
1259
1298
  const png = renderPng(body, width, fonts);
1260
- fs2.writeFileSync(path3.join(outDir, file), png);
1299
+ fs2.writeFileSync(path5.join(outDir, file), png);
1261
1300
  files.push({ file, ...pngSize(png) });
1262
1301
  }
1263
1302
  };
@@ -1285,7 +1324,7 @@ function writeRasters(brand, w, outDir) {
1285
1324
  }
1286
1325
  const favicon = (s) => faviconSvg(brand, s) ?? iconCanvas(brand, "light" /* Light */, { w: s, h: s }, 1, null);
1287
1326
  const icoPngs = ICO_SIZES.map((s) => renderPng(favicon(s), s));
1288
- fs2.writeFileSync(path3.join(outDir, "favicon.ico"), buildIco(icoPngs));
1327
+ fs2.writeFileSync(path5.join(outDir, "favicon.ico"), buildIco(icoPngs));
1289
1328
  w.files.push({ file: "favicon.ico", width: Math.max(...ICO_SIZES), height: Math.max(...ICO_SIZES) });
1290
1329
  w.png("og.png", cardSvg(brand, "dark" /* Dark */, { w: 1200, h: 630 }), 1200);
1291
1330
  w.png("landing-card.png", cardSvg(brand, "light" /* Light */, { w: 640, h: 400 }), 640);
@@ -1305,9 +1344,9 @@ function exportBrand(brand, outDir) {
1305
1344
  w.svg(`header-${mode}-${vw}.svg`, lockup.svg, lockup.width, h);
1306
1345
  }
1307
1346
  }
1308
- const moduleDir = path3.join(outDir, `brand-${brand.slug}`);
1347
+ const moduleDir = path5.join(outDir, `brand-${brand.slug}`);
1309
1348
  fs2.mkdirSync(moduleDir, { recursive: true });
1310
- fs2.writeFileSync(path3.join(moduleDir, "markGeometry.ts"), geometryModule(brand.mark));
1349
+ fs2.writeFileSync(path5.join(moduleDir, "markGeometry.ts"), geometryModule(brand.mark));
1311
1350
  w.files.push({ file: `brand-${brand.slug}/markGeometry.ts`, width: 0, height: 0 });
1312
1351
  return w.files;
1313
1352
  }
@@ -1537,8 +1576,8 @@ var MIN_OPTIONS = 3;
1537
1576
  var MOTION_OPTIONS = ["stagger-rise" /* StaggerRise */, "scale-pop" /* ScalePop */, "orbit" /* Orbit */, "wipe" /* Wipe */, "morph-from-circle" /* MorphFromCircle */];
1538
1577
  function frame(outDir, file, mark, palette) {
1539
1578
  const rel = `frames/${file}.png`;
1540
- fs2.mkdirSync(path3.join(outDir, "frames"), { recursive: true });
1541
- fs2.writeFileSync(path3.join(outDir, rel), renderPng(frameSvg(mark, palette), FRAME.w));
1579
+ fs2.mkdirSync(path5.join(outDir, "frames"), { recursive: true });
1580
+ fs2.writeFileSync(path5.join(outDir, rel), renderPng(frameSvg(mark, palette), FRAME.w));
1542
1581
  return rel;
1543
1582
  }
1544
1583
  var option = (name, why, image, extra = {}) => ({ name, why, image, inventory: "1/1", aligned: "pass", targetBox: TARGET_BOX, ...extra });
@@ -1577,13 +1616,13 @@ function colourStep(brand, mark, outDir) {
1577
1616
  }
1578
1617
  function motionStep(mark, palette, outDir) {
1579
1618
  const still = frame(outDir, "motion-still", mark, palette);
1580
- fs2.mkdirSync(path3.join(outDir, "motion"), { recursive: true });
1619
+ fs2.mkdirSync(path5.join(outDir, "motion"), { recursive: true });
1581
1620
  const n = mark.layers.length;
1582
1621
  const options2 = MOTION_OPTIONS.map((preset) => {
1583
1622
  const base = PRESET_DEFAULTS[preset] ?? { preset, durationMs: 600 };
1584
1623
  const beat = preset === "morph-from-circle" /* MorphFromCircle */ ? { ...base, fadeIn: mark.layers.slice(1).map((l) => l.name) } : fitBeat(base, n, INTRO_CAP_MS);
1585
1624
  const rel = `motion/${preset}.svg`;
1586
- fs2.writeFileSync(path3.join(outDir, rel), frameSvg(mark, palette, [beat]));
1625
+ fs2.writeFileSync(path5.join(outDir, rel), frameSvg(mark, palette, [beat]));
1587
1626
  return option(preset, `The ${preset} intro, ${beat.durationMs} ms per layer, ends on the still.`, still, { motion: rel, targetBox: void 0 });
1588
1627
  });
1589
1628
  return { screen: "logo-motion", viewport: "mobile", kind: "motion", target: "n/a -- the options differ over time; every still frame is the same end frame", title: "Motion", question: "Which intro should the mark play?", options: options2 };
@@ -1602,18 +1641,18 @@ function buildPickSpec(brand, outDir) {
1602
1641
  noloss: "noloss: allow new screen -- a logo pick page has no screen fields",
1603
1642
  steps: [shape.step, colour.step, motion]
1604
1643
  };
1605
- fs2.writeFileSync(path3.join(outDir, "spec.json"), `${JSON.stringify(spec, null, 2)}
1644
+ fs2.writeFileSync(path5.join(outDir, "spec.json"), `${JSON.stringify(spec, null, 2)}
1606
1645
  `);
1607
1646
  return spec;
1608
1647
  }
1609
1648
  function buildPickPage(builder, outDir) {
1610
- const html = path3.join(outDir, "index.html");
1611
- execFileSync(process.execPath, [builder, path3.join(outDir, "spec.json"), html], { stdio: "inherit" });
1649
+ const html = path5.join(outDir, "index.html");
1650
+ execFileSync(process.execPath, [builder, path5.join(outDir, "spec.json"), html], { stdio: "inherit" });
1612
1651
  return html;
1613
1652
  }
1614
1653
 
1615
1654
  // src/cliMain.ts
1616
- var USAGE = "usage: logo-kit <export|generate|pick|check> <brand.json> [--out dir] [--seed n] [--count n] [--builder build-pick-page.mjs]";
1655
+ var USAGE = "usage: logo-kit <export|generate|pick|check|pull-brand|check-brand-copy> <brand.json> [--out dir] [--seed n] [--count n] [--builder build-pick-page.mjs]";
1617
1656
  function flags(args) {
1618
1657
  const out = /* @__PURE__ */ new Map();
1619
1658
  args.forEach((a, i) => {
@@ -1633,10 +1672,10 @@ function generate(file, f, out) {
1633
1672
  const variants = generateVariants(seed, count);
1634
1673
  fs2.mkdirSync(dir, { recursive: true });
1635
1674
  for (const v of variants) {
1636
- fs2.writeFileSync(path3.join(dir, `${v.id}.svg`), markSvg(v.mark, palette, "light" /* Light */, { label: v.recipe }));
1675
+ fs2.writeFileSync(path5.join(dir, `${v.id}.svg`), markSvg(v.mark, palette, "light" /* Light */, { label: v.recipe }));
1637
1676
  }
1638
1677
  const report = checkVariants(seed, variants, palette);
1639
- fs2.writeFileSync(path3.join(dir, `checks-${seed}.json`), `${JSON.stringify(report, null, 2)}
1678
+ fs2.writeFileSync(path5.join(dir, `checks-${seed}.json`), `${JSON.stringify(report, null, 2)}
1640
1679
  `);
1641
1680
  out(`generated ${count}, passed ${report.passed.length}, dropped ${report.dropped.length} -> ${dir}`);
1642
1681
  return 0;
@@ -1660,6 +1699,10 @@ function runCli(args, out = (line) => process.stdout.write(`${line}
1660
1699
  out(USAGE);
1661
1700
  return 2;
1662
1701
  }
1702
+ const brandExit = brandCommand(cmd, file, f, out);
1703
+ if (brandExit !== null) {
1704
+ return brandExit;
1705
+ }
1663
1706
  const refusal = cmd === "export" || cmd === "generate" ? motionRefusal(file) : null;
1664
1707
  if (refusal !== null) {
1665
1708
  out(refusal);
@@ -1677,7 +1720,7 @@ function runCli(args, out = (line) => process.stdout.write(`${line}
1677
1720
  const dir = f.get("out") ?? "pick";
1678
1721
  const spec = buildPickSpec(loadBrand(file), dir);
1679
1722
  const builder = f.get("builder");
1680
- out(builder !== void 0 ? `built ${buildPickPage(builder, dir)}` : `wrote ${spec.steps.length} steps -> ${path3.join(dir, "spec.json")}`);
1723
+ out(builder !== void 0 ? `built ${buildPickPage(builder, dir)}` : `wrote ${spec.steps.length} steps -> ${path5.join(dir, "spec.json")}`);
1681
1724
  return 0;
1682
1725
  }
1683
1726
  if (cmd === "check") {