@perkyzz/emvb-mcp 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -3132,6 +3132,9 @@ function handlePipeResult(left, next, ctx) {
3132
3132
  }
3133
3133
  return next._zod.run({ value: left.value, issues: left.issues }, ctx);
3134
3134
  }
3135
+ var $ZodPreprocess = /* @__PURE__ */ $constructor("$ZodPreprocess", (inst, def) => {
3136
+ $ZodPipe.init(inst, def);
3137
+ });
3135
3138
  var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
3136
3139
  $ZodType.init(inst, def);
3137
3140
  defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
@@ -6198,6 +6201,10 @@ function pipe(in_, out) {
6198
6201
  out
6199
6202
  });
6200
6203
  }
6204
+ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
6205
+ ZodPipe.init(inst, def);
6206
+ $ZodPreprocess.init(inst, def);
6207
+ });
6201
6208
  var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
6202
6209
  $ZodReadonly.init(inst, def);
6203
6210
  ZodType.init(inst, def);
@@ -6233,6 +6240,13 @@ function refine(fn, _params = {}) {
6233
6240
  function superRefine(fn, params) {
6234
6241
  return _superRefine(fn, params);
6235
6242
  }
6243
+ function preprocess(fn, schema) {
6244
+ return new ZodPreprocess({
6245
+ type: "pipe",
6246
+ in: transform(fn),
6247
+ out: schema
6248
+ });
6249
+ }
6236
6250
  // ../../node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/iso.js
6237
6251
  function datetime2(params) {
6238
6252
  return _isoDateTime(ZodISODateTime, params);
@@ -6247,12 +6261,12 @@ function duration2(params) {
6247
6261
  return _isoDuration(ZodISODuration, params);
6248
6262
  }
6249
6263
  // ../../docs/system/layout-format.md
6250
- var layout_format_default = "# Layout format (schema 16)\n\nHow EmVB stores a page and its site-wide design, at schema 16 (the image editor's `edit` record on images in W-481; per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 16,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `16` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341, W-481; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`) | none | `<p>` or `<div>` |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered` | none | `<ul>` or `<ol>` with `<li>` |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound) | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `text-input` | `field`, optional `label`, `placeholder` | none | labelled `<input class=\"ec-form-input\">` + `data-error-for` |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\") | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `itemPartId`; `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `section` (shown as \"Theme section\") | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `label` (1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000).\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }` | a colour layer above the image. Hex becomes 8-digit hex; a colour variable becomes `color-mix` |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`. No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`. For example `opacity 200ms ease-out 50ms` |\n| `entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `scrollMotion` (W-319, Normal only) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `iconAnimation` (W-237, Normal only) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear infinite`, `emvb-icon-pulse <ms> ease-in-out infinite alternate` or `none`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `transition`, `entrance`, `iconAnimation` and `scrollMotion`, which belong to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `transition` inside a state is dropped and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"tablet\"?, \"mobile\"? }`. Each is a style object with the same keys as `style`. Only keys that differ from desktop are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Tablet is `@media (max-width: 1024.98px)`, then mobile `@media (max-width: 767.98px)`. A phone matches both, so mobile wins on a shared key, and a tablet-only key still applies on mobile. The bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1025px)`, tablet `(min-width: 768px) and (max-width: 1024.98px)`, mobile `(max-width: 767.98px)`. The `.98` keeps fractional widths from zoom or display scaling (1024.5, say) inside one device, so nothing slips between two hide queries (W-506).\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 15,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins.\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no `data-emvb-*` attributes and no scripts.\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`). `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n";
6264
+ var layout_format_default = "# Layout format (schema 17)\n\nHow EmVB stores a page and its site-wide design, at layout schema 17 and design schema 16 (Loop forever on an icon animation in W-853, D-059; the image editor's `edit` record on images in W-481; per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 17,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `17` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341, W-481, W-885; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`) | none | `<p>` or `<div>` |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered` | none | `<ul>` or `<ol>` with `<li>` |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound) | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `text-input` | `field`, optional `label`, `placeholder` | none | labelled `<input class=\"ec-form-input\">` + `data-error-for` |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` (words the empty first choice; unset is \"Choose…\", W-686) | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\"), `titleText` (the paged archive title, `{title}` and `{page}`, W-529), `archiveTitle` (replaces \"Posts\" as the posts archive title, ≤ 60, W-532), and screen reader names `navLabel` (\"Pagination\"), `pageLabel` (\"Page {page}\"), `prevLabel` and `nextLabel` (\"Previous page\" / \"Next page\", used when the text is only an arrow), each ≤ 60 (W-689) | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `itemPartId`; `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `section` (shown as \"Theme section\") | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `label` (1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000).\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }` | a colour layer above the image. Hex becomes 8-digit hex; a colour variable becomes `color-mix` |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`. No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`. For example `opacity 200ms ease-out 50ms` |\n| `entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `scrollMotion` (W-319, Normal only) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `iconAnimation` (W-237, Normal only) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000; optional `loop: true` (W-853, D-059) keeps it running forever. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear <runs>`, `emvb-icon-pulse <ms> ease-in-out <runs> alternate` or `none`; W-848: `<runs>` is as many whole runs as fit in 5 s, at least one, even for a pulse; with `loop: true` it is `infinite`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `transition`, `entrance`, `iconAnimation` and `scrollMotion`, which belong to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `transition` inside a state is dropped and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"tablet\"?, \"mobile\"? }`. Each is a style object with the same keys as `style`. Only keys that differ from desktop are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Tablet is `@media (max-width: 1024.98px)`, then mobile `@media (max-width: 767.98px)`. A phone matches both, so mobile wins on a shared key, and a tablet-only key still applies on mobile. The bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1025px)`, tablet `(min-width: 768px) and (max-width: 1024.98px)`, mobile `(max-width: 767.98px)`. The `.98` keeps fractional widths from zoom or display scaling (1024.5, say) inside one device, so nothing slips between two hide queries (W-506).\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 16,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins.\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no `data-emvb-*` attributes and no scripts.\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`). `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n";
6251
6265
 
6252
6266
  // skill/emvb-page-builder/SKILL.md
6253
6267
  var SKILL_default = `---
6254
6268
  name: emvb-page-builder
6255
- description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
6269
+ description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, insert_saved_section, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
6256
6270
  ---
6257
6271
 
6258
6272
  # EmVB page builder
@@ -6281,6 +6295,10 @@ instructions.
6281
6295
  \`recipes\` or \`apply_section_recipe\`), then replace every placeholder with real copy using
6282
6296
  \`update_element\`. Start with "hero" so its heading is the page's one h1. For anything the
6283
6297
  recipes don't cover, \`add_element\` takes a whole section with nested \`children\` in one call.
6298
+ The site's own saved sections come first when one fits: \`list_saved_sections\`, then
6299
+ \`insert_saved_section\` (it adds the classes the section uses to the styles draft; a class whose
6300
+ look changed comes in as a numbered copy such as "Card 2", never overwriting the site's).
6301
+ \`save_section\` saves an element for reuse; \`delete_saved_section\` only when the person asks.
6284
6302
  6. **Check accessibility** with \`get_accessibility_findings\` after building and fix every
6285
6303
  error. Contrast findings that share one colour: change that colour variable once.
6286
6304
  7. **Don't publish** unless the person asked and \`publish_page\` is available. End with
@@ -6309,6 +6327,11 @@ instructions.
6309
6327
  replace those references first. Pass \`force: true\` only if the person asked.
6310
6328
  - An image \`src\` must be an http(s) URL or a path on the site; \`javascript:\`, \`data:\` and
6311
6329
  \`//host\` sources are refused.
6330
+ - \`REFUSED\` on a link or an SVG: the page would drop it (a \`javascript:\` link, \`onload\` or a
6331
+ script in SVG markup); the message gives the reason. A class or variable name another one
6332
+ already has is refused too. A write that changes nothing saves no new version.
6333
+ - \`REFUSED\` on \`insert_saved_section\`: the place can't take the section, or the site is at 100
6334
+ classes; nothing was added to the styles draft. Pick another \`parentId\` or ask the person.
6312
6335
  - \`PUBLISH_DISABLED\`: leave the draft for review.
6313
6336
  - \`FORBIDDEN\`: agent access is off on the site, or the token can't use EmVB; tell the person.
6314
6337
  - \`NOT_SET_UP\`: an admin must click "Set up EmVB" in the EmDash admin first; tell the person.
@@ -6405,6 +6428,15 @@ var MAX_TABS = 12;
6405
6428
  function clipText(text, max) {
6406
6429
  if (text.length <= max)
6407
6430
  return text;
6431
+ if (typeof Intl !== "undefined" && "Segmenter" in Intl) {
6432
+ let end = 0;
6433
+ for (const { segment } of new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text.slice(0, max + 32))) {
6434
+ if (end + segment.length > max)
6435
+ break;
6436
+ end += segment.length;
6437
+ }
6438
+ return text.slice(0, end);
6439
+ }
6408
6440
  const code = text.charCodeAt(max - 1);
6409
6441
  return text.slice(0, code >= 55296 && code <= 56319 ? max - 1 : max);
6410
6442
  }
@@ -6459,7 +6491,15 @@ var Geometry = strictObject({
6459
6491
  aspectRatio: number2().finite().min(0.01).max(100).nullable()
6460
6492
  }).partial();
6461
6493
  var FilterLabel = string2().regex(/^[A-Za-z0-9 _-]{1,32}$/, "Filter names are short words");
6462
- var BlendSrc = string2().max(2000).refine((s) => /^\/(?!\/)/.test(s) || /^https:\/\//i.test(s), "Blend images must be a site path or an https URL");
6494
+ function hasUnsafeUrlChar(s) {
6495
+ for (const ch of s) {
6496
+ const code = ch.charCodeAt(0);
6497
+ if (ch === "\\" || code < 32 || code === 127)
6498
+ return true;
6499
+ }
6500
+ return false;
6501
+ }
6502
+ var BlendSrc = string2().max(2000).refine((s) => !hasUnsafeUrlChar(s) && (/^\/(?!\/)/.test(s) || /^https:\/\//i.test(s)), "Blend images must be a site path or an https URL");
6463
6503
  var ImageEditRecipe = strictObject({
6464
6504
  version: literal(1),
6465
6505
  name: string2().max(80).optional(),
@@ -6575,7 +6615,7 @@ function sanitizeUrl(value, schemes) {
6575
6615
  return;
6576
6616
  if (/[^\S ]|\\/.test(trimmed))
6577
6617
  return;
6578
- if (/^(?:[/?#.]|[A-Za-z0-9._~-])/.test(trimmed))
6618
+ if (/^(?:[/?#.]|[\p{L}\p{N}._~-])/u.test(trimmed))
6579
6619
  return trimmed;
6580
6620
  return;
6581
6621
  }
@@ -6620,6 +6660,14 @@ var MOTION_KEYFRAMES = `@media (prefers-reduced-motion: no-preference){@supports
6620
6660
  // ../emvb/src/core/record.ts
6621
6661
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
6622
6662
 
6663
+ // ../emvb/src/core/icons/animation-runs.ts
6664
+ var ICON_ANIMATION_LIMIT_MS = 5000;
6665
+ function iconAnimationRuns(type, durationMs) {
6666
+ if (type === "spin")
6667
+ return Math.max(1, Math.floor(ICON_ANIMATION_LIMIT_MS / durationMs));
6668
+ return 2 * Math.max(1, Math.floor(ICON_ANIMATION_LIMIT_MS / (2 * durationMs)));
6669
+ }
6670
+
6623
6671
  // ../emvb/src/core/sanitize/css.ts
6624
6672
  var setOf = (values) => new Set(values);
6625
6673
  var VAR_ID = /^[a-z0-9-]{1,40}$/;
@@ -6884,22 +6932,25 @@ function cssIconShadow(value) {
6884
6932
  return `drop-shadow(${decimal(x)}px ${decimal(y)}px ${decimal(blur)}px${color ? ` ${color}` : ""})`;
6885
6933
  }
6886
6934
  var ICON_ANIMATIONS = {
6887
- spin: "emvb-icon-spin {ms} linear infinite",
6888
- pulse: "emvb-icon-pulse {ms} ease-in-out infinite alternate"
6935
+ spin: "emvb-icon-spin {ms} linear {runs}",
6936
+ pulse: "emvb-icon-pulse {ms} ease-in-out {runs} alternate"
6889
6937
  };
6890
6938
  function cssIconAnimation(value) {
6891
6939
  if (!isRecord(value))
6892
6940
  return;
6893
- if (Object.keys(value).some((key) => key !== "type" && key !== "duration"))
6941
+ if (Object.keys(value).some((key) => key !== "type" && key !== "duration" && key !== "loop"))
6942
+ return;
6943
+ const { type, duration, loop } = value;
6944
+ if (loop !== undefined && (loop !== true || type === "none"))
6894
6945
  return;
6895
- const { type, duration } = value;
6896
6946
  if (type === "none")
6897
6947
  return duration === undefined ? "none" : undefined;
6898
6948
  if (typeof type !== "string" || !Object.hasOwn(ICON_ANIMATIONS, type))
6899
6949
  return;
6900
6950
  if (!Number.isInteger(duration) || !inRangeNumber(duration, 200, 1e4))
6901
6951
  return;
6902
- return ICON_ANIMATIONS[type]?.replace("{ms}", `${duration}ms`);
6952
+ const runs = loop ? "infinite" : iconAnimationRuns(type === "spin" ? "spin" : "pulse", duration);
6953
+ return ICON_ANIMATIONS[type]?.replace("{ms}", `${duration}ms`).replace("{runs}", String(runs));
6903
6954
  }
6904
6955
  var BACKGROUND_SIZE = setOf(BACKGROUND_SIZES);
6905
6956
  var BACKGROUND_POSITION = setOf(BACKGROUND_POSITIONS);
@@ -7090,7 +7141,8 @@ var SHORTHANDS = new Set(["borderWidth", "borderRadius"]);
7090
7141
  var TRIGGER_LIMITS = {
7091
7142
  maxDelayMs: 120000,
7092
7143
  maxScrollPercent: 100,
7093
- minIdleMs: 1000
7144
+ minIdleMs: 1000,
7145
+ maxClickSelectorLength: 200
7094
7146
  };
7095
7147
  var POPUP_DEVICES = ["desktop", "tablet", "mobile"];
7096
7148
 
@@ -7247,7 +7299,8 @@ var StyleProps = strictObject({
7247
7299
  iconAnimation: union([
7248
7300
  strictObject({
7249
7301
  type: _enum(["spin", "pulse"]),
7250
- duration: number2().int().min(200).max(1e4)
7302
+ duration: number2().int().min(200).max(1e4),
7303
+ loop: literal(true).optional()
7251
7304
  }),
7252
7305
  strictObject({ type: literal("none") })
7253
7306
  ]).optional(),
@@ -7302,7 +7355,7 @@ var DeviceStyles = strictObject({
7302
7355
  var HiddenOn = array(_enum(POPUP_DEVICES)).max(3);
7303
7356
 
7304
7357
  // ../emvb/src/core/schema/layout.ts
7305
- var LAYOUT_SCHEMA_VERSION = 16;
7358
+ var LAYOUT_SCHEMA_VERSION = 17;
7306
7359
  var NodeId = string2().regex(/^[A-Za-z0-9_-]{4,24}$/, "Ids are 4-24 letters, digits, _ or -");
7307
7360
  var ClassIds = array(string2().regex(/^[a-z0-9-]{1,40}$/)).max(20);
7308
7361
  var HtmlId = string2().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/, "CSS ids start with a letter and are at most 64 characters");
@@ -7338,9 +7391,9 @@ var Variant = strictObject({
7338
7391
  });
7339
7392
  var AUDIENCE_DEVICES = ["mobile", "tablet", "desktop"];
7340
7393
  var AUDIENCE_SEGMENT = /^[a-z0-9][a-z0-9:_-]{0,63}$/;
7341
- var SEGMENT_HINT = "Segments are lowercase letters, digits, :, - or _, e.g. plan:pro";
7394
+ var SEGMENT_HINT = "Segments are lowercase letters, digits, :, - or _, such as plan:pro";
7342
7395
  var Audience = strictObject({
7343
- countries: array(string2().regex(/^[A-Z]{2}$/, "Two-letter country codes, e.g. CA")).min(1).max(50).optional(),
7396
+ countries: array(string2().regex(/^[A-Z]{2}$/, "Two-letter country codes, such as CA")).min(1).max(50).optional(),
7344
7397
  devices: array(_enum(AUDIENCE_DEVICES)).min(1).max(3).optional(),
7345
7398
  visitor: _enum(["new", "returning"]).optional(),
7346
7399
  hours: strictObject({ from: number2().int().min(0).max(23), to: number2().int().min(0).max(24) }).optional(),
@@ -7559,19 +7612,19 @@ var PostLinkNode = leafNode("post-link", strictObject({
7559
7612
  }));
7560
7613
  var LOOP_DISPLAYS = ["list", "grid", "cards"];
7561
7614
  var FIELD_SLUG = /^[a-z][a-z0-9_]{0,63}$/;
7562
- var FIELD_SLUG_HINT = "Use the field's slug, e.g. photo";
7615
+ var FIELD_SLUG_HINT = "Use the field's slug, such as photo";
7563
7616
  var LOOP_PERMALINK = /^(?=.*\{(?:slug|id)\})\/(?!\/)(?:[A-Za-z0-9._~/-]|\{slug\}|\{id\})*$/;
7564
7617
  var LOOP_FILTER = /^\s*[a-z][a-z0-9_]{0,63}\s*=\s*[^;=<>\s](?:[^;=<>]{0,98}[^;=<>\s])?(?:\s*;\s*[a-z][a-z0-9_]{0,63}\s*=\s*[^;=<>\s](?:[^;=<>]{0,98}[^;=<>\s])?)*\s*;?\s*$/;
7565
7618
  var LOOP_ORDERS = ["newest", "oldest", "title"];
7566
7619
  var LoopNode = parentNode("loop", strictObject({
7567
7620
  itemPartId: string2().max(128).optional(),
7568
7621
  perPage: number2().int().min(1).max(50).optional(),
7569
- collection: string2().regex(/^[a-z][a-z0-9_]{0,63}$/, "Use the collection's slug, e.g. team").optional(),
7622
+ collection: string2().regex(/^[a-z][a-z0-9_]{0,63}$/, "Use the collection's slug, such as team").optional(),
7570
7623
  limit: number2().int().min(1).max(50).optional(),
7571
7624
  order: _enum(LOOP_ORDERS).optional(),
7572
7625
  display: _enum(LOOP_DISPLAYS).optional(),
7573
7626
  columns: number2().int().min(1).max(6).optional(),
7574
- permalink: string2().max(200).regex(LOOP_PERMALINK, "A site path with {slug} or {id}, e.g. /team/{slug}").optional(),
7627
+ permalink: string2().max(200).regex(LOOP_PERMALINK, "A site path with {slug} or {id}, such as /team/{slug}").optional(),
7575
7628
  imageField: string2().regex(FIELD_SLUG, FIELD_SLUG_HINT).optional(),
7576
7629
  excerptField: string2().regex(FIELD_SLUG, FIELD_SLUG_HINT).optional(),
7577
7630
  filter: string2().max(300).regex(LOOP_FILTER, "Use field=value pairs separated by ;").optional()
@@ -7582,7 +7635,12 @@ var PaginationNode = leafNode("pagination", strictObject({
7582
7635
  nextText: string2().max(40).optional(),
7583
7636
  showCount: boolean2().optional(),
7584
7637
  countText: string2().max(60).optional(),
7585
- titleText: string2().max(60).optional()
7638
+ titleText: string2().max(60).optional(),
7639
+ archiveTitle: string2().max(60).optional(),
7640
+ navLabel: string2().max(60).optional(),
7641
+ pageLabel: string2().max(60).optional(),
7642
+ prevLabel: string2().max(60).optional(),
7643
+ nextLabel: string2().max(60).optional()
7586
7644
  }));
7587
7645
  var SectionNode = parentNode("section", strictObject({
7588
7646
  partId: string2().max(128).optional()
@@ -8053,6 +8111,44 @@ function parseSvg(raw) {
8053
8111
  return;
8054
8112
  return build(tokens);
8055
8113
  }
8114
+ function isSafeSvgMarkup(raw) {
8115
+ return sanitizeSvgMarkup(raw) !== undefined;
8116
+ }
8117
+
8118
+ // ../emvb/src/core/elements/svg-ids.ts
8119
+ var URL_REF = /url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/g;
8120
+ var ID_LIST_ATTRS = new Set(["aria-labelledby", "aria-describedby"]);
8121
+ function scopeSvgIds(children, prefix) {
8122
+ const ids = new Set;
8123
+ const collect = (node) => {
8124
+ if (typeof node === "string")
8125
+ return;
8126
+ if (node.attrs.id)
8127
+ ids.add(node.attrs.id);
8128
+ node.children.forEach(collect);
8129
+ };
8130
+ children.forEach(collect);
8131
+ if (ids.size === 0)
8132
+ return children;
8133
+ const scoped = (id) => ids.has(id) ? `${prefix}-${id}` : id;
8134
+ const rewrite = (node) => {
8135
+ if (typeof node === "string")
8136
+ return node;
8137
+ const attrs = {};
8138
+ for (const [name, value] of Object.entries(node.attrs)) {
8139
+ if (name === "id")
8140
+ attrs[name] = scoped(value);
8141
+ else if ((name === "href" || name === "xlink:href") && value.startsWith("#"))
8142
+ attrs[name] = `#${scoped(value.slice(1))}`;
8143
+ else if (ID_LIST_ATTRS.has(name))
8144
+ attrs[name] = value.split(/\s+/).map(scoped).join(" ");
8145
+ else
8146
+ attrs[name] = value.replace(URL_REF, (_m, q, id) => `url(${q}#${scoped(id)}${q})`);
8147
+ }
8148
+ return { ...node, attrs, children: node.children.map(rewrite) };
8149
+ };
8150
+ return children.map(rewrite);
8151
+ }
8056
8152
 
8057
8153
  // ../emvb/src/core/icons/catalog.ts
8058
8154
  var BUNDLED_ICONS = [
@@ -8105,8 +8201,8 @@ var BUNDLED_ICONS = [
8105
8201
  label: "Circle Alert",
8106
8202
  children: [
8107
8203
  { tag: "circle", attrs: { cx: "12", cy: "12", r: "10" } },
8108
- { tag: "line", attrs: {} },
8109
- { tag: "line", attrs: {} }
8204
+ { tag: "line", attrs: { x1: "12", x2: "12", y1: "8", y2: "12" } },
8205
+ { tag: "line", attrs: { x1: "12", x2: "12.01", y1: "16", y2: "16" } }
8110
8206
  ]
8111
8207
  },
8112
8208
  {
@@ -8317,6 +8413,7 @@ var YT_HOSTS = new Set([
8317
8413
  "youtube.com",
8318
8414
  "www.youtube.com",
8319
8415
  "m.youtube.com",
8416
+ "music.youtube.com",
8320
8417
  "youtu.be",
8321
8418
  "www.youtu.be",
8322
8419
  "youtube-nocookie.com",
@@ -8327,9 +8424,20 @@ var matching = (id, pattern) => id && pattern.test(id) ? id : undefined;
8327
8424
  var YT_ID = /^[\w-]{6,}$/;
8328
8425
  var VIMEO_ID = /^\d{6,}$/;
8329
8426
  var firstSegment = (path) => path.split("/").find(Boolean);
8427
+ var YT_LIST = /^[\w-]{10,64}$/;
8428
+ function youtubePlaylist(parsed) {
8429
+ const path = parsed.pathname.replace(/\/+$/, "");
8430
+ if (path !== "/embed/videoseries" && path !== "/playlist")
8431
+ return null;
8432
+ const list = matching(parsed.searchParams.get("list") ?? undefined, YT_LIST);
8433
+ return list ? `videoseries?list=${list}` : undefined;
8434
+ }
8330
8435
  function youtubeId(parsed) {
8331
8436
  const host = parsed.hostname.toLowerCase();
8332
8437
  const path = parsed.pathname;
8438
+ const playlist = youtubePlaylist(parsed);
8439
+ if (playlist !== null)
8440
+ return playlist;
8333
8441
  if (host === "youtu.be" || host === "www.youtu.be")
8334
8442
  return matching(firstSegment(path), YT_ID);
8335
8443
  for (const prefix of ["/embed/", "/shorts/", "/live/"]) {
@@ -8343,7 +8451,7 @@ function vimeoId(parsed) {
8343
8451
  const parts = parsed.pathname.split("/").filter(Boolean);
8344
8452
  const player = parsed.hostname.toLowerCase() === "player.vimeo.com";
8345
8453
  const videoIdx = parts.indexOf("video");
8346
- const at = player ? videoIdx >= 0 ? videoIdx + 1 : 0 : parts[0] === "channels" ? 2 : parts[0] === "groups" && parts[2] === "videos" ? 3 : 0;
8454
+ const at = player ? videoIdx >= 0 ? videoIdx + 1 : 0 : parts[0] === "channels" ? 2 : parts[0] === "groups" && parts[2] === "videos" || parts[0] === "showcase" && parts[2] === "video" ? 3 : 0;
8347
8455
  const id = matching(parts[at], VIMEO_ID);
8348
8456
  if (!id)
8349
8457
  return;
@@ -8363,7 +8471,7 @@ function startOf(parsed) {
8363
8471
  const fragment = new URLSearchParams(parsed.hash.replace(/^#/, ""));
8364
8472
  return parseStartSeconds(parsed.searchParams.get("t") ?? parsed.searchParams.get("start") ?? fragment.get("t"));
8365
8473
  }
8366
- var withStart = (provider, src, start) => start === undefined ? src : provider === "youtube" ? `${src}?start=${start}` : `${src}#t=${start}s`;
8474
+ var withStart = (provider, src, start) => start === undefined ? src : provider === "youtube" ? `${src}${src.includes("?") ? "&" : "?"}start=${start}` : `${src}#t=${start}s`;
8367
8475
  var PROVIDERS = [
8368
8476
  {
8369
8477
  provider: "youtube",
@@ -8373,14 +8481,28 @@ var PROVIDERS = [
8373
8481
  },
8374
8482
  { provider: "vimeo", hosts: VIMEO_HOSTS, id: vimeoId, embed: "https://player.vimeo.com/video/" }
8375
8483
  ];
8376
- var BARE_VIDEO_HOST = /^(?:(?:www\.|m\.)?youtube\.com|youtu\.be|(?:www\.|player\.)?vimeo\.com)\//i;
8484
+ function bareVideoHost(typed) {
8485
+ const slash = typed.indexOf("/");
8486
+ if (slash <= 0)
8487
+ return false;
8488
+ const host = typed.slice(0, slash).toLowerCase();
8489
+ return YT_HOSTS.has(host) || VIMEO_HOSTS.has(host);
8490
+ }
8491
+ function isVideoFilePath(value) {
8492
+ if (value.startsWith("//"))
8493
+ return false;
8494
+ const path = value.split(/[?#]/)[0] ?? "";
8495
+ return /\.(mp4|webm|ogg)$/i.test(path) || path.startsWith("/_emdash/api/media/file/");
8496
+ }
8377
8497
  function resolveEmbedUrl(value) {
8378
8498
  const typed = value.trim();
8379
- const trimmed = BARE_VIDEO_HOST.test(typed) ? `https://${typed}` : typed;
8499
+ const trimmed = bareVideoHost(typed) ? `https://${typed}` : typed;
8380
8500
  if (trimmed.length === 0 || trimmed.length > 2000)
8381
8501
  return;
8382
8502
  const hasScheme = /^[a-z][a-z0-9+.-]*:/i.test(trimmed);
8383
8503
  if (!hasScheme) {
8504
+ if (!isVideoFilePath(trimmed))
8505
+ return;
8384
8506
  const media = sanitizeMediaUrl(trimmed);
8385
8507
  if (!media)
8386
8508
  return;
@@ -8437,7 +8559,7 @@ function stampGroup(children, name) {
8437
8559
  };
8438
8560
  });
8439
8561
  }
8440
- function groupItems(children) {
8562
+ function groupItems(children, listClass = "emvb-menu__list emvb-menu__list--sub") {
8441
8563
  const out = [];
8442
8564
  let batch = [];
8443
8565
  const flush = () => {
@@ -8445,7 +8567,7 @@ function groupItems(children) {
8445
8567
  return;
8446
8568
  out.push({
8447
8569
  tag: "ul",
8448
- attrs: { class: "emvb-menu__list emvb-menu__list--sub" },
8570
+ attrs: { class: listClass },
8449
8571
  children: batch
8450
8572
  });
8451
8573
  batch = [];
@@ -8473,13 +8595,18 @@ var MENU_CSS = [
8473
8595
  ".emvb-menu-item__toggle{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;padding:0;cursor:pointer;list-style:none}",
8474
8596
  ".emvb-menu-item__toggle::-webkit-details-marker{display:none}",
8475
8597
  ".emvb-menu-item__toggle::before{content:'';width:.4rem;height:.4rem;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg) translateY(-1px)}",
8598
+ ".emvb-menu-item__toggle--label{width:auto;gap:.6rem;padding-inline-end:.35rem}",
8599
+ ".emvb-menu-item__toggle--label::before{order:1}",
8476
8600
  ".emvb-menu-panel{display:none;position:absolute;z-index:30;top:100%;inset-inline-start:0;min-width:12rem;padding:.75rem;background:canvas;color:canvastext;border:1px solid #00000014;box-shadow:0 12px 32px #00000029}",
8477
8601
  ".emvb-menu-item__disclosure[open]>.emvb-menu-panel{display:block}",
8478
- "@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel,.emvb-menu-item:focus-within>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel{display:block}}",
8479
- "@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure::details-content{content-visibility:visible}}",
8602
+ "@media (hover:hover) and (pointer:fine){.emvb-menu-item:not([data-emvb-menu-dismissed]):hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel,.emvb-menu-item:not([data-emvb-menu-dismissed]):focus-within>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel{display:block}}",
8603
+ "@media (hover:hover) and (pointer:fine){.emvb-menu-item:not([data-emvb-menu-dismissed]):hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure::details-content{content-visibility:visible}}",
8480
8604
  ".emvb-menu-panel--wide{inset-inline:0;min-width:0}",
8605
+ ".emvb-menu--column .emvb-menu-item{position:static}",
8606
+ ".emvb-menu--column .emvb-menu-item__bar{position:relative;width:fit-content;max-width:100%}",
8481
8607
  ".emvb-menu--column .emvb-menu-panel{top:0;inset-inline-start:100%}",
8482
- ".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}"
8608
+ ".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}",
8609
+ "@media (max-width: 767.98px){.emvb-menu--column .emvb-menu-panel,.emvb-menu--column .emvb-menu-panel--wide{top:100%;inset-inline:auto;inset-inline-start:0;min-width:min(12rem,calc(100vw - 2rem));max-width:calc(100vw - 2rem)}}"
8483
8610
  ].join("");
8484
8611
  var menu = {
8485
8612
  baseCss: MENU_CSS,
@@ -8522,13 +8649,7 @@ var menu = {
8522
8649
  return {
8523
8650
  tag: "nav",
8524
8651
  attrs: { ...attrs, class: classes, "aria-label": label },
8525
- children: [
8526
- {
8527
- tag: "ul",
8528
- attrs: { class: "emvb-menu__list" },
8529
- children: stampGroup(children, `emvb-menu-${node.id}`)
8530
- }
8531
- ]
8652
+ children: groupItems(stampGroup(children, `emvb-menu-${node.id}`), "emvb-menu__list")
8532
8653
  };
8533
8654
  }
8534
8655
  };
@@ -8541,11 +8662,11 @@ var menuItem = {
8541
8662
  group: "content",
8542
8663
  defaultTab: "content",
8543
8664
  fields: [
8544
- { key: "text", kind: "text", label: "Label" },
8665
+ { key: "text", kind: "text", label: "Text" },
8545
8666
  {
8546
8667
  key: "href",
8547
8668
  kind: "href",
8548
- label: "Link",
8669
+ label: "URL",
8549
8670
  optional: true,
8550
8671
  message: "Use a full URL such as https://example.com or a path such as /pricing."
8551
8672
  },
@@ -8562,14 +8683,19 @@ var menuItem = {
8562
8683
  attrs: { class: "emvb-menu-item__link", href, ...newTabAttrs(node.props.newTab) },
8563
8684
  children: [node.props.text]
8564
8685
  } : { tag: "span", attrs: { class: "emvb-menu-item__label" }, children: [node.props.text] };
8565
- const bar = [label];
8686
+ const textToggle = !href && children.length > 0;
8687
+ const bar = textToggle ? [] : [label];
8566
8688
  if (children.length > 0) {
8567
8689
  const panelClass = wide ? "emvb-menu-panel emvb-menu-panel--wide" : "emvb-menu-panel";
8568
8690
  bar.push({
8569
8691
  tag: "details",
8570
8692
  attrs: { class: "emvb-menu-item__disclosure" },
8571
8693
  children: [
8572
- {
8694
+ textToggle ? {
8695
+ tag: "summary",
8696
+ attrs: { class: "emvb-menu-item__toggle emvb-menu-item__toggle--label" },
8697
+ children: [node.props.text]
8698
+ } : {
8573
8699
  tag: "summary",
8574
8700
  attrs: { class: "emvb-menu-item__toggle", "aria-label": `Open ${node.props.text}` },
8575
8701
  children: []
@@ -8590,6 +8716,9 @@ var menuItem = {
8590
8716
  }
8591
8717
  };
8592
8718
 
8719
+ // ../emvb/src/core/elements/select-prompt.ts
8720
+ var selectPrompt = (props) => props.placeholder?.trim() || "Choose…";
8721
+
8593
8722
  // ../emvb/src/core/elements/field-id.ts
8594
8723
  var controlId = (nodeId) => `emvb-field-${nodeId}`;
8595
8724
 
@@ -8603,9 +8732,9 @@ var TEXT_FIELDS = [
8603
8732
  ...NAME_AND_LABEL,
8604
8733
  { key: "placeholder", kind: "text", label: "Placeholder", optional: true }
8605
8734
  ];
8606
- var FORM_FIELD_CSS = ":where(.emvb-form .emvb-form-label){font-weight:600}" + ":where(.emvb-form .ec-form-input){box-sizing:border-box;width:100%;max-width:100%;margin:0;padding:.625em .75em;font:inherit;color:inherit;background-color:transparent;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 30%,transparent);border-radius:6px}" + ":where(.emvb-form textarea.ec-form-input){min-height:7.5em;resize:vertical}" + ":where(.emvb-form .ec-form-input)::placeholder{color:inherit;opacity:.55}" + ":where(.emvb-form .ec-form-input:focus-visible){outline:2px solid currentColor;outline-offset:1px;border-color:currentColor}" + ':where(.emvb-form .ec-form-input[aria-invalid="true"]){border-color:#b3261e}' + ':where(.emvb-form input[type="checkbox"],.emvb-form input[type="radio"]){width:1.1em;height:1.1em;margin:0;accent-color:currentColor}' + ":where(.emvb-form .emvb-form-checkbox-label,.emvb-form .emvb-form-radio-label){display:inline-flex;align-items:center;gap:.5em}" + ":where(.emvb-form .emvb-radio-group){display:flex;flex-direction:column;gap:6px;margin:0;padding:0;border:0;min-width:0}" + ":where(.emvb-form .emvb-radio-group>legend){float:left;width:100%;margin:0 0 -2px;padding:0}" + ":where(.emvb-form .ec-form-error){font-size:.875em;color:#b3261e}";
8735
+ var FORM_FIELD_CSS = ":where(.emvb-form .emvb-form-label){font-weight:600}" + ":where(.emvb-form .ec-form-input){box-sizing:border-box;width:100%;max-width:100%;margin:0;padding:.625em .75em;font:inherit;color:inherit;background-color:transparent;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 30%,transparent);border-radius:6px}" + ":where(.emvb-form textarea.ec-form-input){min-height:7.5em;resize:vertical}" + ":where(.emvb-form .ec-form-input)::placeholder{color:inherit;opacity:.55}" + ":where(.emvb-form .ec-form-input:focus-visible){outline:2px solid currentColor;outline-offset:1px;border-color:currentColor}" + ':where(.emvb-form .ec-form-input[aria-invalid="true"]){border-color:#b3261e}' + ':where(.emvb-form input[type="checkbox"],.emvb-form input[type="radio"]){width:1.1em;height:1.1em;margin:0;accent-color:currentColor}' + ":where(.emvb-form .emvb-form-checkbox-label,.emvb-form .emvb-form-radio-label){display:inline-flex;align-items:center;gap:.5em;overflow-wrap:anywhere}" + ":where(.emvb-form .emvb-radio-group){display:flex;flex-direction:column;gap:6px;margin:0;padding:0;border:0;min-width:0}" + ":where(.emvb-form .emvb-radio-group>legend){float:left;width:100%;margin:0 0 -2px;padding:0}" + ":where(.emvb-form .ec-form-error){font-size:.875em;color:#b3261e}";
8607
8736
  var form = {
8608
- baseCss: ".emvb-form{display:flex;flex-direction:column;gap:12px;min-width:0}.emvb-form-unbound{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}.ec-form-hp{position:absolute;left:-9999px}" + ":where(.emvb-form-paused){padding:12px 16px;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 25%,transparent);border-radius:6px}:where(.emvb-form-paused p){margin:0}" + FORM_FIELD_CSS,
8737
+ baseCss: ".emvb-form{display:flex;flex-direction:column;gap:12px;min-width:0}.emvb-form-unbound{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}.emvb-form-field[hidden]{display:none!important}.ec-form-hp{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}" + ":where(.emvb-form-paused){padding:12px 16px;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 25%,transparent);border-radius:6px}:where(.emvb-form-paused p){margin:0}" + FORM_FIELD_CSS,
8609
8738
  defaults: () => ({ type: "form", props: { formId: "" }, children: [] }),
8610
8739
  descriptor: fieldDescriptor("form", "Form", [
8611
8740
  { key: "formId", kind: "text", label: "Form id", message: "Paste a forms-plugin form id." }
@@ -8616,27 +8745,39 @@ var form = {
8616
8745
  children
8617
8746
  })
8618
8747
  };
8619
- var errorSlot = (name) => ({
8748
+ var errorSlot = (name, controlFor) => ({
8620
8749
  tag: "span",
8621
- attrs: { class: "ec-form-error", "data-error-for": name, "aria-live": "polite" },
8750
+ attrs: {
8751
+ class: "ec-form-error",
8752
+ id: errorId(controlFor),
8753
+ "data-error-for": name,
8754
+ "aria-live": "polite"
8755
+ },
8622
8756
  children: []
8623
8757
  });
8758
+ var errorId = (controlFor) => `${controlFor}-error`;
8759
+ var describedBy = (controlFor) => ({ "aria-describedby": errorId(controlFor) });
8624
8760
  var fieldBox = (attrs, children) => ({
8625
8761
  tag: "div",
8626
8762
  attrs: { ...attrs, class: `${attrs.class ?? ""} emvb-form-field`.trim() },
8627
8763
  children
8628
8764
  });
8629
8765
  var fieldWrap = (controlFor, name, labelText, control, attrs) => fieldBox(attrs, [
8630
- ...labelText ? [
8766
+ ...labelText?.trim() ? [
8631
8767
  {
8632
8768
  tag: "label",
8633
8769
  attrs: { class: "emvb-form-label", for: controlFor },
8634
8770
  children: [labelText]
8635
8771
  }
8636
8772
  ] : [],
8637
- control,
8638
- errorSlot(name)
8773
+ withDescription(labelText?.trim() ? control : named(control, name), controlFor),
8774
+ errorSlot(name, controlFor)
8639
8775
  ]);
8776
+ var withDescription = (control, controlFor) => ({
8777
+ ...control,
8778
+ attrs: { ...control.attrs, ...describedBy(controlFor) }
8779
+ });
8780
+ var named = (control, name) => control.attrs.placeholder?.trim() || !name.trim() ? control : { ...control, attrs: { ...control.attrs, "aria-label": name } };
8640
8781
  var textControl = (tag, props, id) => ({
8641
8782
  tag,
8642
8783
  attrs: {
@@ -8663,13 +8804,13 @@ var textareaEl = {
8663
8804
  var selectEl = {
8664
8805
  baseCss: ".emvb-select{display:flex;flex-direction:column;gap:4px}",
8665
8806
  defaults: () => ({ type: "select", props: { field: "choice", label: "Choice" } }),
8666
- descriptor: fieldDescriptor("select", "Select", NAME_AND_LABEL),
8807
+ descriptor: fieldDescriptor("select", "Select", TEXT_FIELDS),
8667
8808
  build: (node, attrs) => {
8668
8809
  const name = node.props.field;
8669
8810
  const control = {
8670
8811
  tag: "select",
8671
8812
  attrs: { class: "ec-form-input", id: controlId(node.id), name },
8672
- children: [{ tag: "option", attrs: { value: "" }, children: ["Choose…"] }]
8813
+ children: [{ tag: "option", attrs: { value: "" }, children: [selectPrompt(node.props)] }]
8673
8814
  };
8674
8815
  return fieldWrap(controlId(node.id), name, node.props.label, control, attrs);
8675
8816
  }
@@ -8682,15 +8823,21 @@ var checkbox = {
8682
8823
  const name = node.props.field;
8683
8824
  const input = {
8684
8825
  tag: "input",
8685
- attrs: { type: "checkbox", id: controlId(node.id), name, value: "true" },
8826
+ attrs: {
8827
+ type: "checkbox",
8828
+ id: controlId(node.id),
8829
+ name,
8830
+ value: "true",
8831
+ ...describedBy(controlId(node.id))
8832
+ },
8686
8833
  children: []
8687
8834
  };
8688
8835
  const labelEl = {
8689
8836
  tag: "label",
8690
8837
  attrs: { class: "emvb-form-checkbox-label" },
8691
- children: [input, ` ${node.props.label ?? name}`]
8838
+ children: [input, ` ${node.props.label?.trim() || name}`]
8692
8839
  };
8693
- return fieldBox(attrs, [labelEl, errorSlot(name)]);
8840
+ return fieldBox(attrs, [labelEl, errorSlot(name, controlId(node.id))]);
8694
8841
  }
8695
8842
  };
8696
8843
  var radio = {
@@ -8700,7 +8847,7 @@ var radio = {
8700
8847
  build: (node, attrs) => {
8701
8848
  const name = node.props.field;
8702
8849
  const id = controlId(node.id);
8703
- const legend = node.props.label ? [
8850
+ const legend = node.props.label?.trim() ? [
8704
8851
  {
8705
8852
  tag: "legend",
8706
8853
  attrs: { class: "emvb-form-label", id: `${id}-label` },
@@ -8709,7 +8856,11 @@ var radio = {
8709
8856
  ] : [];
8710
8857
  const control = {
8711
8858
  tag: "fieldset",
8712
- attrs: { class: "emvb-radio-group" },
8859
+ attrs: {
8860
+ class: "emvb-radio-group",
8861
+ ...describedBy(id),
8862
+ ...legend.length || !name.trim() ? {} : { "aria-label": name }
8863
+ },
8713
8864
  children: [
8714
8865
  ...legend,
8715
8866
  {
@@ -8722,11 +8873,11 @@ var radio = {
8722
8873
  }
8723
8874
  ]
8724
8875
  };
8725
- return fieldBox(attrs, [control, errorSlot(name)]);
8876
+ return fieldBox(attrs, [control, errorSlot(name, id)]);
8726
8877
  }
8727
8878
  };
8728
8879
  var submit = {
8729
- baseCss: ".emvb-submit{display:inline-flex}",
8880
+ baseCss: ".emvb-submit{display:inline-flex;max-width:100%;overflow-wrap:anywhere}",
8730
8881
  defaults: () => ({ type: "submit", props: { label: "Submit" } }),
8731
8882
  descriptor: fieldDescriptor("submit", "Submit", [
8732
8883
  { key: "label", kind: "text", label: "Label", optional: true }
@@ -8748,7 +8899,7 @@ var postTitle = {
8748
8899
  defaults: () => ({ type: "post-title", props: { level: 1 } }),
8749
8900
  descriptor: {
8750
8901
  type: "post-title",
8751
- name: "Post Title",
8902
+ name: "Post title",
8752
8903
  group: "dynamic",
8753
8904
  defaultTab: "content",
8754
8905
  fields: [
@@ -8768,7 +8919,7 @@ var postExcerpt = {
8768
8919
  defaults: () => ({ type: "post-excerpt", props: {} }),
8769
8920
  descriptor: {
8770
8921
  type: "post-excerpt",
8771
- name: "Post Excerpt",
8922
+ name: "Post excerpt",
8772
8923
  group: "dynamic",
8773
8924
  defaultTab: "style",
8774
8925
  fields: [
@@ -8788,7 +8939,7 @@ var postContent = {
8788
8939
  defaults: () => ({ type: "post-content", props: {} }),
8789
8940
  descriptor: {
8790
8941
  type: "post-content",
8791
- name: "Post Content",
8942
+ name: "Post content",
8792
8943
  group: "dynamic",
8793
8944
  defaultTab: "style",
8794
8945
  fields: []
@@ -8804,7 +8955,7 @@ var postImage = {
8804
8955
  defaults: () => ({ type: "post-image", props: { decorative: false } }),
8805
8956
  descriptor: {
8806
8957
  type: "post-image",
8807
- name: "Post Image",
8958
+ name: "Post image",
8808
8959
  group: "dynamic",
8809
8960
  defaultTab: "content",
8810
8961
  fields: [{ key: "decorative", kind: "boolean", label: "Decorative", optional: true }]
@@ -8820,7 +8971,7 @@ var postDate = {
8820
8971
  defaults: () => ({ type: "post-date", props: {} }),
8821
8972
  descriptor: {
8822
8973
  type: "post-date",
8823
- name: "Post Date",
8974
+ name: "Post date",
8824
8975
  group: "dynamic",
8825
8976
  defaultTab: "style",
8826
8977
  fields: [
@@ -8846,7 +8997,7 @@ var postAuthor = {
8846
8997
  defaults: () => ({ type: "post-author", props: {} }),
8847
8998
  descriptor: {
8848
8999
  type: "post-author",
8849
- name: "Post Author",
9000
+ name: "Post author",
8850
9001
  group: "dynamic",
8851
9002
  defaultTab: "style",
8852
9003
  fields: []
@@ -8858,7 +9009,7 @@ var postLink = {
8858
9009
  defaults: () => ({ type: "post-link", props: {} }),
8859
9010
  descriptor: {
8860
9011
  type: "post-link",
8861
- name: "Post Link",
9012
+ name: "Post link",
8862
9013
  group: "dynamic",
8863
9014
  defaultTab: "content",
8864
9015
  fields: [
@@ -8869,7 +9020,7 @@ var postLink = {
8869
9020
  optional: true,
8870
9021
  message: "Leave blank to use the post title."
8871
9022
  },
8872
- { key: "newTab", kind: "boolean", label: "Open in new tab", optional: true }
9023
+ { key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true }
8873
9024
  ]
8874
9025
  },
8875
9026
  build: (_node, attrs) => ({ tag: "a", attrs: { ...attrs, href: "#" }, children: ["Post link"] })
@@ -8934,35 +9085,35 @@ var loop = {
8934
9085
  kind: "text",
8935
9086
  label: "Link pattern",
8936
9087
  optional: true,
8937
- message: "Where each entry links, e.g. /team/{slug}; {slug} and {id} are filled in. Leave it empty for /collection/{slug}."
9088
+ message: "Where each entry links, such as /team/{slug}; {slug} and {id} are filled in. Leave it empty for /collection/{slug}."
8938
9089
  },
8939
9090
  {
8940
9091
  key: "imageField",
8941
9092
  kind: "text",
8942
9093
  label: "Image field",
8943
9094
  optional: true,
8944
- message: "The field Post Image shows, e.g. photo. Leave it empty for the featured image."
9095
+ message: "The field Post image shows, such as photo. Leave it empty for the featured image."
8945
9096
  },
8946
9097
  {
8947
9098
  key: "excerptField",
8948
9099
  kind: "text",
8949
9100
  label: "Excerpt field",
8950
9101
  optional: true,
8951
- message: "The field Post Excerpt shows, e.g. role. Leave it empty for the excerpt."
9102
+ message: "The field Post excerpt shows, such as role. Leave it empty for the excerpt."
8952
9103
  },
8953
9104
  {
8954
9105
  key: "filter",
8955
9106
  kind: "text",
8956
9107
  label: "Only entries where",
8957
9108
  optional: true,
8958
- message: "field=value pairs separated by ;, e.g. category=news; team=design. A taxonomy works too. The same field twice matches either value."
9109
+ message: "field=value pairs separated by semicolons, such as category=news; team=design. A taxonomy works too. The same field twice matches either value."
8959
9110
  },
8960
9111
  {
8961
9112
  key: "itemPartId",
8962
9113
  kind: "text",
8963
- label: "Loop Item",
9114
+ label: "Loop item",
8964
9115
  optional: true,
8965
- message: "Optional published Loop Item theme part. Leave blank to use nested elements as the item template."
9116
+ message: "Optional published Loop item theme part. Leave blank to use nested elements as the item template."
8966
9117
  },
8967
9118
  {
8968
9119
  key: "perPage",
@@ -9021,6 +9172,41 @@ var pagination = {
9021
9172
  label: "Page title text",
9022
9173
  optional: true,
9023
9174
  message: 'The browser title of page 2 onward. {title} and {page} are filled in; unset is "{title} – page {page}".'
9175
+ },
9176
+ {
9177
+ key: "archiveTitle",
9178
+ kind: "text",
9179
+ label: "Posts archive title",
9180
+ optional: true,
9181
+ message: `Replaces "Posts" as the posts archive's title, in the site's language. Category and tag archives use the term's name.`
9182
+ },
9183
+ {
9184
+ key: "navLabel",
9185
+ kind: "text",
9186
+ label: "Screen reader name",
9187
+ optional: true,
9188
+ message: `What screen readers call the links, in the site's language. Unset is "Pagination".`
9189
+ },
9190
+ {
9191
+ key: "pageLabel",
9192
+ kind: "text",
9193
+ label: "Page number name",
9194
+ optional: true,
9195
+ message: 'What screen readers call each number. {page} is filled in; unset is "Page {page}".'
9196
+ },
9197
+ {
9198
+ key: "prevLabel",
9199
+ kind: "text",
9200
+ label: "Previous name",
9201
+ optional: true,
9202
+ message: 'Read out when Previous text is only an arrow. Unset is "Previous page".'
9203
+ },
9204
+ {
9205
+ key: "nextLabel",
9206
+ kind: "text",
9207
+ label: "Next name",
9208
+ optional: true,
9209
+ message: 'Read out when Next text is only an arrow. Unset is "Next page".'
9024
9210
  }
9025
9211
  ]
9026
9212
  },
@@ -9050,6 +9236,17 @@ var section = {
9050
9236
  // ../emvb/src/core/elements/index.ts
9051
9237
  var HEADING_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6"];
9052
9238
  var newTabAttrs2 = (newTab) => newTab ? { target: "_blank", rel: "noopener noreferrer" } : {};
9239
+ var TAG_LABELS = {
9240
+ div: "Div",
9241
+ section: "Section",
9242
+ header: "Header",
9243
+ footer: "Footer",
9244
+ main: "Main",
9245
+ article: "Article",
9246
+ aside: "Aside",
9247
+ nav: "Nav",
9248
+ p: "Paragraph (p)"
9249
+ };
9053
9250
  var LINK_MESSAGE = "Use a full URL such as https://example.com or a path such as /pricing.";
9054
9251
  var INNER_LINK_FIELDS = [
9055
9252
  { key: "href", kind: "href", label: "Link", optional: true, message: LINK_MESSAGE },
@@ -9097,10 +9294,11 @@ var heading = {
9097
9294
  };
9098
9295
  var BOX_LINK_FIELDS = [
9099
9296
  { key: "href", kind: "href", label: "Link", optional: true, message: LINK_MESSAGE },
9100
- { key: "newTab", kind: "boolean", label: "Open in new tab", optional: true }
9297
+ { key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true }
9101
9298
  ];
9299
+ var BOX_LINK_CSS = ":where(a.emvb-box-link){color:inherit;text-decoration:inherit}";
9102
9300
  var container = {
9103
- baseCss: ".emvb-container{display:flex;flex-direction:column;min-width:0;overflow-wrap:break-word}",
9301
+ baseCss: ".emvb-container{display:flex;flex-direction:column;min-width:0;overflow-wrap:break-word}" + BOX_LINK_CSS,
9104
9302
  defaults: () => ({ type: "container", props: {}, children: [] }),
9105
9303
  descriptor: {
9106
9304
  type: "container",
@@ -9113,7 +9311,7 @@ var container = {
9113
9311
  kind: "select",
9114
9312
  label: "HTML tag",
9115
9313
  optional: true,
9116
- options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: tag })),
9314
+ options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] })),
9117
9315
  message: "Pick a landmark or div."
9118
9316
  },
9119
9317
  ...BOX_LINK_FIELDS
@@ -9175,7 +9373,7 @@ var text = {
9175
9373
  kind: "select",
9176
9374
  label: "HTML tag",
9177
9375
  optional: true,
9178
- options: TEXT_TAGS.map((tag) => ({ value: tag, label: tag }))
9376
+ options: TEXT_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] }))
9179
9377
  }
9180
9378
  ]
9181
9379
  },
@@ -9226,7 +9424,7 @@ var link = {
9226
9424
  }
9227
9425
  };
9228
9426
  var button = {
9229
- baseCss: ".emvb-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5em;margin:0;font:inherit;text-decoration:none;cursor:pointer}:where(.emvb-button){color:inherit;background:transparent;border:1px solid currentColor;border-radius:6px;padding:0.625em 1.25em;line-height:1.2}.emvb-button-icon{display:inline-flex;flex:none}.emvb-button-icon svg{width:100%;height:100%;display:block}.emvb-button-icon--sm{width:1em;height:1em}.emvb-button-icon--md{width:1.25em;height:1.25em}.emvb-button-icon--lg{width:1.5em;height:1.5em}.emvb-figure{margin:0}.emvb-figcaption{margin-top:0.35em}.emvb-image-link{display:contents}",
9427
+ baseCss: ".emvb-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5em;overflow-wrap:anywhere;text-align:center;margin:0;font:inherit;text-decoration:none;cursor:pointer}:where(.emvb-button){color:inherit;background:transparent;border:1px solid currentColor;border-radius:6px;padding:0.625em 1.25em;line-height:1.2}.emvb-button-icon{display:inline-flex;flex:none}.emvb-button-icon svg{width:100%;height:100%;display:block}.emvb-button-icon--sm{width:1em;height:1em}.emvb-button-icon--md{width:1.25em;height:1.25em}.emvb-button-icon--lg{width:1.5em;height:1.5em}",
9230
9428
  defaults: () => ({ type: "button", props: { text: "Button" } }),
9231
9429
  descriptor: {
9232
9430
  type: "button",
@@ -9319,7 +9517,7 @@ function buttonChildren(node) {
9319
9517
  return node.props.iconPosition === "after" ? [buttonText, icon] : [icon, buttonText];
9320
9518
  }
9321
9519
  var list = {
9322
- baseCss: ".emvb-list{margin:0;padding-inline-start:1.25em}.emvb-list li{margin:0}",
9520
+ baseCss: ".emvb-list{margin:0;padding-inline-start:1.25em}.emvb-list li{margin:0}.emvb-list--wide{padding-inline-start:2.25em}",
9323
9521
  defaults: () => ({ type: "list", props: { items: ["Item"] } }),
9324
9522
  descriptor: {
9325
9523
  type: "list",
@@ -9331,14 +9529,18 @@ var list = {
9331
9529
  { key: "items", kind: "list-items", label: "Items" }
9332
9530
  ]
9333
9531
  },
9334
- build: (node, attrs) => ({
9335
- tag: node.props.ordered ? "ol" : "ul",
9336
- attrs,
9337
- children: node.props.items.filter((item) => item.trim() !== "").map((item) => ({ tag: "li", attrs: {}, children: [item] }))
9338
- })
9532
+ build: (node, attrs) => {
9533
+ const items = node.props.items.filter((item) => item.trim() !== "");
9534
+ const wide = node.props.ordered === true && items.length >= 100;
9535
+ return {
9536
+ tag: node.props.ordered ? "ol" : "ul",
9537
+ attrs: wide ? { ...attrs, class: `${attrs.class ?? ""} emvb-list--wide`.trim() } : attrs,
9538
+ children: items.map((item) => ({ tag: "li", attrs: {}, children: [item] }))
9539
+ };
9540
+ }
9339
9541
  };
9340
9542
  var image = {
9341
- baseCss: ".emvb-image{display:block;max-width:100%;height:auto}:where(img.emvb-image:not([width])){width:fit-content}",
9543
+ baseCss: ".emvb-image{display:block;max-width:100%;height:auto}:where(img.emvb-image:not([width])){width:fit-content}" + ".emvb-figure{margin:0}.emvb-figcaption{margin-top:0.35em}.emvb-image-link{display:contents}",
9342
9544
  defaults: () => ({
9343
9545
  type: "image",
9344
9546
  props: { src: "", alt: "Image", decorative: false }
@@ -9359,7 +9561,7 @@ var image = {
9359
9561
  {
9360
9562
  key: "decorative",
9361
9563
  kind: "boolean",
9362
- label: "Decorative (empty alt)",
9564
+ label: "Decorative",
9363
9565
  optional: true
9364
9566
  },
9365
9567
  { key: "priority", kind: "boolean", label: "Load right away", optional: true },
@@ -9443,33 +9645,40 @@ var srcsetUrl = (url) => url?.replaceAll(" ", "%20");
9443
9645
  function imageSources(src, sources, width) {
9444
9646
  if (!sources || sources.length === 0)
9445
9647
  return;
9446
- const parts = [];
9447
- const seen = new Set;
9648
+ const main = srcsetUrl(src);
9448
9649
  let srcWidth;
9449
9650
  for (const source of sources) {
9450
- const url = srcsetUrl(sanitizeMediaUrl(source.src));
9451
9651
  if (!validSourceWidth(source.width))
9452
9652
  continue;
9453
- if (url === srcsetUrl(src)) {
9454
- srcWidth ??= source.width;
9455
- continue;
9653
+ if (srcsetUrl(sanitizeMediaUrl(source.src)) === main) {
9654
+ srcWidth = source.width;
9655
+ break;
9456
9656
  }
9457
- if (!url || /[\s,]/.test(url) || seen.has(url))
9657
+ }
9658
+ srcWidth ??= validSourceWidth(width) ? width : undefined;
9659
+ const mainListed = srcWidth !== undefined && main !== undefined && !/[\s,]/.test(main);
9660
+ const parts = [];
9661
+ const seen = new Set;
9662
+ const widths = new Set(mainListed ? [srcWidth] : []);
9663
+ for (const source of sources) {
9664
+ const url = srcsetUrl(sanitizeMediaUrl(source.src));
9665
+ if (!validSourceWidth(source.width) || url === main)
9666
+ continue;
9667
+ if (!url || /[\s,]/.test(url) || seen.has(url) || widths.has(source.width))
9458
9668
  continue;
9459
9669
  seen.add(url);
9670
+ widths.add(source.width);
9460
9671
  parts.push(`${url} ${source.width}w`);
9461
9672
  }
9462
9673
  if (parts.length === 0)
9463
9674
  return;
9464
- srcWidth ??= validSourceWidth(width) ? width : undefined;
9465
- const main = srcsetUrl(src);
9466
- if (srcWidth !== undefined && main && !/[\s,]/.test(main))
9675
+ if (mainListed)
9467
9676
  parts.push(`${main} ${srcWidth}w`);
9468
9677
  return parts.join(", ");
9469
9678
  }
9470
9679
  var ICON_STROKE_WIDTHS = ["1", "1.5", "2", "2.5", "3"];
9471
9680
  var icon = {
9472
- baseCss: ".emvb-icon{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}.emvb-icon-link{display:inline-flex;color:inherit}.emvb-icon svg{display:block;rotate:var(--emvb-icon-rotate,0deg);scale:var(--emvb-icon-flip,1 1);filter:var(--emvb-icon-shadow,none);animation:var(--emvb-icon-animation,none);transition:inherit}" + ICON_STROKE_WIDTHS.map((width) => `.emvb-icon-sw${width.replace(".", "_")}{stroke-width:var(--emvb-icon-stroke,${width})}`).join("") + "@keyframes emvb-icon-spin{to{transform:rotate(360deg)}}@keyframes emvb-icon-pulse{from{transform:scale(1)}to{transform:scale(1.15)}}@media (prefers-reduced-motion: reduce){.emvb-icon svg{animation:none}}.emvb-icon-missing{min-width:1em;min-height:1em;background:var(--color-kumo-tint,#eee)}",
9681
+ baseCss: ".emvb-icon{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}.emvb-icon-link{display:inline-flex;max-width:100%;color:inherit}.emvb-icon svg{display:block;max-width:100%;rotate:var(--emvb-icon-rotate,0deg);scale:var(--emvb-icon-flip,1 1);filter:var(--emvb-icon-shadow,none);animation:var(--emvb-icon-animation,none);transition:inherit}" + ICON_STROKE_WIDTHS.map((width) => `.emvb-icon-sw${width.replace(".", "_")}{stroke-width:var(--emvb-icon-stroke,${width})}`).join("") + "@keyframes emvb-icon-spin{to{transform:rotate(360deg)}}@keyframes emvb-icon-pulse{from{transform:scale(1)}to{transform:scale(1.15)}}@media (prefers-reduced-motion: reduce){.emvb-icon svg{animation:none}}.emvb-icon-missing{min-width:1em;min-height:1em;background:var(--color-kumo-tint,#eee)}",
9473
9682
  defaults: () => ({
9474
9683
  type: "icon",
9475
9684
  props: { iconId: "star", title: "Star", decorative: false, size: 24 }
@@ -9485,7 +9694,7 @@ var icon = {
9485
9694
  {
9486
9695
  key: "decorative",
9487
9696
  kind: "boolean",
9488
- label: "Decorative (hide from assistive tech)",
9697
+ label: "Decorative",
9489
9698
  optional: true
9490
9699
  },
9491
9700
  {
@@ -9637,13 +9846,14 @@ var video = {
9637
9846
  children: []
9638
9847
  };
9639
9848
  }
9849
+ const title = String(node.props.title ?? "").trim() || "Video";
9640
9850
  if (target.kind === "iframe") {
9641
9851
  return {
9642
9852
  tag: "iframe",
9643
9853
  attrs: {
9644
9854
  ...attrs,
9645
9855
  src: target.src,
9646
- title: node.props.title,
9856
+ title,
9647
9857
  loading: "lazy",
9648
9858
  referrerpolicy: "strict-origin-when-cross-origin",
9649
9859
  allow: "encrypted-media; picture-in-picture; fullscreen",
@@ -9657,7 +9867,7 @@ var video = {
9657
9867
  attrs: {
9658
9868
  ...attrs,
9659
9869
  src: target.src,
9660
- title: node.props.title,
9870
+ title,
9661
9871
  controls: "",
9662
9872
  preload: "metadata"
9663
9873
  },
@@ -9704,7 +9914,7 @@ var svgEl = {
9704
9914
  {
9705
9915
  key: "decorative",
9706
9916
  kind: "boolean",
9707
- label: "Decorative (hide from assistive tech)",
9917
+ label: "Decorative",
9708
9918
  optional: true
9709
9919
  },
9710
9920
  {
@@ -9750,7 +9960,7 @@ var svgEl = {
9750
9960
  return {
9751
9961
  tag: "span",
9752
9962
  attrs,
9753
- children: [{ tag: "svg", attrs: svgAttrs, children: tree.children }]
9963
+ children: [{ tag: "svg", attrs: svgAttrs, children: scopeSvgIds(tree.children, node.id) }]
9754
9964
  };
9755
9965
  }
9756
9966
  };
@@ -9771,7 +9981,7 @@ var tabPanel = {
9771
9981
  build: (_node, attrs, children) => ({ tag: "div", attrs, children })
9772
9982
  };
9773
9983
  var tabs = {
9774
- baseCss: ".emvb-tabs{display:flex;flex-direction:column;min-width:0;gap:0}.emvb-tab-input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}.emvb-tab-list{display:flex;flex-wrap:wrap;gap:0;border-bottom:1px solid currentColor;margin:0;padding:0}.emvb-tab-label{display:inline-block;padding:8px 12px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px}.emvb-tab-panels{min-width:0}.emvb-tab-panel{display:none;padding-top:12px;min-width:0}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(1){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(1){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(2){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(2){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(3){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(3){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(4){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(4){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(5){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(5){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(6){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(6){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(7){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(7){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(8){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(8){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(9){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(9){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(10){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(10){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(11){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(11){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(12){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(12){display:block}",
9984
+ baseCss: ".emvb-tabs{display:flex;flex-direction:column;min-width:0;gap:0}.emvb-tab-input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}.emvb-tab-list{display:flex;flex-wrap:wrap;gap:0;border-bottom:1px solid currentColor;margin:0;padding:0}.emvb-tab-label{display:inline-block;padding:8px 12px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;min-width:0;overflow-wrap:anywhere}.emvb-tab-panels{min-width:0}.emvb-tab-panel{padding-top:12px;min-width:0}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(1){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(1)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(2){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(2)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(3){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(3)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(4){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(4)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(5){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(5)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(6){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(6)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(7){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(7)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(8){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(8)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(9){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(9)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(10){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(10)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(11){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(11)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(12){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(12)){display:none!important}",
9775
9985
  defaults: () => ({
9776
9986
  type: "tabs",
9777
9987
  props: {},
@@ -9787,11 +9997,11 @@ var tabs = {
9787
9997
  build: (_node, attrs, children) => ({ tag: "div", attrs, children })
9788
9998
  };
9789
9999
  var divBlock = {
9790
- baseCss: ".emvb-div-block{display:block;min-width:0}",
10000
+ baseCss: ".emvb-div-block{display:block;min-width:0}" + BOX_LINK_CSS,
9791
10001
  defaults: () => ({ type: "div-block", props: {}, children: [] }),
9792
10002
  descriptor: {
9793
10003
  type: "div-block",
9794
- name: "Div Block",
10004
+ name: "Div block",
9795
10005
  group: "layout",
9796
10006
  defaultTab: "style",
9797
10007
  fields: BOX_LINK_FIELDS
@@ -9830,7 +10040,7 @@ var layoutSection = {
9830
10040
  kind: "select",
9831
10041
  label: "HTML tag",
9832
10042
  optional: true,
9833
- options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: tag })),
10043
+ options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] })),
9834
10044
  message: "Pick a landmark or div. A section is a section by default."
9835
10045
  }
9836
10046
  ]
@@ -9844,7 +10054,7 @@ var layoutSection = {
9844
10054
  };
9845
10055
  var TRACKS_HINT = "Up to 12 tracks, one per line: 1fr, 2fr, 3fr, auto, min-content, max-content, or a length.";
9846
10056
  var grid = {
9847
- baseCss: ".emvb-grid{display:grid;min-width:0}",
10057
+ baseCss: ".emvb-grid{display:grid;min-width:0}" + BOX_LINK_CSS,
9848
10058
  defaults: () => ({ type: "grid", props: { columns: 3 }, children: [] }),
9849
10059
  descriptor: {
9850
10060
  type: "grid",
@@ -9889,7 +10099,7 @@ var grid = {
9889
10099
  build: (_node, attrs, children) => ({ tag: "div", attrs, children })
9890
10100
  };
9891
10101
  var flexbox = {
9892
- baseCss: ".emvb-flexbox{display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;min-width:0;gap:16px}",
10102
+ baseCss: ".emvb-flexbox{display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;min-width:0;gap:16px;overflow-wrap:anywhere}" + BOX_LINK_CSS,
9893
10103
  defaults: () => ({
9894
10104
  type: "flexbox",
9895
10105
  props: {},
@@ -9927,11 +10137,12 @@ var accordionItem = {
9927
10137
  defaultTab: "content",
9928
10138
  fields: [
9929
10139
  { key: "summary", kind: "text", label: "Title" },
9930
- { key: "open", kind: "boolean", label: "Open", optional: true }
10140
+ { key: "open", kind: "boolean", label: "Open by default", optional: true }
9931
10141
  ]
9932
10142
  },
9933
10143
  build: (node, attrs, children) => {
9934
- const summary = { tag: "summary", attrs: {}, children: [node.props.summary] };
10144
+ const title = node.props.summary.trim() || "Details";
10145
+ const summary = { tag: "summary", attrs: {}, children: [title] };
9935
10146
  const body = { tag: "div", attrs: { class: "emvb-accordion-body" }, children };
9936
10147
  return {
9937
10148
  tag: "details",
@@ -10061,7 +10272,8 @@ var LAYOUT_MIGRATIONS = {
10061
10272
  12: unchanged,
10062
10273
  13: unchanged,
10063
10274
  14: unchanged,
10064
- 15: unchanged
10275
+ 15: unchanged,
10276
+ 16: unchanged
10065
10277
  };
10066
10278
  var DESIGN_MIGRATIONS = {
10067
10279
  1: unchanged,
@@ -10077,7 +10289,8 @@ var DESIGN_MIGRATIONS = {
10077
10289
  11: gradients,
10078
10290
  12: unchanged,
10079
10291
  13: unchanged,
10080
- 14: unchanged
10292
+ 14: unchanged,
10293
+ 15: unchanged
10081
10294
  };
10082
10295
  function versionOf(doc) {
10083
10296
  if (typeof doc !== "object" || doc === null)
@@ -10103,7 +10316,7 @@ function upgradeLayout(doc, migrations = LAYOUT_MIGRATIONS, current = LAYOUT_SCH
10103
10316
  return { ok: true, doc: result, from };
10104
10317
  }
10105
10318
  // ../emvb/src/core/schema/design.ts
10106
- var DESIGN_SCHEMA_VERSION = 15;
10319
+ var DESIGN_SCHEMA_VERSION = 16;
10107
10320
  var VariableId = string2().regex(/^[a-z0-9-]{1,40}$/, "Ids are 1-40 lowercase letters, digits or -");
10108
10321
  var ColorVariable = strictObject({
10109
10322
  id: VariableId,
@@ -10398,6 +10611,20 @@ function starterLayout(title, random) {
10398
10611
  }
10399
10612
  };
10400
10613
  }
10614
+ function pageSlug(text, max = 80) {
10615
+ const slug = text.normalize("NFKC").toLowerCase().replace(/[\s_]+/gu, "-").replace(/[^\p{L}\p{N}\p{M}-]+/gu, "").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
10616
+ if (!/[\p{L}\p{N}]/u.test(slug))
10617
+ return "";
10618
+ let out = "";
10619
+ let count = 0;
10620
+ for (const { segment } of new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(slug)) {
10621
+ if (count >= max)
10622
+ break;
10623
+ out += segment;
10624
+ count++;
10625
+ }
10626
+ return out.replace(/-+$/g, "");
10627
+ }
10401
10628
  function slugify2(text) {
10402
10629
  return text.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80).replace(/-+$/g, "");
10403
10630
  }
@@ -10597,6 +10824,40 @@ function nestingIssues(layout, max = 5) {
10597
10824
  walk(layout.root, "root", isFormNode(layout.root));
10598
10825
  return issues;
10599
10826
  }
10827
+ // ../emvb/src/core/stable-json.ts
10828
+ function sorted(value) {
10829
+ if (Array.isArray(value))
10830
+ return value.map(sorted);
10831
+ if (!value || typeof value !== "object")
10832
+ return value;
10833
+ const entries = Object.entries(value).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
10834
+ return Object.fromEntries(entries.map(([k, v]) => [k, sorted(v)]));
10835
+ }
10836
+ var stableJson = (value) => JSON.stringify(sorted(value));
10837
+
10838
+ // ../emvb/src/core/local-style.ts
10839
+ var LOCAL_STYLE_KEYS = ["style", "states", "devices", "hiddenOn"];
10840
+ function localStyleOf(node) {
10841
+ const copied = {};
10842
+ for (const key of LOCAL_STYLE_KEYS) {
10843
+ const value = node[key];
10844
+ if (value !== undefined)
10845
+ copied[key] = structuredClone(value);
10846
+ }
10847
+ return copied;
10848
+ }
10849
+
10850
+ // ../emvb/src/core/design/classes.ts
10851
+ var MAX_CLASSES = 100;
10852
+ function cleanClassName(name) {
10853
+ const spaced = Array.from(name.normalize("NFC"), (ch) => {
10854
+ const code = ch.charCodeAt(0);
10855
+ return code < 32 || code >= 127 && code <= 159 ? " " : ch;
10856
+ }).join("").replace(/[\u200B\u2060\uFEFF\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, "");
10857
+ const spacedTrim = spaced.replace(/ {2,}/g, " ").trim();
10858
+ return clipText(spacedTrim, 60).trim();
10859
+ }
10860
+ var nameKey = (name) => cleanClassName(name).toLowerCase();
10600
10861
  // ../emvb/src/core/design/variables.ts
10601
10862
  var isVariableRef = (value) => typeof value === "object" && value !== null && ("var" in value) && typeof value.var === "string";
10602
10863
  function refMatchesKind(ref, kind) {
@@ -10639,6 +10900,7 @@ function collectAllUsages(owner, id, kind, hit) {
10639
10900
  for (const device of RESPONSIVE) {
10640
10901
  collectStyleUsages(owner.devices?.[device], id, kind, (prop) => hit(`${device}.${prop}`));
10641
10902
  }
10903
+ collectStyleUsages(owner.query?.style, id, kind, (prop) => hit(`query.${prop}`));
10642
10904
  }
10643
10905
  function findVariableUsages(layout, id, kind) {
10644
10906
  const usages = [];
@@ -10658,6 +10920,124 @@ function findVariableUsagesInDesign(design, id, kind) {
10658
10920
  }
10659
10921
  return usages;
10660
10922
  }
10923
+ function stripRefsFromStyle(style, id, kind) {
10924
+ if (!style)
10925
+ return;
10926
+ let changed = false;
10927
+ const next = { ...style };
10928
+ for (const [prop, value] of Object.entries(style)) {
10929
+ if (!matches(value, id, kind))
10930
+ continue;
10931
+ delete next[prop];
10932
+ changed = true;
10933
+ }
10934
+ if (style.boxShadow && matches(style.boxShadow.color, id, kind)) {
10935
+ const { color: _drop, ...shadow } = style.boxShadow;
10936
+ next["boxShadow"] = shadow;
10937
+ changed = true;
10938
+ }
10939
+ if (style.iconShadow && matches(style.iconShadow.color, id, kind)) {
10940
+ const { color: _drop, ...shadow } = style.iconShadow;
10941
+ next["iconShadow"] = shadow;
10942
+ changed = true;
10943
+ }
10944
+ if (style.gradient?.stops.some((stop) => matches(stop.color, id, kind))) {
10945
+ delete next["gradient"];
10946
+ changed = true;
10947
+ }
10948
+ if (style.overlay && matches(style.overlay.color, id, kind)) {
10949
+ delete next["overlay"];
10950
+ changed = true;
10951
+ }
10952
+ if (!changed)
10953
+ return style;
10954
+ return Object.keys(next).length === 0 ? undefined : next;
10955
+ }
10956
+ function stripRefsFromStates(states, id, kind) {
10957
+ if (!states)
10958
+ return;
10959
+ let changed = false;
10960
+ const next = {};
10961
+ for (const state of STYLE_STATES) {
10962
+ const style = states[state];
10963
+ if (!style)
10964
+ continue;
10965
+ const stripped = stripRefsFromStyle(style, id, kind);
10966
+ if (stripped !== style)
10967
+ changed = true;
10968
+ if (stripped)
10969
+ next[state] = stripped;
10970
+ }
10971
+ if (!changed)
10972
+ return states;
10973
+ return Object.keys(next).length === 0 ? undefined : next;
10974
+ }
10975
+ function stripRefsFromDevices(devices, id, kind) {
10976
+ if (!devices)
10977
+ return;
10978
+ let changed = false;
10979
+ const next = { ...devices };
10980
+ for (const device of RESPONSIVE) {
10981
+ const style = stripRefsFromStyle(devices[device], id, kind);
10982
+ if (style === devices[device])
10983
+ continue;
10984
+ changed = true;
10985
+ if (style)
10986
+ next[device] = style;
10987
+ else
10988
+ delete next[device];
10989
+ }
10990
+ if (!changed)
10991
+ return devices;
10992
+ return next.tablet || next.mobile ? next : undefined;
10993
+ }
10994
+ function stripOwner(owner, id, kind) {
10995
+ const style = stripRefsFromStyle(owner.style, id, kind);
10996
+ const states = stripRefsFromStates(owner.states, id, kind);
10997
+ const devices = stripRefsFromDevices(owner.devices, id, kind);
10998
+ const queryStyle = owner.query ? stripRefsFromStyle(owner.query.style, id, kind) : undefined;
10999
+ const queryChanged = owner.query !== undefined && queryStyle !== owner.query.style;
11000
+ if (style === owner.style && states === owner.states && devices === owner.devices && !queryChanged) {
11001
+ return owner;
11002
+ }
11003
+ const next = { ...owner, style, states, devices };
11004
+ if (style === undefined)
11005
+ delete next.style;
11006
+ if (states === undefined)
11007
+ delete next.states;
11008
+ if (devices === undefined)
11009
+ delete next.devices;
11010
+ if (queryChanged && owner.query)
11011
+ next.query = { ...owner.query, style: queryStyle ?? {} };
11012
+ return next;
11013
+ }
11014
+ function clearVariableRefs(layout, id, kind) {
11015
+ let next = layout;
11016
+ const usages = findVariableUsages(layout, id, kind);
11017
+ const nodeIds = [...new Set(usages.map((u) => u.nodeId))];
11018
+ for (const nodeId of nodeIds) {
11019
+ next = updateNode(next, nodeId, (node) => stripOwner(node, id, kind));
11020
+ }
11021
+ return next;
11022
+ }
11023
+ // ../emvb/src/core/audience/variants.ts
11024
+ function loneAbTests(layout) {
11025
+ const arms = new Map;
11026
+ const walk = (node) => {
11027
+ const v = node.variant;
11028
+ if (v) {
11029
+ const seen = arms.get(v.test) ?? new Set;
11030
+ seen.add(v.arm);
11031
+ arms.set(v.test, seen);
11032
+ }
11033
+ if (isParentNode(node))
11034
+ for (const child of node.children)
11035
+ walk(child);
11036
+ };
11037
+ walk(layout.root);
11038
+ return new Set([...arms].filter(([, seen]) => seen.size < 2).map(([test]) => test));
11039
+ }
11040
+
10661
11041
  // ../emvb/src/core/audience/rules.ts
10662
11042
  var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
10663
11043
  var DEVICE_LABELS = { mobile: "mobile", tablet: "tablet", desktop: "desktop" };
@@ -10679,10 +11059,25 @@ function audienceSummary(audience) {
10679
11059
  return audience.hide ? `Hidden for ${who}` : `Only ${who}`;
10680
11060
  }
10681
11061
 
11062
+ // ../emvb/src/core/forms/definition.ts
11063
+ var OPTION_TYPES = new Set(["select", "radio", "checkbox-group"]);
11064
+ var FREE_CONTROLS = new Set(["text-input", "textarea", "checkbox"]);
11065
+
10682
11066
  // ../emvb/src/core/forms/binding.ts
10683
11067
  var FIELD_TYPES = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
10684
11068
  var DEVICE_ORDER = ["desktop", "tablet", "mobile"];
10685
- function restriction(node) {
11069
+ function splitKey(node, lone) {
11070
+ const audience = node.audience;
11071
+ if (audience) {
11072
+ const { hide, ...rules } = audience;
11073
+ return `aud:${hide ? 1 : 0}:${stableJson(rules)}`;
11074
+ }
11075
+ if (node.variant && !lone.has(node.variant.test)) {
11076
+ return `ab:${node.variant.test}:${node.variant.arm}`;
11077
+ }
11078
+ return;
11079
+ }
11080
+ function restriction(node, lone) {
10686
11081
  const audience = node.audience;
10687
11082
  if (audience) {
10688
11083
  const { hide, timeZone: _zone, ...rules } = audience;
@@ -10690,42 +11085,51 @@ function restriction(node) {
10690
11085
  return audienceSummary(audience);
10691
11086
  }
10692
11087
  }
10693
- if (node.variant) {
11088
+ if (node.variant && !lone.has(node.variant.test)) {
10694
11089
  return `Variant ${node.variant.arm.toUpperCase()} of A/B test ${node.variant.test}`;
10695
11090
  }
10696
11091
  return;
10697
11092
  }
10698
11093
  function boundControls(form) {
11094
+ const lone = loneAbTests({ schemaVersion: LAYOUT_SCHEMA_VERSION, root: form });
10699
11095
  const found = new Map;
10700
11096
  const walk = (node, inherited, limited) => {
10701
11097
  const own = node.hiddenOn ?? [];
10702
11098
  const hidden = own.length ? new Set([...inherited, ...own]) : inherited;
10703
- const who = limited ?? restriction(node);
11099
+ let scope = limited;
11100
+ if (!scope) {
11101
+ const who = restriction(node, lone);
11102
+ if (who)
11103
+ scope = { who, split: splitKey(node, lone) };
11104
+ }
10704
11105
  if (FIELD_TYPES.has(node.type)) {
10705
11106
  const field = node.props.field;
10706
11107
  if (typeof field === "string" && field) {
10707
11108
  const control = { nodeId: node.id, hidden: new Set(hidden) };
10708
- if (who)
10709
- control.who = who;
11109
+ if (scope) {
11110
+ control.who = scope.who;
11111
+ if (scope.split)
11112
+ control.split = scope.split;
11113
+ }
10710
11114
  found.set(field, [...found.get(field) ?? [], control]);
10711
11115
  }
10712
11116
  }
10713
11117
  for (const child of nodeChildren(node))
10714
- walk(child, hidden, who);
11118
+ walk(child, hidden, scope);
10715
11119
  };
10716
11120
  for (const child of nodeChildren(form))
10717
11121
  walk(child, new Set, undefined);
10718
11122
  return found;
10719
11123
  }
10720
11124
  function coversEveryone(controls) {
10721
- const who = new Set(controls.map((control) => control.who));
10722
- for (const label of who) {
10723
- if (!label)
11125
+ const splits = new Set(controls.map((control) => control.split));
11126
+ for (const key of splits) {
11127
+ if (!key)
10724
11128
  continue;
10725
- const ab = /^Variant ([AB]) of (A\/B test .+)$/.exec(label);
10726
- if (ab && who.has(`Variant ${ab[1] === "A" ? "B" : "A"} of ${ab[2]}`))
11129
+ const ab = /^ab:(.*):([ab])$/.exec(key);
11130
+ if (ab && splits.has(`ab:${ab[1]}:${ab[2] === "a" ? "b" : "a"}`))
10727
11131
  return true;
10728
- if (label.startsWith("Only ") && who.has(`Hidden for ${label.slice(5)}`))
11132
+ if (key.startsWith("aud:0:") && splits.has(`aud:1:${key.slice(6)}`))
10729
11133
  return true;
10730
11134
  }
10731
11135
  return false;
@@ -10734,7 +11138,7 @@ function requiredFieldIssues(form, fields) {
10734
11138
  const controls = boundControls(form);
10735
11139
  const issues = [];
10736
11140
  for (const field of fields) {
10737
- if (!field.required)
11141
+ if (!field.required || field.type === "hidden")
10738
11142
  continue;
10739
11143
  const label = field.label.trim() || field.name;
10740
11144
  const bound = controls.get(field.name);
@@ -10859,8 +11263,9 @@ function tidy(nodes) {
10859
11263
  var hasText = (nodes) => nodes.some((n) => typeof n === "string" ? n.trim() !== "" : hasText(n.children));
10860
11264
  function portableTextToVNodes(value) {
10861
11265
  if (typeof value === "string") {
10862
- const trimmed = value.trim();
10863
- return trimmed ? [{ tag: "p", attrs: {}, children: [trimmed] }] : [];
11266
+ return value.replaceAll(`\r
11267
+ `, `
11268
+ `).split(/\n[ \t]*\n/).map((para) => para.trim()).filter(Boolean).map((para) => ({ tag: "p", attrs: {}, children: withBreaks(para) }));
10864
11269
  }
10865
11270
  if (!Array.isArray(value))
10866
11271
  return [];
@@ -10904,10 +11309,57 @@ function portableTextToVNodes(value) {
10904
11309
  const tag = style === "normal" ? "p" : style;
10905
11310
  out.push({ tag, attrs: {}, children: inline });
10906
11311
  }
10907
- return out.filter((node) => node.tag !== "ul" && node.tag !== "ol" ? true : node.children.length > 0);
11312
+ return pruneEmptyLists(out);
11313
+ }
11314
+ var isList = (n) => n.tag === "ul" || n.tag === "ol";
11315
+ function pruneEmptyLists(nodes) {
11316
+ const keep = [];
11317
+ for (const node of nodes) {
11318
+ if (isList(node)) {
11319
+ const items = [];
11320
+ for (const li of node.children) {
11321
+ if (typeof li === "string")
11322
+ continue;
11323
+ li.children = li.children.flatMap((c) => typeof c !== "string" && isList(c) ? pruneEmptyLists([c]) : [c]);
11324
+ if (li.children.length > 0)
11325
+ items.push(li);
11326
+ }
11327
+ node.children = items;
11328
+ if (items.length > 0)
11329
+ keep.push(node);
11330
+ } else
11331
+ keep.push(node);
11332
+ }
11333
+ return keep;
10908
11334
  }
10909
11335
 
10910
11336
  // ../emvb/src/core/render/dynamic-post.ts
11337
+ var UNSPACED = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u;
11338
+ var wordSegmenter;
11339
+ function limitWords(text, max) {
11340
+ if (!max || max < 1)
11341
+ return text;
11342
+ let count = 0;
11343
+ for (const chunk of text.matchAll(/\S+/g)) {
11344
+ const start = chunk.index ?? 0;
11345
+ if (!UNSPACED.test(chunk[0])) {
11346
+ count++;
11347
+ if (count === max)
11348
+ return finish(text, start + chunk[0].length);
11349
+ continue;
11350
+ }
11351
+ wordSegmenter ??= new Intl.Segmenter(undefined, { granularity: "word" });
11352
+ for (const piece of wordSegmenter.segment(chunk[0])) {
11353
+ if (!piece.isWordLike)
11354
+ continue;
11355
+ count++;
11356
+ if (count === max)
11357
+ return finish(text, start + piece.index + piece.segment.length);
11358
+ }
11359
+ }
11360
+ return text;
11361
+ }
11362
+ var finish = (text, end) => text.slice(end).trim() === "" ? text : `${text.slice(0, end).trim().replace(/\s+/g, " ")}…`;
10911
11363
  var parseIsoDate = (raw) => {
10912
11364
  const match = /^(\d{4})-(\d{2})-(\d{2})(?:[T ][\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/.exec(raw);
10913
11365
  if (!match)
@@ -10916,13 +11368,22 @@ var parseIsoDate = (raw) => {
10916
11368
  if (Number.isNaN(parsed))
10917
11369
  return Number.NaN;
10918
11370
  const day = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])));
10919
- return day.getUTCDate() === Number(match[3]) && day.getUTCMonth() === Number(match[2]) - 1 ? parsed : Number.NaN;
11371
+ return day.getUTCDate() === Number(match[3]) && day.getUTCMonth() === Number(match[2]) - 1 ? day.getTime() : Number.NaN;
10920
11372
  };
10921
- function formatPostDate(time, format) {
11373
+ function dateLocale(lang) {
11374
+ if (!lang || !/^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/.test(lang))
11375
+ return "en";
11376
+ try {
11377
+ return Intl.DateTimeFormat.supportedLocalesOf([lang])[0] ?? "en";
11378
+ } catch {
11379
+ return "en";
11380
+ }
11381
+ }
11382
+ function formatPostDate(time, format, lang) {
10922
11383
  const date = new Date(time);
10923
11384
  if (format === "numeric")
10924
11385
  return date.toISOString().slice(0, 10);
10925
- return new Intl.DateTimeFormat("en", { dateStyle: format, timeZone: "UTC" }).format(date);
11386
+ return new Intl.DateTimeFormat(dateLocale(lang), { dateStyle: format, timeZone: "UTC" }).format(date);
10926
11387
  }
10927
11388
  var props = (node) => node.props;
10928
11389
  var POST_FIELDS = new Map([
@@ -10930,6 +11391,7 @@ var POST_FIELDS = new Map([
10930
11391
  "post-title",
10931
11392
  {
10932
11393
  placeholder: (attrs) => ({ tag: "h1", attrs, children: ["Post Title"] }),
11394
+ has: (post) => !!post.title?.trim(),
10933
11395
  render: (node, attrs, post) => {
10934
11396
  const level = props(node).level ?? 1;
10935
11397
  const tag = HEADING_TAGS[Math.min(6, Math.max(1, level)) - 1] ?? "h1";
@@ -10942,11 +11404,9 @@ var POST_FIELDS = new Map([
10942
11404
  {
10943
11405
  placeholder: (attrs) => ({ tag: "p", attrs, children: ["Post excerpt…"] }),
10944
11406
  render: (node, attrs, post) => {
10945
- if (!post.excerpt)
11407
+ if (!post.excerpt?.trim())
10946
11408
  return;
10947
- const max = props(node).maxWords;
10948
- const words = post.excerpt.trim().split(/\s+/);
10949
- const text = max && words.length > max ? `${words.slice(0, max).join(" ")}…` : post.excerpt;
11409
+ const text = limitWords(post.excerpt, props(node).maxWords);
10950
11410
  return { tag: "p", attrs, children: [text] };
10951
11411
  }
10952
11412
  }
@@ -10978,7 +11438,7 @@ var POST_FIELDS = new Map([
10978
11438
  const src = sanitizeMediaUrl(post.featuredImageUrl ?? "");
10979
11439
  if (!src)
10980
11440
  return;
10981
- const alt = props(node).decorative ? "" : post.featuredImageAlt?.trim() || post.title || "Featured image";
11441
+ const alt = props(node).decorative ? "" : post.featuredImageAlt?.trim() || post.title?.trim() || "Featured image";
10982
11442
  const lazy = inLoop ? { loading: "lazy", decoding: "async" } : {};
10983
11443
  return { tag: "img", attrs: { ...attrs, src, alt, ...lazy }, children: [] };
10984
11444
  }
@@ -11020,13 +11480,13 @@ var POST_FIELDS = new Map([
11020
11480
  {
11021
11481
  placeholder: (attrs) => ({ tag: "time", attrs, children: ["Post date"] }),
11022
11482
  has: (post) => !!post.publishedAt?.trim(),
11023
- render: (node, attrs, post) => {
11483
+ render: (node, attrs, post, _inLoop, lang) => {
11024
11484
  const raw = post.publishedAt?.trim();
11025
11485
  if (!raw)
11026
11486
  return;
11027
11487
  const parsed = parseIsoDate(raw);
11028
11488
  const format = props(node).format ?? "medium";
11029
- const text = Number.isNaN(parsed) ? raw.slice(0, 80) : formatPostDate(parsed, format);
11489
+ const text = Number.isNaN(parsed) ? clipText(raw, 80) : formatPostDate(parsed, format, lang);
11030
11490
  const timeAttrs = Number.isNaN(parsed) ? attrs : { ...attrs, datetime: raw.slice(0, 80) };
11031
11491
  return { tag: "time", attrs: timeAttrs, children: [text] };
11032
11492
  }
@@ -11048,10 +11508,20 @@ var POST_FIELDS = new Map([
11048
11508
  // ../emvb/src/core/render/form.ts
11049
11509
  var INPUT_TYPES = new Set(["email", "tel", "url", "number", "date"]);
11050
11510
  var LENGTH_TYPES = new Set(["text", "email", "tel", "url", "textarea"]);
11511
+ var CONDITION_OPS = new Set(["eq", "neq", "filled", "empty"]);
11512
+
11513
+ // ../emvb/src/core/render/section.ts
11514
+ var sizes = new WeakMap;
11051
11515
 
11052
11516
  // ../emvb/src/core/sanitize/escape.ts
11053
11517
  var TEXT_ENTITIES = { "&": "&amp;", "<": "&lt;", ">": "&gt;" };
11054
11518
  var ATTR_ENTITIES = { ...TEXT_ENTITIES, '"': "&quot;", "'": "&#39;" };
11519
+ function escapeText(value) {
11520
+ return value.replace(/[&<>]/g, (ch) => TEXT_ENTITIES[ch] ?? ch);
11521
+ }
11522
+ function escapeAttr(value) {
11523
+ return value.replace(/[&<>"']/g, (ch) => ATTR_ENTITIES[ch] ?? ch);
11524
+ }
11055
11525
 
11056
11526
  // ../emvb/src/core/render/vnode.ts
11057
11527
  var TAGS = new Set([
@@ -11126,6 +11596,22 @@ var TAGS = new Set([
11126
11596
  "tspan"
11127
11597
  ]);
11128
11598
  var VOID = new Set(["hr", "img", "input", "br"]);
11599
+ var ATTR_NAME = /^(?:class|id|href|src|srcset|sizes|alt|width|height|loading|decoding|fetchpriority|dir|role|type|checked|target|rel|aria-[a-z][a-z0-9-]*|title|allow|referrerpolicy|preload|controls|allowfullscreen|sandbox|xmlns|viewBox|fill|stroke|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-opacity|fill-opacity|opacity|transform|focusable|d|cx|cy|r|x|y|x1|y1|x2|y2|points|rx|ry|xlink:href|preserveAspectRatio|gradientUnits|gradientTransform|offset|stop-color|stop-opacity|clipPathUnits|maskUnits|maskContentUnits|patternUnits|patternContentUnits|patternTransform|markerUnits|markerWidth|markerHeight|refX|refY|orient|font-size|font-family|font-weight|text-anchor|dominant-baseline|dx|dy|clip-path|method|action|name|value|placeholder|for|tabindex|autocomplete|open|datetime|muted|loop|playsinline|autoplay|required|novalidate|minlength|maxlength|min|max|pattern|step|data-[a-z][a-z0-9-]*)$/;
11600
+ function serialize(node) {
11601
+ if (typeof node === "string")
11602
+ return escapeText(node);
11603
+ if (!TAGS.has(node.tag))
11604
+ throw new Error(`EmVB: tag "${node.tag}" is not allowed`);
11605
+ let attrs = "";
11606
+ for (const [name, value] of Object.entries(node.attrs)) {
11607
+ if (!ATTR_NAME.test(name))
11608
+ throw new Error(`EmVB: attribute "${name}" is not allowed`);
11609
+ attrs += ` ${name}="${escapeAttr(value)}"`;
11610
+ }
11611
+ if (VOID.has(node.tag))
11612
+ return `<${node.tag}${attrs}>`;
11613
+ return `<${node.tag}${attrs}>${node.children.map(serialize).join("")}</${node.tag}>`;
11614
+ }
11129
11615
 
11130
11616
  // ../emvb/src/core/data/bindings.ts
11131
11617
  var TEXT = (label = "Text") => ({ key: "text", label, kind: "text" });
@@ -11171,8 +11657,59 @@ var FORMS_RUNTIME_ATTRS = new Set([
11171
11657
  "data-submit-label",
11172
11658
  "data-was-required"
11173
11659
  ]);
11660
+ function childrenOf(node) {
11661
+ return "children" in node && Array.isArray(node.children) ? node.children : [];
11662
+ }
11663
+ var ALWAYS_INTERACTIVE = new Set([
11664
+ "link",
11665
+ "post-link",
11666
+ "button",
11667
+ "menu",
11668
+ "menu-item",
11669
+ "accordion",
11670
+ "accordion-item",
11671
+ "tabs",
11672
+ "video",
11673
+ "form",
11674
+ "text-input",
11675
+ "textarea",
11676
+ "select",
11677
+ "checkbox",
11678
+ "radio",
11679
+ "submit",
11680
+ "pagination",
11681
+ "toc",
11682
+ "post-content"
11683
+ ]);
11684
+ function containsInteractive(node) {
11685
+ if (ALWAYS_INTERACTIVE.has(node.type))
11686
+ return true;
11687
+ const props = node.props;
11688
+ if (node.type === "section" && typeof props.partId === "string" && props.partId.trim())
11689
+ return true;
11690
+ if (node.type === "loop" && typeof props.itemPartId === "string" && props.itemPartId.trim()) {
11691
+ return true;
11692
+ }
11693
+ if (BOX.has(node.type) || node.type === "heading" || node.type === "icon" || node.type === "image") {
11694
+ const href = node.props.href;
11695
+ if (typeof href === "string" && href.trim())
11696
+ return true;
11697
+ }
11698
+ return childrenOf(node).some(containsInteractive);
11699
+ }
11700
+ function boxBecomesLink(node) {
11701
+ if (!BOX.has(node.type))
11702
+ return false;
11703
+ const { href, tag } = node.props;
11704
+ if (tag !== undefined && tag !== "div")
11705
+ return false;
11706
+ if (typeof href !== "string" || !href.trim() || !sanitizeHref(href))
11707
+ return false;
11708
+ return !childrenOf(node).some(containsInteractive);
11709
+ }
11174
11710
  // ../emvb/src/core/render/index.ts
11175
11711
  var FIELD_TYPES2 = new Set(FORM_FIELD_TYPES.filter((type) => type !== "submit"));
11712
+ var MAX_SECTION_ELEMENTS = 20 * MAX_NODES;
11176
11713
  // ../emvb/src/core/design/transfer.ts
11177
11714
  var MAX_DESIGN_FILE_BYTES = 1024 * 1024;
11178
11715
  // ../emvb/src/core/sanitize/svg-upload.ts
@@ -11235,7 +11772,7 @@ var ConditionsDocSchema = strictObject({
11235
11772
  // ../emvb/src/core/theme/triggers.ts
11236
11773
  var TRIGGERS_SCHEMA_VERSION = 1;
11237
11774
  var MAX_POPUP_TRIGGERS = 8;
11238
- var MAX_CLICK_SELECTOR_LENGTH = 200;
11775
+ var MAX_CLICK_SELECTOR_LENGTH = TRIGGER_LIMITS.maxClickSelectorLength;
11239
11776
  var MAX_SHOW_TIMES = 100;
11240
11777
  var PageLoadTrigger = strictObject({ type: literal("page_load") });
11241
11778
  var DelayTrigger = strictObject({
@@ -11279,7 +11816,7 @@ var POPUP_CHROME_CSS = `
11279
11816
  .emvb-popup[hidden]{display:none!important}
11280
11817
  .emvb-popup__backdrop{position:absolute;inset:0;background:rgba(15,23,42,.55)}
11281
11818
  .emvb-popup__dialog{position:relative;z-index:1;max-width:min(36rem,100%);max-height:min(90vh,100%);overflow:auto;background:#fff;color:#0f172a;border-radius:.75rem;box-shadow:0 25px 50px -12px rgba(0,0,0,.35);padding:1.5rem 1.5rem 1.25rem}
11282
- .emvb-popup__close{position:absolute;top:.5rem;right:.5rem;width:2rem;height:2rem;border:0;border-radius:999px;background:transparent;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
11819
+ .emvb-popup__close{position:sticky;top:-1rem;z-index:1;float:right;margin:-1rem -1rem 0 .5rem;width:2rem;height:2rem;border:0;border-radius:999px;background:inherit;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
11283
11820
  .emvb-popup__close:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
11284
11821
  .emvb-popup__content{min-width:12rem}
11285
11822
  `.replace(/\n+/g, "").trim();
@@ -11310,12 +11847,161 @@ var FLOAT_CHROME_CSS = `
11310
11847
  :where(.emvb-float--surface){background:#fff;color:#0f172a;box-shadow:0 4px 16px -4px rgba(15,23,42,.25);padding:.5rem 1rem}
11311
11848
  :where(.emvb-float--surface:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom)){border-radius:.75rem;padding:.75rem 1rem}
11312
11849
  .emvb-float__body{min-width:0;flex:1}
11850
+ .emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom){max-width:calc(100% - 2rem)}
11851
+ .emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom) .emvb-float__body{max-height:calc(100vh - 3.5rem);max-height:calc(100dvh - 3.5rem);overflow:auto}
11852
+ .emvb-float:is(.emvb-float--top,.emvb-float--bottom) .emvb-float__body{max-height:50vh;max-height:50dvh;overflow:auto}
11313
11853
  .emvb-float__close{flex:none;width:2rem;height:2rem;border:0;border-radius:999px;background:transparent;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
11314
11854
  .emvb-float__close:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
11315
- html{--emvb-float-top:0px;--emvb-float-bottom:0px}
11855
+ html{--emvb-float-top:0px;--emvb-float-bottom:0px;scroll-padding-top:var(--emvb-float-top);scroll-padding-bottom:var(--emvb-float-bottom)}
11316
11856
  body{padding-top:var(--emvb-float-top);padding-bottom:var(--emvb-float-bottom)}
11317
11857
  `.replace(/\n+/g, "").trim();
11858
+ // ../emvb/src/core/clipboard.ts
11859
+ var WRAPPER_ID = "emvb_clip";
11860
+ var styleOf = localStyleOf;
11861
+ var none = () => ({ classes: 0, variables: 0, htmlIds: 0, unsafe: 0 });
11862
+ var VARIABLE_LISTS = {
11863
+ color: "colors",
11864
+ font: "fonts",
11865
+ fontSize: "fontSizes",
11866
+ spacing: "spacings"
11867
+ };
11868
+ var asRef = (value) => isRecord(value) && typeof value["var"] === "string" ? { var: value["var"], kind: value["from"] ?? "color" } : null;
11869
+ function refsInStyle(style) {
11870
+ const refs = [];
11871
+ forEachStyleRef(style, (value) => {
11872
+ const ref = asRef(value);
11873
+ if (ref)
11874
+ refs.push(ref);
11875
+ });
11876
+ return refs;
11877
+ }
11878
+ var refsOf = (owner) => [
11879
+ ...refsInStyle(owner.style),
11880
+ ...STYLE_STATES.flatMap((state) => refsInStyle(owner.states?.[state])),
11881
+ ...refsInStyle(owner.devices?.tablet),
11882
+ ...refsInStyle(owner.devices?.mobile),
11883
+ ...refsInStyle(owner.query?.style)
11884
+ ];
11885
+ var hasVariable = (design, ref) => (design.variables[VARIABLE_LISTS[ref.kind]] ?? []).some((v) => v.id === ref.var);
11886
+ function withKnownVariables(node, design, dropped) {
11887
+ const missing = refsOf(node).filter((ref) => !hasVariable(design, ref));
11888
+ if (missing.length === 0)
11889
+ return node;
11890
+ dropped.variables += missing.length;
11891
+ let wrapper = {
11892
+ schemaVersion: LAYOUT_SCHEMA_VERSION,
11893
+ root: { id: WRAPPER_ID, type: "container", props: {}, children: [node] }
11894
+ };
11895
+ for (const ref of missing)
11896
+ wrapper = clearVariableRefs(wrapper, ref.var, ref.kind);
11897
+ return wrapper.root.children[0];
11898
+ }
11899
+ var SANITIZERS = {
11900
+ href: sanitizeHref,
11901
+ media: sanitizeMediaUrl
11902
+ };
11903
+ function withSafeProps(node, dropped) {
11904
+ const type = node.type;
11905
+ if (!(type in ELEMENTS))
11906
+ return node;
11907
+ const props = { ...node.props };
11908
+ const defaults = ELEMENTS[type].defaults().props;
11909
+ let changed = false;
11910
+ const fallBack = (key, optional) => {
11911
+ dropped.unsafe++;
11912
+ changed = true;
11913
+ if (optional || defaults[key] === undefined)
11914
+ delete props[key];
11915
+ else
11916
+ props[key] = defaults[key];
11917
+ };
11918
+ const fields = ELEMENT_DESCRIPTORS.find((d) => d.type === type)?.fields ?? [];
11919
+ for (const field of fields) {
11920
+ if (field.kind !== "href" && field.kind !== "media")
11921
+ continue;
11922
+ const value = props[field.key];
11923
+ if (typeof value !== "string" || value.trim() === "")
11924
+ continue;
11925
+ const safe = SANITIZERS[field.kind](value);
11926
+ if (safe === undefined)
11927
+ fallBack(field.key, field.optional);
11928
+ else if (safe !== value) {
11929
+ props[field.key] = safe;
11930
+ changed = true;
11931
+ }
11932
+ }
11933
+ if (type === "icon" && typeof props["iconSvg"] === "string") {
11934
+ const report = sanitizeSvgReport(props["iconSvg"]);
11935
+ if (!report.tree) {
11936
+ dropped.unsafe++;
11937
+ changed = true;
11938
+ delete props["iconSvg"];
11939
+ } else if (report.images > 0) {
11940
+ props["iconSvg"] = serialize(report.tree);
11941
+ dropped.images = (dropped.images ?? 0) + report.images;
11942
+ changed = true;
11943
+ }
11944
+ }
11945
+ if (type === "svg" && typeof props["markup"] === "string") {
11946
+ const report = sanitizeSvgReport(props["markup"]);
11947
+ if (!report.tree)
11948
+ fallBack("markup", false);
11949
+ else if (report.images > 0) {
11950
+ props["markup"] = serialize(report.tree);
11951
+ dropped.images = (dropped.images ?? 0) + report.images;
11952
+ changed = true;
11953
+ }
11954
+ }
11955
+ return changed ? { ...node, props } : node;
11956
+ }
11957
+ function htmlIdsOf(node, into = new Set) {
11958
+ if (node.htmlId)
11959
+ into.add(node.htmlId);
11960
+ for (const child of nodeChildren(node))
11961
+ htmlIdsOf(child, into);
11962
+ return into;
11963
+ }
11964
+ function cleanNode(node, design, usedHtmlIds, dropped) {
11965
+ let next = withSafeProps(withKnownVariables(node, design, dropped), dropped);
11966
+ if (next.classes) {
11967
+ const known = new Set((design.classes ?? []).map((cls) => cls.id));
11968
+ const kept = next.classes.filter((id) => known.has(id));
11969
+ if (kept.length !== next.classes.length) {
11970
+ dropped.classes += next.classes.length - kept.length;
11971
+ next = { ...next, classes: kept };
11972
+ if (kept.length === 0)
11973
+ delete next.classes;
11974
+ }
11975
+ }
11976
+ if (next.htmlId && usedHtmlIds.has(next.htmlId)) {
11977
+ dropped.htmlIds++;
11978
+ next = { ...next };
11979
+ delete next.htmlId;
11980
+ }
11981
+ if (next.variant) {
11982
+ next = { ...next };
11983
+ delete next.variant;
11984
+ }
11985
+ const kids = nodeChildren(next);
11986
+ if (kids.length === 0)
11987
+ return next;
11988
+ return {
11989
+ ...next,
11990
+ children: kids.map((child) => cleanNode(child, design, usedHtmlIds, dropped))
11991
+ };
11992
+ }
11993
+ function prepareElement(node, layout, design, random = Math.random) {
11994
+ const dropped = none();
11995
+ const cleaned = cleanNode(node, design, htmlIdsOf(layout.root), dropped);
11996
+ return { node: withFreshIds(layout, cleaned, random), dropped };
11997
+ }
11998
+ function prepareStyle(style, design) {
11999
+ const dropped = none();
12000
+ const holder = withKnownVariables({ id: WRAPPER_ID, type: "divider", props: {}, ...style }, design, dropped);
12001
+ return { style: styleOf(holder), dropped };
12002
+ }
11318
12003
  // ../emvb/src/core/a11y/audit.ts
12004
+ var spoken = (value) => String(value ?? "").replace(/[\p{Cf}\u115F\u1160\u2800\u3164\uFFA0]/gu, "").trim();
11319
12005
  var WEIGHT = { error: 12, warning: 4 };
11320
12006
  var USELESS_ALT = /^(?:image|img|photo|picture|graphic|logo|icon|untitled|\s*)$|\.(?:jpe?g|png|gif|webp|avif|svg)$|^(?:img|dsc|pxl|screen ?shot|whatsapp image)[\s_-]?\d+/i;
11321
12007
  var VAGUE = /^(?:click here|here|read more|more|learn more|link|this|go|see more|view more|more info(?:rmation)?|details|find out more|continue reading|read more here|click here to (?:read|learn) more)\s*[.!…:»›→>\u2192\u203a\u00bb-]*$/i;
@@ -11369,7 +12055,13 @@ var TEXT_TYPES = new Set([
11369
12055
  ]);
11370
12056
  var FIELD_TYPES3 = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
11371
12057
  var LINKISH = new Set(["link", "button", "menu-item"]);
11372
- function px(value) {
12058
+ function px(value, design) {
12059
+ if (design && value && typeof value === "object" && "var" in value) {
12060
+ const found = design.variables.fontSizes?.find((v) => v.id === value.var);
12061
+ if (!found)
12062
+ return;
12063
+ return found.fluid ? Math.min(found.fluid.min, found.fluid.max) : px(found.value);
12064
+ }
11373
12065
  if (!value || typeof value !== "object" || !("unit" in value))
11374
12066
  return;
11375
12067
  const v = value;
@@ -11379,12 +12071,53 @@ function px(value) {
11379
12071
  return v.value * 16;
11380
12072
  return;
11381
12073
  }
11382
- function largeText(node) {
11383
- const style = node.style;
11384
- const size = px(style?.fontSize) ?? (node.type === "heading" ? 24 : 16);
12074
+ var HEADING_PX = [32, 24, 18.72, 16, 13.28, 10.72];
12075
+ var headingLevel = (node) => {
12076
+ if (node.type !== "heading")
12077
+ return;
12078
+ const level = node.props.level;
12079
+ return typeof level === "number" && level >= 1 && level <= 6 ? level : 2;
12080
+ };
12081
+ function effectiveStyle(node, design) {
12082
+ const level = headingLevel(node);
12083
+ const tagDefaults = level === undefined ? undefined : design.defaults?.[`h${level}`];
12084
+ const classIds = new Set(node.classes ?? []);
12085
+ if (classIds.size === 0 && !tagDefaults)
12086
+ return node.style;
12087
+ const fromClasses = (design.classes ?? []).filter((c) => classIds.has(c.id)).reduce((acc, c) => Object.assign(acc, c.style), { ...tagDefaults });
12088
+ return { ...fromClasses, ...node.style };
12089
+ }
12090
+ function deviceStyles(node, design) {
12091
+ const ids = new Set(node.classes ?? []);
12092
+ const merged = {};
12093
+ const layers = [
12094
+ ...(design.classes ?? []).filter((c) => ids.has(c.id)).map((c) => c.devices),
12095
+ node.devices
12096
+ ];
12097
+ for (const devices of layers) {
12098
+ for (const [key, st] of Object.entries(devices ?? {})) {
12099
+ merged[key] = { ...merged[key], ...st };
12100
+ }
12101
+ }
12102
+ return Object.values(merged);
12103
+ }
12104
+ function largeText(node, design) {
12105
+ const style = effectiveStyle(node, design);
12106
+ const level = headingLevel(node);
12107
+ const size = px(style?.fontSize, design) ?? (level === undefined ? 16 : HEADING_PX[level - 1] ?? 24);
11385
12108
  const weight = typeof style?.fontWeight === "number" ? style.fontWeight : node.type === "heading" ? 700 : 400;
11386
12109
  return size >= 24 || size >= 18.66 && weight >= 700;
11387
12110
  }
12111
+ function boxHasName(node) {
12112
+ if (node.bind || node.type.startsWith("post-") || node.type === "loop" || node.type === "section")
12113
+ return true;
12114
+ const props = node.props;
12115
+ const decorative = props["decorative"] === true;
12116
+ const named = node.type === "image" || node.type === "icon" || node.type === "svg" ? !decorative && spoken(node.type === "image" ? props["alt"] : props["title"]) !== "" : ["text", "title", "label", "summary", "caption"].some((key) => spoken(props[key]) !== "");
12117
+ if (named)
12118
+ return true;
12119
+ return isParentNode(node) && node.children.some(boxHasName);
12120
+ }
11388
12121
  function auditPage(layout, design) {
11389
12122
  const issues = [];
11390
12123
  const add = (issue) => issues.push({ ...issue, id: `${issue.rule}:${issue.nodeId}` });
@@ -11408,7 +12141,7 @@ function auditPage(layout, design) {
11408
12141
  if (before)
11409
12142
  [h1s, lastLevel] = [[...before[0]], before[1]];
11410
12143
  const outerFade = fade;
11411
- const opacity = node.style?.opacity;
12144
+ const opacity = effectiveStyle(node, design)?.opacity;
11412
12145
  if (typeof opacity === "number" && opacity >= 0 && opacity < 1)
11413
12146
  fade *= opacity;
11414
12147
  const outerShown = shownOn;
@@ -11424,8 +12157,9 @@ function auditPage(layout, design) {
11424
12157
  };
11425
12158
  const visitNode = (node, bg, color) => {
11426
12159
  const props = node.props;
11427
- const style = node.style;
11428
- const ownBg = style?.backgroundImage ? "unknown" : hexOf(style?.backgroundColor, design);
12160
+ const style = effectiveStyle(node, design);
12161
+ const covered = style?.backgroundImage || style?.backgroundVideo || style?.gradient;
12162
+ const ownBg = covered ? "unknown" : hexOf(style?.backgroundColor, design);
11429
12163
  const nextBg = ownBg && ownBg !== "unknown" && bg && bg !== "unknown" ? over(ownBg, bg) : ownBg ?? bg;
11430
12164
  const nextColor = hexOf(style?.color, design) ?? color;
11431
12165
  const imageLinked = node.type === "image" && typeof props["href"] === "string" && props["href"].trim() !== "";
@@ -11437,17 +12171,44 @@ function auditPage(layout, design) {
11437
12171
  message: "This image is a link but is marked decorative, so the link has no name."
11438
12172
  });
11439
12173
  } else if (node.type === "image" && props["decorative"] !== true) {
11440
- const alt = typeof props["alt"] === "string" ? props["alt"].trim() : "";
12174
+ const alt = typeof props["alt"] === "string" ? spoken(props["alt"]) : "";
11441
12175
  if (USELESS_ALT.test(alt)) {
11442
12176
  add({
11443
12177
  nodeId: node.id,
11444
12178
  rule: "image-alt",
11445
12179
  severity: "error",
11446
- message: alt ? `The alt text "${alt.slice(0, 40)}" doesn't describe the image.` : "This image has no alt text.",
12180
+ message: alt ? `The alt text "${clipText(alt, 40)}" doesn't describe the image.` : "This image has no alt text.",
11447
12181
  ...imageLinked ? {} : { fix: { kind: "decorative" }, fixLabel: "Mark as decorative" }
11448
12182
  });
11449
12183
  }
11450
12184
  }
12185
+ if (node.type === "svg" && props["decorative"] !== true && !spoken(props["title"]) && !/<title\b[^>]*>\s*[^<\s]/i.test(String(props["markup"] ?? ""))) {
12186
+ add({
12187
+ nodeId: node.id,
12188
+ rule: "image-alt",
12189
+ severity: "error",
12190
+ message: "This SVG has no title, so screen readers can't say what it shows.",
12191
+ fix: { kind: "decorative" },
12192
+ fixLabel: "Mark as decorative"
12193
+ });
12194
+ }
12195
+ const tooLong = [effectiveStyle(node, design), ...deviceStyles(node, design)].some((st) => {
12196
+ const anim = st?.iconAnimation;
12197
+ if (anim?.type !== "spin" && anim?.type !== "pulse")
12198
+ return false;
12199
+ if (anim.loop === true)
12200
+ return true;
12201
+ const ms = typeof anim.duration === "number" ? anim.duration : 0;
12202
+ return iconAnimationRuns(anim.type, ms) * ms > ICON_ANIMATION_LIMIT_MS;
12203
+ });
12204
+ if (tooLong) {
12205
+ add({
12206
+ nodeId: node.id,
12207
+ rule: "motion",
12208
+ severity: "warning",
12209
+ message: "This icon animates for more than 5 seconds and visitors can't pause it. Shorten the duration, or keep it only if the motion is essential."
12210
+ });
12211
+ }
11451
12212
  if (node.type === "image" && Array.isArray(props["sources"]) && props["sources"].length > 0) {
11452
12213
  const width = props["width"];
11453
12214
  const widthSet = typeof width === "number" && Number.isInteger(width) && width >= 1;
@@ -11469,12 +12230,12 @@ function auditPage(layout, design) {
11469
12230
  message: "This image link opens a new tab without saying so; say so in the alt text."
11470
12231
  });
11471
12232
  }
11472
- if (FIELD_TYPES3.has(node.type) && !String(props["label"] ?? "").trim() && !node.bind) {
12233
+ if (FIELD_TYPES3.has(node.type) && !spoken(props["label"]) && !node.bind) {
11473
12234
  add({
11474
12235
  nodeId: node.id,
11475
12236
  rule: "control-name",
11476
12237
  severity: "error",
11477
- message: String(props["placeholder"] ?? "").trim() ? "This field has only a placeholder, which disappears once you type; give it a label." : "This field has no label, so screen readers can't say what it's for."
12238
+ message: spoken(props["placeholder"]) ? "This field has only a placeholder, which disappears once you type; give it a label." : "This field has no label, so screen readers can't say what it's for."
11478
12239
  });
11479
12240
  }
11480
12241
  const NAME_PROP = {
@@ -11483,7 +12244,7 @@ function auditPage(layout, design) {
11483
12244
  video: "title"
11484
12245
  };
11485
12246
  if (node.type === "tab-panel" || node.type === "accordion-item" || node.type === "video") {
11486
- const name = String(props[NAME_PROP[node.type]] ?? "").trim();
12247
+ const name = spoken(props[NAME_PROP[node.type]]);
11487
12248
  if (!name && !node.bind) {
11488
12249
  add({
11489
12250
  nodeId: node.id,
@@ -11494,7 +12255,7 @@ function auditPage(layout, design) {
11494
12255
  }
11495
12256
  }
11496
12257
  if (node.type === "menu" && (node.children?.length ?? 0) > 0) {
11497
- const name = String(props["label"] ?? "").trim() || "Menu";
12258
+ const name = spoken(props["label"]) || "Menu";
11498
12259
  const key = name.toLowerCase();
11499
12260
  if (menuNames.some((names, i) => shownOn[i] && names.has(key))) {
11500
12261
  add({
@@ -11509,7 +12270,7 @@ function auditPage(layout, design) {
11509
12270
  names.add(key);
11510
12271
  });
11511
12272
  }
11512
- if (node.type === "heading" && !String(props["text"] ?? "").trim() && !node.bind) {
12273
+ if (node.type === "heading" && !spoken(props["text"]) && !node.bind) {
11513
12274
  add({
11514
12275
  nodeId: node.id,
11515
12276
  rule: "empty-heading",
@@ -11544,8 +12305,16 @@ function auditPage(layout, design) {
11544
12305
  }
11545
12306
  lastLevel = level;
11546
12307
  }
12308
+ if (boxBecomesLink(node) && !boxHasName(node)) {
12309
+ add({
12310
+ nodeId: node.id,
12311
+ rule: "link-name",
12312
+ severity: "error",
12313
+ message: "This box is a link, but nothing inside it has text, so the link has no name."
12314
+ });
12315
+ }
11547
12316
  if (LINKISH.has(node.type) || node.type === "icon" && props["href"]) {
11548
- const text = String(props["text"] ?? props["title"] ?? "").trim();
12317
+ const text = spoken(props["text"] ?? props["title"]);
11549
12318
  const hasHref = typeof props["href"] === "string" && props["href"].trim() !== "";
11550
12319
  if (!text && !node.bind) {
11551
12320
  add({
@@ -11573,17 +12342,18 @@ function auditPage(layout, design) {
11573
12342
  }
11574
12343
  if (TEXT_TYPES.has(node.type) && nextColor && nextBg && nextBg !== "unknown") {
11575
12344
  const ratio = contrastRatio(over(nextColor, nextBg, fade), nextBg);
11576
- const needed = largeText(node) ? 3 : 4.5;
12345
+ const needed = largeText(node, design) ? 3 : 4.5;
11577
12346
  if (ratio < needed) {
11578
12347
  const black = contrastRatio("#000000", nextBg);
11579
12348
  const white = contrastRatio("#ffffff", nextBg);
11580
12349
  const better = black >= white ? "#111111" : "#ffffff";
11581
12350
  const fixable = contrastRatio(over(better, nextBg, fade), nextBg) >= needed;
12351
+ const shown = (Math.floor(ratio * 10) / 10).toFixed(1);
11582
12352
  add({
11583
12353
  nodeId: node.id,
11584
12354
  rule: "contrast",
11585
12355
  severity: "error",
11586
- message: fixable ? `Text contrast is ${ratio.toFixed(1)}:1; it needs ${needed}:1.` : `Text contrast is ${ratio.toFixed(1)}:1; it needs ${needed}:1. Opacity on this element or a parent fades it; raise the opacity.`,
12356
+ message: fixable ? `Text contrast is ${shown}:1; it needs ${needed}:1.` : `Text contrast is ${shown}:1; it needs ${needed}:1. Opacity on this element or a parent fades it; raise the opacity.`,
11587
12357
  ...fixable ? {
11588
12358
  fix: { kind: "text-color", color: better },
11589
12359
  fixLabel: better === "#ffffff" ? "Use white text" : "Use dark text"
@@ -11591,7 +12361,7 @@ function auditPage(layout, design) {
11591
12361
  });
11592
12362
  }
11593
12363
  }
11594
- const focusable = LINKISH.has(node.type) || node.type === "text-input" || Boolean(props["href"]);
12364
+ const focusable = LINKISH.has(node.type) || FIELD_TYPES3.has(node.type) || node.type === "submit" || Boolean(props["href"]);
11595
12365
  const ownAriaHidden = (node.attributes ?? []).some((a) => a.name === "aria-hidden" && a.value === "true");
11596
12366
  if (focusable && ownAriaHidden) {
11597
12367
  add({
@@ -11696,8 +12466,10 @@ function siteTokens(design) {
11696
12466
  const onAccent = color(pick2(others, /on[- ]?(primary|brand|accent)|inverse|white/));
11697
12467
  if (onAccent)
11698
12468
  tokens.onAccent = onAccent;
11699
- else if (accentVar && /^#[0-9a-f]{6}$/i.test(accentVar.value)) {
11700
- tokens.onAccent = contrastRatio(accentVar.value, "#ffffff") >= contrastRatio(accentVar.value, "#111111") ? "#ffffff" : "#111111";
12469
+ else if (accentVar && /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(accentVar.value)) {
12470
+ const h = accentVar.value.slice(1);
12471
+ const hex = `#${(h.length <= 4 ? [...h].map((c) => c + c).join("") : h).slice(0, 6)}`;
12472
+ tokens.onAccent = contrastRatio(hex, "#ffffff") >= contrastRatio(hex, "#111111") ? "#ffffff" : "#111111";
11701
12473
  }
11702
12474
  const buttonCls = pick2(design.classes, /\b(button|btn)\b/, /cta/);
11703
12475
  if (buttonCls) {
@@ -11938,6 +12710,140 @@ function recipeNode(id, design, layout, random = Math.random) {
11938
12710
  }
11939
12711
  // ../emvb/src/core/share/link.ts
11940
12712
  var MAX_UNPACKED_BYTES = MAX_LAYOUT_BYTES + MAX_DESIGN_BYTES + 4096;
12713
+ // ../emvb/src/core/saved-sections.ts
12714
+ var SAVED_SECTION_VERSION = 1;
12715
+ var SAVED_SECTION_NAME_MAX = 60;
12716
+ var SAVED_SECTION_REASONS = {
12717
+ name: "Give the section a name.",
12718
+ root: "Choose an element inside the page; the page itself can't be saved as a section.",
12719
+ missing: REASONS.missing,
12720
+ tooBig: "This section is too big to save.",
12721
+ damaged: "This saved section can't be read.",
12722
+ tooManyClasses: `Inserting this section would go over ${MAX_CLASSES} classes on this site.`
12723
+ };
12724
+ var refuse2 = (reason) => ({ ok: false, reason });
12725
+ var WRAPPER_ID2 = "savedsection";
12726
+ var savedSectionName = (raw) => clipText(cleanClassName(raw), SAVED_SECTION_NAME_MAX).trim();
12727
+ function withoutVariants(node) {
12728
+ const { variant: _variant, ...rest } = node;
12729
+ const kids = nodeChildren(node);
12730
+ if (kids.length === 0)
12731
+ return rest;
12732
+ return { ...rest, children: kids.map(withoutVariants) };
12733
+ }
12734
+ function classIdsIn(node, into = new Set) {
12735
+ for (const id of node.classes ?? [])
12736
+ into.add(id);
12737
+ for (const child of nodeChildren(node))
12738
+ classIdsIn(child, into);
12739
+ return into;
12740
+ }
12741
+ var wrap = (node) => ({
12742
+ schemaVersion: LAYOUT_SCHEMA_VERSION,
12743
+ root: { id: WRAPPER_ID2, type: "container", props: {}, children: [node] }
12744
+ });
12745
+ function snapshotSection(layout, nodeId, design, rawName, now) {
12746
+ const name = savedSectionName(rawName);
12747
+ if (!name)
12748
+ return refuse2(SAVED_SECTION_REASONS.name);
12749
+ if (nodeId === layout.root.id)
12750
+ return refuse2(SAVED_SECTION_REASONS.root);
12751
+ const found = findNode(layout, nodeId);
12752
+ if (!found)
12753
+ return refuse2(SAVED_SECTION_REASONS.missing);
12754
+ const node = withoutVariants(structuredClone(found));
12755
+ const used = classIdsIn(node);
12756
+ const classes = (design.classes ?? []).filter((c) => used.has(c.id)).map((c) => structuredClone(c));
12757
+ const record = {
12758
+ version: SAVED_SECTION_VERSION,
12759
+ name,
12760
+ layout: wrap(node),
12761
+ designSchemaVersion: DESIGN_SCHEMA_VERSION,
12762
+ classes,
12763
+ createdAt: now,
12764
+ updatedAt: now
12765
+ };
12766
+ if (byteLength2(record) > MAX_LAYOUT_BYTES)
12767
+ return refuse2(SAVED_SECTION_REASONS.tooBig);
12768
+ const checked = validateLayout(record.layout);
12769
+ if (!checked.ok)
12770
+ return refuse2(summarizeIssues(checked.issues));
12771
+ return { ok: true, record };
12772
+ }
12773
+ function lookOf(cls) {
12774
+ const sorted = (value) => Array.isArray(value) ? value.map(sorted) : isRecord(value) ? Object.fromEntries(Object.keys(value).toSorted().map((key) => [key, sorted(value[key])])) : value;
12775
+ const { id: _id, name: _name, ...look } = cls;
12776
+ return JSON.stringify(sorted(look));
12777
+ }
12778
+ function mergeSectionClasses(design, incoming) {
12779
+ const classes = [...design.classes ?? []];
12780
+ const merge = { design, ids: new Map, added: [], reused: [], renamed: [] };
12781
+ for (const raw of incoming) {
12782
+ const { style } = prepareStyle(raw, design);
12783
+ const cls = { id: raw.id, name: raw.name, style: style.style ?? {} };
12784
+ if (style.states)
12785
+ cls.states = style.states;
12786
+ if (style.devices)
12787
+ cls.devices = style.devices;
12788
+ if (style.hiddenOn)
12789
+ cls.hiddenOn = style.hiddenOn;
12790
+ const look = lookOf(cls);
12791
+ const same = classes.find((c) => (c.id === cls.id || nameKey(c.name) === nameKey(cls.name)) && lookOf(c) === look);
12792
+ if (same) {
12793
+ merge.ids.set(raw.id, same.id);
12794
+ merge.reused.push(same.name);
12795
+ continue;
12796
+ }
12797
+ if (classes.length >= MAX_CLASSES)
12798
+ return refuse2(SAVED_SECTION_REASONS.tooManyClasses);
12799
+ const names = new Set(classes.map((c) => nameKey(c.name)));
12800
+ let name = cls.name;
12801
+ for (let n = 2;names.has(nameKey(name)); n++) {
12802
+ name = `${clipText(cls.name, 54).trim()} ${n}`;
12803
+ }
12804
+ const ids = new Set(classes.map((c) => c.id));
12805
+ const base = ids.has(cls.id) ? slugify2(name).slice(0, 34).replace(/-+$/, "") || "class" : cls.id;
12806
+ let id = base;
12807
+ for (let n = 2;ids.has(id); n++)
12808
+ id = `${base}-${n}`.slice(0, 40);
12809
+ classes.push({ ...cls, id, name });
12810
+ merge.ids.set(raw.id, id);
12811
+ if (name === cls.name)
12812
+ merge.added.push(name);
12813
+ else
12814
+ merge.renamed.push({ from: cls.name, to: name });
12815
+ }
12816
+ merge.design = { ...design, classes };
12817
+ return merge;
12818
+ }
12819
+ function withClassIds(node, ids) {
12820
+ const kids = nodeChildren(node);
12821
+ const next = { ...node };
12822
+ if (node.classes)
12823
+ next.classes = node.classes.map((id) => ids.get(id) ?? id);
12824
+ if (kids.length > 0) {
12825
+ next.children = kids.map((kid) => withClassIds(kid, ids));
12826
+ }
12827
+ return next;
12828
+ }
12829
+ function prepareSavedSection(section, layout, design, random = Math.random, merged) {
12830
+ const merge = merged ?? mergeSectionClasses(design, section.classes);
12831
+ if ("ok" in merge)
12832
+ return merge;
12833
+ const remapped = withClassIds(section.node, merge.ids);
12834
+ const { node, dropped } = prepareElement(remapped, layout, merge.design, random);
12835
+ return { ok: true, node, design: merge.design, merge, dropped };
12836
+ }
12837
+ function classMergeNotice(merge) {
12838
+ const parts = [];
12839
+ if (merge.added.length > 0)
12840
+ parts.push(`${merge.added.length} added`);
12841
+ if (merge.renamed.length > 0) {
12842
+ const list = merge.renamed.map(({ from, to }) => `${from} → ${to}`).join(", ");
12843
+ parts.push(`${merge.renamed.length} added as a copy (${list})`);
12844
+ }
12845
+ return parts.length > 0 ? `Classes: ${parts.join("; ")}.` : null;
12846
+ }
11941
12847
  // ../emvb/src/mcp/errors.ts
11942
12848
  var STATUS = {
11943
12849
  INVALID_INPUT: 400,
@@ -11993,7 +12899,7 @@ function summaryText(node) {
11993
12899
  const text = typeof props["text"] === "string" ? props["text"] : undefined;
11994
12900
  if (!text)
11995
12901
  return;
11996
- return text.length > 60 ? `${text.slice(0, 57)}…` : text;
12902
+ return text.length > 60 ? `${clipText(text, 57)}…` : text;
11997
12903
  }
11998
12904
  function stats(layout) {
11999
12905
  let nodes = 0;
@@ -12318,13 +13224,18 @@ var ListVersionsInput = strictObject({
12318
13224
  var ListVersionsOutput = object({
12319
13225
  versions: array(object({ revisionId: string2(), at: string2(), authorId: string2().nullable() }))
12320
13226
  });
13227
+ var utcIso = (at) => /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d+)?$/.test(at) ? `${at.replace(" ", "T")}Z` : at;
12321
13228
  async function listVersions(ports, input) {
12322
13229
  const page = await ports.getPage(input.pageId);
12323
13230
  if (!page)
12324
13231
  throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}.`);
12325
13232
  const revisions = await ports.listRevisions(input.pageId, input.limit ?? 20);
12326
13233
  return {
12327
- versions: revisions.map((r) => ({ revisionId: r.id, at: r.createdAt, authorId: r.authorId }))
13234
+ versions: revisions.map((r) => ({
13235
+ revisionId: r.id,
13236
+ at: utcIso(r.createdAt),
13237
+ authorId: r.authorId
13238
+ }))
12328
13239
  };
12329
13240
  }
12330
13241
 
@@ -12353,9 +13264,26 @@ var KINDS = [
12353
13264
  ["fontSizes", "fontSize"],
12354
13265
  ["spacings", "spacing"]
12355
13266
  ];
13267
+ function nestsDeeperThan(value, max) {
13268
+ const stack = [[value, 1]];
13269
+ while (stack.length > 0) {
13270
+ const [item, depth] = stack.pop();
13271
+ if (typeof item !== "object" || item === null)
13272
+ continue;
13273
+ if (depth > max)
13274
+ return true;
13275
+ for (const child of Object.values(item))
13276
+ stack.push([child, depth + 1]);
13277
+ }
13278
+ return false;
13279
+ }
13280
+ var MAX_INPUT_NESTING = 256;
12356
13281
  var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
12357
13282
  var isRef = (v) => typeof v["var"] === "string" && Object.keys(v).every((k) => k === "var" || k === "from");
12358
13283
  function resolveDesignRefs(value, design) {
13284
+ if (nestsDeeperThan(value, MAX_INPUT_NESTING)) {
13285
+ throw new McpToolError("INVALID_INPUT", "This input nests too deeply.");
13286
+ }
12359
13287
  const kinds = new Map;
12360
13288
  for (const [key, from] of KINDS) {
12361
13289
  for (const v of design.variables[key] ?? [])
@@ -12455,7 +13383,12 @@ async function mutatePage(ports, tool, pageId, expectedRev, apply) {
12455
13383
  }
12456
13384
  const next = apply(current.layout);
12457
13385
  refuseUnsafeImageSources(current.layout, next.layout);
13386
+ refuseUnsafeLinks(current.layout, next.layout);
13387
+ refuseUnsafeSvg(current.layout, next.layout);
12458
13388
  const layout = checkLayout(next.layout);
13389
+ if (stableJson(layout) === stableJson(current.layout)) {
13390
+ return { pageId, rev: page.rev, changed: [], summary: `Nothing changed (${tool})` };
13391
+ }
12459
13392
  try {
12460
13393
  const saved = await ports.savePage(pageId, { layout }, page.rev);
12461
13394
  await ports.log({
@@ -12478,11 +13411,61 @@ async function mutatePage(ports, tool, pageId, expectedRev, apply) {
12478
13411
  var refused = (reason) => {
12479
13412
  throw new McpToolError("REFUSED", reason);
12480
13413
  };
13414
+ var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
13415
+ var propsOf = (node) => isRecord3(node.props) ? node.props : {};
13416
+ function linkValues(root) {
13417
+ const found = new Map;
13418
+ const walk = (node) => {
13419
+ const fields = ELEMENT_DESCRIPTORS.find((d) => d.type === node.type)?.fields ?? [];
13420
+ const props = propsOf(node);
13421
+ for (const field of fields) {
13422
+ const value = props[field.key];
13423
+ if (field.kind === "href" && typeof value === "string")
13424
+ found.set(`${node.id}.${field.key}`, value);
13425
+ }
13426
+ for (const child of nodeChildren(node))
13427
+ walk(child);
13428
+ };
13429
+ walk(root);
13430
+ return found;
13431
+ }
13432
+ function refuseUnsafeLinks(before, after) {
13433
+ const old = linkValues(before.root);
13434
+ for (const [key, href] of linkValues(after.root)) {
13435
+ if (href.trim() === "" || old.get(key) === href || sanitizeHref(href) !== undefined)
13436
+ continue;
13437
+ const [id, prop] = key.split(".");
13438
+ refused(`Element ${id} has the ${prop} ${JSON.stringify(clipText(href, 80))}, which pages can't link to. Use an https:// URL, a path on this site such as /pricing, #section, mailto: or tel:.`);
13439
+ }
13440
+ }
13441
+ function svgValues(root) {
13442
+ const found = new Map;
13443
+ const walk = (node) => {
13444
+ const props = propsOf(node);
13445
+ if (node.type === "svg" && typeof props["markup"] === "string")
13446
+ found.set(`${node.id}.markup`, props["markup"]);
13447
+ if (typeof props["iconSvg"] === "string")
13448
+ found.set(`${node.id}.iconSvg`, props["iconSvg"]);
13449
+ for (const child of nodeChildren(node))
13450
+ walk(child);
13451
+ };
13452
+ walk(root);
13453
+ return found;
13454
+ }
13455
+ function refuseUnsafeSvg(before, after) {
13456
+ const old = svgValues(before.root);
13457
+ for (const [key, markup] of svgValues(after.root)) {
13458
+ if (markup.trim() === "" || old.get(key) === markup || isSafeSvgMarkup(markup))
13459
+ continue;
13460
+ const [id, prop] = key.split(".");
13461
+ refused(`Element ${id} has ${prop} the page can't show. Use plain SVG: no scripts, event handlers such as onload, foreignObject, style blocks, links or external images.`);
13462
+ }
13463
+ }
12481
13464
  function imageSources2(root) {
12482
13465
  const found = new Map;
12483
13466
  const walk = (node) => {
12484
13467
  if (node.type === "image") {
12485
- const props = node.props;
13468
+ const props = propsOf(node);
12486
13469
  const list = typeof props.src === "string" ? [props.src] : [];
12487
13470
  if (Array.isArray(props.sources)) {
12488
13471
  for (const source of props.sources) {
@@ -12515,6 +13498,17 @@ var ElementSpec = lazy(() => looseObject({
12515
13498
  props: record(string2(), unknown()).optional(),
12516
13499
  children: array(ElementSpec).max(200).optional()
12517
13500
  }));
13501
+ var BoundedElementSpec = preprocess((value, ctx) => {
13502
+ if (nestsDeeperThan(value, MAX_DEPTH * 8)) {
13503
+ ctx.addIssue({
13504
+ code: "custom",
13505
+ message: `Elements can be nested at most ${MAX_DEPTH} levels deep.`,
13506
+ input: value
13507
+ });
13508
+ return NEVER;
13509
+ }
13510
+ return value;
13511
+ }, ElementSpec);
12518
13512
  function buildNode(spec) {
12519
13513
  if (!KNOWN_TYPES.has(spec.type)) {
12520
13514
  refused(`Unknown element type ${spec.type}. Call list_element_types.`);
@@ -12544,8 +13538,20 @@ function promoteHeroHeading(layout, title) {
12544
13538
  props: { ...node.props, text: title, level: 1 }
12545
13539
  }));
12546
13540
  }
13541
+ async function slugTaken(ports, slug) {
13542
+ let cursor;
13543
+ for (let i = 0;i < 20; i++) {
13544
+ const batch = await ports.listPages({ limit: 50, ...cursor ? { cursor } : {} });
13545
+ if (batch.pages.some((page) => page.slug === slug))
13546
+ return true;
13547
+ if (!batch.nextCursor)
13548
+ return false;
13549
+ cursor = batch.nextCursor;
13550
+ }
13551
+ return false;
13552
+ }
12547
13553
  async function createPage(ports, input) {
12548
- const slug = slugify2(input.title);
13554
+ const slug = pageSlug(input.title);
12549
13555
  if (!slug)
12550
13556
  refused("Give the page a title with letters or digits.");
12551
13557
  const { design } = await ports.getDesign();
@@ -12570,8 +13576,7 @@ async function createPage(ports, input) {
12570
13576
  if (recipes[0] === "hero")
12571
13577
  layout = promoteHeroHeading(layout, input.title);
12572
13578
  const checked = checkLayout(layout);
12573
- const taken = await ports.listPages({ limit: 50 });
12574
- if (taken.pages.some((page) => page.slug === slug)) {
13579
+ if (await slugTaken(ports, slug)) {
12575
13580
  throw new McpToolError("REFUSED", `The slug "${slug}" is taken. Choose another title.`);
12576
13581
  }
12577
13582
  const created = await ports.createPage({ title: input.title, layout: checked });
@@ -12588,7 +13593,7 @@ var AddElementInput = strictObject({
12588
13593
  pageId: PageId,
12589
13594
  parentId: NodeIdInput,
12590
13595
  index: number2().int().min(0).optional(),
12591
- element: ElementSpec,
13596
+ element: BoundedElementSpec,
12592
13597
  expectedRev: Rev.optional()
12593
13598
  });
12594
13599
  async function addElement(ports, input) {
@@ -12646,7 +13651,6 @@ var UpdateElementInput = strictObject({
12646
13651
  unset: array(string2().regex(/^[a-zA-Z]+(\.[a-zA-Z0-9_-]+)?$/)).max(50).optional(),
12647
13652
  expectedRev: Rev.optional()
12648
13653
  });
12649
- var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
12650
13654
  function dropOldPictureProps(before, setProps, copy) {
12651
13655
  if (typeof setProps.src !== "string" || setProps.src === before.src)
12652
13656
  return;
@@ -12828,6 +13832,11 @@ async function updateSiteStyles(ports, input) {
12828
13832
  }
12829
13833
  const draft = structuredClone(state.design);
12830
13834
  const changes = [];
13835
+ for (const font of input.variables?.fonts ?? []) {
13836
+ if (typeof font.value === "string" && !isSafeFontStack(font.value)) {
13837
+ throw new McpToolError("INVALID_INPUT", `Font ${String(font.id)}: "${font.value.slice(0, 60)}" can't be used in the site CSS. Use names of letters, digits, spaces, - and _, quoted or not, separated by commas.`);
13838
+ }
13839
+ }
12831
13840
  for (const kind of VARIABLE_KINDS) {
12832
13841
  const items = input.variables?.[kind];
12833
13842
  if (items?.length) {
@@ -12835,6 +13844,13 @@ async function updateSiteStyles(ports, input) {
12835
13844
  changes.push(`${items.length} ${kind}`);
12836
13845
  }
12837
13846
  }
13847
+ const unknown2 = [
13848
+ ...(input.removeVariables ?? []).filter(({ kind, id }) => !(draft.variables[kind] ?? []).some((v) => v.id === id)).map(({ kind, id }) => `${kind} ${id}`),
13849
+ ...(input.removeClasses ?? []).filter((id) => !(draft.classes ?? []).some((c) => c.id === id)).map((id) => `class ${id}`)
13850
+ ];
13851
+ if (unknown2.length > 0) {
13852
+ throw new McpToolError("NOT_FOUND", `Nothing to remove for ${unknown2.join(", ")}. Call get_site_styles for the ids.`);
13853
+ }
12838
13854
  if (!input.force && (input.removeVariables?.length || input.removeClasses?.length)) {
12839
13855
  const layouts = await allLayouts(ports);
12840
13856
  const inUse = [
@@ -12874,12 +13890,36 @@ async function updateSiteStyles(ports, input) {
12874
13890
  draft["direction"] = input.direction;
12875
13891
  changes.push(`direction ${input.direction}`);
12876
13892
  }
13893
+ const clash = (list, touched, what) => {
13894
+ const ids = new Set((touched ?? []).map((item) => item.id));
13895
+ const seen = new Map;
13896
+ for (const item of list ?? []) {
13897
+ const name = item.name;
13898
+ if (typeof name !== "string")
13899
+ continue;
13900
+ const key = nameKey(name);
13901
+ const other = seen.get(key);
13902
+ if (other && (ids.has(item.id) || ids.has(other.id))) {
13903
+ const taken = String(other.name);
13904
+ throw new McpToolError("INVALID_INPUT", `${what} ${item.id} and ${other.id} would both be named "${taken}". Pick another name.`);
13905
+ }
13906
+ if (!other)
13907
+ seen.set(key, item);
13908
+ }
13909
+ };
13910
+ clash(draft.classes, input.classes, "Classes");
13911
+ for (const kind of VARIABLE_KINDS) {
13912
+ clash(draft.variables[kind], input.variables?.[kind], `Variables (${kind})`);
13913
+ }
12877
13914
  if (changes.length === 0)
12878
13915
  refused("Nothing to change.");
12879
13916
  const result = validateDesign(draft);
12880
13917
  if (!result.ok) {
12881
13918
  throw new McpToolError("INVALID_INPUT", `The site styles would be invalid. ${summarizeIssues(result.issues)}`);
12882
13919
  }
13920
+ if (stableJson(result.design) === stableJson(state.design) && state.revision) {
13921
+ return { revision: state.revision, summary: "Nothing changed in the site styles draft" };
13922
+ }
12883
13923
  const saved = await ports.saveDesign(result.design, state.revision);
12884
13924
  const summary = `Site styles draft: ${changes.join(", ")}`;
12885
13925
  await ports.log({ target: "styles", tool: "update_site_styles", summary });
@@ -12931,6 +13971,139 @@ async function publishSiteStyles(ports, input) {
12931
13971
  });
12932
13972
  }
12933
13973
 
13974
+ // ../emvb/src/mcp/sections.ts
13975
+ var SectionId = string2().regex(/^[0-9a-f]{16}$/, "Section ids are 16 hex characters");
13976
+ var portOf = (ports) => {
13977
+ if (!ports.savedSections) {
13978
+ throw new McpToolError("NOT_SET_UP", "Saved sections aren't available on this site.");
13979
+ }
13980
+ return ports.savedSections;
13981
+ };
13982
+ var SectionSummary = object({
13983
+ id: string2(),
13984
+ name: string2(),
13985
+ updatedAt: string2(),
13986
+ classCount: number2(),
13987
+ damaged: literal(true).optional()
13988
+ });
13989
+ var ListSavedSectionsInput = strictObject({});
13990
+ var ListSavedSectionsOutput = object({ sections: array(SectionSummary) });
13991
+ var listSavedSections = async (ports) => ({
13992
+ sections: await portOf(ports).list()
13993
+ });
13994
+ var SaveSectionInput = strictObject({
13995
+ pageId: PageId,
13996
+ elementId: NodeIdInput,
13997
+ name: string2().min(1).max(255)
13998
+ });
13999
+ var SaveSectionOutput = object({
14000
+ id: string2(),
14001
+ name: string2(),
14002
+ summary: string2()
14003
+ });
14004
+ async function saveSection(ports, input) {
14005
+ const port = portOf(ports);
14006
+ const page = await ports.getPage(input.pageId);
14007
+ if (!page) {
14008
+ throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}. Call list_pages.`);
14009
+ }
14010
+ const layout = validateLayout(page.layout);
14011
+ if (!layout.ok) {
14012
+ throw new McpToolError("INVALID_LAYOUT", "The stored layout can't be read. Repair it in the editor.");
14013
+ }
14014
+ const { design } = await ports.getDesign();
14015
+ const now = new Date().toISOString();
14016
+ const snap = snapshotSection(layout.layout, input.elementId, design, input.name, now);
14017
+ if (!snap.ok)
14018
+ throw new McpToolError("REFUSED", snap.reason);
14019
+ const made = await port.create(snap.record);
14020
+ if ("ok" in made)
14021
+ throw new McpToolError("REFUSED", made.reason);
14022
+ const summary = `Saved ${input.elementId} as the section "${snap.record.name}"`;
14023
+ return { id: made.id, name: snap.record.name, summary };
14024
+ }
14025
+ async function sectionOf(port, id) {
14026
+ const found = await port.get(id);
14027
+ if (!found) {
14028
+ throw new McpToolError("NOT_FOUND", `No saved section ${id}. Call list_saved_sections.`);
14029
+ }
14030
+ if ("ok" in found)
14031
+ throw new McpToolError("REFUSED", found.reason);
14032
+ return found;
14033
+ }
14034
+ var InsertSavedSectionInput = strictObject({
14035
+ pageId: PageId,
14036
+ sectionId: SectionId,
14037
+ parentId: NodeIdInput.optional(),
14038
+ index: number2().int().min(0).optional(),
14039
+ expectedRev: Rev.optional()
14040
+ });
14041
+ var InsertSavedSectionOutput = WriteOutput.extend({ classes: string2().nullable() });
14042
+ async function insertSavedSection2(ports, input) {
14043
+ const section = await sectionOf(portOf(ports), input.sectionId);
14044
+ const place = (root) => ({
14045
+ parentId: input.parentId ?? root,
14046
+ index: input.index ?? Number.MAX_SAFE_INTEGER
14047
+ });
14048
+ return queued("styles", async () => {
14049
+ const state = await ports.getDesign();
14050
+ const page = await ports.getPage(input.pageId);
14051
+ if (!page) {
14052
+ throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}. Call list_pages.`);
14053
+ }
14054
+ if (input.expectedRev !== undefined && page.rev !== input.expectedRev) {
14055
+ throw new McpToolError("CONFLICT", "The page changed since you read it. Call get_layout again and retry with its rev.", { rev: page.rev });
14056
+ }
14057
+ const current = validateLayout(page.layout);
14058
+ if (!current.ok) {
14059
+ throw new McpToolError("INVALID_LAYOUT", "The stored layout can't be read. Repair it in the editor.");
14060
+ }
14061
+ const tried = prepareSavedSection(section, current.layout, state.design);
14062
+ if (!tried.ok)
14063
+ throw new McpToolError("REFUSED", tried.reason);
14064
+ const fits = addNode(current.layout, tried.node, place(current.layout.root.id));
14065
+ if (!fits.ok)
14066
+ throw new McpToolError("REFUSED", fits.reason);
14067
+ const merge = mergeSectionClasses(state.design, section.classes);
14068
+ if ("ok" in merge)
14069
+ throw new McpToolError("REFUSED", merge.reason);
14070
+ const notice = classMergeNotice(merge);
14071
+ if (notice) {
14072
+ const checked = validateDesign(merge.design);
14073
+ if (!checked.ok)
14074
+ throw new McpToolError("REFUSED", "The section's classes can't be added.");
14075
+ await ports.saveDesign(checked.design, state.revision);
14076
+ await ports.log({ target: "styles", tool: "insert_saved_section", summary: notice });
14077
+ }
14078
+ const design = merge.design;
14079
+ const result = await mutatePage(ports, "insert_saved_section", input.pageId, input.expectedRev, (layout) => {
14080
+ const prepared = prepareSavedSection(section, layout, design, Math.random, merge);
14081
+ if (!prepared.ok)
14082
+ throw new McpToolError("REFUSED", prepared.reason);
14083
+ const added = addNode(layout, prepared.node, place(layout.root.id));
14084
+ if (!added.ok)
14085
+ throw new McpToolError("REFUSED", added.reason);
14086
+ return {
14087
+ layout: added.layout,
14088
+ changed: [prepared.node.id],
14089
+ summary: `Added the saved section "${section.name}" as ${prepared.node.id}`
14090
+ };
14091
+ });
14092
+ return { ...result, classes: notice };
14093
+ });
14094
+ }
14095
+ var DeleteSavedSectionInput = strictObject({ sectionId: SectionId });
14096
+ var DeleteSavedSectionOutput = object({ id: string2(), summary: string2() });
14097
+ async function deleteSavedSection(ports, input) {
14098
+ if (!await portOf(ports).remove(input.sectionId)) {
14099
+ throw new McpToolError("NOT_FOUND", `No saved section ${input.sectionId}. Call list_saved_sections.`);
14100
+ }
14101
+ return {
14102
+ id: input.sectionId,
14103
+ summary: "Deleted the saved section. Pages that already use a copy keep it."
14104
+ };
14105
+ }
14106
+
12934
14107
  // ../emvb/src/mcp/tools.ts
12935
14108
  var tool = (def) => def;
12936
14109
  var READ_TOOLS = [
@@ -13013,6 +14186,16 @@ var READ_TOOLS = [
13013
14186
  readOnly: true,
13014
14187
  destructive: false,
13015
14188
  run: (ports, input) => listVersions(ports, input)
14189
+ }),
14190
+ tool({
14191
+ name: "list_saved_sections",
14192
+ title: "List saved sections",
14193
+ description: "Lists the site's saved sections (My sections) by id and name, newest first. Insert one with insert_saved_section.",
14194
+ input: ListSavedSectionsInput,
14195
+ output: ListSavedSectionsOutput,
14196
+ readOnly: true,
14197
+ destructive: false,
14198
+ run: (ports) => listSavedSections(ports)
13016
14199
  })
13017
14200
  ];
13018
14201
  var WRITE_TOOLS = [
@@ -13095,6 +14278,36 @@ var WRITE_TOOLS = [
13095
14278
  readOnly: false,
13096
14279
  destructive: false,
13097
14280
  run: (ports, input) => restoreVersion(ports, input)
14281
+ }),
14282
+ tool({
14283
+ name: "save_section",
14284
+ title: "Save an element as a section",
14285
+ description: "Saves a copy of an element and its children, with the classes they use, to My sections under a name. Copies only: synced sections are made in the editor.",
14286
+ input: SaveSectionInput,
14287
+ output: SaveSectionOutput,
14288
+ readOnly: false,
14289
+ destructive: false,
14290
+ run: (ports, input) => saveSection(ports, input)
14291
+ }),
14292
+ tool({
14293
+ name: "insert_saved_section",
14294
+ title: "Insert a saved section",
14295
+ description: "Adds a copy of a saved section at parentId/index (default: end of the page). Classes it uses are added to the site styles draft when missing; a class with the same name but a different look is added as a numbered copy, never overwritten.",
14296
+ input: InsertSavedSectionInput,
14297
+ output: InsertSavedSectionOutput,
14298
+ readOnly: false,
14299
+ destructive: false,
14300
+ run: (ports, input) => insertSavedSection2(ports, input)
14301
+ }),
14302
+ tool({
14303
+ name: "delete_saved_section",
14304
+ title: "Delete a saved section",
14305
+ description: "Removes a section from My sections. Pages that already hold a copy keep it.",
14306
+ input: DeleteSavedSectionInput,
14307
+ output: DeleteSavedSectionOutput,
14308
+ readOnly: false,
14309
+ destructive: true,
14310
+ run: (ports, input) => deleteSavedSection(ports, input)
13098
14311
  })
13099
14312
  ];
13100
14313
  var PUBLISH_TOOLS = [
@@ -13173,7 +14386,7 @@ var PROMPTS = [
13173
14386
  }
13174
14387
  ];
13175
14388
  // src/bridge.ts
13176
- var BRIDGE_VERSION = "0.6.0";
14389
+ var BRIDGE_VERSION = "0.8.0";
13177
14390
  var failure = (message) => ({
13178
14391
  content: [{ type: "text", text: message }],
13179
14392
  isError: true