@omerdlw/base-framework 1.0.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 (383) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/dist/atoms/button.d.ts +11 -0
  4. package/dist/atoms/button.d.ts.map +1 -0
  5. package/dist/atoms/icon.d.ts +15 -0
  6. package/dist/atoms/icon.d.ts.map +1 -0
  7. package/dist/atoms/index.d.ts +6 -0
  8. package/dist/atoms/index.d.ts.map +1 -0
  9. package/dist/atoms/index.js +169 -0
  10. package/dist/atoms/index.js.map +1 -0
  11. package/dist/atoms/spinner.d.ts +9 -0
  12. package/dist/atoms/spinner.d.ts.map +1 -0
  13. package/dist/atoms/tooltip.d.ts +18 -0
  14. package/dist/atoms/tooltip.d.ts.map +1 -0
  15. package/dist/error/boundary.d.ts +14 -0
  16. package/dist/error/boundary.d.ts.map +1 -0
  17. package/dist/error/constants.d.ts +18 -0
  18. package/dist/error/constants.d.ts.map +1 -0
  19. package/dist/error/index.d.ts +9 -0
  20. package/dist/error/index.d.ts.map +1 -0
  21. package/dist/error/index.js +688 -0
  22. package/dist/error/index.js.map +1 -0
  23. package/dist/error/listener.d.ts +2 -0
  24. package/dist/error/listener.d.ts.map +1 -0
  25. package/dist/error/reporter.d.ts +32 -0
  26. package/dist/error/reporter.d.ts.map +1 -0
  27. package/dist/error/theme.d.ts +3 -0
  28. package/dist/error/theme.d.ts.map +1 -0
  29. package/dist/error/types.d.ts +91 -0
  30. package/dist/error/types.d.ts.map +1 -0
  31. package/dist/error/utils.d.ts +21 -0
  32. package/dist/error/utils.d.ts.map +1 -0
  33. package/dist/events.d.ts +51 -0
  34. package/dist/events.d.ts.map +1 -0
  35. package/dist/events.js +88 -0
  36. package/dist/events.js.map +1 -0
  37. package/dist/hooks/index.d.ts +17 -0
  38. package/dist/hooks/index.d.ts.map +1 -0
  39. package/dist/hooks/index.js +804 -0
  40. package/dist/hooks/index.js.map +1 -0
  41. package/dist/hooks/types.d.ts +58 -0
  42. package/dist/hooks/types.d.ts.map +1 -0
  43. package/dist/hooks/use-async-action.d.ts +3 -0
  44. package/dist/hooks/use-async-action.d.ts.map +1 -0
  45. package/dist/hooks/use-click-outside.d.ts +3 -0
  46. package/dist/hooks/use-click-outside.d.ts.map +1 -0
  47. package/dist/hooks/use-controllable-state.d.ts +3 -0
  48. package/dist/hooks/use-controllable-state.d.ts.map +1 -0
  49. package/dist/hooks/use-debounce.d.ts +2 -0
  50. package/dist/hooks/use-debounce.d.ts.map +1 -0
  51. package/dist/hooks/use-fullscreen-state.d.ts +4 -0
  52. package/dist/hooks/use-fullscreen-state.d.ts.map +1 -0
  53. package/dist/hooks/use-global-event.d.ts +7 -0
  54. package/dist/hooks/use-global-event.d.ts.map +1 -0
  55. package/dist/hooks/use-hotkey.d.ts +4 -0
  56. package/dist/hooks/use-hotkey.d.ts.map +1 -0
  57. package/dist/hooks/use-intersection-observer.d.ts +4 -0
  58. package/dist/hooks/use-intersection-observer.d.ts.map +1 -0
  59. package/dist/hooks/use-isomorphic-layout-effect.d.ts +3 -0
  60. package/dist/hooks/use-isomorphic-layout-effect.d.ts.map +1 -0
  61. package/dist/hooks/use-media-query.d.ts +2 -0
  62. package/dist/hooks/use-media-query.d.ts.map +1 -0
  63. package/dist/hooks/use-mounted.d.ts +2 -0
  64. package/dist/hooks/use-mounted.d.ts.map +1 -0
  65. package/dist/hooks/use-required-context.d.ts +3 -0
  66. package/dist/hooks/use-required-context.d.ts.map +1 -0
  67. package/dist/hooks/use-server-action.d.ts +4 -0
  68. package/dist/hooks/use-server-action.d.ts.map +1 -0
  69. package/dist/hooks/use-storage-state.d.ts +5 -0
  70. package/dist/hooks/use-storage-state.d.ts.map +1 -0
  71. package/dist/hooks/use-store.d.ts +3 -0
  72. package/dist/hooks/use-store.d.ts.map +1 -0
  73. package/dist/index.d.ts +12 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +20415 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/kernel/adapters.d.ts +5 -0
  78. package/dist/kernel/adapters.d.ts.map +1 -0
  79. package/dist/kernel/compose.d.ts +15 -0
  80. package/dist/kernel/compose.d.ts.map +1 -0
  81. package/dist/kernel/constants.d.ts +12 -0
  82. package/dist/kernel/constants.d.ts.map +1 -0
  83. package/dist/kernel/context-registry.d.ts +3 -0
  84. package/dist/kernel/context-registry.d.ts.map +1 -0
  85. package/dist/kernel/handlers.d.ts +3 -0
  86. package/dist/kernel/handlers.d.ts.map +1 -0
  87. package/dist/kernel/hooks.d.ts +7 -0
  88. package/dist/kernel/hooks.d.ts.map +1 -0
  89. package/dist/kernel/index.d.ts +14 -0
  90. package/dist/kernel/index.d.ts.map +1 -0
  91. package/dist/kernel/index.js +2109 -0
  92. package/dist/kernel/index.js.map +1 -0
  93. package/dist/kernel/installed.d.ts +21 -0
  94. package/dist/kernel/installed.d.ts.map +1 -0
  95. package/dist/kernel/module.d.ts +32 -0
  96. package/dist/kernel/module.d.ts.map +1 -0
  97. package/dist/kernel/operations.d.ts +21 -0
  98. package/dist/kernel/operations.d.ts.map +1 -0
  99. package/dist/kernel/page-controller.d.ts +8 -0
  100. package/dist/kernel/page-controller.d.ts.map +1 -0
  101. package/dist/kernel/provider.d.ts +18 -0
  102. package/dist/kernel/provider.d.ts.map +1 -0
  103. package/dist/kernel/runtime.d.ts +30 -0
  104. package/dist/kernel/runtime.d.ts.map +1 -0
  105. package/dist/kernel/schema.d.ts +13 -0
  106. package/dist/kernel/schema.d.ts.map +1 -0
  107. package/dist/kernel/store.d.ts +4 -0
  108. package/dist/kernel/store.d.ts.map +1 -0
  109. package/dist/kernel/types.d.ts +233 -0
  110. package/dist/kernel/types.d.ts.map +1 -0
  111. package/dist/kernel/utils.d.ts +20 -0
  112. package/dist/kernel/utils.d.ts.map +1 -0
  113. package/dist/modules/ambient/constants.d.ts +23 -0
  114. package/dist/modules/ambient/constants.d.ts.map +1 -0
  115. package/dist/modules/ambient/context.d.ts +10 -0
  116. package/dist/modules/ambient/context.d.ts.map +1 -0
  117. package/dist/modules/ambient/index.d.ts +6 -0
  118. package/dist/modules/ambient/index.d.ts.map +1 -0
  119. package/dist/modules/ambient/index.js +896 -0
  120. package/dist/modules/ambient/index.js.map +1 -0
  121. package/dist/modules/ambient/module.d.ts +12 -0
  122. package/dist/modules/ambient/module.d.ts.map +1 -0
  123. package/dist/modules/ambient/types.d.ts +84 -0
  124. package/dist/modules/ambient/types.d.ts.map +1 -0
  125. package/dist/modules/ambient/utils.d.ts +18 -0
  126. package/dist/modules/ambient/utils.d.ts.map +1 -0
  127. package/dist/modules/background/constants.d.ts +12 -0
  128. package/dist/modules/background/constants.d.ts.map +1 -0
  129. package/dist/modules/background/context.d.ts +13 -0
  130. package/dist/modules/background/context.d.ts.map +1 -0
  131. package/dist/modules/background/hooks.d.ts +119 -0
  132. package/dist/modules/background/hooks.d.ts.map +1 -0
  133. package/dist/modules/background/index.d.ts +7 -0
  134. package/dist/modules/background/index.d.ts.map +1 -0
  135. package/dist/modules/background/index.js +3195 -0
  136. package/dist/modules/background/index.js.map +1 -0
  137. package/dist/modules/background/module.d.ts +14 -0
  138. package/dist/modules/background/module.d.ts.map +1 -0
  139. package/dist/modules/background/motion.d.ts +13 -0
  140. package/dist/modules/background/motion.d.ts.map +1 -0
  141. package/dist/modules/background/overlay.d.ts +49 -0
  142. package/dist/modules/background/overlay.d.ts.map +1 -0
  143. package/dist/modules/background/types.d.ts +153 -0
  144. package/dist/modules/background/types.d.ts.map +1 -0
  145. package/dist/modules/background/utils.d.ts +56 -0
  146. package/dist/modules/background/utils.d.ts.map +1 -0
  147. package/dist/modules/background/youtube/iframe.d.ts +52 -0
  148. package/dist/modules/background/youtube/iframe.d.ts.map +1 -0
  149. package/dist/modules/background/youtube/parse.d.ts +17 -0
  150. package/dist/modules/background/youtube/parse.d.ts.map +1 -0
  151. package/dist/modules/context-menu/constants.d.ts +8 -0
  152. package/dist/modules/context-menu/constants.d.ts.map +1 -0
  153. package/dist/modules/context-menu/context.d.ts +16 -0
  154. package/dist/modules/context-menu/context.d.ts.map +1 -0
  155. package/dist/modules/context-menu/hooks.d.ts +31 -0
  156. package/dist/modules/context-menu/hooks.d.ts.map +1 -0
  157. package/dist/modules/context-menu/index.d.ts +6 -0
  158. package/dist/modules/context-menu/index.d.ts.map +1 -0
  159. package/dist/modules/context-menu/index.js +2008 -0
  160. package/dist/modules/context-menu/index.js.map +1 -0
  161. package/dist/modules/context-menu/module.d.ts +12 -0
  162. package/dist/modules/context-menu/module.d.ts.map +1 -0
  163. package/dist/modules/context-menu/motion.d.ts +9 -0
  164. package/dist/modules/context-menu/motion.d.ts.map +1 -0
  165. package/dist/modules/context-menu/overlay.d.ts +15 -0
  166. package/dist/modules/context-menu/overlay.d.ts.map +1 -0
  167. package/dist/modules/context-menu/resolver.d.ts +7 -0
  168. package/dist/modules/context-menu/resolver.d.ts.map +1 -0
  169. package/dist/modules/context-menu/state.d.ts +4 -0
  170. package/dist/modules/context-menu/state.d.ts.map +1 -0
  171. package/dist/modules/context-menu/types.d.ts +171 -0
  172. package/dist/modules/context-menu/types.d.ts.map +1 -0
  173. package/dist/modules/context-menu/utils.d.ts +16 -0
  174. package/dist/modules/context-menu/utils.d.ts.map +1 -0
  175. package/dist/modules/controls/constants.d.ts +7 -0
  176. package/dist/modules/controls/constants.d.ts.map +1 -0
  177. package/dist/modules/controls/hooks.d.ts +15 -0
  178. package/dist/modules/controls/hooks.d.ts.map +1 -0
  179. package/dist/modules/controls/index.d.ts +6 -0
  180. package/dist/modules/controls/index.d.ts.map +1 -0
  181. package/dist/modules/controls/index.js +1242 -0
  182. package/dist/modules/controls/index.js.map +1 -0
  183. package/dist/modules/controls/module.d.ts +12 -0
  184. package/dist/modules/controls/module.d.ts.map +1 -0
  185. package/dist/modules/controls/overlay.d.ts +2 -0
  186. package/dist/modules/controls/overlay.d.ts.map +1 -0
  187. package/dist/modules/controls/types.d.ts +86 -0
  188. package/dist/modules/controls/types.d.ts.map +1 -0
  189. package/dist/modules/controls/utils.d.ts +9 -0
  190. package/dist/modules/controls/utils.d.ts.map +1 -0
  191. package/dist/modules/dock/cards.d.ts +1035 -0
  192. package/dist/modules/dock/cards.d.ts.map +1 -0
  193. package/dist/modules/dock/constants.d.ts +157 -0
  194. package/dist/modules/dock/constants.d.ts.map +1 -0
  195. package/dist/modules/dock/context.d.ts +26 -0
  196. package/dist/modules/dock/context.d.ts.map +1 -0
  197. package/dist/modules/dock/hooks.d.ts +957 -0
  198. package/dist/modules/dock/hooks.d.ts.map +1 -0
  199. package/dist/modules/dock/hud.d.ts +43 -0
  200. package/dist/modules/dock/hud.d.ts.map +1 -0
  201. package/dist/modules/dock/index.d.ts +27 -0
  202. package/dist/modules/dock/index.d.ts.map +1 -0
  203. package/dist/modules/dock/index.js +12111 -0
  204. package/dist/modules/dock/index.js.map +1 -0
  205. package/dist/modules/dock/module.d.ts +71 -0
  206. package/dist/modules/dock/module.d.ts.map +1 -0
  207. package/dist/modules/dock/motion.d.ts +986 -0
  208. package/dist/modules/dock/motion.d.ts.map +1 -0
  209. package/dist/modules/dock/overlay.d.ts +79 -0
  210. package/dist/modules/dock/overlay.d.ts.map +1 -0
  211. package/dist/modules/dock/provider.d.ts +3 -0
  212. package/dist/modules/dock/provider.d.ts.map +1 -0
  213. package/dist/modules/dock/routing/breadcrumbs.d.ts +43 -0
  214. package/dist/modules/dock/routing/breadcrumbs.d.ts.map +1 -0
  215. package/dist/modules/dock/routing/continuity.d.ts +19 -0
  216. package/dist/modules/dock/routing/continuity.d.ts.map +1 -0
  217. package/dist/modules/dock/routing/guards.d.ts +21 -0
  218. package/dist/modules/dock/routing/guards.d.ts.map +1 -0
  219. package/dist/modules/dock/routing/navigation.d.ts +37 -0
  220. package/dist/modules/dock/routing/navigation.d.ts.map +1 -0
  221. package/dist/modules/dock/routing/transactions.d.ts +21 -0
  222. package/dist/modules/dock/routing/transactions.d.ts.map +1 -0
  223. package/dist/modules/dock/runtime/commands.d.ts +18 -0
  224. package/dist/modules/dock/runtime/commands.d.ts.map +1 -0
  225. package/dist/modules/dock/runtime/display.d.ts +36 -0
  226. package/dist/modules/dock/runtime/display.d.ts.map +1 -0
  227. package/dist/modules/dock/runtime/dock.d.ts +123 -0
  228. package/dist/modules/dock/runtime/dock.d.ts.map +1 -0
  229. package/dist/modules/dock/state.d.ts +22 -0
  230. package/dist/modules/dock/state.d.ts.map +1 -0
  231. package/dist/modules/dock/status/events.d.ts +37 -0
  232. package/dist/modules/dock/status/events.d.ts.map +1 -0
  233. package/dist/modules/dock/status/hooks.d.ts +6 -0
  234. package/dist/modules/dock/status/hooks.d.ts.map +1 -0
  235. package/dist/modules/dock/status/model.d.ts +65 -0
  236. package/dist/modules/dock/status/model.d.ts.map +1 -0
  237. package/dist/modules/dock/surface/context.d.ts +43 -0
  238. package/dist/modules/dock/surface/context.d.ts.map +1 -0
  239. package/dist/modules/dock/surface/definition.d.ts +38 -0
  240. package/dist/modules/dock/surface/definition.d.ts.map +1 -0
  241. package/dist/modules/dock/surface/hooks.d.ts +123 -0
  242. package/dist/modules/dock/surface/hooks.d.ts.map +1 -0
  243. package/dist/modules/dock/surface/machine.d.ts +75 -0
  244. package/dist/modules/dock/surface/machine.d.ts.map +1 -0
  245. package/dist/modules/dock/surface/stack.d.ts +38 -0
  246. package/dist/modules/dock/surface/stack.d.ts.map +1 -0
  247. package/dist/modules/dock/surface/view-model.d.ts +3 -0
  248. package/dist/modules/dock/surface/view-model.d.ts.map +1 -0
  249. package/dist/modules/dock/types.d.ts +1158 -0
  250. package/dist/modules/dock/types.d.ts.map +1 -0
  251. package/dist/modules/dock/utils.d.ts +93 -0
  252. package/dist/modules/dock/utils.d.ts.map +1 -0
  253. package/dist/modules/index.d.ts +12 -0
  254. package/dist/modules/index.d.ts.map +1 -0
  255. package/dist/modules/index.js +18020 -0
  256. package/dist/modules/index.js.map +1 -0
  257. package/dist/modules/loading/constants.d.ts +5 -0
  258. package/dist/modules/loading/constants.d.ts.map +1 -0
  259. package/dist/modules/loading/context.d.ts +13 -0
  260. package/dist/modules/loading/context.d.ts.map +1 -0
  261. package/dist/modules/loading/hooks.d.ts +6 -0
  262. package/dist/modules/loading/hooks.d.ts.map +1 -0
  263. package/dist/modules/loading/index.d.ts +7 -0
  264. package/dist/modules/loading/index.d.ts.map +1 -0
  265. package/dist/modules/loading/index.js +1256 -0
  266. package/dist/modules/loading/index.js.map +1 -0
  267. package/dist/modules/loading/module.d.ts +14 -0
  268. package/dist/modules/loading/module.d.ts.map +1 -0
  269. package/dist/modules/loading/overlay.d.ts +2 -0
  270. package/dist/modules/loading/overlay.d.ts.map +1 -0
  271. package/dist/modules/loading/types.d.ts +47 -0
  272. package/dist/modules/loading/types.d.ts.map +1 -0
  273. package/dist/modules/loading/utils.d.ts +4 -0
  274. package/dist/modules/loading/utils.d.ts.map +1 -0
  275. package/dist/modules/media/constants.d.ts +7 -0
  276. package/dist/modules/media/constants.d.ts.map +1 -0
  277. package/dist/modules/media/context.d.ts +6 -0
  278. package/dist/modules/media/context.d.ts.map +1 -0
  279. package/dist/modules/media/hooks.d.ts +3 -0
  280. package/dist/modules/media/hooks.d.ts.map +1 -0
  281. package/dist/modules/media/index.d.ts +8 -0
  282. package/dist/modules/media/index.d.ts.map +1 -0
  283. package/dist/modules/media/index.js +728 -0
  284. package/dist/modules/media/index.js.map +1 -0
  285. package/dist/modules/media/module.d.ts +11 -0
  286. package/dist/modules/media/module.d.ts.map +1 -0
  287. package/dist/modules/media/overlay.d.ts +9 -0
  288. package/dist/modules/media/overlay.d.ts.map +1 -0
  289. package/dist/modules/media/types.d.ts +77 -0
  290. package/dist/modules/media/types.d.ts.map +1 -0
  291. package/dist/modules/media/utils.d.ts +17 -0
  292. package/dist/modules/media/utils.d.ts.map +1 -0
  293. package/dist/modules/modal/constants.d.ts +20 -0
  294. package/dist/modules/modal/constants.d.ts.map +1 -0
  295. package/dist/modules/modal/context.d.ts +20 -0
  296. package/dist/modules/modal/context.d.ts.map +1 -0
  297. package/dist/modules/modal/hooks.d.ts +41 -0
  298. package/dist/modules/modal/hooks.d.ts.map +1 -0
  299. package/dist/modules/modal/index.d.ts +7 -0
  300. package/dist/modules/modal/index.d.ts.map +1 -0
  301. package/dist/modules/modal/index.js +2672 -0
  302. package/dist/modules/modal/index.js.map +1 -0
  303. package/dist/modules/modal/module.d.ts +12 -0
  304. package/dist/modules/modal/module.d.ts.map +1 -0
  305. package/dist/modules/modal/motion.d.ts +16 -0
  306. package/dist/modules/modal/motion.d.ts.map +1 -0
  307. package/dist/modules/modal/overlay.d.ts +4 -0
  308. package/dist/modules/modal/overlay.d.ts.map +1 -0
  309. package/dist/modules/modal/state.d.ts +4 -0
  310. package/dist/modules/modal/state.d.ts.map +1 -0
  311. package/dist/modules/modal/types.d.ts +109 -0
  312. package/dist/modules/modal/types.d.ts.map +1 -0
  313. package/dist/modules/modal/utils.d.ts +31 -0
  314. package/dist/modules/modal/utils.d.ts.map +1 -0
  315. package/dist/modules/notification/constants.d.ts +9 -0
  316. package/dist/modules/notification/constants.d.ts.map +1 -0
  317. package/dist/modules/notification/context.d.ts +7 -0
  318. package/dist/modules/notification/context.d.ts.map +1 -0
  319. package/dist/modules/notification/hooks.d.ts +10 -0
  320. package/dist/modules/notification/hooks.d.ts.map +1 -0
  321. package/dist/modules/notification/index.d.ts +7 -0
  322. package/dist/modules/notification/index.d.ts.map +1 -0
  323. package/dist/modules/notification/index.js +905 -0
  324. package/dist/modules/notification/index.js.map +1 -0
  325. package/dist/modules/notification/module.d.ts +11 -0
  326. package/dist/modules/notification/module.d.ts.map +1 -0
  327. package/dist/modules/notification/motion.d.ts +15 -0
  328. package/dist/modules/notification/motion.d.ts.map +1 -0
  329. package/dist/modules/notification/overlay.d.ts +3 -0
  330. package/dist/modules/notification/overlay.d.ts.map +1 -0
  331. package/dist/modules/notification/types.d.ts +57 -0
  332. package/dist/modules/notification/types.d.ts.map +1 -0
  333. package/dist/modules/notification/utils.d.ts +9 -0
  334. package/dist/modules/notification/utils.d.ts.map +1 -0
  335. package/dist/modules/theme.d.ts +3 -0
  336. package/dist/modules/theme.d.ts.map +1 -0
  337. package/dist/provider.d.ts +23 -0
  338. package/dist/provider.d.ts.map +1 -0
  339. package/dist/provider.js +1973 -0
  340. package/dist/provider.js.map +1 -0
  341. package/dist/result.d.ts +50 -0
  342. package/dist/result.d.ts.map +1 -0
  343. package/dist/result.js +163 -0
  344. package/dist/result.js.map +1 -0
  345. package/dist/theme.d.ts +25 -0
  346. package/dist/theme.d.ts.map +1 -0
  347. package/dist/theme.js +44 -0
  348. package/dist/theme.js.map +1 -0
  349. package/dist/tokens/index.d.ts +3 -0
  350. package/dist/tokens/index.d.ts.map +1 -0
  351. package/dist/tokens/index.js +325 -0
  352. package/dist/tokens/index.js.map +1 -0
  353. package/dist/tokens/motion.d.ts +315 -0
  354. package/dist/tokens/motion.d.ts.map +1 -0
  355. package/dist/tokens/tokens.d.ts +34 -0
  356. package/dist/tokens/tokens.d.ts.map +1 -0
  357. package/dist/utils/cn.d.ts +3 -0
  358. package/dist/utils/cn.d.ts.map +1 -0
  359. package/dist/utils/dom.d.ts +5 -0
  360. package/dist/utils/dom.d.ts.map +1 -0
  361. package/dist/utils/index.d.ts +16 -0
  362. package/dist/utils/index.d.ts.map +1 -0
  363. package/dist/utils/index.js +485 -0
  364. package/dist/utils/index.js.map +1 -0
  365. package/dist/utils/json.d.ts +3 -0
  366. package/dist/utils/json.d.ts.map +1 -0
  367. package/dist/utils/number.d.ts +4 -0
  368. package/dist/utils/number.d.ts.map +1 -0
  369. package/dist/utils/object.d.ts +7 -0
  370. package/dist/utils/object.d.ts.map +1 -0
  371. package/dist/utils/report.d.ts +5 -0
  372. package/dist/utils/report.d.ts.map +1 -0
  373. package/dist/utils/scheduler.d.ts +34 -0
  374. package/dist/utils/scheduler.d.ts.map +1 -0
  375. package/dist/utils/store.d.ts +11 -0
  376. package/dist/utils/store.d.ts.map +1 -0
  377. package/dist/utils/string.d.ts +8 -0
  378. package/dist/utils/string.d.ts.map +1 -0
  379. package/dist/utils/timing.d.ts +8 -0
  380. package/dist/utils/timing.d.ts.map +1 -0
  381. package/dist/utils/user-message.d.ts +20 -0
  382. package/dist/utils/user-message.d.ts.map +1 -0
  383. package/package.json +113 -0
@@ -0,0 +1,2672 @@
1
+ "use client";
2
+ import { Icon as Icon$1 } from '@iconify-icon/react';
3
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
+ import '@radix-ui/react-tooltip';
5
+ import { useState, useRef, useCallback, useMemo, use, useSyncExternalStore, createContext, useLayoutEffect, useEffect, createElement, useInsertionEffect, useId, useContext, isValidElement, cloneElement, Children } from 'react';
6
+ import { clsx } from 'clsx';
7
+ import { twMerge } from 'tailwind-merge';
8
+ import { usePathname } from 'next/navigation';
9
+ import { motion, AnimatePresence } from 'motion/react';
10
+ import { createPortal } from 'react-dom';
11
+ import dynamic from 'next/dynamic';
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __esm = (fn, res) => function __init() {
16
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
17
+ };
18
+ var __export = (target, all) => {
19
+ for (var name in all)
20
+ __defProp(target, name, { get: all[name], enumerable: true });
21
+ };
22
+ function Icon({
23
+ className = "center",
24
+ color,
25
+ icon,
26
+ onClick,
27
+ size = 20,
28
+ style,
29
+ ...props
30
+ }) {
31
+ return /* @__PURE__ */ jsx(
32
+ Icon$1,
33
+ {
34
+ className,
35
+ height: size,
36
+ icon,
37
+ onClick,
38
+ style: { color, ...style },
39
+ width: size,
40
+ ...props
41
+ }
42
+ );
43
+ }
44
+ var init_icon = __esm({
45
+ "src/atoms/icon.tsx"() {
46
+ "use client";
47
+ Icon.displayName = "Icon";
48
+ }
49
+ });
50
+ var init_spinner = __esm({
51
+ "src/atoms/spinner.tsx"() {
52
+ "use client";
53
+ init_icon();
54
+ }
55
+ });
56
+ var init_tooltip = __esm({
57
+ "src/atoms/tooltip.tsx"() {
58
+ "use client";
59
+ }
60
+ });
61
+ function Button({
62
+ ref,
63
+ children,
64
+ className,
65
+ disabled = false,
66
+ loading = false,
67
+ type = "button",
68
+ ...props
69
+ }) {
70
+ return /* @__PURE__ */ jsx(
71
+ "button",
72
+ {
73
+ ref,
74
+ type,
75
+ disabled: disabled || loading,
76
+ "aria-busy": loading ? true : void 0,
77
+ className,
78
+ ...props,
79
+ children
80
+ }
81
+ );
82
+ }
83
+ var init_button = __esm({
84
+ "src/atoms/button.tsx"() {
85
+ "use client";
86
+ Button.displayName = "Button";
87
+ }
88
+ });
89
+ var init_use_fullscreen_state = __esm({
90
+ "src/hooks/use-fullscreen-state.ts"() {
91
+ "use client";
92
+ }
93
+ });
94
+
95
+ // src/atoms/index.ts
96
+ var init_atoms = __esm({
97
+ "src/atoms/index.ts"() {
98
+ "use client";
99
+ init_icon();
100
+ init_spinner();
101
+ init_tooltip();
102
+ init_button();
103
+ init_use_fullscreen_state();
104
+ }
105
+ });
106
+
107
+ // src/tokens/tokens.ts
108
+ var Z_INDEX;
109
+ var init_tokens = __esm({
110
+ "src/tokens/tokens.ts"() {
111
+ Z_INDEX = Object.freeze({
112
+ BACKGROUND: 0,
113
+ DOCK_BACKDROP: 100,
114
+ DOCK: 110,
115
+ NOTIFICATION: 120,
116
+ MODAL_BACKDROP: 130,
117
+ MODAL: 140,
118
+ SELECT: 150,
119
+ LOADING: 160,
120
+ ERROR_OVERLAY: 170,
121
+ CONTEXT_MENU_BACKDROP: 180,
122
+ CONTEXT_MENU: 190,
123
+ TOOLTIP: 200,
124
+ UI_ELEMENT: 10,
125
+ DOCK_CARD_BACKGROUND: 0,
126
+ DOCK_CARD_CONTENT: 10,
127
+ DOCK_CARD_STACK_BASE: 10,
128
+ DOCK_CARD_BADGE: 20,
129
+ DOCK_CARD_MEDIA: 30,
130
+ DOCK_BREADCRUMBS: 10,
131
+ DOCK_SURFACE_CONTROL: 10,
132
+ DOCK_SURFACE_POPOVER: 30,
133
+ DOCK_SURFACE_CENTER: 0,
134
+ MODAL_FRAME: 1,
135
+ MODAL_STICKY_HEADER: 10
136
+ });
137
+ }
138
+ });
139
+
140
+ // src/tokens/motion.ts
141
+ var DURATION_TOKENS, EASING_CURVES, MOTION_EASINGS, MOTION_TIERS;
142
+ var init_motion = __esm({
143
+ "src/tokens/motion.ts"() {
144
+ DURATION_TOKENS = Object.freeze({
145
+ INSTANT: 0.08,
146
+ MICRO: 0.18,
147
+ FAST: 0.28,
148
+ BASE: 0.36,
149
+ MODERATE: 0.44,
150
+ SLOW: 0.58,
151
+ CINEMATIC: 0.86
152
+ });
153
+ EASING_CURVES = Object.freeze({
154
+ OUT_EXPO: [0.16, 1, 0.3, 1],
155
+ OUT_QUART: [0.25, 1, 0.5, 1],
156
+ OUT_QUINT: [0.22, 1, 0.36, 1],
157
+ IN_OUT_CUBIC: [0.65, 0, 0.35, 1],
158
+ IN_CUBIC: [0.5, 0, 1, 1],
159
+ OUT_BACK: [0.34, 1.56, 0.64, 1]
160
+ });
161
+ MOTION_EASINGS = Object.freeze({
162
+ ENTER: EASING_CURVES.OUT_QUART,
163
+ ENTER_EMPHASIZED: EASING_CURVES.OUT_EXPO,
164
+ EXIT: EASING_CURVES.IN_CUBIC
165
+ });
166
+ MOTION_TIERS = Object.freeze({
167
+ MICRO: Object.freeze({
168
+ distance: 4,
169
+ duration: DURATION_TOKENS.MICRO,
170
+ ease: MOTION_EASINGS.ENTER_EMPHASIZED,
171
+ scaleDelta: 8e-3
172
+ }),
173
+ FAST: Object.freeze({
174
+ distance: 9,
175
+ duration: DURATION_TOKENS.FAST,
176
+ ease: MOTION_EASINGS.ENTER_EMPHASIZED,
177
+ scaleDelta: 0.012
178
+ }),
179
+ STANDARD: Object.freeze({
180
+ distance: 18,
181
+ duration: DURATION_TOKENS.MODERATE,
182
+ ease: MOTION_EASINGS.ENTER,
183
+ scaleDelta: 0.018
184
+ }),
185
+ SURFACE: Object.freeze({
186
+ distance: 28,
187
+ duration: DURATION_TOKENS.SLOW,
188
+ ease: MOTION_EASINGS.ENTER_EMPHASIZED,
189
+ scaleDelta: 0.024
190
+ })
191
+ });
192
+ Object.freeze({
193
+ duration: DURATION_TOKENS.INSTANT,
194
+ ease: "linear"
195
+ });
196
+ }
197
+ });
198
+
199
+ // src/tokens/index.ts
200
+ var init_tokens2 = __esm({
201
+ "src/tokens/index.ts"() {
202
+ init_tokens();
203
+ init_motion();
204
+ }
205
+ });
206
+ function cn(...inputs) {
207
+ return twMerge(clsx(inputs));
208
+ }
209
+ var init_cn = __esm({
210
+ "src/utils/cn.ts"() {
211
+ }
212
+ });
213
+
214
+ // src/utils/string.ts
215
+ function trimToNull(value) {
216
+ if (value === null || value === void 0) return null;
217
+ const trimmed = String(value).trim();
218
+ return trimmed.length > 0 ? trimmed : null;
219
+ }
220
+ var init_string = __esm({
221
+ "src/utils/string.ts"() {
222
+ }
223
+ });
224
+
225
+ // src/utils/dom.ts
226
+ function acquireGlobalScrollLock() {
227
+ if (typeof document === "undefined") return () => {
228
+ };
229
+ if (globalScrollLockCount === 0) {
230
+ globalScrollLockStyles = {
231
+ bodyOverflow: document.body.style.overflow,
232
+ bodyOverscrollBehavior: document.body.style.overscrollBehavior,
233
+ htmlOverflow: document.documentElement.style.overflow,
234
+ htmlOverscrollBehavior: document.documentElement.style.overscrollBehavior
235
+ };
236
+ }
237
+ globalScrollLockCount += 1;
238
+ document.body.style.overflow = "hidden";
239
+ document.body.style.overscrollBehavior = "none";
240
+ document.documentElement.style.overflow = "hidden";
241
+ document.documentElement.style.overscrollBehavior = "none";
242
+ let released = false;
243
+ return () => {
244
+ if (released) return;
245
+ released = true;
246
+ globalScrollLockCount = Math.max(0, globalScrollLockCount - 1);
247
+ if (globalScrollLockCount > 0 || !globalScrollLockStyles) return;
248
+ document.body.style.overflow = globalScrollLockStyles.bodyOverflow;
249
+ document.body.style.overscrollBehavior = globalScrollLockStyles.bodyOverscrollBehavior;
250
+ document.documentElement.style.overflow = globalScrollLockStyles.htmlOverflow;
251
+ document.documentElement.style.overscrollBehavior = globalScrollLockStyles.htmlOverscrollBehavior;
252
+ globalScrollLockStyles = null;
253
+ };
254
+ }
255
+ var isBrowser, globalScrollLockCount, globalScrollLockStyles;
256
+ var init_dom = __esm({
257
+ "src/utils/dom.ts"() {
258
+ init_string();
259
+ isBrowser = typeof window !== "undefined";
260
+ globalScrollLockCount = 0;
261
+ globalScrollLockStyles = null;
262
+ }
263
+ });
264
+
265
+ // src/utils/number.ts
266
+ var init_number = __esm({
267
+ "src/utils/number.ts"() {
268
+ }
269
+ });
270
+
271
+ // src/utils/object.ts
272
+ function isObject(value) {
273
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
274
+ }
275
+ function isPlainObject(value) {
276
+ if (!isObject(value)) return false;
277
+ const proto = Object.getPrototypeOf(value);
278
+ return proto === Object.prototype || proto === null;
279
+ }
280
+ var init_object = __esm({
281
+ "src/utils/object.ts"() {
282
+ }
283
+ });
284
+
285
+ // src/utils/timing.ts
286
+ var init_timing = __esm({
287
+ "src/utils/timing.ts"() {
288
+ }
289
+ });
290
+
291
+ // src/utils/json.ts
292
+ var init_json = __esm({
293
+ "src/utils/json.ts"() {
294
+ }
295
+ });
296
+
297
+ // src/utils/report.ts
298
+ function report(scope, error, level = "error") {
299
+ if (sink) {
300
+ try {
301
+ sink(scope, error, level);
302
+ return;
303
+ } catch {
304
+ }
305
+ }
306
+ if (process.env.NODE_ENV === "production" && typeof window !== "undefined") {
307
+ return;
308
+ }
309
+ console[level](`[${scope}]`, error);
310
+ }
311
+ var sink;
312
+ var init_report = __esm({
313
+ "src/utils/report.ts"() {
314
+ sink = null;
315
+ }
316
+ });
317
+ var init_user_message = __esm({
318
+ "src/utils/user-message.ts"() {
319
+ }
320
+ });
321
+
322
+ // src/utils/store.ts
323
+ function freezeStoreSnapshot(state) {
324
+ if (process.env.NODE_ENV === "production" || !state || typeof state !== "object") {
325
+ return state;
326
+ }
327
+ const seen = /* @__PURE__ */ new WeakSet();
328
+ const freeze = (value) => {
329
+ if (seen.has(value) || Object.isFrozen(value)) return;
330
+ seen.add(value);
331
+ const prototype = Object.getPrototypeOf(value);
332
+ if (Array.isArray(value) || prototype === Object.prototype || prototype === null) {
333
+ for (const key of Reflect.ownKeys(value)) {
334
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
335
+ if (descriptor && "value" in descriptor && descriptor.value !== null) {
336
+ if (typeof descriptor.value === "object") freeze(descriptor.value);
337
+ }
338
+ }
339
+ }
340
+ Object.freeze(value);
341
+ };
342
+ freeze(state);
343
+ return state;
344
+ }
345
+ function createStore(initialState, { freezeSnapshots = true } = {}) {
346
+ const listeners = /* @__PURE__ */ new Set();
347
+ const prepare = freezeSnapshots ? freezeStoreSnapshot : (state) => state;
348
+ let snapshot = prepare(initialState);
349
+ const publish = (nextStateOrUpdater) => {
350
+ const nextState = typeof nextStateOrUpdater === "function" ? nextStateOrUpdater(snapshot) : nextStateOrUpdater;
351
+ if (Object.is(snapshot, nextState)) return false;
352
+ snapshot = prepare(nextState);
353
+ for (const listener of listeners) {
354
+ try {
355
+ listener();
356
+ } catch (error) {
357
+ report("CoreStore subscriber", error, "warn");
358
+ }
359
+ }
360
+ return true;
361
+ };
362
+ const setState = (updater) => {
363
+ if (typeof updater === "function") {
364
+ return publish(updater);
365
+ }
366
+ if (snapshot && typeof snapshot === "object" && updater && typeof updater === "object") {
367
+ return publish({ ...snapshot, ...updater });
368
+ }
369
+ return publish(updater);
370
+ };
371
+ return Object.freeze({
372
+ getSnapshot() {
373
+ return snapshot;
374
+ },
375
+ publish,
376
+ setState,
377
+ subscribe(listener) {
378
+ if (typeof listener !== "function") return () => {
379
+ };
380
+ listeners.add(listener);
381
+ return () => listeners.delete(listener);
382
+ }
383
+ });
384
+ }
385
+ var init_store = __esm({
386
+ "src/utils/store.ts"() {
387
+ init_report();
388
+ }
389
+ });
390
+ var init_scheduler = __esm({
391
+ "src/utils/scheduler.ts"() {
392
+ init_report();
393
+ }
394
+ });
395
+
396
+ // src/utils/index.ts
397
+ var init_utils = __esm({
398
+ "src/utils/index.ts"() {
399
+ init_cn();
400
+ init_dom();
401
+ init_string();
402
+ init_number();
403
+ init_object();
404
+ init_timing();
405
+ init_json();
406
+ init_report();
407
+ init_user_message();
408
+ init_store();
409
+ init_scheduler();
410
+ }
411
+ });
412
+
413
+ // src/kernel/types.ts
414
+ var init_types = __esm({
415
+ "src/kernel/types.ts"() {
416
+ }
417
+ });
418
+
419
+ // src/kernel/constants.ts
420
+ var DEFAULT_SOURCE, REGISTRY_SOURCES, REGISTRY_LIFECYCLES, REGISTRY_VALIDATION_MODES, REGISTRY_METADATA_KEYS, REGISTRY_LIFECYCLE_VALUES, REGISTRY_METADATA_KEY_SET, REGISTRY_SCOPE_KINDS;
421
+ var init_constants = __esm({
422
+ "src/kernel/constants.ts"() {
423
+ DEFAULT_SOURCE = "dynamic";
424
+ REGISTRY_SOURCES = Object.freeze({
425
+ STATIC: "static",
426
+ DYNAMIC: "dynamic",
427
+ USER: "user"
428
+ });
429
+ REGISTRY_LIFECYCLES = Object.freeze({
430
+ IMMEDIATE: "immediate",
431
+ GRACEFUL: "graceful",
432
+ PERSISTENT: "persistent",
433
+ ROUTE: "route"
434
+ });
435
+ REGISTRY_VALIDATION_MODES = Object.freeze({
436
+ WARN: "warn",
437
+ STRICT: "strict"
438
+ });
439
+ REGISTRY_METADATA_KEYS = Object.freeze([
440
+ "cleanup",
441
+ "cleanupDelayMs",
442
+ "instanceId",
443
+ "lifecycle",
444
+ "priority",
445
+ "source",
446
+ "scope",
447
+ "validation"
448
+ ]);
449
+ Object.freeze({
450
+ [REGISTRY_SOURCES.STATIC]: 100,
451
+ [REGISTRY_SOURCES.DYNAMIC]: 200,
452
+ [REGISTRY_SOURCES.USER]: 300
453
+ });
454
+ Object.freeze({
455
+ [REGISTRY_SOURCES.STATIC]: 10,
456
+ [REGISTRY_SOURCES.DYNAMIC]: 20,
457
+ [REGISTRY_SOURCES.USER]: 30
458
+ });
459
+ REGISTRY_LIFECYCLE_VALUES = new Set(
460
+ Object.values(REGISTRY_LIFECYCLES)
461
+ );
462
+ REGISTRY_METADATA_KEY_SET = new Set(
463
+ REGISTRY_METADATA_KEYS
464
+ );
465
+ REGISTRY_SCOPE_KINDS = Object.freeze({
466
+ APP: "app",
467
+ SESSION: "session",
468
+ ROUTE: "route",
469
+ INSTANCE: "instance",
470
+ WORKSPACE: "workspace"
471
+ });
472
+ REGISTRY_SCOPE_KINDS.APP;
473
+ }
474
+ });
475
+
476
+ // src/kernel/utils.ts
477
+ function parseFiniteNumber(value) {
478
+ const parsed = Number(value);
479
+ return Number.isFinite(parsed) ? parsed : null;
480
+ }
481
+ function getValidString(value, fallback = null) {
482
+ return trimToNull(value) ?? fallback;
483
+ }
484
+ var init_utils2 = __esm({
485
+ "src/kernel/utils.ts"() {
486
+ init_constants();
487
+ init_utils();
488
+ }
489
+ });
490
+
491
+ // src/kernel/schema.ts
492
+ function resolveLifecycle(metadata, fallback) {
493
+ const lifecycle = metadata?.lifecycle ?? metadata?.cleanup;
494
+ return lifecycle && REGISTRY_LIFECYCLE_VALUES.has(lifecycle) ? lifecycle : fallback;
495
+ }
496
+ function validateRegistryMetadata(metadata) {
497
+ if (metadata === void 0 || metadata === null)
498
+ return { issues: [], valid: true };
499
+ if (!isObject(metadata))
500
+ return { issues: ["registry metadata must be an object"], valid: false };
501
+ const issues = [];
502
+ Object.keys(metadata).forEach((key) => {
503
+ if (!REGISTRY_METADATA_KEY_SET.has(key))
504
+ issues.push(`unknown registry metadata field: ${key}`);
505
+ });
506
+ if (metadata.source !== void 0 && !getValidString(metadata.source))
507
+ issues.push("source must be a non-empty string");
508
+ if (metadata.instanceId !== void 0 && !getValidString(metadata.instanceId))
509
+ issues.push("instanceId must be a non-empty string");
510
+ if (metadata.scope !== void 0 && !getValidString(metadata.scope))
511
+ issues.push("scope must be a non-empty string");
512
+ if (metadata.priority !== void 0 && parseFiniteNumber(metadata.priority) === null)
513
+ issues.push("priority must be a finite number");
514
+ if (metadata.cleanupDelayMs !== void 0) {
515
+ const delay = parseFiniteNumber(metadata.cleanupDelayMs);
516
+ if (delay === null || delay < 0)
517
+ issues.push("cleanupDelayMs must be a non-negative finite number");
518
+ }
519
+ const lifecycle = metadata.lifecycle ?? metadata.cleanup;
520
+ if (lifecycle !== void 0 && !REGISTRY_LIFECYCLE_VALUES.has(String(lifecycle))) {
521
+ issues.push(
522
+ `lifecycle must be one of: ${[...REGISTRY_LIFECYCLE_VALUES].join(", ")}`
523
+ );
524
+ }
525
+ if (metadata.validation !== void 0 && !Object.values(REGISTRY_VALIDATION_MODES).includes(
526
+ metadata.validation
527
+ )) {
528
+ issues.push(
529
+ `validation must be one of: ${Object.values(REGISTRY_VALIDATION_MODES).join(", ")}`
530
+ );
531
+ }
532
+ return { issues, valid: issues.length === 0 };
533
+ }
534
+ function normalizeRegistryMetadata(metadata, {
535
+ defaultCleanupDelayMs = null,
536
+ defaultLifecycle = null,
537
+ defaultSource = DEFAULT_SOURCE
538
+ } = {}) {
539
+ const registryMeta = isObject(metadata) ? metadata : {};
540
+ const normalizedDefaultDelay = parseFiniteNumber(defaultCleanupDelayMs);
541
+ const fallbackCleanupDelayMs = normalizedDefaultDelay !== null && normalizedDefaultDelay >= 0 ? normalizedDefaultDelay : null;
542
+ const fallbackLifecycle = defaultLifecycle && REGISTRY_LIFECYCLE_VALUES.has(defaultLifecycle) ? defaultLifecycle : null;
543
+ const source = getValidString(registryMeta.source) || getValidString(defaultSource, DEFAULT_SOURCE) || DEFAULT_SOURCE;
544
+ const scope = getValidString(registryMeta.scope);
545
+ const priority = parseFiniteNumber(registryMeta.priority);
546
+ const lifecycle = resolveLifecycle(registryMeta, fallbackLifecycle);
547
+ const validation = isValidationMode(registryMeta.validation) ? registryMeta.validation : null;
548
+ const cleanupDelayCandidate = parseFiniteNumber(registryMeta.cleanupDelayMs);
549
+ let cleanupDelayMs = cleanupDelayCandidate !== null && cleanupDelayCandidate >= 0 ? cleanupDelayCandidate : fallbackCleanupDelayMs;
550
+ if (lifecycle === REGISTRY_LIFECYCLES.IMMEDIATE) {
551
+ cleanupDelayMs = 0;
552
+ } else if ((lifecycle === REGISTRY_LIFECYCLES.GRACEFUL || lifecycle === REGISTRY_LIFECYCLES.ROUTE) && cleanupDelayMs === null) {
553
+ cleanupDelayMs = fallbackCleanupDelayMs;
554
+ }
555
+ return {
556
+ cleanupDelayMs,
557
+ lifecycle,
558
+ priority,
559
+ registerOptions: {
560
+ ...priority !== null && { priority },
561
+ ...validation === REGISTRY_VALIDATION_MODES.STRICT && { validation },
562
+ ...scope && { scope }
563
+ },
564
+ source,
565
+ ...scope && { scope },
566
+ ...validation && { validation }
567
+ };
568
+ }
569
+ function isValidationMode(value) {
570
+ return Object.values(REGISTRY_VALIDATION_MODES).includes(value);
571
+ }
572
+ function pickRegistryMetadata(options) {
573
+ if (!isObject(options)) return {};
574
+ return Object.fromEntries(
575
+ REGISTRY_METADATA_KEYS.filter((key) => options[key] !== void 0).map(
576
+ (key) => [key, options[key]]
577
+ )
578
+ );
579
+ }
580
+ var init_schema = __esm({
581
+ "src/kernel/schema.ts"() {
582
+ init_constants();
583
+ init_utils2();
584
+ }
585
+ });
586
+
587
+ // src/kernel/operations.ts
588
+ var init_operations = __esm({
589
+ "src/kernel/operations.ts"() {
590
+ init_constants();
591
+ init_utils2();
592
+ init_schema();
593
+ }
594
+ });
595
+ function useRequiredContext(context, hookName, providerName) {
596
+ const value = use(context);
597
+ if (value === null) {
598
+ throw new Error(`${hookName} must be used within ${providerName}`);
599
+ }
600
+ return value;
601
+ }
602
+ var init_use_required_context = __esm({
603
+ "src/hooks/use-required-context.ts"() {
604
+ "use client";
605
+ }
606
+ });
607
+ function useStore(store, selector = (state) => state, isEqual = Object.is) {
608
+ const cacheRef = useRef({
609
+ isEqual: null,
610
+ selected: void 0,
611
+ selector: null,
612
+ snapshot: null
613
+ });
614
+ const getSelectedSnapshot = useCallback(() => {
615
+ const snapshot = store.getSnapshot();
616
+ const cache = cacheRef.current;
617
+ if (cache.snapshot === snapshot && cache.selector === selector && cache.isEqual === isEqual) {
618
+ return cache.selected;
619
+ }
620
+ const selected = selector(snapshot);
621
+ if (cache.snapshot !== null && cache.isEqual === isEqual && isEqual(cache.selected, selected)) {
622
+ cache.snapshot = snapshot;
623
+ cache.selector = selector;
624
+ return cache.selected;
625
+ }
626
+ cacheRef.current = {
627
+ isEqual,
628
+ selected,
629
+ selector,
630
+ snapshot
631
+ };
632
+ return selected;
633
+ }, [isEqual, selector, store]);
634
+ return useSyncExternalStore(
635
+ store.subscribe,
636
+ getSelectedSnapshot,
637
+ getSelectedSnapshot
638
+ );
639
+ }
640
+ var init_use_store = __esm({
641
+ "src/hooks/use-store.ts"() {
642
+ "use client";
643
+ }
644
+ });
645
+ var init_use_click_outside = __esm({
646
+ "src/hooks/use-click-outside.ts"() {
647
+ "use client";
648
+ }
649
+ });
650
+ var useIsomorphicLayoutEffect;
651
+ var init_use_isomorphic_layout_effect = __esm({
652
+ "src/hooks/use-isomorphic-layout-effect.ts"() {
653
+ "use client";
654
+ init_utils();
655
+ useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
656
+ }
657
+ });
658
+ var init_use_debounce = __esm({
659
+ "src/hooks/use-debounce.ts"() {
660
+ "use client";
661
+ }
662
+ });
663
+ var init_use_mounted = __esm({
664
+ "src/hooks/use-mounted.ts"() {
665
+ "use client";
666
+ }
667
+ });
668
+ var init_use_media_query = __esm({
669
+ "src/hooks/use-media-query.ts"() {
670
+ "use client";
671
+ init_utils();
672
+ }
673
+ });
674
+ var init_use_controllable_state = __esm({
675
+ "src/hooks/use-controllable-state.ts"() {
676
+ "use client";
677
+ init_use_isomorphic_layout_effect();
678
+ }
679
+ });
680
+ var init_use_hotkey = __esm({
681
+ "src/hooks/use-hotkey.ts"() {
682
+ "use client";
683
+ init_utils();
684
+ init_use_isomorphic_layout_effect();
685
+ }
686
+ });
687
+
688
+ // src/events.ts
689
+ var EventEmitter, GLOBAL_EVENTS_KEY, _global;
690
+ var init_events = __esm({
691
+ "src/events.ts"() {
692
+ init_report();
693
+ EventEmitter = class {
694
+ events = /* @__PURE__ */ new Map();
695
+ debounceTimers = /* @__PURE__ */ new Map();
696
+ subscribe(event, callback) {
697
+ if (typeof event !== "string" || !event || typeof callback !== "function") {
698
+ return () => {
699
+ };
700
+ }
701
+ const listeners = this.events.get(event) || /* @__PURE__ */ new Set();
702
+ listeners.add(callback);
703
+ this.events.set(event, listeners);
704
+ return () => {
705
+ listeners.delete(callback);
706
+ if (listeners.size === 0) this.events.delete(event);
707
+ };
708
+ }
709
+ emit(event, payload) {
710
+ const listeners = this.events.get(event);
711
+ if (!listeners || listeners.size === 0) return;
712
+ const snapshot = Array.from(listeners);
713
+ for (const callback of snapshot) {
714
+ try {
715
+ callback(payload);
716
+ } catch (error) {
717
+ report(`Event listener (${String(event)})`, error);
718
+ }
719
+ }
720
+ }
721
+ emitDebounced(event, payload, waitMs = 100) {
722
+ const existing = this.debounceTimers.get(event);
723
+ if (existing) clearTimeout(existing);
724
+ const timer = setTimeout(() => {
725
+ this.debounceTimers.delete(event);
726
+ this.emit(event, payload);
727
+ }, waitMs);
728
+ this.debounceTimers.set(event, timer);
729
+ }
730
+ cancelDebounced(event) {
731
+ if (event) {
732
+ const timer = this.debounceTimers.get(event);
733
+ if (timer) {
734
+ clearTimeout(timer);
735
+ this.debounceTimers.delete(event);
736
+ }
737
+ } else {
738
+ for (const timer of this.debounceTimers.values()) {
739
+ clearTimeout(timer);
740
+ }
741
+ this.debounceTimers.clear();
742
+ }
743
+ }
744
+ unsubscribeAll(event) {
745
+ this.cancelDebounced(event);
746
+ if (event) this.events.delete(event);
747
+ else this.events.clear();
748
+ }
749
+ hasListeners(event) {
750
+ return Boolean(this.events.get(event)?.size);
751
+ }
752
+ getListenerCount(event) {
753
+ return this.events.get(event)?.size || 0;
754
+ }
755
+ getAllEvents() {
756
+ return [...this.events.keys()];
757
+ }
758
+ };
759
+ GLOBAL_EVENTS_KEY = /* @__PURE__ */ Symbol.for("__base_framework_global_events__");
760
+ _global = globalThis;
761
+ _global[GLOBAL_EVENTS_KEY] ?? (_global[GLOBAL_EVENTS_KEY] = new EventEmitter());
762
+ }
763
+ });
764
+ var init_use_global_event = __esm({
765
+ "src/hooks/use-global-event.ts"() {
766
+ "use client";
767
+ init_events();
768
+ init_use_isomorphic_layout_effect();
769
+ }
770
+ });
771
+
772
+ // src/result.ts
773
+ var init_result = __esm({
774
+ "src/result.ts"() {
775
+ init_user_message();
776
+ init_report();
777
+ }
778
+ });
779
+ var init_use_async_action = __esm({
780
+ "src/hooks/use-async-action.ts"() {
781
+ "use client";
782
+ init_events();
783
+ init_result();
784
+ init_utils();
785
+ }
786
+ });
787
+ var init_use_server_action = __esm({
788
+ "src/hooks/use-server-action.ts"() {
789
+ "use client";
790
+ init_events();
791
+ init_result();
792
+ init_utils();
793
+ }
794
+ });
795
+ var init_use_storage_state = __esm({
796
+ "src/hooks/use-storage-state.ts"() {
797
+ "use client";
798
+ init_utils();
799
+ init_use_isomorphic_layout_effect();
800
+ }
801
+ });
802
+ var init_use_intersection_observer = __esm({
803
+ "src/hooks/use-intersection-observer.ts"() {
804
+ "use client";
805
+ init_utils();
806
+ init_use_isomorphic_layout_effect();
807
+ }
808
+ });
809
+
810
+ // src/hooks/index.ts
811
+ var init_hooks = __esm({
812
+ "src/hooks/index.ts"() {
813
+ "use client";
814
+ init_use_required_context();
815
+ init_use_store();
816
+ init_use_click_outside();
817
+ init_use_isomorphic_layout_effect();
818
+ init_use_debounce();
819
+ init_use_mounted();
820
+ init_use_media_query();
821
+ init_use_controllable_state();
822
+ init_use_hotkey();
823
+ init_use_global_event();
824
+ init_use_async_action();
825
+ init_use_server_action();
826
+ init_use_storage_state();
827
+ init_use_intersection_observer();
828
+ init_use_fullscreen_state();
829
+ }
830
+ });
831
+
832
+ // src/kernel/runtime.ts
833
+ var init_runtime = __esm({
834
+ "src/kernel/runtime.ts"() {
835
+ "use client";
836
+ }
837
+ });
838
+ function createNoopHandle(status = "rejected", reason = "unknown") {
839
+ const handle = Object.assign(() => false, {
840
+ active: false,
841
+ dispose: () => false,
842
+ instanceId: null,
843
+ key: "",
844
+ priority: 0,
845
+ reason,
846
+ source: "",
847
+ status,
848
+ type: "",
849
+ update: () => handle,
850
+ updatedAt: 0,
851
+ validation: "warn"
852
+ });
853
+ return handle;
854
+ }
855
+ var init_store2 = __esm({
856
+ "src/kernel/store.ts"() {
857
+ init_operations();
858
+ init_schema();
859
+ init_runtime();
860
+ init_utils();
861
+ createNoopHandle();
862
+ }
863
+ });
864
+ function getOrCreateGlobalContext(name, defaultValue) {
865
+ const sym = /* @__PURE__ */ Symbol.for(`@omerdlw/base-framework/context/${name}`);
866
+ const store = globalThis;
867
+ if (!store[sym]) {
868
+ store[sym] = createContext(defaultValue);
869
+ }
870
+ return store[sym];
871
+ }
872
+ var init_context_registry = __esm({
873
+ "src/kernel/context-registry.ts"() {
874
+ }
875
+ });
876
+ function useRegistryActions() {
877
+ return useRequiredContext(
878
+ RegistryContext,
879
+ "useRegistryActions",
880
+ "RegistryProvider"
881
+ ).actions;
882
+ }
883
+ function useRegistrySubscription() {
884
+ return useRequiredContext(
885
+ RegistryContext,
886
+ "useRegistrySubscription",
887
+ "RegistryProvider"
888
+ ).subscription;
889
+ }
890
+ function useRegistryEntries(type) {
891
+ const { getEntriesSnapshot, subscribe } = useRegistrySubscription();
892
+ const subscribeToType = useCallback(
893
+ (listener) => subscribe(type, null, listener),
894
+ [subscribe, type]
895
+ );
896
+ const getEntries = useCallback(
897
+ () => getEntriesSnapshot(type),
898
+ [getEntriesSnapshot, type]
899
+ );
900
+ return useSyncExternalStore(subscribeToType, getEntries, getEntries);
901
+ }
902
+ var RegistryContext;
903
+ var init_provider = __esm({
904
+ "src/kernel/provider.tsx"() {
905
+ "use client";
906
+ init_hooks();
907
+ init_store2();
908
+ init_context_registry();
909
+ RegistryContext = getOrCreateGlobalContext(
910
+ "RegistryContext",
911
+ null
912
+ );
913
+ }
914
+ });
915
+ function selectModuleSlice(coreModule, config) {
916
+ const slice = coreModule.page?.select ? coreModule.page.select(config) : config[coreModule.id];
917
+ return slice ?? null;
918
+ }
919
+ function createModulePayload(modules, config, metadata = {}) {
920
+ const payload = {};
921
+ let hasSlices = false;
922
+ for (const coreModule of modules) {
923
+ if (!coreModule.page?.entries) continue;
924
+ const slice = selectModuleSlice(coreModule, config);
925
+ if (slice === null) continue;
926
+ payload[coreModule.id] = slice;
927
+ hasSlices = true;
928
+ }
929
+ if (!hasSlices) return null;
930
+ return {
931
+ ...payload,
932
+ registry: {
933
+ ...metadata,
934
+ ...isObject(config.registry) ? config.registry : {}
935
+ }
936
+ };
937
+ }
938
+ function useInstalledModules() {
939
+ return use(ModuleHostContext)?.modules ?? EMPTY_MODULES;
940
+ }
941
+ var EMPTY_MODULES, PassthroughBoundary, ModuleHostContext;
942
+ var init_installed = __esm({
943
+ "src/kernel/installed.ts"() {
944
+ "use client";
945
+ init_utils();
946
+ init_context_registry();
947
+ EMPTY_MODULES = Object.freeze([]);
948
+ PassthroughBoundary = ({ children }) => children;
949
+ ModuleHostContext = getOrCreateGlobalContext("ModuleHostContext", null);
950
+ }
951
+ });
952
+
953
+ // src/kernel/handlers.ts
954
+ function isPersistentLifecycle(lifecycle) {
955
+ return lifecycle === REGISTRY_LIFECYCLES.PERSISTENT;
956
+ }
957
+ function runRegistrationBatch(context, executor) {
958
+ return typeof context.batch === "function" ? context.batch(executor) : executor(context);
959
+ }
960
+ function createEntryCleanupKey(type, key, source, instanceId, scope) {
961
+ return JSON.stringify([
962
+ "entry",
963
+ type,
964
+ key,
965
+ scope ?? null,
966
+ source,
967
+ instanceId
968
+ ]);
969
+ }
970
+ function getCleanupScope(context) {
971
+ return context?.cleanupScope || /* @__PURE__ */ new Map();
972
+ }
973
+ function clearCleanupTimer(scope, cleanupKey) {
974
+ const lifecycle = scope.get(cleanupKey);
975
+ if (!lifecycle) return;
976
+ lifecycle.cancelled = true;
977
+ if (lifecycle.timerId !== null) clearTimeout(lifecycle.timerId);
978
+ scope.delete(cleanupKey);
979
+ }
980
+ function scheduleCleanup(scope, cleanupKey, callback, delayMs) {
981
+ clearCleanupTimer(scope, cleanupKey);
982
+ const lifecycle = {
983
+ cancelled: false,
984
+ timerId: null
985
+ };
986
+ lifecycle.timerId = setTimeout(() => {
987
+ if (lifecycle.cancelled || scope.get(cleanupKey) !== lifecycle) return;
988
+ scope.delete(cleanupKey);
989
+ callback();
990
+ }, delayMs);
991
+ scope.set(cleanupKey, lifecycle);
992
+ }
993
+ function collectModuleRegistrations(coreModule, slice, pageMetadata, context) {
994
+ const definition = coreModule.registry;
995
+ const toEntries = coreModule.page?.entries;
996
+ if (!definition || !toEntries || slice == null || slice === false) return [];
997
+ const type = coreModule.id;
998
+ const items = Array.isArray(slice) ? slice : [slice];
999
+ const registrations = [];
1000
+ for (const item of items) {
1001
+ if (item == null || item === false) continue;
1002
+ const itemMetadata = isObject(item) && isObject(item.registry) ? item.registry : {};
1003
+ const metadata = { ...pageMetadata, ...itemMetadata };
1004
+ if (metadata.validation === "strict" && !validateRegistryMetadata(metadata).valid) {
1005
+ continue;
1006
+ }
1007
+ const payload = isObject(item) ? Object.fromEntries(
1008
+ Object.entries(item).filter(([key]) => key !== "registry")
1009
+ ) : item;
1010
+ const { cleanupDelayMs, lifecycle, registerOptions, scope, source } = normalizeRegistryMetadata(metadata, {
1011
+ defaultCleanupDelayMs: definition.cleanupDelayMs ?? null,
1012
+ defaultLifecycle: definition.lifecycle,
1013
+ defaultSource: DEFAULT_SOURCE
1014
+ });
1015
+ for (const { key, value } of toEntries(payload, context) ?? []) {
1016
+ const validation = definition.validate?.(value);
1017
+ if (validation && !validation.valid) {
1018
+ report(`Registry ${type} config is invalid`, validation.issues, "warn");
1019
+ continue;
1020
+ }
1021
+ registrations.push({
1022
+ cleanupDelayMs,
1023
+ cleanupKey: createEntryCleanupKey(
1024
+ type,
1025
+ key,
1026
+ source,
1027
+ context.instanceId,
1028
+ scope
1029
+ ),
1030
+ key,
1031
+ lifecycle,
1032
+ registerOptions,
1033
+ scope,
1034
+ source,
1035
+ type,
1036
+ value
1037
+ });
1038
+ }
1039
+ }
1040
+ return registrations;
1041
+ }
1042
+ function applyRegistryConfig(config, context) {
1043
+ const modules = context.modules ?? [];
1044
+ if (!config || modules.length === 0) return NO_CLEANUP;
1045
+ const pageMetadata = isObject(config.registry) ? config.registry : {};
1046
+ const slices = config;
1047
+ const registrations = modules.flatMap((coreModule) => {
1048
+ try {
1049
+ return collectModuleRegistrations(
1050
+ coreModule,
1051
+ slices[coreModule.id],
1052
+ pageMetadata,
1053
+ context
1054
+ );
1055
+ } catch (error) {
1056
+ report(`Registry apply (${coreModule.id})`, error);
1057
+ return [];
1058
+ }
1059
+ });
1060
+ if (registrations.length === 0) return NO_CLEANUP;
1061
+ const cleanupScope = getCleanupScope(context);
1062
+ const owner = (registration) => ({
1063
+ instanceId: context.instanceId,
1064
+ scope: registration.scope,
1065
+ source: registration.source
1066
+ });
1067
+ runRegistrationBatch(context, (queue) => {
1068
+ registrations.forEach(
1069
+ ({ cleanupKey, key, registerOptions, source, type, value }) => {
1070
+ clearCleanupTimer(cleanupScope, cleanupKey);
1071
+ queue.register(type, key, value, source, registerOptions);
1072
+ }
1073
+ );
1074
+ });
1075
+ return () => {
1076
+ const immediate = [];
1077
+ registrations.forEach((registration) => {
1078
+ if (isPersistentLifecycle(registration.lifecycle)) return;
1079
+ const { cleanupDelayMs, cleanupKey, key, type } = registration;
1080
+ if (typeof cleanupDelayMs === "number" && cleanupDelayMs > 0) {
1081
+ scheduleCleanup(
1082
+ cleanupScope,
1083
+ cleanupKey,
1084
+ () => context.unregister(type, key, owner(registration)),
1085
+ cleanupDelayMs
1086
+ );
1087
+ } else {
1088
+ immediate.push(registration);
1089
+ }
1090
+ });
1091
+ if (immediate.length === 0) return;
1092
+ runRegistrationBatch(context, (queue) => {
1093
+ immediate.forEach(
1094
+ (registration) => queue.unregister(
1095
+ registration.type,
1096
+ registration.key,
1097
+ owner(registration)
1098
+ )
1099
+ );
1100
+ });
1101
+ };
1102
+ }
1103
+ var NO_CLEANUP;
1104
+ var init_handlers = __esm({
1105
+ "src/kernel/handlers.ts"() {
1106
+ init_schema();
1107
+ init_utils2();
1108
+ init_utils();
1109
+ NO_CLEANUP = () => {
1110
+ };
1111
+ }
1112
+ });
1113
+ function withInstanceId(instanceId, sourceOrOptions, optionsArg) {
1114
+ if (typeof sourceOrOptions === "string") {
1115
+ return {
1116
+ optionsArg: { ...isObject(optionsArg) ? optionsArg : {}, instanceId },
1117
+ sourceOrOptions
1118
+ };
1119
+ }
1120
+ if (isObject(sourceOrOptions)) {
1121
+ return {
1122
+ optionsArg,
1123
+ sourceOrOptions: { ...sourceOrOptions, instanceId }
1124
+ };
1125
+ }
1126
+ return {
1127
+ optionsArg: void 0,
1128
+ sourceOrOptions: {
1129
+ ...isObject(optionsArg) ? optionsArg : {},
1130
+ instanceId
1131
+ }
1132
+ };
1133
+ }
1134
+ function withInstanceIdForUnregister(instanceId, sourceOrOptions) {
1135
+ if (typeof sourceOrOptions === "string") {
1136
+ return { instanceId, source: sourceOrOptions };
1137
+ }
1138
+ if (isObject(sourceOrOptions)) {
1139
+ return { ...sourceOrOptions, instanceId };
1140
+ }
1141
+ return { instanceId };
1142
+ }
1143
+ function resolveRegisterArgsWithInstance(instanceId, sourceOrOptions, optionsArg) {
1144
+ const input = withInstanceId(instanceId, sourceOrOptions, optionsArg);
1145
+ return [input.sourceOrOptions, input.optionsArg];
1146
+ }
1147
+ function createStableFunctionEntry(fn) {
1148
+ const entry = {
1149
+ current: fn,
1150
+ stable(...args) {
1151
+ return entry.current?.apply(this, args);
1152
+ }
1153
+ };
1154
+ return entry;
1155
+ }
1156
+ function isDirectRegistryComponentPath(path, componentSlices) {
1157
+ const match = /^config\.([^.[]+)\.[^.[]+$/.exec(path);
1158
+ return Boolean(match && componentSlices.has(match[1]));
1159
+ }
1160
+ function isReactNodeLike(value) {
1161
+ return value === null || value === void 0 || typeof value === "boolean" || typeof value === "string" || typeof value === "number" || isValidElement(value);
1162
+ }
1163
+ function isStabilizableObject(value) {
1164
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !isValidElement(value);
1165
+ }
1166
+ function hasSameObjectKeys(previousValue, nextValue) {
1167
+ if (!isStabilizableObject(previousValue) || !isStabilizableObject(nextValue)) {
1168
+ return false;
1169
+ }
1170
+ const previousKeys = Object.keys(previousValue);
1171
+ const nextKeys = Object.keys(nextValue);
1172
+ if (previousKeys.length !== nextKeys.length) return false;
1173
+ return nextKeys.every(
1174
+ (key) => Object.prototype.hasOwnProperty.call(previousValue, key)
1175
+ );
1176
+ }
1177
+ function stabilizeRegistryValue(value, path, scope, previousValue, seen = /* @__PURE__ */ new WeakSet(), depth = 0) {
1178
+ if (depth > MAX_STABILIZATION_DEPTH) return value;
1179
+ if (typeof value === "function") {
1180
+ const isComponent = value.name && /^[A-Z]/.test(value.name);
1181
+ if (isComponent || isDirectRegistryComponentPath(path, scope.componentSlices)) {
1182
+ return value;
1183
+ }
1184
+ scope.usedPaths.add(path);
1185
+ let entry = scope.functionEntries.get(path);
1186
+ if (!entry) {
1187
+ entry = createStableFunctionEntry(value);
1188
+ scope.functionEntries.set(path, entry);
1189
+ } else {
1190
+ entry.current = value;
1191
+ }
1192
+ return entry.stable;
1193
+ }
1194
+ if (value && typeof value === "object") {
1195
+ if (seen.has(value)) return value;
1196
+ seen.add(value);
1197
+ }
1198
+ if (isValidElement(value)) {
1199
+ const nextProps = stabilizeRegistryValue(
1200
+ value.props,
1201
+ `${path}.props`,
1202
+ scope,
1203
+ isValidElement(previousValue) ? previousValue.props : void 0,
1204
+ seen,
1205
+ depth + 1
1206
+ );
1207
+ if (isValidElement(previousValue) && previousValue.type === value.type && previousValue.key === value.key && previousValue.props === nextProps) {
1208
+ return previousValue;
1209
+ }
1210
+ return cloneElement(value, nextProps);
1211
+ }
1212
+ if (Array.isArray(value)) {
1213
+ const nextValue = value.every(isReactNodeLike) ? Children.toArray(value) : value;
1214
+ const previousArray = Array.isArray(previousValue) ? previousValue : null;
1215
+ let hasChanged2 = !previousArray || previousArray.length !== nextValue.length;
1216
+ const stabilizedValue2 = nextValue.map((item, index) => {
1217
+ const nextItem = stabilizeRegistryValue(
1218
+ item,
1219
+ `${path}[${index}]`,
1220
+ scope,
1221
+ previousArray?.[index],
1222
+ seen,
1223
+ depth + 1
1224
+ );
1225
+ if (!previousArray || nextItem !== previousArray[index]) {
1226
+ hasChanged2 = true;
1227
+ }
1228
+ return nextItem;
1229
+ });
1230
+ return !hasChanged2 ? previousArray : stabilizedValue2;
1231
+ }
1232
+ if (typeof value !== "object" || value === null) {
1233
+ return value;
1234
+ }
1235
+ const source = value;
1236
+ const previousRecord = previousValue;
1237
+ const stabilizedValue = {};
1238
+ const canReusePrevious = hasSameObjectKeys(previousValue, value);
1239
+ let hasChanged = !canReusePrevious;
1240
+ Object.keys(source).forEach((key) => {
1241
+ const nextValue = stabilizeRegistryValue(
1242
+ source[key],
1243
+ `${path}.${key}`,
1244
+ scope,
1245
+ previousRecord?.[key],
1246
+ seen,
1247
+ depth + 1
1248
+ );
1249
+ stabilizedValue[key] = nextValue;
1250
+ if (!canReusePrevious || nextValue !== previousRecord?.[key]) {
1251
+ hasChanged = true;
1252
+ }
1253
+ });
1254
+ return !hasChanged ? previousValue : stabilizedValue;
1255
+ }
1256
+ function useAppliedRegistryConfig(payload, context, componentSlices) {
1257
+ const functionEntriesRef = useRef(/* @__PURE__ */ new Map());
1258
+ const appliedRef = useRef(null);
1259
+ useIsomorphicLayoutEffect(() => {
1260
+ const previous = appliedRef.current;
1261
+ if (previous && previous.payload === payload && previous.context === context) {
1262
+ return;
1263
+ }
1264
+ const functionEntries = functionEntriesRef.current;
1265
+ const usedPaths = /* @__PURE__ */ new Set();
1266
+ const config = stabilizeRegistryValue(
1267
+ payload,
1268
+ "config",
1269
+ { componentSlices, functionEntries, usedPaths },
1270
+ previous?.config
1271
+ );
1272
+ functionEntries.forEach((_entry, path) => {
1273
+ if (!usedPaths.has(path)) functionEntries.delete(path);
1274
+ });
1275
+ if (previous && previous.config === config && previous.context === context) {
1276
+ previous.payload = payload;
1277
+ return;
1278
+ }
1279
+ previous?.cleanup();
1280
+ appliedRef.current = {
1281
+ cleanup: applyRegistryConfig(config, context),
1282
+ config,
1283
+ context,
1284
+ payload
1285
+ };
1286
+ });
1287
+ useIsomorphicLayoutEffect(
1288
+ () => () => {
1289
+ appliedRef.current?.cleanup();
1290
+ appliedRef.current = null;
1291
+ },
1292
+ []
1293
+ );
1294
+ }
1295
+ function createRegistryApplyContext(actions, {
1296
+ cleanupScope = /* @__PURE__ */ new Map(),
1297
+ instanceId,
1298
+ modules = [],
1299
+ pathname
1300
+ }) {
1301
+ const stamp = (queue) => ({
1302
+ register: (type, key, item, sourceOrOptions, optionsArg) => queue.register(
1303
+ type,
1304
+ key,
1305
+ item,
1306
+ ...resolveRegisterArgsWithInstance(
1307
+ instanceId,
1308
+ sourceOrOptions,
1309
+ optionsArg
1310
+ )
1311
+ ),
1312
+ unregister: (type, key, sourceOrOptions) => queue.unregister(
1313
+ type,
1314
+ key,
1315
+ withInstanceIdForUnregister(instanceId, sourceOrOptions)
1316
+ )
1317
+ });
1318
+ return {
1319
+ ...stamp(actions),
1320
+ batch: (executor) => typeof executor === "function" ? actions.batch((queue) => executor(stamp(queue))) : 0,
1321
+ cleanupScope,
1322
+ instanceId,
1323
+ modules,
1324
+ pathname
1325
+ };
1326
+ }
1327
+ function useRegistry(config, metadata) {
1328
+ const { batch, register, unregister } = useRegistryActions();
1329
+ const pathname = usePathname();
1330
+ const modules = useInstalledModules();
1331
+ const instanceId = `registry-instance-${useId()}`;
1332
+ const [cleanupScope] = useState(
1333
+ () => /* @__PURE__ */ new Map()
1334
+ );
1335
+ const context = useMemo(
1336
+ () => createRegistryApplyContext(
1337
+ { batch, register, unregister },
1338
+ {
1339
+ cleanupScope,
1340
+ instanceId,
1341
+ modules,
1342
+ pathname
1343
+ }
1344
+ ),
1345
+ [batch, cleanupScope, instanceId, modules, pathname, register, unregister]
1346
+ );
1347
+ const payload = useMemo(
1348
+ () => config ? createModulePayload(modules, config, metadata) : null,
1349
+ [config, metadata, modules]
1350
+ );
1351
+ const componentSlices = useMemo(
1352
+ () => new Set(
1353
+ modules.filter(
1354
+ (coreModule) => coreModule.registry?.valueKind === "component"
1355
+ ).map((coreModule) => coreModule.id)
1356
+ ),
1357
+ [modules]
1358
+ );
1359
+ useAppliedRegistryConfig(payload, context, componentSlices);
1360
+ }
1361
+ var MAX_STABILIZATION_DEPTH;
1362
+ var init_hooks2 = __esm({
1363
+ "src/kernel/hooks.ts"() {
1364
+ "use client";
1365
+ init_hooks();
1366
+ init_handlers();
1367
+ init_installed();
1368
+ init_provider();
1369
+ init_utils();
1370
+ MAX_STABILIZATION_DEPTH = 64;
1371
+ }
1372
+ });
1373
+ function createPageControllerStore() {
1374
+ const listeners = /* @__PURE__ */ new Set();
1375
+ let stack = [];
1376
+ const notify = () => {
1377
+ listeners.forEach((listener) => {
1378
+ try {
1379
+ listener();
1380
+ } catch (error) {
1381
+ report("Page controller listener", error);
1382
+ }
1383
+ });
1384
+ };
1385
+ return {
1386
+ getSnapshot() {
1387
+ const top = stack[stack.length - 1];
1388
+ return top?.controllerRef?.current || null;
1389
+ },
1390
+ notify,
1391
+ register(id, controllerRef) {
1392
+ stack = stack.filter((item) => item.id !== id);
1393
+ stack.push({ controllerRef, id });
1394
+ notify();
1395
+ },
1396
+ subscribe(listener) {
1397
+ listeners.add(listener);
1398
+ return () => {
1399
+ listeners.delete(listener);
1400
+ };
1401
+ },
1402
+ unregister(id) {
1403
+ stack = stack.filter((item) => item.id !== id);
1404
+ notify();
1405
+ }
1406
+ };
1407
+ }
1408
+ var fallbackStandaloneStore;
1409
+ var init_page_controller = __esm({
1410
+ "src/kernel/page-controller.tsx"() {
1411
+ "use client";
1412
+ init_hooks();
1413
+ init_hooks2();
1414
+ init_installed();
1415
+ init_schema();
1416
+ init_utils2();
1417
+ init_utils();
1418
+ init_context_registry();
1419
+ fallbackStandaloneStore = createPageControllerStore();
1420
+ getOrCreateGlobalContext(
1421
+ "PageControllerContext",
1422
+ null
1423
+ );
1424
+ getOrCreateGlobalContext(
1425
+ "PageControllerStoreContext",
1426
+ fallbackStandaloneStore
1427
+ );
1428
+ }
1429
+ });
1430
+ function defineModule(coreModule) {
1431
+ return Object.freeze({ ...coreModule });
1432
+ }
1433
+ function ModuleBoundary({
1434
+ children,
1435
+ name
1436
+ }) {
1437
+ const Boundary = use(ModuleHostContext)?.Boundary ?? PassthroughBoundary;
1438
+ return createElement(Boundary, { name }, children);
1439
+ }
1440
+ var init_module = __esm({
1441
+ "src/kernel/module.tsx"() {
1442
+ "use client";
1443
+ init_hooks();
1444
+ init_utils();
1445
+ init_installed();
1446
+ init_page_controller();
1447
+ init_provider();
1448
+ init_utils();
1449
+ createStore(void 0);
1450
+ }
1451
+ });
1452
+
1453
+ // src/kernel/adapters.tsx
1454
+ function useModuleRegistration(id, value, options) {
1455
+ const coreModule = useInstalledModules().find(
1456
+ (candidate) => candidate.id === id
1457
+ );
1458
+ const config = coreModule && options?.enabled !== false && value != null ? { [id]: value } : null;
1459
+ useRegistry(config, pickRegistryMetadata(options));
1460
+ }
1461
+ var init_adapters = __esm({
1462
+ "src/kernel/adapters.tsx"() {
1463
+ "use client";
1464
+ init_schema();
1465
+ init_hooks2();
1466
+ init_installed();
1467
+ }
1468
+ });
1469
+ var init_compose = __esm({
1470
+ "src/kernel/compose.ts"() {
1471
+ }
1472
+ });
1473
+
1474
+ // src/kernel/index.ts
1475
+ var init_kernel = __esm({
1476
+ "src/kernel/index.ts"() {
1477
+ "use client";
1478
+ init_types();
1479
+ init_constants();
1480
+ init_utils2();
1481
+ init_operations();
1482
+ init_provider();
1483
+ init_store2();
1484
+ init_installed();
1485
+ init_module();
1486
+ init_handlers();
1487
+ init_hooks2();
1488
+ init_adapters();
1489
+ init_page_controller();
1490
+ init_compose();
1491
+ }
1492
+ });
1493
+ function defineThemeSpec(id) {
1494
+ return Object.freeze({ id });
1495
+ }
1496
+ function useTheme(spec) {
1497
+ const config = useContext(ThemeContext).get(spec.id);
1498
+ if (!config) {
1499
+ throw new Error(
1500
+ `Theme "${spec.id}" is missing. Add its theme file to src/config/ and list it in src/config/index.ts.`
1501
+ );
1502
+ }
1503
+ return {
1504
+ slots: config.slots,
1505
+ styles: config.styles ?? {}
1506
+ };
1507
+ }
1508
+ var EMPTY, ThemeContext;
1509
+ var init_theme = __esm({
1510
+ "src/theme.tsx"() {
1511
+ "use client";
1512
+ init_context_registry();
1513
+ EMPTY = /* @__PURE__ */ new Map();
1514
+ ThemeContext = getOrCreateGlobalContext("ThemeContext", EMPTY);
1515
+ }
1516
+ });
1517
+
1518
+ // src/modules/theme.ts
1519
+ var init_theme2 = __esm({
1520
+ "src/modules/theme.ts"() {
1521
+ init_theme();
1522
+ }
1523
+ });
1524
+
1525
+ // src/modules/modal/constants.ts
1526
+ var MODAL_POSITIONS, MODAL_CHROME, MODAL_BREAKPOINTS, SMOOTH_SCROLL_LOCK_EVENT, FOCUSABLE_SELECTOR, HEIGHT_CONSTRAINT_PATTERN, modalTheme;
1527
+ var init_constants2 = __esm({
1528
+ "src/modules/modal/constants.ts"() {
1529
+ init_theme2();
1530
+ MODAL_POSITIONS = Object.freeze({
1531
+ BOTTOM: "bottom",
1532
+ CENTER: "center",
1533
+ LEFT: "left",
1534
+ RIGHT: "right",
1535
+ TOP: "top"
1536
+ });
1537
+ MODAL_CHROME = Object.freeze({
1538
+ BARE: "bare",
1539
+ PANEL: "panel"
1540
+ });
1541
+ MODAL_BREAKPOINTS = Object.freeze({
1542
+ MOBILE_MAX_WIDTH: 639
1543
+ });
1544
+ SMOOTH_SCROLL_LOCK_EVENT = "modal:smooth-scroll-lock";
1545
+ FOCUSABLE_SELECTOR = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [contenteditable="true"], [tabindex]:not([tabindex="-1"])';
1546
+ HEIGHT_CONSTRAINT_PATTERN = /(\s|^)(?:[\w-]+:)*(?:h|max-h)-/;
1547
+ modalTheme = defineThemeSpec("modal");
1548
+ }
1549
+ });
1550
+
1551
+ // src/modules/modal/motion.ts
1552
+ function toCssDistance(value = 0) {
1553
+ return typeof value === "number" ? `${Math.round(value)}px` : value;
1554
+ }
1555
+ function toGpuTransform(yOrConfig, scaleValue = 1) {
1556
+ if (typeof yOrConfig === "object" && yOrConfig !== null) {
1557
+ const xVal = yOrConfig.x ?? 0;
1558
+ const yVal = yOrConfig.y ?? 0;
1559
+ const sVal = yOrConfig.scale ?? 1;
1560
+ const safeScale2 = Number.parseFloat(String(sVal));
1561
+ const roundedScale2 = Number.isFinite(safeScale2) ? Math.round(safeScale2 * 1e3) / 1e3 : 1;
1562
+ return `translate3d(${toCssDistance(xVal)}, ${toCssDistance(yVal)}, 0) scale(${roundedScale2})`;
1563
+ }
1564
+ const safeY = Number.parseFloat(String(yOrConfig));
1565
+ const safeScale = Number.parseFloat(String(scaleValue));
1566
+ const roundedY = Number.isFinite(safeY) ? Math.round(safeY) : 0;
1567
+ const roundedScale = Number.isFinite(safeScale) ? Math.round(safeScale * 1e3) / 1e3 : 1;
1568
+ return `translate3d(0, ${roundedY}px, 0) scale(${roundedScale})`;
1569
+ }
1570
+ function buildVariants(tierName, {
1571
+ axis,
1572
+ direction = 1,
1573
+ fullSlide = false
1574
+ }) {
1575
+ const tier = MODAL_TIERS[tierName];
1576
+ const distance = fullSlide ? "100%" : tier.distance;
1577
+ const signedDistance = direction < 0 ? fullSlide ? "-100%" : -Number(distance) : distance;
1578
+ const transform = axis === "x" ? {
1579
+ x: signedDistance
1580
+ } : {
1581
+ y: signedDistance
1582
+ };
1583
+ return Object.freeze({
1584
+ exit: {
1585
+ opacity: 0,
1586
+ transform: toGpuTransform(transform),
1587
+ transition: MODAL_SURFACE_EXIT_TRANSITION
1588
+ },
1589
+ hidden: {
1590
+ opacity: 0,
1591
+ transform: toGpuTransform(transform)
1592
+ },
1593
+ visible: {
1594
+ opacity: 1,
1595
+ transform: toGpuTransform(),
1596
+ transition: MODAL_SURFACE_ENTER_TRANSITION
1597
+ }
1598
+ });
1599
+ }
1600
+ function getModalPositionVariants(position) {
1601
+ switch (position) {
1602
+ case MODAL_POSITIONS.BOTTOM:
1603
+ return BOTTOM_VARIANTS;
1604
+ case MODAL_POSITIONS.RIGHT:
1605
+ return RIGHT_VARIANTS;
1606
+ case MODAL_POSITIONS.LEFT:
1607
+ return LEFT_VARIANTS;
1608
+ case MODAL_POSITIONS.TOP:
1609
+ return TOP_VARIANTS;
1610
+ case MODAL_POSITIONS.CENTER:
1611
+ default:
1612
+ return CENTER_VARIANTS;
1613
+ }
1614
+ }
1615
+ function getModalTransition(position) {
1616
+ return position === MODAL_POSITIONS.CENTER ? MODAL_PANEL_SPRING : void 0;
1617
+ }
1618
+ var MODAL_EASINGS, MODAL_TIERS, MODAL_DURATIONS, MODAL_SPRINGS, MODAL_COMPOSITOR_STYLE, MODAL_PANEL_SPRING, MODAL_BACKDROP_TRANSITION, MODAL_BACKDROP_EXIT_TRANSITION, MODAL_SURFACE_ENTER_TRANSITION, MODAL_SURFACE_EXIT_TRANSITION, MODAL_BODY_ENTER_TRANSITION, MODAL_BODY_EXIT_TRANSITION, MODAL_CONTENT_VARIANTS, MODAL_HEADER_VARIANTS, MODAL_FOOTER_VARIANTS, modalBackdropVariants, CENTER_VARIANTS, BOTTOM_VARIANTS, RIGHT_VARIANTS, LEFT_VARIANTS, TOP_VARIANTS;
1619
+ var init_motion2 = __esm({
1620
+ "src/modules/modal/motion.ts"() {
1621
+ init_tokens2();
1622
+ init_constants2();
1623
+ MODAL_EASINGS = Object.freeze({
1624
+ CINEMATIC: EASING_CURVES.OUT_EXPO,
1625
+ EMPHASIZED: EASING_CURVES.OUT_EXPO,
1626
+ EXIT: EASING_CURVES.IN_CUBIC,
1627
+ FLUID: EASING_CURVES.OUT_QUART,
1628
+ FLUID_RESIZE: EASING_CURVES.OUT_QUART,
1629
+ PROGRESSIVE_EXIT: EASING_CURVES.IN_CUBIC,
1630
+ SOFT: EASING_CURVES.OUT_QUART,
1631
+ SOFT_EXIT: EASING_CURVES.IN_CUBIC
1632
+ });
1633
+ MODAL_TIERS = MOTION_TIERS;
1634
+ MODAL_DURATIONS = Object.freeze({
1635
+ BACKDROP_EXIT: DURATION_TOKENS.FAST,
1636
+ BODY: DURATION_TOKENS.BASE,
1637
+ BODY_EXIT: DURATION_TOKENS.FAST,
1638
+ EDGE_EXIT: DURATION_TOKENS.FAST,
1639
+ FAST: DURATION_TOKENS.FAST,
1640
+ MODERATE: DURATION_TOKENS.MODERATE,
1641
+ SLOT: DURATION_TOKENS.BASE,
1642
+ SLOT_EXIT: DURATION_TOKENS.MICRO,
1643
+ SLOW: DURATION_TOKENS.SLOW
1644
+ });
1645
+ MODAL_SPRINGS = Object.freeze({
1646
+ DECK: Object.freeze({
1647
+ damping: 28,
1648
+ mass: 0.85,
1649
+ stiffness: 240,
1650
+ type: "spring"
1651
+ }),
1652
+ MICRO: Object.freeze({
1653
+ damping: 32,
1654
+ mass: 0.3,
1655
+ stiffness: 480,
1656
+ type: "spring"
1657
+ }),
1658
+ PANEL: Object.freeze({
1659
+ damping: 28,
1660
+ mass: 0.85,
1661
+ stiffness: 240,
1662
+ type: "spring"
1663
+ })
1664
+ });
1665
+ MODAL_COMPOSITOR_STYLE = Object.freeze({
1666
+ WebkitBackfaceVisibility: "hidden",
1667
+ WebkitFontSmoothing: "antialiased",
1668
+ backfaceVisibility: "hidden",
1669
+ transform: "translateZ(0)",
1670
+ willChange: "transform, opacity"
1671
+ });
1672
+ MODAL_PANEL_SPRING = MODAL_SPRINGS.PANEL;
1673
+ MODAL_BACKDROP_TRANSITION = Object.freeze({
1674
+ duration: MODAL_DURATIONS.SLOW,
1675
+ ease: MODAL_EASINGS.FLUID,
1676
+ type: "tween"
1677
+ });
1678
+ MODAL_BACKDROP_EXIT_TRANSITION = Object.freeze({
1679
+ duration: MODAL_DURATIONS.BACKDROP_EXIT,
1680
+ ease: MODAL_EASINGS.FLUID,
1681
+ type: "tween"
1682
+ });
1683
+ MODAL_SURFACE_ENTER_TRANSITION = Object.freeze({
1684
+ duration: MODAL_DURATIONS.SLOW,
1685
+ ease: MODAL_EASINGS.FLUID,
1686
+ type: "tween"
1687
+ });
1688
+ MODAL_SURFACE_EXIT_TRANSITION = Object.freeze({
1689
+ duration: MODAL_DURATIONS.EDGE_EXIT,
1690
+ ease: MODAL_EASINGS.EXIT,
1691
+ type: "tween"
1692
+ });
1693
+ MODAL_BODY_ENTER_TRANSITION = Object.freeze({
1694
+ delay: 0.04,
1695
+ duration: MODAL_DURATIONS.BODY,
1696
+ ease: MODAL_EASINGS.FLUID,
1697
+ type: "tween"
1698
+ });
1699
+ MODAL_BODY_EXIT_TRANSITION = Object.freeze({
1700
+ duration: MODAL_DURATIONS.BODY_EXIT,
1701
+ ease: MODAL_EASINGS.EXIT,
1702
+ type: "tween"
1703
+ });
1704
+ MODAL_CONTENT_VARIANTS = Object.freeze({
1705
+ exit: {
1706
+ opacity: 0,
1707
+ transform: toGpuTransform({
1708
+ scale: 0.98,
1709
+ y: 12
1710
+ }),
1711
+ transition: MODAL_BODY_EXIT_TRANSITION
1712
+ },
1713
+ hidden: {
1714
+ opacity: 0,
1715
+ transform: toGpuTransform({
1716
+ scale: 0.98,
1717
+ y: 12
1718
+ })
1719
+ },
1720
+ visible: {
1721
+ opacity: 1,
1722
+ transform: toGpuTransform(),
1723
+ transition: MODAL_BODY_ENTER_TRANSITION
1724
+ }
1725
+ });
1726
+ MODAL_HEADER_VARIANTS = Object.freeze({
1727
+ exit: {
1728
+ opacity: 0,
1729
+ transform: toGpuTransform({
1730
+ scale: 0.99,
1731
+ y: -6
1732
+ }),
1733
+ transition: {
1734
+ duration: MODAL_DURATIONS.SLOT_EXIT,
1735
+ ease: MODAL_EASINGS.EXIT
1736
+ }
1737
+ },
1738
+ hidden: {
1739
+ opacity: 0,
1740
+ transform: toGpuTransform({
1741
+ scale: 0.99,
1742
+ y: -6
1743
+ })
1744
+ },
1745
+ visible: {
1746
+ opacity: 1,
1747
+ transform: toGpuTransform(),
1748
+ transition: {
1749
+ delay: 0.02,
1750
+ duration: MODAL_DURATIONS.SLOT,
1751
+ ease: MODAL_EASINGS.FLUID
1752
+ }
1753
+ }
1754
+ });
1755
+ MODAL_FOOTER_VARIANTS = Object.freeze({
1756
+ exit: {
1757
+ opacity: 0,
1758
+ transform: toGpuTransform({
1759
+ scale: 0.99,
1760
+ y: 6
1761
+ }),
1762
+ transition: {
1763
+ duration: MODAL_DURATIONS.SLOT_EXIT,
1764
+ ease: MODAL_EASINGS.EXIT
1765
+ }
1766
+ },
1767
+ hidden: {
1768
+ opacity: 0,
1769
+ transform: toGpuTransform({
1770
+ scale: 0.99,
1771
+ y: 6
1772
+ })
1773
+ },
1774
+ visible: {
1775
+ opacity: 1,
1776
+ transform: toGpuTransform(),
1777
+ transition: {
1778
+ delay: 0.06,
1779
+ duration: MODAL_DURATIONS.SLOT,
1780
+ ease: MODAL_EASINGS.FLUID
1781
+ }
1782
+ }
1783
+ });
1784
+ modalBackdropVariants = Object.freeze({
1785
+ exit: {
1786
+ opacity: 0,
1787
+ transition: MODAL_BACKDROP_EXIT_TRANSITION
1788
+ },
1789
+ hidden: {
1790
+ opacity: 0
1791
+ },
1792
+ visible: {
1793
+ opacity: 1,
1794
+ transition: MODAL_BACKDROP_TRANSITION
1795
+ }
1796
+ });
1797
+ CENTER_VARIANTS = Object.freeze({
1798
+ exit: {
1799
+ opacity: 0,
1800
+ transform: toGpuTransform({
1801
+ scale: 0.96,
1802
+ y: 8
1803
+ }),
1804
+ transition: {
1805
+ duration: MODAL_DURATIONS.FAST,
1806
+ ease: MODAL_EASINGS.EXIT
1807
+ }
1808
+ },
1809
+ hidden: {
1810
+ opacity: 0,
1811
+ transform: toGpuTransform({
1812
+ scale: 0.95,
1813
+ y: 12
1814
+ })
1815
+ },
1816
+ visible: {
1817
+ opacity: 1,
1818
+ transform: toGpuTransform(),
1819
+ transition: {
1820
+ duration: MODAL_TIERS.STANDARD.duration,
1821
+ ease: MODAL_EASINGS.FLUID
1822
+ }
1823
+ }
1824
+ });
1825
+ BOTTOM_VARIANTS = buildVariants("SURFACE", {
1826
+ axis: "y",
1827
+ fullSlide: true
1828
+ });
1829
+ RIGHT_VARIANTS = buildVariants("SURFACE", {
1830
+ axis: "x",
1831
+ fullSlide: true
1832
+ });
1833
+ LEFT_VARIANTS = buildVariants("SURFACE", {
1834
+ axis: "x",
1835
+ direction: -1,
1836
+ fullSlide: true
1837
+ });
1838
+ TOP_VARIANTS = buildVariants("SURFACE", {
1839
+ axis: "y",
1840
+ direction: -1,
1841
+ fullSlide: true
1842
+ });
1843
+ }
1844
+ });
1845
+ function getModalIdentity(input) {
1846
+ if (typeof input === "string") return { component: null, type: input };
1847
+ const options = typeof input === "function" ? { component: input } : input;
1848
+ const component = options.component ?? null;
1849
+ return {
1850
+ component,
1851
+ type: "type" in options && options.type || "id" in options && options.id || component?.displayName || component?.name || "modal"
1852
+ };
1853
+ }
1854
+ function hasHeightConstraint(className) {
1855
+ return typeof className === "string" && HEIGHT_CONSTRAINT_PATTERN.test(className);
1856
+ }
1857
+ function isSidePosition(position) {
1858
+ return position === MODAL_POSITIONS.LEFT || position === MODAL_POSITIONS.RIGHT;
1859
+ }
1860
+ function isVerticalEdgePosition(position) {
1861
+ return position === MODAL_POSITIONS.TOP || position === MODAL_POSITIONS.BOTTOM;
1862
+ }
1863
+ function hasSlotContent(value) {
1864
+ return value !== null && value !== void 0 && value !== false && value !== "";
1865
+ }
1866
+ function isHeaderConfig(value) {
1867
+ return Boolean(
1868
+ value && typeof value === "object" && !Array.isArray(value) && !isValidElement(value)
1869
+ );
1870
+ }
1871
+ function resolveHeaderActions(actions, close) {
1872
+ return typeof actions === "function" ? actions({ close }) : actions || null;
1873
+ }
1874
+ function getModalPosition(position) {
1875
+ return position === MODAL_POSITIONS.TOP || position === MODAL_POSITIONS.BOTTOM || position === MODAL_POSITIONS.LEFT || position === MODAL_POSITIONS.RIGHT ? position : MODAL_POSITIONS.CENTER;
1876
+ }
1877
+ function getModalLayout(position, isMobile) {
1878
+ const resolved = getModalPosition(position);
1879
+ if (!isMobile) return resolved;
1880
+ if (resolved === MODAL_POSITIONS.TOP || resolved === MODAL_POSITIONS.BOTTOM)
1881
+ return `${resolved}-mobile`;
1882
+ if (resolved === MODAL_POSITIONS.LEFT || resolved === MODAL_POSITIONS.RIGHT)
1883
+ return "side-mobile";
1884
+ return resolved;
1885
+ }
1886
+ function dispatchSmoothScrollLock(locked) {
1887
+ if (typeof window === "undefined") return;
1888
+ window.dispatchEvent(
1889
+ new CustomEvent(SMOOTH_SCROLL_LOCK_EVENT, {
1890
+ detail: { locked, source: "modal" }
1891
+ })
1892
+ );
1893
+ }
1894
+ function getViewportIsMobile() {
1895
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
1896
+ return false;
1897
+ }
1898
+ return window.matchMedia(
1899
+ `(max-width: ${MODAL_BREAKPOINTS.MOBILE_MAX_WIDTH}px)`
1900
+ ).matches;
1901
+ }
1902
+ function resolveActivePosition(position, responsivePosition, isMobileViewport) {
1903
+ if (!isPlainObject(responsivePosition)) return position;
1904
+ const responsive = isMobileViewport ? responsivePosition.mobile : responsivePosition.desktop;
1905
+ return responsive || position;
1906
+ }
1907
+ function normalizePosition(input) {
1908
+ if (typeof input === "string") {
1909
+ return { position: input, responsivePosition: null };
1910
+ }
1911
+ if (!isPlainObject(input)) {
1912
+ return { position: MODAL_POSITIONS.CENTER, responsivePosition: null };
1913
+ }
1914
+ return {
1915
+ position: resolveActivePosition(
1916
+ MODAL_POSITIONS.CENTER,
1917
+ input,
1918
+ getViewportIsMobile()
1919
+ ),
1920
+ responsivePosition: input
1921
+ };
1922
+ }
1923
+ function getFocusableElements(container) {
1924
+ if (!container || typeof container.querySelectorAll !== "function") return [];
1925
+ return Array.from(
1926
+ container.querySelectorAll(FOCUSABLE_SELECTOR)
1927
+ ).filter(
1928
+ (element) => !element.hasAttribute("disabled") && element.getAttribute("aria-hidden") !== "true"
1929
+ );
1930
+ }
1931
+ function trapFocus(event, container) {
1932
+ if (event.key !== "Tab" || !container) return;
1933
+ const elements = getFocusableElements(container);
1934
+ if (elements.length === 0) return;
1935
+ const firstElement = elements[0];
1936
+ const lastElement = elements[elements.length - 1];
1937
+ if (event.shiftKey) {
1938
+ if (document.activeElement === firstElement) {
1939
+ event.preventDefault();
1940
+ lastElement?.focus();
1941
+ }
1942
+ } else {
1943
+ if (document.activeElement === lastElement) {
1944
+ event.preventDefault();
1945
+ firstElement?.focus();
1946
+ }
1947
+ }
1948
+ }
1949
+ function getModalLabel(modalType) {
1950
+ if (typeof modalType !== "string" || !modalType.trim()) return "Modal";
1951
+ return modalType.trim().toLowerCase().split(/[_-]+/).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join(" ");
1952
+ }
1953
+ var init_utils3 = __esm({
1954
+ "src/modules/modal/utils.ts"() {
1955
+ init_utils();
1956
+ init_constants2();
1957
+ }
1958
+ });
1959
+
1960
+ // src/modules/modal/state.ts
1961
+ function createModalState(modalStack = []) {
1962
+ const activeModal = modalStack[modalStack.length - 1] || null;
1963
+ return {
1964
+ activeModalId: activeModal?.id || null,
1965
+ chrome: activeModal?.chrome || MODAL_CHROME.PANEL,
1966
+ headerActions: activeModal?.headerActions || null,
1967
+ isOpen: modalStack.length > 0,
1968
+ modalStack,
1969
+ modalType: activeModal?.modalType || null,
1970
+ position: activeModal?.position || MODAL_POSITIONS.CENTER,
1971
+ props: activeModal?.props || {},
1972
+ responsivePosition: activeModal?.responsivePosition || null,
1973
+ showClose: activeModal?.showClose ?? true,
1974
+ title: activeModal?.title || null
1975
+ };
1976
+ }
1977
+ var INITIAL_MODAL_STATE;
1978
+ var init_state = __esm({
1979
+ "src/modules/modal/state.ts"() {
1980
+ init_constants2();
1981
+ INITIAL_MODAL_STATE = createModalState([]);
1982
+ }
1983
+ });
1984
+ function useModalRegistration(config, options) {
1985
+ useModuleRegistration("modal", config, options);
1986
+ }
1987
+ function useModalRegistryEntries() {
1988
+ const entries = useRegistryEntries("modal");
1989
+ return useMemo(() => ({ get: (type) => entries[type] }), [entries]);
1990
+ }
1991
+ function ModalProvider({
1992
+ children,
1993
+ modalRenderer: ModalRenderer = null
1994
+ }) {
1995
+ const [store] = useState(
1996
+ () => createStore(INITIAL_MODAL_STATE, { freezeSnapshots: false })
1997
+ );
1998
+ const modalStackRef = useRef([]);
1999
+ const pendingRef = useRef(/* @__PURE__ */ new Map());
2000
+ const modalIdRef = useRef(0);
2001
+ const syncModalStack = useCallback(
2002
+ (nextStack) => {
2003
+ modalStackRef.current = nextStack;
2004
+ store.publish(createModalState(nextStack));
2005
+ },
2006
+ [store]
2007
+ );
2008
+ const settleModal = useCallback((modalId, result) => {
2009
+ const pending = pendingRef.current.get(modalId);
2010
+ if (!pending) return;
2011
+ pendingRef.current.delete(modalId);
2012
+ try {
2013
+ const outcome = pending.onClose?.(result);
2014
+ if (outcome instanceof Promise) {
2015
+ outcome.catch((error) => report("Modal onClose", error));
2016
+ }
2017
+ } catch (error) {
2018
+ report("Modal onClose", error);
2019
+ }
2020
+ pending.resolve(result);
2021
+ }, []);
2022
+ const openModal = useCallback(
2023
+ (modalInput, options = {}) => {
2024
+ if (!modalInput) return Promise.resolve(null);
2025
+ const stack = modalStackRef.current;
2026
+ const { component, type } = getModalIdentity(modalInput);
2027
+ const topEntry = stack[stack.length - 1];
2028
+ if (topEntry && (topEntry.modalType === type || component && topEntry.component === component)) {
2029
+ return Promise.resolve(null);
2030
+ }
2031
+ const definition = typeof modalInput === "object" ? modalInput : void 0;
2032
+ const merged = {
2033
+ ...definition,
2034
+ ...options
2035
+ };
2036
+ const data = { ...definition?.defaultData, ...options.data };
2037
+ const modalId = ++modalIdRef.current;
2038
+ const entry = {
2039
+ chrome: merged.chrome || MODAL_CHROME.PANEL,
2040
+ component,
2041
+ headerActions: merged.actions || null,
2042
+ id: modalId,
2043
+ modalType: type,
2044
+ props: data,
2045
+ showClose: merged.showClose ?? true,
2046
+ title: typeof merged.title === "function" ? merged.title(data) : merged.title ?? null,
2047
+ ...normalizePosition(merged.position)
2048
+ };
2049
+ return new Promise((resolve) => {
2050
+ pendingRef.current.set(modalId, { onClose: merged.onClose, resolve });
2051
+ syncModalStack([...stack, entry]);
2052
+ });
2053
+ },
2054
+ [syncModalStack]
2055
+ );
2056
+ const closeModal = useCallback(
2057
+ (result = null, targetModalId = null) => {
2058
+ const stack = modalStackRef.current;
2059
+ const modalId = targetModalId || stack[stack.length - 1]?.id;
2060
+ if (!modalId || !stack.some((entry) => entry.id === modalId)) return;
2061
+ syncModalStack(stack.filter((entry) => entry.id !== modalId));
2062
+ settleModal(modalId, result);
2063
+ },
2064
+ [settleModal, syncModalStack]
2065
+ );
2066
+ const closeAllModals = useCallback(
2067
+ (result = null) => {
2068
+ const stack = modalStackRef.current;
2069
+ if (stack.length === 0) return;
2070
+ syncModalStack([]);
2071
+ stack.forEach((entry) => settleModal(entry.id, result));
2072
+ },
2073
+ [settleModal, syncModalStack]
2074
+ );
2075
+ const actionsValue = useMemo(
2076
+ () => ({ closeAllModals, closeModal, openModal }),
2077
+ [openModal, closeModal, closeAllModals]
2078
+ );
2079
+ const contextValue = useMemo(
2080
+ () => ({ actions: actionsValue, store }),
2081
+ [actionsValue, store]
2082
+ );
2083
+ return /* @__PURE__ */ jsxs(ModalContext, { value: contextValue, children: [
2084
+ ModalRenderer && /* @__PURE__ */ jsx(ModalRenderer, {}),
2085
+ children
2086
+ ] });
2087
+ }
2088
+ function useModalActions() {
2089
+ return useRequiredContext(ModalContext, "useModalActions", "ModalProvider").actions;
2090
+ }
2091
+ function useModalState() {
2092
+ const { store } = useRequiredContext(
2093
+ ModalContext,
2094
+ "useModalState",
2095
+ "ModalProvider"
2096
+ );
2097
+ return useStore(store);
2098
+ }
2099
+ function useModal(modalInput) {
2100
+ const actions = useModalActions();
2101
+ const state = useModalState();
2102
+ return useMemo(() => {
2103
+ if (!modalInput) return { ...actions, ...state };
2104
+ const { component, type } = getModalIdentity(modalInput);
2105
+ const isOpen = state.modalStack.some(
2106
+ (entry) => entry.modalType === type || component && entry.component === component
2107
+ );
2108
+ const open = (data, overrides) => actions.openModal(modalInput, { ...overrides, data });
2109
+ const controls = {
2110
+ close: actions.closeModal,
2111
+ closeAll: actions.closeAllModals,
2112
+ isOpen,
2113
+ state
2114
+ };
2115
+ return Object.assign([open, controls], controls, { open });
2116
+ }, [actions, modalInput, state]);
2117
+ }
2118
+ var ModalContext;
2119
+ var init_context = __esm({
2120
+ "src/modules/modal/context.tsx"() {
2121
+ "use client";
2122
+ init_hooks();
2123
+ init_kernel();
2124
+ init_utils();
2125
+ init_constants2();
2126
+ init_state();
2127
+ init_utils3();
2128
+ init_utils();
2129
+ init_context_registry();
2130
+ ModalContext = getOrCreateGlobalContext(
2131
+ "ModalContext",
2132
+ null
2133
+ );
2134
+ }
2135
+ });
2136
+ function useModalLayerModel({
2137
+ closeModal,
2138
+ entry,
2139
+ isMobileViewport,
2140
+ isTopModal,
2141
+ modalStack,
2142
+ registry,
2143
+ stackIndex
2144
+ }) {
2145
+ const modalRef = useRef(null);
2146
+ const activePosition = useMemo(
2147
+ () => resolveActivePosition(
2148
+ entry.position,
2149
+ entry.responsivePosition,
2150
+ isMobileViewport
2151
+ ),
2152
+ [entry.position, entry.responsivePosition, isMobileViewport]
2153
+ );
2154
+ const ActiveModalComponent = entry.component || registry.get(entry.modalType);
2155
+ const isPanelChrome = entry.chrome !== MODAL_CHROME.BARE;
2156
+ const isLeftModal = activePosition === MODAL_POSITIONS.LEFT;
2157
+ const isSide = isSidePosition(activePosition);
2158
+ const isVerticalEdge = isVerticalEdgePosition(activePosition);
2159
+ const previousEntry = modalStack[stackIndex - 1] || null;
2160
+ const baseZIndex = Z_INDEX.MODAL;
2161
+ useEffect(() => {
2162
+ if (!isTopModal || !modalRef.current) return;
2163
+ const previouslyFocusedElement = document.activeElement;
2164
+ const initialElements = getFocusableElements(modalRef.current);
2165
+ if (initialElements.length > 0) initialElements[0].focus();
2166
+ const handleKeyDown = (event) => {
2167
+ if (event.key === "Escape") closeModal(null, entry.id);
2168
+ else trapFocus(event, modalRef.current);
2169
+ };
2170
+ window.addEventListener("keydown", handleKeyDown);
2171
+ return () => {
2172
+ window.removeEventListener("keydown", handleKeyDown);
2173
+ if (previouslyFocusedElement?.isConnected)
2174
+ previouslyFocusedElement.focus();
2175
+ };
2176
+ }, [closeModal, entry.id, isTopModal]);
2177
+ return {
2178
+ modalRef,
2179
+ activePosition,
2180
+ ActiveModalComponent,
2181
+ isPanelChrome,
2182
+ isLeftModal,
2183
+ isSide,
2184
+ isVerticalEdge,
2185
+ previousEntry,
2186
+ baseZIndex
2187
+ };
2188
+ }
2189
+ function useModalContainerModel() {
2190
+ return { theme: useTheme(modalTheme) };
2191
+ }
2192
+ function useModalModel() {
2193
+ const { modalStack = [], isOpen, closeModal } = useModal();
2194
+ const registry = useModalRegistryEntries();
2195
+ const visibleModalStack = useMemo(
2196
+ () => modalStack.filter(
2197
+ (entry) => Boolean(entry.component || registry.get(entry.modalType))
2198
+ ),
2199
+ [modalStack, registry]
2200
+ );
2201
+ const topModalEntry = visibleModalStack[visibleModalStack.length - 1] || null;
2202
+ const isModalVisible = Boolean(isOpen && topModalEntry);
2203
+ const mounted = useSyncExternalStore(
2204
+ emptySubscribe,
2205
+ () => true,
2206
+ () => false
2207
+ );
2208
+ const [isMobileViewport, setIsMobileViewport] = useState(getViewportIsMobile);
2209
+ const [isTopExitSettling, setIsTopExitSettling] = useState(false);
2210
+ const previousTopModalIdRef = useRef(null);
2211
+ const releaseScrollLockRef = useRef(null);
2212
+ useLayoutEffect(() => {
2213
+ const currentTopModalId = topModalEntry?.id || null;
2214
+ const previousTopModalId = previousTopModalIdRef.current;
2215
+ const previousTopStillMounted = visibleModalStack.some(
2216
+ (entry) => entry.id === previousTopModalId
2217
+ );
2218
+ if (previousTopModalId && previousTopModalId !== currentTopModalId && !previousTopStillMounted) {
2219
+ setIsTopExitSettling(true);
2220
+ }
2221
+ previousTopModalIdRef.current = currentTopModalId;
2222
+ }, [topModalEntry?.id, visibleModalStack]);
2223
+ useEffect(() => {
2224
+ if (typeof window === "undefined" || !window.matchMedia) return;
2225
+ const mediaQuery = window.matchMedia(
2226
+ `(max-width: ${MODAL_BREAKPOINTS.MOBILE_MAX_WIDTH}px)`
2227
+ );
2228
+ const handleViewportChange = (e) => setIsMobileViewport(e.matches);
2229
+ mediaQuery.addEventListener("change", handleViewportChange);
2230
+ return () => mediaQuery.removeEventListener("change", handleViewportChange);
2231
+ }, []);
2232
+ useEffect(() => {
2233
+ if (typeof document === "undefined") return;
2234
+ if (isModalVisible) {
2235
+ releaseScrollLockRef.current ??= acquireGlobalScrollLock();
2236
+ } else if (releaseScrollLockRef.current) {
2237
+ releaseScrollLockRef.current();
2238
+ releaseScrollLockRef.current = null;
2239
+ }
2240
+ dispatchSmoothScrollLock(isModalVisible);
2241
+ }, [isModalVisible]);
2242
+ useEffect(() => {
2243
+ return () => {
2244
+ releaseScrollLockRef.current?.();
2245
+ releaseScrollLockRef.current = null;
2246
+ dispatchSmoothScrollLock(false);
2247
+ };
2248
+ }, []);
2249
+ return {
2250
+ modalStack,
2251
+ closeModal,
2252
+ registry,
2253
+ visibleModalStack,
2254
+ topModalEntry,
2255
+ isModalVisible,
2256
+ mounted,
2257
+ isMobileViewport,
2258
+ isTopExitSettling,
2259
+ setIsTopExitSettling,
2260
+ theme: useTheme(modalTheme)
2261
+ };
2262
+ }
2263
+ var emptySubscribe;
2264
+ var init_hooks3 = __esm({
2265
+ "src/modules/modal/hooks.ts"() {
2266
+ "use client";
2267
+ init_tokens2();
2268
+ init_utils();
2269
+ init_theme2();
2270
+ init_constants2();
2271
+ init_utils3();
2272
+ init_context();
2273
+ emptySubscribe = () => () => {
2274
+ };
2275
+ }
2276
+ });
2277
+
2278
+ // src/modules/modal/overlay.tsx
2279
+ var overlay_exports = {};
2280
+ __export(overlay_exports, {
2281
+ Modal: () => Modal,
2282
+ ModalContainer: () => ModalContainer
2283
+ });
2284
+ function CloseButton({
2285
+ close,
2286
+ theme
2287
+ }) {
2288
+ if (typeof close !== "function") return null;
2289
+ return /* @__PURE__ */ jsx(
2290
+ Button,
2291
+ {
2292
+ type: "button",
2293
+ "aria-label": "Close modal",
2294
+ onClick: close,
2295
+ className: theme.slots.closeButton,
2296
+ children: /* @__PURE__ */ jsx(Icon, { icon: "solar:close-bold", size: 16 })
2297
+ }
2298
+ );
2299
+ }
2300
+ function SlotRow({
2301
+ center,
2302
+ left,
2303
+ right,
2304
+ sticky,
2305
+ theme,
2306
+ variants
2307
+ }) {
2308
+ const hasCenter = hasSlotContent(center);
2309
+ return /* @__PURE__ */ jsxs(
2310
+ motion.div,
2311
+ {
2312
+ variants,
2313
+ initial: "hidden",
2314
+ animate: "visible",
2315
+ "data-columns": hasCenter ? 3 : 2,
2316
+ "data-sticky": sticky,
2317
+ className: theme.slots.row,
2318
+ style: sticky ? theme.styles.row : void 0,
2319
+ children: [
2320
+ /* @__PURE__ */ jsx("div", { className: theme.slots.rowStart, children: left }),
2321
+ hasCenter && /* @__PURE__ */ jsx("div", { className: theme.slots.rowCenter, children: center }),
2322
+ /* @__PURE__ */ jsx("div", { className: theme.slots.rowEnd, children: right })
2323
+ ]
2324
+ }
2325
+ );
2326
+ }
2327
+ function resolveHeader(header, close, theme) {
2328
+ const config = isHeaderConfig(header) ? header : {};
2329
+ const customNode = typeof header !== "boolean" && !isHeaderConfig(header) && hasSlotContent(header) ? header : null;
2330
+ const actions = resolveHeaderActions(config.actions, close);
2331
+ const showClose = config.showClose === true;
2332
+ const left = customNode !== null ? null : config.left ?? (config.title ? /* @__PURE__ */ jsx("h2", { id: config.titleId, className: theme.slots.title, children: config.title }) : null);
2333
+ const right = customNode !== null ? null : config.right ?? (hasSlotContent(actions) || showClose ? /* @__PURE__ */ jsxs(Fragment, { children: [
2334
+ actions,
2335
+ showClose && /* @__PURE__ */ jsx(CloseButton, { close, theme })
2336
+ ] }) : null);
2337
+ return { center: customNode ?? config.center ?? null, config, left, right };
2338
+ }
2339
+ function ModalContainer({
2340
+ bodyClassName,
2341
+ children,
2342
+ className,
2343
+ close,
2344
+ footer,
2345
+ header = {},
2346
+ position = null
2347
+ }) {
2348
+ const { theme } = useModalContainerModel();
2349
+ const headerRow = header === false ? null : resolveHeader(header, close, theme);
2350
+ const shouldRenderHeader = headerRow && [headerRow.left, headerRow.center, headerRow.right].some(hasSlotContent);
2351
+ const footerConfig = footer && typeof footer === "object" ? footer : {};
2352
+ const {
2353
+ center: footerCenter = null,
2354
+ left: footerLeft = null,
2355
+ right: footerRight = null
2356
+ } = footerConfig;
2357
+ const shouldRenderFooter = footer !== false && [footerLeft, footerCenter, footerRight].some(hasSlotContent);
2358
+ const resolvedPosition = position || headerRow?.config.position || null;
2359
+ return /* @__PURE__ */ jsxs(
2360
+ "div",
2361
+ {
2362
+ "data-height": isSidePosition(resolvedPosition) ? "full" : hasHeightConstraint(className) ? void 0 : "capped",
2363
+ className: cn(theme.slots.content, className),
2364
+ children: [
2365
+ shouldRenderHeader && /* @__PURE__ */ jsx(
2366
+ SlotRow,
2367
+ {
2368
+ variants: MODAL_HEADER_VARIANTS,
2369
+ left: headerRow.left,
2370
+ center: headerRow.center,
2371
+ right: headerRow.right,
2372
+ theme,
2373
+ sticky: headerRow.config.sticky ? "top" : void 0
2374
+ }
2375
+ ),
2376
+ /* @__PURE__ */ jsx(
2377
+ motion.div,
2378
+ {
2379
+ variants: MODAL_CONTENT_VARIANTS,
2380
+ initial: "hidden",
2381
+ animate: "visible",
2382
+ "data-lenis-prevent": true,
2383
+ "data-lenis-prevent-wheel": true,
2384
+ className: cn(theme.slots.body, bodyClassName),
2385
+ children
2386
+ }
2387
+ ),
2388
+ shouldRenderFooter && /* @__PURE__ */ jsx(
2389
+ SlotRow,
2390
+ {
2391
+ variants: MODAL_FOOTER_VARIANTS,
2392
+ left: footerLeft,
2393
+ center: footerCenter,
2394
+ right: footerRight,
2395
+ theme,
2396
+ sticky: footerConfig.sticky ? "bottom" : void 0
2397
+ }
2398
+ )
2399
+ ]
2400
+ }
2401
+ );
2402
+ }
2403
+ function ModalLayerSwitcher({
2404
+ currentEntry,
2405
+ onSwitchToPrevious,
2406
+ previousEntry,
2407
+ theme
2408
+ }) {
2409
+ return /* @__PURE__ */ jsxs("div", { className: theme.slots.switcher, children: [
2410
+ /* @__PURE__ */ jsxs(
2411
+ Button,
2412
+ {
2413
+ type: "button",
2414
+ onClick: onSwitchToPrevious,
2415
+ className: theme.slots.switcherButton,
2416
+ children: [
2417
+ /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ jsx(
2418
+ "path",
2419
+ {
2420
+ d: "M7.5 2.5L4 6l3.5 3.5",
2421
+ stroke: "currentColor",
2422
+ strokeWidth: "1.5",
2423
+ strokeLinecap: "round",
2424
+ strokeLinejoin: "round"
2425
+ }
2426
+ ) }),
2427
+ getModalLabel(previousEntry.modalType)
2428
+ ]
2429
+ }
2430
+ ),
2431
+ /* @__PURE__ */ jsx("span", { className: theme.slots.switcherDivider, children: "/" }),
2432
+ /* @__PURE__ */ jsx("span", { className: theme.slots.switcherCurrent, children: getModalLabel(currentEntry.modalType) })
2433
+ ] });
2434
+ }
2435
+ function ModalLayer({
2436
+ closeModal,
2437
+ entry,
2438
+ isMobileViewport,
2439
+ isTopModal,
2440
+ modalStack,
2441
+ registry,
2442
+ stackIndex,
2443
+ theme
2444
+ }) {
2445
+ const {
2446
+ modalRef,
2447
+ activePosition,
2448
+ ActiveModalComponent,
2449
+ isPanelChrome,
2450
+ previousEntry,
2451
+ baseZIndex
2452
+ } = useModalLayerModel({
2453
+ closeModal,
2454
+ entry,
2455
+ isMobileViewport,
2456
+ isTopModal,
2457
+ modalStack,
2458
+ registry,
2459
+ stackIndex
2460
+ });
2461
+ if (!ActiveModalComponent) return null;
2462
+ const layout = getModalLayout(activePosition, isMobileViewport);
2463
+ return /* @__PURE__ */ jsx(
2464
+ "div",
2465
+ {
2466
+ role: "dialog",
2467
+ "aria-modal": isTopModal,
2468
+ "aria-labelledby": entry.title ? `modal-title-${entry.id}` : void 0,
2469
+ style: { zIndex: baseZIndex },
2470
+ "data-position": getModalPosition(activePosition),
2471
+ "data-inset": activePosition === MODAL_POSITIONS.CENTER && !isMobileViewport ? true : void 0,
2472
+ className: theme.slots.layer,
2473
+ children: /* @__PURE__ */ jsx(
2474
+ motion.div,
2475
+ {
2476
+ ref: modalRef,
2477
+ variants: getModalPositionVariants(activePosition),
2478
+ initial: "hidden",
2479
+ animate: "visible",
2480
+ exit: "exit",
2481
+ transition: getModalTransition(activePosition),
2482
+ "data-active": isTopModal,
2483
+ "data-layout": layout,
2484
+ className: theme.slots.frame,
2485
+ style: { zIndex: Z_INDEX.MODAL_FRAME, ...MODAL_COMPOSITOR_STYLE },
2486
+ onClick: (e) => e.stopPropagation(),
2487
+ children: /* @__PURE__ */ jsxs(
2488
+ "div",
2489
+ {
2490
+ "data-layout": layout,
2491
+ className: cn(
2492
+ theme.slots.panel,
2493
+ isPanelChrome ? theme.slots.panelChrome : theme.slots.panelBare
2494
+ ),
2495
+ children: [
2496
+ /* @__PURE__ */ jsx(ModuleBoundary, { name: entry.modalType, children: createElement(ActiveModalComponent, {
2497
+ close: (result) => closeModal(result, entry.id),
2498
+ data: entry.props,
2499
+ header: {
2500
+ actions: entry.headerActions,
2501
+ position: activePosition,
2502
+ showClose: entry.showClose,
2503
+ title: entry.title,
2504
+ titleId: `modal-title-${entry.id}`
2505
+ }
2506
+ }) }),
2507
+ !isTopModal && /* @__PURE__ */ jsx(
2508
+ "div",
2509
+ {
2510
+ onClick: (e) => {
2511
+ e.stopPropagation();
2512
+ const topModal = modalStack[modalStack.length - 1];
2513
+ if (topModal) closeModal(null, topModal.id);
2514
+ },
2515
+ className: theme.slots.dim,
2516
+ style: theme.styles.dim,
2517
+ "aria-label": "Close active top modal"
2518
+ }
2519
+ ),
2520
+ isTopModal && stackIndex > 0 && previousEntry && /* @__PURE__ */ jsx(
2521
+ ModalLayerSwitcher,
2522
+ {
2523
+ currentEntry: entry,
2524
+ previousEntry,
2525
+ theme,
2526
+ onSwitchToPrevious: () => closeModal(null, entry.id)
2527
+ }
2528
+ )
2529
+ ]
2530
+ }
2531
+ )
2532
+ }
2533
+ )
2534
+ }
2535
+ );
2536
+ }
2537
+ function Modal() {
2538
+ const {
2539
+ closeModal,
2540
+ registry,
2541
+ visibleModalStack,
2542
+ topModalEntry,
2543
+ isModalVisible,
2544
+ mounted,
2545
+ isMobileViewport,
2546
+ isTopExitSettling,
2547
+ setIsTopExitSettling,
2548
+ theme
2549
+ } = useModalModel();
2550
+ if (!mounted) return null;
2551
+ return createPortal(
2552
+ /* @__PURE__ */ jsxs(Fragment, { children: [
2553
+ /* @__PURE__ */ jsx(AnimatePresence, { children: isModalVisible && /* @__PURE__ */ jsx(
2554
+ motion.div,
2555
+ {
2556
+ variants: modalBackdropVariants,
2557
+ initial: "hidden",
2558
+ animate: "visible",
2559
+ exit: "exit",
2560
+ className: theme.slots.backdrop,
2561
+ style: theme.styles.backdrop,
2562
+ onClick: () => {
2563
+ if (!isTopExitSettling) closeModal(null, topModalEntry.id);
2564
+ }
2565
+ },
2566
+ "global-modal-backdrop"
2567
+ ) }),
2568
+ /* @__PURE__ */ jsx(AnimatePresence, { onExitComplete: () => setIsTopExitSettling(false), children: visibleModalStack.map((entry, index) => /* @__PURE__ */ jsx(
2569
+ ModalLayer,
2570
+ {
2571
+ entry,
2572
+ stackIndex: index,
2573
+ isTopModal: index === visibleModalStack.length - 1 && !isTopExitSettling,
2574
+ isMobileViewport,
2575
+ closeModal,
2576
+ registry,
2577
+ modalStack: visibleModalStack,
2578
+ theme
2579
+ },
2580
+ entry.id
2581
+ )) })
2582
+ ] }),
2583
+ document.body
2584
+ );
2585
+ }
2586
+ var init_overlay = __esm({
2587
+ "src/modules/modal/overlay.tsx"() {
2588
+ "use client";
2589
+ init_atoms();
2590
+ init_tokens2();
2591
+ init_utils();
2592
+ init_kernel();
2593
+ init_constants2();
2594
+ init_motion2();
2595
+ init_utils3();
2596
+ init_hooks3();
2597
+ }
2598
+ });
2599
+
2600
+ // src/modules/modal/index.ts
2601
+ init_overlay();
2602
+ init_overlay();
2603
+ init_context();
2604
+
2605
+ // src/modules/modal/module.tsx
2606
+ init_kernel();
2607
+ init_context();
2608
+ init_utils3();
2609
+ var LazyModal = dynamic(
2610
+ () => Promise.resolve().then(() => (init_overlay(), overlay_exports)).then((view) => view.Modal),
2611
+ {
2612
+ ssr: false
2613
+ }
2614
+ );
2615
+ function selectPageModals(config) {
2616
+ return config.modal ?? null;
2617
+ }
2618
+ function useModalPage(slice, page) {
2619
+ const actions = useModalActions();
2620
+ const sliceRef = useRef(slice);
2621
+ useInsertionEffect(() => {
2622
+ sliceRef.current = slice;
2623
+ }, [slice]);
2624
+ return useMemo(
2625
+ () => ({
2626
+ ...actions,
2627
+ open: (modal, data = {}) => {
2628
+ const own = typeof modal === "string" && modal !== "registry" ? sliceRef.current?.[modal] : void 0;
2629
+ return actions.openModal(own ?? modal, { data });
2630
+ },
2631
+ set: (modal) => page.set({ modal })
2632
+ }),
2633
+ [actions, page]
2634
+ );
2635
+ }
2636
+ var modalModule = defineModule({
2637
+ id: "modal",
2638
+ context: ModalContext,
2639
+ Provider: ModalProvider,
2640
+ Overlay: LazyModal,
2641
+ registry: {
2642
+ cleanupDelayMs: 600,
2643
+ keyPolicy: "named",
2644
+ lifecycle: "immediate",
2645
+ valueKind: "component"
2646
+ },
2647
+ page: {
2648
+ select: selectPageModals,
2649
+ entries: (slice) => Object.entries(slice).map(([key, value]) => ({ key, value })),
2650
+ use: useModalPage
2651
+ }
2652
+ });
2653
+ function defineModal(definition = {}) {
2654
+ const { type } = getModalIdentity(definition);
2655
+ const modalDefinition = Object.freeze({
2656
+ ...definition,
2657
+ id: definition.id || type,
2658
+ isModalDefinition: true,
2659
+ type,
2660
+ use: function useDefinedModal() {
2661
+ return useModal(modalDefinition);
2662
+ }
2663
+ });
2664
+ return modalDefinition;
2665
+ }
2666
+
2667
+ // src/modules/modal/index.ts
2668
+ init_constants2();
2669
+
2670
+ export { MODAL_CHROME, MODAL_POSITIONS, Modal, ModalContainer, ModalContext, ModalProvider, defineModal, modalModule, modalTheme, useModal, useModalActions, useModalRegistration, useModalState };
2671
+ //# sourceMappingURL=index.js.map
2672
+ //# sourceMappingURL=index.js.map