@vectoriox/iox-ui 5.121.0 → 5.123.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.
@@ -1,5 +1,5 @@
1
1
  import { AiStep, STRICT_SCHEMA_BUDGET, strictSchemaComplexity, jsonText, jsonListOf, jsonOneOf, jsonClosedObject, jsonAnyOf, PlanWordIssueCode, factIssues, walkSerialized, AdjustKind, AdjustAxis, adjustStepOf, ADJUST_STEPS, NODE_BASELINES, adjustStyleProps, ADJUST_AXIS_LABELS, adjustStepLabel, patternById, composeSection } from '@vectoriox/iox-ui/generation-core';
2
- import { elementStylesFor, colorSchemeOf, ColorScheme, COLOR_SCHEME_TYPES, elementStyleById, COLOR_SCHEMES, NEW_NODE_STYLE_DEFAULTS, setColorScheme, switchElementStyle } from '@vectoriox/iox-ui/design-core';
2
+ import { elementStylesFor, colorSchemeOf, ColorScheme, COLOR_SCHEME_TYPES, elementStyleById, COLOR_SCHEMES, NEW_NODE_STYLE_DEFAULTS, setColorScheme, switchElementStyle, flavorPackById, parseHexColor, resolveDesignChoices, SPEC_AXES, stylePresetOfChoices, BETWEEN_IDS, ANIMATE_IDS, SCROLL_IDS, TINT_IDS, STYLE_PRESETS, stylePresetById, presetChoices, designTokenRows, auditDesignContrast } from '@vectoriox/iox-ui/design-core';
3
3
 
4
4
  /**
5
5
  * The surfaces AI Assist runs on (ai-assist-plan §2, §4): each screen that offers a prompt registers ONE spec — what it
@@ -81,6 +81,7 @@ var AssistPermission;
81
81
  AssistPermission["PageDelete"] = "page_delete";
82
82
  AssistPermission["StorageAll"] = "storage_all";
83
83
  AssistPermission["ProductsAll"] = "products_all";
84
+ AssistPermission["SettingsAll"] = "settings_all";
84
85
  })(AssistPermission || (AssistPermission = {}));
85
86
  var SurfaceStatus;
86
87
  (function (SurfaceStatus) {
@@ -93,14 +94,16 @@ const spec = (s) => ({
93
94
  ...s,
94
95
  });
95
96
  const SURFACES = {
96
- // S1 offers only the families the server answers (the route can never pick one it cannot): Words first (AI2a);
97
- // Look & motion joins when its slice ships (ai-assist-plan §6, AI2e).
97
+ // S1 offers only the families the server answers (the route can never pick one it cannot). The look is the SITE's: it
98
+ // needs what Design ▸ Apply needs — the design row (settings) and the token rows (pages) — and the builder commits it
99
+ // through Design's own Apply, never as a page history step.
98
100
  [AssistSurface.BuilderPage]: spec({
99
101
  surface: AssistSurface.BuilderPage,
100
- families: [EditFamily.Words, EditFamily.Style, EditFamily.Sections],
102
+ families: [EditFamily.Words, EditFamily.Style, EditFamily.Sections, EditFamily.Look],
101
103
  commit: CommitKind.BuilderStep,
102
104
  steps: [AssistStep.AssistRoute, AssistStep.AssistEdit],
103
105
  permissions: [AssistPermission.PageUpdate],
106
+ familyPermissions: { [EditFamily.Look]: [AssistPermission.SettingsAll, AssistPermission.PageCreate] },
104
107
  scopes: [AssistScope.Node, AssistScope.Section, AssistScope.Page],
105
108
  status: SurfaceStatus.Built,
106
109
  }),
@@ -256,6 +259,8 @@ var AssistIssueCode;
256
259
  AssistIssueCode["InventedFact"] = "inventedFact";
257
260
  /** A word this site must not use. */
258
261
  AssistIssueCode["AvoidWord"] = "avoidWord";
262
+ /** A look whose colours fail the contrast audit in a mode the site is worn in (family `look`, R4). */
263
+ AssistIssueCode["Contrast"] = "contrast";
259
264
  })(AssistIssueCode || (AssistIssueCode = {}));
260
265
  /** A caller's mistake building a brief (a focus that is not on the screen) — never a model answer. */
261
266
  class AssistBriefError extends Error {
@@ -1241,6 +1246,8 @@ var PageChangeOp;
1241
1246
  PageChangeOp["Scheme"] = "scheme";
1242
1247
  PageChangeOp["Size"] = "size";
1243
1248
  PageChangeOp["Section"] = "section";
1249
+ /** The site's look (family `look`, AI2e) — every page follows. */
1250
+ PageChangeOp["Look"] = "look";
1244
1251
  })(PageChangeOp || (PageChangeOp = {}));
1245
1252
  /** The serialized baseline: the type's constructor values, its text colour released as a new node's is (generation-core `createSerializedNode`). */
1246
1253
  const serializedBaselineStyles = type => {
@@ -1507,7 +1514,7 @@ function carryParts(root) {
1507
1514
  return out;
1508
1515
  }
1509
1516
  const BUTTON_LINK_PROPS = ['tag', 'linkType', 'href', 'pageRoute', 'url', 'target'];
1510
- const labelOf = (button) => (button.children ?? []).find(c => c.type === 'Text');
1517
+ const labelOf$1 = (button) => (button.children ?? []).find(c => c.type === 'Text');
1511
1518
  /** The owner's words and pictures, placed into the new section part for part (kind by kind, in order); how many found no place. */
1512
1519
  function carryOver(from, to) {
1513
1520
  const old = carryParts(from);
@@ -1528,8 +1535,8 @@ function carryOver(from, to) {
1528
1535
  target.props = { ...target.props, src: source.props['src'], alt: source.props['alt'] ?? target.props['alt'] };
1529
1536
  }
1530
1537
  else if (kind === CarryKind.Button) {
1531
- const words = labelOf(source);
1532
- const into = labelOf(target);
1538
+ const words = labelOf$1(source);
1539
+ const into = labelOf$1(target);
1533
1540
  if (words && into)
1534
1541
  into.props = { ...into.props, content: words.props['content'] };
1535
1542
  const link = Object.fromEntries(BUTTON_LINK_PROPS.filter(k => k in source.props).map(k => [k, source.props[k]]));
@@ -1705,6 +1712,302 @@ function applySectionEdits(layout, edits, ctx) {
1705
1712
  return { ok: true, result, changes, issues: [] };
1706
1713
  }
1707
1714
 
1715
+ /**
1716
+ * Surface S1 (the builder), family `look` (ai-assist-plan §4 AI2e; ai-session-panel-plan `setLook` / `setMotion`): the
1717
+ * SITE's look and motion — every page follows — changed only along the contract's own axes: a style preset, the brand
1718
+ * colour, the background tint, corners, pill buttons, spacing, the type pairing, the colour mode, speed, scrolling, how
1719
+ * animated and the change between pages. Never a token value, never CSS. A preset brings its whole look and keeps the
1720
+ * site's own Scrolling · How animated · Between pages (MO-D3, as Design ▸ Look does); a type pairing is one of the worn
1721
+ * style's own. The colour is checked by the SAME audit the contract gates every preset with (`auditDesignContrast`, in
1722
+ * every mode the look is worn) — a colour that fails is refused, never worn (R4: the AA gate decides the colour).
1723
+ * The SAME pure functions run on the server (the check) and in the builder (the trial through the Design side-card's
1724
+ * own trial): `lookJsonSchema`, `decodeLookAnswers`, `applyLookEdits`.
1725
+ */
1726
+ /** One axis of the look, as the answer names it and the change card says it. */
1727
+ var LookAxis;
1728
+ (function (LookAxis) {
1729
+ LookAxis["Style"] = "style";
1730
+ LookAxis["Colour"] = "colour";
1731
+ LookAxis["Tint"] = "tint";
1732
+ LookAxis["Corners"] = "corners";
1733
+ LookAxis["Buttons"] = "buttons";
1734
+ LookAxis["Spacing"] = "spacing";
1735
+ LookAxis["Type"] = "type";
1736
+ LookAxis["Mode"] = "mode";
1737
+ LookAxis["Speed"] = "speed";
1738
+ LookAxis["Scrolling"] = "scrolling";
1739
+ LookAxis["Entrances"] = "entrances";
1740
+ LookAxis["Between"] = "between";
1741
+ })(LookAxis || (LookAxis = {}));
1742
+ /** How the card names each axis (the builder translates it by the axis). */
1743
+ const LOOK_AXIS_LABELS = {
1744
+ [LookAxis.Style]: 'Style', [LookAxis.Colour]: 'Brand colour', [LookAxis.Tint]: 'Background tint', [LookAxis.Corners]: 'Corners',
1745
+ [LookAxis.Buttons]: 'Buttons', [LookAxis.Spacing]: 'Spacing', [LookAxis.Type]: 'Fonts', [LookAxis.Mode]: 'Mode', [LookAxis.Speed]: 'Speed',
1746
+ [LookAxis.Scrolling]: 'Scrolling', [LookAxis.Entrances]: 'How animated', [LookAxis.Between]: 'Between pages',
1747
+ };
1748
+ /** The axes in the order a card lists them (and the answer asks them). */
1749
+ const LOOK_AXES = Object.values(LookAxis);
1750
+ /** The answer's extra key. Every axis is required; `''` keeps it as it is. */
1751
+ var LookAnswerKey;
1752
+ (function (LookAnswerKey) {
1753
+ LookAnswerKey["Note"] = "note";
1754
+ })(LookAnswerKey || (LookAnswerKey = {}));
1755
+ /** "Keep it as it is" — strict outputs require every key. */
1756
+ const LOOK_KEEP = '';
1757
+ /** `buttons`: pill-shaped or as the look draws them. */
1758
+ var LookButtons;
1759
+ (function (LookButtons) {
1760
+ LookButtons["Pill"] = "pill";
1761
+ LookButtons["Look"] = "look";
1762
+ })(LookButtons || (LookButtons = {}));
1763
+ /** How the owner reads a colour mode. */
1764
+ const MODE_LABELS = { light: 'Light', dark: 'Dark', auto: 'Follow the visitor' };
1765
+ const BUTTON_LABELS = { [LookButtons.Pill]: 'Pill-shaped', [LookButtons.Look]: 'As the look draws them' };
1766
+ /** The worn modes a colour is judged in (`auto` = both). */
1767
+ const wornModes = (mode) => (mode === 'auto' ? ['light', 'dark'] : [mode]);
1768
+ const labelOf = (table, id) => table[id]?.label ?? id;
1769
+ /** The type pairings of a flavor: id → its label ("Fraunces + Manrope"). */
1770
+ function pairsOf(flavorId) {
1771
+ return flavorPackById(flavorId)?.pairs ?? [];
1772
+ }
1773
+ /** A colour as the look stores it (`#RRGGBB`), or null. */
1774
+ function lookHex(value) {
1775
+ const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((value ?? '').trim());
1776
+ if (!m || !parseHexColor(value))
1777
+ return null;
1778
+ const h = m[1].length === 3 ? m[1].split('').map(c => c + c).join('') : m[1];
1779
+ return `#${h.toUpperCase()}`;
1780
+ }
1781
+ /** How the owner reads one axis of a set of choices. */
1782
+ function lookAxisValue(choices, axis) {
1783
+ const c = resolveDesignChoices(choices);
1784
+ switch (axis) {
1785
+ case LookAxis.Style: {
1786
+ const preset = stylePresetOfChoices(c);
1787
+ const flavor = flavorPackById(c.flavorId)?.name ?? c.flavorId;
1788
+ return preset ? { id: preset.id, label: preset.name } : { id: c.flavorId, label: `${flavor}, your own` };
1789
+ }
1790
+ case LookAxis.Colour: return { id: c.seed.toUpperCase(), label: c.seed.toUpperCase() };
1791
+ case LookAxis.Tint: return { id: c.tint ?? '', label: labelOf(SPEC_AXES.tints, c.tint ?? '') };
1792
+ case LookAxis.Corners: return { id: c.shape, label: labelOf(SPEC_AXES.shapes, c.shape) };
1793
+ case LookAxis.Buttons: {
1794
+ const id = c.pillButtons ? LookButtons.Pill : LookButtons.Look;
1795
+ return { id, label: BUTTON_LABELS[id] };
1796
+ }
1797
+ case LookAxis.Spacing: return { id: c.density, label: labelOf(SPEC_AXES.densities, c.density) };
1798
+ case LookAxis.Type: return { id: c.pairId, label: pairsOf(c.flavorId).find(p => p.id === c.pairId)?.label ?? c.pairId };
1799
+ case LookAxis.Mode: return { id: c.mode, label: MODE_LABELS[c.mode] ?? c.mode };
1800
+ case LookAxis.Speed: return { id: c.motion, label: labelOf(SPEC_AXES.motions, c.motion) };
1801
+ case LookAxis.Scrolling: return { id: c.scroll ?? '', label: labelOf(SPEC_AXES.scrolls, c.scroll ?? '') };
1802
+ case LookAxis.Entrances: return { id: c.animate ?? '', label: labelOf(SPEC_AXES.animations, c.animate ?? '') };
1803
+ case LookAxis.Between: return { id: c.between ?? '', label: labelOf(SPEC_AXES.betweens, c.between ?? '') };
1804
+ }
1805
+ }
1806
+ function summarizeLook(choices) {
1807
+ return Object.fromEntries(LOOK_AXES.map(axis => [axis, lookAxisValue(choices, axis).label]));
1808
+ }
1809
+ /** The ids an axis may take — what the strict format lists (`''` keeps it). Type: the worn style's own pairings. */
1810
+ function axisOptions(axis, current) {
1811
+ switch (axis) {
1812
+ case LookAxis.Style: return STYLE_PRESETS.map(p => p.id);
1813
+ case LookAxis.Colour: return [];
1814
+ case LookAxis.Tint: return TINT_IDS;
1815
+ case LookAxis.Corners: return Object.keys(SPEC_AXES.shapes);
1816
+ case LookAxis.Buttons: return Object.values(LookButtons);
1817
+ case LookAxis.Spacing: return Object.keys(SPEC_AXES.densities);
1818
+ case LookAxis.Type: return pairsOf(resolveDesignChoices(current).flavorId).map(p => p.id);
1819
+ case LookAxis.Mode: return SPEC_AXES.modes;
1820
+ case LookAxis.Speed: return Object.keys(SPEC_AXES.motions);
1821
+ case LookAxis.Scrolling: return SCROLL_IDS;
1822
+ case LookAxis.Entrances: return ANIMATE_IDS;
1823
+ case LookAxis.Between: return BETWEEN_IDS;
1824
+ }
1825
+ }
1826
+ const options = (ids, says) => ids.map(id => `${id} = ${says(id)}`).join('; ');
1827
+ /** What each axis's ids mean, in the format's own descriptions — read only when the look is asked. */
1828
+ function axisDescription(axis, current) {
1829
+ const keep = 'Empty string = keep it as it is.';
1830
+ switch (axis) {
1831
+ case LookAxis.Style:
1832
+ return `A whole style for the site (colour, type, corners, spacing and speed together). ${keep} `
1833
+ + options(STYLE_PRESETS.map(p => p.id), id => {
1834
+ const p = stylePresetById(id);
1835
+ return `${p.name} (${p.moods.join(', ')}; ${p.modes.join('/')}): ${p.blurb}`;
1836
+ });
1837
+ case LookAxis.Colour:
1838
+ return `The brand colour as #RRGGBB, only when the owner names or describes one ("our green", "#2E7D45"); every background, `
1839
+ + `button and link is derived from it and checked for contrast. ${keep}`;
1840
+ case LookAxis.Tint: return `How much of the brand colour the backgrounds carry. ${keep} ${options(TINT_IDS, id => labelOf(SPEC_AXES.tints, id))}`;
1841
+ case LookAxis.Corners: return `Corner roundness everywhere. ${keep} ${options(Object.keys(SPEC_AXES.shapes), id => labelOf(SPEC_AXES.shapes, id))}`;
1842
+ case LookAxis.Buttons: return `Button shape. ${keep} ${options(Object.values(LookButtons), id => BUTTON_LABELS[id])}`;
1843
+ case LookAxis.Spacing: return `Space around and between every section of the site. ${keep} ${options(Object.keys(SPEC_AXES.densities), id => labelOf(SPEC_AXES.densities, id))}`;
1844
+ case LookAxis.Type: return `The site's fonts, as one of the pairings the current style offers. ${keep} ${options(axisOptions(axis, current), id => pairsOf(resolveDesignChoices(current).flavorId).find(p => p.id === id)?.label ?? id)}`;
1845
+ case LookAxis.Mode: return `Light or dark site. ${keep} ${options(SPEC_AXES.modes, id => MODE_LABELS[id])}`;
1846
+ case LookAxis.Speed: return `How fast buttons and cards respond and things move. ${keep} ${options(Object.keys(SPEC_AXES.motions), id => labelOf(SPEC_AXES.motions, id))}`;
1847
+ case LookAxis.Scrolling: return `How the page scrolls. ${keep} ${options(SCROLL_IDS, id => `${labelOf(SPEC_AXES.scrolls, id)}: ${SPEC_AXES.scrolls[id].hint}`)}`;
1848
+ case LookAxis.Entrances: return `How content moves in as the visitor scrolls (the site's "how animated"). ${keep} ${options(ANIMATE_IDS, id => `${labelOf(SPEC_AXES.animations, id)}: ${SPEC_AXES.animations[id].hint}`)}`;
1849
+ case LookAxis.Between: return `What plays between pages. ${keep} ${options(BETWEEN_IDS, id => `${labelOf(SPEC_AXES.betweens, id)}: ${SPEC_AXES.betweens[id].hint}`)}`;
1850
+ }
1851
+ }
1852
+ /** Family `look`'s ONE strict format: every axis required, `''` keeps it; the ids listed and described from the contract. */
1853
+ function lookJsonSchema(current) {
1854
+ const properties = {};
1855
+ for (const axis of LOOK_AXES) {
1856
+ const ids = axisOptions(axis, current);
1857
+ properties[axis] = { ...(axis === LookAxis.Colour ? jsonText() : jsonOneOf([LOOK_KEEP, ...ids])), description: axisDescription(axis, current) };
1858
+ }
1859
+ properties[LookAnswerKey.Note] = { ...jsonText(), description: 'One short line for the owner on what changed, or what needs them.' };
1860
+ const part = jsonClosedObject(properties, Object.keys(properties));
1861
+ assertAssistBudget('look', [part]);
1862
+ return { parts: [part], handles: [[]] };
1863
+ }
1864
+ const isSiteLookEdit = (e) => !!e && typeof e === 'object' && 'look' in e;
1865
+ /** The answer as ONE edit (or none, when every axis is kept). */
1866
+ function decodeLookAnswers(answers) {
1867
+ const look = {};
1868
+ for (const answer of answers) {
1869
+ const a = (answer && typeof answer === 'object' ? answer : {});
1870
+ for (const axis of LOOK_AXES) {
1871
+ const v = typeof a[axis] === 'string' ? a[axis].trim() : '';
1872
+ if (v)
1873
+ look[axis] = v;
1874
+ }
1875
+ }
1876
+ return Object.keys(look).length ? [{ look }] : [];
1877
+ }
1878
+ /** The axes `presetChoices` sets that the site keeps (MO-D3: a style pick in the builder keeps its motion). */
1879
+ const SITE_MOTION = ['scroll', 'animate', 'between'];
1880
+ /** The first finding a failed audit names, as the owner reads it. */
1881
+ const findingLine = (f) => `${f.element} ${f.part} on ${f.scheme} is ${f.ratio.toFixed(2)}:1 (needs ${f.min}:1)`;
1882
+ /**
1883
+ * The answer on the current look: a style first (its whole look, the site's motion kept, the mode kept when the style
1884
+ * offers it), then every other axis named. Refused, all or none: an id the axis does not have, a colour that is not one,
1885
+ * a pairing the style does not offer, a mode the style was not drawn in, and a colour, tint or mode that fails the contrast
1886
+ * audit in a mode the site is worn in. A look that is exactly an audited style is not re-audited (the contract gated it).
1887
+ */
1888
+ function applyLookEdits(current, edits) {
1889
+ const before = resolveDesignChoices(current ?? null);
1890
+ const asked = Object.assign({}, ...edits.map(e => e.look));
1891
+ const issues = [];
1892
+ const refuse = (axis, code, message) => issues.push({ code, message: `${axis}: ${message}` });
1893
+ const has = (axis) => typeof asked[axis] === 'string' && asked[axis] !== LOOK_KEEP;
1894
+ const valid = (axis, ids) => {
1895
+ const v = asked[axis];
1896
+ if (ids.includes(v))
1897
+ return v;
1898
+ refuse(axis, AssistIssueCode.NotAnOption, `"${v}" is not one of ${ids.join(', ')}`);
1899
+ return null;
1900
+ };
1901
+ let next = { ...before };
1902
+ const mode = has(LookAxis.Mode) ? valid(LookAxis.Mode, SPEC_AXES.modes) : null;
1903
+ if (has(LookAxis.Style)) {
1904
+ const id = valid(LookAxis.Style, STYLE_PRESETS.map(p => p.id));
1905
+ const preset = id ? stylePresetById(id) : undefined;
1906
+ if (preset) {
1907
+ const wear = mode ?? (presetChoices(preset.id, before.mode) ? before.mode : undefined);
1908
+ const look = presetChoices(preset.id, wear);
1909
+ if (!look) {
1910
+ refuse(LookAxis.Mode, AssistIssueCode.NotAnOption, `${preset.name} is drawn in ${preset.modes.join(' and ')} only, not ${MODE_LABELS[wear]}`);
1911
+ }
1912
+ else {
1913
+ const { fonts: _drop, ...rest } = look;
1914
+ next = { ...rest, ...Object.fromEntries(SITE_MOTION.map(k => [k, before[k]])) };
1915
+ }
1916
+ }
1917
+ }
1918
+ if (has(LookAxis.Colour)) {
1919
+ const hex = lookHex(asked[LookAxis.Colour]);
1920
+ if (hex)
1921
+ next = { ...next, seed: hex };
1922
+ else
1923
+ refuse(LookAxis.Colour, AssistIssueCode.WrongType, `"${asked[LookAxis.Colour]}" is not a colour (#RRGGBB)`);
1924
+ }
1925
+ if (has(LookAxis.Tint)) {
1926
+ const v = valid(LookAxis.Tint, TINT_IDS);
1927
+ if (v)
1928
+ next = { ...next, tint: v };
1929
+ }
1930
+ if (has(LookAxis.Corners)) {
1931
+ const v = valid(LookAxis.Corners, Object.keys(SPEC_AXES.shapes));
1932
+ if (v)
1933
+ next = { ...next, shape: v };
1934
+ }
1935
+ if (has(LookAxis.Buttons)) {
1936
+ const v = valid(LookAxis.Buttons, Object.values(LookButtons));
1937
+ if (v)
1938
+ next = { ...next, pillButtons: v === LookButtons.Pill };
1939
+ }
1940
+ if (has(LookAxis.Spacing)) {
1941
+ const v = valid(LookAxis.Spacing, Object.keys(SPEC_AXES.densities));
1942
+ if (v)
1943
+ next = { ...next, density: v };
1944
+ }
1945
+ if (has(LookAxis.Type)) {
1946
+ const pairs = pairsOf(next.flavorId);
1947
+ const v = asked[LookAxis.Type];
1948
+ if (pairs.some(p => p.id === v)) {
1949
+ if (v !== next.pairId) {
1950
+ const { fonts: _drop, ...rest } = next;
1951
+ next = { ...rest, pairId: v };
1952
+ }
1953
+ }
1954
+ else {
1955
+ refuse(LookAxis.Type, AssistIssueCode.NotAnOption, `"${v}" is not a pairing of ${flavorPackById(next.flavorId)?.name ?? next.flavorId} (${pairs.map(p => p.id).join(', ')})`);
1956
+ }
1957
+ }
1958
+ if (mode)
1959
+ next = { ...next, mode };
1960
+ if (has(LookAxis.Speed)) {
1961
+ const v = valid(LookAxis.Speed, Object.keys(SPEC_AXES.motions));
1962
+ if (v)
1963
+ next = { ...next, motion: v };
1964
+ }
1965
+ if (has(LookAxis.Scrolling)) {
1966
+ const v = valid(LookAxis.Scrolling, SCROLL_IDS);
1967
+ if (v)
1968
+ next = { ...next, scroll: v };
1969
+ }
1970
+ if (has(LookAxis.Entrances)) {
1971
+ const v = valid(LookAxis.Entrances, ANIMATE_IDS);
1972
+ if (v)
1973
+ next = { ...next, animate: v };
1974
+ }
1975
+ if (has(LookAxis.Between)) {
1976
+ const v = valid(LookAxis.Between, BETWEEN_IDS);
1977
+ if (v)
1978
+ next = { ...next, between: v };
1979
+ }
1980
+ next = resolveDesignChoices(next);
1981
+ // The AA gate decides the colour: judged where the look paints, in every mode the site is worn in.
1982
+ const colourMoved = ['flavorId', 'seed', 'tint', 'mode'].some(k => String(next[k] ?? '').toLowerCase() !== String(before[k] ?? '').toLowerCase());
1983
+ if (!issues.length && colourMoved && !stylePresetOfChoices(next)) {
1984
+ const rows = designTokenRows(next);
1985
+ for (const worn of wornModes(next.mode)) {
1986
+ const failed = auditDesignContrast(rows, worn).filter(f => !f.pass);
1987
+ if (failed.length) {
1988
+ const axis = has(LookAxis.Colour) ? LookAxis.Colour : has(LookAxis.Tint) ? LookAxis.Tint : LookAxis.Mode;
1989
+ refuse(axis, AssistIssueCode.Contrast, `in ${MODE_LABELS[worn]} it does not pass contrast: ${findingLine(failed[0])}`
1990
+ + `${failed.length > 1 ? ` and ${failed.length - 1} more` : ''} — choose a ${worn === 'dark' ? 'lighter' : 'deeper'} colour or keep it`);
1991
+ break;
1992
+ }
1993
+ }
1994
+ }
1995
+ if (issues.length)
1996
+ return { ok: false, choices: before, changes: [], issues };
1997
+ const said = new Set([...(has(LookAxis.Style) ? [LookAxis.Style] : []), ...LOOK_AXES.filter(has)]);
1998
+ const changes = [];
1999
+ for (const axis of LOOK_AXES) {
2000
+ if (!said.has(axis))
2001
+ continue;
2002
+ const was = lookAxisValue(before, axis);
2003
+ const now = lookAxisValue(next, axis);
2004
+ if (was.id.toLowerCase() === now.id.toLowerCase() && was.label === now.label)
2005
+ continue;
2006
+ changes.push({ op: PageChangeOp.Look, axis, label: LOOK_AXIS_LABELS[axis], from: was.id, to: now.id, before: was.label, after: now.label });
2007
+ }
2008
+ return { ok: true, choices: next, changes, issues: [] };
2009
+ }
2010
+
1708
2011
  /**
1709
2012
  * Surface S1 (the builder, this page), family `words` (ai-assist-plan §4, ai-session-panel-plan §3b–§3d): the page as
1710
2013
  * the model sees it — sections in order, each a handle (`s0`), the parts that carry words as handles (`s0.heading1`,
@@ -1898,7 +2201,7 @@ function summarizePage(layout, ctx) {
1898
2201
  brief: {
1899
2202
  surface: AssistSurface.BuilderPage,
1900
2203
  focus,
1901
- around: { sections: around, pages: [...(ctx.pages ?? [])] },
2204
+ around: { sections: around, pages: [...(ctx.pages ?? [])], ...(ctx.look ? { look: summarizeLook(ctx.look) } : {}) },
1902
2205
  owner: ctx.owner ?? null,
1903
2206
  rules,
1904
2207
  memory: [...(ctx.memory ?? [])],
@@ -2102,20 +2405,25 @@ function pageWriteLocale(layout, ctx) {
2102
2405
  }
2103
2406
 
2104
2407
  const isWordEdit = (e) => 'value' in e;
2105
- const isLookEdit = (e) => !isWordEdit(e) && !isSectionEdit(e) && (isStyleEdit(e) || isSchemeEdit(e) || isSizeEdit(e));
2408
+ const isNodeStyleEdit = (e) => !isWordEdit(e) && !isSectionEdit(e) && !isSiteLookEdit(e) && (isStyleEdit(e) || isSchemeEdit(e) || isSizeEdit(e));
2106
2409
  function applyPageEdits(layout, edits, ctx) {
2107
2410
  const words = applyWordEdits(layout, edits.filter(isWordEdit), {
2108
2411
  handles: ctx.summary.handles, never: ctx.summary.brief.rules.never, sentence: ctx.sentence, words: ctx.words,
2109
2412
  });
2110
- const style = applyStyleEdits(words.result, edits.filter(isLookEdit), { looks: ctx.summary.looks, baseline: ctx.baseline });
2413
+ const style = applyStyleEdits(words.result, edits.filter(isNodeStyleEdit), { looks: ctx.summary.looks, baseline: ctx.baseline });
2111
2414
  const sectionEdits = edits.filter(isSectionEdit);
2112
2415
  const sections = sectionEdits.length
2113
2416
  ? applySectionEdits(style.result, sectionEdits, { sections: ctx.summary.sections ?? {}, input: ctx.sectionInput, newId: ctx.newId })
2114
2417
  : { result: style.result, changes: [], issues: [] };
2115
- const issues = [...words.issues, ...style.issues, ...sections.issues];
2418
+ const lookEdits = edits.filter(isSiteLookEdit);
2419
+ const look = lookEdits.length ? applyLookEdits(ctx.look, lookEdits) : null;
2420
+ const issues = [...words.issues, ...style.issues, ...sections.issues, ...(look?.issues ?? [])];
2116
2421
  if (issues.length)
2117
2422
  return { ok: false, result: JSON.parse(JSON.stringify(layout)), changes: [], issues };
2118
- return { ok: true, result: sections.result, changes: [...words.changes, ...style.changes, ...sections.changes], issues: [] };
2423
+ return {
2424
+ ok: true, result: sections.result, changes: [...words.changes, ...style.changes, ...sections.changes, ...(look?.changes ?? [])], issues: [],
2425
+ ...(look?.changes.length ? { look: look.choices } : {}),
2426
+ };
2119
2427
  }
2120
2428
 
2121
2429
  /**
@@ -2139,7 +2447,7 @@ const ASSIST_MODEL_AUTO = 'auto';
2139
2447
  const ASSIST_POLL_MS = 750;
2140
2448
  const MAX_SENTENCE_CHARS = 2000;
2141
2449
  const isLookChange = (c) => 'op' in c
2142
- && (c.op === PageChangeOp.Style || c.op === PageChangeOp.Scheme || c.op === PageChangeOp.Size || c.op === PageChangeOp.Section);
2450
+ && (c.op === PageChangeOp.Style || c.op === PageChangeOp.Scheme || c.op === PageChangeOp.Size || c.op === PageChangeOp.Section || c.op === PageChangeOp.Look);
2143
2451
  /** A turn's own refusals and failures, beside generation-core's `AiRefusalCode`s (credits, plan, key), which a turn returns as they are. */
2144
2452
  var AssistRefusalCode;
2145
2453
  (function (AssistRefusalCode) {
@@ -2287,5 +2595,5 @@ function validateTurnRequest(req) {
2287
2595
  * Generated bundle index. Do not edit.
2288
2596
  */
2289
2597
 
2290
- export { AROUND_ITEMS_MAX, AROUND_TEXT_CHARS, ASK_SECTION_PATTERNS, ASK_STYLE_SETS, ASSIST_MODEL_AUTO, ASSIST_POLL_MS, ASSIST_ROUTES, AssistBriefError, AssistBudgetError, AssistFieldKind, AssistIssueCode, AssistPathError, AssistPermission, AssistRefusalCode, AssistRouteKey, AssistScope, AssistStep, AssistSurface, AssistTurnStatus, BOOLEAN_FALSE, BOOLEAN_TRUE, CommitKind, EditFamily, FIELDS_PER_PART, FIELD_HANDLE_PREFIX, FOCUS_TEXT_CHARS, FieldsAnswerKey, ItemSuggestionKind, LOCALE_NAME_LANGUAGES, MAX_ASSIST_PROPERTIES, MAX_ROUTE_PROPERTIES, MAX_SENTENCE_CHARS, MEMORY_TURNS, NEW_TARGET, NONE_TEXT, NeverWriteReason, PAGE_WORD_SLOTS, PageChangeOp, PagePartKind, PageSuggestionKind, RouteAnswerKey, SECTION_START, SHORTEN_FROM_CHARS, SHORTEN_HEADING_FROM_CHARS, SHORTEN_TEXT_FROM_CHARS, SIBLING_HANDLE_PREFIX, SURFACES, SectionChangeKind, SectionsAnswerKey, StyleAnswerKey, SurfaceStatus, WORDS_PER_PART, WordsAnswerKey, adjustAxesOf, applyFieldEdits, applyPageEdits, applySectionEdits, applyStyleEdits, applyWordEdits, askSectionPatternNames, askableStyles, assertAssistBudget, assistBudgetIssues, assistFactIssues, assistFields, assistPath, assistSession, assistSessionKey, builtSurfaces, clipText, commitOf, containsHtml, decodeFieldsAnswers, decodeSectionsAnswers, decodeStyleAnswers, decodeWordsAnswers, escapeText, fieldHandle, fieldsJsonSchema, fieldsNamedIn, isEmptyFieldValue, isPlainRecord, isSchemeEdit, isSectionEdit, isSessionOf, isSizeEdit, isStyleEdit, isTerminalTurn, isWritable, itemLocales, itemSuggestions, languageName, lookNames, memoryLine, namedLocale, pageLooks, pageSuggestions, pageWriteLocale, paragraphsToRichText, primaryLocale, readFieldValue, readLocaleValues, readRoute, readableWords, resolveHandle, richTextParagraphs, routeJsonSchema, sectionLabel, sectionPatternOf, sectionsJsonSchema, serializedBaselineStyles, sessionMemory, styleJsonSchema, summarizeItem, summarizePage, surfacePermissions, surfaceSpec, titleField, turnLocale, unknownHandles, validateTurnRequest, wordsJsonSchema };
2598
+ export { AROUND_ITEMS_MAX, AROUND_TEXT_CHARS, ASK_SECTION_PATTERNS, ASK_STYLE_SETS, ASSIST_MODEL_AUTO, ASSIST_POLL_MS, ASSIST_ROUTES, AssistBriefError, AssistBudgetError, AssistFieldKind, AssistIssueCode, AssistPathError, AssistPermission, AssistRefusalCode, AssistRouteKey, AssistScope, AssistStep, AssistSurface, AssistTurnStatus, BOOLEAN_FALSE, BOOLEAN_TRUE, CommitKind, EditFamily, FIELDS_PER_PART, FIELD_HANDLE_PREFIX, FOCUS_TEXT_CHARS, FieldsAnswerKey, ItemSuggestionKind, LOCALE_NAME_LANGUAGES, LOOK_AXES, LOOK_AXIS_LABELS, LOOK_KEEP, LookAnswerKey, LookAxis, LookButtons, MAX_ASSIST_PROPERTIES, MAX_ROUTE_PROPERTIES, MAX_SENTENCE_CHARS, MEMORY_TURNS, MODE_LABELS, NEW_TARGET, NONE_TEXT, NeverWriteReason, PAGE_WORD_SLOTS, PageChangeOp, PagePartKind, PageSuggestionKind, RouteAnswerKey, SECTION_START, SHORTEN_FROM_CHARS, SHORTEN_HEADING_FROM_CHARS, SHORTEN_TEXT_FROM_CHARS, SIBLING_HANDLE_PREFIX, SURFACES, SectionChangeKind, SectionsAnswerKey, StyleAnswerKey, SurfaceStatus, WORDS_PER_PART, WordsAnswerKey, adjustAxesOf, applyFieldEdits, applyLookEdits, applyPageEdits, applySectionEdits, applyStyleEdits, applyWordEdits, askSectionPatternNames, askableStyles, assertAssistBudget, assistBudgetIssues, assistFactIssues, assistFields, assistPath, assistSession, assistSessionKey, builtSurfaces, clipText, commitOf, containsHtml, decodeFieldsAnswers, decodeLookAnswers, decodeSectionsAnswers, decodeStyleAnswers, decodeWordsAnswers, escapeText, fieldHandle, fieldsJsonSchema, fieldsNamedIn, isEmptyFieldValue, isPlainRecord, isSchemeEdit, isSectionEdit, isSessionOf, isSiteLookEdit, isSizeEdit, isStyleEdit, isTerminalTurn, isWritable, itemLocales, itemSuggestions, languageName, lookAxisValue, lookHex, lookJsonSchema, lookNames, memoryLine, namedLocale, pageLooks, pageSuggestions, pageWriteLocale, paragraphsToRichText, primaryLocale, readFieldValue, readLocaleValues, readRoute, readableWords, resolveHandle, richTextParagraphs, routeJsonSchema, sectionLabel, sectionPatternOf, sectionsJsonSchema, serializedBaselineStyles, sessionMemory, styleJsonSchema, summarizeItem, summarizeLook, summarizePage, surfacePermissions, surfaceSpec, titleField, turnLocale, unknownHandles, validateTurnRequest, wordsJsonSchema };
2291
2599
  //# sourceMappingURL=vectoriox-iox-ui-assist-core.mjs.map