stimeo-ui 0.16.0 → 0.17.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 (328) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +8 -1
  3. package/dist/cable/index.d.ts +79 -23
  4. package/dist/cable/index.js +363 -436
  5. package/dist/cable/index.js.map +1 -1
  6. package/dist/controllers/accordion_controller.d.ts +4 -2
  7. package/dist/controllers/accordion_controller.js +166 -55
  8. package/dist/controllers/accordion_controller.js.map +1 -1
  9. package/dist/controllers/alert_dialog_controller.d.ts +12 -2
  10. package/dist/controllers/alert_dialog_controller.js +862 -221
  11. package/dist/controllers/alert_dialog_controller.js.map +1 -1
  12. package/dist/controllers/announcer_controller.d.ts +35 -5
  13. package/dist/controllers/announcer_controller.js +135 -198
  14. package/dist/controllers/announcer_controller.js.map +1 -1
  15. package/dist/controllers/aspect_ratio_controller.js +0 -10
  16. package/dist/controllers/aspect_ratio_controller.js.map +1 -1
  17. package/dist/controllers/auto_submit_controller.d.ts +30 -6
  18. package/dist/controllers/auto_submit_controller.js +271 -127
  19. package/dist/controllers/auto_submit_controller.js.map +1 -1
  20. package/dist/controllers/avatar_controller.js +171 -105
  21. package/dist/controllers/avatar_controller.js.map +1 -1
  22. package/dist/controllers/breadcrumb_controller.js +0 -130
  23. package/dist/controllers/breadcrumb_controller.js.map +1 -1
  24. package/dist/controllers/bulk_select_controller.d.ts +18 -0
  25. package/dist/controllers/bulk_select_controller.js +262 -52
  26. package/dist/controllers/bulk_select_controller.js.map +1 -1
  27. package/dist/controllers/calendar_controller.d.ts +24 -5
  28. package/dist/controllers/calendar_controller.js +175 -209
  29. package/dist/controllers/calendar_controller.js.map +1 -1
  30. package/dist/controllers/carousel_controller.d.ts +34 -7
  31. package/dist/controllers/carousel_controller.js +461 -399
  32. package/dist/controllers/carousel_controller.js.map +1 -1
  33. package/dist/controllers/character_counter_controller.d.ts +17 -1
  34. package/dist/controllers/character_counter_controller.js +246 -156
  35. package/dist/controllers/character_counter_controller.js.map +1 -1
  36. package/dist/controllers/checkbox_controller.d.ts +7 -2
  37. package/dist/controllers/checkbox_controller.js +32 -74
  38. package/dist/controllers/checkbox_controller.js.map +1 -1
  39. package/dist/controllers/clipboard_controller.d.ts +16 -5
  40. package/dist/controllers/clipboard_controller.js +168 -147
  41. package/dist/controllers/clipboard_controller.js.map +1 -1
  42. package/dist/controllers/collapsible_controller.d.ts +16 -4
  43. package/dist/controllers/collapsible_controller.js +301 -120
  44. package/dist/controllers/collapsible_controller.js.map +1 -1
  45. package/dist/controllers/color_picker_controller.d.ts +18 -6
  46. package/dist/controllers/color_picker_controller.js +149 -139
  47. package/dist/controllers/color_picker_controller.js.map +1 -1
  48. package/dist/controllers/combobox_controller.d.ts +23 -5
  49. package/dist/controllers/combobox_controller.js +360 -133
  50. package/dist/controllers/combobox_controller.js.map +1 -1
  51. package/dist/controllers/command_palette_controller.d.ts +45 -14
  52. package/dist/controllers/command_palette_controller.js +970 -358
  53. package/dist/controllers/command_palette_controller.js.map +1 -1
  54. package/dist/controllers/conditional_fields_controller.d.ts +15 -2
  55. package/dist/controllers/conditional_fields_controller.js +166 -124
  56. package/dist/controllers/conditional_fields_controller.js.map +1 -1
  57. package/dist/controllers/confirm_controller.d.ts +49 -12
  58. package/dist/controllers/confirm_controller.js +939 -248
  59. package/dist/controllers/confirm_controller.js.map +1 -1
  60. package/dist/controllers/context_menu_controller.d.ts +31 -4
  61. package/dist/controllers/context_menu_controller.js +256 -128
  62. package/dist/controllers/context_menu_controller.js.map +1 -1
  63. package/dist/controllers/count_up_controller.d.ts +13 -1
  64. package/dist/controllers/count_up_controller.js +73 -21
  65. package/dist/controllers/count_up_controller.js.map +1 -1
  66. package/dist/controllers/countdown_controller.d.ts +45 -1
  67. package/dist/controllers/countdown_controller.js +183 -148
  68. package/dist/controllers/countdown_controller.js.map +1 -1
  69. package/dist/controllers/currency_input_controller.d.ts +21 -2
  70. package/dist/controllers/currency_input_controller.js +134 -158
  71. package/dist/controllers/currency_input_controller.js.map +1 -1
  72. package/dist/controllers/data_grid_controller.d.ts +15 -4
  73. package/dist/controllers/data_grid_controller.js +114 -186
  74. package/dist/controllers/data_grid_controller.js.map +1 -1
  75. package/dist/controllers/date_range_picker_controller.d.ts +30 -5
  76. package/dist/controllers/date_range_picker_controller.js +288 -206
  77. package/dist/controllers/date_range_picker_controller.js.map +1 -1
  78. package/dist/controllers/dialog_controller.d.ts +13 -1
  79. package/dist/controllers/dialog_controller.js +858 -223
  80. package/dist/controllers/dialog_controller.js.map +1 -1
  81. package/dist/controllers/direct_upload_controller.d.ts +24 -7
  82. package/dist/controllers/direct_upload_controller.js +73 -153
  83. package/dist/controllers/direct_upload_controller.js.map +1 -1
  84. package/dist/controllers/dirty_form_controller.js +14 -48
  85. package/dist/controllers/dirty_form_controller.js.map +1 -1
  86. package/dist/controllers/dismissible_controller.d.ts +19 -0
  87. package/dist/controllers/dismissible_controller.js +175 -21
  88. package/dist/controllers/dismissible_controller.js.map +1 -1
  89. package/dist/controllers/drawer_controller.d.ts +39 -11
  90. package/dist/controllers/drawer_controller.js +933 -341
  91. package/dist/controllers/drawer_controller.js.map +1 -1
  92. package/dist/controllers/dropdown_controller.d.ts +31 -1
  93. package/dist/controllers/dropdown_controller.js +312 -82
  94. package/dist/controllers/dropdown_controller.js.map +1 -1
  95. package/dist/controllers/editable_controller.d.ts +12 -1
  96. package/dist/controllers/editable_controller.js +158 -68
  97. package/dist/controllers/editable_controller.js.map +1 -1
  98. package/dist/controllers/empty_state_controller.js +67 -53
  99. package/dist/controllers/empty_state_controller.js.map +1 -1
  100. package/dist/controllers/file_dropzone_controller.d.ts +60 -18
  101. package/dist/controllers/file_dropzone_controller.js +311 -207
  102. package/dist/controllers/file_dropzone_controller.js.map +1 -1
  103. package/dist/controllers/filter_controller.js +67 -39
  104. package/dist/controllers/filter_controller.js.map +1 -1
  105. package/dist/controllers/flash_controller.d.ts +31 -8
  106. package/dist/controllers/flash_controller.js +172 -314
  107. package/dist/controllers/flash_controller.js.map +1 -1
  108. package/dist/controllers/focus_controller.d.ts +12 -3
  109. package/dist/controllers/focus_controller.js +654 -240
  110. package/dist/controllers/focus_controller.js.map +1 -1
  111. package/dist/controllers/form_field_controller.js +147 -132
  112. package/dist/controllers/form_field_controller.js.map +1 -1
  113. package/dist/controllers/form_validation_controller.js +13 -86
  114. package/dist/controllers/form_validation_controller.js.map +1 -1
  115. package/dist/controllers/frame_loading_controller.d.ts +41 -9
  116. package/dist/controllers/frame_loading_controller.js +264 -213
  117. package/dist/controllers/frame_loading_controller.js.map +1 -1
  118. package/dist/controllers/highlight_controller.d.ts +22 -2
  119. package/dist/controllers/highlight_controller.js +107 -75
  120. package/dist/controllers/highlight_controller.js.map +1 -1
  121. package/dist/controllers/hover_card_controller.d.ts +56 -3
  122. package/dist/controllers/hover_card_controller.js +309 -118
  123. package/dist/controllers/hover_card_controller.js.map +1 -1
  124. package/dist/controllers/idle_controller.d.ts +42 -1
  125. package/dist/controllers/idle_controller.js +267 -101
  126. package/dist/controllers/idle_controller.js.map +1 -1
  127. package/dist/controllers/input_mask_controller.js +71 -72
  128. package/dist/controllers/input_mask_controller.js.map +1 -1
  129. package/dist/controllers/intersection_controller.d.ts +32 -13
  130. package/dist/controllers/intersection_controller.js +147 -106
  131. package/dist/controllers/intersection_controller.js.map +1 -1
  132. package/dist/controllers/lazy_frame_controller.d.ts +16 -0
  133. package/dist/controllers/lazy_frame_controller.js +9 -65
  134. package/dist/controllers/lazy_frame_controller.js.map +1 -1
  135. package/dist/controllers/listbox_controller.d.ts +34 -2
  136. package/dist/controllers/listbox_controller.js +306 -204
  137. package/dist/controllers/listbox_controller.js.map +1 -1
  138. package/dist/controllers/local_time_controller.d.ts +1 -1
  139. package/dist/controllers/local_time_controller.js +54 -64
  140. package/dist/controllers/local_time_controller.js.map +1 -1
  141. package/dist/controllers/masonry_controller.d.ts +11 -3
  142. package/dist/controllers/masonry_controller.js +70 -93
  143. package/dist/controllers/masonry_controller.js.map +1 -1
  144. package/dist/controllers/menu_controller.d.ts +32 -7
  145. package/dist/controllers/menu_controller.js +214 -156
  146. package/dist/controllers/menu_controller.js.map +1 -1
  147. package/dist/controllers/menubar_controller.d.ts +4 -4
  148. package/dist/controllers/menubar_controller.js +170 -329
  149. package/dist/controllers/menubar_controller.js.map +1 -1
  150. package/dist/controllers/meter_controller.d.ts +20 -0
  151. package/dist/controllers/meter_controller.js +151 -67
  152. package/dist/controllers/meter_controller.js.map +1 -1
  153. package/dist/controllers/multi_select_controller.d.ts +32 -4
  154. package/dist/controllers/multi_select_controller.js +593 -358
  155. package/dist/controllers/multi_select_controller.js.map +1 -1
  156. package/dist/controllers/navigation_menu_controller.d.ts +8 -1
  157. package/dist/controllers/navigation_menu_controller.js +124 -232
  158. package/dist/controllers/navigation_menu_controller.js.map +1 -1
  159. package/dist/controllers/nested_form_controller.d.ts +10 -0
  160. package/dist/controllers/nested_form_controller.js +352 -182
  161. package/dist/controllers/nested_form_controller.js.map +1 -1
  162. package/dist/controllers/network_status_controller.d.ts +23 -0
  163. package/dist/controllers/network_status_controller.js +242 -54
  164. package/dist/controllers/network_status_controller.js.map +1 -1
  165. package/dist/controllers/number_input_controller.d.ts +26 -2
  166. package/dist/controllers/number_input_controller.js +320 -263
  167. package/dist/controllers/number_input_controller.js.map +1 -1
  168. package/dist/controllers/optimistic_controller.js +16 -76
  169. package/dist/controllers/optimistic_controller.js.map +1 -1
  170. package/dist/controllers/otp_controller.d.ts +20 -4
  171. package/dist/controllers/otp_controller.js +198 -193
  172. package/dist/controllers/otp_controller.js.map +1 -1
  173. package/dist/controllers/overflow_indicator_controller.d.ts +5 -0
  174. package/dist/controllers/overflow_indicator_controller.js +116 -113
  175. package/dist/controllers/overflow_indicator_controller.js.map +1 -1
  176. package/dist/controllers/overflow_menu_controller.d.ts +48 -11
  177. package/dist/controllers/overflow_menu_controller.js +343 -283
  178. package/dist/controllers/overflow_menu_controller.js.map +1 -1
  179. package/dist/controllers/pagination_controller.d.ts +35 -6
  180. package/dist/controllers/pagination_controller.js +295 -119
  181. package/dist/controllers/pagination_controller.js.map +1 -1
  182. package/dist/controllers/password_reveal_controller.d.ts +45 -8
  183. package/dist/controllers/password_reveal_controller.js +389 -121
  184. package/dist/controllers/password_reveal_controller.js.map +1 -1
  185. package/dist/controllers/password_strength_controller.d.ts +14 -5
  186. package/dist/controllers/password_strength_controller.js +99 -153
  187. package/dist/controllers/password_strength_controller.js.map +1 -1
  188. package/dist/controllers/persist_controller.d.ts +11 -4
  189. package/dist/controllers/persist_controller.js +237 -103
  190. package/dist/controllers/persist_controller.js.map +1 -1
  191. package/dist/controllers/pointer_drag_controller.d.ts +19 -7
  192. package/dist/controllers/pointer_drag_controller.js +185 -165
  193. package/dist/controllers/pointer_drag_controller.js.map +1 -1
  194. package/dist/controllers/popover_controller.d.ts +38 -2
  195. package/dist/controllers/popover_controller.js +236 -97
  196. package/dist/controllers/popover_controller.js.map +1 -1
  197. package/dist/controllers/portal_controller.d.ts +44 -4
  198. package/dist/controllers/portal_controller.js +209 -76
  199. package/dist/controllers/portal_controller.js.map +1 -1
  200. package/dist/controllers/preview_guard_controller.d.ts +10 -4
  201. package/dist/controllers/preview_guard_controller.js +232 -116
  202. package/dist/controllers/preview_guard_controller.js.map +1 -1
  203. package/dist/controllers/progress_controller.d.ts +11 -0
  204. package/dist/controllers/progress_controller.js +125 -56
  205. package/dist/controllers/progress_controller.js.map +1 -1
  206. package/dist/controllers/radio_group_controller.d.ts +14 -5
  207. package/dist/controllers/radio_group_controller.js +117 -137
  208. package/dist/controllers/radio_group_controller.js.map +1 -1
  209. package/dist/controllers/range_slider_controller.d.ts +43 -3
  210. package/dist/controllers/range_slider_controller.js +192 -105
  211. package/dist/controllers/range_slider_controller.js.map +1 -1
  212. package/dist/controllers/rating_controller.d.ts +20 -4
  213. package/dist/controllers/rating_controller.js +418 -207
  214. package/dist/controllers/rating_controller.js.map +1 -1
  215. package/dist/controllers/read_more_controller.d.ts +2 -0
  216. package/dist/controllers/read_more_controller.js +134 -63
  217. package/dist/controllers/read_more_controller.js.map +1 -1
  218. package/dist/controllers/reading_progress_controller.d.ts +1 -1
  219. package/dist/controllers/reading_progress_controller.js +147 -135
  220. package/dist/controllers/reading_progress_controller.js.map +1 -1
  221. package/dist/controllers/relative_time_controller.d.ts +18 -4
  222. package/dist/controllers/relative_time_controller.js +145 -110
  223. package/dist/controllers/relative_time_controller.js.map +1 -1
  224. package/dist/controllers/reset_on_restore_controller.d.ts +85 -0
  225. package/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +97 -38
  226. package/dist/controllers/reset_on_restore_controller.js.map +1 -0
  227. package/dist/controllers/resizable_controller.d.ts +28 -2
  228. package/dist/controllers/resizable_controller.js +255 -139
  229. package/dist/controllers/resizable_controller.js.map +1 -1
  230. package/dist/controllers/roving_controller.js +39 -84
  231. package/dist/controllers/roving_controller.js.map +1 -1
  232. package/dist/controllers/scroll_area_controller.d.ts +7 -3
  233. package/dist/controllers/scroll_area_controller.js +428 -225
  234. package/dist/controllers/scroll_area_controller.js.map +1 -1
  235. package/dist/controllers/scroll_restore_controller.js +0 -53
  236. package/dist/controllers/scroll_restore_controller.js.map +1 -1
  237. package/dist/controllers/scroll_visibility_controller.d.ts +28 -12
  238. package/dist/controllers/scroll_visibility_controller.js +395 -145
  239. package/dist/controllers/scroll_visibility_controller.js.map +1 -1
  240. package/dist/controllers/scrollspy_controller.d.ts +6 -1
  241. package/dist/controllers/scrollspy_controller.js +181 -242
  242. package/dist/controllers/scrollspy_controller.js.map +1 -1
  243. package/dist/controllers/separator_controller.d.ts +19 -4
  244. package/dist/controllers/separator_controller.js +267 -140
  245. package/dist/controllers/separator_controller.js.map +1 -1
  246. package/dist/controllers/sidebar_controller.d.ts +64 -7
  247. package/dist/controllers/sidebar_controller.js +1023 -386
  248. package/dist/controllers/sidebar_controller.js.map +1 -1
  249. package/dist/controllers/skeleton_controller.d.ts +23 -0
  250. package/dist/controllers/skeleton_controller.js +248 -97
  251. package/dist/controllers/skeleton_controller.js.map +1 -1
  252. package/dist/controllers/slider_controller.d.ts +27 -1
  253. package/dist/controllers/slider_controller.js +159 -79
  254. package/dist/controllers/slider_controller.js.map +1 -1
  255. package/dist/controllers/smart_sticky_header_controller.d.ts +21 -3
  256. package/dist/controllers/smart_sticky_header_controller.js +162 -63
  257. package/dist/controllers/smart_sticky_header_controller.js.map +1 -1
  258. package/dist/controllers/sortable_controller.js +0 -112
  259. package/dist/controllers/sortable_controller.js.map +1 -1
  260. package/dist/controllers/spinner_controller.d.ts +39 -4
  261. package/dist/controllers/spinner_controller.js +277 -169
  262. package/dist/controllers/spinner_controller.js.map +1 -1
  263. package/dist/controllers/step_indicator_controller.d.ts +5 -0
  264. package/dist/controllers/step_indicator_controller.js +99 -46
  265. package/dist/controllers/step_indicator_controller.js.map +1 -1
  266. package/dist/controllers/stepper_controller.d.ts +12 -3
  267. package/dist/controllers/stepper_controller.js +114 -73
  268. package/dist/controllers/stepper_controller.js.map +1 -1
  269. package/dist/controllers/stick_to_bottom_controller.d.ts +6 -0
  270. package/dist/controllers/stick_to_bottom_controller.js +262 -138
  271. package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
  272. package/dist/controllers/sticky_observer_controller.d.ts +11 -0
  273. package/dist/controllers/sticky_observer_controller.js +214 -49
  274. package/dist/controllers/sticky_observer_controller.js.map +1 -1
  275. package/dist/controllers/submit_once_controller.d.ts +23 -8
  276. package/dist/controllers/submit_once_controller.js +294 -205
  277. package/dist/controllers/submit_once_controller.js.map +1 -1
  278. package/dist/controllers/switch_controller.d.ts +12 -1
  279. package/dist/controllers/switch_controller.js +33 -60
  280. package/dist/controllers/switch_controller.js.map +1 -1
  281. package/dist/controllers/tabs_controller.d.ts +2 -2
  282. package/dist/controllers/tabs_controller.js +35 -29
  283. package/dist/controllers/tabs_controller.js.map +1 -1
  284. package/dist/controllers/tags_input_controller.d.ts +12 -0
  285. package/dist/controllers/tags_input_controller.js +136 -145
  286. package/dist/controllers/tags_input_controller.js.map +1 -1
  287. package/dist/controllers/textarea_autosize_controller.d.ts +10 -0
  288. package/dist/controllers/textarea_autosize_controller.js +71 -58
  289. package/dist/controllers/textarea_autosize_controller.js.map +1 -1
  290. package/dist/controllers/theme_controller.d.ts +21 -9
  291. package/dist/controllers/theme_controller.js +130 -112
  292. package/dist/controllers/theme_controller.js.map +1 -1
  293. package/dist/controllers/time_picker_controller.d.ts +18 -1
  294. package/dist/controllers/time_picker_controller.js +146 -80
  295. package/dist/controllers/time_picker_controller.js.map +1 -1
  296. package/dist/controllers/toast_controller.d.ts +36 -11
  297. package/dist/controllers/toast_controller.js +186 -297
  298. package/dist/controllers/toast_controller.js.map +1 -1
  299. package/dist/controllers/toggle_group_controller.d.ts +12 -3
  300. package/dist/controllers/toggle_group_controller.js +95 -136
  301. package/dist/controllers/toggle_group_controller.js.map +1 -1
  302. package/dist/controllers/toolbar_controller.js +68 -98
  303. package/dist/controllers/toolbar_controller.js.map +1 -1
  304. package/dist/controllers/tooltip_controller.d.ts +45 -3
  305. package/dist/controllers/tooltip_controller.js +158 -124
  306. package/dist/controllers/tooltip_controller.js.map +1 -1
  307. package/dist/controllers/transition_controller.d.ts +22 -4
  308. package/dist/controllers/transition_controller.js +123 -119
  309. package/dist/controllers/transition_controller.js.map +1 -1
  310. package/dist/controllers/tree_view_controller.d.ts +21 -11
  311. package/dist/controllers/tree_view_controller.js +150 -345
  312. package/dist/controllers/tree_view_controller.js.map +1 -1
  313. package/dist/index.d.ts +8 -5
  314. package/dist/index.js +6370 -9346
  315. package/dist/index.js.map +1 -1
  316. package/dist/inspector/cli.d.ts +23 -3
  317. package/dist/inspector/cli.js +92 -37
  318. package/dist/inspector/cli.js.map +1 -1
  319. package/dist/inspector/cli_bin.js +92 -56
  320. package/dist/inspector/cli_bin.js.map +1 -1
  321. package/dist/inspector/examples.json +8 -8
  322. package/dist/inspector/manifest.json +787 -100
  323. package/dist/positioning/index.d.ts +8 -0
  324. package/dist/positioning/index.js +148 -47
  325. package/dist/positioning/index.js.map +1 -1
  326. package/package.json +6 -6
  327. package/dist/controllers/reset_before_cache_controller.d.ts +0 -76
  328. package/dist/controllers/reset_before_cache_controller.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/attribute_lease.ts","../../src/utils/before_cache_reset.ts","../../src/utils/detach_gate.ts","../../src/utils/event_owner.ts","../../src/utils/listener_set.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/reduced_motion.ts","../../src/utils/roving_tabindex.ts","../../src/utils/safe_timeout.ts","../../src/utils/state_regions.ts","../../src/controllers/carousel_controller.ts"],"names":[],"mappings":";;;;;AAiBO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;;ACiBO,SAAS,gBAAA,CAAiB,KAAa,OAAA,EAA8B;AAC1E,EAAA,IAAI,GAAA,KAAQ,aAAa,OAAO,CAAA;AAChC,EAAA,IAAI,GAAA,KAAQ,WAAW,OAAO,EAAA;AAC9B,EAAA,IAAI,GAAA,KAAQ,YAAA,IAAgB,GAAA,KAAQ,WAAA,EAAa,OAAO,CAAA;AACxD,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,OAAO,CAAA,GAAI,WAAA,GAAc,YAAA;AAC/C,EAAA,OAAO,GAAA,KAAQ,UAAU,CAAA,GAAI,EAAA;AAC/B;AAqDO,SAAS,oBAAA,CACd,KAAA,EACA,KAAA,GAAkC,EAAC,EAC1B;AACT,EAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,OAAO,GAAG,OAAO,KAAA;AAC3C,EAAA,OACG,KAAA,CAAM,MAAA,IAAU,CAAC,KAAA,CAAM,QAAA,CAAS,KAAK,CAAA,IACrC,KAAA,CAAM,OAAA,IAAW,CAAC,KAAA,CA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EAAU;AAAA,EAC7B;AACF;AAGA,SAAS,aAAa,KAAA,EAAoC;AACxD,EAAA,OAAO,KAAA,EAAO,IAAA,CAAK,UAAA,CAAW,OAAO,CAAA,KAAM,IAAA;AAC7C;AAGA,SAAS,YAAY,KAAA,EAA+B;AAClD,EAAA,OAAO,MAAM,MAAA,IAAU,KAAA,CAAM,OAAA,IAAW,KAAA,CAAM,WAAW,KAAA,CAAM,QAAA;AACjE;AAGA,SAAS,IAAA,CAAK,UAAkC,IAAA,EAAmC;AACjF,EAAA,OAAO,UAAA,CAAW,QAAA,EAAU,IAAI,CAAA,KAAM,EAAA;AACxC;AAGA,SAAS,qBAAA,CAAsB,OAAA,EAAkB,IAAA,EAAc,KAAA,EAAqB;AAClF,EAAA,IAAI,OAAA,CAAQ,aAAa,IAAI,CAAA,KAAM,OAAO,OAAA,CAAQ,YAAA,CAAa,MAAM,KAAK,CAAA;AAC5E","file":"carousel_controller.js","sourcesContent":["/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","import { isRtl } from \"./logical_scroll\";\n\n/**\n * Turns an arrow key into a **logical** step: `+1` for \"next\", `-1` for\n * \"previous\", `0` when the key names neither.\n *\n * APG defines the horizontal pair as *next / previous* and says a vertical\n * arrangement swaps in Down/Up for the same meaning — so the pair is one axis's\n * spelling of an order, and the order reverses with the writing direction. Only\n * the horizontal pair reverses. Down/Up name an axis the writing direction does\n * not mirror, and returning them unchanged is the point: many controllers fold\n * both pairs into one branch, where swapping the branches under RTL would flip\n * the vertical axis too — a bug that reads as \"the arrows work\" until someone\n * presses Down.\n *\n * **Direction is read from the element the caller passes, which should be the\n * container that lays the items out** — not the focused child. A child may carry\n * its own `dir` (an LTR input inside an RTL form is ordinary authoring), and\n * probing per handler makes two handlers disagree at the boundary between them.\n *\n * This decides direction only. Whether the axis is even active (an\n * `orientation=\"horizontal\"` widget ignoring Down/Up), how far the step lands,\n * and what wrapping does all stay with the caller.\n *\n * **It encodes the list-order convention: `ArrowDown` is *next*.** Widgets that\n * pair the arrows by *value* instead — `ArrowUp` meaning \"more\", as a rating or a\n * slider does — must not use this, or their vertical axis inverts. Reverse the\n * horizontal pair on its own there.\n *\n * @example\n * ```ts\n * const step = logicalArrowStep(event.key, this.element);\n * if (step === 0) return;\n * this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n * ```\n */\nexport function logicalArrowStep(key: string, element: Element): 1 | -1 | 0 {\n if (key === \"ArrowDown\") return 1;\n if (key === \"ArrowUp\") return -1;\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return 0;\n const forward = isRtl(element) ? \"ArrowLeft\" : \"ArrowRight\";\n return key === forward ? 1 : -1;\n}\n\n/**\n * Rewrites `key` so an existing LTR-shaped branch keeps working under RTL:\n * `ArrowRight` and `ArrowLeft` trade places, everything else passes through.\n *\n * The alternative — negating a delta — silently breaks handlers whose two\n * horizontal branches are **not mirror images**. A grid that clamps one edge but\n * not the other, or a segmented field guarding `index > 0` on one side and\n * `index < length - 1` on the other, ends up applying the wrong guard to the\n * wrong direction. Swapping the key leaves each branch, guards and all, exactly\n * where its author put it.\n *\n * Same rule as {@link logicalArrowStep} about which element to read: pass the\n * container that lays the items out, not the focused child.\n *\n * @example\n * ```ts\n * switch (logicalArrowKey(event.key, this.element)) {\n * case \"ArrowLeft\": // \"previous\" — whatever direction that is on screen\n * ```\n */\nexport function logicalArrowKey(key: string, element: Element): string {\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return key;\n if (!isRtl(element)) return key;\n return key === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n}\n\n/** Modifiers a widget may claim on an arrow key, named for the `allow` list. */\nexport type ArrowModifier = \"alt\" | \"ctrl\" | \"meta\" | \"shift\";\n\n/**\n * True when an arrow key arrived carrying a modifier the widget must leave to\n * the browser: return without calling `preventDefault()` and without moving any\n * state.\n *\n * A bare arrow belongs to the widget; a chorded one usually does not.\n * `Alt`/`Meta` plus a horizontal arrow is history back/forward on every desktop\n * browser, and a widget that swallows it makes the shortcut work or not\n * depending on where focus happens to sit — a coin-flip the user cannot see.\n *\n * `allow` is for the combinations APG assigns to a pattern **and the widget\n * actually implements** — today only Combobox's optional `Alt+Down`/`Alt+Up`.\n * Listing one the widget does not implement defeats the point: the chord then\n * runs the plain-arrow branch, which is exactly what this guard exists to stop.\n * Non-arrow keys return `false`, so chorded letters and\n * `Control+Home`/`Control+End` are untouched.\n *\n * @example\n * ```ts\n * if (isReservedArrowChord(event)) return;\n * ```\n */\nexport function isReservedArrowChord(\n event: KeyboardEvent,\n allow: readonly ArrowModifier[] = [],\n): boolean {\n if (!event.key.startsWith(\"Arrow\")) return false;\n return (\n (event.altKey && !allow.includes(\"alt\")) ||\n (event.ctrlKey && !allow.includes(\"ctrl\")) ||\n (event.metaKey && !allow.includes(\"meta\")) ||\n (event.shiftKey && !allow.includes(\"shift\"))\n );\n}\n\n/**\n * True when a press arrived carrying any modifier, for the keys the browser and\n * the OS own outright: return without calling `preventDefault()` and without\n * moving any state.\n *\n * `Control+Home` and `Control+End` jump the document to its ends, and a widget\n * that swallows them makes the shortcut work or not depending on where focus\n * happens to sit. {@link isReservedArrowChord} answers the same question for the\n * arrows, but returns `false` for every other key so that this one can decide.\n *\n * There is no `allow` list here on purpose. APG assigns no modifier chord to\n * `Home`/`End`, so a widget that wanted one would be claiming a combination the\n * pattern never gave it.\n *\n * @example\n * ```ts\n * case \"Home\":\n * case \"End\":\n * if (hasModifierChord(event)) return;\n * ```\n */\nexport function hasModifierChord(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n","/** One temporarily controlled attribute value and the authored value it displaced. */\ninterface AttributeLeaseRecord {\n readonly original: string | null;\n written: string | null;\n}\n\n/**\n * Temporarily controls one attribute across a changing set of elements.\n *\n * The first write remembers the authored value, including the distinction between\n * an absent attribute and an authored empty string. Returning a lease restores that\n * value only while the attribute still matches the controller's last write. If a\n * consumer changed it in the meantime, the consumer owns the new value and teardown\n * leaves it alone.\n *\n * A `null` write deliberately removes the attribute while retaining the lease. This\n * is useful for derived ARIA whose valid absence is itself controller state, such as\n * an unbounded `aria-valuemin` or a blank spinbutton's `aria-valuenow`.\n *\n * The lease has no lifecycle of its own, so it never subscribes to document events.\n * A consumer that must not let a derived value become the authored baseline of a\n * cached page returns its leases from its own `turbo:before-cache` rewind, where the\n * matching `disconnect()` also releases the subscription.\n */\nexport class AttributeLease<T extends Element = Element> {\n readonly #attribute: string;\n readonly #records = new Map<T, AttributeLeaseRecord>();\n\n /** @param attribute - The attribute whose temporary values this lease owns. */\n constructor(attribute: string) {\n this.#attribute = attribute;\n }\n\n /** Writes or removes the leased attribute while preserving its authored value. */\n write(element: T, value: string | null): void {\n const existing = this.#records.get(element);\n if (existing) {\n existing.written = value;\n } else {\n this.#records.set(element, {\n original: element.getAttribute(this.#attribute),\n written: value,\n });\n }\n\n this.#reflect(element, value);\n }\n\n /** Returns one lease without overwriting a value subsequently authored by a consumer. */\n return(element: T): void {\n const record = this.#records.get(element);\n if (!record) return;\n this.#records.delete(element);\n const stillOwned = element.getAttribute(this.#attribute) === record.written;\n if (stillOwned) this.#reflect(element, record.original);\n }\n\n /** Reflects only a real value transition, avoiding self-triggered mutation work. */\n #reflect(element: T, value: string | null): void {\n if (element.getAttribute(this.#attribute) === value) return;\n if (value === null) element.removeAttribute(this.#attribute);\n else element.setAttribute(this.#attribute, value);\n }\n\n /** Returns every outstanding lease using the same ownership check as {@link return}. */\n returnAll(): void {\n for (const element of Array.from(this.#records.keys())) this.return(element);\n }\n}\n","/**\n * Runs a controller's \"return to the initial state\" pass just before Turbo\n * caches the page.\n *\n * **`disconnect()` cannot do this job, for two independent reasons.** Turbo\n * queues the clone from this event rather than taking it here, and the body swap\n * that runs the controller's `disconnect()` is queued separately — so which of\n * the two lands first is not something a controller can rely on, and a rewind\n * written in `disconnect()` may reach only the DOM being thrown away. In the\n * other direction, `disconnect()` also fires on an in-page move (Stimulus tears\n * down and reconnects the same element), where rewinding would wipe a\n * legitimately in-progress interaction — a spinner mid-load would vanish. One\n * timing is unreliable, the other is too eager; `turbo:before-cache` is the only\n * point that is exactly \"the page is about to be frozen\".\n *\n * Scope is the subscription only: registering on `activate()`, unregistering on\n * `deactivate()`, and one shared document listener no matter how many instances\n * are live. *What* to return to its initial state — which `data-state`, which\n * `hidden`, which `aria-busy` — stays in the controller, because no two\n * consumers answer it the same way.\n *\n * **Rewind state, not appearance.** The pass writes attributes the controller\n * itself owns; the visual result of those attributes is the consumer's CSS, and\n * a library that reached for style or class names would be guessing at markup\n * it does not own.\n *\n * Both entry points are idempotent, so the lifecycle hooks can call them\n * unconditionally: a second `activate()` does not double-subscribe and does not\n * make the callback run twice, and `deactivate()` on an instance that never\n * subscribed is a no-op.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #beforeCache = new BeforeCacheReset(() => this.#rewind());\n *\n * connect() { this.#beforeCache.activate(); }\n * disconnect() { this.#beforeCache.deactivate(); }\n * ```\n */\nexport class BeforeCacheReset {\n /** Every subscribed instance, iterated by the one shared document listener. */\n static readonly #subscribers = new Set<BeforeCacheReset>();\n\n /** The shared listener; installed while at least one instance is subscribed. */\n static readonly #onBeforeCache = (): void => {\n for (const subscriber of BeforeCacheReset.#subscribers) subscriber.#rewind();\n };\n\n readonly #rewind: () => void;\n\n /** @param rewind - the pass that returns this controller's state to its initial form. */\n constructor(rewind: () => void) {\n this.#rewind = rewind;\n }\n\n /** Subscribes to `turbo:before-cache`; call from `connect()`. Idempotent. */\n activate(): void {\n const first = BeforeCacheReset.#subscribers.size === 0;\n BeforeCacheReset.#subscribers.add(this);\n if (first) {\n document.addEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n }\n\n /** Unsubscribes; call from `disconnect()`. Safe when never subscribed. */\n deactivate(): void {\n BeforeCacheReset.#subscribers.delete(this);\n if (BeforeCacheReset.#subscribers.size > 0) return;\n document.removeEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n}\n","/**\n * Shared \"in-page move vs real detach\" discriminator for `disconnect()`.\n *\n * A mid-session `disconnect()` whose element is still in the document is\n * ambiguous. It can be:\n *\n * - an **in-page move** — a consumer (sortable, a teleport) re-inserted the\n * element; Stimulus reconnects the SAME instance in the same mutation batch\n * and the controller's runtime state must survive;\n * - a **detach that keeps the element** — `data-controller` no longer lists the\n * identifier (a Turbo 8 morph), or the element moved outside the observed\n * root (a scoped `Application.start(root)`, a shadow root); no reconnect will\n * ever come and the controller must tear down or it leaks its sessions,\n * document listeners, and moved nodes.\n *\n * Neither available signal decides this alone. A synchronous `data-controller`\n * token check catches the morph case but misses an observed-root exit (the\n * token stays, the reconnect never comes). Deferring teardown one microtask and\n * letting `connect()` cancel it catches the root exit, but leans on Stimulus\n * reconnecting moved elements within the same mutation batch — internal\n * behavior, not a public contract. {@link DetachGate} composes both: the token\n * check is the synchronous fast path (no probe, no reliance on batching), the\n * microtask probe is the fallback for the genuinely ambiguous remainder.\n *\n * Policy stays with the consumer; this util owns the discrimination only:\n *\n * - **Probe** ({@link disconnected}) when the teardown must eventually happen —\n * live drag sessions, document listeners, teleported *content*. Call\n * {@link cancel} from `connect()` (a reconnect means in-page move) and from\n * the head of any direct teardown path (see below).\n * - **Keep** (bare {@link DetachGate.isDetached}) when undoing the ambiguous\n * case would fight the controller's own effect: a controller that moves its\n * OWN element (portal's no-`content` form) exits a scoped observed root as\n * its normal job — a probe-driven teardown would restore the element into\n * the root, reconnect, re-teleport, and disconnect again, forever. Such\n * controllers keep their state on an ambiguous disconnect and tear down only\n * on {@link DetachGate.isDetached}.\n *\n * Event convention for probe consumers: teardown into a dead (detached) tree is\n * silent — consumers restore from their own `connect()`; a detach that keeps the\n * tree alive must end an in-flight session with a `cancel` event, or composing\n * consumers strand their session bookkeeping.\n */\n\n/** The slice of a Stimulus controller the gate inspects. */\nexport interface DetachGateHost {\n readonly element: Element;\n readonly identifier: string;\n}\n\n/**\n * Per-controller-instance gate deciding whether a `disconnect()` is a real\n * detach. Hold one per controller (`#gate = new DetachGate()`) — Stimulus\n * reuses the instance across reconnects, so the pending probe state carries\n * over exactly as the protocol needs.\n *\n * @example\n * ```ts\n * #gate = new DetachGate();\n *\n * connect(): void {\n * this.#gate.cancel(); // a reconnect: the element moved in-page\n * // …\n * }\n *\n * disconnect(): void {\n * this.#gate.disconnected(this, () => this.#teardown());\n * }\n *\n * #teardown(): void {\n * this.#gate.cancel(); // disarm a still-queued probe (double-run guard)\n * // …\n * }\n * ```\n */\nexport class DetachGate {\n /** Set while a probe is queued, waiting for a reconnect to cancel it. */\n #pending = false;\n\n /**\n * True while a probe is queued — the last disconnect was ambiguous and no\n * reconnect has cancelled it yet. Read it from `connect()` to tell the\n * reconnect half of an in-page move from a first connect: a controller whose\n * initialisation restarts a measurement (a min-duration floor, an elapsed\n * counter) must skip it for the move, where nothing actually restarted.\n */\n get pending(): boolean {\n return this.#pending;\n }\n\n /**\n * True when the disconnect is definitely a real detach — the element left\n * the document, or `data-controller` no longer lists the identifier. False\n * means ambiguous (in-page move or observed-root exit), NOT \"alive\".\n */\n static isDetached(host: DetachGateHost): boolean {\n if (!host.element.isConnected) return true;\n const tokens = (host.element.getAttribute(\"data-controller\") ?? \"\").split(/\\s+/);\n return !tokens.includes(host.identifier);\n }\n\n /**\n * Call from `disconnect()`: runs `teardown` synchronously on a definite\n * detach (fast path), otherwise defers it one microtask — a reconnect\n * ({@link cancel} from `connect()`) keeps the state, no reconnect runs it.\n * One microtask is the whole probe window: Stimulus reconnects a moved\n * element within the same mutation batch, before the checkpoint drains.\n */\n disconnected(host: DetachGateHost, teardown: () => void): void {\n if (DetachGate.isDetached(host)) {\n // Also disarms a probe a previous ambiguous disconnect left queued\n // (defer, element removed, disconnect again) — exactly one teardown.\n this.#pending = false;\n teardown();\n return;\n }\n this.#pending = true;\n queueMicrotask(() => {\n if (!this.#pending) return;\n this.#pending = false;\n teardown();\n });\n }\n\n /**\n * Disarms a pending probe. Call from `connect()` (the reconnect that proves\n * an in-page move) and from the head of any teardown path not routed through\n * {@link disconnected} (disabled-toggle, Escape), so an orphaned probe can\n * never run the teardown a second time.\n */\n cancel(): void {\n this.#pending = false;\n }\n}\n","/**\n * Resolves which of a controller's elements owns a node.\n *\n * A delegated listener hears events from a whole subtree, so the handler's first\n * job is almost always the same question: which item, handle, or control does\n * this `event.target` belong to? The same question comes up for a\n * `MutationRecord.target`, for `document.activeElement`, and for a\n * `relatedTarget` on the way out of a hover region.\n *\n * The answer is `Node.contains()`, which is **inclusive** — an element contains\n * itself — so testing the candidate for identity as well would be redundant.\n *\n * **The guard is what makes this safe to call with a raw event target.**\n * `event.target` is typed `EventTarget | null`, and `contains()` takes a `Node?`:\n * browsers throw `TypeError` for anything else, and `window` — the everyday\n * `EventTarget` that is not a `Node` — is what an event dispatched at it carries.\n * Narrowing here means a caller never has to cast, and the rule cannot drift\n * between the places that ask the question.\n *\n * Scope stays with the caller. These helpers say *which candidate owns the node*,\n * not *whether the node belongs to this controller at all* — a component with\n * nested instances of itself decides that first (by comparing the closest\n * annotated ancestor) and passes the candidates it owns.\n */\n\n/**\n * Index in `candidates` of the first one that is, or contains, `node`.\n *\n * `-1` when none does, when `node` is absent, and when it is an `EventTarget`\n * that is not a `Node`. Candidates are tested in array order, so a nested pair\n * resolves to whichever the caller listed first.\n */\nexport function ownerIndex<T extends Element>(\n candidates: readonly T[],\n node: EventTarget | null | undefined,\n): number {\n if (!(node instanceof Node)) return -1;\n return candidates.findIndex((candidate) => candidate.contains(node));\n}\n\n/**\n * The first candidate that is, or contains, `node`; `null` when none does.\n *\n * A miss indexes the array at `-1`, which reads as `undefined` and lands on the\n * same `null` the absent cases produce.\n */\nexport function ownerOf<T extends Element>(\n candidates: readonly T[],\n node: EventTarget | null | undefined,\n): T | null {\n return candidates[ownerIndex(candidates, node)] ?? null;\n}\n","/**\n * Owns every listener a controller attaches for one connected lifetime and\n * releases them together, so an event name is spelled once and the release\n * cannot drift from the registration.\n *\n * Detaching by hand repeats three things at the release site — the type, the\n * handler reference and the capture flag — and any one of them drifting leaves\n * a listener alive on an element the controller no longer drives. Aborting the\n * signal a registration was created with releases it whatever it was made of,\n * so the release site names nothing.\n *\n * One set per lifetime, held as a field and never rebuilt. {@link\n * ListenerSet.dispose} is the only thing that closes a generation, and it opens\n * the next one in the same step, so the lifecycle hooks can call `add` and\n * `dispose` in any order any number of times, and no `add` ever meets an\n * already aborted signal — a DOM that registers a listener on such a signal\n * would keep it forever. Rebuilding the set instead would leak:\n * `addEventListener` matches an existing registration on target, type, callback\n * and capture alone, so re-adding the same handler while the first registration\n * is live is discarded, and that live registration keeps the signal it was\n * attached with — a set built by a second `connect()` can never release what it\n * appears to own.\n *\n * Scope is the registration only. Timers, observers, leases and the order they\n * are unwound in stay with the controller, so `dispose()` belongs exactly where\n * the `removeEventListener` block stood. A receiver that changes at runtime (a\n * swapped target) is rebound by calling `dispose()` and then `add()` again from\n * the rebind, not by a second set.\n *\n * The set must own every registration of a tuple it holds: a listener the same\n * target already carries for the same type, callback and capture flag keeps the\n * right to remove it, and this set's `add` for that tuple is discarded. A\n * subscription shared between instances behind a participant count, or one that\n * lives for less than the connection, keeps its own pair of calls.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #listeners = new ListenerSet();\n *\n * connect(): void {\n * this.#listeners.add(this.element, \"submit\", this.#onNativeSubmit, { capture: true });\n * this.#listeners.add(this.element, \"turbo:submit-start\", this.#onSubmitStart);\n * this.#listeners.add(this.element, \"turbo:submit-end\", this.#onSubmitEnd);\n * }\n *\n * disconnect(): void {\n * this.#listeners.dispose();\n * }\n * ```\n */\nexport class ListenerSet {\n /** The generation every `add` joins until the next `dispose()`. */\n #abort = new AbortController();\n\n /**\n * Attaches `handler` to the open generation, exactly as the caller spelled it.\n *\n * The set supplies the signal, so `options` carries everything else the DOM\n * accepts — `capture` included, which has to match at release time and no\n * longer has a second place to drift from.\n */\n add(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: Omit<AddEventListenerOptions, \"signal\">,\n ): void {\n target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });\n }\n\n /**\n * Releases every listener of the open generation, synchronously, and opens the\n * next one. Idempotent, and safe before anything has been added.\n */\n dispose(): void {\n this.#abort.abort();\n this.#abort = new AbortController();\n }\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","/**\n * Shared `prefers-reduced-motion` lookup for the motion-aware controllers.\n *\n * This one-liner keeps the media query string and the environment guard\n * single-sourced across them. The preference is intentionally re-read on every\n * call — the controllers check it at each animation/scroll start (WCAG 2.2\n * **2.3.3**), so flipping the OS setting takes effect immediately without any\n * listener or cache bookkeeping here.\n */\n\n/**\n * Whether the user currently requests reduced motion.\n *\n * @returns `true` when `(prefers-reduced-motion: reduce)` matches; `false`\n * otherwise, including environments without `window.matchMedia` (treated as\n * \"no preference\").\n */\nexport function prefersReducedMotion(): boolean {\n return (\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n","/**\n * Low-level roving-tabindex primitive shared by composite-widget controllers.\n *\n * The APG roving-tabindex pattern keeps a composite widget a single Tab stop:\n * exactly one item is in the Tab sequence (`tabindex=\"0\"`) while the rest are\n * removed from it (`tabindex=\"-1\"`), and the arrow keys move both DOM focus and\n * that single tabbable position together. {@link RovingTabindex} owns *only* that\n * mechanical bookkeeping — \"which one item is tabbable, and move focus there\".\n *\n * It is intentionally **policy-free**. Orientation, wrapping vs. clamping,\n * selection-follows-focus, typeahead, and `Home`/`End` semantics differ per APG\n * pattern (Radio Group, Toolbar, Rating, …); folding them into one helper would\n * flatten those widgets to a lowest common denominator and lose each pattern's\n * correctness. Those decisions therefore stay in each controller, which calls\n * {@link RovingTabindex.setActive} with an index it computed itself (optionally\n * via the pure {@link rovingMove} helper).\n *\n * @remarks\n * Items are read lazily through a getter so a controller can add or remove\n * targets (Stimulus re-scans the DOM) without re-wiring this helper. A caller\n * that already captured one event-scoped snapshot may pass it to\n * {@link RovingTabindex.setActive}, avoiding a second live-target scan while\n * preserving one coherent collection for the whole operation.\n */\nexport class RovingTabindex {\n /** Returns the current ordered item elements; called on every operation. */\n readonly #getItems: () => HTMLElement[];\n\n /**\n * @param getItems - Returns the current ordered item elements. Called on every\n * operation so the live target list is always used.\n */\n constructor(getItems: () => HTMLElement[]) {\n this.#getItems = getItems;\n }\n\n /** Index of the currently tabbable item (`tabindex=\"0\"`), or `-1` if none. */\n get activeIndex(): number {\n return this.#getItems().findIndex((item) => item.tabIndex === 0);\n }\n\n /**\n * Makes exactly the item at `index` tabbable (`tabindex=\"0\"`) and removes every\n * other item from the Tab sequence (`tabindex=\"-1\"`). An out-of-range `index`\n * (e.g. `-1`) leaves all items at `-1`, which a controller can use to express\n * \"nothing is currently tabbable\".\n *\n * @param index - Position of the item to make tabbable.\n * @param options - Pass `{ focus: true }` to also move DOM focus to that item,\n * and `items` to reuse an event-scoped collection snapshot.\n */\n setActive(\n index: number,\n options: { focus?: boolean; items?: readonly HTMLElement[] } = {},\n ): void {\n const { focus = false } = options;\n const items = options.items ?? this.#getItems();\n items.forEach((item, i) => {\n item.tabIndex = i === index ? 0 : -1;\n });\n if (focus) items[index]?.focus();\n }\n}\n\n/** Edge behavior for {@link rovingMove}: cycle past the ends, or stop at them. */\nexport type RovingWrap = \"wrap\" | \"clamp\";\n\n/**\n * Pure helper that resolves the target index for a one-step directional move.\n *\n * Keyboard/orientation mapping stays in the caller: it decides that a key means\n * `delta` `+1` (next) or `-1` (previous) and whether the widget should `\"wrap\"`\n * (Radio Group, Toolbar) or `\"clamp\"` at the ends.\n *\n * @param current - The index focus is moving from.\n * @param length - Number of items in the set.\n * @param delta - `+1` to move to the next item, `-1` for the previous.\n * @param wrap - `\"wrap\"` cycles around the ends; `\"clamp\"` stops at them.\n * @returns The resolved index, or `-1` when there are no items.\n */\nexport function rovingMove(\n current: number,\n length: number,\n delta: number,\n wrap: RovingWrap,\n): number {\n if (length === 0) return -1;\n const next = current + delta;\n if (wrap === \"wrap\") return (next + length) % length;\n return Math.min(length - 1, Math.max(0, next));\n}\n","/**\n * Self-cleaning timer registries shared by Stimeo controllers.\n *\n * Stimulus controllers frequently schedule `setTimeout` / `setInterval` work\n * (auto-dismiss, debouncing, polling). When the element leaves the DOM — a\n * Turbo Drive navigation, a Turbo Stream replacement, or any `disconnect()` —\n * orphaned timers keep firing against a detached controller, leaking memory and\n * mutating stale state. {@link SafeTimeout} and {@link SafeInterval} track every\n * timer they create so a single {@link TimerRegistry.clearAll | clearAll()} call\n * in `disconnect()` tears them all down.\n *\n * These are intentionally low-level primitives: they own *registration and\n * cleanup only*. Higher-level policy (pause/resume, remaining-time accounting)\n * stays in the individual controllers so per-widget semantics are not flattened\n * into a lowest-common-denominator helper.\n */\n\n/**\n * Largest delay a timer can hold: the platform stores it in a 32-bit signed\n * integer, and anything larger overflows to `1`, so a delay meant to be far in\n * the future fires almost immediately. A declared delay above this bound names\n * no delay at all, and a controller reading one falls back to its default.\n */\nexport const MAX_TIMER_DELAY_MS = 2_147_483_647;\n\n/**\n * Shared registry bookkeeping for the timeout/interval variants.\n *\n * Subclasses provide the scheduling primitive ({@link schedule}) and its matching\n * canceller ({@link cancel}); this base owns the set of live ids plus the\n * per-id and bulk teardown shared by both.\n */\nabstract class TimerRegistry {\n /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */\n protected readonly ids = new Set<number>();\n\n /** Schedules the underlying platform timer and returns its id. */\n protected abstract schedule(callback: () => void, delay: number): number;\n\n /** Cancels the underlying platform timer for `id`. */\n protected abstract cancel(id: number): void;\n\n /**\n * Cancels a single tracked timer.\n *\n * No-ops if the id is unknown (already cleared, fired, or never owned by this\n * registry), so callers can clear defensively without guarding.\n */\n clear(id: number): void {\n if (this.ids.delete(id)) {\n this.cancel(id);\n }\n }\n\n /**\n * Cancels every tracked timer. Call this from a controller's `disconnect()`\n * to guarantee no timer outlives the element.\n */\n clearAll(): void {\n for (const id of this.ids) {\n this.cancel(id);\n }\n this.ids.clear();\n }\n\n /** Number of timers currently tracked (pending). */\n get size(): number {\n return this.ids.size;\n }\n}\n\n/**\n * `setTimeout` wrapper that auto-forgets each timer once it fires and supports\n * bulk teardown on disconnect.\n *\n * @example\n * ```ts\n * #timers = new SafeTimeout();\n *\n * connect() {\n * this.#timers.set(() => this.dismiss(), 5000);\n * }\n *\n * disconnect() {\n * this.#timers.clearAll();\n * }\n * ```\n */\nexport class SafeTimeout extends TimerRegistry {\n /**\n * Schedules `callback` after `delay` ms and returns the timer id.\n *\n * The id is removed from the registry automatically when the timeout fires,\n * so {@link TimerRegistry.size | size} reflects only still-pending timers.\n */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(() => {\n this.ids.delete(id);\n callback();\n }, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setTimeout(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearTimeout(id);\n }\n}\n\n/**\n * `setInterval` wrapper that tracks every interval for bulk teardown on\n * disconnect. Unlike {@link SafeTimeout}, intervals are retained until they are\n * explicitly cleared because they fire repeatedly.\n *\n * @example\n * ```ts\n * #intervals = new SafeInterval();\n *\n * connect() {\n * this.#intervals.set(() => this.tick(), 1000);\n * }\n *\n * disconnect() {\n * this.#intervals.clearAll();\n * }\n * ```\n */\nexport class SafeInterval extends TimerRegistry {\n /** Schedules a repeating `callback` every `delay` ms and returns the timer id. */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(callback, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setInterval(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearInterval(id);\n }\n}\n","/** What a consumer declares once about the regions one boolean state reveals. */\nexport interface StateRegionsOptions {\n /** Returns the declared regions shown while the state holds. */\n readonly whenTrue: () => readonly HTMLElement[];\n /**\n * Returns the declared regions shown while the state does not hold. Omitted by a\n * state whose other side has nothing of its own to show.\n */\n readonly whenFalse?: () => readonly HTMLElement[];\n}\n\n/**\n * Owns `hidden` on the regions a boolean state reveals.\n *\n * A region is a **declared** target, so the consumer decides whether one exists at\n * all; where it does, which side is shown is a pure function of the state and the\n * controller writes it unconditionally. An authored `hidden` is therefore not read\n * back — the first reflection after a connection settles it, and a restored DOM\n * cannot leave a region contradicting the state it belongs to.\n *\n * The regions arrive as the caller's own target arrays, which Stimulus has already\n * scoped to this instance: a nested controller registered under the same identifier\n * keeps its own regions. `host` narrows that set further, to the regions inside one\n * trigger or item, so a widget with several of them reflects each independently.\n *\n * **Two sides are a pair.** Where the state has a `whenFalse` side and only one half\n * sits inside `host`, the half that is there is left in view: hiding it would take\n * the only label with it, and the static check names the missing one instead. What\n * the author wrote on a lone half is theirs and stays — only a half this instance\n * took out of view is given back, which is what a pair losing one side at runtime\n * leaves behind.\n *\n * `hidden` moves only when it changes, so a consumer watching its own subtree for\n * attribute mutations sees one record per transition rather than one per reflection.\n *\n * @example\n * ```ts\n * readonly #labels = new StateRegions({\n * whenTrue: () => this.expandedLabelTargets,\n * whenFalse: () => this.collapsedLabelTargets,\n * });\n *\n * #reflect(): void {\n * this.#labels.reflect(this.triggerTarget, this.#expanded);\n * }\n * ```\n */\nexport class StateRegions {\n readonly #whenTrue: () => readonly HTMLElement[];\n readonly #whenFalse: (() => readonly HTMLElement[]) | null;\n readonly #taken = new WeakSet<HTMLElement>();\n\n constructor(options: StateRegionsOptions) {\n this.#whenTrue = options.whenTrue;\n this.#whenFalse = options.whenFalse ?? null;\n }\n\n /** Shows the regions inside `host` that belong to `isTrue` and hides the others. */\n reflect(host: Element, isTrue: boolean): void {\n const shown = this.#inside(host, this.#whenTrue());\n if (!this.#whenFalse) {\n for (const region of shown) this.#write(region, !isTrue);\n return;\n }\n const hiddenSide = this.#inside(host, this.#whenFalse());\n if (shown.length === 0 || hiddenSide.length === 0) {\n for (const region of shown) this.#give(region);\n for (const region of hiddenSide) this.#give(region);\n return;\n }\n for (const region of shown) this.#write(region, !isTrue);\n for (const region of hiddenSide) this.#write(region, isTrue);\n }\n\n /** Writes `hidden` where it moves, noting which regions it takes out of view. */\n #write(region: HTMLElement, hidden: boolean): void {\n if (hidden) this.#taken.add(region);\n else this.#taken.delete(region);\n if (region.hidden !== hidden) region.hidden = hidden;\n }\n\n /** Returns a region this instance hid; one it never hid keeps what it carries. */\n #give(region: HTMLElement): void {\n if (this.#taken.delete(region)) region.hidden = false;\n }\n\n /** The declared regions that sit within `host`, which may be the host itself. */\n #inside(host: Element, regions: readonly HTMLElement[]): HTMLElement[] {\n return regions.filter((region) => host.contains(region));\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { isReservedArrowChord, logicalArrowStep } from \"../utils/arrow_step\";\nimport { AttributeLease } from \"../utils/attribute_lease\";\nimport { BeforeCacheReset } from \"../utils/before_cache_reset\";\nimport { DetachGate } from \"../utils/detach_gate\";\nimport { ownerIndex } from \"../utils/event_owner\";\nimport { ListenerSet } from \"../utils/listener_set\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { prefersReducedMotion } from \"../utils/reduced_motion\";\nimport { RovingTabindex, rovingMove } from \"../utils/roving_tabindex\";\nimport { SafeInterval } from \"../utils/safe_timeout\";\nimport { StateRegions } from \"../utils/state_regions\";\n\n/** Advance delay used when `interval` is not a finite positive number. */\nconst DEFAULT_INTERVAL = 5000;\n\n/**\n * State attributes whose in-place rewrite changes what the carousel shows without\n * any target connecting or disconnecting — the shape a Turbo morph takes when it\n * keeps the elements and swaps only their attributes.\n */\nconst OBSERVED_ATTRIBUTES = [\"aria-selected\", \"data-state\", \"hidden\"];\n\n/**\n * Headless, accessible **Carousel** (slideshow) behavior.\n *\n * Markup contract (identifier: `stimeo--carousel`):\n * <section data-controller=\"stimeo--carousel\" aria-roledescription=\"carousel\"\n * aria-label=\"Featured\"\n * data-stimeo--carousel-autoplay-value=\"false\"\n * data-stimeo--carousel-interval-value=\"5000\"\n * data-stimeo--carousel-loop-value=\"true\">\n * <button aria-label=\"Slide autoplay\" data-stimeo--carousel-target=\"playToggle\">\n * <span aria-hidden=\"true\" data-stimeo--carousel-target=\"onLabel\" hidden>Pause</span>\n * <span aria-hidden=\"true\" data-stimeo--carousel-target=\"offLabel\">Play</span>\n * </button>\n * <div data-stimeo--carousel-target=\"viewport\">\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\">…</div>\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\" hidden inert>…</div>\n * </div>\n * <button data-stimeo--carousel-target=\"prev\">‹</button>\n * <button data-stimeo--carousel-target=\"next\">›</button>\n * <div role=\"tablist\">\n * <button role=\"tab\" data-stimeo--carousel-target=\"picker\"></button>\n * </div>\n * </section>\n *\n * Implements the WAI-ARIA APG **Carousel** pattern. With pickers it is the tabbed\n * variant: each picker is a `tab` carrying `aria-selected` and the single roving\n * `tabindex`, and each slide is its `tabpanel`. Without pickers the slides are\n * `group`s and `prev`/`next` drive them. The current slide is exposed through\n * `data-state` (`active`/`inactive`); the rest carry `hidden` **and** `inert`, so\n * they stay out of the focus order and the accessibility tree even when consumer\n * CSS overrides `display` to lay the slides out as a track.\n *\n * @remarks\n * Behavior only — transitions, layout, and visuals are the consumer's CSS.\n *\n * **The controller owns its own wiring.** Clicks, picker keys, hover, and focus\n * are delegated from the controller element, so no `data-action` is required and\n * a target added at runtime works the moment it appears. Explicit `data-action`\n * bindings to the declared actions still work and coexist with the delegated\n * path: the binding runs first and marks the event, and the delegated listener\n * stands down, so one interaction is never handled twice.\n *\n * **`autoplay` is the single source of truth for the rotation intent.** The\n * toggle writes back to it, so the state survives a Turbo Drive cache restore\n * without a second, competing signal; `aria-pressed` is a pure output the\n * controller owns, as is the `onLabel`/`offLabel` pair a toggle may carry: each\n * toggle shows the half its rotation state belongs to, and a half with no partner\n * inside the same toggle keeps the visibility the consumer authored. The toggle's\n * name comes from `aria-label` and holds in both states, so the pair is a visual\n * affordance the accessibility tree does not read. Rotation is suspended — not\n * cancelled — while the pointer rests on the carousel, while focus is inside it,\n * and while the tab is hidden; each suspension lifts on its own (WCAG 2.2.2 is met\n * by the toggle, which is the one control that stops rotation for good). A carousel\n * with nothing left to advance to (one slide, or the last slide of a non-looping\n * set) shows the intent as off and marks the toggle `aria-disabled`, without\n * rewriting `autoplay`: once a slide lies ahead again, the intent takes effect\n * again. `prefers-reduced-motion` holds back the intent `autoplay` declares at\n * connect the same way, until the user presses the toggle or the page changes\n * `autoplay`.\n *\n * The rotation ends when the controller really leaves — a Turbo navigation, a\n * removed element, `data-controller` dropping it — and a carousel still in the\n * document hears that end as `pause`. An in-page move reconnects the same\n * instance and keeps the run: no edge, no restarted interval. The leased ARIA\n * is returned before Turbo caches the page. Picker arrow keys, `Home`,\n * and `End` move focus only (manual activation); slide changes never steal focus\n * from the control the user operated. A slide change the user drove — including an\n * autoplay tick they started — is reported as `stimeo--carousel:change` with\n * `{ index, total }`; the same detail arrives as `stimeo--carousel:reconcile` when\n * the controller re-derives the position itself, whether a target came or went or\n * a retained element's state attributes were rewritten in place.\n */\nexport class CarouselController extends Controller<HTMLElement> {\n static override targets = [\n \"slide\",\n \"viewport\",\n \"prev\",\n \"next\",\n \"picker\",\n \"playToggle\",\n \"onLabel\",\n \"offLabel\",\n ];\n static override values = {\n autoplay: { type: Boolean, default: false },\n interval: { type: Number, default: DEFAULT_INTERVAL },\n loop: { type: Boolean, default: true },\n };\n static actions = [\n \"goto\",\n \"next\",\n \"onPickerKeydown\",\n \"pause\",\n \"prev\",\n \"resume\",\n \"togglePlay\",\n ] as const;\n static events = [\"change\", \"pause\", \"play\", \"reconcile\"] as const;\n\n declare readonly slideTargets: HTMLElement[];\n declare readonly pickerTargets: HTMLElement[];\n declare readonly viewportTarget: HTMLElement;\n declare readonly hasViewportTarget: boolean;\n declare readonly prevTargets: HTMLElement[];\n declare readonly nextTargets: HTMLElement[];\n declare readonly playToggleTargets: HTMLElement[];\n declare readonly onLabelTargets: HTMLElement[];\n declare readonly offLabelTargets: HTMLElement[];\n declare autoplayValue: boolean;\n declare intervalValue: number;\n declare loopValue: boolean;\n\n readonly #roving = new RovingTabindex(() => this.pickerTargets);\n readonly #reconcileTargets = new MicrotaskCoalescer(() => this.#reconcileTargetSet());\n readonly #intervals = new SafeInterval();\n /** Unreachable step controls and the toggle of a carousel that cannot rotate. */\n readonly #ariaDisabled = new AttributeLease<HTMLElement>(\"aria-disabled\");\n /** The slide container's live-region politeness, which tracks the rotation. */\n readonly #ariaLive = new AttributeLease<HTMLElement>(\"aria-live\");\n /** Pairs with {@link CarouselController.#ariaLive}: only the changed slide is read. */\n readonly #ariaAtomic = new AttributeLease<HTMLElement>(\"aria-atomic\");\n /** The label pair a play toggle may carry, one half per rotation state. */\n readonly #labels = new StateRegions({\n whenTrue: () => this.onLabelTargets,\n whenFalse: () => this.offLabelTargets,\n });\n readonly #beforeCache = new BeforeCacheReset(() => this.#returnLeases());\n /** Tells an in-page move, which keeps the rotation, from a real detach. */\n readonly #gate = new DetachGate();\n /** The next pointer movement, listened for while a pointer suspension waits on it. */\n readonly #pointer = new ListenerSet();\n /**\n * Events an authored action binding already took. The delegated listener runs\n * later — it sits on the controller element, above every control — so it can\n * consume the mark and stand down, letting the two wirings coexist without\n * handling one interaction twice.\n */\n readonly #handledEvents = new WeakSet<Event>();\n\n /**\n * Whether `connect()` has run. Scheduling is already inert outside that window\n * (`MicrotaskCoalescer`), so this gates the Value callbacks Stimulus\n * delivers ahead of `connect()`.\n */\n #connected = false;\n /** Index of the visible slide. */\n #index = 0;\n /** The visible slide element, which identifies it across a changing target set. */\n #activeSlide: HTMLElement | null = null;\n /** Slide count at the last resolved state, so a changed total is reportable. */\n #total = 0;\n /**\n * Pointer rests on the carousel: a suspension that lifts on `mouseleave`, or on the\n * pointer movement that confirms a suspension a move or a connect left unconfirmed.\n */\n #pointerPaused = false;\n /** Focus is inside the carousel: a suspension that lifts when it leaves. */\n #focusPaused = false;\n /** The tab is in the background: a suspension that lifts when it returns. */\n #hiddenPaused = false;\n /** Reduced motion holds back the intent declared at connect, until a press or a new one. */\n #motionHold = false;\n /** Id of the live autoplay interval, or null when stopped. */\n #timerId: number | null = null;\n /** Delay the live interval was armed with, so an `interval` change re-arms it. */\n #timerInterval = 0;\n /** Follows state-attribute rewrites on retained slides and pickers. */\n #observer: MutationObserver | null = null;\n\n /** Keeps a hidden tab from advancing behind the user's back. */\n readonly #onVisibilityChange = (): void => {\n this.#hiddenPaused = document.visibilityState === \"hidden\";\n this.#syncTimer();\n };\n\n /**\n * Renders the initial slide, wires the delegated listeners, and starts autoplay\n * when requested.\n *\n * Focus, the tab's visibility and the reduced-motion hold are read afresh. The\n * pointer is not something the document can answer yet: no `mouseleave` reaches a\n * node that moved, and `:hover` can answer from before the move until the pointer\n * moves again. So an in-page move — which Stimulus delivers to the *same* controller\n * instance as `disconnect()` then `connect()` — keeps the pointer suspension it had,\n * `:hover` reading true adds one, and either waits for the next pointer movement to\n * be confirmed or lifted. A rotation the move carried is still running, so the edges\n * are judged against it. The attribute observer starts after the first render so the\n * controller's own opening writes are not fed back to it.\n */\n override connect(): void {\n const moved = this.#gate.pending;\n this.#gate.cancel();\n this.#pointerPaused = (moved && this.#pointerPaused) || this.element.matches(\":hover\");\n if (this.#pointerPaused) this.#awaitPointer();\n this.#focusPaused = this.element.contains(document.activeElement);\n this.#hiddenPaused = document.visibilityState === \"hidden\";\n this.#motionHold = prefersReducedMotion();\n this.#index = this.#resolveIndex();\n this.#render({ focus: false });\n this.#total = this.slideTargets.length;\n this.#syncTimer();\n this.#connected = true;\n this.#reconcileTargets.activate();\n this.#beforeCache.activate();\n\n this.element.addEventListener(\"click\", this.#onClick);\n this.element.addEventListener(\"keydown\", this.#onKeydown);\n this.element.addEventListener(\"focusin\", this.#onFocusin);\n this.element.addEventListener(\"focusout\", this.#onFocusout);\n this.element.addEventListener(\"mouseenter\", this.#onMouseenter);\n this.element.addEventListener(\"mouseleave\", this.#onMouseleave);\n document.addEventListener(\"visibilitychange\", this.#onVisibilityChange);\n this.#observer = new MutationObserver(this.#onAttributeMutations);\n this.#observer.observe(this.element, {\n subtree: true,\n attributes: true,\n attributeFilter: OBSERVED_ATTRIBUTES,\n });\n }\n\n /**\n * Releases every listener and observer, returns the leased ARIA, drops the focus\n * and tab suspensions. The rotation goes through the detach gate: a reconnect in\n * the same batch — an in-page move — keeps it, and the pointer suspension with it;\n * anything else ends it.\n */\n override disconnect(): void {\n this.#connected = false;\n this.#pointer.dispose();\n this.element.removeEventListener(\"click\", this.#onClick);\n this.element.removeEventListener(\"keydown\", this.#onKeydown);\n this.element.removeEventListener(\"focusin\", this.#onFocusin);\n this.element.removeEventListener(\"focusout\", this.#onFocusout);\n this.element.removeEventListener(\"mouseenter\", this.#onMouseenter);\n this.element.removeEventListener(\"mouseleave\", this.#onMouseleave);\n document.removeEventListener(\"visibilitychange\", this.#onVisibilityChange);\n this.#observer?.disconnect();\n this.#observer = null;\n this.#reconcileTargets.cancel();\n this.#focusPaused = false;\n this.#hiddenPaused = false;\n this.#activeSlide = null;\n this.#returnLeases();\n this.#beforeCache.deactivate();\n this.#gate.disconnected(this, () => this.#endRun());\n }\n\n /**\n * Re-establishes the single selected picker when one is added after connect.\n *\n * Without this an appended picker that arrives `aria-selected=\"true\"` leaves two\n * marked at once — the authored pre-selection is only read on connect, so\n * nothing else ever resolves the conflict. The current slide is kept: the\n * repaint re-derives every picker from `#index`, so a late arrival never steals\n * the selection.\n */\n pickerTargetConnected(picker: HTMLElement): void {\n picker.tabIndex = -1;\n this.#reconcileTargets.schedule();\n }\n\n /** Repairs selection and roving after a picker leaves a retained carousel. */\n pickerTargetDisconnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Reconciles a slide added in the same DOM batch as its picker. */\n slideTargetConnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Re-clamps the active index after a slide is removed. */\n slideTargetDisconnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /**\n * Publishes the rotation state on a toggle that joins a connected carousel.\n *\n * A toggle the markup already carries connects ahead of `connect()`, where the\n * suspensions and the reduced-motion hold are not settled yet; the opening pass\n * covers it.\n */\n playToggleTargetConnected(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /**\n * Publishes the rotation state on a label half that joins a connected toggle.\n *\n * A half arriving changes the toggle's subtree, not its attributes, so the\n * attribute observer never sees it; where the arrival completes a pair that was\n * standing alone, this is what makes that pair whole and reflectable.\n */\n onLabelTargetConnected(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /** Publishes the rotation state on a label half that joins a connected toggle. */\n offLabelTargetConnected(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /** Follows a rotation intent the page changed at runtime, lifting the reduced-motion hold. */\n autoplayValueChanged(): void {\n if (!this.#connected) return;\n this.#motionHold = false;\n this.#syncTimer();\n }\n\n /** Re-arms the live interval at the new delay without reporting a state change. */\n intervalValueChanged(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /**\n * Re-publishes the step controls and re-evaluates the non-looping end through the\n * reconcile pass, which reports a move only when the position changed.\n */\n loopValueChanged(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Advances to the next slide. Delegated; `data-action` wiring is optional. */\n next(event?: Event): void {\n if (event?.defaultPrevented) return;\n this.#markHandled(event);\n this.#select(this.#step(1), { focus: false });\n }\n\n /** Returns to the previous slide. Delegated; `data-action` wiring is optional. */\n prev(event?: Event): void {\n if (event?.defaultPrevented) return;\n this.#markHandled(event);\n this.#select(this.#step(-1), { focus: false });\n }\n\n /** Jumps to the slide whose picker was activated (click / Enter / Space). */\n goto(event: Event): void {\n if (event.defaultPrevented) return;\n this.#markHandled(event);\n const index = this.#pickerIndexFor(event.currentTarget);\n if (index !== -1) this.#select(index, { focus: false });\n }\n\n /**\n * Flips the rotation intent the toggle shows, on the user's explicit request.\n *\n * The result is written to the `autoplay` Value, which is where every other path\n * reads it from. A carousel with nothing to advance to has no intent to flip: the\n * toggle is marked `aria-disabled` and does nothing.\n */\n togglePlay(event?: Event): void {\n if (event?.defaultPrevented) return;\n this.#markHandled(event);\n this.#togglePlay();\n }\n\n /**\n * Suspends rotation. A `focus`-family event records that focus is inside the\n * carousel; anything else — hover, or a bare programmatic call — records the\n * pointer suspension. Both lift through the matching {@link resume}, and\n * neither touches the rotation intent.\n */\n pause(event?: Event): void {\n this.#markHandled(event);\n if (isFocusEvent(event)) this.#focusPaused = true;\n else this.#setPointerPaused(true);\n this.#syncTimer();\n }\n\n /**\n * Lifts the matching suspension. A `focusout` whose `relatedTarget` is still\n * inside the carousel is focus moving between its own controls, which leaves the\n * focus suspension in place — releasing it there would stop and restart the\n * interval on every Tab press.\n */\n resume(event?: Event): void {\n this.#markHandled(event);\n if (isFocusEvent(event)) {\n if (this.#focusStaysInside(event)) return;\n this.#focusPaused = false;\n } else {\n this.#setPointerPaused(false);\n }\n this.#syncTimer();\n }\n\n /** Picker roving for authored bindings; the delegated path is `#onKeydown`. */\n onPickerKeydown(event: KeyboardEvent): void {\n const index = this.#pickerIndexFor(event.currentTarget);\n if (index === -1) return;\n this.#markHandled(event);\n this.#handlePickerKeydown(event, index);\n }\n\n /** Delegated activation for pickers and step controls without authored actions. */\n readonly #onClick = (event: MouseEvent): void =>\n this.#delegate(event, () => {\n const index = this.#pickerIndexFor(event.target);\n if (index !== -1) {\n this.#select(index, { focus: false });\n } else if (hits(this.nextTargets, event.target)) {\n this.#select(this.#step(1), { focus: false });\n } else if (hits(this.prevTargets, event.target)) {\n this.#select(this.#step(-1), { focus: false });\n } else if (hits(this.playToggleTargets, event.target)) {\n this.#togglePlay();\n }\n });\n\n /** Delegated picker roving for pickers without authored actions. */\n readonly #onKeydown = (event: KeyboardEvent): void =>\n this.#delegate(event, () => {\n const index = this.#pickerIndexFor(event.target);\n if (index !== -1) this.#handlePickerKeydown(event, index);\n });\n\n /** Focus arriving anywhere inside suspends the rotation. */\n readonly #onFocusin = (event: FocusEvent): void =>\n this.#delegate(event, () => {\n this.#focusPaused = true;\n this.#syncTimer();\n });\n\n /** Focus genuinely leaving lifts the suspension; moves between own controls do not. */\n readonly #onFocusout = (event: FocusEvent): void =>\n this.#delegate(event, () => {\n if (this.#focusStaysInside(event)) return;\n this.#focusPaused = false;\n this.#syncTimer();\n });\n\n /** Pointer entry suspends the rotation. */\n readonly #onMouseenter = (event: MouseEvent): void =>\n this.#delegate(event, () => {\n this.#setPointerPaused(true);\n this.#syncTimer();\n });\n\n /** Pointer exit lifts the suspension. */\n readonly #onMouseleave = (event: MouseEvent): void =>\n this.#delegate(event, () => {\n this.#setPointerPaused(false);\n this.#syncTimer();\n });\n\n /**\n * Reads `:hover` once the pointer has moved, when the answer is current, and lifts\n * the pointer suspension if the pointer is not over the carousel. Listens once.\n */\n readonly #onPointerMove = (): void => {\n this.#pointer.dispose();\n if (this.element.matches(\":hover\")) return;\n this.#pointerPaused = false;\n this.#syncTimer();\n };\n\n /** Leaves the pointer suspension to be confirmed or lifted on the next pointer movement. */\n #awaitPointer(): void {\n this.#pointer.add(document, \"pointermove\", this.#onPointerMove, {\n capture: true,\n passive: true,\n });\n }\n\n /** Records the pointer suspension; a newer answer ends any wait on the next movement. */\n #setPointerPaused(paused: boolean): void {\n this.#pointer.dispose();\n this.#pointerPaused = paused;\n }\n\n /**\n * Schedules one reconciliation when a state attribute is rewritten in place —\n * the only shape of change no target callback reports.\n *\n * The filter is the `attributeFilter` alone: those three attributes belong to\n * the slides and pickers, and a coalesced pass over an unrelated one costs a\n * repaint that writes nothing. Narrowing further here would add a branch no\n * test could distinguish.\n */\n readonly #onAttributeMutations = (): void => {\n this.#reconcileTargets.schedule();\n };\n\n /**\n * Records that an action binding took this event.\n *\n * An authored binding sits on the control, so it runs while the event is still\n * below the controller element and always precedes the delegated listener.\n * Marking is the one signal that keeps the two wirings from both acting.\n */\n #markHandled(event?: Event): void {\n if (event) this.#handledEvents.add(event);\n }\n\n /** Runs a delegated handler unless an action binding, or a descendant, took the event. */\n #delegate(event: Event, run: () => void): void {\n if (this.#handledEvents.delete(event) || event.defaultPrevented) return;\n run();\n }\n\n /** Position of the picker that is or contains `node`, or `-1` when none does. */\n #pickerIndexFor(node: EventTarget | null): number {\n return ownerIndex(this.pickerTargets, node);\n }\n\n /** Whether a focus transition lands on another control of this same carousel. */\n #focusStaysInside(event: FocusEvent): boolean {\n const next = event.relatedTarget;\n return next instanceof Node && this.element.contains(next);\n }\n\n /** Flips the rotation intent unless there is nothing to rotate to; lifts the motion hold. */\n #togglePlay(): void {\n if (!this.#canAutoplay()) return;\n const next = !this.#intent;\n this.#motionHold = false;\n this.autoplayValue = next;\n this.#syncTimer();\n }\n\n /** Applies the APG picker key map: arrows, Home, and End all move focus only. */\n #handlePickerKeydown(event: KeyboardEvent, current: number): void {\n // A descendant widget that already claimed the key must not ALSO move the\n // picker focus — composition depends on this yield.\n if (event.defaultPrevented) return;\n if (isReservedArrowChord(event)) return;\n\n const length = this.pickerTargets.length;\n // Logical, not physical. The helper reverses only the horizontal\n // pair, so folding Down/Up into the same branch stays correct.\n switch (event.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n case \"ArrowLeft\":\n case \"ArrowUp\": {\n event.preventDefault();\n const step = logicalArrowStep(event.key, this.element);\n this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n return;\n }\n // A chorded Home/End is a document-level shortcut (`Control+Home` scrolls\n // the page) that belongs to the browser, exactly as a chorded arrow does.\n case \"Home\":\n if (hasModifier(event)) return;\n event.preventDefault();\n this.#roving.setActive(0, { focus: true });\n return;\n case \"End\":\n if (hasModifier(event)) return;\n event.preventDefault();\n this.#roving.setActive(length - 1, { focus: true });\n return;\n default:\n }\n }\n\n /**\n * Resolves the index one step away from the current one, honoring `loop`.\n *\n * Bounding is {@link CarouselController.#clampToSlides}'s job alone, so an\n * empty set is allowed to fall out of the arithmetic here rather than being\n * special-cased in two places that could disagree.\n */\n #step(delta: number): number {\n const total = this.slideTargets.length;\n const next = this.#index + delta;\n if (this.loopValue) return (next + total) % total;\n return Math.min(total - 1, Math.max(0, next));\n }\n\n /**\n * Confines an index to the slide range, so no index can hide every slide.\n *\n * The single place an index is bounded: an empty set collapses to the first\n * position, which is also where a non-numeric step from that empty set lands.\n */\n #clampToSlides(index: number): number {\n const last = this.slideTargets.length - 1;\n if (last < 0) return 0;\n return Math.min(last, Math.max(0, index));\n }\n\n /**\n * Changes the active slide, updates state hooks, and emits `change` — but only\n * when the index actually changes, so a `next`/`prev` clamped at the end (or an\n * autoplay tick at a non-looping boundary) re-renders without a spurious event.\n */\n #select(index: number, { focus }: { focus: boolean }): void {\n const target = this.#clampToSlides(index);\n const changed = target !== this.#index;\n this.#index = target;\n this.#render({ focus });\n // Re-evaluate autoplay after every move so reaching the non-looping end stops\n // the timer (see `#syncTimer`); idempotent for moves that don't cross a boundary.\n this.#syncTimer();\n if (changed) {\n this.dispatch(\"change\", { detail: { index: target, total: this.slideTargets.length } });\n }\n }\n\n /**\n * Reflects `this.#index` onto the slides, the pickers, and the step controls.\n *\n * Every observed attribute is written only when its value actually changes: the\n * same writes are watched by {@link CarouselController.#onAttributeMutations},\n * and an unconditional rewrite would feed the controller its own output.\n *\n * @stimeoRenderRoot\n */\n #render({ focus }: { focus: boolean }): void {\n this.#activeSlide = this.slideTargets[this.#index] ?? null;\n this.slideTargets.forEach((slide, i) => {\n const active = i === this.#index;\n setAttributeIfChanged(slide, \"data-state\", active ? \"active\" : \"inactive\");\n if (slide.hidden !== !active) slide.hidden = !active;\n // `hidden` alone is a style a slide track's own CSS overrides; `inert` is not.\n slide.toggleAttribute(\"inert\", !active);\n });\n // The picker set can be shorter than the slide set (a picker removed on its\n // own, or a carousel that only pickers part of its slides). Resolving the\n // selection inside the picker range keeps exactly one selected tab and one Tab\n // stop; an out-of-range index would leave every picker at `tabindex=\"-1\"` and\n // strand the tablist outside the Tab sequence.\n const pickerIndex = Math.min(this.#index, this.pickerTargets.length - 1);\n this.pickerTargets.forEach((picker, i) => {\n setAttributeIfChanged(picker, \"aria-selected\", i === pickerIndex ? \"true\" : \"false\");\n });\n this.#roving.setActive(pickerIndex, { focus });\n this.#syncStepControls();\n }\n\n /** Marks the step control a non-looping carousel has no slide left to reach. */\n #syncStepControls(): void {\n const last = this.slideTargets.length - 1;\n const atStart = !this.loopValue && this.#index <= 0;\n const atEnd = !this.loopValue && this.#index >= last;\n for (const button of this.prevTargets) {\n this.#ariaDisabled.write(button, atStart ? \"true\" : null);\n }\n for (const button of this.nextTargets) {\n this.#ariaDisabled.write(button, atEnd ? \"true\" : null);\n }\n }\n\n /**\n * Resolves which slide is current from the strongest evidence available.\n *\n * A single `data-state=\"active\"` is unambiguous and wins, which is what restores\n * the visible slide after a Turbo cache restore even with no pickers present.\n * Competing claims — a slide inserted already marked active — are settled by the\n * element the last render actually showed, so a newcomer never displaces what the\n * reader is looking at. With no claim at all the authored picker selection\n * decides, first in DOM order; failing that the previous position is kept.\n */\n #resolveIndex(): number {\n const slides = this.slideTargets;\n const claims: number[] = [];\n slides.forEach((slide, index) => {\n if (slide.getAttribute(\"data-state\") === \"active\") claims.push(index);\n });\n if (claims.length > 1 && this.#activeSlide !== null) {\n const live = slides.indexOf(this.#activeSlide);\n if (claims.includes(live)) return live;\n }\n const claimed = claims[0];\n if (claimed !== undefined) return claimed;\n\n const selected = this.pickerTargets.findIndex(\n (picker) => picker.getAttribute(\"aria-selected\") === \"true\",\n );\n return this.#clampToSlides(selected === -1 ? this.#index : selected);\n }\n\n /** Re-resolves the active slide after the target set changed and reports the move. */\n #reconcileTargetSet(): void {\n const previousIndex = this.#index;\n const previousTotal = this.#total;\n this.#index = this.#resolveIndex();\n this.#render({ focus: false });\n this.#total = this.slideTargets.length;\n this.#syncTimer();\n // `change` stays reserved for user navigation; re-resolving onto a surviving\n // slide, or reporting a set that grew or shrank, is this controller's decision.\n if (this.#index !== previousIndex || this.#total !== previousTotal) {\n this.dispatch(\"reconcile\", { detail: { index: this.#index, total: this.#total } });\n }\n }\n\n /** The rotation intent in effect: `autoplay`, unless reduced motion holds it back. */\n get #intent(): boolean {\n return this.autoplayValue && !this.#motionHold;\n }\n\n /** Whether autoplay has anywhere left to advance to. */\n #canAutoplay(): boolean {\n const total = this.slideTargets.length;\n if (total <= 1) return false;\n return this.loopValue || this.#index < total - 1;\n }\n\n /** The advance delay; a non-finite or non-positive declaration falls back. */\n get #interval(): number {\n const declared = this.intervalValue;\n return Number.isFinite(declared) && declared > 0 ? declared : DEFAULT_INTERVAL;\n }\n\n /**\n * Drives the autoplay interval toward the desired state and publishes it.\n *\n * Rotation runs when the intent is on, nothing suspends it, and a slide is left\n * to advance to. The toggle shows the intent only while a slide is left, so\n * `aria-pressed` never claims a rotation that cannot happen. This body reads\n * `autoplay` and never writes it, so the declared intent returns once a slide\n * lies ahead again. Crossing the run/stop boundary emits `play`/`pause`;\n * re-arming at a new `interval` is the same state and stays silent.\n *\n * @stimeoRenderRoot\n */\n #syncTimer(): void {\n const canAutoplay = this.#canAutoplay();\n const pressed = this.#intent && canAutoplay;\n const shouldRun = pressed && !this.#pointerPaused && !this.#focusPaused && !this.#hiddenPaused;\n const wasRunning = this.#timerId !== null;\n const interval = this.#interval;\n\n if (this.#timerId !== null && (!shouldRun || interval !== this.#timerInterval)) {\n this.#intervals.clear(this.#timerId);\n this.#timerId = null;\n }\n if (shouldRun && this.#timerId === null) {\n this.#timerInterval = interval;\n this.#timerId = this.#intervals.set(() => this.next(), interval);\n }\n // The events are edges. A consumer that subscribes after `connect()` — which\n // is every consumer on a Turbo restore, where the controller reconnects before\n // the page's own scripts run again — would miss the transition it arrived in\n // the middle of, so the same state is published as a hook it can read.\n setAttributeIfChanged(this.element, \"data-state\", shouldRun ? \"playing\" : \"paused\");\n if (shouldRun !== wasRunning) {\n if (shouldRun) this.dispatch(\"play\");\n else this.dispatch(\"pause\");\n }\n\n for (const toggle of this.playToggleTargets) {\n toggle.setAttribute(\"aria-pressed\", pressed ? \"true\" : \"false\");\n this.#ariaDisabled.write(toggle, canAutoplay ? null : \"true\");\n this.#labels.reflect(toggle, pressed);\n }\n if (this.hasViewportTarget) {\n this.#ariaLive.write(this.viewportTarget, shouldRun ? \"off\" : \"polite\");\n this.#ariaAtomic.write(this.viewportTarget, \"false\");\n }\n }\n\n /**\n * Ends the rotation once the controller has really left. A carousel still in\n * the document hears the end — `pause`, and `data-state=\"paused\"` — so no `play`\n * it reported is left without one; a detached tree keeps the markup it had.\n */\n #endRun(): void {\n const wasRunning = this.#timerId !== null;\n this.#intervals.clearAll();\n this.#timerId = null;\n if (!wasRunning || !this.element.isConnected) return;\n setAttributeIfChanged(this.element, \"data-state\", \"paused\");\n this.dispatch(\"pause\");\n }\n\n /** Hands every leased attribute back to the value the consumer authored. */\n #returnLeases(): void {\n this.#ariaDisabled.returnAll();\n this.#ariaLive.returnAll();\n this.#ariaAtomic.returnAll();\n }\n}\n\n/** Whether an event names a focus transition rather than a pointer one. */\nfunction isFocusEvent(event?: Event): event is FocusEvent {\n return event?.type.startsWith(\"focus\") === true;\n}\n\n/** Whether a key arrived with a modifier that makes it the browser's shortcut. */\nfunction hasModifier(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n\n/** Whether `node` is one of `elements` or sits inside one. */\nfunction hits(elements: readonly HTMLElement[], node: EventTarget | null): boolean {\n return ownerIndex(elements, node) !== -1;\n}\n\n/** Writes an attribute only on a real transition, so an observer sees no self-echo. */\nfunction setAttributeIfChanged(element: Element, name: string, value: string): void {\n if (element.getAttribute(name) !== value) element.setAttribute(name, value);\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils/state_reason.ts","../../src/utils/action_source.ts","../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/shared_registry.ts","../../src/utils/attribute_lease.ts","../../src/utils/detach_gate.ts","../../src/utils/event_owner.ts","../../src/utils/listener_set.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/morph_render_watcher.ts","../../src/utils/move_counter.ts","../../src/utils/timer_bounds.ts","../../src/utils/number_bounds.ts","../../src/utils/coerce.ts","../../src/utils/number_value.ts","../../src/utils/reduced_motion.ts","../../src/utils/roving_tabindex.ts","../../src/utils/safe_timeout.ts","../../src/utils/state_regions.ts","../../src/utils/target_selector.ts","../../src/controllers/carousel_controller.ts"],"names":[],"mappings":";;AA0CA,IAAM,YAAA,uBAAmB,GAAA,CAAI,CAAC,QAAQ,OAAA,EAAS,SAAA,EAAW,UAAU,CAAC,CAAA;AAGrE,IAAM,cAAA,uBAAqB,GAAA,CAAI,CAAC,cAAc,YAAA,EAAc,cAAA,EAAgB,cAAc,CAAC,CAAA;AA0BpF,SAAS,eAAe,KAAA,EAA4D;AACzF,EAAA,IAAI,CAAC,OAAO,OAAO,KAAA;AACnB,EAAA,IAAI,YAAA,CAAa,GAAA,CAAI,KAAA,CAAM,IAAI,GAAG,OAAO,OAAA;AACzC,EAAA,IAAI,cAAA,CAAe,GAAA,CAAI,KAAA,CAAM,IAAI,GAAG,OAAO,SAAA;AAC3C,EAAA,OAAO,MAAA;AACT;;ACxDO,SAAS,aAAa,MAAA,EAA4C;AACvE,EAAA,IAAI,kBAAkB,WAAA,EAAa;AACjC,IAAA,OAAO,EAAE,OAAO,IAAA,EAAM,IAAA,EAAM,QAAQ,MAAA,EAAQ,MAAA,EAAQ,QAAQ,KAAA,EAAM;AAAA,EACpE;AACA,EAAA,MAAM,QAAQ,MAAA,IAAU,IAAA;AACxB,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,IAAA,EAAM,KAAA,EAAO,aAAA,YAAyB,OAAA,GAAU,MAAM,aAAA,GAAgB,IAAA;AAAA,IACtE,MAAA,EAAQ,KAAA,EAAO,MAAA,YAAkB,OA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OAAO,KAAA,EAAO,IAAA,CAAK,UAAA,CAAW,OAAO,CAAA,KAAM,IAAA;AAC7C;AAGA,SAAS,YAAY,KAAA,EAA+B;AAClD,EAAA,OAAO,MAAM,MAAA,IAAU,KAAA,CAAM,OAAA,IAAW,KAAA,CAAM,WAAW,KAAA,CAAM,QAAA;AACjE;AAGA,SAAS,IAAA,CAAK,UAAkC,IAAA,EAAmC;AACjF,EAAA,OAAO,UAAA,CAAW,QAAA,EAAU,IAAI,CAAA,KAAM,EAAA;AACxC;AAGA,SAAS,qBAAA,CAAsB,OAAA,EAAkB,IAAA,EAAc,KAAA,EAAqB;AAClF,EAAA,IAAI,OAAA,CAAQ,aAAa,IAAI,CAAA,KAAM,OAAO,OAAA,CAAQ,YAAA,CAAa,MAAM,KAAK,CAAA;AAC5E","file":"carousel_controller.js","sourcesContent":["/**\n * Why a component's public state moved, carried as `detail.reason`\n * on the state event that reports the move.\n *\n * The attribute a component publishes (`aria-expanded`, `hidden`, `data-state`)\n * only says *what* the state is now. A subscriber that mirrors the state\n * elsewhere, or reports it, needs *why*: closing on `Escape` and closing because\n * the consumer called the action are the same attribute write and different\n * events to the page around it.\n *\n * `\"api\"` is the one every subscriber has to look at. A close the consumer asked\n * for arrives back at their own listener, so a listener that closes something\n * else on `close` loops unless it ignores its own calls.\n *\n * | Reason | The state moved because |\n * | --- | --- |\n * | `\"user\"` | a control of this component was operated |\n * | `\"select\"` | an item inside it was activated |\n * | `\"escape\"` | `Escape` was pressed and this layer owned it |\n * | `\"outside\"` | a pointer landed outside it, or on its backdrop |\n * | `\"focus\"` | focus entered or left it |\n * | `\"pointer\"` | the pointer entered or left it |\n * | `\"scroll\"` | a tracked scroll container scrolled |\n * | `\"api\"` | a public action was called with no DOM event |\n * | `\"timeout\"` | an automatic timer advanced or dismissed the state |\n * | `\"limit\"` | a capacity limit dismissed an item |\n * | `\"media\"` | an operating-system media preference changed |\n */\nexport type StateReason =\n | \"user\"\n | \"select\"\n | \"escape\"\n | \"outside\"\n | \"focus\"\n | \"pointer\"\n | \"scroll\"\n | \"api\"\n | \"timeout\"\n | \"limit\"\n | \"media\";\n\n/** Focus modality: the events a focus move delivers to an action. */\nconst FOCUS_EVENTS = new Set([\"blur\", \"focus\", \"focusin\", \"focusout\"]);\n\n/** Pointer modality: the crossing events an action is bound to for hover. */\nconst POINTER_EVENTS = new Set([\"mouseenter\", \"mouseleave\", \"pointerenter\", \"pointerleave\"]);\n\n/**\n * Reads the interaction behind a **public action** from the DOM event it was\n * handed.\n *\n * Stimulus always passes the event to an action it invoked from `data-action`,\n * and a consumer calling the method themselves passes nothing — which is what\n * separates `\"api\"` from the rest.\n *\n * Only an action entry may resolve a reason this way. Inside the component the\n * event type no longer identifies the interaction: one `click` is the trigger\n * being pressed, the page outside being pressed, and an item being activated,\n * and those paths pass their own reason instead.\n *\n * @param event - The event the action received, if any.\n * @returns `\"api\"` with no event, else the modality the event type names, else\n * `\"user\"`.\n *\n * @example\n * ```ts\n * toggle(event?: Event): void {\n * this.#apply(!this.#isOpen, stateReasonFor(event));\n * }\n * ```\n */\nexport function stateReasonFor(event?: Event | null): \"user\" | \"focus\" | \"pointer\" | \"api\" {\n if (!event) return \"api\";\n if (FOCUS_EVENTS.has(event.type)) return \"focus\";\n if (POINTER_EVENTS.has(event.type)) return \"pointer\";\n return \"user\";\n}\n","import { stateReasonFor } from \"./state_reason\";\n\n/** The DOM binding and origin of a public action, or its explicit API element. */\nexport interface ActionSource {\n readonly event: Event | null;\n readonly host: Element | null;\n readonly origin: Element | null;\n readonly reason: ReturnType<typeof stateReasonFor>;\n}\n\n/**\n * Normalizes an action's DOM event or explicit element without choosing an owned target.\n *\n * Event hosts and origins stay separate so consumers can yield to nested controls.\n * An explicit element supplies both, with no DOM event and an `\"api\"` reason.\n * Consumers resolve current targets and enforce their own scope and interaction rules.\n *\n * @param source - The DOM event, explicit element, or absent optional argument.\n * @returns The source elements, original event and public interaction reason.\n */\nexport function actionSource(source?: Event | HTMLElement): ActionSource {\n if (source instanceof HTMLElement) {\n return { event: null, host: source, origin: source, reason: \"api\" };\n }\n const event = source ?? null;\n return {\n event,\n host: event?.currentTarget instanceof Element ? event.currentTarget : null,\n origin: event?.target instanceof Element ? event.target : null,\n reason: stateReasonFor(event),\n };\n}\n","/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","import { isRtl } from \"./logical_scroll\";\n\n/**\n * Turns an arrow key into a **logical** step: `+1` for \"next\", `-1` for\n * \"previous\", `0` when the key names neither.\n *\n * APG defines the horizontal pair as *next / previous* and says a vertical\n * arrangement swaps in Down/Up for the same meaning — so the pair is one axis's\n * spelling of an order, and the order reverses with the writing direction. Only\n * the horizontal pair reverses. Down/Up name an axis the writing direction does\n * not mirror, and returning them unchanged is the point: many controllers fold\n * both pairs into one branch, where swapping the branches under RTL would flip\n * the vertical axis too — a bug that reads as \"the arrows work\" until someone\n * presses Down.\n *\n * **Direction is read from the element the caller passes, which should be the\n * container that lays the items out** — not the focused child. A child may carry\n * its own `dir` (an LTR input inside an RTL form is ordinary authoring), and\n * probing per handler makes two handlers disagree at the boundary between them.\n *\n * This decides direction only. Whether the axis is even active (an\n * `orientation=\"horizontal\"` widget ignoring Down/Up), how far the step lands,\n * and what wrapping does all stay with the caller.\n *\n * **It encodes the list-order convention: `ArrowDown` is *next*.** Widgets that\n * pair the arrows by *value* instead — `ArrowUp` meaning \"more\", as a rating or a\n * slider does — must not use this, or their vertical axis inverts. Reverse the\n * horizontal pair on its own there.\n *\n * @example\n * ```ts\n * const step = logicalArrowStep(event.key, this.element);\n * if (step === 0) return;\n * this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n * ```\n */\nexport function logicalArrowStep(key: string, element: Element): 1 | -1 | 0 {\n if (key === \"ArrowDown\") return 1;\n if (key === \"ArrowUp\") return -1;\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return 0;\n const forward = isRtl(element) ? \"ArrowLeft\" : \"ArrowRight\";\n return key === forward ? 1 : -1;\n}\n\n/**\n * Rewrites `key` so an existing LTR-shaped branch keeps working under RTL:\n * `ArrowRight` and `ArrowLeft` trade places, everything else passes through.\n *\n * The alternative — negating a delta — silently breaks handlers whose two\n * horizontal branches are **not mirror images**. A grid that clamps one edge but\n * not the other, or a segmented field guarding `index > 0` on one side and\n * `index < length - 1` on the other, ends up applying the wrong guard to the\n * wrong direction. Swapping the key leaves each branch, guards and all, exactly\n * where its author put it.\n *\n * Same rule as {@link logicalArrowStep} about which element to read: pass the\n * container that lays the items out, not the focused child.\n *\n * @example\n * ```ts\n * switch (logicalArrowKey(event.key, this.element)) {\n * case \"ArrowLeft\": // \"previous\" — whatever direction that is on screen\n * ```\n */\nexport function logicalArrowKey(key: string, element: Element): string {\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return key;\n if (!isRtl(element)) return key;\n return key === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n}\n\n/** Modifiers a widget may claim on an arrow key, named for the `allow` list. */\nexport type ArrowModifier = \"alt\" | \"ctrl\" | \"meta\" | \"shift\";\n\n/**\n * True when an arrow key arrived carrying a modifier the widget must leave to\n * the browser: return without calling `preventDefault()` and without moving any\n * state.\n *\n * A bare arrow belongs to the widget; a chorded one usually does not.\n * `Alt`/`Meta` plus a horizontal arrow is history back/forward on every desktop\n * browser, and a widget that swallows it makes the shortcut work or not\n * depending on where focus happens to sit — a coin-flip the user cannot see.\n *\n * `allow` is for the combinations APG assigns to a pattern **and the widget\n * actually implements** — today only Combobox's optional `Alt+Down`/`Alt+Up`.\n * Listing one the widget does not implement defeats the point: the chord then\n * runs the plain-arrow branch, which is exactly what this guard exists to stop.\n * Non-arrow keys return `false`, so chorded letters and\n * `Control+Home`/`Control+End` are untouched.\n *\n * @example\n * ```ts\n * if (isReservedArrowChord(event)) return;\n * ```\n */\nexport function isReservedArrowChord(\n event: KeyboardEvent,\n allow: readonly ArrowModifier[] = [],\n): boolean {\n if (!event.key.startsWith(\"Arrow\")) return false;\n return (\n (event.altKey && !allow.includes(\"alt\")) ||\n (event.ctrlKey && !allow.includes(\"ctrl\")) ||\n (event.metaKey && !allow.includes(\"meta\")) ||\n (event.shiftKey && !allow.includes(\"shift\"))\n );\n}\n\n/**\n * True when a press arrived carrying any modifier, for the keys the browser and\n * the OS own outright: return without calling `preventDefault()` and without\n * moving any state.\n *\n * `Control+Home` and `Control+End` jump the document to its ends, and a widget\n * that swallows them makes the shortcut work or not depending on where focus\n * happens to sit. {@link isReservedArrowChord} answers the same question for the\n * arrows, but returns `false` for every other key so that this one can decide.\n *\n * There is no `allow` list here on purpose. APG assigns no modifier chord to\n * `Home`/`End`, so a widget that wanted one would be claiming a combination the\n * pattern never gave it.\n *\n * @example\n * ```ts\n * case \"Home\":\n * case \"End\":\n * if (hasModifierChord(event)) return;\n * ```\n */\nexport function hasModifierChord(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n","/**\n * One registry per page for every copy of the library.\n *\n * Each `stimeo-ui/controllers/*` file, and each opt-in entry, is built on its own and carries\n * its own copy of every utility it uses, so a page that imports controllers one by one, or one\n * of them next to the barrel, evaluates a utility several times. A registry that coordinates\n * instances of different controllers — the stacks of leased values, the loans of a\n * `tabindex`, the Escape layers, the focus traps — must not be split by that: a dialog inside\n * a drawer, or a character counter and a form field on one input, coordinate whichever files\n * they came from. So such a registry lives once on `globalThis`, under a `Symbol.for` key the\n * copies agree on, and the first copy to ask for it creates it.\n *\n * The key names the registry and the version of its shape\n * (`stimeo-ui.<utility>.registry.v<n>`). Copies whose registries have the same shape share\n * one; a release that changes the shape changes the version, so a copy of another release\n * keeps a registry of its own instead of reading entries it does not understand — the two\n * then coordinate within each release only. An entry another copy put in a registry is read\n * through its fields alone, never through `#private` members, which belong to the class of\n * the copy that created it.\n */\n\n/**\n * The registry stored under `key`, created by `create` on first use.\n *\n * @param key - `stimeo-ui.<utility>.registry.v<n>`: the version is that of the shape `create`\n * returns.\n * @param create - Builds the empty registry.\n */\nexport function sharedRegistry<T extends object>(key: string, create: () => T): T {\n const symbol = Symbol.for(key);\n const scope = globalThis as unknown as Record<symbol, T | undefined>;\n const existing = scope[symbol];\n if (existing !== undefined) return existing;\n const registry = create();\n Object.defineProperty(globalThis, symbol, { value: registry });\n return registry;\n}\n","import { sharedRegistry } from \"./shared_registry\";\n\n/** What a lease's record says: the author's value, its last write, the leases beneath. */\ninterface AttributeLeaseRecord {\n readonly original: string | null;\n readonly written: string | null;\n /** Whether it hands back what the lease right beneath it wrote last. */\n readonly linked: boolean;\n /** The records of the other owners' leases beneath it, nearest first. */\n readonly beneath: readonly string[];\n}\n\n/** One lease's hold on one element's attribute, in the stack every lease of it shares. */\ninterface AttributeHold {\n /** The lease holding it; `null` for a hold read from a copy's record until its lease takes it. */\n lease: object | null;\n readonly record: string;\n written: string | null;\n /** What it hands back with nothing beneath it: the author's value. */\n readonly original: string | null;\n /** Whether it hands back what the hold beneath it wrote last instead. */\n linked: boolean;\n}\n\n/** The holds on each element by attribute, and every lease's record name by attribute. */\ninterface AttributeLeaseRegistry {\n readonly stacks: WeakMap<Element, Map<string, AttributeHold[]>>;\n readonly names: Map<string, Set<string>>;\n}\n\n/** Whether a parsed record entry is an attribute value: a string, or `null` for absence. */\nfunction isAttributeValue(value: unknown): value is string | null {\n return value === null || typeof value === \"string\";\n}\n\n/**\n * Reads the record a lease left on `element`: the author's value, the value the lease wrote\n * last, whether it hands back the value beneath it (`false` before the names when it does not)\n * and the records beneath it. `undefined` when the record is missing or holds anything else.\n */\nfunction readLeaseRecord(element: Element, record: string): AttributeLeaseRecord | undefined {\n try {\n const parsed: unknown = JSON.parse(element.getAttribute(record) ?? \"null\");\n if (!Array.isArray(parsed)) return undefined;\n const [original, written, ...rest] = parsed as unknown[];\n const linked = rest[0] !== false;\n const beneath = linked ? rest : rest.slice(1);\n if (!beneath.every((under): under is string => typeof under === \"string\")) return undefined;\n return isAttributeValue(original) && isAttributeValue(written)\n ? { original, written, linked, beneath }\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The value `element`'s author wrote for `attribute`, as the record a lease of any owner leaves\n * on the element carries it; `undefined` while no lease leaves one, as when nothing has moved\n * the attribute off the author's value. A field a reveal turned from `password` into `text`\n * still reads `\"password\"` here.\n */\nexport function leasedAuthorValue(element: Element, attribute: string): string | null | undefined {\n const suffix = `-${attribute}-lease`;\n for (const name of element.getAttributeNames()) {\n if (!name.startsWith(\"data-\") || !name.endsWith(suffix)) continue;\n const record = readLeaseRecord(element, name);\n if (record) return record.original;\n }\n return undefined;\n}\n\n/**\n * Temporarily controls one attribute across a changing set of elements.\n *\n * The first write remembers the authored value, including the distinction between\n * an absent attribute and an authored empty string. Returning a lease restores that\n * value only while the attribute still matches the controller's last write. If a\n * consumer changed it in the meantime, the consumer owns the new value and teardown\n * leaves it alone.\n *\n * A `null` write deliberately removes the attribute while retaining the lease. This\n * is useful for derived ARIA whose valid absence is itself controller state, such as\n * an unbounded `aria-valuemin` or a blank spinbutton's `aria-valuenow`.\n *\n * **Every lease of an attribute shares one stack of holds per element**, whatever its owner\n * and whichever file of the package constructed it (the stacks are one per page): the holds\n * sit in the order their leases first wrote the element, each with the value it wrote last.\n * The element's value is the highest hold's that carries it, and the page's when none does.\n * A write reaches the element unless a hold above the writer carries the element's value: the\n * top hold always shows its writes, a hold beneath it shows nothing while a hold above keeps\n * its value on the element, and once the page has put a value there that no hold carries, the\n * next write of any hold replaces it. A return gives a value back only from the hold the\n * element's value is: the value the hold beneath it wrote last, or the author's once nothing\n * is beneath it; any other return only leaves the stack, and the page's value stays. Holds\n * that wrote the same value are told apart by the stack, never by the value: the higher one\n * keeps it. A first write over a top hold whose value the page has replaced takes the\n * element's value as the author's. Two instances of one controller on one element — an\n * element outside their scope — stack the same way.\n *\n * A **base lease** (`{ base: true }`) holds the element's own state rather than a value over\n * it — a form field's ARIA on its control is one — so its first write goes to the bottom of\n * the stack, beneath the leases of other owners already there: a temporary value another\n * owner leased stays shown and returns to the base lease's latest value.\n *\n * **The stack travels with the element.** While a hold shows a value other than the author's,\n * lies on another hold or is covered by one, the element carries its owner's record\n * `data-<owner>-<attribute>-lease`: JSON of the author's value and the value the hold wrote\n * last (each a string, or `null` for an absent attribute), `false` where the hold hands back\n * the author's value rather than the latest value of the hold beneath it, and the records of\n * every hold beneath it, nearest first. Returning the last lease of an owner removes its\n * record. A copy of the element — a page Turbo restores from its cache is one — therefore\n * carries the stack, and the first lease to touch the copy reads it back under the record\n * names of the leases constructed so far, which include every lease that wrote a record the\n * cache holds, and orders the holds by the records each one lists beneath it. Each lease takes\n * the hold its owner's record describes over in place. Complete records for distinct owners\n * preserve their order across a copy. The records describe holds by owner, not by instance:\n * one owner holding the element more than once leaves only its topmost hold's record, which\n * the first of its leases to write or return on the copy takes. Lower holds of that owner and\n * their positions are absent; mutually listed owners cannot express their full live order.\n * A hold that showed the author's value alone carries no record and is taken by its first\n * write on the copy. Missing or unreadable records also leave their holds unknown, so copying\n * the DOM does not promise identical decisions for every live stack. Without a record it can\n * read, a new stack takes the current value as the author's. A Turbo morph removes records\n * absent from the server HTML; existing holds remain in memory until their leases return.\n *\n * The lease has no lifecycle of its own, so it never subscribes to document events,\n * and nothing rewinds a live page before Turbo caches it: `turbo:before-cache` also\n * fires on pages that stay.\n */\nexport class AttributeLease<T extends Element = Element> {\n /** The holds on each element, bottom first, and the record names; one per page. */\n static readonly #registry = sharedRegistry(\n \"stimeo-ui.attribute-lease.registry.v1\",\n (): AttributeLeaseRegistry => ({ stacks: new WeakMap(), names: new Map() }),\n );\n readonly #attribute: string;\n readonly #record: string;\n readonly #base: boolean;\n readonly #held = new Set<T>();\n\n /**\n * @param attribute - The attribute whose temporary values this lease owns.\n * @param owner - Names the record on the element; the controller's identifier.\n * @param options - `base`: written beneath the other owners' leases.\n */\n constructor(attribute: string, owner: string, options: { readonly base?: boolean } = {}) {\n this.#attribute = attribute;\n this.#record = `data-${owner}-${attribute}-lease`;\n this.#base = options.base === true;\n const names = AttributeLease.#registry.names;\n names.set(attribute, (names.get(attribute) ?? new Set<string>()).add(this.#record));\n }\n\n /** Writes or removes the leased attribute while preserving its authored value. */\n write(element: T, value: string | null): void {\n const stack = this.#stack(element);\n const hold = this.#take(stack) ?? this.#acquire(element, stack);\n this.#held.add(element);\n const shows = !this.#covered(element, stack, hold);\n hold.written = value;\n this.#mark(element, stack);\n if (shows) this.#reflect(element, value);\n }\n\n /**\n * Returns one lease, also on a restored copy, to the value the hold beneath it wrote last or\n * the author's, without overwriting a value a consumer wrote since. Says whether there was a\n * lease to return: a hold this lease has, or the hold a copy's record describes while no live\n * lease of the owner has taken it — a copy of a page an earlier connection wrote carries one.\n */\n return(element: T): boolean {\n const held = this.#held.delete(element);\n const known = AttributeLease.#registry.stacks.get(element)?.has(this.#attribute);\n const stack = held || known || element.hasAttribute(this.#record) ? this.#stack(element) : [];\n const hold = this.#take(stack);\n if (!hold) return false;\n const carries = element.getAttribute(this.#attribute) === hold.written;\n const owns = carries && !this.#covered(element, stack, hold);\n const index = stack.indexOf(hold);\n stack.splice(index, 1);\n const above = stack[index];\n if (above) above.linked &&= hold.linked;\n this.#mark(element, stack);\n if (!owns) return true;\n const below = hold.linked ? stack[index - 1] : undefined;\n this.#reflect(element, below ? below.written : hold.original);\n return true;\n }\n\n /** Returns every lease it holds, with the same ownership check as {@link return}. */\n returnAll(): void {\n for (const element of Array.from(this.#held)) this.return(element);\n }\n\n /** The element's stack, read from its records the first time. */\n #stack(element: T): AttributeHold[] {\n const stacks = AttributeLease.#registry.stacks;\n const byAttribute = stacks.get(element) ?? new Map<string, AttributeHold[]>();\n stacks.set(element, byAttribute);\n const stack = byAttribute.get(this.#attribute) ?? this.#seed(element);\n byAttribute.set(this.#attribute, stack);\n return stack;\n }\n\n /** The holds a copy's records describe, each above every hold its record lists beneath. */\n #seed(element: T): AttributeHold[] {\n const found: (AttributeLeaseRecord & { readonly record: string })[] = [];\n for (const record of AttributeLease.#registry.names.get(this.#attribute) ?? []) {\n const read = readLeaseRecord(element, record);\n if (read) found.push({ ...read, record });\n }\n const depth = ({ beneath }: (typeof found)[number]) =>\n beneath.filter((name) => found.some((other) => other.record === name)).length;\n return found\n .sort((one, other) => depth(one) - depth(other))\n .map(({ record, written, original, linked }, index) => ({\n lease: null,\n record,\n written,\n original,\n linked: linked && index > 0,\n }));\n }\n\n /** Its hold in `stack`, taking over one read from its record. */\n #take(stack: AttributeHold[]): AttributeHold | undefined {\n const hold =\n stack.find((held) => held.lease === this) ??\n stack.find((held) => held.lease === null && held.record === this.#record);\n if (hold) hold.lease = this;\n return hold;\n }\n\n /** A new hold: on top, over the top hold while the element shows it; a base one at the bottom. */\n #acquire(element: T, stack: AttributeHold[]): AttributeHold {\n const current = element.getAttribute(this.#attribute);\n const top = stack.at(-1);\n const bottom = stack[0];\n const over = top?.written === current ? top : undefined;\n const from = this.#base ? bottom : over;\n const hold: AttributeHold = {\n lease: this,\n record: this.#record,\n written: current,\n original: from ? from.original : current,\n linked: !this.#base && over !== undefined,\n };\n if (this.#base && bottom) {\n bottom.linked = true;\n stack.unshift(hold);\n } else stack.push(hold);\n return hold;\n }\n\n /** Whether a hold above `hold` carries the element's value, which is then that hold's. */\n #covered(element: T, stack: readonly AttributeHold[], hold: AttributeHold): boolean {\n const current = element.getAttribute(this.#attribute);\n return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);\n }\n\n /** Leaves each owner's record of its topmost hold, or none where nothing needs one. */\n #mark(element: T, stack: readonly AttributeHold[]): void {\n const records = new Map<string, string | null>([[this.#record, null]]);\n stack.forEach((hold, index) => {\n const names = stack.slice(0, index).map((under) => under.record);\n const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);\n const marker = hold.linked || beneath.length === 0 ? [] : [false];\n records.set(\n hold.record,\n hold.written === hold.original && beneath.length === 0 && index === stack.length - 1\n ? null\n : JSON.stringify([hold.original, hold.written, ...marker, ...beneath]),\n );\n });\n for (const [name, recorded] of records) {\n if (element.getAttribute(name) === recorded) continue;\n if (recorded === null) element.removeAttribute(name);\n else element.setAttribute(name, recorded);\n }\n }\n\n /** Reflects only a real value transition, avoiding self-triggered mutation work. */\n #reflect(element: T, value: string | null): void {\n if (element.getAttribute(this.#attribute) === value) return;\n if (value === null) element.removeAttribute(this.#attribute);\n else element.setAttribute(this.#attribute, value);\n }\n}\n","/**\n * Shared \"in-page move vs real detach\" discriminator for `disconnect()`.\n *\n * A mid-session `disconnect()` whose element is still in the document is\n * ambiguous. It can be:\n *\n * - an **in-page move** — a consumer (sortable, a teleport) re-inserted the\n * element; Stimulus reconnects the SAME instance in the same mutation batch\n * and the controller's runtime state must survive;\n * - a **detach that keeps the element** — `data-controller` no longer lists the\n * identifier (a Turbo 8 morph), or the element moved outside the observed\n * root (a scoped `Application.start(root)`, a shadow root); no reconnect will\n * ever come and the controller must tear down or it leaks its sessions,\n * document listeners, and moved nodes.\n *\n * Neither available signal decides this alone. A synchronous `data-controller`\n * token check catches the morph case but misses an observed-root exit (the\n * token stays, the reconnect never comes). Deferring teardown one microtask and\n * letting `connect()` cancel it catches the root exit, but leans on Stimulus\n * reconnecting moved elements within the same mutation batch — internal\n * behavior, not a public contract. {@link DetachGate} composes both: the token\n * check is the synchronous fast path (no probe, no reliance on batching), the\n * microtask probe is the fallback for the genuinely ambiguous remainder.\n *\n * An element out of the document is a real detach, with one exception: a\n * `data-turbo-permanent` element, or one inside it, that Turbo carries to the\n * next page. Turbo takes it out of the old `<body>`, which Stimulus answers with\n * a `disconnect()` while it is out of the document, and puts it into the new one\n * a few microtasks later in the same task, where the same instance connects\n * again. Such a disconnect is probed until the next task instead.\n *\n * Policy stays with the consumer; this util owns the discrimination only:\n *\n * - **Probe** ({@link disconnected}) when the teardown must eventually happen —\n * live drag sessions, document listeners, teleported *content*. Call\n * {@link cancel} from `connect()` (a reconnect means in-page move) and from\n * the head of any direct teardown path (see below).\n * - **Keep** (bare {@link DetachGate.isDetached}) when undoing the ambiguous\n * case would fight the controller's own effect: a controller that moves its\n * OWN element (portal's no-`content` form) exits a scoped observed root as\n * its normal job — a probe-driven teardown would restore the element into\n * the root, reconnect, re-teleport, and disconnect again, forever. Such\n * controllers keep their state on an ambiguous disconnect and tear down only\n * on {@link DetachGate.isDetached}.\n *\n * Event convention for probe consumers: teardown into a dead (detached) tree is\n * silent — consumers restore from their own `connect()`; a detach that keeps the\n * tree alive must end an in-flight session with a `cancel` event, or composing\n * consumers strand their session bookkeeping.\n */\n\n/** The slice of a Stimulus controller the gate inspects. */\nexport interface DetachGateHost {\n readonly element: Element;\n readonly identifier: string;\n}\n\n/**\n * Per-controller-instance gate deciding whether a `disconnect()` is a real\n * detach. Hold one per controller (`#gate = new DetachGate()`) — Stimulus\n * reuses the instance across reconnects, so the pending probe state carries\n * over exactly as the protocol needs.\n *\n * @example\n * ```ts\n * #gate = new DetachGate();\n *\n * connect(): void {\n * this.#gate.cancel(); // a reconnect: the element moved in-page\n * // …\n * }\n *\n * disconnect(): void {\n * this.#gate.disconnected(this, () => this.#teardown());\n * }\n *\n * dismiss(): void {\n * this.#gate.cancel(); // a direct path: disarm a probe a disconnect queued\n * this.#teardown();\n * }\n *\n * #teardown(): void {\n * // … (`disconnected` has already disarmed the probe on its own path)\n * }\n * ```\n */\nexport class DetachGate {\n /** Set while a probe is queued, waiting for a reconnect to cancel it. */\n #pending = false;\n\n /**\n * True while a probe is queued — the last disconnect was ambiguous and no\n * reconnect has cancelled it yet. Read it from `connect()` to tell the\n * reconnect half of an in-page move from a first connect: a controller whose\n * initialisation restarts a measurement (a min-duration floor, an elapsed\n * counter) must skip it for the move, where nothing actually restarted.\n */\n get pending(): boolean {\n return this.#pending;\n }\n\n /**\n * True when the disconnect is definitely a real detach — the element left\n * the document, or `data-controller` no longer lists the identifier. False\n * means ambiguous (in-page move or observed-root exit), NOT \"alive\".\n */\n static isDetached(host: DetachGateHost): boolean {\n return !host.element.isConnected || !DetachGate.#listed(host);\n }\n\n /**\n * Call from `disconnect()`: runs `teardown` synchronously on a definite\n * detach (fast path), otherwise defers it one microtask — a reconnect\n * ({@link cancel} from `connect()`) keeps the state, no reconnect runs it.\n * One microtask is the whole probe window: Stimulus reconnects a moved\n * element within the same mutation batch, before the checkpoint drains. An\n * element Turbo carries to the next page is probed until the next task, by\n * which time Turbo has put it back.\n */\n disconnected(host: DetachGateHost, teardown: () => void): void {\n const carried = DetachGate.#carried(host);\n if (!carried && DetachGate.isDetached(host)) {\n // Also disarms a probe a previous ambiguous disconnect left queued\n // (defer, element removed, disconnect again) — exactly one teardown.\n this.#pending = false;\n teardown();\n return;\n }\n this.#pending = true;\n const probe = (): void => {\n if (!this.#pending) return;\n this.#pending = false;\n teardown();\n };\n if (carried) setTimeout(probe, 0);\n else queueMicrotask(probe);\n }\n\n /**\n * Whether `host` is out of the document inside a `data-turbo-permanent` element, its\n * identifier still listed: where Turbo holds an element it carries to the next page.\n */\n static #carried(host: DetachGateHost): boolean {\n const element = host.element;\n return (\n !element.isConnected &&\n element.closest(\"[data-turbo-permanent]\") !== null &&\n DetachGate.#listed(host)\n );\n }\n\n /** Whether the element's `data-controller` still lists the identifier. */\n static #listed(host: DetachGateHost): boolean {\n const tokens = (host.element.getAttribute(\"data-controller\") ?? \"\").split(/\\s+/);\n return tokens.includes(host.identifier);\n }\n\n /**\n * Disarms a pending probe. Call from `connect()` (the reconnect that proves\n * an in-page move) and from the head of any teardown path not routed through\n * {@link disconnected} (disabled-toggle, Escape), so an orphaned probe can\n * never run the teardown a second time.\n */\n cancel(): void {\n this.#pending = false;\n }\n}\n","/**\n * Resolves which of a controller's elements owns a node.\n *\n * A delegated listener hears events from a whole subtree, so the handler's first\n * job is almost always the same question: which item, handle, or control does\n * this `event.target` belong to? The same question comes up for a\n * `MutationRecord.target`, for `document.activeElement`, and for a\n * `relatedTarget` on the way out of a hover region.\n *\n * The answer is `Node.contains()`, which is **inclusive** — an element contains\n * itself — so testing the candidate for identity as well would be redundant.\n *\n * **The guard is what makes this safe to call with a raw event target.**\n * `event.target` is typed `EventTarget | null`, and `contains()` takes a `Node?`:\n * browsers throw `TypeError` for anything else, and `window` — the everyday\n * `EventTarget` that is not a `Node` — is what an event dispatched at it carries.\n * Narrowing here means a caller never has to cast, and the rule cannot drift\n * between the places that ask the question.\n *\n * Scope stays with the caller. These helpers say *which candidate owns the node*,\n * not *whether the node belongs to this controller at all* — a component with\n * nested instances of itself decides that first (by comparing the closest\n * annotated ancestor) and passes the candidates it owns.\n */\n\n/**\n * Index in `candidates` of the first one that is, or contains, `node`.\n *\n * `-1` when none does, when `node` is absent, and when it is an `EventTarget`\n * that is not a `Node`. Candidates are tested in array order, so a nested pair\n * resolves to whichever the caller listed first.\n */\nexport function ownerIndex<T extends Element>(\n candidates: readonly T[],\n node: EventTarget | null | undefined,\n): number {\n if (!(node instanceof Node)) return -1;\n return candidates.findIndex((candidate) => candidate.contains(node));\n}\n\n/**\n * The first candidate that is, or contains, `node`; `null` when none does.\n *\n * A miss indexes the array at `-1`, which reads as `undefined` and lands on the\n * same `null` the absent cases produce.\n */\nexport function ownerOf<T extends Element>(\n candidates: readonly T[],\n node: EventTarget | null | undefined,\n): T | null {\n return candidates[ownerIndex(candidates, node)] ?? null;\n}\n","/**\n * Owns every listener a controller attaches for one connected lifetime and\n * releases them together, so an event name is spelled once and the release\n * cannot drift from the registration.\n *\n * Detaching by hand repeats three things at the release site — the type, the\n * handler reference and the capture flag — and any one of them drifting leaves\n * a listener alive on an element the controller no longer drives. Aborting the\n * signal a registration was created with releases it whatever it was made of,\n * so the release site names nothing.\n *\n * One set per lifetime, held as a field and never rebuilt. {@link\n * ListenerSet.dispose} is the only thing that closes a generation, and it opens\n * the next one in the same step, so the lifecycle hooks can call `add` and\n * `dispose` in any order any number of times, and no `add` ever meets an\n * already aborted signal — a DOM that registers a listener on such a signal\n * would keep it forever. Rebuilding the set instead would leak:\n * `addEventListener` matches an existing registration on target, type, callback\n * and capture alone, so re-adding the same handler while the first registration\n * is live is discarded, and that live registration keeps the signal it was\n * attached with — a set built by a second `connect()` can never release what it\n * appears to own.\n *\n * Scope is the registration only. Timers, observers, leases and the order they\n * are unwound in stay with the controller, which places `dispose()` in its\n * cleanup sequence. A receiver that changes at runtime (a\n * swapped target) is rebound by calling `dispose()` and then `add()` again from\n * the rebind, not by a second set.\n *\n * The set must own every registration of a tuple it holds: a listener the same\n * target already carries for the same type, callback and capture flag keeps the\n * right to remove it, and this set's `add` for that tuple is discarded. A\n * subscription shared between instances behind a participant count, or one that\n * lives for less than the connection, keeps its own pair of calls.\n *\n * @example\n * ```ts\n * readonly #listeners = new ListenerSet();\n *\n * connect(): void {\n * this.#listeners.add(this.element, \"submit\", this.#onNativeSubmit, { capture: true });\n * this.#listeners.add(this.element, \"turbo:submit-start\", this.#onSubmitStart);\n * this.#listeners.add(this.element, \"turbo:submit-end\", this.#onSubmitEnd);\n * }\n *\n * disconnect(): void {\n * this.#listeners.dispose();\n * }\n * ```\n */\nexport class ListenerSet {\n /** The generation every `add` joins until the next `dispose()`. */\n #abort = new AbortController();\n\n /**\n * Attaches `handler` to the open generation, exactly as the caller spelled it.\n *\n * The set supplies the signal, so `options` carries everything else the DOM\n * accepts — `capture` included, which has to match at release time and no\n * longer has a second place to drift from.\n */\n add(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: Omit<AddEventListenerOptions, \"signal\">,\n ): void {\n target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });\n }\n\n /**\n * Releases every listener of the open generation, synchronously, and opens the\n * next one. Idempotent, and safe before anything has been added.\n */\n dispose(): void {\n this.#abort.abort();\n this.#abort = new AbortController();\n }\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","import { ListenerSet } from \"./listener_set\";\nimport { MicrotaskCoalescer } from \"./microtask_coalescer\";\n\n/**\n * Coalesces retained-element morphs and explicit lifecycle requests into one pass.\n *\n * Observe the controller's element after its initial state is settled. Morphs on\n * that element and bubbling morphs on its descendants share the same microtask\n * as {@link schedule}. The callback repairs derived output; the controller owns\n * any logical transition reporting. {@link disconnect} releases the listener and\n * cancels pending work, including work from an earlier connected lifetime.\n */\nexport class MorphRenderWatcher {\n readonly #listeners = new ListenerSet();\n readonly #pass: MicrotaskCoalescer;\n #element: Element | null = null;\n readonly #onMorph = (): void => this.#pass.schedule();\n\n /** @param run - the single pass that repairs the settled controller's output. */\n constructor(run: () => void) {\n this.#pass = new MicrotaskCoalescer(run);\n }\n\n /** Opens observation; observing the same element again preserves queued work. */\n observe(element: Element): void {\n if (this.#element === element) return;\n this.disconnect();\n this.#element = element;\n this.#pass.activate();\n this.#listeners.add(element, \"turbo:morph-element\", this.#onMorph);\n }\n\n /** Requests one pass; requests outside an observed lifetime are ignored. */\n schedule(): void {\n this.#pass.schedule();\n }\n\n /** Releases observation and pending work synchronously; safe to repeat. */\n disconnect(): void {\n this.#listeners.dispose();\n this.#pass.cancel();\n this.#element = null;\n }\n}\n","/**\n * Identifies the latest reported state transition of one owner.\n *\n * Record a transition after its state is written and before invoking external\n * code. Check the returned token before each later report: a synchronous\n * transition made by a listener supersedes reports that have not been sent.\n * Reading state or committing an unchanged state must not advance the counter.\n * Reports stay in the caller so their ordering remains explicit.\n */\nexport class MoveCounter {\n #sequence = 0;\n\n /** Records a state transition and returns its report token. */\n record(): number {\n this.#sequence += 1;\n return this.#sequence;\n }\n\n /** Whether no later state transition has superseded this report token. */\n isLatest(token: number): boolean {\n return token === this.#sequence;\n }\n}\n","/**\n * Largest delay a timer can hold: the platform stores it in a 32-bit signed\n * integer, and anything larger overflows to `1`, so a delay meant to be far in\n * the future fires almost immediately. A declared delay above this bound names\n * no delay at all, and a controller reading one falls back to its default.\n */\nexport const MAX_TIMER_DELAY_MS = 2_147_483_647;\n","import { MAX_TIMER_DELAY_MS } from \"./timer_bounds\";\n\n/** Semantic constraints on an already decoded number, independent of the DOM. */\nexport interface NumberBounds {\n /** Finite numbers are required, including when this field is omitted. */\n readonly finite?: true;\n /** Inclusive lower endpoint. */\n readonly min?: number;\n /** Inclusive upper endpoint. */\n readonly max?: number;\n /** Exclusive lower endpoint. */\n readonly exclusiveMin?: number;\n /** Require a number without a fractional part. */\n readonly integer?: boolean;\n /** Exact decoded numbers accepted by a discrete contract. */\n readonly allowedValues?: readonly number[];\n /** JSON-safe exceptions to finite-number checking for unbounded endpoints. */\n readonly allowInfinity?: \"negative\" | \"positive\" | \"both\";\n}\n\n/** One constraint for each Number Value, including shorthand declarations. */\nexport type NumberValueConstraints<Values> = {\n readonly [Key in keyof Values as Values[Key] extends\n | NumberConstructor\n | { type: NumberConstructor }\n ? Key\n : never]: NumberBounds;\n};\n\n/** Reusable semantic domains; fractional inputs remain fractional unless excluded. */\nexport const NUMBER_BOUNDS = {\n finite: { finite: true },\n nonNegative: { finite: true, min: 0 },\n positive: { finite: true, exclusiveMin: 0 },\n nonNegativeInteger: { finite: true, min: 0, integer: true },\n positiveInteger: { finite: true, exclusiveMin: 0, integer: true },\n lowerBound: { finite: true, allowInfinity: \"negative\" },\n upperBound: { finite: true, allowInfinity: \"positive\" },\n timer: { finite: true, min: 0, max: MAX_TIMER_DELAY_MS },\n positiveTimer: { finite: true, exclusiveMin: 0, max: MAX_TIMER_DELAY_MS },\n} as const satisfies Record<string, NumberBounds>;\n\n/**\n * Checks all declared bounds without rounding, clamping, or coercing the input.\n * Infinity exceptions relax only finite checking; every other bound still applies.\n */\nexport function matchesNumberBounds(value: number, bounds: NumberBounds): boolean {\n if (!Number.isFinite(value)) {\n const direction = value === Infinity ? \"positive\" : value === -Infinity ? \"negative\" : null;\n if (direction === null) return false;\n if (bounds.allowInfinity !== \"both\" && bounds.allowInfinity !== direction) return false;\n }\n if (bounds.min !== undefined && value < bounds.min) return false;\n if (bounds.max !== undefined && value > bounds.max) return false;\n if (bounds.exclusiveMin !== undefined && value <= bounds.exclusiveMin) return false;\n if (bounds.integer && !Number.isInteger(value)) return false;\n if (bounds.allowedValues !== undefined && !bounds.allowedValues.includes(value)) return false;\n return true;\n}\n\n/** Decodes a Number Value literal; action params use their own JSON decoder. */\nexport function decodeNumberValue(raw: string): number {\n return Number(raw.replace(/_/g, \"\"));\n}\n","/**\n * Numeric coercion for controllers that accept a number through a Value, an action\n * param, or an event detail.\n *\n * Stimulus decodes action params as JSON when possible and leaves other text\n * untouched. CustomEvent detail can also supply a number or numeric string.\n * The reader accepts those two types while rejecting blank and non-finite input.\n */\n\nimport { matchesNumberBounds, type NumberBounds } from \"./number_bounds\";\n\n/**\n * Reads a finite number or nonblank numeric string; other input returns `null`.\n * Blank strings cannot silently reset a value to zero.\n */\nexport function toFiniteNumber(raw: unknown): number | null {\n if (typeof raw !== \"number\" && typeof raw !== \"string\") return null;\n if (typeof raw === \"string\" && raw.trim().length === 0) return null;\n const value = Number(raw);\n return Number.isFinite(value) ? value : null;\n}\n\n/**\n * Returns an accepted decoded Number Value or the caller's fallback unchanged.\n * The caller owns the fallback contract; this reader does not parse or write a Value.\n */\nexport function readNumber(raw: number, fallback: number, bounds: NumberBounds): number {\n return matchesNumberBounds(raw, bounds) ? raw : fallback;\n}\n","import { readNumber } from \"./coerce\";\nimport { matchesNumberBounds, type NumberBounds } from \"./number_bounds\";\n\n/** The instance identity carried by a Number Value read. */\nexport interface NumberValueOwner {\n readonly identifier: string;\n readonly element: Element;\n}\n\n/** Reads current declarations at the point of use without rewriting their attributes. */\nexport class NumberValueReader {\n /** The last rejected literal per Value; no history grows for an unchanged instance. */\n readonly #lastRejected = new Map<string, string>();\n\n /** Resolves the declared number using its own fallback and shared class contract. */\n read(\n owner: NumberValueOwner,\n name: string,\n raw: number,\n fallback: number,\n bounds: NumberBounds,\n ): number {\n const resolved = readNumber(raw, fallback, bounds);\n if (matchesNumberBounds(raw, bounds)) {\n this.#lastRejected.delete(name);\n return resolved;\n }\n const attribute = `data-${owner.identifier}-${name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}-value`;\n const literal = owner.element.getAttribute(attribute);\n if (literal === null) {\n this.#lastRejected.delete(name);\n return resolved;\n }\n if (this.#lastRejected.get(name) !== literal) {\n this.#lastRejected.set(name, literal);\n console.warn(\n `Stimeo UI: \"${owner.identifier}\" has an invalid number Value \"${name}\" declaration ${JSON.stringify(literal)}; using ${fallback}.`,\n );\n }\n return resolved;\n }\n}\n","/**\n * Shared `prefers-reduced-motion` lookup for the motion-aware controllers.\n *\n * This one-liner keeps the media query string and the environment guard\n * single-sourced across them. The preference is intentionally re-read on every\n * call — the controllers check it at each animation/scroll start (WCAG 2.2\n * **2.3.3**), so flipping the OS setting takes effect immediately without any\n * listener or cache bookkeeping here.\n */\n\n/**\n * Whether the user currently requests reduced motion.\n *\n * @returns `true` when `(prefers-reduced-motion: reduce)` matches; `false`\n * otherwise, including environments without `window.matchMedia` (treated as\n * \"no preference\").\n */\nexport function prefersReducedMotion(): boolean {\n return (\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n","/**\n * Low-level roving-tabindex primitive shared by composite-widget controllers.\n *\n * The APG roving-tabindex pattern keeps a composite widget a single Tab stop:\n * exactly one item is in the Tab sequence (`tabindex=\"0\"`) while the rest are\n * removed from it (`tabindex=\"-1\"`), and the arrow keys move both DOM focus and\n * that single tabbable position together. {@link RovingTabindex} owns *only* that\n * mechanical bookkeeping — \"which one item is tabbable, and move focus there\".\n *\n * It is intentionally **policy-free**. Orientation, wrapping vs. clamping,\n * selection-follows-focus, typeahead, and `Home`/`End` semantics differ per APG\n * pattern (Radio Group, Toolbar, Rating, …); folding them into one helper would\n * flatten those widgets to a lowest common denominator and lose each pattern's\n * correctness. Those decisions therefore stay in each controller, which calls\n * {@link RovingTabindex.setActive} with an index it computed itself (optionally\n * via the pure {@link rovingMove} helper).\n *\n * @remarks\n * Items are read lazily through a getter so a controller can add or remove\n * targets (Stimulus re-scans the DOM) without re-wiring this helper. A caller\n * that already captured one event-scoped snapshot may pass it to\n * {@link RovingTabindex.setActive}, avoiding a second live-target scan while\n * preserving one coherent collection for the whole operation.\n */\nexport class RovingTabindex {\n /** Returns the current ordered item elements; called on every operation. */\n readonly #getItems: () => HTMLElement[];\n\n /**\n * @param getItems - Returns the current ordered item elements. Called on every\n * operation so the live target list is always used.\n */\n constructor(getItems: () => HTMLElement[]) {\n this.#getItems = getItems;\n }\n\n /** Index of the currently tabbable item (`tabindex=\"0\"`), or `-1` if none. */\n get activeIndex(): number {\n return this.#getItems().findIndex((item) => item.tabIndex === 0);\n }\n\n /**\n * Makes exactly the item at `index` tabbable (`tabindex=\"0\"`) and removes every\n * other item from the Tab sequence (`tabindex=\"-1\"`). An out-of-range `index`\n * (e.g. `-1`) leaves all items at `-1`, which a controller can use to express\n * \"nothing is currently tabbable\".\n *\n * @param index - Position of the item to make tabbable.\n * @param options - Pass `{ focus: true }` to also move DOM focus to that item,\n * and `items` to reuse an event-scoped collection snapshot.\n */\n setActive(\n index: number,\n options: { focus?: boolean; items?: readonly HTMLElement[] } = {},\n ): void {\n const { focus = false } = options;\n const items = options.items ?? this.#getItems();\n items.forEach((item, i) => {\n item.tabIndex = i === index ? 0 : -1;\n });\n if (focus) items[index]?.focus();\n }\n}\n\n/** Edge behavior for {@link rovingMove}: cycle past the ends, or stop at them. */\nexport type RovingWrap = \"wrap\" | \"clamp\";\n\n/**\n * Pure helper that resolves the target index for a one-step directional move.\n *\n * Keyboard/orientation mapping stays in the caller: it decides that a key means\n * `delta` `+1` (next) or `-1` (previous) and whether the widget should `\"wrap\"`\n * (Radio Group, Toolbar) or `\"clamp\"` at the ends.\n *\n * @param current - The index focus is moving from.\n * @param length - Number of items in the set.\n * @param delta - `+1` to move to the next item, `-1` for the previous.\n * @param wrap - `\"wrap\"` cycles around the ends; `\"clamp\"` stops at them.\n * @returns The resolved index, or `-1` when there are no items.\n */\nexport function rovingMove(\n current: number,\n length: number,\n delta: number,\n wrap: RovingWrap,\n): number {\n if (length === 0) return -1;\n const next = current + delta;\n if (wrap === \"wrap\") return (next + length) % length;\n return Math.min(length - 1, Math.max(0, next));\n}\n","/**\n * Self-cleaning timer registries shared by Stimeo controllers.\n *\n * Stimulus controllers frequently schedule `setTimeout` / `setInterval` work\n * (auto-dismiss, debouncing, polling). When the element leaves the DOM — a\n * Turbo Drive navigation, a Turbo Stream replacement, or any `disconnect()` —\n * orphaned timers keep firing against a detached controller, leaking memory and\n * mutating stale state. {@link SafeTimeout} and {@link SafeInterval} track every\n * timer they create so a single {@link TimerRegistry.clearAll | clearAll()} call\n * in `disconnect()` tears them all down.\n *\n * These are intentionally low-level primitives: they own *registration and\n * cleanup only*. Higher-level policy (pause/resume, remaining-time accounting)\n * stays in the individual controllers so per-widget semantics are not flattened\n * into a lowest-common-denominator helper.\n */\n\nexport { MAX_TIMER_DELAY_MS } from \"./timer_bounds\";\n\n/**\n * Shared registry bookkeeping for the timeout/interval variants.\n *\n * Subclasses provide the scheduling primitive ({@link schedule}) and its matching\n * canceller ({@link cancel}); this base owns the set of live ids plus the\n * per-id and bulk teardown shared by both.\n */\nabstract class TimerRegistry {\n /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */\n protected readonly ids = new Set<number>();\n\n /** Schedules the underlying platform timer and returns its id. */\n protected abstract schedule(callback: () => void, delay: number): number;\n\n /** Cancels the underlying platform timer for `id`. */\n protected abstract cancel(id: number): void;\n\n /**\n * Cancels a single tracked timer.\n *\n * No-ops if the id is unknown (already cleared, fired, or never owned by this\n * registry), so callers can clear defensively without guarding.\n */\n clear(id: number): void {\n if (this.ids.delete(id)) {\n this.cancel(id);\n }\n }\n\n /**\n * Cancels every tracked timer. Call this from a controller's `disconnect()`\n * to guarantee no timer outlives the element.\n */\n clearAll(): void {\n for (const id of this.ids) {\n this.cancel(id);\n }\n this.ids.clear();\n }\n\n /** Number of timers currently tracked (pending). */\n get size(): number {\n return this.ids.size;\n }\n}\n\n/**\n * `setTimeout` wrapper that auto-forgets each timer once it fires and supports\n * bulk teardown on disconnect.\n *\n * @example\n * ```ts\n * #timers = new SafeTimeout();\n *\n * connect() {\n * this.#timers.set(() => this.dismiss(), 5000);\n * }\n *\n * disconnect() {\n * this.#timers.clearAll();\n * }\n * ```\n */\nexport class SafeTimeout extends TimerRegistry {\n /**\n * Schedules `callback` after `delay` ms and returns the timer id.\n *\n * The id is removed from the registry automatically when the timeout fires,\n * so {@link TimerRegistry.size | size} reflects only still-pending timers.\n */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(() => {\n this.ids.delete(id);\n callback();\n }, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setTimeout(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearTimeout(id);\n }\n}\n\n/**\n * `setInterval` wrapper that tracks every interval for bulk teardown on\n * disconnect. Unlike {@link SafeTimeout}, intervals are retained until they are\n * explicitly cleared because they fire repeatedly.\n *\n * @example\n * ```ts\n * #intervals = new SafeInterval();\n *\n * connect() {\n * this.#intervals.set(() => this.tick(), 1000);\n * }\n *\n * disconnect() {\n * this.#intervals.clearAll();\n * }\n * ```\n */\nexport class SafeInterval extends TimerRegistry {\n /** Schedules a repeating `callback` every `delay` ms and returns the timer id. */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(callback, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setInterval(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearInterval(id);\n }\n}\n","import { sharedRegistry } from \"./shared_registry\";\n\n/** What a consumer declares once about the regions one boolean state reveals. */\nexport interface StateRegionsOptions {\n /** Returns the declared regions shown while the state holds. */\n readonly whenTrue: () => readonly HTMLElement[];\n /**\n * Returns the declared regions shown while the state does not hold. Omitted by a\n * state whose other side has nothing of its own to show.\n */\n readonly whenFalse?: () => readonly HTMLElement[];\n}\n\n/** One instance's hold on one region's `hidden`, in the stack every instance shares. */\ninterface RegionHold {\n /** The instance holding it; `null` for a hold read from a copy's record until it is taken. */\n instance: object | null;\n readonly record: string;\n /** What the author wrote: the `hidden` it hands back with nothing beneath it. */\n readonly authored: string | null;\n /** Whether the visibility it wrote last hides the region. */\n written: boolean;\n /** Whether it hands back what the hold beneath it wrote last instead. */\n linked: boolean;\n}\n\n/** What an instance's record on a region says. */\ninterface RegionRecord {\n readonly authored: string | null;\n readonly written: boolean;\n readonly linked: boolean;\n /** The records of the other owners' holds beneath it, nearest first. */\n readonly beneath: readonly string[];\n}\n\n/** The holds on each region and every instance's record name. */\ninterface StateRegionsRegistry {\n readonly stacks: WeakMap<HTMLElement, RegionHold[]>;\n readonly names: Set<string>;\n}\n\n/**\n * Owns `hidden` on the regions a boolean state reveals.\n *\n * A region is a **declared** target, so the consumer decides whether one exists at\n * all; where it does, which side is shown is a pure function of the state and the\n * controller writes it unconditionally. An authored `hidden` is therefore not read\n * back — the first reflection after a connection settles it, and a restored DOM\n * cannot leave a region contradicting the state it belongs to.\n *\n * The regions arrive as the caller's own target arrays, which Stimulus has already\n * scoped to this instance: a nested controller registered under the same identifier\n * keeps its own regions. `host` narrows that set further, to the regions inside one\n * trigger or item, so a widget with several of them reflects each independently.\n *\n * **Two sides are a pair.** Where the state has a `whenFalse` side and only one half\n * sits inside `host`, the half that is there is left in view: hiding it would take\n * the only label with it, and the static check names the missing one instead. What\n * the author wrote on a lone half is theirs and stays — only a half this instance\n * took out of view is given back, which is what a pair losing one side at runtime\n * leaves behind.\n *\n * `hidden` moves only where it changes, and the record below only where what it says changes:\n * a transition costs a consumer watching its own subtree for attribute mutations two of them on\n * each region it moves — `hidden` and the record — and a reflection that moves nothing costs\n * none. A write that moves no `hidden` — the page moved the region first, or another\n * instance's hold lies above this one — changes only the record.\n *\n * **Every instance shares one stack of holds per region**, whatever its owner and whichever\n * file of the package constructed it (the stacks are one per page): the holds sit in the order\n * their instances first wrote the region, each with the visibility it wrote last. The region's\n * visibility is the highest hold's that carries it, and the page's when none does. A write\n * moves `hidden` unless a hold above the writer carries the region's visibility, so the top\n * hold always shows its writes and the page's visibility gives way to the next write of any\n * hold. A release gives a visibility back only from the hold the region's visibility is: the\n * one the hold beneath it wrote last, or the author's `hidden` once nothing is beneath it; any\n * other release only leaves the stack. Holds that wrote the same visibility are told apart by\n * the stack: the higher one keeps it. A first write over a top hold whose visibility the page\n * has replaced takes the region's `hidden` as the author's. Two instances of one owner on one\n * region stack the same way.\n *\n * **The stack travels with the region.** While the region carries anything but what the author\n * wrote under its top hold, or a hold lies on another hold or is covered by one, the region\n * carries that hold's owner's record `data-<owner>-hidden-region`: JSON of what the author\n * wrote (a string, or `null` for an absent attribute), whether the visibility written last\n * hides the region, `false` where the hold hands back the author's `hidden` rather than the\n * latest visibility of the hold beneath it, and the records of every hold beneath it, nearest\n * first; the last release of an owner removes it. A copy of the region — a page Turbo restores\n * from its cache — therefore carries the stack, read back under the record names of the\n * instances constructed so far and ordered by the records each hold lists beneath it, and an\n * instance that reflects, gives back or releases the copy takes the hold its owner's record\n * describes over in place. Complete records for distinct owners preserve their order across\n * a copy, including release without a new reflection. Records describe owners, not instances:\n * one owner holding the region more than once leaves only its topmost hold's record, which\n * the first of its instances to write or release on the copy takes. Its lower holds and\n * positions are absent; mutually listed owners cannot express their full live order. A hold\n * that showed the author's `hidden` alone carries no record and is taken by its first write\n * on the copy. Missing or unreadable records also leave their holds unknown, so copying the\n * DOM does not promise identical decisions for every live stack. A new stack with no readable\n * record takes the current value as the author's; a morph can remove records while existing\n * holds remain in memory until released.\n *\n * @example\n * ```ts\n * readonly #labels = new StateRegions(\n * {\n * whenTrue: () => this.expandedLabelTargets,\n * whenFalse: () => this.collapsedLabelTargets,\n * },\n * this.identifier,\n * );\n *\n * #reflect(): void {\n * this.#labels.reflect(this.triggerTarget, this.#expanded);\n * }\n * ```\n */\nexport class StateRegions {\n /** The holds on each region, bottom first, and the record names; one per page. */\n static readonly #registry = sharedRegistry(\n \"stimeo-ui.state-regions.registry.v1\",\n (): StateRegionsRegistry => ({ stacks: new WeakMap(), names: new Set() }),\n );\n readonly #whenTrue: () => readonly HTMLElement[];\n readonly #whenFalse: (() => readonly HTMLElement[]) | null;\n readonly #record: string;\n\n /**\n * @param options - The declared regions of each side.\n * @param owner - Names the record on a region; the controller's identifier.\n */\n constructor(options: StateRegionsOptions, owner: string) {\n this.#whenTrue = options.whenTrue;\n this.#whenFalse = options.whenFalse ?? null;\n this.#record = `data-${owner}-hidden-region`;\n StateRegions.#registry.names.add(this.#record);\n }\n\n /** Shows the regions inside `host` that belong to `isTrue` and hides the others. */\n reflect(host: Element, isTrue: boolean): void {\n const shown = this.#inside(host, this.#whenTrue());\n if (!this.#whenFalse) {\n for (const region of shown) this.#write(region, !isTrue);\n return;\n }\n const hiddenSide = this.#inside(host, this.#whenFalse());\n if (shown.length === 0 || hiddenSide.length === 0) {\n for (const region of shown) this.#give(region);\n for (const region of hiddenSide) this.#give(region);\n return;\n }\n for (const region of shown) this.#write(region, !isTrue);\n for (const region of hiddenSide) this.#write(region, isTrue);\n }\n\n /**\n * Restores the regions this instance wrote inside `host` to what the hold beneath it wrote last\n * or the authored `hidden`, unless changed since; found by scan, as the declared lists stop\n * resolving with targets.\n */\n release(host: Element): void {\n for (const region of [host, ...host.querySelectorAll(\"*\")]) {\n if (!(region instanceof HTMLElement)) continue;\n const stack = this.#held(region);\n const hold = stack && this.#take(stack);\n if (!stack || !hold) continue;\n const owns = region.hidden === hold.written && !this.#covered(region, stack, hold);\n const index = stack.indexOf(hold);\n stack.splice(index, 1);\n const above = stack[index];\n if (above) above.linked &&= hold.linked;\n if (owns) {\n const below = hold.linked ? stack[index - 1] : undefined;\n if (below) {\n if (region.hidden !== below.written) region.hidden = below.written;\n } else if (region.getAttribute(\"hidden\") !== hold.authored) {\n if (hold.authored === null) region.removeAttribute(\"hidden\");\n else region.setAttribute(\"hidden\", hold.authored);\n }\n }\n this.#mark(region, stack);\n }\n }\n\n /** Writes `hidden` where it moves, unless a hold above this one carries the region's. */\n #write(region: HTMLElement, hidden: boolean): void {\n const stack = this.#stack(region);\n const hold = this.#take(stack) ?? this.#acquire(region, stack);\n const shows = !this.#covered(region, stack, hold);\n hold.written = hidden;\n if (shows && region.hidden !== hidden) region.hidden = hidden;\n this.#mark(region, stack);\n }\n\n /** Returns a region this instance hid; one it never hid keeps what it carries. */\n #give(region: HTMLElement): void {\n const stack = this.#held(region);\n if (stack && this.#take(stack)?.written) this.#write(region, false);\n }\n\n /** The region's stack, while it has one or carries this owner's record. */\n #held(region: HTMLElement): RegionHold[] | undefined {\n return StateRegions.#registry.stacks.has(region) || region.hasAttribute(this.#record)\n ? this.#stack(region)\n : undefined;\n }\n\n /** The region's stack, read from its records the first time. */\n #stack(region: HTMLElement): RegionHold[] {\n const stacks = StateRegions.#registry.stacks;\n const stack = stacks.get(region) ?? this.#seed(region);\n stacks.set(region, stack);\n return stack;\n }\n\n /** The holds a copy's records describe, each above every hold its record lists beneath. */\n #seed(region: HTMLElement): RegionHold[] {\n const found: (RegionRecord & { readonly record: string })[] = [];\n for (const record of StateRegions.#registry.names) {\n const read = this.#recorded(region, record);\n if (read) found.push({ ...read, record });\n }\n const depth = ({ beneath }: (typeof found)[number]) =>\n beneath.filter((name) => found.some((other) => other.record === name)).length;\n return found\n .sort((one, other) => depth(one) - depth(other))\n .map(({ record, authored, written, linked }, index) => ({\n instance: null,\n record,\n authored,\n written,\n linked: linked && index > 0,\n }));\n }\n\n /** Its hold in `stack`, taking over one read from its record. */\n #take(stack: RegionHold[]): RegionHold | undefined {\n const hold =\n stack.find((held) => held.instance === this) ??\n stack.find((held) => held.instance === null && held.record === this.#record);\n if (hold) hold.instance = this;\n return hold;\n }\n\n /** Whether a hold above `hold` carries the region's visibility, then that hold's. */\n #covered(region: HTMLElement, stack: readonly RegionHold[], hold: RegionHold): boolean {\n return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === region.hidden);\n }\n\n /** A new hold on top, over the top hold while the region shows what it wrote. */\n #acquire(region: HTMLElement, stack: RegionHold[]): RegionHold {\n const top = stack.at(-1);\n const over = top && region.hidden === top.written ? top : undefined;\n const hold: RegionHold = {\n instance: this,\n record: this.#record,\n authored: over ? over.authored : region.getAttribute(\"hidden\"),\n written: false,\n linked: over !== undefined,\n };\n stack.push(hold);\n return hold;\n }\n\n /** Leaves each owner's record of its topmost hold, or none where nothing needs one. */\n #mark(region: HTMLElement, stack: readonly RegionHold[]): void {\n const records = new Map<string, string | null>([[this.#record, null]]);\n stack.forEach((hold, index) => {\n const names = stack.slice(0, index).map((under) => under.record);\n const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);\n const marker = hold.linked || beneath.length === 0 ? [] : [false];\n records.set(\n hold.record,\n region.getAttribute(\"hidden\") === hold.authored &&\n beneath.length === 0 &&\n index === stack.length - 1\n ? null\n : JSON.stringify([hold.authored, hold.written, ...marker, ...beneath]),\n );\n });\n for (const [name, recorded] of records) {\n if (region.getAttribute(name) === recorded) continue;\n if (recorded === null) region.removeAttribute(name);\n else region.setAttribute(name, recorded);\n }\n }\n\n /**\n * The author's `hidden`, the visibility written last, whether it hands back the visibility\n * beneath it (`false` before the names when it does not) and the records beneath that the\n * record `name` on `region` holds.\n */\n #recorded(region: HTMLElement, name: string): RegionRecord | null {\n try {\n const parsed: unknown = JSON.parse(region.getAttribute(name) ?? \"null\");\n if (!Array.isArray(parsed)) return null;\n const [authored, written, ...rest] = parsed as unknown[];\n if (authored !== null && typeof authored !== \"string\") return null;\n const linked = rest[0] !== false;\n const beneath = linked ? rest : rest.slice(1);\n if (!beneath.every((under): under is string => typeof under === \"string\")) return null;\n return typeof written === \"boolean\" ? { authored, written, linked, beneath } : null;\n } catch {\n return null;\n }\n }\n\n /** The declared regions that sit within `host`, which may be the host itself. */\n #inside(host: Element, regions: readonly HTMLElement[]): HTMLElement[] {\n return regions.filter((region) => host.contains(region));\n }\n}\n","/**\n * The attribute selector for one declared target, in a controller's own namespace.\n *\n * Stimulus reads `data-<identifier>-target` as a **space-separated token list**, so a\n * single element can carry several target names at once. Matching the attribute value\n * whole would reach only the elements that declare exactly one name, which is why the\n * name is paired with `~=`.\n *\n * `identifier` is the name the controller is registered under, so the selector reaches\n * the markup that registration renders rather than one fixed spelling.\n */\nexport function targetSelector(identifier: string, name: string): string {\n return `[data-${identifier}-target~=\"${name}\"]`;\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { actionSource } from \"../utils/action_source\";\nimport { isReservedArrowChord, logicalArrowStep } from \"../utils/arrow_step\";\nimport { AttributeLease } from \"../utils/attribute_lease\";\nimport { DetachGate } from \"../utils/detach_gate\";\nimport { ownerIndex } from \"../utils/event_owner\";\nimport { ListenerSet } from \"../utils/listener_set\";\nimport { MorphRenderWatcher } from \"../utils/morph_render_watcher\";\nimport { MoveCounter } from \"../utils/move_counter\";\nimport { NUMBER_BOUNDS, type NumberValueConstraints } from \"../utils/number_bounds\";\nimport { NumberValueReader } from \"../utils/number_value\";\nimport { prefersReducedMotion } from \"../utils/reduced_motion\";\nimport { RovingTabindex, rovingMove } from \"../utils/roving_tabindex\";\nimport { SafeInterval } from \"../utils/safe_timeout\";\nimport { type StateReason, stateReasonFor } from \"../utils/state_reason\";\nimport { StateRegions } from \"../utils/state_regions\";\nimport { targetSelector } from \"../utils/target_selector\";\n\n/** Advance delay used when `interval` is not a finite positive number. */\nconst DEFAULT_INTERVAL = 5000;\n\n/**\n * State attributes whose in-place rewrite changes what the carousel shows without\n * any target connecting or disconnecting — the shape a Turbo morph takes when it\n * keeps the elements and swaps only their attributes.\n */\nconst OBSERVED_ATTRIBUTES = [\"aria-selected\", \"data-state\", \"hidden\"];\n\n/**\n * Headless, accessible **Carousel** (slideshow) behavior.\n *\n * Stepping reads the current slide markup and compares with the last published\n * position. Slide and rotation controls settle before notification; synchronous\n * replacement navigation suppresses any older slide confirmation still pending.\n *\n * Markup contract (identifier: `stimeo--carousel`):\n * <section data-controller=\"stimeo--carousel\" aria-roledescription=\"carousel\"\n * aria-label=\"Featured\"\n * data-stimeo--carousel-autoplay-value=\"false\"\n * data-stimeo--carousel-interval-value=\"5000\"\n * data-stimeo--carousel-loop-value=\"true\">\n * <button aria-label=\"Slide autoplay\" data-stimeo--carousel-target=\"playToggle\">\n * <span aria-hidden=\"true\" data-stimeo--carousel-target=\"onLabel\" hidden>Pause</span>\n * <span aria-hidden=\"true\" data-stimeo--carousel-target=\"offLabel\">Play</span>\n * </button>\n * <div data-stimeo--carousel-target=\"viewport\">\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\">…</div>\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\" hidden inert>…</div>\n * </div>\n * <button data-stimeo--carousel-target=\"prev\">‹</button>\n * <button data-stimeo--carousel-target=\"next\">›</button>\n * <div role=\"tablist\">\n * <button role=\"tab\" data-stimeo--carousel-target=\"picker\"></button>\n * </div>\n * </section>\n *\n * Implements the WAI-ARIA APG **Carousel** pattern. With pickers it is the tabbed\n * variant: each picker is a `tab` carrying `aria-selected` and the single roving\n * `tabindex`, and each slide is its `tabpanel`. Without pickers the slides are\n * `group`s and `prev`/`next` drive them. The current slide is exposed through\n * `data-state` (`active`/`inactive`); the rest carry `hidden` **and** `inert`, so\n * they stay out of the focus order and the accessibility tree even when consumer\n * CSS overrides `display` to lay the slides out as a track.\n *\n * @remarks\n * Behavior only — transitions, layout, and visuals are the consumer's CSS.\n *\n * **The controller owns its own wiring.** Clicks, picker keys, hover, and focus\n * are delegated from the controller element, so no `data-action` is required and\n * a target added at runtime works the moment it appears. Explicit `data-action`\n * bindings to the declared actions still work and coexist with the delegated\n * path: the binding runs first and marks the event, and the delegated listener\n * stands down, so one interaction is never handled twice.\n *\n * **`autoplay` is the single source of truth for the rotation intent.** The\n * toggle writes back to it, so the state survives a Turbo Drive cache restore\n * without a second, competing signal; `aria-pressed` is a pure output the\n * controller owns, as is the `onLabel`/`offLabel` pair a toggle may carry: each\n * toggle shows the half its rotation state belongs to, and a half with no partner\n * inside the same toggle keeps the visibility the consumer authored. The toggle's\n * name comes from `aria-label` and holds in both states, so the pair is a visual\n * affordance the accessibility tree does not read. Rotation is suspended — not\n * cancelled — while the pointer rests on the carousel, while focus is inside it,\n * and while the tab is hidden; each suspension lifts on its own (WCAG 2.2.2 is met\n * by the toggle, which is the one control that stops rotation for good). A carousel\n * with nothing left to advance to (one slide, or the last slide of a non-looping\n * set) shows the intent as off and marks the toggle `aria-disabled`, without\n * rewriting `autoplay`: once a slide lies ahead again, the intent takes effect\n * again. `prefers-reduced-motion` holds back the intent `autoplay` declares at\n * connect the same way, until the user presses the toggle or the page changes\n * `autoplay`.\n *\n * The rotation ends when the controller really leaves — a Turbo navigation, a\n * removed element, `data-controller` dropping it — and a carousel still in the\n * document hears that end as `pause`. An in-page move reconnects the same\n * instance and keeps the run: no edge, no restarted interval. Picker arrow keys,\n * `Home`, and `End` move focus only (manual activation); slide changes never steal focus\n * from the control the user operated. A slide change the user drove — including an\n * autoplay tick they started — is reported as `stimeo--carousel:change` with\n * `{ index, total, reason }`. `stimeo--carousel:reconcile` carries `{ index, total }`\n * when the controller re-derives the position itself, whether a target came or went or\n * a retained element's state attributes were rewritten in place.\n */\nexport class CarouselController extends Controller<HTMLElement> {\n /** Numeric read boundaries share one reader for this controller instance. */\n readonly #numbers = new NumberValueReader();\n\n /** Identifies the latest published state transition. */\n readonly #moves = new MoveCounter();\n\n static override targets = [\n \"slide\",\n \"viewport\",\n \"prev\",\n \"next\",\n \"picker\",\n \"playToggle\",\n \"onLabel\",\n \"offLabel\",\n ];\n static override values = {\n autoplay: { type: Boolean, default: false },\n interval: { type: Number, default: DEFAULT_INTERVAL },\n loop: { type: Boolean, default: true },\n };\n\n static valueConstraints = {\n interval: NUMBER_BOUNDS.positiveTimer,\n } satisfies NumberValueConstraints<typeof CarouselController.values>;\n static actions = [\n \"goto\",\n \"next\",\n \"onPickerKeydown\",\n \"pause\",\n \"prev\",\n \"resume\",\n \"togglePlay\",\n ] as const;\n static events = [\"change\", \"pause\", \"play\", \"reconcile\"] as const;\n\n declare readonly slideTargets: HTMLElement[];\n declare readonly pickerTargets: HTMLElement[];\n declare readonly viewportTarget: HTMLElement;\n declare readonly viewportTargets: HTMLElement[];\n declare readonly hasViewportTarget: boolean;\n declare readonly prevTargets: HTMLElement[];\n declare readonly nextTargets: HTMLElement[];\n declare readonly playToggleTargets: HTMLElement[];\n declare readonly onLabelTargets: HTMLElement[];\n declare readonly offLabelTargets: HTMLElement[];\n declare autoplayValue: boolean;\n declare intervalValue: number;\n declare loopValue: boolean;\n\n readonly #roving = new RovingTabindex(() => this.pickerTargets);\n readonly #reconcileTargets = new MorphRenderWatcher(() => this.#reconcileTargetSet());\n readonly #intervals = new SafeInterval();\n /** Unreachable step controls and the toggle of a carousel that cannot rotate. */\n readonly #ariaDisabled = new AttributeLease<HTMLElement>(\"aria-disabled\", this.identifier);\n /** The play toggle's pressed state, a pure output of the rotation intent. */\n readonly #ariaPressed = new AttributeLease<HTMLElement>(\"aria-pressed\", this.identifier);\n /** The slide container's live-region politeness, which tracks the rotation. */\n readonly #ariaLive = new AttributeLease<HTMLElement>(\"aria-live\", this.identifier);\n /** Pairs with {@link CarouselController.#ariaLive}: only the changed slide is read. */\n readonly #ariaAtomic = new AttributeLease<HTMLElement>(\"aria-atomic\", this.identifier);\n /** The label pair a play toggle may carry, one half per rotation state. */\n readonly #labels = new StateRegions(\n {\n whenTrue: () => this.onLabelTargets,\n whenFalse: () => this.offLabelTargets,\n },\n this.identifier,\n );\n /** Tells an in-page move, which keeps the rotation, from a real detach. */\n readonly #gate = new DetachGate();\n /** The next pointer movement, listened for while a pointer suspension waits on it. */\n readonly #pointer = new ListenerSet();\n /**\n * Events an authored action binding already took. The delegated listener runs\n * later — it sits on the controller element, above every control — so it can\n * consume the mark and stand down, letting the two wirings coexist without\n * handling one interaction twice.\n */\n readonly #handledEvents = new WeakSet<Event>();\n\n /**\n * Whether `connect()` has run. Scheduling is already inert outside that window\n * (`MorphRenderWatcher`), so this gates the Value callbacks Stimulus\n * delivers ahead of `connect()`.\n */\n #connected = false;\n /** Index of the visible slide. */\n #index = 0;\n /** The visible slide element, which identifies it across a changing target set. */\n #activeSlide: HTMLElement | null = null;\n /** Slide count at the last resolved state, so a changed total is reportable. */\n #total = 0;\n /**\n * Pointer rests on the carousel: a suspension that lifts on `mouseleave`, or on the\n * pointer movement that confirms a suspension a move or a connect left unconfirmed.\n */\n #pointerPaused = false;\n /** Focus is inside the carousel: a suspension that lifts when it leaves. */\n #focusPaused = false;\n /** The tab is in the background: a suspension that lifts when it returns. */\n #hiddenPaused = false;\n /** Reduced motion holds back the intent declared at connect, until a press or a new one. */\n #motionHold = false;\n /** Id of the live autoplay interval, or null when stopped. */\n #timerId: number | null = null;\n /** Delay the live interval was armed with, so an `interval` change re-arms it. */\n #timerInterval = 0;\n /** Follows state-attribute rewrites on retained slides and pickers. */\n #observer: MutationObserver | null = null;\n\n /** Keeps a hidden tab from advancing behind the user's back. */\n readonly #onVisibilityChange = (): void => {\n this.#hiddenPaused = document.visibilityState === \"hidden\";\n this.#syncTimer();\n };\n\n /**\n * Renders the initial slide, wires the delegated listeners, and starts autoplay\n * when requested.\n *\n * Focus, the tab's visibility and the reduced-motion hold are read afresh. The\n * pointer is not something the document can answer yet: no `mouseleave` reaches a\n * node that moved, and `:hover` can answer from before the move until the pointer\n * moves again. So an in-page move — which Stimulus delivers to the *same* controller\n * instance as `disconnect()` then `connect()` — keeps the pointer suspension it had,\n * `:hover` reading true adds one, and either waits for the next pointer movement to\n * be confirmed or lifted. A rotation the move carried is still running, so the edges\n * are judged against it. The attribute observer starts after the first render so the\n * controller's own opening writes are not fed back to it.\n */\n override connect(): void {\n const moved = this.#gate.pending;\n this.#gate.cancel();\n this.#pointerPaused = (moved && this.#pointerPaused) || this.element.matches(\":hover\");\n if (this.#pointerPaused) this.#awaitPointer();\n this.#focusPaused = this.element.contains(document.activeElement);\n this.#hiddenPaused = document.visibilityState === \"hidden\";\n this.#motionHold = prefersReducedMotion();\n this.#index = this.#resolveIndex();\n this.#render({ focus: false });\n this.#total = this.slideTargets.length;\n this.#syncTimer();\n this.#connected = true;\n this.#reconcileTargets.observe(this.element);\n\n this.element.addEventListener(\"click\", this.#onClick);\n this.element.addEventListener(\"keydown\", this.#onKeydown);\n this.element.addEventListener(\"focusin\", this.#onFocusin);\n this.element.addEventListener(\"focusout\", this.#onFocusout);\n this.element.addEventListener(\"mouseenter\", this.#onMouseenter);\n this.element.addEventListener(\"mouseleave\", this.#onMouseleave);\n document.addEventListener(\"visibilitychange\", this.#onVisibilityChange);\n this.#observer = new MutationObserver(this.#onAttributeMutations);\n this.#observer.observe(this.element, {\n subtree: true,\n attributes: true,\n attributeFilter: OBSERVED_ATTRIBUTES,\n });\n }\n\n /**\n * Releases every listener and observer, returns the leased ARIA, drops the focus\n * and tab suspensions. The rotation goes through the detach gate: a reconnect in\n * the same batch — an in-page move — keeps it, and the pointer suspension with it;\n * anything else ends it.\n */\n override disconnect(): void {\n this.#connected = false;\n this.#pointer.dispose();\n this.element.removeEventListener(\"click\", this.#onClick);\n this.element.removeEventListener(\"keydown\", this.#onKeydown);\n this.element.removeEventListener(\"focusin\", this.#onFocusin);\n this.element.removeEventListener(\"focusout\", this.#onFocusout);\n this.element.removeEventListener(\"mouseenter\", this.#onMouseenter);\n this.element.removeEventListener(\"mouseleave\", this.#onMouseleave);\n document.removeEventListener(\"visibilitychange\", this.#onVisibilityChange);\n this.#observer?.disconnect();\n this.#observer = null;\n this.#reconcileTargets.disconnect();\n this.#focusPaused = false;\n this.#hiddenPaused = false;\n this.#activeSlide = null;\n this.#returnLeases();\n this.#gate.disconnected(this, () => this.#endRun());\n }\n\n /**\n * Re-establishes the single selected picker when one is added after connect.\n *\n * Without this an appended picker that arrives `aria-selected=\"true\"` leaves two\n * marked at once — the authored pre-selection is only read on connect, so\n * nothing else ever resolves the conflict. The current slide is kept: the\n * repaint re-derives every picker from `#index`, so a late arrival never steals\n * the selection.\n */\n pickerTargetConnected(picker: HTMLElement): void {\n picker.tabIndex = -1;\n this.#reconcileTargets.schedule();\n }\n\n /** Repairs selection and roving after a picker leaves a retained carousel. */\n pickerTargetDisconnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Reconciles a slide added in the same DOM batch as its picker. */\n slideTargetConnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Re-clamps the active index after a slide is removed. */\n slideTargetDisconnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Publishes the live region on a viewport that joins a connected carousel. */\n viewportTargetConnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /**\n * Gives a viewport that no longer resolves its own live region back, even after\n * `disconnect()`, and republishes it on the viewport that stays.\n */\n viewportTargetDisconnected(viewport: HTMLElement): void {\n if (!this.viewportTargets.includes(viewport)) {\n this.#ariaLive.return(viewport);\n this.#ariaAtomic.return(viewport);\n }\n this.#reconcileTargets.schedule();\n }\n\n /**\n * Gives a toggle that no longer resolves as one its label pair, its `aria-disabled` and\n * its `aria-pressed` back, even after `disconnect()`.\n */\n playToggleTargetDisconnected(toggle: HTMLElement): void {\n if (this.playToggleTargets.includes(toggle)) return;\n this.#labels.release(toggle);\n this.#ariaDisabled.return(toggle);\n this.#ariaPressed.return(toggle);\n }\n\n /** Gives a button that no longer resolves as a `prev` control its `aria-disabled` back. */\n prevTargetDisconnected(button: HTMLElement): void {\n if (!this.prevTargets.includes(button)) this.#ariaDisabled.return(button);\n }\n\n /** Gives a button that no longer resolves as a `next` control its `aria-disabled` back. */\n nextTargetDisconnected(button: HTMLElement): void {\n if (!this.nextTargets.includes(button)) this.#ariaDisabled.return(button);\n }\n\n /**\n * Publishes the rotation state on a toggle that joins a connected carousel.\n *\n * A toggle the markup already carries connects ahead of `connect()`, where the\n * suspensions and the reduced-motion hold are not settled yet; the opening pass\n * covers it.\n */\n playToggleTargetConnected(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /**\n * Publishes the rotation state on a label half that joins a connected toggle.\n *\n * A half arriving changes the toggle's subtree, not its attributes, so the\n * attribute observer never sees it; where the arrival completes a pair that was\n * standing alone, this is what makes that pair whole and reflectable.\n */\n onLabelTargetConnected(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /** Publishes the rotation state on a label half that joins a connected toggle. */\n offLabelTargetConnected(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /** Follows a rotation intent the page changed at runtime, lifting the reduced-motion hold. */\n autoplayValueChanged(): void {\n if (!this.#connected) return;\n this.#motionHold = false;\n this.#syncTimer();\n }\n\n /** Re-arms the live interval at the new delay without reporting a state change. */\n intervalValueChanged(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /**\n * Re-publishes the step controls and re-evaluates the non-looping end through the\n * reconcile pass, which reports a move only when the position changed.\n */\n loopValueChanged(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Advances to the next slide. Delegated; `data-action` wiring is optional. */\n next(event?: Event): void {\n if (event?.defaultPrevented) return;\n this.#markHandled(event);\n this.#select(this.#step(1), { focus: false }, stateReasonFor(event));\n }\n\n /** Returns to the previous slide. Delegated; `data-action` wiring is optional. */\n prev(event?: Event): void {\n if (event?.defaultPrevented) return;\n this.#markHandled(event);\n this.#select(this.#step(-1), { focus: false }, stateReasonFor(event));\n }\n\n /** Jumps to the slide of an owned picker or descendant, without moving DOM focus. */\n goto(source: Event | HTMLElement): void {\n const { event, host, origin, reason } = actionSource(source);\n if (origin && origin.closest(`[data-controller~=\"${this.identifier}\"]`) !== this.element)\n return;\n if (event?.defaultPrevented) return;\n const picker = host?.closest<HTMLElement>(targetSelector(this.identifier, \"picker\"));\n if (!picker || !this.pickerTargets.includes(picker)) return;\n this.#markHandled(event ?? undefined);\n this.#select(this.pickerTargets.indexOf(picker), { focus: false }, reason);\n }\n\n /**\n * Flips the rotation intent the toggle shows, on the user's explicit request.\n *\n * The result is written to the `autoplay` Value, which is where every other path\n * reads it from. A carousel with nothing to advance to has no intent to flip: the\n * toggle is marked `aria-disabled` and does nothing.\n */\n togglePlay(event?: Event): void {\n if (event?.defaultPrevented) return;\n this.#markHandled(event);\n this.#togglePlay();\n }\n\n /**\n * Suspends rotation. A `focus`-family event records that focus is inside the\n * carousel; anything else — hover, or a bare programmatic call — records the\n * pointer suspension. Both lift through the matching {@link resume}, and\n * neither touches the rotation intent.\n */\n pause(event?: Event): void {\n this.#markHandled(event);\n if (isFocusEvent(event)) this.#focusPaused = true;\n else this.#setPointerPaused(true);\n this.#syncTimer();\n }\n\n /**\n * Lifts the matching suspension. A `focusout` whose `relatedTarget` is still\n * inside the carousel is focus moving between its own controls, which leaves the\n * focus suspension in place — releasing it there would stop and restart the\n * interval on every Tab press.\n */\n resume(event?: Event): void {\n this.#markHandled(event);\n if (isFocusEvent(event)) {\n if (this.#focusStaysInside(event)) return;\n this.#focusPaused = false;\n } else {\n this.#setPointerPaused(false);\n }\n this.#syncTimer();\n }\n\n /** Picker roving for authored bindings; the delegated path is `#onKeydown`. */\n onPickerKeydown(event: KeyboardEvent): void {\n const index = this.#pickerIndexFor(event.currentTarget);\n if (index === -1) return;\n this.#markHandled(event);\n this.#handlePickerKeydown(event, index);\n }\n\n /** Delegated activation for pickers and step controls without authored actions. */\n readonly #onClick = (event: MouseEvent): void =>\n this.#delegate(event, () => {\n const index = this.#pickerIndexFor(event.target);\n if (index !== -1) {\n this.#select(index, { focus: false });\n } else if (hits(this.nextTargets, event.target)) {\n this.#select(this.#step(1), { focus: false });\n } else if (hits(this.prevTargets, event.target)) {\n this.#select(this.#step(-1), { focus: false });\n } else if (hits(this.playToggleTargets, event.target)) {\n this.#togglePlay();\n }\n });\n\n /** Delegated picker roving for pickers without authored actions. */\n readonly #onKeydown = (event: KeyboardEvent): void =>\n this.#delegate(event, () => {\n const index = this.#pickerIndexFor(event.target);\n if (index !== -1) this.#handlePickerKeydown(event, index);\n });\n\n /** Focus arriving anywhere inside suspends the rotation. */\n readonly #onFocusin = (event: FocusEvent): void =>\n this.#delegate(event, () => {\n this.#focusPaused = true;\n this.#syncTimer();\n });\n\n /** Focus genuinely leaving lifts the suspension; moves between own controls do not. */\n readonly #onFocusout = (event: FocusEvent): void =>\n this.#delegate(event, () => {\n if (this.#focusStaysInside(event)) return;\n this.#focusPaused = false;\n this.#syncTimer();\n });\n\n /** Pointer entry suspends the rotation. */\n readonly #onMouseenter = (event: MouseEvent): void =>\n this.#delegate(event, () => {\n this.#setPointerPaused(true);\n this.#syncTimer();\n });\n\n /** Pointer exit lifts the suspension. */\n readonly #onMouseleave = (event: MouseEvent): void =>\n this.#delegate(event, () => {\n this.#setPointerPaused(false);\n this.#syncTimer();\n });\n\n /**\n * Reads `:hover` once the pointer has moved, when the answer is current, and lifts\n * the pointer suspension if the pointer is not over the carousel. Listens once.\n */\n readonly #onPointerMove = (): void => {\n this.#pointer.dispose();\n if (this.element.matches(\":hover\")) return;\n this.#pointerPaused = false;\n this.#syncTimer();\n };\n\n /** Leaves the pointer suspension to be confirmed or lifted on the next pointer movement. */\n #awaitPointer(): void {\n this.#pointer.add(document, \"pointermove\", this.#onPointerMove, {\n capture: true,\n passive: true,\n });\n }\n\n /** Records the pointer suspension; a newer answer ends any wait on the next movement. */\n #setPointerPaused(paused: boolean): void {\n this.#pointer.dispose();\n this.#pointerPaused = paused;\n }\n\n /**\n * Schedules one reconciliation when a state attribute is rewritten in place —\n * the only shape of change no target callback reports.\n *\n * The filter is the `attributeFilter` alone: those three attributes belong to\n * the slides and pickers, and a coalesced pass over an unrelated one costs a\n * repaint that writes nothing. Narrowing further here would add a branch no\n * test could distinguish.\n */\n readonly #onAttributeMutations = (): void => {\n this.#reconcileTargets.schedule();\n };\n\n /**\n * Records that an action binding took this event.\n *\n * An authored binding sits on the control, so it runs while the event is still\n * below the controller element and always precedes the delegated listener.\n * Marking is the one signal that keeps the two wirings from both acting.\n */\n #markHandled(event?: Event): void {\n if (event) this.#handledEvents.add(event);\n }\n\n /** Runs a delegated handler unless an action binding, or a descendant, took the event. */\n #delegate(event: Event, run: () => void): void {\n if (this.#handledEvents.delete(event) || event.defaultPrevented) return;\n run();\n }\n\n /** Position of the picker that is or contains `node`, or `-1` when none does. */\n #pickerIndexFor(node: EventTarget | null): number {\n return ownerIndex(this.pickerTargets, node);\n }\n\n /** Whether a focus transition lands on another control of this same carousel. */\n #focusStaysInside(event: FocusEvent): boolean {\n const next = event.relatedTarget;\n return next instanceof Node && this.element.contains(next);\n }\n\n /** Flips the rotation intent unless there is nothing to rotate to; lifts the motion hold. */\n #togglePlay(): void {\n if (!this.#canAutoplay()) return;\n const next = !this.#intent;\n this.#motionHold = false;\n this.autoplayValue = next;\n this.#syncTimer();\n }\n\n /** Applies the APG picker key map: arrows, Home, and End all move focus only. */\n #handlePickerKeydown(event: KeyboardEvent, current: number): void {\n // A descendant widget that already claimed the key must not ALSO move the\n // picker focus — composition depends on this yield.\n if (event.defaultPrevented) return;\n if (isReservedArrowChord(event)) return;\n\n const length = this.pickerTargets.length;\n // Logical, not physical. The helper reverses only the horizontal\n // pair, so folding Down/Up into the same branch stays correct.\n switch (event.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n case \"ArrowLeft\":\n case \"ArrowUp\": {\n event.preventDefault();\n const step = logicalArrowStep(event.key, this.element);\n this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n return;\n }\n // A chorded Home/End is a document-level shortcut (`Control+Home` scrolls\n // the page) that belongs to the browser, exactly as a chorded arrow does.\n case \"Home\":\n if (hasModifier(event)) return;\n event.preventDefault();\n this.#roving.setActive(0, { focus: true });\n return;\n case \"End\":\n if (hasModifier(event)) return;\n event.preventDefault();\n this.#roving.setActive(length - 1, { focus: true });\n return;\n default:\n }\n }\n\n /**\n * Resolves the index one step away from the current one, honoring `loop`.\n *\n * Bounding is {@link CarouselController.#clampToSlides}'s job alone, so an\n * empty set is allowed to fall out of the arithmetic here rather than being\n * special-cased in two places that could disagree.\n */\n #step(delta: number): number {\n const total = this.slideTargets.length;\n const next = this.#resolveIndex() + delta;\n if (this.loopValue) return (next + total) % total;\n return Math.min(total - 1, Math.max(0, next));\n }\n\n /**\n * Confines an index to the slide range, so no index can hide every slide.\n *\n * The single place an index is bounded: an empty set collapses to the first\n * position, which is also where a non-numeric step from that empty set lands.\n */\n #clampToSlides(index: number): number {\n const last = this.slideTargets.length - 1;\n if (last < 0) return 0;\n return Math.min(last, Math.max(0, index));\n }\n\n /**\n * Changes the active slide, updates state hooks, and emits `change` — but only\n * when the index or total changes, so a `next`/`prev` clamped at the end (or an\n * autoplay tick at a non-looping boundary) re-renders without a spurious event.\n */\n #select(index: number, { focus }: { focus: boolean }, reason: StateReason = \"user\"): void {\n const target = this.#clampToSlides(index);\n const total = this.slideTargets.length;\n const changed = target !== this.#index || total !== this.#total;\n this.#index = target;\n this.#total = total;\n const token = changed ? this.#moves.record() : null;\n this.#render({ focus });\n // Re-evaluate autoplay after every move so reaching the non-looping end stops\n // the timer (see `#syncTimer`); idempotent for moves that don't cross a boundary.\n this.#syncTimer();\n if (token !== null && this.#moves.isLatest(token)) {\n this.dispatch(\"change\", { detail: { index: target, total, reason } });\n }\n }\n\n /**\n * Reflects `this.#index` onto the slides, the pickers, and the step controls.\n *\n * Every observed attribute is written only when its value actually changes: the\n * same writes are watched by {@link CarouselController.#onAttributeMutations},\n * and an unconditional rewrite would feed the controller its own output.\n *\n * @stimeoRenderRoot\n */\n #render({ focus }: { focus: boolean }): void {\n this.#activeSlide = this.slideTargets[this.#index] ?? null;\n this.slideTargets.forEach((slide, i) => {\n const active = i === this.#index;\n setAttributeIfChanged(slide, \"data-state\", active ? \"active\" : \"inactive\");\n if (slide.hidden !== !active) slide.hidden = !active;\n // `hidden` alone is a style a slide track's own CSS overrides; `inert` is not.\n slide.toggleAttribute(\"inert\", !active);\n });\n // The picker set can be shorter than the slide set (a picker removed on its\n // own, or a carousel that only pickers part of its slides). Resolving the\n // selection inside the picker range keeps exactly one selected tab and one Tab\n // stop; an out-of-range index would leave every picker at `tabindex=\"-1\"` and\n // strand the tablist outside the Tab sequence.\n const pickerIndex = Math.min(this.#index, this.pickerTargets.length - 1);\n this.pickerTargets.forEach((picker, i) => {\n setAttributeIfChanged(picker, \"aria-selected\", i === pickerIndex ? \"true\" : \"false\");\n });\n this.#syncStepControls();\n this.#roving.setActive(pickerIndex, { focus });\n }\n\n /** Marks the step control a non-looping carousel has no slide left to reach. */\n #syncStepControls(): void {\n const last = this.slideTargets.length - 1;\n const atStart = !this.loopValue && this.#index <= 0;\n const atEnd = !this.loopValue && this.#index >= last;\n for (const button of this.prevTargets) {\n this.#ariaDisabled.write(button, atStart ? \"true\" : null);\n }\n for (const button of this.nextTargets) {\n this.#ariaDisabled.write(button, atEnd ? \"true\" : null);\n }\n }\n\n /**\n * Resolves which slide is current from the strongest evidence available.\n *\n * A single `data-state=\"active\"` is unambiguous and wins, which is what restores\n * the visible slide after a Turbo cache restore even with no pickers present.\n * Competing claims — a slide inserted already marked active — are settled by the\n * element the last render actually showed, so a newcomer never displaces what the\n * reader is looking at. With no claim at all the authored picker selection\n * decides, first in DOM order; failing that the previous position is kept.\n */\n #resolveIndex(): number {\n const slides = this.slideTargets;\n const claims: number[] = [];\n slides.forEach((slide, index) => {\n if (slide.getAttribute(\"data-state\") === \"active\") claims.push(index);\n });\n if (claims.length > 1 && this.#activeSlide !== null) {\n const live = slides.indexOf(this.#activeSlide);\n if (claims.includes(live)) return live;\n }\n const claimed = claims[0];\n if (claimed !== undefined) return claimed;\n\n const selected = this.pickerTargets.findIndex(\n (picker) => picker.getAttribute(\"aria-selected\") === \"true\",\n );\n return this.#clampToSlides(selected === -1 ? this.#index : selected);\n }\n\n /** Re-resolves the active slide after the target set changed and reports the move. */\n #reconcileTargetSet(): void {\n const previousIndex = this.#index;\n const previousTotal = this.#total;\n this.#index = this.#resolveIndex();\n this.#total = this.slideTargets.length;\n const changed = this.#index !== previousIndex || this.#total !== previousTotal;\n const token = changed ? this.#moves.record() : null;\n this.#render({ focus: false });\n this.#syncTimer();\n // `change` stays reserved for user navigation; re-resolving onto a surviving\n // slide, or reporting a set that grew or shrank, is this controller's decision.\n if (token !== null && this.#moves.isLatest(token)) {\n this.dispatch(\"reconcile\", { detail: { index: this.#index, total: this.#total } });\n }\n }\n\n /** The rotation intent in effect: `autoplay`, unless reduced motion holds it back. */\n get #intent(): boolean {\n return this.autoplayValue && !this.#motionHold;\n }\n\n /** Whether autoplay has anywhere left to advance to. */\n #canAutoplay(): boolean {\n const total = this.slideTargets.length;\n if (total <= 1) return false;\n return this.loopValue || this.#index < total - 1;\n }\n\n /** The advance delay; a non-finite or non-positive declaration falls back. */\n get #interval(): number {\n return this.#safeInterval;\n }\n\n /**\n * Drives the autoplay interval toward the desired state and publishes it.\n *\n * Rotation runs when the intent is on, nothing suspends it, and a slide is left\n * to advance to. The toggle shows the intent only while a slide is left, so\n * `aria-pressed` never claims a rotation that cannot happen. This body reads\n * `autoplay` and never writes it, so the declared intent returns once a slide\n * lies ahead again. Crossing the run/stop boundary emits `play`/`pause`;\n * re-arming at a new `interval` is the same state and stays silent.\n *\n * @stimeoRenderRoot\n */\n #syncTimer(): void {\n const canAutoplay = this.#canAutoplay();\n const pressed = this.#intent && canAutoplay;\n const shouldRun = pressed && !this.#pointerPaused && !this.#focusPaused && !this.#hiddenPaused;\n const wasRunning = this.#timerId !== null;\n const interval = this.#interval;\n\n if (this.#timerId !== null && (!shouldRun || interval !== this.#timerInterval)) {\n this.#intervals.clear(this.#timerId);\n this.#timerId = null;\n }\n if (shouldRun && this.#timerId === null) {\n this.#timerInterval = interval;\n this.#timerId = this.#intervals.set(\n () => this.#select(this.#step(1), { focus: false }, \"timeout\"),\n interval,\n );\n }\n // The events are edges. A consumer that subscribes after `connect()` — which\n // is every consumer on a Turbo restore, where the controller reconnects before\n // the page's own scripts run again — would miss the transition it arrived in\n // the middle of, so the same state is published as a hook it can read.\n setAttributeIfChanged(this.element, \"data-state\", shouldRun ? \"playing\" : \"paused\");\n for (const toggle of this.playToggleTargets) {\n this.#ariaPressed.write(toggle, pressed ? \"true\" : \"false\");\n this.#ariaDisabled.write(toggle, canAutoplay ? null : \"true\");\n this.#labels.reflect(toggle, pressed);\n }\n if (this.hasViewportTarget) {\n this.#ariaLive.write(this.viewportTarget, shouldRun ? \"off\" : \"polite\");\n this.#ariaAtomic.write(this.viewportTarget, \"false\");\n }\n if (shouldRun !== wasRunning) {\n if (shouldRun) this.dispatch(\"play\");\n else this.dispatch(\"pause\");\n }\n }\n\n /**\n * Ends the rotation once the controller has really left. A carousel still in\n * the document hears the end — `pause`, and `data-state=\"paused\"` — so no `play`\n * it reported is left without one; a detached tree keeps the markup it had.\n */\n #endRun(): void {\n const wasRunning = this.#timerId !== null;\n this.#intervals.clearAll();\n this.#timerId = null;\n if (!wasRunning || !this.element.isConnected) return;\n setAttributeIfChanged(this.element, \"data-state\", \"paused\");\n this.dispatch(\"pause\");\n }\n\n /** Hands every leased attribute back to the value the consumer authored. */\n #returnLeases(): void {\n this.#ariaDisabled.returnAll();\n this.#ariaPressed.returnAll();\n this.#ariaLive.returnAll();\n this.#ariaAtomic.returnAll();\n }\n /** Current `interval` declaration resolved against its numeric contract. */\n get #safeInterval(): number {\n return this.#numbers.read(\n this,\n \"interval\",\n this.intervalValue,\n CarouselController.values.interval.default,\n CarouselController.valueConstraints.interval,\n );\n }\n}\n\n/** Whether an event names a focus transition rather than a pointer one. */\nfunction isFocusEvent(event?: Event): event is FocusEvent {\n return event?.type.startsWith(\"focus\") === true;\n}\n\n/** Whether a key arrived with a modifier that makes it the browser's shortcut. */\nfunction hasModifier(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n\n/** Whether `node` is one of `elements` or sits inside one. */\nfunction hits(elements: readonly HTMLElement[], node: EventTarget | null): boolean {\n return ownerIndex(elements, node) !== -1;\n}\n\n/** Writes an attribute only on a real transition, so an observer sees no self-echo. */\nfunction setAttributeIfChanged(element: Element, name: string, value: string): void {\n if (element.getAttribute(name) !== value) element.setAttribute(name, value);\n}\n"]}