@astryx-vue/core 0.25.0 → 0.26.1

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 (334) hide show
  1. package/dist/AlertDialog/index.js +1 -1
  2. package/dist/{AlertDialog-Cub9_aPC.js → AlertDialog-CGGkPG4T.js} +192 -6
  3. package/dist/AppShell/index.d.ts +1 -1
  4. package/dist/AppShell/index.js +1 -1
  5. package/dist/{AppShell-D62A7lqZ.js → AppShell-DGJgCvS6.js} +6 -6
  6. package/dist/Avatar/index.js +1 -1
  7. package/dist/{Avatar-BKoSK75s.js → Avatar-DpFHPRlE.js} +1 -1
  8. package/dist/AvatarGroup/index.d.ts +1 -1
  9. package/dist/Badge/index.d.ts +1 -2
  10. package/dist/Banner/index.d.ts +1 -1
  11. package/dist/Banner/index.js +1 -1
  12. package/dist/{Banner-cg2nXT_4.js → Banner-DVU5-fWC.js} +1 -1
  13. package/dist/BottomSheet/index.js +2 -2
  14. package/dist/{BottomSheet-DGhRZLw4.js → BottomSheet-Dn8gpT4m.js} +9 -6
  15. package/dist/{BottomSheet-CpLYy3vb.js → BottomSheet-gctYQ3sV.js} +2 -2
  16. package/dist/Breadcrumbs/index.js +2 -2
  17. package/dist/{Breadcrumbs-D-nHDHV8.js → Breadcrumbs-BZsjHn_5.js} +1 -1
  18. package/dist/Button/index.d.ts +1 -1
  19. package/dist/Button/index.js +1 -1
  20. package/dist/{Button-D8AGK5oT.js → Button-yJiHoWps.js} +1 -1
  21. package/dist/ButtonGroup/index.d.ts +1 -1
  22. package/dist/Calendar/index.d.ts +1 -1
  23. package/dist/Card/index.d.ts +1 -1
  24. package/dist/Carousel/index.d.ts +1 -1
  25. package/dist/Carousel/index.js +1 -1
  26. package/dist/{Carousel-DrCG9wbP.js → Carousel-DPhwOTjx.js} +1 -1
  27. package/dist/Center/index.d.ts +1 -1
  28. package/dist/Chat/index.d.ts +1 -1
  29. package/dist/Chat/index.js +1 -1
  30. package/dist/{Chat-U1qq8gkF.js → Chat-RE_6Ez79.js} +206 -44
  31. package/dist/CheckboxInput/index.d.ts +1 -1
  32. package/dist/CheckboxInput/index.js +1 -1
  33. package/dist/{CheckboxInput-qm6lkjAw.js → CheckboxInput-C-UseBJo.js} +5 -5
  34. package/dist/CheckboxList/index.d.ts +1 -1
  35. package/dist/CheckboxList/index.js +1 -1
  36. package/dist/{CheckboxList-DuCKhJHJ.js → CheckboxList-CWHlG8Jq.js} +4 -4
  37. package/dist/ClickableCard/index.d.ts +1 -1
  38. package/dist/Code/index.d.ts +1 -1
  39. package/dist/Code/index.js +1 -1
  40. package/dist/{CodeBlock-PMZd9dQ9.js → CodeBlock-3QLhu3jZ.js} +1 -1
  41. package/dist/Collapsible/index.d.ts +1 -1
  42. package/dist/Collapsible/index.js +1 -1
  43. package/dist/{Collapsible-BmUloCSR.js → Collapsible-BSRdsb6w.js} +3 -3
  44. package/dist/CommandPalette/index.d.ts +1 -1
  45. package/dist/CommandPalette/index.js +1 -1
  46. package/dist/{CommandPalette-Cy7trpD3.js → CommandPalette-CtY5ZCR7.js} +50 -20
  47. package/dist/ComplexSelector/index.d.ts +1 -1
  48. package/dist/ComplexSelector/index.js +1 -1
  49. package/dist/{ComplexSelector-DMBiVQWp.js → ComplexSelector-DI3J30Ho.js} +4 -4
  50. package/dist/ContextMenu/index.d.ts +1 -1
  51. package/dist/ContextMenu/index.js +2 -2
  52. package/dist/{ContextMenu-63ay7EE-.js → ContextMenu-CVf4OqJP.js} +4 -4
  53. package/dist/DateInput/index.d.ts +1 -1
  54. package/dist/DateInput/index.js +1 -1
  55. package/dist/{DateInput-B3Q91FDT.js → DateInput-DK-FI37x.js} +14 -33
  56. package/dist/DateRangeInput/index.d.ts +1 -1
  57. package/dist/DateRangeInput/index.js +1 -1
  58. package/dist/{DateRangeInput-B6Z66OsH.js → DateRangeInput-ClriBc4F.js} +6 -6
  59. package/dist/DateTimeInput/index.d.ts +1 -1
  60. package/dist/DateTimeInput/index.js +1 -1
  61. package/dist/{DateTimeInput-B_7cn7ze.js → DateTimeInput-BdXkBBYi.js} +7 -7
  62. package/dist/Dialog/index.d.ts +1 -1
  63. package/dist/Dialog/index.js +3 -3
  64. package/dist/{Dialog-CBPD5b-S.js → Dialog-CKDlXonX.js} +1 -1
  65. package/dist/{Dialog-C4FZ7p7Q.js → Dialog-DjhG_vpE.js} +3 -3
  66. package/dist/{DialogHeader-CQ3pnLYi.js → DialogHeader-C1Bz4Knk.js} +2 -2
  67. package/dist/Divider/index.d.ts +1 -1
  68. package/dist/Drawer/index.d.ts +1 -1
  69. package/dist/Drawer/index.js +1 -1
  70. package/dist/{Drawer-BOwQLKm9.js → Drawer-BqcPP0z7.js} +2 -2
  71. package/dist/DropdownMenu/index.js +3 -3
  72. package/dist/{DropdownMenu-9CR9TiKG.js → DropdownMenu-CdwEvDld.js} +3 -3
  73. package/dist/{DropdownMenu-DwIfoTnV.js → DropdownMenu-q5euMYv-.js} +40 -11
  74. package/dist/EmptyState/index.js +1 -1
  75. package/dist/{EmptyState-BG5g2jwJ.js → EmptyState-DNjqNAT3.js} +4 -50
  76. package/dist/Field/index.d.ts +3 -3
  77. package/dist/Field/index.js +3 -3
  78. package/dist/{Field-eAowUUMX.js → Field-DrUMz0oj.js} +2 -2
  79. package/dist/{FieldInfoTip-Dwl9HNp1.js → FieldInfoTip-DmDOcxU1.js} +1 -1
  80. package/dist/{FieldLabel-CgYk-ORu.js → FieldLabel-DsFZnW1l.js} +3 -3
  81. package/dist/FieldStatus/index.d.ts +1 -1
  82. package/dist/FileInput/index.d.ts +1 -1
  83. package/dist/FileInput/index.js +1 -1
  84. package/dist/{FileInput-B7zeePbM.js → FileInput-0u4zjJfx.js} +135 -85
  85. package/dist/FormLayout/index.js +1 -1
  86. package/dist/{FormLayout-CGJVeNsL.js → FormLayout-0_X9o-L4.js} +1 -1
  87. package/dist/Heading/index.js +1 -1
  88. package/dist/{Heading-B1dNZQtu.js → Heading-BG1PBVkf.js} +1 -1
  89. package/dist/HoverCard/index.d.ts +1 -1
  90. package/dist/HoverCard/index.js +1 -1
  91. package/dist/{HoverCard-CZhfsvP4.js → HoverCard-Fr6RLRR8.js} +2 -2
  92. package/dist/IconButton/index.js +1 -1
  93. package/dist/{IconButton-D9ZRJ7vD.js → IconButton-CEjiXpUg.js} +1 -1
  94. package/dist/Indicator/index.d.ts +2 -2
  95. package/dist/InfoTip/index.d.ts +1 -1
  96. package/dist/InfoTip/index.js +1 -1
  97. package/dist/{InfoTip-LJi9llxi.js → InfoTip-CKRaCO6I.js} +1 -1
  98. package/dist/{InputClearButton-C-j9Nf1s.js → InputClearButton-ByUJXRmY.js} +1 -1
  99. package/dist/InputGroup/index.d.ts +1 -1
  100. package/dist/InputGroup/index.js +1 -1
  101. package/dist/{InputGroup-B8PGJZKH.js → InputGroup-H8DP0TAG.js} +6 -6
  102. package/dist/InternationalizationProvider/index.d.ts +1 -1
  103. package/dist/InternationalizationProvider/index.js +1 -1
  104. package/dist/{InternationalizationProvider-DaZS5Dch.js → InternationalizationProvider-8qllKdVk.js} +1 -1
  105. package/dist/Layout/index.js +2 -2
  106. package/dist/{Layout-DOIeCgs4.js → Layout-094k14rN.js} +1 -1
  107. package/dist/{LayoutPanel-C7Wsid2W.js → LayoutPanel-BPboQAJj.js} +1 -1
  108. package/dist/Lightbox/index.js +1 -1
  109. package/dist/{Lightbox-BOWTHnTb.js → Lightbox-LI6h7LFn.js} +3 -3
  110. package/dist/Link/index.d.ts +1 -1
  111. package/dist/Link/index.js +1 -1
  112. package/dist/{Link-B75ygGzG.js → Link-Dx2ql41g.js} +1 -1
  113. package/dist/List/index.d.ts +1 -1
  114. package/dist/Markdown/index.d.ts +1 -1
  115. package/dist/Markdown/index.js +1 -1
  116. package/dist/{Markdown-Cqrcj-ct.js → Markdown-BHWf2IOO.js} +3 -3
  117. package/dist/MetadataList/index.d.ts +1 -1
  118. package/dist/MobileNav/index.js +1 -1
  119. package/dist/{MobileNavToggle-DLpEONfs.js → MobileNavToggle-Dx7rmb-V.js} +3 -3
  120. package/dist/MoreMenu/index.d.ts +1 -1
  121. package/dist/MoreMenu/index.js +1 -1
  122. package/dist/{MoreMenu-aR88r9xp.js → MoreMenu-DAq29azZ.js} +3 -3
  123. package/dist/MultiSelector/index.d.ts +1 -1
  124. package/dist/MultiSelector/index.js +1 -1
  125. package/dist/{MultiSelector-UTaDe-YT.js → MultiSelector-BUXFzIla.js} +8 -8
  126. package/dist/NavItem/index.d.ts +1 -1
  127. package/dist/NavMenu/index.js +2 -2
  128. package/dist/{NavMenu-DS6y8ZAY.js → NavMenu-BoKuJq-K.js} +1 -1
  129. package/dist/{NavMenuItem-BqIi3o3D.js → NavMenuItem-Ez3_K8iI.js} +1 -1
  130. package/dist/NumberInput/index.d.ts +2 -2
  131. package/dist/NumberInput/index.js +1 -1
  132. package/dist/{NumberInput-ClkOGF5j.js → NumberInput-lqUmTsqB.js} +386 -99
  133. package/dist/OverflowList/index.d.ts +1 -1
  134. package/dist/OverflowList/index.js +1 -1
  135. package/dist/{OverflowList-UnVXBDIW.js → OverflowList-B6En7wIj.js} +1 -1
  136. package/dist/Overlay/index.d.ts +1 -1
  137. package/dist/Pagination/index.d.ts +1 -1
  138. package/dist/Pagination/index.js +1 -1
  139. package/dist/{Pagination-CTCLE02h.js → Pagination-CRrou1P-.js} +60 -49
  140. package/dist/Popover/index.d.ts +3 -3
  141. package/dist/Popover/index.js +1 -1
  142. package/dist/Popover-sERt08TR.js +1247 -0
  143. package/dist/PowerSearch/index.d.ts +1 -1
  144. package/dist/PowerSearch/index.js +1 -1
  145. package/dist/{PowerSearch-BBOum0TP.js → PowerSearch-CiVIW13b.js} +230 -143
  146. package/dist/ProgressBar/index.d.ts +1 -1
  147. package/dist/ProgressBar/index.js +1 -1
  148. package/dist/{ProgressBar-Bgg6zsKR.js → ProgressBar-yw2BCtB_.js} +1 -1
  149. package/dist/Radio/index.d.ts +1 -1
  150. package/dist/Radio/index.js +1 -1
  151. package/dist/{RadioGroup-DPy5JQhm.js → RadioGroup-B8QoJyJu.js} +5 -5
  152. package/dist/RadioList/index.d.ts +1 -1
  153. package/dist/RadioList/index.js +1 -1
  154. package/dist/{RadioList-UN7IxQg8.js → RadioList-BEv82wbs.js} +1 -1
  155. package/dist/ScrollableArea/index.d.ts +1 -1
  156. package/dist/SelectableCard/index.d.ts +1 -1
  157. package/dist/Selector/index.d.ts +1 -1
  158. package/dist/Selector/index.js +1 -1
  159. package/dist/{Selector-CCtsUveZ.js → Selector-Bj4q6aT5.js} +6 -6
  160. package/dist/SideNav/index.d.ts +1 -1
  161. package/dist/SideNav/index.js +2 -2
  162. package/dist/{SideNav-COl5ApOz.js → SideNav-CHSwzwTt.js} +7 -7
  163. package/dist/Slider/index.d.ts +1 -1
  164. package/dist/Slider/index.js +1 -1
  165. package/dist/{Slider-CYie9hWm.js → Slider-Bmksx8ng.js} +4 -4
  166. package/dist/Stack/index.d.ts +1 -1
  167. package/dist/StatusDot/index.js +1 -1
  168. package/dist/{StatusDot-CHfgSYmv.js → StatusDot-Bz4l43St.js} +1 -1
  169. package/dist/Stepper/index.d.ts +1 -1
  170. package/dist/Switch/index.d.ts +1 -1
  171. package/dist/Switch/index.js +1 -1
  172. package/dist/{Switch-D24CvhDS.js → Switch-CeNEvvTn.js} +5 -5
  173. package/dist/TabList/index.d.ts +1 -1
  174. package/dist/TabList/index.js +1 -1
  175. package/dist/{TabList-DToCh5JW.js → TabList-BLLxHXwu.js} +1 -1
  176. package/dist/Table/index.d.ts +1 -1
  177. package/dist/Table/index.js +1 -1
  178. package/dist/{Table-D3mzxBr0.js → Table-DEqfIA3q.js} +16 -16
  179. package/dist/Text/index.js +1 -1
  180. package/dist/{Text-5p-eZodt.js → Text-DkSHitKh.js} +1 -1
  181. package/dist/TextArea/index.d.ts +1 -1
  182. package/dist/TextArea/index.js +1 -1
  183. package/dist/{TextArea-Bp6D-riO.js → TextArea-CAcjMvls.js} +56 -22
  184. package/dist/TextInput/index.d.ts +1 -1
  185. package/dist/TextInput/index.js +1 -1
  186. package/dist/{TextInput-BYslwBDZ.js → TextInput-BvQQTG75.js} +78 -34
  187. package/dist/Theme/index.d.ts +2 -2
  188. package/dist/Thumbnail/index.js +1 -1
  189. package/dist/{Thumbnail-B_a8tOS7.js → Thumbnail-Bv-M13fy.js} +2 -2
  190. package/dist/{TimeField-MDSJny9m.js → TimeField-hB88chlQ.js} +13 -32
  191. package/dist/TimeInput/index.d.ts +1 -1
  192. package/dist/TimeInput/index.js +1 -1
  193. package/dist/{TimeInput-B19amuxi.js → TimeInput-JrTs9r66.js} +3 -3
  194. package/dist/Timer/index.js +1 -1
  195. package/dist/{Timer-BD3tfzrF.js → Timer-qjI_QrCz.js} +1 -1
  196. package/dist/Timestamp/index.d.ts +1 -1
  197. package/dist/Timestamp/index.js +1 -1
  198. package/dist/{Timestamp-CqWoZUKM.js → Timestamp-CJ_HUcek.js} +3 -3
  199. package/dist/Toast/index.js +1 -1
  200. package/dist/{Toast-BKPl8iIr.js → Toast-CFpOSuAr.js} +1 -1
  201. package/dist/ToggleButton/index.d.ts +1 -1
  202. package/dist/ToggleButton/index.js +1 -1
  203. package/dist/{ToggleButton-DfpsuhMa.js → ToggleButton-BtXMvoOA.js} +1 -1
  204. package/dist/Token/index.d.ts +1 -1
  205. package/dist/Tokenizer/index.d.ts +1 -1
  206. package/dist/Tokenizer/index.js +1 -1
  207. package/dist/{Tokenizer-C-eorFsF.js → Tokenizer-2zj57yDt.js} +4 -4
  208. package/dist/Toolbar/index.d.ts +1 -1
  209. package/dist/Tooltip/index.d.ts +1 -1
  210. package/dist/Tooltip/index.js +2 -2
  211. package/dist/{Tooltip-88zhGfzF.js → Tooltip-ByLqPCP7.js} +1 -1
  212. package/dist/TopNav/index.d.ts +1 -1
  213. package/dist/TopNav/index.js +1 -1
  214. package/dist/{TopNav-DMFIsFwy.js → TopNav-Ce79A3zT.js} +3 -3
  215. package/dist/TreeList/index.d.ts +1 -1
  216. package/dist/TreeList/index.js +1 -1
  217. package/dist/{TreeList-nU2gSmQm.js → TreeList-BEPHdVYu.js} +2 -2
  218. package/dist/Typeahead/index.d.ts +2 -2
  219. package/dist/Typeahead/index.js +1 -1
  220. package/dist/{Typeahead-DUQfmy_r.js → Typeahead-CBrUdbHv.js} +4 -4
  221. package/dist/{types-fRasDCe4.d.ts → adaptationTypes-Cn_pfrsw.d.ts} +155 -155
  222. package/dist/animator-BooLoGyI.js +3164 -0
  223. package/dist/announceRenderedText-CslZ0cev.js +50 -0
  224. package/dist/{assertOptions-DVRsfCk1.js → assertOptions-CJgNig1l.js} +2 -2
  225. package/dist/{batch-DR5SgbnX.js → batch-CM-vJhQg.js} +2 -278
  226. package/dist/{handle-ma1yF_B_.js → bezier-Cts7gENO.js} +1 -21
  227. package/dist/composables/index.d.ts +2 -2
  228. package/dist/composables/index.js +7 -7
  229. package/dist/{composables-Do86VAmM.js → composables-BtqijTIO.js} +5 -3163
  230. package/dist/{context-DsNhYm5O.js → context-CrVCeUUK.js} +1 -1
  231. package/dist/context-DH8E-qjm.js +173 -0
  232. package/dist/{edge-qfeek_VV.js → edge-BYXwSggM.js} +1 -1
  233. package/dist/{edgeRide-iWUNdlxe.js → edgeRide-B5mlN2Q4.js} +3 -3
  234. package/dist/escape-DzSxSmez.js +10 -0
  235. package/dist/{field-CehUqCe0.js → field-BaUBjqf5.js} +4 -2
  236. package/dist/{fieldParts-CbWvZLhH.js → fieldParts-CuE5V12i.js} +1 -1
  237. package/dist/{focusLeaving-Dqm8Yj4T.js → focusLeaving-DMkbxFkF.js} +1 -1
  238. package/dist/{focusReturn-C1cFL3WM.js → focusReturn-DfZS7TCp.js} +1 -1
  239. package/dist/handle-BazRxHwq.js +22 -0
  240. package/dist/holdEntranceInput-DMCOeRqu.js +37 -0
  241. package/dist/{index-CsYDrQ9R.d.ts → index-668zPVsH.d.ts} +1 -1
  242. package/dist/{index-CnVjgLP5.d.ts → index-B5aHF0Ml.d.ts} +1 -2
  243. package/dist/{index-CuW4AQ7M.d.ts → index-BD-Pxni9.d.ts} +3 -3
  244. package/dist/{index-DDAcxZAP.d.ts → index-BZUVNr2c.d.ts} +1 -1
  245. package/dist/{index-B52PMrO7.d.ts → index-BdhQpERn.d.ts} +7 -7
  246. package/dist/{index-CEjvYAUZ.d.ts → index-BenG-F5d.d.ts} +1 -1
  247. package/dist/{index-CTjkJP4x.d.ts → index-Bgk1Rj2A.d.ts} +1 -1
  248. package/dist/{index-Qdbssopn.d.ts → index-BjqoHLMq.d.ts} +4 -1
  249. package/dist/{index-BDZCJ9ri.d.ts → index-BuubzuE8.d.ts} +2 -2
  250. package/dist/{index-ChqMaV6N.d.ts → index-Bzi3A980.d.ts} +1 -1
  251. package/dist/{index-0RIgvtdm.d.ts → index-C2zWUiJ1.d.ts} +2 -2
  252. package/dist/{index-CKnr0JlT.d.ts → index-C4S65SAW.d.ts} +1 -1
  253. package/dist/{index-D05JGsT3.d.ts → index-C8wfe0Mr.d.ts} +1 -1
  254. package/dist/{index-CiVrhGUJ.d.ts → index-C9ZssPUV.d.ts} +1 -1
  255. package/dist/{index-ZKBj_1nu.d.ts → index-CB6VQETg.d.ts} +2 -2
  256. package/dist/{index-BfoazhEu.d.ts → index-CTXG-KKT.d.ts} +1 -1
  257. package/dist/{index-mK1ICsVg.d.ts → index-Cm36VS1A.d.ts} +2 -2
  258. package/dist/{index-_FjbcSgD.d.ts → index-CnOH43-f.d.ts} +1 -2
  259. package/dist/index-CuFLztiI.d.ts +49 -0
  260. package/dist/{index-QnlWyUxN.d.ts → index-D14kSf-g.d.ts} +4 -4
  261. package/dist/{index-BgT6mH3U.d.ts → index-D7ShT2c-.d.ts} +1 -1
  262. package/dist/index-DHUCHxn2.d.ts +69 -0
  263. package/dist/{index-GmoeIuhl.d.ts → index-DMZ5SKJJ.d.ts} +35 -3
  264. package/dist/{index-CO9GW-ik.d.ts → index-DPklTi3o.d.ts} +1 -1
  265. package/dist/{index-Dcxqzk_d.d.ts → index-DSMv6W8s.d.ts} +8 -8
  266. package/dist/{index-BjmMJ_4E.d.ts → index-DY1kpap1.d.ts} +1657 -275
  267. package/dist/{index-DxR6cZBf.d.ts → index-DZCpswvp.d.ts} +1 -1
  268. package/dist/{index-BhdxP-OG.d.ts → index-DeZ11MNP.d.ts} +2 -2
  269. package/dist/{index-lmd9LZKB.d.ts → index-DlKz3dB1.d.ts} +6 -3
  270. package/dist/{index-CbA8rR_b.d.ts → index-FeZXsFO-.d.ts} +2 -2
  271. package/dist/{index-CH-xSiJz.d.ts → index-LqFjvL4C.d.ts} +4 -4
  272. package/dist/{index-utZGF4GR.d.ts → index-NOXYEdOI.d.ts} +1 -1
  273. package/dist/{index-DofC9Rll.d.ts → index-Otl047R1.d.ts} +1 -1
  274. package/dist/{index-DCyYldjP.d.ts → index-T5bzxQ30.d.ts} +1 -1
  275. package/dist/{index-COgrQZIL.d.ts → index-YKCx03zD.d.ts} +2 -2
  276. package/dist/{index-BKnyTWPM.d.ts → index-ZbNwGVkS.d.ts} +1 -1
  277. package/dist/{index-DGXCnzOL.d.ts → index-aHC2C89h.d.ts} +1 -1
  278. package/dist/{index-DYabo8TI.d.ts → index-eCp-ElSp.d.ts} +1 -1
  279. package/dist/{index-yQc-te9a.d.ts → index-ql9ApSTF.d.ts} +2 -2
  280. package/dist/{index-0pBqcQXV.d.ts → index-tpkJfk6X.d.ts} +6 -1
  281. package/dist/index.d.ts +49 -52
  282. package/dist/index.js +90 -90
  283. package/dist/{holdEntranceInput-DjEzfGRU.js → inputHold-BmChuR9x.js} +87 -85
  284. package/dist/inputHoldState-pblUT4oh.js +39 -0
  285. package/dist/{interactionModality-CedLz5PC.js → interactionModality-4Km2ibsq.js} +4 -3
  286. package/dist/{landing-qVsYAZ-v.js → landing-B9Uvex6x.js} +3 -2
  287. package/dist/{layerFocusReturn-KvH6DMFT.js → layerFocusReturn-CEvrMbxH.js} +1 -1
  288. package/dist/lazyBottomSheet-CxEu25bK.js +16 -0
  289. package/dist/{loadCatalog-BeQt6Uq-.js → loadCatalog-BRd5XCbW.js} +24 -1
  290. package/dist/{loadCatalog-C8mRnC0E.d.ts → loadCatalog-CLm4V7mm.d.ts} +100 -2
  291. package/dist/locale/index.d.ts +2 -3
  292. package/dist/locale/index.js +3 -3
  293. package/dist/{locale-B4FpGKpc.js → locale-BkAezFog.js} +1 -1
  294. package/dist/{useHeldPresentation-fQsuYFhz.js → presentationHold-7IkbR4d8.js} +14 -22
  295. package/dist/progress-FQfSgLZC.js +38 -0
  296. package/dist/renderedText-BwJdmps3.js +32 -0
  297. package/dist/textEntryTraits-cb0LZSNl.js +11 -0
  298. package/dist/themeTiming-CWEvdh31.js +287 -0
  299. package/dist/{tooltipFocusRules-CFNKWzYn.js → tooltipFocusRules-DvVDuqZI.js} +1 -1
  300. package/dist/{context-WY1ippwe.js → transientCopy-VAsg2a46.js} +1 -172
  301. package/dist/{types-OGMYGejX.d.ts → types-BA1veIoa.d.ts} +25 -2
  302. package/dist/{types-bAQk3F8G.d.ts → types-Cvh2VwQZ.d.ts} +4 -2
  303. package/dist/{types-C1ydeFiu.d.ts → types-DL-hRibg.d.ts} +1 -1
  304. package/dist/{useChatStreamScroll-BIMKffDA.js → useChatStreamScroll-Cv51kRT0.js} +91 -30
  305. package/dist/useEntryErrorReport-Wee3N8IA.js +51 -0
  306. package/dist/{useFocusTrap-DTz_d7IP.js → useFocusTrap-BD9POtMp.js} +2 -2
  307. package/dist/useHeldPresentation-7MH-RlSF.js +24 -0
  308. package/dist/{useInputStatusIcon-B6m_t8cK.d.ts → useInputStatusIcon-CFkOmDS4.d.ts} +1 -1
  309. package/dist/{useInputStatusIcon-BFw-EXjJ.js → useInputStatusIcon-CGj9gMj8.js} +1 -1
  310. package/dist/{useMenuDrillIn-CDn2na4X.js → useMenuDrillIn-CP0P49ej.js} +1 -1
  311. package/dist/{useMenuPress-CxUqSUZ9.js → useMenuPress-DU6pAIHy.js} +4 -2
  312. package/dist/{useRestoreFocus-BxooFhas.js → useRestoreFocus-AeZABFZN.js} +2 -2
  313. package/dist/{useTooltip-CJHbG8Pv.js → useTooltip-Bsm43vbi.js} +5 -35
  314. package/dist/{useTouchTriggerInternal-Bdm_M4aa.js → useTouchTriggerInternal-Bl602PtA.js} +1 -1
  315. package/dist/{useTruncationTooltip-BTcr1LCR.js → useTruncationTooltip-wc6Lzz34.js} +3 -3
  316. package/package.json +1 -1
  317. package/styles/alert-dialog.css +5 -0
  318. package/styles/chat.css +45 -17
  319. package/styles/command-palette.css +9 -6
  320. package/styles/dropdown-menu.css +47 -38
  321. package/styles/file-input.css +8 -1
  322. package/styles/input-group.css +0 -15
  323. package/styles/number-input.css +49 -4
  324. package/styles/pagination.css +0 -22
  325. package/styles/popover.css +13 -0
  326. package/styles/text-area.css +16 -1
  327. package/styles/text-input.css +26 -5
  328. package/dist/Popover-CZvRSqqD.js +0 -374
  329. package/dist/index-B63NOJRc.d.ts +0 -957
  330. package/dist/index-B9WzWqzk.d.ts +0 -18
  331. package/dist/index-BtgkNd0Q.d.ts +0 -446
  332. package/dist/power-search-CuMzfLwW.d.ts +0 -87
  333. package/dist/types-DIYwbkpe.d.ts +0 -33
  334. package/dist/{index-CHx33xGa.d.ts → index-J6YRJ7Ul.d.ts} +1 -1
@@ -0,0 +1,3164 @@
1
+ import { b as isSpring, h as motionRoleOf, m as motionRoleIn } from "./pressGesture-BzIBmKF2.js";
2
+ import { t as quietFinished } from "./quietFinished-CKZXgsPM.js";
3
+ import { a as clearPresentedResolve, c as registerPresentedOffset, d as writePresentedResolve, f as themeReducesMotion, n as reducedMotionCrossFade, r as registerReducedMotionCrossFade, t as cubicBezier } from "./bezier-Cts7gENO.js";
4
+ import { n as isDevBuild } from "./devBuild-G249YcdZ.js";
5
+ import { t as devWarn } from "./useDevWarning-B2fsk2B-.js";
6
+ //#region src/motion/springParameters.ts
7
+ /**
8
+ * @file springParameters.ts
9
+ * @output The `Spring` model and the conversions between Apple's spring
10
+ * vocabularies (duration and bounce, response and damping ratio, mass,
11
+ * stiffness and damping), and UIKit's relative velocity
12
+ * @position Pure math under spring.ts, which re-exports all of it. See
13
+ * spring.ts for the sources of each conversion.
14
+ */
15
+ const TAU = 2 * Math.PI;
16
+ function assertPositiveFinite(name, value) {
17
+ if (!(Number.isFinite(value) && value > 0)) throw new RangeError(`spring: ${name} must be a positive number, got ${value}`);
18
+ }
19
+ /**
20
+ * SwiftUI's `Spring(duration:bounce:)` and UIKit's
21
+ * `UIView.animate(springDuration:bounce:…)`: the WWDC23 equations. Bounce is
22
+ * clamped to SwiftUI's documented range (−1, 1].
23
+ *
24
+ * @example
25
+ * ```
26
+ * springFromDurationBounce({duration: 0.5, bounce: 0}); // SwiftUI .smooth
27
+ * ```
28
+ */
29
+ function springFromDurationBounce({ duration, bounce }) {
30
+ assertPositiveFinite("duration", duration);
31
+ if (!Number.isFinite(bounce)) throw new RangeError(`spring: bounce must be finite, got ${bounce}`);
32
+ const b = Math.min(1, Math.max(-.999999, bounce));
33
+ return {
34
+ mass: 1,
35
+ stiffness: (TAU / duration) ** 2,
36
+ damping: b >= 0 ? (1 - b) * 2 * TAU / duration : 2 * TAU / (duration * (1 + b))
37
+ };
38
+ }
39
+ /**
40
+ * SwiftUI's `Spring(response:dampingRatio:)` and
41
+ * `Animation.spring(response:dampingFraction:)`. Overdamping (ratio > 1) is
42
+ * kept, as SwiftUI keeps it for this initializer.
43
+ */
44
+ function springFromResponse({ response, dampingRatio }) {
45
+ assertPositiveFinite("response", response);
46
+ if (!(Number.isFinite(dampingRatio) && dampingRatio >= 0)) throw new RangeError(`spring: dampingRatio must be ≥ 0, got ${dampingRatio}`);
47
+ const omega = TAU / response;
48
+ return {
49
+ mass: 1,
50
+ stiffness: omega * omega,
51
+ damping: 2 * dampingRatio * omega
52
+ };
53
+ }
54
+ /**
55
+ * `CASpringAnimation` / `UISpringTimingParameters(mass:stiffness:damping:)`
56
+ * / SwiftUI `Spring(mass:stiffness:damping:allowOverDamping:)`. Like SwiftUI,
57
+ * an overdamped spring is treated as critically damped unless
58
+ * `allowOverdamping` is set: "a value of false specifies that such cases
59
+ * should instead be treated as critically damped".
60
+ */
61
+ function springFromPhysics({ mass = 1, stiffness, damping, allowOverdamping = false }) {
62
+ assertPositiveFinite("mass", mass);
63
+ assertPositiveFinite("stiffness", stiffness);
64
+ if (!(Number.isFinite(damping) && damping >= 0)) throw new RangeError(`spring: damping must be ≥ 0, got ${damping}`);
65
+ const critical = 2 * Math.sqrt(stiffness * mass);
66
+ return {
67
+ mass,
68
+ stiffness,
69
+ damping: allowOverdamping ? damping : Math.min(damping, critical)
70
+ };
71
+ }
72
+ /** Undamped angular frequency ω₀ = √(k/m), rad/s. */
73
+ function naturalFrequency(spring) {
74
+ return Math.sqrt(spring.stiffness / spring.mass);
75
+ }
76
+ /** Damping ratio ζ = c / (2·√(k·m)). */
77
+ function dampingRatioOf(spring) {
78
+ return spring.damping / (2 * Math.sqrt(spring.stiffness * spring.mass));
79
+ }
80
+ /**
81
+ * Normalizes a description to the physical `Spring`. A physical description
82
+ * gets `springFromPhysics`' treatment: overdamping is clamped to critical, as
83
+ * SwiftUI and Core Animation do by default.
84
+ */
85
+ function toSpring(description) {
86
+ if ("stiffness" in description) return springFromPhysics(description);
87
+ if ("bounce" in description) return springFromDurationBounce(description);
88
+ return springFromResponse(description);
89
+ }
90
+ //#endregion
91
+ //#region src/motion/spring.ts
92
+ /**
93
+ * Closed-form solution of the spring released at `from` with
94
+ * `initialVelocity` (units/s), heading for `to`.
95
+ *
96
+ * @example
97
+ * ```
98
+ * const curve = solveSpring(springFromDurationBounce({duration: 0.5, bounce: 0}), {from: 0, to: 300});
99
+ * curve.value(0.1); // px after 100 ms
100
+ * ```
101
+ */
102
+ function solveSpring(spring, { from, to, velocity: initialVelocity = 0 }) {
103
+ const omega0 = naturalFrequency(spring);
104
+ const zeta = dampingRatioOf(spring);
105
+ const x0 = from - to;
106
+ const v0 = initialVelocity;
107
+ let displacement;
108
+ let speed;
109
+ let envelope;
110
+ let envelopePeak = 0;
111
+ if (zeta < .999999) {
112
+ const decay = zeta * omega0;
113
+ const omegaD = omega0 * Math.sqrt(1 - zeta * zeta);
114
+ const a = x0;
115
+ const b = (v0 + decay * x0) / omegaD;
116
+ const bv = (decay * v0 + omega0 * omega0 * x0) / omegaD;
117
+ displacement = (t) => Math.exp(-decay * t) * (a * Math.cos(omegaD * t) + b * Math.sin(omegaD * t));
118
+ speed = (t) => Math.exp(-decay * t) * (v0 * Math.cos(omegaD * t) - bv * Math.sin(omegaD * t));
119
+ const amplitude = Math.abs(a) + Math.abs(b);
120
+ envelope = (t) => amplitude * Math.exp(-decay * t);
121
+ } else if (zeta <= 1.000001) {
122
+ const b = v0 + omega0 * x0;
123
+ displacement = (t) => (x0 + b * t) * Math.exp(-omega0 * t);
124
+ speed = (t) => (v0 - omega0 * b * t) * Math.exp(-omega0 * t);
125
+ const absA = Math.abs(x0);
126
+ const absB = Math.abs(b);
127
+ envelope = (t) => (absA + absB * t) * Math.exp(-omega0 * t);
128
+ envelopePeak = absB > 0 ? Math.max(0, 1 / omega0 - absA / absB) : 0;
129
+ } else {
130
+ const root = omega0 * Math.sqrt(zeta * zeta - 1);
131
+ const r1 = -zeta * omega0 + root;
132
+ const r2 = -zeta * omega0 - root;
133
+ const c1 = (v0 - r2 * x0) / (r1 - r2);
134
+ const c2 = x0 - c1;
135
+ displacement = (t) => c1 * Math.exp(r1 * t) + c2 * Math.exp(r2 * t);
136
+ speed = (t) => r1 * c1 * Math.exp(r1 * t) + r2 * c2 * Math.exp(r2 * t);
137
+ const absC1 = Math.abs(c1);
138
+ const absC2 = Math.abs(c2);
139
+ envelope = (t) => absC1 * Math.exp(r1 * t) + absC2 * Math.exp(r2 * t);
140
+ }
141
+ const settleTime = (threshold) => {
142
+ if (!(threshold > 0)) return Infinity;
143
+ if (zeta === 0) return x0 === 0 && v0 === 0 ? 0 : Infinity;
144
+ const start = envelopePeak;
145
+ if (envelope(start) <= threshold) return 0;
146
+ if (zeta < .999999) {
147
+ const amplitude = envelope(0);
148
+ return Math.log(amplitude / threshold) / (zeta * omega0);
149
+ }
150
+ let lo = start;
151
+ let hi = Math.max(start, 1 / omega0);
152
+ while (envelope(hi) > threshold) {
153
+ lo = hi;
154
+ hi *= 2;
155
+ if (hi > 1e6) return Infinity;
156
+ }
157
+ for (let i = 0; i < 100 && hi - lo > 1e-12; i++) {
158
+ const mid = (lo + hi) / 2;
159
+ if (envelope(mid) > threshold) lo = mid;
160
+ else hi = mid;
161
+ }
162
+ return hi;
163
+ };
164
+ return {
165
+ spring,
166
+ from,
167
+ to,
168
+ initialVelocity,
169
+ value: (t) => to + displacement(t),
170
+ velocity: (t) => speed(t),
171
+ settleTime
172
+ };
173
+ }
174
+ //#endregion
175
+ //#region src/motion/engine/constants.ts
176
+ const PROPERTIES = [
177
+ "x",
178
+ "y",
179
+ "rotate",
180
+ "scaleX",
181
+ "scaleY",
182
+ "opacity"
183
+ ];
184
+ /** The axes momentum moves: `decay` takes only these (DR2, DEC-2). */
185
+ const DECAY_PROPERTIES = ["x", "y"];
186
+ const IDENTITY = {
187
+ x: 0,
188
+ y: 0,
189
+ rotate: 0,
190
+ scaleX: 1,
191
+ scaleY: 1,
192
+ opacity: 1
193
+ };
194
+ /**
195
+ * Keyframes are added until linear interpolation is within this: a quarter of
196
+ * a device pixel (this quarter of a CSS pixel, divided by the device pixel
197
+ * ratio where it is above 1), a twentieth of a degree, a 2000th of the size,
198
+ * about one step of an 8-bit alpha. Every one is below what a moving element
199
+ * can show.
200
+ */
201
+ const SAMPLE_TOLERANCE = {
202
+ x: .25,
203
+ y: .25,
204
+ rotate: .05,
205
+ scaleX: 5e-4,
206
+ scaleY: 5e-4,
207
+ opacity: .004
208
+ };
209
+ /** Keyframes start on this grid (ms) and are split where the curve needs it. */
210
+ const SAMPLE_GRID_MS = 1e3 / 30;
211
+ /** A curve that has not settled by then (an undamped spring) snaps. */
212
+ const MAX_DURATION_MS = 3e4;
213
+ /**
214
+ * The keyframes hold the end state this long after a curve ends. An engine
215
+ * whose compositor ends an animation while the main thread is blocked falls
216
+ * back to the value its main thread last committed, the curve's start
217
+ * (WebKit on Linux); the hold keeps the end state on screen through any such
218
+ * block. It only stretches the last keyframe. The main thread retires the
219
+ * animation as soon as it runs after the curve's end.
220
+ *
221
+ * Why a tail inside the curve's own animation, with a bound (measured Oct 24
222
+ * 2026; do not replace it without these proofs):
223
+ * - WebKit on Linux (WebKitGTK and WPE) ignores `fill` on its compositor:
224
+ * a 400 ms move that ends during a 1 s main-thread block snaps back to the
225
+ * block-start position 13 ms after its end, with `fill: forwards` or with
226
+ * no fill, and holds with this tail. iOS 26.2 Mobile Safari holds the end
227
+ * in all three forms, so there the tail is unneeded but harmless (measured
228
+ * Oct 25 2026). The browser proof "a spring that ends inside the block
229
+ * keeps showing its end state" catches it.
230
+ * - A separate static animation of the end state under the curve would hold
231
+ * it without a bound, but two animations on one property push Chromium to
232
+ * run the curve on the main thread: the 1 s block proof moved in 0 of 57
233
+ * frames, the start-before-a-block proof failed, and seeking the curve
234
+ * broke.
235
+ */
236
+ const END_HOLD_MS = 6e4;
237
+ /**
238
+ * The soonest a running animation's end is looked for again, ms: a frame at
239
+ * 60 Hz. WebKit moves an animation's currentTime once per frame, so a look
240
+ * within a frame reads the frame's time, a fraction of a ms short of the end,
241
+ * and a timer for that fraction would fire again before anything moved.
242
+ */
243
+ const END_RECHECK_MS = 1e3 / 60;
244
+ const CHANNELS = {
245
+ translate: ["x", "y"],
246
+ rotate: ["rotate"],
247
+ scale: ["scaleX", "scaleY"],
248
+ opacity: ["opacity"]
249
+ };
250
+ const CHANNEL_OF = {
251
+ x: "translate",
252
+ y: "translate",
253
+ rotate: "rotate",
254
+ scaleX: "scale",
255
+ scaleY: "scale",
256
+ opacity: "opacity"
257
+ };
258
+ /** What `inlineText` writes for each channel at identity. */
259
+ const IDENTITY_TEXT = {
260
+ translate: "none",
261
+ rotate: "none",
262
+ scale: "none",
263
+ opacity: "1"
264
+ };
265
+ /**
266
+ * The transition `decay` hands a Reduce Motion transition curve to: under
267
+ * Reduce Motion `animate` plays no spring (a cross-fade, or at once), so the
268
+ * spring itself is never solved.
269
+ */
270
+ const REDUCED_TRANSITION = { spring: {
271
+ duration: .5,
272
+ bounce: 0
273
+ } };
274
+ //#endregion
275
+ //#region src/motion/engine/cssValues.ts
276
+ function round(value, digits) {
277
+ return Number(value.toFixed(digits));
278
+ }
279
+ function format(channel, value) {
280
+ switch (channel) {
281
+ case "translate": return `${round(value("x"), 3)}px ${round(value("y"), 3)}px`;
282
+ case "rotate": return `${round(value("rotate"), 4)}deg`;
283
+ case "scale": return `${round(value("scaleX"), 5)} ${round(value("scaleY"), 5)}`;
284
+ case "opacity": return `${round(Math.min(1, Math.max(0, value("opacity"))), 4)}`;
285
+ }
286
+ }
287
+ /**
288
+ * Whether a computed value shows `expected` (`format`'s text). An unset or
289
+ * `none` value is the channel's identity. One value of a two-value channel
290
+ * stands for both (scale), or for x with y at 0 (translate).
291
+ */
292
+ function sameShown(channel, shown, expected) {
293
+ const numbers = (text) => {
294
+ const list = ((text === "" || text === "none" ? IDENTITY_TEXT[channel] : text).match(/-?\d*\.?\d+(?:e-?\d+)?/g) ?? []).map(Number);
295
+ if (channel === "translate") return [list[0] ?? 0, list[1] ?? 0];
296
+ if (channel === "scale") return [list[0] ?? 1, list[1] ?? list[0] ?? 1];
297
+ return list.length > 0 ? list : [channel === "opacity" ? 1 : 0];
298
+ };
299
+ const a = numbers(shown);
300
+ const b = numbers(expected);
301
+ return a.length === b.length && a.every((value, i) => Math.abs(value - b[i]) < .001);
302
+ }
303
+ /**
304
+ * The inline text for a channel: `format`, except that an identity transform
305
+ * is written `none`. Any other value, `translate: 0px 0px` included, makes
306
+ * the element the containing block of its `position: fixed` descendants and
307
+ * a stacking context, so a motion back to identity would leave a fixed child
308
+ * moved with its parent; Mobile Safari also lets no finger scroll a list
309
+ * inside an element left at `scale: 1`. At rest the identity leaves the
310
+ * element entirely when its stylesheet agrees (`releaseIdentity`).
311
+ */
312
+ function inlineText(channel, value) {
313
+ const at = (property, identity, digits) => round(value(property), digits) === identity;
314
+ switch (channel) {
315
+ case "translate": return at("x", 0, 3) && at("y", 0, 3) ? "none" : format(channel, value);
316
+ case "rotate": return at("rotate", 0, 4) ? "none" : format(channel, value);
317
+ case "scale": return at("scaleX", 1, 5) && at("scaleY", 1, 5) ? "none" : format(channel, value);
318
+ case "opacity": return format(channel, value);
319
+ }
320
+ }
321
+ /** Whether a computed value (or an unset one) is the channel's identity. */
322
+ function isIdentityText(channel, text) {
323
+ const value = text.trim();
324
+ if (value === "" || value === "none") return true;
325
+ const numbers = value.split(/\s+/).map((part) => Number.parseFloat(part));
326
+ if (numbers.some((number) => !Number.isFinite(number))) return false;
327
+ const identity = channel === "scale" || channel === "opacity" ? 1 : 0;
328
+ return numbers.every((number) => Math.abs(number - identity) < 1e-6);
329
+ }
330
+ function expand(values) {
331
+ const out = {};
332
+ for (const [key, value] of Object.entries(values)) {
333
+ if (value == null || !Number.isFinite(value)) continue;
334
+ if (key === "scale") {
335
+ out.scaleX ??= value;
336
+ out.scaleY ??= value;
337
+ } else if (PROPERTIES.includes(key)) out[key] = value;
338
+ }
339
+ return out;
340
+ }
341
+ /** The time the motion clock reads (`performance.now()`'s time base). */
342
+ function motionNow() {
343
+ return typeof performance === "undefined" ? Date.now() : performance.now();
344
+ }
345
+ /**
346
+ * Whether the user asked for reduced motion (`prefers-reduced-motion:
347
+ * reduce`), read at the moment of the call: the preference the animator uses
348
+ * by default for its Reduce Motion substitution. A component never reads it
349
+ * to pick a curve of its own: its motion settings do not override the
350
+ * policy (design:reduced-motion DR4); `animator.reducedMotion()` or
351
+ * `reducedMotionFade()` gives the policy's answer. False without a window
352
+ * (server rendering).
353
+ */
354
+ function defaultPrefersReducedMotion() {
355
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
356
+ }
357
+ /** Whether the primary pointer is coarse: `(pointer: coarse)`. */
358
+ function defaultIsCoarsePointer() {
359
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(pointer: coarse)").matches;
360
+ }
361
+ /**
362
+ * Registers `name` as an inherited `<length>` (initially 0px) or `<number>`
363
+ * (initially 0) so keyframes interpolate it; an unregistered custom property
364
+ * animates in steps. A property the page already registered is left as it
365
+ * is.
366
+ */
367
+ function registerCustomProperty(name, syntax) {
368
+ if (typeof CSS === "undefined" || typeof CSS.registerProperty !== "function") return;
369
+ try {
370
+ CSS.registerProperty({
371
+ name,
372
+ syntax,
373
+ inherits: true,
374
+ initialValue: syntax === "<length>" ? "0px" : "0"
375
+ });
376
+ } catch (error) {
377
+ if (!(error instanceof DOMException) || error.name !== "InvalidModificationError") throw error;
378
+ }
379
+ }
380
+ function expandList(properties) {
381
+ const out = /* @__PURE__ */ new Set();
382
+ for (const property of properties) if (property === "scale") {
383
+ out.add("scaleX");
384
+ out.add("scaleY");
385
+ } else out.add(property);
386
+ return [...out];
387
+ }
388
+ //#endregion
389
+ //#region src/motion/engine/taskClock.ts
390
+ /** The task the current calls from rest are made in, until it ends. */
391
+ let openTask = null;
392
+ /** How many of the animators' animation-frame callbacks are running now. */
393
+ const frameNesting = { depth: 0 };
394
+ /** The mark of the running task, opened by its first call from rest. */
395
+ function markTask(time, clock) {
396
+ if (openTask == null) {
397
+ const task = { first: time };
398
+ openTask = task;
399
+ queueMicrotask(() => {
400
+ task.ended = clock();
401
+ openTask = null;
402
+ });
403
+ }
404
+ return openTask;
405
+ }
406
+ /** The first read of the time an animation frame runs, by its timestamp. */
407
+ let frameRead = null;
408
+ /** The first motion call on a clock since the last microtask checkpoint. */
409
+ let openCall = null;
410
+ /**
411
+ * The time of a motion call with no explicit clock. It is the time of the
412
+ * first such call on the same clock since the last microtask checkpoint. One
413
+ * event listener or frame callback thus shares one clock. So calls on
414
+ * several animators in one callback, such as a pager's children, line up, as
415
+ * calls from rest share one start. A call more than LATE_START_MS after the
416
+ * first opens a new clock: the curves that a block passed restart at their
417
+ * frame instead.
418
+ */
419
+ function callTime(clock) {
420
+ const time = clock();
421
+ if (openCall != null && openCall.clock === clock && time - openCall.time <= 34) return openCall.time;
422
+ const call = {
423
+ time,
424
+ clock
425
+ };
426
+ openCall = call;
427
+ queueMicrotask(() => {
428
+ if (openCall === call) openCall = null;
429
+ });
430
+ return time;
431
+ }
432
+ /**
433
+ * Promotions that wait for their stylesheet's will-change, from every
434
+ * animator, until the running callback's microtasks run.
435
+ */
436
+ const sheetReads = [];
437
+ /**
438
+ * Queues an element's stylesheet read for a microtask after the callback.
439
+ * That microtask lifts every queued promotion, reads every stylesheet, and
440
+ * then writes every promotion back. So motions that one callback starts force
441
+ * one style pass, not one per element.
442
+ */
443
+ function queueSheetRead(read) {
444
+ if (sheetReads.length === 0) queueMicrotask(flushSheetReads);
445
+ sheetReads.push(read);
446
+ }
447
+ function flushSheetReads() {
448
+ const reads = sheetReads.splice(0);
449
+ for (const read of reads) read.lift();
450
+ for (const read of reads) read.read();
451
+ for (const read of reads) read.write();
452
+ }
453
+ /**
454
+ * Per animator, the first of its calls that still wait for the frame that
455
+ * commits them. An animator removes its entry once nothing of its waits: a
456
+ * rebuild or a hidden page committed its calls, or it was disposed or moved.
457
+ * The frame's first read takes every entry.
458
+ */
459
+ const waitingCalls = /* @__PURE__ */ new Map();
460
+ /** The first waiting call, read once by the frame with this timestamp. */
461
+ let waitingRead = null;
462
+ /**
463
+ * The first call that the animation frame with timestamp `frame` commits.
464
+ * The frame reads it once, so every animator in it judges a late commit from
465
+ * the same call. `own` is the first of the reading animator's calls.
466
+ */
467
+ function firstCommitted(frame, own) {
468
+ if (frame != null && waitingRead?.frame === frame) return Math.min(waitingRead.first, own);
469
+ const first = Math.min(own, ...waitingCalls.values());
470
+ waitingCalls.clear();
471
+ if (frame != null) {
472
+ const read = {
473
+ frame,
474
+ first
475
+ };
476
+ waitingRead = read;
477
+ setTimeout(() => {
478
+ if (waitingRead === read) waitingRead = null;
479
+ }, 0);
480
+ }
481
+ return first;
482
+ }
483
+ /**
484
+ * The time the animation frame with timestamp `frame` runs, read once in
485
+ * that frame. Every animator's callback in the frame takes that read, so the
486
+ * calls from rest that one frame commits start together. A long callback
487
+ * before them does not move their start. A call on a moving element keeps
488
+ * its own clock. The read ends with the frame's task, so a frame
489
+ * source that repeats a timestamp still reads each frame anew. A frame
490
+ * source with no timestamp reads the clock.
491
+ */
492
+ function frameTime(frame, clock) {
493
+ if (frame == null) return clock();
494
+ if (frameRead?.frame === frame) return frameRead.time;
495
+ const read = {
496
+ frame,
497
+ time: clock()
498
+ };
499
+ frameRead = read;
500
+ setTimeout(() => {
501
+ if (frameRead === read) frameRead = null;
502
+ }, 0);
503
+ return read.time;
504
+ }
505
+ let taskBakes = null;
506
+ function bakesOfTask() {
507
+ if (taskBakes == null) {
508
+ const bakes = {
509
+ times: [],
510
+ keyframes: []
511
+ };
512
+ taskBakes = bakes;
513
+ queueMicrotask(() => {
514
+ if (taskBakes === bakes) taskBakes = null;
515
+ });
516
+ }
517
+ return taskBakes;
518
+ }
519
+ function isSameKey(a, b) {
520
+ return a.length === b.length && a.every((value, i) => Object.is(value, b[i]));
521
+ }
522
+ /** Whether the engine can copy an effect with its parsed keyframes. */
523
+ function isCopyable(effect) {
524
+ return typeof KeyframeEffect === "function" && typeof Animation === "function" && effect instanceof KeyframeEffect;
525
+ }
526
+ /**
527
+ * Plays a copy of `effect` on `element`, as `element.animate` would play the
528
+ * same keyframes and timing, without parsing them again.
529
+ */
530
+ function copyAnimation(effect, element) {
531
+ const copy = new KeyframeEffect(effect);
532
+ copy.target = element;
533
+ const animation = new Animation(copy, element.ownerDocument.timeline);
534
+ animation.play();
535
+ return quietFinished(animation);
536
+ }
537
+ //#endregion
538
+ //#region src/motion/engine/animate.ts
539
+ function installAnimate(engine) {
540
+ const { animator, isCoarsePointer, lastSpring, now, resting, segments } = engine;
541
+ animator.animate = (to, transition, animateOptions = {}) => {
542
+ engine.syncPending();
543
+ if (animateOptions.start !== "presented") engine.flushDeferred();
544
+ const time = animateOptions.at ?? callTime(now);
545
+ const targets = expand(to);
546
+ const velocities = expand(transition.velocity ?? {});
547
+ const { owner, finished } = engine.newOwner();
548
+ lastSpring.set(owner, transition.spring);
549
+ const properties = Object.keys(targets);
550
+ const next = {};
551
+ let plan = null;
552
+ if (engine.prefersReducedMotion()) {
553
+ plan = engine.reducedMotion(owner, time, targets, properties, isCoarsePointer() || animateOptions.touchRelease === true, animateOptions.crossfadeAs);
554
+ Object.assign(next, plan.next);
555
+ } else for (const property of properties) {
556
+ const running = animateOptions.additive === true && velocities[property] == null ? engine.segmentAt(property, time) : null;
557
+ if (running != null && !engine.isHeld(running)) {
558
+ next[property] = engine.additiveSegment(owner, property, time, targets[property], transition.spring, running);
559
+ continue;
560
+ }
561
+ const handed = velocities[property];
562
+ const current = engine.velocityAt(property, time);
563
+ const segment = engine.springSegment(owner, property, time, targets[property], transition.spring, handed ?? current);
564
+ const isHanded = handed != null && Math.abs(handed - current) > SAMPLE_TOLERANCE[property] * 60;
565
+ next[property] = segment != null && isHanded ? {
566
+ ...segment,
567
+ handedVelocity: handed
568
+ } : segment;
569
+ }
570
+ const group = engine.beginGroup(time, Object.keys(next), animateOptions.at, animateOptions.start);
571
+ if (group != null && animateOptions.at == null && animateOptions.start === "next-frame") group.nextFrame = true;
572
+ const waitsForFrame = engine.noteShown(Object.keys(next), time, group, animateOptions.at);
573
+ const adopted = plan?.landing != null ? engine.adoptLandings(plan.landing, Object.keys(next)) : null;
574
+ const changed = [];
575
+ for (const [property, segment] of Object.entries(next)) {
576
+ engine.interrupt(property, time);
577
+ changed.push(property);
578
+ if (segment == null) {
579
+ const value = plan?.holds[property] ?? targets[property] ?? engine.valueAt(property, time);
580
+ segments.delete(property);
581
+ resting[property] = value;
582
+ } else segments.set(property, segment);
583
+ }
584
+ engine.commitCall(group, owner, changed, time, animateOptions.start === "presented" && animateOptions.at == null, waitsForFrame);
585
+ if (plan?.borrowed != null) engine.borrowedOpacity = plan.borrowed;
586
+ if (plan?.joins === true) engine.joinWaitingDip(owner);
587
+ const handle = plan?.joins === true ? engine.makeHandle(owner, ["opacity"], finished, time, group, true) : engine.makeHandle(owner, changed, finished, time, group);
588
+ if (plan?.landing != null) engine.scheduleLanding(owner, handle.started, plan.landing, adopted);
589
+ return handle;
590
+ };
591
+ }
592
+ //#endregion
593
+ //#region src/motion/engine/attach.ts
594
+ function installAttach(engine) {
595
+ const { animator, heldForFrame, isCoarsePointer, landings, now, pseudoElement, restWaits, resting, retireFrames, retireLooks, retireTimers, running, segments } = engine;
596
+ animator.reducedMotion = (reducedOptions = {}) => {
597
+ if (!engine.prefersReducedMotion()) return "off";
598
+ return isCoarsePointer() || reducedOptions.touchRelease === true ? "crossfade" : "instant";
599
+ };
600
+ animator.attach = (next) => {
601
+ if (next === engine.target) return;
602
+ engine.flushDeferred();
603
+ engine.present(false);
604
+ engine.forgetShown();
605
+ heldForFrame.clear();
606
+ if (next == null) {
607
+ engine.lastDetached = engine.target;
608
+ if (!engine.unmountQueued) {
609
+ engine.unmountQueued = true;
610
+ queueMicrotask(() => {
611
+ if (!engine.unmountQueued) return;
612
+ engine.unmountQueued = false;
613
+ engine.onLastDetached(() => {
614
+ engine.landPending(false);
615
+ for (const animation of running.values()) animation.cancel();
616
+ running.clear();
617
+ for (const timer of retireTimers.values()) clearTimeout(timer);
618
+ retireTimers.clear();
619
+ for (const timer of retireLooks.values()) clearTimeout(timer);
620
+ retireLooks.clear();
621
+ retireFrames.clear();
622
+ engine.demote();
623
+ engine.cancelSheetWillChangeRead();
624
+ });
625
+ engine.lastDetached = null;
626
+ const time = now();
627
+ for (const property of PROPERTIES) engine.interrupt(property, time);
628
+ for (const wait of [...restWaits]) wait.settle();
629
+ });
630
+ }
631
+ } else {
632
+ engine.unmountQueued = false;
633
+ engine.lastDetached = null;
634
+ }
635
+ engine.demote();
636
+ const isOpacityBorrowed = engine.borrowedOpacity != null || [...landings].some((landing) => landing.restoreIsBorrowed === true);
637
+ const pseudoHeld = pseudoElement == null || engine.target == null ? null : new Set(Object.keys(CHANNELS).filter((channel) => running.has(channel) && !(channel === "opacity" && isOpacityBorrowed) && CHANNELS[channel].every((p) => !segments.has(p) && resting[p] === IDENTITY[p])));
638
+ for (const animation of running.values()) animation.cancel();
639
+ running.clear();
640
+ for (const timer of retireTimers.values()) clearTimeout(timer);
641
+ retireTimers.clear();
642
+ for (const timer of retireLooks.values()) clearTimeout(timer);
643
+ retireLooks.clear();
644
+ retireFrames.clear();
645
+ if (isOpacityBorrowed) engine.releaseOwnOpacity();
646
+ if (engine.target != null) {
647
+ const outgoing = engine.target;
648
+ engine.heldIdentity = pseudoHeld ?? new Set(Object.keys(CHANNELS).filter((channel) => outgoing.style.getPropertyValue(engine.cssName(channel)) === engine.identityOf(channel)));
649
+ }
650
+ const held = engine.heldIdentity;
651
+ engine.target = next;
652
+ engine.cancelSheetWillChangeRead();
653
+ engine.sheetWillChangeRead = false;
654
+ if (engine.target == null) return;
655
+ engine.heldIdentity = /* @__PURE__ */ new Set();
656
+ const time = now();
657
+ const dip = segments.get("opacity");
658
+ if (engine.borrowedOpacity != null && (dip == null || time >= dip.start + dip.duration)) {
659
+ engine.borrowedOpacity = null;
660
+ segments.delete("opacity");
661
+ resting.opacity = IDENTITY.opacity;
662
+ }
663
+ for (const channel of Object.keys(CHANNELS)) if (!CHANNELS[channel].every((p) => !segments.has(p) && resting[p] === IDENTITY[p])) engine.rebuild(channel, time);
664
+ else if (held.has(channel)) {
665
+ if (pseudoElement != null) engine.hold(channel, time);
666
+ else engine.writeInline(channel, (property) => resting[property]);
667
+ }
668
+ engine.flushReleases();
669
+ engine.readSheetWillChangeLater();
670
+ };
671
+ }
672
+ //#endregion
673
+ //#region src/motion/engine/channelText.ts
674
+ function installChannelText(engine) {
675
+ const { companion, customProperty, customUnit } = engine;
676
+ engine.companionText = (x) => companion == null ? "" : companion.syntax === "<number>" ? `${round(companion.map(x), 5)}` : `${round(companion.map(x), 3)}px`;
677
+ engine.isCustom = (channel) => customProperty != null && channel === "translate";
678
+ engine.cssName = (channel) => customProperty != null && channel === "translate" ? customProperty.name : channel;
679
+ engine.textOf = (channel, value) => engine.isCustom(channel) ? `${round(value("x"), customUnit === "" ? 5 : 3)}${customUnit}` : format(channel, value);
680
+ /** A keyframe's properties for a channel: the companion rides x's. */
681
+ engine.frameOf = (channel, value) => engine.isCustom(channel) && companion != null ? {
682
+ [engine.cssName(channel)]: engine.textOf(channel, value),
683
+ [companion.name]: engine.companionText(value("x"))
684
+ } : { [engine.cssName(channel)]: engine.textOf(channel, value) };
685
+ engine.identityOf = (channel) => engine.isCustom(channel) ? `0${customUnit}` : IDENTITY_TEXT[channel];
686
+ engine.prefersReducedMotion = () => defaultPrefersReducedMotion() || themeReducesMotion(engine.target);
687
+ /** Runs `write` with the pending unmount's node as the target. */
688
+ engine.onLastDetached = (write) => {
689
+ const current = engine.target;
690
+ engine.target = engine.target ?? engine.lastDetached;
691
+ try {
692
+ write();
693
+ } finally {
694
+ engine.target = current;
695
+ }
696
+ };
697
+ }
698
+ //#endregion
699
+ //#region src/motion/engine/curveReads.ts
700
+ function installCurveReads(engine) {
701
+ const { companion, now, presentedSource, pseudoElement, resting, segments, touched } = engine;
702
+ engine.segmentAt = (property, time) => {
703
+ const segment = segments.get(property);
704
+ if (segment == null) return null;
705
+ if (time >= engine.endOf(property, segment)) return null;
706
+ return segment;
707
+ };
708
+ /**
709
+ * A curve whose call the browser has not started yet: still at its start
710
+ * on screen (valueAt), already moving in the model (velocityAt).
711
+ */
712
+ engine.isHeld = (segment) => segment.group != null && !segment.group.resolved;
713
+ /** The curve itself at `time`: what the keyframes play. */
714
+ engine.curveAt = (property, time) => {
715
+ const segment = segments.get(property);
716
+ if (segment == null) return resting[property];
717
+ if (time >= segment.start + segment.duration) return segment.target;
718
+ return segment.at(Math.max(0, time - segment.start));
719
+ };
720
+ /**
721
+ * A held curve's start once a frame dated its call, as the browser's start
722
+ * moves it: by that frame's lead over the call's own time.
723
+ */
724
+ engine.datedFromLatest = (segment, latest) => latest == null || segment.group == null ? null : {
725
+ latest,
726
+ start: segment.start + latest - segment.group.provisional
727
+ };
728
+ /**
729
+ * When a waiting curve's call had its first frame, which put the curve on
730
+ * screen. Undefined for a curve that does not wait, or whose call has had
731
+ * no first frame.
732
+ */
733
+ engine.shownSince = (property, segment) => segment.group?.resolved === false ? segment.group.latest?.get(CHANNEL_OF[property]) : void 0;
734
+ /** A curve's end, dated from its call's first frame while it waits. */
735
+ engine.endOf = (property, segment) => (engine.datedFromLatest(segment, engine.shownSince(property, segment))?.start ?? segment.start) + segment.duration;
736
+ /**
737
+ * Takes a curve on screen out of the call that still waits for the
738
+ * browser's start. The curve keeps its course, dated from the call's first
739
+ * frame. A call that has no channel left starts at that frame.
740
+ */
741
+ engine.leaveWaitingCall = (segment, channel, latest) => {
742
+ const group = segment.group;
743
+ if (group == null) return;
744
+ const index = group.segments.indexOf(segment);
745
+ if (index >= 0) group.segments.splice(index, 1);
746
+ segment.start += latest - group.provisional;
747
+ segment.group = void 0;
748
+ if (!CHANNELS[channel].some((p) => segments.get(p)?.group === group)) {
749
+ group.latest?.delete(channel);
750
+ group.channels.delete(channel);
751
+ }
752
+ if (group.channels.size === 0 && group.segments.length === 0) engine.resolveGroup(group, latest);
753
+ };
754
+ /**
755
+ * The value on screen at `time`. Until the browser reports its start, a
756
+ * held curve shows its first value. A frame that ran without that start
757
+ * dates the curve. Without that frame, a later time reads from the
758
+ * provisional start, so a companion that samples ahead follows the curve's
759
+ * shape.
760
+ */
761
+ engine.valueAt = (property, time) => {
762
+ const segment = segments.get(property);
763
+ if (segment != null && engine.isHeld(segment)) {
764
+ const latest = segment.group?.latest?.get(CHANNEL_OF[property]);
765
+ const dated = engine.datedFromLatest(segment, latest);
766
+ if (dated != null) {
767
+ const elapsed = Math.max(time, dated.latest) - dated.start;
768
+ return elapsed >= segment.duration ? segment.target : segment.at(elapsed);
769
+ }
770
+ if (time <= now()) return segment.at(0);
771
+ }
772
+ return engine.curveAt(property, time);
773
+ };
774
+ /**
775
+ * Whether a curve's tail already shows as at rest at `time`. Under a
776
+ * starved main thread the browser commits a call late. A call that starts
777
+ * at its own time then skips that far into its curve. One that starts at
778
+ * the commit holds an element that hardly moves.
779
+ */
780
+ engine.showsAtRest = (property, segment, time) => Math.abs(engine.valueAt(property, time) - segment.target) <= 2 * SAMPLE_TOLERANCE[property] && Math.abs(engine.velocityAt(property, time)) <= SAMPLE_TOLERANCE[property] * 60;
781
+ engine.velocityAt = (property, time) => {
782
+ const held = segments.get(property);
783
+ if (held != null && engine.isHeld(held)) {
784
+ const dated = engine.datedFromLatest(held, held.group?.latest?.get(CHANNEL_OF[property]));
785
+ return held.speed(Math.max(0, dated != null && time > dated.latest ? time - dated.start : time - held.start));
786
+ }
787
+ const segment = engine.segmentAt(property, time);
788
+ if (segment == null || time < segment.start) return 0;
789
+ return segment.speed(time - segment.start);
790
+ };
791
+ engine.valueBefore = (property, time) => engine.curveAt(property, time - 1e-6);
792
+ engine.finalValue = (property) => segments.get(property)?.target ?? resting[property];
793
+ /**
794
+ * Where translate is drawn relative to where the translate animation
795
+ * started, read live when a touch lands. iOS WebKit keeps the transform it
796
+ * resolved when the animation went to the compositor (iOS 26.2: the
797
+ * element's rect and its hit tests stay at the start for the whole curve,
798
+ * while the computed style is live), until the animation is retired. A
799
+ * segment whose start still waits for the browser's commit has painted
800
+ * nothing of its curve yet.
801
+ */
802
+ engine.drawnTranslate = (property, time) => {
803
+ const segment = segments.get(property);
804
+ return segment?.group != null && !segment.group.resolved ? segment.at(0) : engine.valueAt(property, time);
805
+ };
806
+ /** Reports the element while its translate moves (not a pseudo-element's). */
807
+ engine.present = (isMoving) => {
808
+ const element = isMoving && pseudoElement == null ? engine.target : null;
809
+ if (element === engine.presented) return;
810
+ engine.unpresent?.();
811
+ engine.unpresent = null;
812
+ if (engine.presented instanceof HTMLElement) clearPresentedResolve(engine.presented);
813
+ engine.presented = element;
814
+ if (element != null) engine.unpresent = registerPresentedOffset(element, presentedSource);
815
+ };
816
+ engine.writeInline = (channel, value, release = true) => {
817
+ if (engine.target == null || pseudoElement != null) return;
818
+ touched.add(channel);
819
+ const text = engine.isCustom(channel) ? engine.textOf(channel, value) : inlineText(channel, value);
820
+ if (engine.target.style.getPropertyValue(engine.cssName(channel)) !== text) engine.target.style.setProperty(engine.cssName(channel), text);
821
+ if (engine.isCustom(channel) && companion != null) {
822
+ const companionValue = engine.companionText(value("x"));
823
+ if (engine.target.style.getPropertyValue(companion.name) !== companionValue) engine.target.style.setProperty(companion.name, companionValue);
824
+ }
825
+ if (release && text === engine.identityOf(channel)) engine.releaseIdentity(channel);
826
+ };
827
+ }
828
+ //#endregion
829
+ //#region src/motion/engine/decayStop.ts
830
+ function installDecayStop(engine) {
831
+ const { animator, landings, now, resting, segments, shown } = engine;
832
+ animator.decay = (curves, decayOptions = {}) => {
833
+ engine.syncPending();
834
+ engine.flushDeferred();
835
+ const time = decayOptions.at ?? callTime(now);
836
+ const reduce = engine.prefersReducedMotion();
837
+ const transitions = {};
838
+ for (const property of DECAY_PROPERTIES) {
839
+ const curve = curves[property];
840
+ if (reduce && curve?.isTransition === true) transitions[property] = curve.at(curve.duration);
841
+ }
842
+ const transitioned = Object.keys(transitions).length > 0 ? animator.animate(transitions, REDUCED_TRANSITION, {
843
+ at: time,
844
+ touchRelease: decayOptions.touchRelease
845
+ }) : null;
846
+ const { owner, finished } = engine.newOwner();
847
+ const properties = DECAY_PROPERTIES.filter((property) => curves[property] != null && transitions[property] === void 0);
848
+ if (transitioned != null && properties.length === 0) return transitioned;
849
+ const group = engine.beginGroup(time, properties, decayOptions.at);
850
+ const waitsForFrame = engine.noteShown(properties, time, group, decayOptions.at);
851
+ for (const property of properties) {
852
+ const curve = curves[property];
853
+ engine.interrupt(property, time);
854
+ if (!(curve.duration > 0)) {
855
+ segments.delete(property);
856
+ resting[property] = curve.at(0);
857
+ continue;
858
+ }
859
+ segments.set(property, {
860
+ start: time,
861
+ duration: Math.min(MAX_DURATION_MS, curve.duration * 1e3),
862
+ target: curve.at(curve.duration),
863
+ at: (t) => curve.at(t / 1e3),
864
+ speed: (t) => curve.velocity(t / 1e3),
865
+ jumps: [],
866
+ owner
867
+ });
868
+ }
869
+ engine.commitCall(group, owner, properties, time, false, waitsForFrame);
870
+ const handle = engine.makeHandle(owner, properties, finished, time, group);
871
+ if (transitioned == null) return handle;
872
+ const faded = transitioned;
873
+ const owns = (property) => faded.properties.includes(property);
874
+ return {
875
+ ...handle,
876
+ properties: [...handle.properties, ...faded.properties],
877
+ started: Promise.all([handle.started, faded.started]).then(([coasting]) => coasting),
878
+ finished: Promise.all([handle.finished, faded.finished]).then(([coasted, done]) => coasted && done),
879
+ value: (property, at) => owns(property) ? faded.value(property, at) : handle.value(property, at),
880
+ velocity: (property, at) => owns(property) ? faded.velocity(property, at) : handle.velocity(property, at),
881
+ stop: () => {
882
+ handle.stop();
883
+ faded.stop();
884
+ }
885
+ };
886
+ };
887
+ animator.stop = (properties) => {
888
+ engine.syncPending();
889
+ engine.flushDeferred();
890
+ const time = now();
891
+ const list = properties == null ? PROPERTIES : expandList(properties);
892
+ const changed = [];
893
+ const wasBorrowed = engine.borrowedOpacity != null || [...landings].some((landing) => landing.restoreIsBorrowed === true);
894
+ const heading = engine.opacityHeading();
895
+ for (const property of list) {
896
+ engine.cancelLanding(property);
897
+ const segment = segments.get(property);
898
+ if (segment == null) continue;
899
+ const noted = shown.get(property);
900
+ shown.delete(property);
901
+ const value = !segment.isFade ? noted != null && time - noted.since > 34 ? engine.shownAt(noted, time).value : engine.valueAt(property, time) : wasBorrowed ? IDENTITY.opacity : heading;
902
+ engine.interrupt(property, time);
903
+ segments.delete(property);
904
+ resting[property] = value;
905
+ changed.push(property);
906
+ }
907
+ engine.commit(changed, time);
908
+ if (wasBorrowed && changed.includes("opacity")) engine.releaseOwnOpacity();
909
+ };
910
+ }
911
+ //#endregion
912
+ //#region src/motion/engine/groupSync.ts
913
+ function installGroupSync(engine) {
914
+ const { now, pendingGroups, requestFrame, resting, running, segments } = engine;
915
+ /**
916
+ * A call whose first animation was cancelled before its first frame: if a
917
+ * later call in the same task took over its curves, it starts with that
918
+ * call; otherwise it never started.
919
+ */
920
+ engine.settleCancelled = (group) => {
921
+ if (group.resolved) return;
922
+ let adopter = group.adoptedBy;
923
+ while (adopter?.adoptedBy != null) adopter = adopter.adoptedBy;
924
+ if (adopter != null && adopter !== group) {
925
+ adopter.started.then((start) => engine.resolveGroup(group, start));
926
+ return;
927
+ }
928
+ if (engine.awaitStart(group)) return;
929
+ engine.resolveGroup(group, group.provisional);
930
+ };
931
+ /**
932
+ * Waits for the browser's start of a call through one of its animations
933
+ * still playing; false when none is left to wait on.
934
+ */
935
+ engine.awaitStart = (group) => {
936
+ const ready = group.animations.find((animation) => animation.playState !== "idle")?.ready;
937
+ if (ready == null || typeof ready.then !== "function") return false;
938
+ ready.then(() => engine.syncGroup(group), () => engine.settleCancelled(group));
939
+ return true;
940
+ };
941
+ engine.syncGroup = (group) => {
942
+ if (group.resolved) return;
943
+ for (const animation of group.animations) if (animation.startTime != null) {
944
+ engine.resolveGroup(group, engine.startAfterBlock(group, Number(animation.startTime)));
945
+ return;
946
+ }
947
+ if (group.animations.length > 0 && group.animations.every((animation) => animation.playState === "finished" || animation.playState === "idle") && group.animations.some((animation) => animation.playState === "finished")) {
948
+ engine.resolveGroup(group, group.provisional);
949
+ return;
950
+ }
951
+ if (group.animations.some((animation) => animation.startTime == null && animation.playState !== "idle")) requestFrame?.(() => engine.syncGroup(group));
952
+ };
953
+ /**
954
+ * Reads the start of every call whose first frame may have been committed:
955
+ * not those created in the running task, whose start the browser cannot
956
+ * have set (reading it there can cost a style update per call).
957
+ */
958
+ engine.syncPending = () => {
959
+ for (const group of pendingGroups) if (!group.fresh) engine.syncGroup(group);
960
+ engine.syncFinished();
961
+ };
962
+ /**
963
+ * An animation finished from outside (a test utility's or devtools'
964
+ * `finish()`) shows its end state while the model still reads its curve:
965
+ * the curve ends now in the model too, so the next call starts from what
966
+ * is on screen.
967
+ */
968
+ engine.syncFinished = () => {
969
+ for (const [channel, animation] of running) {
970
+ if (animation.playState !== "finished") continue;
971
+ const time = now();
972
+ for (const property of CHANNELS[channel]) {
973
+ const segment = segments.get(property);
974
+ if (segment == null || time >= segment.start + segment.duration) continue;
975
+ segments.delete(property);
976
+ resting[property] = segment.target;
977
+ }
978
+ }
979
+ };
980
+ /**
981
+ * The start of a call from rest, on the frame that commits it. Chromium,
982
+ * like Core Animation, starts a pending animation when it commits it, so a
983
+ * main-thread block later in the call's task delays the motion; WebKit
984
+ * dates it at its last frame time before that task, so the first frame
985
+ * after the block would show it skipped into its curve. When the task ran
986
+ * on more than LATE_START_MS past its first call, a start the browser put
987
+ * by the task's first animations (a presented call's second frame, not the
988
+ * call) and more than LATE_START_MS before the call's first read (its
989
+ * `ready`, once the task has ended, or the first frame after it) moves to
990
+ * that read, with every animation of the call, and every call of the task
991
+ * moves to the same read. A shorter task, or a read other tasks delay,
992
+ * keeps the browser's start.
993
+ */
994
+ engine.startAfterBlock = (group, start) => {
995
+ const timeline = typeof document === "undefined" ? null : document.timeline?.currentTime;
996
+ if (timeline == null || group.framed === true || start > (group.task?.first ?? group.provisional) + 34) return start;
997
+ const { task } = group;
998
+ const ended = task?.nextFrame === true ? now() : task?.ended ?? now();
999
+ if (task == null || ended - task.first <= 34) return start;
1000
+ const at = task.at ?? Math.max(now(), timeline);
1001
+ if (at - start <= 34) return start;
1002
+ task.at = at;
1003
+ for (const animation of group.animations) if (animation.playState !== "idle") animation.startTime = at;
1004
+ return at;
1005
+ };
1006
+ /** Moves a call from rest onto the time the browser started it. */
1007
+ engine.resolveGroup = (group, start) => {
1008
+ if (group.resolved) return;
1009
+ group.resolved = true;
1010
+ pendingGroups.delete(group);
1011
+ for (const animation of group.animations) if (animation.startTime == null && animation.playState !== "idle") animation.startTime = start;
1012
+ const delta = start - group.provisional;
1013
+ if (delta !== 0) {
1014
+ for (const segment of group.segments) segment.start += delta;
1015
+ for (const channel of group.channels) {
1016
+ const animation = running.get(channel);
1017
+ if (animation == null || !group.animations.includes(animation)) continue;
1018
+ const ends = CHANNELS[channel].flatMap((p) => {
1019
+ const segment = segments.get(p);
1020
+ return segment == null ? [] : [segment.start + segment.duration];
1021
+ });
1022
+ if (ends.length > 0) engine.scheduleRetire(channel, animation, Math.max(...ends));
1023
+ }
1024
+ for (const owner of new Set(group.segments.map((s) => s.owner))) {
1025
+ if (owner.settled || owner.timer == null) continue;
1026
+ clearTimeout(owner.timer);
1027
+ const ends = group.segments.filter((segment) => segment.owner === owner).map((segment) => segment.start + segment.duration);
1028
+ owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, Math.max(start, ...ends) - now()));
1029
+ }
1030
+ }
1031
+ group.resolve(start);
1032
+ };
1033
+ }
1034
+ //#endregion
1035
+ //#region src/motion/engine/handles.ts
1036
+ function installHandles(engine) {
1037
+ const { animator, carriedOwners, heldForFrame, landings, lastSpring, now, running, segments } = engine;
1038
+ engine.interrupt = (property, time) => {
1039
+ engine.cancelLanding(property);
1040
+ const segment = segments.get(property);
1041
+ if (segment == null) return;
1042
+ if (time < segment.start + segment.duration && !carriedOwners.has(segment.owner)) engine.settle(segment.owner, false);
1043
+ };
1044
+ engine.settle = (owner, finished) => {
1045
+ if (owner.settled) return;
1046
+ owner.settled = true;
1047
+ if (owner.timer != null) {
1048
+ clearTimeout(owner.timer);
1049
+ owner.timer = null;
1050
+ }
1051
+ owner.resolve(finished);
1052
+ };
1053
+ /**
1054
+ * A handle whose curves have reached their end on the wall clock finishes,
1055
+ * unless a sampler holds one of its animations (paused, or sought back):
1056
+ * then it waits on that animation's own time, as retiring does
1057
+ * (scheduleRetire), so `finished` never resolves under motion still on
1058
+ * screen.
1059
+ */
1060
+ engine.settleAtEnd = (owner) => {
1061
+ owner.timer = null;
1062
+ let wait = 0;
1063
+ for (const [channel, animation] of running) {
1064
+ if (!CHANNELS[channel].some((property) => segments.get(property)?.owner === owner)) continue;
1065
+ if (heldForFrame.has(channel)) {
1066
+ wait = Math.max(wait, END_RECHECK_MS);
1067
+ continue;
1068
+ }
1069
+ const remaining = engine.remainingCurve(animation);
1070
+ if (remaining != null && remaining > 0) wait = Math.max(wait, animation.playState === "paused" ? 100 : Math.max(remaining, END_RECHECK_MS));
1071
+ }
1072
+ if (wait > 0) {
1073
+ owner.timer = setTimeout(() => engine.settleAtEnd(owner), wait);
1074
+ return;
1075
+ }
1076
+ engine.settle(owner, true);
1077
+ };
1078
+ engine.makeHandle = (owner, properties, finished, time, group = null, settlesWithLanding = false) => {
1079
+ const ends = properties.map((p) => {
1080
+ const segment = segments.get(p);
1081
+ return segment != null && segment.owner === owner ? segment.start + segment.duration : time;
1082
+ });
1083
+ const end = Math.max(time, ...ends);
1084
+ if (settlesWithLanding) {} else if (properties.length === 0 || end <= time) engine.settle(owner, true);
1085
+ else owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, end - now()));
1086
+ const curves = /* @__PURE__ */ new Map();
1087
+ for (const property of properties) {
1088
+ const segment = segments.get(property);
1089
+ if (segment != null && segment.owner === owner) curves.set(property, segment);
1090
+ }
1091
+ return {
1092
+ properties,
1093
+ finished,
1094
+ started: group?.started ?? Promise.resolve(time),
1095
+ curve: (property) => {
1096
+ const segment = curves.get(property === "scale" ? "scaleX" : property);
1097
+ if (segment == null) return null;
1098
+ return {
1099
+ duration: segment.duration / 1e3,
1100
+ at: (t) => t * 1e3 >= segment.duration ? segment.target : segment.at(Math.max(0, t * 1e3)),
1101
+ velocity: (t) => t * 1e3 >= segment.duration ? 0 : segment.speed(t * 1e3)
1102
+ };
1103
+ },
1104
+ value: (property, at = now()) => {
1105
+ engine.syncPending();
1106
+ return engine.valueAt(property, at);
1107
+ },
1108
+ velocity: (property, at = now()) => {
1109
+ engine.syncPending();
1110
+ return engine.velocityAt(property, at);
1111
+ },
1112
+ retarget: (to, transition, retargetOptions) => {
1113
+ const spring = transition?.spring ?? lastSpring.get(owner);
1114
+ if (spring == null) throw new Error("animator: retarget needs a spring");
1115
+ return animator.animate(to, {
1116
+ ...transition,
1117
+ spring
1118
+ }, retargetOptions);
1119
+ },
1120
+ stop: () => animator.stop(PROPERTIES.filter((p) => properties.includes(p) && (segments.get(p)?.owner === owner || [...landings].some((landing) => landing.values.has(p) && (landing.owners.get(p) ?? landing.owner) === owner))))
1121
+ };
1122
+ };
1123
+ engine.newOwner = () => {
1124
+ let resolve = () => {};
1125
+ const finished = new Promise((r) => {
1126
+ resolve = r;
1127
+ });
1128
+ return {
1129
+ owner: {
1130
+ resolve,
1131
+ settled: false,
1132
+ timer: null
1133
+ },
1134
+ finished
1135
+ };
1136
+ };
1137
+ }
1138
+ //#endregion
1139
+ //#region src/motion/reducedMotionPlan.ts
1140
+ /** The properties that move an element rather than fade it. */
1141
+ const TRAVEL_PROPERTIES = [
1142
+ "x",
1143
+ "y",
1144
+ "rotate",
1145
+ "scaleX",
1146
+ "scaleY"
1147
+ ];
1148
+ /** The opacity no call has changed. */
1149
+ const IDENTITY_OPACITY = 1;
1150
+ /**
1151
+ * Plans one call under Reduce Motion: with `fade`, an opacity-only
1152
+ * cross-fade whose travel lands while the element is transparent; without,
1153
+ * everything at once. `role` gives a call that names no opacity its
1154
+ * direction (`crossfadeAs`).
1155
+ */
1156
+ function planReducedMotion(view, time, targets, properties, fade, role) {
1157
+ const holds = {};
1158
+ if (!fade) return {
1159
+ atOnce: [...properties],
1160
+ opacityFade: null,
1161
+ holds,
1162
+ landing: null
1163
+ };
1164
+ const atOnce = properties.filter((property) => TRAVEL_PROPERTIES.includes(property));
1165
+ const opacityNow = view.valueAt("opacity", time);
1166
+ const opacityTo = targets.opacity ?? view.opacityHeading();
1167
+ const travel = properties.filter((property) => TRAVEL_PROPERTIES.includes(property) && Math.abs(targets[property] - view.valueAt(property, time)) > 1e-9);
1168
+ const named = targets.opacity != null;
1169
+ let entering = named && opacityTo > opacityNow + 1e-6;
1170
+ let leaving = named && opacityTo < opacityNow - 1e-6;
1171
+ let fadeFrom = opacityNow;
1172
+ let fadeTo = opacityTo;
1173
+ let restore = null;
1174
+ const roleBorrow = role != null && !named && view.borrowedOpacity == null && !view.hasOpacityCurve && view.restingOpacity === IDENTITY_OPACITY && !view.writesOwnOpacity() ? view.ownOpacity() : null;
1175
+ if (!entering && !leaving && role === "entrance") {
1176
+ entering = true;
1177
+ fadeFrom = view.hasOpacityCurve ? opacityNow : 0;
1178
+ fadeTo = roleBorrow ?? opacityTo;
1179
+ } else if (!entering && !leaving && role === "exit") {
1180
+ leaving = true;
1181
+ fadeFrom = roleBorrow ?? opacityNow;
1182
+ fadeTo = 0;
1183
+ restore = roleBorrow ?? opacityTo;
1184
+ }
1185
+ const pending = view.hasPendingLanding;
1186
+ const ms = reducedMotionCrossFade.durationMs;
1187
+ const landsLater = (at, fadeIn) => {
1188
+ const values = /* @__PURE__ */ new Map();
1189
+ for (const property of travel) {
1190
+ holds[property] = view.valueAt(property, time);
1191
+ values.set(property, targets[property]);
1192
+ }
1193
+ return {
1194
+ at,
1195
+ values,
1196
+ fadeIn,
1197
+ restore,
1198
+ ...roleBorrow != null && restore != null ? { restoreIsBorrowed: true } : {}
1199
+ };
1200
+ };
1201
+ if (named && view.hasWaitingDip && !properties.some((property) => TRAVEL_PROPERTIES.includes(property)) && Math.abs(opacityTo - view.opacityHeading()) < 1e-6) return {
1202
+ atOnce: [],
1203
+ opacityFade: null,
1204
+ holds,
1205
+ landing: null,
1206
+ joins: true
1207
+ };
1208
+ const carries = travel.length > 0 || pending;
1209
+ if (entering && !pending && (!carries || fadeFrom <= 1e-6)) return {
1210
+ atOnce,
1211
+ opacityFade: [{
1212
+ at: 0,
1213
+ value: fadeFrom
1214
+ }, {
1215
+ at: ms,
1216
+ value: fadeTo
1217
+ }],
1218
+ holds,
1219
+ landing: null,
1220
+ borrowed: roleBorrow
1221
+ };
1222
+ if (leaving && (!carries || fadeTo <= 1e-6)) return {
1223
+ atOnce,
1224
+ opacityFade: [{
1225
+ at: 0,
1226
+ value: fadeFrom
1227
+ }, {
1228
+ at: ms,
1229
+ value: fadeTo
1230
+ }],
1231
+ holds,
1232
+ landing: travel.length > 0 || restore != null || pending ? landsLater(ms, null) : null
1233
+ };
1234
+ if (carries) {
1235
+ const priorBorrow = view.borrowedOpacity;
1236
+ const borrowed = named || priorBorrow == null && (view.hasOpacityCurve || view.restingOpacity !== IDENTITY_OPACITY || view.writesOwnOpacity()) ? null : priorBorrow ?? view.ownOpacity();
1237
+ if (borrowed != null && borrowed <= 1e-6) return {
1238
+ atOnce,
1239
+ opacityFade: null,
1240
+ holds,
1241
+ landing: null
1242
+ };
1243
+ return {
1244
+ atOnce,
1245
+ opacityFade: [{
1246
+ at: 0,
1247
+ value: view.hasOpacityCurve ? opacityNow : borrowed ?? opacityNow
1248
+ }, {
1249
+ at: ms / 2,
1250
+ value: 0
1251
+ }],
1252
+ holds,
1253
+ landing: landsLater(ms / 2, {
1254
+ to: borrowed ?? opacityTo,
1255
+ ms: ms / 2,
1256
+ isBorrowed: borrowed != null
1257
+ }),
1258
+ borrowed
1259
+ };
1260
+ }
1261
+ return {
1262
+ atOnce: "opacity" in targets ? [...atOnce, "opacity"] : atOnce,
1263
+ opacityFade: null,
1264
+ holds,
1265
+ landing: null
1266
+ };
1267
+ }
1268
+ //#endregion
1269
+ //#region src/motion/engine/landingRun.ts
1270
+ function installLandingRun(engine) {
1271
+ const { carriedOwners, landings, namedOpacity, now, resting, segments } = engine;
1272
+ /**
1273
+ * Writes the travel while the element is transparent: a plain style write,
1274
+ * never an animation (DR2: opacity only), so it is never shown in the wrong
1275
+ * place. In a dip the fade back in starts from here and takes what is left
1276
+ * of the cross-fade, so the dip ends when it was due even when a busy main
1277
+ * thread runs this timer late; past the whole fade back in (100 ms late or
1278
+ * more) the element appears at once where it landed, with no animation,
1279
+ * and the call settles then.
1280
+ */
1281
+ engine.land = (landing) => {
1282
+ landings.delete(landing);
1283
+ landing.timer = null;
1284
+ const time = now();
1285
+ const changed = [];
1286
+ for (const [property, value] of landing.values) {
1287
+ segments.delete(property);
1288
+ resting[property] = value;
1289
+ changed.push(property);
1290
+ }
1291
+ let end = time;
1292
+ const late = landing.due == null ? 0 : Math.max(0, time - landing.due);
1293
+ const appears = landing.fadeIn != null && late >= landing.fadeIn.ms;
1294
+ if (landing.fadeIn != null && !appears) {
1295
+ const ms = landing.fadeIn.ms - late;
1296
+ segments.set("opacity", engine.fadeSegment(landing.owner, time, [{
1297
+ at: 0,
1298
+ value: engine.valueAt("opacity", time)
1299
+ }, {
1300
+ at: ms,
1301
+ value: landing.fadeIn.to
1302
+ }]));
1303
+ changed.push("opacity");
1304
+ end = time + ms;
1305
+ } else if (landing.fadeIn != null) {
1306
+ segments.delete("opacity");
1307
+ resting.opacity = landing.fadeIn.isBorrowed === true ? IDENTITY.opacity : landing.fadeIn.to;
1308
+ changed.push("opacity");
1309
+ } else if (landing.restore != null) {
1310
+ segments.delete("opacity");
1311
+ resting.opacity = landing.restoreIsBorrowed === true ? IDENTITY.opacity : landing.restore;
1312
+ changed.push("opacity");
1313
+ }
1314
+ engine.commit(changed, time);
1315
+ if (landing.restoreIsBorrowed === true || appears && landing.fadeIn?.isBorrowed === true) engine.releaseOwnOpacity();
1316
+ else if (landing.fadeIn?.isBorrowed === true) engine.borrowedOpacity = landing.fadeIn.to;
1317
+ for (const carried of landing.carried) {
1318
+ carriedOwners.delete(carried);
1319
+ if (!carried.settled) engine.settle(carried, true);
1320
+ }
1321
+ const { owner } = landing;
1322
+ if (owner.settled) return;
1323
+ if (end <= time) engine.settle(owner, true);
1324
+ else owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, end - now()));
1325
+ };
1326
+ /**
1327
+ * A call that sets a value still waiting to land takes it over: the earlier
1328
+ * move never lands, and its call settles interrupted. Once nothing waiting
1329
+ * is left, a call that names its own opacity replaces an earlier fade back
1330
+ * in or restore too, so a caught dismissal fades straight back up instead
1331
+ * of dipping. Whatever still waits is carried by the new plan.
1332
+ */
1333
+ engine.takeOverLandings = (properties, namesOpacity) => {
1334
+ for (const property of properties) if (property !== "opacity") engine.cancelLanding(property);
1335
+ if (!namesOpacity) {
1336
+ for (const landing of [...landings]) if (landing.values.size === 0 && landing.fadeIn != null) {
1337
+ engine.endLanding(landing);
1338
+ engine.land(landing);
1339
+ }
1340
+ return;
1341
+ }
1342
+ for (const landing of [...landings]) {
1343
+ for (const owner of [landing.owner, ...landing.carried]) if (namedOpacity.has(owner) && !owner.settled) engine.settle(owner, false);
1344
+ if (landing.values.size > 0) continue;
1345
+ engine.endLanding(landing);
1346
+ if (landing.fadeIn?.isBorrowed === true || landing.restoreIsBorrowed === true) engine.borrowedOpacity = null;
1347
+ for (const owner of [landing.owner, ...landing.carried]) {
1348
+ carriedOwners.delete(owner);
1349
+ if (!owner.settled) engine.settle(owner, false);
1350
+ }
1351
+ }
1352
+ };
1353
+ /**
1354
+ * Reduced Motion (see the file header): the planner's plan
1355
+ * (reducedMotionPlan.ts) as this call's segments.
1356
+ */
1357
+ engine.reducedMotion = (owner, time, targets, properties, fade, role) => {
1358
+ const heading = engine.opacityHeading();
1359
+ engine.takeOverLandings(properties, targets.opacity != null || role != null);
1360
+ if (targets.opacity != null) namedOpacity.add(owner);
1361
+ engine.headingBeforeTakeOver = heading;
1362
+ let plan;
1363
+ try {
1364
+ plan = planReducedMotion(engine.planView, time, targets, properties, fade, role);
1365
+ } finally {
1366
+ engine.headingBeforeTakeOver = null;
1367
+ }
1368
+ const next = {};
1369
+ for (const property of plan.atOnce) next[property] = null;
1370
+ if (plan.opacityFade != null) next.opacity = engine.fadeSegment(owner, time, plan.opacityFade);
1371
+ return {
1372
+ next,
1373
+ holds: plan.holds,
1374
+ landing: plan.landing,
1375
+ borrowed: plan.borrowed,
1376
+ joins: plan.joins
1377
+ };
1378
+ };
1379
+ }
1380
+ //#endregion
1381
+ //#region src/motion/engine/landings.ts
1382
+ function installLandings(engine) {
1383
+ const { carriedOwners, landings, now, resting, running, segments } = engine;
1384
+ /**
1385
+ * A later write to `property` takes it from any landing. A write to opacity
1386
+ * decides what shows, so a landing still waiting writes its travel at once
1387
+ * rather than never, and its calls settle as interrupted.
1388
+ */
1389
+ engine.cancelLanding = (property) => {
1390
+ for (const landing of [...landings]) if (property === "opacity") {
1391
+ engine.endLanding(landing);
1392
+ engine.landNow(landing);
1393
+ } else if (landing.values.delete(property)) {
1394
+ const moved = landing.owners.get(property) ?? landing.owner;
1395
+ landing.owners.delete(property);
1396
+ if (!moved.settled) engine.settle(moved, false);
1397
+ }
1398
+ };
1399
+ engine.landNow = (landing) => {
1400
+ const changed = [];
1401
+ for (const [property, value] of landing.values) {
1402
+ segments.delete(property);
1403
+ resting[property] = value;
1404
+ changed.push(property);
1405
+ }
1406
+ if (changed.length > 0) engine.commit(changed, now());
1407
+ for (const owner of [landing.owner, ...landing.carried]) {
1408
+ carriedOwners.delete(owner);
1409
+ if (!owner.settled) engine.settle(owner, false);
1410
+ }
1411
+ };
1412
+ /**
1413
+ * A later Reduced Motion call that lands too carries the landings still
1414
+ * waiting: their travel lands with its own, which wins where both move a
1415
+ * property, and their calls settle when it lands. So two calls in one
1416
+ * frame (a drag cancel's position and scale) both land.
1417
+ */
1418
+ engine.adoptLandings = (plan, properties) => {
1419
+ const carried = [];
1420
+ const owners = /* @__PURE__ */ new Map();
1421
+ for (const landing of [...landings]) {
1422
+ for (const [property, value] of landing.values) {
1423
+ const moved = landing.owners.get(property) ?? landing.owner;
1424
+ if (!properties.includes(property) && !plan.values.has(property)) {
1425
+ plan.values.set(property, value);
1426
+ owners.set(property, moved);
1427
+ } else if (!moved.settled) engine.settle(moved, false);
1428
+ }
1429
+ carried.push(landing.owner, ...landing.carried);
1430
+ engine.endLanding(landing);
1431
+ }
1432
+ for (const owner of carried) carriedOwners.add(owner);
1433
+ return {
1434
+ carried,
1435
+ owners
1436
+ };
1437
+ };
1438
+ /**
1439
+ * A call joins the newest waiting dip: it takes the landing over and
1440
+ * settles when the dip ends, and the call it replaces lands with it. Each
1441
+ * value keeps the call whose move it is.
1442
+ */
1443
+ engine.joinWaitingDip = (owner) => {
1444
+ const dip = [...landings].reverse().find((landing) => landing.fadeIn != null);
1445
+ if (dip == null) {
1446
+ engine.settle(owner, true);
1447
+ return;
1448
+ }
1449
+ for (const property of dip.values.keys()) if (!dip.owners.has(property)) dip.owners.set(property, dip.owner);
1450
+ dip.carried.push(dip.owner);
1451
+ carriedOwners.add(dip.owner);
1452
+ dip.owner = owner;
1453
+ };
1454
+ /** Where opacity is heading: past a waiting landing's fade back in. */
1455
+ engine.opacityHeading = () => {
1456
+ let to = engine.finalValue("opacity");
1457
+ for (const landing of landings) if (landing.fadeIn != null) to = landing.fadeIn.to;
1458
+ else if (landing.restore != null) to = landing.restore;
1459
+ return to;
1460
+ };
1461
+ engine.endLanding = (landing) => {
1462
+ if (landing.timer != null) clearTimeout(landing.timer);
1463
+ landings.delete(landing);
1464
+ };
1465
+ /**
1466
+ * How long `landing` still waits for its fade, in ms. A sampler that pauses
1467
+ * the fade holds it, so it checks again later. A resumed fade holds it until
1468
+ * the fade starts again. A fade that runs past the landing's due time, as
1469
+ * after a pause, holds it for the rest of the fade. Any other fade holds
1470
+ * nothing.
1471
+ */
1472
+ engine.fadeHeldFor = (landing) => {
1473
+ const animation = running.get("opacity");
1474
+ const owner = segments.get("opacity")?.owner;
1475
+ if (animation == null || owner == null || owner !== landing.owner && !landing.carried.includes(owner)) return 0;
1476
+ if (animation.playState === "paused") return 100;
1477
+ const start = animation.startTime;
1478
+ const duration = Number(animation.effect?.getTiming?.().duration);
1479
+ if (!Number.isFinite(duration)) return 0;
1480
+ if (start == null) return animation.playState === "running" ? END_RECHECK_MS : 0;
1481
+ const end = Number(start) + duration - END_HOLD_MS;
1482
+ if (landing.due != null && end <= landing.due) return 0;
1483
+ const left = end - now();
1484
+ return left > 0 ? left : 0;
1485
+ };
1486
+ /**
1487
+ * The landing's timer: it lands once its fade lets it. A call that takes the
1488
+ * landing over lands it directly, at once.
1489
+ */
1490
+ engine.landWhenFaded = (landing) => {
1491
+ const held = engine.fadeHeldFor(landing);
1492
+ if (held > 0) {
1493
+ landing.due = now() + held;
1494
+ landing.timer = setTimeout(() => engine.landWhenFaded(landing), held);
1495
+ return;
1496
+ }
1497
+ engine.land(landing);
1498
+ };
1499
+ /** Arms a landing from the call's start (the browser's, for a call from rest). */
1500
+ engine.scheduleLanding = (owner, started, plan, adopted) => {
1501
+ const owners = /* @__PURE__ */ new Map();
1502
+ for (const property of plan.values.keys()) owners.set(property, adopted?.owners.get(property) ?? owner);
1503
+ const landing = {
1504
+ ...plan,
1505
+ owner,
1506
+ carried: adopted?.carried ?? [],
1507
+ owners,
1508
+ timer: null,
1509
+ due: null
1510
+ };
1511
+ landings.add(landing);
1512
+ if (owner.timer != null) {
1513
+ clearTimeout(owner.timer);
1514
+ owner.timer = null;
1515
+ }
1516
+ started.then((start) => {
1517
+ if (!landings.has(landing)) return;
1518
+ landing.due = start + landing.at;
1519
+ landing.timer = setTimeout(() => engine.landWhenFaded(landing), Math.max(0, landing.due - now()));
1520
+ });
1521
+ };
1522
+ }
1523
+ //#endregion
1524
+ //#region src/motion/engine/lookAtShown.ts
1525
+ function installLookAtShown(engine) {
1526
+ const { heldForFrame, now, resting, segments, shown } = engine;
1527
+ /**
1528
+ * The frame that commits calls that continue motion. When it comes more
1529
+ * than LATE_START_MS after the first call it commits on any animator, the
1530
+ * screen has shown the old curve. Each spring that they leave
1531
+ * then starts here, from the value on screen, as UIKit's added spring
1532
+ * begins at its commit. It keeps a velocity that its call handed it, such
1533
+ * as a release's, and otherwise takes the one on screen. A played curve or
1534
+ * a coast keeps its call's clock, and an earlier frame keeps every call on
1535
+ * its own clock.
1536
+ */
1537
+ engine.lookAtShown = (frame) => {
1538
+ engine.isShownLookQueued = false;
1539
+ const entries = [...shown];
1540
+ const channels = [...heldForFrame];
1541
+ heldForFrame.clear();
1542
+ engine.forgetShown();
1543
+ if (engine.target == null) return;
1544
+ const at = frameTime(frame, now);
1545
+ const late = at - firstCommitted(frame, Math.min(...entries.map(([, entry]) => entry.since))) > 34;
1546
+ const changed = [];
1547
+ const owners = /* @__PURE__ */ new Set();
1548
+ for (const [property, entry] of entries) {
1549
+ const current = segments.get(property);
1550
+ if (!late || current == null || current.spring == null || current.isFade === true || engine.isHeld(current)) continue;
1551
+ const screen = engine.shownAt(entry, at);
1552
+ const next = current.isAdditive === true && entry.segment != null ? engine.additiveSegment(current.owner, property, at, current.target, current.spring, engine.shifted(entry.segment, entry.offset)) : engine.springFrom(current.owner, property, at, screen.value, current.handedVelocity ?? (entry.segment == null ? current.speed(0) : screen.velocity), current.target, current.spring);
1553
+ if (next == null) {
1554
+ segments.delete(property);
1555
+ resting[property] = current.target;
1556
+ } else segments.set(property, current.handedVelocity == null ? next : {
1557
+ ...next,
1558
+ handedVelocity: current.handedVelocity
1559
+ });
1560
+ owners.add(current.owner);
1561
+ changed.push(property);
1562
+ }
1563
+ const restarted = new Set(changed.map((property) => CHANNEL_OF[property]));
1564
+ if (restarted.size > 0) engine.commit([...restarted].flatMap((channel) => CHANNELS[channel]), at);
1565
+ engine.rebuildOnCallClocks(channels.filter(([channel]) => !restarted.has(channel)));
1566
+ for (const owner of owners) {
1567
+ if (owner.settled || owner.timer == null) continue;
1568
+ clearTimeout(owner.timer);
1569
+ let end = at;
1570
+ for (const segment of segments.values()) if (segment.owner === owner) end = Math.max(end, segment.start + segment.duration);
1571
+ owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, end - now()));
1572
+ }
1573
+ };
1574
+ engine.commit = (changed, time) => {
1575
+ const channels = /* @__PURE__ */ new Set();
1576
+ for (const property of changed) channels.add(CHANNEL_OF[property]);
1577
+ if (channels.has("opacity")) engine.borrowedOpacity = null;
1578
+ for (const channel of channels) engine.rebuild(channel, time);
1579
+ engine.flushReleases();
1580
+ };
1581
+ }
1582
+ //#endregion
1583
+ //#region src/motion/engine/play.ts
1584
+ function installPlay(engine) {
1585
+ const { animator, isCoarsePointer, now, resting, segments } = engine;
1586
+ animator.play = (curves, playOptions = {}) => {
1587
+ engine.syncPending();
1588
+ if (playOptions.start !== "presented") engine.flushDeferred();
1589
+ const time = playOptions.at ?? callTime(now);
1590
+ const { owner, finished } = engine.newOwner();
1591
+ const byProperty = {};
1592
+ const entries = Object.entries(curves).sort(([a], [b]) => Number(b === "scale") - Number(a === "scale"));
1593
+ for (const [key, curve] of entries) {
1594
+ if (curve == null) continue;
1595
+ if (!Number.isFinite(curve.duration) || curve.duration < 0) throw new RangeError(`animator: a curve needs a finite duration ≥ 0 (got ${curve.duration})`);
1596
+ for (const property of expandList([key])) byProperty[property] = curve;
1597
+ }
1598
+ const properties = Object.keys(byProperty);
1599
+ const targets = {};
1600
+ for (const property of properties) {
1601
+ const curve = byProperty[property];
1602
+ targets[property] = curve.at(curve.duration);
1603
+ }
1604
+ const plan = engine.prefersReducedMotion() ? engine.reducedMotion(owner, time, targets, properties, isCoarsePointer() || playOptions.touchRelease === true, playOptions.crossfadeAs) : null;
1605
+ const next = { ...plan?.next };
1606
+ for (const property of properties) {
1607
+ if (property in next) continue;
1608
+ const curve = byProperty[property];
1609
+ const running = playOptions.additive === true ? engine.segmentAt(property, time) : null;
1610
+ if (running != null && !engine.isHeld(running) && curve.duration > 0 && Math.abs(curve.at(curve.duration) - curve.at(0)) > 1e-9) {
1611
+ next[property] = engine.additiveCurveSegment(owner, time, curve, running);
1612
+ continue;
1613
+ }
1614
+ next[property] = curve.duration === 0 ? null : {
1615
+ start: time,
1616
+ duration: Math.min(MAX_DURATION_MS, curve.duration * 1e3),
1617
+ target: targets[property],
1618
+ at: (t) => curve.at(t / 1e3),
1619
+ speed: (t) => curve.velocity(t / 1e3),
1620
+ jumps: [],
1621
+ owner,
1622
+ source: curve
1623
+ };
1624
+ }
1625
+ const group = engine.beginGroup(time, Object.keys(next), playOptions.at, playOptions.start);
1626
+ if (group != null && playOptions.at == null && playOptions.start === "next-frame") group.nextFrame = true;
1627
+ const waitsForFrame = engine.noteShown(Object.keys(next), time, group, playOptions.at);
1628
+ const adopted = plan?.landing != null ? engine.adoptLandings(plan.landing, Object.keys(next)) : null;
1629
+ const changed = [];
1630
+ for (const [property, segment] of Object.entries(next)) {
1631
+ engine.interrupt(property, time);
1632
+ changed.push(property);
1633
+ if (segment == null) {
1634
+ const value = plan?.holds[property] ?? targets[property] ?? engine.valueAt(property, time);
1635
+ segments.delete(property);
1636
+ resting[property] = value;
1637
+ } else segments.set(property, segment);
1638
+ }
1639
+ engine.commitCall(group, owner, changed, time, playOptions.start === "presented" && playOptions.at == null, waitsForFrame);
1640
+ if (plan?.borrowed != null) engine.borrowedOpacity = plan.borrowed;
1641
+ if (plan?.joins === true) engine.joinWaitingDip(owner);
1642
+ const handle = plan?.joins === true ? engine.makeHandle(owner, ["opacity"], finished, time, group, true) : engine.makeHandle(owner, changed, finished, time, group);
1643
+ if (plan?.landing != null) engine.scheduleLanding(owner, handle.started, plan.landing, adopted);
1644
+ return handle;
1645
+ };
1646
+ }
1647
+ //#endregion
1648
+ //#region src/motion/engine/promotion.ts
1649
+ function installPromotion(engine) {
1650
+ const { now, pendingGroups, promoted, promotionProperty, segments } = engine;
1651
+ /** Writes the promoted channels as will-change (or the pseudo's property). */
1652
+ engine.writePromotion = (element) => {
1653
+ const list = [...promoted].join(", ");
1654
+ if (promotionProperty != null) {
1655
+ if (list === "") element.style.removeProperty(promotionProperty);
1656
+ else element.style.setProperty(promotionProperty, list);
1657
+ return;
1658
+ }
1659
+ if (list === "") {
1660
+ element.style.willChange = engine.ownWillChange ?? "";
1661
+ engine.ownWillChange = null;
1662
+ return;
1663
+ }
1664
+ engine.ownWillChange ??= element.style.willChange;
1665
+ if (engine.ownWillChange === "" && !engine.sheetWillChangeRead) {
1666
+ element.style.willChange = [...promoted].join(", ");
1667
+ engine.queueSheetReadFor(element);
1668
+ return;
1669
+ }
1670
+ const base = engine.ownWillChange !== "" ? engine.ownWillChange : engine.sheetWillChange;
1671
+ const reasons = (base === "auto" ? "" : base).split(",").map((reason) => reason.trim()).filter((reason) => reason !== "" && !promoted.has(reason));
1672
+ element.style.willChange = [...reasons, ...promoted].join(", ");
1673
+ };
1674
+ /** Reads the element's own will-change while no promotion of ours is written. */
1675
+ engine.readSheetWillChange = (element) => {
1676
+ engine.sheetWillChange = element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue("will-change") ?? "";
1677
+ engine.sheetWillChangeRead = true;
1678
+ };
1679
+ /** Joins the stylesheet's reasons to a promotion once the callback ends. */
1680
+ engine.queueSheetReadFor = (element) => {
1681
+ if (engine.sheetReadQueuedFor === element) return;
1682
+ engine.sheetReadQueuedFor = element;
1683
+ const waits = () => engine.sheetReadQueuedFor === element && engine.target === element && promoted.size > 0 && engine.ownWillChange === "";
1684
+ queueSheetRead({
1685
+ lift: () => {
1686
+ if (waits()) element.style.willChange = "";
1687
+ },
1688
+ read: () => {
1689
+ if (waits()) engine.readSheetWillChange(element);
1690
+ },
1691
+ write: () => {
1692
+ if (engine.sheetReadQueuedFor !== element) return;
1693
+ engine.sheetReadQueuedFor = null;
1694
+ if (engine.target === element && promoted.size > 0) engine.writePromotion(element);
1695
+ }
1696
+ });
1697
+ };
1698
+ /**
1699
+ * Reads sheetWillChange in a task of its own, so a later promotion reads no
1700
+ * style in its own task. Skipped while a promotion of ours is written,
1701
+ * which the read would see (demote asks again), and for a node out of the
1702
+ * document. A pseudo-element's promotion is its own property, with
1703
+ * nothing to read.
1704
+ */
1705
+ engine.readSheetWillChangeLater = () => {
1706
+ engine.cancelSheetWillChangeRead();
1707
+ engine.sheetWillChangeRead = false;
1708
+ if (engine.target == null || promotionProperty != null) return;
1709
+ const element = engine.target;
1710
+ engine.sheetReadTimer = setTimeout(() => {
1711
+ engine.sheetReadTimer = null;
1712
+ if (engine.target === element && promoted.size === 0 && element.isConnected) engine.readSheetWillChange(element);
1713
+ }, 0);
1714
+ };
1715
+ engine.cancelSheetWillChangeRead = () => {
1716
+ if (engine.sheetReadTimer != null) {
1717
+ clearTimeout(engine.sheetReadTimer);
1718
+ engine.sheetReadTimer = null;
1719
+ }
1720
+ };
1721
+ /**
1722
+ * Gives the element (or its pseudo-element) a compositing layer for
1723
+ * `channel` from the task that starts the motion: Mobile Safari runs an
1724
+ * animation whose start time is set from script on its compositor at its
1725
+ * first commit only if the element already has a layer.
1726
+ */
1727
+ engine.promote = (channel) => {
1728
+ if (engine.target == null) return;
1729
+ if (!promoted.has(channel)) {
1730
+ promoted.add(channel);
1731
+ engine.writePromotion(engine.target);
1732
+ }
1733
+ engine.scheduleDemote();
1734
+ };
1735
+ /** Ends promotion PROMOTION_LINGER_MS after the last motion ends. */
1736
+ engine.scheduleDemote = () => {
1737
+ if (engine.demoteTimer != null) clearTimeout(engine.demoteTimer);
1738
+ let end = now();
1739
+ for (const segment of segments.values()) end = Math.max(end, segment.start + segment.duration);
1740
+ engine.demoteTimer = setTimeout(() => {
1741
+ engine.demoteTimer = null;
1742
+ const time = now();
1743
+ if ([...segments.values()].some((segment) => time < segment.start + segment.duration) || pendingGroups.size > 0) {
1744
+ engine.scheduleDemote();
1745
+ return;
1746
+ }
1747
+ engine.demote();
1748
+ }, Math.max(0, end - now()) + 500);
1749
+ };
1750
+ engine.demote = () => {
1751
+ if (engine.demoteTimer != null) {
1752
+ clearTimeout(engine.demoteTimer);
1753
+ engine.demoteTimer = null;
1754
+ }
1755
+ if (promoted.size === 0) return;
1756
+ promoted.clear();
1757
+ if (engine.target != null) {
1758
+ engine.writePromotion(engine.target);
1759
+ engine.readSheetWillChangeLater();
1760
+ }
1761
+ };
1762
+ }
1763
+ //#endregion
1764
+ //#region src/motion/engine/readSet.ts
1765
+ function installReadSet(engine) {
1766
+ const { animator, now, resting, segments, shown } = engine;
1767
+ animator.get = (property, time = now()) => {
1768
+ engine.syncPending();
1769
+ return engine.valueAt(property === "scale" ? "scaleX" : property, time);
1770
+ };
1771
+ animator.getVelocity = (property, time = now()) => {
1772
+ engine.syncPending();
1773
+ return engine.velocityAt(property === "scale" ? "scaleX" : property, time);
1774
+ };
1775
+ animator.set = (values, setOptions = {}) => {
1776
+ engine.syncPending();
1777
+ engine.flushDeferred();
1778
+ const time = now();
1779
+ const next = expand(values);
1780
+ for (const [property, value] of Object.entries(next)) {
1781
+ engine.interrupt(property, time);
1782
+ segments.delete(property);
1783
+ shown.delete(property);
1784
+ resting[property] = value;
1785
+ }
1786
+ if (setOptions.promote !== false) for (const property of Object.keys(next)) engine.promote(CHANNEL_OF[property]);
1787
+ engine.commit(Object.keys(next), time);
1788
+ };
1789
+ }
1790
+ //#endregion
1791
+ //#region src/motion/types.ts
1792
+ /**
1793
+ * Within this of its target a curve is over (in the property's own unit). A
1794
+ * curve built outside the animator (a progress curve) settles where a call
1795
+ * would with this as its epsilon.
1796
+ */
1797
+ const SETTLE_THRESHOLD = {
1798
+ x: .05,
1799
+ y: .05,
1800
+ rotate: .01,
1801
+ scaleX: 1e-4,
1802
+ scaleY: 1e-4,
1803
+ opacity: .001
1804
+ };
1805
+ //#endregion
1806
+ //#region src/motion/engine/rebase.ts
1807
+ function installRebase(engine) {
1808
+ const { animator, heldForFrame, landings, now, restWaits, resting, retireFrames, retireLooks, retireTimers, running, segments, shown, stale } = engine;
1809
+ animator.rebase = (deltas, rebaseOptions = {}) => {
1810
+ engine.syncPending();
1811
+ engine.flushDeferred();
1812
+ const time = rebaseOptions.at ?? now();
1813
+ const towards = expand(rebaseOptions.towards ?? {});
1814
+ const changed = [];
1815
+ const owners = /* @__PURE__ */ new Set();
1816
+ for (const [property, delta] of Object.entries(expand(deltas))) {
1817
+ if (delta === 0) continue;
1818
+ const noted = shown.get(property);
1819
+ if (noted != null) noted.offset += delta;
1820
+ const segment = engine.segmentAt(property, time);
1821
+ if (segment == null) {
1822
+ changed.push(property);
1823
+ resting[property] = engine.valueAt(property, time) + delta;
1824
+ segments.delete(property);
1825
+ continue;
1826
+ }
1827
+ owners.add(segment.owner);
1828
+ const latest = engine.shownSince(property, segment);
1829
+ const group = latest == null && segment.group != null && !segment.group.resolved ? segment.group : void 0;
1830
+ const replace = (next) => {
1831
+ if (group != null) engine.replaceIn(group, segment, next);
1832
+ segments.set(property, next);
1833
+ };
1834
+ const heading = towards[property];
1835
+ if (segment.spring != null && heading != null && Math.abs(segment.target + delta - heading) <= 1e-6) {
1836
+ const whole = {
1837
+ ...segment,
1838
+ target: heading,
1839
+ at: (t) => segment.at(t) + delta
1840
+ };
1841
+ if (latest == null) {
1842
+ changed.push(property);
1843
+ replace(whole);
1844
+ continue;
1845
+ }
1846
+ const waiting = segment.group;
1847
+ if (waiting != null && !waiting.resolved) {
1848
+ engine.replaceIn(waiting, segment, whole);
1849
+ segments.set(property, whole);
1850
+ engine.markStale(CHANNEL_OF[property]);
1851
+ continue;
1852
+ }
1853
+ }
1854
+ changed.push(property);
1855
+ if (segment.spring != null) {
1856
+ const from = engine.valueAt(property, time) + delta;
1857
+ const velocity = engine.velocityAt(property, time);
1858
+ if (latest != null) engine.leaveWaitingCall(segment, CHANNEL_OF[property], latest);
1859
+ const curve = solveSpring(toSpring(segment.spring), {
1860
+ from,
1861
+ to: segment.target,
1862
+ velocity
1863
+ });
1864
+ replace({
1865
+ start: group?.provisional ?? time,
1866
+ ...group != null ? { group } : {},
1867
+ duration: Math.min(MAX_DURATION_MS, curve.settleTime(SETTLE_THRESHOLD[property]) * 1e3),
1868
+ target: segment.target,
1869
+ at: (t) => curve.value(t / 1e3),
1870
+ speed: (t) => curve.velocity(t / 1e3),
1871
+ jumps: [],
1872
+ owner: segment.owner,
1873
+ spring: segment.spring
1874
+ });
1875
+ } else {
1876
+ if (latest != null) engine.leaveWaitingCall(segment, CHANNEL_OF[property], latest);
1877
+ replace({
1878
+ ...segment,
1879
+ source: void 0,
1880
+ target: segment.target + delta,
1881
+ at: (t) => segment.at(t) + delta
1882
+ });
1883
+ }
1884
+ }
1885
+ engine.commit(changed.filter((property) => !heldForFrame.has(CHANNEL_OF[property])), time);
1886
+ for (const channel of new Set(changed.map((p) => CHANNEL_OF[p]))) if (heldForFrame.has(channel)) engine.rebuildShown(channel, time);
1887
+ for (const owner of owners) {
1888
+ if (owner.settled || owner.timer == null) continue;
1889
+ clearTimeout(owner.timer);
1890
+ let end = time;
1891
+ for (const segment of segments.values()) if (segment.owner === owner) end = Math.max(end, segment.start + segment.duration);
1892
+ owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, end - now()));
1893
+ }
1894
+ };
1895
+ animator.atRest = async (properties) => {
1896
+ const list = properties == null ? PROPERTIES : expandList(properties);
1897
+ return new Promise((resolve) => {
1898
+ const wait = {
1899
+ timer: null,
1900
+ settle: () => {}
1901
+ };
1902
+ const done = () => {
1903
+ if (wait.timer != null) clearTimeout(wait.timer);
1904
+ restWaits.delete(wait);
1905
+ resolve();
1906
+ };
1907
+ wait.settle = done;
1908
+ restWaits.add(wait);
1909
+ const check = () => {
1910
+ wait.timer = null;
1911
+ engine.syncPending();
1912
+ const time = now();
1913
+ let end = time;
1914
+ for (const property of list) {
1915
+ const segment = segments.get(property);
1916
+ if (segment != null) end = Math.max(end, segment.start + segment.duration);
1917
+ }
1918
+ if (landings.size > 0) wait.timer = setTimeout(check, 16);
1919
+ else if (end <= time) done();
1920
+ else wait.timer = setTimeout(check, end - time);
1921
+ };
1922
+ check();
1923
+ });
1924
+ };
1925
+ animator.dispose = () => {
1926
+ engine.flushDeferred();
1927
+ if (engine.target == null && engine.unmountQueued) engine.target = engine.lastDetached;
1928
+ engine.lastDetached = null;
1929
+ engine.unmountQueued = false;
1930
+ engine.landPending(false);
1931
+ for (const wait of [...restWaits]) wait.settle();
1932
+ const time = now();
1933
+ for (const property of PROPERTIES) engine.interrupt(property, time);
1934
+ for (const animation of running.values()) animation.cancel();
1935
+ running.clear();
1936
+ stale.clear();
1937
+ engine.forgetShown();
1938
+ heldForFrame.clear();
1939
+ for (const timer of retireTimers.values()) clearTimeout(timer);
1940
+ retireTimers.clear();
1941
+ engine.present(false);
1942
+ for (const timer of retireLooks.values()) clearTimeout(timer);
1943
+ retireLooks.clear();
1944
+ retireFrames.clear();
1945
+ engine.handBackBorrow();
1946
+ engine.demote();
1947
+ engine.cancelSheetWillChangeRead();
1948
+ engine.target = null;
1949
+ };
1950
+ }
1951
+ //#endregion
1952
+ //#region src/motion/engine/rebuild.ts
1953
+ function installRebuild(engine) {
1954
+ const { now, pseudoElement, requestFrame, resting, retireLooks, retireTimers, running, segments, stale } = engine;
1955
+ engine.rebuild = (channel, time) => {
1956
+ engine.commitWaitingNow(channel);
1957
+ stale.delete(channel);
1958
+ const previous = running.get(channel);
1959
+ running.delete(channel);
1960
+ clearTimeout(retireTimers.get(channel));
1961
+ retireTimers.delete(channel);
1962
+ clearTimeout(retireLooks.get(channel));
1963
+ retireLooks.delete(channel);
1964
+ if (pseudoElement == null) previous?.cancel();
1965
+ const properties = CHANNELS[channel];
1966
+ for (const property of properties) {
1967
+ const segment = segments.get(property);
1968
+ if (segment != null && time >= engine.endOf(property, segment)) {
1969
+ resting[property] = segment.target;
1970
+ segments.delete(property);
1971
+ }
1972
+ }
1973
+ const moving = properties.filter((p) => segments.has(p));
1974
+ if (engine.callGroup == null) for (const property of moving) {
1975
+ const segment = segments.get(property);
1976
+ const latest = engine.shownSince(property, segment);
1977
+ if (latest != null) engine.leaveWaitingCall(segment, channel, latest);
1978
+ }
1979
+ const waiting = engine.callGroup ?? moving.map((p) => segments.get(p).group).find((group) => group != null && !group.resolved) ?? null;
1980
+ const rebuiltAfterFirstFrame = waiting?.framed === true;
1981
+ const restarted = /* @__PURE__ */ new Set();
1982
+ if (rebuiltAfterFirstFrame) restarted.add(waiting);
1983
+ if (engine.callGroup != null) for (const property of moving) {
1984
+ const group = segments.get(property).group;
1985
+ if (group != null && group !== engine.callGroup && !group.resolved) restarted.add(group);
1986
+ }
1987
+ for (const group of restarted) group.latest?.delete(channel);
1988
+ if (channel === "translate" && !engine.isCustom(channel)) {
1989
+ engine.hitTested = {
1990
+ x: engine.valueAt("x", time),
1991
+ y: engine.valueAt("y", time)
1992
+ };
1993
+ engine.present(moving.length > 0 && engine.target != null && typeof engine.target.animate === "function");
1994
+ }
1995
+ if (moving.length === 0 || engine.target == null || typeof engine.target.animate !== "function") engine.writeInline(channel, engine.finalValue);
1996
+ else engine.writeInline(channel, (p) => engine.valueAt(p, time));
1997
+ if (engine.target == null || typeof engine.target.animate !== "function") {
1998
+ previous?.cancel();
1999
+ return;
2000
+ }
2001
+ if (moving.length === 0) {
2002
+ if (pseudoElement != null) engine.hold(channel, time);
2003
+ previous?.cancel();
2004
+ return;
2005
+ }
2006
+ const from = waiting?.provisional ?? time;
2007
+ const end = Math.min(from + MAX_DURATION_MS, Math.max(...moving.map((p) => segments.get(p).start + segments.get(p).duration)));
2008
+ if (end <= from) {
2009
+ if (pseudoElement != null) engine.hold(channel, time);
2010
+ previous?.cancel();
2011
+ return;
2012
+ }
2013
+ if (engine.callGroup != null) for (const property of moving) {
2014
+ const segment = segments.get(property);
2015
+ const group = segment.group;
2016
+ if (group != null && group !== engine.callGroup && !group.resolved) {
2017
+ const index = group.segments.indexOf(segment);
2018
+ if (index >= 0) group.segments.splice(index, 1);
2019
+ group.adoptedBy = engine.callGroup;
2020
+ segment.group = engine.callGroup;
2021
+ segment.start += engine.callGroup.provisional - group.provisional;
2022
+ engine.callGroup.segments.push(segment);
2023
+ }
2024
+ }
2025
+ const devicePixel = 1 / Math.max(1, globalThis.devicePixelRatio || 1);
2026
+ const bakeKey = pseudoElement == null && !engine.isCustom(channel) ? engine.taskBakeKey(channel, moving, from, end, devicePixel) : null;
2027
+ const baked = bakeKey == null ? void 0 : bakesOfTask().keyframes.find((bake) => isSameKey(bake.key, bakeKey));
2028
+ const collect = (scale) => {
2029
+ const times = /* @__PURE__ */ new Set([from, end]);
2030
+ for (const property of moving) {
2031
+ const tolerance = SAMPLE_TOLERANCE[property] * scale * (property === "x" || property === "y" ? devicePixel : 1);
2032
+ for (const t of engine.sharedSampleTimes(property, from, end, tolerance)) times.add(t);
2033
+ }
2034
+ return times;
2035
+ };
2036
+ const span = end - from + END_HOLD_MS;
2037
+ const bakeKeyframes = () => {
2038
+ let scale = 1;
2039
+ let all = collect(scale);
2040
+ while (all.size > 1200 && scale < 64) {
2041
+ scale *= 2;
2042
+ all = collect(scale);
2043
+ }
2044
+ const jumpTimes = /* @__PURE__ */ new Set();
2045
+ for (const property of moving) {
2046
+ const segment = segments.get(property);
2047
+ for (const j of segment.jumps) {
2048
+ const t = segment.start + j;
2049
+ if (t > from && t <= end) {
2050
+ jumpTimes.add(t);
2051
+ all.add(t);
2052
+ }
2053
+ }
2054
+ }
2055
+ const times = [...all].sort((a, b) => a - b);
2056
+ const frames = [];
2057
+ for (const t of times) {
2058
+ const offset = (t - from) / span;
2059
+ if (jumpTimes.has(t)) frames.push({
2060
+ offset,
2061
+ ...engine.frameOf(channel, (p) => engine.valueBefore(p, t))
2062
+ });
2063
+ frames.push({
2064
+ offset,
2065
+ ...engine.frameOf(channel, (p) => t >= end ? engine.finalValue(p) : engine.curveAt(p, t))
2066
+ });
2067
+ }
2068
+ frames.push({
2069
+ offset: 1,
2070
+ ...engine.frameOf(channel, engine.finalValue)
2071
+ });
2072
+ return frames;
2073
+ };
2074
+ const keyframes = baked?.keyframes ?? bakeKeyframes();
2075
+ if (!engine.isCustom(channel)) engine.promote(channel);
2076
+ const animation = baked != null && isCopyable(baked.effect) ? copyAnimation(baked.effect, engine.target) : quietFinished(engine.target.animate(keyframes, {
2077
+ duration: span,
2078
+ fill: "both",
2079
+ easing: "linear",
2080
+ ...pseudoElement != null ? { pseudoElement } : {}
2081
+ }));
2082
+ if (bakeKey != null && baked == null) bakesOfTask().keyframes.push({
2083
+ key: bakeKey,
2084
+ keyframes,
2085
+ effect: animation.effect
2086
+ });
2087
+ if (waiting != null) {
2088
+ waiting.animations.push(animation);
2089
+ waiting.channels.add(channel);
2090
+ animation.ready?.catch(() => {});
2091
+ if (rebuiltAfterFirstFrame) requestFrame?.((frame) => {
2092
+ if (!waiting.resolved && running.get(channel) === animation && animation.startTime == null && animation.playState === "running") (waiting.latest ??= /* @__PURE__ */ new Map()).set(channel, frameTime(frame, now));
2093
+ });
2094
+ } else animation.startTime = time;
2095
+ running.set(channel, animation);
2096
+ previous?.cancel();
2097
+ engine.scheduleRetire(channel, animation, end);
2098
+ };
2099
+ }
2100
+ //#endregion
2101
+ //#region src/motion/engine/retire.ts
2102
+ function installRetire(engine) {
2103
+ const { carriedOwners, heldForFrame, landings, now, pendingGroups, pseudoElement, releasing, requestFrame, resting, retireFrames, retireLooks, retireTimers, running, segments } = engine;
2104
+ /**
2105
+ * Once the main thread runs after the curve's end, the animation leaves the
2106
+ * running state: an element's end values are written inline in the task
2107
+ * that cancels it; a pseudo-element's end value moves to a static holding
2108
+ * animation, created before the long one goes.
2109
+ *
2110
+ * Why a timer at the curve's end: no browser event reports that an
2111
+ * animation's time has reached a point inside its effect, and its
2112
+ * `finished` comes only after the END_HOLD_MS tail, which would keep the
2113
+ * element promoted and the animation alive for a minute. The timer is set
2114
+ * on the curve's own clock and re-armed while a sampler pauses or seeks the
2115
+ * animation, so it never retires a held one.
2116
+ */
2117
+ engine.scheduleRetire = (channel, animation, end) => {
2118
+ clearTimeout(retireTimers.get(channel));
2119
+ retireTimers.delete(channel);
2120
+ clearTimeout(retireLooks.get(channel));
2121
+ retireLooks.delete(channel);
2122
+ const lookAtFrame = () => {
2123
+ if (requestFrame == null || retireFrames.has(animation)) return;
2124
+ retireFrames.add(animation);
2125
+ requestFrame(() => {
2126
+ retireFrames.delete(animation);
2127
+ retire(true);
2128
+ });
2129
+ };
2130
+ const retire = (atFrame = false) => {
2131
+ if (!atFrame) retireTimers.delete(channel);
2132
+ if (running.get(channel) !== animation) return;
2133
+ if (heldForFrame.has(channel)) {
2134
+ if (!retireTimers.has(channel)) retireTimers.set(channel, setTimeout(retire, END_RECHECK_MS));
2135
+ return;
2136
+ }
2137
+ const remaining = engine.remainingCurve(animation);
2138
+ if (atFrame && remaining == null) return;
2139
+ if (remaining != null && remaining > 0) {
2140
+ const paused = animation.playState === "paused";
2141
+ if (!paused && remaining <= (atFrame ? 2 : 1) * 16.666666666666668) lookAtFrame();
2142
+ if (!retireTimers.has(channel)) retireTimers.set(channel, setTimeout(retire, paused ? 100 : Math.max(remaining, END_RECHECK_MS)));
2143
+ return;
2144
+ }
2145
+ clearTimeout(retireTimers.get(channel));
2146
+ retireTimers.delete(channel);
2147
+ running.delete(channel);
2148
+ if (channel === "translate") engine.present(false);
2149
+ const handsBack = channel === "opacity" && engine.borrowedOpacity != null && ![...landings].some((landing) => landing.fadeIn?.isBorrowed === true);
2150
+ if (pseudoElement != null && !handsBack) engine.hold(channel, now());
2151
+ else engine.writeInline(channel, engine.finalValue, false);
2152
+ const waiting = [...pendingGroups].filter((group) => group.animations.includes(animation));
2153
+ for (const group of waiting) engine.syncGroup(group);
2154
+ animation.cancel();
2155
+ for (const group of waiting) engine.resolveGroup(group, group.provisional);
2156
+ engine.releaseIdentity(channel);
2157
+ engine.flushReleases();
2158
+ };
2159
+ retireTimers.set(channel, setTimeout(retire, Math.max(0, end - now())));
2160
+ if (requestFrame != null) retireLooks.set(channel, setTimeout(() => {
2161
+ retireLooks.delete(channel);
2162
+ lookAtFrame();
2163
+ }, Math.max(0, end - now() - END_RECHECK_MS)));
2164
+ };
2165
+ /** The element's own (stylesheet) opacity, read once when a dip starts. */
2166
+ engine.ownOpacity = () => {
2167
+ const view = engine.target?.ownerDocument.defaultView;
2168
+ const value = engine.target == null ? NaN : Number.parseFloat(view?.getComputedStyle(engine.target, pseudoElement ?? null).getPropertyValue("opacity") ?? "");
2169
+ return Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 1;
2170
+ };
2171
+ /**
2172
+ * Whether the animator holds an opacity of its own on the element: an inline
2173
+ * value it wrote, or a pseudo-element's holding animation (a `set` over a
2174
+ * stylesheet that hides or dims it). A dip returns to that value.
2175
+ */
2176
+ engine.writesOwnOpacity = () => pseudoElement == null ? (engine.target?.style.getPropertyValue("opacity") ?? "") !== "" : running.has("opacity");
2177
+ /**
2178
+ * Gives the element's opacity back to its stylesheet: an element's inline
2179
+ * value goes; a pseudo-element, which has no inline style, loses the
2180
+ * animation holding its value.
2181
+ */
2182
+ engine.releaseOwnOpacity = () => {
2183
+ if (pseudoElement == null) {
2184
+ engine.target?.style.removeProperty("opacity");
2185
+ return;
2186
+ }
2187
+ const held = running.get("opacity");
2188
+ running.delete("opacity");
2189
+ held?.cancel();
2190
+ };
2191
+ /**
2192
+ * Lands every Reduce Motion move still waiting, at once, on the current
2193
+ * element: its travel, and the opacity its fade was heading to (the
2194
+ * stylesheet's again for a borrowed one). Its calls settle `finished`.
2195
+ */
2196
+ engine.landPending = (finished) => {
2197
+ if (landings.size === 0) return;
2198
+ const changed = /* @__PURE__ */ new Set();
2199
+ let handedBack = false;
2200
+ for (const landing of [...landings]) {
2201
+ engine.endLanding(landing);
2202
+ for (const [property, value] of landing.values) {
2203
+ segments.delete(property);
2204
+ resting[property] = value;
2205
+ changed.add(property);
2206
+ }
2207
+ if (landing.fadeIn != null || landing.restore != null) {
2208
+ const borrowed = landing.fadeIn?.isBorrowed === true || landing.restoreIsBorrowed === true;
2209
+ segments.delete("opacity");
2210
+ resting.opacity = borrowed ? IDENTITY.opacity : landing.fadeIn?.to ?? landing.restore ?? IDENTITY.opacity;
2211
+ changed.add("opacity");
2212
+ if (borrowed) {
2213
+ engine.borrowedOpacity = null;
2214
+ handedBack = true;
2215
+ }
2216
+ }
2217
+ for (const owner of [landing.owner, ...landing.carried]) {
2218
+ carriedOwners.delete(owner);
2219
+ if (!owner.settled) engine.settle(owner, finished);
2220
+ }
2221
+ }
2222
+ engine.commit(changed, now());
2223
+ if (handedBack) engine.releaseOwnOpacity();
2224
+ };
2225
+ /**
2226
+ * Ends a borrowed dip on the element it ran on: the stylesheet owns its
2227
+ * opacity again (an unmount or a new element never keeps the borrow).
2228
+ */
2229
+ engine.handBackBorrow = () => {
2230
+ if (engine.borrowedOpacity == null) return;
2231
+ engine.borrowedOpacity = null;
2232
+ segments.delete("opacity");
2233
+ resting.opacity = IDENTITY.opacity;
2234
+ engine.releaseOwnOpacity();
2235
+ };
2236
+ /**
2237
+ * A channel at identity with no animation of its own leaves the element:
2238
+ * its inline value is removed, unless the stylesheet would then move the
2239
+ * element, in which case the identity stays inline. Runs when such a value
2240
+ * is written and again when a motion ends.
2241
+ */
2242
+ engine.releaseIdentity = (channel) => {
2243
+ if (engine.target == null || running.has(channel)) return;
2244
+ if (channel === "opacity" && engine.borrowedOpacity != null) {
2245
+ if ([...landings].some((landing) => landing.fadeIn?.isBorrowed === true)) return;
2246
+ engine.borrowedOpacity = null;
2247
+ segments.delete("opacity");
2248
+ resting.opacity = IDENTITY.opacity;
2249
+ engine.releaseOwnOpacity();
2250
+ return;
2251
+ }
2252
+ if (pseudoElement != null) return;
2253
+ if (engine.target.style.getPropertyValue(engine.cssName(channel)) !== engine.identityOf(channel)) return;
2254
+ releasing.add(channel);
2255
+ if (!engine.releaseQueued) {
2256
+ engine.releaseQueued = true;
2257
+ queueMicrotask(engine.flushReleases);
2258
+ }
2259
+ };
2260
+ /**
2261
+ * Removes the identity values written since the last flush, reads the
2262
+ * stylesheet once for all of them, and puts back the ones it would move:
2263
+ * a single forced style read per element and commit, where a read per
2264
+ * channel used to force one each.
2265
+ */
2266
+ engine.flushReleases = () => {
2267
+ engine.releaseQueued = false;
2268
+ const element = engine.target;
2269
+ const channels = [...releasing].filter((channel) => !running.has(channel) && element?.style.getPropertyValue(engine.cssName(channel)) === engine.identityOf(channel));
2270
+ releasing.clear();
2271
+ if (element == null || channels.length === 0) return;
2272
+ for (const channel of channels) element.style.removeProperty(engine.cssName(channel));
2273
+ const style = element.ownerDocument.defaultView?.getComputedStyle(element);
2274
+ for (const channel of channels) {
2275
+ const underneath = style?.getPropertyValue(engine.cssName(channel));
2276
+ if (underneath != null && !isIdentityText(channel, underneath)) element.style.setProperty(engine.cssName(channel), engine.identityOf(channel));
2277
+ }
2278
+ };
2279
+ /**
2280
+ * Curve time an animation still has to play on its own clock (its keyframes
2281
+ * hold the end for END_HOLD_MS after the curve), or null where the engine
2282
+ * does not report it; a paused animation always has some left.
2283
+ */
2284
+ engine.remainingCurve = (animation) => {
2285
+ const timing = animation.effect?.getTiming?.();
2286
+ const current = animation.currentTime;
2287
+ if (timing == null || current == null) return animation.playState === "paused" ? Infinity : null;
2288
+ const left = Number(timing.duration) - END_HOLD_MS - Number(current);
2289
+ return animation.playState === "paused" ? Math.max(left, 1) : left;
2290
+ };
2291
+ }
2292
+ //#endregion
2293
+ //#region src/motion/engine/sampling.ts
2294
+ function installSampling(engine) {
2295
+ const { base, heldForFrame, now, pseudoElement, resting, running, segments, stale } = engine;
2296
+ /**
2297
+ * What identifies a channel's keyframes across calls of one task: each
2298
+ * moving property's curve object, offset and length, and each other
2299
+ * property's rest value. Null when a moving property has no shared curve
2300
+ * (a spring, a rebase, a jump).
2301
+ */
2302
+ engine.taskBakeKey = (channel, moving, from, end, devicePixel) => {
2303
+ const key = [
2304
+ channel,
2305
+ end - from,
2306
+ devicePixel
2307
+ ];
2308
+ for (const property of CHANNELS[channel]) {
2309
+ const segment = segments.get(property);
2310
+ if (!moving.includes(property)) key.push(property, resting[property]);
2311
+ else if (segment?.source != null && segment.jumps.length === 0) {
2312
+ key.push(property, segment.source, segment.start - from);
2313
+ key.push(segment.duration);
2314
+ } else return null;
2315
+ }
2316
+ return key;
2317
+ };
2318
+ /** `sampleTimes`, shared by the calls of a task that play one curve. */
2319
+ engine.sharedSampleTimes = (property, from, end, tolerance) => {
2320
+ const segment = segments.get(property);
2321
+ if (segment?.source == null || segment.jumps.length > 0) return engine.sampleTimes(property, from, end, tolerance);
2322
+ const key = [
2323
+ segment.source,
2324
+ segment.start - from,
2325
+ segment.duration,
2326
+ end - from,
2327
+ tolerance
2328
+ ];
2329
+ const { times } = bakesOfTask();
2330
+ const known = times.find((entry) => isSameKey(entry.key, key));
2331
+ if (known != null) return known.times.map((t) => t + from);
2332
+ const sampled = engine.sampleTimes(property, from, end, tolerance);
2333
+ times.push({
2334
+ key,
2335
+ times: sampled.map((t) => t - from)
2336
+ });
2337
+ return sampled;
2338
+ };
2339
+ engine.sampleTimes = (property, from, to, tolerance) => {
2340
+ const segment = segments.get(property);
2341
+ if (segment == null) return [];
2342
+ const begin = Math.max(from, segment.start);
2343
+ const end = Math.min(to, segment.start + segment.duration);
2344
+ if (end <= begin) return [];
2345
+ const times = [begin];
2346
+ const value = (t) => engine.curveAt(property, t);
2347
+ const breaks = segment.jumps.map((j) => segment.start + j).filter((t) => t > begin && t < end);
2348
+ const edges = [
2349
+ begin,
2350
+ ...breaks,
2351
+ end
2352
+ ];
2353
+ for (let e = 0; e + 1 < edges.length; e++) {
2354
+ const a = edges[e];
2355
+ const b = edges[e + 1];
2356
+ const steps = Math.max(1, Math.ceil((b - a) / SAMPLE_GRID_MS));
2357
+ const split = (t0, t1, depth) => {
2358
+ const v0 = value(t0);
2359
+ const v1 = t1 === b && breaks.includes(b) ? engine.valueBefore(property, b) : value(t1);
2360
+ let worst = 0;
2361
+ for (const f of [
2362
+ .25,
2363
+ .5,
2364
+ .75
2365
+ ]) {
2366
+ const t = t0 + (t1 - t0) * f;
2367
+ worst = Math.max(worst, Math.abs(value(t) - (v0 + (v1 - v0) * f)));
2368
+ }
2369
+ if (worst > tolerance && depth < 10 && t1 - t0 > .25) {
2370
+ const mid = (t0 + t1) / 2;
2371
+ split(t0, mid, depth + 1);
2372
+ split(mid, t1, depth + 1);
2373
+ } else times.push(t1);
2374
+ };
2375
+ for (let i = 0; i < steps; i++) split(a + (b - a) * i / steps, a + (b - a) * (i + 1) / steps, 0);
2376
+ }
2377
+ return times;
2378
+ };
2379
+ /**
2380
+ * Whether the pseudo-element's stylesheet shows the channel's resting
2381
+ * value: its base, to within the sampling tolerance, which no frame shows.
2382
+ * A curve that settles to a threshold ends that close to its target.
2383
+ */
2384
+ engine.atBase = (channel) => CHANNELS[channel].every((property) => {
2385
+ const value = base[property];
2386
+ return value != null && Math.abs(engine.finalValue(property) - value) <= SAMPLE_TOLERANCE[property];
2387
+ });
2388
+ /**
2389
+ * The first hold dropped at `base` checks, in development, that the
2390
+ * stylesheet shows it. It reads after the cancel and off the motion's task,
2391
+ * so it adds no style read to a frame that starts a motion.
2392
+ */
2393
+ engine.checkBase = (channel) => {
2394
+ if (!isDevBuild() || engine.baseChecked) return;
2395
+ engine.baseChecked = true;
2396
+ setTimeout(() => {
2397
+ if (engine.target == null) return;
2398
+ const shown = getComputedStyle(engine.target, pseudoElement).getPropertyValue(channel);
2399
+ const expected = format(channel, (p) => base[p] ?? IDENTITY[p]);
2400
+ if (!sameShown(channel, shown, expected)) devWarn("Astryx motion", `the ${pseudoElement} stylesheet shows ${channel} ${shown || "(unset)"}, not its declared base ${expected}, so it shows the wrong value at rest. Make \`base\` match the stylesheet.`);
2401
+ }, 0);
2402
+ };
2403
+ /**
2404
+ * A pseudo-element's resting value, held by a static filling animation,
2405
+ * unless its stylesheet shows it (`base`).
2406
+ */
2407
+ engine.hold = (channel, time) => {
2408
+ if (engine.target == null) return;
2409
+ if (engine.atBase(channel)) {
2410
+ engine.checkBase(channel);
2411
+ return;
2412
+ }
2413
+ const value = format(channel, engine.finalValue);
2414
+ const animation = quietFinished(engine.target.animate([{ [channel]: value }, { [channel]: value }], {
2415
+ duration: 1,
2416
+ fill: "both",
2417
+ pseudoElement
2418
+ }));
2419
+ animation.startTime = time;
2420
+ running.set(channel, animation);
2421
+ };
2422
+ engine.replaceIn = (group, segment, next) => {
2423
+ const index = group.segments.indexOf(segment);
2424
+ if (index >= 0) group.segments[index] = next;
2425
+ else group.segments.push(next);
2426
+ };
2427
+ engine.markStale = (channel) => {
2428
+ stale.add(channel);
2429
+ if (!engine.healQueued) {
2430
+ engine.healQueued = true;
2431
+ queueMicrotask(engine.healStale);
2432
+ }
2433
+ };
2434
+ engine.healStale = () => {
2435
+ engine.healQueued = false;
2436
+ if (stale.size === 0) return;
2437
+ const properties = [...stale].filter((channel) => !heldForFrame.has(channel)).flatMap((channel) => CHANNELS[channel]);
2438
+ stale.clear();
2439
+ engine.commit(properties, now());
2440
+ };
2441
+ }
2442
+ //#endregion
2443
+ //#region src/motion/themeTempo.ts
2444
+ /**
2445
+ * @file themeTempo.ts
2446
+ * @input An element on the page
2447
+ * @output `themeTempo(element)`: the tempo of the theme the element is in
2448
+ * @position Motion foundation; resolveMotion.ts scales a motion role by it,
2449
+ * and the pager scales its settle by it, which no role names
2450
+ *
2451
+ * A theme that sets `tempo` writes it, clamped, to the private custom
2452
+ * property `--_astryx-motion-tempo` beside its duration tokens. An
2453
+ * adaptation rule writes it where its condition holds, and a nested theme
2454
+ * that sets no tempo inherits it. A layer whose durations come from a
2455
+ * duration scale writes a tempo of 1, so its springs keep its own pace. One
2456
+ * read of a custom property forces no layout.
2457
+ * Nothing here imports a theme module, runs on import or runs on the server.
2458
+ */
2459
+ /** The property a theme that sets `tempo` writes (theme/themeMotion.ts). */
2460
+ const TEMPO_PROPERTY = "--_astryx-motion-tempo";
2461
+ /**
2462
+ * The tempo motion on `element` plays at: the one its theme or an adaptation
2463
+ * rule sets, else 1. Without an element in a document, or with a value that
2464
+ * is not a positive number, it is 1.
2465
+ */
2466
+ function themeTempo(element) {
2467
+ const view = element?.ownerDocument?.defaultView;
2468
+ if (element == null || view == null) return 1;
2469
+ const text = view.getComputedStyle(element).getPropertyValue(TEMPO_PROPERTY).trim();
2470
+ const tempo = text === "" ? NaN : Number(text);
2471
+ return Number.isFinite(tempo) && tempo > 0 ? tempo : 1;
2472
+ }
2473
+ //#endregion
2474
+ //#region src/motion/resolveMotion.ts
2475
+ /**
2476
+ * The roles the tempo leaves as measured: the parts that follow a finger,
2477
+ * and ProgressBar's busy loop.
2478
+ */
2479
+ const FIXED_ROLES = /* @__PURE__ */ new Set([
2480
+ "springs.fingerTracking",
2481
+ "switchControl.tracking",
2482
+ "progress.reducedMotionPulseMs"
2483
+ ]);
2484
+ /** Each role spring at each tempo, so a role resolves to one object per tempo. */
2485
+ const springsAtTempo = /* @__PURE__ */ new WeakMap();
2486
+ /**
2487
+ * `spring` at `tempo`. In each of its forms, the undamped period grows by the
2488
+ * tempo and the damping ratio stays. So the motion keeps its shape and takes
2489
+ * `tempo` times as long.
2490
+ */
2491
+ function springAtTempo(spring, tempo) {
2492
+ let byTempo = springsAtTempo.get(spring);
2493
+ if (byTempo == null) {
2494
+ byTempo = /* @__PURE__ */ new Map();
2495
+ springsAtTempo.set(spring, byTempo);
2496
+ }
2497
+ let scaled = byTempo.get(tempo);
2498
+ if (scaled == null) {
2499
+ if ("response" in spring) scaled = {
2500
+ response: spring.response * tempo,
2501
+ dampingRatio: spring.dampingRatio
2502
+ };
2503
+ else if ("duration" in spring) scaled = {
2504
+ duration: spring.duration * tempo,
2505
+ bounce: spring.bounce
2506
+ };
2507
+ else scaled = {
2508
+ ...spring.mass == null ? null : { mass: spring.mass },
2509
+ stiffness: spring.stiffness / (tempo * tempo),
2510
+ damping: spring.damping / tempo
2511
+ };
2512
+ byTempo.set(tempo, scaled);
2513
+ }
2514
+ return scaled;
2515
+ }
2516
+ function resolveMotion(element, leafOrGroup, key) {
2517
+ const value = key === void 0 ? leafOrGroup : leafOrGroup[key];
2518
+ const role = key === void 0 ? motionRoleOf(leafOrGroup) : motionRoleIn(leafOrGroup, key);
2519
+ if (role == null || role.kind === "curve" || FIXED_ROLES.has(role.id)) return value;
2520
+ const tempo = themeTempo(element);
2521
+ if (tempo === 1) return value;
2522
+ if (typeof value === "number") return value * tempo;
2523
+ return isSpring(value) ? springAtTempo(value, tempo) : value;
2524
+ }
2525
+ //#endregion
2526
+ //#region src/motion/engine/segments.ts
2527
+ function installSegments(engine) {
2528
+ engine.springSegment = (owner, property, start, to, spring, velocity) => engine.springFrom(owner, property, start, engine.valueAt(property, start), velocity, to, resolveMotion(engine.target, spring));
2529
+ /**
2530
+ * `resolved` is already at the theme's tempo. A restart passes a segment's
2531
+ * spring as it is.
2532
+ */
2533
+ engine.springFrom = (owner, property, start, from, velocity, to, resolved) => {
2534
+ if (from === to && velocity === 0) return null;
2535
+ const curve = solveSpring(toSpring(resolved), {
2536
+ from,
2537
+ to,
2538
+ velocity
2539
+ });
2540
+ return {
2541
+ start,
2542
+ duration: Math.min(MAX_DURATION_MS, curve.settleTime(SETTLE_THRESHOLD[property]) * 1e3),
2543
+ target: to,
2544
+ at: (t) => curve.value(t / 1e3),
2545
+ speed: (t) => curve.velocity(t / 1e3),
2546
+ jumps: [],
2547
+ owner,
2548
+ spring: resolved
2549
+ };
2550
+ };
2551
+ /** The retarget of `additive`: the old curve plus a spring of the difference. */
2552
+ engine.additiveSegment = (owner, property, start, to, spring, old) => {
2553
+ const oldEnd = old.start + old.duration;
2554
+ const resolved = resolveMotion(engine.target, spring);
2555
+ const delta = solveSpring(toSpring(resolved), {
2556
+ from: 0,
2557
+ to: to - old.target,
2558
+ velocity: 0
2559
+ });
2560
+ const deltaMs = Math.min(MAX_DURATION_MS, delta.settleTime(SETTLE_THRESHOLD[property]) * 1e3);
2561
+ const ownAt = (t) => t >= deltaMs ? to - old.target : delta.value(t / 1e3);
2562
+ const oldAt = (time) => time >= oldEnd ? old.target : old.at(Math.max(0, time - old.start));
2563
+ return {
2564
+ start,
2565
+ duration: Math.min(MAX_DURATION_MS, Math.max(oldEnd - start, deltaMs)),
2566
+ target: to,
2567
+ at: (t) => oldAt(start + t) + ownAt(t),
2568
+ speed: (t) => (start + t >= oldEnd ? 0 : old.speed(start + t - old.start)) + (t >= deltaMs ? 0 : delta.velocity(t / 1e3)),
2569
+ jumps: old.jumps.map((jump) => old.start + jump - start).filter((jump) => jump > 0),
2570
+ owner,
2571
+ spring: resolved,
2572
+ isAdditive: true
2573
+ };
2574
+ };
2575
+ /**
2576
+ * `additive` for a played curve: the old curve plus the new curve's shape,
2577
+ * scaled to the difference between the two targets.
2578
+ */
2579
+ engine.additiveCurveSegment = (owner, start, curve, old) => {
2580
+ const from = curve.at(0);
2581
+ const to = curve.at(curve.duration);
2582
+ const scale = (to - old.target) / (to - from);
2583
+ const ms = Math.min(MAX_DURATION_MS, curve.duration * 1e3);
2584
+ const oldEnd = old.start + old.duration;
2585
+ const oldAt = (time) => time >= oldEnd ? old.target : old.at(Math.max(0, time - old.start));
2586
+ return {
2587
+ start,
2588
+ duration: Math.min(MAX_DURATION_MS, Math.max(oldEnd - start, ms)),
2589
+ target: to,
2590
+ at: (t) => oldAt(start + t) + (t >= ms ? to - old.target : (curve.at(t / 1e3) - from) * scale),
2591
+ speed: (t) => (start + t >= oldEnd ? 0 : old.speed(start + t - old.start)) + (t >= ms ? 0 : curve.velocity(t / 1e3) * scale),
2592
+ jumps: old.jumps.map((jump) => old.start + jump - start).filter((jump) => jump > 0),
2593
+ owner
2594
+ };
2595
+ };
2596
+ engine.fadeSegment = (owner, start, stops, jumps = []) => {
2597
+ registerReducedMotionCrossFade();
2598
+ const ease = cubicBezier(resolveMotion(engine.target, reducedMotionCrossFade.curve));
2599
+ const duration = stops[stops.length - 1].at;
2600
+ const at = (t) => {
2601
+ for (let i = 0; i + 1 < stops.length; i++) {
2602
+ const a = stops[i];
2603
+ const b = stops[i + 1];
2604
+ if (t < b.at || i + 2 === stops.length) {
2605
+ if (b.at === a.at) return b.value;
2606
+ const p = Math.min(1, Math.max(0, (t - a.at) / (b.at - a.at)));
2607
+ return a.value + (b.value - a.value) * ease(p);
2608
+ }
2609
+ }
2610
+ return stops[stops.length - 1].value;
2611
+ };
2612
+ return {
2613
+ start,
2614
+ duration,
2615
+ target: stops[stops.length - 1].value,
2616
+ at,
2617
+ speed: (t) => (at(t + .5) - at(Math.max(0, t - .5))) / (t >= .5 ? 1 : .5 + t) * 1e3,
2618
+ jumps,
2619
+ owner,
2620
+ isFade: true
2621
+ };
2622
+ };
2623
+ }
2624
+ //#endregion
2625
+ //#region src/motion/engine/shownWatch.ts
2626
+ function installShownWatch(engine) {
2627
+ const { framePage, heldForFrame, requestFrame, resting, retireLooks, retireTimers, segments, shown, stale, waitKey } = engine;
2628
+ /**
2629
+ * Whether no frame comes. A hidden page draws none. The frame source of a
2630
+ * hidden page draws none either, while the element shows elsewhere (a
2631
+ * Picture-in-Picture window's opener).
2632
+ */
2633
+ engine.isPageHidden = () => engine.target?.ownerDocument.visibilityState === "hidden" || framePage?.visibilityState === "hidden";
2634
+ engine.forgetShown = () => {
2635
+ shown.clear();
2636
+ engine.syncWaiting();
2637
+ engine.stopWatchingHidden?.();
2638
+ };
2639
+ engine.syncWaiting = () => {
2640
+ let first = Infinity;
2641
+ for (const entry of shown.values()) first = Math.min(first, entry.since);
2642
+ if (first === Infinity) waitingCalls.delete(waitKey);
2643
+ else waitingCalls.set(waitKey, first);
2644
+ };
2645
+ /**
2646
+ * Rebuilds channels from their last calls' times, as those calls would
2647
+ * have rebuilt them: the same keyframes and start time.
2648
+ */
2649
+ engine.rebuildOnCallClocks = (channels) => {
2650
+ for (const time of new Set(channels.map(([, at]) => at))) engine.commit(channels.filter(([, at]) => at === time).flatMap(([channel]) => CHANNELS[channel]), time);
2651
+ };
2652
+ engine.flushWaiting = () => {
2653
+ const channels = [...heldForFrame];
2654
+ heldForFrame.clear();
2655
+ engine.rebuildOnCallClocks(channels);
2656
+ };
2657
+ /**
2658
+ * A hidden page draws no frames and shows nothing, so its calls keep their
2659
+ * own clock, as the timers do (scheduleRetire). A page that goes hidden
2660
+ * before the frame forgets what it showed and rebuilds what waits.
2661
+ */
2662
+ engine.watchHidden = () => {
2663
+ const pages = [...new Set([engine.target?.ownerDocument, framePage].filter((page) => page != null))];
2664
+ if (engine.stopWatchingHidden != null || pages.length === 0) return;
2665
+ const onChange = () => {
2666
+ if (engine.isPageHidden()) {
2667
+ engine.forgetShown();
2668
+ engine.flushWaiting();
2669
+ }
2670
+ };
2671
+ for (const page of pages) page.addEventListener("visibilitychange", onChange);
2672
+ engine.stopWatchingHidden = () => {
2673
+ for (const page of pages) page.removeEventListener("visibilitychange", onChange);
2674
+ engine.stopWatchingHidden = null;
2675
+ };
2676
+ };
2677
+ /**
2678
+ * Holds a call's channels for the frame that commits it, which rebuilds
2679
+ * them (lookAtShown). Until then the old curve plays on, and no end look
2680
+ * retires it.
2681
+ */
2682
+ engine.deferRebuild = (changed, time) => {
2683
+ for (const property of changed) {
2684
+ const channel = CHANNEL_OF[property];
2685
+ const isNew = !heldForFrame.has(channel);
2686
+ heldForFrame.set(channel, time);
2687
+ if (!isNew) continue;
2688
+ stale.delete(channel);
2689
+ clearTimeout(retireTimers.get(channel));
2690
+ retireTimers.delete(channel);
2691
+ clearTimeout(retireLooks.get(channel));
2692
+ retireLooks.delete(channel);
2693
+ }
2694
+ };
2695
+ /** A rebuild before that frame commits the channel's calls at once. */
2696
+ engine.commitWaitingNow = (channel) => {
2697
+ if (!heldForFrame.delete(channel)) return;
2698
+ for (const property of CHANNELS[channel]) shown.delete(property);
2699
+ engine.syncWaiting();
2700
+ };
2701
+ /**
2702
+ * Rebuilds a waiting channel from what the screen shows, after a rebase
2703
+ * moved the element under it. The old curve plays on, shifted with the
2704
+ * element, until the frame that commits the call.
2705
+ */
2706
+ engine.rebuildShown = (channel, time) => {
2707
+ const model = /* @__PURE__ */ new Map();
2708
+ const rests = /* @__PURE__ */ new Map();
2709
+ for (const property of CHANNELS[channel]) {
2710
+ const entry = shown.get(property);
2711
+ if (entry == null) continue;
2712
+ model.set(property, segments.get(property));
2713
+ rests.set(property, resting[property]);
2714
+ if (entry.segment == null) {
2715
+ segments.delete(property);
2716
+ resting[property] = entry.resting + entry.offset;
2717
+ } else segments.set(property, engine.shifted(entry.segment, entry.offset));
2718
+ }
2719
+ const callTime = heldForFrame.get(channel);
2720
+ heldForFrame.delete(channel);
2721
+ try {
2722
+ engine.rebuild(channel, time);
2723
+ } finally {
2724
+ for (const [property, segment] of model) if (segment == null) segments.delete(property);
2725
+ else segments.set(property, segment);
2726
+ for (const [property, rest] of rests) resting[property] = rest;
2727
+ if (callTime != null) heldForFrame.set(channel, callTime);
2728
+ }
2729
+ };
2730
+ /**
2731
+ * Notes what the screen shows of each property that a call continuing
2732
+ * motion changes, before the call replaces its curve. The call's channels
2733
+ * then wait for the frame that commits it, which rebuilds them
2734
+ * (lookAtShown). That holds for a call in a frame callback of the page's.
2735
+ * A call from rest, a call on an explicit clock and a call in an
2736
+ * animator's frame callback start on their frame already.
2737
+ */
2738
+ engine.noteShown = (properties, time, group, at) => {
2739
+ if (group != null || at != null || frameNesting.depth > 0 || requestFrame == null || engine.target == null || typeof engine.target.animate !== "function" || engine.isPageHidden()) return false;
2740
+ const list = [...properties];
2741
+ if (list.some((property) => CHANNELS[CHANNEL_OF[property]].some((other) => {
2742
+ const segment = segments.get(other);
2743
+ return segment != null && engine.isHeld(segment);
2744
+ }))) return false;
2745
+ for (const property of list) {
2746
+ if (shown.has(property)) continue;
2747
+ shown.set(property, {
2748
+ segment: segments.get(property) ?? null,
2749
+ resting: resting[property],
2750
+ offset: 0,
2751
+ since: time
2752
+ });
2753
+ }
2754
+ engine.syncWaiting();
2755
+ engine.watchHidden();
2756
+ if (!engine.isShownLookQueued) {
2757
+ engine.isShownLookQueued = true;
2758
+ requestFrame(engine.lookAtShown);
2759
+ }
2760
+ return true;
2761
+ };
2762
+ /** The value and velocity that the screen shows of a property at `time`. */
2763
+ engine.shownAt = (entry, time) => {
2764
+ const { segment, offset } = entry;
2765
+ if (segment == null) return {
2766
+ value: entry.resting + offset,
2767
+ velocity: 0
2768
+ };
2769
+ const elapsed = time - segment.start;
2770
+ if (elapsed >= segment.duration) return {
2771
+ value: segment.target + offset,
2772
+ velocity: 0
2773
+ };
2774
+ const t = Math.max(0, elapsed);
2775
+ return {
2776
+ value: segment.at(t) + offset,
2777
+ velocity: segment.speed(t)
2778
+ };
2779
+ };
2780
+ engine.shifted = (segment, offset) => offset === 0 ? segment : {
2781
+ ...segment,
2782
+ target: segment.target + offset,
2783
+ at: (t) => segment.at(t) + offset
2784
+ };
2785
+ }
2786
+ //#endregion
2787
+ //#region src/motion/engine/startGroups.ts
2788
+ function installStartGroups(engine) {
2789
+ const { deferredCalls, now, pendingGroups, requestFrame, running, segments } = engine;
2790
+ /**
2791
+ * A call starts from rest when nothing on the channels it drives moves on
2792
+ * screen and nothing pins its clock (`at`). A curve still waiting for its
2793
+ * first frame counts as rest, as does one whose tail already shows as at
2794
+ * rest. Returns its start group, or null for an explicit start.
2795
+ */
2796
+ engine.beginGroup = (time, properties, at, start) => {
2797
+ if (engine.target == null || typeof engine.target.animate !== "function") return null;
2798
+ const channels = /* @__PURE__ */ new Set();
2799
+ for (const property of properties) channels.add(CHANNEL_OF[property]);
2800
+ if (at != null) {
2801
+ for (const channel of channels) for (const property of CHANNELS[channel]) {
2802
+ const group = segments.get(property)?.group;
2803
+ if (group != null && !group.resolved && at <= group.provisional) return group;
2804
+ }
2805
+ return null;
2806
+ }
2807
+ for (const channel of start === "commit" ? [] : channels) for (const property of CHANNELS[channel]) {
2808
+ const segment = segments.get(property);
2809
+ if (segment != null && time < engine.endOf(property, segment) && (segment.group == null || segment.group.resolved || engine.shownSince(property, segment) != null) && !engine.showsAtRest(property, segment, time)) return null;
2810
+ }
2811
+ let resolve = () => {};
2812
+ const started = new Promise((r) => {
2813
+ resolve = r;
2814
+ });
2815
+ return {
2816
+ provisional: time,
2817
+ fresh: false,
2818
+ segments: [],
2819
+ animations: [],
2820
+ channels: /* @__PURE__ */ new Set(),
2821
+ resolved: false,
2822
+ resolve,
2823
+ started
2824
+ };
2825
+ };
2826
+ /** Commits a call's changes, from rest when it has a start group. */
2827
+ engine.commitCall = (group, owner, changed, time, presented = false, waitsForFrame = false) => {
2828
+ if (group != null) for (const property of changed) {
2829
+ const segment = segments.get(property);
2830
+ if (segment != null && segment.owner === owner) {
2831
+ segment.group = group;
2832
+ group.segments.push(segment);
2833
+ }
2834
+ }
2835
+ if (presented && group != null && requestFrame != null) {
2836
+ const call = {
2837
+ group,
2838
+ changed
2839
+ };
2840
+ deferredCalls.push(call);
2841
+ requestFrame(() => requestFrame(() => engine.flushDeferredThrough(call)));
2842
+ return;
2843
+ }
2844
+ if (group == null && waitsForFrame) {
2845
+ engine.deferRebuild(changed, time);
2846
+ return;
2847
+ }
2848
+ engine.startCall(group, changed, time);
2849
+ };
2850
+ /** Creates the animations of the given waiting calls, in call order. */
2851
+ engine.startDeferred = (calls) => {
2852
+ for (const { group, changed } of calls) {
2853
+ const own = [];
2854
+ let handedTo = null;
2855
+ for (const property of changed) {
2856
+ const holder = CHANNELS[CHANNEL_OF[property]].map((other) => segments.get(other)?.group).find((waiting) => waiting != null && waiting !== group && deferredCalls.some((call) => call.group === waiting));
2857
+ if (holder == null) {
2858
+ own.push(property);
2859
+ continue;
2860
+ }
2861
+ const segment = segments.get(property);
2862
+ if (segment != null && segment.group === group) {
2863
+ segment.start += holder.provisional - group.provisional;
2864
+ segment.group = holder;
2865
+ holder.segments.push(segment);
2866
+ group.segments.splice(group.segments.indexOf(segment), 1);
2867
+ handedTo = holder;
2868
+ }
2869
+ }
2870
+ if (own.length === 0 && handedTo != null) {
2871
+ const adopter = handedTo;
2872
+ group.adoptedBy = adopter;
2873
+ adopter.started.then((start) => engine.resolveGroup(group, start));
2874
+ continue;
2875
+ }
2876
+ engine.startCall(group, own, group.provisional);
2877
+ }
2878
+ };
2879
+ /** Creates the animations of every waiting call, in call order. */
2880
+ engine.flushDeferred = () => {
2881
+ engine.startDeferred(deferredCalls.splice(0));
2882
+ };
2883
+ /**
2884
+ * A call's second frame: it starts, with every call queued before it (in
2885
+ * call order), unless another change created it already.
2886
+ */
2887
+ engine.flushDeferredThrough = (call) => {
2888
+ const index = deferredCalls.indexOf(call);
2889
+ if (index >= 0) engine.startDeferred(deferredCalls.splice(0, index + 1));
2890
+ };
2891
+ engine.startCall = (group, changed, time) => {
2892
+ engine.callGroup = group;
2893
+ try {
2894
+ engine.commit(changed, time);
2895
+ } finally {
2896
+ engine.callGroup = null;
2897
+ }
2898
+ if (group == null) return;
2899
+ if (group.animations.length === 0) {
2900
+ engine.resolveGroup(group, group.provisional);
2901
+ return;
2902
+ }
2903
+ pendingGroups.add(group);
2904
+ group.fresh = true;
2905
+ group.task = markTask(now(), now);
2906
+ if (group.nextFrame === true) group.task.nextFrame = true;
2907
+ group.madeInFrame = frameNesting.depth > 0;
2908
+ queueMicrotask(() => {
2909
+ group.fresh = false;
2910
+ });
2911
+ for (const animation of group.animations) animation.ready?.catch(() => {});
2912
+ const ready = group.animations[0].ready;
2913
+ if (ready == null || typeof ready.then !== "function") {
2914
+ engine.resolveGroup(group, group.provisional);
2915
+ return;
2916
+ }
2917
+ requestFrame?.((frame) => {
2918
+ engine.syncGroup(group);
2919
+ group.framed = true;
2920
+ if (group.resolved) return;
2921
+ const at = frameTime(frame, now);
2922
+ if (group.madeInFrame !== true && (group.task?.nextFrame === true || at - (group.task?.first ?? group.provisional) <= 34) && group.animations.some((animation) => animation.startTime == null && animation.playState === "running")) engine.resolveGroup(group, at);
2923
+ if (!group.resolved) for (const channel of group.channels) {
2924
+ const animation = running.get(channel);
2925
+ if (animation != null && group.animations.includes(animation) && animation.startTime == null && animation.playState === "running") (group.latest ??= /* @__PURE__ */ new Map()).set(channel, at);
2926
+ }
2927
+ });
2928
+ ready.then(() => engine.syncGroup(group), () => engine.settleCancelled(group));
2929
+ };
2930
+ }
2931
+ //#endregion
2932
+ //#region src/motion/engine/state.ts
2933
+ function initEngineState(engine) {
2934
+ const { options } = engine;
2935
+ const now = options.now ?? motionNow;
2936
+ engine.now = now;
2937
+ const frameSource = options.requestFrame ?? (typeof requestAnimationFrame === "function" ? (callback) => {
2938
+ requestAnimationFrame((frame) => callback(frame));
2939
+ } : null);
2940
+ engine.frameSource = frameSource;
2941
+ engine.requestFrame = frameSource == null ? null : (callback) => {
2942
+ frameSource((frame) => {
2943
+ frameNesting.depth += 1;
2944
+ try {
2945
+ callback(frame);
2946
+ } finally {
2947
+ frameNesting.depth -= 1;
2948
+ }
2949
+ });
2950
+ };
2951
+ const pseudoElement = options.pseudoElement;
2952
+ engine.pseudoElement = pseudoElement;
2953
+ const customProperty = options.customProperty;
2954
+ engine.customProperty = customProperty;
2955
+ const companion = customProperty?.companion;
2956
+ engine.companion = companion;
2957
+ if (customProperty != null) registerCustomProperty(customProperty.name, customProperty.syntax);
2958
+ if (companion != null) registerCustomProperty(companion.name, companion.syntax);
2959
+ engine.customUnit = customProperty?.syntax === "<number>" ? "" : "px";
2960
+ engine.isCoarsePointer = defaultIsCoarsePointer;
2961
+ engine.resting = {
2962
+ ...IDENTITY,
2963
+ ...expand(options.initial ?? {})
2964
+ };
2965
+ engine.base = expand(options.base ?? {});
2966
+ engine.segments = /* @__PURE__ */ new Map();
2967
+ engine.running = /* @__PURE__ */ new Map();
2968
+ /** Drops a finished, still-filling animation once the main thread runs. */
2969
+ engine.retireTimers = /* @__PURE__ */ new Map();
2970
+ /**
2971
+ * Animations whose retire looks again at the next frame (scheduleRetire):
2972
+ * each its own, so one still waiting for a replaced animation does not
2973
+ * stand in for the next.
2974
+ */
2975
+ engine.retireFrames = /* @__PURE__ */ new Set();
2976
+ /** The timer that starts those looks a frame before a curve's end. */
2977
+ engine.retireLooks = /* @__PURE__ */ new Map();
2978
+ engine.touched = /* @__PURE__ */ new Set();
2979
+ /**
2980
+ * The stylesheet's opacity a Reduce Motion dip borrowed because no call
2981
+ * owned opacity; the dip runs from and back to it, then hands it back.
2982
+ */
2983
+ engine.borrowedOpacity = null;
2984
+ engine.target = null;
2985
+ /** Calls from rest whose start still waits for the browser's commit. */
2986
+ engine.pendingGroups = /* @__PURE__ */ new Set();
2987
+ /** atRest() calls still waiting; dispose settles them. */
2988
+ engine.restWaits = /* @__PURE__ */ new Set();
2989
+ /** A detach that settles as an unmount at the end of the task, unless an attach follows. */
2990
+ engine.unmountQueued = false;
2991
+ /**
2992
+ * The node the latest attach(null) detached, while its unmount is pending:
2993
+ * a waiting Reduce Motion move lands there, so that node is left visible
2994
+ * where it was going.
2995
+ */
2996
+ engine.lastDetached = null;
2997
+ /** The call being committed, when it starts from rest. */
2998
+ engine.callGroup = null;
2999
+ /** The element reported to presentation.ts while translate moves. */
3000
+ engine.presented = null;
3001
+ /**
3002
+ * The translate the engine hit-tests the element at while the compositor
3003
+ * moves it: where the animation started, or where a `resolve` left it.
3004
+ */
3005
+ engine.hitTested = {
3006
+ x: 0,
3007
+ y: 0
3008
+ };
3009
+ engine.unpresent = null;
3010
+ /** Channels promoted to the element's compositing layer (will-change). */
3011
+ engine.promoted = /* @__PURE__ */ new Set();
3012
+ /** The element's own inline will-change, restored when promotion ends. */
3013
+ engine.ownWillChange = null;
3014
+ /** The stylesheet's will-change when there is no inline value. */
3015
+ engine.sheetWillChange = "";
3016
+ /**
3017
+ * Whether sheetWillChange holds a read of the element's current style: it
3018
+ * is read in the task after the element is attached, and again after each
3019
+ * demotion, so a promotion (a drag's first move) reads no style in its
3020
+ * own task.
3021
+ */
3022
+ engine.sheetWillChangeRead = false;
3023
+ /** The pending read of sheetWillChange, cancelled with its element. */
3024
+ engine.sheetReadTimer = null;
3025
+ /** The node whose promotion waits in sheetReads for its stylesheet. */
3026
+ engine.sheetReadQueuedFor = null;
3027
+ engine.demoteTimer = null;
3028
+ /** A pseudo-element is promoted through a custom property on its host. */
3029
+ engine.promotionProperty = pseudoElement == null ? null : `--astryx-motion-will-change-${pseudoElement.replace(/^:+/, "")}`;
3030
+ /** Channels whose identity the last node held inline (see `attach`). */
3031
+ engine.heldIdentity = /* @__PURE__ */ new Set();
3032
+ engine.presentedSource = {
3033
+ offset: (time = now()) => {
3034
+ engine.syncPending();
3035
+ return {
3036
+ x: engine.drawnTranslate("x", time) - engine.hitTested.x,
3037
+ y: engine.drawnTranslate("y", time) - engine.hitTested.y
3038
+ };
3039
+ },
3040
+ resolve: () => {
3041
+ if (engine.target == null) return;
3042
+ engine.syncPending();
3043
+ const time = now();
3044
+ writePresentedResolve(engine.target);
3045
+ engine.hitTested = {
3046
+ x: engine.drawnTranslate("x", time),
3047
+ y: engine.drawnTranslate("y", time)
3048
+ };
3049
+ }
3050
+ };
3051
+ engine.baseChecked = false;
3052
+ /**
3053
+ * Channels whose model a rebase moved while their animation still shows
3054
+ * the old curve. Any rebuild clears its channel; the end of the task
3055
+ * rebuilds the rest, so a frame never shows the old curve at the new rest.
3056
+ */
3057
+ engine.stale = /* @__PURE__ */ new Set();
3058
+ engine.healQueued = false;
3059
+ /** Channels left at identity whose stylesheet value is still to be read. */
3060
+ engine.releasing = /* @__PURE__ */ new Set();
3061
+ engine.releaseQueued = false;
3062
+ /** Calls with `start: 'presented'` waiting for their second frame. */
3063
+ engine.deferredCalls = [];
3064
+ engine.lastSpring = /* @__PURE__ */ new WeakMap();
3065
+ engine.shown = /* @__PURE__ */ new Map();
3066
+ /**
3067
+ * Channels whose rebuild waits for the frame that commits their call, with
3068
+ * the time of the last call on each.
3069
+ */
3070
+ engine.heldForFrame = /* @__PURE__ */ new Map();
3071
+ engine.isShownLookQueued = false;
3072
+ engine.stopWatchingHidden = null;
3073
+ /** The page whose frames the animator's own frame source draws. */
3074
+ engine.framePage = options.requestFrame == null && typeof document !== "undefined" ? document : null;
3075
+ /** This animator's entry in the waiting calls, from what still waits. */
3076
+ engine.waitKey = {};
3077
+ /** Reduced Motion landings still waiting for the element to be transparent. */
3078
+ engine.landings = /* @__PURE__ */ new Set();
3079
+ /** Calls a later call's landing carries: an interrupt does not settle them. */
3080
+ engine.carriedOwners = /* @__PURE__ */ new Set();
3081
+ /** Reduce Motion calls that named their own opacity. */
3082
+ engine.namedOpacity = /* @__PURE__ */ new WeakSet();
3083
+ /**
3084
+ * Where opacity was heading before a call took the waiting landings over:
3085
+ * an entrance by role that catches an exit fades back to what the exit
3086
+ * would have restored.
3087
+ */
3088
+ engine.headingBeforeTakeOver = null;
3089
+ engine.animator = { get element() {
3090
+ return engine.target;
3091
+ } };
3092
+ }
3093
+ function initLateEngineState(engine) {
3094
+ /** What the Reduce Motion planner reads of this animator. */
3095
+ engine.planView = {
3096
+ valueAt: engine.valueAt,
3097
+ opacityHeading: () => engine.headingBeforeTakeOver ?? engine.opacityHeading(),
3098
+ ownOpacity: () => engine.ownOpacity(),
3099
+ writesOwnOpacity: () => engine.writesOwnOpacity(),
3100
+ get borrowedOpacity() {
3101
+ return engine.borrowedOpacity;
3102
+ },
3103
+ get hasOpacityCurve() {
3104
+ return engine.segments.has("opacity");
3105
+ },
3106
+ get restingOpacity() {
3107
+ return engine.resting.opacity;
3108
+ },
3109
+ get hasPendingLanding() {
3110
+ return engine.landings.size > 0;
3111
+ },
3112
+ get hasWaitingDip() {
3113
+ return [...engine.landings].some((landing) => landing.fadeIn != null);
3114
+ }
3115
+ };
3116
+ }
3117
+ //#endregion
3118
+ //#region src/motion/animator.ts
3119
+ /**
3120
+ * Creates an animator for `element` (or for an element attached later).
3121
+ *
3122
+ * @example
3123
+ * ```
3124
+ * const animator = createMotionEngine(sheet);
3125
+ * // finger lifts at 1200 px/s heading for the detent at 0 (a component
3126
+ * // passes the spring of its motion role):
3127
+ * animator.animate({y: 0}, {spring: {response: 0.45, dampingRatio: 0.9}, velocity: {y: 1200}});
3128
+ * // the finger lands again: where is it right now?
3129
+ * const y = animator.get('y', event.timeStamp);
3130
+ * animator.stop(['y']);
3131
+ * ```
3132
+ */
3133
+ function createMotionEngine(element, options = {}) {
3134
+ const engine = {
3135
+ element,
3136
+ options
3137
+ };
3138
+ initEngineState(engine);
3139
+ installChannelText(engine);
3140
+ installCurveReads(engine);
3141
+ installSampling(engine);
3142
+ installRebuild(engine);
3143
+ installRetire(engine);
3144
+ installPromotion(engine);
3145
+ installStartGroups(engine);
3146
+ installGroupSync(engine);
3147
+ installHandles(engine);
3148
+ installSegments(engine);
3149
+ installShownWatch(engine);
3150
+ installLookAtShown(engine);
3151
+ installLandings(engine);
3152
+ installLandingRun(engine);
3153
+ installAttach(engine);
3154
+ installReadSet(engine);
3155
+ installAnimate(engine);
3156
+ installPlay(engine);
3157
+ installDecayStop(engine);
3158
+ installRebase(engine);
3159
+ initLateEngineState(engine);
3160
+ engine.animator.attach(element);
3161
+ return engine.animator;
3162
+ }
3163
+ //#endregion
3164
+ export { solveSpring as a, motionNow as i, resolveMotion as n, toSpring as o, SETTLE_THRESHOLD as r, createMotionEngine as t };