@principal-ai/logo-component 0.1.16 → 0.1.18

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.
@@ -0,0 +1,148 @@
1
+ import React from 'react';
2
+ import type { Theme } from '@principal-ade/industry-theme';
3
+ export type FileCityMark = 'P' | 'AI' | 'PAI' | 'lockup' | 'none';
4
+ /**
5
+ * How the per-file shading of the mark is chosen.
6
+ * - `scatter`: each file picks a random shade (the default texture)
7
+ * - `vertical` / `horizontal` / `diagonal`: a smooth directional gradient
8
+ * across the grid, dark → light.
9
+ */
10
+ export type FileCityGradient = 'scatter' | 'vertical' | 'horizontal' | 'diagonal';
11
+ export interface FileCityLogoProps {
12
+ width?: number;
13
+ height?: number;
14
+ /**
15
+ * Which brand mark the primary-colored files spell out. `'none'` is a
16
+ * plain city grid with an optional single highlighted file.
17
+ */
18
+ mark?: FileCityMark;
19
+ /**
20
+ * Primary color — the tint of the files that form the mark and the
21
+ * brighter building shades. Defaults to the theme's `primary`.
22
+ */
23
+ primary?: string;
24
+ /**
25
+ * Accent color used for the `trail` overlay so it stands apart from
26
+ * the primary-colored mark. Defaults to the theme's `accent` (falling
27
+ * back to the primary color).
28
+ */
29
+ accent?: string;
30
+ /**
31
+ * Base color the neutral building tints are derived from (the
32
+ * equivalent of the theme's text color in TrailCityDiagram).
33
+ */
34
+ color?: string;
35
+ /**
36
+ * Panel background behind the grid. Pass `"transparent"` to drop the
37
+ * panel and let the mark sit directly on its surface.
38
+ */
39
+ background?: string;
40
+ /**
41
+ * Optional theme — fills `primary` / `color` / `background` for any
42
+ * that aren't passed explicitly, so the logo can ride a theme like
43
+ * TrailCityDiagram does, or take raw colors like the other logos.
44
+ */
45
+ theme?: Theme;
46
+ /** Grid size for the `'none'` plain-city variant (columns === rows). */
47
+ cells?: number;
48
+ /** For `mark="none"`: highlight one center file in the primary color. */
49
+ highlight?: boolean;
50
+ /**
51
+ * Render part of the mark as a code trail — the lower stem + base of
52
+ * the P's bowl become a dashed path with marker dots instead of solid
53
+ * files, nodding to TrailCityDiagram. Only applies to marks containing
54
+ * a "P" (`"P"` and `"PAI"`).
55
+ */
56
+ trail?: boolean;
57
+ /**
58
+ * How the mark's files are shaded. `diagonal` (default) runs a smooth
59
+ * dark→light gradient corner to corner; `vertical` / `horizontal` do
60
+ * the same in other directions; `scatter` gives each file a random shade.
61
+ */
62
+ gradient?: FileCityGradient;
63
+ /** Round the panel corners. Default true. */
64
+ rounded?: boolean;
65
+ /**
66
+ * Empty ring of city cells around the mark glyph, in cells. `1`
67
+ * (default) gives the mark breathing room; `0` packs the glyph
68
+ * edge-to-edge so each square is larger — e.g. a 3×5 "P" fills a 5×5
69
+ * grid instead of sitting in a 7×7 one.
70
+ */
71
+ margin?: number;
72
+ /**
73
+ * Drop a small "file card" into the bottom-right of the grid (3 cells
74
+ * across × 2 down) with **AI** as its contents — echoing the filename +
75
+ * snippet card from TrailCityDiagram. Only applies to `mark="P"`; the P
76
+ * is nudged one column left to clear room for the card.
77
+ */
78
+ aiCard?: boolean;
79
+ opacity?: number;
80
+ }
81
+ /**
82
+ * One rendered grid square of the file-city mark, with everything needed
83
+ * to draw it statically or animate it: its position, final fill / stroke,
84
+ * whether it belongs to the letter, and a `weight` (how strongly it
85
+ * contributes to the mark — letter files weigh more than city files) that
86
+ * the animated variant uses to decide how many "samples" a cell needs
87
+ * before it reaches full intensity.
88
+ */
89
+ export interface FileCityCell {
90
+ key: string;
91
+ c: number;
92
+ r: number;
93
+ x: number;
94
+ y: number;
95
+ sq: number;
96
+ rx: number;
97
+ fill: string;
98
+ stroke: string;
99
+ strokeWidth: number;
100
+ isLetter: boolean;
101
+ weight: number;
102
+ }
103
+ /**
104
+ * The resolved geometry + palette for a {@link FileCityLogo}, shared by the
105
+ * static component and {@link FileCityLogoAnimated} so the two never drift.
106
+ */
107
+ export interface FileCityLayout {
108
+ /** Grid squares, post skip/void culling, in render order. */
109
+ cells: FileCityCell[];
110
+ /** Overlay nodes (trail path/dots, AI card) drawn above the grid. */
111
+ extras: React.ReactNode[];
112
+ bgColor: string;
113
+ baseColor: string;
114
+ rounded: boolean;
115
+ opacity: number;
116
+ mark: FileCityMark;
117
+ }
118
+ /**
119
+ * Compute the full layout (cells + overlays + palette) for a file-city
120
+ * mark from the public props. Pure — no hooks — so both the static and
121
+ * animated components can build their SVG from the identical cell list.
122
+ */
123
+ export declare function computeFileCityLayout({ mark, primary, accent, color, background, theme, cells, highlight, trail, gradient, rounded, margin, aiCard, opacity, }: FileCityLogoProps): FileCityLayout;
124
+ /** Accessible label for a given mark, shared by both components. */
125
+ export declare function fileCityLabel(mark: FileCityMark): string;
126
+ /**
127
+ * SVG panel chrome shared by the static and animated components: the
128
+ * rounded background panel (clipping its children) and the edge hairline.
129
+ * `children` are the grid + overlays drawn inside the clip.
130
+ */
131
+ export declare const FileCityPanel: React.FC<{
132
+ width: number;
133
+ height: number;
134
+ bgColor: string;
135
+ baseColor: string;
136
+ rounded: boolean;
137
+ opacity: number;
138
+ label: string;
139
+ children: React.ReactNode;
140
+ }>;
141
+ /**
142
+ * A compact, iconic "file city" mark — the same top-down grid of file
143
+ * squares as {@link TrailCityDiagram}, distilled to a logo: a small grid
144
+ * of smaller buildings, no trail / markers / snippet. The primary-colored
145
+ * files spell out the brand mark (P / AI / PAI) so the letters emerge
146
+ * from the muted city.
147
+ */
148
+ export declare const FileCityLogo: React.FC<FileCityLogoProps>;
@@ -0,0 +1,459 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.FileCityLogo = exports.FileCityPanel = void 0;
37
+ exports.computeFileCityLayout = computeFileCityLayout;
38
+ exports.fileCityLabel = fileCityLabel;
39
+ const react_1 = __importStar(require("react"));
40
+ const VIEW = 100;
41
+ // Corner radius for the rounded panel, as a fraction of the panel side.
42
+ // macOS app icons use a ~22.4% continuous-corner ("squircle") radius; the
43
+ // Electron app supplies the transparent safe-area padding, so the panel
44
+ // fills the whole viewBox and just needs the right corner curvature to
45
+ // read as a native dock icon. A plain SVG rx is a close approximation.
46
+ const PANEL_RADIUS = VIEW * 0.2237;
47
+ // Width of the edge hairline (in viewBox units) that keeps the icon
48
+ // defined against the dock background.
49
+ const HAIRLINE = 0.75;
50
+ // 5-row pixel glyphs — the primary-colored files trace these.
51
+ // `1` = a mark (primary) file
52
+ // `H` = the letter's counter — a forced hole (background shows through,
53
+ // no city file) so the loop reads as a real hole
54
+ // `0` = a city file (muted backdrop)
55
+ const GLYPHS = {
56
+ // Closed bowl with a single hole punched in its center.
57
+ P: ['111', '1H1', '111', '100', '100'],
58
+ A: ['0110', '1HH1', '1111', '1001', '1001'],
59
+ I: ['111', '010', '010', '010', '111'],
60
+ };
61
+ const MARK_LETTERS = {
62
+ P: ['P'],
63
+ AI: ['A', 'I'],
64
+ PAI: ['P', 'A', 'I'],
65
+ };
66
+ /** Compose letters side by side (1 city column between them) into a
67
+ * single kind map: 1 = mark, 2 = void/hole, 0 = city. */
68
+ function composeMark(letters, gap = 1) {
69
+ const rows = 5;
70
+ const out = Array.from({ length: rows }, () => []);
71
+ letters.forEach((key, li) => {
72
+ if (li > 0)
73
+ for (let r = 0; r < rows; r++)
74
+ out[r].push(...new Array(gap).fill(0));
75
+ const glyph = GLYPHS[key];
76
+ for (let r = 0; r < rows; r++) {
77
+ for (const ch of glyph[r])
78
+ out[r].push(ch === '1' ? 1 : ch === 'H' ? 2 : 0);
79
+ }
80
+ });
81
+ return out;
82
+ }
83
+ function mulberry32(seed) {
84
+ let t = seed;
85
+ return () => {
86
+ t = (t + 0x6d2b79f5) | 0;
87
+ let r = t;
88
+ r = Math.imul(r ^ (r >>> 15), r | 1);
89
+ r ^= r + Math.imul(r ^ (r >>> 7), r | 61);
90
+ return ((r ^ (r >>> 14)) >>> 0) / 4294967296;
91
+ };
92
+ }
93
+ function withAlpha(color, alpha) {
94
+ // Accept #rgb / #rrggbb — leave non-hex as-is and rely on the caller.
95
+ if (/^#([0-9a-f]{3}){1,2}$/i.test(color)) {
96
+ let hex = color.slice(1);
97
+ if (hex.length === 3)
98
+ hex = hex.split('').map(c => c + c).join('');
99
+ const a = Math.round(Math.max(0, Math.min(1, alpha)) * 255)
100
+ .toString(16)
101
+ .padStart(2, '0');
102
+ return `#${hex}${a}`;
103
+ }
104
+ return color;
105
+ }
106
+ function toRgb(color) {
107
+ if (!/^#([0-9a-f]{3}){1,2}$/i.test(color))
108
+ return null;
109
+ let hex = color.slice(1);
110
+ if (hex.length === 3)
111
+ hex = hex.split('').map(c => c + c).join('');
112
+ return [
113
+ parseInt(hex.slice(0, 2), 16),
114
+ parseInt(hex.slice(2, 4), 16),
115
+ parseInt(hex.slice(4, 6), 16),
116
+ ];
117
+ }
118
+ /** Blend two colors. `t` = 0 returns `a`, `t` = 1 returns `b`. Falls
119
+ * back to `a` when either side isn't a parseable hex. */
120
+ function mix(a, b, t) {
121
+ const ca = toRgb(a);
122
+ const cb = toRgb(b);
123
+ if (!ca || !cb)
124
+ return a;
125
+ const ch = (i) => Math.round(ca[i] + (cb[i] - ca[i]) * Math.max(0, Math.min(1, t)))
126
+ .toString(16)
127
+ .padStart(2, '0');
128
+ return `#${ch(0)}${ch(1)}${ch(2)}`;
129
+ }
130
+ /**
131
+ * Compute the full layout (cells + overlays + palette) for a file-city
132
+ * mark from the public props. Pure — no hooks — so both the static and
133
+ * animated components can build their SVG from the identical cell list.
134
+ */
135
+ function computeFileCityLayout({ mark = 'P', primary, accent, color, background, theme, cells = 5, highlight = true, trail = false, gradient = 'diagonal', rounded = true, margin = 1, aiCard = false, opacity = 0.9, }) {
136
+ var _a, _b, _c, _d;
137
+ const primaryColor = (_a = primary !== null && primary !== void 0 ? primary : theme === null || theme === void 0 ? void 0 : theme.colors.primary) !== null && _a !== void 0 ? _a : '#22d3ee';
138
+ const accentColor = (_b = accent !== null && accent !== void 0 ? accent : theme === null || theme === void 0 ? void 0 : theme.colors.accent) !== null && _b !== void 0 ? _b : primaryColor;
139
+ const baseColor = (_c = color !== null && color !== void 0 ? color : theme === null || theme === void 0 ? void 0 : theme.colors.text) !== null && _c !== void 0 ? _c : '#f8fafc';
140
+ const bgColor = (_d = background !== null && background !== void 0 ? background : theme === null || theme === void 0 ? void 0 : theme.colors.background) !== null && _d !== void 0 ? _d : '#0a0f14';
141
+ // Same palette weighting as TrailCityDiagram so the two read as a set.
142
+ const palette = [
143
+ withAlpha(primaryColor, 0.18),
144
+ withAlpha(primaryColor, 0.32),
145
+ withAlpha(baseColor, 0.08),
146
+ withAlpha(baseColor, 0.14),
147
+ withAlpha(baseColor, 0.22),
148
+ ];
149
+ // The mark files vary in shade so the letter doesn't read as one flat
150
+ // block, but every shade stays vivid so it still stands out from the
151
+ // muted city behind it.
152
+ const markPalette = [
153
+ primaryColor,
154
+ mix(primaryColor, '#ffffff', 0.22),
155
+ mix(primaryColor, '#ffffff', 0.1),
156
+ withAlpha(primaryColor, 0.82),
157
+ ];
158
+ // Same idea for `accent` cells (e.g. the AI in the lockup), so they
159
+ // read in the accent color while the P stays primary.
160
+ const accentPalette = [
161
+ accentColor,
162
+ mix(accentColor, '#ffffff', 0.22),
163
+ mix(accentColor, '#ffffff', 0.1),
164
+ withAlpha(accentColor, 0.82),
165
+ ];
166
+ // Dimmed accent — used for the A in the lockup so it sits back from the
167
+ // brighter I.
168
+ const accentDimPalette = [
169
+ withAlpha(accentColor, 0.5),
170
+ withAlpha(accentColor, 0.62),
171
+ withAlpha(accentColor, 0.42),
172
+ withAlpha(accentColor, 0.55),
173
+ ];
174
+ // Build a square grid. For `mark="none"` it's a plain `cells × cells`
175
+ // city; otherwise the glyph bitmap sits inside a square grid (side =
176
+ // longest glyph dimension + a margin ring) so the city reads square.
177
+ const trailEnabled = trail && (mark === 'P' || mark === 'PAI');
178
+ const aiCardOn = aiCard && mark === 'P';
179
+ let side;
180
+ let offX = 0;
181
+ let offY = 0;
182
+ let kindAt;
183
+ if (mark === 'none') {
184
+ side = cells;
185
+ const hi = Math.floor((cells - 1) / 2);
186
+ kindAt = (c, r) => (highlight && c === hi && r === hi ? 'mark' : 'city');
187
+ }
188
+ else if (mark === 'lockup') {
189
+ // Brand lockup: P on the left (cols 0-2, vertically centered), a gap
190
+ // column, then a stacked "AI" filling the right 3 columns — A in the
191
+ // top 4 rows, I in the bottom 3.
192
+ side = 7;
193
+ const pGlyph = GLYPHS.P; // 3 × 5
194
+ const aGlyph = ['111', '1H1', '111', '101']; // 3 × 4
195
+ const iGlyph = ['111', '010', '111']; // 3 × 3
196
+ const at = (g, gc, gr) => {
197
+ if (gr < 0 || gr >= g.length)
198
+ return null;
199
+ const row = g[gr];
200
+ return gc < 0 || gc >= row.length ? null : row[gc];
201
+ };
202
+ kindAt = (c, r) => {
203
+ // P is primary; the stacked AI is accent.
204
+ const pch = at(pGlyph, c, r - 1); // P: cols 0-2, rows 1-5
205
+ if (pch != null) {
206
+ return pch === '1' ? 'mark' : pch === 'H' ? 'void' : 'city';
207
+ }
208
+ const ach = at(aGlyph, c - 4, r); // A: cols 4-6, rows 0-3 (dimmer)
209
+ if (ach != null) {
210
+ return ach === '1' ? 'accentDim' : ach === 'H' ? 'void' : 'city';
211
+ }
212
+ const ich = at(iGlyph, c - 4, r - 4); // I: cols 4-6, rows 4-6 (brighter)
213
+ if (ich != null) {
214
+ return ich === '1' ? 'accent' : ich === 'H' ? 'void' : 'city';
215
+ }
216
+ return 'city';
217
+ };
218
+ }
219
+ else {
220
+ const bitmap = composeMark(MARK_LETTERS[mark]);
221
+ const bw = bitmap[0].length;
222
+ const bh = bitmap.length;
223
+ side = Math.max(bw, bh) + margin * 2;
224
+ // With a trail, shove the letter to the left so the trail has room
225
+ // on the right; otherwise center it in the square.
226
+ offX = trailEnabled ? margin : Math.floor((side - bw) / 2);
227
+ // Nudge the P one column left so the AI card has room on the right.
228
+ if (aiCardOn)
229
+ offX = Math.max(0, offX - 1);
230
+ offY = Math.floor((side - bh) / 2);
231
+ kindAt = (c, r) => {
232
+ const bc = c - offX;
233
+ const br = r - offY;
234
+ if (br < 0 || br >= bh || bc < 0 || bc >= bw)
235
+ return 'city';
236
+ const v = bitmap[br][bc];
237
+ return v === 1 ? 'mark' : v === 2 ? 'void' : 'city';
238
+ };
239
+ }
240
+ const cols = side;
241
+ const rows = side;
242
+ // The AI card occupies the bottom-right 4×3 block of cells. Those cells
243
+ // render no building — the card covers them.
244
+ const AI_CARD_COLS = 3;
245
+ const AI_CARD_ROWS = 2;
246
+ // Inset one cell up and left from the bottom-right corner.
247
+ const aiCardC0 = cols - AI_CARD_COLS - 1;
248
+ const aiCardR0 = rows - AI_CARD_ROWS - 1;
249
+ // Nudge the card down half a cell so it straddles the row line — its
250
+ // body sits over the bottom of the top row and the top of the bottom
251
+ // row. The city renders behind it, so squares show around its edges.
252
+ const AI_CARD_ROW_SHIFT = 0.5;
253
+ const AI_CARD_COL_SHIFT = 0.5;
254
+ // Trail to the right of the letter — starts in the top-right corner,
255
+ // crosses 2 cells diagonally to its first node, zigzags down, and ends
256
+ // in the bottom-right corner. The dots sit on city files, which are
257
+ // forced to render under them.
258
+ const trailGrid = trailEnabled
259
+ ? [
260
+ [cols - 1, 0], // start: top-right corner
261
+ [cols - 3, 2], // first segment crosses 2 diagonally
262
+ [cols - 2, 4],
263
+ [cols - 1, rows - 1], // end: bottom-right corner
264
+ ]
265
+ : [];
266
+ const trailKeys = new Set(trailGrid.map(([c, r]) => `${c}-${r}`));
267
+ const centerOf = (c, r) => ({
268
+ x: startX + c * cell + cell / 2,
269
+ y: startY + r * cell + cell / 2,
270
+ });
271
+ // True when an edge neighbor is a letter file (mark or accent) — those
272
+ // city cells must always render so no empty square shares a side with
273
+ // the letter (and breaks a stroke). Diagonal corners are allowed to go
274
+ // empty, so the margins around the letter still get some missing squares.
275
+ const isLetterKind = (k) => k === 'mark' || k === 'accent' || k === 'accentDim';
276
+ const touchesMark = (c, r) => isLetterKind(kindAt(c - 1, r)) ||
277
+ isLetterKind(kindAt(c + 1, r)) ||
278
+ isLetterKind(kindAt(c, r - 1)) ||
279
+ isLetterKind(kindAt(c, r + 1));
280
+ // Per-file shade for a letter cell. `scatter` keeps the random-shade
281
+ // texture; the directional modes interpolate the letter's base color
282
+ // dark→light across the grid.
283
+ const baseFor = (kind) => kind === 'accent'
284
+ ? accentColor
285
+ : kind === 'accentDim'
286
+ ? mix(accentColor, bgColor, 0.45)
287
+ : primaryColor;
288
+ const gradientShade = (base, c, r) => {
289
+ const fx = cols > 1 ? c / (cols - 1) : 0;
290
+ const fy = rows > 1 ? r / (rows - 1) : 0;
291
+ const t = gradient === 'vertical'
292
+ ? fy
293
+ : gradient === 'horizontal'
294
+ ? fx
295
+ : (fx + fy) / 2; // diagonal
296
+ const lo = mix(base, '#000000', 0.12);
297
+ const hi = mix(base, '#ffffff', 0.4);
298
+ return mix(lo, hi, t);
299
+ };
300
+ // Square files centered in the panel; letterboxed when the mark is
301
+ // wider than it is tall (AI / PAI).
302
+ const pad = 12;
303
+ const avail = VIEW - pad * 2;
304
+ const cell = Math.min(avail / cols, avail / rows);
305
+ const sq = cell * 0.74; // smaller than the cell → gaps between buildings
306
+ const inset = (cell - sq) / 2;
307
+ const startX = (VIEW - cell * cols) / 2;
308
+ const startY = (VIEW - cell * rows) / 2;
309
+ const rng = mulberry32(7);
310
+ const cellsOut = [];
311
+ const extras = [];
312
+ // Track the previous cell to the left (per row) and above (per column)
313
+ // so we never leave two empty squares back to back in either
314
+ // direction — that's what produced the long blank runs.
315
+ const colEmpty = new Array(cols).fill(false);
316
+ for (let r = 0; r < rows; r++) {
317
+ let lastEmpty = false;
318
+ for (let c = 0; c < cols; c++) {
319
+ const kind = kindAt(c, r);
320
+ const skipRoll = rng();
321
+ const colorRoll = rng();
322
+ // Void cells are the letter's counter — leave them empty so the
323
+ // background shows through as a real hole. Mark files always
324
+ // render; city files skip occasionally so the primary letters read
325
+ // against a sparser, muted backdrop — but only when the square to
326
+ // the left and the square above are both filled, so gaps stay
327
+ // isolated.
328
+ if (kind === 'void') {
329
+ lastEmpty = true;
330
+ colEmpty[c] = true;
331
+ continue;
332
+ }
333
+ if (kind === 'city' && !lastEmpty && !colEmpty[c] && !touchesMark(c, r) && !trailKeys.has(`${c}-${r}`) && skipRoll < 0.2) {
334
+ lastEmpty = true;
335
+ colEmpty[c] = true;
336
+ continue;
337
+ }
338
+ lastEmpty = false;
339
+ colEmpty[c] = false;
340
+ const isLetter = isLetterKind(kind);
341
+ const letterPalette = kind === 'accent'
342
+ ? accentPalette
343
+ : kind === 'accentDim'
344
+ ? accentDimPalette
345
+ : markPalette;
346
+ const letterColor = kind === 'accent' || kind === 'accentDim' ? accentColor : primaryColor;
347
+ const letterFill = gradient === 'scatter'
348
+ ? letterPalette[Math.floor(colorRoll * letterPalette.length)]
349
+ : gradientShade(baseFor(kind), c, r);
350
+ const x = startX + c * cell + inset;
351
+ const y = startY + r * cell + inset;
352
+ cellsOut.push({
353
+ key: `${c}-${r}`,
354
+ c,
355
+ r,
356
+ x,
357
+ y,
358
+ sq,
359
+ rx: Math.max(1, sq * 0.12),
360
+ fill: isLetter
361
+ ? letterFill
362
+ : palette[Math.floor(colorRoll * palette.length)],
363
+ stroke: isLetter ? withAlpha(letterColor, 0.55) : withAlpha(baseColor, 0.08),
364
+ strokeWidth: isLetter ? 0.6 : 0.4,
365
+ isLetter,
366
+ // Letter files weigh the most so they build up over several
367
+ // samples; city files weigh less and resolve in one or two hits.
368
+ weight: isLetter ? 1 : 0.4,
369
+ });
370
+ }
371
+ }
372
+ // AI card — a small file card (filename header band + "AI" contents)
373
+ // dropped into the bottom-right block, mirroring TrailCityDiagram's
374
+ // snippet card.
375
+ if (aiCardOn) {
376
+ const cx0 = startX + (aiCardC0 + AI_CARD_COL_SHIFT) * cell + inset;
377
+ const cy0 = startY + (aiCardR0 + AI_CARD_ROW_SHIFT) * cell + inset;
378
+ const cw = AI_CARD_COLS * cell - inset * 2;
379
+ const chh = AI_CARD_ROWS * cell - inset * 2;
380
+ const headerH = chh * 0.28;
381
+ const cardR = Math.max(2, cell * 0.2);
382
+ const barH = Math.max(1, headerH * 0.26);
383
+ const fs = Math.min(cw * 0.42, (chh - headerH) * 0.64);
384
+ // Leader — anchored at the center of the P's bottom square. Routed
385
+ // with right-angle segments: down, right, up, then right into the
386
+ // card's left edge, "opening" the block. Dot at each end.
387
+ const aX = startX + (offX + 0.5) * cell; // center of the stem column
388
+ const aY = startY + (offY + 4.5) * cell; // middle of the bottom square
389
+ const bX = cx0; // left edge of the card
390
+ const bY = cy0 + chh * 0.2; // near the top of that edge
391
+ // Route along grid centerlines so the runs thread through square
392
+ // centers: dip to the row below the P, climb at the column just left
393
+ // of the card.
394
+ const valleyY = startY + (offY + 5.5) * cell; // center of the next row down
395
+ const turnX = startX + 2.5 * cell; // center of the 3rd column
396
+ const dot = Math.max(1, cell * 0.12);
397
+ const leaderPath = `M ${aX} ${aY} L ${aX} ${valleyY} L ${turnX} ${valleyY} L ${turnX} ${bY} L ${bX} ${bY}`;
398
+ extras.push(react_1.default.createElement("g", { key: "ai-leader", opacity: 0.75 },
399
+ react_1.default.createElement("path", { d: leaderPath, fill: "none", stroke: accentColor, strokeWidth: Math.max(0.6, cell * 0.07), strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: `${cell * 0.2} ${cell * 0.15}` }),
400
+ react_1.default.createElement("circle", { cx: aX, cy: aY, r: dot, fill: accentColor }),
401
+ react_1.default.createElement("circle", { cx: bX, cy: bY, r: dot, fill: accentColor })));
402
+ extras.push(react_1.default.createElement("g", { key: "ai-card" },
403
+ react_1.default.createElement("rect", { x: cx0, y: cy0, width: cw, height: chh, rx: cardR, fill: mix(bgColor, '#ffffff', 0.06), stroke: withAlpha(accentColor, 0.55), strokeWidth: 0.8 }),
404
+ react_1.default.createElement("path", { d: `M ${cx0} ${cy0 + headerH} L ${cx0} ${cy0 + cardR} Q ${cx0} ${cy0} ${cx0 + cardR} ${cy0} L ${cx0 + cw - cardR} ${cy0} Q ${cx0 + cw} ${cy0} ${cx0 + cw} ${cy0 + cardR} L ${cx0 + cw} ${cy0 + headerH} Z`, fill: withAlpha(accentColor, 0.14) }),
405
+ react_1.default.createElement("rect", { x: cx0 + cw * 0.16, y: cy0 + headerH / 2 - barH / 2, width: cw * 0.44, height: barH, rx: barH / 2, fill: withAlpha(baseColor, 0.5) }),
406
+ react_1.default.createElement("text", { x: cx0 + cw / 2, y: cy0 + headerH + (chh - headerH) / 2, textAnchor: "middle", dominantBaseline: "central", fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fontWeight: 700, fontSize: fs, letterSpacing: "0.06em", fill: accentColor }, "AI")));
407
+ }
408
+ // Trail overlay — a dashed accent path to the right of the letter with
409
+ // a marker dot on each node.
410
+ if (trailEnabled && trailGrid.length > 1) {
411
+ const linePts = trailGrid.map(([c, r]) => centerOf(c, r));
412
+ const d = linePts.map((p, i) => `${i ? 'L' : 'M'} ${p.x} ${p.y}`).join(' ');
413
+ const dot = Math.max(1.5, sq * 0.3);
414
+ extras.push(react_1.default.createElement("path", { key: "trail-path", d: d, fill: "none", stroke: accentColor, strokeWidth: Math.max(1, cell * 0.12), strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: `${cell * 0.18} ${cell * 0.18}`, opacity: 0.9 }));
415
+ trailGrid.forEach(([c, r], i) => {
416
+ const p = centerOf(c, r);
417
+ extras.push(react_1.default.createElement("circle", { key: `trail-dot-${i}`, cx: p.x, cy: p.y, r: dot, fill: mix(accentColor, '#ffffff', 0.15), stroke: bgColor, strokeWidth: 0.5 }));
418
+ });
419
+ }
420
+ return { cells: cellsOut, extras, bgColor, baseColor, rounded, opacity, mark };
421
+ }
422
+ /** Accessible label for a given mark, shared by both components. */
423
+ function fileCityLabel(mark) {
424
+ return mark === 'none'
425
+ ? 'A top-down grid of file squares'
426
+ : `A top-down grid of file squares spelling ${mark}`;
427
+ }
428
+ /**
429
+ * SVG panel chrome shared by the static and animated components: the
430
+ * rounded background panel (clipping its children) and the edge hairline.
431
+ * `children` are the grid + overlays drawn inside the clip.
432
+ */
433
+ const FileCityPanel = ({ width, height, bgColor, baseColor, rounded, opacity, label, children }) => {
434
+ const uid = (0, react_1.useId)().replace(/:/g, '');
435
+ return (react_1.default.createElement("svg", { width: width, height: height, viewBox: `0 0 ${VIEW} ${VIEW}`, xmlns: "http://www.w3.org/2000/svg", style: { opacity, display: 'block', overflow: 'visible' }, role: "img", "aria-label": label },
436
+ react_1.default.createElement("defs", null,
437
+ react_1.default.createElement("clipPath", { id: `panel-${uid}` },
438
+ react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, rx: rounded ? PANEL_RADIUS : 0 }))),
439
+ react_1.default.createElement("g", { clipPath: `url(#panel-${uid})` },
440
+ react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: bgColor, rx: rounded ? PANEL_RADIUS : 0 }),
441
+ children),
442
+ react_1.default.createElement("rect", { x: HAIRLINE / 2, y: HAIRLINE / 2, width: VIEW - HAIRLINE, height: VIEW - HAIRLINE, rx: rounded ? Math.max(0, PANEL_RADIUS - HAIRLINE / 2) : 0, fill: "none", stroke: withAlpha(baseColor, 0.14), strokeWidth: HAIRLINE })));
443
+ };
444
+ exports.FileCityPanel = FileCityPanel;
445
+ /**
446
+ * A compact, iconic "file city" mark — the same top-down grid of file
447
+ * squares as {@link TrailCityDiagram}, distilled to a logo: a small grid
448
+ * of smaller buildings, no trail / markers / snippet. The primary-colored
449
+ * files spell out the brand mark (P / AI / PAI) so the letters emerge
450
+ * from the muted city.
451
+ */
452
+ const FileCityLogo = (props) => {
453
+ const { width = 150, height = 150 } = props;
454
+ const { cells, extras, bgColor, baseColor, rounded, opacity, mark } = computeFileCityLayout(props);
455
+ return (react_1.default.createElement(exports.FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, label: fileCityLabel(mark) },
456
+ cells.map((cell) => (react_1.default.createElement("rect", { key: cell.key, x: cell.x, y: cell.y, width: cell.sq, height: cell.sq, rx: cell.rx, fill: cell.fill, stroke: cell.stroke, strokeWidth: cell.strokeWidth }))),
457
+ extras));
458
+ };
459
+ exports.FileCityLogo = FileCityLogo;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { type FileCityLogoProps } from './FileCityLogo';
3
+ export interface FileCityLogoAnimatedProps extends FileCityLogoProps {
4
+ /**
5
+ * Min / max number of cells in each group. The cells in a group reveal
6
+ * one at a time (`cellMs` apart); then the build holds for `pauseMs`
7
+ * before the next group. Default 3–6.
8
+ */
9
+ batchMin?: number;
10
+ batchMax?: number;
11
+ /** Milliseconds between cells within a group. Default 130. */
12
+ cellMs?: number;
13
+ /** Milliseconds to hold after a group completes, before the next. Default 700. */
14
+ pauseMs?: number;
15
+ /**
16
+ * Draw a connector line threading the cells of the active group in reveal
17
+ * order — it grows as each cell appears, then fades out during the pause.
18
+ * Default true.
19
+ */
20
+ connectors?: boolean;
21
+ /** Connector color. Defaults to the accent (falling back to primary). */
22
+ connectorColor?: string;
23
+ /**
24
+ * How many samples a full-weight (letter) cell needs before it reaches
25
+ * full intensity. City files need proportionally fewer (by their lower
26
+ * weight), so the letter builds up gradually while the city pops in. */
27
+ buildSteps?: number;
28
+ /** Start playing on mount. Default true. */
29
+ autoPlay?: boolean;
30
+ /** Replay key — change this value to restart the animation. */
31
+ playKey?: string | number;
32
+ /** Called once the heatmap has fully resolved. */
33
+ onComplete?: () => void;
34
+ }
35
+ /**
36
+ * Animated file-city mark: the squares accumulate like a heatmap. Each tick
37
+ * a batch of cells gets a "sample" added; letter cells weigh more so they
38
+ * take several samples to reach full intensity while city files resolve
39
+ * quickly. Once the summed weights fill in, the logo holds on screen.
40
+ */
41
+ export declare const FileCityLogoAnimated: React.FC<FileCityLogoAnimatedProps>;