ngwr 16.5.0 → 16.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/back-top/styles/_index.scss +6 -0
  2. package/breadcrumbs/styles/_rules.scss +34 -0
  3. package/cascader/styles/_rules.scss +7 -0
  4. package/charts/chart-legend/styles/_index.scss +1 -9
  5. package/counter/styles/_index.scss +1 -8
  6. package/date-picker/styles/_index.scss +15 -9
  7. package/dialog/styles/_index.scss +37 -0
  8. package/editor/styles/_index.scss +1 -8
  9. package/event-calendar/styles/_index.scss +2 -6
  10. package/fesm2022/ngwr-affix.mjs +1 -1
  11. package/fesm2022/ngwr-affix.mjs.map +1 -1
  12. package/fesm2022/ngwr-anchor.mjs +9 -2
  13. package/fesm2022/ngwr-anchor.mjs.map +1 -1
  14. package/fesm2022/ngwr-animations-aurora.mjs.map +1 -1
  15. package/fesm2022/ngwr-animations-blur-reveal.mjs.map +1 -1
  16. package/fesm2022/ngwr-animations-click-sparks.mjs.map +1 -1
  17. package/fesm2022/ngwr-animations-confetti.mjs.map +1 -1
  18. package/fesm2022/ngwr-animations-decode.mjs.map +1 -1
  19. package/fesm2022/ngwr-animations-destruct.mjs.map +1 -1
  20. package/fesm2022/ngwr-animations-dot-grid.mjs.map +1 -1
  21. package/fesm2022/ngwr-animations-falling-letters.mjs.map +1 -1
  22. package/fesm2022/ngwr-animations-flow-lines.mjs.map +1 -1
  23. package/fesm2022/ngwr-animations-fluid-cursor.mjs.map +1 -1
  24. package/fesm2022/ngwr-animations-glitch.mjs.map +1 -1
  25. package/fesm2022/ngwr-animations-glow-border.mjs.map +1 -1
  26. package/fesm2022/ngwr-animations-gradient-flow.mjs.map +1 -1
  27. package/fesm2022/ngwr-animations-marquee.mjs.map +1 -1
  28. package/fesm2022/ngwr-animations-orbit.mjs.map +1 -1
  29. package/fesm2022/ngwr-animations-reveal.mjs.map +1 -1
  30. package/fesm2022/ngwr-animations-ripple-grid.mjs.map +1 -1
  31. package/fesm2022/ngwr-animations-rotate-reveal.mjs.map +1 -1
  32. package/fesm2022/ngwr-animations-shimmer.mjs.map +1 -1
  33. package/fesm2022/ngwr-animations-spotlight.mjs.map +1 -1
  34. package/fesm2022/ngwr-animations-thread-lines.mjs.map +1 -1
  35. package/fesm2022/ngwr-animations-tilt.mjs +20 -13
  36. package/fesm2022/ngwr-animations-tilt.mjs.map +1 -1
  37. package/fesm2022/ngwr-animations-typewriter.mjs.map +1 -1
  38. package/fesm2022/ngwr-breadcrumbs.mjs +40 -7
  39. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  40. package/fesm2022/ngwr-button.mjs +12 -3
  41. package/fesm2022/ngwr-button.mjs.map +1 -1
  42. package/fesm2022/ngwr-carousel.mjs +8 -2
  43. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  44. package/fesm2022/ngwr-cascader.mjs +24 -4
  45. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  46. package/fesm2022/ngwr-charts-core.mjs +12 -5
  47. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  48. package/fesm2022/ngwr-charts-meter-group.mjs +4 -2
  49. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  50. package/fesm2022/ngwr-checkbox.mjs +3 -2
  51. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  52. package/fesm2022/ngwr-color-picker.mjs +21 -1
  53. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  54. package/fesm2022/ngwr-context-menu.mjs +4 -5
  55. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  56. package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
  57. package/fesm2022/ngwr-date-picker.mjs +49 -1
  58. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  59. package/fesm2022/ngwr-dialog.mjs +16 -6
  60. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  61. package/fesm2022/ngwr-directives.mjs +9 -6
  62. package/fesm2022/ngwr-directives.mjs.map +1 -1
  63. package/fesm2022/ngwr-event-calendar.mjs +20 -9
  64. package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
  65. package/fesm2022/ngwr-form.mjs +170 -3
  66. package/fesm2022/ngwr-form.mjs.map +1 -1
  67. package/fesm2022/ngwr-i18n-ar.mjs +15 -0
  68. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  69. package/fesm2022/ngwr-i18n-cs.mjs +15 -0
  70. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  71. package/fesm2022/ngwr-i18n-de.mjs +15 -0
  72. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  73. package/fesm2022/ngwr-i18n-en.mjs +15 -0
  74. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  75. package/fesm2022/ngwr-i18n-es.mjs +15 -0
  76. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  77. package/fesm2022/ngwr-i18n-fr.mjs +15 -0
  78. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  79. package/fesm2022/ngwr-i18n-he.mjs +15 -0
  80. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  81. package/fesm2022/ngwr-i18n-hi.mjs +15 -0
  82. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  83. package/fesm2022/ngwr-i18n-id.mjs +15 -0
  84. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  85. package/fesm2022/ngwr-i18n-it.mjs +15 -0
  86. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  87. package/fesm2022/ngwr-i18n-ja.mjs +15 -0
  88. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  89. package/fesm2022/ngwr-i18n-ko.mjs +15 -0
  90. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  91. package/fesm2022/ngwr-i18n-nl.mjs +15 -0
  92. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  93. package/fesm2022/ngwr-i18n-pl.mjs +15 -0
  94. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  95. package/fesm2022/ngwr-i18n-pt.mjs +15 -0
  96. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  97. package/fesm2022/ngwr-i18n-ru.mjs +15 -0
  98. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  99. package/fesm2022/ngwr-i18n-sv.mjs +15 -0
  100. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  101. package/fesm2022/ngwr-i18n-tr.mjs +15 -0
  102. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  103. package/fesm2022/ngwr-i18n-uk.mjs +15 -0
  104. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  105. package/fesm2022/ngwr-i18n-vi.mjs +15 -0
  106. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  107. package/fesm2022/ngwr-i18n-zh-tw.mjs +15 -0
  108. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  109. package/fesm2022/ngwr-i18n-zh.mjs +15 -0
  110. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  111. package/fesm2022/ngwr-i18n.mjs +82 -11
  112. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  113. package/fesm2022/ngwr-input-number.mjs +24 -1
  114. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  115. package/fesm2022/ngwr-input-otp.mjs +2 -2
  116. package/fesm2022/ngwr-input-otp.mjs.map +1 -1
  117. package/fesm2022/ngwr-input.mjs +10 -2
  118. package/fesm2022/ngwr-input.mjs.map +1 -1
  119. package/fesm2022/ngwr-layout.mjs.map +1 -1
  120. package/fesm2022/ngwr-list.mjs +1 -1
  121. package/fesm2022/ngwr-list.mjs.map +1 -1
  122. package/fesm2022/ngwr-loading-bar-router.mjs.map +1 -1
  123. package/fesm2022/ngwr-loading-bar.mjs +2 -2
  124. package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
  125. package/fesm2022/ngwr-mention.mjs +8 -0
  126. package/fesm2022/ngwr-mention.mjs.map +1 -1
  127. package/fesm2022/ngwr-meta.mjs +9 -6
  128. package/fesm2022/ngwr-meta.mjs.map +1 -1
  129. package/fesm2022/ngwr-page-header.mjs +21 -0
  130. package/fesm2022/ngwr-page-header.mjs.map +1 -1
  131. package/fesm2022/ngwr-pagination.mjs +2 -0
  132. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  133. package/fesm2022/ngwr-pipes.mjs +8 -1
  134. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  135. package/fesm2022/ngwr-popconfirm.mjs +2 -1
  136. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  137. package/fesm2022/ngwr-popover.mjs +47 -3
  138. package/fesm2022/ngwr-popover.mjs.map +1 -1
  139. package/fesm2022/ngwr-qr.mjs +6 -2
  140. package/fesm2022/ngwr-qr.mjs.map +1 -1
  141. package/fesm2022/ngwr-radio.mjs +71 -5
  142. package/fesm2022/ngwr-radio.mjs.map +1 -1
  143. package/fesm2022/ngwr-schema-form.mjs +10 -1
  144. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  145. package/fesm2022/ngwr-scroll.mjs +1 -3
  146. package/fesm2022/ngwr-scroll.mjs.map +1 -1
  147. package/fesm2022/ngwr-segmented.mjs +20 -0
  148. package/fesm2022/ngwr-segmented.mjs.map +1 -1
  149. package/fesm2022/ngwr-select.mjs +80 -9
  150. package/fesm2022/ngwr-select.mjs.map +1 -1
  151. package/fesm2022/ngwr-sortable-list.mjs +16 -4
  152. package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
  153. package/fesm2022/ngwr-storage.mjs +1 -1
  154. package/fesm2022/ngwr-storage.mjs.map +1 -1
  155. package/fesm2022/ngwr-switch.mjs +2 -2
  156. package/fesm2022/ngwr-switch.mjs.map +1 -1
  157. package/fesm2022/ngwr-table.mjs +41 -7
  158. package/fesm2022/ngwr-table.mjs.map +1 -1
  159. package/fesm2022/ngwr-tabs-router.mjs.map +1 -1
  160. package/fesm2022/ngwr-textarea.mjs +2 -2
  161. package/fesm2022/ngwr-textarea.mjs.map +1 -1
  162. package/fesm2022/ngwr-toast.mjs +28 -0
  163. package/fesm2022/ngwr-toast.mjs.map +1 -1
  164. package/fesm2022/ngwr-tour.mjs +2 -2
  165. package/fesm2022/ngwr-tour.mjs.map +1 -1
  166. package/fesm2022/ngwr-typography.mjs +20 -0
  167. package/fesm2022/ngwr-typography.mjs.map +1 -1
  168. package/fesm2022/ngwr-utils-router.mjs.map +1 -1
  169. package/fesm2022/ngwr-utils.mjs +46 -4
  170. package/fesm2022/ngwr-utils.mjs.map +1 -1
  171. package/fesm2022/ngwr-validators.mjs +33 -1
  172. package/fesm2022/ngwr-validators.mjs.map +1 -1
  173. package/fesm2022/ngwr-version.mjs +1 -1
  174. package/fesm2022/ngwr-version.mjs.map +1 -1
  175. package/form/styles/_index.scss +37 -0
  176. package/graph/styles/_index.scss +1 -9
  177. package/i18n/ar.json +15 -0
  178. package/i18n/cs.json +15 -0
  179. package/i18n/de.json +15 -0
  180. package/i18n/en.json +15 -0
  181. package/i18n/es.json +15 -0
  182. package/i18n/fr.json +15 -0
  183. package/i18n/he.json +15 -0
  184. package/i18n/hi.json +15 -0
  185. package/i18n/id.json +15 -0
  186. package/i18n/it.json +15 -0
  187. package/i18n/ja.json +15 -0
  188. package/i18n/ko.json +15 -0
  189. package/i18n/nl.json +15 -0
  190. package/i18n/pl.json +15 -0
  191. package/i18n/pt.json +15 -0
  192. package/i18n/ru.json +15 -0
  193. package/i18n/sv.json +15 -0
  194. package/i18n/tr.json +15 -0
  195. package/i18n/uk.json +15 -0
  196. package/i18n/vi.json +15 -0
  197. package/i18n/zh-TW.json +15 -0
  198. package/i18n/zh.json +15 -0
  199. package/image-cropper/styles/_index.scss +1 -9
  200. package/input-number/styles/_index.scss +7 -0
  201. package/layout/styles/_index.scss +13 -1
  202. package/llms-full.txt +10 -10
  203. package/loading-bar/styles/_rules.scss +6 -0
  204. package/package.json +2 -2
  205. package/page-header/styles/_index.scss +18 -0
  206. package/popover/styles/_index.scss +7 -0
  207. package/schematics/use/symbol-map.json +2 -0
  208. package/segmented/styles/_index.scss +7 -0
  209. package/select/styles/_index.scss +7 -0
  210. package/sidebar/styles/_index.scss +6 -0
  211. package/skills/ngwr/references/catalog.md +1 -1
  212. package/sortable-list/styles/_rules.scss +1 -9
  213. package/speed-dial/styles/_index.scss +6 -0
  214. package/stepper/styles/_index.scss +1 -9
  215. package/table/styles/_index.scss +49 -0
  216. package/theme/_index.scss +12 -1
  217. package/theme/styles/_colors.scss +11 -0
  218. package/theme/styles/_contrast.scss +6 -0
  219. package/theme/styles/_index.scss +1 -0
  220. package/theme/styles/_mixins.scss +45 -0
  221. package/theme/styles/_print.scss +17 -0
  222. package/toast/styles/_index.scss +7 -0
  223. package/tour/styles/_index.scss +8 -0
  224. package/tree/styles/_index.scss +1 -9
  225. package/types/ngwr-anchor.d.ts +3 -0
  226. package/types/ngwr-animations-aurora.d.ts +6 -0
  227. package/types/ngwr-animations-blur-reveal.d.ts +6 -0
  228. package/types/ngwr-animations-click-sparks.d.ts +6 -0
  229. package/types/ngwr-animations-confetti.d.ts +6 -0
  230. package/types/ngwr-animations-decode.d.ts +6 -0
  231. package/types/ngwr-animations-destruct.d.ts +6 -0
  232. package/types/ngwr-animations-dot-grid.d.ts +6 -0
  233. package/types/ngwr-animations-falling-letters.d.ts +6 -0
  234. package/types/ngwr-animations-flow-lines.d.ts +6 -0
  235. package/types/ngwr-animations-fluid-cursor.d.ts +6 -0
  236. package/types/ngwr-animations-glitch.d.ts +6 -0
  237. package/types/ngwr-animations-glow-border.d.ts +6 -0
  238. package/types/ngwr-animations-gradient-flow.d.ts +6 -0
  239. package/types/ngwr-animations-marquee.d.ts +6 -0
  240. package/types/ngwr-animations-orbit.d.ts +6 -0
  241. package/types/ngwr-animations-reveal.d.ts +6 -0
  242. package/types/ngwr-animations-ripple-grid.d.ts +6 -0
  243. package/types/ngwr-animations-rotate-reveal.d.ts +6 -0
  244. package/types/ngwr-animations-shimmer.d.ts +6 -0
  245. package/types/ngwr-animations-spotlight.d.ts +6 -0
  246. package/types/ngwr-animations-thread-lines.d.ts +6 -0
  247. package/types/ngwr-animations-tilt.d.ts +10 -0
  248. package/types/ngwr-animations-typewriter.d.ts +6 -0
  249. package/types/ngwr-breadcrumbs.d.ts +25 -0
  250. package/types/ngwr-button.d.ts +23 -3
  251. package/types/ngwr-carousel.d.ts +2 -0
  252. package/types/ngwr-cascader.d.ts +7 -0
  253. package/types/ngwr-charts-core.d.ts +16 -0
  254. package/types/ngwr-charts-meter-group.d.ts +2 -0
  255. package/types/ngwr-checkbox.d.ts +1 -0
  256. package/types/ngwr-color-picker.d.ts +1 -0
  257. package/types/ngwr-context-menu.d.ts +1 -1
  258. package/types/ngwr-date-picker.d.ts +19 -0
  259. package/types/ngwr-dialog.d.ts +39 -8
  260. package/types/ngwr-directives.d.ts +12 -4
  261. package/types/ngwr-drawer.d.ts +1 -1
  262. package/types/ngwr-dropdown.d.ts +1 -1
  263. package/types/ngwr-event-calendar.d.ts +4 -0
  264. package/types/ngwr-form.d.ts +85 -1
  265. package/types/ngwr-i18n.d.ts +65 -5
  266. package/types/ngwr-input-number.d.ts +8 -0
  267. package/types/ngwr-input.d.ts +7 -0
  268. package/types/ngwr-layout.d.ts +1 -1
  269. package/types/ngwr-loading-bar-router.d.ts +6 -0
  270. package/types/ngwr-page-header.d.ts +23 -1
  271. package/types/ngwr-popconfirm.d.ts +1 -1
  272. package/types/ngwr-popover.d.ts +28 -4
  273. package/types/ngwr-radio.d.ts +47 -5
  274. package/types/ngwr-segmented.d.ts +7 -0
  275. package/types/ngwr-select.d.ts +57 -13
  276. package/types/ngwr-sortable-list.d.ts +20 -7
  277. package/types/ngwr-table.d.ts +58 -5
  278. package/types/ngwr-tabs-router.d.ts +6 -0
  279. package/types/ngwr-toast.d.ts +11 -0
  280. package/types/ngwr-tour.d.ts +0 -1
  281. package/types/ngwr-typography.d.ts +7 -0
  282. package/types/ngwr-utils-router.d.ts +6 -0
  283. package/types/ngwr-utils.d.ts +56 -2
  284. package/types/ngwr-validators.d.ts +49 -1
  285. package/types/ngwr-version.d.ts +1 -1
  286. package/typography/styles/_index.scss +4 -0
  287. package/window/styles/_index.scss +1 -9
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-animations-aurora.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/aurora/aurora-model.ts","../../../projects/lib/animations/aurora/aurora-gl.ts","../../../projects/lib/animations/aurora/aurora.ts","../../../projects/lib/animations/aurora/aurora.html","../../../projects/lib/animations/aurora/public-api.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { wrClamp } from 'ngwr/utils';\n\nimport type { WrAuroraEdge } from './types';\n\n/**\n * The pure side of `<wr-aurora>`: the inputs as the shader takes them, the\n * curtain's vertical profile, the ray gain, the intro, the drift toward the\n * pointer, the colour stops in OKLCh, the canvas size and the frame cap. The\n * shader in `aurora-gl.ts` reads these numbers as uniforms and owns only what\n * has to be per pixel; the formulas it shares with this file (the profile,\n * the ray gain, the stop interpolation) are written here too, so a spec can\n * read them.\n *\n * Colour is the one idea worth a note. The three stops are mixed in OKLCh,\n * not sRGB: lightness and chroma move linearly and the hue walks the shorter\n * arc, so the colour between two stops is as saturated as either and never\n * the grey an sRGB mix of two hues falls into. The conversion happens once\n * per stop here; the shader interpolates in that space and converts back.\n */\n\n/** The curtain reaches this share of the region at least and at most. */\nconst HEIGHT_MIN = 0.1;\nconst HEIGHT_MAX = 1;\n/** The shader's loop bound over the curtains. */\nconst LAYERS_MAX = 3;\n/** How far the free edge's wave moves it at a unit `amplitude`, as a share of the curtain's height, at the wave's full swing. */\nconst WAVE = 0.35;\n/** How many broad waves cross the width at a unit `scale`, and how many fine rays. */\nconst WAVE_FREQ = 2.2;\nconst RAY_FREQ = 26;\n/** How fast the wave, the rays and the hue move at a unit `speed`, in noise cells per second. */\nconst WAVE_DRIFT = 0.055;\nconst RAY_DRIFT = 0.24;\nconst HUE_DRIFT = 0.08;\n/** The vertical profile's veil: what is left at the anchored edge, how bright the veil is at the free edge and how fast it grows there. */\nconst PROFILE_FLOOR = 0.06;\nconst VEIL = 0.36;\nconst VEIL_POWER = 1.4;\n/** The bright lower border: its height over the veil, where it sits and its half width, in shares of the curtain's height; and how soft the free edge is past it. */\nconst BORDER = 0.85;\nconst BORDER_AT = 0.9;\nconst BORDER_WIDTH = 0.16;\nconst EDGE_SOFT = 0.16;\n/** The folds: how dim the curtain is between its bright knots. */\nconst FOLD_FLOOR = 0.55;\n/** The rays: how bright the brightest ray is over the veil at a unit `rays`, how fast a ray fades from the free edge toward the root over its length, and the shortest ray's length as a share of the longest. */\nconst RAY_GAIN = 0.9;\nconst RAY_FALL = 1.8;\nconst RAY_SHORT = 0.3;\n/** The intro's length in seconds and how far the curtain reaches when it begins. */\nconst INTRO_S = 2.4;\nconst INTRO_REACH_START = 0.3;\n/** The drift toward the pointer: its approach rate per second, how far it moves the curtain across (share of the width) and how much it stretches it toward the pointer. */\nconst FOLLOW_RATE = 1.4;\nconst FOLLOW_REACH = 0.08;\nconst FOLLOW_LIFT = 0.14;\n/** The drift is settled once it is within this share of the width. */\nconst FOLLOW_SETTLE = 0.0005;\n/** The sides fade over this share of the width, within these bounds, in CSS px. */\nconst SIDE_SHARE = 0.22;\nconst SIDE_MIN = 48;\nconst SIDE_MAX = 360;\n/** The canvas: device px per CSS px at most, at least, and the most pixels it may hold. An aurora is soft, so it is drawn small and the browser scales it up. */\nconst RATIO_MAX = 0.5;\nconst RATIO_MIN = 0.15;\nconst PIXELS = 400_000;\n/** Frames a second, and the gap between them in ms: slow light needs no more. */\nconst FPS = 30;\nconst FRAME_MS = 1000 / FPS;\n/**\n * On a light surface the curtain is a wash, a pale pastel: its peak alpha,\n * the lightness every stop is laid at, the share of a stop's chroma it keeps\n * and the most chroma it may hold (a pastel this light holds no more in\n * sRGB). The shape is the curtain's but softer: where it is whole, how far\n * past the free edge it dissolves, how dim it is between the folds, how far\n * the rays modulate it at a unit `rays` and how much of the wave's finer\n * octaves it keeps.\n */\nconst WASH_ALPHA = 0.85;\nconst WASH_L = 0.9;\nconst WASH_CHROMA = 0.5;\nconst WASH_CHROMA_MAX = 0.08;\nconst WASH_RISE = 0.85;\nconst WASH_SOFT = 0.5;\nconst WASH_FOLD_FLOOR = 0.8;\nconst WASH_RAY = 0.2;\nconst WASH_DETAIL = 0.4;\n/** On a dark surface it is light: its peak strength, and how far the brightest spots are lifted toward white. */\nconst GLOW_PEAK = 1;\nconst GLOW_LIFT = 0.1;\n\n/** `height` as the shader takes it: a finite share of the region within the bounds. */\nfunction auroraHeight(height: number): number {\n return wrClamp(Number.isFinite(height) ? height : 0.5, HEIGHT_MIN, HEIGHT_MAX);\n}\n\n/** `layers` as the shader takes it: a whole number from one to {@link LAYERS_MAX}. */\nfunction auroraLayers(layers: number): number {\n return wrClamp(Math.round(Number.isFinite(layers) ? layers : 2), 1, LAYERS_MAX);\n}\n\n/** A share, `rays` and the like: finite and within zero and one. */\nfunction auroraShare(value: number, fallback: number): number {\n return wrClamp(Number.isFinite(value) ? value : fallback, 0, 1);\n}\n\n/** A multiplier, `scale`, `amplitude`, `speed` and `glow`: finite and never negative; `scale` never nothing. */\nfunction auroraFactor(value: number, fallback: number, min = 0): number {\n return Math.max(min, Number.isFinite(value) ? value : fallback);\n}\n\n/** The free edge's wave as a share of the curtain's height under `amplitude`. */\nfunction auroraWave(amplitude: number): number {\n return WAVE * auroraFactor(amplitude, 1);\n}\n\n/** The edge's sign for the shader: one hangs from the top, minus one from the bottom. */\nfunction auroraEdgeSign(edge: WrAuroraEdge): 1 | -1 {\n return edge === 'bottom' ? -1 : 1;\n}\n\n/**\n * How bright the curtain is `v` of the way from the anchored edge to the free\n * edge: a veil, faint at the root and growing toward the free edge, and over\n * it a bright border just short of that edge, the way an aurora is brightest\n * at its lower border; past the edge both fall softly to nothing. Never over\n * one. The shader's own formula.\n */\nfunction auroraProfile(v: number): number {\n const vc = wrClamp(v, 0, 1);\n const veil = PROFILE_FLOOR + (VEIL - PROFILE_FLOOR) * Math.pow(vc, VEIL_POWER);\n const border = BORDER * Math.exp(-(((v - BORDER_AT) / BORDER_WIDTH) ** 2));\n const edge = 1 - smoothstep(1 - EDGE_SOFT, 1 + EDGE_SOFT * 0.6, v);\n return Math.min(1, veil + border) * edge;\n}\n\n/**\n * How bright a ray of brightness `bright` (0..1) and length `length` (0..1,\n * the share of the longest) is `v` of the way from the anchored edge to the\n * free edge: whole at the free edge and fading toward the root, the shorter\n * ray the faster. The shader's own formula.\n */\nfunction auroraRay(bright: number, length: number, v: number): number {\n const len = RAY_SHORT + (1 - RAY_SHORT) * wrClamp(length, 0, 1);\n return wrClamp(bright, 0, 1) * Math.exp((-(1 - wrClamp(v, 0, 1)) * RAY_FALL) / len);\n}\n\n/**\n * The curtain's brightness at `v` before the folds and the fades, for a ray\n * of `bright` and `length` there, under `rays`: at none the smooth profile\n * alone, at one half the veil, the border beaded by the ray and the ray\n * itself at {@link RAY_GAIN}; never over one. The shader's own formula.\n */\nfunction auroraIntensity(v: number, bright: number, length: number, rays: number): number {\n const vc = wrClamp(v, 0, 1);\n const r = wrClamp(rays, 0, 1);\n const veil = PROFILE_FLOOR + (VEIL - PROFILE_FLOOR) * Math.pow(vc, VEIL_POWER);\n const border = BORDER * Math.exp(-(((v - BORDER_AT) / BORDER_WIDTH) ** 2));\n const bead = 1 + r * (0.6 + 0.4 * wrClamp(bright, 0, 1) - 1);\n const edge = 1 - smoothstep(1 - EDGE_SOFT, 1 + EDGE_SOFT * 0.6, v);\n return Math.min(1, veil * (1 - 0.5 * r) + border * bead + r * RAY_GAIN * auroraRay(bright, length, v)) * edge;\n}\n\n/**\n * The intro `elapsed` seconds in: how far in the curtain has faded and how\n * far it reaches, both as shares, both eased out and one once it is over.\n */\nfunction auroraIntro(elapsed: number): [fade: number, reach: number] {\n if (elapsed >= INTRO_S) return [1, 1];\n const t = wrClamp(elapsed, 0, INTRO_S) / INTRO_S;\n const eased = 1 - (1 - t) ** 3;\n return [eased, INTRO_REACH_START + (1 - INTRO_REACH_START) * eased];\n}\n\n/** `current` moved toward `target` over `dt` seconds at `rate`: an exponential approach, the same path on a fast and a slow screen. */\nfunction auroraApproach(current: number, target: number, dt: number, rate = FOLLOW_RATE): number {\n return target + (current - target) * Math.exp(-rate * Math.max(0, dt));\n}\n\n/**\n * Where the drift wants to be for a pointer at `x`, `y` over a region of\n * `width` by `height` whose curtain reaches `reach` of it: across, as a share\n * of the width toward the pointer, and the stretch toward it, as a share of\n * the curtain's height. Nothing for no pointer.\n */\nfunction auroraFollowTarget(\n x: number,\n y: number,\n width: number,\n height: number,\n reach: number\n): [across: number, stretch: number] {\n if (!Number.isFinite(x) || !Number.isFinite(y) || width <= 0 || height <= 0) return [0, 0];\n const across = wrClamp(x / width - 0.5, -0.5, 0.5) * 2 * FOLLOW_REACH;\n const stretch = wrClamp((y / height - reach) / Math.max(reach, 0.01), -1, 1) * FOLLOW_LIFT;\n return [across, stretch];\n}\n\n/** Whether the drift still moves: either part farther than the settle from its target. */\nfunction auroraDriftLive(across: number, stretch: number, target: readonly [number, number]): boolean {\n return Math.abs(across - target[0]) > FOLLOW_SETTLE || Math.abs(stretch - target[1]) > FOLLOW_SETTLE;\n}\n\n/** How far in from each side the curtain is faded, in CSS px, for a region this wide. */\nfunction auroraSideFade(width: number): number {\n return wrClamp(SIDE_SHARE * width, SIDE_MIN, SIDE_MAX);\n}\n\n/** The render ratio, device px per CSS px: {@link RATIO_MAX} at most, lowered to keep the canvas under {@link PIXELS}, never under {@link RATIO_MIN}. The device ratio plays no part: the drawing is soft and the browser's upscale is free. */\nfunction auroraRatio(width: number, height: number): number {\n const area = Math.max(1, width * height);\n return wrClamp(Math.sqrt(PIXELS / area), RATIO_MIN, RATIO_MAX);\n}\n\n/**\n * How dense the wash is `v` of the way from the anchored edge to the free\n * edge: nothing at the root, whole from {@link WASH_RISE} and dissolving\n * past the free edge over {@link WASH_SOFT} of the curtain's height. One\n * broad bump, no bright border and no edge. The shader's own formula.\n */\nfunction auroraWashShape(v: number): number {\n const rise = smoothstep(0, WASH_RISE, v);\n const dissolve = 1 - smoothstep(WASH_RISE - 0.1, 1 + WASH_SOFT, v);\n return rise * dissolve;\n}\n\n/**\n * A stop as the wash lays it, in OKLCh: the hue kept, the lightness set to\n * {@link WASH_L} whatever the stop's, the chroma a share of the stop's within\n * {@link WASH_CHROMA_MAX}. The shader's own formula.\n */\nfunction auroraWashColor(stop: ArrayLike<number>): [L: number, C: number, h: number] {\n return [WASH_L, Math.min(stop[1] * WASH_CHROMA, WASH_CHROMA_MAX), stop[2]];\n}\n\n/** Whether `surface` is light, so the curtain is laid as a wash rather than as light. */\nfunction auroraLight(surface: ArrayLike<number>): boolean {\n return 0.2126 * surface[0] + 0.7152 * surface[1] + 0.0722 * surface[2] > 0.5;\n}\n\n// Colour\n\nconst toLinear = (c: number): number => (c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));\nconst toGamma = (c: number): number => (c <= 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - 0.055);\n\n/** An sRGB colour, channels 0..1, as OKLab. */\nfunction auroraSrgbToOklab(rgb: ArrayLike<number>): [L: number, a: number, b: number] {\n const r = toLinear(rgb[0]);\n const g = toLinear(rgb[1]);\n const b = toLinear(rgb[2]);\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n return [\n 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,\n ];\n}\n\n/** An OKLab colour as sRGB, channels 0..1, clipped to the gamut. */\nfunction auroraOklabToSrgb(lab: ArrayLike<number>): [number, number, number] {\n const l = (lab[0] + 0.3963377774 * lab[1] + 0.2158037573 * lab[2]) ** 3;\n const m = (lab[0] - 0.1055613458 * lab[1] - 0.0638541728 * lab[2]) ** 3;\n const s = (lab[0] - 0.0894841775 * lab[1] - 1.291485548 * lab[2]) ** 3;\n const r = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;\n const g = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;\n const b = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;\n return [toGamma(wrClamp(r, 0, 1)), toGamma(wrClamp(g, 0, 1)), toGamma(wrClamp(b, 0, 1))];\n}\n\n/** An sRGB colour as OKLCh: lightness, chroma and the hue in radians, which is what the shader interpolates. */\nfunction auroraStop(rgb: ArrayLike<number>): [L: number, C: number, h: number] {\n const [L, a, b] = auroraSrgbToOklab(rgb);\n return [L, Math.hypot(a, b), Math.atan2(b, a)];\n}\n\n/** An OKLCh colour as sRGB. */\nfunction auroraStopToSrgb(lch: ArrayLike<number>): [number, number, number] {\n return auroraOklabToSrgb([lch[0], lch[1] * Math.cos(lch[2]), lch[1] * Math.sin(lch[2])]);\n}\n\n/** The signed turn from hue `from` to hue `to` along the shorter arc, in radians. */\nfunction auroraHueArc(from: number, to: number): number {\n const tau = Math.PI * 2;\n return ((((to - from + Math.PI) % tau) + tau) % tau) - Math.PI;\n}\n\n/**\n * The colour `u` of the way across the three stops, in OKLCh: the first at\n * nought, the second midway, the third at one, each held on a short plateau\n * by the smoothstep between them; lightness and chroma move linearly and the\n * hue walks the shorter arc. The shader's own formula.\n */\nfunction auroraColorAt(stops: readonly ArrayLike<number>[], u: number): [L: number, C: number, h: number] {\n const x = wrClamp(u, 0, 1);\n const [a, b, t] = x < 0.5 ? [stops[0], stops[1], x * 2] : [stops[1], stops[2], x * 2 - 1];\n const s = t * t * (3 - 2 * t);\n return [a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s, a[2] + auroraHueArc(a[2], b[2]) * s];\n}\n\nfunction smoothstep(edge0: number, edge1: number, x: number): number {\n const t = wrClamp((x - edge0) / (edge1 - edge0), 0, 1);\n return t * t * (3 - 2 * t);\n}\n\nexport {\n BORDER,\n BORDER_AT,\n BORDER_WIDTH,\n EDGE_SOFT,\n FOLD_FLOOR,\n FOLLOW_LIFT,\n FOLLOW_RATE,\n FOLLOW_REACH,\n FOLLOW_SETTLE,\n FPS,\n FRAME_MS,\n GLOW_LIFT,\n GLOW_PEAK,\n HEIGHT_MAX,\n HEIGHT_MIN,\n HUE_DRIFT,\n INTRO_REACH_START,\n INTRO_S,\n LAYERS_MAX,\n PIXELS,\n PROFILE_FLOOR,\n RATIO_MAX,\n RATIO_MIN,\n RAY_DRIFT,\n RAY_FALL,\n RAY_FREQ,\n RAY_GAIN,\n RAY_SHORT,\n SIDE_MAX,\n SIDE_MIN,\n SIDE_SHARE,\n VEIL,\n VEIL_POWER,\n WASH_ALPHA,\n WASH_CHROMA,\n WASH_CHROMA_MAX,\n WASH_DETAIL,\n WASH_FOLD_FLOOR,\n WASH_L,\n WASH_RAY,\n WASH_RISE,\n WASH_SOFT,\n WAVE,\n WAVE_DRIFT,\n WAVE_FREQ,\n auroraApproach,\n auroraColorAt,\n auroraDriftLive,\n auroraEdgeSign,\n auroraFactor,\n auroraFollowTarget,\n auroraHeight,\n auroraHueArc,\n auroraIntensity,\n auroraIntro,\n auroraLayers,\n auroraLight,\n auroraOklabToSrgb,\n auroraProfile,\n auroraRatio,\n auroraRay,\n auroraShare,\n auroraSideFade,\n auroraSrgbToOklab,\n auroraStop,\n auroraStopToSrgb,\n auroraWashColor,\n auroraWashShape,\n auroraWave,\n};\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport {\n BORDER,\n BORDER_AT,\n BORDER_WIDTH,\n EDGE_SOFT,\n FOLD_FLOOR,\n GLOW_LIFT,\n LAYERS_MAX,\n PROFILE_FLOOR,\n RAY_FALL,\n RAY_GAIN,\n RAY_SHORT,\n VEIL,\n VEIL_POWER,\n WASH_CHROMA_MAX,\n WASH_DETAIL,\n WASH_FOLD_FLOOR,\n WASH_RAY,\n WASH_RISE,\n WASH_SOFT,\n} from './aurora-model';\n\n/**\n * The one pass `<wr-aurora>` draws: a full-screen quad whose fragment shader\n * lights, for its pixel, up to three curtains hanging from one edge of the\n * region. A curtain's free edge is a slow wave, three octaves of smooth\n * noise across the width; the pixel's place between the anchored edge and\n * that wave gives it the vertical profile (dim at the root, brightest just\n * short of the free edge, soft past it), fine noise across the width makes\n * the rays, leaning with the wave and shimmering on a clock of their own,\n * and the colour is the three stops interpolated in OKLCh at the pixel's\n * place across the width, the hue drifting with the wave. The curtains sit\n * at depths: the farther one is broader, slower, dimmer and moves less with\n * the pointer. They are composited back to front inside the shader.\n *\n * Two ways to lay the result, mixed by `uLook.z`. On a light surface the\n * curtain is a wash, a pale pastel: the stop's hue at one high lightness and\n * a fraction of its chroma, laid at an alpha that follows a softer shape\n * than the curtain's (no bright border, a wave with less fine detail, a long\n * dissolve past the free edge, the rays a whisper), so it dissolves into the\n * surface with no edge and never falls to grey. On a dark one it is light:\n * the colour scaled by the brightness in the colour channels with half that\n * in alpha, so it adds to the surface rather than covering it, the brightest\n * spots lifted toward white. The output is premultiplied either way. GLSL\n * ES 1.00, which WebGL1 and WebGL2 both accept.\n */\n\ntype AuroraGLContext = WebGLRenderingContext | WebGL2RenderingContext;\n\n/** What one frame needs, every length in CSS px unless said otherwise. */\ninterface AuroraFrame {\n /** The canvas, in device px. */\n width: number;\n height: number;\n /** CSS px per device px: the inverse of the render ratio. */\n scale: number;\n /** The region's CSS size. */\n regionWidth: number;\n regionHeight: number;\n /** One hangs from the top, minus one from the bottom; and minus one under RTL, so the stops run from the inline start. */\n edge: number;\n mirror: number;\n /** The curtain's reach as a share of the region, the wave as a share of that, and the wave's and the rays' frequency across the width. */\n reach: number;\n wave: number;\n waveFrequency: number;\n rayFrequency: number;\n /** The clocks: the wave's, the rays' and the hue's, in noise cells. */\n waveTime: number;\n rayTime: number;\n hueTime: number;\n /** How many curtains, one to three. */\n layers: number;\n /** The rays' strength, the glow multiplier, one for a wash on a light surface and nought for light on a dark one, and how far in from each side the curtain fades. */\n rays: number;\n glow: number;\n light: number;\n sideFade: number;\n /** The intro's fade and reach, both shares; and the drift toward the pointer, across as a share of the width and the stretch as a share of the reach. */\n introFade: number;\n introReach: number;\n driftAcross: number;\n driftStretch: number;\n /** The three stops in OKLCh: lightness, chroma, hue in radians. */\n stops: readonly Float32Array[];\n /** The wash: its peak alpha, the lightness it lays every stop at and the share of a stop's chroma it keeps; the light: its peak strength. */\n washAlpha: number;\n washLightness: number;\n washChroma: number;\n glowPeak: number;\n}\n\ninterface AuroraRenderer {\n /** Draws the frame onto the canvas. */\n render(frame: AuroraFrame): void;\n /** Frees the program and the quad. */\n destroy(): void;\n}\n\nconst VERTEX = `\nattribute vec2 aPosition;\nvoid main () {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n}`;\n\nconst FRAGMENT = `\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nconst int LAYERS_MAX = ${LAYERS_MAX};\nconst float EDGE_SOFT = ${EDGE_SOFT.toFixed(4)};\nconst float PROFILE_FLOOR = ${PROFILE_FLOOR.toFixed(4)};\nconst float VEIL = ${VEIL.toFixed(4)};\nconst float VEIL_POWER = ${VEIL_POWER.toFixed(4)};\nconst float BORDER = ${BORDER.toFixed(4)};\nconst float BORDER_AT = ${BORDER_AT.toFixed(4)};\nconst float BORDER_WIDTH = ${BORDER_WIDTH.toFixed(4)};\nconst float FOLD_FLOOR = ${FOLD_FLOOR.toFixed(4)};\nconst float RAY_GAIN = ${RAY_GAIN.toFixed(4)};\nconst float RAY_FALL = ${RAY_FALL.toFixed(4)};\nconst float RAY_SHORT = ${RAY_SHORT.toFixed(4)};\nconst float GLOW_LIFT = ${GLOW_LIFT.toFixed(4)};\nconst float WASH_RISE = ${WASH_RISE.toFixed(4)};\nconst float WASH_SOFT = ${WASH_SOFT.toFixed(4)};\nconst float WASH_FOLD_FLOOR = ${WASH_FOLD_FLOOR.toFixed(4)};\nconst float WASH_RAY = ${WASH_RAY.toFixed(4)};\nconst float WASH_DETAIL = ${WASH_DETAIL.toFixed(4)};\nconst float WASH_CHROMA_MAX = ${WASH_CHROMA_MAX.toFixed(4)};\nconst float PI = 3.14159265;\nconst float TAU = 6.28318531;\nuniform vec2 uSize;\nuniform float uScale;\nuniform vec2 uAxis;\nuniform vec4 uShape;\nuniform vec4 uMotion;\nuniform vec4 uLook;\nuniform vec4 uState;\nuniform vec3 uStops[3];\nuniform vec4 uTone;\n\nfloat hash (vec2 p) {\n vec3 q = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));\n q += dot(q, q.yzx + 19.19);\n return fract((q.x + q.y) * q.z);\n}\n\n// Value noise in -1..1, quintic-smoothed.\nfloat noise (vec2 x) {\n vec2 p = floor(x);\n vec2 w = fract(x);\n vec2 u = w * w * w * (w * (w * 6.0 - 15.0) + 10.0);\n float a = hash(p);\n float b = hash(p + vec2(1.0, 0.0));\n float c = hash(p + vec2(0.0, 1.0));\n float d = hash(p + vec2(1.0, 1.0));\n return mix(mix(a, b, u.x), mix(c, d, u.x), u.y) * 2.0 - 1.0;\n}\n\nfloat toGamma (float c) {\n return c <= 0.0031308 ? c * 12.92 : 1.055 * pow(c, 1.0 / 2.4) - 0.055;\n}\n\n// OKLCh to sRGB, clipped to the gamut.\nvec3 oklchToSrgb (vec3 lch) {\n vec3 lab = vec3(lch.x, lch.y * cos(lch.z), lch.y * sin(lch.z));\n float l = lab.x + 0.3963377774 * lab.y + 0.2158037573 * lab.z;\n float m = lab.x - 0.1055613458 * lab.y - 0.0638541728 * lab.z;\n float s = lab.x - 0.0894841775 * lab.y - 1.2914855480 * lab.z;\n l = l * l * l;\n m = m * m * m;\n s = s * s * s;\n vec3 lin = clamp(vec3(\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s), 0.0, 1.0);\n return vec3(toGamma(lin.r), toGamma(lin.g), toGamma(lin.b));\n}\n\n// The stops at u across: the first at nought, the second midway, the third at one, the hue on the shorter arc.\nvec3 stopAt (float u) {\n float x = clamp(u, 0.0, 1.0);\n vec3 a = x < 0.5 ? uStops[0] : uStops[1];\n vec3 b = x < 0.5 ? uStops[1] : uStops[2];\n float t = x < 0.5 ? x * 2.0 : x * 2.0 - 1.0;\n t = t * t * (3.0 - 2.0 * t);\n float dh = mod(b.z - a.z + PI, TAU) - PI;\n return vec3(mix(a.x, b.x, t), mix(a.y, b.y, t), a.z + dh * t);\n}\n\nvoid main () {\n // The pixel in CSS px, x from the inline start, y from the anchored edge.\n vec2 p = vec2(gl_FragCoord.x * uScale, uSize.y - gl_FragCoord.y * uScale);\n if (uAxis.x < 0.0) p.y = uSize.y - p.y;\n float u = p.x / uSize.x;\n if (uAxis.y < 0.0) u = 1.0 - u;\n float side = smoothstep(0.0, 1.0, min(p.x, uSize.x - p.x) / uLook.w);\n if (side <= 0.0) {\n gl_FragColor = vec4(0.0);\n return;\n }\n\n vec4 acc = vec4(0.0);\n for (int i = LAYERS_MAX - 1; i >= 0; i--) {\n if (float(i) >= uMotion.w) continue;\n // The curtain's depth: nought in front, one at the back, which is broader, slower, dimmer and moves less.\n float depth = float(i) / max(uMotion.w - 1.0, 1.0);\n float broad = 1.0 + 0.7 * depth;\n float dim = 1.0 - 0.45 * depth;\n float seed = float(i) * 17.0;\n float ux = u - uState.z * (1.0 - 0.6 * depth);\n\n // The free edge: three octaves across the width, on the wave's clock.\n float wt = uMotion.x / broad + seed;\n float nx = ux * uShape.z / broad;\n float n1 = noise(vec2(nx, wt));\n float n2 = noise(vec2(nx * 2.3 + 5.1, wt * 1.4 + 2.0));\n float n3 = noise(vec2(nx * 4.7 + 11.0, wt * 1.9 + 7.0));\n float w = clamp((n1 + 0.6 * n2 + 0.3 * n3) / 1.4, -1.0, 1.0);\n float stretch = uSize.y * uShape.x * (1.0 + 0.12 * depth) * uState.y * (1.0 + uState.w);\n float reach = uSize.y * uShape.x * (1.0 + uShape.y * w) * (1.0 + 0.12 * depth) * uState.y * (1.0 + uState.w);\n reach = min(max(reach, 1.0), uSize.y);\n float v = p.y / reach;\n // The wash has a wave of its own, with less of the finer octaves: a broad, slow edge. Kept apart from the\n // curtain's, so the light's arithmetic is what it was.\n float wl = clamp((n1 + WASH_DETAIL * (0.6 * n2 + 0.3 * n3)) / (1.0 + 0.9 * WASH_DETAIL), -1.0, 1.0);\n float vl = p.y / min(max(stretch * (1.0 + uShape.y * wl), 1.0), uSize.y);\n if (v > 1.0 + EDGE_SOFT && (uLook.z <= 0.0 || vl > 1.0 + WASH_SOFT)) continue;\n float vc = clamp(v, 0.0, 1.0);\n\n // The vertical profile: a veil, faint at the root and growing toward the free edge, a bright border\n // just short of that edge, and both soft past it.\n float veil = mix(PROFILE_FLOOR, VEIL, pow(vc, VEIL_POWER));\n float b = (v - BORDER_AT) / BORDER_WIDTH;\n float border = BORDER * exp(-b * b);\n float fade = 1.0 - smoothstep(1.0 - EDGE_SOFT, 1.0 + EDGE_SOFT * 0.6, v);\n\n // The folds: the curtain is bright in knots along its length and dimmer between them, on the wave's clock.\n float knot = smoothstep(-0.9, 0.9, noise(vec2(nx * 1.3 + 7.7, wt * 0.9 + 3.3)));\n float fold = mix(FOLD_FLOOR, 1.0, knot);\n\n // The rays: columns across the width, each with a brightness and a length of its own, leaning with the\n // wave toward the root, shimmering on their own clock; a ray is whole at the free edge and fades toward\n // the root, the shorter the faster. At a unit rays half the veil goes, the border is beaded and the rays\n // rise over it.\n float rx = (ux + 0.04 * w * (1.0 - vc)) * uShape.w / broad + seed;\n float c = 0.5 + 0.5 * (0.65 * noise(vec2(rx, uMotion.y + seed)) + 0.35 * noise(vec2(rx * 2.3 + 3.0, uMotion.y * 1.6 + 1.0)));\n c = smoothstep(0.25, 0.95, c);\n float len = mix(RAY_SHORT, 1.0, 0.5 + 0.5 * noise(vec2(rx * 0.21 + 9.0, uMotion.y * 0.35 + seed)));\n float ray = c * exp(-(1.0 - vc) * RAY_FALL / len);\n float bead = mix(1.0, 0.6 + 0.4 * c, uLook.x);\n float shape = min(1.0, veil * (1.0 - 0.5 * uLook.x) + border * bead + uLook.x * RAY_GAIN * ray);\n float I = shape * fade * fold * dim * side * uState.x * uLook.y;\n\n // The wash's shape: one broad bump, whole from WASH_RISE, dissolving long past the free edge, the folds\n // shallow and the rays a whisper over it.\n float washShape = smoothstep(0.0, WASH_RISE, vl) * (1.0 - smoothstep(WASH_RISE - 0.1, 1.0 + WASH_SOFT, vl));\n washShape *= mix(WASH_FOLD_FLOOR, 1.0, knot) * (1.0 + uLook.x * WASH_RAY * (ray - 0.5));\n float W = washShape * dim * side * uState.x * uLook.y;\n if (mix(I, W, uLook.z) <= 0.0) continue;\n\n // The colour: the stops across the width, the hue carried a little by the wave and the clock.\n vec3 lch = stopAt(ux + 0.1 * mix(w, wl, uLook.z) + 0.15 * depth + 0.04 * sin(uMotion.z + seed));\n\n // A wash on a light surface: the stop's hue at one high lightness and a share of its chroma, at an alpha\n // that follows the wash's shape.\n float a = min(1.0, W * uTone.x);\n vec3 washRgb = oklchToSrgb(vec3(uTone.y, min(lch.y * uTone.z, WASH_CHROMA_MAX), lch.z));\n vec4 wash = vec4(washRgb * a, a);\n\n // Light on a dark surface: the colour by the glow, half as much alpha, the brightest spots lifted toward white.\n float k = min(1.0, I * uTone.w);\n vec3 glowRgb = oklchToSrgb(vec3(lch.x + GLOW_LIFT * k * k, lch.y, lch.z));\n vec4 glow = vec4(glowRgb * k, k * 0.5);\n\n vec4 layer = mix(glow, wash, uLook.z);\n acc = layer + acc * (1.0 - layer.a);\n }\n gl_FragColor = acc;\n}`;\n\nconst UNIFORMS = ['uSize', 'uScale', 'uAxis', 'uShape', 'uMotion', 'uLook', 'uState', 'uStops', 'uTone'] as const;\n\ntype AuroraUniform = (typeof UNIFORMS)[number];\n\nclass Renderer implements AuroraRenderer {\n private readonly program: WebGLProgram;\n private readonly quad: WebGLBuffer;\n private readonly uniforms: Record<AuroraUniform, WebGLUniformLocation | null>;\n private readonly stops = new Float32Array(9);\n\n constructor(private readonly gl: AuroraGLContext) {\n const quad = gl.createBuffer();\n if (!quad) throw new Error('aurora: no buffer');\n this.quad = quad;\n gl.bindBuffer(gl.ARRAY_BUFFER, quad);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);\n gl.disable(gl.BLEND);\n gl.disable(gl.DEPTH_TEST);\n\n const vertex = this.shader(gl.VERTEX_SHADER, VERTEX);\n const fragment = this.shader(gl.FRAGMENT_SHADER, FRAGMENT);\n const program = gl.createProgram();\n if (!program) throw new Error('aurora: no program');\n gl.attachShader(program, vertex);\n gl.attachShader(program, fragment);\n gl.bindAttribLocation(program, 0, 'aPosition');\n gl.linkProgram(program);\n gl.deleteShader(vertex);\n gl.deleteShader(fragment);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`aurora: program failed: ${log ?? ''}`);\n }\n this.program = program;\n const uniforms = {} as Record<AuroraUniform, WebGLUniformLocation | null>;\n for (const name of UNIFORMS) uniforms[name] = gl.getUniformLocation(program, name);\n this.uniforms = uniforms;\n }\n\n render(frame: AuroraFrame): void {\n const { gl, uniforms, stops } = this;\n gl.useProgram(this.program);\n gl.uniform2f(uniforms.uSize, frame.regionWidth, frame.regionHeight);\n gl.uniform1f(uniforms.uScale, frame.scale);\n gl.uniform2f(uniforms.uAxis, frame.edge, frame.mirror);\n gl.uniform4f(uniforms.uShape, frame.reach, frame.wave, frame.waveFrequency, frame.rayFrequency);\n gl.uniform4f(uniforms.uMotion, frame.waveTime, frame.rayTime, frame.hueTime, frame.layers);\n gl.uniform4f(uniforms.uLook, frame.rays, frame.glow, frame.light, frame.sideFade);\n gl.uniform4f(uniforms.uState, frame.introFade, frame.introReach, frame.driftAcross, frame.driftStretch);\n for (let i = 0; i < 3; i++) stops.set(frame.stops[i], i * 3);\n gl.uniform3fv(uniforms.uStops, stops);\n gl.uniform4f(uniforms.uTone, frame.washAlpha, frame.washLightness, frame.washChroma, frame.glowPeak);\n\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.viewport(0, 0, frame.width, frame.height);\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n gl.bindBuffer(gl.ARRAY_BUFFER, this.quad);\n gl.enableVertexAttribArray(0);\n gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n destroy(): void {\n const { gl } = this;\n gl.deleteBuffer(this.quad);\n gl.deleteProgram(this.program);\n }\n\n private shader(kind: number, source: string): WebGLShader {\n const { gl } = this;\n const shader = gl.createShader(kind);\n if (!shader) throw new Error('aurora: no shader');\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`aurora: shader failed: ${log ?? ''}`);\n }\n return shader;\n }\n}\n\n/**\n * The attributes the canvas's context is asked for: premultiplied alpha,\n * which is what the pass writes, no antialiasing (the drawing is soft and\n * upscaled) and no buffer the pass does not use.\n */\nconst AURORA_CONTEXT_ATTRIBUTES: WebGLContextAttributes = {\n alpha: true,\n premultipliedAlpha: true,\n antialias: false,\n depth: false,\n stencil: false,\n preserveDrawingBuffer: false,\n powerPreference: 'low-power',\n};\n\n/** A renderer on `gl`, or `null` where the shader will not compile or link. */\nfunction createAuroraRenderer(gl: AuroraGLContext): AuroraRenderer | null {\n try {\n return new Renderer(gl);\n } catch {\n return null;\n }\n}\n\nexport { AURORA_CONTEXT_ATTRIBUTES, UNIFORMS as AURORA_UNIFORMS, createAuroraRenderer };\nexport type { AuroraFrame, AuroraGLContext, AuroraRenderer, AuroraUniform };\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n PLATFORM_ID,\n ViewEncapsulation,\n afterNextRender,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n untracked,\n viewChild,\n} from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrResolveCssColorChannels, wrWatchColorScheme, wrCheckStyles } from 'ngwr/utils';\n\nimport { FRAME_FLOOR_SLACK, MAX_FRAME_MS } from '../internal';\n\nimport {\n AURORA_CONTEXT_ATTRIBUTES,\n type AuroraFrame,\n type AuroraGLContext,\n type AuroraRenderer,\n createAuroraRenderer,\n} from './aurora-gl';\nimport {\n FRAME_MS,\n GLOW_PEAK,\n HUE_DRIFT,\n RAY_DRIFT,\n RAY_FREQ,\n WASH_ALPHA,\n WASH_CHROMA,\n WASH_L,\n WAVE_DRIFT,\n WAVE_FREQ,\n auroraApproach,\n auroraDriftLive,\n auroraEdgeSign,\n auroraFactor,\n auroraFollowTarget,\n auroraHeight,\n auroraIntro,\n auroraLayers,\n auroraLight,\n auroraRatio,\n auroraShare,\n auroraSideFade,\n auroraStop,\n auroraWave,\n} from './aurora-model';\nimport type { WrAuroraEdge } from './types';\n\n/** The stops' fallbacks where a hook resolves to nothing: green, blue, violet. */\nconst FALLBACK_STOPS = ['#008800', '#3969e2', '#8a4fcf'] as const;\n\n/**\n * A curtain of light hanging from one edge of a section and reaching part of\n * the way in, like an aurora: its free edge a slow broad wave, fine rays\n * shimmering inside it, brightest just short of the free edge and fading\n * toward the one it hangs from, its colour flowing across the width through\n * three stops from the theme. Up to three curtains hang at different depths,\n * the farther one broader, slower and dimmer, so they move in parallax, and\n * the whole drifts gently toward the pointer. On a light surface it is a\n * pale pastel wash that dissolves into the surface; on a dark one it is\n * light added to the surface. The drawing is one WebGL pass in\n * `aurora-gl.ts`, drawn at half resolution at most and scaled up by the\n * browser, since nothing in it is sharp; the pure pieces (the profile, the\n * rays, the intro, the drift, the colour stops in OKLCh, the canvas size and\n * the frame cap) are `aurora-model.ts`.\n *\n * Fills its positioned parent, which isolates itself, so the host's negative\n * z-index lands under the content and over the page background. The parent\n * takes the pointer, passively: the host and its canvas never do, and a\n * finger is ignored, so a scroll over the section is never fought. The\n * context is made when the host is first on screen and sized, not at mount,\n * so a region nobody scrolls to costs nothing; the loop runs while the host\n * is on screen and the document is visible, at thirty frames a second, and\n * with `speed` at none only while the intro or the drift still moves.\n *\n * Colours come from the `--wr-aurora-color-1`, `-2` and `-3` hooks through\n * `wrResolveCssColorChannels`, re-read when the scheme changes; the surface is\n * read too, which decides between the wash and the light. Under\n * `prefers-reduced-motion: reduce` one still frame is drawn, whole and at\n * rest; under `forced-colors: active` nothing is; without WebGL nothing is;\n * on the server the empty canvas is rendered, absolutely positioned, so the\n * browser's first draw shifts no layout. A lost context is let go and rebuilt\n * when it comes back. Decorative: `aria-hidden`, no pointer events. Styles:\n * `@use 'ngwr/animations/aurora'`.\n */\n@Component({\n selector: 'wr-aurora',\n templateUrl: './aurora.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-aurora', 'aria-hidden': 'true' },\n})\nexport class WrAurora {\n /** The edge the curtain hangs from. @default 'top' */\n readonly edge = input<WrAuroraEdge>('top');\n /** How far into the region the curtain reaches, as a share of its height, from 0.1 to 1. @default 0.5 */\n readonly height = input(0.5, { transform: wrNumAttr(0.5) });\n /** How far the free edge's wave moves it, a multiplier: one is about a quarter of the curtain's height; none is a straight edge. @default 1 */\n readonly amplitude = input(1, { transform: wrNumAttr(1) });\n /** The size of the shapes, a multiplier: one puts about a wave and a half across the width; more is broader. @default 1 */\n readonly scale = input(1, { transform: wrNumAttr(1) });\n /** How fast the wave, the rays and the hue move, a multiplier: none holds the curtain still. @default 1 */\n readonly speed = input(1, { transform: wrNumAttr(1) });\n /** How strong the light is, a multiplier on the wash's alpha and the glow. @default 1 */\n readonly glow = input(1, { transform: wrNumAttr(1) });\n /** How strongly the rays show, from none to one. @default 0.6 */\n readonly rays = input(0.6, { transform: wrNumAttr(0.6) });\n /** How many curtains hang at different depths, from one to three. @default 2 */\n readonly layers = input(2, { transform: wrNumAttr(2) });\n /** Whether the curtain fades and lengthens in when first on screen. @default false */\n readonly intro = input(false, { transform: booleanAttribute });\n /** Whether the curtain drifts gently toward the pointer over the parent. @default true */\n readonly follow = input(true, { transform: booleanAttribute });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private readonly dir = inject(Directionality, { optional: true });\n private readonly canvasRef = viewChild.required<ElementRef<HTMLCanvasElement>>('canvas');\n /** The stops run from the inline start: under RTL that is the right. */\n private readonly mirrored = computed(() => this.dir?.valueSignal() === 'rtl');\n\n private gl: AuroraGLContext | null = null;\n private renderer: AuroraRenderer | null = null;\n /** Set once the browser was asked for a context, so a refusal is not asked again. */\n private contextTried = false;\n\n /** The host's CSS size, zero until the first layout. */\n private regionWidth = 0;\n private regionHeight = 0;\n private readonly frame: AuroraFrame = {\n width: 0,\n height: 0,\n scale: 1,\n regionWidth: 0,\n regionHeight: 0,\n edge: 1,\n mirror: 1,\n reach: 0.5,\n wave: 0,\n waveFrequency: WAVE_FREQ,\n rayFrequency: RAY_FREQ,\n waveTime: 0,\n rayTime: 0,\n hueTime: 0,\n layers: 2,\n rays: 0.6,\n glow: 1,\n light: 1,\n sideFade: 0,\n introFade: 1,\n introReach: 1,\n driftAcross: 0,\n driftStretch: 0,\n stops: [new Float32Array(3), new Float32Array(3), new Float32Array(3)],\n washAlpha: WASH_ALPHA,\n washLightness: WASH_L,\n washChroma: WASH_CHROMA,\n glowPeak: GLOW_PEAK,\n };\n\n /** The scene's clock in seconds, moving only while a frame runs, so a hidden tab holds the pose; and the motion's own, scaled by `speed`. */\n private time = 0;\n private motion = 0;\n /** When the intro began on the scene's clock; NaN before it has. */\n private introAt = NaN;\n /** Where the pointer is over the parent, in CSS px from the host's top left; NaN when it is not. */\n private pointerX = NaN;\n private pointerY = NaN;\n /** The drift toward the pointer, across and the stretch, and where it is heading. */\n private across = 0;\n private stretch = 0;\n private target: [number, number] = [0, 0];\n\n private running = false;\n private rafId: number | null = null;\n private lastFrame = 0;\n private resizeRafId: number | null = null;\n private pendingWidth = 0;\n private pendingHeight = 0;\n private inView = false;\n private mounted = false;\n\n private resizeObserver: ResizeObserver | null = null;\n private viewObserver: IntersectionObserver | null = null;\n private pointerTarget: HTMLElement | null = null;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/aurora');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n effect(() => {\n this.platform.pageVisible();\n this.platform.prefersReducedMotion();\n this.speed();\n untracked(() => this.sync());\n });\n effect(() => {\n this.edge();\n this.height();\n this.amplitude();\n this.scale();\n this.glow();\n this.rays();\n this.layers();\n this.mirrored();\n untracked(() => this.still());\n });\n effect(() => {\n this.follow();\n untracked(() => {\n this.retarget();\n this.sync();\n });\n });\n wrWatchColorScheme(() => {\n this.resolveColors();\n this.still();\n });\n\n afterNextRender(() => this.mount());\n inject(DestroyRef).onDestroy(() => this.unmount());\n }\n\n // Lifecycle\n\n private mount(): void {\n // Nothing drawn under forced colours: the stylesheet hides the host too.\n if (this.doc.defaultView?.matchMedia?.('(forced-colors: active)').matches) return;\n const host = this.host.nativeElement;\n this.mounted = true;\n\n if (typeof ResizeObserver !== 'undefined') {\n this.resizeObserver = new ResizeObserver(entries => {\n const rect = entries[entries.length - 1]?.contentRect;\n this.scheduleResize(rect?.width ?? host.clientWidth, rect?.height ?? host.clientHeight);\n });\n this.resizeObserver.observe(host);\n } else {\n this.layout(host.clientWidth, host.clientHeight);\n }\n\n if (typeof IntersectionObserver !== 'undefined') {\n this.viewObserver = new IntersectionObserver(entries => {\n this.inView = entries[entries.length - 1]?.isIntersecting ?? false;\n this.sync();\n });\n this.viewObserver.observe(host);\n } else {\n this.inView = true;\n this.sync();\n }\n\n const canvas = this.canvasRef().nativeElement;\n canvas.addEventListener('webglcontextlost', this.onContextLost);\n canvas.addEventListener('webglcontextrestored', this.onContextRestored);\n\n const target = host.parentElement;\n this.pointerTarget = target;\n target?.addEventListener('pointermove', this.onPointerMove, { passive: true });\n target?.addEventListener('pointerleave', this.onPointerLeave, { passive: true });\n }\n\n private unmount(): void {\n this.running = false;\n this.stopLoop();\n if (this.resizeRafId !== null) cancelAnimationFrame(this.resizeRafId);\n this.resizeRafId = null;\n this.resizeObserver?.disconnect();\n this.resizeObserver = null;\n this.viewObserver?.disconnect();\n this.viewObserver = null;\n this.pointerTarget?.removeEventListener('pointermove', this.onPointerMove);\n this.pointerTarget?.removeEventListener('pointerleave', this.onPointerLeave);\n this.pointerTarget = null;\n if (this.mounted) {\n const canvas = this.canvasRef().nativeElement;\n canvas.removeEventListener('webglcontextlost', this.onContextLost);\n canvas.removeEventListener('webglcontextrestored', this.onContextRestored);\n }\n this.renderer?.destroy();\n this.renderer = null;\n // The context itself is let go now rather than when the canvas is collected.\n this.gl?.getExtension('WEBGL_lose_context')?.loseContext();\n this.gl = null;\n this.mounted = false;\n }\n\n // Context\n\n /** The context and the renderer, made at the first chance to draw; `null` where the browser has no WebGL. */\n private ensure(): AuroraRenderer | null {\n if (this.renderer) return this.renderer;\n if (this.contextTried || !this.mounted) return null;\n this.contextTried = true;\n const canvas = this.canvasRef().nativeElement;\n const gl =\n canvas.getContext('webgl2', AURORA_CONTEXT_ATTRIBUTES) ?? canvas.getContext('webgl', AURORA_CONTEXT_ATTRIBUTES);\n if (!gl) return null;\n this.gl = gl;\n this.renderer = createAuroraRenderer(gl);\n if (!this.renderer) return null;\n this.resolveColors();\n return this.renderer;\n }\n\n private readonly onContextLost = (event: Event): void => {\n // Not prevented, the browser never restores it.\n event.preventDefault();\n this.renderer = null;\n this.running = false;\n this.stopLoop();\n };\n\n private readonly onContextRestored = (): void => {\n if (!this.gl) return;\n this.renderer = createAuroraRenderer(this.gl);\n this.sync();\n };\n\n // Layout\n\n private scheduleResize(width: number, height: number): void {\n this.pendingWidth = width;\n this.pendingHeight = height;\n if (this.resizeRafId !== null) return;\n this.resizeRafId = requestAnimationFrame(() => {\n this.resizeRafId = null;\n this.layout(this.pendingWidth, this.pendingHeight);\n });\n }\n\n private layout(width: number, height: number): void {\n if (width <= 0 || height <= 0) return;\n this.regionWidth = width;\n this.regionHeight = height;\n this.retarget();\n this.sync();\n }\n\n /** Sizes the canvas to the host under the render ratio. */\n private size(): void {\n const canvas = this.canvasRef().nativeElement;\n const ratio = auroraRatio(this.regionWidth, this.regionHeight);\n const width = Math.max(1, Math.round(this.regionWidth * ratio));\n const height = Math.max(1, Math.round(this.regionHeight * ratio));\n if (canvas.width !== width) canvas.width = width;\n if (canvas.height !== height) canvas.height = height;\n this.frame.width = width;\n this.frame.height = height;\n this.frame.scale = this.regionWidth / width;\n }\n\n // Colours\n\n private resolveColors(): void {\n if (!this.renderer) return;\n const canvas = this.canvasRef().nativeElement;\n FALLBACK_STOPS.forEach((fallback, i) => {\n const rgb = wrResolveCssColorChannels(canvas, `var(--wr-aurora-color-${i + 1})`, fallback);\n this.frame.stops[i].set(auroraStop(rgb));\n });\n const light = auroraLight(wrResolveCssColorChannels(canvas, 'var(--wr-color-surface)', '#ffffff'));\n this.frame.light = light ? 1 : 0;\n }\n\n // Pointer\n\n private readonly onPointerMove = (event: PointerEvent): void => {\n // A finger that moves is scrolling: the curtain must never fight it. Nothing to follow under reduced motion or with `follow` off.\n if (\n event.pointerType === 'touch' ||\n this.regionWidth === 0 ||\n !untracked(this.follow) ||\n this.platform.prefersReducedMotion()\n ) {\n return;\n }\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pointerX = event.clientX - rect.left;\n this.pointerY = event.clientY - rect.top;\n this.retarget();\n this.sync();\n };\n\n private readonly onPointerLeave = (): void => {\n if (Number.isNaN(this.pointerX)) return;\n this.pointerX = NaN;\n this.pointerY = NaN;\n this.retarget();\n this.sync();\n };\n\n /** Where the drift is heading, from the pointer; nothing under reduced motion or with `follow` off. */\n private retarget(): void {\n if (this.platform.prefersReducedMotion() || !untracked(this.follow)) {\n this.target = [0, 0];\n return;\n }\n const reach = auroraHeight(untracked(this.height));\n this.target = auroraFollowTarget(this.pointerX, this.pointerY, this.regionWidth, this.regionHeight, reach);\n }\n\n // Loop\n\n /** Whether anything moves while `speed` is none: the intro, or the drift toward the pointer. */\n private live(): boolean {\n return (\n (!Number.isNaN(this.introAt) && this.frame.introFade < 1) ||\n auroraDriftLive(this.across, this.stretch, this.target)\n );\n }\n\n private sync(): void {\n const reduced = this.platform.prefersReducedMotion();\n const allowed = this.mounted && this.regionWidth > 0 && this.inView && this.platform.pageVisible();\n const run = allowed && !reduced && (untracked(this.speed) > 0 || this.live());\n if (run !== this.running) {\n this.running = run;\n if (run) {\n this.lastFrame = performance.now();\n this.rafId = requestAnimationFrame(this.frameLoop);\n return;\n }\n this.stopLoop();\n }\n // Allowed but not running: one still frame, under reduced motion whole and at rest, however the pointer sits.\n if (allowed && !run) {\n if (reduced) this.rest();\n this.still();\n }\n }\n\n /** Everything beyond the curtain gone at once: the still frame has no drift and no intro in it. */\n private rest(): void {\n this.introAt = NaN;\n this.frame.introFade = 1;\n this.frame.introReach = 1;\n this.across = 0;\n this.stretch = 0;\n this.target = [0, 0];\n }\n\n private stopLoop(): void {\n if (this.rafId !== null) cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n\n /** One frame drawn outside the loop: the reduced-motion still, and a resize or a retheme while the loop is off. */\n private still(): void {\n if (this.running || !this.mounted || this.regionWidth === 0 || !this.inView) return;\n this.draw();\n }\n\n private readonly frameLoop = (now: number): void => {\n this.rafId = null;\n if (!this.running) return;\n if (now - this.lastFrame + FRAME_FLOOR_SLACK < FRAME_MS) {\n this.rafId = requestAnimationFrame(this.frameLoop);\n return;\n }\n const dt = Math.min(Math.max(now - this.lastFrame, 0), MAX_FRAME_MS) / 1000;\n this.lastFrame = now;\n this.advance(dt);\n this.draw();\n // Nothing left to move: the loop rests until the pointer, a resize or a retheme.\n if (untracked(this.speed) <= 0 && !this.live()) {\n this.running = false;\n return;\n }\n if (this.running) this.rafId = requestAnimationFrame(this.frameLoop);\n };\n\n /** The clocks move on and the drift follows its target. */\n private advance(dt: number): void {\n this.time += dt;\n this.motion += dt * Math.max(0, untracked(this.speed));\n this.across = auroraApproach(this.across, this.target[0], dt);\n this.stretch = auroraApproach(this.stretch, this.target[1], dt);\n if (!auroraDriftLive(this.across, this.stretch, this.target)) {\n [this.across, this.stretch] = this.target;\n }\n }\n\n /** The frame's numbers from the inputs and the state, and the pass. */\n private draw(): void {\n const renderer = this.ensure();\n if (!renderer || this.regionWidth === 0) return;\n const frame = this.frame;\n this.size();\n\n const scale = auroraFactor(untracked(this.scale), 1, 0.2);\n frame.regionWidth = this.regionWidth;\n frame.regionHeight = this.regionHeight;\n frame.edge = auroraEdgeSign(untracked(this.edge));\n frame.mirror = this.mirrored() ? -1 : 1;\n frame.reach = auroraHeight(untracked(this.height));\n frame.wave = auroraWave(untracked(this.amplitude));\n frame.waveFrequency = WAVE_FREQ / scale;\n frame.rayFrequency = RAY_FREQ / scale;\n frame.waveTime = this.motion * WAVE_DRIFT;\n frame.rayTime = this.motion * RAY_DRIFT;\n frame.hueTime = this.motion * HUE_DRIFT;\n frame.layers = auroraLayers(untracked(this.layers));\n frame.rays = auroraShare(untracked(this.rays), 0.6);\n frame.glow = auroraFactor(untracked(this.glow), 1);\n frame.sideFade = auroraSideFade(this.regionWidth);\n frame.driftAcross = this.across;\n frame.driftStretch = this.stretch;\n\n // The intro begins at the first drawn frame, when the host is sized and on screen.\n if (untracked(this.intro) && Number.isNaN(this.introAt) && !this.platform.prefersReducedMotion()) {\n this.introAt = this.time;\n }\n [frame.introFade, frame.introReach] = Number.isNaN(this.introAt) ? [1, 1] : auroraIntro(this.time - this.introAt);\n\n renderer.render(frame);\n }\n}\n\nexport { FALLBACK_STOPS };\n","<canvas #canvas class=\"wr-aurora__canvas\"></canvas>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nexport { WrAurora } from './aurora';\nexport type { WrAuroraEdge } from './types';\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAM,aAAa;AAKnB,MAAM,OAAO;AAEb,MAAM,YAAY;AAGlB,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,YAAY;AAElB,MAAM,gBAAgB;AACtB,MAAM,OAAO;AACb,MAAM,aAAa;AAEnB,MAAM,SAAS;AACf,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,YAAY;AAElB,MAAM,aAAa;AAEnB,MAAM,WAAW;AACjB,MAAM,WAAW;AACjB,MAAM,YAAY;AAElB,MAAM,UAAU;AAChB,MAAM,oBAAoB;AAE1B,MAAM,cAAc;AACpB,MAAM,eAAe;AACrB,MAAM,cAAc;AAIpB,MAAM,aAAa;AAInB,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,SAAS;AAaf,MAAM,aAAa;AACnB,MAAM,SAAS;AACf,MAAM,cAAc;AACpB,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,kBAAkB;AACxB,MAAM,WAAW;AACjB,MAAM,cAAc;AAGpB,MAAM,YAAY;AAGlB,SAAS,aAAa,QAAc;CAClC,OAAO,QAAQ,OAAO,SAAS,MAAM,IAAI,SAAS,IAAK,YAAA,CAAsB;AAC/E;AAGA,SAAS,aAAa,QAAc;CAClC,OAAO,QAAQ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A;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,UAAQ,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-animations-aurora.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/aurora/aurora-model.ts","../../../projects/lib/animations/aurora/aurora-gl.ts","../../../projects/lib/animations/aurora/aurora.ts","../../../projects/lib/animations/aurora/aurora.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { wrClamp } from 'ngwr/utils';\n\nimport type { WrAuroraEdge } from './types';\n\n/**\n * The pure side of `<wr-aurora>`: the inputs as the shader takes them, the\n * curtain's vertical profile, the ray gain, the intro, the drift toward the\n * pointer, the colour stops in OKLCh, the canvas size and the frame cap. The\n * shader in `aurora-gl.ts` reads these numbers as uniforms and owns only what\n * has to be per pixel; the formulas it shares with this file (the profile,\n * the ray gain, the stop interpolation) are written here too, so a spec can\n * read them.\n *\n * Colour is the one idea worth a note. The three stops are mixed in OKLCh,\n * not sRGB: lightness and chroma move linearly and the hue walks the shorter\n * arc, so the colour between two stops is as saturated as either and never\n * the grey an sRGB mix of two hues falls into. The conversion happens once\n * per stop here; the shader interpolates in that space and converts back.\n */\n\n/** The curtain reaches this share of the region at least and at most. */\nconst HEIGHT_MIN = 0.1;\nconst HEIGHT_MAX = 1;\n/** The shader's loop bound over the curtains. */\nconst LAYERS_MAX = 3;\n/** How far the free edge's wave moves it at a unit `amplitude`, as a share of the curtain's height, at the wave's full swing. */\nconst WAVE = 0.35;\n/** How many broad waves cross the width at a unit `scale`, and how many fine rays. */\nconst WAVE_FREQ = 2.2;\nconst RAY_FREQ = 26;\n/** How fast the wave, the rays and the hue move at a unit `speed`, in noise cells per second. */\nconst WAVE_DRIFT = 0.055;\nconst RAY_DRIFT = 0.24;\nconst HUE_DRIFT = 0.08;\n/** The vertical profile's veil: what is left at the anchored edge, how bright the veil is at the free edge and how fast it grows there. */\nconst PROFILE_FLOOR = 0.06;\nconst VEIL = 0.36;\nconst VEIL_POWER = 1.4;\n/** The bright lower border: its height over the veil, where it sits and its half width, in shares of the curtain's height; and how soft the free edge is past it. */\nconst BORDER = 0.85;\nconst BORDER_AT = 0.9;\nconst BORDER_WIDTH = 0.16;\nconst EDGE_SOFT = 0.16;\n/** The folds: how dim the curtain is between its bright knots. */\nconst FOLD_FLOOR = 0.55;\n/** The rays: how bright the brightest ray is over the veil at a unit `rays`, how fast a ray fades from the free edge toward the root over its length, and the shortest ray's length as a share of the longest. */\nconst RAY_GAIN = 0.9;\nconst RAY_FALL = 1.8;\nconst RAY_SHORT = 0.3;\n/** The intro's length in seconds and how far the curtain reaches when it begins. */\nconst INTRO_S = 2.4;\nconst INTRO_REACH_START = 0.3;\n/** The drift toward the pointer: its approach rate per second, how far it moves the curtain across (share of the width) and how much it stretches it toward the pointer. */\nconst FOLLOW_RATE = 1.4;\nconst FOLLOW_REACH = 0.08;\nconst FOLLOW_LIFT = 0.14;\n/** The drift is settled once it is within this share of the width. */\nconst FOLLOW_SETTLE = 0.0005;\n/** The sides fade over this share of the width, within these bounds, in CSS px. */\nconst SIDE_SHARE = 0.22;\nconst SIDE_MIN = 48;\nconst SIDE_MAX = 360;\n/** The canvas: device px per CSS px at most, at least, and the most pixels it may hold. An aurora is soft, so it is drawn small and the browser scales it up. */\nconst RATIO_MAX = 0.5;\nconst RATIO_MIN = 0.15;\nconst PIXELS = 400_000;\n/** Frames a second, and the gap between them in ms: slow light needs no more. */\nconst FPS = 30;\nconst FRAME_MS = 1000 / FPS;\n/**\n * On a light surface the curtain is a wash, a pale pastel: its peak alpha,\n * the lightness every stop is laid at, the share of a stop's chroma it keeps\n * and the most chroma it may hold (a pastel this light holds no more in\n * sRGB). The shape is the curtain's but softer: where it is whole, how far\n * past the free edge it dissolves, how dim it is between the folds, how far\n * the rays modulate it at a unit `rays` and how much of the wave's finer\n * octaves it keeps.\n */\nconst WASH_ALPHA = 0.85;\nconst WASH_L = 0.9;\nconst WASH_CHROMA = 0.5;\nconst WASH_CHROMA_MAX = 0.08;\nconst WASH_RISE = 0.85;\nconst WASH_SOFT = 0.5;\nconst WASH_FOLD_FLOOR = 0.8;\nconst WASH_RAY = 0.2;\nconst WASH_DETAIL = 0.4;\n/** On a dark surface it is light: its peak strength, and how far the brightest spots are lifted toward white. */\nconst GLOW_PEAK = 1;\nconst GLOW_LIFT = 0.1;\n\n/** `height` as the shader takes it: a finite share of the region within the bounds. */\nfunction auroraHeight(height: number): number {\n return wrClamp(Number.isFinite(height) ? height : 0.5, HEIGHT_MIN, HEIGHT_MAX);\n}\n\n/** `layers` as the shader takes it: a whole number from one to {@link LAYERS_MAX}. */\nfunction auroraLayers(layers: number): number {\n return wrClamp(Math.round(Number.isFinite(layers) ? layers : 2), 1, LAYERS_MAX);\n}\n\n/** A share, `rays` and the like: finite and within zero and one. */\nfunction auroraShare(value: number, fallback: number): number {\n return wrClamp(Number.isFinite(value) ? value : fallback, 0, 1);\n}\n\n/** A multiplier, `scale`, `amplitude`, `speed` and `glow`: finite and never negative; `scale` never nothing. */\nfunction auroraFactor(value: number, fallback: number, min = 0): number {\n return Math.max(min, Number.isFinite(value) ? value : fallback);\n}\n\n/** The free edge's wave as a share of the curtain's height under `amplitude`. */\nfunction auroraWave(amplitude: number): number {\n return WAVE * auroraFactor(amplitude, 1);\n}\n\n/** The edge's sign for the shader: one hangs from the top, minus one from the bottom. */\nfunction auroraEdgeSign(edge: WrAuroraEdge): 1 | -1 {\n return edge === 'bottom' ? -1 : 1;\n}\n\n/**\n * How bright the curtain is `v` of the way from the anchored edge to the free\n * edge: a veil, faint at the root and growing toward the free edge, and over\n * it a bright border just short of that edge, the way an aurora is brightest\n * at its lower border; past the edge both fall softly to nothing. Never over\n * one. The shader's own formula.\n */\nfunction auroraProfile(v: number): number {\n const vc = wrClamp(v, 0, 1);\n const veil = PROFILE_FLOOR + (VEIL - PROFILE_FLOOR) * Math.pow(vc, VEIL_POWER);\n const border = BORDER * Math.exp(-(((v - BORDER_AT) / BORDER_WIDTH) ** 2));\n const edge = 1 - smoothstep(1 - EDGE_SOFT, 1 + EDGE_SOFT * 0.6, v);\n return Math.min(1, veil + border) * edge;\n}\n\n/**\n * How bright a ray of brightness `bright` (0..1) and length `length` (0..1,\n * the share of the longest) is `v` of the way from the anchored edge to the\n * free edge: whole at the free edge and fading toward the root, the shorter\n * ray the faster. The shader's own formula.\n */\nfunction auroraRay(bright: number, length: number, v: number): number {\n const len = RAY_SHORT + (1 - RAY_SHORT) * wrClamp(length, 0, 1);\n return wrClamp(bright, 0, 1) * Math.exp((-(1 - wrClamp(v, 0, 1)) * RAY_FALL) / len);\n}\n\n/**\n * The curtain's brightness at `v` before the folds and the fades, for a ray\n * of `bright` and `length` there, under `rays`: at none the smooth profile\n * alone, at one half the veil, the border beaded by the ray and the ray\n * itself at {@link RAY_GAIN}; never over one. The shader's own formula.\n */\nfunction auroraIntensity(v: number, bright: number, length: number, rays: number): number {\n const vc = wrClamp(v, 0, 1);\n const r = wrClamp(rays, 0, 1);\n const veil = PROFILE_FLOOR + (VEIL - PROFILE_FLOOR) * Math.pow(vc, VEIL_POWER);\n const border = BORDER * Math.exp(-(((v - BORDER_AT) / BORDER_WIDTH) ** 2));\n const bead = 1 + r * (0.6 + 0.4 * wrClamp(bright, 0, 1) - 1);\n const edge = 1 - smoothstep(1 - EDGE_SOFT, 1 + EDGE_SOFT * 0.6, v);\n return Math.min(1, veil * (1 - 0.5 * r) + border * bead + r * RAY_GAIN * auroraRay(bright, length, v)) * edge;\n}\n\n/**\n * The intro `elapsed` seconds in: how far in the curtain has faded and how\n * far it reaches, both as shares, both eased out and one once it is over.\n */\nfunction auroraIntro(elapsed: number): [fade: number, reach: number] {\n if (elapsed >= INTRO_S) return [1, 1];\n const t = wrClamp(elapsed, 0, INTRO_S) / INTRO_S;\n const eased = 1 - (1 - t) ** 3;\n return [eased, INTRO_REACH_START + (1 - INTRO_REACH_START) * eased];\n}\n\n/** `current` moved toward `target` over `dt` seconds at `rate`: an exponential approach, the same path on a fast and a slow screen. */\nfunction auroraApproach(current: number, target: number, dt: number, rate = FOLLOW_RATE): number {\n return target + (current - target) * Math.exp(-rate * Math.max(0, dt));\n}\n\n/**\n * Where the drift wants to be for a pointer at `x`, `y` over a region of\n * `width` by `height` whose curtain reaches `reach` of it: across, as a share\n * of the width toward the pointer, and the stretch toward it, as a share of\n * the curtain's height. Nothing for no pointer.\n */\nfunction auroraFollowTarget(\n x: number,\n y: number,\n width: number,\n height: number,\n reach: number\n): [across: number, stretch: number] {\n if (!Number.isFinite(x) || !Number.isFinite(y) || width <= 0 || height <= 0) return [0, 0];\n const across = wrClamp(x / width - 0.5, -0.5, 0.5) * 2 * FOLLOW_REACH;\n const stretch = wrClamp((y / height - reach) / Math.max(reach, 0.01), -1, 1) * FOLLOW_LIFT;\n return [across, stretch];\n}\n\n/** Whether the drift still moves: either part farther than the settle from its target. */\nfunction auroraDriftLive(across: number, stretch: number, target: readonly [number, number]): boolean {\n return Math.abs(across - target[0]) > FOLLOW_SETTLE || Math.abs(stretch - target[1]) > FOLLOW_SETTLE;\n}\n\n/** How far in from each side the curtain is faded, in CSS px, for a region this wide. */\nfunction auroraSideFade(width: number): number {\n return wrClamp(SIDE_SHARE * width, SIDE_MIN, SIDE_MAX);\n}\n\n/** The render ratio, device px per CSS px: {@link RATIO_MAX} at most, lowered to keep the canvas under {@link PIXELS}, never under {@link RATIO_MIN}. The device ratio plays no part: the drawing is soft and the browser's upscale is free. */\nfunction auroraRatio(width: number, height: number): number {\n const area = Math.max(1, width * height);\n return wrClamp(Math.sqrt(PIXELS / area), RATIO_MIN, RATIO_MAX);\n}\n\n/**\n * How dense the wash is `v` of the way from the anchored edge to the free\n * edge: nothing at the root, whole from {@link WASH_RISE} and dissolving\n * past the free edge over {@link WASH_SOFT} of the curtain's height. One\n * broad bump, no bright border and no edge. The shader's own formula.\n */\nfunction auroraWashShape(v: number): number {\n const rise = smoothstep(0, WASH_RISE, v);\n const dissolve = 1 - smoothstep(WASH_RISE - 0.1, 1 + WASH_SOFT, v);\n return rise * dissolve;\n}\n\n/**\n * A stop as the wash lays it, in OKLCh: the hue kept, the lightness set to\n * {@link WASH_L} whatever the stop's, the chroma a share of the stop's within\n * {@link WASH_CHROMA_MAX}. The shader's own formula.\n */\nfunction auroraWashColor(stop: ArrayLike<number>): [L: number, C: number, h: number] {\n return [WASH_L, Math.min(stop[1] * WASH_CHROMA, WASH_CHROMA_MAX), stop[2]];\n}\n\n/** Whether `surface` is light, so the curtain is laid as a wash rather than as light. */\nfunction auroraLight(surface: ArrayLike<number>): boolean {\n return 0.2126 * surface[0] + 0.7152 * surface[1] + 0.0722 * surface[2] > 0.5;\n}\n\n// Colour\n\nconst toLinear = (c: number): number => (c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));\nconst toGamma = (c: number): number => (c <= 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - 0.055);\n\n/** An sRGB colour, channels 0..1, as OKLab. */\nfunction auroraSrgbToOklab(rgb: ArrayLike<number>): [L: number, a: number, b: number] {\n const r = toLinear(rgb[0]);\n const g = toLinear(rgb[1]);\n const b = toLinear(rgb[2]);\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n return [\n 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,\n ];\n}\n\n/** An OKLab colour as sRGB, channels 0..1, clipped to the gamut. */\nfunction auroraOklabToSrgb(lab: ArrayLike<number>): [number, number, number] {\n const l = (lab[0] + 0.3963377774 * lab[1] + 0.2158037573 * lab[2]) ** 3;\n const m = (lab[0] - 0.1055613458 * lab[1] - 0.0638541728 * lab[2]) ** 3;\n const s = (lab[0] - 0.0894841775 * lab[1] - 1.291485548 * lab[2]) ** 3;\n const r = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;\n const g = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;\n const b = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;\n return [toGamma(wrClamp(r, 0, 1)), toGamma(wrClamp(g, 0, 1)), toGamma(wrClamp(b, 0, 1))];\n}\n\n/** An sRGB colour as OKLCh: lightness, chroma and the hue in radians, which is what the shader interpolates. */\nfunction auroraStop(rgb: ArrayLike<number>): [L: number, C: number, h: number] {\n const [L, a, b] = auroraSrgbToOklab(rgb);\n return [L, Math.hypot(a, b), Math.atan2(b, a)];\n}\n\n/** An OKLCh colour as sRGB. */\nfunction auroraStopToSrgb(lch: ArrayLike<number>): [number, number, number] {\n return auroraOklabToSrgb([lch[0], lch[1] * Math.cos(lch[2]), lch[1] * Math.sin(lch[2])]);\n}\n\n/** The signed turn from hue `from` to hue `to` along the shorter arc, in radians. */\nfunction auroraHueArc(from: number, to: number): number {\n const tau = Math.PI * 2;\n return ((((to - from + Math.PI) % tau) + tau) % tau) - Math.PI;\n}\n\n/**\n * The colour `u` of the way across the three stops, in OKLCh: the first at\n * nought, the second midway, the third at one, each held on a short plateau\n * by the smoothstep between them; lightness and chroma move linearly and the\n * hue walks the shorter arc. The shader's own formula.\n */\nfunction auroraColorAt(stops: readonly ArrayLike<number>[], u: number): [L: number, C: number, h: number] {\n const x = wrClamp(u, 0, 1);\n const [a, b, t] = x < 0.5 ? [stops[0], stops[1], x * 2] : [stops[1], stops[2], x * 2 - 1];\n const s = t * t * (3 - 2 * t);\n return [a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s, a[2] + auroraHueArc(a[2], b[2]) * s];\n}\n\nfunction smoothstep(edge0: number, edge1: number, x: number): number {\n const t = wrClamp((x - edge0) / (edge1 - edge0), 0, 1);\n return t * t * (3 - 2 * t);\n}\n\nexport {\n BORDER,\n BORDER_AT,\n BORDER_WIDTH,\n EDGE_SOFT,\n FOLD_FLOOR,\n FOLLOW_LIFT,\n FOLLOW_RATE,\n FOLLOW_REACH,\n FOLLOW_SETTLE,\n FPS,\n FRAME_MS,\n GLOW_LIFT,\n GLOW_PEAK,\n HEIGHT_MAX,\n HEIGHT_MIN,\n HUE_DRIFT,\n INTRO_REACH_START,\n INTRO_S,\n LAYERS_MAX,\n PIXELS,\n PROFILE_FLOOR,\n RATIO_MAX,\n RATIO_MIN,\n RAY_DRIFT,\n RAY_FALL,\n RAY_FREQ,\n RAY_GAIN,\n RAY_SHORT,\n SIDE_MAX,\n SIDE_MIN,\n SIDE_SHARE,\n VEIL,\n VEIL_POWER,\n WASH_ALPHA,\n WASH_CHROMA,\n WASH_CHROMA_MAX,\n WASH_DETAIL,\n WASH_FOLD_FLOOR,\n WASH_L,\n WASH_RAY,\n WASH_RISE,\n WASH_SOFT,\n WAVE,\n WAVE_DRIFT,\n WAVE_FREQ,\n auroraApproach,\n auroraColorAt,\n auroraDriftLive,\n auroraEdgeSign,\n auroraFactor,\n auroraFollowTarget,\n auroraHeight,\n auroraHueArc,\n auroraIntensity,\n auroraIntro,\n auroraLayers,\n auroraLight,\n auroraOklabToSrgb,\n auroraProfile,\n auroraRatio,\n auroraRay,\n auroraShare,\n auroraSideFade,\n auroraSrgbToOklab,\n auroraStop,\n auroraStopToSrgb,\n auroraWashColor,\n auroraWashShape,\n auroraWave,\n};\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport {\n BORDER,\n BORDER_AT,\n BORDER_WIDTH,\n EDGE_SOFT,\n FOLD_FLOOR,\n GLOW_LIFT,\n LAYERS_MAX,\n PROFILE_FLOOR,\n RAY_FALL,\n RAY_GAIN,\n RAY_SHORT,\n VEIL,\n VEIL_POWER,\n WASH_CHROMA_MAX,\n WASH_DETAIL,\n WASH_FOLD_FLOOR,\n WASH_RAY,\n WASH_RISE,\n WASH_SOFT,\n} from './aurora-model';\n\n/**\n * The one pass `<wr-aurora>` draws: a full-screen quad whose fragment shader\n * lights, for its pixel, up to three curtains hanging from one edge of the\n * region. A curtain's free edge is a slow wave, three octaves of smooth\n * noise across the width; the pixel's place between the anchored edge and\n * that wave gives it the vertical profile (dim at the root, brightest just\n * short of the free edge, soft past it), fine noise across the width makes\n * the rays, leaning with the wave and shimmering on a clock of their own,\n * and the colour is the three stops interpolated in OKLCh at the pixel's\n * place across the width, the hue drifting with the wave. The curtains sit\n * at depths: the farther one is broader, slower, dimmer and moves less with\n * the pointer. They are composited back to front inside the shader.\n *\n * Two ways to lay the result, mixed by `uLook.z`. On a light surface the\n * curtain is a wash, a pale pastel: the stop's hue at one high lightness and\n * a fraction of its chroma, laid at an alpha that follows a softer shape\n * than the curtain's (no bright border, a wave with less fine detail, a long\n * dissolve past the free edge, the rays a whisper), so it dissolves into the\n * surface with no edge and never falls to grey. On a dark one it is light:\n * the colour scaled by the brightness in the colour channels with half that\n * in alpha, so it adds to the surface rather than covering it, the brightest\n * spots lifted toward white. The output is premultiplied either way. GLSL\n * ES 1.00, which WebGL1 and WebGL2 both accept.\n */\n\ntype AuroraGLContext = WebGLRenderingContext | WebGL2RenderingContext;\n\n/** What one frame needs, every length in CSS px unless said otherwise. */\ninterface AuroraFrame {\n /** The canvas, in device px. */\n width: number;\n height: number;\n /** CSS px per device px: the inverse of the render ratio. */\n scale: number;\n /** The region's CSS size. */\n regionWidth: number;\n regionHeight: number;\n /** One hangs from the top, minus one from the bottom; and minus one under RTL, so the stops run from the inline start. */\n edge: number;\n mirror: number;\n /** The curtain's reach as a share of the region, the wave as a share of that, and the wave's and the rays' frequency across the width. */\n reach: number;\n wave: number;\n waveFrequency: number;\n rayFrequency: number;\n /** The clocks: the wave's, the rays' and the hue's, in noise cells. */\n waveTime: number;\n rayTime: number;\n hueTime: number;\n /** How many curtains, one to three. */\n layers: number;\n /** The rays' strength, the glow multiplier, one for a wash on a light surface and nought for light on a dark one, and how far in from each side the curtain fades. */\n rays: number;\n glow: number;\n light: number;\n sideFade: number;\n /** The intro's fade and reach, both shares; and the drift toward the pointer, across as a share of the width and the stretch as a share of the reach. */\n introFade: number;\n introReach: number;\n driftAcross: number;\n driftStretch: number;\n /** The three stops in OKLCh: lightness, chroma, hue in radians. */\n stops: readonly Float32Array[];\n /** The wash: its peak alpha, the lightness it lays every stop at and the share of a stop's chroma it keeps; the light: its peak strength. */\n washAlpha: number;\n washLightness: number;\n washChroma: number;\n glowPeak: number;\n}\n\ninterface AuroraRenderer {\n /** Draws the frame onto the canvas. */\n render(frame: AuroraFrame): void;\n /** Frees the program and the quad. */\n destroy(): void;\n}\n\nconst VERTEX = `\nattribute vec2 aPosition;\nvoid main () {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n}`;\n\nconst FRAGMENT = `\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nconst int LAYERS_MAX = ${LAYERS_MAX};\nconst float EDGE_SOFT = ${EDGE_SOFT.toFixed(4)};\nconst float PROFILE_FLOOR = ${PROFILE_FLOOR.toFixed(4)};\nconst float VEIL = ${VEIL.toFixed(4)};\nconst float VEIL_POWER = ${VEIL_POWER.toFixed(4)};\nconst float BORDER = ${BORDER.toFixed(4)};\nconst float BORDER_AT = ${BORDER_AT.toFixed(4)};\nconst float BORDER_WIDTH = ${BORDER_WIDTH.toFixed(4)};\nconst float FOLD_FLOOR = ${FOLD_FLOOR.toFixed(4)};\nconst float RAY_GAIN = ${RAY_GAIN.toFixed(4)};\nconst float RAY_FALL = ${RAY_FALL.toFixed(4)};\nconst float RAY_SHORT = ${RAY_SHORT.toFixed(4)};\nconst float GLOW_LIFT = ${GLOW_LIFT.toFixed(4)};\nconst float WASH_RISE = ${WASH_RISE.toFixed(4)};\nconst float WASH_SOFT = ${WASH_SOFT.toFixed(4)};\nconst float WASH_FOLD_FLOOR = ${WASH_FOLD_FLOOR.toFixed(4)};\nconst float WASH_RAY = ${WASH_RAY.toFixed(4)};\nconst float WASH_DETAIL = ${WASH_DETAIL.toFixed(4)};\nconst float WASH_CHROMA_MAX = ${WASH_CHROMA_MAX.toFixed(4)};\nconst float PI = 3.14159265;\nconst float TAU = 6.28318531;\nuniform vec2 uSize;\nuniform float uScale;\nuniform vec2 uAxis;\nuniform vec4 uShape;\nuniform vec4 uMotion;\nuniform vec4 uLook;\nuniform vec4 uState;\nuniform vec3 uStops[3];\nuniform vec4 uTone;\n\nfloat hash (vec2 p) {\n vec3 q = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));\n q += dot(q, q.yzx + 19.19);\n return fract((q.x + q.y) * q.z);\n}\n\n// Value noise in -1..1, quintic-smoothed.\nfloat noise (vec2 x) {\n vec2 p = floor(x);\n vec2 w = fract(x);\n vec2 u = w * w * w * (w * (w * 6.0 - 15.0) + 10.0);\n float a = hash(p);\n float b = hash(p + vec2(1.0, 0.0));\n float c = hash(p + vec2(0.0, 1.0));\n float d = hash(p + vec2(1.0, 1.0));\n return mix(mix(a, b, u.x), mix(c, d, u.x), u.y) * 2.0 - 1.0;\n}\n\nfloat toGamma (float c) {\n return c <= 0.0031308 ? c * 12.92 : 1.055 * pow(c, 1.0 / 2.4) - 0.055;\n}\n\n// OKLCh to sRGB, clipped to the gamut.\nvec3 oklchToSrgb (vec3 lch) {\n vec3 lab = vec3(lch.x, lch.y * cos(lch.z), lch.y * sin(lch.z));\n float l = lab.x + 0.3963377774 * lab.y + 0.2158037573 * lab.z;\n float m = lab.x - 0.1055613458 * lab.y - 0.0638541728 * lab.z;\n float s = lab.x - 0.0894841775 * lab.y - 1.2914855480 * lab.z;\n l = l * l * l;\n m = m * m * m;\n s = s * s * s;\n vec3 lin = clamp(vec3(\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s), 0.0, 1.0);\n return vec3(toGamma(lin.r), toGamma(lin.g), toGamma(lin.b));\n}\n\n// The stops at u across: the first at nought, the second midway, the third at one, the hue on the shorter arc.\nvec3 stopAt (float u) {\n float x = clamp(u, 0.0, 1.0);\n vec3 a = x < 0.5 ? uStops[0] : uStops[1];\n vec3 b = x < 0.5 ? uStops[1] : uStops[2];\n float t = x < 0.5 ? x * 2.0 : x * 2.0 - 1.0;\n t = t * t * (3.0 - 2.0 * t);\n float dh = mod(b.z - a.z + PI, TAU) - PI;\n return vec3(mix(a.x, b.x, t), mix(a.y, b.y, t), a.z + dh * t);\n}\n\nvoid main () {\n // The pixel in CSS px, x from the inline start, y from the anchored edge.\n vec2 p = vec2(gl_FragCoord.x * uScale, uSize.y - gl_FragCoord.y * uScale);\n if (uAxis.x < 0.0) p.y = uSize.y - p.y;\n float u = p.x / uSize.x;\n if (uAxis.y < 0.0) u = 1.0 - u;\n float side = smoothstep(0.0, 1.0, min(p.x, uSize.x - p.x) / uLook.w);\n if (side <= 0.0) {\n gl_FragColor = vec4(0.0);\n return;\n }\n\n vec4 acc = vec4(0.0);\n for (int i = LAYERS_MAX - 1; i >= 0; i--) {\n if (float(i) >= uMotion.w) continue;\n // The curtain's depth: nought in front, one at the back, which is broader, slower, dimmer and moves less.\n float depth = float(i) / max(uMotion.w - 1.0, 1.0);\n float broad = 1.0 + 0.7 * depth;\n float dim = 1.0 - 0.45 * depth;\n float seed = float(i) * 17.0;\n float ux = u - uState.z * (1.0 - 0.6 * depth);\n\n // The free edge: three octaves across the width, on the wave's clock.\n float wt = uMotion.x / broad + seed;\n float nx = ux * uShape.z / broad;\n float n1 = noise(vec2(nx, wt));\n float n2 = noise(vec2(nx * 2.3 + 5.1, wt * 1.4 + 2.0));\n float n3 = noise(vec2(nx * 4.7 + 11.0, wt * 1.9 + 7.0));\n float w = clamp((n1 + 0.6 * n2 + 0.3 * n3) / 1.4, -1.0, 1.0);\n float stretch = uSize.y * uShape.x * (1.0 + 0.12 * depth) * uState.y * (1.0 + uState.w);\n float reach = uSize.y * uShape.x * (1.0 + uShape.y * w) * (1.0 + 0.12 * depth) * uState.y * (1.0 + uState.w);\n reach = min(max(reach, 1.0), uSize.y);\n float v = p.y / reach;\n // The wash has a wave of its own, with less of the finer octaves: a broad, slow edge. Kept apart from the\n // curtain's, so the light's arithmetic is what it was.\n float wl = clamp((n1 + WASH_DETAIL * (0.6 * n2 + 0.3 * n3)) / (1.0 + 0.9 * WASH_DETAIL), -1.0, 1.0);\n float vl = p.y / min(max(stretch * (1.0 + uShape.y * wl), 1.0), uSize.y);\n if (v > 1.0 + EDGE_SOFT && (uLook.z <= 0.0 || vl > 1.0 + WASH_SOFT)) continue;\n float vc = clamp(v, 0.0, 1.0);\n\n // The vertical profile: a veil, faint at the root and growing toward the free edge, a bright border\n // just short of that edge, and both soft past it.\n float veil = mix(PROFILE_FLOOR, VEIL, pow(vc, VEIL_POWER));\n float b = (v - BORDER_AT) / BORDER_WIDTH;\n float border = BORDER * exp(-b * b);\n float fade = 1.0 - smoothstep(1.0 - EDGE_SOFT, 1.0 + EDGE_SOFT * 0.6, v);\n\n // The folds: the curtain is bright in knots along its length and dimmer between them, on the wave's clock.\n float knot = smoothstep(-0.9, 0.9, noise(vec2(nx * 1.3 + 7.7, wt * 0.9 + 3.3)));\n float fold = mix(FOLD_FLOOR, 1.0, knot);\n\n // The rays: columns across the width, each with a brightness and a length of its own, leaning with the\n // wave toward the root, shimmering on their own clock; a ray is whole at the free edge and fades toward\n // the root, the shorter the faster. At a unit rays half the veil goes, the border is beaded and the rays\n // rise over it.\n float rx = (ux + 0.04 * w * (1.0 - vc)) * uShape.w / broad + seed;\n float c = 0.5 + 0.5 * (0.65 * noise(vec2(rx, uMotion.y + seed)) + 0.35 * noise(vec2(rx * 2.3 + 3.0, uMotion.y * 1.6 + 1.0)));\n c = smoothstep(0.25, 0.95, c);\n float len = mix(RAY_SHORT, 1.0, 0.5 + 0.5 * noise(vec2(rx * 0.21 + 9.0, uMotion.y * 0.35 + seed)));\n float ray = c * exp(-(1.0 - vc) * RAY_FALL / len);\n float bead = mix(1.0, 0.6 + 0.4 * c, uLook.x);\n float shape = min(1.0, veil * (1.0 - 0.5 * uLook.x) + border * bead + uLook.x * RAY_GAIN * ray);\n float I = shape * fade * fold * dim * side * uState.x * uLook.y;\n\n // The wash's shape: one broad bump, whole from WASH_RISE, dissolving long past the free edge, the folds\n // shallow and the rays a whisper over it.\n float washShape = smoothstep(0.0, WASH_RISE, vl) * (1.0 - smoothstep(WASH_RISE - 0.1, 1.0 + WASH_SOFT, vl));\n washShape *= mix(WASH_FOLD_FLOOR, 1.0, knot) * (1.0 + uLook.x * WASH_RAY * (ray - 0.5));\n float W = washShape * dim * side * uState.x * uLook.y;\n if (mix(I, W, uLook.z) <= 0.0) continue;\n\n // The colour: the stops across the width, the hue carried a little by the wave and the clock.\n vec3 lch = stopAt(ux + 0.1 * mix(w, wl, uLook.z) + 0.15 * depth + 0.04 * sin(uMotion.z + seed));\n\n // A wash on a light surface: the stop's hue at one high lightness and a share of its chroma, at an alpha\n // that follows the wash's shape.\n float a = min(1.0, W * uTone.x);\n vec3 washRgb = oklchToSrgb(vec3(uTone.y, min(lch.y * uTone.z, WASH_CHROMA_MAX), lch.z));\n vec4 wash = vec4(washRgb * a, a);\n\n // Light on a dark surface: the colour by the glow, half as much alpha, the brightest spots lifted toward white.\n float k = min(1.0, I * uTone.w);\n vec3 glowRgb = oklchToSrgb(vec3(lch.x + GLOW_LIFT * k * k, lch.y, lch.z));\n vec4 glow = vec4(glowRgb * k, k * 0.5);\n\n vec4 layer = mix(glow, wash, uLook.z);\n acc = layer + acc * (1.0 - layer.a);\n }\n gl_FragColor = acc;\n}`;\n\nconst UNIFORMS = ['uSize', 'uScale', 'uAxis', 'uShape', 'uMotion', 'uLook', 'uState', 'uStops', 'uTone'] as const;\n\ntype AuroraUniform = (typeof UNIFORMS)[number];\n\nclass Renderer implements AuroraRenderer {\n private readonly program: WebGLProgram;\n private readonly quad: WebGLBuffer;\n private readonly uniforms: Record<AuroraUniform, WebGLUniformLocation | null>;\n private readonly stops = new Float32Array(9);\n\n constructor(private readonly gl: AuroraGLContext) {\n const quad = gl.createBuffer();\n if (!quad) throw new Error('aurora: no buffer');\n this.quad = quad;\n gl.bindBuffer(gl.ARRAY_BUFFER, quad);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);\n gl.disable(gl.BLEND);\n gl.disable(gl.DEPTH_TEST);\n\n const vertex = this.shader(gl.VERTEX_SHADER, VERTEX);\n const fragment = this.shader(gl.FRAGMENT_SHADER, FRAGMENT);\n const program = gl.createProgram();\n if (!program) throw new Error('aurora: no program');\n gl.attachShader(program, vertex);\n gl.attachShader(program, fragment);\n gl.bindAttribLocation(program, 0, 'aPosition');\n gl.linkProgram(program);\n gl.deleteShader(vertex);\n gl.deleteShader(fragment);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`aurora: program failed: ${log ?? ''}`);\n }\n this.program = program;\n const uniforms = {} as Record<AuroraUniform, WebGLUniformLocation | null>;\n for (const name of UNIFORMS) uniforms[name] = gl.getUniformLocation(program, name);\n this.uniforms = uniforms;\n }\n\n render(frame: AuroraFrame): void {\n const { gl, uniforms, stops } = this;\n gl.useProgram(this.program);\n gl.uniform2f(uniforms.uSize, frame.regionWidth, frame.regionHeight);\n gl.uniform1f(uniforms.uScale, frame.scale);\n gl.uniform2f(uniforms.uAxis, frame.edge, frame.mirror);\n gl.uniform4f(uniforms.uShape, frame.reach, frame.wave, frame.waveFrequency, frame.rayFrequency);\n gl.uniform4f(uniforms.uMotion, frame.waveTime, frame.rayTime, frame.hueTime, frame.layers);\n gl.uniform4f(uniforms.uLook, frame.rays, frame.glow, frame.light, frame.sideFade);\n gl.uniform4f(uniforms.uState, frame.introFade, frame.introReach, frame.driftAcross, frame.driftStretch);\n for (let i = 0; i < 3; i++) stops.set(frame.stops[i], i * 3);\n gl.uniform3fv(uniforms.uStops, stops);\n gl.uniform4f(uniforms.uTone, frame.washAlpha, frame.washLightness, frame.washChroma, frame.glowPeak);\n\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.viewport(0, 0, frame.width, frame.height);\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n gl.bindBuffer(gl.ARRAY_BUFFER, this.quad);\n gl.enableVertexAttribArray(0);\n gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n destroy(): void {\n const { gl } = this;\n gl.deleteBuffer(this.quad);\n gl.deleteProgram(this.program);\n }\n\n private shader(kind: number, source: string): WebGLShader {\n const { gl } = this;\n const shader = gl.createShader(kind);\n if (!shader) throw new Error('aurora: no shader');\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`aurora: shader failed: ${log ?? ''}`);\n }\n return shader;\n }\n}\n\n/**\n * The attributes the canvas's context is asked for: premultiplied alpha,\n * which is what the pass writes, no antialiasing (the drawing is soft and\n * upscaled) and no buffer the pass does not use.\n */\nconst AURORA_CONTEXT_ATTRIBUTES: WebGLContextAttributes = {\n alpha: true,\n premultipliedAlpha: true,\n antialias: false,\n depth: false,\n stencil: false,\n preserveDrawingBuffer: false,\n powerPreference: 'low-power',\n};\n\n/** A renderer on `gl`, or `null` where the shader will not compile or link. */\nfunction createAuroraRenderer(gl: AuroraGLContext): AuroraRenderer | null {\n try {\n return new Renderer(gl);\n } catch {\n return null;\n }\n}\n\nexport { AURORA_CONTEXT_ATTRIBUTES, UNIFORMS as AURORA_UNIFORMS, createAuroraRenderer };\nexport type { AuroraFrame, AuroraGLContext, AuroraRenderer, AuroraUniform };\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n PLATFORM_ID,\n ViewEncapsulation,\n afterNextRender,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n untracked,\n viewChild,\n} from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrResolveCssColorChannels, wrWatchColorScheme, wrCheckStyles } from 'ngwr/utils';\n\nimport { FRAME_FLOOR_SLACK, MAX_FRAME_MS } from '../internal';\n\nimport {\n AURORA_CONTEXT_ATTRIBUTES,\n type AuroraFrame,\n type AuroraGLContext,\n type AuroraRenderer,\n createAuroraRenderer,\n} from './aurora-gl';\nimport {\n FRAME_MS,\n GLOW_PEAK,\n HUE_DRIFT,\n RAY_DRIFT,\n RAY_FREQ,\n WASH_ALPHA,\n WASH_CHROMA,\n WASH_L,\n WAVE_DRIFT,\n WAVE_FREQ,\n auroraApproach,\n auroraDriftLive,\n auroraEdgeSign,\n auroraFactor,\n auroraFollowTarget,\n auroraHeight,\n auroraIntro,\n auroraLayers,\n auroraLight,\n auroraRatio,\n auroraShare,\n auroraSideFade,\n auroraStop,\n auroraWave,\n} from './aurora-model';\nimport type { WrAuroraEdge } from './types';\n\n/** The stops' fallbacks where a hook resolves to nothing: green, blue, violet. */\nconst FALLBACK_STOPS = ['#008800', '#3969e2', '#8a4fcf'] as const;\n\n/**\n * A curtain of light hanging from one edge of a section and reaching part of\n * the way in, like an aurora: its free edge a slow broad wave, fine rays\n * shimmering inside it, brightest just short of the free edge and fading\n * toward the one it hangs from, its colour flowing across the width through\n * three stops from the theme. Up to three curtains hang at different depths,\n * the farther one broader, slower and dimmer, so they move in parallax, and\n * the whole drifts gently toward the pointer. On a light surface it is a\n * pale pastel wash that dissolves into the surface; on a dark one it is\n * light added to the surface. The drawing is one WebGL pass in\n * `aurora-gl.ts`, drawn at half resolution at most and scaled up by the\n * browser, since nothing in it is sharp; the pure pieces (the profile, the\n * rays, the intro, the drift, the colour stops in OKLCh, the canvas size and\n * the frame cap) are `aurora-model.ts`.\n *\n * Fills its positioned parent, which isolates itself, so the host's negative\n * z-index lands under the content and over the page background. The parent\n * takes the pointer, passively: the host and its canvas never do, and a\n * finger is ignored, so a scroll over the section is never fought. The\n * context is made when the host is first on screen and sized, not at mount,\n * so a region nobody scrolls to costs nothing; the loop runs while the host\n * is on screen and the document is visible, at thirty frames a second, and\n * with `speed` at none only while the intro or the drift still moves.\n *\n * Colours come from the `--wr-aurora-color-1`, `-2` and `-3` hooks through\n * `wrResolveCssColorChannels`, re-read when the scheme changes; the surface is\n * read too, which decides between the wash and the light. Under\n * `prefers-reduced-motion: reduce` one still frame is drawn, whole and at\n * rest; under `forced-colors: active` nothing is; without WebGL nothing is;\n * on the server the empty canvas is rendered, absolutely positioned, so the\n * browser's first draw shifts no layout. A lost context is let go and rebuilt\n * when it comes back. Decorative: `aria-hidden`, no pointer events. Styles:\n * `@use 'ngwr/animations/aurora'`.\n */\n@Component({\n selector: 'wr-aurora',\n templateUrl: './aurora.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-aurora', 'aria-hidden': 'true' },\n})\nexport class WrAurora {\n /** The edge the curtain hangs from. @default 'top' */\n readonly edge = input<WrAuroraEdge>('top');\n /** How far into the region the curtain reaches, as a share of its height, from 0.1 to 1. @default 0.5 */\n readonly height = input(0.5, { transform: wrNumAttr(0.5) });\n /** How far the free edge's wave moves it, a multiplier: one is about a quarter of the curtain's height; none is a straight edge. @default 1 */\n readonly amplitude = input(1, { transform: wrNumAttr(1) });\n /** The size of the shapes, a multiplier: one puts about a wave and a half across the width; more is broader. @default 1 */\n readonly scale = input(1, { transform: wrNumAttr(1) });\n /** How fast the wave, the rays and the hue move, a multiplier: none holds the curtain still. @default 1 */\n readonly speed = input(1, { transform: wrNumAttr(1) });\n /** How strong the light is, a multiplier on the wash's alpha and the glow. @default 1 */\n readonly glow = input(1, { transform: wrNumAttr(1) });\n /** How strongly the rays show, from none to one. @default 0.6 */\n readonly rays = input(0.6, { transform: wrNumAttr(0.6) });\n /** How many curtains hang at different depths, from one to three. @default 2 */\n readonly layers = input(2, { transform: wrNumAttr(2) });\n /** Whether the curtain fades and lengthens in when first on screen. @default false */\n readonly intro = input(false, { transform: booleanAttribute });\n /** Whether the curtain drifts gently toward the pointer over the parent. @default true */\n readonly follow = input(true, { transform: booleanAttribute });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private readonly dir = inject(Directionality, { optional: true });\n private readonly canvasRef = viewChild.required<ElementRef<HTMLCanvasElement>>('canvas');\n /** The stops run from the inline start: under RTL that is the right. */\n private readonly mirrored = computed(() => this.dir?.valueSignal() === 'rtl');\n\n private gl: AuroraGLContext | null = null;\n private renderer: AuroraRenderer | null = null;\n /** Set once the browser was asked for a context, so a refusal is not asked again. */\n private contextTried = false;\n\n /** The host's CSS size, zero until the first layout. */\n private regionWidth = 0;\n private regionHeight = 0;\n private readonly frame: AuroraFrame = {\n width: 0,\n height: 0,\n scale: 1,\n regionWidth: 0,\n regionHeight: 0,\n edge: 1,\n mirror: 1,\n reach: 0.5,\n wave: 0,\n waveFrequency: WAVE_FREQ,\n rayFrequency: RAY_FREQ,\n waveTime: 0,\n rayTime: 0,\n hueTime: 0,\n layers: 2,\n rays: 0.6,\n glow: 1,\n light: 1,\n sideFade: 0,\n introFade: 1,\n introReach: 1,\n driftAcross: 0,\n driftStretch: 0,\n stops: [new Float32Array(3), new Float32Array(3), new Float32Array(3)],\n washAlpha: WASH_ALPHA,\n washLightness: WASH_L,\n washChroma: WASH_CHROMA,\n glowPeak: GLOW_PEAK,\n };\n\n /** The scene's clock in seconds, moving only while a frame runs, so a hidden tab holds the pose; and the motion's own, scaled by `speed`. */\n private time = 0;\n private motion = 0;\n /** When the intro began on the scene's clock; NaN before it has. */\n private introAt = NaN;\n /** Where the pointer is over the parent, in CSS px from the host's top left; NaN when it is not. */\n private pointerX = NaN;\n private pointerY = NaN;\n /** The drift toward the pointer, across and the stretch, and where it is heading. */\n private across = 0;\n private stretch = 0;\n private target: [number, number] = [0, 0];\n\n private running = false;\n private rafId: number | null = null;\n private lastFrame = 0;\n private resizeRafId: number | null = null;\n private pendingWidth = 0;\n private pendingHeight = 0;\n private inView = false;\n private mounted = false;\n\n private resizeObserver: ResizeObserver | null = null;\n private viewObserver: IntersectionObserver | null = null;\n private pointerTarget: HTMLElement | null = null;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/aurora');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n effect(() => {\n this.platform.pageVisible();\n this.platform.prefersReducedMotion();\n this.speed();\n untracked(() => this.sync());\n });\n effect(() => {\n this.edge();\n this.height();\n this.amplitude();\n this.scale();\n this.glow();\n this.rays();\n this.layers();\n this.mirrored();\n untracked(() => this.still());\n });\n effect(() => {\n this.follow();\n untracked(() => {\n this.retarget();\n this.sync();\n });\n });\n wrWatchColorScheme(() => {\n this.resolveColors();\n this.still();\n });\n\n afterNextRender(() => this.mount());\n inject(DestroyRef).onDestroy(() => this.unmount());\n }\n\n // Lifecycle\n\n private mount(): void {\n // Nothing drawn under forced colours: the stylesheet hides the host too.\n if (this.doc.defaultView?.matchMedia?.('(forced-colors: active)').matches) return;\n const host = this.host.nativeElement;\n this.mounted = true;\n\n if (typeof ResizeObserver !== 'undefined') {\n this.resizeObserver = new ResizeObserver(entries => {\n const rect = entries[entries.length - 1]?.contentRect;\n this.scheduleResize(rect?.width ?? host.clientWidth, rect?.height ?? host.clientHeight);\n });\n this.resizeObserver.observe(host);\n } else {\n this.layout(host.clientWidth, host.clientHeight);\n }\n\n if (typeof IntersectionObserver !== 'undefined') {\n this.viewObserver = new IntersectionObserver(entries => {\n this.inView = entries[entries.length - 1]?.isIntersecting ?? false;\n this.sync();\n });\n this.viewObserver.observe(host);\n } else {\n this.inView = true;\n this.sync();\n }\n\n const canvas = this.canvasRef().nativeElement;\n canvas.addEventListener('webglcontextlost', this.onContextLost);\n canvas.addEventListener('webglcontextrestored', this.onContextRestored);\n\n const target = host.parentElement;\n this.pointerTarget = target;\n target?.addEventListener('pointermove', this.onPointerMove, { passive: true });\n target?.addEventListener('pointerleave', this.onPointerLeave, { passive: true });\n }\n\n private unmount(): void {\n this.running = false;\n this.stopLoop();\n if (this.resizeRafId !== null) cancelAnimationFrame(this.resizeRafId);\n this.resizeRafId = null;\n this.resizeObserver?.disconnect();\n this.resizeObserver = null;\n this.viewObserver?.disconnect();\n this.viewObserver = null;\n this.pointerTarget?.removeEventListener('pointermove', this.onPointerMove);\n this.pointerTarget?.removeEventListener('pointerleave', this.onPointerLeave);\n this.pointerTarget = null;\n if (this.mounted) {\n const canvas = this.canvasRef().nativeElement;\n canvas.removeEventListener('webglcontextlost', this.onContextLost);\n canvas.removeEventListener('webglcontextrestored', this.onContextRestored);\n }\n this.renderer?.destroy();\n this.renderer = null;\n // The context itself is let go now rather than when the canvas is collected.\n this.gl?.getExtension('WEBGL_lose_context')?.loseContext();\n this.gl = null;\n this.mounted = false;\n }\n\n // Context\n\n /** The context and the renderer, made at the first chance to draw; `null` where the browser has no WebGL. */\n private ensure(): AuroraRenderer | null {\n if (this.renderer) return this.renderer;\n if (this.contextTried || !this.mounted) return null;\n this.contextTried = true;\n const canvas = this.canvasRef().nativeElement;\n const gl =\n canvas.getContext('webgl2', AURORA_CONTEXT_ATTRIBUTES) ?? canvas.getContext('webgl', AURORA_CONTEXT_ATTRIBUTES);\n if (!gl) return null;\n this.gl = gl;\n this.renderer = createAuroraRenderer(gl);\n if (!this.renderer) return null;\n this.resolveColors();\n return this.renderer;\n }\n\n private readonly onContextLost = (event: Event): void => {\n // Not prevented, the browser never restores it.\n event.preventDefault();\n this.renderer = null;\n this.running = false;\n this.stopLoop();\n };\n\n private readonly onContextRestored = (): void => {\n if (!this.gl) return;\n this.renderer = createAuroraRenderer(this.gl);\n this.sync();\n };\n\n // Layout\n\n private scheduleResize(width: number, height: number): void {\n this.pendingWidth = width;\n this.pendingHeight = height;\n if (this.resizeRafId !== null) return;\n this.resizeRafId = requestAnimationFrame(() => {\n this.resizeRafId = null;\n this.layout(this.pendingWidth, this.pendingHeight);\n });\n }\n\n private layout(width: number, height: number): void {\n if (width <= 0 || height <= 0) return;\n this.regionWidth = width;\n this.regionHeight = height;\n this.retarget();\n this.sync();\n }\n\n /** Sizes the canvas to the host under the render ratio. */\n private size(): void {\n const canvas = this.canvasRef().nativeElement;\n const ratio = auroraRatio(this.regionWidth, this.regionHeight);\n const width = Math.max(1, Math.round(this.regionWidth * ratio));\n const height = Math.max(1, Math.round(this.regionHeight * ratio));\n if (canvas.width !== width) canvas.width = width;\n if (canvas.height !== height) canvas.height = height;\n this.frame.width = width;\n this.frame.height = height;\n this.frame.scale = this.regionWidth / width;\n }\n\n // Colours\n\n private resolveColors(): void {\n if (!this.renderer) return;\n const canvas = this.canvasRef().nativeElement;\n FALLBACK_STOPS.forEach((fallback, i) => {\n const rgb = wrResolveCssColorChannels(canvas, `var(--wr-aurora-color-${i + 1})`, fallback);\n this.frame.stops[i].set(auroraStop(rgb));\n });\n const light = auroraLight(wrResolveCssColorChannels(canvas, 'var(--wr-color-surface)', '#ffffff'));\n this.frame.light = light ? 1 : 0;\n }\n\n // Pointer\n\n private readonly onPointerMove = (event: PointerEvent): void => {\n // A finger that moves is scrolling: the curtain must never fight it. Nothing to follow under reduced motion or with `follow` off.\n if (\n event.pointerType === 'touch' ||\n this.regionWidth === 0 ||\n !untracked(this.follow) ||\n this.platform.prefersReducedMotion()\n ) {\n return;\n }\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pointerX = event.clientX - rect.left;\n this.pointerY = event.clientY - rect.top;\n this.retarget();\n this.sync();\n };\n\n private readonly onPointerLeave = (): void => {\n if (Number.isNaN(this.pointerX)) return;\n this.pointerX = NaN;\n this.pointerY = NaN;\n this.retarget();\n this.sync();\n };\n\n /** Where the drift is heading, from the pointer; nothing under reduced motion or with `follow` off. */\n private retarget(): void {\n if (this.platform.prefersReducedMotion() || !untracked(this.follow)) {\n this.target = [0, 0];\n return;\n }\n const reach = auroraHeight(untracked(this.height));\n this.target = auroraFollowTarget(this.pointerX, this.pointerY, this.regionWidth, this.regionHeight, reach);\n }\n\n // Loop\n\n /** Whether anything moves while `speed` is none: the intro, or the drift toward the pointer. */\n private live(): boolean {\n return (\n (!Number.isNaN(this.introAt) && this.frame.introFade < 1) ||\n auroraDriftLive(this.across, this.stretch, this.target)\n );\n }\n\n private sync(): void {\n const reduced = this.platform.prefersReducedMotion();\n const allowed = this.mounted && this.regionWidth > 0 && this.inView && this.platform.pageVisible();\n const run = allowed && !reduced && (untracked(this.speed) > 0 || this.live());\n if (run !== this.running) {\n this.running = run;\n if (run) {\n this.lastFrame = performance.now();\n this.rafId = requestAnimationFrame(this.frameLoop);\n return;\n }\n this.stopLoop();\n }\n // Allowed but not running: one still frame, under reduced motion whole and at rest, however the pointer sits.\n if (allowed && !run) {\n if (reduced) this.rest();\n this.still();\n }\n }\n\n /** Everything beyond the curtain gone at once: the still frame has no drift and no intro in it. */\n private rest(): void {\n this.introAt = NaN;\n this.frame.introFade = 1;\n this.frame.introReach = 1;\n this.across = 0;\n this.stretch = 0;\n this.target = [0, 0];\n }\n\n private stopLoop(): void {\n if (this.rafId !== null) cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n\n /** One frame drawn outside the loop: the reduced-motion still, and a resize or a retheme while the loop is off. */\n private still(): void {\n if (this.running || !this.mounted || this.regionWidth === 0 || !this.inView) return;\n this.draw();\n }\n\n private readonly frameLoop = (now: number): void => {\n this.rafId = null;\n if (!this.running) return;\n if (now - this.lastFrame + FRAME_FLOOR_SLACK < FRAME_MS) {\n this.rafId = requestAnimationFrame(this.frameLoop);\n return;\n }\n const dt = Math.min(Math.max(now - this.lastFrame, 0), MAX_FRAME_MS) / 1000;\n this.lastFrame = now;\n this.advance(dt);\n this.draw();\n // Nothing left to move: the loop rests until the pointer, a resize or a retheme.\n if (untracked(this.speed) <= 0 && !this.live()) {\n this.running = false;\n return;\n }\n if (this.running) this.rafId = requestAnimationFrame(this.frameLoop);\n };\n\n /** The clocks move on and the drift follows its target. */\n private advance(dt: number): void {\n this.time += dt;\n this.motion += dt * Math.max(0, untracked(this.speed));\n this.across = auroraApproach(this.across, this.target[0], dt);\n this.stretch = auroraApproach(this.stretch, this.target[1], dt);\n if (!auroraDriftLive(this.across, this.stretch, this.target)) {\n [this.across, this.stretch] = this.target;\n }\n }\n\n /** The frame's numbers from the inputs and the state, and the pass. */\n private draw(): void {\n const renderer = this.ensure();\n if (!renderer || this.regionWidth === 0) return;\n const frame = this.frame;\n this.size();\n\n const scale = auroraFactor(untracked(this.scale), 1, 0.2);\n frame.regionWidth = this.regionWidth;\n frame.regionHeight = this.regionHeight;\n frame.edge = auroraEdgeSign(untracked(this.edge));\n frame.mirror = this.mirrored() ? -1 : 1;\n frame.reach = auroraHeight(untracked(this.height));\n frame.wave = auroraWave(untracked(this.amplitude));\n frame.waveFrequency = WAVE_FREQ / scale;\n frame.rayFrequency = RAY_FREQ / scale;\n frame.waveTime = this.motion * WAVE_DRIFT;\n frame.rayTime = this.motion * RAY_DRIFT;\n frame.hueTime = this.motion * HUE_DRIFT;\n frame.layers = auroraLayers(untracked(this.layers));\n frame.rays = auroraShare(untracked(this.rays), 0.6);\n frame.glow = auroraFactor(untracked(this.glow), 1);\n frame.sideFade = auroraSideFade(this.regionWidth);\n frame.driftAcross = this.across;\n frame.driftStretch = this.stretch;\n\n // The intro begins at the first drawn frame, when the host is sized and on screen.\n if (untracked(this.intro) && Number.isNaN(this.introAt) && !this.platform.prefersReducedMotion()) {\n this.introAt = this.time;\n }\n [frame.introFade, frame.introReach] = Number.isNaN(this.introAt) ? [1, 1] : auroraIntro(this.time - this.introAt);\n\n renderer.render(frame);\n }\n}\n\nexport { FALLBACK_STOPS };\n","<canvas #canvas class=\"wr-aurora__canvas\"></canvas>\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAM,aAAa;AAKnB,MAAM,OAAO;AAEb,MAAM,YAAY;AAGlB,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,YAAY;AAElB,MAAM,gBAAgB;AACtB,MAAM,OAAO;AACb,MAAM,aAAa;AAEnB,MAAM,SAAS;AACf,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,YAAY;AAElB,MAAM,aAAa;AAEnB,MAAM,WAAW;AACjB,MAAM,WAAW;AACjB,MAAM,YAAY;AAElB,MAAM,UAAU;AAChB,MAAM,oBAAoB;AAE1B,MAAM,cAAc;AACpB,MAAM,eAAe;AACrB,MAAM,cAAc;AAIpB,MAAM,aAAa;AAInB,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,SAAS;AAaf,MAAM,aAAa;AACnB,MAAM,SAAS;AACf,MAAM,cAAc;AACpB,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,kBAAkB;AACxB,MAAM,WAAW;AACjB,MAAM,cAAc;AAGpB,MAAM,YAAY;AAGlB,SAAS,aAAa,QAAc;CAClC,OAAO,QAAQ,OAAO,SAAS,MAAM,IAAI,SAAS,IAAK,YAAA,CAAsB;AAC/E;AAGA,SAAS,aAAa,QAAc;CAClC,OAAO,QAAQ,KAAK,MAAM,OAAO,SAAS,MAAM,IAAI,SAAS,CAAC,GAAG,GAAA,CAAa;AAChF;AAGA,SAAS,YAAY,OAAe,UAAgB;CAClD,OAAO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;GAAA,MAAA,CAAA,UAAQ,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-animations-blur-reveal.mjs","names":[],"sources":["../../../projects/lib/animations/blur-reveal/blur-reveal.ts","../../../projects/lib/animations/blur-reveal/public-api.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Directive, ElementRef, PLATFORM_ID, afterNextRender, inject, input } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\nimport { BREAKING_SPACES, VIEW_THRESHOLD, graphemes, optionalMs, staggerGap } from '../internal';\n\nimport type { WrBlurRevealBy, WrBlurRevealFrom } from './types';\n\n/**\n * One-shot entrance for a text element: the first time the host scrolls into\n * view its text comes in piece by piece, each one from blurred, transparent and\n * a little below its place to sharp, opaque and in place, in reading order. The\n * host keeps its own tag and its authored children: they are moved out while\n * the pieces play and the same nodes are moved back when the last piece lands,\n * so selection, find-in-page and Angular bindings inside work as before. While\n * split, the pieces are `aria-hidden` and a visually-hidden copy of the text\n * stands beside them, so a screen reader hears the sentence once. Nothing is\n * split under `prefers-reduced-motion: reduce`, on the server or without\n * `IntersectionObserver`.\n */\n@Directive({\n selector: '[wrBlurReveal]',\n host: {\n class: 'wr-blur-reveal',\n '[class.wr-blur-reveal--letters]': 'by() === \"letters\"',\n '[class.wr-blur-reveal--above]': 'from() === \"above\"',\n '(animationend)': 'onAnimationEnd($event)',\n '(animationcancel)': 'restore()',\n },\n})\nexport class WrBlurReveal {\n /**\n * What enters one at a time: a word, or a grapheme. In letter mode the\n * letters of one word sit in a no-wrap wrapper, so a word never breaks across\n * lines mid-word. @default 'words'\n */\n readonly by = input<WrBlurRevealBy>('words');\n\n /** The side a piece settles in from. @default 'below' */\n readonly from = input<WrBlurRevealFrom>('below');\n\n /**\n * Gap between the start of one piece and the next, in ms. Unset, the mode\n * decides: 70 for words, 28 for letters. Either way the whole reveal spreads\n * over 1.2 s at most, so for a long text the gap shrinks until the last piece\n * starts by then.\n */\n readonly stagger = input<number | null, unknown>(null, { transform: optionalMs });\n\n /** Pause between the host entering the viewport and the first piece, in ms. @default 0 */\n readonly delay = input(0, { transform: wrNumAttr(0) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private observer: IntersectionObserver | null = null;\n /** The host's authored children while they are out of the DOM, else `null`. */\n private original: ChildNode[] | null = null;\n private lastPiece: HTMLElement | null = null;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/blur-reveal');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion() || typeof IntersectionObserver === 'undefined') return;\n this.observer = new IntersectionObserver(\n entries => {\n if (!entries.some(entry => entry.isIntersecting)) return;\n this.observer?.disconnect();\n this.observer = null;\n if (!this.platform.prefersReducedMotion()) this.play();\n },\n { threshold: VIEW_THRESHOLD }\n );\n this.observer.observe(this.host.nativeElement);\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.observer?.disconnect();\n this.observer = null;\n this.restore();\n });\n }\n\n /** Last piece landed: the authored children go back. Another piece or a child's own animation is not it. */\n protected onAnimationEnd(event: Event): void {\n if (event.target === this.lastPiece) this.restore();\n }\n\n /**\n * Put the authored children back, the same node objects, and drop the\n * wrappers. Idempotent: the end of the last piece, a cancelled animation and\n * destroy all call it.\n */\n protected restore(): void {\n if (!this.original) return;\n const host = this.host.nativeElement;\n host.replaceChildren(...this.original);\n host.classList.remove('wr-blur-reveal--run');\n this.original = null;\n this.lastPiece = null;\n }\n\n /**\n * Split the authored children into pieces and start the animation in one\n * task. Each piece carries its index; the stylesheet turns that into a delay,\n * and `--run` is added by hand rather than through a binding because change\n * detection may run after the next paint, and that paint would show the\n * pieces sharp before they hide.\n */\n private play(): void {\n const host = this.host.nativeElement;\n const original = Array.from(host.childNodes);\n const text = host.textContent ?? '';\n const letters = this.by() === 'letters';\n const pieces = document.createElement('span');\n pieces.className = 'wr-blur-reveal__pieces';\n pieces.setAttribute('aria-hidden', 'true');\n\n let count = 0;\n const piece = (content: Node): HTMLElement => {\n const el = document.createElement('span');\n el.className = 'wr-blur-reveal__piece';\n el.style.setProperty('--wr-blur-reveal-i', String(count++));\n el.append(content);\n this.lastPiece = el;\n return el;\n };\n\n for (const node of original) {\n if (node.nodeType !== Node.TEXT_NODE) {\n // An inline element (`<code>`, `<a>`) is one piece, moved whole; a comment keeps its place.\n pieces.append(node.nodeType === Node.ELEMENT_NODE ? piece(node) : node);\n continue;\n }\n // `split` on a capturing group alternates: a run of text, then the spaces after it.\n (node.textContent ?? '').split(BREAKING_SPACES).forEach((run, i) => {\n if (run === '') return;\n if (i % 2 === 1) {\n pieces.append(run);\n } else if (!letters) {\n pieces.append(piece(document.createTextNode(run)));\n } else {\n const word = document.createElement('span');\n word.className = 'wr-blur-reveal__word';\n for (const grapheme of graphemes(run)) word.append(piece(document.createTextNode(grapheme)));\n pieces.append(word);\n }\n });\n }\n\n this.original = original;\n if (count === 0) {\n this.restore();\n return;\n }\n\n const stagger = staggerGap(this.by(), count, this.stagger());\n pieces.style.setProperty('--wr-blur-reveal-delay', `${Math.max(0, this.delay())}ms`);\n pieces.style.setProperty('--wr-blur-reveal-stagger', `${stagger}ms`);\n\n const copy = document.createElement('span');\n copy.className = 'wr-blur-reveal__sr';\n copy.textContent = text;\n\n host.replaceChildren(pieces, copy);\n host.classList.add('wr-blur-reveal--run');\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nexport { WrBlurReveal } from './blur-reveal';\nexport type { WrBlurRevealBy, Wr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O;IACP,mCAAmC;IACnC,iCAAiC;IACjC,kBAAkB;IAClB,qBAAqB;GACtB;EACF,CAAA"}
1
+ {"version":3,"file":"ngwr-animations-blur-reveal.mjs","names":[],"sources":["../../../projects/lib/animations/blur-reveal/blur-reveal.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Directive, ElementRef, PLATFORM_ID, afterNextRender, inject, input } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\nimport { BREAKING_SPACES, VIEW_THRESHOLD, graphemes, optionalMs, staggerGap } from '../internal';\n\nimport type { WrBlurRevealBy, WrBlurRevealFrom } from './types';\n\n/**\n * One-shot entrance for a text element: the first time the host scrolls into\n * view its text comes in piece by piece, each one from blurred, transparent and\n * a little below its place to sharp, opaque and in place, in reading order. The\n * host keeps its own tag and its authored children: they are moved out while\n * the pieces play and the same nodes are moved back when the last piece lands,\n * so selection, find-in-page and Angular bindings inside work as before. While\n * split, the pieces are `aria-hidden` and a visually-hidden copy of the text\n * stands beside them, so a screen reader hears the sentence once. Nothing is\n * split under `prefers-reduced-motion: reduce`, on the server or without\n * `IntersectionObserver`.\n */\n@Directive({\n selector: '[wrBlurReveal]',\n host: {\n class: 'wr-blur-reveal',\n '[class.wr-blur-reveal--letters]': 'by() === \"letters\"',\n '[class.wr-blur-reveal--above]': 'from() === \"above\"',\n '(animationend)': 'onAnimationEnd($event)',\n '(animationcancel)': 'restore()',\n },\n})\nexport class WrBlurReveal {\n /**\n * What enters one at a time: a word, or a grapheme. In letter mode the\n * letters of one word sit in a no-wrap wrapper, so a word never breaks across\n * lines mid-word. @default 'words'\n */\n readonly by = input<WrBlurRevealBy>('words');\n\n /** The side a piece settles in from. @default 'below' */\n readonly from = input<WrBlurRevealFrom>('below');\n\n /**\n * Gap between the start of one piece and the next, in ms. Unset, the mode\n * decides: 70 for words, 28 for letters. Either way the whole reveal spreads\n * over 1.2 s at most, so for a long text the gap shrinks until the last piece\n * starts by then.\n */\n readonly stagger = input<number | null, unknown>(null, { transform: optionalMs });\n\n /** Pause between the host entering the viewport and the first piece, in ms. @default 0 */\n readonly delay = input(0, { transform: wrNumAttr(0) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private observer: IntersectionObserver | null = null;\n /** The host's authored children while they are out of the DOM, else `null`. */\n private original: ChildNode[] | null = null;\n private lastPiece: HTMLElement | null = null;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/blur-reveal');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion() || typeof IntersectionObserver === 'undefined') return;\n this.observer = new IntersectionObserver(\n entries => {\n if (!entries.some(entry => entry.isIntersecting)) return;\n this.observer?.disconnect();\n this.observer = null;\n if (!this.platform.prefersReducedMotion()) this.play();\n },\n { threshold: VIEW_THRESHOLD }\n );\n this.observer.observe(this.host.nativeElement);\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.observer?.disconnect();\n this.observer = null;\n this.restore();\n });\n }\n\n /** Last piece landed: the authored children go back. Another piece or a child's own animation is not it. */\n protected onAnimationEnd(event: Event): void {\n if (event.target === this.lastPiece) this.restore();\n }\n\n /**\n * Put the authored children back, the same node objects, and drop the\n * wrappers. Idempotent: the end of the last piece, a cancelled animation and\n * destroy all call it.\n */\n protected restore(): void {\n if (!this.original) return;\n const host = this.host.nativeElement;\n host.replaceChildren(...this.original);\n host.classList.remove('wr-blur-reveal--run');\n this.original = null;\n this.lastPiece = null;\n }\n\n /**\n * Split the authored children into pieces and start the animation in one\n * task. Each piece carries its index; the stylesheet turns that into a delay,\n * and `--run` is added by hand rather than through a binding because change\n * detection may run after the next paint, and that paint would show the\n * pieces sharp before they hide.\n */\n private play(): void {\n const host = this.host.nativeElement;\n const original = Array.from(host.childNodes);\n const text = host.textContent ?? '';\n const letters = this.by() === 'letters';\n const pieces = document.createElement('span');\n pieces.className = 'wr-blur-reveal__pieces';\n pieces.setAttribute('aria-hidden', 'true');\n\n let count = 0;\n const piece = (content: Node): HTMLElement => {\n const el = document.createElement('span');\n el.className = 'wr-blur-reveal__piece';\n el.style.setProperty('--wr-blur-reveal-i', String(count++));\n el.append(content);\n this.lastPiece = el;\n return el;\n };\n\n for (const node of original) {\n if (node.nodeType !== Node.TEXT_NODE) {\n // An inline element (`<code>`, `<a>`) is one piece, moved whole; a comment keeps its place.\n pieces.append(node.nodeType === Node.ELEMENT_NODE ? piece(node) : node);\n continue;\n }\n // `split` on a capturing group alternates: a run of text, then the spaces after it.\n (node.textContent ?? '').split(BREAKING_SPACES).forEach((run, i) => {\n if (run === '') return;\n if (i % 2 === 1) {\n pieces.append(run);\n } else if (!letters) {\n pieces.append(piece(document.createTextNode(run)));\n } else {\n const word = document.createElement('span');\n word.className = 'wr-blur-reveal__word';\n for (const grapheme of graphemes(run)) word.append(piece(document.createTextNode(grapheme)));\n pieces.append(word);\n }\n });\n }\n\n this.original = original;\n if (count === 0) {\n this.restore();\n return;\n }\n\n const stagger = staggerGap(this.by(), count, this.stagger());\n pieces.style.setProperty('--wr-blur-reveal-delay', `${Math.max(0, this.delay())}ms`);\n pieces.style.setProperty('--wr-blur-reveal-stagger', `${stagger}ms`);\n\n const copy = document.createElement('span');\n copy.className = 'wr-blur-reveal__sr';\n copy.textContent = text;\n\n host.replaceChildren(pieces, copy);\n host.classList.add('wr-blur-reveal--run');\n }\n}\n"],"mappings":";;;;;;;;;;;;AAuCA,IAAa,eAAb,MAAa,aAAY;CAMd,KAAK,MAAsB,SAAQ,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAGnC,OAAO,MAAwB,SAAQ,GAAA,YAAA,CAAA,EAAA,W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AAI;EAEnE,MAAM,OAAO,SAAS,cAAc,MAAM;EAC1C,KAAK,YAAY;EACjB,KAAK,cAAc;EAEnB,KAAK,gBAAgB,QAAQ,IAAI;EACjC,KAAK,UAAU,IAAI,qBAAqB;CAC1C;CAzIW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAY,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAZ,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAY,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,IAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,MAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA;GAAA,WAAA;IAAA,gBAAA;IAAA,mBAAA;GAAA;GAAA,YAAA;IAAA,iCAAA;IAAA,+BAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;CAAA,CAAA;;AAAZ,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAY,YAAA,CAAA;EAVxB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM;IACJ,OAAO;IACP,mCAAmC;IACnC,iCAAiC;IACjC,kBAAkB;IAClB,qBAAqB;GACtB;EACF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-animations-click-sparks.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/click-sparks/click-sparks.ts","../../../projects/lib/animations/click-sparks/public-api.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Directive, ElementRef, PLATFORM_ID, afterNextRender, inject, input } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\n/** How long one burst lasts, in ms: every stroke flies, shrinks and fades inside it. */\nconst CLICK_SPARKS_MS = 480;\n\n/** Strokes in one burst, spread evenly round the ring. */\nconst CLICK_SPARKS_COUNT = 8;\n\n/** Bursts alive at once: a fifth click takes the oldest out before its animation ends. */\nconst CLICK_SPARKS_MAX = 4;\n\n/**\n * How far the ring turns from one burst to the next, in degrees: the golden\n * angle, so no two consecutive bursts put a stroke in the same place and the\n * pattern never repeats over a handful of clicks.\n */\nconst CLICK_SPARKS_TURN = 137.5;\n\n/** The `animation-name` of a stroke, as the stylesheet declares it. */\nconst SPARK = 'wr-click-sparks-fly';\n\n/** One burst: its layer in the body and the fallback that takes it out if no `animationend` comes. */\ninterface Burst {\n readonly layer: HTMLElement;\n readonly timer: ReturnType<typeof setTimeout>;\n}\n\n/**\n * A ring of short spark strokes bursts out from the point a button or link is\n * clicked, flies a short way, shrinks and fades, all within half a second.\n * Several quick clicks make several bursts; at most {@link CLICK_SPARKS_MAX}\n * are alive at once and a newer one takes the oldest out.\n *\n * DOM and CSS, no canvas: a burst is one `aria-hidden` layer of zero size,\n * fixed at the click's client coordinates, holding {@link CLICK_SPARKS_COUNT}\n * spans. Each span is rotated to its angle and animated outward with\n * `transform` and `opacity` only, so the whole burst is composited and never\n * reflows anything. The layer sits in `document.body`, not in the host: a\n * button clips its overflow, and a `position: fixed` box inside a transformed\n * or filtered ancestor (`wrGlowBorder`, a hero that animates) would be\n * measured from that ancestor instead of the viewport. In the body, client\n * coordinates are exactly where the layer goes, and no ancestor can clip it.\n * It is under no pointer and the layer is removed on the first `animationend`\n * of its strokes, or by a timer a little after the burst length if that event\n * never comes (a motion preference flipped mid-burst).\n *\n * The strokes paint in the host's own colour, read at the click, and scale\n * with the host's font size: `--wr-click-sparks-color` on the host (a theme\n * role, say `var(--wr-color-primary)` for a filled button whose text is a\n * `-contrast`) is copied to the layer and overrides the colour; the\n * stylesheet's own hooks set the stroke length, distance and width in `em`.\n *\n * A keyboard activation (`click` with `detail === 0`, from Enter or Space)\n * bursts from the host's centre. The click itself is never touched: the\n * listener is passive, nothing is prevented or stopped, and a `routerLink` or\n * a plain `href` navigates as it did. Nothing plays under\n * `prefers-reduced-motion: reduce`, under `forced-colors: active` or on the\n * server. Styles: `@use 'ngwr/animations/click-sparks'`, which also lists the\n * `--wr-click-sparks-*` hooks.\n */\n@Directive({\n selector: '[wrClickSparks]',\n})\nexport class WrClickSparks {\n /**\n * How many strokes one burst has. Written as the directive's own value:\n * `wrClickSparks=\"10\"`. Unset or empty, {@link CLICK_SPARKS_COUNT}.\n */\n readonly count = input(CLICK_SPARKS_COUNT, { alias: 'wrClickSparks', transform: wrNumAttr(CLICK_SPARKS_COUNT) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private listeners: AbortController | null = null;\n private bursts: Burst[] = [];\n /** Bursts made so far: turns the ring a golden angle each time. */\n private made = 0;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/click-sparks');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n // The stylesheet paints no stroke under forced colours: nothing to listen for.\n if (this.doc.defaultView?.matchMedia?.('(forced-colors: active)').matches) return;\n this.listeners = new AbortController();\n this.host.nativeElement.addEventListener('click', event => this.onClick(event), {\n signal: this.listeners.signal,\n passive: true,\n });\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.listeners?.abort();\n this.listeners = null;\n while (this.bursts.length > 0) this.remove(this.bursts[0]);\n });\n }\n\n /** A pointer gives its point; a keyboard gives `detail === 0` and the host's centre stands in. */\n private onClick(event: MouseEvent): void {\n if (this.platform.prefersReducedMotion()) return;\n const host = this.host.nativeElement;\n let x = event.clientX;\n let y = event.clientY;\n if (event.detail === 0) {\n const rect = host.getBoundingClientRect();\n x = rect.left + rect.width / 2;\n y = rect.top + rect.height / 2;\n }\n this.burst(x, y);\n }\n\n /**\n * One burst at a client point. The layer takes the host's colour and font\n * size inline, so `currentColor` and `em` in the stylesheet mean the host's,\n * not the body's; the hook, when the host sets one, wins over the colour.\n */\n private burst(x: number, y: number): void {\n const host = this.host.nativeElement;\n const doc = host.ownerDocument;\n const style = doc.defaultView?.getComputedStyle(host);\n const count = Math.max(1, Math.round(this.count()));\n const spin = (this.made++ * CLICK_SPARKS_TURN) % 360;\n\n const layer = doc.createElement('span');\n layer.className = 'wr-click-sparks';\n layer.setAttribute('aria-hidden', 'true');\n layer.style.setProperty('--wr-click-sparks-x', `${x}px`);\n layer.style.setProperty('--wr-click-sparks-y', `${y}px`);\n layer.style.setProperty('--wr-click-sparks-duration', `${CLICK_SPARKS_MS}ms`);\n if (style) {\n const hook = style.getPropertyValue('--wr-click-sparks-color').trim();\n layer.style.color = hook || style.color;\n layer.style.fontSize = style.fontSize;\n }\n for (let i = 0; i < count; i++) {\n const spark = doc.createElement('span');\n spark.className = 'wr-click-sparks__spark';\n spark.style.setProperty('--wr-click-sparks-angle', `${spin + (i * 360) / count}deg`);\n layer.append(spark);\n }\n\n const burst: Burst = {\n layer,\n timer: setTimeout(() => this.remove(burst), CLICK_SPARKS_MS + 100),\n };\n layer.addEventListener(\n 'animationend',\n event => {\n if (event.animationName === SPARK) this.remove(burst);\n },\n { passive: true }\n );\n\n while (this.bursts.length >= CLICK_SPARKS_MAX) this.remove(this.bursts[0]);\n this.bursts.push(burst);\n doc.body.append(layer);\n }\n\n /** Take a burst out of the body and the list, and stop its fallback. Idempotent. */\n private remove(burst: Burst): void {\n clearTimeout(burst.timer);\n burst.layer.remove();\n const at = this.bursts.indexOf(burst);\n if (at !== -1) this.bursts.splice(at, 1);\n }\n}\n\nexport { CLICK_SPARKS_COUNT, CLICK_SPARKS_MAX, CLICK_SPARKS_MS, CLICK_SPARKS_TURN, SPARK as CLICK_SPARKS_FLY };\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nexport { WrClickSparks } from './click-sparks';\n"],"mappings":";;;;;;;;;;;AA2BA,MAAM,oBAAoB;AA+C1B,IAAa,gBAAb,MAAa,cAAa;CAKf,QAAQ,MAAA,GAAwB;EAAA,GAAA,YAAA,EAAA,WAAA,QAAA,+BAAA,CAAA;EAAI,OAAO;EAAiB,WAAW,UAAA,CAA4B;CAAC,CAAA;CAE5F,OAAO,OAAgC,UAAU;CACjD,WAAW,OAAO,UAAU;CAC5B,MAAM,OAAOA,UAAQ;CAC9B,YAAoC;CACpC,SAAkB,CAAA;CAElB,OAAO;CAEf,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,yBAAyB;EAC1F,IAAI,CAAC,kBAAkB,OAAO,WAAW,CAAC,GAAG;EAE7C,sBAAqB;GAEnB,IAAI,KAAK,IAAI,aAAa,aAAa,yBAAyB,CAAC,CAAC,SAAS;GAC3E,KAAK,YAAY,IAAI,gBAAe;GACpC,KAAK,KAAK,cAAc,iBAAiB,UAAS,UAAS,KAAK,QAAQ,KAAK,GAAG;IAC9E,QAAQ,KAAK,UAAU;IACvB,SAAS;GACV,CAAA;EACH,CAAC;EAED,OAAO,UAAU,CAAC,CAAC,gBAAe;GAChC,KAAK,WAAW,MAAK;GACrB,KAAK,YAAY;GACjB,OAAO,KAAK,OAAO,SAAS,GAAG,KAAK,OAAO,KAAK,OAAO,EAAE;EAC3D,CAAC;CACH;CAGQ,QAAQ,OAAiB;EAC/B,IAAI,KAAK,SAAS,qBAAoB,GAAI;EAC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AAK;EACtD,GACA,EAAE,SAAS,KAAI,CAAE;EAGnB,OAAO,KAAK,OAAO,UAAA,GAA4B,KAAK,OAAO,KAAK,OAAO,EAAE;EACzE,KAAK,OAAO,KAAK,KAAK;EACtB,IAAI,KAAK,OAAO,KAAK;CACvB;CAGQ,OAAO,OAAY;EACzB,aAAa,MAAM,KAAK;EACxB,MAAM,MAAM,OAAM;EAClB,MAAM,KAAK,KAAK,OAAO,QAAQ,KAAK;EACpC,IAAI,OAAO,IAAI,KAAK,OAAO,OAAO,IAAI,CAAC;CACzC;CAvGW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAa,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAb,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAa,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,OAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,UAAA;CAAA,CAAA;;AAAb,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA;EAHzB,MAAA;EAAU,MAAA,CAAA,EACT,UAAU,kBACX,CAAA"}
1
+ {"version":3,"file":"ngwr-animations-click-sparks.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/click-sparks/click-sparks.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Directive, ElementRef, PLATFORM_ID, afterNextRender, inject, input } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\n/** How long one burst lasts, in ms: every stroke flies, shrinks and fades inside it. */\nconst CLICK_SPARKS_MS = 480;\n\n/** Strokes in one burst, spread evenly round the ring. */\nconst CLICK_SPARKS_COUNT = 8;\n\n/** Bursts alive at once: a fifth click takes the oldest out before its animation ends. */\nconst CLICK_SPARKS_MAX = 4;\n\n/**\n * How far the ring turns from one burst to the next, in degrees: the golden\n * angle, so no two consecutive bursts put a stroke in the same place and the\n * pattern never repeats over a handful of clicks.\n */\nconst CLICK_SPARKS_TURN = 137.5;\n\n/** The `animation-name` of a stroke, as the stylesheet declares it. */\nconst SPARK = 'wr-click-sparks-fly';\n\n/** One burst: its layer in the body and the fallback that takes it out if no `animationend` comes. */\ninterface Burst {\n readonly layer: HTMLElement;\n readonly timer: ReturnType<typeof setTimeout>;\n}\n\n/**\n * A ring of short spark strokes bursts out from the point a button or link is\n * clicked, flies a short way, shrinks and fades, all within half a second.\n * Several quick clicks make several bursts; at most {@link CLICK_SPARKS_MAX}\n * are alive at once and a newer one takes the oldest out.\n *\n * DOM and CSS, no canvas: a burst is one `aria-hidden` layer of zero size,\n * fixed at the click's client coordinates, holding {@link CLICK_SPARKS_COUNT}\n * spans. Each span is rotated to its angle and animated outward with\n * `transform` and `opacity` only, so the whole burst is composited and never\n * reflows anything. The layer sits in `document.body`, not in the host: a\n * button clips its overflow, and a `position: fixed` box inside a transformed\n * or filtered ancestor (`wrGlowBorder`, a hero that animates) would be\n * measured from that ancestor instead of the viewport. In the body, client\n * coordinates are exactly where the layer goes, and no ancestor can clip it.\n * It is under no pointer and the layer is removed on the first `animationend`\n * of its strokes, or by a timer a little after the burst length if that event\n * never comes (a motion preference flipped mid-burst).\n *\n * The strokes paint in the host's own colour, read at the click, and scale\n * with the host's font size: `--wr-click-sparks-color` on the host (a theme\n * role, say `var(--wr-color-primary)` for a filled button whose text is a\n * `-contrast`) is copied to the layer and overrides the colour; the\n * stylesheet's own hooks set the stroke length, distance and width in `em`.\n *\n * A keyboard activation (`click` with `detail === 0`, from Enter or Space)\n * bursts from the host's centre. The click itself is never touched: the\n * listener is passive, nothing is prevented or stopped, and a `routerLink` or\n * a plain `href` navigates as it did. Nothing plays under\n * `prefers-reduced-motion: reduce`, under `forced-colors: active` or on the\n * server. Styles: `@use 'ngwr/animations/click-sparks'`, which also lists the\n * `--wr-click-sparks-*` hooks.\n */\n@Directive({\n selector: '[wrClickSparks]',\n})\nexport class WrClickSparks {\n /**\n * How many strokes one burst has. Written as the directive's own value:\n * `wrClickSparks=\"10\"`. Unset or empty, {@link CLICK_SPARKS_COUNT}.\n */\n readonly count = input(CLICK_SPARKS_COUNT, { alias: 'wrClickSparks', transform: wrNumAttr(CLICK_SPARKS_COUNT) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private listeners: AbortController | null = null;\n private bursts: Burst[] = [];\n /** Bursts made so far: turns the ring a golden angle each time. */\n private made = 0;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/click-sparks');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n // The stylesheet paints no stroke under forced colours: nothing to listen for.\n if (this.doc.defaultView?.matchMedia?.('(forced-colors: active)').matches) return;\n this.listeners = new AbortController();\n this.host.nativeElement.addEventListener('click', event => this.onClick(event), {\n signal: this.listeners.signal,\n passive: true,\n });\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.listeners?.abort();\n this.listeners = null;\n while (this.bursts.length > 0) this.remove(this.bursts[0]);\n });\n }\n\n /** A pointer gives its point; a keyboard gives `detail === 0` and the host's centre stands in. */\n private onClick(event: MouseEvent): void {\n if (this.platform.prefersReducedMotion()) return;\n const host = this.host.nativeElement;\n let x = event.clientX;\n let y = event.clientY;\n if (event.detail === 0) {\n const rect = host.getBoundingClientRect();\n x = rect.left + rect.width / 2;\n y = rect.top + rect.height / 2;\n }\n this.burst(x, y);\n }\n\n /**\n * One burst at a client point. The layer takes the host's colour and font\n * size inline, so `currentColor` and `em` in the stylesheet mean the host's,\n * not the body's; the hook, when the host sets one, wins over the colour.\n */\n private burst(x: number, y: number): void {\n const host = this.host.nativeElement;\n const doc = host.ownerDocument;\n const style = doc.defaultView?.getComputedStyle(host);\n const count = Math.max(1, Math.round(this.count()));\n const spin = (this.made++ * CLICK_SPARKS_TURN) % 360;\n\n const layer = doc.createElement('span');\n layer.className = 'wr-click-sparks';\n layer.setAttribute('aria-hidden', 'true');\n layer.style.setProperty('--wr-click-sparks-x', `${x}px`);\n layer.style.setProperty('--wr-click-sparks-y', `${y}px`);\n layer.style.setProperty('--wr-click-sparks-duration', `${CLICK_SPARKS_MS}ms`);\n if (style) {\n const hook = style.getPropertyValue('--wr-click-sparks-color').trim();\n layer.style.color = hook || style.color;\n layer.style.fontSize = style.fontSize;\n }\n for (let i = 0; i < count; i++) {\n const spark = doc.createElement('span');\n spark.className = 'wr-click-sparks__spark';\n spark.style.setProperty('--wr-click-sparks-angle', `${spin + (i * 360) / count}deg`);\n layer.append(spark);\n }\n\n const burst: Burst = {\n layer,\n timer: setTimeout(() => this.remove(burst), CLICK_SPARKS_MS + 100),\n };\n layer.addEventListener(\n 'animationend',\n event => {\n if (event.animationName === SPARK) this.remove(burst);\n },\n { passive: true }\n );\n\n while (this.bursts.length >= CLICK_SPARKS_MAX) this.remove(this.bursts[0]);\n this.bursts.push(burst);\n doc.body.append(layer);\n }\n\n /** Take a burst out of the body and the list, and stop its fallback. Idempotent. */\n private remove(burst: Burst): void {\n clearTimeout(burst.timer);\n burst.layer.remove();\n const at = this.bursts.indexOf(burst);\n if (at !== -1) this.bursts.splice(at, 1);\n }\n}\n\nexport { CLICK_SPARKS_COUNT, CLICK_SPARKS_MAX, CLICK_SPARKS_MS, CLICK_SPARKS_TURN, SPARK as CLICK_SPARKS_FLY };\n"],"mappings":";;;;;;;;;;;AA2BA,MAAM,oBAAoB;AA+C1B,IAAa,gBAAb,MAAa,cAAa;CAKf,QAAQ,MAAA,GAAw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A;EAAa,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAb,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAa,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,OAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,UAAA;CAAA,CAAA;;AAAb,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA;EAHzB,MAAA;EAAU,MAAA,CAAA,EACT,UAAU,kBACX,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-animations-confetti.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/confetti/confetti.ts","../../../projects/lib/animations/confetti/public-api.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, PLATFORM_ID, Service, effect, inject } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrClamp, wrResolveCssColor } from 'ngwr/utils';\n\nimport { MAX_FRAME_MS, canvasBackdropRatio } from '../internal';\n\nimport type { WrConfettiOptions, WrConfettiRect } from './types';\n\n/** Pieces in one burst. */\nconst CONFETTI_COUNT = 84;\n\n/** How wide the fan of launch directions is, in degrees, centred straight up. */\nconst CONFETTI_CONE = 80;\n\n/** Launch speed, px/s: the slowest and the fastest piece. */\nconst CONFETTI_SPEED_MIN = 520;\nconst CONFETTI_SPEED_MAX = 980;\n\n/** Gravity, px/s²: light, as paper falls, not a stone. */\nconst CONFETTI_GRAVITY = 560;\n\n/**\n * Air drag, per second: velocity decays by `e^-drag` every second, so a piece\n * launched at 900px/s is at a third of that after two thirds of a second and\n * falls no faster than `gravity / drag` (350px/s) however long it drops.\n */\nconst CONFETTI_DRAG = 1.6;\n\n/** How far the flutter pushes a piece sideways, px/s at the peak of a flip. */\nconst CONFETTI_SWAY = 60;\n\n/** How long a piece lives, ms: at least this, plus up to the spread. */\nconst CONFETTI_LIFE_MS = 1900;\nconst CONFETTI_LIFE_SPREAD_MS = 500;\n\n/** A piece fades over its last ms. */\nconst CONFETTI_FADE_MS = 600;\n\n/** Every fifth piece is a thin strip rather than a rectangle. */\nconst CONFETTI_STRIP_EVERY = 5;\n\n/**\n * The colour hooks on the canvas, each a bare intent: confetti is a graphic,\n * not text, so it keeps the intent itself rather than the `-ink` text role\n * (see `docs/internals/theme.md`). The literal is the fallback when a hook\n * cannot be resolved, as in a document with no stylesheet.\n */\nconst CONFETTI_COLORS: readonly (readonly [hook: string, fallback: string])[] = [\n ['var(--wr-confetti-color-1)', '#3969e2'],\n ['var(--wr-confetti-color-2)', '#008800'],\n ['var(--wr-confetti-color-3)', '#ffba00'],\n ['var(--wr-confetti-color-4)', '#dc3137'],\n ['var(--wr-confetti-color-5)', '#3472d9'],\n];\n\n/** One piece of paper in the air. Positions in CSS px, velocities in px/s, angles in rad. */\nexport interface WrConfettiPiece {\n x: number;\n y: number;\n vx: number;\n vy: number;\n readonly width: number;\n readonly height: number;\n /** Its turn on the screen plane. */\n angle: number;\n readonly spin: number;\n /** Its flip round its own long axis: the drawn height is `height * cos(phase)`. */\n phase: number;\n readonly flutter: number;\n readonly color: string;\n /** ms left. */\n life: number;\n}\n\n/* eslint-disable no-bitwise -- xorshift is defined in 32-bit integer arithmetic */\n/**\n * A deterministic 0–1 sequence from `seed` (xorshift32): the same seed gives\n * the same burst, which a spec can pin. A zero seed would stay zero for ever,\n * so it is replaced by a constant.\n */\nexport function confettiRandom(seed: number): () => number {\n let state = seed >>> 0 || 0x9e3779b9;\n return () => {\n state ^= state << 13;\n state >>>= 0;\n state ^= state >>> 17;\n state ^= state << 5;\n state >>>= 0;\n return state / 0x1_0000_0000;\n };\n}\n/* eslint-enable no-bitwise */\n\n/**\n * The pieces of one burst at launch: `count` of them, spread over `from`,\n * each thrown upward inside the cone at its own speed with its own spin,\n * flutter and life, coloured from `palette` in turn so every colour is\n * equally represented.\n */\nexport function confettiLaunch(\n from: WrConfettiRect,\n seed: number,\n count: number,\n palette: readonly string[]\n): WrConfettiPiece[] {\n const random = confettiRandom(seed);\n const half = (CONFETTI_CONE / 2) * (Math.PI / 180);\n const pieces: WrConfettiPiece[] = [];\n for (let i = 0; i < Math.max(0, Math.round(count)); i++) {\n const strip = i % CONFETTI_STRIP_EVERY === CONFETTI_STRIP_EVERY - 1;\n const direction = -Math.PI / 2 + (random() * 2 - 1) * half;\n const speed = CONFETTI_SPEED_MIN + random() * (CONFETTI_SPEED_MAX - CONFETTI_SPEED_MIN);\n pieces.push({\n x: from.left + random() * from.width,\n y: from.top + random() * from.height,\n vx: Math.cos(direction) * speed,\n vy: Math.sin(direction) * speed,\n width: strip ? 2 + random() * 1.5 : 6 + random() * 4,\n height: strip ? 10 + random() * 6 : 3 + random() * 2.5,\n angle: random() * Math.PI * 2,\n spin: (random() * 2 - 1) * 8,\n phase: random() * Math.PI * 2,\n flutter: 5 + random() * 7,\n color: palette[i % palette.length] ?? '',\n life: CONFETTI_LIFE_MS + random() * CONFETTI_LIFE_SPREAD_MS,\n });\n }\n return pieces;\n}\n\n/**\n * Moves one piece `dt` ms on. Gravity pulls, drag slows both axes towards the\n * terminal speed, the flutter sways it sideways as it flips, and the spin and\n * the flip advance; the life runs down.\n */\nexport function confettiStep(piece: WrConfettiPiece, dt: number): void {\n const s = dt / 1000;\n const keep = Math.exp(-CONFETTI_DRAG * s);\n const terminal = CONFETTI_GRAVITY / CONFETTI_DRAG;\n piece.vx *= keep;\n piece.vy = terminal + (piece.vy - terminal) * keep;\n piece.x += (piece.vx + Math.sin(piece.phase) * CONFETTI_SWAY) * s;\n piece.y += piece.vy * s;\n piece.angle += piece.spin * s;\n piece.phase += piece.flutter * s;\n piece.life -= dt;\n}\n\n/** Whether a piece is still worth drawing: alive and not below the bottom edge of a `height` tall viewport. */\nexport function confettiAlive(piece: WrConfettiPiece, height: number): boolean {\n return piece.life > 0 && piece.y - Math.max(piece.width, piece.height) < height;\n}\n\n/** A piece's opacity: solid, then fading over its last {@link CONFETTI_FADE_MS}. */\nexport function confettiAlpha(piece: WrConfettiPiece): number {\n return wrClamp(piece.life / CONFETTI_FADE_MS, 0, 1);\n}\n\n/**\n * A one-shot celebration: small paper pieces burst up and out from an\n * element, flutter, tumble and fall under gravity, and are gone inside two\n * and a half seconds. A service, not a component: call {@link burst} from\n * wherever the moment is.\n *\n * The first burst makes one fixed, full-viewport canvas in `document.body`\n * (`aria-hidden`, under no pointer, at the device ratio capped as the\n * backdrops cap it) and starts one frame loop; a burst that comes while\n * pieces are in the air joins the same canvas and loop, and the canvas goes\n * when the last piece has faded or dropped off the bottom. The layout of a\n * burst is deterministic for a seed; the physics is in {@link confettiLaunch},\n * {@link confettiStep} and {@link confettiAlive}, pure functions a spec can\n * run on their own. Each piece is a rectangle, every fifth a thin strip,\n * turning on the screen plane while its drawn height follows a cosine, so it\n * flips like paper; the back of a piece paints a shade darker.\n *\n * Colours are the `--wr-confetti-color-*` hooks on the canvas, bare theme\n * intents by default, resolved through the cascade when a burst starts, so\n * the scheme the reader is in is the one that paints. Nothing happens under\n * `prefers-reduced-motion: reduce` (a preference that flips mid-burst clears\n * the canvas at once), under `forced-colors: active` or on the server; a\n * hidden document pauses the loop and a visible one resumes it where it\n * stopped. Styles: `@use 'ngwr/animations/confetti'`, which places the canvas and\n * lists the `--wr-confetti-color-*` hooks; a service has no host to check them\n * from, so the first burst warns in dev mode when the sheet is missing.\n */\n@Service()\nexport class WrConfetti {\n private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private canvas: HTMLCanvasElement | null = null;\n private ctx: CanvasRenderingContext2D | null = null;\n private pieces: WrConfettiPiece[] = [];\n private rafId: number | null = null;\n private lastFrame = 0;\n private dpr = 1;\n private width = 0;\n private height = 0;\n private listeners: AbortController | null = null;\n /** The stylesheet was looked for once in this document. */\n private checked = false;\n\n constructor() {\n if (!this.browser) return;\n\n effect(() => {\n const reduced = this.platform.prefersReducedMotion();\n this.platform.pageVisible();\n if (reduced) this.clear();\n else this.sync();\n });\n\n inject(DestroyRef).onDestroy(() => this.clear());\n }\n\n /** Whether pieces are in the air. */\n get active(): boolean {\n return this.pieces.length > 0;\n }\n\n /**\n * Throws a burst of confetti up from `from`: an element, whose client rect\n * is read now, or a rect in client coordinates. Pieces start anywhere\n * inside the rect, so a wide block showers along its width and a button\n * bursts from a point.\n */\n burst(from: Element | WrConfettiRect, options: WrConfettiOptions = {}): void {\n if (!this.browser || this.platform.prefersReducedMotion()) return;\n const view = this.doc.defaultView;\n if (!view || view.matchMedia?.('(forced-colors: active)').matches) return;\n\n const canvas = this.canvas ?? this.mount(view);\n if (!canvas) return;\n const rect = 'getBoundingClientRect' in from ? from.getBoundingClientRect() : from;\n const seed = options.seed ?? Math.floor(Math.random() * 0x1_0000_0000);\n const palette = CONFETTI_COLORS.map(([hook, fallback]) => wrResolveCssColor(canvas, hook, fallback));\n this.pieces.push(...confettiLaunch(rect, seed, options.count ?? CONFETTI_COUNT, palette));\n this.sync();\n }\n\n /** Stops the loop and takes the canvas and every piece out. Idempotent. */\n clear(): void {\n this.stopLoop();\n this.pieces = [];\n this.listeners?.abort();\n this.listeners = null;\n this.canvas?.remove();\n this.canvas = null;\n this.ctx = null;\n }\n\n /** Makes the canvas, or returns `null` when the browser gives it no context. */\n private mount(view: Window): HTMLCanvasElement | null {\n const canvas = this.doc.createElement('canvas');\n canvas.className = 'wr-confetti';\n canvas.setAttribute('aria-hidden', 'true');\n const ctx = canvas.getContext('2d');\n if (!ctx) return null;\n this.canvas = canvas;\n this.ctx = ctx;\n this.listeners = new AbortController();\n view.addEventListener('resize', () => this.resize(view), { signal: this.listeners.signal, passive: true });\n this.doc.body.append(canvas);\n this.resize(view);\n if (typeof ngDevMode === 'undefined' || ngDevMode) this.checkStyles(view);\n return canvas;\n }\n\n /**\n * The service's own `wrCheckStyles`, which a root service cannot call: that\n * helper reads the host element it is injected beside, and a service has\n * none. The same marker, the same words, once per document.\n */\n private checkStyles(view: Window): void {\n if (this.checked || /jsdom|happydom/i.test(view.navigator.userAgent)) return;\n this.checked = true;\n const loaded = view.getComputedStyle(this.doc.documentElement).getPropertyValue('--wr-loaded-animations-confetti');\n if (loaded.trim() !== '') return;\n // eslint-disable-next-line no-console -- a dev-mode diagnostic, reported and never thrown\n console.warn(\n \"[NGWR] WrConfetti paints without its styles. Add @use 'ngwr/animations/confetti'; to your global stylesheet, \" +\n 'or run ng g ngwr:component-style animations/confetti.'\n );\n }\n\n private resize(view: Window): void {\n if (!this.canvas || !this.ctx) return;\n this.width = view.innerWidth;\n this.height = view.innerHeight;\n this.dpr = canvasBackdropRatio(Math.max(1, this.width), Math.max(1, this.height), view.devicePixelRatio ?? 1);\n this.canvas.width = Math.round(this.width * this.dpr);\n this.canvas.height = Math.round(this.height * this.dpr);\n }\n\n /** Starts or stops the loop: it runs while pieces are in the air and the document is visible. */\n private sync(): void {\n const run = this.ctx !== null && this.pieces.length > 0 && this.platform.pageVisible();\n if (run === (this.rafId !== null)) return;\n if (run) {\n this.lastFrame = performance.now();\n this.rafId = requestAnimationFrame(this.frame);\n return;\n }\n this.stopLoop();\n }\n\n private stopLoop(): void {\n if (this.rafId !== null) cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n\n private readonly frame = (now: number): void => {\n this.rafId = null;\n // A tab that was throttled comes back with one huge frame; the pieces move at most this far at once.\n const dt = wrClamp(now - this.lastFrame, 0, MAX_FRAME_MS);\n this.lastFrame = now;\n for (const piece of this.pieces) confettiStep(piece, dt);\n this.pieces = this.pieces.filter(piece => confettiAlive(piece, this.height));\n if (this.pieces.length === 0) {\n this.clear();\n return;\n }\n this.draw();\n this.rafId = requestAnimationFrame(this.frame);\n };\n\n private draw(): void {\n const ctx = this.ctx;\n if (!ctx) return;\n const { dpr } = this;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, this.width * dpr, this.height * dpr);\n for (const piece of this.pieces) {\n const flip = Math.cos(piece.phase);\n // Never flat: a sheet seen edge-on still shows its edge.\n const thickness = Math.sign(flip || 1) * Math.max(0.12, Math.abs(flip));\n ctx.setTransform(dpr, 0, 0, dpr, piece.x * dpr, piece.y * dpr);\n ctx.rotate(piece.angle);\n ctx.scale(1, thickness);\n // The back of the paper is in shadow.\n ctx.globalAlpha = confettiAlpha(piece) * (flip < 0 ? 0.75 : 1);\n ctx.fillStyle = piece.color;\n ctx.fillRect(-piece.width / 2, -piece.height / 2, piece.width, piece.height);\n }\n ctx.globalAlpha = 1;\n }\n}\n\nexport {\n CONFETTI_CONE,\n CONFETTI_COUNT,\n CONFETTI_DRAG,\n CONFETTI_FADE_MS,\n CONFETTI_GRAVITY,\n CONFETTI_LIFE_MS,\n CONFETTI_LIFE_SPREAD_MS,\n CONFETTI_SPEED_MAX,\n CONFETTI_SPEED_MIN,\n CONFETTI_STRIP_EVERY,\n};\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nexport { WrConfetti } from './confetti';\nexport type { WrConfettiOptions, WrConfettiRect } from './types';\n"],"mappings":";;;;;;;;;;;;AAmCA,MAAM,gBAAgB;AAGtB,MAAM,gBAAgB;AAGtB,MAAM,mBAAmB;AAezB,MAAM,kBAA0E;CAC9E,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;AACzC;AA2BD,SAAgB,eAAe,MAAY;CACzC,IAAI,QAAQ,SAAS,KAAK;CAC1B,aAAY;EACV,SAAS,SAAS;EAClB,WAAW;EACX,SAAS,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,KAAK,KAAK,QAAQ,CAAC,IAAI,KAAK,IAAI,KAAM,KAAK,IAAI,IAAI,CAAC;GACtE,IAAI,aAAa,KAAK,GAAG,GAAG,KAAK,MAAM,IAAI,KAAK,MAAM,IAAI,GAAG;GAC7D,IAAI,OAAO,MAAM,KAAK;GACtB,IAAI,MAAM,GAAG,SAAS;GAEtB,IAAI,cAAc,cAAc,KAAK,KAAK,OAAO,IAAI,MAAO;GAC5D,IAAI,YAAY,MAAM;GACtB,IAAI,SAAS,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAM,SAAS,GAAG,MAAM,OAAO,MAAM,MAAM;EAC7E;EACA,IAAI,cAAc;CACpB;CA/JW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAU,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAV,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAU,CAAA;;AAAV,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA,EADtB,MAAA,Q"}
1
+ {"version":3,"file":"ngwr-animations-confetti.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/confetti/confetti.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, PLATFORM_ID, Service, effect, inject } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrClamp, wrResolveCssColor } from 'ngwr/utils';\n\nimport { MAX_FRAME_MS, canvasBackdropRatio } from '../internal';\n\nimport type { WrConfettiOptions, WrConfettiRect } from './types';\n\n/** Pieces in one burst. */\nconst CONFETTI_COUNT = 84;\n\n/** How wide the fan of launch directions is, in degrees, centred straight up. */\nconst CONFETTI_CONE = 80;\n\n/** Launch speed, px/s: the slowest and the fastest piece. */\nconst CONFETTI_SPEED_MIN = 520;\nconst CONFETTI_SPEED_MAX = 980;\n\n/** Gravity, px/s²: light, as paper falls, not a stone. */\nconst CONFETTI_GRAVITY = 560;\n\n/**\n * Air drag, per second: velocity decays by `e^-drag` every second, so a piece\n * launched at 900px/s is at a third of that after two thirds of a second and\n * falls no faster than `gravity / drag` (350px/s) however long it drops.\n */\nconst CONFETTI_DRAG = 1.6;\n\n/** How far the flutter pushes a piece sideways, px/s at the peak of a flip. */\nconst CONFETTI_SWAY = 60;\n\n/** How long a piece lives, ms: at least this, plus up to the spread. */\nconst CONFETTI_LIFE_MS = 1900;\nconst CONFETTI_LIFE_SPREAD_MS = 500;\n\n/** A piece fades over its last ms. */\nconst CONFETTI_FADE_MS = 600;\n\n/** Every fifth piece is a thin strip rather than a rectangle. */\nconst CONFETTI_STRIP_EVERY = 5;\n\n/**\n * The colour hooks on the canvas, each a bare intent: confetti is a graphic,\n * not text, so it keeps the intent itself rather than the `-ink` text role\n * (see `docs/internals/theme.md`). The literal is the fallback when a hook\n * cannot be resolved, as in a document with no stylesheet.\n */\nconst CONFETTI_COLORS: readonly (readonly [hook: string, fallback: string])[] = [\n ['var(--wr-confetti-color-1)', '#3969e2'],\n ['var(--wr-confetti-color-2)', '#008800'],\n ['var(--wr-confetti-color-3)', '#ffba00'],\n ['var(--wr-confetti-color-4)', '#dc3137'],\n ['var(--wr-confetti-color-5)', '#3472d9'],\n];\n\n/** One piece of paper in the air. Positions in CSS px, velocities in px/s, angles in rad. */\nexport interface WrConfettiPiece {\n x: number;\n y: number;\n vx: number;\n vy: number;\n readonly width: number;\n readonly height: number;\n /** Its turn on the screen plane. */\n angle: number;\n readonly spin: number;\n /** Its flip round its own long axis: the drawn height is `height * cos(phase)`. */\n phase: number;\n readonly flutter: number;\n readonly color: string;\n /** ms left. */\n life: number;\n}\n\n/* eslint-disable no-bitwise -- xorshift is defined in 32-bit integer arithmetic */\n/**\n * A deterministic 0–1 sequence from `seed` (xorshift32): the same seed gives\n * the same burst, which a spec can pin. A zero seed would stay zero for ever,\n * so it is replaced by a constant.\n */\nexport function confettiRandom(seed: number): () => number {\n let state = seed >>> 0 || 0x9e3779b9;\n return () => {\n state ^= state << 13;\n state >>>= 0;\n state ^= state >>> 17;\n state ^= state << 5;\n state >>>= 0;\n return state / 0x1_0000_0000;\n };\n}\n/* eslint-enable no-bitwise */\n\n/**\n * The pieces of one burst at launch: `count` of them, spread over `from`,\n * each thrown upward inside the cone at its own speed with its own spin,\n * flutter and life, coloured from `palette` in turn so every colour is\n * equally represented.\n */\nexport function confettiLaunch(\n from: WrConfettiRect,\n seed: number,\n count: number,\n palette: readonly string[]\n): WrConfettiPiece[] {\n const random = confettiRandom(seed);\n const half = (CONFETTI_CONE / 2) * (Math.PI / 180);\n const pieces: WrConfettiPiece[] = [];\n for (let i = 0; i < Math.max(0, Math.round(count)); i++) {\n const strip = i % CONFETTI_STRIP_EVERY === CONFETTI_STRIP_EVERY - 1;\n const direction = -Math.PI / 2 + (random() * 2 - 1) * half;\n const speed = CONFETTI_SPEED_MIN + random() * (CONFETTI_SPEED_MAX - CONFETTI_SPEED_MIN);\n pieces.push({\n x: from.left + random() * from.width,\n y: from.top + random() * from.height,\n vx: Math.cos(direction) * speed,\n vy: Math.sin(direction) * speed,\n width: strip ? 2 + random() * 1.5 : 6 + random() * 4,\n height: strip ? 10 + random() * 6 : 3 + random() * 2.5,\n angle: random() * Math.PI * 2,\n spin: (random() * 2 - 1) * 8,\n phase: random() * Math.PI * 2,\n flutter: 5 + random() * 7,\n color: palette[i % palette.length] ?? '',\n life: CONFETTI_LIFE_MS + random() * CONFETTI_LIFE_SPREAD_MS,\n });\n }\n return pieces;\n}\n\n/**\n * Moves one piece `dt` ms on. Gravity pulls, drag slows both axes towards the\n * terminal speed, the flutter sways it sideways as it flips, and the spin and\n * the flip advance; the life runs down.\n */\nexport function confettiStep(piece: WrConfettiPiece, dt: number): void {\n const s = dt / 1000;\n const keep = Math.exp(-CONFETTI_DRAG * s);\n const terminal = CONFETTI_GRAVITY / CONFETTI_DRAG;\n piece.vx *= keep;\n piece.vy = terminal + (piece.vy - terminal) * keep;\n piece.x += (piece.vx + Math.sin(piece.phase) * CONFETTI_SWAY) * s;\n piece.y += piece.vy * s;\n piece.angle += piece.spin * s;\n piece.phase += piece.flutter * s;\n piece.life -= dt;\n}\n\n/** Whether a piece is still worth drawing: alive and not below the bottom edge of a `height` tall viewport. */\nexport function confettiAlive(piece: WrConfettiPiece, height: number): boolean {\n return piece.life > 0 && piece.y - Math.max(piece.width, piece.height) < height;\n}\n\n/** A piece's opacity: solid, then fading over its last {@link CONFETTI_FADE_MS}. */\nexport function confettiAlpha(piece: WrConfettiPiece): number {\n return wrClamp(piece.life / CONFETTI_FADE_MS, 0, 1);\n}\n\n/**\n * A one-shot celebration: small paper pieces burst up and out from an\n * element, flutter, tumble and fall under gravity, and are gone inside two\n * and a half seconds. A service, not a component: call {@link burst} from\n * wherever the moment is.\n *\n * The first burst makes one fixed, full-viewport canvas in `document.body`\n * (`aria-hidden`, under no pointer, at the device ratio capped as the\n * backdrops cap it) and starts one frame loop; a burst that comes while\n * pieces are in the air joins the same canvas and loop, and the canvas goes\n * when the last piece has faded or dropped off the bottom. The layout of a\n * burst is deterministic for a seed; the physics is in {@link confettiLaunch},\n * {@link confettiStep} and {@link confettiAlive}, pure functions a spec can\n * run on their own. Each piece is a rectangle, every fifth a thin strip,\n * turning on the screen plane while its drawn height follows a cosine, so it\n * flips like paper; the back of a piece paints a shade darker.\n *\n * Colours are the `--wr-confetti-color-*` hooks on the canvas, bare theme\n * intents by default, resolved through the cascade when a burst starts, so\n * the scheme the reader is in is the one that paints. Nothing happens under\n * `prefers-reduced-motion: reduce` (a preference that flips mid-burst clears\n * the canvas at once), under `forced-colors: active` or on the server; a\n * hidden document pauses the loop and a visible one resumes it where it\n * stopped. Styles: `@use 'ngwr/animations/confetti'`, which places the canvas and\n * lists the `--wr-confetti-color-*` hooks; a service has no host to check them\n * from, so the first burst warns in dev mode when the sheet is missing.\n */\n@Service()\nexport class WrConfetti {\n private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private canvas: HTMLCanvasElement | null = null;\n private ctx: CanvasRenderingContext2D | null = null;\n private pieces: WrConfettiPiece[] = [];\n private rafId: number | null = null;\n private lastFrame = 0;\n private dpr = 1;\n private width = 0;\n private height = 0;\n private listeners: AbortController | null = null;\n /** The stylesheet was looked for once in this document. */\n private checked = false;\n\n constructor() {\n if (!this.browser) return;\n\n effect(() => {\n const reduced = this.platform.prefersReducedMotion();\n this.platform.pageVisible();\n if (reduced) this.clear();\n else this.sync();\n });\n\n inject(DestroyRef).onDestroy(() => this.clear());\n }\n\n /** Whether pieces are in the air. */\n get active(): boolean {\n return this.pieces.length > 0;\n }\n\n /**\n * Throws a burst of confetti up from `from`: an element, whose client rect\n * is read now, or a rect in client coordinates. Pieces start anywhere\n * inside the rect, so a wide block showers along its width and a button\n * bursts from a point.\n */\n burst(from: Element | WrConfettiRect, options: WrConfettiOptions = {}): void {\n if (!this.browser || this.platform.prefersReducedMotion()) return;\n const view = this.doc.defaultView;\n if (!view || view.matchMedia?.('(forced-colors: active)').matches) return;\n\n const canvas = this.canvas ?? this.mount(view);\n if (!canvas) return;\n const rect = 'getBoundingClientRect' in from ? from.getBoundingClientRect() : from;\n const seed = options.seed ?? Math.floor(Math.random() * 0x1_0000_0000);\n const palette = CONFETTI_COLORS.map(([hook, fallback]) => wrResolveCssColor(canvas, hook, fallback));\n this.pieces.push(...confettiLaunch(rect, seed, options.count ?? CONFETTI_COUNT, palette));\n this.sync();\n }\n\n /** Stops the loop and takes the canvas and every piece out. Idempotent. */\n clear(): void {\n this.stopLoop();\n this.pieces = [];\n this.listeners?.abort();\n this.listeners = null;\n this.canvas?.remove();\n this.canvas = null;\n this.ctx = null;\n }\n\n /** Makes the canvas, or returns `null` when the browser gives it no context. */\n private mount(view: Window): HTMLCanvasElement | null {\n const canvas = this.doc.createElement('canvas');\n canvas.className = 'wr-confetti';\n canvas.setAttribute('aria-hidden', 'true');\n const ctx = canvas.getContext('2d');\n if (!ctx) return null;\n this.canvas = canvas;\n this.ctx = ctx;\n this.listeners = new AbortController();\n view.addEventListener('resize', () => this.resize(view), { signal: this.listeners.signal, passive: true });\n this.doc.body.append(canvas);\n this.resize(view);\n if (typeof ngDevMode === 'undefined' || ngDevMode) this.checkStyles(view);\n return canvas;\n }\n\n /**\n * The service's own `wrCheckStyles`, which a root service cannot call: that\n * helper reads the host element it is injected beside, and a service has\n * none. The same marker, the same words, once per document.\n */\n private checkStyles(view: Window): void {\n if (this.checked || /jsdom|happydom/i.test(view.navigator.userAgent)) return;\n this.checked = true;\n const loaded = view.getComputedStyle(this.doc.documentElement).getPropertyValue('--wr-loaded-animations-confetti');\n if (loaded.trim() !== '') return;\n // eslint-disable-next-line no-console -- a dev-mode diagnostic, reported and never thrown\n console.warn(\n \"[NGWR] WrConfetti paints without its styles. Add @use 'ngwr/animations/confetti'; to your global stylesheet, \" +\n 'or run ng g ngwr:component-style animations/confetti.'\n );\n }\n\n private resize(view: Window): void {\n if (!this.canvas || !this.ctx) return;\n this.width = view.innerWidth;\n this.height = view.innerHeight;\n this.dpr = canvasBackdropRatio(Math.max(1, this.width), Math.max(1, this.height), view.devicePixelRatio ?? 1);\n this.canvas.width = Math.round(this.width * this.dpr);\n this.canvas.height = Math.round(this.height * this.dpr);\n }\n\n /** Starts or stops the loop: it runs while pieces are in the air and the document is visible. */\n private sync(): void {\n const run = this.ctx !== null && this.pieces.length > 0 && this.platform.pageVisible();\n if (run === (this.rafId !== null)) return;\n if (run) {\n this.lastFrame = performance.now();\n this.rafId = requestAnimationFrame(this.frame);\n return;\n }\n this.stopLoop();\n }\n\n private stopLoop(): void {\n if (this.rafId !== null) cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n\n private readonly frame = (now: number): void => {\n this.rafId = null;\n // A tab that was throttled comes back with one huge frame; the pieces move at most this far at once.\n const dt = wrClamp(now - this.lastFrame, 0, MAX_FRAME_MS);\n this.lastFrame = now;\n for (const piece of this.pieces) confettiStep(piece, dt);\n this.pieces = this.pieces.filter(piece => confettiAlive(piece, this.height));\n if (this.pieces.length === 0) {\n this.clear();\n return;\n }\n this.draw();\n this.rafId = requestAnimationFrame(this.frame);\n };\n\n private draw(): void {\n const ctx = this.ctx;\n if (!ctx) return;\n const { dpr } = this;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, this.width * dpr, this.height * dpr);\n for (const piece of this.pieces) {\n const flip = Math.cos(piece.phase);\n // Never flat: a sheet seen edge-on still shows its edge.\n const thickness = Math.sign(flip || 1) * Math.max(0.12, Math.abs(flip));\n ctx.setTransform(dpr, 0, 0, dpr, piece.x * dpr, piece.y * dpr);\n ctx.rotate(piece.angle);\n ctx.scale(1, thickness);\n // The back of the paper is in shadow.\n ctx.globalAlpha = confettiAlpha(piece) * (flip < 0 ? 0.75 : 1);\n ctx.fillStyle = piece.color;\n ctx.fillRect(-piece.width / 2, -piece.height / 2, piece.width, piece.height);\n }\n ctx.globalAlpha = 1;\n }\n}\n\nexport {\n CONFETTI_CONE,\n CONFETTI_COUNT,\n CONFETTI_DRAG,\n CONFETTI_FADE_MS,\n CONFETTI_GRAVITY,\n CONFETTI_LIFE_MS,\n CONFETTI_LIFE_SPREAD_MS,\n CONFETTI_SPEED_MAX,\n CONFETTI_SPEED_MIN,\n CONFETTI_STRIP_EVERY,\n};\n"],"mappings":";;;;;;;;;;;;AAmCA,MAAM,gBAAgB;AAGtB,MAAM,gBAAgB;AAGtB,MAAM,mBAAmB;AAezB,MAAM,kBAA0E;CAC9E,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC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