@vectoriox/iox-ui 5.90.1 → 5.91.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.
@@ -0,0 +1,260 @@
1
+ import {
2
+ LAYOUT_TEXT_KINDS, LayoutDepth, LayoutLayer, LayoutLayerKind, LayoutPage, LayoutRole, LayoutSection, LayoutSectionKind, LayoutSize, LayoutTrack, LayoutTrackProp,
3
+ } from './layout-language';
4
+ import { SPEC_SITE_LAYOUT } from './site-spec.generated';
5
+
6
+ /**
7
+ * Space on a composed page (the M8 demo, the bar's live page 2026-11-10): what the static check can read off the grid
8
+ * about stillness and emptiness — a held section where nothing moves, a shape that is there for nothing, a stretch of the
9
+ * laptop's screen with nothing on it, an opening with no display. Estimates on the check's laptop (1440 × 900), the
10
+ * render check measures the real page. Pure.
11
+ */
12
+
13
+ const L = SPEC_SITE_LAYOUT;
14
+ const LIM = L.limits;
15
+
16
+ /**
17
+ * The laptop the estimates are made on (the render check's 1440 × 900). A grid column is taken as 1440 / 12 px and a row
18
+ * as its section's screens × 900 / rows (a held section's grid is its one-screen stage): the gutter and the column gaps
19
+ * are left out, so a box reads about a fifth wider than it renders — the render check measures the real one.
20
+ */
21
+ export const LAYOUT_CHECK_VIEWPORT = { width: 1440, height: 900 } as const;
22
+ const GRID = 12;
23
+ const COLUMN_PX = LAYOUT_CHECK_VIEWPORT.width / GRID;
24
+ /** A line of words stands its size × this tall. */
25
+ export const LAYOUT_LINE_HEIGHT = 1.2;
26
+ const HEBREW = /[֐-׿]/;
27
+ /** A button's ink, as tall as its padding and one line. */
28
+ const BUTTON_PX = 56;
29
+ /** How far the screens mend lowers a section at a time, and how often it tries. */
30
+ const SCREENS_STEP = 0.25;
31
+ const SCREENS_TRIES = 40;
32
+ /** The kinds the composer stretches over their whole cell (`place`); every other kind sits in its cell's middle. */
33
+ const FULL_CELL: ReadonlySet<string> = new Set([LayoutLayerKind.Photo, LayoutLayerKind.Shape, LayoutLayerKind.Gallery, LayoutLayerKind.Form, LayoutLayerKind.Marquee]);
34
+ /** The kinds a held section's line may be lit by the scroll (`kinetic`). */
35
+ export const LAYOUT_KINETIC_KINDS: ReadonlySet<string> = new Set([LayoutLayerKind.Word, LayoutLayerKind.Heading, LayoutLayerKind.Text]);
36
+
37
+ const span = (r: readonly number[] | undefined) => (r ? r[1] - r[0] : 0);
38
+ const isText = (l: LayoutLayer) => LAYOUT_TEXT_KINDS.has(l.kind);
39
+ const isPictured = (l: LayoutLayer) => l.kind === LayoutLayerKind.Photo || l.kind === LayoutLayerKind.Gallery;
40
+ const wordsOf = (t: string | undefined) => String(t ?? '').trim().split(/\s+/).filter(Boolean).length;
41
+ const meets = (a: LayoutLayer, b: LayoutLayer) => {
42
+ const ov = (p: readonly number[], q: readonly number[]) => p[0] < q[1] && q[0] < p[1];
43
+ return ov(a.col ?? [0, 0], b.col ?? [0, 0]) && ov(a.row ?? [0, 0], b.row ?? [0, 0]);
44
+ };
45
+ const textOf = (l: LayoutLayer) => String(l.text ?? (l.items ?? []).join(' '));
46
+ const advanceOf = (text: string) => (HEBREW.test(text) ? LIM.advance.hebrew : LIM.advance.latin);
47
+
48
+ /** A grid box's size in px on the laptop. */
49
+ export function layoutBoxPx(col: readonly number[], row: readonly number[], s: Pick<LayoutSection, 'pin' | 'screens' | 'rows'>): { w: number; h: number } {
50
+ const height = (s.pin ? 1 : s.screens) * LAYOUT_CHECK_VIEWPORT.height;
51
+ return { w: span(col) * COLUMN_PX, h: (span(row) * height) / Math.max(1, s.rows) };
52
+ }
53
+
54
+ /** Whether a sized text layer's words fit its box at its size (the check's estimate; a `screen` word is sized to fit). */
55
+ export function layoutTextFits(l: LayoutLayer, s: Pick<LayoutSection, 'pin' | 'screens' | 'rows'>, size: string | undefined = l.size): boolean {
56
+ const text = textOf(l);
57
+ if (!isText(l) || !size || size === LayoutSize.Screen || !text) return true;
58
+ const px = L.sizePx[size as keyof typeof L.sizePx];
59
+ const box = layoutBoxPx(l.col, l.row, s);
60
+ const lines = Math.floor(box.h / (px * LAYOUT_LINE_HEIGHT));
61
+ const items = l.kind === LayoutLayerKind.List ? Math.max(1, l.items?.length ?? 1) : 1;
62
+ return lines >= items && (text.length * px * advanceOf(text)) / Math.max(1, lines) <= box.w * LIM.textFitSlack;
63
+ }
64
+
65
+ /** Words or a button drawn over a layer (above it, meeting it). */
66
+ function wordsOver(s: LayoutSection, li: number): boolean {
67
+ const l = s.layers[li];
68
+ return s.layers.some((o, oi) => oi !== li && (isText(o) || o.kind === LayoutLayerKind.Button) && (o.z ?? 0) > (l.z ?? 0) && meets(o, l));
69
+ }
70
+
71
+ /**
72
+ * A rule: a shape one row high with no words on it — the looks' hairline ("a shape one row high"). The composer draws it
73
+ * as a line, never as the row's full height (the bar's grey boxes: a 150–180 px block where a hairline was meant).
74
+ */
75
+ export function isLayoutRule(s: LayoutSection, li: number): boolean {
76
+ const l = s.layers?.[li];
77
+ return !!l && l.kind === LayoutLayerKind.Shape && span(l.row) === 1 && !wordsOver(s, li);
78
+ }
79
+
80
+ /** Where a rule's line sits in its row: against the words it belongs to (above it → its top, below it → its bottom). */
81
+ export function layoutRuleEdge(s: LayoutSection, li: number): 'start' | 'end' | 'center' {
82
+ const l = s.layers[li];
83
+ const beside = (o: LayoutLayer) => isText(o) && (o.col?.[0] ?? 0) < (l.col?.[1] ?? 0) && (l.col?.[0] ?? 0) < (o.col?.[1] ?? 0);
84
+ if (s.layers.some((o, oi) => oi !== li && beside(o) && o.row?.[1] === l.row[0])) return 'start';
85
+ if (s.layers.some((o, oi) => oi !== li && beside(o) && o.row?.[0] === l.row[1])) return 'end';
86
+ return 'center';
87
+ }
88
+
89
+ /**
90
+ * A shape is there for something: a rule, a band of colour (wide, or off an edge), a backdrop to words, a frame meeting
91
+ * a picture, or it moves (tracks, a depth). Anything else is an empty box on the page.
92
+ */
93
+ export function layoutShapeHasPurpose(s: LayoutSection, li: number): boolean {
94
+ const l = s.layers?.[li];
95
+ if (!l || l.kind !== LayoutLayerKind.Shape) return true;
96
+ if (isLayoutRule(s, li) || wordsOver(s, li)) return true;
97
+ if (span(l.col) >= LIM.bandColumns || (l.bleed && l.bleed !== 'none')) return true;
98
+ if (s.layers.some((o, oi) => oi !== li && isPictured(o) && meets(o, l))) return true;
99
+ return !!l.motion?.length || (!!l.depth && l.depth !== LayoutDepth.Mid);
100
+ }
101
+
102
+ /** A held section where nothing moves by the scroll: no track, no kinetic line, no gallery the scroll turns. */
103
+ export function layoutHeldStill(s: LayoutSection): boolean {
104
+ if (!s.pin || (s.track ?? 1) > 1 || s.readyMade) return false;
105
+ return !(s.layers ?? []).some(l => !!l.motion?.length || !!l.kinetic || (l.kind === LayoutLayerKind.Gallery && !!l.gallery?.scroll));
106
+ }
107
+
108
+ /**
109
+ * The line a still hold can light word by word: a word, heading or text of 2 to the kinetic words, never over a picture —
110
+ * the lead first, then by size. -1: none.
111
+ */
112
+ export function layoutStillLine(s: LayoutSection): number {
113
+ const sizes = Object.keys(L.sizePx);
114
+ const found = (s.layers ?? [])
115
+ .map((l, li) => ({ l, li }))
116
+ .filter(({ l }) => LAYOUT_KINETIC_KINDS.has(l.kind) && wordsOf(l.text) >= 2 && wordsOf(l.text) <= LIM.kineticWords)
117
+ .filter(({ l }) => !(s.layers ?? []).some(o => o !== l && isPictured(o) && meets(o, l)))
118
+ .sort((a, b) => Number(b.l.role === LayoutRole.Lead) - Number(a.l.role === LayoutRole.Lead) || sizes.indexOf(b.l.size ?? 'm') - sizes.indexOf(a.l.size ?? 'm') || a.li - b.li);
119
+ return found[0]?.li ?? -1;
120
+ }
121
+
122
+ /** A held section's largest photo that may move (not decoration — decoration only fades), for a still hold that cannot
123
+ * let go of the page: -1, none. */
124
+ export function layoutDriftPhoto(s: LayoutSection): number {
125
+ const area = (l: LayoutLayer) => span(l.col) * span(l.row);
126
+ const found = (s.layers ?? []).map((l, li) => ({ l, li }))
127
+ .filter(({ l }) => l.kind === LayoutLayerKind.Photo && l.role !== LayoutRole.Decoration && Array.isArray(l.col) && Array.isArray(l.row))
128
+ .sort((a, b) => area(b.l) - area(a.l) || a.li - b.li);
129
+ return found[0]?.li ?? -1;
130
+ }
131
+
132
+ /** The drift a still hold's photo takes: a slow scale over the whole hold — transform only, inside the track's bounds. */
133
+ export const LAYOUT_DRIFT: Readonly<LayoutTrack> = { prop: LayoutTrackProp.Scale, from: 1, to: 1.08, at: [0, 1] };
134
+
135
+ /** A section whose screen is spoken for: what is on it never leaves it (held, sideways, a photo ground, ready-made), or
136
+ * its space is the point (an inhale — the page's one breath, a word in the quiet). */
137
+ const filled = (s: LayoutSection) => !!s.pin || (s.track ?? 1) > 1 || !!s.readyMade || String(s.ground ?? '').startsWith('photo:')
138
+ || s.kind === LayoutSectionKind.Inhale;
139
+
140
+ /** Where a layer's ink is in its section (px from the section's top): its cell for what stretches, its words' lines in the
141
+ * cell's middle for the rest, the line of a rule. */
142
+ function inkOf(s: LayoutSection, li: number, rowPx: number): [number, number] {
143
+ const l = s.layers[li];
144
+ const t = (l.row[0] - 1) * rowPx;
145
+ const b = (l.row[1] - 1) * rowPx;
146
+ const mid = (t + b) / 2;
147
+ if (l.kind === LayoutLayerKind.Shape && isLayoutRule(s, li)) {
148
+ const edge = layoutRuleEdge(s, li);
149
+ const at = edge === 'start' ? t : edge === 'end' ? b : mid;
150
+ return [at, at];
151
+ }
152
+ if (FULL_CELL.has(l.kind) || l.size === LayoutSize.Screen) return [t, b];
153
+ let h = BUTTON_PX;
154
+ if (isText(l)) {
155
+ const text = textOf(l);
156
+ const px = L.sizePx[(l.size ?? LayoutSize.M) as keyof typeof L.sizePx] ?? L.sizePx.m;
157
+ const w = Math.max(1, span(l.col) * COLUMN_PX);
158
+ const items = l.kind === LayoutLayerKind.List ? Math.max(1, l.items?.length ?? 1) : 1;
159
+ const lines = Math.max(items, Math.ceil((text.length * px * advanceOf(text)) / (w * LIM.textFitSlack)));
160
+ h = lines * px * LAYOUT_LINE_HEIGHT;
161
+ }
162
+ h = Math.min(b - t, h);
163
+ return [mid - h / 2, mid + h / 2];
164
+ }
165
+
166
+ /** A stretch of the laptop's page with nothing on it: where it is (px from the page's top) and the sections it lies in. */
167
+ export interface LayoutVoid {
168
+ from: number;
169
+ to: number;
170
+ sections: number[];
171
+ }
172
+
173
+ /**
174
+ * Every stretch more than `voidScreen` of a screen tall with nothing on it, top to bottom. A section that holds (or is a
175
+ * photo, or ready-made) fills its height; one that flows has its layers' ink (`inkOf`). Judged across the sections, as a
176
+ * visitor scrolls them; the end of the page counts (the footer is not the page's).
177
+ */
178
+ export function layoutVoids(sections: ReadonlyArray<LayoutSection>): LayoutVoid[] {
179
+ const ink: Array<[number, number]> = [];
180
+ const bounds: Array<[number, number]> = [];
181
+ let top = 0;
182
+ for (const s of sections) {
183
+ const height = Math.max(1, Number(s.screens) || 1) * LAYOUT_CHECK_VIEWPORT.height;
184
+ bounds.push([top, top + height]);
185
+ if (filled(s)) ink.push([top, top + height]);
186
+ else {
187
+ const rowPx = height / Math.max(1, s.rows);
188
+ (s.layers ?? []).forEach((l, li) => {
189
+ if (!Array.isArray(l.row) || !Array.isArray(l.col)) return;
190
+ const [a, b] = inkOf(s, li, rowPx);
191
+ ink.push([top + a, top + b]);
192
+ });
193
+ }
194
+ top += height;
195
+ }
196
+ ink.sort((a, b) => a[0] - b[0]);
197
+ const voids: LayoutVoid[] = [];
198
+ const least = LIM.voidScreen * LAYOUT_CHECK_VIEWPORT.height;
199
+ let end = 0;
200
+ const push = (from: number, to: number) => {
201
+ if (to - from <= least) return;
202
+ const within = bounds.map((b, i) => (b[0] < to && from < b[1] ? i : -1)).filter(i => i >= 0);
203
+ voids.push({ from: Math.round(from), to: Math.round(to), sections: within });
204
+ };
205
+ for (const [a, b] of ink) {
206
+ push(end, a);
207
+ end = Math.max(end, b);
208
+ }
209
+ push(end, top);
210
+ return voids;
211
+ }
212
+
213
+ /**
214
+ * The heights that close every void: the sections a void lies in that flow come down a quarter screen at a time (never
215
+ * under one screen; their rows keep their share, and each of their words still fits) until no void is left. Null when
216
+ * that cannot close them — then the model is asked.
217
+ */
218
+ export function layoutVoidScreens(sections: ReadonlyArray<LayoutSection>): Array<{ section: number; screens: number }> | null {
219
+ const next = sections.map(s => ({ ...s }));
220
+ const stuck = new Set<number>();
221
+ for (let tries = 0; tries < SCREENS_TRIES; tries++) {
222
+ const voids = layoutVoids(next);
223
+ if (!voids.length) {
224
+ return next.map((s, i) => ({ section: i, screens: s.screens })).filter(({ section, screens }) => screens !== sections[section].screens);
225
+ }
226
+ const free = [...new Set(voids.flatMap(v => v.sections))]
227
+ .filter(i => !filled(next[i]) && !stuck.has(i) && next[i].screens > 1)
228
+ .sort((a, b) => next[b].screens - next[a].screens || a - b);
229
+ if (!free.length) return null;
230
+ const i = free[0];
231
+ const lower = { ...next[i], screens: Math.max(1, Math.round((next[i].screens - SCREENS_STEP) * 100) / 100) };
232
+ if ((lower.layers ?? []).every(l => layoutTextFits(l, lower))) next[i] = lower;
233
+ else stuck.add(i);
234
+ }
235
+ return null;
236
+ }
237
+
238
+ /** The layers that make an opening's display: a word (set in the display face), or words at xxl or screen size. */
239
+ export function layoutOpeningDisplays(page: Pick<LayoutPage, 'sections'>): number[] {
240
+ const first = page.sections?.[0];
241
+ if (!first || first.readyMade) return [];
242
+ return (first.layers ?? []).map((l, li) => ({ l, li }))
243
+ .filter(({ l }) => isText(l) && (l.kind === LayoutLayerKind.Word || l.size === LayoutSize.Screen || l.size === LayoutSize.Xxl))
244
+ .map(({ li }) => li);
245
+ }
246
+
247
+ /**
248
+ * The opening's lead set as its display (a word) where it can be: a heading of at most `xl`'s characters. Its size goes
249
+ * up to xl where it still fits there. Null: no such lead.
250
+ */
251
+ export function layoutOpeningDisplayMend(page: Pick<LayoutPage, 'sections'>): { layer: number; size?: `${LayoutSize}` } | null {
252
+ const first = page.sections?.[0];
253
+ if (!first || first.readyMade) return null;
254
+ const li = (first.layers ?? []).findIndex(l => l.role === LayoutRole.Lead && l.kind === LayoutLayerKind.Heading);
255
+ if (li < 0) return null;
256
+ const lead = first.layers[li];
257
+ if (textOf(lead).length > L.maxChars.xl) return null;
258
+ const small = lead.size !== LayoutSize.Xl && lead.size !== LayoutSize.Xxl;
259
+ return small && layoutTextFits(lead, first, LayoutSize.Xl) ? { layer: li, size: LayoutSize.Xl } : { layer: li };
260
+ }
@@ -47,6 +47,8 @@ export interface PatternNode {
47
47
  readonly slot?: string;
48
48
  readonly fromBusiness?: string;
49
49
  readonly text?: string;
50
+ /** The pattern's own words on a Hebrew site (the contract's COPY_HE); `text` everywhere else. */
51
+ readonly textHe?: string;
50
52
  readonly ph?: string;
51
53
  readonly bind?: string;
52
54
  readonly alt?: string;
@@ -8,7 +8,7 @@ import { patternById } from './patterns';
8
8
  import { SerializedNode, walkSerialized } from './serialized-node';
9
9
  import { SitePlan } from './site-plan.model';
10
10
  import { STOCK_INTENT_ORDER, StockIntent } from './stock-match';
11
- import { OwnPhotoPlacement, planOwnPhotos, stockItemSlots, StockSlotKind, stockSlots, StockTarget } from './stock-photos';
11
+ import { OwnPhoto, OwnPhotoPlacement, planOwnPhotos, stockItemSlots, StockSlotKind, stockSlots, StockTarget } from './stock-photos';
12
12
 
13
13
  /**
14
14
  * Pictures MADE for a site (premium-components M7, AI plan I3, premium sites PS4) — pure and deterministic: which picture
@@ -96,8 +96,8 @@ export interface PicturePlan {
96
96
  }
97
97
 
98
98
  export interface PicturePlanOptions {
99
- /** The owner's own photos (urls), in order. */
100
- ownPhotos?: ReadonlyArray<string>;
99
+ /** The owner's own photos (urls, with what each shows), in order. */
100
+ ownPhotos?: ReadonlyArray<string | OwnPhoto>;
101
101
  /** The business type's rule (harness-core `BusinessType.stock`): where stock may not stand in for the work, no made
102
102
  * picture may either. */
103
103
  stockAllowed: boolean;
@@ -50,5 +50,6 @@ export * from './layout-section-fallback';
50
50
  export * from './layout-photos';
51
51
  export * from './photo-inventory';
52
52
  export * from './check-layout';
53
+ export * from './layout-space';
53
54
  export * from './layout-fingerprint';
54
55
  export * from './layout-edits';
@@ -600,7 +600,8 @@ export const SPEC_SITE_PATTERNS = {
600
600
  ]
601
601
  ]
602
602
  }
603
- ]
603
+ ],
604
+ "textHe": "צרו קשר"
604
605
  }
605
606
  ]
606
607
  }
@@ -751,7 +752,8 @@ export const SPEC_SITE_PATTERNS = {
751
752
  ]
752
753
  ]
753
754
  }
754
- ]
755
+ ],
756
+ "textHe": "צרו קשר"
755
757
  }
756
758
  ]
757
759
  }
@@ -1223,7 +1225,8 @@ export const SPEC_SITE_PATTERNS = {
1223
1225
  "slot": "cta",
1224
1226
  "max": 24,
1225
1227
  "text": "Get in touch",
1226
- "role": "nav.cta"
1228
+ "role": "nav.cta",
1229
+ "textHe": "צרו קשר"
1227
1230
  }
1228
1231
  ]
1229
1232
  }
@@ -1302,7 +1305,8 @@ export const SPEC_SITE_PATTERNS = {
1302
1305
  "slot": "cta",
1303
1306
  "max": 24,
1304
1307
  "text": "Get in touch",
1305
- "role": "nav.cta"
1308
+ "role": "nav.cta",
1309
+ "textHe": "צרו קשר"
1306
1310
  }
1307
1311
  ]
1308
1312
  }
@@ -1375,7 +1379,8 @@ export const SPEC_SITE_PATTERNS = {
1375
1379
  "level": "h4",
1376
1380
  "slot": "pagesLabel",
1377
1381
  "max": 40,
1378
- "text": "Pages"
1382
+ "text": "Pages",
1383
+ "textHe": "עמודים"
1379
1384
  },
1380
1385
  {
1381
1386
  "t": "Link",
@@ -1401,7 +1406,8 @@ export const SPEC_SITE_PATTERNS = {
1401
1406
  "level": "h4",
1402
1407
  "slot": "contactLabel",
1403
1408
  "max": 40,
1404
- "text": "Contact"
1409
+ "text": "Contact",
1410
+ "textHe": "יצירת קשר"
1405
1411
  },
1406
1412
  {
1407
1413
  "t": "Text",
@@ -1510,7 +1516,8 @@ export const SPEC_SITE_PATTERNS = {
1510
1516
  "level": "h4",
1511
1517
  "slot": "pagesLabel",
1512
1518
  "max": 40,
1513
- "text": "Pages"
1519
+ "text": "Pages",
1520
+ "textHe": "עמודים"
1514
1521
  },
1515
1522
  {
1516
1523
  "t": "Link",
@@ -1536,7 +1543,8 @@ export const SPEC_SITE_PATTERNS = {
1536
1543
  "level": "h4",
1537
1544
  "slot": "visitLabel",
1538
1545
  "max": 40,
1539
- "text": "Visit"
1546
+ "text": "Visit",
1547
+ "textHe": "ביקור"
1540
1548
  },
1541
1549
  {
1542
1550
  "t": "Text",
@@ -1565,7 +1573,8 @@ export const SPEC_SITE_PATTERNS = {
1565
1573
  "level": "h4",
1566
1574
  "slot": "contactLabel",
1567
1575
  "max": 40,
1568
- "text": "Contact"
1576
+ "text": "Contact",
1577
+ "textHe": "יצירת קשר"
1569
1578
  },
1570
1579
  {
1571
1580
  "t": "Text",
@@ -1746,7 +1755,8 @@ export const SPEC_SITE_PATTERNS = {
1746
1755
  "href": "/contact",
1747
1756
  "slot": "secondary",
1748
1757
  "max": 24,
1749
- "text": "Get in touch"
1758
+ "text": "Get in touch",
1759
+ "textHe": "צרו קשר"
1750
1760
  }
1751
1761
  ]
1752
1762
  }
@@ -1836,7 +1846,8 @@ export const SPEC_SITE_PATTERNS = {
1836
1846
  "href": "/contact",
1837
1847
  "slot": "primary",
1838
1848
  "max": 24,
1839
- "text": "Get in touch"
1849
+ "text": "Get in touch",
1850
+ "textHe": "צרו קשר"
1840
1851
  },
1841
1852
  {
1842
1853
  "t": "ButtonBlock",
@@ -2770,7 +2781,8 @@ export const SPEC_SITE_PATTERNS = {
2770
2781
  "href": "/contact",
2771
2782
  "slot": "action",
2772
2783
  "max": 24,
2773
- "text": "Get in touch"
2784
+ "text": "Get in touch",
2785
+ "textHe": "צרו קשר"
2774
2786
  }
2775
2787
  ]
2776
2788
  }
@@ -3516,7 +3528,8 @@ export const SPEC_SITE_PATTERNS = {
3516
3528
  "slot": "title",
3517
3529
  "max": 44,
3518
3530
  "text": "Get in touch",
3519
- "enter": "heading"
3531
+ "enter": "heading",
3532
+ "textHe": "צרו קשר"
3520
3533
  },
3521
3534
  {
3522
3535
  "t": "Text",
@@ -4537,7 +4550,8 @@ export const SPEC_SITE_PATTERNS = {
4537
4550
  "href": "/contact",
4538
4551
  "slot": "cta",
4539
4552
  "max": 24,
4540
- "text": "Get in touch"
4553
+ "text": "Get in touch",
4554
+ "textHe": "צרו קשר"
4541
4555
  }
4542
4556
  ]
4543
4557
  }
@@ -6189,6 +6203,8 @@ export const SPEC_SITE_LAYOUT = {
6189
6203
  "distinct": {
6190
6204
  "holdsMax": 1
6191
6205
  },
6206
+ "voidScreen": 0.6,
6207
+ "bandColumns": 10,
6192
6208
  "composedPages": 2,
6193
6209
  "repairs": 1
6194
6210
  },
@@ -118,6 +118,8 @@ export interface StockItemSlot extends StockNeed {
118
118
  index: number;
119
119
  /** The field playing the type's `image` role. */
120
120
  field: string;
121
+ /** The item's own name, as words (its `title`): an owner's photo stands under it only when it shows that. */
122
+ subject?: string[];
121
123
  }
122
124
 
123
125
  export type StockTarget = StockSlot | StockItemSlot;
@@ -125,40 +127,102 @@ export type StockTarget = StockSlot | StockItemSlot;
125
127
  /** Where the owner's photo goes: a slot of a composed section or the image field of a sample item. */
126
128
  export type OwnPhotoPlacement = (Pick<StockSlot, 'nodeId' | 'owner'> | { item: Pick<StockItemSlot, 'contentType' | 'index' | 'field'> }) & { url: string };
127
129
 
128
- /** The owner's photos, in order, come before any stock or sample picture: sections never repeat one, and sample items go round again. */
129
- export function planOwnPhotos(slots: ReadonlyArray<StockTarget>, urls: ReadonlyArray<string>): { placements: OwnPhotoPlacement[]; rest: StockTarget[] } {
130
- if (!urls.length) return { placements: [], rest: [...slots] };
130
+ /** One of the owner's photos: its address, and what it shows in words (the owner's description or the picture review's). */
131
+ export interface OwnPhoto {
132
+ url: string;
133
+ words?: string;
134
+ }
135
+
136
+ const ownPhotoOf = (photo: string | OwnPhoto): OwnPhoto => (typeof photo === 'string' ? { url: photo } : photo);
137
+
138
+ /** A title word counts this much more than any other word the item and the photo share. */
139
+ const OWN_NAMED_POINTS = 10;
140
+ /** Without its name, this many of the item's words must be in the photo's. */
141
+ const OWN_SHARED_MIN = 2;
142
+
143
+ /**
144
+ * How well an owner's photo stands under a sample item (M8 demo: the bar's room photos stood under "Martini" and
145
+ * "Negroni"): its words name the item, or share at least two of the item's words. 0 — it does not; a photo with no words
146
+ * never does.
147
+ */
148
+ export function ownPhotoFit(photo: OwnPhoto, subject: ReadonlyArray<string>, words: ReadonlyArray<string>): number {
149
+ const has = new Set(stockWords(photo.words));
150
+ if (!has.size) return 0;
151
+ const named = subject.filter(w => has.has(w)).length;
152
+ const shared = words.filter(w => has.has(w)).length;
153
+ return named ? OWN_NAMED_POINTS * named + shared : shared >= OWN_SHARED_MIN ? shared : 0;
154
+ }
155
+
156
+ /** The owner's photos that fit an item, best first (their order breaks a tie). */
157
+ function ownPhotosFor(photos: ReadonlyArray<OwnPhoto>, subject: ReadonlyArray<string>, words: ReadonlyArray<string>): OwnPhoto[] {
158
+ return photos.map((photo, i) => ({ photo, i, fit: ownPhotoFit(photo, subject, words) }))
159
+ .filter(f => f.fit > 0)
160
+ .sort((a, b) => b.fit - a.fit || a.i - b.i)
161
+ .map(f => f.photo);
162
+ }
163
+
164
+ /**
165
+ * The owner's photos come before any stock or sample picture. A composed section's empty picture takes them in order and
166
+ * never repeats one. A sample item takes only one that shows it (`ownPhotoFit`), never twice in one type's samples; an
167
+ * item none fits keeps its sample picture or goes on to the library (`rest`) — never an unrelated photo under its name.
168
+ */
169
+ export function planOwnPhotos(slots: ReadonlyArray<StockTarget>, photos: ReadonlyArray<string | OwnPhoto>): { placements: OwnPhotoPlacement[]; rest: StockTarget[] } {
170
+ const own = photos.map(ownPhotoOf).filter(p => !!p.url);
171
+ if (!own.length) return { placements: [], rest: [...slots] };
131
172
  const placements: OwnPhotoPlacement[] = [];
132
173
  const rest: StockTarget[] = [];
174
+ const shown = new Map<string, Set<string>>();
133
175
  let next = 0;
134
176
  for (const slot of slots) {
135
177
  if (slot.kind === StockSlotKind.Section) {
136
- if (next < urls.length) placements.push({ nodeId: slot.nodeId, owner: slot.owner, url: urls[next++] });
178
+ if (next < own.length) placements.push({ nodeId: slot.nodeId, owner: slot.owner, url: own[next++].url });
137
179
  else rest.push(slot);
138
- } else {
139
- placements.push({ item: { contentType: slot.contentType, index: slot.index, field: slot.field }, url: urls[next++ % urls.length] });
180
+ continue;
181
+ }
182
+ const group = shown.get(slot.contentType) ?? new Set<string>();
183
+ const best = ownPhotosFor(own.filter(p => !group.has(p.url)), slot.subject ?? [], slot.words)[0];
184
+ if (!best) {
185
+ rest.push(slot);
186
+ continue;
140
187
  }
188
+ group.add(best.url);
189
+ shown.set(slot.contentType, group);
190
+ placements.push({ item: { contentType: slot.contentType, index: slot.index, field: slot.field }, url: best.url });
141
191
  }
142
192
  return { placements, rest };
143
193
  }
144
194
 
145
- /** Each marked sample's gallery shows the owner's photos instead of bundled samples, each list starting where the last one stopped. */
146
- export function applyOwnPhotoGalleries(plan: Pick<SitePlan, 'contentTypes'>, items: Readonly<Record<string, ReadonlyArray<Record<string, unknown>>>>, urls: ReadonlyArray<string>): number {
147
- if (!urls.length) return 0;
195
+ /**
196
+ * Each marked sample's gallery shows the owner's photos that fit the item (`ownPhotoFit`) instead of bundled samples; an
197
+ * item none fits keeps its samples.
198
+ */
199
+ export function applyOwnPhotoGalleries(plan: Pick<SitePlan, 'contentTypes'>, items: Readonly<Record<string, ReadonlyArray<Record<string, unknown>>>>, photos: ReadonlyArray<string | OwnPhoto>): number {
200
+ const own = photos.map(ownPhotoOf).filter(p => !!p.url);
201
+ if (!own.length) return 0;
148
202
  let changed = 0;
149
203
  for (const type of plan.contentTypes) {
150
204
  const field = roleField(type, ContentRole.Gallery);
151
205
  if (!field) continue;
152
- (items[type.name] ?? []).forEach((item, index) => {
206
+ (items[type.name] ?? []).forEach(item => {
153
207
  const list = item[field];
154
208
  if (!item['isSample'] || !Array.isArray(list)) return;
155
- item[field] = list.map((value, i) => (parseSampleImageRef(value) === null ? value : urls[(index + i) % urls.length]));
209
+ const { subject, words } = itemWords(type, item);
210
+ const fitting = ownPhotosFor(own, subject, words);
211
+ if (!fitting.length) return;
212
+ let next = 0;
213
+ item[field] = list.map(value => (parseSampleImageRef(value) === null ? value : fitting[next++ % fitting.length].url));
156
214
  changed++;
157
215
  });
158
216
  }
159
217
  return changed;
160
218
  }
161
219
 
220
+ /** A sample item's words: its name (`title`) and everything that says what it is (the type's label and name, its summary). */
221
+ function itemWords(type: SitePlan['contentTypes'][number], item: Record<string, unknown>): { subject: string[]; words: string[] } {
222
+ const title = item[roleField(type, ContentRole.Title) ?? ''];
223
+ return { subject: stockWords(title), words: stockWords(type.label, type.name, title, item[roleField(type, ContentRole.Summary) ?? '']) };
224
+ }
225
+
162
226
  /** Where a photo may not appear twice: one page; one content type's samples (a list shows them together). */
163
227
  export function stockGroupOf(target: StockTarget): string {
164
228
  return target.kind === StockSlotKind.Section ? `page:${target.owner}` : `items:${target.contentType}`;
@@ -216,10 +280,10 @@ export function stockItemSlots(plan: Pick<SitePlan, 'contentTypes'>, composed: P
216
280
  for (const type of plan.contentTypes) {
217
281
  const field = roleField(type, ContentRole.Image);
218
282
  if (!field) continue;
219
- const words = (item: Record<string, unknown>) => [type.label, type.name, ...[ContentRole.Title, ContentRole.Summary].map(r => item[roleField(type, r) ?? ''])];
220
283
  (composed.items[type.name] ?? []).forEach((item, index) => {
221
284
  if (!item.isSample || parseSampleImageRef(item[field]) === null) return;
222
- out.push({ kind: StockSlotKind.Item, contentType: type.name, index, field, intent: StockIntent.Product, aspect: STOCK_ITEM_ASPECT, words: stockWords(...words(item)) });
285
+ const { subject, words } = itemWords(type, item);
286
+ out.push({ kind: StockSlotKind.Item, contentType: type.name, index, field, intent: StockIntent.Product, aspect: STOCK_ITEM_ASPECT, words, subject });
223
287
  });
224
288
  }
225
289
  return out;