@reqvire-org/ads 0.5.9 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/ads-errors.mjs +68 -4
  2. package/dist/analysis/owner-source.mjs +16 -2
  3. package/dist/asset-declaration.d.mts +5 -0
  4. package/dist/asset-declaration.mjs +8 -2
  5. package/dist/asset-model.mjs +3 -0
  6. package/dist/construction-output.mjs +36 -7
  7. package/dist/construction-spec.d.mts +109 -10
  8. package/dist/construction-spec.mjs +173 -45
  9. package/dist/end-alignment.mjs +17 -2
  10. package/dist/form-states.mjs +2 -2
  11. package/dist/grid-lowering.mjs +24 -1
  12. package/dist/lowering-layer.mjs +11 -10
  13. package/dist/lowering-overlaps.mjs +5 -3
  14. package/dist/lowering-properties.mjs +13 -1
  15. package/dist/lowering-region-layout.mjs +4 -4
  16. package/dist/lowering-sequence.mjs +6 -2
  17. package/dist/measured-geometry.mjs +15 -3
  18. package/dist/owner-analysis-check.mjs +3 -0
  19. package/dist/owner-errors.mjs +6 -0
  20. package/dist/ownership-model.mjs +34 -9
  21. package/dist/platform-features.mjs +12 -0
  22. package/dist/press-scale.mjs +3 -1
  23. package/dist/profile-macro.d.mts +5 -0
  24. package/dist/profile-view-facts.mjs +1 -1
  25. package/dist/recipe-macro.d.mts +53 -6
  26. package/dist/recipe-model.mjs +8 -5
  27. package/dist/region-lowering.mjs +398 -30
  28. package/dist/role-vocabulary.d.mts +12 -1
  29. package/dist/role-vocabulary.mjs +21 -3
  30. package/dist/skills/ads-designer/references/motion.md +4 -1
  31. package/dist/skills/ads-designer/references/recipes.md +36 -3
  32. package/dist/skills/ads-import/references/recipes.md +36 -3
  33. package/dist/skills/ads-port/references/recipes.md +36 -3
  34. package/dist/spatial-model.mjs +11 -2
  35. package/dist/surface-effects.mjs +25 -6
  36. package/dist/token-dtcg.mjs +2 -1
  37. package/docs/ARCHITECTURE.md +8 -0
  38. package/docs/ASSETS.md +7 -1
  39. package/docs/CHANGELOG.md +143 -18
  40. package/docs/GUIDE.md +9 -0
  41. package/docs/LANGUAGE.md +137 -17
  42. package/docs/MOTION.md +45 -0
  43. package/docs/PROFILE-KINDS.md +32 -5
  44. package/docs/RULES.md +13 -5
  45. package/docs/TOKEN-ROLES.md +9 -2
  46. package/package.json +1 -1
@@ -2,6 +2,7 @@ import { BORDER_STYLE, compositeSlot } from "./role-vocabulary.mjs";
2
2
  import { PART_EFFECTS, normalizedDeclarations, scaleValue } from "./construction-spec.mjs";
3
3
  import {
4
4
  coverArtwork,
5
+ decorationArtwork,
5
6
  HIT_AREA_FIELDS,
6
7
  controlBox,
7
8
  controlBoxValues,
@@ -29,7 +30,7 @@ import {
29
30
  import { settled } from "./lowering-enter.mjs";
30
31
  import { checkPlaceholderContrast, checkProgressContrast } from "./placeholder-contrast.mjs";
31
32
  import { fixedLength, lowerLayer, ownsPlacement } from "./lowering-layer.mjs";
32
- import { RATIO_SUFFIX, focalPosition, intrinsicInlineSize, measuredFallback, measuredProperty, measuredWrites, positions } from "./measured-geometry.mjs";
33
+ import { RATIO_SUFFIX, focalPosition, intrinsicInlineSize, measuredFallback, measuredProperty, measuredRead, measuredWrites, positions } from "./measured-geometry.mjs";
33
34
  import { paintProperty, paintTokens, paintWrites } from "./runtime-paint.mjs";
34
35
  import { conditionBound, conditionQueries, geometryOf, tierBelowQuery } from "./spatial-reading.mjs";
35
36
  import { CORNER_RADIUS_FIELDS, cornerRadius, FRAME_CORNERS } from "./construction-spec.mjs";
@@ -321,7 +322,7 @@ const REDUCED_MOTION_QUERY = ["media", "(prefers-reduced-motion: reduce)"];
321
322
  function measuredMotion(measured, profile, reject) {
322
323
  const groups = new Map;
323
324
  for (const value of measured) {
324
- if (value.type === "position" || value.type === "intrinsic-size" || value.motion === null)
325
+ if (value.type === "position" || value.type === "intrinsic-size" || value.type === "share" || value.motion === null)
325
326
  continue;
326
327
  groups.set(value.motion, [...groups.get(value.motion) ?? [], value.property]);
327
328
  }
@@ -352,17 +353,54 @@ export function contentValue(content) {
352
353
  const value = content.kind === "counter" ? `counter(${content.name}, ${content.style})` : `counters(${content.name}, ${cssString(content.separator)}, ${content.style})`;
353
354
  return [...content.prefix === "" ? [] : [cssString(content.prefix)], value, ...content.suffix === "" ? [] : [cssString(content.suffix)]].join(" ");
354
355
  }
355
- function writeBetween(out, path, between, axis, profile, reject) {
356
+ export function betweenRuleSet(between, profile, reject) {
357
+ const frame = profile.of(between.frame, "frame"), width = frame["border-width"] ?? reject({ kind: "profile-field-missing", profile: between.frame, field: "borderWidth" }), color = profile.of(between.surface, "surface")["border-color"] ?? reject({ kind: "profile-field-missing", profile: between.surface, field: "borderColor" }), style = frame[BORDER_STYLE] ?? "solid";
358
+ return { width, side: (side) => ({ [`border-${side}-width`]: width, [`border-${side}-style`]: style, [`border-${side}-color`]: color }) };
359
+ }
360
+ export function betweenItemRules(out, path, between, axes, items, gaps, clipped, profile, reject, media) {
361
+ const { width, side } = betweenRuleSet(between, profile, reject), back = (gap) => `calc(-1 * max((${gap} + ${width}) / 2, ${width}))`, reach = (axis) => clipped || axes.includes(axis) ? back(axis === "inline" ? gaps.inline : gaps.block) : "0", rule = {
362
+ "inset-inline-start": reach("inline"),
363
+ "inset-block-start": reach("block"),
364
+ ...axes.includes("inline") ? side("inline-start") : {},
365
+ ...axes.includes("block") ? side("block-start") : {}
366
+ }, selector = clipped ? `${path} > ${items}::before` : `${path} > ${items} ~ ${items}::before`;
367
+ if (media !== void 0) {
368
+ out.rule(selector, rule, media);
369
+ return;
370
+ }
371
+ out.rule(clipped ? `${path} > ${items}` : `${path} > ${items} ~ ${items}`, { position: "relative" });
372
+ out.rule(selector, { content: '""', position: "absolute", "pointer-events": "none", "inset-inline-end": "0", "inset-block-end": "0", ...rule });
373
+ }
374
+ function writeBetween(out, path, between, axis, profile, reject, arranged) {
356
375
  if (between === null)
357
376
  return;
377
+ if (between.axes !== null) {
378
+ if (arranged === void 0)
379
+ return reject({ kind: "between-axes-unsupported", element: path, layout: "unknown" });
380
+ return writeBetweenAxes(out, path, between, between.axes, arranged, profile, reject);
381
+ }
358
382
  const frame = profile.of(between.frame, "frame"), width = frame["border-width"] ?? reject({ kind: "profile-field-missing", profile: between.frame, field: "borderWidth" }), color = profile.of(between.surface, "surface")["border-color"] ?? reject({ kind: "profile-field-missing", profile: between.surface, field: "borderColor" }), side = `border-${axis}-start`;
359
383
  out.rule(`${path} > * + *`, { [`${side}-width`]: width, [`${side}-style`]: frame[BORDER_STYLE] ?? "solid", [`${side}-color`]: color });
360
384
  }
385
+ function writeBetweenAxes(out, path, between, axes, host, profile, reject) {
386
+ const layout = host.arrangement?.layout ?? "native", wraps = host.arrangement?.wrap === !0, consecutive = layout === "inline" ? wraps ? null : "inline" : layout === "layered" ? void 0 : "block";
387
+ if (consecutive === void 0)
388
+ return reject({ kind: "between-axes-unsupported", element: path, layout });
389
+ if (consecutive !== null && axes.some((axis) => axis !== consecutive))
390
+ return reject({ kind: "between-axes-unsupported", element: path, layout: `${layout} (${consecutive} axis only)` });
391
+ for (const child of host.children)
392
+ if (child.pseudo.some((treatment) => treatment.pseudo === "before"))
393
+ return reject({ kind: "between-axes-unsupported", element: `${path} > ${child.selector}`, layout: "::before taken" });
394
+ const gap = (axis) => (axis === "inline" ? host.values["column-gap"] : host.values["row-gap"]) ?? host.values.gap ?? "0px", decorations = host.children.filter((child) => child.decoration !== null).map((child) => child.selector), items = decorations.length === 0 ? "*" : `:not(${decorations.join(", ")})`, clipped = consecutive === null;
395
+ if (clipped && host.overflow.kind === "visible")
396
+ out.rule(path, { overflow: "clip" });
397
+ betweenItemRules(out, path, between, axes, items, { inline: gap("inline"), block: gap("block") }, clipped, profile, reject);
398
+ }
361
399
  const ASSISTIVE_ONLY = { position: "absolute", "inline-size": "1px", "block-size": "1px", overflow: "hidden", "clip-path": "inset(50%)", "white-space": "nowrap" }, counterValues = (counter) => counter === null ? {} : { ...counter.reset === null ? {} : { "counter-reset": counter.reset }, ...counter.increment === null ? {} : { "counter-increment": counter.increment } };
362
400
  function writeMarkerStyles(out, styles) {
363
401
  styles.forEach((style, depth) => out.rule(`&${" li &".repeat(depth)}`, { "list-style-type": style }));
364
402
  }
365
- function pseudoRules(name, treatments, path, fills, context, hasBox) {
403
+ function pseudoRules(name, treatments, path, fills, context, hasBox, measured = []) {
366
404
  const { out, profile, reject, foundation } = context;
367
405
  for (const treatment of treatments)
368
406
  switch (treatment.pseudo) {
@@ -399,6 +437,8 @@ function pseudoRules(name, treatments, path, fills, context, hasBox) {
399
437
  paint.background = fields.background;
400
438
  if (fields["border-color"] !== void 0)
401
439
  paint["border-color"] = fields["border-color"];
440
+ if (fields["box-shadow"] !== void 0)
441
+ paint["box-shadow"] = fields["box-shadow"];
402
442
  if (frame["border-width"] !== void 0)
403
443
  Object.assign(paint, { "border-width": frame["border-width"], "border-style": "solid" });
404
444
  else
@@ -407,20 +447,62 @@ function pseudoRules(name, treatments, path, fills, context, hasBox) {
407
447
  if (frame[field] !== void 0)
408
448
  paint[property] = frame[field];
409
449
  return paint;
410
- }, track = treatments.find((item) => item.pseudo === "sliderTrack"), thumb = treatment.pseudo === "sliderThumb", suffixes = thumb ? SLIDER_THUMBS : SLIDER_TRACKS, own = box(treatment, treatment.surface ?? "");
450
+ }, track = treatments.find((item) => item.pseudo === "sliderTrack"), thumb = treatment.pseudo === "sliderThumb", suffixes = thumb ? SLIDER_THUMBS : SLIDER_TRACKS, own = box(treatment, treatment.surface ?? ""), fill = thumb ? void 0 : treatments.find((item) => item.pseudo === "sliderFill"), share = fill === void 0 ? null : sliderShare(name, measured, context), background = (surface) => profile.of(surface, "surface").background ?? "transparent", painted = (fillSurface, trackSurface, side) => {
451
+ const at = `calc(${share} * 100%)`;
452
+ return `linear-gradient(to ${side}, ${background(fillSurface)} 0 ${at}, ${background(trackSurface)} ${at} 100%)`;
453
+ }, fillAt = (condition) => fill?.when.find(([at]) => at === condition)?.[1] ?? fill?.surface ?? "", trackAt = (condition) => treatment.when.find(([at]) => at === condition)?.[1] ?? treatment.surface ?? "";
411
454
  for (const suffix of suffixes) {
412
- out.rule(`${path}${suffix}`, { ...thumb ? { appearance: "none", "-webkit-appearance": "none" } : {}, ...own });
413
- for (const [condition, state] of treatment.when)
414
- if (state !== null)
415
- out.rule(`${under(condition, path)}${suffix}`, box(treatment, state));
455
+ const drawn = fill !== void 0 && share !== null && suffix === "::-webkit-slider-runnable-track";
456
+ out.rule(`${path}${suffix}`, { ...thumb ? { appearance: "none", "-webkit-appearance": "none" } : {}, ...own, ...drawn ? { background: painted(fill.surface ?? "", treatment.surface ?? "", "right") } : {} });
457
+ if (drawn)
458
+ out.rule(`${path}:dir(rtl)${suffix}`, { background: painted(fill.surface ?? "", treatment.surface ?? "", "left") });
459
+ for (const [condition, state] of treatment.when) {
460
+ if (state === null)
461
+ continue;
462
+ out.rule(`${under(condition, path)}${suffix}`, { ...box(treatment, state), ...drawn ? { background: painted(fillAt(condition), state, "right") } : {} });
463
+ if (drawn)
464
+ out.rule(`${under(condition, path)}:dir(rtl)${suffix}`, { background: painted(fillAt(condition), state, "left") });
465
+ }
466
+ if (drawn)
467
+ for (const [condition, state] of fill.when) {
468
+ if (state === null || treatment.when.some(([at]) => at === condition))
469
+ continue;
470
+ out.rule(`${under(condition, path)}${suffix}`, { background: painted(state, trackAt(condition), "right") });
471
+ out.rule(`${under(condition, path)}:dir(rtl)${suffix}`, { background: painted(state, trackAt(condition), "left") });
472
+ }
416
473
  }
417
474
  const thumbBlock = own["block-size"], trackBlock = track === void 0 || track.frame === null || track.frame === void 0 ? void 0 : profile.of(track.frame, "frame", name)["block-size"];
418
475
  if (thumb && thumbBlock !== void 0 && trackBlock !== void 0)
419
476
  out.rule(`${path}::-webkit-slider-thumb`, { "margin-block-start": `calc((${trackBlock} - ${thumbBlock}) / 2)` });
420
477
  if (thumb && track !== void 0 && track.surface !== null) {
421
- const fill = (surface) => profile.of(surface, "surface").background ?? null, paints = (of, base) => [{ condition: null, value: fill(base) }, ...of.when.flatMap(([condition, state]) => state === null ? [] : [{ condition, value: fill(state) }])], checked = checkProgressContrast(foundation, name, paints(treatment, treatment.surface ?? ""), paints(track, track.surface));
478
+ const paintOf = (field) => (surface) => profile.of(surface, "surface")[field] ?? null, paints = (of, base, field) => [{ condition: null, value: paintOf(field)(base) }, ...of.when.flatMap(([condition, state]) => state === null ? [] : [{ condition, value: paintOf(field)(state) }])], trackPaints = paints(track, track.surface, "background"), checked = checkProgressContrast(foundation, name, paints(treatment, treatment.surface ?? "", "background"), trackPaints), ringed = own["border-width"] !== void 0 && paintOf("border-color")(treatment.surface ?? "") !== null, ring = checked.kind === "err" && ringed ? checkProgressContrast(foundation, name, paints(treatment, treatment.surface ?? "", "border-color"), trackPaints) : checked;
479
+ if (ring.kind === "err")
480
+ return reject({ ...checked.kind === "err" ? checked.error : ring.error, subject: "slider-thumb" });
481
+ }
482
+ if (thumb)
483
+ sliderThumbExtras(treatment, path, context);
484
+ break;
485
+ }
486
+ case "sliderFill": {
487
+ const track = treatments.find((item) => item.pseudo === "sliderTrack");
488
+ if (track === void 0)
489
+ return reject({ kind: "slider-fill-unsupported", part: name, reason: "track-missing" });
490
+ if (sliderShare(name, measured, context) === null)
491
+ return;
492
+ const frame = track.frame === null || track.frame === void 0 ? {} : profile.of(track.frame, "frame", name), background = (surface) => profile.of(surface, "surface").background ?? "transparent";
493
+ out.rule(`${path}::-moz-range-progress`, {
494
+ background: background(treatment.surface ?? ""),
495
+ ...frame["block-size"] === void 0 ? {} : { "block-size": frame["block-size"] },
496
+ ...frame.radius === void 0 ? {} : { "border-radius": frame.radius }
497
+ });
498
+ for (const [condition, state] of treatment.when)
499
+ if (state !== null)
500
+ out.rule(`${under(condition, path)}::-moz-range-progress`, { background: background(state) });
501
+ const fillOf = (surface) => profile.of(surface, "surface").background ?? null, paints = (of, base) => [{ condition: null, value: fillOf(base) }, ...of.when.flatMap(([condition, state]) => state === null ? [] : [{ condition, value: fillOf(state) }])];
502
+ if (track.surface !== null) {
503
+ const checked = checkProgressContrast(foundation, name, paints(treatment, treatment.surface ?? ""), paints(track, track.surface));
422
504
  if (checked.kind === "err")
423
- return reject({ ...checked.error, subject: "slider-thumb" });
505
+ return reject(checked.error);
424
506
  }
425
507
  break;
426
508
  }
@@ -438,6 +520,71 @@ function pseudoRules(name, treatments, path, fills, context, hasBox) {
438
520
  }
439
521
  }
440
522
  }
523
+ function sliderShare(name, measured, context) {
524
+ const value = measured.find((item) => item.type === "share" && item.property === "slider-fill");
525
+ if (value === void 0)
526
+ return context.reject({ kind: "slider-fill-unsupported", part: name, reason: "share-missing" });
527
+ return measuredRead(context.input.scope, value, "0");
528
+ }
529
+ function sliderThumbExtras(thumb, path, context) {
530
+ const { out, profile, slots } = context;
531
+ if (thumb.grow !== null && thumb.grow !== void 0) {
532
+ const motion = profile.of(slots["motion-profile"], "motion", "slider-thumb"), scale = scaleValue("scale", profile.field(motion, "motion", thumb.grow));
533
+ for (const suffix of SLIDER_THUMBS) {
534
+ out.rule(`${path}${suffix}`, {
535
+ scale: "1",
536
+ "transition-property": "scale",
537
+ "transition-duration": profile.field(motion, "motion", "duration"),
538
+ "transition-timing-function": profile.field(motion, "motion", "easing")
539
+ });
540
+ out.rule(`${path}:hover:not(:disabled)${suffix}`, { scale });
541
+ out.rule(`${path}:active:not(:disabled)${suffix}`, { scale });
542
+ out.rule(`${path}${suffix}`, { "transition-duration": "0s" }, ["media", "(prefers-reduced-motion: reduce)"]);
543
+ }
544
+ }
545
+ if (slots["focus-profile"] !== void 0) {
546
+ const focus = profile.of(slots["focus-profile"], "focus", "slider-thumb");
547
+ out.rule(`${path}:focus-visible`, { "outline-style": "none" });
548
+ for (const suffix of SLIDER_THUMBS)
549
+ out.rule(`${path}:focus-visible${suffix}`, {
550
+ "outline-width": profile.field(focus, "focus", "width"),
551
+ "outline-color": profile.field(focus, "focus", "color"),
552
+ "outline-offset": profile.field(focus, "focus", "offset"),
553
+ "outline-style": "solid"
554
+ });
555
+ }
556
+ }
557
+ function writeSliderSteps(parts, parent, context) {
558
+ const { out, profile, reject } = context;
559
+ for (const part of parts) {
560
+ if (part.along === null)
561
+ continue;
562
+ const slider = parts.find((other) => other.name === part.along), thumb = slider?.pseudo.find((item) => item.pseudo === "sliderThumb");
563
+ if (slider === void 0 || thumb === void 0)
564
+ return reject({ kind: "slider-steps-unsupported", part: part.name, reason: "slider-missing" });
565
+ const width = thumb.frame === null || thumb.frame === void 0 ? void 0 : profile.of(thumb.frame, "frame", part.name)["inline-size"];
566
+ if (width === void 0)
567
+ return reject({ kind: "slider-steps-unsupported", part: part.name, reason: "thumb-size" });
568
+ const share = part.measured.find((item) => item.type === "share" && item.property === "slider-step");
569
+ if (share === void 0)
570
+ return reject({ kind: "slider-steps-unsupported", part: part.name, reason: "share-missing" });
571
+ if (part.arrangement !== null)
572
+ return reject({ kind: "slider-steps-unsupported", part: part.name, reason: "arranged" });
573
+ const row = `${parent} > ${part.selector}`;
574
+ out.rule(row, { display: "grid", "grid-template-columns": "minmax(0, 1fr)", "margin-inline": `calc(${width} / 2)` });
575
+ for (const label of part.parts)
576
+ out.rule(`${row} > ${label.selector}`, {
577
+ "grid-column": "1",
578
+ "grid-row": "1",
579
+ "justify-self": "start",
580
+ "margin-inline-start": `calc(${measuredRead(context.input.scope, share, "0")} * 100%)`,
581
+ translate: "-50% 0",
582
+ "white-space": "nowrap"
583
+ });
584
+ for (const label of part.parts)
585
+ out.rule(`${row}:dir(rtl) > ${label.selector}`, { translate: "50% 0" });
586
+ }
587
+ }
441
588
  const SLIDER_TRACKS = ["::-webkit-slider-runnable-track", "::-moz-range-track"], SLIDER_THUMBS = ["::-webkit-slider-thumb", "::-moz-range-thumb"], PROGRESS_FILLS = ["::-webkit-progress-value", "::-moz-progress-bar"];
442
589
  function pseudoFill(treatment, surface, profile, reject) {
443
590
  const fields = profile.of(surface, "surface"), other = Object.keys(fields).find((field) => field !== "background");
@@ -454,6 +601,13 @@ function normalizeElement(spec, name, path, values, provided, context) {
454
601
  if (normalized.marker)
455
602
  context.out.rule(`${path}::-webkit-details-marker`, { ...MARKER_HIDDEN });
456
603
  }
604
+ function alignmentValues(alignment) {
605
+ return {
606
+ ...alignment.align === null ? {} : { "align-items": alignment.align },
607
+ ...alignment.justify === null ? {} : { "justify-content": alignment.justify },
608
+ ...alignment.textAlign === null ? {} : { "text-align": alignment.textAlign }
609
+ };
610
+ }
457
611
  function writeConditioned(part, path, values, context) {
458
612
  const { out, profile, slots, foundation, reject } = context, [condition] = part.at;
459
613
  if (condition === void 0) {
@@ -471,6 +625,9 @@ function writeConditioned(part, path, values, context) {
471
625
  out.rule(path, { ...split.inside }, ["media", queries.inside]);
472
626
  if (Object.keys(split.outside).length > 0)
473
627
  out.rule(path, { ...split.outside }, ["media", queries.outside]);
628
+ const aligned = alignmentValues(condition.alignment);
629
+ if (Object.keys(aligned).length > 0)
630
+ out.rule(path, aligned, ["media", queries.inside]);
474
631
  }
475
632
  function lowerVector(part, stroke, path, context) {
476
633
  const { out, profile, slots, reject } = context;
@@ -483,6 +640,8 @@ function lowerVector(part, stroke, path, context) {
483
640
  writeConditioned(part, path, {}, context);
484
641
  }
485
642
  function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overlapping = null, stateGaps = [], parentWraps = !1) {
643
+ writeAnchoredLabels(parts, parent, context);
644
+ writeSliderSteps(parts, parent, context);
486
645
  for (const part of parts) {
487
646
  const source = part.focusOf === null ? void 0 : parts.find((other) => other.name === part.focusOf);
488
647
  if (source === void 0)
@@ -585,6 +744,153 @@ function writePartSpace(parts, parent, layout, gap, context, carry = !1) {
585
744
  out.rule(`&:not(:last-child):has(> ${part.selector}:last-child)`, { "margin-block-end": `max(0px, calc(${after} - var(${FLOW_GAP}, 0px)))` });
586
745
  }
587
746
  }
747
+ const ORIGIN_VALUES = {
748
+ center: null,
749
+ "inline-start": ["left center", "right center"],
750
+ "inline-end": ["right center", "left center"],
751
+ "block-start": ["center top", "center top"],
752
+ "block-end": ["center bottom", "center bottom"]
753
+ };
754
+ function writeOrigin(out, path, origin) {
755
+ const values = ORIGIN_VALUES[origin];
756
+ if (values === null)
757
+ return;
758
+ const [ltr, rtl] = values;
759
+ out.rule(path, { "transform-origin": ltr });
760
+ if (rtl !== ltr)
761
+ out.rule(`${path}:dir(rtl)`, { "transform-origin": rtl });
762
+ }
763
+ const SAFE_AREA_PHYSICAL = {
764
+ "block-start": ["top", "top"],
765
+ "block-end": ["bottom", "bottom"],
766
+ "inline-start": ["left", "right"],
767
+ "inline-end": ["right", "left"]
768
+ };
769
+ function safeAreaPadding(values, sides, path, out) {
770
+ for (const side of sides) {
771
+ const property = `padding-${side}`, base = values[property] ?? "0px", [ltr, rtl] = SAFE_AREA_PHYSICAL[side];
772
+ values[property] = `calc(${base} + env(safe-area-inset-${ltr}, 0px))`;
773
+ if (rtl !== ltr)
774
+ out.rule(`${path}:dir(rtl)`, { [property]: `calc(${base} + env(safe-area-inset-${rtl}, 0px))` });
775
+ }
776
+ }
777
+ const decorationHost = (values) => ({ ...values.position === void 0 ? { position: "relative" } : {}, isolation: "isolate" });
778
+ function lowerDecorationArt(path, context, art, partName) {
779
+ const { out, profile, slots, reject } = context;
780
+ if (art.kind === "content-media") {
781
+ const fit = slots["visual-profile"] !== void 0 && !covers(profile.of(slots["visual-profile"], "visual")) ? "contain" : "cover";
782
+ out.rule(`${path} > *`, { display: "block", "inline-size": "100%", "block-size": "100%", "object-fit": fit });
783
+ return;
784
+ }
785
+ if (art.kind !== "asset")
786
+ return reject({ kind: "artwork-binding-missing" });
787
+ const reference = art.visualProfile ?? slots["visual-profile"], visualProfile = reference === void 0 ? {} : profile.of(reference, "visual", "visual"), cover = reference === void 0 || covers(visualProfile), placed = decorationArtwork(art.asset, visualProfile, art.state, art.theme, reject), [, , width, height] = placed.drawing.box, ratio = width / height, pick = cover ? "max" : "min", [offsetX, offsetY] = placed.drawing.center, centerX = 0.5 + offsetX, centerY = 0.5 + offsetY;
788
+ out.rule(`${path} > ${placed.element}`, {
789
+ display: "block",
790
+ position: "absolute",
791
+ "inset-inline-start": `${(centerX * 100).toFixed(3)}%`,
792
+ "inset-block-start": `${(centerY * 100).toFixed(3)}%`,
793
+ translate: `${(-centerX * 100).toFixed(3)}% ${(-centerY * 100).toFixed(3)}%`,
794
+ "inline-size": `${pick}(100cqw, calc(100cqh * ${ratio.toFixed(6)}))`,
795
+ "block-size": `${pick}(100cqh, calc(100cqw / ${ratio.toFixed(6)}))`,
796
+ "max-inline-size": "none"
797
+ });
798
+ if (art.asset.paint === "slots")
799
+ out.paint(path.replace(/^& > /, ""), [...art.asset.slots].map(([slot, value]) => ({ slot, paint: value === "currentColor" ? { kind: "current-color" } : { kind: "token", name: value } })));
800
+ context.placedArtwork.push(placed);
801
+ context.placedByPart.set(partName, placed);
802
+ }
803
+ function stageOf(parts, context) {
804
+ const anchored = parts.filter((part) => part.anchor !== null), [first] = anchored;
805
+ if (first?.anchor === null || first === void 0)
806
+ return null;
807
+ if (new Set(anchored.map((part) => part.anchor?.artwork)).size > 1)
808
+ return context.reject({ kind: "text-anchor-unsupported", part: anchored[1]?.name ?? first.name, reason: "several" });
809
+ const artwork = parts.find((part) => part.name === first.anchor?.artwork && part.decoration !== null), art = artwork === void 0 ? null : context.input.visuals?.get(artwork.name) ?? null, [drawing] = art !== null && art.kind === "asset" ? art.asset.drawings : [];
810
+ if (drawing === void 0)
811
+ return context.reject({ kind: "text-anchor-unsupported", part: first.name, reason: "artwork" });
812
+ return drawing.box;
813
+ }
814
+ function stageValues(parts, values, context) {
815
+ const box = stageOf(parts, context);
816
+ if (box === null)
817
+ return {};
818
+ if (values["aspect-ratio"] !== void 0 || values["block-size"] !== void 0)
819
+ return context.reject({ kind: "text-anchor-unsupported", part: parts.find((part) => part.anchor !== null)?.name ?? "", reason: "sized" });
820
+ return { "aspect-ratio": `${box[2]} / ${box[3]}` };
821
+ }
822
+ function writeAnchoredLabels(parts, parent, context) {
823
+ const box = stageOf(parts, context);
824
+ if (box === null)
825
+ return;
826
+ const [bx, by, bw, bh] = box, shift = { start: "0%", center: "-50%", end: "-100%" };
827
+ for (const part of parts) {
828
+ if (part.anchor === null)
829
+ continue;
830
+ context.out.rule(`${parent} > ${part.selector}`, {
831
+ position: "absolute",
832
+ left: `${((part.anchor.x - bx) / bw * 100).toFixed(4)}%`,
833
+ top: `${((part.anchor.y - by) / bh * 100).toFixed(4)}%`,
834
+ translate: `${shift[part.anchor.inline]} ${shift[part.anchor.block]}`,
835
+ "white-space": "nowrap"
836
+ });
837
+ }
838
+ }
839
+ function anchorOffsets(reference, measured, profile, reject) {
840
+ if (reference === void 0)
841
+ return measured;
842
+ const fields = profile.of(reference, "layer"), block = ((out, back) => {
843
+ if (fields[out] !== void 0 && fields[back] !== void 0)
844
+ return reject({ kind: "profile-provider-conflict", field: out, providers: [out, back] });
845
+ return fields[out] !== void 0 ? profile.field(fields, "layer", out) : fields[back] !== void 0 ? `calc(-1 * ${profile.field(fields, "layer", back)})` : null;
846
+ })("anchor-gap", "anchor-overlap"), outdent = fields["anchor-outdent"] !== void 0 ? `calc(-1 * ${profile.field(fields, "layer", "anchor-outdent")})` : null, inline = outdent !== null && fields["anchor-indent"] !== void 0 ? reject({ kind: "profile-provider-conflict", field: "anchor-outdent", providers: ["anchor-outdent", "anchor-indent"] }) : outdent ?? (fields["anchor-indent"] !== void 0 ? profile.field(fields, "layer", "anchor-indent") : null);
847
+ if (block === null && inline === null)
848
+ return measured;
849
+ const plus = (value, offset) => offset === null ? value : `calc(${value} + ${offset})`, moved = {};
850
+ for (const [property, value] of Object.entries(measured))
851
+ if (/^inset-block-(start|end)$/.test(property))
852
+ moved[property] = plus(value, block);
853
+ else if (/^inset-inline-(start|end)$/.test(property))
854
+ moved[property] = plus(value, inline);
855
+ else if (property === "translate") {
856
+ let depth = 0, cut = -1;
857
+ for (let index = 0;index < value.length; index += 1) {
858
+ const character = value[index];
859
+ if (character === "(")
860
+ depth += 1;
861
+ else if (character === ")")
862
+ depth -= 1;
863
+ else if (character === " " && depth === 0) {
864
+ cut = index;
865
+ break;
866
+ }
867
+ }
868
+ const [x, y] = cut < 0 ? [value, "0px"] : [value.slice(0, cut), value.slice(cut + 1).trim()];
869
+ moved[property] = `${plus(x, inline)} ${plus(y, block)}`;
870
+ } else
871
+ moved[property] = value;
872
+ return moved;
873
+ }
874
+ const DRAWN_SHAPES = /<(path|line|polyline|polygon|circle|ellipse|rect)\b[^>]*>/g;
875
+ function lowerArtworkGroups(part, path, context) {
876
+ const { out, profile, reject } = context, art = context.input.visuals?.get(part.name) ?? null, declared = art !== null && art.kind === "asset" && art.asset.paint !== "intrinsic" && art.kind === "asset" ? art.asset.spec.groups ?? [] : [];
877
+ for (const group of part.groups) {
878
+ if (!declared.includes(group.name))
879
+ return reject({ kind: "artwork-group-unknown", part: part.name, group: group.name, groups: declared });
880
+ const selector = `${path} > svg [data-group="${group.name}"]`;
881
+ out.rule(selector, { "transform-box": "fill-box", "transform-origin": "center" });
882
+ if (group.plays.some((play) => {
883
+ const selected = profile.select(play.sequence);
884
+ return selected.kind === "sequence" && [...selected.clauses].some(([key, values]) => key.startsWith("ads-step") && values.has("draw"));
885
+ }) && art !== null && art.kind === "asset")
886
+ for (const drawing of art.asset.drawings) {
887
+ const start = drawing.text.search(new RegExp(`<[a-z]+\\b[^>]*\\bdata-group="${group.name}"`)), end = (drawing.text.slice(start).match(/^<([a-z]+)/)?.[1] ?? "") === "g" ? drawing.text.indexOf("</g>", start) : drawing.text.indexOf(">", start) + 1, shapes = [...drawing.text.slice(start, end).matchAll(DRAWN_SHAPES)].map((match) => match[0]);
888
+ if (shapes.length === 0 || shapes.some((shape) => !/\bpathLength="1"/.test(shape)))
889
+ return reject({ kind: "artwork-group-draw-length", part: part.name, group: group.name });
890
+ }
891
+ writePlays(out, profile, context.foundation, `${part.name} [${group.name}]`, group.plays, selector, [], reject);
892
+ }
893
+ }
588
894
  const BLOCK_EDGE = /^(padding|border)-(block|top|bottom)(-start|-end)?(-width)?$/, framedBlock = (values) => Object.entries(values).some(([property, value]) => BLOCK_EDGE.test(property) && (property.startsWith("padding") || property.endsWith("-width")) && !/^0(px)?$/.test(String(value).trim()));
589
895
  function trimFlowEdges(parts, parent, context) {
590
896
  if (!parts.some((part) => ownSpace(part, "before", context) !== null || ownSpace(part, "after", context) !== null))
@@ -602,6 +908,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
602
908
  if (part.content.kind === "component") {
603
909
  const placed = checked(extentValues(part.extent, parentLayout, part.name, parentGrows, parentWraps && keepsWords(part)), reject);
604
910
  writeConditioned(part, path, { ...placed, ...parentLayout === "native" ? flowSpace(part, context) : {} }, context);
911
+ writeOrigin(context.out, path, part.origin);
605
912
  return null;
606
913
  }
607
914
  const partSurface = part.surface === null ? {} : profile.of(part.surface, "surface"), moving = partMotion(path, part.effects, context), collapsible = part.collapsed || part.geometryWhen.some((state) => state.collapsed !== null), axis = parentLayout === "inline" ? "inline" : parentLayout === "stack" ? "block" : null;
@@ -640,6 +947,11 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
640
947
  transitionRules(path, part.paintTransition, part.surface === null ? null : { name: part.surface, fields: partSurface }, part.when, context, entering === null ? partGroups : [...partGroups, entering.group]);
641
948
  writePlays(out, profile, context.foundation, part.name, part.plays, path, [...transitioned(part.paintTransition, entering === null ? [] : [entering.group]), ...moved], reject);
642
949
  const values = part.arrangement === null ? {} : { "box-sizing": "border-box", "min-inline-size": "0", ...arrangementValues(part.arrangement, slots, profile, part.overflow) };
950
+ if (parentLayout === "native" && part.arrangement?.layout === "inline" && Object.keys(flowSpace(part, context)).length > 0) {
951
+ values.display = "flex";
952
+ if (part.extent.kind !== "fill")
953
+ values["inline-size"] = "fit-content";
954
+ }
643
955
  if (collapsible && axis !== null)
644
956
  Object.assign(values, collapsibleValues(axis), collapsedValues(part.collapsed, axis));
645
957
  if (part.arrangement?.layout === "layered")
@@ -653,9 +965,19 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
653
965
  if (part.surface !== null)
654
966
  Object.assign(values, settled(partSurface, entering?.blurred ?? !1));
655
967
  Object.assign(values, stickyValues(part.sticky, context), anchorClearValues(part.anchorClear, context));
656
- const boxFields = part.box === null ? {} : frameValues(profile.of(part.box, "frame"), profile, reject);
968
+ const [partCondition] = part.at, boxChange = partCondition?.frame ?? null, boxFrame = (border, corners) => part.box === null ? {} : regionFrameValues({ kind: "fields", container: !1, ratio: null, border, corners, safeArea: [] }, { ...slots, "frame-profile": part.box }, part.surface, profile, reject).values, restCorners = boxChange?.corners === null || boxChange === null ? part.boxCorners : part.boxCorners ?? FRAME_CORNERS, boxFields = boxFrame(part.boxBorder, restCorners);
969
+ if (part.box !== null && boxChange !== null && partCondition !== void 0) {
970
+ const spatial = slots["spatial-profile"], bound = spatial === void 0 ? null : conditionBound(context.foundation, spatial, partCondition.condition, profile, reject);
971
+ if (bound === null)
972
+ return reject({ kind: "condition-unknown", part: part.name, condition: partCondition.condition, spatial: spatial ?? null });
973
+ const held = boxFrame(boxChange.border ?? part.boxBorder, boxChange.corners ?? restCorners), changed = Object.fromEntries(Object.entries(held).filter(([property, value]) => boxFields[property] !== value));
974
+ if (Object.keys(changed).length > 0)
975
+ out.rule(path, changed, ["media", conditionQueries(bound).inside]);
976
+ }
657
977
  if (part.box !== null)
658
978
  Object.assign(values, { "box-sizing": "border-box" }, boxFields);
979
+ if (part.box !== null)
980
+ writeHitArea(out, path, hitAreaOf(profile.of(part.box, "frame")));
659
981
  let target = null, frameFields = {};
660
982
  if (part.frame !== null) {
661
983
  const lineText = text["line-height"] === void 0 && slots["text-profile"] !== void 0 ? profile.of(slots["text-profile"], "text") : text, lineHeight = profile.field(lineText, "text", "line-height"), frame = profile.of(slots["frame-profile"], "frame", "control"), box = controlBox(frame, LINE_BOX, profile.field, reject);
@@ -696,9 +1018,23 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
696
1018
  if (snapped !== null)
697
1019
  add(snapped.container, "snap");
698
1020
  add(checked(extentValues(part.extent, parentLayout, part.name, parentGrows, parentWraps && keepsWords(part) && values["min-inline-size"] === void 0), reject), "extent");
699
- if (parentLayout === "layered")
1021
+ if (parentLayout === "layered" && part.decoration === null)
700
1022
  add(LAYER, "layer");
701
- if (part.outset !== null) {
1023
+ if (part.parts.some((child) => child.decoration !== null))
1024
+ add(decorationHost(values), "decoration");
1025
+ add(stageValues(part.parts, values, context), "anchor");
1026
+ if (part.decoration !== null) {
1027
+ const spacing = (binding) => binding === null || binding === void 0 ? "0" : `calc(-1 * ${profile.field(profile.of(slots["spacing-profile"], "spacing", "outset"), "spacing", kebab(binding.field))})`, block = spacing(part.outset?.block), inline = spacing(part.outset?.inline), art = context.input.visuals?.get(part.name) ?? null;
1028
+ add({
1029
+ position: part.decoration.attachment === "fixed" ? "fixed" : "absolute",
1030
+ "inset-block": block,
1031
+ "inset-inline": inline,
1032
+ "z-index": "-1",
1033
+ "pointer-events": "none",
1034
+ overflow: "clip",
1035
+ ...art !== null && art.kind === "asset" ? { "container-type": "size" } : {}
1036
+ }, "decoration");
1037
+ } else if (part.outset !== null) {
702
1038
  if (parentLayout !== "layered" || part.parts.length > 0 || part.content.kind === "text")
703
1039
  return reject({ kind: "outset-unsupported", part: part.name });
704
1040
  const spacing = (binding) => binding === null ? null : profile.field(profile.of(slots["spacing-profile"], "spacing", "outset"), "spacing", kebab(binding.field)), [block, inline] = [spacing(part.outset.block), spacing(part.outset.inline)], share = (value) => context.foundation.tokens.get(/^var\(\s*(--[\w-]+)\s*\)$/.exec(value)?.[1] ?? "")?.role === "box-share", outset = (axis, value) => value === null ? {} : axis === "block" && share(value) ? { "block-size": `calc(100% + 2 * ${value})`, "align-self": "center" } : { [`margin-${axis}`]: `calc(-1 * ${value})` };
@@ -720,15 +1056,22 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
720
1056
  if (Object.keys(reset).length > 0)
721
1057
  out.rule(path, reset);
722
1058
  }
723
- const media = part.measured.some((value) => value.type === "position" || value.type === "intrinsic-size") && part.content.kind === "visual" && visualOf(context.input, part.name)?.kind === "content-media" ? covers(profile.of(slots["visual-profile"], "visual", "visual")) ? "cover" : "contain" : null;
724
- Object.assign(values, checked(measuredWrites(context.input.scope, part.measured, part.name, values, part.frame !== null ? supplied(slots, frameFields) : null, media), reject));
1059
+ const unrendered = part.content.kind === "visual" && (!part.required || context.withinOptional === !0) && visualOf(context.input, part.name) === null, imageValue = (value) => value.type === "position" || value.type === "intrinsic-size", measured = unrendered ? part.measured.filter((value) => !imageValue(value)) : part.measured, media = measured.some(imageValue) && part.content.kind === "visual" && visualOf(context.input, part.name)?.kind === "content-media" ? covers(profile.of(slots["visual-profile"], "visual", "visual")) ? "cover" : "contain" : null;
1060
+ Object.assign(values, checked(measuredWrites(context.input.scope, measured, part.name, values, part.frame !== null ? supplied(slots, frameFields) : null, media, { fill: part.pseudo.some((item) => item.pseudo === "sliderFill"), steps: part.along !== null }), reject));
725
1061
  Object.assign(values, paintValues(part.name, part.paints, "box", [part.surface], part.when, context));
1062
+ safeAreaPadding(values, part.safeArea, path, out);
726
1063
  writeConditioned(part, path, values, context);
1064
+ writeOrigin(out, path, part.origin);
727
1065
  const conditioned = conditionedVisual(part, context), schemed = visualOf(context.input, part.name)?.kind;
728
- if (part.scheme !== null && schemed !== "content-media" && schemed !== "asset")
1066
+ if (part.scheme !== null && !unrendered && schemed !== "content-media" && schemed !== "asset")
729
1067
  return reject({ kind: "scheme-unsupported", part: part.name });
730
- const unrendered = part.content.kind === "visual" && (!part.required || context.withinOptional === !0) && visualOf(context.input, part.name) === null;
731
- if (part.content.kind === "visual" && !unrendered)
1068
+ if (part.groups.length > 0)
1069
+ lowerArtworkGroups(part, path, context);
1070
+ if (part.decoration !== null) {
1071
+ const art = context.input.visuals?.get(part.name) ?? null;
1072
+ if (art !== null)
1073
+ lowerDecorationArt(path, context, art, part.name);
1074
+ } else if (part.content.kind === "visual" && !unrendered)
732
1075
  lowerVisual(path, context, part.measured.find((value) => value.type === "intrinsic-size") ?? null, conditioned, part.scheme, boxFields, part.name);
733
1076
  if (snapped !== null)
734
1077
  out.rule(`${path} > *`, { ...snapped.children });
@@ -737,11 +1080,11 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
737
1080
  out.rule(under(condition, path), normalizedDeclarations(normalized));
738
1081
  {
739
1082
  const background = (surface) => surface === null ? null : profile.of(surface, "surface").background ?? null, fills = [{ condition: null, value: background(part.surface) }, ...part.when.map(([condition, surface]) => ({ condition, value: background(surface) }))];
740
- pseudoRules(part.name, part.pseudo, path, fills, context, part.box !== null);
1083
+ pseudoRules(part.name, part.pseudo, path, fills, context, part.box !== null, part.measured);
741
1084
  const counted = counterValues(part.counter);
742
1085
  if (Object.keys(counted).length > 0)
743
1086
  out.rule(path, counted);
744
- writeBetween(out, path, part.between, part.arrangement?.layout === "inline" ? "inline" : "block", profile, reject);
1087
+ writeBetween(out, path, part.between, part.arrangement?.layout === "inline" ? "inline" : "block", profile, reject, { arrangement: part.arrangement, values, overflow: part.overflow, children: part.parts });
745
1088
  if (part.presence === "assistive")
746
1089
  out.rule(path, { ...ASSISTIVE_ONLY });
747
1090
  }
@@ -840,7 +1183,12 @@ function layerInput(layer, spec, root, slots, profile, foundation, reject) {
840
1183
  const placing = spec.normalizeWhen.flatMap(([, values]) => values.map(([property]) => property)).find(ownsPlacement);
841
1184
  if (placing !== void 0)
842
1185
  return reject({ kind: "layer-frame-position", property: placing });
843
- const motion = layer.motion === null ? null : transitionTiming(profile.of(slots["motion-profile"], "motion", "layer"), profile, reject);
1186
+ const motion = layer.motion === null ? null : transitionTiming(profile.of(slots["motion-profile"], "motion", "layer"), profile, reject), drop = () => {
1187
+ if (layer.kind === "modal-sheet" || layer.motion !== "drop")
1188
+ return null;
1189
+ const fields = profile.of(slots["motion-profile"], "motion", "layer");
1190
+ return { distance: profile.field(fields, "motion", "distance"), scale: profile.field(fields, "motion", "scale") };
1191
+ };
844
1192
  switch (layer.kind) {
845
1193
  case "modal-sheet":
846
1194
  sheetQuery(layer, slots, profile, foundation, reject);
@@ -848,10 +1196,10 @@ function layerInput(layer, spec, root, slots, profile, foundation, reject) {
848
1196
  return { kind: "modal-sheet", sheet: layer, backdrop: { name: layer.backdrop.surface, fields: profile.of(layer.backdrop.surface, "surface") }, root, motion, margin };
849
1197
  case "measured-popover": {
850
1198
  const fields = profile.of(slots["layer-profile"], "layer", "layer");
851
- profile.only(fields, "layer", ["clear-block-start", "edge-gap", "viewport-margin"]);
1199
+ profile.only(fields, "layer", ["clear-block-start", "edge-gap", "viewport-margin", "anchor-gap", "anchor-overlap", "anchor-outdent", "anchor-indent"]);
852
1200
  if (!spec.measured.some((value) => positions(value.property)))
853
1201
  return reject({ kind: "measured-placement-missing" });
854
- return { kind: "measured-popover", popover: layer, viewportMargin: profile.field(fields, "layer", "viewport-margin"), root, motion };
1202
+ return { kind: "measured-popover", popover: layer, viewportMargin: profile.field(fields, "layer", "viewport-margin"), root, motion, drop: drop() };
855
1203
  }
856
1204
  case "anchored-popover": {
857
1205
  const fields = profile.of(slots["layer-profile"], "layer", "layer");
@@ -864,7 +1212,7 @@ function layerInput(layer, spec, root, slots, profile, foundation, reject) {
864
1212
  clear = value;
865
1213
  }
866
1214
  const placement = { edgeGap: profile.field(fields, "layer", "edge-gap"), viewportMargin: profile.field(fields, "layer", "viewport-margin"), clear };
867
- return { kind: "anchored-popover", popover: layer, placement, root, motion };
1215
+ return { kind: "anchored-popover", popover: layer, placement, root, motion, drop: drop() };
868
1216
  }
869
1217
  }
870
1218
  }
@@ -926,12 +1274,17 @@ export function lowerRegion(spec, foundation, input) {
926
1274
  transitionRules("&", spec.paintTransition, surface === null ? null : { name: surface, fields: rootSurface }, spec.when, context, entering === null ? rootGroups : [...rootGroups, entering.group]);
927
1275
  writePlays(out, profile, foundation, "&", spec.plays, "&", transitioned(spec.paintTransition, entering === null ? rootGroups : [...rootGroups, entering.group]), reject);
928
1276
  const rootFill = (name) => name === null ? null : profile.of(name, "surface").background ?? null;
929
- pseudoRules("&", spec.pseudo, "&", [{ condition: null, value: rootFill(surface) }, ...spec.when.map(([condition, name]) => ({ condition, value: rootFill(name) }))], context, spec.frame !== null);
1277
+ pseudoRules("&", spec.pseudo, "&", [{ condition: null, value: rootFill(surface) }, ...spec.when.map(([condition, name]) => ({ condition, value: rootFill(name) }))], context, spec.frame !== null, spec.measured);
930
1278
  const rootCounters = counterValues(spec.counter);
931
1279
  if (Object.keys(rootCounters).length > 0)
932
1280
  out.rule("&", rootCounters);
933
1281
  writeMarkerStyles(out, spec.markers);
934
- writeBetween(out, "&", spec.between, spec.arrangement.layout === "inline" ? "inline" : "block", profile, reject);
1282
+ writeBetween(out, "&", spec.between, spec.arrangement.layout === "inline" ? "inline" : "block", profile, reject, {
1283
+ arrangement: spec.arrangement,
1284
+ values: spec.arrangement.layout === "native" ? {} : arrangementValues(spec.arrangement, slots, profile, spec.overflow),
1285
+ overflow: spec.overflow,
1286
+ children: spec.parts
1287
+ });
935
1288
  const { arrangement } = spec, values = arrangement.layout !== "native" || spec.frame !== null ? { "box-sizing": "border-box", "min-inline-size": "0" } : {};
936
1289
  let exposed = null;
937
1290
  if (spec.exposeRows.length > 0) {
@@ -951,7 +1304,16 @@ export function lowerRegion(spec, foundation, input) {
951
1304
  const framed = spec.frame === null || spec.frameAt === null || spec.frameAt.corners === null ? spec.frame : { ...spec.frame, corners: spec.frame.corners ?? FRAME_CORNERS }, rootFrame = framed === null ? null : regionFrameValues(framed, slots, surface, profile, reject);
952
1305
  if (rootFrame !== null)
953
1306
  Object.assign(values, rootFrame.values);
954
- if (framed !== null && rootFrame !== null && spec.frameAt !== null) {
1307
+ if (spec.frameAt !== null) {
1308
+ const aligned = alignmentValues(spec.frameAt.alignment);
1309
+ if (Object.keys(aligned).length > 0) {
1310
+ const spatial = slots["spatial-profile"], bound = spatial === void 0 ? null : conditionBound(foundation, spatial, spec.frameAt.condition, profile, reject);
1311
+ if (bound === null)
1312
+ return reject({ kind: "condition-unknown", part: "&", condition: spec.frameAt.condition, spatial: spatial ?? null });
1313
+ out.rule("&", aligned, ["media", conditionQueries(bound).inside]);
1314
+ }
1315
+ }
1316
+ if (framed !== null && rootFrame !== null && spec.frameAt !== null && (spec.frameAt.border !== null || spec.frameAt.corners !== null)) {
955
1317
  const { condition, border, corners } = spec.frameAt, spatial = slots["spatial-profile"], bound = spatial === void 0 ? null : conditionBound(foundation, spatial, condition, profile, reject);
956
1318
  if (bound === null)
957
1319
  return reject({ kind: "condition-unknown", part: "&", condition, spatial: spatial ?? null });
@@ -1005,14 +1367,19 @@ export function lowerRegion(spec, foundation, input) {
1005
1367
  const placing = layer.kind === "measured-popover" ? void 0 : spec.measured.find((value) => positions(value.property));
1006
1368
  if (placing !== void 0)
1007
1369
  return reject({ kind: "measured-property-unsupported", element: "&", name: placing.name, property: placing.property, type: placing.type, reason: "layer-placement" });
1008
- const measured = checked(measuredWrites(input.scope, spec.measured, "&", layered.value.root, frameSupplied), reject);
1370
+ const measured = anchorOffsets(layer.kind === "measured-popover" ? slots["layer-profile"] : void 0, checked(measuredWrites(input.scope, spec.measured, "&", layered.value.root, frameSupplied), reject), profile, reject);
1009
1371
  out.rule("&", { ...layered.value.root, ...measured, ...rootPaints });
1010
1372
  for (const rule of layered.value.rules)
1011
1373
  out.rule(rule.selector, { ...rule.values }, rule.condition ?? void 0);
1012
1374
  for (const rule of layered.value.documents)
1013
1375
  out.document(rule);
1014
1376
  } else {
1015
- Object.assign(values, stickyValues(spec.sticky, context), anchorClearValues(spec.anchorClear, context), checked(measuredWrites(input.scope, spec.measured, "&", values, frameSupplied), reject), rootPaints);
1377
+ Object.assign(values, stickyValues(spec.sticky, context), anchorClearValues(spec.anchorClear, context), checked(measuredWrites(input.scope, spec.measured, "&", values, frameSupplied, null, { fill: spec.pseudo.some((item) => item.pseudo === "sliderFill"), steps: !1 }), reject), rootPaints);
1378
+ if (spec.parts.some((part) => part.decoration !== null))
1379
+ Object.assign(values, decorationHost(values));
1380
+ Object.assign(values, stageValues(spec.parts, values, context));
1381
+ if (spec.frame !== null)
1382
+ safeAreaPadding(values, spec.frame.safeArea, "&", out);
1016
1383
  if (Object.keys(values).length > 0)
1017
1384
  out.rule("&", { ...settled(values, entering?.blurred ?? !1) });
1018
1385
  if (spec.normalize.length > 0)
@@ -1024,6 +1391,7 @@ export function lowerRegion(spec, foundation, input) {
1024
1391
  }
1025
1392
  writeHitArea(out, "&", rootHitArea);
1026
1393
  }
1394
+ writeOrigin(out, "&", spec.origin);
1027
1395
  if (rootSnap !== null)
1028
1396
  out.rule("& > *", { ...rootSnap.children });
1029
1397
  for (const [selector, normalized] of spec.normalizeWhen)