@styleflow.app/flowpress-astro-core 1.0.0-beta.4 → 1.0.0-beta.41

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 (317) hide show
  1. package/CHANGELOG.md +249 -1
  2. package/README.md +104 -5
  3. package/dist/accessibility-panel.d.ts +2 -0
  4. package/dist/accessibility-panel.d.ts.map +1 -0
  5. package/dist/accessibility-panel.js +81 -0
  6. package/dist/accessibility-panel.js.map +1 -0
  7. package/dist/astro/BaseLayout.astro +34 -17
  8. package/dist/astro/CompositionRenderer.astro +168 -0
  9. package/dist/astro/DefaultBlockAdapter.astro +37 -0
  10. package/dist/astro/FontStylesheets.astro +35 -0
  11. package/dist/astro/GutenbergRenderer.astro +267 -80
  12. package/dist/astro/Media.astro +27 -0
  13. package/dist/astro/StyleflowElement.astro +25 -0
  14. package/dist/astro/ThemeRuntime.astro +26 -0
  15. package/dist/astro/blocks/CarouselBlock.astro +11 -10
  16. package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
  17. package/dist/astro/blocks/ColumnBlock.astro +4 -5
  18. package/dist/astro/blocks/CoverBlock.astro +158 -0
  19. package/dist/astro/blocks/FormBlock.astro +23 -20
  20. package/dist/astro/blocks/GridBlock.astro +5 -4
  21. package/dist/astro/blocks/HeroBlock.astro +6 -6
  22. package/dist/astro/blocks/ImageBlock.astro +6 -6
  23. package/dist/astro/blocks/ListItemFallback.astro +9 -7
  24. package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
  25. package/dist/astro/blocks/SemanticElement.astro +35 -0
  26. package/dist/astro/blocks/SiteLogoBlock.astro +54 -0
  27. package/dist/astro/blocks/TextBlock.astro +33 -28
  28. package/dist/astro/blocks/ThemeToggleBlock.astro +13 -0
  29. package/dist/astro/blocks/cover.d.ts +13 -0
  30. package/dist/astro/blocks/cover.d.ts.map +1 -0
  31. package/dist/astro/blocks/cover.js +105 -0
  32. package/dist/astro/blocks/cover.js.map +1 -0
  33. package/dist/astro/blocks/cover.ts +119 -0
  34. package/dist/astro/blocks/helpers.d.ts +10 -1
  35. package/dist/astro/blocks/helpers.d.ts.map +1 -1
  36. package/dist/astro/blocks/helpers.js +55 -39
  37. package/dist/astro/blocks/helpers.js.map +1 -1
  38. package/dist/astro/blocks/helpers.ts +69 -44
  39. package/dist/astro/motion/AccordionRuntime.astro +9 -0
  40. package/dist/astro/motion/MotionBoot.astro +21 -0
  41. package/dist/astro/motion/MotionRuntime.astro +31 -0
  42. package/dist/astro/motion/accordion.css +163 -0
  43. package/dist/astro/motion/accordion.d.ts +3 -0
  44. package/dist/astro/motion/accordion.d.ts.map +1 -0
  45. package/dist/astro/motion/accordion.js +98 -0
  46. package/dist/astro/motion/accordion.js.map +1 -0
  47. package/dist/astro/motion/accordion.ts +109 -0
  48. package/dist/astro/motion/motion-controller.d.ts +12 -0
  49. package/dist/astro/motion/motion-controller.d.ts.map +1 -0
  50. package/dist/astro/motion/motion-controller.js +293 -0
  51. package/dist/astro/motion/motion-controller.js.map +1 -0
  52. package/dist/astro/motion/motion-controller.ts +377 -0
  53. package/dist/astro/motion/motion.css +546 -0
  54. package/dist/astro/motion/motion.d.ts +127 -0
  55. package/dist/astro/motion/motion.d.ts.map +1 -0
  56. package/dist/astro/motion/motion.js +255 -0
  57. package/dist/astro/motion/motion.js.map +1 -0
  58. package/dist/astro/motion/motion.ts +419 -0
  59. package/dist/astro/native/Blob.astro +113 -0
  60. package/dist/astro/native/BlobBlock.astro +52 -0
  61. package/dist/astro/native/CustomFieldValue.astro +88 -0
  62. package/dist/astro/native/LevelTag.astro +20 -0
  63. package/dist/astro/native/MapBlock.astro +41 -0
  64. package/dist/astro/native/NativeHtmlBlock.astro +12 -0
  65. package/dist/astro/native/NativeIconBlock.astro +42 -0
  66. package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
  67. package/dist/astro/native/ReservedLogin.astro +107 -0
  68. package/dist/astro/native/ResolvedBlocks.astro +91 -0
  69. package/dist/astro/native/SyncedPatternContent.astro +94 -0
  70. package/dist/astro/native/TermFieldValue.astro +39 -0
  71. package/dist/astro/native/Timeline.astro +22 -0
  72. package/dist/astro/native/TimelineCardBlock.astro +7 -0
  73. package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
  74. package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
  75. package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
  76. package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
  77. package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
  78. package/dist/astro/native/blob/config.d.ts +49 -0
  79. package/dist/astro/native/blob/config.d.ts.map +1 -0
  80. package/dist/astro/native/blob/config.js +86 -0
  81. package/dist/astro/native/blob/config.js.map +1 -0
  82. package/dist/astro/native/blob/config.ts +132 -0
  83. package/dist/astro/native/blob/controller.d.ts +11 -0
  84. package/dist/astro/native/blob/controller.d.ts.map +1 -0
  85. package/dist/astro/native/blob/controller.js +240 -0
  86. package/dist/astro/native/blob/controller.js.map +1 -0
  87. package/dist/astro/native/blob/controller.ts +248 -0
  88. package/dist/astro/native/blob/geometry.d.ts +2 -0
  89. package/dist/astro/native/blob/geometry.d.ts.map +1 -0
  90. package/dist/astro/native/blob/geometry.js +2 -0
  91. package/dist/astro/native/blob/geometry.js.map +1 -0
  92. package/dist/astro/native/blob/geometry.ts +1 -0
  93. package/dist/astro/native/blob/ids.d.ts +7 -0
  94. package/dist/astro/native/blob/ids.d.ts.map +1 -0
  95. package/dist/astro/native/blob/ids.js +11 -0
  96. package/dist/astro/native/blob/ids.js.map +1 -0
  97. package/dist/astro/native/blob/ids.ts +11 -0
  98. package/dist/astro/native/blob.css +83 -0
  99. package/dist/astro/native/block-sizing.css +34 -0
  100. package/dist/astro/native/button-template.d.ts +31 -0
  101. package/dist/astro/native/button-template.d.ts.map +1 -0
  102. package/dist/astro/native/button-template.js +54 -0
  103. package/dist/astro/native/button-template.js.map +1 -0
  104. package/dist/astro/native/button-template.ts +92 -0
  105. package/dist/astro/native/button.d.ts +13 -0
  106. package/dist/astro/native/button.d.ts.map +1 -0
  107. package/dist/astro/native/button.js +26 -0
  108. package/dist/astro/native/button.js.map +1 -0
  109. package/dist/astro/native/button.ts +26 -0
  110. package/dist/astro/native/core-block.astro +18 -0
  111. package/dist/astro/native/core-button-fallback.astro +43 -0
  112. package/dist/astro/native/core-button.astro +65 -0
  113. package/dist/astro/native/core-buttons.astro +14 -0
  114. package/dist/astro/native/core-group.astro +25 -0
  115. package/dist/astro/native/core-home-link.astro +12 -0
  116. package/dist/astro/native/core-html.astro +8 -0
  117. package/dist/astro/native/core-icon.astro +7 -0
  118. package/dist/astro/native/core-image.astro +137 -0
  119. package/dist/astro/native/core-navigation-link.astro +71 -0
  120. package/dist/astro/native/core-navigation-submenu.astro +33 -0
  121. package/dist/astro/native/core-navigation.astro +101 -0
  122. package/dist/astro/native/core-page-list-data-item.astro +19 -0
  123. package/dist/astro/native/core-page-list-item.astro +8 -0
  124. package/dist/astro/native/core-page-list.astro +40 -0
  125. package/dist/astro/native/core-post-date.astro +21 -0
  126. package/dist/astro/native/core-post-excerpt.astro +26 -0
  127. package/dist/astro/native/core-post-featured-image.astro +40 -0
  128. package/dist/astro/native/core-post-template-fallback.astro +30 -0
  129. package/dist/astro/native/core-post-template.astro +23 -0
  130. package/dist/astro/native/core-post-terms.astro +47 -0
  131. package/dist/astro/native/core-post-title.astro +23 -0
  132. package/dist/astro/native/core-query-no-results.astro +12 -0
  133. package/dist/astro/native/core-query.astro +22 -0
  134. package/dist/astro/native/core-separator.astro +18 -0
  135. package/dist/astro/native/core-site-title.astro +16 -0
  136. package/dist/astro/native/core-term-description.astro +12 -0
  137. package/dist/astro/native/core-term-name.astro +21 -0
  138. package/dist/astro/native/core-term-template.astro +30 -0
  139. package/dist/astro/native/core-terms-query.astro +19 -0
  140. package/dist/astro/native/core-transparent.astro +11 -0
  141. package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
  142. package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
  143. package/dist/astro/native/flowpress-navigation-controller.js +217 -0
  144. package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
  145. package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
  146. package/dist/astro/native/flowpress-navigation.css +17 -0
  147. package/dist/astro/native/grid-bleed.d.ts +2 -0
  148. package/dist/astro/native/grid-bleed.d.ts.map +1 -0
  149. package/dist/astro/native/grid-bleed.js +123 -0
  150. package/dist/astro/native/grid-bleed.js.map +1 -0
  151. package/dist/astro/native/grid.css +180 -0
  152. package/dist/astro/native/grid.d.ts +17 -0
  153. package/dist/astro/native/grid.d.ts.map +1 -0
  154. package/dist/astro/native/grid.js +103 -0
  155. package/dist/astro/native/grid.js.map +1 -0
  156. package/dist/astro/native/grid.ts +118 -0
  157. package/dist/astro/native/group.css +36 -0
  158. package/dist/astro/native/group.d.ts +15 -0
  159. package/dist/astro/native/group.d.ts.map +1 -0
  160. package/dist/astro/native/group.js +66 -0
  161. package/dist/astro/native/group.js.map +1 -0
  162. package/dist/astro/native/group.ts +61 -0
  163. package/dist/astro/native/html.d.ts +6 -0
  164. package/dist/astro/native/html.d.ts.map +1 -0
  165. package/dist/astro/native/html.js +10 -0
  166. package/dist/astro/native/html.js.map +1 -0
  167. package/dist/astro/native/html.ts +9 -0
  168. package/dist/astro/native/icon.d.ts +3 -0
  169. package/dist/astro/native/icon.d.ts.map +1 -0
  170. package/dist/astro/native/icon.js +23 -0
  171. package/dist/astro/native/icon.js.map +1 -0
  172. package/dist/astro/native/icon.ts +21 -0
  173. package/dist/astro/native/image.d.ts +5 -0
  174. package/dist/astro/native/image.d.ts.map +1 -0
  175. package/dist/astro/native/image.js +65 -0
  176. package/dist/astro/native/image.js.map +1 -0
  177. package/dist/astro/native/image.ts +56 -0
  178. package/dist/astro/native/inline-text.css +15 -0
  179. package/dist/astro/native/map.d.ts +14 -0
  180. package/dist/astro/native/map.d.ts.map +1 -0
  181. package/dist/astro/native/map.js +60 -0
  182. package/dist/astro/native/map.js.map +1 -0
  183. package/dist/astro/native/map.ts +70 -0
  184. package/dist/astro/native/motion-preference.d.ts +50 -0
  185. package/dist/astro/native/motion-preference.d.ts.map +1 -0
  186. package/dist/astro/native/motion-preference.js +132 -0
  187. package/dist/astro/native/motion-preference.js.map +1 -0
  188. package/dist/astro/native/motion-preference.ts +158 -0
  189. package/dist/astro/native/motion.d.ts +101 -0
  190. package/dist/astro/native/motion.d.ts.map +1 -0
  191. package/dist/astro/native/motion.js +168 -0
  192. package/dist/astro/native/motion.js.map +1 -0
  193. package/dist/astro/native/motion.ts +312 -0
  194. package/dist/astro/native/query-carousel.d.ts +12 -0
  195. package/dist/astro/native/query-carousel.d.ts.map +1 -0
  196. package/dist/astro/native/query-carousel.js +36 -0
  197. package/dist/astro/native/query-carousel.js.map +1 -0
  198. package/dist/astro/native/query-carousel.ts +56 -0
  199. package/dist/astro/native/query-loop.d.ts +38 -0
  200. package/dist/astro/native/query-loop.d.ts.map +1 -0
  201. package/dist/astro/native/query-loop.js +20 -0
  202. package/dist/astro/native/query-loop.js.map +1 -0
  203. package/dist/astro/native/query-loop.ts +67 -0
  204. package/dist/astro/native/registry.d.ts +3 -0
  205. package/dist/astro/native/registry.d.ts.map +1 -0
  206. package/dist/astro/native/registry.js +81 -0
  207. package/dist/astro/native/registry.js.map +1 -0
  208. package/dist/astro/native/registry.ts +82 -0
  209. package/dist/astro/native/sf-block-binding.astro +20 -0
  210. package/dist/astro/native/sf-post-field.astro +9 -0
  211. package/dist/astro/native/sf-term-field.astro +9 -0
  212. package/dist/astro/native/timeline.css +4 -0
  213. package/dist/astro/native/timeline.d.ts +28 -0
  214. package/dist/astro/native/timeline.d.ts.map +1 -0
  215. package/dist/astro/native/timeline.js +43 -0
  216. package/dist/astro/native/timeline.js.map +1 -0
  217. package/dist/astro/native/timeline.ts +79 -0
  218. package/dist/astro/preferences/AccessibilityPanel.astro +105 -0
  219. package/dist/astro/preferences/ColorModeToggle.astro +26 -0
  220. package/dist/astro/preferences/MotionToggle.astro +27 -0
  221. package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
  222. package/dist/astro/preferences/ThemeToggle.astro +30 -0
  223. package/dist/astro/preferences/Toggle.astro +50 -0
  224. package/dist/astro/preferences/preferences.css +125 -0
  225. package/dist/block-renderers.d.ts +23 -3
  226. package/dist/block-renderers.d.ts.map +1 -1
  227. package/dist/block-renderers.js.map +1 -1
  228. package/dist/build-cache.d.ts +8 -0
  229. package/dist/build-cache.d.ts.map +1 -0
  230. package/dist/build-cache.js +81 -0
  231. package/dist/build-cache.js.map +1 -0
  232. package/dist/client.d.ts +23 -2
  233. package/dist/client.d.ts.map +1 -1
  234. package/dist/client.js +78 -39
  235. package/dist/client.js.map +1 -1
  236. package/dist/composition.d.ts +14 -0
  237. package/dist/composition.d.ts.map +1 -0
  238. package/dist/composition.js +125 -0
  239. package/dist/composition.js.map +1 -0
  240. package/dist/default-blocks.d.ts +9 -0
  241. package/dist/default-blocks.d.ts.map +1 -0
  242. package/dist/default-blocks.js +117 -0
  243. package/dist/default-blocks.js.map +1 -0
  244. package/dist/env.d.ts +9 -0
  245. package/dist/env.d.ts.map +1 -1
  246. package/dist/env.js +20 -0
  247. package/dist/env.js.map +1 -1
  248. package/dist/index.d.ts +7 -0
  249. package/dist/index.d.ts.map +1 -1
  250. package/dist/index.js +6 -0
  251. package/dist/index.js.map +1 -1
  252. package/dist/media.d.ts +20 -0
  253. package/dist/media.d.ts.map +1 -0
  254. package/dist/media.js +106 -0
  255. package/dist/media.js.map +1 -0
  256. package/dist/motion-preference.d.ts +50 -0
  257. package/dist/motion-preference.d.ts.map +1 -0
  258. package/dist/motion-preference.js +132 -0
  259. package/dist/motion-preference.js.map +1 -0
  260. package/dist/preferences-runtime.d.ts +3 -0
  261. package/dist/preferences-runtime.d.ts.map +1 -0
  262. package/dist/preferences-runtime.js +23 -0
  263. package/dist/preferences-runtime.js.map +1 -0
  264. package/dist/preferences-styleflow.d.ts +3 -0
  265. package/dist/preferences-styleflow.d.ts.map +1 -0
  266. package/dist/preferences-styleflow.js +14 -0
  267. package/dist/preferences-styleflow.js.map +1 -0
  268. package/dist/preferences.d.ts +4 -0
  269. package/dist/preferences.d.ts.map +1 -0
  270. package/dist/preferences.js +4 -0
  271. package/dist/preferences.js.map +1 -0
  272. package/dist/reserved-area.d.ts +10 -0
  273. package/dist/reserved-area.d.ts.map +1 -0
  274. package/dist/reserved-area.js +93 -0
  275. package/dist/reserved-area.js.map +1 -0
  276. package/dist/styleflow.d.ts +18 -1
  277. package/dist/styleflow.d.ts.map +1 -1
  278. package/dist/styleflow.js +82 -11
  279. package/dist/styleflow.js.map +1 -1
  280. package/dist/svg-media-runtime.d.ts +3 -0
  281. package/dist/svg-media-runtime.d.ts.map +1 -0
  282. package/dist/svg-media-runtime.js +33 -0
  283. package/dist/svg-media-runtime.js.map +1 -0
  284. package/dist/svg-media-types.d.ts +11 -0
  285. package/dist/svg-media-types.d.ts.map +1 -0
  286. package/dist/svg-media-types.js +2 -0
  287. package/dist/svg-media-types.js.map +1 -0
  288. package/dist/svg-media.d.ts +13 -0
  289. package/dist/svg-media.d.ts.map +1 -0
  290. package/dist/svg-media.js +47 -0
  291. package/dist/svg-media.js.map +1 -0
  292. package/dist/template-hierarchy.d.ts +0 -7
  293. package/dist/template-hierarchy.d.ts.map +1 -1
  294. package/dist/template-hierarchy.js +0 -21
  295. package/dist/template-hierarchy.js.map +1 -1
  296. package/dist/text.d.ts +3 -0
  297. package/dist/text.d.ts.map +1 -0
  298. package/dist/text.js +6 -0
  299. package/dist/text.js.map +1 -0
  300. package/dist/theme-runtime.d.ts +16 -0
  301. package/dist/theme-runtime.d.ts.map +1 -0
  302. package/dist/theme-runtime.js +100 -0
  303. package/dist/theme-runtime.js.map +1 -0
  304. package/dist/tsconfig.tsbuildinfo +1 -1
  305. package/dist/types.d.ts +75 -1
  306. package/dist/types.d.ts.map +1 -1
  307. package/dist/types.js.map +1 -1
  308. package/dist/vivid-colors-preference.d.ts +31 -0
  309. package/dist/vivid-colors-preference.d.ts.map +1 -0
  310. package/dist/vivid-colors-preference.js +102 -0
  311. package/dist/vivid-colors-preference.js.map +1 -0
  312. package/package.json +58 -7
  313. package/dist/astro/DefaultTemplate.astro +0 -42
  314. package/dist/templates.d.ts +0 -19
  315. package/dist/templates.d.ts.map +0 -1
  316. package/dist/templates.js +0 -20
  317. package/dist/templates.js.map +0 -1
@@ -0,0 +1,255 @@
1
+ export const SF_REVEAL_SELECTOR = ".sf-reveal:not(.sf-motion-static)";
2
+ export const SF_REVEAL_CLASS = "sf-reveal";
3
+ export const SF_MOTION_STATIC_CLASS = "sf-motion-static";
4
+ export const SF_MOTION_DISABLE_CLASS = "sf-motion-disable";
5
+ export const SF_MOTION_DRAWER_EXIT_MS = 820;
6
+ export const SF_REVEAL_VISIBLE_RATIO = 0.2;
7
+ export const SF_REVEAL_STAGGER_SELECTOR = ".sf-reveal-stagger";
8
+ export const SF_REVEAL_STAGGER_STEP_MS = 90;
9
+ export const SF_REVEAL_STAGGER_MAX_MS = 450;
10
+ /** Reveals matching or containing this content always start visible. */
11
+ export const SF_MOTION_PROTECTED_CONTENT_SELECTOR = [
12
+ ".flowpress-hero",
13
+ 'img[fetchpriority="high"]',
14
+ 'img[loading="eager"]',
15
+ "video[autoplay]",
16
+ "form",
17
+ "[aria-live]",
18
+ '[role="alert"]',
19
+ '[role="status"]',
20
+ ].join(",");
21
+ const SF_REVEAL_MODIFIER_PATTERN = /^sf-reveal--\S+$/;
22
+ export function isSfRevealModifier(value) {
23
+ return typeof value === "string" && SF_REVEAL_MODIFIER_PATTERN.test(value);
24
+ }
25
+ function normalizeSelectors(value) {
26
+ if (!Array.isArray(value))
27
+ return [];
28
+ return Array.from(new Set(value
29
+ .filter((selector) => typeof selector === "string")
30
+ .map((selector) => selector.trim())
31
+ .filter(Boolean)));
32
+ }
33
+ function normalizeRevealRules(value) {
34
+ if (!Array.isArray(value))
35
+ return [];
36
+ const seenSelectors = new Set();
37
+ return value.flatMap((rule) => {
38
+ if (!rule || typeof rule !== "object")
39
+ return [];
40
+ const candidate = rule;
41
+ const selector = typeof candidate.selector === "string" ? candidate.selector.trim() : "";
42
+ if (!selector ||
43
+ seenSelectors.has(selector) ||
44
+ !isSfRevealModifier(candidate.reveal)) {
45
+ return [];
46
+ }
47
+ seenSelectors.add(selector);
48
+ return [{ selector, reveal: candidate.reveal }];
49
+ });
50
+ }
51
+ /**
52
+ * Normalizes server- or client-provided configuration. Invalid values fail
53
+ * open by disabling automatic reveals; empty and duplicate selectors are
54
+ * removed without changing their order.
55
+ */
56
+ export function resolveSfMotionOptions(options = {}) {
57
+ const defaultReveal = isSfRevealModifier(options.defaultReveal)
58
+ ? options.defaultReveal
59
+ : false;
60
+ return {
61
+ autoRevealSelectors: normalizeSelectors(options.autoRevealSelectors),
62
+ defaultReveal,
63
+ revealAboveFold: options.revealAboveFold === true,
64
+ revealRules: normalizeRevealRules(options.revealRules),
65
+ };
66
+ }
67
+ /** Exact class mutation required by an authoritative selector rule. */
68
+ export function ruleRevealClassChanges(existingClasses, reveal) {
69
+ const classes = Array.from(existingClasses);
70
+ if (classes.includes(SF_MOTION_STATIC_CLASS) ||
71
+ classes.includes(SF_MOTION_DISABLE_CLASS)) {
72
+ return { add: [], remove: [] };
73
+ }
74
+ return {
75
+ add: [
76
+ ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),
77
+ ...(classes.includes(reveal) ? [] : [reveal]),
78
+ ],
79
+ remove: classes
80
+ .filter(isSfRevealModifier)
81
+ .filter((modifier) => modifier !== reveal),
82
+ };
83
+ }
84
+ /** Delay for a zero-based participant index in a reveal stagger group. */
85
+ export function staggerRevealDelayMs(index) {
86
+ if (!Number.isFinite(index) || index <= 0)
87
+ return 0;
88
+ return Math.min(Math.floor(index) * SF_REVEAL_STAGGER_STEP_MS, SF_REVEAL_STAGGER_MAX_MS);
89
+ }
90
+ /**
91
+ * Returns only the classes that automatic inheritance must add. Explicit
92
+ * modifiers win over the configured default and `sf-motion-static` remains a
93
+ * complete opt-out.
94
+ */
95
+ export function automaticRevealClasses(existingClasses, defaultReveal) {
96
+ if (defaultReveal === false)
97
+ return [];
98
+ const classes = Array.from(existingClasses);
99
+ if (classes.includes(SF_MOTION_STATIC_CLASS) ||
100
+ classes.includes(SF_MOTION_DISABLE_CLASS)) {
101
+ return [];
102
+ }
103
+ return [
104
+ ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),
105
+ ...(classes.some(isSfRevealModifier) ? [] : [defaultReveal]),
106
+ ];
107
+ }
108
+ function cssTimeToMs(value) {
109
+ const normalized = value.trim();
110
+ const amount = Number.parseFloat(normalized);
111
+ if (!Number.isFinite(amount))
112
+ return 0;
113
+ return normalized.endsWith("ms") ? amount : amount * 1000;
114
+ }
115
+ /** Returns the longest combined CSS transition duration and delay. */
116
+ export function maximumTransitionTimeMs(transitionDuration, transitionDelay) {
117
+ const durations = transitionDuration.split(",").map(cssTimeToMs);
118
+ const delays = transitionDelay.split(",").map(cssTimeToMs);
119
+ const itemCount = Math.max(durations.length, delays.length);
120
+ return Array.from({ length: itemCount }, (_, index) => {
121
+ const duration = durations[index % durations.length] ?? 0;
122
+ const delay = delays[index % delays.length] ?? 0;
123
+ return Math.max(0, duration + delay);
124
+ }).reduce((maximum, value) => Math.max(maximum, value), 0);
125
+ }
126
+ /**
127
+ * Initial viewport content stays static unless the project explicitly enables
128
+ * above-the-fold reveals. Deep links and protected content remain visible.
129
+ */
130
+ export function initialRevealState({ bottom, containsHashTarget, protectedContent, reducedMotion, revealAboveFold, top, viewportHeight, }) {
131
+ if (reducedMotion ||
132
+ containsHashTarget ||
133
+ protectedContent) {
134
+ return "visible";
135
+ }
136
+ // reveal share of its height) waits for the scroll instead of appearing
137
+ // statically; content already scrolled past the top stays visible.
138
+ if (!revealAboveFold &&
139
+ bottom > 0 &&
140
+ top < viewportHeight &&
141
+ (top < 0 ||
142
+ hasEnoughVisibleArea({
143
+ bottom,
144
+ height: Math.max(0, bottom - top),
145
+ top,
146
+ viewportHeight,
147
+ }))) {
148
+ return "visible";
149
+ }
150
+ return "pending";
151
+ }
152
+ /**
153
+ * Reveal ordinary content once 20% of its perceivable height is visible.
154
+ * For elements taller than the viewport, the viewport height is the reference.
155
+ */
156
+ export function hasEnoughVisibleArea({ bottom, height, top, viewportHeight, }) {
157
+ if (height <= 0 || viewportHeight <= 0)
158
+ return true;
159
+ const visibleHeight = Math.max(0, Math.min(bottom, viewportHeight) - Math.max(top, 0));
160
+ // The 1px tolerance below must not let thin elements such as a 1px <hr>
161
+ // pass while they are still entirely outside the viewport.
162
+ if (visibleHeight <= 0)
163
+ return false;
164
+ const requiredHeight = Math.min(height, viewportHeight) * SF_REVEAL_VISIBLE_RATIO;
165
+ return visibleHeight + 1 >= requiredHeight;
166
+ }
167
+ /**
168
+ * Reveal is deliberately one-way: focus and viewport entry can complete it,
169
+ * while leaving the viewport never conceals content again.
170
+ */
171
+ export function nextRevealState(current, event) {
172
+ if (current === "settled")
173
+ return "settled";
174
+ if (current === "visible" || event === "focus" || event === "intersect") {
175
+ return "visible";
176
+ }
177
+ return "pending";
178
+ }
179
+ export function shouldInitializeMotion(initialized) {
180
+ return initialized !== "true";
181
+ }
182
+ /** `<html data-sf-motion>` value from the head bootstrap until the controller arms. */
183
+ export const SF_MOTION_BOOT_STATE = "boot";
184
+ /** Failsafe: boot-hidden content shows anyway if the controller never arms. */
185
+ export const SF_MOTION_BOOT_FAILSAFE_MS = 3000;
186
+ /**
187
+ * Modifiers whose pending state keeps the element visible and hides only a
188
+ * drawn decoration, mapped to the pseudo-element carrying it.
189
+ */
190
+ export const SF_REVEAL_DECORATION_PSEUDOS = {
191
+ "sf-reveal--accordion-line": "::after",
192
+ };
193
+ // Everything the controller leaves visible: opt-outs, protected content and the hash target.
194
+ // :has() makes :not() invalid where unsupported, which drops the rule: content stays visible.
195
+ const SF_MOTION_BOOT_EXCLUDED = [
196
+ `.${SF_MOTION_STATIC_CLASS}`,
197
+ `.${SF_MOTION_DISABLE_CLASS}`,
198
+ `.${SF_MOTION_DISABLE_CLASS} *`,
199
+ SF_MOTION_PROTECTED_CONTENT_SELECTOR,
200
+ `:has(${SF_MOTION_PROTECTED_CONTENT_SELECTOR})`,
201
+ ":target",
202
+ ":has(:target)",
203
+ ].join(", ");
204
+ /**
205
+ * Inline `<head>` script, placed after the motion preference bootstrap: marks
206
+ * the document as booting when the controller will arm reveals, so the CSS of
207
+ * `motionBootCss` hides them before first paint.
208
+ */
209
+ export function motionBootScript(preferenceAttribute) {
210
+ const attribute = JSON.stringify(preferenceAttribute);
211
+ const state = JSON.stringify(SF_MOTION_BOOT_STATE);
212
+ return `(()=>{const r=document.documentElement;if(r.getAttribute(${attribute})==="full"&&"IntersectionObserver"in window&&!r.dataset.sfMotion)r.dataset.sfMotion=${state}})()`;
213
+ }
214
+ /**
215
+ * Pre-paint counterpart of the controller for `revealAboveFold`: hides what the
216
+ * controller will arm (authored reveals, rule and automatic selectors) while
217
+ * `<html data-sf-motion="boot">`, so content is never painted, hidden, then
218
+ * revealed. Each selector gets its own rule: an invalid one only drops itself.
219
+ * Like the controller, the first matching rule decides the modifier.
220
+ * Portabile in FlowPress: docs/pilots/primo-paint-stabile.md
221
+ */
222
+ export function motionBootCss(options = {}) {
223
+ const { autoRevealSelectors, defaultReveal, revealAboveFold, revealRules } = resolveSfMotionOptions(options);
224
+ if (!revealAboveFold)
225
+ return "";
226
+ const root = `html[data-sf-motion="${SF_MOTION_BOOT_STATE}"]`;
227
+ const failsafe = `${SF_MOTION_BOOT_FAILSAFE_MS}ms`;
228
+ const decorations = Object.entries(SF_REVEAL_DECORATION_PSEUDOS);
229
+ const hide = (target, reveal) => {
230
+ const pseudo = reveal ? (SF_REVEAL_DECORATION_PSEUDOS[reveal] ?? "") : "";
231
+ return `${root} ${target}${pseudo}{opacity:0;animation:sf-motion-boot-failsafe 0s linear ${failsafe} forwards}`;
232
+ };
233
+ const rules = [];
234
+ // Authored reveals keep their own modifier; decorations hide their pseudo.
235
+ const decorationClasses = decorations.map(([modifier]) => `.${modifier}`);
236
+ rules.push(hide(`.${SF_REVEAL_CLASS}:not(${[SF_MOTION_BOOT_EXCLUDED, ...decorationClasses].join(", ")})`, null));
237
+ decorations.forEach(([modifier]) => {
238
+ rules.push(hide(`.${SF_REVEAL_CLASS}.${modifier}:not(${SF_MOTION_BOOT_EXCLUDED})`, modifier));
239
+ });
240
+ const earlier = [];
241
+ revealRules.forEach(({ selector, reveal }) => {
242
+ const shadowed = earlier.length ? `, :is(${earlier.join(", ")})` : "";
243
+ rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, reveal));
244
+ earlier.push(selector);
245
+ });
246
+ if (defaultReveal !== false) {
247
+ const shadowed = earlier.length ? `, :is(${earlier.join(", ")})` : "";
248
+ autoRevealSelectors.forEach((selector) => {
249
+ rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, defaultReveal));
250
+ });
251
+ }
252
+ rules.push("@keyframes sf-motion-boot-failsafe{to{opacity:1}}");
253
+ return rules.join("\n");
254
+ }
255
+ //# sourceMappingURL=motion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion.js","sourceRoot":"","sources":["../../../src/astro/motion/motion.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,mCAAmC,CAAC;AAEtE,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAE3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAE/D,MAAM,CAAC,MAAM,yBAA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AM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,QAAQ,SAAS,uBAAuB,GAAG,QAAQ,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;QACxF,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,IAAI,aAAa,KAAK,KAAK,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,mBAAmB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACvC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,QAAQ,SAAS,uBAAuB,GAAG,QAAQ,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC;QACjG,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IAChE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["export const SF_REVEAL_SELECTOR = \".sf-reveal:not(.sf-motion-static)\";\n\nexport const SF_REVEAL_CLASS = \"sf-reveal\";\n\nexport const SF_MOTION_STATIC_CLASS = \"sf-motion-static\";\n\nexport const SF_MOTION_DISABLE_CLASS = \"sf-motion-disable\";\n\nexport const SF_MOTION_DRAWER_EXIT_MS = 820;\n\nexport const SF_REVEAL_VISIBLE_RATIO = 0.2;\n\nexport const SF_REVEAL_STAGGER_SELECTOR = \".sf-reveal-stagger\";\n\nexport const SF_REVEAL_STAGGER_STEP_MS = 90;\n\nexport const SF_REVEAL_STAGGER_MAX_MS = 450;\n\n/** Reveals matching or containing this content always start visible. */\nexport const SF_MOTION_PROTECTED_CONTENT_SELECTOR = [\n \".flowpress-hero\",\n 'img[fetchpriority=\"high\"]',\n 'img[loading=\"eager\"]',\n \"video[autoplay]\",\n \"form\",\n \"[aria-live]\",\n '[role=\"alert\"]',\n '[role=\"status\"]',\n].join(\",\");\n\nconst SF_REVEAL_MODIFIER_PATTERN = /^sf-reveal--\\S+$/;\n\nexport type SfRevealModifier = `sf-reveal--${string}`;\n\nexport type SfDefaultReveal = false | SfRevealModifier;\n\nexport interface SfRevealRule {\n /** Any selector accepted by `document.querySelectorAll`. */\n selector: string;\n /** Reveal modifier enforced on every matching element. */\n reveal: SfRevealModifier;\n}\n\nexport interface SfRevealClassChanges {\n add: string[];\n remove: SfRevealModifier[];\n}\n\nexport interface SfMotionOptions {\n /**\n * Allows reveal elements already in the initial viewport to animate.\n * Defaults to `false`, so initial content is immediately available.\n */\n revealAboveFold?: boolean;\n /**\n * Ordered selector-specific reveal rules. The first matching rule wins and\n * enforces its modifier. Any valid CSS selector may be used.\n */\n revealRules?: readonly SfRevealRule[];\n /**\n * Preset applied to automatically selected elements. `false` keeps the\n * reveal system strictly opt-in.\n */\n defaultReveal?: SfDefaultReveal;\n /**\n * Standard CSS selectors. Tags, classes, IDs, attributes and combinations\n * can be mixed in the same array.\n */\n autoRevealSelectors?: readonly string[];\n}\n\nexport interface ResolvedSfMotionOptions {\n autoRevealSelectors: string[];\n defaultReveal: SfDefaultReveal;\n revealAboveFold: boolean;\n revealRules: SfRevealRule[];\n}\n\nexport type SfRevealState = \"pending\" | \"visible\" | \"settled\";\n\nexport interface InitialRevealStateInput {\n bottom: number;\n containsHashTarget: boolean;\n protectedContent: boolean;\n reducedMotion: boolean;\n revealAboveFold: boolean;\n top: number;\n viewportHeight: number;\n}\n\nexport interface RevealVisibilityInput {\n bottom: number;\n height: number;\n top: number;\n viewportHeight: number;\n}\n\nexport function isSfRevealModifier(value: unknown): value is SfRevealModifier {\n return typeof value === \"string\" && SF_REVEAL_MODIFIER_PATTERN.test(value);\n}\n\nfunction normalizeSelectors(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n\n return Array.from(\n new Set(\n value\n .filter((selector): selector is string => typeof selector === \"string\")\n .map((selector) => selector.trim())\n .filter(Boolean),\n ),\n );\n}\n\nfunction normalizeRevealRules(value: unknown): SfRevealRule[] {\n if (!Array.isArray(value)) return [];\n\n const seenSelectors = new Set<string>();\n return value.flatMap((rule: unknown) => {\n if (!rule || typeof rule !== \"object\") return [];\n\n const candidate = rule as Partial<SfRevealRule>;\n const selector =\n typeof candidate.selector === \"string\" ? candidate.selector.trim() : \"\";\n if (\n !selector ||\n seenSelectors.has(selector) ||\n !isSfRevealModifier(candidate.reveal)\n ) {\n return [];\n }\n\n seenSelectors.add(selector);\n return [{ selector, reveal: candidate.reveal }];\n });\n}\n\n/**\n * Normalizes server- or client-provided configuration. Invalid values fail\n * open by disabling automatic reveals; empty and duplicate selectors are\n * removed without changing their order.\n */\nexport function resolveSfMotionOptions(\n options: SfMotionOptions = {},\n): ResolvedSfMotionOptions {\n const defaultReveal = isSfRevealModifier(options.defaultReveal)\n ? options.defaultReveal\n : false;\n return {\n autoRevealSelectors: normalizeSelectors(options.autoRevealSelectors),\n defaultReveal,\n revealAboveFold: options.revealAboveFold === true,\n revealRules: normalizeRevealRules(options.revealRules),\n };\n}\n\n/** Exact class mutation required by an authoritative selector rule. */\nexport function ruleRevealClassChanges(\n existingClasses: Iterable<string>,\n reveal: SfRevealModifier,\n): SfRevealClassChanges {\n const classes = Array.from(existingClasses);\n if (\n classes.includes(SF_MOTION_STATIC_CLASS) ||\n classes.includes(SF_MOTION_DISABLE_CLASS)\n ) {\n return { add: [], remove: [] };\n }\n\n return {\n add: [\n ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),\n ...(classes.includes(reveal) ? [] : [reveal]),\n ],\n remove: classes\n .filter(isSfRevealModifier)\n .filter((modifier) => modifier !== reveal),\n };\n}\n\n/** Delay for a zero-based participant index in a reveal stagger group. */\nexport function staggerRevealDelayMs(index: number): number {\n if (!Number.isFinite(index) || index <= 0) return 0;\n return Math.min(\n Math.floor(index) * SF_REVEAL_STAGGER_STEP_MS,\n SF_REVEAL_STAGGER_MAX_MS,\n );\n}\n\n/**\n * Returns only the classes that automatic inheritance must add. Explicit\n * modifiers win over the configured default and `sf-motion-static` remains a\n * complete opt-out.\n */\nexport function automaticRevealClasses(\n existingClasses: Iterable<string>,\n defaultReveal: SfDefaultReveal,\n): string[] {\n if (defaultReveal === false) return [];\n\n const classes = Array.from(existingClasses);\n if (\n classes.includes(SF_MOTION_STATIC_CLASS) ||\n classes.includes(SF_MOTION_DISABLE_CLASS)\n ) {\n return [];\n }\n\n return [\n ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),\n ...(classes.some(isSfRevealModifier) ? [] : [defaultReveal]),\n ];\n}\n\nfunction cssTimeToMs(value: string): number {\n const normalized = value.trim();\n const amount = Number.parseFloat(normalized);\n if (!Number.isFinite(amount)) return 0;\n\n return normalized.endsWith(\"ms\") ? amount : amount * 1000;\n}\n\n/** Returns the longest combined CSS transition duration and delay. */\nexport function maximumTransitionTimeMs(\n transitionDuration: string,\n transitionDelay: string,\n): number {\n const durations = transitionDuration.split(\",\").map(cssTimeToMs);\n const delays = transitionDelay.split(\",\").map(cssTimeToMs);\n const itemCount = Math.max(durations.length, delays.length);\n\n return Array.from({ length: itemCount }, (_, index) => {\n const duration = durations[index % durations.length] ?? 0;\n const delay = delays[index % delays.length] ?? 0;\n return Math.max(0, duration + delay);\n }).reduce((maximum, value) => Math.max(maximum, value), 0);\n}\n\n/**\n * Initial viewport content stays static unless the project explicitly enables\n * above-the-fold reveals. Deep links and protected content remain visible.\n */\nexport function initialRevealState({\n bottom,\n containsHashTarget,\n protectedContent,\n reducedMotion,\n revealAboveFold,\n top,\n viewportHeight,\n}: InitialRevealStateInput): SfRevealState {\n if (\n reducedMotion ||\n containsHashTarget ||\n protectedContent\n ) {\n return \"visible\";\n }\n\n // reveal share of its height) waits for the scroll instead of appearing\n // statically; content already scrolled past the top stays visible.\n if (\n !revealAboveFold &&\n bottom > 0 &&\n top < viewportHeight &&\n (top < 0 ||\n hasEnoughVisibleArea({\n bottom,\n height: Math.max(0, bottom - top),\n top,\n viewportHeight,\n }))\n ) {\n return \"visible\";\n }\n\n return \"pending\";\n}\n\n/**\n * Reveal ordinary content once 20% of its perceivable height is visible.\n * For elements taller than the viewport, the viewport height is the reference.\n */\nexport function hasEnoughVisibleArea({\n bottom,\n height,\n top,\n viewportHeight,\n}: RevealVisibilityInput): boolean {\n if (height <= 0 || viewportHeight <= 0) return true;\n\n const visibleHeight = Math.max(\n 0,\n Math.min(bottom, viewportHeight) - Math.max(top, 0),\n );\n // The 1px tolerance below must not let thin elements such as a 1px <hr>\n // pass while they are still entirely outside the viewport.\n if (visibleHeight <= 0) return false;\n\n const requiredHeight =\n Math.min(height, viewportHeight) * SF_REVEAL_VISIBLE_RATIO;\n\n return visibleHeight + 1 >= requiredHeight;\n}\n\n/**\n * Reveal is deliberately one-way: focus and viewport entry can complete it,\n * while leaving the viewport never conceals content again.\n */\nexport function nextRevealState(\n current: SfRevealState,\n event: \"focus\" | \"intersect\" | \"leave\",\n): SfRevealState {\n if (current === \"settled\") return \"settled\";\n\n if (current === \"visible\" || event === \"focus\" || event === \"intersect\") {\n return \"visible\";\n }\n\n return \"pending\";\n}\n\nexport function shouldInitializeMotion(\n initialized: string | undefined,\n): boolean {\n return initialized !== \"true\";\n}\n\n/** `<html data-sf-motion>` value from the head bootstrap until the controller arms. */\nexport const SF_MOTION_BOOT_STATE = \"boot\";\n\n/** Failsafe: boot-hidden content shows anyway if the controller never arms. */\nexport const SF_MOTION_BOOT_FAILSAFE_MS = 3000;\n\n/**\n * Modifiers whose pending state keeps the element visible and hides only a\n * drawn decoration, mapped to the pseudo-element carrying it.\n */\nexport const SF_REVEAL_DECORATION_PSEUDOS: Readonly<\n Record<SfRevealModifier, \"::before\" | \"::after\">\n> = {\n \"sf-reveal--accordion-line\": \"::after\",\n};\n\n// Everything the controller leaves visible: opt-outs, protected content and the hash target.\n// :has() makes :not() invalid where unsupported, which drops the rule: content stays visible.\nconst SF_MOTION_BOOT_EXCLUDED = [\n `.${SF_MOTION_STATIC_CLASS}`,\n `.${SF_MOTION_DISABLE_CLASS}`,\n `.${SF_MOTION_DISABLE_CLASS} *`,\n SF_MOTION_PROTECTED_CONTENT_SELECTOR,\n `:has(${SF_MOTION_PROTECTED_CONTENT_SELECTOR})`,\n \":target\",\n \":has(:target)\",\n].join(\", \");\n\n/**\n * Inline `<head>` script, placed after the motion preference bootstrap: marks\n * the document as booting when the controller will arm reveals, so the CSS of\n * `motionBootCss` hides them before first paint.\n */\nexport function motionBootScript(preferenceAttribute: string): string {\n const attribute = JSON.stringify(preferenceAttribute);\n const state = JSON.stringify(SF_MOTION_BOOT_STATE);\n return `(()=>{const r=document.documentElement;if(r.getAttribute(${attribute})===\"full\"&&\"IntersectionObserver\"in window&&!r.dataset.sfMotion)r.dataset.sfMotion=${state}})()`;\n}\n\n/**\n * Pre-paint counterpart of the controller for `revealAboveFold`: hides what the\n * controller will arm (authored reveals, rule and automatic selectors) while\n * `<html data-sf-motion=\"boot\">`, so content is never painted, hidden, then\n * revealed. Each selector gets its own rule: an invalid one only drops itself.\n * Like the controller, the first matching rule decides the modifier.\n * Portabile in FlowPress: docs/pilots/primo-paint-stabile.md\n */\nexport function motionBootCss(options: SfMotionOptions = {}): string {\n const { autoRevealSelectors, defaultReveal, revealAboveFold, revealRules } =\n resolveSfMotionOptions(options);\n if (!revealAboveFold) return \"\";\n\n const root = `html[data-sf-motion=\"${SF_MOTION_BOOT_STATE}\"]`;\n const failsafe = `${SF_MOTION_BOOT_FAILSAFE_MS}ms`;\n const decorations = Object.entries(SF_REVEAL_DECORATION_PSEUDOS) as [\n SfRevealModifier,\n string,\n ][];\n const hide = (target: string, reveal: SfRevealModifier | null): string => {\n const pseudo = reveal ? (SF_REVEAL_DECORATION_PSEUDOS[reveal] ?? \"\") : \"\";\n return `${root} ${target}${pseudo}{opacity:0;animation:sf-motion-boot-failsafe 0s linear ${failsafe} forwards}`;\n };\n const rules: string[] = [];\n\n // Authored reveals keep their own modifier; decorations hide their pseudo.\n const decorationClasses = decorations.map(([modifier]) => `.${modifier}`);\n rules.push(hide(\n `.${SF_REVEAL_CLASS}:not(${[SF_MOTION_BOOT_EXCLUDED, ...decorationClasses].join(\", \")})`,\n null,\n ));\n decorations.forEach(([modifier]) => {\n rules.push(hide(`.${SF_REVEAL_CLASS}.${modifier}:not(${SF_MOTION_BOOT_EXCLUDED})`, modifier));\n });\n\n const earlier: string[] = [];\n revealRules.forEach(({ selector, reveal }) => {\n const shadowed = earlier.length ? `, :is(${earlier.join(\", \")})` : \"\";\n rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, reveal));\n earlier.push(selector);\n });\n\n if (defaultReveal !== false) {\n const shadowed = earlier.length ? `, :is(${earlier.join(\", \")})` : \"\";\n autoRevealSelectors.forEach((selector) => {\n rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, defaultReveal));\n });\n }\n\n rules.push(\"@keyframes sf-motion-boot-failsafe{to{opacity:1}}\");\n return rules.join(\"\\n\");\n}\n"]}