@sprawlify/primitives 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/dist/anatomy.cjs +3 -0
  2. package/dist/anatomy.d.cts +2 -0
  3. package/dist/anatomy.d.mts +2 -0
  4. package/dist/anatomy.mjs +3 -0
  5. package/dist/aria-hidden-DqYx0f_y.mjs +177 -0
  6. package/dist/aria-hidden-DtLU6hSU.cjs +182 -0
  7. package/dist/aria-hidden.cjs +4 -0
  8. package/dist/aria-hidden.d.cts +16 -0
  9. package/dist/aria-hidden.d.mts +16 -0
  10. package/dist/aria-hidden.mjs +4 -0
  11. package/dist/auto-resize-D3qHtFy1.mjs +114 -0
  12. package/dist/auto-resize-xzlPFDyD.cjs +125 -0
  13. package/dist/auto-resize.cjs +5 -0
  14. package/dist/auto-resize.d.cts +17 -0
  15. package/dist/auto-resize.d.mts +17 -0
  16. package/dist/auto-resize.mjs +4 -0
  17. package/dist/chunk-CbDLau6x.cjs +34 -0
  18. package/dist/collection-8XqaNHs_.mjs +1279 -0
  19. package/dist/collection-DIoIDISa.cjs +1326 -0
  20. package/dist/collection.cjs +11 -0
  21. package/dist/collection.d.cts +5 -0
  22. package/dist/collection.d.mts +5 -0
  23. package/dist/collection.mjs +4 -0
  24. package/dist/color-BkAP1Tkd.d.mts +60 -0
  25. package/dist/color-VKewNv2e.d.cts +60 -0
  26. package/dist/color-utils-Cc5GVXZh.mjs +657 -0
  27. package/dist/color-utils-LER_6Zwu.cjs +680 -0
  28. package/dist/color-utils.cjs +7 -0
  29. package/dist/color-utils.d.cts +19 -0
  30. package/dist/color-utils.d.mts +19 -0
  31. package/dist/color-utils.mjs +4 -0
  32. package/dist/core-30pJjyC2.d.mts +49 -0
  33. package/dist/core-CQFbMdTl.cjs +176 -0
  34. package/dist/core-CefBjbst.d.cts +49 -0
  35. package/dist/core-DCFNMTZF.mjs +129 -0
  36. package/dist/core.cjs +12 -0
  37. package/dist/core.d.cts +3 -0
  38. package/dist/core.d.mts +3 -0
  39. package/dist/core.mjs +5 -0
  40. package/dist/create-anatomy-B3XYc-qG.d.mts +70 -0
  41. package/dist/create-anatomy-BGQ8pv8J.d.cts +70 -0
  42. package/dist/create-anatomy-BbDZbHpC.mjs +39 -0
  43. package/dist/create-anatomy-CDsIFUXg.cjs +45 -0
  44. package/dist/create-props-BnF_vl-E.mjs +5 -0
  45. package/dist/create-props-YKy7JIKj.cjs +11 -0
  46. package/dist/data-url-C3ITPVRX.d.cts +10 -0
  47. package/dist/data-url-DLwZ9M77.d.mts +10 -0
  48. package/dist/date-utils-D2xPHa_I.cjs +738 -0
  49. package/dist/date-utils-wEa1hhpc.mjs +474 -0
  50. package/dist/date-utils.cjs +46 -0
  51. package/dist/date-utils.d.cts +101 -0
  52. package/dist/date-utils.d.mts +2 -0
  53. package/dist/date-utils.mjs +3 -0
  54. package/dist/defineProperty-BoUOT9Ie.cjs +49 -0
  55. package/dist/defineProperty-DrXfyjd4.mjs +43 -0
  56. package/dist/dismissable-CTfKZ4OG.cjs +282 -0
  57. package/dist/dismissable-DDrx0xnH.mjs +271 -0
  58. package/dist/dismissable-layer-C7pZU2wi.d.cts +39 -0
  59. package/dist/dismissable-layer-t_b0fk-p.d.mts +39 -0
  60. package/dist/dismissable.cjs +7 -0
  61. package/dist/dismissable.d.cts +3 -0
  62. package/dist/dismissable.d.mts +3 -0
  63. package/dist/dismissable.mjs +6 -0
  64. package/dist/dom-query-CWZdWUGp.cjs +2141 -0
  65. package/dist/dom-query-DFCRhyj1.mjs +1374 -0
  66. package/dist/dom-query.cjs +130 -0
  67. package/dist/dom-query.d.cts +307 -0
  68. package/dist/dom-query.d.mts +307 -0
  69. package/dist/dom-query.mjs +3 -0
  70. package/dist/file-utils.cjs +220 -0
  71. package/dist/file-utils.d.cts +51 -0
  72. package/dist/file-utils.d.mts +51 -0
  73. package/dist/file-utils.mjs +210 -0
  74. package/dist/focus-trap-D-bypQEJ.mjs +485 -0
  75. package/dist/focus-trap-D4i52S9A.cjs +496 -0
  76. package/dist/focus-trap.cjs +5 -0
  77. package/dist/focus-trap.d.cts +88 -0
  78. package/dist/focus-trap.d.mts +88 -0
  79. package/dist/focus-trap.mjs +4 -0
  80. package/dist/focus-visible-DYTWdWpa.cjs +210 -0
  81. package/dist/focus-visible-irppYatv.mjs +175 -0
  82. package/dist/focus-visible.cjs +9 -0
  83. package/dist/focus-visible.d.cts +31 -0
  84. package/dist/focus-visible.d.mts +31 -0
  85. package/dist/focus-visible.mjs +4 -0
  86. package/dist/functions-BOkTDEFM.d.cts +15 -0
  87. package/dist/functions-IZtWcC8Q.d.mts +15 -0
  88. package/dist/highlight-word.cjs +100 -0
  89. package/dist/highlight-word.d.cts +24 -0
  90. package/dist/highlight-word.d.mts +24 -0
  91. package/dist/highlight-word.mjs +99 -0
  92. package/dist/hotkeys.cjs +758 -0
  93. package/dist/hotkeys.d.cts +130 -0
  94. package/dist/hotkeys.d.mts +130 -0
  95. package/dist/hotkeys.mjs +754 -0
  96. package/dist/i18n-utils.cjs +450 -0
  97. package/dist/i18n-utils.d.cts +61 -0
  98. package/dist/i18n-utils.d.mts +61 -0
  99. package/dist/i18n-utils.mjs +440 -0
  100. package/dist/index-BkzYij2j.d.mts +25 -0
  101. package/dist/index-Bqw3r34-.d.cts +1383 -0
  102. package/dist/index-C0MKXQmE.d.mts +1383 -0
  103. package/dist/index-C9-feK5c.d.cts +25 -0
  104. package/dist/index-CD5FN7kY.d.mts +114 -0
  105. package/dist/index-CJji6wHl.d.cts +15 -0
  106. package/dist/index-CNi5FkPe.d.mts +15 -0
  107. package/dist/index-D96rs8B0.d.mts +115 -0
  108. package/dist/index.cjs +0 -0
  109. package/dist/index.d.cts +1 -0
  110. package/dist/index.d.mts +1 -0
  111. package/dist/index.mjs +1 -0
  112. package/dist/interact-outside-BplxR9cR.mjs +200 -0
  113. package/dist/interact-outside-C8-oFBpB.cjs +205 -0
  114. package/dist/interact-outside.cjs +5 -0
  115. package/dist/interact-outside.d.cts +2 -0
  116. package/dist/interact-outside.d.mts +2 -0
  117. package/dist/interact-outside.mjs +5 -0
  118. package/dist/json-tree-utils.cjs +1512 -0
  119. package/dist/json-tree-utils.d.cts +117 -0
  120. package/dist/json-tree-utils.d.mts +117 -0
  121. package/dist/json-tree-utils.mjs +1463 -0
  122. package/dist/list-collection-BIMJGQjn.d.cts +61 -0
  123. package/dist/list-collection-Db3eixRU.d.mts +61 -0
  124. package/dist/live-region-CcZPGo89.cjs +52 -0
  125. package/dist/live-region-CnPh21WH.mjs +46 -0
  126. package/dist/live-region.cjs +3 -0
  127. package/dist/live-region.d.cts +2 -0
  128. package/dist/live-region.d.mts +2 -0
  129. package/dist/live-region.mjs +3 -0
  130. package/dist/machines/accordion/index.cjs +328 -0
  131. package/dist/machines/accordion/index.d.cts +83 -0
  132. package/dist/machines/accordion/index.d.mts +83 -0
  133. package/dist/machines/accordion/index.mjs +322 -0
  134. package/dist/machines/async-list/index.cjs +311 -0
  135. package/dist/machines/async-list/index.d.cts +89 -0
  136. package/dist/machines/async-list/index.d.mts +89 -0
  137. package/dist/machines/async-list/index.mjs +310 -0
  138. package/dist/machines/avatar/index.cjs +169 -0
  139. package/dist/machines/avatar/index.d.cts +63 -0
  140. package/dist/machines/avatar/index.d.mts +63 -0
  141. package/dist/machines/avatar/index.mjs +165 -0
  142. package/dist/machines/bottom-sheet/index.cjs +676 -0
  143. package/dist/machines/bottom-sheet/index.d.cts +239 -0
  144. package/dist/machines/bottom-sheet/index.d.mts +239 -0
  145. package/dist/machines/bottom-sheet/index.mjs +672 -0
  146. package/dist/machines/carousel/index.cjs +859 -0
  147. package/dist/machines/carousel/index.d.cts +146 -0
  148. package/dist/machines/carousel/index.d.mts +146 -0
  149. package/dist/machines/carousel/index.mjs +851 -0
  150. package/dist/machines/checkbox/index.cjs +316 -0
  151. package/dist/machines/checkbox/index.d.cts +81 -0
  152. package/dist/machines/checkbox/index.d.mts +81 -0
  153. package/dist/machines/checkbox/index.mjs +312 -0
  154. package/dist/machines/clipboard/index.cjs +225 -0
  155. package/dist/machines/clipboard/index.d.cts +68 -0
  156. package/dist/machines/clipboard/index.d.mts +68 -0
  157. package/dist/machines/clipboard/index.mjs +219 -0
  158. package/dist/machines/collapsible/index.cjs +362 -0
  159. package/dist/machines/collapsible/index.d.cts +82 -0
  160. package/dist/machines/collapsible/index.d.mts +82 -0
  161. package/dist/machines/collapsible/index.mjs +358 -0
  162. package/dist/machines/color-picker/index.cjs +1529 -0
  163. package/dist/machines/color-picker/index.d.cts +205 -0
  164. package/dist/machines/color-picker/index.d.mts +205 -0
  165. package/dist/machines/color-picker/index.mjs +1514 -0
  166. package/dist/machines/combobox/index.cjs +1593 -0
  167. package/dist/machines/combobox/index.d.cts +214 -0
  168. package/dist/machines/combobox/index.d.mts +214 -0
  169. package/dist/machines/combobox/index.mjs +1582 -0
  170. package/dist/machines/date-picker/index.cjs +2177 -0
  171. package/dist/machines/date-picker/index.d.cts +350 -0
  172. package/dist/machines/date-picker/index.d.mts +350 -0
  173. package/dist/machines/date-picker/index.mjs +2161 -0
  174. package/dist/machines/dialog/index.cjs +325 -0
  175. package/dist/machines/dialog/index.d.cts +80 -0
  176. package/dist/machines/dialog/index.d.mts +80 -0
  177. package/dist/machines/dialog/index.mjs +321 -0
  178. package/dist/machines/editable/index.cjs +551 -0
  179. package/dist/machines/editable/index.d.cts +114 -0
  180. package/dist/machines/editable/index.d.mts +114 -0
  181. package/dist/machines/editable/index.mjs +547 -0
  182. package/dist/machines/floating-panel/index.cjs +995 -0
  183. package/dist/machines/floating-panel/index.d.cts +147 -0
  184. package/dist/machines/floating-panel/index.d.mts +147 -0
  185. package/dist/machines/floating-panel/index.mjs +988 -0
  186. package/dist/machines/hover-card/index.cjs +383 -0
  187. package/dist/machines/hover-card/index.d.cts +69 -0
  188. package/dist/machines/hover-card/index.d.mts +69 -0
  189. package/dist/machines/hover-card/index.mjs +379 -0
  190. package/dist/machines/image-cropper/index.cjs +1995 -0
  191. package/dist/machines/image-cropper/index.d.cts +182 -0
  192. package/dist/machines/image-cropper/index.d.mts +182 -0
  193. package/dist/machines/image-cropper/index.mjs +1990 -0
  194. package/dist/machines/listbox/index.cjs +794 -0
  195. package/dist/machines/listbox/index.d.cts +168 -0
  196. package/dist/machines/listbox/index.d.mts +168 -0
  197. package/dist/machines/listbox/index.mjs +782 -0
  198. package/dist/machines/marquee/index.cjs +395 -0
  199. package/dist/machines/marquee/index.d.cts +102 -0
  200. package/dist/machines/marquee/index.d.mts +102 -0
  201. package/dist/machines/marquee/index.mjs +391 -0
  202. package/dist/machines/menu/index.cjs +1298 -0
  203. package/dist/machines/menu/index.d.cts +175 -0
  204. package/dist/machines/menu/index.d.mts +175 -0
  205. package/dist/machines/menu/index.mjs +1286 -0
  206. package/dist/machines/navigation-menu/index.cjs +861 -0
  207. package/dist/machines/navigation-menu/index.d.cts +127 -0
  208. package/dist/machines/navigation-menu/index.d.mts +127 -0
  209. package/dist/machines/navigation-menu/index.mjs +857 -0
  210. package/dist/machines/number-input/index.cjs +996 -0
  211. package/dist/machines/number-input/index.d.cts +134 -0
  212. package/dist/machines/number-input/index.d.mts +134 -0
  213. package/dist/machines/number-input/index.mjs +991 -0
  214. package/dist/machines/pagination/index.cjs +419 -0
  215. package/dist/machines/pagination/index.d.cts +139 -0
  216. package/dist/machines/pagination/index.d.mts +139 -0
  217. package/dist/machines/pagination/index.mjs +411 -0
  218. package/dist/machines/password-input/index.cjs +228 -0
  219. package/dist/machines/password-input/index.d.cts +71 -0
  220. package/dist/machines/password-input/index.d.mts +71 -0
  221. package/dist/machines/password-input/index.mjs +224 -0
  222. package/dist/machines/pin-input/index.cjs +523 -0
  223. package/dist/machines/pin-input/index.d.cts +105 -0
  224. package/dist/machines/pin-input/index.d.mts +105 -0
  225. package/dist/machines/pin-input/index.mjs +519 -0
  226. package/dist/machines/popover/index.cjs +430 -0
  227. package/dist/machines/popover/index.d.cts +88 -0
  228. package/dist/machines/popover/index.d.mts +88 -0
  229. package/dist/machines/popover/index.mjs +426 -0
  230. package/dist/machines/presence/index.cjs +192 -0
  231. package/dist/machines/presence/index.d.cts +44 -0
  232. package/dist/machines/presence/index.d.mts +44 -0
  233. package/dist/machines/presence/index.mjs +190 -0
  234. package/dist/machines/progress/index.cjs +288 -0
  235. package/dist/machines/progress/index.d.cts +96 -0
  236. package/dist/machines/progress/index.d.mts +96 -0
  237. package/dist/machines/progress/index.mjs +284 -0
  238. package/dist/machines/qr-code/index.cjs +172 -0
  239. package/dist/machines/qr-code/index.d.cts +70 -0
  240. package/dist/machines/qr-code/index.d.mts +70 -0
  241. package/dist/machines/qr-code/index.mjs +167 -0
  242. package/dist/machines/radio-group/index.cjs +436 -0
  243. package/dist/machines/radio-group/index.d.cts +106 -0
  244. package/dist/machines/radio-group/index.d.mts +106 -0
  245. package/dist/machines/radio-group/index.mjs +430 -0
  246. package/dist/machines/rating-group/index.cjs +405 -0
  247. package/dist/machines/rating-group/index.d.cts +101 -0
  248. package/dist/machines/rating-group/index.d.mts +101 -0
  249. package/dist/machines/rating-group/index.mjs +399 -0
  250. package/dist/machines/scroll-area/index.cjs +857 -0
  251. package/dist/machines/scroll-area/index.d.cts +159 -0
  252. package/dist/machines/scroll-area/index.d.mts +159 -0
  253. package/dist/machines/scroll-area/index.mjs +853 -0
  254. package/dist/machines/select/index.cjs +1165 -0
  255. package/dist/machines/select/index.d.cts +183 -0
  256. package/dist/machines/select/index.d.mts +183 -0
  257. package/dist/machines/select/index.mjs +1154 -0
  258. package/dist/machines/signature-pad/index.cjs +334 -0
  259. package/dist/machines/signature-pad/index.d.cts +108 -0
  260. package/dist/machines/signature-pad/index.d.mts +108 -0
  261. package/dist/machines/signature-pad/index.mjs +328 -0
  262. package/dist/machines/slider/index.cjs +957 -0
  263. package/dist/machines/slider/index.d.cts +149 -0
  264. package/dist/machines/slider/index.d.mts +149 -0
  265. package/dist/machines/slider/index.mjs +949 -0
  266. package/dist/machines/splitter/index.cjs +1112 -0
  267. package/dist/machines/splitter/index.d.cts +155 -0
  268. package/dist/machines/splitter/index.d.mts +155 -0
  269. package/dist/machines/splitter/index.mjs +1103 -0
  270. package/dist/machines/steps/index.cjs +289 -0
  271. package/dist/machines/steps/index.d.cts +97 -0
  272. package/dist/machines/steps/index.d.mts +97 -0
  273. package/dist/machines/steps/index.mjs +285 -0
  274. package/dist/machines/switch/index.cjs +305 -0
  275. package/dist/machines/switch/index.d.cts +80 -0
  276. package/dist/machines/switch/index.d.mts +80 -0
  277. package/dist/machines/switch/index.mjs +301 -0
  278. package/dist/machines/tabs/index.cjs +508 -0
  279. package/dist/machines/tabs/index.d.cts +111 -0
  280. package/dist/machines/tabs/index.d.mts +111 -0
  281. package/dist/machines/tabs/index.mjs +500 -0
  282. package/dist/machines/tags-input/index.cjs +1127 -0
  283. package/dist/machines/tags-input/index.d.cts +179 -0
  284. package/dist/machines/tags-input/index.d.mts +179 -0
  285. package/dist/machines/tags-input/index.mjs +1121 -0
  286. package/dist/machines/timer/index.cjs +329 -0
  287. package/dist/machines/timer/index.d.cts +98 -0
  288. package/dist/machines/timer/index.d.mts +98 -0
  289. package/dist/machines/timer/index.mjs +324 -0
  290. package/dist/machines/toast/index.cjs +1155 -0
  291. package/dist/machines/toast/index.d.cts +195 -0
  292. package/dist/machines/toast/index.d.mts +195 -0
  293. package/dist/machines/toast/index.mjs +1151 -0
  294. package/dist/machines/toggle/index.cjs +103 -0
  295. package/dist/machines/toggle/index.d.cts +46 -0
  296. package/dist/machines/toggle/index.d.mts +46 -0
  297. package/dist/machines/toggle/index.mjs +99 -0
  298. package/dist/machines/toggle-group/index.cjs +328 -0
  299. package/dist/machines/toggle-group/index.d.cts +81 -0
  300. package/dist/machines/toggle-group/index.d.mts +81 -0
  301. package/dist/machines/toggle-group/index.mjs +322 -0
  302. package/dist/machines/tooltip/index.cjs +516 -0
  303. package/dist/machines/tooltip/index.d.cts +71 -0
  304. package/dist/machines/tooltip/index.d.mts +71 -0
  305. package/dist/machines/tooltip/index.mjs +512 -0
  306. package/dist/machines/tour/index.cjs +1108 -0
  307. package/dist/machines/tour/index.d.cts +206 -0
  308. package/dist/machines/tour/index.d.mts +206 -0
  309. package/dist/machines/tour/index.mjs +1101 -0
  310. package/dist/machines/tree-view/index.cjs +1271 -0
  311. package/dist/machines/tree-view/index.d.cts +215 -0
  312. package/dist/machines/tree-view/index.d.mts +215 -0
  313. package/dist/machines/tree-view/index.mjs +1263 -0
  314. package/dist/node-BctU8GXk.d.mts +24 -0
  315. package/dist/node-CSsuPZVZ.d.cts +24 -0
  316. package/dist/popper-BPJeAtcA.mjs +349 -0
  317. package/dist/popper-D0FAW_p7.cjs +373 -0
  318. package/dist/popper.cjs +8 -0
  319. package/dist/popper.d.cts +74 -0
  320. package/dist/popper.d.mts +2 -0
  321. package/dist/popper.mjs +5 -0
  322. package/dist/raf-BnlYUlDi.d.mts +15 -0
  323. package/dist/raf-Cd2FGy0z.d.cts +15 -0
  324. package/dist/rect-utils-0ellN0a_.mjs +854 -0
  325. package/dist/rect-utils-DKLRhP8G.cjs +1147 -0
  326. package/dist/rect-utils.cjs +51 -0
  327. package/dist/rect-utils.d.cts +198 -0
  328. package/dist/rect-utils.d.mts +198 -0
  329. package/dist/rect-utils.mjs +3 -0
  330. package/dist/remove-scroll-Lrfv79X_.mjs +58 -0
  331. package/dist/remove-scroll-Uvzg1L9r.cjs +63 -0
  332. package/dist/remove-scroll.cjs +0 -0
  333. package/dist/remove-scroll.d.cts +1 -0
  334. package/dist/remove-scroll.d.mts +1 -0
  335. package/dist/remove-scroll.mjs +1 -0
  336. package/dist/scroll-snap-CrTmQRzA.mjs +152 -0
  337. package/dist/scroll-snap-zyiZLv7W.cjs +175 -0
  338. package/dist/scroll-snap.cjs +7 -0
  339. package/dist/scroll-snap.d.cts +14 -0
  340. package/dist/scroll-snap.d.mts +14 -0
  341. package/dist/scroll-snap.mjs +4 -0
  342. package/dist/selection-BIhSzkF7.d.mts +50 -0
  343. package/dist/selection-CS1GBp8e.d.cts +50 -0
  344. package/dist/store-BZcXv49B.cjs +305 -0
  345. package/dist/store-DEojWy9H.mjs +263 -0
  346. package/dist/store.cjs +9 -0
  347. package/dist/store.d.cts +26 -0
  348. package/dist/store.d.mts +26 -0
  349. package/dist/store.mjs +3 -0
  350. package/dist/stringify-state.cjs +49 -0
  351. package/dist/stringify-state.d.cts +8 -0
  352. package/dist/stringify-state.d.mts +8 -0
  353. package/dist/stringify-state.mjs +46 -0
  354. package/dist/tree-collection-BwU5WhGQ.d.mts +78 -0
  355. package/dist/tree-collection-DP_eznnI.d.cts +78 -0
  356. package/dist/typeahead-BdNwVP09.d.cts +45 -0
  357. package/dist/typeahead-XN6lZ7G9.d.mts +45 -0
  358. package/dist/types-BivBkYg9.d.cts +57 -0
  359. package/dist/types-Bl_6JtPQ.d.mts +57 -0
  360. package/dist/types-CPUMVt7c.d.mts +54 -0
  361. package/dist/types-CT_W6HWr.d.cts +54 -0
  362. package/dist/types-DDTcG99l.d.mts +201 -0
  363. package/dist/types-DejIu60O.d.cts +201 -0
  364. package/dist/types-DiIdKZ3K.d.cts +45 -0
  365. package/dist/types-GxLIgJib.d.cts +17 -0
  366. package/dist/types.cjs +15 -0
  367. package/dist/types.d.cts +2 -0
  368. package/dist/types.d.mts +2 -0
  369. package/dist/types.mjs +14 -0
  370. package/dist/utils-BZyrxWWR.mjs +525 -0
  371. package/dist/utils-_6frwjgJ.cjs +1040 -0
  372. package/dist/utils.cjs +88 -0
  373. package/dist/utils.d.cts +144 -0
  374. package/dist/utils.d.mts +144 -0
  375. package/dist/utils.mjs +3 -0
  376. package/dist/wait-for-CMjPsqWk.d.cts +10 -0
  377. package/dist/wait-for-D2nkdD4z.d.mts +10 -0
  378. package/package.json +399 -0
@@ -0,0 +1,1101 @@
1
+ import { t as createAnatomy } from "../../create-anatomy-BbDZbHpC.mjs";
2
+ import { U as raf, Xt as contains, Yt as getComputedStyle$1, ln as isHTMLElement, n as waitForPromise, rn as getWindow, t as waitForElement, vn as dataAttr } from "../../dom-query-DFCRhyj1.mjs";
3
+ import { Ot as prevIndex, Tt as nextIndex, dt as isEqual, i as warn, u as createSplitProps, ut as isString } from "../../utils-BZyrxWWR.mjs";
4
+ import { a as createMachine, c as mergeProps, i as createGuards } from "../../core-DCFNMTZF.mjs";
5
+ import { t as trackInteractOutside } from "../../interact-outside-BplxR9cR.mjs";
6
+ import { t as trackDismissableBranch } from "../../dismissable-DDrx0xnH.mjs";
7
+ import { t as trapFocus } from "../../focus-trap-D-bypQEJ.mjs";
8
+ import { n as getPlacement, t as getPlacementStyles } from "../../popper-BPJeAtcA.mjs";
9
+ import { t as createProps } from "../../create-props-BnF_vl-E.mjs";
10
+
11
+ //#region src/machines/tour/tour.anatomy.ts
12
+ const anatomy = createAnatomy("tour").parts("content", "actionTrigger", "closeTrigger", "progressText", "title", "description", "positioner", "arrow", "arrowTip", "backdrop", "spotlight");
13
+ const parts = anatomy.build();
14
+
15
+ //#endregion
16
+ //#region src/machines/tour/tour.dom.ts
17
+ const getPositionerId = (ctx) => ctx.ids?.positioner ?? `tour:${ctx.id}:positioner`;
18
+ const getContentId = (ctx) => ctx.ids?.content ?? `tour:${ctx.id}:content`;
19
+ const getTitleId = (ctx) => ctx.ids?.title ?? `tour:${ctx.id}:title`;
20
+ const getDescriptionId = (ctx) => ctx.ids?.description ?? `tour:${ctx.id}:description`;
21
+ const getArrowId = (ctx) => ctx.ids?.arrow ?? `tour:${ctx.id}:arrow`;
22
+ const getBackdropId = (ctx) => ctx.ids?.backdrop ?? `tour:${ctx.id}:backdrop`;
23
+ const getContentEl = (ctx) => ctx.getById(getContentId(ctx));
24
+ const getPositionerEl = (ctx) => ctx.getById(getPositionerId(ctx));
25
+ const getBackdropEl = (ctx) => ctx.getById(getBackdropId(ctx));
26
+ function syncZIndex(scope) {
27
+ return raf(() => {
28
+ const contentEl = getContentEl(scope);
29
+ if (!contentEl) return;
30
+ const styles = getComputedStyle$1(contentEl);
31
+ const positionerEl = getPositionerEl(scope);
32
+ const backdropEl = getBackdropEl(scope);
33
+ if (positionerEl) {
34
+ positionerEl.style.setProperty("--z-index", styles.zIndex);
35
+ positionerEl.style.setProperty("z-index", "var(--z-index)");
36
+ }
37
+ if (backdropEl) backdropEl.style.setProperty("--z-index", styles.zIndex);
38
+ });
39
+ }
40
+
41
+ //#endregion
42
+ //#region src/machines/tour/utils/clip-path.ts
43
+ function getClipPath(options) {
44
+ const { radius = 0, rootSize: { width: w, height: h }, rect: { width, height, x, y }, enabled = true } = options;
45
+ if (!enabled) return "";
46
+ const { topLeft = 0, topRight = 0, bottomRight = 0, bottomLeft = 0 } = typeof radius === "number" ? {
47
+ topLeft: radius,
48
+ topRight: radius,
49
+ bottomRight: radius,
50
+ bottomLeft: radius
51
+ } : radius;
52
+ return `M${w},${h}\
53
+ H0\
54
+ V0\
55
+ H${w}\
56
+ V${h}\
57
+ Z\
58
+ M${x + topLeft},${y}\
59
+ a${topLeft},${topLeft},0,0,0-${topLeft},${topLeft}\
60
+ V${height + y - bottomLeft}\
61
+ a${bottomLeft},${bottomLeft},0,0,0,${bottomLeft},${bottomLeft}\
62
+ H${width + x - bottomRight}\
63
+ a${bottomRight},${bottomRight},0,0,0,${bottomRight}-${bottomRight}\
64
+ V${y + topRight}\
65
+ a${topRight},${topRight},0,0,0-${topRight}-${topRight}\
66
+ Z`;
67
+ }
68
+
69
+ //#endregion
70
+ //#region src/machines/tour/utils/step.ts
71
+ const isTooltipStep = (step) => {
72
+ return step?.type === "tooltip";
73
+ };
74
+ const isDialogStep = (step) => {
75
+ return step?.type === "dialog";
76
+ };
77
+ const isWaitStep = (step) => {
78
+ return step?.type === "wait";
79
+ };
80
+ const getEffectiveSteps = (steps) => {
81
+ return steps.filter((step) => step.type !== "wait");
82
+ };
83
+ const getProgress = (steps, stepIndex) => {
84
+ const effectiveLength = getEffectiveSteps(steps).length;
85
+ return (stepIndex + 1) / effectiveLength;
86
+ };
87
+ const getEffectiveStepIndex = (steps, stepId) => {
88
+ return findStepIndex(getEffectiveSteps(steps), stepId);
89
+ };
90
+ const isTooltipPlacement = (placement) => {
91
+ return placement != null && placement != "center";
92
+ };
93
+ const normalizeStep = (step) => {
94
+ if (step.type === "floating") return {
95
+ backdrop: false,
96
+ arrow: false,
97
+ placement: "bottom-end",
98
+ ...step
99
+ };
100
+ if (step.target == null || step.type === "dialog") return {
101
+ type: "dialog",
102
+ placement: "center",
103
+ backdrop: true,
104
+ ...step
105
+ };
106
+ if (!step.type || step.type === "tooltip") return {
107
+ type: "tooltip",
108
+ arrow: true,
109
+ backdrop: true,
110
+ ...step
111
+ };
112
+ return step;
113
+ };
114
+ const findStep = (steps, id) => {
115
+ const res = id != null ? steps.find((step) => step.id === id) : null;
116
+ return res ? normalizeStep(res) : null;
117
+ };
118
+ const findStepIndex = (steps, id) => {
119
+ return id != null ? steps.findIndex((step) => step.id === id) : -1;
120
+ };
121
+
122
+ //#endregion
123
+ //#region src/machines/tour/tour.connect.ts
124
+ function connect(service, normalize) {
125
+ const { state, context, computed, send, prop, scope } = service;
126
+ const open = state.hasTag("open");
127
+ const steps = Array.from(context.get("steps"));
128
+ const stepIndex = computed("stepIndex");
129
+ const step = computed("step");
130
+ const hasTarget = typeof step?.target?.() !== "undefined";
131
+ const hasNextStep = computed("hasNextStep");
132
+ const hasPrevStep = computed("hasPrevStep");
133
+ const firstStep = computed("isFirstStep");
134
+ const lastStep = computed("isLastStep");
135
+ const placement = context.get("currentPlacement");
136
+ const targetRect = context.get("targetRect");
137
+ const popperStyles = getPlacementStyles({
138
+ strategy: "absolute",
139
+ placement: isTooltipPlacement(placement) ? placement : void 0
140
+ });
141
+ const clipPath = getClipPath({
142
+ enabled: isTooltipStep(step),
143
+ rect: targetRect,
144
+ rootSize: context.get("boundarySize"),
145
+ radius: prop("spotlightRadius")
146
+ });
147
+ const actionMap = {
148
+ next() {
149
+ send({
150
+ type: "STEP.NEXT",
151
+ src: "actionTrigger"
152
+ });
153
+ },
154
+ prev() {
155
+ send({
156
+ type: "STEP.PREV",
157
+ src: "actionTrigger"
158
+ });
159
+ },
160
+ dismiss() {
161
+ send({
162
+ type: "DISMISS",
163
+ src: "actionTrigger"
164
+ });
165
+ },
166
+ skip() {
167
+ send({
168
+ type: "SKIP",
169
+ src: "actionTrigger"
170
+ });
171
+ },
172
+ goto(id) {
173
+ send({
174
+ type: "STEP.SET",
175
+ value: id,
176
+ src: "actionTrigger"
177
+ });
178
+ }
179
+ };
180
+ return {
181
+ open,
182
+ totalSteps: steps.length,
183
+ stepIndex,
184
+ step,
185
+ hasNextStep,
186
+ hasPrevStep,
187
+ firstStep,
188
+ lastStep,
189
+ addStep(step$1) {
190
+ send({
191
+ type: "STEPS.SET",
192
+ value: steps.concat(step$1),
193
+ src: "addStep"
194
+ });
195
+ },
196
+ removeStep(id) {
197
+ send({
198
+ type: "STEPS.SET",
199
+ value: steps.filter((step$1) => step$1.id !== id),
200
+ src: "removeStep"
201
+ });
202
+ },
203
+ updateStep(id, stepOverrides) {
204
+ send({
205
+ type: "STEPS.SET",
206
+ value: steps.map((step$1) => step$1.id === id ? mergeProps(step$1, stepOverrides) : step$1),
207
+ src: "updateStep"
208
+ });
209
+ },
210
+ setSteps(steps$1) {
211
+ send({
212
+ type: "STEPS.SET",
213
+ value: steps$1,
214
+ src: "setSteps"
215
+ });
216
+ },
217
+ setStep(id) {
218
+ send({
219
+ type: "STEP.SET",
220
+ value: id
221
+ });
222
+ },
223
+ start(id) {
224
+ send({
225
+ type: "START",
226
+ value: id
227
+ });
228
+ },
229
+ isValidStep(id) {
230
+ return steps.some((step$1) => step$1.id === id);
231
+ },
232
+ isCurrentStep(id) {
233
+ return Boolean(step?.id === id);
234
+ },
235
+ next() {
236
+ send({ type: "STEP.NEXT" });
237
+ },
238
+ prev() {
239
+ send({ type: "STEP.PREV" });
240
+ },
241
+ getProgressPercent() {
242
+ const index = getEffectiveStepIndex(steps, step?.id);
243
+ const total = getEffectiveSteps(steps).length;
244
+ return (index + 1) / total * 100;
245
+ },
246
+ getProgressText() {
247
+ const details = {
248
+ current: getEffectiveStepIndex(steps, step?.id),
249
+ total: getEffectiveSteps(steps).length
250
+ };
251
+ return prop("translations").progressText?.(details) ?? "";
252
+ },
253
+ getBackdropProps() {
254
+ return normalize.element({
255
+ ...parts.backdrop.attrs,
256
+ id: getBackdropId(scope),
257
+ dir: prop("dir"),
258
+ hidden: !open,
259
+ "data-state": open ? "open" : "closed",
260
+ "data-type": step?.type,
261
+ style: {
262
+ "--tour-layer": 0,
263
+ clipPath: isTooltipStep(step) ? `path("${clipPath}")` : void 0,
264
+ position: "absolute",
265
+ inset: "0",
266
+ willChange: "clip-path"
267
+ }
268
+ });
269
+ },
270
+ getSpotlightProps() {
271
+ return normalize.element({
272
+ ...parts.spotlight.attrs,
273
+ hidden: !open || !step?.target?.(),
274
+ style: {
275
+ "--tour-layer": 1,
276
+ position: "absolute",
277
+ width: `${targetRect.width}px`,
278
+ height: `${targetRect.height}px`,
279
+ left: `${targetRect.x}px`,
280
+ top: `${targetRect.y}px`,
281
+ borderRadius: `${prop("spotlightRadius")}px`,
282
+ pointerEvents: "none"
283
+ }
284
+ });
285
+ },
286
+ getProgressTextProps() {
287
+ return normalize.element({ ...parts.progressText.attrs });
288
+ },
289
+ getPositionerProps() {
290
+ return normalize.element({
291
+ ...parts.positioner.attrs,
292
+ dir: prop("dir"),
293
+ id: getPositionerId(scope),
294
+ "data-type": step?.type,
295
+ "data-placement": placement,
296
+ style: {
297
+ "--tour-layer": 2,
298
+ ...step?.type === "tooltip" && popperStyles.floating
299
+ }
300
+ });
301
+ },
302
+ getArrowProps() {
303
+ return normalize.element({
304
+ id: getArrowId(scope),
305
+ ...parts.arrow.attrs,
306
+ dir: prop("dir"),
307
+ hidden: step?.type !== "tooltip",
308
+ style: step?.type === "tooltip" ? popperStyles.arrow : void 0,
309
+ opacity: hasTarget ? void 0 : 0
310
+ });
311
+ },
312
+ getArrowTipProps() {
313
+ return normalize.element({
314
+ ...parts.arrowTip.attrs,
315
+ dir: prop("dir"),
316
+ style: popperStyles.arrowTip
317
+ });
318
+ },
319
+ getContentProps() {
320
+ return normalize.element({
321
+ ...parts.content.attrs,
322
+ id: getContentId(scope),
323
+ dir: prop("dir"),
324
+ role: "alertdialog",
325
+ "aria-modal": "true",
326
+ "aria-live": "polite",
327
+ "aria-atomic": "true",
328
+ hidden: !open,
329
+ "data-state": open ? "open" : "closed",
330
+ "data-type": step?.type,
331
+ "data-placement": placement,
332
+ "data-step": step?.id,
333
+ "aria-labelledby": getTitleId(scope),
334
+ "aria-describedby": getDescriptionId(scope),
335
+ tabIndex: -1,
336
+ onKeyDown(event) {
337
+ if (event.defaultPrevented) return;
338
+ if (!prop("keyboardNavigation")) return;
339
+ const isRtl = prop("dir") === "rtl";
340
+ switch (event.key) {
341
+ case "ArrowRight":
342
+ if (!hasNextStep) return;
343
+ send({
344
+ type: isRtl ? "STEP.PREV" : "STEP.NEXT",
345
+ src: "keydown"
346
+ });
347
+ break;
348
+ case "ArrowLeft":
349
+ if (!hasPrevStep) return;
350
+ send({
351
+ type: isRtl ? "STEP.NEXT" : "STEP.PREV",
352
+ src: "keydown"
353
+ });
354
+ break;
355
+ default: break;
356
+ }
357
+ }
358
+ });
359
+ },
360
+ getTitleProps() {
361
+ return normalize.element({
362
+ ...parts.title.attrs,
363
+ id: getTitleId(scope),
364
+ "data-placement": hasTarget ? placement : "center"
365
+ });
366
+ },
367
+ getDescriptionProps() {
368
+ return normalize.element({
369
+ ...parts.description.attrs,
370
+ id: getDescriptionId(scope),
371
+ "data-placement": hasTarget ? placement : "center"
372
+ });
373
+ },
374
+ getCloseTriggerProps() {
375
+ return normalize.element({
376
+ ...parts.closeTrigger.attrs,
377
+ "data-type": step?.type,
378
+ "aria-label": prop("translations").close,
379
+ onClick: actionMap.dismiss
380
+ });
381
+ },
382
+ getActionTriggerProps(props$1) {
383
+ const { action, attrs } = props$1.action;
384
+ let actionProps = {};
385
+ switch (action) {
386
+ case "next":
387
+ actionProps = {
388
+ "data-type": "next",
389
+ disabled: !hasNextStep,
390
+ "data-disabled": dataAttr(!hasNextStep),
391
+ "aria-label": prop("translations").nextStep,
392
+ onClick: actionMap.next
393
+ };
394
+ break;
395
+ case "prev":
396
+ actionProps = {
397
+ "data-type": "prev",
398
+ disabled: !hasPrevStep,
399
+ "data-disabled": dataAttr(!hasPrevStep),
400
+ "aria-label": prop("translations").prevStep,
401
+ onClick: actionMap.prev
402
+ };
403
+ break;
404
+ case "dismiss":
405
+ actionProps = {
406
+ "data-type": "close",
407
+ "aria-label": prop("translations").close,
408
+ onClick: actionMap.dismiss
409
+ };
410
+ break;
411
+ default:
412
+ actionProps = {
413
+ "data-type": "custom",
414
+ onClick() {
415
+ if (typeof action === "function") action(actionMap);
416
+ }
417
+ };
418
+ break;
419
+ }
420
+ return normalize.button({
421
+ ...parts.actionTrigger.attrs,
422
+ type: "button",
423
+ ...attrs,
424
+ ...actionProps
425
+ });
426
+ }
427
+ };
428
+ }
429
+
430
+ //#endregion
431
+ //#region src/machines/tour/utils/rect.ts
432
+ function getFrameElement(win) {
433
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
434
+ }
435
+ const normalizeEventPoint = (event) => {
436
+ let clientX = event.clientX;
437
+ let clientY = event.clientY;
438
+ let win = event.view || window;
439
+ let frame = getFrameElement(win);
440
+ while (frame) {
441
+ const iframeRect = frame.getBoundingClientRect();
442
+ const css = getComputedStyle(frame);
443
+ const left = iframeRect.left + (frame.clientLeft + parseFloat(css.paddingLeft));
444
+ const top = iframeRect.top + (frame.clientTop + parseFloat(css.paddingTop));
445
+ clientX += left;
446
+ clientY += top;
447
+ win = getWindow(frame);
448
+ frame = getFrameElement(win);
449
+ }
450
+ return {
451
+ clientX,
452
+ clientY
453
+ };
454
+ };
455
+ function isEventInRect(rect, event) {
456
+ const { clientX, clientY } = normalizeEventPoint(event);
457
+ return rect.y <= clientY && clientY <= rect.y + rect.height && rect.x <= clientX && clientX <= rect.x + rect.width;
458
+ }
459
+ function offset(r, i) {
460
+ const dx = i.x || 0;
461
+ const dy = i.y || 0;
462
+ return {
463
+ x: r.x - dx,
464
+ y: r.y - dy,
465
+ width: r.width + dx + dx,
466
+ height: r.height + dy + dy
467
+ };
468
+ }
469
+
470
+ //#endregion
471
+ //#region src/machines/tour/tour.machine.ts
472
+ const { and } = createGuards();
473
+ const machine = createMachine({
474
+ props({ props: props$1 }) {
475
+ return {
476
+ preventInteraction: false,
477
+ closeOnInteractOutside: true,
478
+ closeOnEscape: true,
479
+ keyboardNavigation: true,
480
+ spotlightOffset: {
481
+ x: 10,
482
+ y: 10
483
+ },
484
+ spotlightRadius: 4,
485
+ ...props$1,
486
+ translations: {
487
+ nextStep: "next step",
488
+ prevStep: "previous step",
489
+ close: "close tour",
490
+ progressText: ({ current, total }) => `${current + 1} of ${total}`,
491
+ skip: "skip tour",
492
+ ...props$1.translations
493
+ }
494
+ };
495
+ },
496
+ initialState() {
497
+ return "tour.inactive";
498
+ },
499
+ context({ prop, bindable, getContext }) {
500
+ return {
501
+ steps: bindable(() => ({
502
+ defaultValue: prop("steps") ?? [],
503
+ onChange(value) {
504
+ prop("onStepsChange")?.({ steps: value });
505
+ }
506
+ })),
507
+ stepId: bindable(() => ({
508
+ defaultValue: prop("stepId"),
509
+ sync: true,
510
+ onChange(value) {
511
+ const steps = getContext().get("steps");
512
+ const stepIndex = findStepIndex(steps, value);
513
+ const progress = getProgress(steps, stepIndex);
514
+ const complete = stepIndex == steps.length - 1;
515
+ prop("onStepChange")?.({
516
+ stepId: value,
517
+ stepIndex,
518
+ totalSteps: steps.length,
519
+ complete,
520
+ progress
521
+ });
522
+ }
523
+ })),
524
+ resolvedTarget: bindable(() => ({
525
+ sync: true,
526
+ defaultValue: null
527
+ })),
528
+ targetRect: bindable(() => ({ defaultValue: {
529
+ width: 0,
530
+ height: 0,
531
+ x: 0,
532
+ y: 0
533
+ } })),
534
+ boundarySize: bindable(() => ({ defaultValue: {
535
+ width: 0,
536
+ height: 0
537
+ } })),
538
+ currentPlacement: bindable(() => ({ defaultValue: void 0 }))
539
+ };
540
+ },
541
+ computed: {
542
+ stepIndex: ({ context }) => findStepIndex(context.get("steps"), context.get("stepId")),
543
+ step: ({ context }) => findStep(context.get("steps"), context.get("stepId")),
544
+ hasNextStep: ({ context, computed }) => computed("stepIndex") < context.get("steps").length - 1,
545
+ hasPrevStep: ({ computed }) => computed("stepIndex") > 0,
546
+ isFirstStep: ({ computed }) => computed("stepIndex") === 0,
547
+ isLastStep: ({ context, computed }) => computed("stepIndex") === context.get("steps").length - 1,
548
+ progress: ({ context, computed }) => {
549
+ const effectiveLength = getEffectiveSteps(context.get("steps")).length;
550
+ return (computed("stepIndex") + 1) / effectiveLength;
551
+ }
552
+ },
553
+ watch({ track, context, action }) {
554
+ track([() => context.get("stepId")], () => {
555
+ queueMicrotask(() => {
556
+ action([
557
+ "setResolvedTarget",
558
+ "raiseStepChange",
559
+ "syncTargetAttrs"
560
+ ]);
561
+ });
562
+ });
563
+ },
564
+ effects: ["trackBoundarySize"],
565
+ exit: ["cleanupAll"],
566
+ on: {
567
+ "STEPS.SET": { actions: ["setSteps", "validateSteps"] },
568
+ "STEP.SET": { actions: ["setStep"] },
569
+ "STEP.NEXT": { actions: ["setNextStep"] },
570
+ "STEP.PREV": { actions: ["setPrevStep"] },
571
+ "STEP.CHANGED": [
572
+ {
573
+ guard: and("isValidStep", "hasResolvedTarget"),
574
+ target: "target.scrolling",
575
+ actions: ["cleanupStepEffect"]
576
+ },
577
+ {
578
+ guard: and("isValidStep", "hasTarget"),
579
+ target: "target.resolving",
580
+ actions: ["cleanupStepEffect"]
581
+ },
582
+ {
583
+ guard: and("isValidStep", "isWaitingStep"),
584
+ target: "step.waiting",
585
+ actions: ["cleanupStepEffect"]
586
+ },
587
+ {
588
+ guard: "isValidStep",
589
+ target: "tour.active",
590
+ actions: ["cleanupStepEffect"]
591
+ }
592
+ ],
593
+ DISMISS: [{
594
+ guard: "isLastStep",
595
+ target: "tour.inactive",
596
+ actions: [
597
+ "cleanupAll",
598
+ "invokeOnDismiss",
599
+ "invokeOnComplete",
600
+ "clearStep"
601
+ ]
602
+ }, {
603
+ target: "tour.inactive",
604
+ actions: [
605
+ "cleanupAll",
606
+ "invokeOnDismiss",
607
+ "clearStep"
608
+ ]
609
+ }],
610
+ SKIP: {
611
+ target: "tour.inactive",
612
+ actions: [
613
+ "cleanupAll",
614
+ "invokeOnSkip",
615
+ "clearStep"
616
+ ]
617
+ }
618
+ },
619
+ states: {
620
+ "tour.inactive": {
621
+ tags: ["closed"],
622
+ entry: ["validateSteps"],
623
+ on: { START: { actions: ["setInitialStep", "invokeOnStart"] } }
624
+ },
625
+ "target.resolving": {
626
+ tags: ["closed"],
627
+ effects: ["waitForTarget", "waitForTargetTimeout"],
628
+ on: {
629
+ "TARGET.NOT_FOUND": {
630
+ target: "tour.inactive",
631
+ actions: ["invokeOnNotFound", "clearStep"]
632
+ },
633
+ "TARGET.RESOLVED": {
634
+ target: "target.scrolling",
635
+ actions: ["setResolvedTarget"]
636
+ }
637
+ }
638
+ },
639
+ "target.scrolling": {
640
+ tags: ["open"],
641
+ entry: ["scrollToTarget"],
642
+ effects: [
643
+ "waitForScrollEnd",
644
+ "trapFocus",
645
+ "trackPlacement",
646
+ "trackDismissableBranch",
647
+ "trackInteractOutside",
648
+ "trackEscapeKeydown"
649
+ ],
650
+ on: { "SCROLL.END": { target: "tour.active" } }
651
+ },
652
+ "step.waiting": { tags: ["closed"] },
653
+ "tour.active": {
654
+ tags: ["open"],
655
+ effects: [
656
+ "trapFocus",
657
+ "trackPlacement",
658
+ "trackDismissableBranch",
659
+ "trackInteractOutside",
660
+ "trackEscapeKeydown"
661
+ ]
662
+ }
663
+ },
664
+ implementations: {
665
+ guards: {
666
+ isLastStep: ({ computed, context }) => computed("stepIndex") === context.get("steps").length - 1,
667
+ isValidStep: ({ context }) => context.get("stepId") != null,
668
+ hasTarget: ({ computed }) => computed("step")?.target != null,
669
+ hasResolvedTarget: ({ context }) => context.get("resolvedTarget") != null,
670
+ isWaitingStep: ({ computed }) => computed("step")?.type === "wait"
671
+ },
672
+ actions: {
673
+ scrollToTarget({ context }) {
674
+ context.get("resolvedTarget")?.scrollIntoView({
675
+ behavior: "instant",
676
+ block: "center",
677
+ inline: "center"
678
+ });
679
+ },
680
+ setSteps(params) {
681
+ const { event, context } = params;
682
+ context.set("steps", event.value);
683
+ },
684
+ setStep(params) {
685
+ const { event } = params;
686
+ const step = event.value;
687
+ if (step == null) return;
688
+ new StepManager(params).transitionToStep(step);
689
+ },
690
+ clearStep(params) {
691
+ new StepManager(params).clear();
692
+ },
693
+ setInitialStep(params) {
694
+ const { context, event } = params;
695
+ if (context.get("steps").length === 0) return;
696
+ new StepManager(params).transitionToStep(event.value ?? 0);
697
+ },
698
+ setNextStep(params) {
699
+ const { computed } = params;
700
+ new StepManager(params).next(computed("stepIndex"));
701
+ },
702
+ setPrevStep(params) {
703
+ const { computed } = params;
704
+ new StepManager(params).prev(computed("stepIndex"));
705
+ },
706
+ invokeOnStart({ prop, context, computed }) {
707
+ prop("onStatusChange")?.({
708
+ status: "started",
709
+ stepId: context.get("stepId"),
710
+ stepIndex: computed("stepIndex")
711
+ });
712
+ },
713
+ invokeOnDismiss({ prop, context, computed }) {
714
+ prop("onStatusChange")?.({
715
+ status: "dismissed",
716
+ stepId: context.get("stepId"),
717
+ stepIndex: computed("stepIndex")
718
+ });
719
+ },
720
+ invokeOnComplete({ prop, context, computed }) {
721
+ prop("onStatusChange")?.({
722
+ status: "completed",
723
+ stepId: context.get("stepId"),
724
+ stepIndex: computed("stepIndex")
725
+ });
726
+ },
727
+ invokeOnSkip({ prop, context, computed }) {
728
+ prop("onStatusChange")?.({
729
+ status: "skipped",
730
+ stepId: context.get("stepId"),
731
+ stepIndex: computed("stepIndex")
732
+ });
733
+ },
734
+ invokeOnNotFound({ prop, context, computed }) {
735
+ prop("onStatusChange")?.({
736
+ status: "not-found",
737
+ stepId: context.get("stepId"),
738
+ stepIndex: computed("stepIndex")
739
+ });
740
+ },
741
+ raiseStepChange({ send }) {
742
+ send({ type: "STEP.CHANGED" });
743
+ },
744
+ setResolvedTarget({ context, event, computed }) {
745
+ const node = event.node ?? computed("step")?.target?.();
746
+ context.set("resolvedTarget", node ?? null);
747
+ },
748
+ syncTargetAttrs(params) {
749
+ const { context } = params;
750
+ const targetEl = context.get("resolvedTarget");
751
+ new StepManager(params).syncTarget(targetEl);
752
+ },
753
+ cleanupAll(params) {
754
+ new StepManager(params).cleanupAll();
755
+ },
756
+ cleanupStepEffect(params) {
757
+ new StepManager(params).cleanupStepEffect();
758
+ },
759
+ validateSteps({ context }) {
760
+ const ids = /* @__PURE__ */ new Set();
761
+ context.get("steps").forEach((step) => {
762
+ if (ids.has(step.id)) throw new Error(`[sprawlify-js/tour] Duplicate step id: ${step.id}`);
763
+ if (step.target == null && step.type == null) throw new Error(`[sprawlify-js/tour] Step ${step.id} has no target or type. At least one of those is required.`);
764
+ ids.add(step.id);
765
+ });
766
+ }
767
+ },
768
+ effects: {
769
+ waitForScrollEnd({ send }) {
770
+ const id = setTimeout(() => {
771
+ send({ type: "SCROLL.END" });
772
+ }, 100);
773
+ return () => clearTimeout(id);
774
+ },
775
+ waitForTargetTimeout({ send }) {
776
+ const id = setTimeout(() => {
777
+ send({ type: "TARGET.NOT_FOUND" });
778
+ }, 3e3);
779
+ return () => clearTimeout(id);
780
+ },
781
+ waitForTarget({ scope, computed, send }) {
782
+ const step = computed("step");
783
+ if (!step) return;
784
+ const targetEl = step.target;
785
+ const win = scope.getWin();
786
+ const rootNode = scope.getRootNode();
787
+ const observer = new win.MutationObserver(() => {
788
+ const node = targetEl?.();
789
+ if (node) {
790
+ send({
791
+ type: "TARGET.RESOLVED",
792
+ node
793
+ });
794
+ observer.disconnect();
795
+ }
796
+ });
797
+ observer.observe(rootNode, {
798
+ childList: true,
799
+ subtree: true,
800
+ characterData: true
801
+ });
802
+ return () => {
803
+ observer.disconnect();
804
+ };
805
+ },
806
+ trackBoundarySize({ context, scope }) {
807
+ const win = scope.getWin();
808
+ const doc = scope.getDoc();
809
+ const onResize = () => {
810
+ const width = visualViewport?.width ?? win.innerWidth;
811
+ const height = doc.documentElement.scrollHeight;
812
+ context.set("boundarySize", {
813
+ width,
814
+ height
815
+ });
816
+ };
817
+ onResize();
818
+ const viewport = win.visualViewport ?? win;
819
+ viewport.addEventListener("resize", onResize);
820
+ return () => viewport.removeEventListener("resize", onResize);
821
+ },
822
+ trackEscapeKeydown({ scope, send, prop }) {
823
+ if (!prop("closeOnEscape")) return;
824
+ const doc = scope.getDoc();
825
+ const onKeyDown = (event) => {
826
+ if (event.key === "Escape") {
827
+ event.preventDefault();
828
+ event.stopPropagation();
829
+ send({
830
+ type: "DISMISS",
831
+ src: "esc"
832
+ });
833
+ }
834
+ };
835
+ doc.addEventListener("keydown", onKeyDown, true);
836
+ return () => {
837
+ doc.removeEventListener("keydown", onKeyDown, true);
838
+ };
839
+ },
840
+ trackInteractOutside({ context, computed, scope, send, prop }) {
841
+ const step = computed("step");
842
+ if (step == null) return;
843
+ const contentEl = () => getContentEl(scope);
844
+ return trackInteractOutside(contentEl, {
845
+ defer: true,
846
+ exclude(target) {
847
+ return contains(step.target?.(), target);
848
+ },
849
+ onFocusOutside(event) {
850
+ prop("onFocusOutside")?.(event);
851
+ if (!prop("closeOnInteractOutside")) event.preventDefault();
852
+ },
853
+ onPointerDownOutside(event) {
854
+ prop("onPointerDownOutside")?.(event);
855
+ if (isEventInRect(context.get("targetRect"), event.detail.originalEvent)) {
856
+ event.preventDefault();
857
+ return;
858
+ }
859
+ if (!prop("closeOnInteractOutside")) event.preventDefault();
860
+ },
861
+ onInteractOutside(event) {
862
+ prop("onInteractOutside")?.(event);
863
+ if (event.defaultPrevented) return;
864
+ send({
865
+ type: "DISMISS",
866
+ src: "interact-outside"
867
+ });
868
+ }
869
+ });
870
+ },
871
+ trackDismissableBranch({ computed, scope }) {
872
+ if (computed("step") == null) return;
873
+ const contentEl = () => getContentEl(scope);
874
+ return trackDismissableBranch(contentEl, { defer: true });
875
+ },
876
+ trapFocus({ computed, scope }) {
877
+ if (computed("step") == null) return;
878
+ const contentEl = () => getContentEl(scope);
879
+ return trapFocus(contentEl, {
880
+ escapeDeactivates: false,
881
+ allowOutsideClick: true,
882
+ preventScroll: true,
883
+ returnFocusOnDeactivate: false,
884
+ getShadowRoot: true
885
+ });
886
+ },
887
+ trackPlacement({ context, computed, scope, prop }) {
888
+ const step = computed("step");
889
+ if (step == null) return;
890
+ context.set("currentPlacement", step.placement ?? "bottom");
891
+ if (isDialogStep(step)) return syncZIndex(scope);
892
+ if (!isTooltipStep(step)) return;
893
+ const positionerEl = () => getPositionerEl(scope);
894
+ return getPlacement(context.get("resolvedTarget"), positionerEl, {
895
+ defer: true,
896
+ placement: step.placement ?? "bottom",
897
+ strategy: "absolute",
898
+ gutter: 10,
899
+ offset: step.offset,
900
+ getAnchorRect(el) {
901
+ if (!isHTMLElement(el)) return null;
902
+ return offset(el.getBoundingClientRect(), prop("spotlightOffset"));
903
+ },
904
+ onComplete(data) {
905
+ const { rects } = data.middlewareData;
906
+ context.set("currentPlacement", data.placement);
907
+ context.set("targetRect", rects.reference);
908
+ }
909
+ });
910
+ }
911
+ }
912
+ }
913
+ });
914
+ var StepManager = class {
915
+ constructor(params) {
916
+ this.params = params;
917
+ }
918
+ transitionToStep(step) {
919
+ const steps = this.params.context.get("steps");
920
+ const idx = isString(step) ? findStepIndex(steps, step) : step;
921
+ this.transitionTo(idx);
922
+ }
923
+ next(currentIndex) {
924
+ const idx = nextIndex(this.params.context.get("steps"), currentIndex);
925
+ this.transitionTo(idx);
926
+ }
927
+ prev(currentIndex) {
928
+ const idx = prevIndex(this.params.context.get("steps"), currentIndex);
929
+ this.transitionTo(idx);
930
+ }
931
+ clear() {
932
+ const { context } = this.params;
933
+ context.set("targetRect", {
934
+ width: 0,
935
+ height: 0,
936
+ x: 0,
937
+ y: 0
938
+ });
939
+ context.set("resolvedTarget", null);
940
+ this.transitionTo(-1);
941
+ }
942
+ cleanupAll() {
943
+ const { refs } = this.params;
944
+ refs.get("_targetCleanup")?.();
945
+ refs.set("_targetCleanup", void 0);
946
+ refs.set("_prevTarget", void 0);
947
+ refs.get("_effectCleanup")?.();
948
+ refs.set("_effectCleanup", void 0);
949
+ }
950
+ cleanupStepEffect() {
951
+ const { refs } = this.params;
952
+ if (refs.get("_runningEffect")) return;
953
+ refs.get("_effectCleanup")?.();
954
+ refs.set("_effectCleanup", void 0);
955
+ }
956
+ syncTarget(targetEl) {
957
+ const { refs, prop } = this.params;
958
+ const prevTarget = refs.get("_prevTarget");
959
+ if (targetEl !== prevTarget) {
960
+ refs.get("_targetCleanup")?.();
961
+ refs.set("_targetCleanup", void 0);
962
+ }
963
+ if (!targetEl) {
964
+ refs.set("_prevTarget", null);
965
+ return;
966
+ }
967
+ if (targetEl === prevTarget) return;
968
+ if (prop("preventInteraction")) targetEl.inert = true;
969
+ targetEl.setAttribute("data-tour-highlighted", "");
970
+ refs.set("_targetCleanup", () => {
971
+ if (prop("preventInteraction")) targetEl.inert = false;
972
+ targetEl.removeAttribute("data-tour-highlighted");
973
+ });
974
+ refs.set("_prevTarget", targetEl);
975
+ }
976
+ transitionTo(idx) {
977
+ const { context, refs } = this.params;
978
+ const step = context.get("steps")[idx];
979
+ if (!step) {
980
+ context.set("stepId", null);
981
+ return;
982
+ }
983
+ if (isEqual(context.get("stepId"), step.id)) {
984
+ refs.set("_runningEffect", false);
985
+ return;
986
+ }
987
+ this.cleanup();
988
+ const utilities = this.createUtilities(step, idx);
989
+ if (step.effect) this.executeEffect(step, utilities);
990
+ else utilities.show();
991
+ }
992
+ cleanup() {
993
+ const { refs } = this.params;
994
+ refs.get("_effectCleanup")?.();
995
+ refs.set("_effectCleanup", void 0);
996
+ refs.get("_targetCleanup")?.();
997
+ refs.set("_targetCleanup", void 0);
998
+ }
999
+ createUtilities(step, idx) {
1000
+ const { context, computed, prop } = this.params;
1001
+ const steps = context.get("steps");
1002
+ return {
1003
+ show: () => {
1004
+ context.set("stepId", step.id);
1005
+ },
1006
+ update: (data) => {
1007
+ context.set("steps", (prev) => prev.map((s, i) => i === idx ? {
1008
+ ...s,
1009
+ ...data
1010
+ } : s));
1011
+ },
1012
+ next: () => {
1013
+ const nextIdx = nextIndex(steps, computed("stepIndex"));
1014
+ this.transitionTo(nextIdx);
1015
+ },
1016
+ goto: (id) => {
1017
+ const targetIdx = findStepIndex(steps, id);
1018
+ if (targetIdx === -1) {
1019
+ warn(`[sprawlify-js/tour] Step with id "${id}" not found`);
1020
+ return;
1021
+ }
1022
+ this.transitionTo(targetIdx);
1023
+ },
1024
+ dismiss: () => {
1025
+ context.set("stepId", null);
1026
+ prop("onStatusChange")?.({
1027
+ status: "dismissed",
1028
+ stepId: null,
1029
+ stepIndex: -1
1030
+ });
1031
+ },
1032
+ target: step.target
1033
+ };
1034
+ }
1035
+ executeEffect(step, utilities) {
1036
+ const { refs } = this.params;
1037
+ refs.set("_runningEffect", true);
1038
+ let cleanup;
1039
+ try {
1040
+ cleanup = step.effect(utilities);
1041
+ } catch (error) {
1042
+ refs.set("_runningEffect", false);
1043
+ console.error(error);
1044
+ return;
1045
+ }
1046
+ refs.set("_effectCleanup", cleanup);
1047
+ if (isWaitStep(step)) utilities.show();
1048
+ queueMicrotask(() => {
1049
+ queueMicrotask(() => {
1050
+ refs.set("_runningEffect", false);
1051
+ });
1052
+ });
1053
+ }
1054
+ };
1055
+
1056
+ //#endregion
1057
+ //#region src/machines/tour/tour.props.ts
1058
+ const props = createProps()([
1059
+ "closeOnEscape",
1060
+ "closeOnInteractOutside",
1061
+ "dir",
1062
+ "getRootNode",
1063
+ "id",
1064
+ "ids",
1065
+ "keyboardNavigation",
1066
+ "onFocusOutside",
1067
+ "onInteractOutside",
1068
+ "onPointerDownOutside",
1069
+ "onStatusChange",
1070
+ "onStepChange",
1071
+ "onStepsChange",
1072
+ "preventInteraction",
1073
+ "spotlightOffset",
1074
+ "spotlightRadius",
1075
+ "stepId",
1076
+ "steps",
1077
+ "translations"
1078
+ ]);
1079
+ const splitProps = createSplitProps(props);
1080
+
1081
+ //#endregion
1082
+ //#region src/machines/tour/utils/wait.ts
1083
+ function waitForElementValue(target, value, options) {
1084
+ const { timeout, rootNode } = options;
1085
+ const controller = new (getWindow(rootNode)).AbortController();
1086
+ return waitForPromise(new Promise((resolve) => {
1087
+ const el = target();
1088
+ if (!el) return;
1089
+ const checkValue = () => {
1090
+ if (el.value === value) {
1091
+ resolve();
1092
+ el.removeEventListener("input", checkValue);
1093
+ }
1094
+ };
1095
+ checkValue();
1096
+ el.addEventListener("input", checkValue, { signal: controller.signal });
1097
+ }), controller, timeout);
1098
+ }
1099
+
1100
+ //#endregion
1101
+ export { anatomy, connect, machine, props, splitProps, waitForElement, waitForElementValue, waitForPromise };