@eifi1/ui-kit 0.51.7 → 0.52.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 (746) hide show
  1. package/README.md +141 -23
  2. package/dist/account/account-parts.d.ts +10 -8
  3. package/dist/account/account-parts.js +1 -18
  4. package/dist/account/account-parts.js.map +1 -1
  5. package/dist/account/data-export-setting-labels.js +1 -1
  6. package/dist/account/data-export-setting-labels.js.map +1 -1
  7. package/dist/account/delete-account-setting-labels.js +1 -1
  8. package/dist/account/delete-account-setting-labels.js.map +1 -1
  9. package/dist/account/email-change-setting-labels.js +1 -1
  10. package/dist/account/email-change-setting-labels.js.map +1 -1
  11. package/dist/account/passkeys-setting.d.ts +9 -2
  12. package/dist/account/passkeys-setting.js +41 -29
  13. package/dist/account/passkeys-setting.js.map +1 -1
  14. package/dist/account/sessions-setting.d.ts +3 -2
  15. package/dist/account/sessions-setting.js +10 -8
  16. package/dist/account/sessions-setting.js.map +1 -1
  17. package/dist/admin/admin-action-confirm.js +1 -3
  18. package/dist/admin/admin-action-confirm.js.map +1 -1
  19. package/dist/admin/admin-parts.d.ts +6 -3
  20. package/dist/admin/admin-parts.js +6 -21
  21. package/dist/admin/admin-parts.js.map +1 -1
  22. package/dist/admin/mail-test-card-labels.js +1 -1
  23. package/dist/admin/mail-test-card-labels.js.map +1 -1
  24. package/dist/admin/plan-change-labels.d.ts +2 -2
  25. package/dist/admin/plan-change-labels.js +1 -17
  26. package/dist/admin/plan-change-labels.js.map +1 -1
  27. package/dist/admin/plan-change.d.ts +3 -42
  28. package/dist/admin/plan-change.js +1 -1
  29. package/dist/admin/plan-change.js.map +1 -1
  30. package/dist/admin/reviewer-scope-editor.js +3 -3
  31. package/dist/admin/reviewer-scope-editor.js.map +1 -1
  32. package/dist/auth/auth-errors-labels.d.ts +11 -0
  33. package/dist/auth/auth-errors-labels.js +13 -0
  34. package/dist/auth/auth-errors-labels.js.map +1 -0
  35. package/dist/auth/auth-errors.d.ts +7 -23
  36. package/dist/auth/auth-errors.js +2 -15
  37. package/dist/auth/auth-errors.js.map +1 -1
  38. package/dist/auth/complete-name-dialog.js +2 -1
  39. package/dist/auth/complete-name-dialog.js.map +1 -1
  40. package/dist/auth/forgot-password-form-labels.js +1 -1
  41. package/dist/auth/forgot-password-form-labels.js.map +1 -1
  42. package/dist/auth/forgot-password-form.js +7 -2
  43. package/dist/auth/forgot-password-form.js.map +1 -1
  44. package/dist/auth/register-form-labels.js +1 -1
  45. package/dist/auth/register-form-labels.js.map +1 -1
  46. package/dist/auth/reset-password-form-labels.js +1 -1
  47. package/dist/auth/reset-password-form-labels.js.map +1 -1
  48. package/dist/auth/reset-password-form.js +5 -1
  49. package/dist/auth/reset-password-form.js.map +1 -1
  50. package/dist/auth/sign-in-form-labels.js +1 -1
  51. package/dist/auth/sign-in-form-labels.js.map +1 -1
  52. package/dist/auth/status-parts.d.ts +0 -3
  53. package/dist/auth/status-parts.js +0 -4
  54. package/dist/auth/status-parts.js.map +1 -1
  55. package/dist/auth/verify-email-labels.js +1 -1
  56. package/dist/auth/verify-email-labels.js.map +1 -1
  57. package/dist/auth/verify-email.js +7 -2
  58. package/dist/auth/verify-email.js.map +1 -1
  59. package/dist/billing/cancel-subscription.d.ts +20 -8
  60. package/dist/billing/cancel-subscription.js +7 -5
  61. package/dist/billing/cancel-subscription.js.map +1 -1
  62. package/dist/billing/dialog-close.d.ts +29 -0
  63. package/dist/billing/dialog-close.js +8 -0
  64. package/dist/billing/dialog-close.js.map +1 -0
  65. package/dist/billing/plan-card.d.ts +14 -4
  66. package/dist/billing/plan-card.js +15 -8
  67. package/dist/billing/plan-card.js.map +1 -1
  68. package/dist/billing/plan-change-labels.d.ts +42 -0
  69. package/dist/billing/plan-change-labels.js +22 -0
  70. package/dist/billing/plan-change-labels.js.map +1 -0
  71. package/dist/billing/plan-switch.d.ts +19 -7
  72. package/dist/billing/plan-switch.js +8 -4
  73. package/dist/billing/plan-switch.js.map +1 -1
  74. package/dist/chart.d.ts +12 -0
  75. package/dist/chart.js +16 -1
  76. package/dist/chart.js.map +1 -1
  77. package/dist/components/account-chips.d.ts +5 -5
  78. package/dist/components/account-chips.js +11 -13
  79. package/dist/components/account-chips.js.map +1 -1
  80. package/dist/components/alert-banner.d.ts +16 -5
  81. package/dist/components/alert-banner.js +46 -1
  82. package/dist/components/alert-banner.js.map +1 -1
  83. package/dist/components/amount-input.d.ts +13 -0
  84. package/dist/components/amount-input.js +1 -0
  85. package/dist/components/amount-input.js.map +1 -1
  86. package/dist/components/autocomplete.js +57 -65
  87. package/dist/components/autocomplete.js.map +1 -1
  88. package/dist/components/bulk-action-bar.d.ts +12 -2
  89. package/dist/components/bulk-action-bar.js +65 -21
  90. package/dist/components/bulk-action-bar.js.map +1 -1
  91. package/dist/components/button-look.d.ts +5 -5
  92. package/dist/components/button-look.js.map +1 -1
  93. package/dist/components/button.d.ts +2 -2
  94. package/dist/components/button.js.map +1 -1
  95. package/dist/components/chart-edge.d.ts +16 -0
  96. package/dist/components/chart-edge.js +14 -1
  97. package/dist/components/chart-edge.js.map +1 -1
  98. package/dist/components/chart-figure.d.ts +13 -0
  99. package/dist/components/chart-figure.js +15 -0
  100. package/dist/components/chart-figure.js.map +1 -0
  101. package/dist/components/chart-zoom-core.js +1 -4
  102. package/dist/components/chart-zoom-core.js.map +1 -1
  103. package/dist/components/chart.d.ts +8 -1
  104. package/dist/components/chart.js +19 -10
  105. package/dist/components/chart.js.map +1 -1
  106. package/dist/components/combobox-core.d.ts +111 -2
  107. package/dist/components/combobox-core.js +148 -42
  108. package/dist/components/combobox-core.js.map +1 -1
  109. package/dist/components/combobox.d.ts +1 -1
  110. package/dist/components/combobox.js +141 -130
  111. package/dist/components/combobox.js.map +1 -1
  112. package/dist/components/copy-button.d.ts +6 -5
  113. package/dist/components/copy-button.js +5 -3
  114. package/dist/components/copy-button.js.map +1 -1
  115. package/dist/components/country-select.js +2 -2
  116. package/dist/components/country-select.js.map +1 -1
  117. package/dist/components/data-table-column-settings.d.ts +1 -1
  118. package/dist/components/data-table-column-settings.js +33 -7
  119. package/dist/components/data-table-column-settings.js.map +1 -1
  120. package/dist/components/data-table-filters.d.ts +4 -2
  121. package/dist/components/data-table-filters.js +2 -2
  122. package/dist/components/data-table-filters.js.map +1 -1
  123. package/dist/components/data-table-fit.d.ts +6 -4
  124. package/dist/components/data-table-fit.js +4 -1
  125. package/dist/components/data-table-fit.js.map +1 -1
  126. package/dist/components/data-table-groups.d.ts +1 -1
  127. package/dist/components/data-table-groups.js.map +1 -1
  128. package/dist/components/data-table-head.d.ts +1 -1
  129. package/dist/components/data-table-head.js +15 -12
  130. package/dist/components/data-table-head.js.map +1 -1
  131. package/dist/components/data-table-mobile.d.ts +12 -7
  132. package/dist/components/data-table-mobile.js +43 -30
  133. package/dist/components/data-table-mobile.js.map +1 -1
  134. package/dist/components/data-table-pagination.js +11 -6
  135. package/dist/components/data-table-pagination.js.map +1 -1
  136. package/dist/components/data-table-resize.d.ts +1 -1
  137. package/dist/components/data-table-resize.js.map +1 -1
  138. package/dist/components/data-table-row-actions.d.ts +2 -2
  139. package/dist/components/data-table-row-actions.js.map +1 -1
  140. package/dist/components/data-table-row.d.ts +6 -2
  141. package/dist/components/data-table-row.js +17 -10
  142. package/dist/components/data-table-row.js.map +1 -1
  143. package/dist/components/data-table-selection.d.ts +1 -1
  144. package/dist/components/data-table-selection.js.map +1 -1
  145. package/dist/components/data-table-shared.d.ts +10 -2
  146. package/dist/components/data-table-shared.js +18 -0
  147. package/dist/components/data-table-shared.js.map +1 -1
  148. package/dist/components/data-table-sort.d.ts +21 -2
  149. package/dist/components/data-table-sort.js +24 -0
  150. package/dist/components/data-table-sort.js.map +1 -1
  151. package/dist/components/data-table-virtual.d.ts +1 -1
  152. package/dist/components/data-table-virtual.js +18 -6
  153. package/dist/components/data-table-virtual.js.map +1 -1
  154. package/dist/components/data-table.d.ts +13 -4
  155. package/dist/components/data-table.js +139 -36
  156. package/dist/components/data-table.js.map +1 -1
  157. package/dist/components/date-field.d.ts +24 -2
  158. package/dist/components/date-field.js +33 -8
  159. package/dist/components/date-field.js.map +1 -1
  160. package/dist/components/date-picker.d.ts +15 -2
  161. package/dist/components/date-picker.js +55 -26
  162. package/dist/components/date-picker.js.map +1 -1
  163. package/dist/components/date-range-picker.d.ts +47 -20
  164. package/dist/components/date-range-picker.js +23 -7
  165. package/dist/components/date-range-picker.js.map +1 -1
  166. package/dist/components/error-boundary.js +37 -30
  167. package/dist/components/error-boundary.js.map +1 -1
  168. package/dist/components/{ui-labels.d.ts → field-base-labels.d.ts} +0 -2
  169. package/dist/components/{ui-labels.js → field-base-labels.js} +2 -9
  170. package/dist/components/field-base-labels.js.map +1 -0
  171. package/dist/components/field-base.d.ts +4 -3
  172. package/dist/components/field-base.js +3 -3
  173. package/dist/components/field-base.js.map +1 -1
  174. package/dist/components/field-sync-labels.d.ts +1 -0
  175. package/dist/components/field-sync-labels.js.map +1 -1
  176. package/dist/components/field-sync.d.ts +23 -1
  177. package/dist/components/field-sync.js.map +1 -1
  178. package/dist/components/form-actions.js +11 -5
  179. package/dist/components/form-actions.js.map +1 -1
  180. package/dist/components/hover-menu.d.ts +3 -0
  181. package/dist/components/hover-menu.js +5 -3
  182. package/dist/components/hover-menu.js.map +1 -1
  183. package/dist/components/icon-button.js +14 -9
  184. package/dist/components/icon-button.js.map +1 -1
  185. package/dist/components/inline-confirm.d.ts +43 -0
  186. package/dist/components/inline-confirm.js +67 -0
  187. package/dist/components/inline-confirm.js.map +1 -0
  188. package/dist/components/inline-entity-combobox.d.ts +4 -3
  189. package/dist/components/inline-entity-combobox.js +148 -140
  190. package/dist/components/inline-entity-combobox.js.map +1 -1
  191. package/dist/components/input.js +1 -1
  192. package/dist/components/input.js.map +1 -1
  193. package/dist/components/jump-calendar.js +28 -112
  194. package/dist/components/jump-calendar.js.map +1 -1
  195. package/dist/components/legal-page.d.ts +3 -1
  196. package/dist/components/legal-page.js +3 -2
  197. package/dist/components/legal-page.js.map +1 -1
  198. package/dist/components/legal.d.ts +4 -2
  199. package/dist/components/legal.js.map +1 -1
  200. package/dist/components/lightbox.d.ts +2 -2
  201. package/dist/components/lightbox.js +17 -6
  202. package/dist/components/lightbox.js.map +1 -1
  203. package/dist/components/list.d.ts +6 -2
  204. package/dist/components/list.js +3 -2
  205. package/dist/components/list.js.map +1 -1
  206. package/dist/components/measured-grid.d.ts +1 -1
  207. package/dist/components/measured-grid.js +2 -1
  208. package/dist/components/measured-grid.js.map +1 -1
  209. package/dist/components/mini-calendar.js +3 -5
  210. package/dist/components/mini-calendar.js.map +1 -1
  211. package/dist/components/modal.js +3 -1
  212. package/dist/components/modal.js.map +1 -1
  213. package/dist/components/month-grid.d.ts +55 -0
  214. package/dist/components/month-grid.js +148 -0
  215. package/dist/components/month-grid.js.map +1 -0
  216. package/dist/components/month-picker.d.ts +36 -4
  217. package/dist/components/month-picker.js +123 -146
  218. package/dist/components/month-picker.js.map +1 -1
  219. package/dist/components/multi-select.d.ts +2 -2
  220. package/dist/components/multi-select.js +11 -6
  221. package/dist/components/multi-select.js.map +1 -1
  222. package/dist/components/picker-sheet.js +2 -1
  223. package/dist/components/picker-sheet.js.map +1 -1
  224. package/dist/components/pie-chart-labels.d.ts +7 -0
  225. package/dist/components/pie-chart-labels.js +1 -0
  226. package/dist/components/pie-chart-labels.js.map +1 -1
  227. package/dist/components/pie-chart.d.ts +5 -3
  228. package/dist/components/pie-chart.js +7 -22
  229. package/dist/components/pie-chart.js.map +1 -1
  230. package/dist/components/popover.d.ts +3 -0
  231. package/dist/components/popover.js +7 -1
  232. package/dist/components/popover.js.map +1 -1
  233. package/dist/components/row-actions.js +2 -1
  234. package/dist/components/row-actions.js.map +1 -1
  235. package/dist/components/section-nav.d.ts +7 -0
  236. package/dist/components/section-nav.js.map +1 -1
  237. package/dist/components/series-chart-axes.d.ts +3 -3
  238. package/dist/components/series-chart-axes.js.map +1 -1
  239. package/dist/components/series-chart-labels.d.ts +7 -4
  240. package/dist/components/series-chart-labels.js.map +1 -1
  241. package/dist/components/series-chart.d.ts +31 -7
  242. package/dist/components/series-chart.js +72 -29
  243. package/dist/components/series-chart.js.map +1 -1
  244. package/dist/components/share-card.js +3 -3
  245. package/dist/components/share-card.js.map +1 -1
  246. package/dist/components/sign-chip-labels.d.ts +1 -0
  247. package/dist/components/sign-chip-labels.js.map +1 -1
  248. package/dist/components/sign-chip.d.ts +10 -1
  249. package/dist/components/sign-chip.js.map +1 -1
  250. package/dist/components/tabs-labels.d.ts +2 -0
  251. package/dist/components/tabs-labels.js +11 -0
  252. package/dist/components/tabs-labels.js.map +1 -0
  253. package/dist/components/tabs.d.ts +1 -1
  254. package/dist/components/tabs.js +1 -1
  255. package/dist/components/tabs.js.map +1 -1
  256. package/dist/components/toggle-legend.d.ts +2 -2
  257. package/dist/components/toggle-legend.js +6 -6
  258. package/dist/components/toggle-legend.js.map +1 -1
  259. package/dist/components/translation-review-editor.d.ts +4 -2
  260. package/dist/components/translation-review-editor.js +2 -3
  261. package/dist/components/translation-review-editor.js.map +1 -1
  262. package/dist/components/translation-review.d.ts +2 -1
  263. package/dist/components/translation-review.js +2 -2
  264. package/dist/components/translation-review.js.map +1 -1
  265. package/dist/components/treemap-labels.d.ts +26 -0
  266. package/dist/components/treemap-labels.js +10 -0
  267. package/dist/components/treemap-labels.js.map +1 -0
  268. package/dist/components/treemap-layout.d.ts +62 -0
  269. package/dist/components/treemap-layout.js +126 -0
  270. package/dist/components/treemap-layout.js.map +1 -0
  271. package/dist/components/treemap.d.ts +140 -17
  272. package/dist/components/treemap.js +324 -97
  273. package/dist/components/treemap.js.map +1 -1
  274. package/dist/components/use-table-state.d.ts +5 -5
  275. package/dist/components/use-table-state.js +4 -1
  276. package/dist/components/use-table-state.js.map +1 -1
  277. package/dist/data-table.d.ts +6 -2
  278. package/dist/data-table.js +7 -2
  279. package/dist/data-table.js.map +1 -1
  280. package/dist/eslint/index.js +1 -1
  281. package/dist/eslint/role-utilities.d.ts +36 -7
  282. package/dist/eslint/role-utilities.js +42 -9
  283. package/dist/eslint/role-utilities.js.map +1 -1
  284. package/dist/feedback/feedback-dialog.d.ts +25 -16
  285. package/dist/feedback/feedback-dialog.js +6 -2
  286. package/dist/feedback/feedback-dialog.js.map +1 -1
  287. package/dist/feedback/feedback-mutation.d.ts +30 -0
  288. package/dist/feedback/feedback-mutation.js +16 -0
  289. package/dist/feedback/feedback-mutation.js.map +1 -0
  290. package/dist/feedback/feedback-page-link.d.ts +53 -0
  291. package/dist/feedback/feedback-page-link.js +37 -0
  292. package/dist/feedback/feedback-page-link.js.map +1 -0
  293. package/dist/feedback/feedback-public-list.d.ts +12 -3
  294. package/dist/feedback/feedback-public-list.js +2 -1
  295. package/dist/feedback/feedback-public-list.js.map +1 -1
  296. package/dist/feedback/feedback-replies.d.ts +3 -1
  297. package/dist/feedback/feedback-replies.js +5 -4
  298. package/dist/feedback/feedback-replies.js.map +1 -1
  299. package/dist/feedback/feedback-row-detail-labels.js +5 -0
  300. package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
  301. package/dist/feedback/feedback-row-detail.d.ts +64 -28
  302. package/dist/feedback/feedback-row-detail.js +30 -28
  303. package/dist/feedback/feedback-row-detail.js.map +1 -1
  304. package/dist/feedback/feedback-status-undo.d.ts +30 -11
  305. package/dist/feedback/feedback-status-undo.js +10 -15
  306. package/dist/feedback/feedback-status-undo.js.map +1 -1
  307. package/dist/feedback/feedback-submit-dialog.d.ts +1 -1
  308. package/dist/feedback/feedback-submit-dialog.js +1 -1
  309. package/dist/feedback/feedback-submit-dialog.js.map +1 -1
  310. package/dist/feedback/feedback-submit.js +9 -3
  311. package/dist/feedback/feedback-submit.js.map +1 -1
  312. package/dist/feedback/feedback-swipe.d.ts +1 -1
  313. package/dist/feedback/feedback-swipe.js.map +1 -1
  314. package/dist/feedback/feedback-table.d.ts +21 -9
  315. package/dist/feedback/feedback-table.js +45 -25
  316. package/dist/feedback/feedback-table.js.map +1 -1
  317. package/dist/feedback/feedback-thread-labels.d.ts +2 -2
  318. package/dist/feedback/feedback-thread-labels.js.map +1 -1
  319. package/dist/feedback/feedback-thread.d.ts +24 -23
  320. package/dist/feedback/feedback-thread.js +2 -1
  321. package/dist/feedback/feedback-thread.js.map +1 -1
  322. package/dist/feedback.d.ts +34 -0
  323. package/dist/feedback.js +42 -0
  324. package/dist/feedback.js.map +1 -1
  325. package/dist/hooks/use-focus-trap.d.ts +35 -0
  326. package/dist/hooks/use-focus-trap.js +6 -4
  327. package/dist/hooks/use-focus-trap.js.map +1 -1
  328. package/dist/hooks/use-hotkey.d.ts +5 -2
  329. package/dist/hooks/use-hotkey.js +5 -4
  330. package/dist/hooks/use-hotkey.js.map +1 -1
  331. package/dist/hooks/use-long-press.d.ts +7 -4
  332. package/dist/hooks/use-long-press.js +3 -0
  333. package/dist/hooks/use-long-press.js.map +1 -1
  334. package/dist/hooks/use-media-query.js +12 -4
  335. package/dist/hooks/use-media-query.js.map +1 -1
  336. package/dist/hooks/use-mounted.d.ts +22 -0
  337. package/dist/hooks/use-mounted.js +24 -0
  338. package/dist/hooks/use-mounted.js.map +1 -0
  339. package/dist/hooks/use-overlay-history.js +19 -3
  340. package/dist/hooks/use-overlay-history.js.map +1 -1
  341. package/dist/i18n/defaults.js +4 -5
  342. package/dist/i18n/defaults.js.map +1 -1
  343. package/dist/i18n/german.js +7 -1
  344. package/dist/i18n/german.js.map +1 -1
  345. package/dist/i18n/kit-labels.d.ts +9 -2
  346. package/dist/i18n/kit-labels.js.map +1 -1
  347. package/dist/i18n/locales/en.js +20 -41
  348. package/dist/i18n/locales/en.js.map +3 -3
  349. package/dist/i18n/locales/es.js +7 -1
  350. package/dist/i18n/locales/es.js.map +1 -1
  351. package/dist/i18n/locales/fr.js +20 -10
  352. package/dist/i18n/locales/fr.js.map +1 -1
  353. package/dist/i18n/locales/hu.js +9 -1
  354. package/dist/i18n/locales/hu.js.map +1 -1
  355. package/dist/i18n/locales/it.js +7 -1
  356. package/dist/i18n/locales/it.js.map +1 -1
  357. package/dist/i18n/locales/zh.js +8 -1
  358. package/dist/i18n/locales/zh.js.map +1 -1
  359. package/dist/i18n/review.js +5 -0
  360. package/dist/i18n/review.js.map +1 -1
  361. package/dist/index.d.ts +64 -17
  362. package/dist/index.js +77 -12
  363. package/dist/index.js.map +1 -1
  364. package/dist/landing/routing.d.ts +3 -1
  365. package/dist/landing/routing.js +4 -7
  366. package/dist/landing/routing.js.map +1 -1
  367. package/dist/lib/broadcast.d.ts +17 -0
  368. package/dist/lib/broadcast.js +30 -0
  369. package/dist/lib/broadcast.js.map +1 -0
  370. package/dist/lib/date-format.d.ts +37 -2
  371. package/dist/lib/date-format.js +34 -8
  372. package/dist/lib/date-format.js.map +1 -1
  373. package/dist/lib/day-format.d.ts +46 -0
  374. package/dist/lib/day-format.js +46 -0
  375. package/dist/lib/day-format.js.map +1 -0
  376. package/dist/lib/describe-failure.d.ts +14 -0
  377. package/dist/lib/describe-failure.js +9 -0
  378. package/dist/lib/describe-failure.js.map +1 -0
  379. package/dist/lib/direction.d.ts +16 -0
  380. package/dist/lib/direction.js +9 -1
  381. package/dist/lib/direction.js.map +1 -1
  382. package/dist/lib/focus-left.d.ts +63 -0
  383. package/dist/lib/focus-left.js +67 -0
  384. package/dist/lib/focus-left.js.map +1 -0
  385. package/dist/lib/format.js +5 -14
  386. package/dist/lib/format.js.map +1 -1
  387. package/dist/lib/http-status.d.ts +24 -0
  388. package/dist/lib/http-status.js +14 -0
  389. package/dist/lib/http-status.js.map +1 -0
  390. package/dist/lib/intl-cache.d.ts +14 -0
  391. package/dist/lib/intl-cache.js +15 -0
  392. package/dist/lib/intl-cache.js.map +1 -0
  393. package/dist/lib/isin.d.ts +10 -0
  394. package/dist/lib/isin.js.map +1 -1
  395. package/dist/lib/iso-day.d.ts +11 -0
  396. package/dist/lib/iso-day.js +8 -0
  397. package/dist/lib/iso-day.js.map +1 -0
  398. package/dist/lib/lazy-with-fallback.d.ts +31 -0
  399. package/dist/lib/lazy-with-fallback.js +40 -0
  400. package/dist/lib/lazy-with-fallback.js.map +1 -0
  401. package/dist/lib/path-pattern.d.ts +34 -0
  402. package/dist/lib/path-pattern.js +24 -0
  403. package/dist/lib/path-pattern.js.map +1 -0
  404. package/dist/lib/reduced-motion.d.ts +2 -1
  405. package/dist/lib/reduced-motion.js.map +1 -1
  406. package/dist/lib/round.d.ts +2 -1
  407. package/dist/lib/round.js +2 -1
  408. package/dist/lib/round.js.map +1 -1
  409. package/dist/lib/safe-storage.d.ts +24 -5
  410. package/dist/lib/safe-storage.js +27 -2
  411. package/dist/lib/safe-storage.js.map +1 -1
  412. package/dist/lib/session-refresh.js +1 -1
  413. package/dist/lib/session-refresh.js.map +1 -1
  414. package/dist/lib/share-format.d.ts +13 -0
  415. package/dist/lib/share-format.js +10 -0
  416. package/dist/lib/share-format.js.map +1 -0
  417. package/dist/lib/text-case.d.ts +17 -0
  418. package/dist/lib/text-case.js +8 -0
  419. package/dist/lib/text-case.js.map +1 -0
  420. package/dist/lib/text-match.d.ts +29 -0
  421. package/dist/lib/text-match.js +20 -2
  422. package/dist/lib/text-match.js.map +1 -1
  423. package/dist/lib/thenable.d.ts +13 -0
  424. package/dist/lib/thenable.js +8 -0
  425. package/dist/lib/thenable.js.map +1 -0
  426. package/dist/lib/translation-review.d.ts +7 -2
  427. package/dist/lib/translation-review.js +4 -4
  428. package/dist/lib/translation-review.js.map +1 -1
  429. package/dist/notifications/device-zone-report.js +1 -1
  430. package/dist/notifications/device-zone-report.js.map +1 -1
  431. package/dist/notifications/notification-bell.d.ts +2 -1
  432. package/dist/notifications/notification-bell.js +3 -3
  433. package/dist/notifications/notification-bell.js.map +1 -1
  434. package/dist/notifications/notification-inbox.d.ts +10 -6
  435. package/dist/notifications/notification-inbox.js +26 -48
  436. package/dist/notifications/notification-inbox.js.map +1 -1
  437. package/dist/notifications/notification-parts.d.ts +3 -2
  438. package/dist/notifications/notification-parts.js +1 -3
  439. package/dist/notifications/notification-parts.js.map +1 -1
  440. package/dist/notifications/notification-types-setting.js +1 -1
  441. package/dist/notifications/notification-types-setting.js.map +1 -1
  442. package/dist/notifications/notifications-labels.d.ts +6 -0
  443. package/dist/notifications/notifications-labels.js +1 -0
  444. package/dist/notifications/notifications-labels.js.map +1 -1
  445. package/dist/notifications/push-device-setting.js +1 -1
  446. package/dist/notifications/push-device-setting.js.map +1 -1
  447. package/dist/notifications/push-devices-setting.d.ts +2 -1
  448. package/dist/notifications/push-devices-setting.js +27 -49
  449. package/dist/notifications/push-devices-setting.js.map +1 -1
  450. package/dist/notifications/quiet-hours-setting.d.ts +10 -3
  451. package/dist/notifications/quiet-hours-setting.js +65 -26
  452. package/dist/notifications/quiet-hours-setting.js.map +1 -1
  453. package/dist/notifications/unsubscribe-panel.js +4 -7
  454. package/dist/notifications/unsubscribe-panel.js.map +1 -1
  455. package/dist/notifications/use-push-device.d.ts +39 -1
  456. package/dist/notifications/use-push-device.js +28 -7
  457. package/dist/notifications/use-push-device.js.map +1 -1
  458. package/dist/offline/query-persistence.d.ts +3 -1
  459. package/dist/offline/query-persistence.js +19 -2
  460. package/dist/offline/query-persistence.js.map +1 -1
  461. package/dist/rhf/fields.d.ts +11 -4
  462. package/dist/rhf/fields.js.map +1 -1
  463. package/dist/search/command-palette.js +1 -1
  464. package/dist/search/command-palette.js.map +1 -1
  465. package/dist/search/global-search.js +19 -9
  466. package/dist/search/global-search.js.map +1 -1
  467. package/dist/search/use-command-key.d.ts +12 -1
  468. package/dist/search/use-command-key.js +3 -12
  469. package/dist/search/use-command-key.js.map +1 -1
  470. package/dist/search.d.ts +7 -0
  471. package/dist/search.js +10 -0
  472. package/dist/search.js.map +1 -1
  473. package/dist/settings/use-settings-focus.js +1 -0
  474. package/dist/settings/use-settings-focus.js.map +1 -1
  475. package/dist/shell/account-menu-language.d.ts +21 -5
  476. package/dist/shell/account-menu-language.js +3 -1
  477. package/dist/shell/account-menu-language.js.map +1 -1
  478. package/dist/shell/account-menu-text-size.d.ts +26 -9
  479. package/dist/shell/account-menu-text-size.js +3 -2
  480. package/dist/shell/account-menu-text-size.js.map +1 -1
  481. package/dist/shell/dev-menu.js +5 -18
  482. package/dist/shell/dev-menu.js.map +1 -1
  483. package/dist/shell/role-switcher.d.ts +7 -0
  484. package/dist/shell/role-switcher.js.map +1 -1
  485. package/dist/shell/top-bar-actions.d.ts +1 -1
  486. package/dist/shell/top-bar-actions.js.map +1 -1
  487. package/dist/shell/top-bar-parts-labels.d.ts +0 -2
  488. package/dist/shell/top-bar-parts-labels.js +0 -1
  489. package/dist/shell/top-bar-parts-labels.js.map +1 -1
  490. package/dist/shell.d.ts +27 -8
  491. package/dist/shell.js +28 -7
  492. package/dist/shell.js.map +1 -1
  493. package/dist/sync/engine.d.ts +30 -4
  494. package/dist/sync/engine.js +172 -52
  495. package/dist/sync/engine.js.map +1 -1
  496. package/dist/sync.d.ts +6 -2
  497. package/dist/sync.js +6 -1
  498. package/dist/sync.js.map +1 -1
  499. package/dist/testing/css-variables.js +3 -8
  500. package/dist/testing/css-variables.js.map +1 -1
  501. package/dist/theme/contrast.d.ts +2 -1
  502. package/dist/theme/contrast.js +3 -8
  503. package/dist/theme/contrast.js.map +1 -1
  504. package/dist/theme/palette-store.js +6 -6
  505. package/dist/theme/palette-store.js.map +1 -1
  506. package/dist/theme/text-size.js +3 -8
  507. package/dist/theme/text-size.js.map +1 -1
  508. package/dist/theme/theme-store.js +3 -6
  509. package/dist/theme/theme-store.js.map +1 -1
  510. package/dist/tour/tour-catalogue.d.ts +7 -4
  511. package/dist/tour/tour-catalogue.js +12 -10
  512. package/dist/tour/tour-catalogue.js.map +1 -1
  513. package/dist/tour/tour-dock.d.ts +0 -2
  514. package/dist/tour/tour-dock.js +0 -2
  515. package/dist/tour/tour-dock.js.map +1 -1
  516. package/dist/tour/tour-gates.d.ts +4 -0
  517. package/dist/tour/tour-gates.js +14 -0
  518. package/dist/tour/tour-gates.js.map +1 -1
  519. package/dist/tour/tour-overlay.d.ts +27 -0
  520. package/dist/tour/tour-overlay.js +741 -0
  521. package/dist/tour/tour-overlay.js.map +1 -0
  522. package/dist/tour/tour.d.ts +13 -3
  523. package/dist/tour/tour.js +59 -781
  524. package/dist/tour/tour.js.map +1 -1
  525. package/dist/tour/use-tour-progress.js +1 -1
  526. package/dist/tour/use-tour-progress.js.map +1 -1
  527. package/dist/wizard/stepper-nav.d.ts +5 -1
  528. package/dist/wizard/stepper-nav.js.map +1 -1
  529. package/dist/wizard/types.d.ts +6 -2
  530. package/dist/wizard/types.js.map +1 -1
  531. package/dist/wizard/use-wizard.d.ts +3 -1
  532. package/dist/wizard/use-wizard.js.map +1 -1
  533. package/dist/wizard/validation.d.ts +3 -1
  534. package/dist/wizard/validation.js.map +1 -1
  535. package/package.json +10 -6
  536. package/src/account/account-parts.ts +5 -25
  537. package/src/account/data-export-setting-labels.ts +1 -1
  538. package/src/account/delete-account-setting-labels.ts +1 -1
  539. package/src/account/email-change-setting-labels.ts +1 -1
  540. package/src/account/passkeys-setting.tsx +60 -38
  541. package/src/account/sessions-setting.tsx +18 -12
  542. package/src/admin/admin-action-confirm.tsx +1 -5
  543. package/src/admin/admin-parts.ts +11 -25
  544. package/src/admin/mail-test-card-labels.ts +1 -1
  545. package/src/admin/plan-change-labels.ts +5 -23
  546. package/src/admin/plan-change.tsx +7 -44
  547. package/src/admin/reviewer-scope-editor.tsx +3 -3
  548. package/src/auth/auth-errors-labels.ts +23 -0
  549. package/src/auth/auth-errors.ts +11 -38
  550. package/src/auth/complete-name-dialog.tsx +4 -1
  551. package/src/auth/forgot-password-form-labels.ts +1 -1
  552. package/src/auth/forgot-password-form.tsx +11 -6
  553. package/src/auth/register-form-labels.ts +1 -1
  554. package/src/auth/reset-password-form-labels.ts +1 -1
  555. package/src/auth/reset-password-form.tsx +8 -4
  556. package/src/auth/sign-in-form-labels.ts +1 -1
  557. package/src/auth/status-parts.tsx +0 -6
  558. package/src/auth/verify-email-labels.ts +1 -1
  559. package/src/auth/verify-email.tsx +11 -6
  560. package/src/billing/cancel-subscription.tsx +26 -12
  561. package/src/billing/dialog-close.ts +34 -0
  562. package/src/billing/plan-card.tsx +36 -11
  563. package/src/billing/plan-change-labels.ts +66 -0
  564. package/src/billing/plan-switch.tsx +26 -12
  565. package/src/chart.ts +21 -3
  566. package/src/components/account-chips.tsx +20 -23
  567. package/src/components/alert-banner.tsx +82 -5
  568. package/src/components/amount-input.tsx +18 -7
  569. package/src/components/autocomplete.tsx +64 -70
  570. package/src/components/bulk-action-bar.tsx +70 -2
  571. package/src/components/button-look.ts +5 -5
  572. package/src/components/button.tsx +2 -2
  573. package/src/components/chart-edge.ts +34 -1
  574. package/src/components/chart-figure.tsx +35 -0
  575. package/src/components/chart-zoom-core.tsx +6 -5
  576. package/src/components/chart.tsx +26 -5
  577. package/src/components/combobox-core.tsx +293 -62
  578. package/src/components/combobox.tsx +183 -153
  579. package/src/components/copy-button.tsx +34 -23
  580. package/src/components/country-select.tsx +16 -11
  581. package/src/components/data-table-column-settings.tsx +52 -10
  582. package/src/components/data-table-filters.ts +6 -4
  583. package/src/components/data-table-fit.ts +19 -5
  584. package/src/components/data-table-groups.tsx +1 -1
  585. package/src/components/data-table-head.tsx +32 -22
  586. package/src/components/data-table-mobile.tsx +61 -26
  587. package/src/components/data-table-pagination.tsx +21 -6
  588. package/src/components/data-table-resize.ts +1 -1
  589. package/src/components/data-table-row-actions.tsx +3 -3
  590. package/src/components/data-table-row.tsx +25 -14
  591. package/src/components/data-table-selection.ts +1 -1
  592. package/src/components/data-table-shared.tsx +33 -1
  593. package/src/components/data-table-sort.ts +57 -2
  594. package/src/components/data-table-virtual.ts +32 -8
  595. package/src/components/data-table.tsx +239 -68
  596. package/src/components/date-field.tsx +65 -8
  597. package/src/components/date-picker.tsx +125 -48
  598. package/src/components/date-range-picker.tsx +82 -31
  599. package/src/components/error-boundary.tsx +53 -39
  600. package/src/components/field-base-labels.ts +20 -0
  601. package/src/components/field-base.tsx +13 -7
  602. package/src/components/field-sync-labels.ts +1 -0
  603. package/src/components/field-sync.tsx +23 -1
  604. package/src/components/form-actions.tsx +20 -5
  605. package/src/components/hover-menu.tsx +18 -8
  606. package/src/components/icon-button.tsx +14 -9
  607. package/src/components/inline-confirm.tsx +116 -0
  608. package/src/components/inline-entity-combobox.tsx +197 -153
  609. package/src/components/input.tsx +1 -1
  610. package/src/components/jump-calendar.tsx +30 -146
  611. package/src/components/legal-page.tsx +10 -7
  612. package/src/components/legal.tsx +4 -2
  613. package/src/components/lightbox.tsx +21 -8
  614. package/src/components/list.tsx +10 -4
  615. package/src/components/measured-grid.tsx +8 -4
  616. package/src/components/mini-calendar.tsx +6 -5
  617. package/src/components/modal.tsx +6 -1
  618. package/src/components/month-grid.tsx +229 -0
  619. package/src/components/month-picker.tsx +192 -200
  620. package/src/components/multi-select.tsx +21 -9
  621. package/src/components/picker-sheet.tsx +12 -9
  622. package/src/components/pie-chart-labels.ts +8 -0
  623. package/src/components/pie-chart.tsx +22 -28
  624. package/src/components/popover.tsx +18 -1
  625. package/src/components/row-actions.tsx +2 -1
  626. package/src/components/section-nav.tsx +7 -0
  627. package/src/components/series-chart-axes.ts +3 -3
  628. package/src/components/series-chart-labels.ts +7 -4
  629. package/src/components/series-chart.tsx +178 -69
  630. package/src/components/share-card.tsx +6 -6
  631. package/src/components/sign-chip-labels.ts +1 -0
  632. package/src/components/sign-chip.tsx +10 -1
  633. package/src/components/tabs-labels.ts +13 -0
  634. package/src/components/tabs.tsx +2 -2
  635. package/src/components/toggle-legend.tsx +16 -11
  636. package/src/components/translation-review-editor.tsx +6 -5
  637. package/src/components/translation-review.tsx +4 -3
  638. package/src/components/treemap-labels.ts +39 -0
  639. package/src/components/treemap-layout.ts +210 -0
  640. package/src/components/treemap.tsx +722 -133
  641. package/src/components/use-table-state.ts +12 -9
  642. package/src/data-table.ts +9 -2
  643. package/src/eslint/role-utilities.ts +97 -19
  644. package/src/feedback/feedback-dialog.tsx +30 -19
  645. package/src/feedback/feedback-mutation.ts +41 -0
  646. package/src/feedback/feedback-page-link.ts +90 -0
  647. package/src/feedback/feedback-public-list.tsx +17 -5
  648. package/src/feedback/feedback-replies.tsx +13 -6
  649. package/src/feedback/feedback-row-detail-labels.ts +5 -0
  650. package/src/feedback/feedback-row-detail.tsx +103 -67
  651. package/src/feedback/feedback-status-undo.ts +41 -27
  652. package/src/feedback/feedback-submit-dialog.tsx +2 -2
  653. package/src/feedback/feedback-submit.tsx +21 -7
  654. package/src/feedback/feedback-swipe.tsx +1 -1
  655. package/src/feedback/feedback-table.tsx +86 -38
  656. package/src/feedback/feedback-thread-labels.ts +2 -2
  657. package/src/feedback/feedback-thread.tsx +27 -25
  658. package/src/feedback.ts +42 -0
  659. package/src/hooks/use-focus-trap.ts +8 -24
  660. package/src/hooks/use-hotkey.ts +24 -7
  661. package/src/hooks/use-long-press.ts +16 -2
  662. package/src/hooks/use-media-query.ts +20 -4
  663. package/src/hooks/use-mounted.ts +39 -0
  664. package/src/hooks/use-overlay-history.ts +32 -3
  665. package/src/i18n/defaults.ts +4 -5
  666. package/src/i18n/german.ts +8 -2
  667. package/src/i18n/kit-labels.tsx +9 -2
  668. package/src/i18n/locales/es.ts +8 -2
  669. package/src/i18n/locales/fr.ts +21 -13
  670. package/src/i18n/locales/hu.ts +10 -2
  671. package/src/i18n/locales/it.ts +8 -2
  672. package/src/i18n/locales/zh.ts +9 -2
  673. package/src/i18n/review.ts +5 -0
  674. package/src/index.ts +103 -13
  675. package/src/landing/routing.tsx +14 -10
  676. package/src/lib/broadcast.ts +52 -0
  677. package/src/lib/date-format.ts +89 -13
  678. package/src/lib/day-format.ts +96 -0
  679. package/src/lib/describe-failure.ts +18 -0
  680. package/src/lib/direction.ts +39 -0
  681. package/src/lib/focus-left.ts +156 -0
  682. package/src/lib/format.ts +5 -17
  683. package/src/lib/http-status.ts +38 -0
  684. package/src/lib/intl-cache.ts +25 -0
  685. package/src/lib/isin.ts +10 -0
  686. package/src/lib/iso-day.ts +13 -0
  687. package/src/lib/lazy-with-fallback.ts +82 -0
  688. package/src/lib/path-pattern.ts +55 -0
  689. package/src/lib/reduced-motion.ts +2 -1
  690. package/src/lib/round.ts +7 -2
  691. package/src/lib/safe-storage.ts +48 -6
  692. package/src/lib/session-refresh.ts +1 -1
  693. package/src/lib/share-format.ts +18 -0
  694. package/src/lib/text-case.ts +19 -0
  695. package/src/lib/text-match.ts +57 -2
  696. package/src/lib/thenable.ts +19 -0
  697. package/src/lib/translation-review.ts +13 -5
  698. package/src/notifications/device-zone-report.ts +1 -1
  699. package/src/notifications/notification-bell.tsx +7 -4
  700. package/src/notifications/notification-inbox.tsx +40 -58
  701. package/src/notifications/notification-parts.tsx +3 -4
  702. package/src/notifications/notification-types-setting.tsx +1 -1
  703. package/src/notifications/notifications-labels.ts +7 -0
  704. package/src/notifications/push-device-setting.tsx +1 -1
  705. package/src/notifications/push-devices-setting.tsx +30 -55
  706. package/src/notifications/quiet-hours-setting.tsx +93 -31
  707. package/src/notifications/unsubscribe-panel.tsx +4 -7
  708. package/src/notifications/use-push-device.ts +76 -10
  709. package/src/offline/query-persistence.ts +35 -3
  710. package/src/rhf/fields.tsx +11 -4
  711. package/src/search/command-palette.tsx +2 -4
  712. package/src/search/global-search.tsx +36 -15
  713. package/src/search/use-command-key.ts +13 -12
  714. package/src/search.ts +9 -0
  715. package/src/settings/use-settings-focus.ts +3 -0
  716. package/src/shell/account-menu-language.tsx +27 -5
  717. package/src/shell/account-menu-text-size.tsx +32 -10
  718. package/src/shell/dev-menu.tsx +7 -21
  719. package/src/shell/role-switcher.tsx +7 -0
  720. package/src/shell/top-bar-actions.tsx +1 -1
  721. package/src/shell/top-bar-parts-labels.ts +0 -3
  722. package/src/shell.ts +40 -9
  723. package/src/sync/engine.ts +339 -61
  724. package/src/sync.ts +8 -1
  725. package/src/testing/css-variables.ts +8 -9
  726. package/src/theme/contrast.ts +8 -9
  727. package/src/theme/palette-store.ts +9 -9
  728. package/src/theme/text-size.ts +6 -8
  729. package/src/theme/theme-store.ts +7 -9
  730. package/src/tour/tour-catalogue.tsx +26 -15
  731. package/src/tour/tour-dock.ts +0 -2
  732. package/src/tour/tour-gates.ts +23 -0
  733. package/src/tour/tour-overlay.tsx +1170 -0
  734. package/src/tour/tour.tsx +108 -1202
  735. package/src/tour/use-tour-progress.ts +1 -1
  736. package/src/wizard/stepper-nav.tsx +3 -1
  737. package/src/wizard/types.ts +11 -2
  738. package/src/wizard/use-wizard.ts +2 -1
  739. package/src/wizard/validation.ts +8 -2
  740. package/tokens.css +2 -1
  741. package/dist/components/ui-labels.js.map +0 -1
  742. package/dist/shell/dev-switchers.d.ts +0 -6
  743. package/dist/shell/dev-switchers.js +0 -12
  744. package/dist/shell/dev-switchers.js.map +0 -1
  745. package/src/components/ui-labels.ts +0 -24
  746. package/src/shell/dev-switchers.tsx +0 -18
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tour/tour.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport type { CSSProperties, ReactNode, RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { Button } from \"../components/button\";\nimport { useFocusTrap } from \"../hooks/use-focus-trap\";\nimport { useDismissLayer } from \"../hooks/use-dismiss\";\nimport { sameRect } from \"../hooks/use-anchored-rect\";\nimport { dirOf, horizontalStep } from \"../lib/direction\";\nimport { isComposing } from \"../lib/ime\";\nimport { focusQuietly } from \"../lib/quiet-focus\";\nimport type { Direction } from \"../lib/direction\";\nimport { DEFAULT_TOUR_LABELS } from \"./tour-labels\";\nimport type { TourInfo } from \"./tour-info\";\nimport { completeStored, rememberAccount, rememberMigrate, type UseTourProgressOptions } from \"./use-tour-progress\";\nimport { createGateRegistry, devWarnings, TourInternalContext, type GateRegistry } from \"./tour-gates\";\nimport { liveEngine } from \"./tour-engine\";\nimport { DOCK_MAX_WIDTH, dockEdge, dockStyle, readBand, scrollIntoFreeHalf, type DockEdge } from \"./tour-dock\";\n\nexport { useTourGate, useTourGateRelease } from \"./tour-gates\";\nexport type { TourGateRelease } from \"./tour-gates\";\n\n/**\n * `start`/`end` follow the reading direction (`end` is the right side in LTR and the\n * left side in RTL) and are what a translated app wants. `left`/`right` stay physical\n * for the steps that genuinely mean a screen side.\n */\nexport type TourPlacement = \"top\" | \"right\" | \"bottom\" | \"left\" | \"start\" | \"end\" | \"center\" | \"dock\";\n\nexport interface TourStep {\n /** CSS selector for the element to spotlight. Omit for a centered step\n * (welcome/finish). If the target isn't found/visible, the step centers. */\n target?: string;\n title: string;\n body: ReactNode;\n /** Extra footer content, e.g. a \"load sample data\" shortcut. */\n action?: ReactNode;\n /** Spotlight padding around the target, px (default 8). On a field step the spot also\n * takes in the lines the field's `aria-describedby` names when they sit within the\n * ring's reach of it (a hint or warning line under the field, keksdose S1, §11.6). */\n padding?: number;\n /** Where the card sits relative to the target. Omit for auto placement\n * (below → above → centered). \"center\" ignores the target and centers on\n * screen. \"start\"/\"end\" are the logical sides and flip in RTL; \"left\"/\"right\"\n * are physical. An explicit side flips to the opposite side if it would\n * overflow, then clamps into the viewport.\n *\n * `\"dock\"` (0.50, §11.7): below `sm` (640 px) the card is pinned full-width to the top\n * or bottom edge of the usable band — the visual viewport less the keyboard and any\n * `[data-tour-obstruction]` (the number pad) — on the edge away from the field, and the\n * field's scroll container brings it into the other half. From `sm` up it is auto\n * placement. On a phone a field step (`interactive`, `awaitInput`, `gate`, `awaitGate`)\n * with a target and no `placement` docks by default (`TourProvider dockOnPhones`). */\n placement?: TourPlacement;\n /** Advance only when the user clicks the spotlighted target itself (not the\n * card's Next button). Requires `target`: the real control's own handler runs\n * first, then the tour steps forward on a microtask. The spotlight hole stays\n * click-through to the target; the rest of the page does not. */\n awaitClick?: boolean;\n /**\n * The spotlighted control is for USING, not only for looking at (0.46, keksdose live\n * #436): the layers it opens sit above the scrim and work. A plain step's overlay is\n * `z-[60]`, over every kit layer, so a field whose number pad (`NumberPadSheet`), a\n * select's menu or a popover opens at `z-50` opened UNDER the shields, where nothing\n * could be tapped. Here the overlay drops to `z-[45]`: still over the top bar and the\n * page (`z-40` and below, still dimmed and shielded), under every `z-50` layer the\n * target opens — so an app's own layer wants `z-50` or more to clear it. Keys pressed\n * in the target or in such a layer are theirs (Escape closes the pad, arrows walk a\n * list); from the card the tour's keys work as on any step. The overlay is not\n * `aria-modal` then, and carries `data-tour-interactive`.\n *\n * The card is in the same layer as the scrim, so an open pad or sheet may cover it\n * until it closes. Requires `target`. A `HoverMenu` (`z-40`, the top bar's menus) stays\n * under the scrim: point an `awaitClick` step at its trigger instead.\n */\n interactive?: boolean;\n /**\n * Advance once a value was ENTERED in the spotlighted control (0.46, keksdose live\n * #436) — `awaitClick` for a field. Implies `interactive`. Counted when focus leaves\n * the target (the number pad's Done, a Tab, a tap elsewhere), or Enter is pressed in\n * it, and one of its fields (`input`, `textarea`, `select`: the target itself or\n * inside it) then holds another value than when the step began; a native `change`\n * (a select, a checkbox) counts at once. The card swaps Next for `awaitInputHint`,\n * as for `awaitClick`. A picker whose value is not a field's (the kit's `Select`\n * button) has nothing to compare: call `useTour().next()` from its `onChange`.\n */\n awaitInput?: boolean;\n /**\n * 0.50 (docs/tours-harmonization.md §11.1): Next stays locked until the gate `key` is\n * satisfied — the form publishes it with `useTourGate(key, satisfied)` beside the field.\n * Implies `interactive`. The locked Next is `aria-disabled` with {@link gateHint} under\n * it; pressing it focuses the field. Once satisfied the tour does NOT advance by itself:\n * Next, Enter in the field, or focus leaving the field to nowhere or to the card (the\n * number pad's Done) moves on. A key nobody publishes is not enforced (the form closed\n * under the tour): Next opens. A step may have a `gate` and no `target`.\n */\n gate?: string;\n /** Overrides `labels.gateHint` for this step. */\n gateHint?: string;\n /**\n * 0.50 (§11.4): wait for the app to RELEASE this key — `useTourGateRelease().release(key)`\n * from the save's `onSuccess`. Implies `interactive`; usually it targets the Save button,\n * whose hole stays click-through. Next is replaced by {@link awaitGateHint}, and a click\n * does not advance: only `release` does. A release that arrives on an earlier step (Enter\n * in the last field submitted the form) jumps past the first later step awaiting the key.\n * `refuse(key, reason)` keeps the step and shows the reason, with a \"Back to …\" link to the\n * first earlier field whose gate is now unsatisfied; the kit never jumps there itself.\n * A viewer who cannot save gets `awaitGate: undefined`, so a plain Next.\n */\n awaitGate?: string;\n /** Overrides `labels.awaitGateHint` for this step. */\n awaitGateHint?: string;\n /**\n * 0.50 (§11.2): the field may stay empty. While the `gate` is unsatisfied the card\n * offers \"Leave empty\" beside the locked Next, which moves on without touching the field\n * (the kit never writes app values); the title carries an \"Optional\" chip. Not a skip:\n * the run continues and can complete. Without a `gate`, only the chip.\n */\n optional?: boolean;\n /**\n * 0.50 (§11.3): shown only if this returns true on ARRIVAL (evaluated before\n * `beforeStep`, so a skipped step never navigates). Next walks forward to the first step\n * shown, Back to the nearest earlier one shown now. Branch facts are gates:\n * `when: (c) => c.gate(\"txn.transfer\") === true`. Keep it pure and cheap: the counter\n * evaluates every step's `when` on each arrival. A throw counts as skipped.\n */\n when?: (ctx: TourStepContext) => boolean;\n /** Runs before the step is shown — e.g. navigate to a route, open a panel.\n * May be async; the step waits for it, then locates the target. Receives the\n * {@link TourStepContext} (0.50); a step entered by \"Guide me\" sees `via: \"at\"` and\n * should leave an open form alone. One that throws or rejects is logged to the\n * console, and the step is located and shown anyway. Enter and the arrows wait for\n * it; Escape does not. */\n beforeStep?: (ctx: TourStepContext) => void | Promise<void>;\n}\n\n/** What a step's `when` and `beforeStep` may ask on arrival (0.50, §11.3). */\nexport interface TourStepContext {\n /** The gate's current value: true/false, or undefined while nobody publishes it. */\n gate(key: string): boolean | undefined;\n /** How this step is being entered. */\n via: \"start\" | \"at\" | \"next\" | \"back\" | \"goto\";\n}\n\nexport interface TourLabels {\n next: string;\n back: string;\n skip: string;\n done: string;\n /** Shown in place of the Next button on an `awaitClick` step. */\n awaitClickHint: string;\n /** Shown in place of the Next button on an `awaitInput` step (0.46). */\n awaitInputHint: string;\n /** Step counter, e.g. (2, 7) => \"2 / 7\". Counts the steps the run shows (0.50). */\n step: (current: number, total: number) => string;\n /** 0.50: an `optional` gate step's button while the field is empty. */\n leaveEmpty: string;\n /** 0.50: the chip beside an `optional` step's title. */\n optional: string;\n /** 0.50: under a `gate` step's locked Next (`TourStep.gateHint` overrides it). */\n gateHint: string;\n /** 0.50: announced (screen readers only) when a gate step's field is filled. */\n gateReady: string;\n /** 0.50: in place of Next on an `awaitGate` step (`TourStep.awaitGateHint` overrides it). */\n awaitGateHint: string;\n /** 0.50: the warning when the app `refuse`s an `awaitGate` step without a reason. */\n awaitGateRefused: string;\n /** 0.50: the link to an earlier step whose field was emptied, after a refused save. */\n backToStep: (title: string) => string;\n}\n\n// Defined in ./tour-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_TOUR_LABELS };\n\n/** 0.50 (§11.5): a step index, or the `data-tour` value of the step's anchor. */\nexport type TourAt = number | string;\n\n/** `useTour().start`, both forms: what `TourProvider` hands its `launch` as the third argument. */\nexport type TourStart = TourContextValue[\"start\"];\n\n/**\n * 0.50 (§11.5): the app's launcher — the shape `useTourUrlSync` already takes, plus `at`.\n * It builds the steps (`prepare()`, `build()`, `tour: tourInfo(def)`) and passes `at` on to\n * `start(steps, { …, at })`. Give the same function to `TourProvider launch` and to\n * `useTourUrlSync`.\n *\n * `start` is the provider's own `start` (keksdose N4), so the launcher needs no ref to a\n * component below the provider and may be defined above it. `engine` (0.50.1, keksdose N1)\n * is the rest of the engine — `stop`, `next`, `active`, … — read live, see {@link TourEngine}.\n * `useTourUrlSync` passes both (under a provider). A launcher taking fewer arguments still\n * works.\n */\nexport type TourLauncher = (\n id: string,\n opts: { startIndex?: number; at?: TourAt },\n start: TourStart,\n engine: TourEngine,\n) => void | Promise<unknown>;\n\n/**\n * 0.50.1 (keksdose N1): the whole engine `useTour()` returns, handed to a launcher as its\n * FOURTH argument by `TourProvider` and `useTourUrlSync`, so a tour built above the provider\n * can also `stop`, `next` or read `active` with no `useTour()` registered from below. One\n * object per provider whose fields read the latest render (`engine.active` after an\n * `await` is current); its methods are the provider's own. `start` (the third argument) is\n * `engine.start`.\n */\nexport type TourEngine = TourContextValue;\n\nconst ENGINE_KEYS = [\n \"active\",\n \"activeId\",\n \"start\",\n \"stop\",\n \"next\",\n \"prev\",\n \"goToStep\",\n \"index\",\n \"total\",\n \"position\",\n \"count\",\n] as const satisfies readonly (keyof TourContextValue)[];\n\ninterface StartOptions {\n /** Stable id of the tour, surfaced as `activeId` so the app can mirror it to\n * the URL (deep-link / evaluation tracking) and record completion. Defaults to\n * `tour.id`. */\n id?: string;\n /** The tour being started, as the app lists it (docs/tours-harmonization.md §9.6.1).\n * When its last step is finished, the provider records the completion in its\n * `progress` and hands this to `onComplete`. */\n tour?: TourInfo;\n /** Start at this step index instead of 0 (clamped) — for URL/deep-link resume. */\n startIndex?: number;\n /**\n * 0.50 (§11.5): start here AND make it the floor — earlier steps never run (nor their\n * `beforeStep`), Back stops here, `position`/`count` count from here, and the finish\n * records the completion as a full run does (Marcel, Q2). A number is a step index\n * (clamped); a string is the first step whose `target` contains `data-tour=\"<at>\"`\n * verbatim (unknown: 0, with a development warning). The `at` step is entered with\n * `via: \"at\"`. With `startIndex` too, `startIndex` picks the step and `at` the floor.\n */\n at?: TourAt;\n /** Fires synchronously when the tour starts (e.g. enable a mock interceptor). */\n onStart?: () => void;\n /** After the last step: runs after the provider's progress write and `onComplete`. */\n onFinish?: () => void;\n onSkip?: () => void;\n}\n\n/** What `TourProvider`'s `onComplete` learns besides the tour (§9.1, §9.6). */\nexport interface TourCompletion {\n /**\n * `true` when the completion counts anew (the first time, or the first time after the\n * tour's update, §8): the moment for the app's points toast. `false` for a replay, and\n * when the stored text is in an old shape no `migrate` reads: nothing is overwritten\n * then, and the error goes to `console.error` (keksdose B-1). `undefined` when the provider has no `progress` or the start carried no `tour`, so\n * nothing was recorded.\n */\n awarded: boolean | undefined;\n}\n\ninterface TourContextValue {\n active: boolean;\n /** Id of the running tour (from {@link StartOptions.id}), else null. */\n activeId: string | null;\n /**\n * Start a tour with the given steps — or, by id (0.50), through the provider's `launch`:\n * `start(\"create-transaction\", { at: \"txn-entry-mode\" })`. Without a `launch` the id form\n * does nothing (a development build warns).\n */\n start: {\n // The id form first: `Parameters<typeof start>` reads the LAST overload, which stays\n // the 0.49 one.\n (id: string, opts?: { at?: TourAt }): void;\n (steps: TourStep[], opts?: StartOptions): void;\n };\n /** End the current tour (no callbacks fire). */\n stop: () => void;\n /** Advance one step; past the last step it finishes the tour (fires onFinish). */\n next: () => void;\n /** Go back one step (no-op on the first). */\n prev: () => void;\n /** Jump to a step by index, clamped to range — e.g. for URL/deep-link resume. */\n goToStep: (index: number) => void;\n /** Current step (0-based; 0 while inactive). */\n index: number;\n /** Total steps (0 while inactive). */\n total: number;\n /** 0.50: 1-based position among the steps this run shows, for \"3 of 9\"; 0 while inactive. */\n position: number;\n /** 0.50: how many steps this run shows, from its first (the `at` floor) to the end; 0 while inactive. */\n count: number;\n}\n\nconst TourContext = createContext<TourContextValue | null>(null);\n\nexport function useTour(): TourContextValue {\n const ctx = useContext(TourContext);\n if (!ctx) throw new Error(\"useTour must be used within <TourProvider>\");\n return ctx;\n}\n\n/**\n * The tour engine if it is there, `null` if it is not — for a control that is a\n * DECORATION rather than a participant.\n *\n * {@link useTour}'s throw is correct and stays: a component that runs a tour cannot do\n * its job without the provider, and failing loudly is how that gets fixed. But the\n * throw's blast radius is whatever error boundary is above it, and for a launcher in\n * the app shell that is the whole app.\n *\n * Keksdose feedback dev#524 is what that costs: an `@hb/ui` module was edited while a\n * dev server was running, vite re-evaluated it, and the module's freshly created\n * context object was no longer the one the mounted provider was providing. React's\n * `useContext` then answers `null` for a provider that is, structurally, right there —\n * and the top bar's tour menu took the entire shell down with it. **Build-time module\n * graphs cannot produce that**, so it is a development-only failure; a menu that\n * disappears for a second is the proportionate response to it either way.\n *\n * Only for controls that can honestly render nothing. If a component would show a\n * broken half of itself without the tour, it wants {@link useTour}.\n */\nexport function useTourOptional(): TourContextValue | null {\n return useContext(TourContext);\n}\n\n/**\n * Provides the guided-tour engine: a dimmed spotlight overlay + step card driven\n * by a list of {@link TourStep}s. Domain-free — the app supplies the steps (copy,\n * selectors, per-step navigation, placement) and the translated {@link TourLabels}.\n * Mount once inside the router; start a tour from anywhere via {@link useTour},\n * which also exposes step control (`next`/`prev`/`goToStep`) and the current\n * `index`/`total` for URL mirroring, `awaitClick` and deep-link resume.\n *\n * **Completion in one place** (docs/tours-harmonization.md §9.6): give the provider the\n * app's `progress` (the same `{storageKey, migrate}` as `useTourProgress`) and start each\n * tour with `start(steps, {tour})`. When the last step is finished the provider writes the\n * completion ONCE, through the store every `useTourProgress` reader of the key shares\n * (never a second copy), then calls `onComplete(tour, {awarded})`, then the start's own\n * `onFinish`. A skip or `stop()` records nothing and calls neither. The app removes its\n * own `complete()` from `onFinish`, or that second write answers `false`.\n *\n * Both props are optional: without `progress` or a `tour` on the start, `onComplete`\n * still fires, with `awarded: undefined` (and `tour` as given, possibly `undefined`). A\n * new `storageKey` (an account switch on a shared PC) is followed on the next\n * completion, without a remount.\n */\nexport function TourProvider({\n children,\n labels,\n progress,\n onComplete,\n launch,\n dockOnPhones = true,\n}: {\n children: ReactNode;\n labels?: LabelOverride<TourLabels>;\n /**\n * 0.50 (§11.5): lets `start(id)` and `<TourGuideButton>` start a tour by id. Usually the\n * same function the app gives `useTourUrlSync`.\n */\n launch?: TourLauncher;\n /** The app's tour progress: the same options its `useTourProgress` readers use. */\n progress?: UseTourProgressOptions;\n /** A tour's last step was finished; see {@link TourCompletion}. */\n onComplete?: (tour: TourInfo | undefined, completion: TourCompletion) => void;\n /**\n * 0.50 (§11.7, Marcel's Q1): below `sm`, a field step with a target and no `placement`\n * docks. Default `true`; `false` makes docking strictly opt-in (`placement: \"dock\"`).\n */\n dockOnPhones?: boolean;\n}) {\n // `labels` over the provider's `tour` over English. Resolved once here and handed\n // down: the step card is portalled, but context crosses portals anyway — this is\n // simply the one place that already owned the merge.\n const merged = useKitLabels(\"tour\", DEFAULT_TOUR_LABELS, labels);\n const [steps, setSteps] = useState<TourStep[] | null>(null);\n // Where the run is: the raw index (what `?tourStep=` mirrors), how it got there, and\n // its place among the steps shown (§11.3), computed once on arrival.\n const [nav, setNav] = useState<Nav>(NO_NAV);\n const index = nav.index;\n // The app's last `refuse` on the step awaiting its key; any arrival clears it.\n const [refusal, setRefusal] = useState<Refusal | null>(null);\n const [activeId, setActiveId] = useState<string | null>(null);\n const optsRef = useRef<StartOptions>({});\n // The latest props, read at the finish: a new `storageKey` or callback needs no remount.\n const progressRef = useRef(progress);\n const onCompleteRef = useRef(onComplete);\n const launchRef = useRef(launch);\n useLayoutEffect(() => {\n progressRef.current = progress;\n onCompleteRef.current = onComplete;\n launchRef.current = launch;\n });\n // The provider's migrate becomes the key's, for readers that pass none (keksdose B-2).\n const storageKey = progress?.storageKey;\n const migrate = progress?.migrate;\n // 0.45: and its `account` (§10.3), so a finish on an account key is sent as readers' are.\n const account = progress?.account;\n useLayoutEffect(() => {\n if (storageKey !== undefined) rememberMigrate(storageKey, migrate);\n if (storageKey !== undefined) rememberAccount(storageKey, account);\n }, [storageKey, migrate, account]);\n const warnedNoTourRef = useRef(false);\n // Live mirrors so the step-control callbacks can stay stable (identity-safe for\n // consumers) while still reading the current steps/index. Synced in a layout\n // effect — after the commit, before paint and before any passive effect or event\n // can call them — rather than written during render.\n const stepsRef = useRef<TourStep[] | null>(null);\n const indexRef = useRef(0);\n useLayoutEffect(() => {\n stepsRef.current = steps;\n indexRef.current = index;\n }, [steps, index]);\n /** The run's first step: earlier steps never run, Back stops here (the `at` floor). */\n const floorRef = useRef(0);\n const active = !!steps && steps.length > 0;\n const total = steps?.length ?? 0;\n // The gate registry (§11.1): one per provider, read by the overlay while a tour runs.\n const [gates] = useState(createGateRegistry);\n useLayoutEffect(() => {\n gates.setActive(active);\n }, [gates, active]);\n const canLaunch = !!launch;\n const internals = useMemo(() => ({ gates, canLaunch }), [gates, canLaunch]);\n\n /** Is step `i` shown, asked now (§11.3)? */\n const shown = useCallback(\n (s: TourStep[], i: number, via: TourStepContext[\"via\"]) => isShown(s[i], stepContext(gates, via)),\n [gates],\n );\n /** Arrive at `i`: the counter is recomputed from every step's `when`, against the gates now. */\n const arrive = useCallback(\n (s: TourStep[], i: number, via: TourStepContext[\"via\"]) => {\n const ctx = stepContext(gates, via);\n let position = 0;\n let count = 0;\n for (let j = floorRef.current; j < s.length; j++) {\n if (j !== i && !isShown(s[j], ctx)) continue;\n count++;\n if (j <= i) position++;\n }\n indexRef.current = i;\n setRefusal(null);\n setNav({ index: i, floor: floorRef.current, via, position, count });\n },\n [gates],\n );\n /** The first step shown at or after `from`, or -1. */\n const forward = useCallback(\n (s: TourStep[], from: number, via: TourStepContext[\"via\"]) => {\n for (let j = Math.max(from, floorRef.current); j < s.length; j++) if (shown(s, j, via)) return j;\n return -1;\n },\n [shown],\n );\n /** The nearest step shown at or before `from`, not below the floor, or -1. */\n const backward = useCallback(\n (s: TourStep[], from: number, via: TourStepContext[\"via\"]) => {\n for (let j = Math.min(from, s.length - 1); j >= floorRef.current; j--) if (shown(s, j, via)) return j;\n return -1;\n },\n [shown],\n );\n\n const startSteps = useCallback(\n (s: TourStep[], opts?: StartOptions) => {\n optsRef.current = opts ?? {};\n optsRef.current.onStart?.();\n const last = Math.max(0, s.length - 1);\n floorRef.current = opts?.at === undefined ? 0 : resolveAt(s, opts.at);\n const via: TourStepContext[\"via\"] = opts?.at === undefined ? \"start\" : \"at\";\n // Floored, as `at` is (FLW-9): `steps[1.5]` is undefined, and `forward` threw on\n // its `when` — an edited `?tourStep=2.5` was enough.\n const asked = opts?.startIndex === undefined ? floorRef.current : Math.floor(opts.startIndex);\n const wanted = Math.min(Math.max(floorRef.current, asked), last);\n let to = forward(s, wanted, via);\n if (to < 0) to = backward(s, wanted, via);\n // Not one step of the run is shown: there is nothing to tour.\n if (to < 0) return;\n arrive(s, to, via);\n setActiveId(opts?.id ?? opts?.tour?.id ?? null);\n setSteps(s);\n },\n [arrive, forward, backward],\n );\n // The provider's own `start` and the live engine, handed to `launch` as its third and\n // fourth arguments (keksdose N4, N1).\n const ownStartRef = useRef<TourContextValue[\"start\"] | null>(null);\n const [live] = useState(() => liveEngine<TourEngine>(ENGINE_KEYS));\n const engine = live.engine;\n const start = useCallback(\n (what: TourStep[] | string, opts?: StartOptions | { at?: TourAt }) => {\n if (typeof what !== \"string\") {\n startSteps(what, opts as StartOptions | undefined);\n return;\n }\n const run = launchRef.current;\n if (!run) {\n if (devWarnings()) console.warn(`[ui-kit] start(\"${what}\") needs TourProvider's \\`launch\\` prop.`);\n return;\n }\n void Promise.resolve(run(what, { at: opts?.at }, ownStartRef.current!, engine)).catch((error: unknown) =>\n console.error(error),\n );\n },\n [startSteps, engine],\n ) as TourContextValue[\"start\"];\n useLayoutEffect(() => {\n ownStartRef.current = start;\n }, [start]);\n const stop = useCallback(() => {\n setSteps(null);\n setActiveId(null);\n }, []);\n const finish = useCallback(() => {\n // Once per tour: a second \"Done\" before the overlay unmounts records nothing more.\n if (!stepsRef.current) return;\n stepsRef.current = null;\n const { tour, onFinish } = optsRef.current;\n const store = progressRef.current;\n // Exactly one write per completion (§9.6.2), so `awarded` is what `complete(tour)` answered.\n let awarded: boolean | undefined;\n if (store && tour) {\n try {\n awarded = completeStored(store.storageKey, store.migrate, tour);\n } catch (error) {\n // A stored text no migrate reads is left as it is (keksdose B-1); the tour still ends.\n console.error(error);\n awarded = false;\n }\n } else if (store && !tour && devWarnings() && !warnedNoTourRef.current) {\n warnedNoTourRef.current = true;\n console.warn(\n \"[ui-kit] TourProvider has `progress`, but a finished tour's start carried no `tour`: \" +\n \"nothing was recorded and `awarded` is undefined. Start it with `start(steps, { tour })`.\",\n );\n }\n onCompleteRef.current?.(tour, { awarded });\n onFinish?.();\n setSteps(null);\n setActiveId(null);\n }, []);\n const skip = useCallback(() => {\n optsRef.current.onSkip?.();\n setSteps(null);\n setActiveId(null);\n }, []);\n\n // A step whose `when` is false is passed over: `goToStep` lands on the next step shown\n // after it, failing that the previous one; Next past the last shown step finishes.\n const goToStep = useCallback(\n (i: number) => {\n const s = stepsRef.current;\n if (!s || s.length === 0) return;\n const wanted = Math.min(Math.max(floorRef.current, Math.floor(i)), s.length - 1);\n let to = forward(s, wanted, \"goto\");\n if (to < 0) to = backward(s, wanted, \"goto\");\n if (to >= 0) arrive(s, to, \"goto\");\n },\n [arrive, forward, backward],\n );\n const next = useCallback(() => {\n const s = stepsRef.current;\n if (!s || s.length === 0) return;\n const to = forward(s, indexRef.current + 1, \"next\");\n if (to < 0) finish();\n else arrive(s, to, \"next\");\n }, [arrive, forward, finish]);\n const prev = useCallback(() => {\n const s = stepsRef.current;\n if (!s) return;\n const to = backward(s, indexRef.current - 1, \"back\");\n if (to >= 0) arrive(s, to, \"back\");\n }, [arrive, backward]);\n\n // awaitGate (§11.4): `release` and `refuse` are events, heard only while a tour runs.\n useEffect(() => {\n if (!active) return;\n let seq = 0;\n return gates.listen((signal) => {\n const s = stepsRef.current;\n if (!s) return;\n const i = indexRef.current;\n if (signal.kind === \"refuse\") {\n // On any other step the form's own errors speak.\n if (s[i]?.awaitGate === signal.key) setRefusal({ step: s[i], reason: signal.reason, seq: ++seq });\n return;\n }\n // The step awaiting it, or the first later one: the record is saved, so the fields\n // between are passed over.\n const awaiting =\n s[i]?.awaitGate === signal.key ? i : s.findIndex((st, k) => k > i && st.awaitGate === signal.key);\n if (awaiting < 0) return;\n const to = forward(s, awaiting + 1, \"next\");\n if (to < 0) finish();\n else arrive(s, to, \"next\");\n });\n }, [active, gates, arrive, forward, finish]);\n\n const value: TourContextValue = {\n active,\n activeId,\n start,\n stop,\n next,\n prev,\n goToStep,\n index,\n total,\n position: active ? nav.position : 0,\n count: active ? nav.count : 0,\n };\n // Read by the live engine (`launch`'s fourth argument) after this render commits.\n useLayoutEffect(() => {\n live.set(value);\n });\n\n return (\n <TourInternalContext.Provider value={internals}>\n <TourContext.Provider value={value}>\n {children}\n {active && (\n <TourOverlay\n steps={steps!}\n index={index}\n via={nav.via}\n floor={nav.floor}\n position={nav.position}\n count={nav.count}\n refusal={refusal?.step === steps![index] ? refusal : null}\n onGoTo={goToStep}\n labels={merged}\n gates={gates}\n dockOnPhones={dockOnPhones}\n onNext={next}\n onPrev={prev}\n onSkip={skip}\n />\n )}\n </TourContext.Provider>\n </TourInternalContext.Provider>\n );\n}\n\ninterface Nav {\n index: number;\n /** The run's first step (the `at` floor). */\n floor: number;\n via: TourStepContext[\"via\"];\n position: number;\n count: number;\n}\n\nconst NO_NAV: Nav = { index: 0, floor: 0, via: \"start\", position: 0, count: 0 };\n\n/** The app's `refuse` on the step that awaits its key (§11.4). */\ninterface Refusal {\n step: TourStep;\n reason?: string;\n /** Bumped per refusal, so the same words are announced again. */\n seq: number;\n}\n\nconst NOOP = () => {};\n\nfunction stepContext(gates: GateRegistry, via: TourStepContext[\"via\"]): TourStepContext {\n return { gate: (key) => gates.get(key), via };\n}\n\n/** `StartOptions.at` as a step index: a number clamped, an anchor's first step, else 0. */\nfunction resolveAt(steps: TourStep[], at: TourAt): number {\n if (typeof at === \"number\") return Math.min(Math.max(0, Math.floor(at)), Math.max(0, steps.length - 1));\n const anchor = `data-tour=\"${at}\"`;\n const found = steps.findIndex((step) => step.target?.includes(anchor));\n if (found >= 0) return found;\n if (devWarnings())\n console.warn(`[ui-kit] A tour was started at \"${at}\", but no step targets [${anchor}]: it starts at 0.`);\n return 0;\n}\n\n/** The first step in [floor, index) shown now whose gate is published and unsatisfied, or -1. */\nfunction firstEmptied(steps: TourStep[], floor: number, index: number, gates: GateRegistry): number {\n const ctx = stepContext(gates, \"goto\");\n for (let j = floor; j < index; j++) {\n const key = steps[j].gate;\n if (key && gates.get(key) === false && isShown(steps[j], ctx)) return j;\n }\n return -1;\n}\n\n/** A step's `when`, asked now; a throw is a skip, and the error goes to the console. */\nfunction isShown(step: TourStep, ctx: TourStepContext): boolean {\n if (!step.when) return true;\n try {\n return step.when(ctx) === true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\ninterface Rect {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\nfunction isVisible(el: Element): boolean {\n // A non-zero box already rules out display:none on the element or any ancestor\n // (an unrendered element measures 0x0). We deliberately do NOT test\n // offsetParent: it is null for position:fixed elements even when fully visible,\n // which made the mobile bottom-nav bar (fixed) un-highlightable on mobile\n // (feedback #313). visibility:hidden keeps a box, so check it explicitly.\n const r = el.getBoundingClientRect();\n if (r.width <= 0 || r.height <= 0) return false;\n const style = getComputedStyle(el);\n return style.visibility !== \"hidden\" && style.display !== \"none\";\n}\n\n// The first VISIBLE element matching the selector, not merely the first in DOM\n// order. This lets a step target the same control across layouts with one\n// combined selector — e.g. the desktop sidebar link AND the mobile bottom-bar\n// link — where the off-layout copy is present but `display:none` (feedback\n// #313). Returns null while none is visible so the finder keeps retrying.\nfunction queryVisibleTarget(selector: string): Element | null {\n const els = document.querySelectorAll(selector);\n for (const el of els) {\n if (isVisible(el)) return el;\n }\n return null;\n}\n\nfunction rectOf(el: Element): Rect {\n const r = el.getBoundingClientRect();\n return { top: r.top, left: r.left, width: r.width, height: r.height };\n}\n\n/** The two-tone frame's width outside the spot (3px white, 2px keyline), plus a pixel. */\nconst RING_BAND = 6;\n\n/**\n * What a step's ring frames (keksdose S1, §11.6): the target, and on a FIELD step also the\n * lines that describe the field from outside it — the elements its `aria-describedby`\n * (on the target or a control inside) names that lie within the ring's reach of it (a\n * caption, a hint or warning line, an error drawn under or above the field). Without\n * them the ring's frame ran through such a line; with them it frames field and line, and\n * the line is lit, not under the scrim. A kit field's own caption and error are inside\n * its root already. A line far away (a tooltip, another part of the page) is not taken.\n */\nfunction spotRectOf(el: Element, step: TourStep): Rect {\n const own = rectOf(el);\n if (!isFieldStep(step)) return own;\n const ids = new Set<string>();\n const holders = [el, ...Array.from(el.querySelectorAll(\"[aria-describedby]\"))];\n for (const holder of holders) {\n for (const id of (holder.getAttribute(\"aria-describedby\") ?? \"\").split(/\\s+/)) if (id) ids.add(id);\n }\n if (ids.size === 0) return own;\n const lines: DOMRect[] = [];\n for (const id of ids) {\n const line = document.getElementById(id);\n if (!line || el.contains(line) || line.closest('[role=\"tooltip\"]') || !isVisible(line)) continue;\n const r = line.getBoundingClientRect();\n // An `sr-only` description measures 1×1: nothing to frame.\n if (r.width > 1 && r.height > 1) lines.push(r);\n }\n let top = own.top;\n let left = own.left;\n let right = own.left + own.width;\n let bottom = own.top + own.height;\n const reach = (step.padding ?? 8) + RING_BAND;\n // Grow until nothing more is in reach: a hint under the field, then an error under it.\n for (let grew = true; grew;) {\n grew = false;\n for (let i = lines.length - 1; i >= 0; i--) {\n const r = lines[i];\n const across = r.left < right && r.right > left;\n const gap = Math.max(r.top - bottom, top - r.bottom);\n if (!across || gap > reach) continue;\n top = Math.min(top, r.top);\n left = Math.min(left, r.left);\n right = Math.max(right, r.right);\n bottom = Math.max(bottom, r.bottom);\n lines.splice(i, 1);\n grew = true;\n }\n }\n return { top, left, width: right - left, height: bottom - top };\n}\n\n/**\n * What the finder established for ONE step: where its target is (`null` = no target,\n * or not on the page), and the reading direction the card takes from it.\n *\n * It carries the step it was found for, and the overlay only believes it for that\n * step — which is the whole fix for keksdose's tours audit 2026-10-02, §1.0 A (\"stale\n * spotlight on the step after a spotlighted one\", 15 steps in 16 tours, desktop and\n * phone, mouse and keyboard). When step N spotlit a target and step N+1 had none (or\n * its anchor was missing), N+1 kept N's hole and parked its card beside it, so a\n * centred \"You're all set\" read as pointing at the Import & Export link; Back→Next kept\n * it for as long as anyone watched.\n *\n * The overlay used to hold `rect` and `ready` as separate states and reset them\n * DURING RENDER when the step changed. React 19 does not keep a render-phase update\n * while an earlier, lower-priority update to the same hook is still queued — it only\n * writes the result to the base state \"unless the queue is empty\" — and the follow\n * interval below queues exactly such an update every 250 ms (eagerly bailed out because\n * the rect had not moved, but left in the queue for rebasing). So the click's render\n * showed the reset, and the very next render (the finder saying \"ready\") re-based on\n * the old rect. A deep link was fine because nothing had queued anything yet.\n *\n * Keying the result to its step does not depend on any of that ordering: a rect found\n * for another step is not this step's rect, whatever the queue does with it, and a\n * missing anchor reads as \"no target\" instead of as the last thing that was lit.\n */\ninterface Located {\n index: number;\n step: TourStep;\n rect: Rect | null;\n dir: Direction;\n /**\n * A field step's own container (§11.6): inserted right after the kit layer holding the\n * target (`host.after`), or at the end of <body> on the page. `null` on a plain step,\n * which is portalled to <body> at z-[60] as ever.\n */\n layer: HTMLElement | null;\n /** The host fills the visual viewport (a phone's FullBleedDialog): no scrim, no shields. */\n fullScreen: boolean;\n}\n\n/** The kit layer (`data-kit-layer`) holding `el`, if any. */\nfunction layerHost(el: Element): HTMLElement | null {\n return el.closest<HTMLElement>(\"[data-kit-layer]\");\n}\n\n/**\n * Does the host fill the visual viewport? A backdrop host (`data-kit-layer=\"backdrop\"`:\n * Modal, FullBleedDialog) is judged by its panel, the child holding the target.\n */\nfunction coversViewport(host: HTMLElement, el: Element): boolean {\n let surface: Element = host;\n if (host.getAttribute(\"data-kit-layer\") === \"backdrop\") {\n for (const child of Array.from(host.children)) {\n if (child.contains(el)) {\n surface = child;\n break;\n }\n }\n }\n const r = surface.getBoundingClientRect();\n const vv = window.visualViewport;\n const top = vv?.offsetTop ?? 0;\n const bottom = top + (vv?.height ?? window.innerHeight);\n const width = vv?.width ?? window.innerWidth;\n return r.width > 0 && r.left <= 1 && r.top <= top + 1 && r.right >= width - 1 && r.bottom >= bottom - 1;\n}\n\n/** Does this step's card dock now (§11.7)? A phone-width viewport, and `\"dock\"` or a field\n * step with no placement while the provider docks on phones. */\nfunction docks(step: TourStep, dockOnPhones: boolean): boolean {\n if (typeof window === \"undefined\" || window.innerWidth >= DOCK_MAX_WIDTH || !step.target) return false;\n return step.placement === \"dock\" || (step.placement === undefined && dockOnPhones && isFieldStep(step));\n}\n\n/** A step whose control is for using: its card joins the layer stack above the field (§11.6). */\nfunction isFieldStep(step: TourStep): boolean {\n return !!(step.interactive || step.awaitInput || step.gate || step.awaitGate);\n}\n\n/** The first control in `el` (or `el` itself) a person would type into or press. */\nfunction firstFocusable(el: Element): HTMLElement | null {\n if (el instanceof HTMLElement && el.matches(FOCUSABLE_CONTROL)) return el;\n return el.querySelector<HTMLElement>(FOCUSABLE_CONTROL);\n}\n\n/** The tab stops inside `el`, in DOM order (the focus trap's selector). */\nfunction tabStops(el: Element): HTMLElement[] {\n const all = el.matches(FOCUSABLE_CONTROL) ? [el as HTMLElement] : [];\n return all.concat(\n Array.from(el.querySelectorAll<HTMLElement>(FOCUSABLE_CONTROL)).filter(\n (x) => x.tabIndex >= 0 && !x.closest(\"[hidden],[inert]\"),\n ),\n );\n}\n\nconst FOCUSABLE_CONTROL =\n 'a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex=\"-1\"])';\n\n/** A touch screen: the card takes focus, so no keyboard or pad opens before the step is read (§11.8). */\nfunction coarsePointer(): boolean {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\"\n ? window.matchMedia(\"(pointer: coarse)\").matches\n : false;\n}\n\nfunction TourOverlay({\n steps,\n index,\n via,\n floor,\n position,\n count,\n refusal,\n onGoTo,\n labels,\n gates,\n dockOnPhones,\n onNext,\n onPrev,\n onSkip,\n}: {\n steps: TourStep[];\n index: number;\n via: TourStepContext[\"via\"];\n floor: number;\n /** The app refused this step's save (§11.4). */\n refusal: Refusal | null;\n onGoTo: (index: number) => void;\n /** 1-based among the steps shown; Back is hidden on the first, Done on the last. */\n position: number;\n count: number;\n labels: TourLabels;\n gates: GateRegistry;\n dockOnPhones: boolean;\n onNext: () => void;\n onPrev: () => void;\n onSkip: () => void;\n}) {\n const step = steps[index];\n const isFirst = position <= 1;\n const isLast = position >= count;\n // A new step starts unlocated: whatever was found for another step (see `Located`)\n // is ignored, so the overlay renders nothing until the effect below has located THIS\n // step, and never the previous step's spotlight.\n const [located, setLocated] = useState<Located | null>(null);\n const current = located !== null && located.index === index && located.step === step ? located : null;\n const ready = current !== null;\n const rect = current?.rect ?? null;\n // The overlay is portalled to <body>, out of whatever `dir` subtree the app set, so it\n // takes the direction of the element it spotlights (the document's for a centered\n // step). Arrow keys and start/end placement read it.\n const dir: Direction = current?.dir ?? \"ltr\";\n const rootRef = useRef<HTMLDivElement>(null);\n const cardRef = useRef<HTMLDivElement>(null);\n const bodyId = useId();\n const hintId = useId();\n\n // The gate (§11.1). Re-rendered on every registry change while the tour runs.\n const gateVersion = useSyncExternalStore(gates.subscribe, gates.version, gates.version);\n const gateKey = step.gate;\n const enforced = !!gateKey && gates.has(gateKey);\n const locked = enforced && gates.get(gateKey) !== true;\n\n // The polite live region (§11.8): `gateReady` once a gate opens, the hint on a locked\n // Next. A repeat of the same words gets a trailing zero-width space so it is read again.\n const [polite, setPolite] = useState(\"\");\n const announce = useCallback((text: string) => {\n setPolite((prev) => (prev === text ? `${text}\\u200b` : text));\n }, []);\n\n // Run beforeStep, then locate the target (retrying across route/render lag).\n useEffect(() => {\n let cancelled = false;\n let raf = 0;\n // `null` = untargeted, or the finder gave up → the card centres, with no hole.\n const settle = (el: Element | null) => {\n let layer: HTMLElement | null = null;\n let fullScreen = false;\n if (el && isFieldStep(step)) {\n // §11.6: directly above the layer holding the field — DOM order decides between\n // the kit's z-50 body children, so this paints over the host and everything opened\n // before it, and under whatever the field opens next (a list, the number pad).\n const host = layerHost(el);\n layer = document.createElement(\"div\");\n layer.setAttribute(\"data-tour-layer\", \"\");\n if (host) host.after(layer);\n else document.body.appendChild(layer);\n fullScreen = !!host && coversViewport(host, el);\n }\n setLocated({ index, step, rect: el ? spotRectOf(el, step) : null, dir: dirOf(el), layer, fullScreen });\n };\n void (async () => {\n try {\n await step.beforeStep?.(stepContext(gates, via));\n } catch (error) {\n // The step is shown anyway (FLW-5): left unlocated, the tour stayed `active`\n // with no card, no scrim and no Escape layer, and everything keyed on \"a tour\n // runs\" (the `?tour=` mirror, the apps' PWA-update hold) stayed on with it. The\n // target may well be there regardless; if not, the finder gives up and centres.\n console.error(error);\n }\n if (cancelled) return;\n if (!step.target) {\n settle(null);\n return;\n }\n let tries = 0;\n const find = () => {\n if (cancelled) return;\n const el = queryVisibleTarget(step.target!);\n if (el) {\n // A docked step scrolls the field into the half the card leaves free, through\n // the field's own scroll container (§11.7); any other centres it, as ever.\n if (docks(step, dockOnPhones)) scrollIntoFreeHalf(el, null, null);\n else el.scrollIntoView({ block: \"center\", behavior: \"smooth\" });\n settle(el);\n return;\n }\n if (tries++ < 45) raf = requestAnimationFrame(find);\n else settle(null); // give up → render centered\n };\n find();\n })();\n return () => {\n cancelled = true;\n cancelAnimationFrame(raf);\n };\n // `via` and the gates are read at arrival, not followed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [index, step]);\n\n // Follow the target as the page scrolls / reflows — only once THIS step is located,\n // and only into this step's result.\n useEffect(() => {\n if (!step.target) return;\n const update = () => {\n const el = queryVisibleTarget(step.target!);\n if (el) {\n const next = spotRectOf(el, step);\n // A sheet that grows to full screen (or shrinks from it) takes or drops the scrim.\n const host = layerHost(el);\n const full = !!host && coversViewport(host, el);\n setLocated((prev) => {\n if (!prev || prev.index !== index || prev.step !== step) return prev;\n const fullScreen = prev.layer ? full : prev.fullScreen;\n if (sameRect(prev.rect, next) && fullScreen === prev.fullScreen) return prev;\n return { ...prev, rect: next, fullScreen };\n });\n }\n };\n window.addEventListener(\"scroll\", update, true);\n window.addEventListener(\"resize\", update);\n const id = window.setInterval(update, 250);\n return () => {\n window.removeEventListener(\"scroll\", update, true);\n window.removeEventListener(\"resize\", update);\n clearInterval(id);\n };\n }, [index, step]);\n\n // A field step's container goes with the step (and with the tour).\n const layer = located?.layer ?? null;\n useEffect(() => {\n if (!layer) return;\n return () => layer.remove();\n }, [layer]);\n\n // Escape (§11.6.4): the tour is a layer on the kit's Escape stack, pushed on each\n // arrival, so it sits above the sheet holding the form. Escape from the card skips the\n // tour and no longer also closes that sheet; a layer the field opens afterwards (a\n // list, the pad) is above the tour and takes Escape first. An Escape pressed in the\n // field itself belongs to the field: the tour lets it pass by doing nothing.\n useDismissLayer(\n ready,\n (e) => {\n if (fieldStepNow && step.target && e.target instanceof Node) {\n const el = queryVisibleTarget(step.target);\n if (el?.contains(e.target)) return;\n }\n onSkip();\n },\n // Not an overlay to `useOverlayOpen`: a floating launcher a tour spotlights stays.\n { overlay: false },\n );\n\n // awaitClick: advance when the *real* target is clicked. The spotlight hole is\n // click-through (see the shields in the render below) so the element's own\n // handler runs first; we step forward on the next macrotask.\n //\n // Re-armed when the target turns up after the finder gave up (the follow effect\n // lights it late): the card swaps Next for the \"click the highlighted element\" hint\n // as soon as there is a rect, so the click must work from that moment too.\n const spotted = rect !== null;\n useEffect(() => {\n if (!ready || !spotted || !step.awaitClick || !step.target) return;\n const el = queryVisibleTarget(step.target);\n if (!el) return;\n const onClick = () => window.setTimeout(() => onNext(), 0);\n el.addEventListener(\"click\", onClick, { once: true });\n return () => el.removeEventListener(\"click\", onClick);\n }, [ready, spotted, index, step, onNext]);\n\n // A field step (see `TourStep.interactive`): only while the target is lit — a step\n // whose target is missing centres its card over a full scrim, modal as ever.\n const interactive =\n spotted && !!step.target && !!(step.interactive || step.awaitInput || step.gate || step.awaitGate);\n // A GUIDED field step (§11.8): focus goes to the field on a fine pointer, and Tab\n // cycles field + card. A plain `interactive` step keeps the card's own trap.\n const guided = interactive && !!(step.gate || step.awaitInput || step.awaitGate);\n const fieldStepNow = interactive;\n // An awaitGate step whose target is lit: only `release` moves it (a missing Save\n // button would otherwise be a dead end, as for awaitClick).\n const awaitsRelease = spotted && !!step.target && !!step.awaitGate;\n\n // A gate nobody publishes is not enforced: Next opens, and a development build says why\n // (on arrival, or when its publisher unmounts under the step), once per step.\n const warnedGateRef = useRef<TourStep | null>(null);\n useEffect(() => {\n if (!ready || !gateKey || gates.has(gateKey) || !devWarnings() || warnedGateRef.current === step) return;\n warnedGateRef.current = step;\n console.warn(\n `[ui-kit] Tour step \"${step.title}\" waits for the gate \"${gateKey}\", which nothing publishes: its Next is open. ` +\n \"Publish it with useTourGate beside the field, or the form has closed under the tour.\",\n );\n }, [ready, gateKey, gates, step, gateVersion]);\n\n // `optional` means \"may stay EMPTY\": without a gate there is no value to compare.\n useEffect(() => {\n if (!ready || !step.optional || step.gate || !devWarnings()) return;\n console.warn(\n `[ui-kit] Tour step \"${step.title}\" is \\`optional\\` without a \\`gate\\`: it shows the Optional chip ` +\n 'and a plain Next. \"Leave empty\" needs a gate to compare.',\n );\n }, [ready, step]);\n\n // \"Ready\" once, when this step's gate turns satisfied (not when it arrives satisfied).\n const wasLockedRef = useRef<{ step: TourStep; locked: boolean } | null>(null);\n useEffect(() => {\n if (!ready || !gateKey) return;\n const before = wasLockedRef.current;\n if (before && before.step === step && before.locked && !locked && enforced) announce(labels.gateReady);\n wasLockedRef.current = { step, locked };\n }, [ready, gateKey, step, locked, enforced, announce, labels.gateReady]);\n\n // Arrival on a guided step: the field takes focus on a fine pointer, the card on a\n // coarse one; the field is described by the card's body while the step lasts.\n // Declared BEFORE the advance listeners below, so the focus it moves is not mistaken\n // for the person leaving the field.\n useEffect(() => {\n if (!ready || !guided || !step.target) return;\n const el = queryVisibleTarget(step.target);\n const control = el ? firstFocusable(el) : null;\n // Described BEFORE it is focused, so a screen reader reads the step with the field's\n // name. Focused quietly (0.50.1, keksdose B1): a picker that opens on focus stays\n // closed, or its list would cover the card; ArrowDown, typing or a click opens it.\n const previous = control ? control.getAttribute(\"aria-describedby\") : null;\n if (control) control.setAttribute(\"aria-describedby\", previous ? `${previous} ${bodyId}` : bodyId);\n if (coarsePointer() || !control) cardRef.current?.focus();\n else if (!el!.contains(document.activeElement)) focusQuietly(control);\n if (!control) return;\n return () => {\n if (previous === null) control.removeAttribute(\"aria-describedby\");\n else control.setAttribute(\"aria-describedby\", previous);\n };\n }, [ready, guided, index, step, bodyId]);\n\n // Tab on a guided step cycles field + card as one ring (§11.8): from the field's last\n // stop to the card's first, from the card's last back to the field. Captured on the\n // document, ahead of a sheet's own trap, which would wrap inside the sheet.\n useEffect(() => {\n if (!ready || !guided || !step.target) return;\n const onTab = (e: KeyboardEvent) => {\n if (e.key !== \"Tab\") return;\n const el = queryVisibleTarget(step.target!);\n const card = cardRef.current;\n if (!el || !card) return;\n const active = document.activeElement;\n const fieldStops = tabStops(el);\n const cardStops = tabStops(card);\n if (fieldStops.length === 0 || cardStops.length === 0) return;\n let to: HTMLElement | null = null;\n if (active instanceof Node && el.contains(active)) {\n if (!e.shiftKey && active === fieldStops[fieldStops.length - 1]) to = cardStops[0];\n else if (e.shiftKey && active === fieldStops[0]) to = cardStops[cardStops.length - 1];\n } else if (active instanceof Node && card.contains(active)) {\n if (!e.shiftKey && active === cardStops[cardStops.length - 1]) to = fieldStops[0];\n else if (e.shiftKey && (active === cardStops[0] || active === card)) to = fieldStops[fieldStops.length - 1];\n }\n if (!to) return;\n e.preventDefault();\n e.stopPropagation();\n to.focus();\n };\n document.addEventListener(\"keydown\", onTab, true);\n return () => document.removeEventListener(\"keydown\", onTab, true);\n }, [ready, guided, index, step]);\n\n // gate: once satisfied, advance on Enter in the field (unless the control took it, or\n // a textarea without Ctrl/Cmd) or on focus leaving the field to nowhere or to the card.\n // Checked on the next macrotask, after the field's own blur/Enter commit has rendered.\n useEffect(() => {\n if (!ready || !spotted || !gateKey || !step.target) return;\n const el = queryVisibleTarget(step.target) as HTMLElement | null;\n if (!el) return;\n const satisfied = () => !gates.has(gateKey) || gates.get(gateKey) === true;\n let timer = 0;\n // Focus that was in the field when the step settled, or went there since. A focus\n // move the tour made itself (the card taking it on a phone) is not a leave.\n let armed = el.contains(document.activeElement);\n const check = () => {\n window.clearTimeout(timer);\n timer = window.setTimeout(() => {\n if (satisfied()) onNext();\n }, 0);\n };\n const onFocusIn = () => {\n armed = true;\n };\n const onFocusOut = (e: FocusEvent) => {\n const to = e.relatedTarget;\n if (to instanceof Node && el.contains(to)) return;\n const wasArmed = armed;\n armed = false;\n if (!wasArmed) return;\n if (to === null || (to instanceof Node && rootRef.current?.contains(to))) check();\n };\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== \"Enter\" || !(e.target instanceof Node) || !el.contains(e.target)) return;\n // Heard at the document, after React's handlers: a combobox picking an option has\n // called preventDefault by now.\n if (e.defaultPrevented || isComposing(e)) return;\n if (e.target instanceof HTMLTextAreaElement && !(e.ctrlKey || e.metaKey)) return;\n check();\n };\n el.addEventListener(\"focusin\", onFocusIn);\n el.addEventListener(\"focusout\", onFocusOut);\n document.addEventListener(\"keydown\", onKeyDown);\n return () => {\n window.clearTimeout(timer);\n el.removeEventListener(\"focusin\", onFocusIn);\n el.removeEventListener(\"focusout\", onFocusOut);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [ready, spotted, gateKey, gates, index, step, onNext]);\n\n // awaitInput: advance once the target's fields hold another value than when the step\n // was armed, checked when focus leaves the target or Enter is pressed in it — on the\n // next macrotask, after the field's own blur/Enter commit has rendered. A value the\n // number pad typed fires no native `change`, so comparing is what catches it.\n useEffect(() => {\n if (!ready || !spotted || !step.awaitInput || !step.target) return;\n const el = queryVisibleTarget(step.target) as HTMLElement | null;\n if (!el) return;\n const read = () => fieldValues(el);\n const before = read();\n let timer = 0;\n let done = false;\n const check = () => {\n window.clearTimeout(timer);\n timer = window.setTimeout(() => {\n if (done || read() === before) return;\n done = true;\n onNext();\n }, 0);\n };\n const onFocusOut = (e: FocusEvent) => {\n if (e.relatedTarget instanceof Node && el.contains(e.relatedTarget)) return;\n check();\n };\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Enter\") check();\n };\n el.addEventListener(\"focusout\", onFocusOut);\n el.addEventListener(\"keydown\", onKeyDown);\n el.addEventListener(\"change\", check);\n return () => {\n window.clearTimeout(timer);\n el.removeEventListener(\"focusout\", onFocusOut);\n el.removeEventListener(\"keydown\", onKeyDown);\n el.removeEventListener(\"change\", check);\n };\n }, [ready, spotted, index, step, onNext]);\n\n /** A press on the locked Next (or Enter / → from the card): no move; the field takes\n * focus and the hint is read again. */\n const gateHint = step.gateHint ?? labels.gateHint;\n const lockedNext = useCallback(() => {\n const el = step.target ? queryVisibleTarget(step.target) : null;\n const control = el ? firstFocusable(el) : null;\n // Quietly, as on arrival: the hint is read with the card in view, not under a list.\n if (control) focusQuietly(control);\n announce(gateHint);\n }, [step.target, announce, gateHint]);\n const tryNext = awaitsRelease ? NOOP : locked ? lockedNext : onNext;\n\n // After a refused save: the first earlier step shown whose field is now empty (§11.4).\n // Computed each render, which the gate subscription above triggers: a field filled\n // again drops the link.\n const backTo = refusal ? firstEmptied(steps, floor, index, gates) : -1;\n\n // Keyboard: Esc skips, Enter and the reading-direction arrow advance (→ in LTR,\n // ← in RTL), the other arrow goes back. On awaitClick steps Enter is ignored (it\n // would fire the target's click AND advance) — the forward arrow stays as an escape\n // hatch. On a locked gate step both are the locked Next.\n //\n // Enter on a focused control belongs to that control. This used to advance from\n // anywhere, so Enter on a focused Skip or Back ran the button's own click AND stepped\n // forward: Back moved nowhere, Skip skipped and then called `next` on a dead tour.\n // The same goes for arrows in a text field a step's `action` might contain.\n useEffect(() => {\n const onKey = (e: KeyboardEvent) => {\n // On an interactive step a key pressed in the target, or in a layer it opened (the\n // number pad's Escape, a menu's arrows), is the page's. The card's and the bare\n // page's (focus on <body>) stay the tour's.\n if (\n interactive &&\n e.target instanceof Node &&\n e.target !== document.body &&\n !rootRef.current?.contains(e.target)\n ) {\n return;\n }\n // Escape is the tour's Escape layer's (above) once the step is shown; while it is\n // still being located there is no layer yet, and the tour takes it here as in 0.49.\n if (e.key === \"Escape\") {\n if (!ready) onSkip();\n return;\n }\n // Nothing on screen to move on from: a step whose `beforeStep` is still running\n // (a route loading) is not passed over by an Enter or a → pressed on the bare\n // page (FLW-5). Escape, above, still leaves.\n if (!ready) return;\n if (e.key === \"Enter\") {\n if (step.awaitClick || step.awaitInput || ownsKey(e.target, \"Enter\")) return;\n e.preventDefault();\n tryNext();\n return;\n }\n if (ownsKey(e.target, e.key)) return;\n // The overlay root carries `dir`; before it paints, the document's answers.\n const delta = horizontalStep(e.key, rootRef.current);\n if (delta === 1) {\n e.preventDefault();\n tryNext();\n } else if (delta === -1) {\n if (!isFirst) onPrev();\n }\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n }, [isFirst, step, interactive, tryNext, onPrev, onSkip, ready]);\n\n if (!ready) return null;\n\n // No scrim, no shields: a field step inside a layer that fills the screen (§11.6.3).\n const bare = interactive && !!current?.fullScreen;\n const pad = step.padding ?? 8;\n const spot: Rect | null = rect\n ? { top: rect.top - pad, left: rect.left - pad, width: rect.width + pad * 2, height: rect.height + pad * 2 }\n : null;\n\n // `aria-modal` promises the page behind is out of reach, and the card's focus trap\n // keeps that promise for the keyboard. The pointer used to get no such treatment: the\n // root is `pointer-events-none` so that the spotlight hole can stay live for\n // `awaitClick`, and the scrim is a box-shadow, which takes no clicks — so every\n // control on the dimmed page stayed clickable. Four shields now tile the viewport\n // around the hole: the page is blocked, the card and the spotlighted target are not.\n // Keeping `aria-modal` (rather than dropping it) is the coherent half: the tour\n // really is modal — focus is trapped and Esc/Skip is the way out.\n return createPortal(\n <div\n ref={rootRef}\n // z-50 on a field step, in its own container right after the layer holding the field\n // (or at the end of <body>): over that layer and the page, under the z-50 layers the\n // field opens next (§11.6). z-[60] on a plain step, over everything.\n className={cn(\"pointer-events-none fixed inset-0\", interactive ? \"z-50\" : \"z-[60]\")}\n role=\"dialog\"\n aria-modal={interactive ? undefined : \"true\"}\n // A stable marker for the overlay, on every step (0.48, keksdose dev#611–613): an\n // app that hides its floating help launcher while a modal is open excepts the\n // tour, which may spotlight that launcher — `[aria-modal=\"true\"]:not([data-tour-overlay])`.\n // keksdose matched the `pointer-events-none` class until now, which is the kit's to change.\n data-tour-overlay=\"\"\n data-tour-interactive={interactive ? \"\" : undefined}\n data-tour-bare={bare ? \"\" : undefined}\n aria-label={step.title}\n dir={dir}\n >\n {/* In a full-screen layer (a phone's form sheet) no scrim and no shields: the rest of\n the form stays usable and scrollable, and the ring alone marks the field. */}\n {spot && !bare && <SpotlightShields spot={spot} />}\n {spot ? (\n <div\n className=\"pointer-events-none fixed rounded-lg transition-all duration-200 ease-out\"\n style={{\n top: spot.top,\n left: spot.left,\n width: spot.width,\n height: spot.height,\n // A two-tone frame, not a single translucent ring.\n //\n // The old treatment was `ring-2 ring-white/80` over a 55% scrim, and it\n // \"was barely visible\" on the app's blue-tinted surfaces. Two reasons,\n // and a single ring can't fix either: at 55% the surround stays bright\n // enough that the un-dimmed hole barely reads AS a hole, and a 80%-white\n // ring sitting on the edge of a light card is white-on-near-white.\n //\n // So: an opaque white band immediately around the target, a dark keyline\n // outside it, then the scrim. Whatever the target's own colour is, one of\n // the two bands is always in contrast with it and the other is always in\n // contrast with the dimmed surround — there is no background that can\n // swallow both. The blurred layer between them softens the step so the\n // frame reads as lighting rather than as a pasted-on rectangle.\n boxShadow: [\n \"0 0 0 3px rgba(255,255,255,0.98)\",\n \"0 0 0 5px rgba(15,23,42,0.92)\",\n \"0 0 18px 6px rgba(15,23,42,0.45)\",\n ...(bare ? [] : [\"0 0 0 9999px rgba(15,23,42,0.70)\"]),\n ].join(\", \"),\n }}\n />\n ) : (\n <div className=\"pointer-events-auto fixed inset-0 bg-black/70\" />\n )}\n <TourCard\n cardRef={cardRef}\n step={step}\n index={index}\n position={position}\n total={count}\n labels={labels}\n isFirst={isFirst}\n isLast={isLast}\n rect={spot}\n dir={dir}\n trap={!guided}\n bodyId={bodyId}\n hintId={hintId}\n locked={locked}\n gateHint={gateHint}\n onBack={onPrev}\n onNext={tryNext}\n onLeaveEmpty={onNext}\n onSkip={onSkip}\n awaitsRelease={awaitsRelease}\n docked={spot !== null && docks(step, dockOnPhones)}\n refusal={refusal}\n backTo={backTo >= 0 ? { title: steps[backTo].title, go: () => onGoTo(backTo) } : null}\n />\n <div className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {polite}\n </div>\n </div>,\n (interactive && current?.layer) || document.body,\n );\n}\n\n/** The values of the fields at or inside `el`, as one string to compare (`awaitInput`). */\nfunction fieldValues(el: Element): string {\n const fields = el.matches(\"input,textarea,select\") ? [el] : Array.from(el.querySelectorAll(\"input,textarea,select\"));\n return fields\n .map((f) =>\n f instanceof HTMLInputElement && (f.type === \"checkbox\" || f.type === \"radio\")\n ? String(f.checked)\n : (f as HTMLInputElement).value,\n )\n .join(\"\\u0000\");\n}\n\n/** Does the focused element handle `key` itself? Enter on a button or link, and any\n * editing key in a text field or select, is the control's — not the tour's. */\nfunction ownsKey(target: EventTarget | null, key: string): boolean {\n if (!(target instanceof HTMLElement)) return false;\n if (target.isContentEditable) return true;\n const tag = target.tagName;\n if (tag === \"TEXTAREA\" || tag === \"SELECT\") return true;\n if (tag === \"INPUT\") {\n const type = (target as HTMLInputElement).type;\n // Enter on a checkbox does nothing natively, but ←/→ on a radio moves it.\n return key !== \"Enter\" || type !== \"checkbox\";\n }\n if (key !== \"Enter\") return false;\n return (\n tag === \"BUTTON\" ||\n (tag === \"A\" && target.hasAttribute(\"href\")) ||\n target.getAttribute(\"role\") === \"button\" ||\n target.getAttribute(\"role\") === \"link\"\n );\n}\n\n/**\n * Transparent pointer blockers tiling the viewport around the spotlight hole: one\n * full-width band above and below, one on each side at the hole's own height. The hole\n * itself stays uncovered, so the target keeps its clicks.\n */\nfunction SpotlightShields({ spot }: { spot: Rect }) {\n const shield = \"pointer-events-auto fixed\";\n const bottom = spot.top + spot.height;\n return (\n <>\n <div\n data-tour-shield=\"\"\n className={shield}\n style={{ top: 0, left: 0, right: 0, height: Math.max(0, spot.top) }}\n />\n <div data-tour-shield=\"\" className={shield} style={{ top: bottom, left: 0, right: 0, bottom: 0 }} />\n <div\n data-tour-shield=\"\"\n className={shield}\n style={{ top: spot.top, left: 0, width: Math.max(0, spot.left), height: spot.height }}\n />\n <div\n data-tour-shield=\"\"\n className={shield}\n style={{ top: spot.top, left: spot.left + spot.width, right: 0, height: spot.height }}\n />\n </>\n );\n}\n\n/**\n * Card position (viewport px) for the given placement relative to the padded\n * spotlight `rect`. Omitted placement keeps the original auto behavior\n * (below → above → vertically centered); an explicit side flips to its opposite\n * if it would overflow, then clamps into the viewport. \"center\" (or no rect)\n * centers on screen.\n */\nfunction placeCard(\n rect: Rect | null,\n cw: number,\n ch: number,\n vw: number,\n vh: number,\n m: number,\n placement?: TourPlacement,\n dir: Direction = \"ltr\",\n): { top: number; left: number } {\n // The logical sides resolve to a physical one here, and only here.\n if (placement === \"start\") placement = dir === \"rtl\" ? \"right\" : \"left\";\n else if (placement === \"end\") placement = dir === \"rtl\" ? \"left\" : \"right\";\n if (!rect || placement === \"center\") {\n return { top: Math.max(m, (vh - ch) / 2), left: Math.max(m, (vw - cw) / 2) };\n }\n const clampX = (x: number) => Math.min(Math.max(m, x), Math.max(m, vw - cw - m));\n const clampY = (y: number) => Math.min(Math.max(m, y), Math.max(m, vh - ch - m));\n const centerX = clampX(rect.left + rect.width / 2 - cw / 2);\n const centerY = clampY(rect.top + rect.height / 2 - ch / 2);\n const belowTop = rect.top + rect.height + m;\n const aboveTop = rect.top - ch - m;\n const rightLeft = rect.left + rect.width + m;\n const leftLeft = rect.left - cw - m;\n const fitsBelow = belowTop + ch <= vh;\n const fitsAbove = aboveTop >= 0;\n const fitsRight = rightLeft + cw <= vw;\n const fitsLeft = leftLeft >= 0;\n\n switch (placement) {\n case \"top\":\n return { top: fitsAbove ? aboveTop : fitsBelow ? belowTop : clampY(aboveTop), left: centerX };\n case \"bottom\":\n return { top: fitsBelow ? belowTop : fitsAbove ? aboveTop : clampY(belowTop), left: centerX };\n case \"right\":\n return { top: centerY, left: fitsRight ? rightLeft : fitsLeft ? leftLeft : clampX(rightLeft) };\n case \"left\":\n return { top: centerY, left: fitsLeft ? leftLeft : fitsRight ? rightLeft : clampX(leftLeft) };\n default:\n if (fitsBelow) return { top: belowTop, left: centerX };\n if (fitsAbove) return { top: aboveTop, left: centerX };\n return { top: Math.max(m, (vh - ch) / 2), left: centerX };\n }\n}\n\nfunction TourCard({\n cardRef: ref,\n step,\n index,\n position,\n total,\n labels,\n isFirst,\n isLast,\n rect,\n dir,\n trap,\n bodyId,\n hintId,\n locked,\n gateHint,\n onBack,\n onNext,\n onLeaveEmpty,\n onSkip,\n awaitsRelease,\n docked,\n refusal,\n backTo,\n}: {\n cardRef: RefObject<HTMLDivElement | null>;\n step: TourStep;\n index: number;\n /** 1-based among the steps shown (§11.3). */\n position: number;\n /** How many steps the run shows. */\n total: number;\n labels: TourLabels;\n isFirst: boolean;\n isLast: boolean;\n rect: Rect | null;\n dir: Direction;\n /** The card's own focus trap; off on a guided step, where field + card are one ring. */\n trap: boolean;\n bodyId: string;\n hintId: string;\n /** A gate step whose field is not filled yet (§11.1). */\n locked: boolean;\n gateHint: string;\n onBack: () => void;\n onNext: () => void;\n /** Moves on past an `optional` field left empty. */\n onLeaveEmpty: () => void;\n onSkip: () => void;\n /** An awaitGate step with its target lit: the hint in place of Next. */\n awaitsRelease: boolean;\n /** Pinned to the band's edge away from the field (§11.7). */\n docked: boolean;\n refusal: Refusal | null;\n /** The \"Back to …\" link after a refused save. */\n backTo: { title: string; go: () => void } | null;\n}) {\n const [style, setStyle] = useState<CSSProperties>({ opacity: 0 });\n\n /**\n * The card holds the focus, because the card is what the tour IS.\n *\n * The overlay above declares `role=\"dialog\" aria-modal=\"true\"` — it always has — and\n * then left focus wherever the page had put it. For a tour that is the most pointed\n * version of the audit's *\"Only Modal manages focus\"*: the whole component exists to\n * say \"look here\", and for a keyboard user \"here\" is the focus ring. They were told\n * the page was hidden, given no way to reach the Next button without Tabbing through\n * it, and left on a control the screen reader would no longer describe.\n *\n * It re-engages on every step, without any bookkeeping here, because `TourOverlay`\n * returns null while it re-locates the next target: the card genuinely unmounts and\n * remounts between steps. That is what keeps focus honest when the BUTTONS change —\n * \"Back\" does not exist on the first step, so stepping back onto it destroys the\n * control the press came from, and focus would otherwise fall to `<body>`, outside\n * this trap's own listener, where Tab walks straight into the page the overlay claims\n * to have hidden.\n *\n * **The cost, written down:** on an `awaitClick` step the user is asked to click the\n * spotlighted element, and they can no longer Tab to it. ArrowRight still advances\n * (the key handler in `TourOverlay` is on the document and does not care where focus\n * is), which is the escape hatch that step already documents for the case where the\n * target cannot be found. Containment is worth that: an `awaitClick` step is a\n * minority of steps, while focus stranded behind `aria-modal` is every step.\n *\n * A guided field step (`gate`, `awaitInput`, 0.50) is the exception: the field is\n * what the step is about, so the overlay focuses it (or the card, on a touch screen)\n * and runs one Tab ring over field + card itself.\n */\n useFocusTrap(ref, { active: trap });\n\n // Docked (§11.7): the edge it last took, for the hysteresis, and a tick bumped when the\n // band moves under an unmoved field (a pad or keyboard opening).\n const edgeRef = useRef<DockEdge | null>(null);\n const [bandTick, setBandTick] = useState(0);\n const [edge, setEdge] = useState<DockEdge | null>(null);\n useEffect(() => {\n if (!docked) return;\n let last = \"\";\n const look = () => {\n const target = step.target ? queryVisibleTarget(step.target) : null;\n const band = readBand(target, ref.current);\n const key = `${band.top}:${band.bottom}`;\n if (key === last) return;\n last = key;\n // A field the pad or keyboard now covers is brought back into the free half.\n if (target) {\n const r = target.getBoundingClientRect();\n if (r.top < band.top || r.bottom > band.bottom) {\n edgeRef.current = scrollIntoFreeHalf(target, ref.current, edgeRef.current);\n }\n }\n setBandTick((t) => t + 1);\n };\n const vv = window.visualViewport;\n vv?.addEventListener(\"resize\", look);\n vv?.addEventListener(\"scroll\", look);\n window.addEventListener(\"resize\", look);\n // The follow tick's cadence: it catches a pad opening, which moves nothing.\n const id = window.setInterval(look, 250);\n return () => {\n vv?.removeEventListener(\"resize\", look);\n vv?.removeEventListener(\"scroll\", look);\n window.removeEventListener(\"resize\", look);\n clearInterval(id);\n };\n }, [docked, step.target, ref]);\n\n useLayoutEffect(() => {\n const card = ref.current;\n if (!card) return;\n if (docked) {\n const target = step.target ? queryVisibleTarget(step.target) : null;\n const band = readBand(target, card);\n const next = rect ? dockEdge(rect, band, edgeRef.current, card.offsetHeight) : \"bottom\";\n edgeRef.current = next;\n setEdge(next);\n setStyle(dockStyle(next, rect, band));\n return;\n }\n setEdge(null);\n setStyle(\n placeCard(\n rect,\n card.offsetWidth,\n card.offsetHeight,\n window.innerWidth,\n window.innerHeight,\n 12,\n step.placement,\n dir,\n ),\n );\n }, [ref, rect, index, step.placement, step.target, dir, docked, bandTick]);\n\n const awaitsTarget = ((step.awaitClick || step.awaitInput) && step.target && rect) || awaitsRelease;\n\n return (\n <div\n ref={ref}\n // Focusable but not tabbable: the trap above focuses the card itself rather than\n // its first button, so a screen reader reads the step's title and body before it\n // reads \"Next\" — and without this the container cannot take focus at all and the\n // trap silently does nothing.\n tabIndex={-1}\n style={style}\n data-tour-card=\"\"\n data-tour-docked={edge ?? undefined}\n className={cn(\n \"pointer-events-auto fixed z-[61] w-80 max-w-[calc(100vw-1.5rem)] rounded-lg border border-subtle bg-surface p-4 shadow-xl outline-none transition-all duration-200 ease-out\",\n // Docked, the height is capped: the body scrolls, the title and buttons stay.\n docked && \"flex flex-col\",\n )}\n >\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm font-semibold text-primary\">\n <span>{step.title}</span>\n {step.optional && (\n <span className=\"rounded-full border border-subtle px-1.5 py-px text-xs font-normal text-muted\">\n {labels.optional}\n </span>\n )}\n </div>\n <div\n id={bodyId}\n className={cn(\"mt-1 text-sm leading-relaxed text-secondary\", docked && \"min-h-0 shrink overflow-y-auto\")}\n >\n {step.body}\n </div>\n {step.action && <div className=\"mt-3\">{step.action}</div>}\n <div className=\"mt-4 space-y-2\">\n <div className=\"flex items-center justify-between gap-2\">\n <button type=\"button\" onClick={onSkip} className=\"text-xs text-placeholder hover:text-secondary\">\n {labels.skip}\n </button>\n <div className=\"flex items-center gap-2\">\n <span className=\"whitespace-nowrap text-xs tabular-nums text-placeholder\">\n {labels.step(position, total)}\n </span>\n {!isFirst && (\n <Button variant=\"secondary\" onClick={onBack} className=\"px-2.5 py-1 text-xs\">\n {labels.back}\n </Button>\n )}\n {/* On an awaitClick step the Next button is replaced by a hint on its\n own row below, so it doesn't cram the counter + buttons and wrap.\n Only when the target was actually FOUND, though — `rect` is null\n when the finder gave up, and the click listener early-returns on\n the same absence. Keyed on `step.target` alone this hid the only\n way forward on any step whose anchor happens not to be rendered\n for this user (a guest sees no \"add account\" button), leaving the\n undocumented ArrowRight key as the sole escape. */}\n {/* \"Leave empty\" (§11.2): an optional field may stay empty, so the step can\n move on without it. Gone once the field is filled. */}\n {step.optional && locked && !awaitsTarget && (\n <Button variant=\"secondary\" onClick={onLeaveEmpty} className=\"px-2.5 py-1 text-xs\">\n {labels.leaveEmpty}\n </Button>\n )}\n {!awaitsTarget && (\n <Button\n variant=\"accent\"\n onClick={onNext}\n // Locked, not disabled (§11.1): it stays focusable, and a press focuses the\n // field and reads the hint again.\n aria-disabled={locked || undefined}\n aria-describedby={locked ? hintId : undefined}\n className={cn(\"px-2.5 py-1 text-xs\", locked && \"opacity-60\")}\n >\n {isLast ? labels.done : labels.next}\n </Button>\n )}\n </div>\n </div>\n {awaitsTarget && (\n <div className=\"text-center text-xs italic text-placeholder\">\n {awaitsRelease\n ? (step.awaitGateHint ?? labels.awaitGateHint)\n : step.awaitInput && !step.awaitClick\n ? labels.awaitInputHint\n : labels.awaitClickHint}\n </div>\n )}\n {/* Always mounted on an awaitGate step, so a refusal is read out (assertively)\n the moment it lands. */}\n {awaitsRelease && (\n <div aria-live=\"assertive\" aria-atomic=\"true\" className=\"space-y-1\">\n {refusal && (\n <p data-tour-refused=\"\" className=\"text-xs text-danger\">\n {refusal.reason ?? labels.awaitGateRefused}\n {refusal.seq % 2 === 0 ? \"\\u200b\" : \"\"}\n </p>\n )}\n {refusal && backTo && (\n <Button variant=\"link\" onClick={backTo.go} className=\"text-xs\">\n {labels.backToStep(backTo.title)}\n </Button>\n )}\n </div>\n )}\n {locked && !awaitsTarget && (\n <div id={hintId} className=\"text-center text-xs italic text-placeholder\">\n {gateHint}\n </div>\n )}\n </div>\n </div>\n );\n}\n"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W,UACV,oBAAC,UAAO,SAAQ,QAAO,SAAS,OAAO,IAAI,WAAU,WAClD,iBAAO,WAAW,OAAO,KAAK,GACjC;AAAA,aAEJ;AAAA,UAED,UAAU,CAAC,gBACV,oBAAC,SAAI,IAAI,QAAQ,WAAU,+CACxB,oBACH;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["layer"]}
1
+ {"version":3,"sources":["../../src/tour/tour.tsx"],"sourcesContent":["import {\n createContext,\n Suspense,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_TOUR_LABELS } from \"./tour-labels\";\nimport type { TourInfo } from \"./tour-info\";\nimport { completeStored, rememberAccount, rememberMigrate, type UseTourProgressOptions } from \"./use-tour-progress\";\nimport { createGateRegistry, devWarnings, isShown, stepContext, TourInternalContext } from \"./tour-gates\";\nimport { liveEngine } from \"./tour-engine\";\nimport { lazyWithFallback } from \"../lib/lazy-with-fallback\";\n// Types only, gone from the built module: the overlay's modules load with the overlay.\nimport type { Refusal } from \"./tour-overlay\";\n\n/**\n * The overlay — the card, the spotlight and its shields, the placement, the dock — loaded\n * when a tour first starts, not with the provider every app mounts above its routes\n * (refactor audit 2026-10-30, MOD-1: about 28.5 kB minified, 10.3 kB gzip of each app's\n * first load at 0.51.6). A LITERAL relative `import()`, as feedback-submit.tsx's dialog\n * is (0.34, MOD-1): the library build keeps the module its own (`bundle: false`), and a\n * path an app's bundler can read is a chunk it can split off.\n *\n * A fetch that fails — a tab left open across a deploy, a local-first app offline — ends\n * the run and leaves the page (0.52 code review, tour.tsx): the provider sits above the\n * routes, in keksdose and Kurvenschmiede above the app's own boundary, and the rejected\n * import unmounted the whole app — for a tour, whose start fetched nothing before 0.52.\n * `lazyWithFallback` logs it, and the next start fetches again.\n */\nconst LazyTourOverlay = lazyWithFallback(\n () => import(\"./tour-overlay\").then((module) => module.TourOverlay),\n TourOverlayUnavailable,\n);\n\n/** The provider's end of a run whose overlay did not load; see {@link TourOverlayUnavailable}. */\nconst TourUnavailableContext = createContext<() => void>(() => {});\n\n/**\n * Stands in for an overlay whose chunk did not arrive: ends the run with the start's\n * `onSkip(\"unavailable\")` and draws nothing. It ended with `stop()` at first, which calls\n * nothing — after the start's `onStart` had run, so what the app turned on for the run\n * stayed on: kastlan's practice mode, which its launcher turns on and its `onSkip` and\n * `onFinish` turn off (0.52 code review, tour.tsx).\n */\nfunction TourOverlayUnavailable() {\n const unavailable = useContext(TourUnavailableContext);\n useLayoutEffect(unavailable, [unavailable]);\n return null;\n}\n\n/**\n * Hears Escape while the overlay's chunk is on its way, as the overlay does before it has\n * located its step: the run is skipped. With nothing mounted the tour was `active` and\n * deaf, and on a slow first start the overlay came up seconds after the person had\n * pressed Escape and gone back to the page (0.52 code review, tour.tsx).\n */\nfunction TourOverlayLoading({ onSkip }: { onSkip: () => void }) {\n useEffect(() => {\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onSkip();\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n }, [onSkip]);\n return null;\n}\n\nexport { useTourGate, useTourGateRelease } from \"./tour-gates\";\nexport type { TourGateRelease } from \"./tour-gates\";\n\n/**\n * `start`/`end` follow the reading direction (`end` is the right side in LTR and the\n * left side in RTL) and are what a translated app wants. `left`/`right` stay physical\n * for the steps that genuinely mean a screen side.\n */\nexport type TourPlacement = \"top\" | \"right\" | \"bottom\" | \"left\" | \"start\" | \"end\" | \"center\" | \"dock\";\n\nexport interface TourStep {\n /** CSS selector for the element to spotlight. Omit for a centered step\n * (welcome/finish). If the target isn't found/visible, the step centers. */\n target?: string;\n title: string;\n body: ReactNode;\n /** Extra footer content, e.g. a \"load sample data\" shortcut. */\n action?: ReactNode;\n /** Spotlight padding around the target, px (default 8). On a field step the spot also\n * takes in the lines the field's `aria-describedby` names when they sit within the\n * ring's reach of it (a hint or warning line under the field, keksdose S1, §11.6). */\n padding?: number;\n /** Where the card sits relative to the target. Omit for auto placement\n * (below → above → centered). \"center\" ignores the target and centers on\n * screen. \"start\"/\"end\" are the logical sides and flip in RTL; \"left\"/\"right\"\n * are physical. An explicit side flips to the opposite side if it would\n * overflow, then clamps into the viewport.\n *\n * `\"dock\"` (0.50, §11.7): below `sm` (640 px at Normal text, 800 at Large, as\n * `max-sm:` since 0.52) the card is pinned full-width to the top or bottom edge of the\n * usable band — the visual viewport less the keyboard and any\n * `[data-tour-obstruction]` (the number pad) — on the edge away from the field, and the\n * field's scroll container brings it into the other half. From `sm` up it is auto\n * placement. On a phone a field step (`interactive`, `awaitInput`, `gate`, `awaitGate`)\n * with a target and no `placement` docks by default (`TourProvider dockOnPhones`). */\n placement?: TourPlacement;\n /** Advance only when the user clicks the spotlighted target itself (not the\n * card's Next button). Requires `target`: the real control's own handler runs\n * first, then the tour steps forward on a microtask. The spotlight hole stays\n * click-through to the target; the rest of the page does not. */\n awaitClick?: boolean;\n /**\n * The spotlighted control is for USING, not only for looking at (0.46, keksdose live\n * #436): the layers it opens sit above the scrim and work. A plain step's overlay is\n * `z-[60]`, over every kit layer, so a field whose number pad (`NumberPadSheet`), a\n * select's menu or a popover opens at `z-50` opened UNDER the shields, where nothing\n * could be tapped. Here the overlay drops to `z-[45]`: still over the top bar and the\n * page (`z-40` and below, still dimmed and shielded), under every `z-50` layer the\n * target opens — so an app's own layer wants `z-50` or more to clear it. Keys pressed\n * in the target or in such a layer are theirs (Escape closes the pad, arrows walk a\n * list); from the card the tour's keys work as on any step. The overlay is not\n * `aria-modal` then, and carries `data-tour-interactive`.\n *\n * The card is in the same layer as the scrim, so an open pad or sheet may cover it\n * until it closes. Requires `target`. A `HoverMenu` (`z-40`, the top bar's menus) stays\n * under the scrim: point an `awaitClick` step at its trigger instead.\n */\n interactive?: boolean;\n /**\n * Advance once a value was ENTERED in the spotlighted control (0.46, keksdose live\n * #436) — `awaitClick` for a field. Implies `interactive`. Counted when focus leaves\n * the target (the number pad's Done, a Tab, a tap elsewhere), or Enter is pressed in\n * it, and one of its fields (`input`, `textarea`, `select`: the target itself or\n * inside it) then holds another value than when the step began; a native `change`\n * (a select, a checkbox) counts at once. The card swaps Next for `awaitInputHint`,\n * as for `awaitClick`. A picker whose value is not a field's (the kit's `Select`\n * button) has nothing to compare: call `useTour().next()` from its `onChange`.\n */\n awaitInput?: boolean;\n /**\n * 0.50 (docs/tours-harmonization.md §11.1): Next stays locked until the gate `key` is\n * satisfied — the form publishes it with `useTourGate(key, satisfied)` beside the field.\n * Implies `interactive`. The locked Next is `aria-disabled` with {@link gateHint} under\n * it; pressing it focuses the field. Once satisfied the tour does NOT advance by itself:\n * Next, Enter in the field, or focus leaving the field to nowhere or to the card (the\n * number pad's Done) moves on. A key nobody publishes is not enforced (the form closed\n * under the tour): Next opens. A step may have a `gate` and no `target`.\n */\n gate?: string;\n /** Overrides `labels.gateHint` for this step. */\n gateHint?: string;\n /**\n * 0.50 (§11.4): wait for the app to RELEASE this key — `useTourGateRelease().release(key)`\n * from the save's `onSuccess`. Implies `interactive`; usually it targets the Save button,\n * whose hole stays click-through. Next is replaced by {@link awaitGateHint}, and a click\n * does not advance: only `release` does. A release that arrives on an earlier step (Enter\n * in the last field submitted the form) jumps past the first later step awaiting the key.\n * `refuse(key, reason)` keeps the step and shows the reason, with a \"Back to …\" link to the\n * first earlier field whose gate is now unsatisfied; the kit never jumps there itself.\n * A viewer who cannot save gets `awaitGate: undefined`, so a plain Next.\n */\n awaitGate?: string;\n /** Overrides `labels.awaitGateHint` for this step. */\n awaitGateHint?: string;\n /**\n * 0.50 (§11.2): the field may stay empty. While the `gate` is unsatisfied the card\n * offers \"Leave empty\" beside the locked Next, which moves on without touching the field\n * (the kit never writes app values); the title carries an \"Optional\" chip. Not a skip:\n * the run continues and can complete. Without a `gate`, only the chip.\n */\n optional?: boolean;\n /**\n * 0.50 (§11.3): shown only if this returns true on ARRIVAL (evaluated before\n * `beforeStep`, so a skipped step never navigates). Next walks forward to the first step\n * shown, Back to the nearest earlier one shown now. Branch facts are gates:\n * `when: (c) => c.gate(\"txn.transfer\") === true`. Keep it pure and cheap: the counter\n * evaluates every step's `when` on each arrival. A throw counts as skipped.\n */\n when?: (ctx: TourStepContext) => boolean;\n /** Runs before the step is shown — e.g. navigate to a route, open a panel.\n * May be async; the step waits for it, then locates the target. Receives the\n * {@link TourStepContext} (0.50); a step entered by \"Guide me\" sees `via: \"at\"` and\n * should leave an open form alone. One that throws or rejects is logged to the\n * console, and the step is located and shown anyway. Enter and the arrows wait for\n * it; Escape does not. */\n beforeStep?: (ctx: TourStepContext) => void | Promise<void>;\n}\n\n/** What a step's `when` and `beforeStep` may ask on arrival (0.50, §11.3). */\nexport interface TourStepContext {\n /** The gate's current value: true/false, or undefined while nobody publishes it. */\n gate(key: string): boolean | undefined;\n /** How this step is being entered. */\n via: \"start\" | \"at\" | \"next\" | \"back\" | \"goto\";\n}\n\nexport interface TourLabels {\n next: string;\n back: string;\n skip: string;\n done: string;\n /** Shown in place of the Next button on an `awaitClick` step. */\n awaitClickHint: string;\n /** Shown in place of the Next button on an `awaitInput` step (0.46). */\n awaitInputHint: string;\n /** Step counter, e.g. (2, 7) => \"2 / 7\". Counts the steps the run shows (0.50). */\n step: (current: number, total: number) => string;\n /** 0.50: an `optional` gate step's button while the field is empty. */\n leaveEmpty: string;\n /** 0.50: the chip beside an `optional` step's title. */\n optional: string;\n /** 0.50: under a `gate` step's locked Next (`TourStep.gateHint` overrides it). */\n gateHint: string;\n /** 0.50: announced (screen readers only) when a gate step's field is filled. */\n gateReady: string;\n /** 0.50: in place of Next on an `awaitGate` step (`TourStep.awaitGateHint` overrides it). */\n awaitGateHint: string;\n /** 0.50: the warning when the app `refuse`s an `awaitGate` step without a reason. */\n awaitGateRefused: string;\n /** 0.50: the link to an earlier step whose field was emptied, after a refused save. */\n backToStep: (title: string) => string;\n}\n\n// Defined in ./tour-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_TOUR_LABELS };\n\n/** 0.50 (§11.5): a step index, or the `data-tour` value of the step's anchor. */\nexport type TourAt = number | string;\n\n/** `useTour().start`, both forms: what `TourProvider` hands its `launch` as the third argument. */\nexport type TourStart = TourContextValue[\"start\"];\n\n/**\n * 0.50 (§11.5): the app's launcher — the shape `useTourUrlSync` already takes, plus `at`.\n * It builds the steps (`prepare()`, `build()`, `tour: tourInfo(def)`) and passes `at` on to\n * `start(steps, { …, at })`. Give the same function to `TourProvider launch` and to\n * `useTourUrlSync`.\n *\n * `start` is the provider's own `start` (keksdose N4), so the launcher needs no ref to a\n * component below the provider and may be defined above it. `engine` (0.50.1, keksdose N1)\n * is the rest of the engine — `stop`, `next`, `active`, … — read live, see {@link TourEngine}.\n * `useTourUrlSync` passes both (under a provider). A launcher taking fewer arguments still\n * works.\n */\nexport type TourLauncher = (\n id: string,\n opts: { startIndex?: number; at?: TourAt },\n start: TourStart,\n engine: TourEngine,\n) => void | Promise<unknown>;\n\n/**\n * 0.50.1 (keksdose N1): the whole engine `useTour()` returns, handed to a launcher as its\n * FOURTH argument by `TourProvider` and `useTourUrlSync`, so a tour built above the provider\n * can also `stop`, `next` or read `active` with no `useTour()` registered from below. One\n * object per provider whose fields read the latest render (`engine.active` after an\n * `await` is current); its methods are the provider's own. `start` (the third argument) is\n * `engine.start`.\n */\nexport type TourEngine = TourContextValue;\n\nconst ENGINE_KEYS = [\n \"active\",\n \"activeId\",\n \"start\",\n \"stop\",\n \"next\",\n \"prev\",\n \"goToStep\",\n \"index\",\n \"total\",\n \"position\",\n \"count\",\n] as const satisfies readonly (keyof TourContextValue)[];\n\ninterface StartOptions {\n /** Stable id of the tour, surfaced as `activeId` so the app can mirror it to\n * the URL (deep-link / evaluation tracking) and record completion. Defaults to\n * `tour.id`. */\n id?: string;\n /** The tour being started, as the app lists it (docs/tours-harmonization.md §9.6.1).\n * When its last step is finished, the provider records the completion in its\n * `progress` and hands this to `onComplete`. */\n tour?: TourInfo;\n /** Start at this step index instead of 0 (clamped) — for URL/deep-link resume. */\n startIndex?: number;\n /**\n * 0.50 (§11.5): start here AND make it the floor — earlier steps never run (nor their\n * `beforeStep`), Back stops here, `position`/`count` count from here, and the finish\n * records the completion as a full run does (Marcel, Q2). A number is a step index\n * (clamped); a string is the first step whose `target` contains `data-tour=\"<at>\"`\n * verbatim (unknown: 0, with a development warning). The `at` step is entered with\n * `via: \"at\"`. With `startIndex` too, `startIndex` picks the step and `at` the floor.\n */\n at?: TourAt;\n /** Fires synchronously when the tour starts (e.g. enable a mock interceptor). */\n onStart?: () => void;\n /** After the last step: runs after the provider's progress write and `onComplete`. */\n onFinish?: () => void;\n /**\n * The run ended before its last step — undo here what `onStart` or the launcher turned\n * on. `reason` says why: `\"skipped\"`, the person left (Skip, Escape); `\"unavailable\"`\n * (0.52), the overlay's chunk did not load (a tab left open across a deploy, offline),\n * so no step was shown — the moment to say so, if the app wants to. `stop()` calls\n * nothing.\n */\n onSkip?: (reason?: TourSkipReason) => void;\n}\n\n/** Why a run ended before its last step, as `onSkip` hears it. */\ntype TourSkipReason = \"skipped\" | \"unavailable\";\n\n/** What `TourProvider`'s `onComplete` learns besides the tour (§9.1, §9.6). */\nexport interface TourCompletion {\n /**\n * `true` when the completion counts anew (the first time, or the first time after the\n * tour's update, §8): the moment for the app's points toast. `false` for a replay, and\n * when the stored text is in an old shape no `migrate` reads: nothing is overwritten\n * then, and the error goes to `console.error` (keksdose B-1). `undefined` when the provider has no `progress` or the start carried no `tour`, so\n * nothing was recorded.\n */\n awarded: boolean | undefined;\n}\n\ninterface TourContextValue {\n active: boolean;\n /** Id of the running tour (from {@link StartOptions.id}), else null. */\n activeId: string | null;\n /**\n * Start a tour with the given steps — or, by id (0.50), through the provider's `launch`:\n * `start(\"create-transaction\", { at: \"txn-entry-mode\" })`. Without a `launch` the id form\n * does nothing (a development build warns).\n */\n start: {\n // The id form first: `Parameters<typeof start>` reads the LAST overload, which stays\n // the 0.49 one.\n (id: string, opts?: { at?: TourAt }): void;\n (steps: TourStep[], opts?: StartOptions): void;\n };\n /** End the current tour (no callbacks fire). */\n stop: () => void;\n /** Advance one step; past the last step it finishes the tour (fires onFinish). */\n next: () => void;\n /** Go back one step (no-op on the first). */\n prev: () => void;\n /** Jump to a step by index, clamped to range — e.g. for URL/deep-link resume. */\n goToStep: (index: number) => void;\n /** Current step (0-based; 0 while inactive). */\n index: number;\n /** Total steps (0 while inactive). */\n total: number;\n /** 0.50: 1-based position among the steps this run shows, for \"3 of 9\"; 0 while inactive. */\n position: number;\n /** 0.50: how many steps this run shows, from its first (the `at` floor) to the end; 0 while inactive. */\n count: number;\n}\n\nconst TourContext = createContext<TourContextValue | null>(null);\n\nexport function useTour(): TourContextValue {\n const ctx = useContext(TourContext);\n if (!ctx) throw new Error(\"useTour must be used within <TourProvider>\");\n return ctx;\n}\n\n/**\n * The tour engine if it is there, `null` if it is not — for a control that is a\n * DECORATION rather than a participant.\n *\n * {@link useTour}'s throw is correct and stays: a component that runs a tour cannot do\n * its job without the provider, and failing loudly is how that gets fixed. But the\n * throw's blast radius is whatever error boundary is above it, and for a launcher in\n * the app shell that is the whole app.\n *\n * Keksdose feedback dev#524 is what that costs: an `@hb/ui` module was edited while a\n * dev server was running, vite re-evaluated it, and the module's freshly created\n * context object was no longer the one the mounted provider was providing. React's\n * `useContext` then answers `null` for a provider that is, structurally, right there —\n * and the top bar's tour menu took the entire shell down with it. **Build-time module\n * graphs cannot produce that**, so it is a development-only failure; a menu that\n * disappears for a second is the proportionate response to it either way.\n *\n * Only for controls that can honestly render nothing. If a component would show a\n * broken half of itself without the tour, it wants {@link useTour}.\n */\nexport function useTourOptional(): TourContextValue | null {\n return useContext(TourContext);\n}\n\n/**\n * Provides the guided-tour engine: a dimmed spotlight overlay + step card driven\n * by a list of {@link TourStep}s. Domain-free — the app supplies the steps (copy,\n * selectors, per-step navigation, placement) and the translated {@link TourLabels}.\n * Mount once inside the router; start a tour from anywhere via {@link useTour},\n * which also exposes step control (`next`/`prev`/`goToStep`) and the current\n * `index`/`total` for URL mirroring, `awaitClick` and deep-link resume.\n *\n * **Completion in one place** (docs/tours-harmonization.md §9.6): give the provider the\n * app's `progress` (the same `{storageKey, migrate}` as `useTourProgress`) and start each\n * tour with `start(steps, {tour})`. When the last step is finished the provider writes the\n * completion ONCE, through the store every `useTourProgress` reader of the key shares\n * (never a second copy), then calls `onComplete(tour, {awarded})`, then the start's own\n * `onFinish`. A skip or `stop()` records nothing and calls neither. The app removes its\n * own `complete()` from `onFinish`, or that second write answers `false`.\n *\n * Both props are optional: without `progress` or a `tour` on the start, `onComplete`\n * still fires, with `awarded: undefined` (and `tour` as given, possibly `undefined`). A\n * new `storageKey` (an account switch on a shared PC) is followed on the next\n * completion, without a remount.\n */\nexport function TourProvider({\n children,\n labels,\n progress,\n onComplete,\n launch,\n dockOnPhones = true,\n}: {\n children: ReactNode;\n labels?: LabelOverride<TourLabels>;\n /**\n * 0.50 (§11.5): lets `start(id)` and `<TourGuideButton>` start a tour by id. Usually the\n * same function the app gives `useTourUrlSync`.\n */\n launch?: TourLauncher;\n /** The app's tour progress: the same options its `useTourProgress` readers use. */\n progress?: UseTourProgressOptions;\n /** A tour's last step was finished; see {@link TourCompletion}. */\n onComplete?: (tour: TourInfo | undefined, completion: TourCompletion) => void;\n /**\n * 0.50 (§11.7, Marcel's Q1): below `sm`, a field step with a target and no `placement`\n * docks. Default `true`; `false` makes docking strictly opt-in (`placement: \"dock\"`).\n */\n dockOnPhones?: boolean;\n}) {\n // `labels` over the provider's `tour` over English. Resolved once here and handed\n // down: the step card is portalled, but context crosses portals anyway — this is\n // simply the one place that already owned the merge.\n const merged = useKitLabels(\"tour\", DEFAULT_TOUR_LABELS, labels);\n const [steps, setSteps] = useState<TourStep[] | null>(null);\n // Where the run is: the raw index (what `?tourStep=` mirrors), how it got there, and\n // its place among the steps shown (§11.3), computed once on arrival.\n const [nav, setNav] = useState<Nav>(NO_NAV);\n const index = nav.index;\n // The app's last `refuse` on the step awaiting its key; any arrival clears it.\n const [refusal, setRefusal] = useState<Refusal | null>(null);\n const [activeId, setActiveId] = useState<string | null>(null);\n const optsRef = useRef<StartOptions>({});\n // The latest props, read at the finish: a new `storageKey` or callback needs no remount.\n const progressRef = useRef(progress);\n const onCompleteRef = useRef(onComplete);\n const launchRef = useRef(launch);\n useLayoutEffect(() => {\n progressRef.current = progress;\n onCompleteRef.current = onComplete;\n launchRef.current = launch;\n });\n // The provider's migrate becomes the key's, for readers that pass none (keksdose B-2).\n const storageKey = progress?.storageKey;\n const migrate = progress?.migrate;\n // 0.45: and its `account` (§10.3), so a finish on an account key is sent as readers' are.\n const account = progress?.account;\n useLayoutEffect(() => {\n if (storageKey !== undefined) rememberMigrate(storageKey, migrate);\n if (storageKey !== undefined) rememberAccount(storageKey, account);\n }, [storageKey, migrate, account]);\n const warnedNoTourRef = useRef(false);\n // Live mirrors so the step-control callbacks can stay stable (identity-safe for\n // consumers) while still reading the current steps/index. Synced in a layout\n // effect — after the commit, before paint and before any passive effect or event\n // can call them — rather than written during render.\n const stepsRef = useRef<TourStep[] | null>(null);\n const indexRef = useRef(0);\n useLayoutEffect(() => {\n stepsRef.current = steps;\n indexRef.current = index;\n }, [steps, index]);\n /** The run's first step: earlier steps never run, Back stops here (the `at` floor). */\n const floorRef = useRef(0);\n const active = !!steps && steps.length > 0;\n const total = steps?.length ?? 0;\n // The gate registry (§11.1): one per provider, read by the overlay while a tour runs.\n const [gates] = useState(createGateRegistry);\n useLayoutEffect(() => {\n gates.setActive(active);\n }, [gates, active]);\n const canLaunch = !!launch;\n const internals = useMemo(() => ({ gates, canLaunch }), [gates, canLaunch]);\n\n /** Is step `i` shown, asked now (§11.3)? */\n const shown = useCallback(\n (s: TourStep[], i: number, via: TourStepContext[\"via\"]) => isShown(s[i], stepContext(gates, via)),\n [gates],\n );\n /** Arrive at `i`: the counter is recomputed from every step's `when`, against the gates now. */\n const arrive = useCallback(\n (s: TourStep[], i: number, via: TourStepContext[\"via\"]) => {\n const ctx = stepContext(gates, via);\n let position = 0;\n let count = 0;\n for (let j = floorRef.current; j < s.length; j++) {\n if (j !== i && !isShown(s[j], ctx)) continue;\n count++;\n if (j <= i) position++;\n }\n indexRef.current = i;\n setRefusal(null);\n setNav({ index: i, floor: floorRef.current, via, position, count });\n },\n [gates],\n );\n /** The first step shown at or after `from`, or -1. */\n const forward = useCallback(\n (s: TourStep[], from: number, via: TourStepContext[\"via\"]) => {\n for (let j = Math.max(from, floorRef.current); j < s.length; j++) if (shown(s, j, via)) return j;\n return -1;\n },\n [shown],\n );\n /** The nearest step shown at or before `from`, not below the floor, or -1. */\n const backward = useCallback(\n (s: TourStep[], from: number, via: TourStepContext[\"via\"]) => {\n for (let j = Math.min(from, s.length - 1); j >= floorRef.current; j--) if (shown(s, j, via)) return j;\n return -1;\n },\n [shown],\n );\n\n const startSteps = useCallback(\n (s: TourStep[], opts?: StartOptions) => {\n optsRef.current = opts ?? {};\n optsRef.current.onStart?.();\n const last = Math.max(0, s.length - 1);\n floorRef.current = opts?.at === undefined ? 0 : resolveAt(s, opts.at);\n const via: TourStepContext[\"via\"] = opts?.at === undefined ? \"start\" : \"at\";\n // Floored, as `at` is (FLW-9): `steps[1.5]` is undefined, and `forward` threw on\n // its `when` — an edited `?tourStep=2.5` was enough.\n const asked = opts?.startIndex === undefined ? floorRef.current : Math.floor(opts.startIndex);\n const wanted = Math.min(Math.max(floorRef.current, asked), last);\n let to = forward(s, wanted, via);\n if (to < 0) to = backward(s, wanted, via);\n // Not one step of the run is shown: there is nothing to tour.\n if (to < 0) return;\n arrive(s, to, via);\n setActiveId(opts?.id ?? opts?.tour?.id ?? null);\n setSteps(s);\n },\n [arrive, forward, backward],\n );\n // The provider's own `start` and the live engine, handed to `launch` as its third and\n // fourth arguments (keksdose N4, N1).\n const ownStartRef = useRef<TourContextValue[\"start\"] | null>(null);\n const [live] = useState(() => liveEngine<TourEngine>(ENGINE_KEYS));\n const engine = live.engine;\n const start = useCallback(\n (what: TourStep[] | string, opts?: StartOptions | { at?: TourAt }) => {\n if (typeof what !== \"string\") {\n startSteps(what, opts as StartOptions | undefined);\n return;\n }\n const run = launchRef.current;\n if (!run) {\n if (devWarnings()) console.warn(`[ui-kit] start(\"${what}\") needs TourProvider's \\`launch\\` prop.`);\n return;\n }\n void Promise.resolve(run(what, { at: opts?.at }, ownStartRef.current!, engine)).catch((error: unknown) =>\n console.error(error),\n );\n },\n [startSteps, engine],\n ) as TourContextValue[\"start\"];\n useLayoutEffect(() => {\n ownStartRef.current = start;\n }, [start]);\n const stop = useCallback(() => {\n setSteps(null);\n setActiveId(null);\n }, []);\n const finish = useCallback(() => {\n // Once per tour: a second \"Done\" before the overlay unmounts records nothing more.\n if (!stepsRef.current) return;\n stepsRef.current = null;\n const { tour, onFinish } = optsRef.current;\n const store = progressRef.current;\n // Exactly one write per completion (§9.6.2), so `awarded` is what `complete(tour)` answered.\n let awarded: boolean | undefined;\n if (store && tour) {\n try {\n awarded = completeStored(store.storageKey, store.migrate, tour);\n } catch (error) {\n // A stored text no migrate reads is left as it is (keksdose B-1); the tour still ends.\n console.error(error);\n awarded = false;\n }\n } else if (store && !tour && devWarnings() && !warnedNoTourRef.current) {\n warnedNoTourRef.current = true;\n console.warn(\n \"[ui-kit] TourProvider has `progress`, but a finished tour's start carried no `tour`: \" +\n \"nothing was recorded and `awarded` is undefined. Start it with `start(steps, { tour })`.\",\n );\n }\n onCompleteRef.current?.(tour, { awarded });\n onFinish?.();\n setSteps(null);\n setActiveId(null);\n }, []);\n // Takes no argument: the card's Skip passes its click event.\n const skip = useCallback(() => {\n optsRef.current.onSkip?.(\"skipped\");\n setSteps(null);\n setActiveId(null);\n }, []);\n const unavailable = useCallback(() => {\n // Once per run: the fallback's layout effect runs twice under StrictMode.\n if (!stepsRef.current) return;\n stepsRef.current = null;\n optsRef.current.onSkip?.(\"unavailable\");\n setSteps(null);\n setActiveId(null);\n }, []);\n\n // A step whose `when` is false is passed over: `goToStep` lands on the next step shown\n // after it, failing that the previous one; Next past the last shown step finishes.\n const goToStep = useCallback(\n (i: number) => {\n const s = stepsRef.current;\n if (!s || s.length === 0) return;\n const wanted = Math.min(Math.max(floorRef.current, Math.floor(i)), s.length - 1);\n let to = forward(s, wanted, \"goto\");\n if (to < 0) to = backward(s, wanted, \"goto\");\n if (to >= 0) arrive(s, to, \"goto\");\n },\n [arrive, forward, backward],\n );\n const next = useCallback(() => {\n const s = stepsRef.current;\n if (!s || s.length === 0) return;\n const to = forward(s, indexRef.current + 1, \"next\");\n if (to < 0) finish();\n else arrive(s, to, \"next\");\n }, [arrive, forward, finish]);\n const prev = useCallback(() => {\n const s = stepsRef.current;\n if (!s) return;\n const to = backward(s, indexRef.current - 1, \"back\");\n if (to >= 0) arrive(s, to, \"back\");\n }, [arrive, backward]);\n\n // awaitGate (§11.4): `release` and `refuse` are events, heard only while a tour runs.\n useEffect(() => {\n if (!active) return;\n let seq = 0;\n return gates.listen((signal) => {\n const s = stepsRef.current;\n if (!s) return;\n const i = indexRef.current;\n if (signal.kind === \"refuse\") {\n // On any other step the form's own errors speak.\n if (s[i]?.awaitGate === signal.key) setRefusal({ step: s[i], reason: signal.reason, seq: ++seq });\n return;\n }\n // The step awaiting it, or the first later one: the record is saved, so the fields\n // between are passed over.\n const awaiting =\n s[i]?.awaitGate === signal.key ? i : s.findIndex((st, k) => k > i && st.awaitGate === signal.key);\n if (awaiting < 0) return;\n const to = forward(s, awaiting + 1, \"next\");\n if (to < 0) finish();\n else arrive(s, to, \"next\");\n });\n }, [active, gates, arrive, forward, finish]);\n\n const value: TourContextValue = {\n active,\n activeId,\n start,\n stop,\n next,\n prev,\n goToStep,\n index,\n total,\n position: active ? nav.position : 0,\n count: active ? nav.count : 0,\n };\n // Read by the live engine (`launch`'s fourth argument) after this render commits.\n useLayoutEffect(() => {\n live.set(value);\n });\n\n return (\n <TourInternalContext.Provider value={internals}>\n <TourContext.Provider value={value}>\n {children}\n {active ? (\n // Its own boundary, so the first start's chunk fetch suspends nothing of the\n // app's; it shows nothing meanwhile, as the overlay itself does until it has\n // located the step, and hears Escape as it does. A failed fetch ends the run\n // (`TourOverlayUnavailable`).\n <Suspense fallback={<TourOverlayLoading onSkip={skip} />}>\n <TourUnavailableContext.Provider value={unavailable}>\n <LazyTourOverlay\n steps={steps!}\n index={index}\n via={nav.via}\n floor={nav.floor}\n position={nav.position}\n count={nav.count}\n refusal={refusal?.step === steps![index] ? refusal : null}\n onGoTo={goToStep}\n labels={merged}\n gates={gates}\n dockOnPhones={dockOnPhones}\n onNext={next}\n onPrev={prev}\n onSkip={skip}\n />\n </TourUnavailableContext.Provider>\n </Suspense>\n ) : null}\n </TourContext.Provider>\n </TourInternalContext.Provider>\n );\n}\n\ninterface Nav {\n index: number;\n /** The run's first step (the `at` floor). */\n floor: number;\n via: TourStepContext[\"via\"];\n position: number;\n count: number;\n}\n\nconst NO_NAV: Nav = { index: 0, floor: 0, via: \"start\", position: 0, count: 0 };\n\n/** `StartOptions.at` as a step index: a number clamped, an anchor's first step, else 0. */\nfunction resolveAt(steps: TourStep[], at: TourAt): number {\n if (typeof at === \"number\") return Math.min(Math.max(0, Math.floor(at)), Math.max(0, steps.length - 1));\n const anchor = `data-tour=\"${at}\"`;\n const found = steps.findIndex((step) => step.target?.includes(anchor));\n if (found >= 0) return found;\n if (devWarnings())\n console.warn(`[ui-kit] A tour was started at \"${at}\", but no step targets [${anchor}]: it starts at 0.`);\n return 0;\n}\n"],"mappings":";AAwrBM,SAOwB,KAPxB;AAxrBN;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAwC;AACjD,SAAS,2BAA2B;AAEpC,SAAS,gBAAgB,iBAAiB,uBAAoD;AAC9F,SAAS,oBAAoB,aAAa,SAAS,aAAa,2BAA2B;AAC3F,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AAkB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AO;AACT;","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
3
3
  import { readStored, removeStored, writeStored } from "../lib/safe-storage.js";
4
- import { httpStatusOf } from "../auth/auth-errors.js";
4
+ import { httpStatusOf } from "../lib/http-status.js";
5
5
  import { isTourDone } from "./tour-info.js";
6
6
  const EMPTY = Object.freeze({});
7
7
  const listeners = /* @__PURE__ */ new Map();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tour/use-tour-progress.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport { readStored, removeStored, writeStored } from \"../lib/safe-storage\";\nimport { httpStatusOf } from \"../auth/auth-errors\";\nimport { isTourDone, type TourCompletions } from \"./tour-info\";\n\n/**\n * Which tours this device has completed (docs/tours-harmonization.md §2.6, §6.2) —\n * keksdose's `tour-progress-store` and kastlan's `completions.ts`, as one hook.\n *\n * - **Device storage, the app's key.** `storageKey` is always the app's: an app on shared\n * devices scopes it per account (KS, bench PCs), and an app that lists its keys\n * (KS `storage-keys.ts`) spells it there. Every access is guarded: a blocked or full\n * storage keeps the marks for this page's life instead of throwing.\n * - **One store, every reader.** A change notifies every hook on the same key in this tab\n * (an in-tab emitter) and in other tabs (the `storage` event), so the tours page and\n * `TourMenu` agree without a reload (ka F3).\n * - **`migrate(raw)`** reads an older shape, so nobody loses their done marks at adoption:\n * it gets the stored JSON (or the raw text, if it is no JSON) and returns the record for\n * a shape it recognises, `undefined` for any other — the kit's own shape included,\n * which it then reads itself. keksdose: zustand's `{state: {completed}, version: 1}`;\n * kastlan: an array of ids, completed without a date (`null`). It runs only on a stored\n * text that is not the kit's shape already, once per text and key. The FIRST `migrate`\n * any reader, `TourProvider` or {@link completeTour} passes for a key is remembered for\n * that key (later identities are ignored), so a reader without one, mounted first, no\n * longer hides the old marks from the rest (keksdose B-2). **Still, define the options\n * once, at module level, and hand the provider and every reader the same object.**\n * - **Never overwritten unread** (keksdose B-1): a write (`complete`, the provider's,\n * `completeTour`) on a stored text that is neither empty nor the kit's shape, and that no\n * known `migrate` reads, THROWS instead of replacing the old marks.\n * - **Resetting the device** (settings §11): register the key with `reset: () =>\n * resetTourProgress(storageKey)`, which clears storage and the page's memory and tells\n * every reader in this tab.\n *\n * **The stored shape** (§9.3, §9.6.6), for an app's tests and seeds: the JSON record\n * `{ [id]: ISO instant | \"\" }` under `storageKey`, where `\"\"` is a completion without a\n * date (a migrated record: kastlan's id list). That is the one written form; the hooks\n * and callbacks (`completed`, `TourCompletions`) give `null` for `\"\"`. A `null` read from\n * storage (or returned by `migrate`) is accepted as the same thing and written back as\n * `\"\"`. To write a completion from outside a page, use {@link completeTour}.\n *\n * **On the account** (0.45, §10.2–§10.3): with `account`, the device key becomes the\n * account's CACHE — see {@link TourProgressAccount}. Without it, nothing changes from 0.44.\n */\nexport interface UseTourProgressOptions {\n storageKey: string;\n migrate?: (raw: unknown) => Record<string, string | null> | undefined;\n /**\n * 0.45: the account's record behind the device key (§10.2.4). Remembered per key like\n * `migrate` (the FIRST one any reader or the provider passes wins). With it,\n * `storageKey` must be per account (a prefix plus the user id), so build the options per\n * account and keep ONE stable object per key — memoise them in a `Map` by user id — and\n * let `load`/`save` read the current token when they run, never capture one:\n *\n * const byUser = new Map<string, UseTourProgressOptions>();\n * function tourProgressFor(user: { id: string; isDemo: boolean } | null) {\n * if (!user || user.isDemo) return { storageKey: \"app.tours.completions\" }; // no account\n * let options = byUser.get(user.id);\n * if (!options) byUser.set(user.id, (options = { storageKey: `app.tours.completions:${user.id}`, account }));\n * return options;\n * }\n *\n * Signed out, and in a demo, pass none (and a fixed key): the device record works as in\n * 0.44, and a demo neither PATCHes into a 403 nor leaves an orphan key per demo id.\n */\n account?: TourProgressAccount;\n}\n\n/** The record on the wire (§10.2.2): tour id → ISO instant, or `\"\"` (done, no date). */\ntype TourProgressWire = Record<string, string>;\n\n/** The `PATCH /tours/progress` body (§10.2.2): what to mark done, and what to forget.\n * An id is never in both. Either may be left out. */\nexport interface TourProgressBody {\n completed?: TourProgressWire;\n forget?: string[];\n}\n\n/**\n * Taking over a device-wide record from before the account (§10.2.5), on the FIRST load\n * of the account key on this page:\n * - `{storageKey, discard: true}` (kastlan): removes the old key and uploads nothing — a\n * shared PC must not hand one person another's marks. Removing an absent key is a no-op.\n * - `{storageKey, migrate?}`: reads the old key once (through `migrate` for an older\n * shape), uploads it to the first account that signs in on this device, then removes it.\n */\nexport type TourProgressAdopt =\n | { storageKey: string; discard: true; migrate?: never }\n | { storageKey: string; discard?: false; migrate?: UseTourProgressOptions[\"migrate\"] };\n\n/**\n * The app's account record (§10.3): `load()` is its `GET /tours/progress`, `save(body)`\n * its `PATCH`, each resolving to the parsed answer, `{completed}` — the whole record.\n *\n * - The page paints from the device key at once (and offline); the account is loaded on\n * the first reader of the key on this page, on `online`, and after each save, and its\n * answer replaces the cache.\n * - A write (`complete`, the provider's finish, `reset`) goes to the cache at once and to\n * a PENDING record beside it, `<storageKey>:pending` (`{synced, completed, forget}`),\n * sent as one PATCH and cleared by its answer. A failure with no answer (offline, 5xx,\n * 401) keeps it for the next load or `online`; a 402 (a lapsed plan) keeps it but sends it\n * no more on this page (the next session or page load tries again); a 403 or 422 drops\n * it and logs.\n * - `awarded` stays the device's answer against the cache (§10.2.4).\n * - The pending record is NOT the app's outbox: leave it out of any \"N waiting\" count\n * and any sign-out guard (losing a tour mark is acceptable).\n * - A device record never synced (no `:pending` with `synced: true`) is uploaded whole on\n * its first load, by the server's merge rule (later completion wins).\n * - On every end of a session call {@link signOutTourProgress}.\n */\nexport interface TourProgressAccount {\n load: () => Promise<{ completed: TourProgressWire }>;\n save: (body: TourProgressBody) => Promise<{ completed: TourProgressWire }>;\n adopt?: TourProgressAdopt;\n}\n\n/** What `complete` takes: a tour id, or the tour (`{id, updated}`, a `TourInfo` fits). */\ntype CompletedTour = string | { id: string; updated?: { date: string } | null };\n\nexport interface TourProgress {\n /** Tour id → the completion's ISO timestamp, or `null` when recorded without a date. */\n completed: TourCompletions;\n /**\n * Record a completion. Keeps the FIRST completion's date, so a replay changes nothing —\n * unless the tour was reset by an update since (§8): pass the tour (`{id, updated}`) and\n * a completion from before `updated.date` is replaced by today's.\n *\n * Returns `true` when this counts as a new completion — the moment to award the tour's\n * points and show the app's toast (§6.1) — and `false` for a replay.\n *\n * A tour started with `start(steps, {tour})` under a `TourProvider` that has `progress`\n * is recorded by the provider (§9.6.2): do not call this from that start's `onFinish`\n * too, or the second write answers `false`.\n */\n complete: (tour: CompletedTour) => boolean;\n /** \"Mark as not done\": forget the completion. */\n reset: (id: string) => void;\n}\n\n/* ── The store: one per key, shared by every hook ───────────────────────────── */\n\nconst EMPTY: TourCompletions = Object.freeze({});\n/** In-tab listeners per key. */\nconst listeners = new Map<string, Set<() => void>>();\n/** What this page wrote where storage refused to keep it (blocked, full): per key. */\nconst memory = new Map<string, string>();\n/**\n * The last raw text read per key and what it parsed to, so a snapshot keeps its identity:\n * the same text gives the same object, whichever reader asks and whatever `migrate` it\n * holds. Several readers of one key with inline `migrate` arrows used to evict each other\n * here and loop (kastlan B1, 0.43).\n */\nconst cache = new Map<string, { raw: string | null; value: TourCompletions; readable: boolean }>();\ntype Migrate = NonNullable<UseTourProgressOptions[\"migrate\"]>;\n/** Each key's migrate: the first one any reader, the provider or `completeTour` passes (B-2). */\nconst migrates = new Map<string, Migrate>();\n\n/**\n * Remember `migrate` for `key` if it is the first one, and return the key's migrate. A\n * snapshot parsed before the key had one is dropped and re-parsed, and the key's readers\n * hear of it after this render (never from inside one).\n * @internal Not part of the barrel; `TourProvider` registers its `progress` with it.\n */\nexport function rememberMigrate(key: string, migrate: UseTourProgressOptions[\"migrate\"]): Migrate | undefined {\n if (migrate && !migrates.has(key)) {\n migrates.set(key, migrate);\n if (cache.delete(key)) queueMicrotask(() => emit(key));\n }\n return migrates.get(key);\n}\n\nfunction emit(key: string) {\n listeners.get(key)?.forEach((listener) => listener());\n}\n\nfunction rawOf(key: string): string | null {\n return memory.get(key) ?? readStored(key);\n}\n\n/** Is this the kit's own shape already: a record whose every value is a string or null? */\nfunction isKitShape(value: unknown): boolean {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n return Object.values(value as Record<string, unknown>).every((at) => at === null || typeof at === \"string\");\n}\n\n/** The kit's own shape: a record of string or null; anything else is dropped. */\nfunction fromRecord(value: unknown): TourCompletions | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n const out: Record<string, string | null> = {};\n for (const [id, at] of Object.entries(value as Record<string, unknown>)) {\n if (at === null || at === \"\") out[id] = null;\n else if (typeof at === \"string\") out[id] = at;\n }\n return out;\n}\n\n/**\n * The record, and whether the text was READ (empty, the kit's shape, or a shape `migrate`\n * knows) rather than dropped: a write over an unread text would lose it (B-1).\n */\nfunction parse(\n raw: string | null,\n migrate: UseTourProgressOptions[\"migrate\"],\n): { value: TourCompletions; readable: boolean } {\n if (raw === null || raw.trim() === \"\") return { value: EMPTY, readable: true };\n let value: unknown = raw;\n try {\n value = JSON.parse(raw);\n } catch {\n // Not JSON: `migrate` still sees the text.\n }\n if (migrate && !isKitShape(value)) {\n try {\n const migrated = fromRecord(migrate(value));\n if (migrated !== undefined) return { value: migrated, readable: true };\n } catch {\n // A migrate that throws reads as \"not a shape it knows\".\n }\n }\n return { value: fromRecord(value) ?? EMPTY, readable: isKitShape(value) };\n}\n\nfunction snapshot(key: string, migrate: UseTourProgressOptions[\"migrate\"]): TourCompletions {\n const known = rememberMigrate(key, migrate);\n const raw = rawOf(key);\n const hit = cache.get(key);\n if (hit && hit.raw === raw) return hit.value;\n const parsed = parse(raw, known);\n cache.set(key, { raw, ...parsed });\n return parsed.value;\n}\n\n/** The record a write builds on; throws rather than overwrite a text nobody could read (B-1). */\nfunction readForWrite(key: string, migrate: UseTourProgressOptions[\"migrate\"], own = false): TourCompletions {\n // `own`: this migrate, even where the key registered another (completeTour's `{migrate}`).\n const known = rememberMigrate(key, migrate);\n const { value, readable } =\n own && migrate && known !== migrate\n ? parse(rawOf(key), migrate)\n : { value: snapshot(key, migrate), readable: cache.get(key)?.readable };\n if (!readable) {\n throw new Error(\n `[ui-kit] tour progress: the text stored under \"${key}\" is not the kit's shape and no migrate reads it; ` +\n \"refusing to overwrite it. Pass the key's migrate (the shared useTourProgress / TourProvider options, \" +\n \"or completeTour's {migrate}).\",\n );\n }\n return value;\n}\n\n/** The one written form (§9.6.6): a completion without a date is stored as `\"\"`, never `null`. */\nfunction write(key: string, record: TourCompletions) {\n const stored: Record<string, string> = {};\n for (const [id, at] of Object.entries(record)) stored[id] = at ?? \"\";\n const raw = JSON.stringify(stored);\n writeStored(key, raw);\n // Storage refused it (blocked, full): keep it for this page's life instead.\n if (readStored(key) === raw) memory.delete(key);\n else memory.set(key, raw);\n emit(key);\n}\n\n/* ── The account behind the device key (0.45, §10.2.4–§10.2.8) ─────────────── */\n\n/** The key's account: the first one any reader or the provider passes (as `migrate`). */\nconst accounts = new Map<string, TourProgressAccount>();\n/** Keys whose account was loaded (or is loading) on this page: the first reader loads. */\nconst loaded = new Set<string>();\n/** Keys with a sync running, and those asked for another while it ran. */\nconst running = new Set<string>();\nconst rerun = new Set<string>();\n/** Keys with a sync queued for the end of this task: two writes in one handler, one PATCH. */\nconst queued = new Set<string>();\n/** Bumped by a sign-out: an answer that comes back after it never refills the cache. */\nconst epochs = new Map<string, number>();\n/** Keys whose PATCH got a 402 (a lapsed plan): the pending record is kept but not sent\n * again on this page; the next session (or page load) tries once more. */\nconst parked = new Set<string>();\n/** The pending record where storage refused to keep it. */\nconst pendingMemory = new Map<string, string>();\nlet onlineListening = false;\n\n/** The pending record (§10.2.4): what waits to be sent, and whether the device key was\n * ever synced. */\ninterface PendingRecord {\n synced: boolean;\n completed: TourProgressWire;\n forget: string[];\n}\n\nconst pendingKey = (key: string) => `${key}:pending`;\n\nfunction devWarn(message: string) {\n if (import.meta.env?.DEV) console.warn(message);\n}\n\n/**\n * Remember `account` for `key` if it is the first one, and return the key's account.\n * @internal Not part of the barrel; `TourProvider` registers its `progress` with it.\n */\nexport function rememberAccount(\n key: string,\n account: TourProgressAccount | undefined,\n): TourProgressAccount | undefined {\n if (account && !accounts.has(key)) {\n accounts.set(key, account);\n if (account.adopt && account.adopt.storageKey === key) {\n devWarn(\n `[ui-kit] tour progress: the account key \"${key}\" is the key \\`adopt\\` takes over. ` +\n \"With an account the key must be per account (a prefix plus the user id), apart from the old device-wide key.\",\n );\n }\n if (!onlineListening && typeof window !== \"undefined\") {\n onlineListening = true;\n window.addEventListener(\"online\", () => {\n for (const known of loaded) void sync(known);\n });\n }\n }\n return accounts.get(key);\n}\n\nfunction readPending(key: string): PendingRecord | null {\n const raw = pendingMemory.get(key) ?? readStored(pendingKey(key));\n if (raw === null) return null;\n try {\n const value = JSON.parse(raw) as Partial<PendingRecord> | null;\n if (!value || typeof value !== \"object\") return null;\n const completed: TourProgressWire = {};\n for (const [id, at] of Object.entries(value.completed ?? {})) {\n if (typeof at === \"string\") completed[id] = at;\n else if (at === null) completed[id] = \"\";\n }\n const forget = Array.isArray(value.forget) ? value.forget.filter((id): id is string => typeof id === \"string\") : [];\n return { synced: value.synced === true, completed, forget };\n } catch {\n return null;\n }\n}\n\nfunction writePending(key: string, record: PendingRecord) {\n const raw = JSON.stringify(record);\n writeStored(pendingKey(key), raw);\n if (readStored(pendingKey(key)) === raw) pendingMemory.delete(key);\n else pendingMemory.set(key, raw);\n}\n\nconst hasWork = (record: PendingRecord) => Object.keys(record.completed).length > 0 || record.forget.length > 0;\n\n/** \"Later completion wins\" (§10.2.3), as the server merges: an instant beats `\"\"`, `\"\"`\n * beats nothing, and between two instants the later is kept. */\nfunction later(a: string | undefined, b: string): string {\n if (a === undefined || a === \"\") return b;\n if (b === \"\") return a;\n return Date.parse(b) > Date.parse(a) ? b : a;\n}\n\n/** Note a completion (or, with `forget`, its removal) in the key's pending record. */\nfunction markPending(key: string, id: string, at: string | null | undefined, forget = false) {\n const record = readPending(key) ?? { synced: false, completed: {}, forget: [] };\n if (forget) {\n delete record.completed[id];\n if (!record.forget.includes(id)) record.forget.push(id);\n } else {\n record.completed[id] = at ?? \"\";\n record.forget = record.forget.filter((other) => other !== id);\n }\n writePending(key, record);\n}\n\n/** After an answer (or a 403/422): take what was sent out of the pending record, keeping\n * what was written while the request ran. */\nfunction clearSent(key: string, sent: TourProgressBody, synced: boolean) {\n const record = readPending(key) ?? { synced: false, completed: {}, forget: [] };\n for (const [id, at] of Object.entries(sent.completed ?? {})) {\n if (record.completed[id] === at) delete record.completed[id];\n }\n const forgotten = new Set(sent.forget ?? []);\n record.forget = record.forget.filter((id) => !forgotten.has(id));\n record.synced = record.synced || synced;\n writePending(key, record);\n}\n\n/** The account's answer as the cache, with what still waits to be sent laid over it. */\nfunction refill(key: string, answer: { completed: TourProgressWire } | null | undefined) {\n const next: Record<string, string> = {};\n for (const [id, at] of Object.entries(fromRecord(answer?.completed) ?? {})) next[id] = at ?? \"\";\n const waiting = readPending(key);\n if (waiting) {\n for (const [id, at] of Object.entries(waiting.completed)) next[id] = later(next[id], at);\n for (const id of waiting.forget) delete next[id];\n }\n const record: Record<string, string | null> = {};\n for (const [id, at] of Object.entries(next)) record[id] = at === \"\" ? null : at;\n write(key, record);\n}\n\n/** The first load of an account key on this page takes over the old device-wide key\n * (§10.2.5). */\nfunction adoptOldRecord(key: string, account: TourProgressAccount) {\n const adopt = account.adopt;\n if (!adopt || adopt.storageKey === key) return;\n const old = adopt.storageKey;\n if (!adopt.discard) {\n const { value } = parse(rawOf(old), adopt.migrate ?? migrates.get(old));\n const entries = Object.entries(value);\n if (entries.length > 0) {\n const record = readPending(key) ?? { synced: false, completed: {}, forget: [] };\n for (const [id, at] of entries) record.completed[id] = later(record.completed[id], at ?? \"\");\n writePending(key, record);\n }\n }\n // Removed either way, at once: no second account on this device gets it.\n removeStored(old);\n memory.delete(old);\n cache.delete(old);\n emit(old);\n}\n\n/** A device record never synced is uploaded whole on its first load (§10.2.5). */\nfunction uploadUnsynced(key: string) {\n const record = readPending(key);\n if (record?.synced) return;\n const device = snapshot(key, migrates.get(key));\n const entries = Object.entries(device);\n const next = record ?? { synced: false, completed: {}, forget: [] };\n if (entries.length === 0 && record) return;\n for (const [id, at] of entries) {\n if (!next.forget.includes(id)) next.completed[id] = later(next.completed[id], at ?? \"\");\n }\n writePending(key, next);\n}\n\n/** The key's first sync on this page: take over the old record, upload a never-synced one. */\nfunction prepare(key: string) {\n loaded.add(key);\n adoptOldRecord(key, accounts.get(key)!);\n uploadUnsynced(key);\n}\n\n/** Queue a sync for the end of this task, so a handler's writes go as one PATCH. */\nfunction queueSync(key: string) {\n if (!loaded.has(key)) prepare(key);\n if (queued.has(key)) return;\n queued.add(key);\n queueMicrotask(() => {\n queued.delete(key);\n void sync(key);\n });\n}\n\n/** The first reader of an account key on this page loads it. */\nfunction ensureLoaded(key: string) {\n if (!accounts.has(key) || loaded.has(key)) return;\n prepare(key);\n void sync(key);\n}\n\n/**\n * Send what waits (one PATCH) or, with nothing waiting, load; the answer replaces the\n * cache. One at a time per key; a request asked for while one runs follows it.\n */\nasync function sync(key: string): Promise<void> {\n const account = accounts.get(key);\n if (!account || !loaded.has(key)) return;\n if (running.has(key)) {\n rerun.add(key);\n return;\n }\n if (typeof navigator !== \"undefined\" && navigator.onLine === false) return;\n running.add(key);\n const epoch = epochs.get(key) ?? 0;\n try {\n const waiting = readPending(key);\n if (waiting && hasWork(waiting)) {\n if (parked.has(key)) return;\n const body: TourProgressBody = {};\n if (Object.keys(waiting.completed).length > 0) body.completed = { ...waiting.completed };\n if (waiting.forget.length > 0) body.forget = [...waiting.forget];\n let answer: { completed: TourProgressWire };\n try {\n answer = await account.save(body);\n } catch (error) {\n const status = httpStatusOf(error);\n if (status === 403 || status === 422) {\n // Refused for good (a demo, a malformed or full record): dropped, not retried.\n if ((epochs.get(key) ?? 0) === epoch) clearSent(key, body, false);\n console.warn(`[ui-kit] tour progress: the account refused the pending record (${status}); dropped.`, error);\n } else if (status === 402) {\n // A lapsed plan refuses every write: kept, but not re-sent after each finish\n // and each `online` — the next session or page load tries again.\n parked.add(key);\n }\n // No answer (offline, 5xx, 401): it stays for the next load or `online`.\n return;\n }\n if ((epochs.get(key) ?? 0) !== epoch) return;\n clearSent(key, body, true);\n refill(key, answer);\n } else {\n const answer = await account.load();\n if ((epochs.get(key) ?? 0) !== epoch) return;\n if (waiting && !waiting.synced) writePending(key, { ...waiting, synced: true });\n else if (!waiting) writePending(key, { synced: true, completed: {}, forget: [] });\n refill(key, answer);\n }\n } catch {\n // A load that failed keeps the cache as it is.\n } finally {\n running.delete(key);\n if (rerun.delete(key)) void sync(key);\n }\n}\n\n/**\n * The end of a session (§10.2.6) — sign-out, a 401 nothing could renew, the account's\n * deletion, every path: removes the CACHE only (the device key and the page's snapshot;\n * every reader in this tab moves), synchronously and with no request, and KEEPS\n * `<storageKey>:pending`. That record sits under this person's own key, holds tour ids and\n * dates only, and goes out on their next sign-in. An answer still on its way is ignored.\n *\n * function logout() { …; signOutTourProgress(`app.tours:${user.id}`); }\n */\nexport function signOutTourProgress(storageKey: string): void {\n epochs.set(storageKey, (epochs.get(storageKey) ?? 0) + 1);\n loaded.delete(storageKey);\n rerun.delete(storageKey);\n parked.delete(storageKey);\n removeStored(storageKey);\n memory.delete(storageKey);\n cache.delete(storageKey);\n emit(storageKey);\n}\n\nfunction subscribe(key: string, listener: () => void): () => void {\n let set = listeners.get(key);\n if (!set) listeners.set(key, (set = new Set()));\n set.add(listener);\n // Another tab wrote (or cleared all storage: `key` null).\n const onStorage = (event: StorageEvent) => {\n if (event.key !== null && event.key !== key) return;\n memory.delete(key);\n listener();\n };\n if (typeof window !== \"undefined\") window.addEventListener(\"storage\", onStorage);\n return () => {\n set.delete(listener);\n if (typeof window !== \"undefined\") window.removeEventListener(\"storage\", onStorage);\n };\n}\n\n/**\n * Forget every tour completion under `storageKey` on this device: the stored key, what the\n * page kept in memory where storage refused it, and every reader in this tab moves at\n * once. For \"Reset this device's settings\" (settings §11):\n *\n * registerDeviceSetting({ key: TOUR_KEY, kind: \"view\", reset: () => resetTourProgress(TOUR_KEY) });\n *\n * With an account (0.45) it clears the cache only: the account is never written, the\n * pending record stays (\"anything waiting to be sent\", settings §11.2.2) and the next load\n * refills the cache. Tour progress is never registered with the device reset (§10.2.8).\n */\nexport function resetTourProgress(storageKey: string): void {\n if (accounts.has(storageKey)) loaded.delete(storageKey);\n removeStored(storageKey);\n memory.delete(storageKey);\n cache.delete(storageKey);\n emit(storageKey);\n}\n\n/**\n * Record a completion under `storageKey`, as {@link TourProgress.complete} does: through\n * the one shared store and snapshot (never a copy), so every reader of the key moves.\n * Returns `true` when it counts anew. `TourProvider` calls this on a tour's last step.\n * @internal Not part of the barrel.\n */\nexport function completeStored(\n storageKey: string,\n migrate: UseTourProgressOptions[\"migrate\"],\n tour: CompletedTour,\n): boolean {\n const subject = typeof tour === \"string\" ? { id: tour } : tour;\n // Read now rather than from a render: two completions in one handler both count.\n const current = readForWrite(storageKey, migrate);\n if (isTourDone(subject, current[subject.id])) return false;\n const at = new Date().toISOString();\n write(storageKey, { ...current, [subject.id]: at });\n if (accounts.has(storageKey)) {\n markPending(storageKey, subject.id, at);\n queueSync(storageKey);\n }\n return true;\n}\n\n/** \"Mark as not done\" (§10.2.8): off the cache, and `forget` to the account. @internal */\nfunction resetStored(storageKey: string, migrate: UseTourProgressOptions[\"migrate\"], id: string) {\n const current = snapshot(storageKey, migrate);\n if (current[id] === undefined) return;\n const next = { ...current };\n delete next[id];\n write(storageKey, next);\n if (accounts.has(storageKey)) {\n markPending(storageKey, id, undefined, true);\n queueSync(storageKey);\n }\n}\n\n/**\n * Write a completion from outside a page (§9.2): for an app's tests, seeds and scripts,\n * beside {@link resetTourProgress}. It writes the kit's stored shape (`{[id]: ISO | \"\"}`)\n * under `storageKey`, keeps the other tours' marks, and notifies every reader of the key\n * in this tab directly (the `storage` event reaches only OTHER tabs), so a mounted\n * `useTourProgress` or `TourCatalogue` moves at once.\n *\n * Unlike `complete`, it always writes (over a readable text; see below): `at` is the\n * completion's instant (an ISO string or a `Date`, default now), `null` a completion\n * without a date (stored as `\"\"`, read back as `null`).\n *\n * completeTour(TOUR_KEY, \"budget\", \"2026-09-01T10:00:00Z\");\n *\n * A stored text in an app's older shape is read through `opts.migrate`, or else the\n * migrate a reader or the provider registered for the key. If the text is neither empty\n * nor the kit's shape and no migrate reads it, this THROWS and writes nothing (B-1):\n *\n * completeTour(TOUR_KEY, \"budget\", undefined, { migrate: fromZustand });\n *\n * With an account on the key (0.45) it stays a device write — no request — and is marked\n * pending, so the next load sends it.\n */\nexport function completeTour(\n storageKey: string,\n tour: string | { id: string },\n at?: string | Date | null,\n opts?: { migrate?: UseTourProgressOptions[\"migrate\"] },\n): void {\n const id = typeof tour === \"string\" ? tour : tour.id;\n const when = at === null ? null : at instanceof Date ? at.toISOString() : (at ?? new Date().toISOString());\n write(storageKey, { ...readForWrite(storageKey, opts?.migrate, true), [id]: when });\n if (accounts.has(storageKey)) markPending(storageKey, id, when);\n}\n\n/** The device's tour completions under `storageKey`; see {@link UseTourProgressOptions}. */\nexport function useTourProgress({ storageKey, migrate, account }: UseTourProgressOptions): TourProgress {\n // Held, not depended on: an inline arrow is a new function every render, and neither the\n // snapshot nor the callbacks may change with it.\n const migrateRef = useRef(migrate);\n useEffect(() => {\n migrateRef.current = migrate;\n });\n // The first account for the key wins (as `migrate`); its first reader on the page loads.\n const accountRef = useRef(account);\n useEffect(() => {\n accountRef.current = account;\n });\n useEffect(() => {\n if (rememberAccount(storageKey, accountRef.current)) ensureLoaded(storageKey);\n }, [storageKey]);\n const completed = useSyncExternalStore(\n useCallback((listener: () => void) => subscribe(storageKey, listener), [storageKey]),\n () => snapshot(storageKey, migrateRef.current),\n () => EMPTY,\n );\n\n const complete = useCallback(\n (tour: CompletedTour) => completeStored(storageKey, migrateRef.current, tour),\n [storageKey],\n );\n\n const reset = useCallback((id: string) => resetStored(storageKey, migrateRef.current, id), [storageKey]);\n\n return useM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Ac,OAAO,GAAG,YAAY,IAAK,OAAM,oBAAI,KAAK,GAAE,YAAY;AACxG,QAAM,YAAY,EAAE,GAAG,aAAa,YAAY,MAAM,SAAS,IAAI,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC;AAClF,MAAI,SAAS,IAAI,UAAU,EAAG,aAAY,YAAY,IAAI,IAAI;AAChE;AAGO,SAAS,gBAAgB,EAAE,YAAY,SAAS,QAAQ,GAAyC;AAGtG,QAAM,aAAa,OAAO,OAAO;AACjC,YAAU,MAAM;AACd,eAAW,UAAU;AAAA,EACvB,CAAC;AAED,QAAM,aAAa,OAAO,OAAO;AACjC,YAAU,MAAM;AACd,eAAW,UAAU;AAAA,EACvB,CAAC;AACD,YAAU,MAAM;AACd,QAAI,gBAAgB,YAAY,WAAW,OAAO,EAAG,cAAa,UAAU;AAAA,EAC9E,GAAG,CAAC,UAAU,CAAC;AACf,QAAM,YAAY;AAAA,IAChB,YAAY,CAAC,aAAyB,UAAU,YAAY,QAAQ,GAAG,CAAC,UAAU,CAAC;AAAA,IACnF,MAAM,SAAS,YAAY,WAAW,OAAO;AAAA,IAC7C,MAAM;AAAA,EACR;AAEA,QAAM,WAAW;AAAA,IACf,CAAC,SAAwB,eAAe,YAAY,WAAW,SAAS,IAAI;AAAA,IAC5E,CAAC,UAAU;AAAA,EACb;AAEA,QAAM,QAAQ,YAAY,CAAC,OAAe,YAAY,YAAY,WAAW,SAAS,EAAE,GAAG,CAAC,UAAU,CAAC;AAEvG,SAAO,QAAQ,OAAO,EAAE,WAAW,UAAU,MAAM,IAAI,CAAC,WAAW,UAAU,KAAK,CAAC;AACrF;","names":[]}
1
+ {"version":3,"sources":["../../src/tour/use-tour-progress.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport { readStored, removeStored, writeStored } from \"../lib/safe-storage\";\nimport { httpStatusOf } from \"../lib/http-status\";\nimport { isTourDone, type TourCompletions } from \"./tour-info\";\n\n/**\n * Which tours this device has completed (docs/tours-harmonization.md §2.6, §6.2) —\n * keksdose's `tour-progress-store` and kastlan's `completions.ts`, as one hook.\n *\n * - **Device storage, the app's key.** `storageKey` is always the app's: an app on shared\n * devices scopes it per account (KS, bench PCs), and an app that lists its keys\n * (KS `storage-keys.ts`) spells it there. Every access is guarded: a blocked or full\n * storage keeps the marks for this page's life instead of throwing.\n * - **One store, every reader.** A change notifies every hook on the same key in this tab\n * (an in-tab emitter) and in other tabs (the `storage` event), so the tours page and\n * `TourMenu` agree without a reload (ka F3).\n * - **`migrate(raw)`** reads an older shape, so nobody loses their done marks at adoption:\n * it gets the stored JSON (or the raw text, if it is no JSON) and returns the record for\n * a shape it recognises, `undefined` for any other — the kit's own shape included,\n * which it then reads itself. keksdose: zustand's `{state: {completed}, version: 1}`;\n * kastlan: an array of ids, completed without a date (`null`). It runs only on a stored\n * text that is not the kit's shape already, once per text and key. The FIRST `migrate`\n * any reader, `TourProvider` or {@link completeTour} passes for a key is remembered for\n * that key (later identities are ignored), so a reader without one, mounted first, no\n * longer hides the old marks from the rest (keksdose B-2). **Still, define the options\n * once, at module level, and hand the provider and every reader the same object.**\n * - **Never overwritten unread** (keksdose B-1): a write (`complete`, the provider's,\n * `completeTour`) on a stored text that is neither empty nor the kit's shape, and that no\n * known `migrate` reads, THROWS instead of replacing the old marks.\n * - **Resetting the device** (settings §11): register the key with `reset: () =>\n * resetTourProgress(storageKey)`, which clears storage and the page's memory and tells\n * every reader in this tab.\n *\n * **The stored shape** (§9.3, §9.6.6), for an app's tests and seeds: the JSON record\n * `{ [id]: ISO instant | \"\" }` under `storageKey`, where `\"\"` is a completion without a\n * date (a migrated record: kastlan's id list). That is the one written form; the hooks\n * and callbacks (`completed`, `TourCompletions`) give `null` for `\"\"`. A `null` read from\n * storage (or returned by `migrate`) is accepted as the same thing and written back as\n * `\"\"`. To write a completion from outside a page, use {@link completeTour}.\n *\n * **On the account** (0.45, §10.2–§10.3): with `account`, the device key becomes the\n * account's CACHE — see {@link TourProgressAccount}. Without it, nothing changes from 0.44.\n */\nexport interface UseTourProgressOptions {\n storageKey: string;\n migrate?: (raw: unknown) => Record<string, string | null> | undefined;\n /**\n * 0.45: the account's record behind the device key (§10.2.4). Remembered per key like\n * `migrate` (the FIRST one any reader or the provider passes wins). With it,\n * `storageKey` must be per account (a prefix plus the user id), so build the options per\n * account and keep ONE stable object per key — memoise them in a `Map` by user id — and\n * let `load`/`save` read the current token when they run, never capture one:\n *\n * const byUser = new Map<string, UseTourProgressOptions>();\n * function tourProgressFor(user: { id: string; isDemo: boolean } | null) {\n * if (!user || user.isDemo) return { storageKey: \"app.tours.completions\" }; // no account\n * let options = byUser.get(user.id);\n * if (!options) byUser.set(user.id, (options = { storageKey: `app.tours.completions:${user.id}`, account }));\n * return options;\n * }\n *\n * Signed out, and in a demo, pass none (and a fixed key): the device record works as in\n * 0.44, and a demo neither PATCHes into a 403 nor leaves an orphan key per demo id.\n */\n account?: TourProgressAccount;\n}\n\n/** The record on the wire (§10.2.2): tour id → ISO instant, or `\"\"` (done, no date). */\ntype TourProgressWire = Record<string, string>;\n\n/** The `PATCH /tours/progress` body (§10.2.2): what to mark done, and what to forget.\n * An id is never in both. Either may be left out. */\nexport interface TourProgressBody {\n completed?: TourProgressWire;\n forget?: string[];\n}\n\n/**\n * Taking over a device-wide record from before the account (§10.2.5), on the FIRST load\n * of the account key on this page:\n * - `{storageKey, discard: true}` (kastlan): removes the old key and uploads nothing — a\n * shared PC must not hand one person another's marks. Removing an absent key is a no-op.\n * - `{storageKey, migrate?}`: reads the old key once (through `migrate` for an older\n * shape), uploads it to the first account that signs in on this device, then removes it.\n */\nexport type TourProgressAdopt =\n | { storageKey: string; discard: true; migrate?: never }\n | { storageKey: string; discard?: false; migrate?: UseTourProgressOptions[\"migrate\"] };\n\n/**\n * The app's account record (§10.3): `load()` is its `GET /tours/progress`, `save(body)`\n * its `PATCH`, each resolving to the parsed answer, `{completed}` — the whole record.\n *\n * - The page paints from the device key at once (and offline); the account is loaded on\n * the first reader of the key on this page, on `online`, and after each save, and its\n * answer replaces the cache.\n * - A write (`complete`, the provider's finish, `reset`) goes to the cache at once and to\n * a PENDING record beside it, `<storageKey>:pending` (`{synced, completed, forget}`),\n * sent as one PATCH and cleared by its answer. A failure with no answer (offline, 5xx,\n * 401) keeps it for the next load or `online`; a 402 (a lapsed plan) keeps it but sends it\n * no more on this page (the next session or page load tries again); a 403 or 422 drops\n * it and logs.\n * - `awarded` stays the device's answer against the cache (§10.2.4).\n * - The pending record is NOT the app's outbox: leave it out of any \"N waiting\" count\n * and any sign-out guard (losing a tour mark is acceptable).\n * - A device record never synced (no `:pending` with `synced: true`) is uploaded whole on\n * its first load, by the server's merge rule (later completion wins).\n * - On every end of a session call {@link signOutTourProgress}.\n */\nexport interface TourProgressAccount {\n load: () => Promise<{ completed: TourProgressWire }>;\n save: (body: TourProgressBody) => Promise<{ completed: TourProgressWire }>;\n adopt?: TourProgressAdopt;\n}\n\n/** What `complete` takes: a tour id, or the tour (`{id, updated}`, a `TourInfo` fits). */\ntype CompletedTour = string | { id: string; updated?: { date: string } | null };\n\nexport interface TourProgress {\n /** Tour id → the completion's ISO timestamp, or `null` when recorded without a date. */\n completed: TourCompletions;\n /**\n * Record a completion. Keeps the FIRST completion's date, so a replay changes nothing —\n * unless the tour was reset by an update since (§8): pass the tour (`{id, updated}`) and\n * a completion from before `updated.date` is replaced by today's.\n *\n * Returns `true` when this counts as a new completion — the moment to award the tour's\n * points and show the app's toast (§6.1) — and `false` for a replay.\n *\n * A tour started with `start(steps, {tour})` under a `TourProvider` that has `progress`\n * is recorded by the provider (§9.6.2): do not call this from that start's `onFinish`\n * too, or the second write answers `false`.\n */\n complete: (tour: CompletedTour) => boolean;\n /** \"Mark as not done\": forget the completion. */\n reset: (id: string) => void;\n}\n\n/* ── The store: one per key, shared by every hook ───────────────────────────── */\n\nconst EMPTY: TourCompletions = Object.freeze({});\n/** In-tab listeners per key. */\nconst listeners = new Map<string, Set<() => void>>();\n/** What this page wrote where storage refused to keep it (blocked, full): per key. */\nconst memory = new Map<string, string>();\n/**\n * The last raw text read per key and what it parsed to, so a snapshot keeps its identity:\n * the same text gives the same object, whichever reader asks and whatever `migrate` it\n * holds. Several readers of one key with inline `migrate` arrows used to evict each other\n * here and loop (kastlan B1, 0.43).\n */\nconst cache = new Map<string, { raw: string | null; value: TourCompletions; readable: boolean }>();\ntype Migrate = NonNullable<UseTourProgressOptions[\"migrate\"]>;\n/** Each key's migrate: the first one any reader, the provider or `completeTour` passes (B-2). */\nconst migrates = new Map<string, Migrate>();\n\n/**\n * Remember `migrate` for `key` if it is the first one, and return the key's migrate. A\n * snapshot parsed before the key had one is dropped and re-parsed, and the key's readers\n * hear of it after this render (never from inside one).\n * @internal Not part of the barrel; `TourProvider` registers its `progress` with it.\n */\nexport function rememberMigrate(key: string, migrate: UseTourProgressOptions[\"migrate\"]): Migrate | undefined {\n if (migrate && !migrates.has(key)) {\n migrates.set(key, migrate);\n if (cache.delete(key)) queueMicrotask(() => emit(key));\n }\n return migrates.get(key);\n}\n\nfunction emit(key: string) {\n listeners.get(key)?.forEach((listener) => listener());\n}\n\nfunction rawOf(key: string): string | null {\n return memory.get(key) ?? readStored(key);\n}\n\n/** Is this the kit's own shape already: a record whose every value is a string or null? */\nfunction isKitShape(value: unknown): boolean {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n return Object.values(value as Record<string, unknown>).every((at) => at === null || typeof at === \"string\");\n}\n\n/** The kit's own shape: a record of string or null; anything else is dropped. */\nfunction fromRecord(value: unknown): TourCompletions | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n const out: Record<string, string | null> = {};\n for (const [id, at] of Object.entries(value as Record<string, unknown>)) {\n if (at === null || at === \"\") out[id] = null;\n else if (typeof at === \"string\") out[id] = at;\n }\n return out;\n}\n\n/**\n * The record, and whether the text was READ (empty, the kit's shape, or a shape `migrate`\n * knows) rather than dropped: a write over an unread text would lose it (B-1).\n */\nfunction parse(\n raw: string | null,\n migrate: UseTourProgressOptions[\"migrate\"],\n): { value: TourCompletions; readable: boolean } {\n if (raw === null || raw.trim() === \"\") return { value: EMPTY, readable: true };\n let value: unknown = raw;\n try {\n value = JSON.parse(raw);\n } catch {\n // Not JSON: `migrate` still sees the text.\n }\n if (migrate && !isKitShape(value)) {\n try {\n const migrated = fromRecord(migrate(value));\n if (migrated !== undefined) return { value: migrated, readable: true };\n } catch {\n // A migrate that throws reads as \"not a shape it knows\".\n }\n }\n return { value: fromRecord(value) ?? EMPTY, readable: isKitShape(value) };\n}\n\nfunction snapshot(key: string, migrate: UseTourProgressOptions[\"migrate\"]): TourCompletions {\n const known = rememberMigrate(key, migrate);\n const raw = rawOf(key);\n const hit = cache.get(key);\n if (hit && hit.raw === raw) return hit.value;\n const parsed = parse(raw, known);\n cache.set(key, { raw, ...parsed });\n return parsed.value;\n}\n\n/** The record a write builds on; throws rather than overwrite a text nobody could read (B-1). */\nfunction readForWrite(key: string, migrate: UseTourProgressOptions[\"migrate\"], own = false): TourCompletions {\n // `own`: this migrate, even where the key registered another (completeTour's `{migrate}`).\n const known = rememberMigrate(key, migrate);\n const { value, readable } =\n own && migrate && known !== migrate\n ? parse(rawOf(key), migrate)\n : { value: snapshot(key, migrate), readable: cache.get(key)?.readable };\n if (!readable) {\n throw new Error(\n `[ui-kit] tour progress: the text stored under \"${key}\" is not the kit's shape and no migrate reads it; ` +\n \"refusing to overwrite it. Pass the key's migrate (the shared useTourProgress / TourProvider options, \" +\n \"or completeTour's {migrate}).\",\n );\n }\n return value;\n}\n\n/** The one written form (§9.6.6): a completion without a date is stored as `\"\"`, never `null`. */\nfunction write(key: string, record: TourCompletions) {\n const stored: Record<string, string> = {};\n for (const [id, at] of Object.entries(record)) stored[id] = at ?? \"\";\n const raw = JSON.stringify(stored);\n writeStored(key, raw);\n // Storage refused it (blocked, full): keep it for this page's life instead.\n if (readStored(key) === raw) memory.delete(key);\n else memory.set(key, raw);\n emit(key);\n}\n\n/* ── The account behind the device key (0.45, §10.2.4–§10.2.8) ─────────────── */\n\n/** The key's account: the first one any reader or the provider passes (as `migrate`). */\nconst accounts = new Map<string, TourProgressAccount>();\n/** Keys whose account was loaded (or is loading) on this page: the first reader loads. */\nconst loaded = new Set<string>();\n/** Keys with a sync running, and those asked for another while it ran. */\nconst running = new Set<string>();\nconst rerun = new Set<string>();\n/** Keys with a sync queued for the end of this task: two writes in one handler, one PATCH. */\nconst queued = new Set<string>();\n/** Bumped by a sign-out: an answer that comes back after it never refills the cache. */\nconst epochs = new Map<string, number>();\n/** Keys whose PATCH got a 402 (a lapsed plan): the pending record is kept but not sent\n * again on this page; the next session (or page load) tries once more. */\nconst parked = new Set<string>();\n/** The pending record where storage refused to keep it. */\nconst pendingMemory = new Map<string, string>();\nlet onlineListening = false;\n\n/** The pending record (§10.2.4): what waits to be sent, and whether the device key was\n * ever synced. */\ninterface PendingRecord {\n synced: boolean;\n completed: TourProgressWire;\n forget: string[];\n}\n\nconst pendingKey = (key: string) => `${key}:pending`;\n\nfunction devWarn(message: string) {\n if (import.meta.env?.DEV) console.warn(message);\n}\n\n/**\n * Remember `account` for `key` if it is the first one, and return the key's account.\n * @internal Not part of the barrel; `TourProvider` registers its `progress` with it.\n */\nexport function rememberAccount(\n key: string,\n account: TourProgressAccount | undefined,\n): TourProgressAccount | undefined {\n if (account && !accounts.has(key)) {\n accounts.set(key, account);\n if (account.adopt && account.adopt.storageKey === key) {\n devWarn(\n `[ui-kit] tour progress: the account key \"${key}\" is the key \\`adopt\\` takes over. ` +\n \"With an account the key must be per account (a prefix plus the user id), apart from the old device-wide key.\",\n );\n }\n if (!onlineListening && typeof window !== \"undefined\") {\n onlineListening = true;\n window.addEventListener(\"online\", () => {\n for (const known of loaded) void sync(known);\n });\n }\n }\n return accounts.get(key);\n}\n\nfunction readPending(key: string): PendingRecord | null {\n const raw = pendingMemory.get(key) ?? readStored(pendingKey(key));\n if (raw === null) return null;\n try {\n const value = JSON.parse(raw) as Partial<PendingRecord> | null;\n if (!value || typeof value !== \"object\") return null;\n const completed: TourProgressWire = {};\n for (const [id, at] of Object.entries(value.completed ?? {})) {\n if (typeof at === \"string\") completed[id] = at;\n else if (at === null) completed[id] = \"\";\n }\n const forget = Array.isArray(value.forget) ? value.forget.filter((id): id is string => typeof id === \"string\") : [];\n return { synced: value.synced === true, completed, forget };\n } catch {\n return null;\n }\n}\n\nfunction writePending(key: string, record: PendingRecord) {\n const raw = JSON.stringify(record);\n writeStored(pendingKey(key), raw);\n if (readStored(pendingKey(key)) === raw) pendingMemory.delete(key);\n else pendingMemory.set(key, raw);\n}\n\nconst hasWork = (record: PendingRecord) => Object.keys(record.completed).length > 0 || record.forget.length > 0;\n\n/** \"Later completion wins\" (§10.2.3), as the server merges: an instant beats `\"\"`, `\"\"`\n * beats nothing, and between two instants the later is kept. */\nfunction later(a: string | undefined, b: string): string {\n if (a === undefined || a === \"\") return b;\n if (b === \"\") return a;\n return Date.parse(b) > Date.parse(a) ? b : a;\n}\n\n/** Note a completion (or, with `forget`, its removal) in the key's pending record. */\nfunction markPending(key: string, id: string, at: string | null | undefined, forget = false) {\n const record = readPending(key) ?? { synced: false, completed: {}, forget: [] };\n if (forget) {\n delete record.completed[id];\n if (!record.forget.includes(id)) record.forget.push(id);\n } else {\n record.completed[id] = at ?? \"\";\n record.forget = record.forget.filter((other) => other !== id);\n }\n writePending(key, record);\n}\n\n/** After an answer (or a 403/422): take what was sent out of the pending record, keeping\n * what was written while the request ran. */\nfunction clearSent(key: string, sent: TourProgressBody, synced: boolean) {\n const record = readPending(key) ?? { synced: false, completed: {}, forget: [] };\n for (const [id, at] of Object.entries(sent.completed ?? {})) {\n if (record.completed[id] === at) delete record.completed[id];\n }\n const forgotten = new Set(sent.forget ?? []);\n record.forget = record.forget.filter((id) => !forgotten.has(id));\n record.synced = record.synced || synced;\n writePending(key, record);\n}\n\n/** The account's answer as the cache, with what still waits to be sent laid over it. */\nfunction refill(key: string, answer: { completed: TourProgressWire } | null | undefined) {\n const next: Record<string, string> = {};\n for (const [id, at] of Object.entries(fromRecord(answer?.completed) ?? {})) next[id] = at ?? \"\";\n const waiting = readPending(key);\n if (waiting) {\n for (const [id, at] of Object.entries(waiting.completed)) next[id] = later(next[id], at);\n for (const id of waiting.forget) delete next[id];\n }\n const record: Record<string, string | null> = {};\n for (const [id, at] of Object.entries(next)) record[id] = at === \"\" ? null : at;\n write(key, record);\n}\n\n/** The first load of an account key on this page takes over the old device-wide key\n * (§10.2.5). */\nfunction adoptOldRecord(key: string, account: TourProgressAccount) {\n const adopt = account.adopt;\n if (!adopt || adopt.storageKey === key) return;\n const old = adopt.storageKey;\n if (!adopt.discard) {\n const { value } = parse(rawOf(old), adopt.migrate ?? migrates.get(old));\n const entries = Object.entries(value);\n if (entries.length > 0) {\n const record = readPending(key) ?? { synced: false, completed: {}, forget: [] };\n for (const [id, at] of entries) record.completed[id] = later(record.completed[id], at ?? \"\");\n writePending(key, record);\n }\n }\n // Removed either way, at once: no second account on this device gets it.\n removeStored(old);\n memory.delete(old);\n cache.delete(old);\n emit(old);\n}\n\n/** A device record never synced is uploaded whole on its first load (§10.2.5). */\nfunction uploadUnsynced(key: string) {\n const record = readPending(key);\n if (record?.synced) return;\n const device = snapshot(key, migrates.get(key));\n const entries = Object.entries(device);\n const next = record ?? { synced: false, completed: {}, forget: [] };\n if (entries.length === 0 && record) return;\n for (const [id, at] of entries) {\n if (!next.forget.includes(id)) next.completed[id] = later(next.completed[id], at ?? \"\");\n }\n writePending(key, next);\n}\n\n/** The key's first sync on this page: take over the old record, upload a never-synced one. */\nfunction prepare(key: string) {\n loaded.add(key);\n adoptOldRecord(key, accounts.get(key)!);\n uploadUnsynced(key);\n}\n\n/** Queue a sync for the end of this task, so a handler's writes go as one PATCH. */\nfunction queueSync(key: string) {\n if (!loaded.has(key)) prepare(key);\n if (queued.has(key)) return;\n queued.add(key);\n queueMicrotask(() => {\n queued.delete(key);\n void sync(key);\n });\n}\n\n/** The first reader of an account key on this page loads it. */\nfunction ensureLoaded(key: string) {\n if (!accounts.has(key) || loaded.has(key)) return;\n prepare(key);\n void sync(key);\n}\n\n/**\n * Send what waits (one PATCH) or, with nothing waiting, load; the answer replaces the\n * cache. One at a time per key; a request asked for while one runs follows it.\n */\nasync function sync(key: string): Promise<void> {\n const account = accounts.get(key);\n if (!account || !loaded.has(key)) return;\n if (running.has(key)) {\n rerun.add(key);\n return;\n }\n if (typeof navigator !== \"undefined\" && navigator.onLine === false) return;\n running.add(key);\n const epoch = epochs.get(key) ?? 0;\n try {\n const waiting = readPending(key);\n if (waiting && hasWork(waiting)) {\n if (parked.has(key)) return;\n const body: TourProgressBody = {};\n if (Object.keys(waiting.completed).length > 0) body.completed = { ...waiting.completed };\n if (waiting.forget.length > 0) body.forget = [...waiting.forget];\n let answer: { completed: TourProgressWire };\n try {\n answer = await account.save(body);\n } catch (error) {\n const status = httpStatusOf(error);\n if (status === 403 || status === 422) {\n // Refused for good (a demo, a malformed or full record): dropped, not retried.\n if ((epochs.get(key) ?? 0) === epoch) clearSent(key, body, false);\n console.warn(`[ui-kit] tour progress: the account refused the pending record (${status}); dropped.`, error);\n } else if (status === 402) {\n // A lapsed plan refuses every write: kept, but not re-sent after each finish\n // and each `online` — the next session or page load tries again.\n parked.add(key);\n }\n // No answer (offline, 5xx, 401): it stays for the next load or `online`.\n return;\n }\n if ((epochs.get(key) ?? 0) !== epoch) return;\n clearSent(key, body, true);\n refill(key, answer);\n } else {\n const answer = await account.load();\n if ((epochs.get(key) ?? 0) !== epoch) return;\n if (waiting && !waiting.synced) writePending(key, { ...waiting, synced: true });\n else if (!waiting) writePending(key, { synced: true, completed: {}, forget: [] });\n refill(key, answer);\n }\n } catch {\n // A load that failed keeps the cache as it is.\n } finally {\n running.delete(key);\n if (rerun.delete(key)) void sync(key);\n }\n}\n\n/**\n * The end of a session (§10.2.6) — sign-out, a 401 nothing could renew, the account's\n * deletion, every path: removes the CACHE only (the device key and the page's snapshot;\n * every reader in this tab moves), synchronously and with no request, and KEEPS\n * `<storageKey>:pending`. That record sits under this person's own key, holds tour ids and\n * dates only, and goes out on their next sign-in. An answer still on its way is ignored.\n *\n * function logout() { …; signOutTourProgress(`app.tours:${user.id}`); }\n */\nexport function signOutTourProgress(storageKey: string): void {\n epochs.set(storageKey, (epochs.get(storageKey) ?? 0) + 1);\n loaded.delete(storageKey);\n rerun.delete(storageKey);\n parked.delete(storageKey);\n removeStored(storageKey);\n memory.delete(storageKey);\n cache.delete(storageKey);\n emit(storageKey);\n}\n\nfunction subscribe(key: string, listener: () => void): () => void {\n let set = listeners.get(key);\n if (!set) listeners.set(key, (set = new Set()));\n set.add(listener);\n // Another tab wrote (or cleared all storage: `key` null).\n const onStorage = (event: StorageEvent) => {\n if (event.key !== null && event.key !== key) return;\n memory.delete(key);\n listener();\n };\n if (typeof window !== \"undefined\") window.addEventListener(\"storage\", onStorage);\n return () => {\n set.delete(listener);\n if (typeof window !== \"undefined\") window.removeEventListener(\"storage\", onStorage);\n };\n}\n\n/**\n * Forget every tour completion under `storageKey` on this device: the stored key, what the\n * page kept in memory where storage refused it, and every reader in this tab moves at\n * once. For \"Reset this device's settings\" (settings §11):\n *\n * registerDeviceSetting({ key: TOUR_KEY, kind: \"view\", reset: () => resetTourProgress(TOUR_KEY) });\n *\n * With an account (0.45) it clears the cache only: the account is never written, the\n * pending record stays (\"anything waiting to be sent\", settings §11.2.2) and the next load\n * refills the cache. Tour progress is never registered with the device reset (§10.2.8).\n */\nexport function resetTourProgress(storageKey: string): void {\n if (accounts.has(storageKey)) loaded.delete(storageKey);\n removeStored(storageKey);\n memory.delete(storageKey);\n cache.delete(storageKey);\n emit(storageKey);\n}\n\n/**\n * Record a completion under `storageKey`, as {@link TourProgress.complete} does: through\n * the one shared store and snapshot (never a copy), so every reader of the key moves.\n * Returns `true` when it counts anew. `TourProvider` calls this on a tour's last step.\n * @internal Not part of the barrel.\n */\nexport function completeStored(\n storageKey: string,\n migrate: UseTourProgressOptions[\"migrate\"],\n tour: CompletedTour,\n): boolean {\n const subject = typeof tour === \"string\" ? { id: tour } : tour;\n // Read now rather than from a render: two completions in one handler both count.\n const current = readForWrite(storageKey, migrate);\n if (isTourDone(subject, current[subject.id])) return false;\n const at = new Date().toISOString();\n write(storageKey, { ...current, [subject.id]: at });\n if (accounts.has(storageKey)) {\n markPending(storageKey, subject.id, at);\n queueSync(storageKey);\n }\n return true;\n}\n\n/** \"Mark as not done\" (§10.2.8): off the cache, and `forget` to the account. @internal */\nfunction resetStored(storageKey: string, migrate: UseTourProgressOptions[\"migrate\"], id: string) {\n const current = snapshot(storageKey, migrate);\n if (current[id] === undefined) return;\n const next = { ...current };\n delete next[id];\n write(storageKey, next);\n if (accounts.has(storageKey)) {\n markPending(storageKey, id, undefined, true);\n queueSync(storageKey);\n }\n}\n\n/**\n * Write a completion from outside a page (§9.2): for an app's tests, seeds and scripts,\n * beside {@link resetTourProgress}. It writes the kit's stored shape (`{[id]: ISO | \"\"}`)\n * under `storageKey`, keeps the other tours' marks, and notifies every reader of the key\n * in this tab directly (the `storage` event reaches only OTHER tabs), so a mounted\n * `useTourProgress` or `TourCatalogue` moves at once.\n *\n * Unlike `complete`, it always writes (over a readable text; see below): `at` is the\n * completion's instant (an ISO string or a `Date`, default now), `null` a completion\n * without a date (stored as `\"\"`, read back as `null`).\n *\n * completeTour(TOUR_KEY, \"budget\", \"2026-09-01T10:00:00Z\");\n *\n * A stored text in an app's older shape is read through `opts.migrate`, or else the\n * migrate a reader or the provider registered for the key. If the text is neither empty\n * nor the kit's shape and no migrate reads it, this THROWS and writes nothing (B-1):\n *\n * completeTour(TOUR_KEY, \"budget\", undefined, { migrate: fromZustand });\n *\n * With an account on the key (0.45) it stays a device write — no request — and is marked\n * pending, so the next load sends it.\n */\nexport function completeTour(\n storageKey: string,\n tour: string | { id: string },\n at?: string | Date | null,\n opts?: { migrate?: UseTourProgressOptions[\"migrate\"] },\n): void {\n const id = typeof tour === \"string\" ? tour : tour.id;\n const when = at === null ? null : at instanceof Date ? at.toISOString() : (at ?? new Date().toISOString());\n write(storageKey, { ...readForWrite(storageKey, opts?.migrate, true), [id]: when });\n if (accounts.has(storageKey)) markPending(storageKey, id, when);\n}\n\n/** The device's tour completions under `storageKey`; see {@link UseTourProgressOptions}. */\nexport function useTourProgress({ storageKey, migrate, account }: UseTourProgressOptions): TourProgress {\n // Held, not depended on: an inline arrow is a new function every render, and neither the\n // snapshot nor the callbacks may change with it.\n const migrateRef = useRef(migrate);\n useEffect(() => {\n migrateRef.current = migrate;\n });\n // The first account for the key wins (as `migrate`); its first reader on the page loads.\n const accountRef = useRef(account);\n useEffect(() => {\n accountRef.current = account;\n });\n useEffect(() => {\n if (rememberAccount(storageKey, accountRef.current)) ensureLoaded(storageKey);\n }, [storageKey]);\n const completed = useSyncExternalStore(\n useCallback((listener: () => void) => subscribe(storageKey, listener), [storageKey]),\n () => snapshot(storageKey, migrateRef.current),\n () => EMPTY,\n );\n\n const complete = useCallback(\n (tour: CompletedTour) => completeStored(storageKey, migrateRef.current, tour),\n [storageKey],\n );\n\n const reset = useCallback((id: string) => resetStored(storageKey, migrateRef.current, id), [storageKey]);\n\n return useMemo(() => ({ completed, complete, reset }), [completed, complete, reset]);\n}\n"],"mappings":";AAAA,SAAS,aAAa,WAAW,SAAS,QAAQ,4BAA4B;AAC9E,SAAS,YAAY,cAAc,mBAAmB;AACtD,SAAS,oBAAoB;AAC7B,SAAS,kBAAwC;AAyIjD,MAAM,QAAyB,OAAO,OAAO,CAAC,CAAC;AAE/C,MAAM,YAAY,oBAAI,IAA6B;AAEnD,MAAM,SAAS,oBAAI,IAAoB;AAOvC,MAAM,QAAQ,oBAAI,IAA+E;AAGjG,MAAM,WAAW,oBAAI,IAAqB;AAQnC,SAAS,gBAAgB,KAAa,SAAiE;AAC5G,MAAI,WAAW,CAAC,SAAS,IAAI,GAAG,GAAG;AACjC,aAAS,IAAI,KAAK,OAAO;AACzB,QAAI,MAAM,OAAO,GAAG,EAAG,gBAAe,MAAM,KAAK,GA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