@vite-hub/ui 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (318) hide show
  1. package/README.md +105 -45
  2. package/dist/AttachmentTitle-BWw0ck0T.js +110 -0
  3. package/dist/BubbleContent-B1a4e3vE.js +45 -0
  4. package/dist/Chat-BZxkf3Tt.js +112 -0
  5. package/dist/ChatMessage-Blr5F-zi.js +94 -0
  6. package/dist/CodeBlockContent-BjXJm8lO.js +92 -0
  7. package/dist/CodeBlockTitle-DYrYpc1U.js +99 -0
  8. package/dist/CommentRow-ViZ7r8nr.js +86 -0
  9. package/dist/CopyButton-Dtg_Oc9_.js +115 -0
  10. package/dist/Markdown-_w7feFzl.js +70 -0
  11. package/dist/MarkdownCodeBlock-B4j7x0H6.js +127 -0
  12. package/dist/MarkdownImage-CJN3myt4.js +111 -0
  13. package/dist/MessageHeader-CJ9eBHSS.js +61 -0
  14. package/dist/MessageParts-FVyYZNsn.js +57 -0
  15. package/dist/MessageScrollerViewport-BaTlWLki.js +142 -0
  16. package/dist/MorphText-CYTndbyp.js +36 -0
  17. package/dist/RollNumber-Bo2tzfAp.js +49 -0
  18. package/dist/TraceTitle-Cp0y7RRD.js +133 -0
  19. package/dist/agent-session-BwZSMi4S.d.ts +312 -0
  20. package/dist/agent-session-DhlTKCQG.js +875 -0
  21. package/dist/{announce-B0DLwflT.js → announce-CJNXaYbT.js} +1 -3
  22. package/dist/appendItems-hQ4aBd9Q.js +4047 -0
  23. package/dist/attachment-BllgHx9Q.d.ts +124 -0
  24. package/dist/attachment-DQMJNfj0.js +35 -0
  25. package/dist/avatar-stack-Bj1xUkzY.d.ts +4 -0
  26. package/dist/avatar-stack-nQErr0qn.js +72 -0
  27. package/dist/bubble-D3M2_InY.js +32 -0
  28. package/dist/bubble-DmplVxLr.d.ts +64 -0
  29. package/dist/chat-DWdyMSuj.d.ts +13 -0
  30. package/dist/chat-message-QLHnX_ED.d.ts +11 -0
  31. package/dist/chat-session-BOj5L3Ey.d.ts +29 -0
  32. package/dist/chat-session-hjZRL6jY.js +43 -0
  33. package/dist/choices-input-DqgXl5a-.d.ts +97 -0
  34. package/dist/{vue-d2Td6uu2.js → client-BG-oCUtv-5i4sRwXP.js} +4156 -4156
  35. package/dist/code-block-Bp8y-XJp.d.ts +182 -0
  36. package/dist/code-block-CMERLfew.js +14 -0
  37. package/dist/code-view-26RY6dX8.js +137 -0
  38. package/dist/code-view-D8yYdFUc.d.ts +184 -0
  39. package/dist/{comment-composer-X7vJKh5b.js → comment-composer-BUt6vbnr.js} +175 -37
  40. package/dist/{comment-composer-DmDM3XYP.d.ts → comment-composer-CIsbz-78.d.ts} +7 -7
  41. package/dist/{comment-layer-KnnVfdRV.d.ts → comment-layer-BlVNORgj.d.ts} +17 -8
  42. package/dist/comment-layer-Ck2H24oJ.js +1206 -0
  43. package/dist/{comment-panel-DoLDOw3E.d.ts → comment-panel-Djx-KxVa.d.ts} +28 -21
  44. package/dist/comment-selection-bar-CbOEI98x.d.ts +33 -0
  45. package/dist/comment-selection-bar-CxPkJxVl.js +145 -0
  46. package/dist/comment-send.css +2 -2
  47. package/dist/{comment-thread-jqPx6aJ8.js → comment-thread-C_Q4UDaV.js} +74 -49
  48. package/dist/{comment-thread-DPV2kqA4.d.ts → comment-thread-X6gYMNay.d.ts} +11 -10
  49. package/dist/comments-B1itauwb.d.ts +52 -0
  50. package/dist/{comments-9MDSNm-9.js → comments-BaSrroRV.js} +32 -4
  51. package/dist/comments-BtD28xEn.js +390 -0
  52. package/dist/{comments-OWjNidkP.d.ts → comments-ZfV6IZs8.d.ts} +9 -2
  53. package/dist/components-CM5mZe0a.js +269 -0
  54. package/dist/{config-LRonN53j.js → config-CFwvNt4Y.js} +11 -30
  55. package/dist/{config-COSdO-ay.d.ts → config-JmsTI7gs.d.ts} +20 -33
  56. package/dist/connection-status-BVSH2ZVo.js +72 -0
  57. package/dist/connection-status-g62BTn44.d.ts +37 -0
  58. package/dist/copy-button-CRiXUFsl.d.ts +17 -0
  59. package/dist/device-frame-BW6IjB6P.d.ts +78 -0
  60. package/dist/device-frame-DDWoyB-G.js +515 -0
  61. package/dist/diffs-BTKaVnsb.d.ts +272 -0
  62. package/dist/diffs.d.ts +3 -0
  63. package/dist/{pierre-code-view-C49BVDrc.js → diffs.js} +147 -4223
  64. package/dist/drop-field-C0bXv1J-.d.ts +35 -0
  65. package/dist/drop-field-DKpYQ3tO.js +77 -0
  66. package/dist/editor-BsOTjnnN.d.ts +540 -0
  67. package/dist/{markdown-editor-D1irG9Xl.js → editor-DJPUs1nt.js} +833 -106
  68. package/dist/editor.d.ts +2 -0
  69. package/dist/editor.js +3 -0
  70. package/dist/element-BpjNQvZ0.js +6 -0
  71. package/dist/{file-tree-CRFIdtzw.js → file-tree-B4JKbp4r.js} +19 -18
  72. package/dist/{file-tree-DOtkeBaq.d.ts → file-tree-BdnKA6UA.d.ts} +33 -8
  73. package/dist/file-tree-DDSIafDn.d.ts +22 -0
  74. package/dist/file-tree-DS5shGSL.js +46 -0
  75. package/dist/file-tree.d.ts +2 -0
  76. package/dist/file-tree.js +1 -0
  77. package/dist/files-cuVXzWlx.js +30 -0
  78. package/dist/filter-search-C9e6sGij.d.ts +28 -0
  79. package/dist/filter-search-COZsoRiR.js +73 -0
  80. package/dist/formatCSSVariablePrefix-DLS1Ed1_.js +5 -0
  81. package/dist/headless-2IcUWHMq.d.ts +51 -0
  82. package/dist/headless.d.ts +7 -4
  83. package/dist/headless.js +5 -3
  84. package/dist/highlight.d.ts +2 -0
  85. package/dist/highlight.js +1 -0
  86. package/dist/{highlights-C2AbEdDI.js → highlights-8Al0-h-v.js} +3 -2
  87. package/dist/{hold-to-delete-BSMrpE-i.d.ts → hold-to-delete-CQc1JaG_.d.ts} +7 -0
  88. package/dist/{hold-to-delete-Cludb56v.js → hold-to-delete-CcQbfiQx.js} +111 -20
  89. package/dist/hold-to-delete-cOPqQ9FJ.js +85 -0
  90. package/dist/hold-to-delete-ksBE7wxc.d.ts +58 -0
  91. package/dist/index-9Z6Gwtnf.d.ts +77 -0
  92. package/dist/{index-B2cbt3py.d.ts → index-D3-uYBqH.d.ts} +1 -1
  93. package/dist/index.d.ts +165 -52
  94. package/dist/index.js +127 -671
  95. package/dist/markdown-BLALLOc0.d.ts +45 -0
  96. package/dist/{markdown-renderer-DMyYKeil.js → markdown-DDyOdYq_.js} +125 -127
  97. package/dist/{parts/components/markdown-renderer.d.ts → markdown-DkDxdpMU.d.ts} +10 -7
  98. package/dist/markdown-editor.d.ts +51 -98
  99. package/dist/markdown-editor.js +70 -3
  100. package/dist/markdown.d.ts +2 -0
  101. package/dist/markdown.js +1 -0
  102. package/dist/marker-CvcWZ3Zp.d.ts +59 -0
  103. package/dist/marker-DNL6QR3L.js +63 -0
  104. package/dist/message-BwivYIEl.js +13 -0
  105. package/dist/message-DEq4K5cQ.d.ts +72 -0
  106. package/dist/message-parts-B1BZFVKe.d.ts +3 -0
  107. package/dist/message-parts-CG3gNWn8.d.ts +11 -0
  108. package/dist/message-parts.d.ts +2 -0
  109. package/dist/message-parts.js +1 -0
  110. package/dist/message-scroller-D7AvM31v.d.ts +41 -0
  111. package/dist/motion/core.d.ts +4 -4
  112. package/dist/motion/core.js +5 -11
  113. package/dist/motion-BH6ShUam.d.ts +12 -0
  114. package/dist/{effects-C1zYpSpg.js → motion-core-BdTfxAhY.js} +1779 -55
  115. package/dist/{motion-core-Dh20n5Se.d.ts → motion-core-BfIefToe.d.ts} +30 -73
  116. package/dist/motion-dPwxx3Wk.js +76 -0
  117. package/dist/{install-C4LwcJda.js → motion-itHFtXwA.js} +1 -1
  118. package/dist/motion-list-BBbz93WT.js +49 -0
  119. package/dist/motion.d.ts +5 -14
  120. package/dist/motion.js +6 -13
  121. package/dist/nuxt-ui-CPdiTwwD.js +22 -0
  122. package/dist/nuxt.d.ts +9 -5
  123. package/dist/nuxt.js +28 -32
  124. package/dist/parts/components/agent-session.d.ts +2 -295
  125. package/dist/parts/components/agent-session.js +1 -659
  126. package/dist/parts/components/attachment.d.ts +2 -85
  127. package/dist/parts/components/attachment.js +3 -72
  128. package/dist/parts/components/avatar-stack.d.ts +3 -2
  129. package/dist/parts/components/avatar-stack.js +1 -60
  130. package/dist/parts/components/bubble.d.ts +2 -69
  131. package/dist/parts/components/bubble.js +3 -52
  132. package/dist/parts/components/chat-message.d.ts +3 -25
  133. package/dist/parts/components/chat-message.js +1 -50
  134. package/dist/parts/components/chat-session.d.ts +2 -26
  135. package/dist/parts/components/chat-session.js +1 -37
  136. package/dist/parts/components/chat.d.ts +3 -52
  137. package/dist/parts/components/chat.js +1 -105
  138. package/dist/parts/components/code-block.d.ts +2 -102
  139. package/dist/parts/components/code-block.js +4 -109
  140. package/dist/parts/components/code-view.d.ts +3 -268
  141. package/dist/parts/components/code-view.js +1 -1
  142. package/dist/parts/components/comment-composer.d.ts +1 -1
  143. package/dist/parts/components/comment-composer.js +1 -1
  144. package/dist/parts/components/comment-layer.d.ts +1 -1
  145. package/dist/parts/components/comment-layer.js +1 -634
  146. package/dist/parts/components/comment-panel.d.ts +2 -2
  147. package/dist/parts/components/comment-panel.js +22 -16
  148. package/dist/parts/components/comment-selection-bar.d.ts +2 -2
  149. package/dist/parts/components/comment-selection-bar.js +1 -116
  150. package/dist/parts/components/comment-thread.d.ts +1 -1
  151. package/dist/parts/components/comment-thread.js +1 -3
  152. package/dist/parts/components/comments.d.ts +8 -9
  153. package/dist/parts/components/comments.js +6 -9
  154. package/dist/parts/components/connection-status.d.ts +2 -36
  155. package/dist/parts/components/connection-status.js +1 -64
  156. package/dist/parts/components/copy-button.d.ts +3 -126
  157. package/dist/parts/components/copy-button.js +3 -226
  158. package/dist/parts/components/device-frame.d.ts +2 -128
  159. package/dist/parts/components/device-frame.js +1 -470
  160. package/dist/parts/components/drop-field.d.ts +2 -67
  161. package/dist/parts/components/drop-field.js +1 -76
  162. package/dist/parts/components/file-tree.d.ts +3 -2
  163. package/dist/parts/components/file-tree.js +3 -1
  164. package/dist/parts/components/filter-search.d.ts +2 -45
  165. package/dist/parts/components/filter-search.js +1 -57
  166. package/dist/parts/components/hold-to-delete.d.ts +2 -80
  167. package/dist/parts/components/hold-to-delete.js +1 -75
  168. package/dist/parts/components/markdown.d.ts +3 -45
  169. package/dist/parts/components/markdown.js +1 -46
  170. package/dist/parts/components/marker.d.ts +2 -32
  171. package/dist/parts/components/marker.js +1 -22
  172. package/dist/parts/components/message-parts.d.ts +3 -25
  173. package/dist/parts/components/message-parts.js +1 -45
  174. package/dist/parts/components/message.d.ts +2 -32
  175. package/dist/parts/components/message.js +3 -22
  176. package/dist/parts/components/motion-list.d.ts +2 -40
  177. package/dist/parts/components/motion-list.js +1 -41
  178. package/dist/parts/components/motion.d.ts +5 -118
  179. package/dist/parts/components/motion.js +4 -171
  180. package/dist/parts/components/patch-parsers.d.ts +1 -1
  181. package/dist/parts/components/progress.d.ts +2 -39
  182. package/dist/parts/components/progress.js +1 -53
  183. package/dist/parts/components/prompt-input.d.ts +2 -134
  184. package/dist/parts/components/prompt-input.js +1 -253
  185. package/dist/parts/components/relative-time.d.ts +2 -71
  186. package/dist/parts/components/relative-time.js +1 -1
  187. package/dist/parts/components/status.d.ts +2 -58
  188. package/dist/parts/components/status.js +1 -47
  189. package/dist/parts/components/sync-status.d.ts +2 -22
  190. package/dist/parts/components/sync-status.js +1 -48
  191. package/dist/parts/components/tool-list.d.ts +2 -28
  192. package/dist/parts/components/tool-list.js +1 -118
  193. package/dist/parts/components/trace-run.d.ts +2 -25
  194. package/dist/parts/components/trace-run.js +1 -89
  195. package/dist/parts/components/trace.d.ts +2 -59
  196. package/dist/parts/components/trace.js +1 -76
  197. package/dist/parts/composables/attachments.js +75 -1
  198. package/dist/parts/headless/choices-input.d.ts +2 -2
  199. package/dist/parts/headless/choices-input.js +49 -37
  200. package/dist/parts/headless/comments.d.ts +1 -1
  201. package/dist/parts/headless/comments.js +1 -1
  202. package/dist/parts/headless/message-scroller.d.ts +2 -2
  203. package/dist/parts/headless/message-scroller.js +211 -309
  204. package/dist/parts/headless/relative-time.d.ts +2 -0
  205. package/dist/parts/headless/relative-time.js +1 -0
  206. package/dist/parts/workspace/browser-support-notice.js +6 -5
  207. package/dist/parts/workspace/connect-panel.js +1 -1
  208. package/dist/parts/workspace/runners/web-container.js +2 -2
  209. package/dist/parts/workspace/workspace-bar.d.ts +1 -1
  210. package/dist/parts/workspace/workspace-bar.js +1 -1
  211. package/dist/parts/workspace/workspace-boot-status.d.ts +1 -1
  212. package/dist/parts/workspace/workspace-boot-status.js +1 -206
  213. package/dist/parts/workspace/workspace-editor-head.d.ts +1 -1
  214. package/dist/parts/workspace/workspace-editor-head.js +1 -1
  215. package/dist/parts/workspace/workspace-editor.d.ts +2 -2
  216. package/dist/parts/workspace/workspace-examples.js +1 -1
  217. package/dist/parts/workspace/workspace-file-tree.d.ts +1 -1
  218. package/dist/parts/workspace/workspace-file-tree.js +3 -2
  219. package/dist/parts/workspace/workspace-guide.js +1 -1
  220. package/dist/parts/workspace/workspace-preview.d.ts +1 -1
  221. package/dist/parts/workspace/workspace-preview.js +14 -12
  222. package/dist/parts/workspace/workspace-shell.d.ts +1 -1
  223. package/dist/parts/workspace/workspace-shell.js +11 -11
  224. package/dist/parts/workspace/workspace-sidebar.d.ts +2 -2
  225. package/dist/parts/workspace/workspace-sidebar.js +2 -2
  226. package/dist/parts/workspace/workspace-start.js +1 -1
  227. package/dist/parts/workspace/workspace-steps.js +1 -1
  228. package/dist/parts/workspace/workspace.d.ts +3 -3
  229. package/dist/parts/workspace/workspace.js +5 -5
  230. package/dist/press-BuEC-XvZ.d.ts +83 -0
  231. package/dist/progress-Ch0fA-bf.d.ts +8 -0
  232. package/dist/progress-D_9sG648.js +47 -0
  233. package/dist/prompt-input-CRXEJBAK.js +412 -0
  234. package/dist/prompt-input-j4OFTF5p.d.ts +116 -0
  235. package/dist/relative-time-BnJfjeEm.js +131 -0
  236. package/dist/relative-time-BuP-Gvzn.d.ts +43 -0
  237. package/dist/{relative-time-DJnw45tr.js → relative-time-Dz2DR4eb.js} +64 -114
  238. package/dist/relative-time-grHFu1kY.d.ts +11 -0
  239. package/dist/{ring-GaJsg32c.js → ring-DoL9jivj.js} +1 -2
  240. package/dist/runtime/nuxt-plugin.js +2 -5
  241. package/dist/{shiki-CbfEu_Az.js → shiki-CxzM_xNo.js} +3 -2
  242. package/dist/stand-ins-CuKM1UH1.js +339 -0
  243. package/dist/status-B2Yhrwv8.js +67 -0
  244. package/dist/status-ySiRa-8O.d.ts +38 -0
  245. package/dist/{stream-tokenizer-ByC3l0HQ.js → stream-tokenizer-BsjV6wxW.js} +1 -1
  246. package/dist/styles.css +4343 -3403
  247. package/dist/sync-status-BRroyOre.js +59 -0
  248. package/dist/sync-status-D4KdGO6y.d.ts +35 -0
  249. package/dist/theme.css +3 -0
  250. package/dist/theme.d.ts +14 -0
  251. package/dist/theme.js +19 -8
  252. package/dist/{themes-DKugPHlg.js → themes-B0_ioVT0.js} +1 -1
  253. package/dist/tool-list-DDaCqpR6.js +209 -0
  254. package/dist/tool-list-DMRPM0Yi.d.ts +50 -0
  255. package/dist/trace-KCBvOsw_.d.ts +113 -0
  256. package/dist/trace-run-Dk962P5a.d.ts +49 -0
  257. package/dist/trace-run-nh6FIsl6.js +202 -0
  258. package/dist/{opt-out-D66l60sg.js → tween-lVMRCUEv.js} +60 -1
  259. package/dist/types-BF_U0tgp.d.ts +74 -0
  260. package/dist/types-CTk3aNb5.d.ts +15 -0
  261. package/dist/types-D0a3i4Fw.d.ts +21 -0
  262. package/dist/types-DTecvcsZ.d.ts +35 -0
  263. package/dist/types-D_BWab7g.d.ts +75 -0
  264. package/dist/types-RHaQ4gj1.d.ts +27 -0
  265. package/dist/ui-components-CKQAPI-W.js +7 -0
  266. package/dist/unwrapDefault-CExq-4rm.js +5 -0
  267. package/dist/use-copy-DK1SSZkh.js +66 -0
  268. package/dist/utils-hi9-xROt.js +37 -0
  269. package/dist/vite.d.ts +0 -1
  270. package/dist/vite.js +8 -14
  271. package/dist/{vue-vUGpdMct.js → vue-DdYvDVOr.js} +1 -1
  272. package/dist/workspace-boot-status-CyGlJS06.js +216 -0
  273. package/dist/{workspace-shell-ChCwWPyv.d.ts → workspace-shell-B4A7CINd.d.ts} +1 -1
  274. package/dist/workspace.d.ts +1 -1
  275. package/dist/workspace.js +1 -2
  276. package/package.json +48 -14
  277. package/dist/attachments-DgwoQZKY.js +0 -88
  278. package/dist/avatar-stack-C0IKwj6g.d.ts +0 -57
  279. package/dist/choices-input-BUf-QqGj.d.ts +0 -92
  280. package/dist/code-view-Cg4nyTNA.js +0 -172
  281. package/dist/comment-attachments-DAzUbRmJ.js +0 -23
  282. package/dist/comment-list-ncwaCSVX.d.ts +0 -60
  283. package/dist/comment-person-D_IyIjXo.js +0 -39
  284. package/dist/comment-pin-hBJFiSYW.d.ts +0 -66
  285. package/dist/comment-row-DPMWI5Z0.js +0 -38
  286. package/dist/comment-selection-bar-CVuS-FNL.d.ts +0 -40
  287. package/dist/comment-send-CUkL3TbZ.js +0 -275
  288. package/dist/comment-send-MmxFsOQf.d.ts +0 -23
  289. package/dist/comment-status-nsCdrRk_.js +0 -20
  290. package/dist/drop-field-CNZgwFVO.js +0 -162
  291. package/dist/editor-Dmk3k6f6.js +0 -620
  292. package/dist/format-CPipR1FP.js +0 -19
  293. package/dist/handlers-CnbkvXjX.js +0 -181
  294. package/dist/icon-XZaCUZTG.d.ts +0 -29
  295. package/dist/image-preview-BKVUtfwQ.js +0 -104
  296. package/dist/index-B_PSX-5h.d.ts +0 -69
  297. package/dist/list-DUTAo0uC.js +0 -270
  298. package/dist/markdown-editor-B7gD60tp.d.ts +0 -189
  299. package/dist/message-scroller-BZqS63IX.d.ts +0 -173
  300. package/dist/nuxt-ui-7ByUrymx.js +0 -43
  301. package/dist/parts/components/comment-list.d.ts +0 -2
  302. package/dist/parts/components/comment-list.js +0 -173
  303. package/dist/parts/components/comment-pin.d.ts +0 -2
  304. package/dist/parts/components/comment-pin.js +0 -74
  305. package/dist/parts/components/comment-send.d.ts +0 -2
  306. package/dist/parts/components/comment-send.js +0 -1
  307. package/dist/parts/components/markdown-editor.d.ts +0 -2
  308. package/dist/parts/components/markdown-editor.js +0 -1
  309. package/dist/parts/components/markdown-renderer.js +0 -1
  310. package/dist/payload-text-DQNRbJY5.js +0 -31
  311. package/dist/progress-DL9k-ERG.js +0 -265
  312. package/dist/registry-DAIjCjWd.js +0 -77
  313. package/dist/slot-part-BWHvQ3mK.js +0 -25
  314. package/dist/text-gacox6bp.js +0 -822
  315. package/dist/travel-BliEidau.js +0 -180
  316. package/dist/tween-Dv3IIIQG.js +0 -61
  317. package/dist/types-Ceh7h7NT.d.ts +0 -31
  318. package/dist/visual-copy-CHHBfJ6O.js +0 -14
@@ -1,15 +1,14 @@
1
- import { c as offsetIn, d as iconShape, n as morph, o as enterIcon, r as morphTarget, s as leaveIcon, t as discardMorph, u as findIcons } from "./text-gacox6bp.js";
2
- import { i as getMotionSlowFactor, l as onReducedMotionChange, r as createSpring, s as springs, t as isMotionOff, u as prefersReducedMotion } from "./opt-out-D66l60sg.js";
3
- import { a as listMotionEffects, c as onMotionEffectsChange, i as handOffMotionEffects, l as otherMotionLayer, o as motionEffectRegistrations, r as defineOwnEffect, s as motionStateAttributes, t as claimMotionLayer, u as writeMotionStyle } from "./registry-DAIjCjWd.js";
4
- import { a as isOwnNode, c as own } from "./ring-GaJsg32c.js";
1
+ import { a as tween, c as createSpring, f as springs, h as prefersReducedMotion, i as playTween, l as getMotionSlowFactor, m as onReducedMotionChange, n as easeIn, o as isMotionOff, r as easeOut, t as cubicBezier, u as onEachFrame } from "./tween-lVMRCUEv.js";
2
+ import { a as defineOwnEffect, c as motionEffectRegistrations, d as otherMotionLayer, f as writeMotionStyle, l as motionStateAttributes, n as visualCopy, o as handOffMotionEffects, r as claimMotionLayer, s as listMotionEffects, u as onMotionEffectsChange } from "./hold-to-delete-CcQbfiQx.js";
3
+ import { a as isOwnNode, c as own, i as glyphNode, l as reduced, n as frameOf$2, o as motionSkipped, r as glyphMotionSkipped, s as openFrame, u as setText } from "./ring-DoL9jivj.js";
5
4
  // src/motion/effects/divider.ts
6
5
  const springBack = {
7
6
  stiffness: 500,
8
7
  damping: 14
9
8
  };
10
- const reach = 60;
9
+ const reach$1 = 60;
11
10
  const inset = 40;
12
- const svgNamespace$1 = "http://www.w3.org/2000/svg";
11
+ const svgNamespace$2 = "http://www.w3.org/2000/svg";
13
12
  const rekaDragAttribute = "data-resize-handle-active";
14
13
  const bends = /* @__PURE__ */ new WeakMap();
15
14
  function axisOf$1(handle, rect) {
@@ -42,7 +41,7 @@ function lineOf(handle, axis) {
42
41
  width: 1
43
42
  };
44
43
  }
45
- function draw$4(bend, amount) {
44
+ function draw$5(bend, amount) {
46
45
  const { handle, axis, line } = bend;
47
46
  if (Math.abs(amount) < .5 && !bend.spring.active) {
48
47
  bend.lane?.svg.remove();
@@ -51,11 +50,11 @@ function draw$4(bend, amount) {
51
50
  return;
52
51
  }
53
52
  if (!bend.lane) {
54
- const svg = document.createElementNS(svgNamespace$1, "svg");
53
+ const svg = document.createElementNS(svgNamespace$2, "svg");
55
54
  svg.setAttribute("aria-hidden", "true");
56
55
  svg.dataset.motion = "bend";
57
56
  svg.style.cssText = "position:absolute;left:0;top:0;width:1px;height:1px;overflow:visible;pointer-events:none;z-index:1";
58
- const path = document.createElementNS(svgNamespace$1, "path");
57
+ const path = document.createElementNS(svgNamespace$2, "path");
59
58
  path.setAttribute("fill", "none");
60
59
  path.style.stroke = line.color;
61
60
  path.style.strokeWidth = `${line.width}px`;
@@ -121,7 +120,7 @@ const divider = {
121
120
  axis,
122
121
  line: lineOf(handle, axis),
123
122
  at: across(event),
124
- spring: createSpring(0, (value) => draw$4(current, value), springBack)
123
+ spring: createSpring(0, (value) => draw$5(current, value), springBack)
125
124
  };
126
125
  bend = current;
127
126
  bends.set(handle, bend);
@@ -136,7 +135,7 @@ const divider = {
136
135
  const zoom = handle.offsetHeight ? box.height / handle.offsetHeight || 1 : 1;
137
136
  const over = (along(pointer) - grab - center(box)) / zoom;
138
137
  active.at = across(pointer);
139
- active.spring.set(Math.abs(over) < 1 ? 0 : over / (1 + Math.abs(over) / reach));
138
+ active.spring.set(Math.abs(over) < 1 ? 0 : over / (1 + Math.abs(over) / reach$1));
140
139
  };
141
140
  return {
142
141
  move(next) {
@@ -566,6 +565,152 @@ function pinGhost(ghost, rect) {
566
565
  function after(ms, callback) {
567
566
  return window.setTimeout(callback, ms * getMotionSlowFactor());
568
567
  }
568
+ // src/motion/effects/icon-shape.ts
569
+ const svgNamespace$1 = "http://www.w3.org/2000/svg";
570
+ const geometry = /* @__PURE__ */ new Map([
571
+ ["path", ["d"]],
572
+ ["line", [
573
+ "x1",
574
+ "y1",
575
+ "x2",
576
+ "y2"
577
+ ]],
578
+ ["polyline", ["points"]],
579
+ ["polygon", ["points"]],
580
+ ["circle", [
581
+ "cx",
582
+ "cy",
583
+ "r"
584
+ ]],
585
+ ["ellipse", [
586
+ "cx",
587
+ "cy",
588
+ "rx",
589
+ "ry"
590
+ ]],
591
+ ["rect", [
592
+ "x",
593
+ "y",
594
+ "width",
595
+ "height",
596
+ "rx",
597
+ "ry"
598
+ ]]
599
+ ]);
600
+ const shapeSelector = [...geometry.keys()].join(", ");
601
+ /** The icons inside an element: inline `<svg>` elements, and Iconify CSS icons. */
602
+ function findIcons(element) {
603
+ const icons = [];
604
+ for (const node of element.querySelectorAll("svg, .iconify")) {
605
+ if (node instanceof SVGSVGElement && node.parentElement?.closest("svg")) continue;
606
+ if (node instanceof SVGSVGElement || cssIconSource(node)) icons.push(node);
607
+ }
608
+ return icons;
609
+ }
610
+ function cssIconSource(element) {
611
+ const value = getComputedStyle(element).getPropertyValue("--svg").trim();
612
+ const url = /^url\(\s*(["']?)(.*)\1\s*\)$/s.exec(value)?.[2];
613
+ if (!url?.startsWith("data:image/svg+xml")) return;
614
+ const comma = url.indexOf(",");
615
+ const data = url.slice(comma + 1);
616
+ try {
617
+ return url.slice(0, comma).endsWith(";base64") ? atob(data) : decodeURIComponent(data);
618
+ } catch {
619
+ return;
620
+ }
621
+ }
622
+ function editor(shapes) {
623
+ const originals = /* @__PURE__ */ new Map();
624
+ return {
625
+ set(shape, name, value) {
626
+ let kept = originals.get(shape);
627
+ if (!kept) originals.set(shape, kept = /* @__PURE__ */ new Map());
628
+ if (!kept.has(name)) kept.set(name, shape.getAttribute(name));
629
+ shape.setAttribute(name, value);
630
+ },
631
+ putBack() {
632
+ for (const [shape, kept] of originals) for (const [name, value] of kept) if (value === null) shape.removeAttribute(name);
633
+ else shape.setAttribute(name, value);
634
+ originals.clear();
635
+ },
636
+ shapes
637
+ };
638
+ }
639
+ /** The shapes of an icon from `findIcons`, or undefined when it has none. */
640
+ function iconShape(icon) {
641
+ if (icon instanceof SVGSVGElement) {
642
+ const { set, putBack, shapes } = editor([...icon.querySelectorAll(shapeSelector)]);
643
+ if (!shapes.length) return;
644
+ return {
645
+ shapes,
646
+ set,
647
+ commit() {},
648
+ restore: putBack,
649
+ measure: (read) => read(shapes)
650
+ };
651
+ }
652
+ const source = cssIconSource(icon);
653
+ if (!source) return;
654
+ const svg = new DOMParser().parseFromString(source, "image/svg+xml").documentElement;
655
+ if (!(svg instanceof SVGSVGElement)) return;
656
+ if (svg.matches("[style], [class], [transform]")) return;
657
+ const copies = [];
658
+ const originals = [];
659
+ for (const child of svg.children) {
660
+ const attributes = geometry.get(child.localName);
661
+ if (!attributes || !(child instanceof SVGGeometryElement) || child.childElementCount || child.matches("[style], [class], [transform]")) return;
662
+ const copy = document.createElementNS(svgNamespace$1, child.localName);
663
+ if (!(copy instanceof SVGGeometryElement)) return;
664
+ for (const name of attributes) {
665
+ const value = child.getAttribute(name);
666
+ if (value !== null) copy.setAttribute(name, value);
667
+ }
668
+ copies.push(copy);
669
+ originals.push(child);
670
+ }
671
+ if (!copies.length) return;
672
+ const { set, putBack, shapes } = editor(originals);
673
+ const readMask = () => ({
674
+ value: icon.style.getPropertyValue("--svg"),
675
+ priority: icon.style.getPropertyPriority("--svg")
676
+ });
677
+ const original = readMask();
678
+ let written;
679
+ const matchesMask = (expected) => {
680
+ const current = readMask();
681
+ return expected.value === current.value && expected.priority === current.priority;
682
+ };
683
+ return {
684
+ shapes,
685
+ set,
686
+ commit() {
687
+ if (!matchesMask(written ?? original)) return;
688
+ icon.style.setProperty("--svg", `url("data:image/svg+xml,${encodeURIComponent(new XMLSerializer().serializeToString(svg))}")`, original.priority);
689
+ written = readMask();
690
+ },
691
+ restore() {
692
+ putBack();
693
+ if (written && matchesMask(written)) {
694
+ const { value, priority } = original;
695
+ if (value) icon.style.setProperty("--svg", value, priority);
696
+ else icon.style.removeProperty("--svg");
697
+ }
698
+ written = void 0;
699
+ },
700
+ measure(read) {
701
+ const host = document.createElementNS(svgNamespace$1, "svg");
702
+ host.setAttribute("aria-hidden", "true");
703
+ host.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;visibility:hidden";
704
+ host.append(...copies);
705
+ document.body.append(host);
706
+ try {
707
+ return read(copies);
708
+ } finally {
709
+ host.remove();
710
+ }
711
+ }
712
+ };
713
+ }
569
714
  // src/motion/effects/check.ts
570
715
  const checks = /* @__PURE__ */ new WeakMap();
571
716
  function isOn$1(value) {
@@ -589,7 +734,7 @@ function keepGhost(check) {
589
734
  check.ghost = ghost;
590
735
  bind(check, findIcons(ghost)[0], ghost);
591
736
  }
592
- function draw$3(check, value) {
737
+ function draw$4(check, value) {
593
738
  keepGhost(check);
594
739
  const drawn = Math.min(1, Math.max(0, value));
595
740
  if (check.icon && !check.reduced) {
@@ -617,7 +762,7 @@ function checkOf(element, wasOn) {
617
762
  const check = {
618
763
  element,
619
764
  drawn: createSpring(wasOn ? 1 : 0, (value) => {
620
- if (check.drawn.active) draw$3(check, value);
765
+ if (check.drawn.active) draw$4(check, value);
621
766
  else finish$1(check);
622
767
  }),
623
768
  icon: void 0,
@@ -654,7 +799,7 @@ const check = {
654
799
  check.indicator = icon && childOf(element, icon);
655
800
  if (isOn$1(oldValue)) check.drawn.set(0);
656
801
  if (!bind(check, icon, check.reduced ? styleable(check.indicator) : void 0)) return;
657
- draw$3(check, check.drawn.value);
802
+ draw$4(check, check.drawn.value);
658
803
  check.drawn.to(1, options);
659
804
  return;
660
805
  }
@@ -667,7 +812,7 @@ const check = {
667
812
  if (icon) check.indicator = childOf(element, icon);
668
813
  if (!bind(check, icon, check.reduced ? styleable(check.indicator) : void 0) && !check.indicator) return;
669
814
  check.drawn.to(0, options);
670
- draw$3(check, check.drawn.value);
815
+ draw$4(check, check.drawn.value);
671
816
  }
672
817
  };
673
818
  // src/motion/effects/disclosure.ts
@@ -699,7 +844,7 @@ function matrixDegrees(value) {
699
844
  return Math.atan2(b, a) * 180 / Math.PI;
700
845
  }
701
846
  /** The angle that the stylesheet draws the icon at now, without what the effect wrote, split into its two sources. */
702
- function measure$2(icon) {
847
+ function measure$3(icon) {
703
848
  const written = icon.style.getPropertyValue("rotate");
704
849
  if (written) icon.style.removeProperty("rotate");
705
850
  const style = getComputedStyle(icon);
@@ -753,7 +898,7 @@ const disclosure = {
753
898
  for (const icon of icons(trigger)) {
754
899
  if (isMotionOff(icon) || transitionsTurn(icon)) continue;
755
900
  const spring = turns.get(icon)?.spring;
756
- angles.set(icon, spring?.active ? spring.target * quarter : measure$2(icon).total);
901
+ angles.set(icon, spring?.active ? spring.target * quarter : measure$3(icon).total);
757
902
  }
758
903
  if (!angles.size) return;
759
904
  pending$1.set(owner, angles);
@@ -781,7 +926,7 @@ const disclosure = {
781
926
  }
782
927
  const turn = turnOf(icon);
783
928
  const from = turn.spring.active ? turn.spring.value * quarter : sampled;
784
- const { total, base } = measure$2(icon);
929
+ const { total, base } = measure$3(icon);
785
930
  turn.base = base;
786
931
  if (Math.abs(total - from) < .5) {
787
932
  if (turn.spring.active) turn.spring.set(total / quarter);
@@ -889,6 +1034,515 @@ const jelly = {
889
1034
  batch.set(element.parentElement, siblings);
890
1035
  }
891
1036
  };
1037
+ // src/motion/helpers/icon.ts
1038
+ const exit = {
1039
+ duration: 200,
1040
+ travel: 12,
1041
+ scale: .6,
1042
+ blur: 2
1043
+ };
1044
+ const enterBlur = {
1045
+ duration: 260,
1046
+ delay: 40,
1047
+ scale: .5,
1048
+ blur: 3,
1049
+ ease: cubicBezier(.3, 1.5, .5, 1)
1050
+ };
1051
+ const enterSlide = {
1052
+ duration: 260,
1053
+ delay: 80,
1054
+ travel: 10,
1055
+ ease: cubicBezier(.2, .8, .2, 1)
1056
+ };
1057
+ const draw$3 = {
1058
+ duration: 340,
1059
+ spinner: 420,
1060
+ delay: 120,
1061
+ ease: cubicBezier(.6, 0, .2, 1)
1062
+ };
1063
+ const crossfade$5 = 150;
1064
+ const directions = {
1065
+ left: [-1, 0],
1066
+ right: [1, 0],
1067
+ up: [0, -1],
1068
+ down: [0, 1]
1069
+ };
1070
+ const states = /* @__PURE__ */ new WeakMap();
1071
+ const positioned = /* @__PURE__ */ new WeakMap();
1072
+ function stateOf(icon) {
1073
+ let state = states.get(icon);
1074
+ if (!state) {
1075
+ state = {
1076
+ shown: 1,
1077
+ leaving: false
1078
+ };
1079
+ states.set(icon, state);
1080
+ }
1081
+ return state;
1082
+ }
1083
+ function styled(icon) {
1084
+ return icon instanceof HTMLElement || icon instanceof SVGElement;
1085
+ }
1086
+ function strokes(icon) {
1087
+ const svg = icon instanceof SVGSVGElement ? icon : icon.querySelector("svg");
1088
+ const shape = svg ? iconShape(svg) : void 0;
1089
+ const parts = shape?.shapes.filter((part) => getComputedStyle(part).stroke !== "none") ?? [];
1090
+ return shape && parts.length ? {
1091
+ shape,
1092
+ parts
1093
+ } : void 0;
1094
+ }
1095
+ function saveStyle(style, property) {
1096
+ const value = style.getPropertyValue(property);
1097
+ const priority = style.getPropertyPriority(property);
1098
+ return () => {
1099
+ if (value) style.setProperty(property, value, priority);
1100
+ else style.removeProperty(property);
1101
+ };
1102
+ }
1103
+ function paintIcon(icon, state, values) {
1104
+ if (!styled(icon)) return;
1105
+ const styles = state.styles ??= /* @__PURE__ */ new Map();
1106
+ for (const [property, value] of Object.entries(values)) {
1107
+ if (!styles.has(property)) styles.set(property, saveStyle(icon.style, property));
1108
+ icon.style.setProperty(property, value);
1109
+ }
1110
+ }
1111
+ function clear$1(state) {
1112
+ state.stroke?.restore();
1113
+ state.stroke = void 0;
1114
+ for (const restore of state.styles?.values() ?? []) restore();
1115
+ state.styles = void 0;
1116
+ }
1117
+ function stopIcon(icon) {
1118
+ const state = states.get(icon);
1119
+ if (!state) return;
1120
+ state.fade?.stop();
1121
+ clear$1(state);
1122
+ state.restorePlacement?.();
1123
+ states.delete(icon);
1124
+ }
1125
+ function leave$4(icon, kind, reducedMotion, done) {
1126
+ const state = stateOf(icon);
1127
+ state.fade?.stop();
1128
+ clear$1(state);
1129
+ state.leaving = true;
1130
+ const [x, y] = kind === "blur" ? [0, 0] : directions[kind];
1131
+ state.fade = tween(state.shown, 0, {
1132
+ duration: reducedMotion ? crossfade$5 : exit.duration,
1133
+ ease: reducedMotion ? easeOut : easeIn
1134
+ }, (value) => {
1135
+ state.shown = value;
1136
+ const gone = 1 - value;
1137
+ paintIcon(icon, state, {
1138
+ opacity: String(value),
1139
+ ...reducedMotion ? {} : kind === "blur" ? {
1140
+ filter: `blur(${(exit.blur * gone).toFixed(2)}px)`,
1141
+ scale: String(1 - (1 - exit.scale) * gone)
1142
+ } : { translate: `${x * exit.travel * gone}px ${y * exit.travel * gone}px` }
1143
+ });
1144
+ }, () => {
1145
+ state.fade = void 0;
1146
+ done();
1147
+ });
1148
+ }
1149
+ function come(icon, kind, reducedMotion, from) {
1150
+ const state = stateOf(icon);
1151
+ state.fade?.stop();
1152
+ state.restorePlacement?.();
1153
+ state.restorePlacement = void 0;
1154
+ state.leaving = false;
1155
+ clear$1(state);
1156
+ const stroke = kind === "draw" && !reducedMotion ? strokes(icon) : void 0;
1157
+ state.stroke = stroke?.shape;
1158
+ const finish = () => {
1159
+ state.fade = void 0;
1160
+ state.shown = 1;
1161
+ clear$1(state);
1162
+ };
1163
+ if (reducedMotion) {
1164
+ state.fade = tween(from, 1, {
1165
+ duration: crossfade$5,
1166
+ ease: easeOut
1167
+ }, (value) => {
1168
+ state.shown = value;
1169
+ paintIcon(icon, state, { opacity: String(value) });
1170
+ }, finish);
1171
+ return;
1172
+ }
1173
+ if (stroke) {
1174
+ const { shape, parts } = stroke;
1175
+ for (const part of parts) {
1176
+ shape.set(part, "pathLength", "1");
1177
+ shape.set(part, "stroke-dasharray", "1");
1178
+ shape.set(part, "stroke-dashoffset", "1");
1179
+ }
1180
+ shape.commit();
1181
+ const spins = icon.matches(".animate-spin") || !!icon.querySelector(".animate-spin");
1182
+ state.shown = 1;
1183
+ state.fade = tween(1, 0, {
1184
+ duration: spins ? draw$3.spinner : draw$3.duration,
1185
+ delay: draw$3.delay,
1186
+ ease: draw$3.ease
1187
+ }, (value) => {
1188
+ for (const part of parts) shape.set(part, "stroke-dashoffset", String(value));
1189
+ shape.commit();
1190
+ }, finish);
1191
+ return;
1192
+ }
1193
+ const effective = kind === "draw" ? "blur" : kind;
1194
+ if (effective === "blur") {
1195
+ state.fade = tween(from, 1, {
1196
+ duration: enterBlur.duration,
1197
+ delay: from ? 0 : enterBlur.delay,
1198
+ ease: enterBlur.ease
1199
+ }, (value) => {
1200
+ state.shown = Math.min(1, value);
1201
+ const gone = 1 - value;
1202
+ paintIcon(icon, state, {
1203
+ opacity: String(Math.min(1, Math.max(0, value))),
1204
+ filter: `blur(${Math.max(0, enterBlur.blur * gone).toFixed(2)}px)`,
1205
+ scale: String(1 - (1 - enterBlur.scale) * gone)
1206
+ });
1207
+ }, finish);
1208
+ return;
1209
+ }
1210
+ const [x, y] = directions[effective];
1211
+ state.fade = tween(from, 1, {
1212
+ duration: enterSlide.duration,
1213
+ delay: from ? 0 : enterSlide.delay,
1214
+ ease: enterSlide.ease
1215
+ }, (value) => {
1216
+ state.shown = value;
1217
+ const gone = 1 - value;
1218
+ paintIcon(icon, state, {
1219
+ opacity: String(Math.min(1, value)),
1220
+ translate: `${-x * enterSlide.travel * gone}px ${-y * enterSlide.travel * gone}px`
1221
+ });
1222
+ }, finish);
1223
+ }
1224
+ /**
1225
+ * Swaps the icon in `container` for `icon`, as rule 5 of docs/design/motion.md asks: the old icon blurs out, or leaves in
1226
+ * the direction it points, while the new one comes in, and a spinner or a check draws its stroke. `icon` may already be
1227
+ * a child of `container`, as when a framework renders it; else the helper appends it. Every other icon in the container
1228
+ * leaves, and is removed when it is gone.
1229
+ *
1230
+ * Call it again at any time: an icon that is still coming in leaves from where it is. Under reduced motion the icons
1231
+ * crossfade in 150ms. Inside `data-motion="none"` the old icons go at once.
1232
+ */
1233
+ function swapIcon(container, icon, options = {}) {
1234
+ const remove = options.onRemove ?? ((old) => old.remove());
1235
+ if (icon.parentNode !== container) container.append(icon);
1236
+ const known = states.get(icon);
1237
+ const others = [...container.children].filter((child) => child !== icon && !states.get(child)?.leaving);
1238
+ const leavingNow = [...container.children].filter((child) => child !== icon && states.get(child)?.leaving);
1239
+ if (motionSkipped(container)) {
1240
+ for (const old of [...others, ...leavingNow]) {
1241
+ stopIcon(old);
1242
+ remove(old);
1243
+ }
1244
+ stopIcon(icon);
1245
+ return;
1246
+ }
1247
+ if (!others.length && (known ? !known.leaving : !leavingNow.length)) {
1248
+ stateOf(icon);
1249
+ return;
1250
+ }
1251
+ const placed = others.map((old) => ({
1252
+ old,
1253
+ at: offsetIn(container, old)
1254
+ }));
1255
+ for (const { old, at } of placed) leaveIcon(container, old, at, options.exit ?? "blur", remove);
1256
+ enterIcon(icon, options.enter, known ? known.shown : 0);
1257
+ }
1258
+ /**
1259
+ * Takes `old` out of the flow at `at`, a place in the padding box of `container`, and plays its exit. `remove` runs when
1260
+ * it is gone. The label effect of the layer uses it for a copy of the icon that Vue already replaced.
1261
+ */
1262
+ function leaveIcon(container, old, at, exit, remove) {
1263
+ const reducedMotion = reduced();
1264
+ let position = positioned.get(container);
1265
+ if (!position && getComputedStyle(container).position === "static") {
1266
+ position = {
1267
+ exits: 0,
1268
+ restore: saveStyle(container.style, "position")
1269
+ };
1270
+ positioned.set(container, position);
1271
+ container.style.position = "relative";
1272
+ }
1273
+ if (position) position.exits++;
1274
+ const restores = [];
1275
+ if (styled(old)) {
1276
+ const placement = {
1277
+ position: "absolute",
1278
+ left: `${at.left}px`,
1279
+ top: `${at.top}px`,
1280
+ "pointer-events": "none",
1281
+ "margin-top": "0",
1282
+ "margin-right": "0",
1283
+ "margin-bottom": "0",
1284
+ "margin-left": "0"
1285
+ };
1286
+ for (const [property, value] of Object.entries(placement)) {
1287
+ restores.push(saveStyle(old.style, property));
1288
+ old.style.setProperty(property, value);
1289
+ }
1290
+ }
1291
+ const hidden = old.getAttribute("aria-hidden");
1292
+ old.setAttribute("aria-hidden", "true");
1293
+ stateOf(old).restorePlacement = () => {
1294
+ for (const restore of restores) restore();
1295
+ if (hidden === null) old.removeAttribute("aria-hidden");
1296
+ else old.setAttribute("aria-hidden", hidden);
1297
+ if (position && --position.exits === 0) {
1298
+ position.restore();
1299
+ positioned.delete(container);
1300
+ }
1301
+ };
1302
+ leave$4(old, exit, reducedMotion, () => {
1303
+ stopIcon(old);
1304
+ remove(old);
1305
+ });
1306
+ }
1307
+ /** Plays the entrance of `icon` from `from` (0 for a new icon). The default draws a spinning icon and blurs in others. */
1308
+ function enterIcon(icon, enter, from) {
1309
+ const spins = icon.matches(".animate-spin") || !!icon.querySelector(".animate-spin");
1310
+ come(icon, enter ?? (spins ? "draw" : "blur"), reduced(), from);
1311
+ }
1312
+ /**
1313
+ * Where `child` sits in the padding box of `container`, in layout pixels. An SVG has no `offsetLeft`, and a press may
1314
+ * scale the button around both, so it divides the distance on screen by that scale.
1315
+ */
1316
+ function offsetIn(container, child) {
1317
+ const outer = container.getBoundingClientRect();
1318
+ const inner = child.getBoundingClientRect();
1319
+ const scale = container.offsetWidth ? outer.width / container.offsetWidth : 1;
1320
+ return {
1321
+ left: (inner.left - outer.left) / (scale || 1) - container.clientLeft,
1322
+ top: (inner.top - outer.top) / (scale || 1) - container.clientTop
1323
+ };
1324
+ }
1325
+ // src/motion/helpers/text.ts
1326
+ /** Splits a change of label into the shared start, the old letters after it, and the new letters after it. */
1327
+ function diffText(from, to) {
1328
+ const a = [...from];
1329
+ const b = [...to];
1330
+ let index = 0;
1331
+ while (index < a.length && index < b.length && a[index] === b[index]) index++;
1332
+ return {
1333
+ kept: a.slice(0, index).join(""),
1334
+ gone: a.slice(index).join(""),
1335
+ typed: b.slice(index).join("")
1336
+ };
1337
+ }
1338
+ const blur$1 = 6;
1339
+ const leave$3 = {
1340
+ duration: 200,
1341
+ stagger: 30
1342
+ };
1343
+ const type = {
1344
+ duration: 240,
1345
+ lead: 30,
1346
+ stagger: 55
1347
+ };
1348
+ const crossfade$4 = 150;
1349
+ const morphs = /* @__PURE__ */ new WeakMap();
1350
+ /** The text that the element shows or moves to, when a morph runs on it. */
1351
+ function morphTarget(element) {
1352
+ return morphs.get(element)?.text;
1353
+ }
1354
+ function paint$1(letter, value, reducedMotion) {
1355
+ letter.shown = value;
1356
+ writeMotionStyle(letter.node, {
1357
+ opacity: value >= 1 ? null : String(value),
1358
+ filter: reducedMotion || value >= 1 ? null : `blur(${(blur$1 * (1 - value)).toFixed(2)}px)`
1359
+ });
1360
+ }
1361
+ function letterNode(char) {
1362
+ return glyphNode(char);
1363
+ }
1364
+ function finishIfIdle$1(element, morph) {
1365
+ if (morphs.get(element) !== morph) return;
1366
+ if (morph.leaving.size || morph.timers.size || morph.frame.width.active || morph.letters.some((letter) => letter.fade || letter.waiting)) return;
1367
+ morphs.delete(element);
1368
+ morph.frame.collapse(morph.text);
1369
+ }
1370
+ function stopAll(morph) {
1371
+ for (const timer of morph.timers) clearTimeout(timer);
1372
+ morph.timers.clear();
1373
+ for (const letter of [...morph.letters, ...morph.leaving]) letter.fade?.stop();
1374
+ }
1375
+ function discardMorph(element) {
1376
+ const current = morphs.get(element);
1377
+ if (!current) return;
1378
+ stopAll(current);
1379
+ morphs.delete(element);
1380
+ current.frame.discard();
1381
+ }
1382
+ /**
1383
+ * Changes the text of `element` letter by letter, as rule 4 of docs/design/motion.md asks: the letters that the old and
1384
+ * new text share at the start stay, the other old letters blur out where they are, and the new letters type in one at
1385
+ * a time with a short blur. The width of the element follows the letters with a spring and never jumps.
1386
+ *
1387
+ * Call it again at any time: a new text continues from the letters on screen. The element keeps the final text for
1388
+ * screen readers during the morph, and holds plain text again when it ends. Under reduced motion the two texts
1389
+ * crossfade in 150ms. Inside `data-motion="none"`, or when the element has no layout, it sets the text at once.
1390
+ *
1391
+ * Give it an element of its own with no padding, such as the label `<span>` of a button.
1392
+ */
1393
+ function morphText(element, text) {
1394
+ morph(element, text, void 0);
1395
+ }
1396
+ function hasLayout(element) {
1397
+ let node = element;
1398
+ while (node) {
1399
+ if (node.getClientRects().length) return true;
1400
+ if (getComputedStyle(node).display !== "contents") return false;
1401
+ const root = node.getRootNode();
1402
+ node = node.parentElement ?? (root instanceof ShadowRoot ? root.host : null);
1403
+ }
1404
+ return false;
1405
+ }
1406
+ /**
1407
+ * The morph of `morphText`. `from` is the text that the element showed before, when the app already wrote the new text
1408
+ * into the element, as Vue does with the label of a button.
1409
+ */
1410
+ function morph(element, text, from) {
1411
+ let current = morphs.get(element);
1412
+ const before = current?.text ?? from ?? element.textContent ?? "";
1413
+ if (!current && before === text || glyphMotionSkipped(element) || !hasLayout(element)) {
1414
+ if (current) {
1415
+ stopAll(current);
1416
+ morphs.delete(element);
1417
+ }
1418
+ setText(element, text);
1419
+ return;
1420
+ }
1421
+ const reducedMotion = reduced();
1422
+ if (!current) {
1423
+ const frame = frameOf$2(element) ?? openFrame(element, "inline", () => {
1424
+ const running = morphs.get(element);
1425
+ if (running) finishIfIdle$1(element, running);
1426
+ });
1427
+ const letters = [...before].map((char) => ({
1428
+ node: letterNode(char),
1429
+ char,
1430
+ shown: 1,
1431
+ waiting: false
1432
+ }));
1433
+ frame.holder.append(...letters.map((letter) => letter.node));
1434
+ frame.width.set(frame.natural());
1435
+ current = {
1436
+ frame,
1437
+ text: before,
1438
+ letters,
1439
+ leaving: /* @__PURE__ */ new Set(),
1440
+ timers: /* @__PURE__ */ new Set()
1441
+ };
1442
+ morphs.set(element, current);
1443
+ }
1444
+ const state = current;
1445
+ const width = state.frame.width;
1446
+ state.frame.restore();
1447
+ for (const timer of state.timers) clearTimeout(timer);
1448
+ state.timers.clear();
1449
+ state.text = text;
1450
+ state.frame.name(text);
1451
+ if (reducedMotion) {
1452
+ leaveLetters(state, state.letters, true);
1453
+ state.letters = [...text].map((char) => {
1454
+ const letter = {
1455
+ node: letterNode(char),
1456
+ char,
1457
+ shown: 0,
1458
+ waiting: false
1459
+ };
1460
+ paint$1(letter, 0, true);
1461
+ state.frame.holder.append(letter.node);
1462
+ return letter;
1463
+ });
1464
+ width.set(state.frame.natural());
1465
+ for (const letter of state.letters) fadeIn(element, state, letter, 0, crossfade$4, true);
1466
+ return;
1467
+ }
1468
+ const diff = diffText(state.letters.map((letter) => letter.char).join(""), text);
1469
+ const keptCount = [...diff.kept].length;
1470
+ const kept = state.letters.slice(0, keptCount);
1471
+ leaveLetters(state, state.letters.slice(keptCount), false);
1472
+ const typing = [...kept.filter((letter) => letter.waiting), ...[...diff.typed].map((char) => {
1473
+ const letter = {
1474
+ node: letterNode(char),
1475
+ char,
1476
+ shown: 0,
1477
+ waiting: true
1478
+ };
1479
+ paint$1(letter, 0, false);
1480
+ state.frame.holder.append(letter.node);
1481
+ return letter;
1482
+ })];
1483
+ state.letters = [...kept, ...typing.filter((letter) => !kept.includes(letter))];
1484
+ const end = state.frame.natural();
1485
+ if (!typing.length) {
1486
+ width.to(end);
1487
+ return;
1488
+ }
1489
+ const start = width.value;
1490
+ let step = end - typing.reduce((sum, letter) => sum + letter.node.offsetWidth, 0);
1491
+ const slow = getMotionSlowFactor();
1492
+ typing.forEach((letter, index) => {
1493
+ step += letter.node.offsetWidth;
1494
+ const target = index === typing.length - 1 ? end : Math.max(step, index === 0 ? Math.min(start, end) : 0);
1495
+ const timer = setTimeout(() => {
1496
+ state.timers.delete(timer);
1497
+ letter.waiting = false;
1498
+ width.to(target);
1499
+ fadeIn(element, state, letter, letter.shown, type.duration, false);
1500
+ }, (type.lead + index * type.stagger) * slow);
1501
+ state.timers.add(timer);
1502
+ });
1503
+ }
1504
+ function fadeIn(element, state, letter, from, duration, reducedMotion) {
1505
+ letter.fade?.stop();
1506
+ letter.fade = tween(from, 1, {
1507
+ duration,
1508
+ ease: easeOut
1509
+ }, (value) => paint$1(letter, value, reducedMotion), () => {
1510
+ letter.fade = void 0;
1511
+ paint$1(letter, 1, reducedMotion);
1512
+ finishIfIdle$1(element, state);
1513
+ });
1514
+ }
1515
+ function leaveLetters(state, letters, reducedMotion) {
1516
+ const element = state.frame.element;
1517
+ const placed = letters.map((letter) => ({
1518
+ letter,
1519
+ left: letter.node.offsetLeft,
1520
+ top: letter.node.offsetTop
1521
+ }));
1522
+ let order = 0;
1523
+ for (const { letter, left, top } of placed) {
1524
+ letter.fade?.stop();
1525
+ letter.fade = void 0;
1526
+ if (letter.waiting || letter.shown <= 0) {
1527
+ letter.node.remove();
1528
+ continue;
1529
+ }
1530
+ letter.node.style.position = "absolute";
1531
+ letter.node.style.left = `${left}px`;
1532
+ letter.node.style.top = `${top}px`;
1533
+ state.leaving.add(letter);
1534
+ letter.fade = tween(letter.shown, 0, {
1535
+ duration: reducedMotion ? crossfade$4 : leave$3.duration,
1536
+ delay: reducedMotion ? 0 : order++ * leave$3.stagger,
1537
+ ease: reducedMotion ? easeOut : easeIn
1538
+ }, (value) => paint$1(letter, value, reducedMotion), () => {
1539
+ letter.fade = void 0;
1540
+ letter.node.remove();
1541
+ state.leaving.delete(letter);
1542
+ finishIfIdle$1(element, state);
1543
+ });
1544
+ }
1545
+ }
892
1546
  // src/motion/effects/label.ts
893
1547
  const controls = ":is(button, a, [role=button])";
894
1548
  /**
@@ -952,12 +1606,12 @@ const buttonIcon = {
952
1606
  }
953
1607
  };
954
1608
  // src/motion/effects/leave.ts
955
- const fold = {
1609
+ const fold$1 = {
956
1610
  stiffness: 260,
957
1611
  damping: 28
958
1612
  };
959
- const slotScale = .9;
960
- const crossfade$2 = .15;
1613
+ const slotScale$1 = .9;
1614
+ const crossfade$3 = .15;
961
1615
  const leaving = /* @__PURE__ */ new WeakMap();
962
1616
  function stop(element) {
963
1617
  const entry = leaving.get(element);
@@ -990,19 +1644,19 @@ const leave$2 = {
990
1644
  const reduced = prefersReducedMotion();
991
1645
  const spring = createSpring(1, (progress) => {
992
1646
  writeMotionStyle(ghost, {
993
- scale: reduced ? null : (slotScale + .09999999999999998 * progress).toFixed(4),
1647
+ scale: reduced ? null : (slotScale$1 + .09999999999999998 * progress).toFixed(4),
994
1648
  opacity: Math.max(0, progress).toFixed(3)
995
1649
  });
996
1650
  if (progress < .02) {
997
1651
  spring.stop();
998
1652
  ghost.remove();
999
1653
  }
1000
- }, fold);
1654
+ }, fold$1);
1001
1655
  leaving.set(element, {
1002
1656
  ghost,
1003
1657
  spring
1004
1658
  });
1005
- spring.to(0, reduced ? { tween: crossfade$2 } : { preset: fold });
1659
+ spring.to(0, reduced ? { tween: crossfade$3 } : { preset: fold$1 });
1006
1660
  }
1007
1661
  };
1008
1662
  // src/motion/effects/panel.ts
@@ -1124,8 +1778,9 @@ const up = {
1124
1778
  damping: 14
1125
1779
  };
1126
1780
  /**
1127
- * Everything a person presses: native controls and the roles of docs/design/motion.md, when they are enabled. A switch
1128
- * is not squashed: the switch effect grows its knob instead.
1781
+ * Everything a person presses: native controls, the roles of docs/design/motion.md, and elements with
1782
+ * `data-motion-press`, when they are enabled. The press mode then picks which of them squash. A switch is not squashed:
1783
+ * the switch effect grows its knob instead.
1129
1784
  */
1130
1785
  const pressSelector = `:is(button, a[href], summary, input:is([type=button], [type=submit], [type=reset], [type=checkbox], [type=radio]), ${[
1131
1786
  "button",
@@ -1137,21 +1792,58 @@ const pressSelector = `:is(button, a[href], summary, input:is([type=button], [ty
1137
1792
  "menuitemcheckbox",
1138
1793
  "option",
1139
1794
  "checkbox"
1140
- ].map((role) => `[role=${role}]`).join(", ")}):not(:disabled, [aria-disabled="true"], [role=switch])`;
1795
+ ].map((role) => `[role=${role}]`).join(", ")}, [data-motion-press]:not([data-motion-press=none])):not(:disabled, [aria-disabled="true"], [role=switch])`;
1141
1796
  const iconSelector = "svg, img, .iconify, [data-slot=icon], [data-slot$=Icon], [data-slot=swap-icon]";
1797
+ const nativeButton = ":is(button, input:is([type=button], [type=submit], [type=reset])):is(:not([role]), [role=button])";
1798
+ const pressModeKey = Symbol.for("vite-hub.motion.press-mode");
1799
+ /**
1800
+ * Sets the press mode of every copy of the motion layer on the page. The first copy that installs runs the press for
1801
+ * all of them, so the mode is on the global object.
1802
+ */
1803
+ function setMotionPressMode(mode) {
1804
+ Reflect.set(globalThis, pressModeKey, mode);
1805
+ }
1806
+ function pressMode() {
1807
+ const mode = Reflect.get(globalThis, pressModeKey);
1808
+ return mode === "opt-in" || mode === "all" ? mode : "buttons";
1809
+ }
1142
1810
  const pressed = /* @__PURE__ */ new WeakMap();
1143
1811
  /** How much a control of this height squashes: 3% from 40px high, 4% from 32px, and 5% below. */
1144
1812
  const amountFor = (height) => height >= 40 ? .03 : height >= 32 ? .04 : .05;
1813
+ const wholeAmount = (element) => Math.min(amountFor(element.offsetHeight), 6 / Math.max(element.offsetWidth, element.offsetHeight));
1814
+ function pressChoice(element, event) {
1815
+ for (const node of event.composedPath()) {
1816
+ if (!(node instanceof Element)) continue;
1817
+ const choice = node.getAttribute("data-motion-press");
1818
+ if (choice === "none") return choice;
1819
+ if (node === element && choice !== null) return choice;
1820
+ }
1821
+ }
1822
+ function squashesByDefault(element) {
1823
+ const mode = pressMode();
1824
+ if (mode !== "buttons") return mode === "all";
1825
+ return element.matches(nativeButton) && element.offsetHeight < 48 && element.offsetWidth <= 4 * element.offsetHeight;
1826
+ }
1145
1827
  /**
1146
1828
  * How much a press squashes, from the prototype: an icon-only control squashes its icon by 15%, and a control squashes
1147
1829
  * by its height. A control that another element draws, such as the mark of the folded page pill, names that element
1148
1830
  * with `data-motion-press-target`, a selector that `closest()` finds from the control. Then that element squashes.
1831
+ * `data-motion-press="icon"` squashes the first icon in the element. Nothing squashes when the press does not apply.
1149
1832
  */
1150
- function squash(element) {
1833
+ function squash(element, choice) {
1834
+ if (choice === "none") return void 0;
1835
+ if (choice === "icon") {
1836
+ const icon = element.querySelector(iconSelector);
1837
+ return icon instanceof HTMLElement || icon instanceof SVGElement ? {
1838
+ target: icon,
1839
+ amount: .15
1840
+ } : void 0;
1841
+ }
1842
+ if (choice === void 0 && !squashesByDefault(element)) return void 0;
1151
1843
  const drawnBy = element.dataset.motionPressTarget ? element.closest(element.dataset.motionPressTarget) : null;
1152
1844
  if (drawnBy instanceof HTMLElement) return {
1153
1845
  target: drawnBy,
1154
- amount: amountFor(drawnBy.offsetHeight)
1846
+ amount: wholeAmount(drawnBy)
1155
1847
  };
1156
1848
  const icon = element.firstElementChild;
1157
1849
  if (element.childElementCount === 1 && !element.textContent?.trim() && (icon instanceof HTMLElement || icon instanceof SVGElement) && icon.matches(iconSelector)) return {
@@ -1160,7 +1852,7 @@ function squash(element) {
1160
1852
  };
1161
1853
  return {
1162
1854
  target: element,
1163
- amount: amountFor(element.offsetHeight)
1855
+ amount: wholeAmount(element)
1164
1856
  };
1165
1857
  }
1166
1858
  /**
@@ -1180,12 +1872,15 @@ const press = {
1180
1872
  name: "press",
1181
1873
  selector: pressSelector,
1182
1874
  press(element, event) {
1183
- const { target, amount } = squash(element);
1875
+ if (!("pointerId" in event)) return;
1876
+ const squashed = squash(element, pressChoice(element, event));
1877
+ if (!squashed) return;
1878
+ const { target, amount } = squashed;
1184
1879
  const style = getComputedStyle(target);
1185
1880
  if (transitionsScale(style) || style.display === "contents") return;
1186
1881
  if (style.display === "inline" && target === element && !(element instanceof HTMLInputElement)) return;
1187
1882
  let bounds;
1188
- if (target === element && "pointerId" in event) {
1883
+ if (target === element) {
1189
1884
  bounds = element.getBoundingClientRect();
1190
1885
  if (nearEdge(bounds, event, amount)) return;
1191
1886
  }
@@ -1335,7 +2030,7 @@ function mapBox(rest, to, from) {
1335
2030
  height: rest.height * sy
1336
2031
  };
1337
2032
  }
1338
- function moving(flight) {
2033
+ function moving$1(flight) {
1339
2034
  return !!flight && (flight.x.active || flight.y.active || flight.width.active || flight.height.active);
1340
2035
  }
1341
2036
  function queue(flight) {
@@ -1364,7 +2059,7 @@ function stretch(start, size, velocity, along, across, bounds, restStart, restSi
1364
2059
  function render(flight) {
1365
2060
  if (!flight.ready) return;
1366
2061
  const { element, rest, translate, origin, x, y, width, height, span } = flight;
1367
- if (!moving(flight)) {
2062
+ if (!moving$1(flight)) {
1368
2063
  writeMotionStyle(element, {
1369
2064
  translate: null,
1370
2065
  scale: null
@@ -1387,7 +2082,7 @@ function render(flight) {
1387
2082
  }
1388
2083
  function fly(group, element, from, to, copyOf) {
1389
2084
  const previous = flights.get(group);
1390
- const wasMoving = moving(previous);
2085
+ const wasMoving = moving$1(previous);
1391
2086
  if (previous && previous.element !== element) {
1392
2087
  writeMotionStyle(previous.element, {
1393
2088
  translate: null,
@@ -1569,7 +2264,7 @@ function move(group, from, to) {
1569
2264
  const indicator = indicatorOf(group, to);
1570
2265
  if (indicator) return isMotionOff(indicator) ? cancelFlight(group) : fly(group, indicator, from, to);
1571
2266
  const previous = flights.get(group);
1572
- const source = from ?? (moving(previous) ? previous?.copyOf : void 0);
2267
+ const source = from ?? (moving$1(previous) ? previous?.copyOf : void 0);
1573
2268
  if (!source) return;
1574
2269
  const look = copyLook(group, source, to);
1575
2270
  if (!look) return;
@@ -1657,7 +2352,7 @@ function along$1(rect, axis) {
1657
2352
  size: rect.height
1658
2353
  };
1659
2354
  }
1660
- function measure$1(motion) {
2355
+ function measure$2(motion) {
1661
2356
  const { thumb, track, axis } = motion;
1662
2357
  motion.zoom = zoomOf(track);
1663
2358
  const shown = along$1(rectOf(thumb, motion), axis);
@@ -1728,7 +2423,7 @@ function start$1(thumb, value) {
1728
2423
  tail: createSpring(0, () => draw$2(motion), trail),
1729
2424
  ownTranslate: split(thumb.style.translate)
1730
2425
  };
1731
- motion.layout = measure$1(motion);
2426
+ motion.layout = measure$2(motion);
1732
2427
  motion.position.set(motion.layout);
1733
2428
  motions.set(thumb, motion);
1734
2429
  return motion;
@@ -1871,7 +2566,7 @@ function follow(thumb, value, from, to) {
1871
2566
  const existing = motions.get(thumb);
1872
2567
  const motion = existing ?? start$1(thumb, value);
1873
2568
  if (!motion) return;
1874
- const next = measure$1(motion);
2569
+ const next = measure$2(motion);
1875
2570
  if (!existing) {
1876
2571
  const was = from === void 0 || to === void 0 ? void 0 : previousCenter(motion, value, from, to);
1877
2572
  motion.position.set(was ?? next);
@@ -1947,7 +2642,7 @@ const slider = {
1947
2642
  }
1948
2643
  };
1949
2644
  // src/motion/effects/switch.ts
1950
- const travel = {
2645
+ const travel$2 = {
1951
2646
  stiffness: 300,
1952
2647
  damping: 24
1953
2648
  };
@@ -1975,7 +2670,7 @@ function isOn(value) {
1975
2670
  return value === "true";
1976
2671
  }
1977
2672
  /** Reads where the stylesheet puts the knob in the current state, without what the effect wrote. */
1978
- function measure(element, knob) {
2673
+ function measure$1(element, knob) {
1979
2674
  writeMotionStyle(knob, {
1980
2675
  translate: null,
1981
2676
  scale: null
@@ -2061,7 +2756,7 @@ function knobOf(element, wasOn) {
2061
2756
  position: createSpring(value, (position, velocity) => {
2062
2757
  state.velocity = velocity;
2063
2758
  redraw();
2064
- }, travel),
2759
+ }, travel$2),
2065
2760
  velocity: 0,
2066
2761
  size: createSpring(value, redraw, size),
2067
2762
  press: createSpring(0, redraw, pressSpring),
@@ -2073,7 +2768,7 @@ function knobOf(element, wasOn) {
2073
2768
  }
2074
2769
  /** Measures the state that the stylesheet draws now and keeps it as the rest of that state. */
2075
2770
  function remeasure(element, state, on) {
2076
- const { rest, translate, width, height } = measure(element, state.knob);
2771
+ const { rest, translate, width, height } = measure$1(element, state.knob);
2077
2772
  state.rest[on ? 1 : 0] = rest;
2078
2773
  state.now = {
2079
2774
  on,
@@ -2115,7 +2810,7 @@ const switchKnob = {
2115
2810
  }
2116
2811
  };
2117
2812
  // src/motion/effects/toast.ts
2118
- const crossfade$1 = .15;
2813
+ const crossfade$2 = .15;
2119
2814
  const lists = /* @__PURE__ */ new WeakMap();
2120
2815
  const fixed = (element) => !!element && getComputedStyle(element).position === "fixed";
2121
2816
  function isToast(element) {
@@ -2242,7 +2937,7 @@ function leave$1(list, element) {
2242
2937
  writeMotionStyle(ghost, { opacity: String(value) });
2243
2938
  if (!fade.active && value === 0) ghost.remove();
2244
2939
  });
2245
- fade.to(0, { tween: crossfade$1 });
2940
+ fade.to(0, { tween: crossfade$2 });
2246
2941
  } else {
2247
2942
  const { axis, distance: target } = exitOf(rect, swipeDirection ?? direction);
2248
2943
  const spring = createSpring(0, (value) => {
@@ -2311,7 +3006,7 @@ const toast = {
2311
3006
  const fade = createSpring(0, () => write(element, item.x, item.y, fade));
2312
3007
  item.fade = fade;
2313
3008
  fade.set(0);
2314
- fade.to(1, { tween: crossfade$1 });
3009
+ fade.to(1, { tween: crossfade$2 });
2315
3010
  } else {
2316
3011
  item.y.set(pastEdge(rect));
2317
3012
  item.y.to(0);
@@ -2341,7 +3036,7 @@ const goneAfter = 520;
2341
3036
  const labelIn = .24;
2342
3037
  const labelOutOnSlide = .15;
2343
3038
  const labelOutOnLeave = .14;
2344
- const crossfade = .15;
3039
+ const crossfade$1 = .15;
2345
3040
  const tips = /* @__PURE__ */ new WeakMap();
2346
3041
  const openTips = /* @__PURE__ */ new Set();
2347
3042
  const exitBoxes = /* @__PURE__ */ new Set();
@@ -2489,15 +3184,18 @@ function draw(box) {
2489
3184
  });
2490
3185
  }
2491
3186
  }
2492
- function settle(box) {
2493
- if (box.holding || box.timers.size || [
3187
+ function moving(box) {
3188
+ return box.holding || box.timers.size > 0 || [
2494
3189
  box.x,
2495
3190
  box.y,
2496
3191
  box.width,
2497
3192
  box.label,
2498
3193
  box.fade,
2499
3194
  box.old?.spring
2500
- ].some((spring) => spring?.active)) return;
3195
+ ].some((spring) => spring?.active);
3196
+ }
3197
+ function settle(box) {
3198
+ if (moving(box)) return;
2501
3199
  box.old?.element.remove();
2502
3200
  box.old = void 0;
2503
3201
  writeMotionStyle(box.element, {
@@ -2642,7 +3340,7 @@ function start(element, tip) {
2642
3340
  if (from) leaveGhost(from, true);
2643
3341
  box.fade.set(0);
2644
3342
  box.holding = false;
2645
- box.fade.to(1, { tween: crossfade });
3343
+ box.fade.to(1, { tween: crossfade$1 });
2646
3344
  return;
2647
3345
  }
2648
3346
  if (from) {
@@ -2692,7 +3390,7 @@ function leaveGhost(box, reduced) {
2692
3390
  box.holding = false;
2693
3391
  if (reduced) {
2694
3392
  box.done = () => removeGhost(box);
2695
- box.fade.to(0, { tween: crossfade });
3393
+ box.fade.to(0, { tween: crossfade$1 });
2696
3394
  return;
2697
3395
  }
2698
3396
  if (box.handoff) handoff = box;
@@ -2846,7 +3544,9 @@ function checkMoves() {
2846
3544
  if (!tip || !box) continue;
2847
3545
  const rest = measureRest(element);
2848
3546
  const text = labelText(box);
2849
- if (!(Math.abs(rest.left - box.rest.left) > 1 || Math.abs(rest.top - box.rest.top) > 1 || Math.abs(rest.width - box.rest.width) > 1) && text === tip.text) continue;
3547
+ const moved = Math.abs(rest.left - box.rest.left) > 1 || Math.abs(rest.top - box.rest.top) > 1 || Math.abs(rest.width - box.rest.width) > 1;
3548
+ const resized = (moved || Math.abs(rest.height - box.rest.height) > 1) && !box.handoff && !moving(box) && Math.abs(rest.left + rest.width / 2 - (box.rest.left + box.rest.width / 2)) <= 1 && Math.abs(rest.top - box.rest.top) <= 1;
3549
+ if (!moved && !resized && text === tip.text) continue;
2850
3550
  const old = text === tip.text ? [] : tip.label;
2851
3551
  tip.trigger = findTrigger(element) ?? tip.trigger;
2852
3552
  const triggerRect = tip.trigger?.getBoundingClientRect();
@@ -2855,7 +3555,7 @@ function checkMoves() {
2855
3555
  box.rest = rest;
2856
3556
  box.side = sideOf(element, rest, triggerRect);
2857
3557
  box.edge = edgeOf(box.side, rest, triggerRect);
2858
- if (prefersReducedMotion()) {
3558
+ if (prefersReducedMotion() || resized) {
2859
3559
  box.x.set(rest.left + rest.width / 2);
2860
3560
  box.y.set(rest.top + rest.height / 2);
2861
3561
  box.width.set(rest.width);
@@ -2959,4 +3659,1028 @@ const motionEffects = [
2959
3659
  leave$2,
2960
3660
  panel
2961
3661
  ];
2962
- export { divider as _, switchKnob as a, press as c, buttonIcon as d, label as f, installMotion as g, check as h, toast as i, panel as l, disclosure as m, appear as n, slider as o, jelly as p, tooltip as r, select as s, motionEffects as t, leave$2 as u };
3662
+ // src/motion/helpers/number.ts
3663
+ const travel$1 = 1;
3664
+ const blur = 2;
3665
+ const out = {
3666
+ duration: 240,
3667
+ ease: easeIn
3668
+ };
3669
+ const into = {
3670
+ duration: 380,
3671
+ delay: 60,
3672
+ ease: cubicBezier(.3, 1.4, .5, 1)
3673
+ };
3674
+ const crossfade = 150;
3675
+ const rolls = /* @__PURE__ */ new WeakMap();
3676
+ const values = /* @__PURE__ */ new WeakMap();
3677
+ function glyph(char) {
3678
+ const node = glyphNode(char);
3679
+ node.style.gridArea = "1 / 1";
3680
+ return {
3681
+ node,
3682
+ shown: 1
3683
+ };
3684
+ }
3685
+ function column(char) {
3686
+ const node = own(document.createElement("span"));
3687
+ node.style.cssText = "display:inline-grid;overflow:hidden;justify-items:center";
3688
+ const current = char ? glyph(char) : void 0;
3689
+ if (current) node.append(current.node);
3690
+ return {
3691
+ node,
3692
+ char,
3693
+ current,
3694
+ leaving: /* @__PURE__ */ new Set()
3695
+ };
3696
+ }
3697
+ function paint(item, value, direction, reducedMotion) {
3698
+ item.shown = value;
3699
+ const gone = 1 - value;
3700
+ writeMotionStyle(item.node, {
3701
+ opacity: value >= 1 ? null : String(Math.max(0, value)),
3702
+ filter: reducedMotion || value >= 1 ? null : `blur(${Math.max(0, blur * gone).toFixed(2)}px)`,
3703
+ scale: reducedMotion || value === 1 ? null : String(1 - .44999999999999996 * gone),
3704
+ translate: reducedMotion || value === 1 ? null : `0 ${(direction * travel$1 * gone).toFixed(3)}em`
3705
+ });
3706
+ }
3707
+ function idle(roll) {
3708
+ return !roll.frame.width.active && roll.columns.every((item) => !item.leaving.size && !item.current?.fade);
3709
+ }
3710
+ function finishIfIdle(element, roll) {
3711
+ if (rolls.get(element) !== roll || !idle(roll)) return;
3712
+ rolls.delete(element);
3713
+ roll.frame.collapse(roll.text);
3714
+ }
3715
+ /**
3716
+ * Rolls the number in `element` to `value`, as rule 6 of docs/design/motion.md asks: only the digits that change roll,
3717
+ * up when the number grows and down when it shrinks. The width of the element follows with a spring. `format` turns the
3718
+ * number into its text, such as `n => n.toLocaleString()`. The default is `String`.
3719
+ *
3720
+ * Call it again at any time: a digit that is still rolling in rolls out from where it is. The element keeps the final
3721
+ * text for screen readers, and holds plain text again when the roll ends. Under reduced motion the changed digits
3722
+ * crossfade in 150ms. Inside `data-motion="none"`, or before the element is on the page, it sets the text at once.
3723
+ */
3724
+ function rollNumber(element, value, format = String) {
3725
+ const text = format(value);
3726
+ let roll = rolls.get(element);
3727
+ const before = roll?.text ?? element.textContent ?? "";
3728
+ const previous = roll?.value ?? values.get(element) ?? parseCount(before);
3729
+ values.set(element, value);
3730
+ if (previous === void 0 || !roll && before === text || glyphMotionSkipped(element)) {
3731
+ if (roll) {
3732
+ for (const item of roll.columns) for (const g of [item.current, ...item.leaving]) g?.fade?.stop();
3733
+ rolls.delete(element);
3734
+ }
3735
+ setText(element, text);
3736
+ return;
3737
+ }
3738
+ const direction = value > previous ? 1 : value < previous ? -1 : 0;
3739
+ const reducedMotion = reduced();
3740
+ if (!roll) {
3741
+ const frame = frameOf$2(element) ?? openFrame(element, "end", () => {
3742
+ const running = rolls.get(element);
3743
+ if (running) finishIfIdle(element, running);
3744
+ });
3745
+ const columns = [...before].map(column);
3746
+ frame.holder.append(...columns.map((item) => item.node));
3747
+ frame.width.set(frame.natural());
3748
+ roll = {
3749
+ frame,
3750
+ text: before,
3751
+ value: previous,
3752
+ columns
3753
+ };
3754
+ rolls.set(element, roll);
3755
+ }
3756
+ const state = roll;
3757
+ state.frame.restore();
3758
+ state.text = text;
3759
+ state.value = value;
3760
+ state.frame.name(text);
3761
+ const chars = [...text];
3762
+ const count = Math.max(chars.length, state.columns.length);
3763
+ while (state.columns.length < count) {
3764
+ const added = column("");
3765
+ state.frame.holder.prepend(added.node);
3766
+ state.columns.unshift(added);
3767
+ }
3768
+ const offset = count - chars.length;
3769
+ state.columns.forEach((item, index) => {
3770
+ const next = chars[index - offset] ?? "";
3771
+ if (next === item.char) return;
3772
+ item.char = next;
3773
+ const old = item.current;
3774
+ if (old) {
3775
+ old.fade?.stop();
3776
+ item.leaving.add(old);
3777
+ old.fade = tween(old.shown, 0, reducedMotion ? {
3778
+ duration: crossfade,
3779
+ ease: easeOut
3780
+ } : out, (v) => paint(old, v, -direction, reducedMotion), () => {
3781
+ old.fade = void 0;
3782
+ old.node.remove();
3783
+ item.leaving.delete(old);
3784
+ settleColumns(element, state);
3785
+ });
3786
+ }
3787
+ item.current = void 0;
3788
+ if (!next) return;
3789
+ const incoming = glyph(next);
3790
+ item.current = incoming;
3791
+ item.node.append(incoming.node);
3792
+ paint(incoming, 0, direction, reducedMotion);
3793
+ incoming.fade = tween(0, 1, reducedMotion ? {
3794
+ duration: crossfade,
3795
+ ease: easeOut
3796
+ } : into, (v) => paint(incoming, v, direction, reducedMotion), () => {
3797
+ incoming.fade = void 0;
3798
+ paint(incoming, 1, direction, reducedMotion);
3799
+ settleColumns(element, state);
3800
+ });
3801
+ });
3802
+ const width = state.frame.width;
3803
+ const leavingColumns = state.columns.filter((item) => !item.char);
3804
+ for (const item of leavingColumns) item.node.style.display = "none";
3805
+ const end = state.frame.natural();
3806
+ for (const item of leavingColumns) item.node.style.display = "inline-grid";
3807
+ if (reducedMotion) width.set(end);
3808
+ else width.to(end);
3809
+ }
3810
+ function parseCount(text) {
3811
+ const digits = text.replace(/[^\d.-]/g, "");
3812
+ const value = digits ? Number(digits) : NaN;
3813
+ return Number.isFinite(value) ? value : void 0;
3814
+ }
3815
+ function settleColumns(element, roll) {
3816
+ if (rolls.get(element) !== roll) return;
3817
+ roll.columns = roll.columns.filter((item) => {
3818
+ if (item.char || item.leaving.size) return true;
3819
+ item.node.remove();
3820
+ return false;
3821
+ });
3822
+ finishIfIdle(element, roll);
3823
+ }
3824
+ // src/motion/helpers/shake.ts
3825
+ const duration = .4;
3826
+ const step = cubicBezier(.36, .07, .19, .97);
3827
+ const frames = [
3828
+ [0, 0],
3829
+ [.1, -1],
3830
+ [.2, 3],
3831
+ [.3, -5],
3832
+ [.4, 5],
3833
+ [.5, -5],
3834
+ [.6, 5],
3835
+ [.7, -5],
3836
+ [.8, 3],
3837
+ [.9, -1],
3838
+ [1, 0]
3839
+ ];
3840
+ const shaking = /* @__PURE__ */ new WeakMap();
3841
+ /** The offset in pixels at `progress` of the shake: each step between two frames runs on the curve. */
3842
+ function shakeOffset(progress) {
3843
+ const index = Math.max(0, frames.findIndex(([at]) => at >= progress) - 1);
3844
+ const [fromAt, from] = frames[index];
3845
+ const [toAt, to] = frames[index + 1] ?? frames[index];
3846
+ const local = toAt > fromAt ? (progress - fromAt) / (toAt - fromAt) : 1;
3847
+ return from + (to - from) * step(Math.min(1, Math.max(0, local)));
3848
+ }
3849
+ /**
3850
+ * Shakes `element` from side to side once, when it refuses an action but keeps what the person wrote, such as a comment
3851
+ * box that Esc did not close. A second call starts the shake again. Under reduced motion and inside
3852
+ * `data-motion="none"` it does nothing: show the refusal with a color instead.
3853
+ */
3854
+ function shake(element) {
3855
+ shaking.get(element)?.();
3856
+ if (motionSkipped(element) || reduced()) return;
3857
+ const timeline = playTween(duration, (progress) => writeMotionStyle(element, { translate: progress >= 1 ? null : `${shakeOffset(progress).toFixed(2)}px 0` }));
3858
+ const stop = () => {
3859
+ timeline.stop();
3860
+ shaking.delete(element);
3861
+ writeMotionStyle(element, { translate: null });
3862
+ };
3863
+ shaking.set(element, stop);
3864
+ timeline.done.then((completed) => completed && stop());
3865
+ }
3866
+ // src/motion/helpers/travel.ts
3867
+ /**
3868
+ * The offset that draws a box `rest` as the box `box`, when the scale turns around the point `origin` of the screen.
3869
+ * The layer writes the separate `translate` and `scale` properties, which apply around the same point as the element's
3870
+ * own transform, so the element can keep a transform of its own.
3871
+ */
3872
+ function travelOffset(rest, origin, box) {
3873
+ const scaleX = rest.width ? box.width / rest.width : 1;
3874
+ const scaleY = rest.height ? box.height / rest.height : 1;
3875
+ return {
3876
+ x: box.left - origin.x - scaleX * (rest.left - origin.x),
3877
+ y: box.top - origin.y - scaleY * (rest.top - origin.y),
3878
+ scaleX,
3879
+ scaleY
3880
+ };
3881
+ }
3882
+ const running = /* @__PURE__ */ new WeakMap();
3883
+ const keys = [
3884
+ "left",
3885
+ "top",
3886
+ "width",
3887
+ "height"
3888
+ ];
3889
+ /** The element's box with nothing of the travel written, and the point of the screen that its scale turns around. */
3890
+ function measure(element) {
3891
+ const { translate, scale } = element.style;
3892
+ writeMotionStyle(element, {
3893
+ translate: null,
3894
+ scale: null
3895
+ });
3896
+ const box = element.getBoundingClientRect();
3897
+ writeMotionStyle(element, { scale: "0.5" });
3898
+ const half = element.getBoundingClientRect();
3899
+ writeMotionStyle(element, { translate: "100px 100px" });
3900
+ const shifted = element.getBoundingClientRect();
3901
+ writeMotionStyle(element, {
3902
+ translate,
3903
+ scale
3904
+ });
3905
+ return {
3906
+ box,
3907
+ origin: {
3908
+ x: 2 * half.left - box.left,
3909
+ y: 2 * half.top - box.top
3910
+ },
3911
+ pixels: {
3912
+ x: (shifted.left - half.left) / 100 || 1,
3913
+ y: (shifted.top - half.top) / 100 || 1
3914
+ }
3915
+ };
3916
+ }
3917
+ /**
3918
+ * Rule 8 for a thing that moves to a new place: a picture that opens larger from where it is in the page, and goes back
3919
+ * there when it closes. The element travels from `from` to its own place, or from where it is to `to`, on a spring for
3920
+ * each of its position and its size, and keeps its speed when a new travel starts in the middle of one.
3921
+ *
3922
+ * The page lays the element out at its new place first; the travel only draws it on the way there, with `translate`
3923
+ * and `scale`. Under reduced motion and inside `data-motion="none"` a new travel leaves the element at its own place,
3924
+ * and `done` is false. If reduced motion turns on during a travel, it lands at once.
3925
+ */
3926
+ function travel(element, options) {
3927
+ const previous = running.get(element);
3928
+ if (motionSkipped(element) || reduced()) {
3929
+ previous?.stop();
3930
+ return {
3931
+ done: Promise.resolve(false),
3932
+ stop() {}
3933
+ };
3934
+ }
3935
+ const { box, origin, pixels } = measure(element);
3936
+ const target = options.to ?? box;
3937
+ const preset = options.preset ?? springs.snappy;
3938
+ let finish;
3939
+ const done = new Promise((resolve) => {
3940
+ finish = resolve;
3941
+ });
3942
+ const draw = () => {
3943
+ if (running.get(element) !== motion) return;
3944
+ const offset = travelOffset(box, origin, {
3945
+ left: parts.left.value,
3946
+ top: parts.top.value,
3947
+ width: parts.width.value,
3948
+ height: parts.height.value
3949
+ });
3950
+ writeMotionStyle(element, {
3951
+ translate: `${offset.x / pixels.x}px ${offset.y / pixels.y}px`,
3952
+ scale: `${offset.scaleX} ${offset.scaleY}`
3953
+ });
3954
+ if (keys.some((key) => parts[key].active)) return;
3955
+ unwatch();
3956
+ if (!options.to) {
3957
+ running.delete(element);
3958
+ writeMotionStyle(element, {
3959
+ translate: null,
3960
+ scale: null
3961
+ });
3962
+ }
3963
+ finish(true);
3964
+ };
3965
+ const spring = (key) => createSpring(options.from?.[key] ?? previous?.parts[key].value ?? box[key], draw, preset);
3966
+ const parts = {
3967
+ left: spring("left"),
3968
+ top: spring("top"),
3969
+ width: spring("width"),
3970
+ height: spring("height")
3971
+ };
3972
+ const velocity = keys.map((key) => previous?.parts[key].velocity ?? 0);
3973
+ const unwatch = onReducedMotionChange((isReduced) => {
3974
+ if (isReduced) for (const key of keys) parts[key].set(target[key]);
3975
+ });
3976
+ const motion = {
3977
+ parts,
3978
+ stop() {
3979
+ if (running.get(element) !== motion) return;
3980
+ unwatch();
3981
+ for (const key of keys) parts[key].stop();
3982
+ running.delete(element);
3983
+ writeMotionStyle(element, {
3984
+ translate: null,
3985
+ scale: null
3986
+ });
3987
+ finish(false);
3988
+ }
3989
+ };
3990
+ previous?.stop();
3991
+ running.set(element, motion);
3992
+ keys.forEach((key, index) => parts[key].to(target[key], { velocity: velocity[index] }));
3993
+ draw();
3994
+ return {
3995
+ done,
3996
+ stop: motion.stop
3997
+ };
3998
+ }
3999
+ // src/motion/list.ts
4000
+ const grow = {
4001
+ stiffness: 380,
4002
+ damping: 26
4003
+ };
4004
+ const fold = {
4005
+ stiffness: 260,
4006
+ damping: 28
4007
+ };
4008
+ const slotScale = .9;
4009
+ const leaveDuration = .32;
4010
+ const leaveEasing = cubicBezier(.5, 0, .75, 0);
4011
+ const ghostAttribute = "data-motion-ghost";
4012
+ const center = (rect) => ({
4013
+ x: rect.left + rect.width / 2,
4014
+ y: rect.top + rect.height / 2
4015
+ });
4016
+ function onScreen(rect) {
4017
+ return rect.bottom > 0 && rect.right > 0 && rect.top < innerHeight && rect.left < innerWidth && rect.width + rect.height > 0;
4018
+ }
4019
+ function defaultItems(container) {
4020
+ return [...container.children].filter((child) => child instanceof HTMLElement && !child.hasAttribute(ghostAttribute));
4021
+ }
4022
+ /**
4023
+ * The list mover of docs/design/motion.md: "Items are added, removed, or reordered". It is FLIP with the springs of the
4024
+ * motion layer. Call `measure()` before a change and `play()` after it.
4025
+ *
4026
+ * Neighbors spring to their new place and keep their speed when a second change comes before they settle. A new item
4027
+ * grows from its origin, such as the row it duplicates, or from its slot. A removed item folds away, or leaves toward
4028
+ * `target`. Items that are off screen before and after the change do not move, so a long list costs one read per item.
4029
+ * Under reduced motion nothing travels: a new item and a removed item cross-fade in 150ms. Inside `data-motion="none"`
4030
+ * nothing moves.
4031
+ */
4032
+ function createMotionList(container, options = {}) {
4033
+ const items = options.items ?? defaultItems;
4034
+ const motions = /* @__PURE__ */ new Map();
4035
+ const ghosts = /* @__PURE__ */ new Set();
4036
+ let snapshot = /* @__PURE__ */ new Map();
4037
+ let starting = false;
4038
+ function offset(motion) {
4039
+ if (!motion) return {
4040
+ x: 0,
4041
+ y: 0
4042
+ };
4043
+ const rest = 1 - motion.grow.value;
4044
+ return {
4045
+ x: motion.x.value + motion.from.x * rest,
4046
+ y: motion.y.value + motion.from.y * rest
4047
+ };
4048
+ }
4049
+ function write(element, motion) {
4050
+ const { x, y, grow, from } = motion;
4051
+ if (!x.active && !y.active && !grow.active && x.value === 0 && y.value === 0 && grow.value === 1) {
4052
+ writeMotionStyle(element, {
4053
+ translate: null,
4054
+ scale: null,
4055
+ opacity: null
4056
+ });
4057
+ if (!starting) motions.delete(element);
4058
+ return;
4059
+ }
4060
+ const { x: dx, y: dy } = offset(motion);
4061
+ const scale = from.scale + (1 - from.scale) * grow.value;
4062
+ writeMotionStyle(element, {
4063
+ translate: dx || dy ? `${dx.toFixed(2)}px ${dy.toFixed(2)}px` : null,
4064
+ scale: scale === 1 ? null : scale.toFixed(4),
4065
+ opacity: grow.value >= 1 ? null : Math.max(0, Math.min(1, grow.value)).toFixed(3)
4066
+ });
4067
+ }
4068
+ function motionOf(element) {
4069
+ let motion = motions.get(element);
4070
+ if (motion) return motion;
4071
+ const draw = () => motion && write(element, motion);
4072
+ motion = {
4073
+ x: createSpring(0, draw, springs.snappy),
4074
+ y: createSpring(0, draw, springs.snappy),
4075
+ grow: createSpring(1, draw, grow),
4076
+ from: {
4077
+ x: 0,
4078
+ y: 0,
4079
+ scale: 1
4080
+ }
4081
+ };
4082
+ motions.set(element, motion);
4083
+ return motion;
4084
+ }
4085
+ function stopItem(element) {
4086
+ const motion = motions.get(element);
4087
+ if (!motion) return;
4088
+ motions.delete(element);
4089
+ motion.x.stop();
4090
+ motion.y.stop();
4091
+ motion.grow.stop();
4092
+ writeMotionStyle(element, {
4093
+ translate: null,
4094
+ scale: null,
4095
+ opacity: null
4096
+ });
4097
+ }
4098
+ function travel(spring, from) {
4099
+ const velocity = spring.velocity;
4100
+ spring.set(from);
4101
+ spring.to(0, {
4102
+ preset: springs.snappy,
4103
+ velocity
4104
+ });
4105
+ }
4106
+ function leave(element, before, target) {
4107
+ if (!onScreen(before)) return;
4108
+ const box = container.getBoundingClientRect();
4109
+ if (getComputedStyle(container).position === "static") container.style.position = "relative";
4110
+ const ghost = visualCopy(element);
4111
+ ghost.setAttribute(ghostAttribute, "");
4112
+ Object.assign(ghost.style, {
4113
+ boxSizing: "border-box",
4114
+ height: `${before.height}px`,
4115
+ left: `${before.left - box.left - container.clientLeft + container.scrollLeft}px`,
4116
+ margin: "0",
4117
+ pointerEvents: "none",
4118
+ position: "absolute",
4119
+ top: `${before.top - box.top - container.clientTop + container.scrollTop}px`,
4120
+ width: `${before.width}px`
4121
+ });
4122
+ writeMotionStyle(ghost, {
4123
+ translate: null,
4124
+ scale: null,
4125
+ opacity: null,
4126
+ filter: null
4127
+ });
4128
+ container.append(ghost);
4129
+ const entry = {
4130
+ element: ghost,
4131
+ stop: () => {}
4132
+ };
4133
+ const end = () => {
4134
+ entry.stop();
4135
+ ghost.remove();
4136
+ ghosts.delete(entry);
4137
+ };
4138
+ ghosts.add(entry);
4139
+ if (prefersReducedMotion()) {
4140
+ const tween = playTween(.15, (p) => writeMotionStyle(ghost, { opacity: (1 - p).toFixed(3) }));
4141
+ entry.stop = tween.stop;
4142
+ tween.done.then(end);
4143
+ return;
4144
+ }
4145
+ if (target) {
4146
+ const to = center(target.getBoundingClientRect());
4147
+ const from = center(before);
4148
+ const tween = playTween(leaveDuration, (p) => {
4149
+ writeMotionStyle(ghost, {
4150
+ translate: `${((to.x - from.x) * p).toFixed(2)}px ${((to.y - from.y) * p).toFixed(2)}px`,
4151
+ scale: (1 - .8 * p).toFixed(4),
4152
+ opacity: (1 - p).toFixed(3),
4153
+ filter: p > 0 ? `blur(${(3 * p).toFixed(2)}px)` : null
4154
+ });
4155
+ }, leaveEasing);
4156
+ entry.stop = tween.stop;
4157
+ tween.done.then(end);
4158
+ return;
4159
+ }
4160
+ const spring = createSpring(1, (value) => {
4161
+ writeMotionStyle(ghost, {
4162
+ scale: (slotScale + .09999999999999998 * value).toFixed(4),
4163
+ opacity: Math.max(0, value).toFixed(3)
4164
+ });
4165
+ if (value < .02) end();
4166
+ }, fold);
4167
+ entry.stop = () => spring.stop();
4168
+ spring.to(0);
4169
+ }
4170
+ return {
4171
+ measure() {
4172
+ snapshot = /* @__PURE__ */ new Map();
4173
+ for (const element of items(container)) {
4174
+ const rect = element.getBoundingClientRect();
4175
+ if (!rect.width && !rect.height) continue;
4176
+ const now = center(rect);
4177
+ const shift = offset(motions.get(element));
4178
+ snapshot.set(element, {
4179
+ x: now.x - shift.x,
4180
+ y: now.y - shift.y,
4181
+ rect
4182
+ });
4183
+ }
4184
+ },
4185
+ play(play = {}) {
4186
+ const before = snapshot;
4187
+ snapshot = /* @__PURE__ */ new Map();
4188
+ const off = isMotionOff(container);
4189
+ const current = items(container);
4190
+ const present = new Set(current);
4191
+ const reads = current.map((element) => {
4192
+ const rect = element.getBoundingClientRect();
4193
+ const shift = offset(motions.get(element));
4194
+ const now = center(rect);
4195
+ return {
4196
+ element,
4197
+ rect,
4198
+ layout: {
4199
+ x: now.x - shift.x,
4200
+ y: now.y - shift.y
4201
+ }
4202
+ };
4203
+ });
4204
+ const origins = reads.map(({ element }) => {
4205
+ if (before.has(element) || !play.origin) return void 0;
4206
+ return (typeof play.origin === "function" ? play.origin(element) : play.origin)?.getBoundingClientRect();
4207
+ });
4208
+ for (const [element, { rect }] of before) {
4209
+ if (present.has(element)) continue;
4210
+ stopItem(element);
4211
+ if (!off && !options.movesOnly && !element.hasAttribute("data-motion-leaving")) leave(element, rect, play.target);
4212
+ }
4213
+ starting = true;
4214
+ reads.forEach(({ element, rect, layout }, index) => {
4215
+ if (off) return stopItem(element);
4216
+ const old = before.get(element);
4217
+ if (old) {
4218
+ const dx = old.x - layout.x;
4219
+ const dy = old.y - layout.y;
4220
+ if (Math.abs(dx) < .5 && Math.abs(dy) < .5) return;
4221
+ if (!onScreen(old.rect) && !onScreen(rect)) return stopItem(element);
4222
+ const motion = motionOf(element);
4223
+ travel(motion.x, motion.x.value + dx);
4224
+ travel(motion.y, motion.y.value + dy);
4225
+ return;
4226
+ }
4227
+ if (!onScreen(rect) || options.movesOnly) return;
4228
+ const motion = motionOf(element);
4229
+ const origin = origins[index];
4230
+ if (prefersReducedMotion()) motion.from = {
4231
+ x: 0,
4232
+ y: 0,
4233
+ scale: 1
4234
+ };
4235
+ else if (origin) {
4236
+ const start = center(origin);
4237
+ const scale = Math.min(1, Math.max(.2, Math.min(origin.width / (rect.width || 1), origin.height / (rect.height || 1))));
4238
+ motion.from = {
4239
+ x: start.x - layout.x,
4240
+ y: start.y - layout.y,
4241
+ scale
4242
+ };
4243
+ } else motion.from = {
4244
+ x: 0,
4245
+ y: 0,
4246
+ scale: slotScale
4247
+ };
4248
+ motion.grow.set(0);
4249
+ motion.grow.to(1, prefersReducedMotion() ? { tween: .15 } : { preset: grow });
4250
+ });
4251
+ starting = false;
4252
+ },
4253
+ destroy() {
4254
+ for (const element of motions.keys()) stopItem(element);
4255
+ for (const ghost of ghosts) {
4256
+ ghost.stop();
4257
+ ghost.element.remove();
4258
+ }
4259
+ ghosts.clear();
4260
+ snapshot = /* @__PURE__ */ new Map();
4261
+ }
4262
+ };
4263
+ }
4264
+ // src/motion/progress.ts
4265
+ const svgNs = "http://www.w3.org/2000/svg";
4266
+ const height = 8;
4267
+ const rail = 2;
4268
+ const bar = 4;
4269
+ const bulge = 4;
4270
+ const headWidth = 10;
4271
+ const waveWidth = 36;
4272
+ const waveSpeed = 260;
4273
+ const settleRate = 3;
4274
+ const tickEasing = cubicBezier(.6, 0, .2, 1);
4275
+ const tickPath = "M5 12.5l4.5 4.5L19 7.5";
4276
+ function svg(tag, attributes) {
4277
+ const element = document.createElementNS(svgNs, tag);
4278
+ for (const [name, value] of Object.entries(attributes)) element.setAttribute(name, value);
4279
+ return element;
4280
+ }
4281
+ function line(x0, x1, thickness) {
4282
+ const y = height / 2;
4283
+ const top = [];
4284
+ const bottom = [];
4285
+ for (let x = x0; x <= x1 + .01; x += 1.5) {
4286
+ const half = thickness(Math.min(x, x1)) / 2;
4287
+ top.push(`${Math.min(x, x1).toFixed(2)} ${(y - half).toFixed(2)}`);
4288
+ bottom.unshift(`${Math.min(x, x1).toFixed(2)} ${(y + half).toFixed(2)}`);
4289
+ }
4290
+ if (!top.length) return "";
4291
+ const end = thickness(x1) / 2;
4292
+ const start = thickness(x0) / 2;
4293
+ return `M${top.join("L")}A${end.toFixed(2)} ${end.toFixed(2)} 0 0 1 ${bottom[0]}L${bottom.join("L")}A${start.toFixed(2)} ${start.toFixed(2)} 0 0 1 ${top[0]}Z`;
4294
+ }
4295
+ /**
4296
+ * The progress helper of docs/design/motion.md: "Work runs". It draws into `host`: a bar with a head while it fills, a
4297
+ * wave while it processes with no known total, and a dot that draws into a check when the work is done.
4298
+ *
4299
+ * The host gets `role="progressbar"` with `aria-valuenow` from 0 to 100, no `aria-valuenow` during the wave, and
4300
+ * `data-phase`. The bar uses `currentColor`, and the rail `--vh-progress-rail` or the Nuxt UI accented border color.
4301
+ * Under reduced motion the bar jumps to its value, there is no head or wave, and the check cross-fades in 150ms. Inside
4302
+ * `data-motion="none"` the bar jumps and the check shows at once.
4303
+ */
4304
+ function createProgress(host, options = {}) {
4305
+ const chart = svg("svg", {
4306
+ "aria-hidden": "true",
4307
+ "data-part": "bar",
4308
+ height: String(height),
4309
+ preserveAspectRatio: "none"
4310
+ });
4311
+ const railPath = svg("path", {
4312
+ "data-part": "rail",
4313
+ fill: "var(--vh-progress-rail, var(--ui-border-accented, color-mix(in oklch, currentColor 20%, transparent)))"
4314
+ });
4315
+ const fillPath = svg("path", {
4316
+ "data-part": "fill",
4317
+ fill: "currentColor"
4318
+ });
4319
+ chart.append(railPath, fillPath);
4320
+ const check = svg("svg", {
4321
+ "aria-hidden": "true",
4322
+ "data-part": "check",
4323
+ fill: "none",
4324
+ stroke: "currentColor",
4325
+ "stroke-linecap": "round",
4326
+ "stroke-linejoin": "round",
4327
+ "stroke-width": "2",
4328
+ viewBox: "0 0 24 24"
4329
+ });
4330
+ const dot = svg("circle", {
4331
+ cx: "12",
4332
+ cy: "12",
4333
+ fill: "currentColor",
4334
+ r: "0",
4335
+ stroke: "none"
4336
+ });
4337
+ const tick = svg("path", {
4338
+ d: tickPath,
4339
+ pathLength: "1",
4340
+ "stroke-dasharray": "1",
4341
+ "stroke-dashoffset": "1"
4342
+ });
4343
+ check.append(dot, tick);
4344
+ Object.assign(chart.style, {
4345
+ display: "block",
4346
+ flex: "1 1 auto",
4347
+ minWidth: "0",
4348
+ overflow: "visible",
4349
+ width: "100%"
4350
+ });
4351
+ Object.assign(check.style, {
4352
+ flex: "none",
4353
+ height: "18px",
4354
+ width: "18px"
4355
+ });
4356
+ if (!host.style.display) Object.assign(host.style, {
4357
+ alignItems: "center",
4358
+ display: "flex",
4359
+ gap: "8px"
4360
+ });
4361
+ host.append(chart, check);
4362
+ host.setAttribute("role", "progressbar");
4363
+ host.setAttribute("aria-valuemin", "0");
4364
+ host.setAttribute("aria-valuemax", "100");
4365
+ if (options.label && !host.hasAttribute("aria-label")) host.setAttribute("aria-label", options.label);
4366
+ let phase = "idle";
4367
+ let width = chart.clientWidth;
4368
+ let wave = -40;
4369
+ let flat = 0;
4370
+ let stopWave;
4371
+ let stopTimeline = [];
4372
+ const still = () => prefersReducedMotion() || isMotionOff(host);
4373
+ const end = createSpring(0, () => draw(), springs.snappy);
4374
+ function draw() {
4375
+ width = chart.clientWidth || width;
4376
+ chart.setAttribute("viewBox", `0 0 ${Math.max(1, width)} ${height}`);
4377
+ const x0 = 2;
4378
+ const x1 = Math.max(x0, width - 2);
4379
+ railPath.setAttribute("d", line(x0, x1, () => rail));
4380
+ const shape = still() ? 0 : 1 - flat;
4381
+ if (phase === "wave" || phase === "done" && flat < 1 && stopWave) {
4382
+ fillPath.setAttribute("d", line(x0, x1, (x) => bar + bulge * shape * Math.exp(-(((x - wave) / waveWidth) ** 2))));
4383
+ return;
4384
+ }
4385
+ const head = x0 + (x1 - x0) * Math.max(0, Math.min(1, end.value));
4386
+ fillPath.setAttribute("d", phase === "idle" ? "" : line(x0, Math.max(x0, head), (x) => bar + bulge * shape * Math.exp(-(((x - head + headWidth) / headWidth) ** 2))));
4387
+ }
4388
+ function setPhase(next) {
4389
+ phase = next;
4390
+ host.dataset.phase = next;
4391
+ host.setAttribute("aria-busy", String(next === "fill" || next === "wave"));
4392
+ }
4393
+ function stopAll() {
4394
+ stopWave?.();
4395
+ stopWave = void 0;
4396
+ for (const stop of stopTimeline) stop();
4397
+ stopTimeline = [];
4398
+ }
4399
+ function startWave() {
4400
+ if (stopWave || still()) return;
4401
+ wave = -40;
4402
+ stopWave = onEachFrame((seconds) => {
4403
+ if (phase === "done") {
4404
+ flat = Math.min(1, flat + seconds * settleRate);
4405
+ wave += waveSpeed * seconds;
4406
+ draw();
4407
+ if (flat < 1) return true;
4408
+ end.set(1);
4409
+ stopWave = void 0;
4410
+ draw();
4411
+ drawCheck();
4412
+ return false;
4413
+ }
4414
+ wave = -40 + (wave + 40 + waveSpeed * seconds) % (width + 80);
4415
+ draw();
4416
+ return true;
4417
+ });
4418
+ }
4419
+ function clearCheck() {
4420
+ dot.setAttribute("r", "0");
4421
+ tick.setAttribute("stroke-dashoffset", "1");
4422
+ check.style.opacity = "";
4423
+ }
4424
+ function drawCheck() {
4425
+ if (isMotionOff(host)) {
4426
+ tick.setAttribute("stroke-dashoffset", "0");
4427
+ return;
4428
+ }
4429
+ if (prefersReducedMotion()) {
4430
+ check.style.opacity = "0";
4431
+ tick.setAttribute("stroke-dashoffset", "0");
4432
+ const fade = playTween(.15, (p) => check.style.opacity = p.toFixed(3));
4433
+ stopTimeline.push(fade.stop);
4434
+ return;
4435
+ }
4436
+ const grow = playTween(.32, (p) => {
4437
+ dot.setAttribute("r", (p <= .5 ? 7 * p : 3.5 - 3 * (p - .5)).toFixed(3));
4438
+ }, easeOut);
4439
+ stopTimeline.push(grow.stop);
4440
+ grow.done.then((completed) => {
4441
+ if (!completed) return;
4442
+ const shrink = playTween(.12, (p) => dot.setAttribute("r", (2 - 2 * p).toFixed(3)));
4443
+ const draw = playTween(.32, (p) => tick.setAttribute("stroke-dashoffset", (1 - p).toFixed(4)), tickEasing);
4444
+ stopTimeline.push(shrink.stop, draw.stop);
4445
+ });
4446
+ }
4447
+ function settleFill() {
4448
+ if (still()) {
4449
+ flat = 1;
4450
+ draw();
4451
+ drawCheck();
4452
+ return;
4453
+ }
4454
+ const wait = onEachFrame(() => {
4455
+ if (end.active) return true;
4456
+ const flatten = playTween(1 / settleRate, (p) => {
4457
+ flat = p;
4458
+ draw();
4459
+ });
4460
+ stopTimeline.push(flatten.stop);
4461
+ flatten.done.then((completed) => completed && drawCheck());
4462
+ return false;
4463
+ });
4464
+ stopTimeline.push(wait);
4465
+ }
4466
+ const resize = typeof ResizeObserver === "function" ? new ResizeObserver(() => draw()) : void 0;
4467
+ resize?.observe(chart);
4468
+ setPhase("idle");
4469
+ draw();
4470
+ return {
4471
+ get phase() {
4472
+ return phase;
4473
+ },
4474
+ set(value) {
4475
+ if (phase === "done") {
4476
+ stopAll();
4477
+ clearCheck();
4478
+ flat = 0;
4479
+ }
4480
+ if (value === null) {
4481
+ host.removeAttribute("aria-valuenow");
4482
+ setPhase("wave");
4483
+ startWave();
4484
+ draw();
4485
+ return;
4486
+ }
4487
+ const fraction = Math.max(0, Math.min(1, value));
4488
+ host.setAttribute("aria-valuenow", String(Math.round(fraction * 100)));
4489
+ if (phase === "wave") {
4490
+ stopWave?.();
4491
+ stopWave = void 0;
4492
+ }
4493
+ if (phase !== "fill") setPhase("fill");
4494
+ if (still()) end.set(fraction);
4495
+ else end.to(fraction);
4496
+ },
4497
+ done() {
4498
+ if (phase === "done") return;
4499
+ host.setAttribute("aria-valuenow", "100");
4500
+ const fromWave = phase === "wave" && stopWave !== void 0;
4501
+ setPhase("done");
4502
+ flat = 0;
4503
+ if (fromWave) return;
4504
+ if (still()) end.set(1);
4505
+ else end.to(1);
4506
+ settleFill();
4507
+ },
4508
+ reset() {
4509
+ stopAll();
4510
+ clearCheck();
4511
+ flat = 0;
4512
+ end.set(0);
4513
+ host.setAttribute("aria-valuenow", "0");
4514
+ setPhase("idle");
4515
+ draw();
4516
+ },
4517
+ destroy() {
4518
+ stopAll();
4519
+ end.stop();
4520
+ resize?.disconnect();
4521
+ chart.remove();
4522
+ check.remove();
4523
+ }
4524
+ };
4525
+ }
4526
+ // src/motion/drop-field.ts
4527
+ const gap = 14;
4528
+ const reach = 110;
4529
+ const lean = 3;
4530
+ const powerRate = .15;
4531
+ const dotRate = .2;
4532
+ const carriesFiles = (event) => [...event.dataTransfer?.types ?? []].includes("Files");
4533
+ const rate = (perFrame, seconds) => 1 - (1 - perFrame) ** (seconds * 60);
4534
+ /**
4535
+ * The drop field of docs/design/motion.md: "Files are dragged in". A grid of dots behind the content of `surface` leans
4536
+ * toward the dragged file and rests again when it leaves or drops. It wraps the native file drop of `field`: the drag
4537
+ * events, `dropEffect`, and `onFiles`. A click or a key that opens a file picker stays with the field's own controls.
4538
+ *
4539
+ * The dots use `--vh-drop-dot`, or the text color of the surface. Under reduced motion and inside `data-motion="none"`
4540
+ * the dots stay still; `data-over` still marks the field, so its colors change.
4541
+ */
4542
+ function createDropField(field, options = {}) {
4543
+ const surface = options.surface ?? field;
4544
+ const accepts = options.accepts ?? carriesFiles;
4545
+ const canvas = document.createElement("canvas");
4546
+ canvas.dataset.part = "dots";
4547
+ canvas.setAttribute("aria-hidden", "true");
4548
+ Object.assign(canvas.style, {
4549
+ height: "100%",
4550
+ inset: "0",
4551
+ pointerEvents: "none",
4552
+ position: "absolute",
4553
+ width: "100%",
4554
+ zIndex: "-1"
4555
+ });
4556
+ if (getComputedStyle(surface).position === "static") surface.style.position = "relative";
4557
+ surface.style.isolation = "isolate";
4558
+ surface.prepend(canvas);
4559
+ const context = canvas.getContext("2d");
4560
+ let dots = [];
4561
+ let pointer = {
4562
+ x: -999,
4563
+ y: -999
4564
+ };
4565
+ let over = false;
4566
+ let depth = 0;
4567
+ let power = 0;
4568
+ let stop;
4569
+ const still = () => prefersReducedMotion() || isMotionOff(surface);
4570
+ function build() {
4571
+ dots = [];
4572
+ for (let y = 10; y < surface.clientHeight; y += gap) for (let x = 10; x < surface.clientWidth; x += gap) dots.push({
4573
+ x,
4574
+ y,
4575
+ pull: 0
4576
+ });
4577
+ }
4578
+ function draw(seconds) {
4579
+ if (!context) return false;
4580
+ const ratio = devicePixelRatio || 1;
4581
+ const width = surface.clientWidth;
4582
+ const height = surface.clientHeight;
4583
+ if (canvas.width !== Math.round(width * ratio) || canvas.height !== Math.round(height * ratio)) {
4584
+ canvas.width = Math.round(width * ratio);
4585
+ canvas.height = Math.round(height * ratio);
4586
+ }
4587
+ context.setTransform(ratio, 0, 0, ratio, 0, 0);
4588
+ context.clearRect(0, 0, width, height);
4589
+ const style = getComputedStyle(surface);
4590
+ context.fillStyle = style.getPropertyValue("--vh-drop-dot").trim() || style.color;
4591
+ const target = over ? 1 : 0;
4592
+ const quiet = still();
4593
+ power += (target - power) * rate(powerRate, seconds);
4594
+ let moving = false;
4595
+ for (const dot of dots) {
4596
+ const distance = Math.hypot(dot.x - pointer.x, dot.y - pointer.y);
4597
+ const want = quiet ? 0 : power * Math.max(0, 1 - distance / reach) ** 2;
4598
+ dot.pull += (want - dot.pull) * rate(dotRate, seconds);
4599
+ if (Math.abs(want - dot.pull) > .002) moving = true;
4600
+ const shift = quiet ? 0 : dot.pull * lean;
4601
+ const angle = Math.atan2(pointer.y - dot.y, pointer.x - dot.x);
4602
+ context.globalAlpha = .16 + dot.pull * .7;
4603
+ context.beginPath();
4604
+ context.arc(dot.x + Math.cos(angle) * shift, dot.y + Math.sin(angle) * shift, .9 + dot.pull * 1.9, 0, Math.PI * 2);
4605
+ context.fill();
4606
+ }
4607
+ context.globalAlpha = 1;
4608
+ return moving || Math.abs(power - target) > .01;
4609
+ }
4610
+ function kick() {
4611
+ if (stop) return;
4612
+ stop = onEachFrame((seconds) => {
4613
+ if (draw(seconds)) return true;
4614
+ stop = void 0;
4615
+ return false;
4616
+ });
4617
+ }
4618
+ function setOver(next) {
4619
+ if (next === over) return;
4620
+ over = next;
4621
+ if (next) field.dataset.over = "";
4622
+ else delete field.dataset.over;
4623
+ kick();
4624
+ }
4625
+ function locate(event) {
4626
+ const box = surface.getBoundingClientRect();
4627
+ pointer = {
4628
+ x: event.clientX - box.left,
4629
+ y: event.clientY - box.top
4630
+ };
4631
+ }
4632
+ const onEnter = (event) => {
4633
+ if (!accepts(event)) return;
4634
+ event.preventDefault();
4635
+ depth++;
4636
+ locate(event);
4637
+ setOver(true);
4638
+ };
4639
+ const onOver = (event) => {
4640
+ if (!accepts(event)) return;
4641
+ event.preventDefault();
4642
+ if (event.dataTransfer) event.dataTransfer.dropEffect = "copy";
4643
+ locate(event);
4644
+ setOver(true);
4645
+ kick();
4646
+ };
4647
+ const onLeave = (event) => {
4648
+ if (!accepts(event)) return;
4649
+ depth = Math.max(0, depth - 1);
4650
+ if (!depth) setOver(false);
4651
+ };
4652
+ const onDrop = (event) => {
4653
+ if (!accepts(event)) return;
4654
+ event.preventDefault();
4655
+ depth = 0;
4656
+ setOver(false);
4657
+ options.onFiles?.([...event.dataTransfer?.files ?? []], event);
4658
+ };
4659
+ field.addEventListener("dragenter", onEnter);
4660
+ field.addEventListener("dragover", onOver);
4661
+ field.addEventListener("dragleave", onLeave);
4662
+ field.addEventListener("drop", onDrop);
4663
+ const resize = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
4664
+ build();
4665
+ draw(0);
4666
+ }) : void 0;
4667
+ resize?.observe(surface);
4668
+ build();
4669
+ draw(0);
4670
+ return {
4671
+ get over() {
4672
+ return over;
4673
+ },
4674
+ destroy() {
4675
+ stop?.();
4676
+ resize?.disconnect();
4677
+ field.removeEventListener("dragenter", onEnter);
4678
+ field.removeEventListener("dragover", onOver);
4679
+ field.removeEventListener("dragleave", onLeave);
4680
+ field.removeEventListener("drop", onDrop);
4681
+ delete field.dataset.over;
4682
+ canvas.remove();
4683
+ }
4684
+ };
4685
+ }
4686
+ export { disclosure as C, divider as E, jelly as S, installMotion as T, leave$2 as _, shake as a, morphText as b, appear as c, switchKnob as d, slider as f, panel as g, setMotionPressMode as h, travel as i, tooltip as l, press as m, createProgress as n, rollNumber as o, select as p, createMotionList as r, motionEffects as s, createDropField as t, toast as u, buttonIcon as v, check as w, swapIcon as x, label as y };