@vectoriox/iox-ui 5.135.0 → 5.137.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.
Files changed (43) hide show
  1. package/composite-core/index.d.ts +15 -2
  2. package/design-core/index.d.ts +184 -9
  3. package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -36
  4. package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
  5. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +28 -1
  6. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  7. package/fesm2022/vectoriox-iox-ui-design-core.mjs +296 -48
  8. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  9. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1269 -154
  10. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  11. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +7 -3
  12. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  13. package/fesm2022/vectoriox-iox-ui.mjs +355 -2
  14. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  15. package/generation-core/index.d.ts +481 -89
  16. package/harness-core/index.d.ts +4 -2
  17. package/index.d.ts +105 -3
  18. package/package.json +1 -1
  19. package/src/assist-core/page-sections.ts +4 -31
  20. package/src/composite-core/slider.ts +35 -0
  21. package/src/design-core/design-settings.ts +16 -3
  22. package/src/design-core/design-token.model.ts +3 -0
  23. package/src/design-core/flavor-spec.generated.ts +98 -25
  24. package/src/design-core/motion-language.ts +12 -9
  25. package/src/design-core/preloader-of.ts +26 -0
  26. package/src/design-core/preloader.ts +174 -0
  27. package/src/design-core/public-api.ts +2 -0
  28. package/src/design-core/style-presets.ts +3 -1
  29. package/src/generation-core/carry.ts +37 -0
  30. package/src/generation-core/compose-site.ts +222 -9
  31. package/src/generation-core/node-baselines.generated.ts +2 -1
  32. package/src/generation-core/opening-edit.ts +240 -0
  33. package/src/generation-core/opening-mix.ts +639 -0
  34. package/src/generation-core/patterns.ts +3 -0
  35. package/src/generation-core/plan-wire.ts +26 -4
  36. package/src/generation-core/public-api.ts +2 -0
  37. package/src/generation-core/redesign-run.ts +42 -2
  38. package/src/generation-core/site-build-run.ts +27 -1
  39. package/src/generation-core/site-plan.model.ts +3 -1
  40. package/src/generation-core/site-spec.generated.ts +137 -84
  41. package/src/generation-core/validate-site-plan.ts +5 -3
  42. package/src/harness-core/starting-design.ts +8 -4
  43. package/styles/iox-design.css +32 -0
@@ -0,0 +1,639 @@
1
+ import { DesignChoices, elementStyleFace, resolveDesignChoices, textWidthEm } from '@vectoriox/iox-ui/design-core';
2
+
3
+ import { GenerationTier } from './site-plan.model';
4
+ import { PatternNode, PatternPlaceholder, PatternRecipe, SitePattern } from './patterns';
5
+ import { SPEC_SITE_LAYOUT } from './site-spec.generated';
6
+
7
+ /**
8
+ * THE OPENING (award-ingredients-plan §3.3, AW8; board award-opening, OB-1…OB-7): a page's first screen is a MIX — its
9
+ * frame, what fills it, how its words sit, small extras and its own motion — never one hero pattern. Every word, its
10
+ * meaning in both languages, whether the product draws it, its tier, the named mixes stored plans use, the gallery and the
11
+ * references live in ONE table, the contract's `site.layout.opening` (layout.mjs `OPENING`). This module reads it, judges
12
+ * a mix against the site (`checkOpening`) and arranges it (`openingRecipe` — ONE recipe for the palette, the Opening
13
+ * studio and the generator, R-H9). Pure.
14
+ *
15
+ * Every opening is the same skeleton, so a re-mix keeps the owner's parts (OB-4) and a phone recomposes by rule:
16
+ *
17
+ * Section `opening` (the page's ground; the inset's margin)
18
+ * └ Container `opening.frame` (the coloured first screen: its scheme, its clip — inset or settling — its height)
19
+ * ├ the media layer `opening.media` · `opening.media-zooms` · `opening.film` · `opening.slides` · `opening.object`
20
+ * │ · `opening.pair` › (`opening.media`, `opening.second`)
21
+ * ├ `opening.scrim` when display words sit straight on the media
22
+ * ├ the words `opening.words` › `opening.title` (h1) · `opening.lead` · `opening.action` (or `opening.apart`)
23
+ * ├ `opening.aside` the line and the action when the title is display-size (on the edge, apart, large, behind)
24
+ * ├ `opening.cutout` the picture in front of the name (behind)
25
+ * ├ `opening.form` the lead form (a working form first)
26
+ * └ extras `opening.card` · `opening.badge` · `opening.cue`
27
+ */
28
+
29
+ const O = SPEC_SITE_LAYOUT.opening as unknown as OpeningTable;
30
+
31
+ interface OpeningTable {
32
+ ingredients: Readonly<Record<string, ReadonlyArray<string>>>;
33
+ many: ReadonlyArray<string>;
34
+ meanings: Readonly<Record<string, string>>;
35
+ meaningsHe?: Readonly<Record<string, string>>;
36
+ waits: Readonly<Record<string, { phase: string; drawnAs: string | null }>>;
37
+ defaults: Readonly<Record<string, string | ReadonlyArray<string>>>;
38
+ named: Readonly<Record<string, Partial<Record<string, string | ReadonlyArray<string>>>>>;
39
+ gallery?: ReadonlyArray<{ id: string; name: string; nameHe: string; words: string; wordsHe: string; mix: Partial<Record<string, string | ReadonlyArray<string>>> }>;
40
+ fingerprint: ReadonlyArray<string>;
41
+ rules: { wordsNeverCut: boolean; phoneInsetPx: readonly [number, number]; slowZoomMinS: number; badgeOwnersOnly: boolean; neverHoldsScroll: boolean };
42
+ tiers: Readonly<Record<string, 'all' | 'pro'>>;
43
+ references: ReadonlyArray<{ id: string; after: string; added: string; mix: Partial<Record<string, string | ReadonlyArray<string>>> }>;
44
+ }
45
+
46
+ /** The ingredients, by the contract's keys (held equal to it by opening-mix.spec). */
47
+ export enum OpeningIngredient {
48
+ Frame = 'frame',
49
+ Media = 'media',
50
+ Words = 'words',
51
+ Extras = 'extras',
52
+ Motion = 'motion',
53
+ }
54
+
55
+ export enum OpeningFrame { Full = 'full', Inset = 'inset', Shrinks = 'shrinks', Grows = 'grows' }
56
+ export enum OpeningMedia { Photo = 'photo', Film = 'film', Slideshow = 'slideshow', Object = 'object', Diptych = 'diptych', Material = 'material', Live = 'live' }
57
+ export enum OpeningWords { Headline = 'headline', OnEdge = 'on-edge', Apart = 'apart', Wordmark = 'wordmark', Behind = 'behind', None = 'none' }
58
+ export enum OpeningExtra { Card = 'card', Badge = 'badge', Cue = 'cue' }
59
+ export enum OpeningMotion { SlowZoom = 'slow-zoom', CopyOut = 'copy-out', PinnedCovered = 'pinned-covered' }
60
+
61
+ /** One word for each of frame, media and words; a list (in the table's order) for extras and motion. */
62
+ export interface OpeningMix {
63
+ frame: string;
64
+ media: string;
65
+ words: string;
66
+ extras: string[];
67
+ motion: string[];
68
+ }
69
+
70
+ export class OpeningMixError extends Error {}
71
+
72
+ /** The opening's parts — each a role, so a re-mix finds the owner's part wherever the new mix puts it. */
73
+ export enum OpeningRole {
74
+ Root = 'opening',
75
+ Frame = 'opening.frame',
76
+ /** The frame that settles from the full screen into the inset card, once, as the page loads. */
77
+ FrameSettles = 'opening.frame-settles',
78
+ Media = 'opening.media',
79
+ /** A picture that slowly comes closer (slow zoom). */
80
+ MediaZooms = 'opening.media-zooms',
81
+ Second = 'opening.second',
82
+ Pair = 'opening.pair',
83
+ Film = 'opening.film',
84
+ Slides = 'opening.slides',
85
+ Object = 'opening.object',
86
+ Scrim = 'opening.scrim',
87
+ Words = 'opening.words',
88
+ Title = 'opening.title',
89
+ Lead = 'opening.lead',
90
+ Action = 'opening.action',
91
+ Apart = 'opening.apart',
92
+ /** The second and third of the words placed apart. */
93
+ ApartWord = 'opening.apart-word',
94
+ Aside = 'opening.aside',
95
+ Cutout = 'opening.cutout',
96
+ Form = 'opening.form',
97
+ Card = 'opening.card',
98
+ Badge = 'opening.badge',
99
+ Cue = 'opening.cue',
100
+ }
101
+
102
+ /** The props key an opening root stores its mix under (OB-5, as `HeaderTrait.Mix`). */
103
+ export const OPENING_MIX_PROP = 'openingMix';
104
+
105
+ const HEBREW = 'he';
106
+ const INGREDIENTS = O.ingredients;
107
+ const MANY: ReadonlySet<string> = new Set(O.many);
108
+ const WAITS = O.waits;
109
+ const ORDER: ReadonlyArray<OpeningIngredient> = Object.values(OpeningIngredient);
110
+
111
+ const isMany = (k: string): k is OpeningIngredient.Extras | OpeningIngredient.Motion => MANY.has(k);
112
+
113
+ /** The words an ingredient may take, in the table's order. */
114
+ export function openingWords(ingredient: `${OpeningIngredient}`): ReadonlyArray<string> {
115
+ return INGREDIENTS[ingredient] ?? [];
116
+ }
117
+
118
+ /** What a word means — in Hebrew when the builder speaks it. */
119
+ export function openingMeaning(ingredient: `${OpeningIngredient}`, word: string, locale?: string | null): string {
120
+ const key = `${ingredient}.${word}`;
121
+ return (locale === HEBREW ? O.meaningsHe?.[key] : undefined) ?? O.meanings[key] ?? word;
122
+ }
123
+
124
+ /** Whether the product draws a word today (OB-7: a waiting word is listed with its phase, drawn as its stand-in). */
125
+ export function openingWordDrawn(ingredient: `${OpeningIngredient}`, word: string): boolean {
126
+ return openingWords(ingredient).includes(word) && !WAITS[`${ingredient}.${word}`];
127
+ }
128
+
129
+ /** The phase a waiting word waits for, or null. */
130
+ export function openingWordWaits(ingredient: `${OpeningIngredient}`, word: string): string | null {
131
+ return WAITS[`${ingredient}.${word}`]?.phase ?? null;
132
+ }
133
+
134
+ /** AW-D23: a word every plan wears (`all`) or one the award tier alone is offered (`pro`). */
135
+ export function openingWordTier(ingredient: `${OpeningIngredient}`, word: string): 'all' | 'pro' {
136
+ return O.tiers[`${ingredient}.${word}`] === 'pro' ? 'pro' : 'all';
137
+ }
138
+
139
+ /** May a build at `tier` wear this word? */
140
+ export function openingWordOffered(ingredient: `${OpeningIngredient}`, word: string, tier: `${GenerationTier}`): boolean {
141
+ return openingWordTier(ingredient, word) === 'all' || tier === GenerationTier.Award;
142
+ }
143
+
144
+ const listOf = (v: string | ReadonlyArray<string> | undefined): string[] => (v === undefined ? [] : Array.isArray(v) ? [...v] : [v as string]);
145
+ /** A many-ingredient's words once each, in the table's order. */
146
+ const ordered = (k: string, words: ReadonlyArray<string>): string[] => openingWords(k as OpeningIngredient).filter(w => words.includes(w));
147
+
148
+ /** A whole mix from part of one: what is not named is the default (a picture, edge to edge, a heading). Refuses a word
149
+ * the table lacks. */
150
+ export function openingMix(partial: Partial<Record<string, string | ReadonlyArray<string>>> = {}): OpeningMix {
151
+ const mix: OpeningMix = {
152
+ frame: O.defaults['frame'] as string, media: O.defaults['media'] as string, words: O.defaults['words'] as string,
153
+ extras: listOf(O.defaults['extras']), motion: listOf(O.defaults['motion']),
154
+ };
155
+ for (const [k, v] of Object.entries(partial)) {
156
+ if (v === undefined) continue;
157
+ if (!INGREDIENTS[k]) throw new OpeningMixError(`no opening ingredient "${k}"`);
158
+ const words = listOf(v);
159
+ for (const w of words) if (!INGREDIENTS[k].includes(w)) throw new OpeningMixError(`an opening's ${k} cannot be "${w}" (${INGREDIENTS[k].join(' · ')})`);
160
+ if (isMany(k)) mix[k] = ordered(k, words);
161
+ else if (words.length !== 1) throw new OpeningMixError(`an opening has one ${k}`);
162
+ else (mix as unknown as Record<string, string>)[k] = words[0];
163
+ }
164
+ return mix;
165
+ }
166
+
167
+ /** The mix with one word changed — a many-ingredient's word toggled on or off. */
168
+ export function withOpeningWord(mix: OpeningMix, ingredient: `${OpeningIngredient}`, word: string, on = true): OpeningMix {
169
+ if (!isMany(ingredient)) return openingMix({ ...mix, [ingredient]: word });
170
+ const words = mix[ingredient].filter(w => w !== word);
171
+ return openingMix({ ...mix, [ingredient]: on ? [...words, word] : words });
172
+ }
173
+
174
+ /** A mix on the wire, and as an opening root stores it: one `<ingredient>:<word>` per word, in the table's order. */
175
+ export function openingMixWords(mix: OpeningMix): string[] {
176
+ return ORDER.flatMap(k => listOf((mix as unknown as Record<string, string | string[]>)[k]).map(w => `${k}:${w}`));
177
+ }
178
+
179
+ /** The words back into a mix. Refuses an unknown word and two words for a one-word ingredient. */
180
+ export function openingMixFromWords(words: ReadonlyArray<string>): OpeningMix {
181
+ const partial: Record<string, string[]> = {};
182
+ for (const pair of words) {
183
+ const [k, w] = String(pair).split(':');
184
+ if (!INGREDIENTS[k] || !w) throw new OpeningMixError(`"${pair}" is no opening word (<ingredient>:<word>)`);
185
+ const got = (partial[k] ??= []);
186
+ if (!isMany(k) && got.length && got[0] !== w) throw new OpeningMixError(`an opening has one ${k} ("${got[0]}" and "${w}")`);
187
+ if (!got.includes(w)) got.push(w);
188
+ }
189
+ return openingMix(Object.fromEntries(Object.entries(partial).map(([k, v]) => [k, isMany(k) ? v : v[0]])));
190
+ }
191
+
192
+ /** A site plan's opening (AW8): its `mixes.opening` as a mix, or null — absent or empty, the home page opens with its
193
+ * sections as written. Refuses a word the table lacks (the validator says it first). */
194
+ export function openingMixOfPlan(plan: { readonly mixes?: { readonly opening?: ReadonlyArray<string> } }): OpeningMix | null {
195
+ const words = plan.mixes?.opening;
196
+ return words?.length ? openingMixFromWords(words) : null;
197
+ }
198
+
199
+ /** The mix as stored on a root: its words, space-separated. */
200
+ export function openingMixValue(mix: OpeningMix): string {
201
+ return openingMixWords(mix).join(' ');
202
+ }
203
+
204
+ /** Writes the mix on an opening root (its props). */
205
+ export function stampOpeningMix(root: { props: Record<string, unknown> }, mix: OpeningMix): void {
206
+ root.props = { ...root.props, [OPENING_MIX_PROP]: openingMixValue(mix) };
207
+ }
208
+
209
+ /** The mix an opening root stores, or null — none stored, or words the table no longer knows. */
210
+ export function storedOpeningMix(root: { props?: Record<string, unknown> } | null | undefined): OpeningMix | null {
211
+ const value = root?.props?.[OPENING_MIX_PROP];
212
+ if (typeof value !== 'string' || !value.trim()) return null;
213
+ try {
214
+ return openingMixFromWords(value.trim().split(/\s+/));
215
+ } catch {
216
+ return null;
217
+ }
218
+ }
219
+
220
+ /** The mix a stored hero pattern id stands for (`hero.split`, `hero.full-bleed-media`, `hero.scene-object`), or null. */
221
+ export function namedOpeningMix(patternId: string): OpeningMix | null {
222
+ const named = O.named[patternId];
223
+ return named ? openingMix(named) : null;
224
+ }
225
+
226
+ /** The stored hero pattern a mix is exactly, else null. */
227
+ export function openingPatternIdOf(mix: OpeningMix): string | null {
228
+ const key = openingMixValue(mix);
229
+ return Object.keys(O.named).find(id => openingMixValue(namedOpeningMix(id)!) === key) ?? null;
230
+ }
231
+
232
+ /** One named mix of Components ▸ Opening and the studio's Start from. */
233
+ export interface OpeningGalleryEntry {
234
+ id: string;
235
+ name: string;
236
+ words: string;
237
+ mix: OpeningMix;
238
+ }
239
+
240
+ /** The gallery, in the contract's order (the defaults first), named in `locale` (English unless Hebrew). */
241
+ export function openingGallery(locale?: string | null): OpeningGalleryEntry[] {
242
+ const he = locale === HEBREW;
243
+ return (O.gallery ?? []).map(g => ({ id: g.id, name: he ? g.nameHe : g.name, words: he ? g.wordsHe : g.words, mix: openingMix(g.mix) }));
244
+ }
245
+
246
+ /** The gallery mix a mix is exactly, or null. */
247
+ export function openingGalleryIdOf(mix: OpeningMix): string | null {
248
+ const key = openingMixValue(mix);
249
+ return (O.gallery ?? []).find(g => openingMixValue(openingMix(g.mix)) === key)?.id ?? null;
250
+ }
251
+
252
+ /** The award readings' openings (§3.3), each a whole mix — Start from lists them after the gallery. */
253
+ export function openingReferences(): ReadonlyArray<{ id: string; after: string; mix: OpeningMix }> {
254
+ return O.references.map(r => ({ id: r.id, after: r.after, mix: openingMix(r.mix) }));
255
+ }
256
+
257
+ /** A word the product does not draw yet, with the phase it waits for and what is drawn instead (null: left out). */
258
+ export interface OpeningGap {
259
+ ingredient: `${OpeningIngredient}`;
260
+ word: string;
261
+ phase: string;
262
+ drawnAs: string | null;
263
+ }
264
+
265
+ /** The mix the product DRAWS today: a waiting word becomes its stand-in (a many-ingredient's is left out), each said. */
266
+ export function drawnOpeningMix(mix: OpeningMix): { drawn: OpeningMix; gaps: OpeningGap[] } {
267
+ const drawn: OpeningMix = { ...mix, extras: [...mix.extras], motion: [...mix.motion] };
268
+ const gaps: OpeningGap[] = [];
269
+ for (const k of ORDER) {
270
+ if (isMany(k)) {
271
+ drawn[k] = mix[k].filter(w => {
272
+ const wait = WAITS[`${k}.${w}`];
273
+ if (wait) gaps.push({ ingredient: k, word: w, phase: wait.phase, drawnAs: wait.drawnAs });
274
+ return !wait;
275
+ });
276
+ continue;
277
+ }
278
+ const word = (mix as unknown as Record<string, string>)[k];
279
+ const wait = WAITS[`${k}.${word}`];
280
+ if (!wait) continue;
281
+ gaps.push({ ingredient: k, word, phase: wait.phase, drawnAs: wait.drawnAs });
282
+ (drawn as unknown as Record<string, string>)[k] = wait.drawnAs ?? (O.defaults[k] as string);
283
+ }
284
+ return { drawn, gaps };
285
+ }
286
+
287
+ /** The fingerprint's prefix for an opening. */
288
+ export const OPENING_TOKEN = 'opening';
289
+
290
+ /** An opening as the fingerprint sees it: `opening:<frame>/<media>/<words>` — what a visitor takes in at once. */
291
+ export function openingTokenOf(mix: OpeningMix): string {
292
+ return `${OPENING_TOKEN}:${O.fingerprint.map(k => (mix as unknown as Record<string, string>)[k]).join('/')}`;
293
+ }
294
+
295
+ /** Every `<ingredient>:<word>` the generator's wire may carry at `tier`: drawn words only (a waiting word is never
296
+ * offered), and the award tier's only at the award tier. */
297
+ export function openingWireWords(tier: `${GenerationTier}` = GenerationTier.Basic): string[] {
298
+ return ORDER.flatMap(k => openingWords(k).filter(w => openingWordDrawn(k, w) && openingWordOffered(k, w, tier)).map(w => `${k}:${w}`));
299
+ }
300
+
301
+ // ── The check: a mix judged against the site, mended where the site cannot carry it, each mend said ──────────────────
302
+
303
+ export enum OpeningRepairCode {
304
+ /** A word the award tier alone wears, on a site built below it. */
305
+ ProOnly = 'pro-only',
306
+ /** The name behind the subject needs a cut-out picture: the name, large. */
307
+ NeedsCutOut = 'needs-cut-out',
308
+ /** "The film is the message" needs a film or pictures that move: a heading. */
309
+ NoneNeedsFilm = 'none-needs-film',
310
+ /** Words placed apart need two or three of them. */
311
+ ApartWords = 'apart-words',
312
+ /** A display-size name would be cut by a phone, or too small on a laptop (R-H6): a heading. */
313
+ NameTooLong = 'name-too-long',
314
+ /** A badge is the owner's own (never invented): left out until they give one. */
315
+ BadgeOwnersOnly = 'badge-owners-only',
316
+ /** A form is already the card in the first screen. */
317
+ OneCard = 'one-card',
318
+ /** A slow zoom moves a still picture. */
319
+ ZoomOnAPicture = 'zoom-on-a-picture',
320
+ }
321
+
322
+ export interface OpeningRepair {
323
+ code: OpeningRepairCode;
324
+ /** In plain words, for the wizard, the studio and the model's next turn. */
325
+ said: string;
326
+ }
327
+
328
+ /** What the check and the recipe need of the site. */
329
+ export interface OpeningContext {
330
+ /** The business name — the words of a display-size opening. */
331
+ readonly name: string;
332
+ readonly design?: DesignChoices | null;
333
+ /** AW-D23: the tier the site is built at; absent: the award words are the owner's to choose (the builder). */
334
+ readonly tier?: `${GenerationTier}`;
335
+ /** The owner gives a cut-out picture (a transparent background) for the name behind the subject. */
336
+ readonly cutOut?: boolean;
337
+ /** The owner's own badge words; `null` = none given (the generator: left out), absent = a placeholder (the builder). */
338
+ readonly badge?: string | null;
339
+ }
340
+
341
+ /** A display word must stand this large on a 1440 laptop, and the longest word fit a 375 phone at this size (px). */
342
+ const LAPTOP_PX = 1440;
343
+ const PHONE_PX = 375;
344
+ const MIN_LAPTOP_DISPLAY_PX = 88;
345
+ const MIN_PHONE_DISPLAY_PX = 36;
346
+ /** What the frame keeps beside a display line (its inset and a little air), per side. */
347
+ const LAPTOP_SIDE_PX = 32;
348
+ const PHONE_SIDE_PX = 24;
349
+
350
+ const faceOf = (ctx: OpeningContext) => elementStyleFace(ctx.design ?? resolveDesignChoices({}), 'display');
351
+ const nameWords = (name: string): string[] => name.trim().split(/\s+/).filter(Boolean);
352
+
353
+ /** How wide the name stands, in em of the display face: the whole line, and its longest word. */
354
+ function nameEm(ctx: OpeningContext): { line: number; longest: number } {
355
+ const face = faceOf(ctx);
356
+ const words = nameWords(ctx.name);
357
+ return {
358
+ line: textWidthEm(words.join(' '), face),
359
+ longest: Math.max(0, ...words.map(w => textWidthEm(w, face))),
360
+ };
361
+ }
362
+
363
+ /** A display-size name fits: one line across a laptop at a size that reads, and every word across a phone (R-H6). */
364
+ function nameFits(ctx: OpeningContext, oneLine: boolean): boolean {
365
+ const { line, longest } = nameEm(ctx);
366
+ if (!longest) return false;
367
+ const laptopOk = !oneLine || (LAPTOP_PX - 2 * LAPTOP_SIDE_PX) / line >= MIN_LAPTOP_DISPLAY_PX;
368
+ return laptopOk && (PHONE_PX - 2 * PHONE_SIDE_PX) / longest >= MIN_PHONE_DISPLAY_PX;
369
+ }
370
+
371
+ /** The stand-in for a word a tier may not wear: the one-word ingredients' defaults; a many-ingredient's word left out. */
372
+ function tierStandIn(k: OpeningIngredient): string {
373
+ return O.defaults[k] as string;
374
+ }
375
+
376
+ /**
377
+ * The ONE judge of an opening mix against the site: what the site cannot carry is mended to the nearest mix it can, and
378
+ * each mend is said. Judges the mix as DRAWN (`drawnOpeningMix` first). Never throws on a well-formed mix. Pure.
379
+ */
380
+ export function checkOpening(mix: OpeningMix, ctx: OpeningContext): { mix: OpeningMix; repairs: OpeningRepair[] } {
381
+ const m: OpeningMix = { ...mix, extras: [...mix.extras], motion: [...mix.motion] };
382
+ const repairs: OpeningRepair[] = [];
383
+ const say = (code: OpeningRepairCode, said: string) => repairs.push({ code, said });
384
+ if (ctx.tier && ctx.tier !== GenerationTier.Award) {
385
+ for (const k of ORDER) {
386
+ if (isMany(k)) {
387
+ const kept = m[k].filter(w => openingWordTier(k, w) === 'all');
388
+ for (const w of m[k].filter(x => !kept.includes(x))) say(OpeningRepairCode.ProOnly, `"${openingMeaning(k, w)}" comes with the award plan: left out`);
389
+ m[k] = kept;
390
+ continue;
391
+ }
392
+ const word = (m as unknown as Record<string, string>)[k];
393
+ if (openingWordTier(k, word) === 'all') continue;
394
+ (m as unknown as Record<string, string>)[k] = tierStandIn(k);
395
+ say(OpeningRepairCode.ProOnly, `"${openingMeaning(k, word)}" comes with the award plan: ${openingMeaning(k, tierStandIn(k))} instead`);
396
+ }
397
+ }
398
+ if (m.words === OpeningWords.Behind && !ctx.cutOut) {
399
+ m.words = OpeningWords.Wordmark;
400
+ say(OpeningRepairCode.NeedsCutOut, 'the name behind the subject needs a cut-out picture: the name, large, until there is one');
401
+ }
402
+ if (m.words === OpeningWords.None && m.media !== OpeningMedia.Film && m.media !== OpeningMedia.Slideshow) {
403
+ m.words = OpeningWords.Headline;
404
+ say(OpeningRepairCode.NoneNeedsFilm, 'one small line leaves the message to a film or moving pictures: a heading, a line and one action');
405
+ }
406
+ if (m.words === OpeningWords.Apart) {
407
+ const count = nameWords(ctx.name).length;
408
+ if (count < 2 || count > 3) {
409
+ m.words = nameFits(ctx, true) ? OpeningWords.Wordmark : OpeningWords.Headline;
410
+ say(OpeningRepairCode.ApartWords, `words placed apart need two or three of them ("${ctx.name}" has ${count}): ${openingMeaning(OpeningIngredient.Words, m.words)}`);
411
+ } else if (!nameFits(ctx, false)) {
412
+ m.words = OpeningWords.Headline;
413
+ say(OpeningRepairCode.NameTooLong, `a word of "${ctx.name}" would be cut on a phone: a heading, a line and one action`);
414
+ }
415
+ }
416
+ const oneLine = m.words === OpeningWords.OnEdge || m.words === OpeningWords.Wordmark || m.words === OpeningWords.Behind;
417
+ if (oneLine && !nameFits(ctx, true)) {
418
+ const was = m.words;
419
+ m.words = OpeningWords.Headline;
420
+ say(OpeningRepairCode.NameTooLong, `"${ctx.name}" is too long to stand ${was === OpeningWords.OnEdge ? 'on the edge' : 'full width'} without being cut or too small: a heading, a line and one action`);
421
+ }
422
+ if (m.extras.includes(OpeningExtra.Badge) && ctx.badge === null) {
423
+ m.extras = m.extras.filter(w => w !== OpeningExtra.Badge);
424
+ say(OpeningRepairCode.BadgeOwnersOnly, 'a badge says the owner\'s own award or offer — left out until they give one');
425
+ }
426
+ if (m.media === OpeningMedia.Live && m.extras.includes(OpeningExtra.Card)) {
427
+ m.extras = m.extras.filter(w => w !== OpeningExtra.Card);
428
+ say(OpeningRepairCode.OneCard, 'the form is the first screen\'s card: the small card is left out');
429
+ }
430
+ const still = m.media === OpeningMedia.Photo || m.media === OpeningMedia.Diptych || m.media === OpeningMedia.Live;
431
+ if (m.motion.includes(OpeningMotion.SlowZoom) && !still) {
432
+ m.motion = m.motion.filter(w => w !== OpeningMotion.SlowZoom);
433
+ say(OpeningRepairCode.ZoomOnAPicture, 'a slow zoom moves a still picture: left out on moving pictures');
434
+ }
435
+ return { mix: m, repairs };
436
+ }
437
+
438
+ // ── The recipe: the mix arranged as ordinary builder nodes (ONE recipe for the palette, the studio and the generator) ──
439
+ //
440
+ // Only what is the same in both directions is written on the nodes; which INLINE side a part sits on (the badge, the card,
441
+ // the cue at the end) and the two motions are the shared stylesheet's (`styles/iox-design.css`, AW8), in logical insets,
442
+ // so a Hebrew site mirrors them.
443
+
444
+ /** How tall the first screen stands: a little less than the window, so the next section's edge says "there is more". */
445
+ export const OPENING_HEIGHT = '88svh';
446
+ const INSET_LAPTOP = '24px';
447
+ const ABS_FILL: Readonly<Record<string, string>> = { position: 'absolute', top: '0px', left: '0px', width: '100%', height: '100%', zIndex: '0' };
448
+ const MEDIA_FILL: Readonly<Record<string, string>> = { ...ABS_FILL, aspectRatio: 'auto', borderRadius: '0px', objectFit: 'cover' };
449
+ const OVER = (z: number): Readonly<Record<string, string>> => ({ position: 'relative', zIndex: String(z) });
450
+ const FRAME_PAD = 'clamp(20px, 4vw, 56px)';
451
+ /** A display line is sized a little under its measured width, so a rounding never wraps it. */
452
+ const FIT = 0.95;
453
+
454
+ /** The phone's inset: within the contract's 8–16 px at every phone width. */
455
+ export function openingPhoneInset(): string {
456
+ const [lo, hi] = O.rules.phoneInsetPx;
457
+ return `clamp(${lo}px, 3vw, ${hi}px)`;
458
+ }
459
+
460
+ const insetClip = (inset: string): string => `inset(${inset} round var(--iox-card-radius))`;
461
+
462
+ /** A display size that keeps `em` of text within the width (`side` px kept per side), never above `cap`. */
463
+ const sizedPx = (em: number, side: number, cap: string): string =>
464
+ `min(calc((100vw - ${2 * side}px) * ${FIT} / ${Math.max(em, 1).toFixed(3)}), ${cap})`;
465
+
466
+ function frameNode(mix: OpeningMix, children: PatternNode[]): PatternNode {
467
+ const inset = mix.frame === OpeningFrame.Inset || mix.frame === OpeningFrame.Shrinks;
468
+ return {
469
+ t: 'Container', es: 'box', scheme: 'inverse',
470
+ role: mix.frame === OpeningFrame.Shrinks ? OpeningRole.FrameSettles : OpeningRole.Frame,
471
+ lay: {
472
+ position: 'relative', overflow: 'hidden', display: 'flex', flexDirection: 'column', justifyContent: 'flex-end', gap: 'var(--iox-space-gap)',
473
+ minHeight: OPENING_HEIGHT, padding: inset ? `calc(${INSET_LAPTOP} + ${FRAME_PAD})` : FRAME_PAD, borderRadius: '0px',
474
+ ...(inset ? { clipPath: insetClip(INSET_LAPTOP) } : {}),
475
+ },
476
+ ...(inset ? { resp: { mobile: { clipPath: insetClip(openingPhoneInset()), padding: `calc(${openingPhoneInset()} + 20px)` } } } : {}),
477
+ c: children,
478
+ };
479
+ }
480
+
481
+ const picture = (role: OpeningRole, lay: Readonly<Record<string, string>> = MEDIA_FILL): PatternNode => ({ t: 'Image', es: 'media', ph: PatternPlaceholder.Image, role, lay });
482
+ const CELL_PICTURE: Readonly<Record<string, string>> = { width: '100%', height: '100%', aspectRatio: 'auto', objectFit: 'cover', borderRadius: '0px' };
483
+
484
+ function mediaNodes(mix: OpeningMix): PatternNode[] {
485
+ const zooms = mix.motion.includes(OpeningMotion.SlowZoom);
486
+ switch (mix.media) {
487
+ case OpeningMedia.Film:
488
+ return [{ t: 'Video', es: 'media', video: 'background', ph: PatternPlaceholder.Video, role: OpeningRole.Film, lay: { ...ABS_FILL, aspectRatio: 'auto', borderRadius: '0px' } }];
489
+ case OpeningMedia.Slideshow:
490
+ return [{ t: 'SliderContainer', recipe: PatternRecipe.Slideshow, role: OpeningRole.Slides, lay: ABS_FILL }];
491
+ case OpeningMedia.Object:
492
+ return [picture(OpeningRole.Object, { position: 'absolute', top: '8%', left: '20%', width: '60%', height: '76%', zIndex: '0', aspectRatio: 'auto', objectFit: 'contain', borderRadius: '0px' })];
493
+ case OpeningMedia.Diptych:
494
+ return [{
495
+ t: 'Container', es: 'box', role: OpeningRole.Pair,
496
+ lay: { ...ABS_FILL, display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) minmax(0, 1fr)', gap: '0px', padding: '0px' },
497
+ resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } },
498
+ c: [
499
+ picture(zooms ? OpeningRole.MediaZooms : OpeningRole.Media, CELL_PICTURE),
500
+ { ...picture(OpeningRole.Second, CELL_PICTURE), resp: { mobile: { display: 'none' } } },
501
+ ],
502
+ }];
503
+ default:
504
+ return [picture(zooms ? OpeningRole.MediaZooms : OpeningRole.Media)];
505
+ }
506
+ }
507
+
508
+ const title = (lay: Readonly<Record<string, string>>, extra: Partial<PatternNode> = {}): PatternNode => ({
509
+ t: 'Heading', es: 'display', level: 'h1', slot: 'title', max: 56, fromBusiness: 'name', ph: PatternPlaceholder.Copy, text: 'Your name', textHe: 'השם שלכם',
510
+ role: OpeningRole.Title, lay, ...extra,
511
+ });
512
+ const lead = (lay: Readonly<Record<string, string>> = {}): PatternNode => ({
513
+ t: 'Text', es: 'lead', slot: 'lead', max: 140, fromBusiness: 'tagline', ph: PatternPlaceholder.Copy, text: 'One line on what you do, and for whom.',
514
+ textHe: 'שורה אחת על מה שאתם עושים, ובשביל מי.', role: OpeningRole.Lead, lay,
515
+ });
516
+ const action = (): PatternNode => ({ t: 'ButtonBlock', es: 'button-primary', href: '/contact', slot: 'cta', max: 24, text: 'Get in touch', textHe: 'צרו קשר', role: OpeningRole.Action });
517
+ const scrim = (): PatternNode => ({ t: 'Container', es: 'media-scrim', role: OpeningRole.Scrim, lay: { ...ABS_FILL, padding: '0px', borderRadius: '0px' } });
518
+ /** The line and the action beside a display-size title: at the frame's top, at the reading start. */
519
+ const aside = (at: 'top' | 'bottom' = 'top'): PatternNode => ({
520
+ t: 'Container', es: 'box', role: OpeningRole.Aside,
521
+ lay: { ...OVER(1), display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: '14px', maxWidth: '420px', margin: at === 'top' ? '0px 0px auto 0px' : 'auto 0px 0px 0px' },
522
+ c: [lead(), action()],
523
+ });
524
+
525
+ /** The words, as the mix places them. Display sizes are measured on the look's own face (never a guess — R-H6): a laptop
526
+ * line by the whole name, a phone by its longest word, so a word is never cut by the screen. */
527
+ function wordsNodes(mix: OpeningMix, ctx: OpeningContext): PatternNode[] {
528
+ const { line, longest } = nameEm(ctx);
529
+ const phoneSize = sizedPx(longest, PHONE_SIDE_PX, '22vw');
530
+ switch (mix.words) {
531
+ case OpeningWords.OnEdge:
532
+ return [scrim(), aside('top'), {
533
+ t: 'Container', es: 'box', role: OpeningRole.Words,
534
+ lay: { position: 'absolute', left: '0px', bottom: '0px', width: '100%', zIndex: '1', padding: `0px ${LAPTOP_SIDE_PX}px`, overflow: 'visible' },
535
+ resp: { mobile: { padding: `0px ${PHONE_SIDE_PX}px` } },
536
+ c: [title({ fontSize: sizedPx(line, LAPTOP_SIDE_PX, '50svh'), lineHeight: '0.82', margin: '0px', translateY: '0.16em' }, { resp: { mobile: { fontSize: phoneSize } } })],
537
+ }];
538
+ case OpeningWords.Wordmark:
539
+ case OpeningWords.Behind:
540
+ return [scrim(), {
541
+ t: 'Container', es: 'box', role: OpeningRole.Words,
542
+ lay: { ...OVER(1), display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '18px', textAlign: 'center', margin: 'auto 0px auto 0px', width: '100%' },
543
+ c: [
544
+ title({ fontSize: sizedPx(line, LAPTOP_SIDE_PX + 24, '40svh'), lineHeight: '0.9', margin: '0px', textAlign: 'center' }, { resp: { mobile: { fontSize: phoneSize } } }),
545
+ lead({ textAlign: 'center' }), action(),
546
+ ],
547
+ }];
548
+ case OpeningWords.Apart: {
549
+ const words = nameWords(ctx.name);
550
+ const size = sizedPx(longest / 0.6, 0, '18vw');
551
+ const place = [
552
+ { gridRow: '1', justifySelf: 'start', alignSelf: 'start' },
553
+ { gridRow: '2', justifySelf: 'end', alignSelf: 'center' },
554
+ { gridRow: '3', justifySelf: 'center', alignSelf: 'end' },
555
+ ];
556
+ // The words are read in order — the first is the page's h1; a heading cannot be split, so the rest are headings
557
+ // too (Text has no display size). Their order IS the name's.
558
+ const word = (w: string, i: number): PatternNode => (i === 0
559
+ ? title({ fontSize: size, lineHeight: '0.9', margin: '0px', ...place[0] }, { text: w, fromBusiness: undefined, textHe: undefined })
560
+ : { t: 'Heading', es: 'display', level: 'h2', text: w, role: OpeningRole.ApartWord, lay: { fontSize: size, lineHeight: '0.9', margin: '0px', ...place[i] } });
561
+ return [scrim(), {
562
+ t: 'Container', es: 'box', role: OpeningRole.Apart,
563
+ lay: { ...ABS_FILL, zIndex: '1', display: 'grid', gridTemplateRows: 'repeat(3, minmax(0, 1fr))', padding: FRAME_PAD },
564
+ c: words.map(word),
565
+ }, aside('bottom')];
566
+ }
567
+ case OpeningWords.None:
568
+ return [{
569
+ t: 'Container', es: 'box', role: OpeningRole.Words, lay: { ...OVER(1), maxWidth: '520px' },
570
+ c: [title({ margin: '0px' }, { es: 'eyebrow' })],
571
+ }];
572
+ default:
573
+ return [{
574
+ t: 'Container', es: 'media-scrim', role: OpeningRole.Words,
575
+ lay: { ...OVER(1), display: 'flex', flexDirection: 'column', gap: '14px', maxWidth: '760px' },
576
+ enter: 'heroText',
577
+ c: [title({}), lead(), action()],
578
+ }];
579
+ }
580
+ }
581
+
582
+ /** The extras. Their inline side (the end) is the shared stylesheet's; a phone keeps the card in the flow under the words. */
583
+ function extrasNodes(mix: OpeningMix): PatternNode[] {
584
+ const out: PatternNode[] = [];
585
+ if (mix.extras.includes(OpeningExtra.Badge)) {
586
+ out.push({
587
+ t: 'Container', es: 'badge-accent', role: OpeningRole.Badge,
588
+ lay: { position: 'absolute', top: '6%', zIndex: '2', width: '132px', aspectRatio: '1 / 1', borderRadius: '999px', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '16px', textAlign: 'center' },
589
+ resp: { mobile: { width: '96px', padding: '10px' } },
590
+ c: [{ t: 'Text', es: 'badge-label', ph: PatternPlaceholder.Stat, text: 'Your award or offer', textHe: 'הפרס או ההצעה שלכם', lay: { textAlign: 'center' } }],
591
+ });
592
+ }
593
+ if (mix.extras.includes(OpeningExtra.Card)) {
594
+ out.push({
595
+ t: 'Container', es: 'box', role: OpeningRole.Card,
596
+ lay: { position: 'absolute', bottom: '6%', zIndex: '2', width: 'min(300px, 36%)' },
597
+ resp: { mobile: { position: 'relative', width: '100%' } },
598
+ c: [{ t: 'Container', recipe: PatternRecipe.Card, layout: 'top', ph: PatternPlaceholder.Copy, parts: { badge: false, eyebrow: false, text: false, actions: false }, words: { title: 'What is new — in a few words' } }],
599
+ });
600
+ }
601
+ if (mix.extras.includes(OpeningExtra.Cue)) {
602
+ out.push({ t: 'Text', es: 'eyebrow', role: OpeningRole.Cue, text: 'Scroll', textHe: 'גללו', lay: { position: 'absolute', bottom: '20px', zIndex: '2', margin: '0px' } });
603
+ }
604
+ return out;
605
+ }
606
+
607
+ /** The words and what sits beside them: a working form first stands beside the words (the words above it on a phone). */
608
+ function bodyOf(mix: OpeningMix, ctx: OpeningContext): PatternNode[] {
609
+ const words = wordsNodes(mix, ctx);
610
+ const cutout: PatternNode[] = mix.words === OpeningWords.Behind
611
+ ? [picture(OpeningRole.Cutout, { position: 'absolute', bottom: '0px', left: '20%', width: '60%', height: '86%', zIndex: '2', aspectRatio: 'auto', objectFit: 'contain', borderRadius: '0px' })]
612
+ : [];
613
+ if (mix.media !== OpeningMedia.Live) return [...words, ...cutout];
614
+ return [{
615
+ t: 'Container', es: 'box', role: OpeningRole.Aside,
616
+ lay: { ...OVER(1), display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) minmax(0, 420px)', gap: '32px', alignItems: 'end', width: '100%' },
617
+ resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } },
618
+ c: [...words, { t: 'Container', es: 'card', role: OpeningRole.Form, c: [{ t: 'Form', preset: 'lead' }] }],
619
+ }, ...cutout];
620
+ }
621
+
622
+ /** What the composer stamps for an opening mix. */
623
+ export interface OpeningRecipe {
624
+ /** The mix it stamps, as drawn (stored on the opening root — OB-5). */
625
+ mix: OpeningMix;
626
+ pattern: SitePattern;
627
+ }
628
+
629
+ /** The opening mix as a pattern — the page's first section. Check it first (`checkOpening` on the drawn mix). Pure. */
630
+ export function openingRecipe(mix: OpeningMix, ctx: OpeningContext): OpeningRecipe {
631
+ const { drawn } = drawnOpeningMix(mix);
632
+ const frame = frameNode(drawn, [...mediaNodes(drawn), ...bodyOf(drawn, ctx), ...extrasNodes(drawn)]);
633
+ const node: PatternNode = { t: 'Section', es: 'section', role: OpeningRole.Root, lay: { position: 'relative', padding: '0px', overflow: 'hidden' }, c: [frame] };
634
+ const words = [openingMeaning(OpeningIngredient.Frame, drawn.frame), openingMeaning(OpeningIngredient.Media, drawn.media), openingMeaning(OpeningIngredient.Words, drawn.words)];
635
+ return {
636
+ mix: drawn,
637
+ pattern: { family: 'hero', label: `Opening — ${words.join(' · ')}`, intent: `${words.join('; ')}.`, node } as SitePattern,
638
+ };
639
+ }
@@ -126,6 +126,9 @@ export enum PatternRecipe {
126
126
  Segmented = 'segmented',
127
127
  /** CC3: the accessible carousel — a named Slider whose controls are parts, one quote per slide (placeholders). */
128
128
  Carousel = 'carousel',
129
+ /** AW8 (`media.slideshow`): pictures cross-fading on their own — the carousel's Slider with a fade, autoplay, its
130
+ * Pause control (WCAG 2.2.2, always there while it rotates) and dots; three empty pictures (placeholders). */
131
+ Slideshow = 'slideshow',
129
132
  /** CC3: the Lightbox — a Dialog holding a Slider over the node's `src` (the gallery's own source). */
130
133
  Lightbox = 'lightbox',
131
134
  /** Commerce G1 (E1c `SHOP_RECIPES`): the product's price — its own on a product page (`$variant`), the row's in a