create-nuclo 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (534) hide show
  1. package/README.md +60 -0
  2. package/package.json +35 -0
  3. package/src/create-nuclo.mjs +193 -0
  4. package/templates/basic/README.md +16 -0
  5. package/templates/basic/_gitignore +5 -0
  6. package/templates/basic/index.html +26 -0
  7. package/templates/basic/node_modules/.package-lock.json +348 -0
  8. package/templates/basic/node_modules/.vite/deps/_metadata.json +15 -0
  9. package/templates/basic/node_modules/.vite/deps/nuclo.js +1665 -0
  10. package/templates/basic/node_modules/.vite/deps/nuclo.js.map +1 -0
  11. package/templates/basic/node_modules/.vite/deps/package.json +3 -0
  12. package/templates/basic/node_modules/@oxc-project/types/LICENSE +22 -0
  13. package/templates/basic/node_modules/@oxc-project/types/README.md +3 -0
  14. package/templates/basic/node_modules/@oxc-project/types/package.json +26 -0
  15. package/templates/basic/node_modules/@oxc-project/types/types.d.ts +1912 -0
  16. package/templates/basic/node_modules/@rolldown/binding-darwin-arm64/README.md +3 -0
  17. package/templates/basic/node_modules/@rolldown/binding-darwin-arm64/package.json +37 -0
  18. package/templates/basic/node_modules/@rolldown/binding-darwin-arm64/rolldown-binding.darwin-arm64.node +0 -0
  19. package/templates/basic/node_modules/@rolldown/pluginutils/LICENSE +21 -0
  20. package/templates/basic/node_modules/@rolldown/pluginutils/README.md +145 -0
  21. package/templates/basic/node_modules/@rolldown/pluginutils/dist/filter/index.d.mts +194 -0
  22. package/templates/basic/node_modules/@rolldown/pluginutils/dist/filter/index.mjs +2 -0
  23. package/templates/basic/node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs +323 -0
  24. package/templates/basic/node_modules/@rolldown/pluginutils/dist/index.d.mts +2 -0
  25. package/templates/basic/node_modules/@rolldown/pluginutils/dist/index.mjs +2 -0
  26. package/templates/basic/node_modules/@rolldown/pluginutils/package.json +40 -0
  27. package/templates/basic/node_modules/detect-libc/LICENSE +201 -0
  28. package/templates/basic/node_modules/detect-libc/README.md +163 -0
  29. package/templates/basic/node_modules/detect-libc/index.d.ts +14 -0
  30. package/templates/basic/node_modules/detect-libc/lib/detect-libc.js +313 -0
  31. package/templates/basic/node_modules/detect-libc/lib/elf.js +39 -0
  32. package/templates/basic/node_modules/detect-libc/lib/filesystem.js +51 -0
  33. package/templates/basic/node_modules/detect-libc/lib/process.js +24 -0
  34. package/templates/basic/node_modules/detect-libc/package.json +44 -0
  35. package/templates/basic/node_modules/fdir/LICENSE +7 -0
  36. package/templates/basic/node_modules/fdir/README.md +91 -0
  37. package/templates/basic/node_modules/fdir/dist/index.cjs +588 -0
  38. package/templates/basic/node_modules/fdir/dist/index.d.cts +155 -0
  39. package/templates/basic/node_modules/fdir/dist/index.d.mts +155 -0
  40. package/templates/basic/node_modules/fdir/dist/index.mjs +570 -0
  41. package/templates/basic/node_modules/fdir/package.json +103 -0
  42. package/templates/basic/node_modules/lightningcss/LICENSE +373 -0
  43. package/templates/basic/node_modules/lightningcss/README.md +105 -0
  44. package/templates/basic/node_modules/lightningcss/node/ast.d.ts +9892 -0
  45. package/templates/basic/node_modules/lightningcss/node/ast.js.flow +10539 -0
  46. package/templates/basic/node_modules/lightningcss/node/browserslistToTargets.js +48 -0
  47. package/templates/basic/node_modules/lightningcss/node/composeVisitors.js +450 -0
  48. package/templates/basic/node_modules/lightningcss/node/flags.js +28 -0
  49. package/templates/basic/node_modules/lightningcss/node/index.d.ts +494 -0
  50. package/templates/basic/node_modules/lightningcss/node/index.js +59 -0
  51. package/templates/basic/node_modules/lightningcss/node/index.js.flow +843 -0
  52. package/templates/basic/node_modules/lightningcss/node/index.mjs +4 -0
  53. package/templates/basic/node_modules/lightningcss/node/targets.d.ts +40 -0
  54. package/templates/basic/node_modules/lightningcss/node/targets.js.flow +39 -0
  55. package/templates/basic/node_modules/lightningcss/package.json +110 -0
  56. package/templates/basic/node_modules/lightningcss-darwin-arm64/LICENSE +373 -0
  57. package/templates/basic/node_modules/lightningcss-darwin-arm64/README.md +1 -0
  58. package/templates/basic/node_modules/lightningcss-darwin-arm64/lightningcss.darwin-arm64.node +0 -0
  59. package/templates/basic/node_modules/lightningcss-darwin-arm64/package.json +34 -0
  60. package/templates/basic/node_modules/nanoid/LICENSE +20 -0
  61. package/templates/basic/node_modules/nanoid/README.md +36 -0
  62. package/templates/basic/node_modules/nanoid/async/index.browser.cjs +42 -0
  63. package/templates/basic/node_modules/nanoid/async/index.browser.js +42 -0
  64. package/templates/basic/node_modules/nanoid/async/index.cjs +44 -0
  65. package/templates/basic/node_modules/nanoid/async/index.d.ts +56 -0
  66. package/templates/basic/node_modules/nanoid/async/index.js +44 -0
  67. package/templates/basic/node_modules/nanoid/async/index.native.js +35 -0
  68. package/templates/basic/node_modules/nanoid/async/package.json +12 -0
  69. package/templates/basic/node_modules/nanoid/bin/nanoid.cjs +55 -0
  70. package/templates/basic/node_modules/nanoid/index.browser.cjs +44 -0
  71. package/templates/basic/node_modules/nanoid/index.browser.js +44 -0
  72. package/templates/basic/node_modules/nanoid/index.cjs +57 -0
  73. package/templates/basic/node_modules/nanoid/index.d.cts +91 -0
  74. package/templates/basic/node_modules/nanoid/index.d.ts +91 -0
  75. package/templates/basic/node_modules/nanoid/index.js +62 -0
  76. package/templates/basic/node_modules/nanoid/nanoid.js +1 -0
  77. package/templates/basic/node_modules/nanoid/non-secure/index.cjs +24 -0
  78. package/templates/basic/node_modules/nanoid/non-secure/index.d.ts +33 -0
  79. package/templates/basic/node_modules/nanoid/non-secure/index.js +24 -0
  80. package/templates/basic/node_modules/nanoid/non-secure/package.json +6 -0
  81. package/templates/basic/node_modules/nanoid/package.json +89 -0
  82. package/templates/basic/node_modules/nanoid/url-alphabet/index.cjs +4 -0
  83. package/templates/basic/node_modules/nanoid/url-alphabet/index.js +4 -0
  84. package/templates/basic/node_modules/nanoid/url-alphabet/package.json +6 -0
  85. package/templates/basic/node_modules/nuclo/LICENSE.md +45 -0
  86. package/templates/basic/node_modules/nuclo/README.md +727 -0
  87. package/templates/basic/node_modules/nuclo/dist/bootstrap.d.ts +5 -0
  88. package/templates/basic/node_modules/nuclo/dist/bootstrap.d.ts.map +1 -0
  89. package/templates/basic/node_modules/nuclo/dist/element/attributes.d.ts +3 -0
  90. package/templates/basic/node_modules/nuclo/dist/element/attributes.d.ts.map +1 -0
  91. package/templates/basic/node_modules/nuclo/dist/element/class-name.d.ts +6 -0
  92. package/templates/basic/node_modules/nuclo/dist/element/class-name.d.ts.map +1 -0
  93. package/templates/basic/node_modules/nuclo/dist/element/events.d.ts +35 -0
  94. package/templates/basic/node_modules/nuclo/dist/element/events.d.ts.map +1 -0
  95. package/templates/basic/node_modules/nuclo/dist/element/factory.d.ts +32 -0
  96. package/templates/basic/node_modules/nuclo/dist/element/factory.d.ts.map +1 -0
  97. package/templates/basic/node_modules/nuclo/dist/element/inline-style.d.ts +9 -0
  98. package/templates/basic/node_modules/nuclo/dist/element/inline-style.d.ts.map +1 -0
  99. package/templates/basic/node_modules/nuclo/dist/element/modifiers.d.ts +11 -0
  100. package/templates/basic/node_modules/nuclo/dist/element/modifiers.d.ts.map +1 -0
  101. package/templates/basic/node_modules/nuclo/dist/element/tags.d.ts +5 -0
  102. package/templates/basic/node_modules/nuclo/dist/element/tags.d.ts.map +1 -0
  103. package/templates/basic/node_modules/nuclo/dist/hydration.d.ts +73 -0
  104. package/templates/basic/node_modules/nuclo/dist/hydration.d.ts.map +1 -0
  105. package/templates/basic/node_modules/nuclo/dist/index.d.ts +17 -0
  106. package/templates/basic/node_modules/nuclo/dist/index.d.ts.map +1 -0
  107. package/templates/basic/node_modules/nuclo/dist/list/index.d.ts +7 -0
  108. package/templates/basic/node_modules/nuclo/dist/list/index.d.ts.map +1 -0
  109. package/templates/basic/node_modules/nuclo/dist/list/runtime.d.ts +6 -0
  110. package/templates/basic/node_modules/nuclo/dist/list/runtime.d.ts.map +1 -0
  111. package/templates/basic/node_modules/nuclo/dist/list/types.d.ts +18 -0
  112. package/templates/basic/node_modules/nuclo/dist/list/types.d.ts.map +1 -0
  113. package/templates/basic/node_modules/nuclo/dist/nuclo.cjs +2 -0
  114. package/templates/basic/node_modules/nuclo/dist/nuclo.cjs.map +1 -0
  115. package/templates/basic/node_modules/nuclo/dist/nuclo.mjs +2 -0
  116. package/templates/basic/node_modules/nuclo/dist/nuclo.mjs.map +1 -0
  117. package/templates/basic/node_modules/nuclo/dist/nuclo.umd.js +2 -0
  118. package/templates/basic/node_modules/nuclo/dist/nuclo.umd.js.map +1 -0
  119. package/templates/basic/node_modules/nuclo/dist/polyfill/Document.d.ts +19 -0
  120. package/templates/basic/node_modules/nuclo/dist/polyfill/Document.d.ts.map +1 -0
  121. package/templates/basic/node_modules/nuclo/dist/polyfill/Element.d.ts +48 -0
  122. package/templates/basic/node_modules/nuclo/dist/polyfill/Element.d.ts.map +1 -0
  123. package/templates/basic/node_modules/nuclo/dist/polyfill/Event.d.ts +43 -0
  124. package/templates/basic/node_modules/nuclo/dist/polyfill/Event.d.ts.map +1 -0
  125. package/templates/basic/node_modules/nuclo/dist/polyfill/Node.d.ts +13 -0
  126. package/templates/basic/node_modules/nuclo/dist/polyfill/Node.d.ts.map +1 -0
  127. package/templates/basic/node_modules/nuclo/dist/polyfill/Text.d.ts +11 -0
  128. package/templates/basic/node_modules/nuclo/dist/polyfill/Text.d.ts.map +1 -0
  129. package/templates/basic/node_modules/nuclo/dist/polyfill/index.d.ts +24 -0
  130. package/templates/basic/node_modules/nuclo/dist/polyfill/index.d.ts.map +1 -0
  131. package/templates/basic/node_modules/nuclo/dist/polyfill/nuclo.polyfill.cjs +2 -0
  132. package/templates/basic/node_modules/nuclo/dist/polyfill/nuclo.polyfill.cjs.map +1 -0
  133. package/templates/basic/node_modules/nuclo/dist/polyfill/nuclo.polyfill.mjs +2 -0
  134. package/templates/basic/node_modules/nuclo/dist/polyfill/nuclo.polyfill.mjs.map +1 -0
  135. package/templates/basic/node_modules/nuclo/dist/render.d.ts +33 -0
  136. package/templates/basic/node_modules/nuclo/dist/render.d.ts.map +1 -0
  137. package/templates/basic/node_modules/nuclo/dist/shared/conditions.d.ts +4 -0
  138. package/templates/basic/node_modules/nuclo/dist/shared/conditions.d.ts.map +1 -0
  139. package/templates/basic/node_modules/nuclo/dist/shared/dom.d.ts +69 -0
  140. package/templates/basic/node_modules/nuclo/dist/shared/dom.d.ts.map +1 -0
  141. package/templates/basic/node_modules/nuclo/dist/shared/environment.d.ts +5 -0
  142. package/templates/basic/node_modules/nuclo/dist/shared/environment.d.ts.map +1 -0
  143. package/templates/basic/node_modules/nuclo/dist/shared/errors.d.ts +2 -0
  144. package/templates/basic/node_modules/nuclo/dist/shared/errors.d.ts.map +1 -0
  145. package/templates/basic/node_modules/nuclo/dist/shared/renderables.d.ts +4 -0
  146. package/templates/basic/node_modules/nuclo/dist/shared/renderables.d.ts.map +1 -0
  147. package/templates/basic/node_modules/nuclo/dist/shared/strings.d.ts +19 -0
  148. package/templates/basic/node_modules/nuclo/dist/shared/strings.d.ts.map +1 -0
  149. package/templates/basic/node_modules/nuclo/dist/shared/type-guards.d.ts +16 -0
  150. package/templates/basic/node_modules/nuclo/dist/shared/type-guards.d.ts.map +1 -0
  151. package/templates/basic/node_modules/nuclo/dist/ssr/index.d.ts +19 -0
  152. package/templates/basic/node_modules/nuclo/dist/ssr/index.d.ts.map +1 -0
  153. package/templates/basic/node_modules/nuclo/dist/ssr/nuclo.ssr.cjs +2 -0
  154. package/templates/basic/node_modules/nuclo/dist/ssr/nuclo.ssr.cjs.map +1 -0
  155. package/templates/basic/node_modules/nuclo/dist/ssr/nuclo.ssr.mjs +2 -0
  156. package/templates/basic/node_modules/nuclo/dist/ssr/nuclo.ssr.mjs.map +1 -0
  157. package/templates/basic/node_modules/nuclo/dist/ssr/render-to-string.d.ts +41 -0
  158. package/templates/basic/node_modules/nuclo/dist/ssr/render-to-string.d.ts.map +1 -0
  159. package/templates/basic/node_modules/nuclo/dist/style/css.d.ts +19 -0
  160. package/templates/basic/node_modules/nuclo/dist/style/css.d.ts.map +1 -0
  161. package/templates/basic/node_modules/nuclo/dist/style/engine.d.ts +34 -0
  162. package/templates/basic/node_modules/nuclo/dist/style/engine.d.ts.map +1 -0
  163. package/templates/basic/node_modules/nuclo/dist/style/index.d.ts +3 -0
  164. package/templates/basic/node_modules/nuclo/dist/style/index.d.ts.map +1 -0
  165. package/templates/basic/node_modules/nuclo/dist/update/conditional.d.ts +3 -0
  166. package/templates/basic/node_modules/nuclo/dist/update/conditional.d.ts.map +1 -0
  167. package/templates/basic/node_modules/nuclo/dist/update/reactive-attributes.d.ts +45 -0
  168. package/templates/basic/node_modules/nuclo/dist/update/reactive-attributes.d.ts.map +1 -0
  169. package/templates/basic/node_modules/nuclo/dist/update/reactive-text.d.ts +38 -0
  170. package/templates/basic/node_modules/nuclo/dist/update/reactive-text.d.ts.map +1 -0
  171. package/templates/basic/node_modules/nuclo/dist/update/registry.d.ts +97 -0
  172. package/templates/basic/node_modules/nuclo/dist/update/registry.d.ts.map +1 -0
  173. package/templates/basic/node_modules/nuclo/dist/update/scope.d.ts +7 -0
  174. package/templates/basic/node_modules/nuclo/dist/update/scope.d.ts.map +1 -0
  175. package/templates/basic/node_modules/nuclo/dist/update/update.d.ts +4 -0
  176. package/templates/basic/node_modules/nuclo/dist/update/update.d.ts.map +1 -0
  177. package/templates/basic/node_modules/nuclo/dist/when/builder.d.ts +16 -0
  178. package/templates/basic/node_modules/nuclo/dist/when/builder.d.ts.map +1 -0
  179. package/templates/basic/node_modules/nuclo/dist/when/index.d.ts +44 -0
  180. package/templates/basic/node_modules/nuclo/dist/when/index.d.ts.map +1 -0
  181. package/templates/basic/node_modules/nuclo/dist/when/runtime.d.ts +59 -0
  182. package/templates/basic/node_modules/nuclo/dist/when/runtime.d.ts.map +1 -0
  183. package/templates/basic/node_modules/nuclo/package.json +88 -0
  184. package/templates/basic/node_modules/nuclo/types/core/base.d.ts +113 -0
  185. package/templates/basic/node_modules/nuclo/types/features/list.d.ts +38 -0
  186. package/templates/basic/node_modules/nuclo/types/features/on.d.ts +59 -0
  187. package/templates/basic/node_modules/nuclo/types/features/render.d.ts +49 -0
  188. package/templates/basic/node_modules/nuclo/types/features/scope.d.ts +6 -0
  189. package/templates/basic/node_modules/nuclo/types/features/style.d.ts +77 -0
  190. package/templates/basic/node_modules/nuclo/types/features/update.d.ts +6 -0
  191. package/templates/basic/node_modules/nuclo/types/features/when.d.ts +18 -0
  192. package/templates/basic/node_modules/nuclo/types/html/tags.d.ts +119 -0
  193. package/templates/basic/node_modules/nuclo/types/index.d.ts +137 -0
  194. package/templates/basic/node_modules/nuclo/types/polyfill.d.ts +131 -0
  195. package/templates/basic/node_modules/nuclo/types/ssr.d.ts +45 -0
  196. package/templates/basic/node_modules/nuclo/types/style.d.ts +404 -0
  197. package/templates/basic/node_modules/nuclo/types/svg/base.d.ts +118 -0
  198. package/templates/basic/node_modules/nuclo/types/svg/tags.d.ts +68 -0
  199. package/templates/basic/node_modules/picocolors/LICENSE +15 -0
  200. package/templates/basic/node_modules/picocolors/README.md +21 -0
  201. package/templates/basic/node_modules/picocolors/package.json +25 -0
  202. package/templates/basic/node_modules/picocolors/picocolors.browser.js +4 -0
  203. package/templates/basic/node_modules/picocolors/picocolors.d.ts +5 -0
  204. package/templates/basic/node_modules/picocolors/picocolors.js +75 -0
  205. package/templates/basic/node_modules/picocolors/types.d.ts +51 -0
  206. package/templates/basic/node_modules/picomatch/LICENSE +21 -0
  207. package/templates/basic/node_modules/picomatch/README.md +743 -0
  208. package/templates/basic/node_modules/picomatch/index.js +17 -0
  209. package/templates/basic/node_modules/picomatch/lib/constants.js +184 -0
  210. package/templates/basic/node_modules/picomatch/lib/parse.js +1416 -0
  211. package/templates/basic/node_modules/picomatch/lib/picomatch.js +361 -0
  212. package/templates/basic/node_modules/picomatch/lib/scan.js +391 -0
  213. package/templates/basic/node_modules/picomatch/lib/utils.js +72 -0
  214. package/templates/basic/node_modules/picomatch/package.json +83 -0
  215. package/templates/basic/node_modules/picomatch/posix.js +3 -0
  216. package/templates/basic/node_modules/postcss/LICENSE +20 -0
  217. package/templates/basic/node_modules/postcss/README.md +25 -0
  218. package/templates/basic/node_modules/postcss/lib/at-rule.d.ts +139 -0
  219. package/templates/basic/node_modules/postcss/lib/at-rule.js +25 -0
  220. package/templates/basic/node_modules/postcss/lib/comment.d.ts +67 -0
  221. package/templates/basic/node_modules/postcss/lib/comment.js +13 -0
  222. package/templates/basic/node_modules/postcss/lib/container.d.ts +478 -0
  223. package/templates/basic/node_modules/postcss/lib/container.js +447 -0
  224. package/templates/basic/node_modules/postcss/lib/css-syntax-error.d.ts +247 -0
  225. package/templates/basic/node_modules/postcss/lib/css-syntax-error.js +133 -0
  226. package/templates/basic/node_modules/postcss/lib/declaration.d.ts +150 -0
  227. package/templates/basic/node_modules/postcss/lib/declaration.js +24 -0
  228. package/templates/basic/node_modules/postcss/lib/document.d.ts +68 -0
  229. package/templates/basic/node_modules/postcss/lib/document.js +33 -0
  230. package/templates/basic/node_modules/postcss/lib/fromJSON.d.ts +9 -0
  231. package/templates/basic/node_modules/postcss/lib/fromJSON.js +68 -0
  232. package/templates/basic/node_modules/postcss/lib/input.d.ts +226 -0
  233. package/templates/basic/node_modules/postcss/lib/input.js +276 -0
  234. package/templates/basic/node_modules/postcss/lib/lazy-result.d.ts +189 -0
  235. package/templates/basic/node_modules/postcss/lib/lazy-result.js +563 -0
  236. package/templates/basic/node_modules/postcss/lib/list.d.ts +60 -0
  237. package/templates/basic/node_modules/postcss/lib/list.js +58 -0
  238. package/templates/basic/node_modules/postcss/lib/map-generator.js +376 -0
  239. package/templates/basic/node_modules/postcss/lib/no-work-result.d.ts +45 -0
  240. package/templates/basic/node_modules/postcss/lib/no-work-result.js +137 -0
  241. package/templates/basic/node_modules/postcss/lib/node.d.ts +555 -0
  242. package/templates/basic/node_modules/postcss/lib/node.js +456 -0
  243. package/templates/basic/node_modules/postcss/lib/parse.d.ts +9 -0
  244. package/templates/basic/node_modules/postcss/lib/parse.js +42 -0
  245. package/templates/basic/node_modules/postcss/lib/parser.js +618 -0
  246. package/templates/basic/node_modules/postcss/lib/postcss.d.mts +66 -0
  247. package/templates/basic/node_modules/postcss/lib/postcss.d.ts +461 -0
  248. package/templates/basic/node_modules/postcss/lib/postcss.js +101 -0
  249. package/templates/basic/node_modules/postcss/lib/postcss.mjs +30 -0
  250. package/templates/basic/node_modules/postcss/lib/previous-map.d.ts +80 -0
  251. package/templates/basic/node_modules/postcss/lib/previous-map.js +161 -0
  252. package/templates/basic/node_modules/postcss/lib/processor.d.ts +114 -0
  253. package/templates/basic/node_modules/postcss/lib/processor.js +67 -0
  254. package/templates/basic/node_modules/postcss/lib/result.d.ts +204 -0
  255. package/templates/basic/node_modules/postcss/lib/result.js +42 -0
  256. package/templates/basic/node_modules/postcss/lib/root.d.ts +86 -0
  257. package/templates/basic/node_modules/postcss/lib/root.js +61 -0
  258. package/templates/basic/node_modules/postcss/lib/rule.d.ts +126 -0
  259. package/templates/basic/node_modules/postcss/lib/rule.js +27 -0
  260. package/templates/basic/node_modules/postcss/lib/stringifier.d.ts +45 -0
  261. package/templates/basic/node_modules/postcss/lib/stringifier.js +374 -0
  262. package/templates/basic/node_modules/postcss/lib/stringify.d.ts +9 -0
  263. package/templates/basic/node_modules/postcss/lib/stringify.js +11 -0
  264. package/templates/basic/node_modules/postcss/lib/symbols.js +5 -0
  265. package/templates/basic/node_modules/postcss/lib/terminal-highlight.js +70 -0
  266. package/templates/basic/node_modules/postcss/lib/tokenize.js +270 -0
  267. package/templates/basic/node_modules/postcss/lib/warn-once.js +13 -0
  268. package/templates/basic/node_modules/postcss/lib/warning.d.ts +146 -0
  269. package/templates/basic/node_modules/postcss/lib/warning.js +37 -0
  270. package/templates/basic/node_modules/postcss/package.json +88 -0
  271. package/templates/basic/node_modules/rolldown/LICENSE +25 -0
  272. package/templates/basic/node_modules/rolldown/README.md +11 -0
  273. package/templates/basic/node_modules/rolldown/bin/cli.mjs +2 -0
  274. package/templates/basic/node_modules/rolldown/dist/cli.d.mts +1 -0
  275. package/templates/basic/node_modules/rolldown/dist/cli.mjs +1202 -0
  276. package/templates/basic/node_modules/rolldown/dist/config.d.mts +14 -0
  277. package/templates/basic/node_modules/rolldown/dist/config.mjs +4 -0
  278. package/templates/basic/node_modules/rolldown/dist/experimental-index.d.mts +280 -0
  279. package/templates/basic/node_modules/rolldown/dist/experimental-index.mjs +331 -0
  280. package/templates/basic/node_modules/rolldown/dist/experimental-runtime-types.d.ts +107 -0
  281. package/templates/basic/node_modules/rolldown/dist/filter-index.d.mts +195 -0
  282. package/templates/basic/node_modules/rolldown/dist/filter-index.mjs +380 -0
  283. package/templates/basic/node_modules/rolldown/dist/get-log-filter.d.mts +3 -0
  284. package/templates/basic/node_modules/rolldown/dist/get-log-filter.mjs +68 -0
  285. package/templates/basic/node_modules/rolldown/dist/index.d.mts +4 -0
  286. package/templates/basic/node_modules/rolldown/dist/index.mjs +50 -0
  287. package/templates/basic/node_modules/rolldown/dist/parallel-plugin-worker.d.mts +1 -0
  288. package/templates/basic/node_modules/rolldown/dist/parallel-plugin-worker.mjs +29 -0
  289. package/templates/basic/node_modules/rolldown/dist/parallel-plugin.d.mts +13 -0
  290. package/templates/basic/node_modules/rolldown/dist/parallel-plugin.mjs +6 -0
  291. package/templates/basic/node_modules/rolldown/dist/parse-ast-index.d.mts +32 -0
  292. package/templates/basic/node_modules/rolldown/dist/parse-ast-index.mjs +60 -0
  293. package/templates/basic/node_modules/rolldown/dist/plugins-index.d.mts +33 -0
  294. package/templates/basic/node_modules/rolldown/dist/plugins-index.mjs +40 -0
  295. package/templates/basic/node_modules/rolldown/dist/shared/binding-B1q9aYT-.d.mts +1947 -0
  296. package/templates/basic/node_modules/rolldown/dist/shared/binding-BmkJW3Wy.mjs +588 -0
  297. package/templates/basic/node_modules/rolldown/dist/shared/bindingify-input-options-BsDhfYrS.mjs +2240 -0
  298. package/templates/basic/node_modules/rolldown/dist/shared/constructors-2i1T9YcF.d.mts +36 -0
  299. package/templates/basic/node_modules/rolldown/dist/shared/constructors-CE6zZSUt.mjs +65 -0
  300. package/templates/basic/node_modules/rolldown/dist/shared/define-config-BBz954-q.d.mts +3901 -0
  301. package/templates/basic/node_modules/rolldown/dist/shared/define-config-Demdg3_4.mjs +6 -0
  302. package/templates/basic/node_modules/rolldown/dist/shared/error-BlQ0-ek7.mjs +85 -0
  303. package/templates/basic/node_modules/rolldown/dist/shared/get-log-filter-BpNVNJ5-.d.mts +35 -0
  304. package/templates/basic/node_modules/rolldown/dist/shared/load-config-FRmAU9xl.mjs +120 -0
  305. package/templates/basic/node_modules/rolldown/dist/shared/logging-BSNejiLS.d.mts +50 -0
  306. package/templates/basic/node_modules/rolldown/dist/shared/logs-aMKUxRpj.mjs +180 -0
  307. package/templates/basic/node_modules/rolldown/dist/shared/misc-CoQm4NHO.mjs +21 -0
  308. package/templates/basic/node_modules/rolldown/dist/shared/normalize-string-or-regex-BYkbbGqQ.mjs +68 -0
  309. package/templates/basic/node_modules/rolldown/dist/shared/parse-DVMnkavl.mjs +74 -0
  310. package/templates/basic/node_modules/rolldown/dist/shared/prompt-B1Yc1NPt.mjs +847 -0
  311. package/templates/basic/node_modules/rolldown/dist/shared/resolve-tsconfig-CdIAR1Eb.mjs +124 -0
  312. package/templates/basic/node_modules/rolldown/dist/shared/rolldown-build-aV0QeeTW.mjs +3264 -0
  313. package/templates/basic/node_modules/rolldown/dist/shared/rolldown-tbHvKzVl.mjs +40 -0
  314. package/templates/basic/node_modules/rolldown/dist/shared/transform-CEmFsvJW.d.mts +149 -0
  315. package/templates/basic/node_modules/rolldown/dist/shared/watch-DIhJ-T1s.mjs +374 -0
  316. package/templates/basic/node_modules/rolldown/dist/utils-index.d.mts +376 -0
  317. package/templates/basic/node_modules/rolldown/dist/utils-index.mjs +2414 -0
  318. package/templates/basic/node_modules/rolldown/package.json +153 -0
  319. package/templates/basic/node_modules/source-map-js/LICENSE +28 -0
  320. package/templates/basic/node_modules/source-map-js/README.md +765 -0
  321. package/templates/basic/node_modules/source-map-js/lib/array-set.js +121 -0
  322. package/templates/basic/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  323. package/templates/basic/node_modules/source-map-js/lib/base64.js +67 -0
  324. package/templates/basic/node_modules/source-map-js/lib/binary-search.js +111 -0
  325. package/templates/basic/node_modules/source-map-js/lib/mapping-list.js +79 -0
  326. package/templates/basic/node_modules/source-map-js/lib/quick-sort.js +132 -0
  327. package/templates/basic/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
  328. package/templates/basic/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
  329. package/templates/basic/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
  330. package/templates/basic/node_modules/source-map-js/lib/source-map-generator.js +444 -0
  331. package/templates/basic/node_modules/source-map-js/lib/source-node.d.ts +1 -0
  332. package/templates/basic/node_modules/source-map-js/lib/source-node.js +413 -0
  333. package/templates/basic/node_modules/source-map-js/lib/util.js +594 -0
  334. package/templates/basic/node_modules/source-map-js/package.json +71 -0
  335. package/templates/basic/node_modules/source-map-js/source-map.d.ts +104 -0
  336. package/templates/basic/node_modules/source-map-js/source-map.js +8 -0
  337. package/templates/basic/node_modules/tinyglobby/LICENSE +21 -0
  338. package/templates/basic/node_modules/tinyglobby/README.md +25 -0
  339. package/templates/basic/node_modules/tinyglobby/dist/index.cjs +335 -0
  340. package/templates/basic/node_modules/tinyglobby/dist/index.d.cts +148 -0
  341. package/templates/basic/node_modules/tinyglobby/dist/index.d.mts +148 -0
  342. package/templates/basic/node_modules/tinyglobby/dist/index.mjs +307 -0
  343. package/templates/basic/node_modules/tinyglobby/package.json +70 -0
  344. package/templates/basic/node_modules/typescript/LICENSE.txt +55 -0
  345. package/templates/basic/node_modules/typescript/README.md +50 -0
  346. package/templates/basic/node_modules/typescript/SECURITY.md +39 -0
  347. package/templates/basic/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  348. package/templates/basic/node_modules/typescript/bin/tsc +2 -0
  349. package/templates/basic/node_modules/typescript/bin/tsserver +2 -0
  350. package/templates/basic/node_modules/typescript/lib/_tsc.js +134465 -0
  351. package/templates/basic/node_modules/typescript/lib/_tsserver.js +659 -0
  352. package/templates/basic/node_modules/typescript/lib/_typingsInstaller.js +222 -0
  353. package/templates/basic/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2129 -0
  354. package/templates/basic/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2125 -0
  355. package/templates/basic/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2129 -0
  356. package/templates/basic/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2129 -0
  357. package/templates/basic/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2125 -0
  358. package/templates/basic/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2129 -0
  359. package/templates/basic/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2129 -0
  360. package/templates/basic/node_modules/typescript/lib/lib.d.ts +20 -0
  361. package/templates/basic/node_modules/typescript/lib/lib.decorators.d.ts +382 -0
  362. package/templates/basic/node_modules/typescript/lib/lib.decorators.legacy.d.ts +20 -0
  363. package/templates/basic/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +18 -0
  364. package/templates/basic/node_modules/typescript/lib/lib.dom.d.ts +45125 -0
  365. package/templates/basic/node_modules/typescript/lib/lib.dom.iterable.d.ts +18 -0
  366. package/templates/basic/node_modules/typescript/lib/lib.es2015.collection.d.ts +150 -0
  367. package/templates/basic/node_modules/typescript/lib/lib.es2015.core.d.ts +595 -0
  368. package/templates/basic/node_modules/typescript/lib/lib.es2015.d.ts +26 -0
  369. package/templates/basic/node_modules/typescript/lib/lib.es2015.generator.d.ts +75 -0
  370. package/templates/basic/node_modules/typescript/lib/lib.es2015.iterable.d.ts +603 -0
  371. package/templates/basic/node_modules/typescript/lib/lib.es2015.promise.d.ts +79 -0
  372. package/templates/basic/node_modules/typescript/lib/lib.es2015.proxy.d.ts +126 -0
  373. package/templates/basic/node_modules/typescript/lib/lib.es2015.reflect.d.ts +142 -0
  374. package/templates/basic/node_modules/typescript/lib/lib.es2015.symbol.d.ts +44 -0
  375. package/templates/basic/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
  376. package/templates/basic/node_modules/typescript/lib/lib.es2016.array.include.d.ts +114 -0
  377. package/templates/basic/node_modules/typescript/lib/lib.es2016.d.ts +19 -0
  378. package/templates/basic/node_modules/typescript/lib/lib.es2016.full.d.ts +21 -0
  379. package/templates/basic/node_modules/typescript/lib/lib.es2016.intl.d.ts +29 -0
  380. package/templates/basic/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +19 -0
  381. package/templates/basic/node_modules/typescript/lib/lib.es2017.d.ts +24 -0
  382. package/templates/basic/node_modules/typescript/lib/lib.es2017.date.d.ts +29 -0
  383. package/templates/basic/node_modules/typescript/lib/lib.es2017.full.d.ts +21 -0
  384. package/templates/basic/node_modules/typescript/lib/lib.es2017.intl.d.ts +42 -0
  385. package/templates/basic/node_modules/typescript/lib/lib.es2017.object.d.ts +47 -0
  386. package/templates/basic/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +133 -0
  387. package/templates/basic/node_modules/typescript/lib/lib.es2017.string.d.ts +43 -0
  388. package/templates/basic/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +51 -0
  389. package/templates/basic/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +75 -0
  390. package/templates/basic/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +51 -0
  391. package/templates/basic/node_modules/typescript/lib/lib.es2018.d.ts +22 -0
  392. package/templates/basic/node_modules/typescript/lib/lib.es2018.full.d.ts +22 -0
  393. package/templates/basic/node_modules/typescript/lib/lib.es2018.intl.d.ts +81 -0
  394. package/templates/basic/node_modules/typescript/lib/lib.es2018.promise.d.ts +28 -0
  395. package/templates/basic/node_modules/typescript/lib/lib.es2018.regexp.d.ts +35 -0
  396. package/templates/basic/node_modules/typescript/lib/lib.es2019.array.d.ts +77 -0
  397. package/templates/basic/node_modules/typescript/lib/lib.es2019.d.ts +22 -0
  398. package/templates/basic/node_modules/typescript/lib/lib.es2019.full.d.ts +22 -0
  399. package/templates/basic/node_modules/typescript/lib/lib.es2019.intl.d.ts +21 -0
  400. package/templates/basic/node_modules/typescript/lib/lib.es2019.object.d.ts +31 -0
  401. package/templates/basic/node_modules/typescript/lib/lib.es2019.string.d.ts +35 -0
  402. package/templates/basic/node_modules/typescript/lib/lib.es2019.symbol.d.ts +22 -0
  403. package/templates/basic/node_modules/typescript/lib/lib.es2020.bigint.d.ts +763 -0
  404. package/templates/basic/node_modules/typescript/lib/lib.es2020.d.ts +25 -0
  405. package/templates/basic/node_modules/typescript/lib/lib.es2020.date.d.ts +40 -0
  406. package/templates/basic/node_modules/typescript/lib/lib.es2020.full.d.ts +22 -0
  407. package/templates/basic/node_modules/typescript/lib/lib.es2020.intl.d.ts +472 -0
  408. package/templates/basic/node_modules/typescript/lib/lib.es2020.number.d.ts +26 -0
  409. package/templates/basic/node_modules/typescript/lib/lib.es2020.promise.d.ts +45 -0
  410. package/templates/basic/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +97 -0
  411. package/templates/basic/node_modules/typescript/lib/lib.es2020.string.d.ts +42 -0
  412. package/templates/basic/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
  413. package/templates/basic/node_modules/typescript/lib/lib.es2021.d.ts +21 -0
  414. package/templates/basic/node_modules/typescript/lib/lib.es2021.full.d.ts +22 -0
  415. package/templates/basic/node_modules/typescript/lib/lib.es2021.intl.d.ts +164 -0
  416. package/templates/basic/node_modules/typescript/lib/lib.es2021.promise.d.ts +46 -0
  417. package/templates/basic/node_modules/typescript/lib/lib.es2021.string.d.ts +31 -0
  418. package/templates/basic/node_modules/typescript/lib/lib.es2021.weakref.d.ts +76 -0
  419. package/templates/basic/node_modules/typescript/lib/lib.es2022.array.d.ts +119 -0
  420. package/templates/basic/node_modules/typescript/lib/lib.es2022.d.ts +23 -0
  421. package/templates/basic/node_modules/typescript/lib/lib.es2022.error.d.ts +73 -0
  422. package/templates/basic/node_modules/typescript/lib/lib.es2022.full.d.ts +22 -0
  423. package/templates/basic/node_modules/typescript/lib/lib.es2022.intl.d.ts +143 -0
  424. package/templates/basic/node_modules/typescript/lib/lib.es2022.object.d.ts +24 -0
  425. package/templates/basic/node_modules/typescript/lib/lib.es2022.regexp.d.ts +37 -0
  426. package/templates/basic/node_modules/typescript/lib/lib.es2022.string.d.ts +23 -0
  427. package/templates/basic/node_modules/typescript/lib/lib.es2023.array.d.ts +922 -0
  428. package/templates/basic/node_modules/typescript/lib/lib.es2023.collection.d.ts +19 -0
  429. package/templates/basic/node_modules/typescript/lib/lib.es2023.d.ts +20 -0
  430. package/templates/basic/node_modules/typescript/lib/lib.es2023.full.d.ts +22 -0
  431. package/templates/basic/node_modules/typescript/lib/lib.es2023.intl.d.ts +62 -0
  432. package/templates/basic/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +63 -0
  433. package/templates/basic/node_modules/typescript/lib/lib.es2024.collection.d.ts +27 -0
  434. package/templates/basic/node_modules/typescript/lib/lib.es2024.d.ts +24 -0
  435. package/templates/basic/node_modules/typescript/lib/lib.es2024.full.d.ts +22 -0
  436. package/templates/basic/node_modules/typescript/lib/lib.es2024.object.d.ts +27 -0
  437. package/templates/basic/node_modules/typescript/lib/lib.es2024.promise.d.ts +33 -0
  438. package/templates/basic/node_modules/typescript/lib/lib.es2024.regexp.d.ts +23 -0
  439. package/templates/basic/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +66 -0
  440. package/templates/basic/node_modules/typescript/lib/lib.es2024.string.d.ts +27 -0
  441. package/templates/basic/node_modules/typescript/lib/lib.es2025.collection.d.ts +94 -0
  442. package/templates/basic/node_modules/typescript/lib/lib.es2025.d.ts +23 -0
  443. package/templates/basic/node_modules/typescript/lib/lib.es2025.float16.d.ts +443 -0
  444. package/templates/basic/node_modules/typescript/lib/lib.es2025.full.d.ts +22 -0
  445. package/templates/basic/node_modules/typescript/lib/lib.es2025.intl.d.ts +200 -0
  446. package/templates/basic/node_modules/typescript/lib/lib.es2025.iterator.d.ts +146 -0
  447. package/templates/basic/node_modules/typescript/lib/lib.es2025.promise.d.ts +32 -0
  448. package/templates/basic/node_modules/typescript/lib/lib.es2025.regexp.d.ts +30 -0
  449. package/templates/basic/node_modules/typescript/lib/lib.es5.d.ts +4599 -0
  450. package/templates/basic/node_modules/typescript/lib/lib.es6.d.ts +21 -0
  451. package/templates/basic/node_modules/typescript/lib/lib.esnext.array.d.ts +33 -0
  452. package/templates/basic/node_modules/typescript/lib/lib.esnext.collection.d.ts +47 -0
  453. package/templates/basic/node_modules/typescript/lib/lib.esnext.d.ts +27 -0
  454. package/templates/basic/node_modules/typescript/lib/lib.esnext.date.d.ts +21 -0
  455. package/templates/basic/node_modules/typescript/lib/lib.esnext.decorators.d.ts +26 -0
  456. package/templates/basic/node_modules/typescript/lib/lib.esnext.disposable.d.ts +191 -0
  457. package/templates/basic/node_modules/typescript/lib/lib.esnext.error.d.ts +22 -0
  458. package/templates/basic/node_modules/typescript/lib/lib.esnext.full.d.ts +22 -0
  459. package/templates/basic/node_modules/typescript/lib/lib.esnext.intl.d.ts +107 -0
  460. package/templates/basic/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +23 -0
  461. package/templates/basic/node_modules/typescript/lib/lib.esnext.temporal.d.ts +485 -0
  462. package/templates/basic/node_modules/typescript/lib/lib.esnext.typedarrays.d.ts +90 -0
  463. package/templates/basic/node_modules/typescript/lib/lib.scripthost.d.ts +320 -0
  464. package/templates/basic/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +18 -0
  465. package/templates/basic/node_modules/typescript/lib/lib.webworker.d.ts +15606 -0
  466. package/templates/basic/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +21 -0
  467. package/templates/basic/node_modules/typescript/lib/lib.webworker.iterable.d.ts +18 -0
  468. package/templates/basic/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2129 -0
  469. package/templates/basic/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2129 -0
  470. package/templates/basic/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2125 -0
  471. package/templates/basic/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2129 -0
  472. package/templates/basic/node_modules/typescript/lib/tsc.js +8 -0
  473. package/templates/basic/node_modules/typescript/lib/tsserver.js +8 -0
  474. package/templates/basic/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
  475. package/templates/basic/node_modules/typescript/lib/tsserverlibrary.js +21 -0
  476. package/templates/basic/node_modules/typescript/lib/typesMap.json +497 -0
  477. package/templates/basic/node_modules/typescript/lib/typescript.d.ts +11448 -0
  478. package/templates/basic/node_modules/typescript/lib/typescript.js +201039 -0
  479. package/templates/basic/node_modules/typescript/lib/typingsInstaller.js +8 -0
  480. package/templates/basic/node_modules/typescript/lib/watchGuard.js +53 -0
  481. package/templates/basic/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2129 -0
  482. package/templates/basic/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2125 -0
  483. package/templates/basic/node_modules/typescript/package.json +118 -0
  484. package/templates/basic/node_modules/vite/LICENSE.md +2287 -0
  485. package/templates/basic/node_modules/vite/README.md +20 -0
  486. package/templates/basic/node_modules/vite/bin/openChrome.js +68 -0
  487. package/templates/basic/node_modules/vite/bin/vite.js +79 -0
  488. package/templates/basic/node_modules/vite/client.d.ts +285 -0
  489. package/templates/basic/node_modules/vite/dist/client/client.mjs +1269 -0
  490. package/templates/basic/node_modules/vite/dist/client/env.mjs +18 -0
  491. package/templates/basic/node_modules/vite/dist/node/chunks/build.js +5371 -0
  492. package/templates/basic/node_modules/vite/dist/node/chunks/dist.js +6784 -0
  493. package/templates/basic/node_modules/vite/dist/node/chunks/lib.js +371 -0
  494. package/templates/basic/node_modules/vite/dist/node/chunks/logger.js +364 -0
  495. package/templates/basic/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +96 -0
  496. package/templates/basic/node_modules/vite/dist/node/chunks/node.js +35836 -0
  497. package/templates/basic/node_modules/vite/dist/node/chunks/postcss-import.js +467 -0
  498. package/templates/basic/node_modules/vite/dist/node/cli.js +836 -0
  499. package/templates/basic/node_modules/vite/dist/node/index.d.ts +4011 -0
  500. package/templates/basic/node_modules/vite/dist/node/index.js +3 -0
  501. package/templates/basic/node_modules/vite/dist/node/internal.d.ts +2 -0
  502. package/templates/basic/node_modules/vite/dist/node/internal.js +2 -0
  503. package/templates/basic/node_modules/vite/dist/node/module-runner.d.ts +314 -0
  504. package/templates/basic/node_modules/vite/dist/node/module-runner.js +1274 -0
  505. package/templates/basic/node_modules/vite/misc/false.js +1 -0
  506. package/templates/basic/node_modules/vite/misc/true.js +1 -0
  507. package/templates/basic/node_modules/vite/package.json +194 -0
  508. package/templates/basic/node_modules/vite/types/customEvent.d.ts +79 -0
  509. package/templates/basic/node_modules/vite/types/hmrPayload.d.ts +80 -0
  510. package/templates/basic/node_modules/vite/types/hot.d.ts +39 -0
  511. package/templates/basic/node_modules/vite/types/import-meta.d.ts +5 -0
  512. package/templates/basic/node_modules/vite/types/importGlob.d.ts +131 -0
  513. package/templates/basic/node_modules/vite/types/importMeta.d.ts +30 -0
  514. package/templates/basic/node_modules/vite/types/internal/cssPreprocessorOptions.d.ts +44 -0
  515. package/templates/basic/node_modules/vite/types/internal/esbuildOptions.d.ts +28 -0
  516. package/templates/basic/node_modules/vite/types/internal/lightningcssOptions.d.ts +18 -0
  517. package/templates/basic/node_modules/vite/types/internal/rollupTypeCompat.d.ts +24 -0
  518. package/templates/basic/node_modules/vite/types/internal/terserOptions.d.ts +11 -0
  519. package/templates/basic/node_modules/vite/types/metadata.d.ts +47 -0
  520. package/templates/basic/package-lock.json +926 -0
  521. package/templates/basic/package.json +18 -0
  522. package/templates/basic/public/apple-touch-icon.png +0 -0
  523. package/templates/basic/public/favicon-16x16.png +0 -0
  524. package/templates/basic/public/favicon-32x32.png +0 -0
  525. package/templates/basic/public/favicon.ico +0 -0
  526. package/templates/basic/public/icon-192.png +0 -0
  527. package/templates/basic/public/icon-512.png +0 -0
  528. package/templates/basic/public/nuclo-logo.svg +24 -0
  529. package/templates/basic/public/site.webmanifest +23 -0
  530. package/templates/basic/src/app.ts +37 -0
  531. package/templates/basic/src/main.ts +5 -0
  532. package/templates/basic/src/styles.ts +85 -0
  533. package/templates/basic/tsconfig.json +23 -0
  534. package/templates/basic/vite.config.ts +3 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuclo.cjs","names":[],"sources":["../src/shared/type-guards.ts","../src/shared/errors.ts","../src/shared/environment.ts","../src/element/events.ts","../src/update/registry.ts","../src/shared/dom.ts","../src/update/reactive-attributes.ts","../src/element/inline-style.ts","../src/element/class-name.ts","../src/update/reactive-text.ts","../src/element/attributes.ts","../src/hydration.ts","../src/element/modifiers.ts","../src/element/factory.ts","../src/element/tags.ts","../src/shared/renderables.ts","../src/list/runtime.ts","../src/list/index.ts","../src/shared/conditions.ts","../src/when/runtime.ts","../src/when/builder.ts","../src/when/index.ts","../src/update/conditional.ts","../src/update/scope.ts","../src/update/update.ts","../src/render.ts","../src/style/engine.ts","../src/style/css.ts","../src/bootstrap.ts"],"sourcesContent":["export function isPrimitive(value: unknown): value is Primitive {\n\treturn value === null || (typeof value !== \"object\" && typeof value !== \"function\");\n}\n\nexport function isNode<T>(value: T): value is T & Node {\n\tif (value instanceof Node) return true;\n\tif (typeof value !== 'object' || value === null) return false;\n\t// Recognize polyfill DOM objects (plain objects with a numeric nodeType)\n\treturn typeof (value as { nodeType?: unknown }).nodeType === 'number';\n}\n\nexport function isObject(value: unknown): value is object {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nexport function isTagLike<T>(value: T): value is T & { tagName?: string } {\n\treturn isObject(value) && \"tagName\" in (value as object);\n}\n\nexport function isBoolean(value: unknown): value is boolean {\n\treturn typeof value === \"boolean\";\n}\n\n/**\n * Narrows `value` to a callable. The generic `<T extends Function>` is intentionally\n * removed: it allowed callers to assert any specific function signature via the type\n * parameter without a runtime check, which is unsafe. Use explicit casts at call sites\n * when a more specific signature is needed.\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n\treturn typeof value === \"function\";\n}\n\nexport function isZeroArityFunction(value: unknown): value is () => unknown {\n\treturn isFunction(value) && (value as { length: number }).length === 0;\n}\n","export function logError(message: string, error?: Error | unknown): void {\n if (typeof console !== 'undefined') {\n // eslint-disable-next-line no-console\n console.error(`nuclo: ${message}`, error);\n }\n}","/**\n * Simplified environment detection - minimal overhead for smaller bundle size\n */\n\n// Basic environment detection - no complex caching or edge cases\nexport const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\n","/**\n * Typed event listener helper.\n *\n * Usage:\n * button(\n * \"Click\",\n * on(\"click\", (e) => {\n * // e is correctly typed (e.g. MouseEvent for \"click\")\n * })\n * )\n *\n * Design notes:\n * - Returns a NodeModFn so it can be used like any other modifier.\n * - Produces no child node (returns void in the modifier body).\n * - Provides strong typing of the event object based on the DOM event name.\n * - Stores listener references in a WeakMap to prevent memory leaks.\n * - Listeners are automatically cleaned up when elements are garbage collected.\n */\n\nimport { logError } from \"../shared/errors\";\nimport { isBrowser } from \"../shared/environment\";\n\ntype EventListenerOptions = boolean | AddEventListenerOptions;\n\ninterface TrackedListener {\n type: string;\n wrapped: EventListener;\n options?: EventListenerOptions;\n}\n\n/**\n * Tracks attached listeners per element so removeAllListeners() can detach them.\n *\n * A flat array per element (rather than a Map<type, Set>) keeps the common\n * case — one or two listeners on a node, as in a list row — down to a single\n * allocation. The WeakMap keying means a collected element drops its listener\n * array automatically, and the listeners themselves are released with the\n * element by the DOM, so no per-listener AbortController is needed: detach is a\n * plain removeEventListener with the tracked wrapper + options.\n */\nconst elementListeners = new WeakMap<HTMLElement, TrackedListener[]>();\n\n/**\n * Store listener info for an element to enable cleanup.\n */\nfunction trackListener(\n element: HTMLElement,\n info: TrackedListener\n): void {\n const list = elementListeners.get(element);\n if (list) {\n list.push(info);\n } else {\n elementListeners.set(element, [info]);\n }\n}\n\n/**\n * Detach a single tracked listener from the DOM.\n */\nfunction detachListener(element: HTMLElement, info: TrackedListener): void {\n element.removeEventListener(info.type, info.wrapped, info.options);\n}\n\n/**\n * Remove all listeners of a specific type from an element.\n */\nexport function removeAllListeners(\n element: HTMLElement,\n type?: string\n): void {\n const list = elementListeners.get(element);\n if (!list) return;\n\n if (type === undefined) {\n for (let i = 0; i < list.length; i++) detachListener(element, list[i]);\n elementListeners.delete(element);\n return;\n }\n\n // Detach matching listeners, compacting survivors back into the same array.\n let write = 0;\n for (let i = 0; i < list.length; i++) {\n const info = list[i];\n if (info.type === type) {\n detachListener(element, info);\n } else {\n list[write++] = info;\n }\n }\n list.length = write;\n if (write === 0) elementListeners.delete(element);\n}\n\n/**\n * Overload for standard HTMLElement events (strongly typed via lib.dom.d.ts)\n */\nexport function on<\n K extends keyof HTMLElementEventMap,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: TypedEventListener<HTMLElementTagNameMap[TTagName], HTMLElementEventMap[K]>,\n options?: EventListenerOptions\n): NodeModFn<TTagName>;\n\n/**\n * Fallback / custom event overload (arbitrary event names or custom event types).\n * Specify a custom event type with the E generic if needed:\n * on<\"my-event\", CustomEvent<MyDetail>>(\"my-event\", e => { ... })\n */\nexport function on<\n K extends string,\n E extends Event = Event,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: TypedEventListener<HTMLElementTagNameMap[TTagName], E>,\n options?: EventListenerOptions\n): NodeModFn<TTagName>;\n\nexport function on<TTagName extends ElementTagName = ElementTagName>(\n type: string,\n listener: TypedEventListener<HTMLElementTagNameMap[TTagName], Event>,\n options?: EventListenerOptions\n): NodeModFn<TTagName> {\n return function(parent: ExpandedElement<TTagName>): void {\n if (!isBrowser) return;\n\n // Type guard: verify parent is an HTMLElement with addEventListener\n if (!parent || typeof (parent as HTMLElement).addEventListener !== \"function\") {\n return;\n }\n\n const el = parent as HTMLElementTagNameMap[TTagName];\n\n const wrapped = function(ev: Event): void {\n try {\n listener.call(\n el,\n ev as Event & { currentTarget: HTMLElementTagNameMap[TTagName] }\n );\n } catch (error) {\n logError(`Error in '${type}' listener`, error);\n }\n };\n\n el.addEventListener(type, wrapped as EventListener, options);\n\n // Track the listener so removeAllListeners() can detach it later.\n trackListener(el, { type, wrapped: wrapped as EventListener, options });\n };\n}\n","/**\n * Shared types and registries for reactive nodes.\n * Single source of truth — imported by reactiveText.ts and reactiveAttributes.ts.\n *\n * Registry structure: the iteration sets only hold WeakRefs; the actual info\n * records live in WeakMaps keyed by the node. Info records may strongly\n * reference the node (e.g. attribute applyValue closures capture the\n * element), so storing them in a strongly-held map would pin the node in\n * memory forever. With WeakMap storage the whole record is collectible as\n * soon as the node is unreachable, and the FinalizationRegistry prunes the\n * leftover WeakRef from the iteration set. The notify passes also prune\n * dead/disconnected entries as they iterate.\n */\n\nexport type TextResolver = () => Primitive;\n\nexport interface ReactiveTextNodeInfo {\n resolver: TextResolver;\n lastValue: string;\n}\n\nexport type AttributeResolver = () => unknown;\n\nexport interface AttributeResolverRecord {\n resolver: AttributeResolver;\n applyValue: (value: unknown) => void;\n lastValue: unknown;\n}\n\nexport interface ReactiveElementInfo {\n attributeResolvers: Map<string, AttributeResolverRecord>;\n}\n\n/**\n * Iteration set of weak references to reactive text nodes.\n */\nexport const reactiveTextNodes = new Set<WeakRef<Text>>();\n\n/**\n * WeakMap for O(1) lookups of reactive text node info by node reference.\n */\nexport const reactiveTextNodesByNode = new WeakMap<Text, { ref: WeakRef<Text>; info: ReactiveTextNodeInfo }>();\n\n/**\n * Iteration set of weak references to reactive elements.\n */\nexport const reactiveElements = new Set<WeakRef<Element>>();\n\n/**\n * WeakMap for O(1) lookups of reactive element info by element reference.\n */\nexport const reactiveElementsByNode = new WeakMap<Element, { ref: WeakRef<Element>; info: ReactiveElementInfo }>();\n\nconst textNodeFinalizer = typeof FinalizationRegistry !== \"undefined\"\n ? new FinalizationRegistry<WeakRef<Text>>((ref) => { reactiveTextNodes.delete(ref); })\n : null;\n\nconst elementFinalizer = typeof FinalizationRegistry !== \"undefined\"\n ? new FinalizationRegistry<WeakRef<Element>>((ref) => { reactiveElements.delete(ref); })\n : null;\n\n/**\n * Registers a reactive text node in both lookup structures.\n */\nexport function registerReactiveTextNode(node: Text, info: ReactiveTextNodeInfo): void {\n const existing = reactiveTextNodesByNode.get(node);\n if (existing) {\n // Re-registration (e.g. repeated hydration): replace the info in place.\n existing.info.resolver = info.resolver;\n existing.info.lastValue = info.lastValue;\n return;\n }\n const ref = new WeakRef(node);\n reactiveTextNodes.add(ref);\n reactiveTextNodesByNode.set(node, { ref, info });\n textNodeFinalizer?.register(node, ref);\n}\n\n/**\n * Registers a reactive element in both lookup structures.\n */\nexport function registerReactiveElement(element: Element, info: ReactiveElementInfo): void {\n const ref = new WeakRef(element);\n reactiveElements.add(ref);\n reactiveElementsByNode.set(element, { ref, info });\n elementFinalizer?.register(element, ref);\n}\n\n/**\n * Removes a reactive text node's WeakRef entry from the iteration set.\n */\nexport function removeReactiveTextNodeRef(ref: WeakRef<Text>): void {\n reactiveTextNodes.delete(ref);\n}\n\n/**\n * Removes a reactive element's WeakRef entry from the iteration set.\n */\nexport function removeReactiveElementRef(ref: WeakRef<Element>): void {\n reactiveElements.delete(ref);\n}\n\n/**\n * Manually removes reactive text node info for a specific text node.\n * This should be called when a text node is removed from the DOM to prevent memory leaks.\n */\nexport function cleanupReactiveTextNode(node: Text): void {\n const entry = reactiveTextNodesByNode.get(node);\n if (entry) {\n reactiveTextNodes.delete(entry.ref);\n reactiveTextNodesByNode.delete(node);\n }\n}\n\n/**\n * Manually removes reactive element info for a specific element.\n * This should be called when an element is removed from the DOM to prevent memory leaks.\n */\nexport function cleanupReactiveElement(element: Element): void {\n const entry = reactiveElementsByNode.get(element);\n if (entry) {\n reactiveElements.delete(entry.ref);\n reactiveElementsByNode.delete(element);\n }\n}\n\n// ─── Conditional elements ────────────────────────────────────────────────────\n// Same idea as above, but for nodes created by conditional rendering: the\n// registry remembers each node's condition + modifiers so update() can\n// re-evaluate and swap the element in place.\n\nexport interface ConditionalInfo<TTagName extends ElementTagName = ElementTagName> {\n\tcondition: () => boolean;\n\ttagName: TTagName;\n\tmodifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n\tisSvg: boolean;\n}\n\n// WeakMap replaces the _conditionalInfo expando property — zero `any`, no DOM pollution, auto-GC.\nconst conditionalInfoMap = new WeakMap<Node, ConditionalInfo<ElementTagName>>();\n\n/**\n * Registry of all nodes that have conditional info attached.\n * Uses WeakRef to prevent memory leaks — allows garbage collection of removed nodes.\n * This enables O(nConditionals) updates instead of a full DOM tree walk.\n */\nconst activeConditionalNodes = new Set<WeakRef<Node>>();\n\n/**\n * Reverse lookup for O(1) unregister — maps node to its WeakRef in the active set.\n */\nconst refByNode = new WeakMap<Node, WeakRef<Node>>();\n\n/**\n * Prunes dead WeakRefs from the active set as soon as their node is\n * collected, instead of waiting for the next getActiveConditionalNodes() pass.\n */\nconst conditionalNodeFinalizer = typeof FinalizationRegistry !== \"undefined\"\n\t? new FinalizationRegistry<WeakRef<Node>>((ref) => { activeConditionalNodes.delete(ref); })\n\t: null;\n\n/**\n * Attach conditional info to a node and register it.\n */\nexport function storeConditionalInfo<TTagName extends ElementTagName>(\n\tnode: Node,\n\tinfo: ConditionalInfo<TTagName>\n): void {\n\tconditionalInfoMap.set(node, info as ConditionalInfo<ElementTagName>);\n\tconst ref = new WeakRef(node);\n\tactiveConditionalNodes.add(ref);\n\trefByNode.set(node, ref);\n\tconditionalNodeFinalizer?.register(node, ref);\n}\n\n/**\n * Explicit unregister helper (optional use on teardown if needed).\n * O(1) via reverse lookup WeakMap.\n */\nexport function unregisterConditionalNode(node: Node): void {\n\tconditionalInfoMap.delete(node);\n\tconst ref = refByNode.get(node);\n\tif (ref) {\n\t\tactiveConditionalNodes.delete(ref);\n\t\trefByNode.delete(node);\n\t}\n}\n\n/**\n * Returns an array of currently tracked conditional nodes that are still alive.\n * Automatically cleans up garbage-collected nodes.\n */\nexport function getActiveConditionalNodes(): Node[] {\n\tconst nodes: Node[] = [];\n\tconst toDelete: WeakRef<Node>[] = [];\n\n\tfor (const ref of activeConditionalNodes) {\n\t\tconst node = ref.deref();\n\t\tif (node === undefined) {\n\t\t\ttoDelete.push(ref);\n\t\t} else {\n\t\t\tnodes.push(node);\n\t\t}\n\t}\n\n\tfor (const ref of toDelete) {\n\t\tactiveConditionalNodes.delete(ref);\n\t}\n\n\treturn nodes;\n}\n\nexport function getConditionalInfo(node: Node): ConditionalInfo<ElementTagName> | null {\n\treturn conditionalInfoMap.get(node) ?? null;\n}\n","import { logError } from \"./errors\";\nimport { removeAllListeners } from \"../element/events\";\nimport { cleanupReactiveTextNode, cleanupReactiveElement, unregisterConditionalNode } from \"../update/registry\";\n\nexport const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n\n/**\n * Creates an HTML element.\n * Wrapper for document.createElement with type safety.\n */\nexport function createElement<K extends keyof HTMLElementTagNameMap>(\n tagName: K\n): HTMLElementTagNameMap[K] | null;\nexport function createElement(tagName: string): ExpandedElement | null;\nexport function createElement(tagName: string): ExpandedElement | null {\n return globalThis.document ? document.createElement(tagName) as ExpandedElement : null;\n}\n\n/**\n * Creates an element in the given namespace (typically for SVG elements).\n * Wrapper for document.createElementNS with type safety.\n */\nexport function createElementNS(\n namespace: string,\n tagName: string\n): ExpandedElement | null {\n return globalThis.document ? document.createElementNS(namespace, tagName) as ExpandedElement : null;\n}\n\n/**\n * Creates a text node with the given content.\n * Wrapper for document.createTextNode.\n */\nexport function createTextNode(text: string): Text | null {\n return globalThis.document ? document.createTextNode(text) : null;\n}\n\n/**\n * Creates a document fragment.\n * Wrapper for document.createDocumentFragment.\n */\nexport function createDocumentFragment(): DocumentFragment | null {\n return globalThis.document ? document.createDocumentFragment() : null;\n}\n\nfunction safeAppendChild(parent: Element | Node, child: Node): boolean {\n try {\n parent.appendChild(child);\n return true;\n } catch (error) {\n logError('Failed to append child node', error);\n return false;\n }\n}\n\n/**\n * Recursively removes all event listeners and reactive subscriptions from a node and its descendants\n * to prevent memory leaks when elements are removed from the DOM.\n */\nfunction cleanupNodeTree(node: Node): void {\n // Clean up the node itself based on its type\n if (node.nodeType === Node.ELEMENT_NODE) {\n const element = node as HTMLElement;\n // Remove all event listeners\n removeAllListeners(element);\n // Remove reactive attribute resolvers\n cleanupReactiveElement(element);\n // Remove conditional info\n unregisterConditionalNode(element);\n } else if (node.nodeType === Node.TEXT_NODE) {\n // Remove reactive text node info\n cleanupReactiveTextNode(node as Text);\n } else if (node.nodeType === Node.COMMENT_NODE) {\n // Remove conditional info from comment nodes (used by when/list)\n unregisterConditionalNode(node);\n }\n \n // Recursively clean up all child nodes\n if (node.childNodes && node.childNodes.length > 0) {\n for (let i = 0; i < node.childNodes.length; i++) {\n cleanupNodeTree(node.childNodes[i]);\n }\n }\n}\n\nexport function safeRemoveChild(child: Node): boolean {\n if (!child?.parentNode) return false;\n try {\n // Clean up all event listeners before removing the element\n cleanupNodeTree(child);\n child.parentNode.removeChild(child);\n return true;\n } catch (error) {\n logError('Failed to remove child node', error);\n return false;\n }\n}\n\nfunction safeInsertBefore(parent: Node, newNode: Node, referenceNode: Node | null): boolean {\n try {\n parent.insertBefore(newNode, referenceNode);\n return true;\n } catch (error) {\n logError('Failed to insert node before reference', error);\n return false;\n }\n}\n\nexport function createComment(text: string): Comment | null {\n return globalThis.document ? globalThis.document.createComment(text) : null;\n}\n\nexport function createConditionalComment(tagName: string, suffix = \"hidden\"): Comment | null {\n return globalThis.document ? globalThis.document.createComment(`conditional-${tagName}-${suffix}`) : null;\n}\n\nexport function createMarkerPair(prefix: string, id: number | string): { start: Comment; end: Comment } {\n const endComment = createComment(`${prefix}-end`);\n if (!endComment) throw new Error(\"Failed to create comment: document not available\");\n const startComment = createComment(`${prefix}-start-${id}`);\n if (!startComment) throw new Error(\"Failed to create comment: document not available\");\n return { start: startComment, end: endComment };\n}\n\nexport function clearBetweenMarkers(startMarker: Comment, endMarker: Comment): void {\n let current = startMarker.nextSibling;\n while (current && current !== endMarker) {\n const next = current.nextSibling;\n safeRemoveChild(current);\n current = next;\n }\n}\n\nexport function insertNodesBefore(nodes: Node[], referenceNode: Node): void {\n const parent = referenceNode.parentNode;\n if (parent) {\n for (let i = 0; i < nodes.length; i++) {\n safeInsertBefore(parent, nodes[i], referenceNode);\n }\n }\n}\n\nexport function appendChildren(\n parent: Element | Node,\n ...children: Array<Element | Node | string | null | undefined>\n): Element | Node {\n if (!parent) return parent;\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child != null) {\n let nodeToAppend: Node;\n\n if (typeof child === \"string\") {\n const textNode = createTextNode(child);\n if (textNode) {\n nodeToAppend = textNode;\n } else {\n continue;\n }\n } else {\n nodeToAppend = child as Node;\n }\n\n safeAppendChild(parent, nodeToAppend);\n }\n }\n\n return parent;\n}\n\nexport function isNodeConnected(node: Node | null | undefined): boolean {\n return node?.isConnected === true;\n}\n\n/**\n * Safely replaces an old node with a new node in the DOM.\n * Returns true on success, false on failure (and logs the error).\n */\nexport function replaceNodeSafely(oldNode: Node, newNode: Node): boolean {\n if (!oldNode?.parentNode) return false;\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n return true;\n } catch (error) {\n logError(\"Error replacing conditional node\", error);\n return false;\n }\n}\n\n// ─── Type-safe DOM helpers ───────────────────────────────────────────────────\n\n/**\n * Safely casts an Element-like object to Node & ParentNode interface.\n * This is a common pattern needed when working with DOM manipulation.\n *\n * @param element - The element to cast\n * @returns The element typed as Node & ParentNode\n */\nexport function asParentNode<T extends Element | object>(element: T): Node & ParentNode {\n return element as unknown as Node & ParentNode;\n}\n\n/**\n * Creates a scoped DOM insertion context that temporarily redirects appendChild\n * to insertBefore at a specific reference node. This is useful for inserting\n * content at specific positions in the DOM tree.\n *\n * @param host - The host element\n * @param referenceNode - The node before which new nodes should be inserted\n * @param callback - Function to execute with the scoped context\n * @returns The result of the callback\n */\nexport function withScopedInsertion<T, THost extends Element | object>(\n host: THost,\n referenceNode: Node,\n callback: () => T\n): T {\n const parent = asParentNode(host);\n const originalAppend = parent.appendChild.bind(parent);\n const originalInsert = parent.insertBefore.bind(parent);\n\n // Temporarily override appendChild to insert before the reference node\n // TypeScript doesn't like this override but it's safe at runtime\n (parent as unknown as Record<string, unknown>).appendChild = function(node: Node): Node {\n return originalInsert(node, referenceNode);\n };\n\n try {\n return callback();\n } finally {\n // Restore original method\n (parent as unknown as Record<string, unknown>).appendChild = originalAppend;\n }\n}\n\n/**\n * Type-safe wrapper for setting CSS style properties.\n * Provides better error handling than direct CSSStyleDeclaration access.\n * Supports both camelCase and kebab-case property names.\n *\n * @param element - The element to apply styles to\n * @param property - The CSS property name (camelCase or kebab-case)\n * @param value - The value to set (string, number, or null to remove)\n * @returns true if the style was applied successfully, false otherwise\n */\nexport function setStyleProperty(\n element: HTMLElement,\n property: string,\n value: string | number | null\n): boolean {\n try {\n if (value === null || value === undefined || value === '') {\n // Use bracket notation to remove property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = '';\n return true;\n }\n\n // Convert value to string first (might throw if toString() throws)\n const stringValue = String(value);\n // Use bracket notation to set property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = stringValue;\n return true;\n } catch {\n return false;\n }\n}\n","import { logError } from \"../shared/errors\";\nimport { isNodeConnected } from \"../shared/dom\";\nimport type { UpdateScope } from \"./scope\";\nimport { reactiveElements, reactiveElementsByNode, registerReactiveElement, removeReactiveElementRef } from \"./registry\";\nimport type { AttributeResolver, AttributeResolverRecord, ReactiveElementInfo } from \"./registry\";\nimport { isBrowser } from \"../shared/environment\";\n\nconst UNSET_LAST_VALUE = {};\nlet updateEventListenerRegistered = false;\n\nfunction handleUpdateEvent(event: Event): void {\n // Update all reactive elements on the event's target ancestor chain.\n // This preserves the \"dispatchEvent(new Event('update'))\" workflow without\n // per-element event listeners.\n const target = event.target;\n if (!target || typeof Node === \"undefined\" || !(target instanceof Node)) return;\n\n let node: Node | null = target;\n while (node) {\n if (node instanceof Element) {\n const entry = reactiveElementsByNode.get(node);\n if (entry) {\n if (!isNodeConnected(node)) {\n removeReactiveElementRef(entry.ref);\n reactiveElementsByNode.delete(node);\n } else {\n applyAttributeResolvers(entry.info);\n }\n }\n }\n node = node.parentNode;\n }\n}\n\nfunction ensureGlobalUpdateEventListener(): void {\n if (updateEventListenerRegistered) return;\n if (typeof document === \"undefined\" || typeof document.addEventListener !== \"function\") return;\n document.addEventListener(\"update\", handleUpdateEvent, true);\n updateEventListenerRegistered = true;\n}\n\nfunction ensureElementInfo(el: Element): ReactiveElementInfo {\n const entry = reactiveElementsByNode.get(el);\n if (entry) return entry.info;\n\n // No existing info, create new\n const info: ReactiveElementInfo = { attributeResolvers: new Map() };\n registerReactiveElement(el, info);\n return info;\n}\n\nfunction isCacheableValue(value: unknown): boolean {\n // Avoid caching objects/arrays that may be mutated in place (e.g. style objects).\n return value === null || typeof value !== \"object\";\n}\n\nfunction updateAttributeResolverRecord(key: string, record: AttributeResolverRecord): void {\n let nextValue: unknown;\n try {\n nextValue = record.resolver();\n } catch (e) {\n logError(`Failed to resolve reactive attribute: ${key}`, e);\n return;\n }\n\n const cacheable = isCacheableValue(nextValue);\n if (cacheable && Object.is(nextValue, record.lastValue)) return;\n\n try {\n record.applyValue(nextValue);\n record.lastValue = cacheable ? nextValue : UNSET_LAST_VALUE;\n } catch (e) {\n logError(`Failed to apply reactive attribute: ${key}`, e);\n }\n}\n\nfunction applyAttributeResolvers(info: ReactiveElementInfo): void {\n for (const [key, record] of info.attributeResolvers) {\n updateAttributeResolverRecord(key, record);\n }\n}\n\n/**\n * Registers a reactive attribute resolver for an element.\n *\n * The resolver will be called whenever reactive updates run (e.g. via `update()`),\n * or when an `\"update\"` event is dispatched on the element (or a descendant),\n * allowing attributes to reactively update based on application state.\n *\n * @param element - The DOM element to make reactive\n * @param key - The attribute name being made reactive (e.g., 'class', 'style', 'disabled')\n * @param resolver - Function that returns the new attribute value\n * @param applyValue - Callback that applies the resolved value to the element\n *\n * @example\n * ```ts\n * const isActive = signal(false);\n * const button = document.createElement('button');\n * registerAttributeResolver(\n * button,\n * 'class',\n * () => isActive.value ? 'active' : 'inactive',\n * (value) => button.className = String(value)\n * );\n * ```\n */\nexport function registerAttributeResolver<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n key: string,\n resolver: AttributeResolver,\n applyValue: (value: unknown) => void\n): void {\n if (!(element instanceof Element) || !key || typeof resolver !== \"function\") {\n logError(\"Invalid parameters for registerAttributeResolver\");\n return;\n }\n\n const record: AttributeResolverRecord = { resolver, applyValue, lastValue: UNSET_LAST_VALUE };\n\n if (!isBrowser) {\n // SSR: just apply once, no registration needed (update() is never called server-side)\n updateAttributeResolverRecord(key, record);\n return;\n }\n\n ensureGlobalUpdateEventListener();\n const info = ensureElementInfo(element as Element);\n info.attributeResolvers.set(key, record);\n updateAttributeResolverRecord(key, record);\n}\n\n/**\n * Updates all registered reactive elements by re-evaluating their attribute resolvers.\n *\n * Iterates through all reactive elements and triggers their registered attribute resolvers\n * to update. Automatically cleans up disconnected elements and their event listeners.\n *\n * This function should be called after state changes to synchronize element attributes\n * with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * isActive.value = true;\n * notifyReactiveElements(); // All reactive attributes update\n * ```\n */\nexport function notifyReactiveElements(scope?: UpdateScope): void {\n const toDelete: WeakRef<Element>[] = [];\n\n for (const ref of reactiveElements) {\n const el = ref.deref();\n if (el === undefined) {\n toDelete.push(ref);\n continue;\n }\n\n const entry = reactiveElementsByNode.get(el);\n if (!entry) {\n toDelete.push(ref);\n continue;\n }\n\n if (!isNodeConnected(el)) {\n reactiveElementsByNode.delete(el);\n toDelete.push(ref);\n continue;\n }\n\n if (scope && !scope.contains(el)) continue;\n applyAttributeResolvers(entry.info);\n }\n\n for (const ref of toDelete) {\n removeReactiveElementRef(ref);\n }\n}\n","import { isFunction } from \"../shared/type-guards\";\nimport { registerAttributeResolver } from \"../update/reactive-attributes\";\nimport { setStyleProperty } from \"../shared/dom\";\nimport { logError } from \"../shared/errors\";\n\ntype StyleAssignment = CSSStyleObject;\ntype StyleResolver = () => StyleAssignment | null | undefined;\n\n/**\n * Simplified style management - basic functionality with minimal overhead\n */\nexport function assignInlineStyles<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styles: StyleAssignment | null | undefined,\n): void {\n if (!element?.style || !styles) return;\n\n for (const property in styles) {\n const success = setStyleProperty(\n element as HTMLElement,\n property,\n (styles as Record<string, string | number | null>)[property]\n );\n\n if (!success) {\n // Don't try to stringify value in error message as it might throw\n logError(`Failed to set style property '${property}'`);\n }\n }\n}\n\nexport function applyStyleAttribute<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styleValue: StyleAssignment | StyleResolver | null | undefined\n): void {\n if (!element) return;\n\n if (isFunction(styleValue)) {\n registerAttributeResolver(element, 'style', styleValue, function(resolvedStyles) {\n assignInlineStyles(element, resolvedStyles as StyleAssignment);\n });\n } else {\n assignInlineStyles(element, styleValue);\n }\n}\n","// WeakMap/WeakSet replace expando properties — zero `any`, automatic GC on element removal.\nconst staticClassNames = new WeakMap<HTMLElement, Set<string>>();\nconst reactiveClassNameFlags = new WeakSet<HTMLElement>();\n\n/**\n * Splits a className string into non-empty tokens and adds them to a Set.\n * Single-pass via charCodeAt — avoids intermediate array from split().filter().\n */\nfunction addClassTokens(target: Set<string>, className: string): void {\n\tconst len = className.length;\n\tlet start = 0;\n\tfor (let i = 0; i <= len; i++) {\n\t\tif (i === len || className.charCodeAt(i) === 32) { // 32 = ' '\n\t\t\tif (i > start) target.add(className.substring(start, i));\n\t\t\tstart = i + 1;\n\t\t}\n\t}\n}\n\n/**\n * Joins a Set of class names into a single space-separated string.\n */\nfunction joinClasses(classes: Set<string>): string {\n\tlet result = '';\n\tfor (const cls of classes) {\n\t\tif (result) result += ' ';\n\t\tresult += cls;\n\t}\n\treturn result;\n}\n\n// Mark element as having a reactive className and capture static classes.\n// Only allocate the tracking Set when the element actually has static classes —\n// reactive-only elements (the common case, e.g. a list row's `class={...}`)\n// skip the Set entirely. mergeReactiveClassName/addStaticClasses both handle a\n// missing Set, so an empty one carries no information.\nexport function initReactiveClassName(el: HTMLElement): void {\n\tif (el.className && !staticClassNames.has(el)) {\n\t\tconst classSet = new Set<string>();\n\t\taddClassTokens(classSet, el.className);\n\t\tstaticClassNames.set(el, classSet);\n\t}\n\treactiveClassNameFlags.add(el);\n}\n\n// Check if element has a reactive className\nexport function hasReactiveClassName(el: HTMLElement): boolean {\n\treturn reactiveClassNameFlags.has(el);\n}\n\n// Add static classes to the element's tracked set\nexport function addStaticClasses(el: HTMLElement, className: string): void {\n\tif (!className) return;\n\tlet classSet = staticClassNames.get(el);\n\tif (!classSet) {\n\t\tclassSet = new Set<string>();\n\t\tstaticClassNames.set(el, classSet);\n\t}\n\taddClassTokens(classSet, className);\n}\n\n// Merge reactive className with static classes — called on every reactive update\nexport function mergeReactiveClassName(el: HTMLElement, reactiveClassName: string): void {\n\tconst staticClasses = staticClassNames.get(el);\n\n\tif (!staticClasses || staticClasses.size === 0) {\n\t\tel.className = reactiveClassName || '';\n\t\treturn;\n\t}\n\tif (!reactiveClassName) {\n\t\tel.className = joinClasses(staticClasses);\n\t\treturn;\n\t}\n\t// Hot path: static + reactive. Avoid new Set() — build string directly\n\t// and deduplicate by checking if reactive tokens already exist in static set\n\tlet result = joinClasses(staticClasses);\n\tconst len = reactiveClassName.length;\n\tlet start = 0;\n\tfor (let i = 0; i <= len; i++) {\n\t\tif (i === len || reactiveClassName.charCodeAt(i) === 32) {\n\t\t\tif (i > start) {\n\t\t\t\tconst token = reactiveClassName.substring(start, i);\n\t\t\t\tif (!staticClasses.has(token)) {\n\t\t\t\t\tresult += ' ' + token;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstart = i + 1;\n\t\t}\n\t}\n\tel.className = result;\n}\n\n// Merge static className (for non-reactive className attributes)\nexport function mergeStaticClassName(el: HTMLElement, newClassName: string): void {\n\tif (!newClassName) return;\n\tconst currentClassName = el.className;\n\tif (currentClassName && currentClassName !== newClassName) {\n\t\tconst existing = new Set<string>();\n\t\taddClassTokens(existing, currentClassName);\n\t\taddClassTokens(existing, newClassName);\n\t\tel.className = joinClasses(existing);\n\t} else {\n\t\tel.className = newClassName;\n\t}\n}\n","import { logError } from \"../shared/errors\";\nimport { isNodeConnected, createTextNode } from \"../shared/dom\";\nimport type { UpdateScope } from \"./scope\";\nimport { reactiveTextNodes, reactiveTextNodesByNode, registerReactiveTextNode, removeReactiveTextNodeRef } from \"./registry\";\nimport type { TextResolver } from \"./registry\";\nimport { isBrowser } from \"../shared/environment\";\n\n/**\n * Creates a reactive text node that automatically updates when its resolver function changes.\n *\n * The text node will be registered for reactive updates and its content will be synchronized\n * whenever notifyReactiveTextNodes() is called.\n *\n * @param resolver - Function that returns the text content (string, number, boolean, etc.)\n * @param preEvaluated - Optional pre-evaluated value to avoid calling resolver immediately\n * @returns A Text node that will reactively update its content\n *\n * @example\n * ```ts\n * const count = signal(0);\n * const textNode = createReactiveTextNode(() => `Count: ${count.value}`);\n * // Later, when count changes and notifyReactiveTextNodes() is called,\n * // the text content automatically updates\n * ```\n */\nexport function createReactiveTextNode(resolver: TextResolver, preEvaluated?: unknown): Text | DocumentFragment {\n if (typeof resolver !== \"function\") {\n logError(\"Invalid resolver provided to createReactiveTextNode\");\n const fallbackNode = createTextNode(\"\");\n if (!fallbackNode) {\n throw new Error(\"Failed to create text node: document not available\");\n }\n return fallbackNode;\n }\n\n let initial: unknown;\n if (arguments.length > 1) {\n initial = preEvaluated;\n } else {\n try {\n initial = resolver();\n } catch (e) {\n logError(\"Failed to evaluate reactive text resolver\", e);\n initial = \"\";\n }\n }\n const str = initial === undefined ? \"\" : String(initial);\n const txt = createTextNode(str);\n \n if (!txt) {\n throw new Error(\"Failed to create text node: document not available\");\n }\n\n if (isBrowser) {\n registerReactiveTextNode(txt, { resolver, lastValue: str });\n }\n return txt;\n}\n\n/**\n * Updates all registered reactive text nodes.\n *\n * Iterates through all reactive text nodes, re-evaluates their resolver functions,\n * and updates their content if it has changed. Automatically cleans up disconnected nodes.\n *\n * This function should be called after state changes to synchronize the DOM with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * count.value++;\n * notifyReactiveTextNodes(); // All reactive text nodes update\n * ```\n */\nexport function notifyReactiveTextNodes(scope?: UpdateScope): void {\n const toDelete: WeakRef<Text>[] = [];\n\n for (const ref of reactiveTextNodes) {\n const node = ref.deref();\n if (node === undefined) {\n toDelete.push(ref);\n continue;\n }\n\n const entry = reactiveTextNodesByNode.get(node);\n if (!entry) {\n toDelete.push(ref);\n continue;\n }\n const info = entry.info;\n\n if (!isNodeConnected(node)) {\n reactiveTextNodesByNode.delete(node);\n toDelete.push(ref);\n continue;\n }\n\n if (scope && !scope.contains(node)) continue;\n\n let raw: unknown;\n try {\n raw = info.resolver();\n } catch (e) {\n logError(\"Failed to update reactive text node\", e);\n raw = undefined;\n }\n\n const newVal = raw === undefined ? \"\" : String(raw);\n if (newVal !== info.lastValue) {\n node.textContent = newVal;\n info.lastValue = newVal;\n }\n }\n\n for (const ref of toDelete) {\n removeReactiveTextNodeRef(ref);\n }\n}\n","import { isFunction } from \"../shared/type-guards\";\nimport { registerAttributeResolver } from \"../update/reactive-attributes\";\nimport { applyStyleAttribute } from \"./inline-style\";\nimport { SVG_NAMESPACE } from \"../shared/dom\";\nimport {\n\tinitReactiveClassName,\n\thasReactiveClassName,\n\taddStaticClasses,\n\tmergeReactiveClassName,\n\tmergeStaticClassName\n} from \"./class-name\";\n\ntype AttributeKey<TTagName extends ElementTagName> = keyof ExpandedElementAttributes<TTagName>;\ntype AttributeCandidate<TTagName extends ElementTagName> =\n ExpandedElementAttributes<TTagName>[AttributeKey<TTagName>];\n\nfunction applySingleAttribute<TTagName extends ElementTagName>(\n el: ExpandedElement<TTagName>,\n key: AttributeKey<TTagName>,\n raw: AttributeCandidate<TTagName> | undefined,\n shouldMergeClassName = false,\n): void {\n if (raw == null) return;\n\n if (key === \"style\") {\n applyStyleAttribute(el, raw as ExpandedElementAttributes<TTagName>[\"style\"]);\n return;\n }\n\n const setValue = (v: unknown, merge = false): void => {\n if (v == null) return;\n\n // Special handling for className to merge instead of replace (only for non-reactive updates)\n if (key === 'className' && el instanceof HTMLElement && merge) {\n mergeStaticClassName(el, String(v));\n return;\n }\n\n // SVG elements should always use setAttribute for most attributes\n // because many SVG properties are read-only\n const isSVGElement = el instanceof Element && el.namespaceURI === SVG_NAMESPACE;\n\n if (isSVGElement) {\n // Always use setAttribute for SVG elements\n el.setAttribute(String(key), String(v));\n } else if (key in el) {\n // For HTML elements, try to set as property first\n try {\n (el as Record<string, unknown>)[key as string] = v;\n } catch {\n // If property is read-only, fall back to setAttribute\n if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n }\n } else if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n };\n\n if (isFunction(raw) && raw.length === 0) {\n // Type narrowing: zero-arity function that returns an attribute value\n const resolver = raw as () => AttributeCandidate<TTagName>;\n\n // For reactive className, we need to track which classes are reactive\n // so we can preserve static classes when the reactive className changes\n if (key === 'className' && el instanceof HTMLElement) {\n initReactiveClassName(el);\n\n registerAttributeResolver(el, String(key), resolver, function(v) {\n mergeReactiveClassName(el, String(v || ''));\n });\n } else {\n registerAttributeResolver(el, String(key), resolver, function(v) {\n setValue(v, false);\n });\n }\n } else {\n // Static attributes should merge classNames\n // For className, if there's already a reactive className, add to static classes\n if (key === 'className' && el instanceof HTMLElement) {\n if (hasReactiveClassName(el)) {\n // There's already a reactive className; update the tracked set and DOM atomically.\n const newClassName = String(raw || '');\n if (newClassName) {\n addStaticClasses(el, newClassName);\n mergeStaticClassName(el, newClassName);\n }\n return;\n }\n }\n setValue(raw, shouldMergeClassName);\n }\n}\n\nexport function applyAttributes<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n attributes: ExpandedElementAttributes<TTagName>,\n mergeClassName = true,\n): void {\n if (!attributes) return;\n for (const k of Object.keys(attributes) as Array<AttributeKey<TTagName>>) {\n const value = (attributes as Record<string, unknown>)[k as string] as\n AttributeCandidate<TTagName> | undefined;\n // Only merge className for non-className keys OR when explicitly enabled for className\n const shouldMerge = mergeClassName && k === 'className';\n applySingleAttribute(element, k, value, shouldMerge);\n }\n}\n\nexport { createReactiveTextNode } from \"../update/reactive-text\";\n","/**\n * Hydration context — tracks global hydration state and per-parent cursor positions.\n *\n * During hydration the component tree is built against an existing DOM tree\n * (produced by SSR). Instead of creating new nodes, factories claim existing\n * children from their parent element by advancing a cursor.\n *\n * The cursor is a *node pointer* (the next unclaimed child), not an index.\n * Indexed childNodes access is O(n) after any tree/attribute mutation in\n * jsdom (live NodeList re-materialization) which made hydration O(n²);\n * firstChild/nextSibling pointers are O(1) in every DOM implementation.\n */\n\nlet _hydrating = false;\n// True while renderToString() is building a tree destined for serialization.\nlet _serializing = false;\n// Missing entry = cursor at parent.firstChild; null = past the last child.\nlet _cursors = new WeakMap<Node, Node | null>();\n\nexport function isHydrating(): boolean {\n return _hydrating;\n}\n\n/**\n * True while a tree is being built for SSR serialization (inside\n * renderToString). Text children must keep their `<!-- text-N -->` markers in\n * this mode so the emitted HTML stays hydratable — even when `isBrowser` is\n * true (SSR running under jsdom, or an isomorphic worker that provides a DOM).\n * A pure client render leaves this false and skips the markers.\n */\nexport function isSerializing(): boolean {\n return _serializing;\n}\n\n/**\n * Runs `fn` with serialization mode enabled, restoring the previous state\n * afterwards (so nested/re-entrant renderToString calls behave correctly).\n */\nexport function runSerializing<T>(fn: () => T): T {\n const previous = _serializing;\n _serializing = true;\n try {\n return fn();\n } finally {\n _serializing = previous;\n }\n}\n\nexport function startHydration(): void {\n _hydrating = true;\n // Each hydration pass starts with a clean cursor slate. Stale cursors from\n // a previous pass would desynchronize claims when a container's content is\n // replaced and re-hydrated (HMR, islands re-mounting).\n _cursors = new WeakMap<Node, Node | null>();\n}\n\nexport function endHydration(): void {\n _hydrating = false;\n}\n\n/**\n * Runs a callback with hydration temporarily disabled, restoring the previous\n * state afterwards. Used when a server/client mismatch forces a subtree to be\n * rendered fresh in the middle of a hydration pass — fresh rendering must not\n * claim nodes from the surrounding SSR DOM.\n */\nexport function runWithoutHydration<T>(fn: () => T): T {\n const wasHydrating = _hydrating;\n _hydrating = false;\n try {\n return fn();\n } finally {\n _hydrating = wasHydrating;\n }\n}\n\n/**\n * Returns the next unclaimed child of a parent node (or null at the end)\n * without advancing the cursor.\n */\nexport function peekChild(parent: Node): Node | null {\n const entry = _cursors.get(parent);\n return entry === undefined ? parent.firstChild : entry;\n}\n\n/**\n * Sets the cursor to a specific child node (or null for \"past the end\").\n */\nexport function setCursor(parent: Node, node: Node | null): void {\n _cursors.set(parent, node);\n}\n\nfunction isWhitespaceText(node: Node): boolean {\n return node.nodeType === 3 && !/\\S/.test(node.textContent || '');\n}\n\n/**\n * Advances the cursor past whitespace-only text nodes.\n *\n * Nuclo's own SSR output never produces bare whitespace text nodes (text\n * children are always preceded by a `<!-- text-N -->` marker), so unmarked\n * whitespace comes from the surrounding template or an HTML\n * formatter/minifier. Skipping (without removing) keeps the cursor aligned\n * while leaving the document's visual whitespace untouched.\n */\nexport function skipWhitespaceText(parent: Node): void {\n let child = peekChild(parent);\n let advanced = false;\n while (child && isWhitespaceText(child)) {\n child = child.nextSibling;\n advanced = true;\n }\n if (advanced) {\n setCursor(parent, child);\n }\n}\n\n/**\n * Claims the next child node from parent at the current cursor position.\n * Advances the cursor by one.\n */\nexport function claimChild(parent: Node): Node | null {\n const child = peekChild(parent);\n if (child) {\n setCursor(parent, child.nextSibling);\n }\n return child;\n}\n\n/**\n * Attempts to claim an existing element from the parent during hydration.\n * Returns the claimed element if the next child matches the expected tag, or null.\n */\nexport function claimElement(parent: Node, tagName: string): Element | null {\n if (!_hydrating) return null;\n skipWhitespaceText(parent);\n const candidate = peekChild(parent);\n if (candidate && candidate.nodeType === 1 && (candidate as Element).tagName.toLowerCase() === tagName) {\n return claimChild(parent) as Element;\n }\n return null;\n}\n\n/**\n * Removes unclaimed SSR children from a hydrated element.\n * Must be called after modifiers have been applied to a claimed element.\n * Removes nodes from the cursor through `lastOriginalChild` (the element's\n * last child before modifiers ran) — nodes appended by modifiers come after\n * that boundary and are preserved.\n */\nexport function cleanupUnclaimedChildren(node: Node, lastOriginalChild: Node | null): void {\n if (!lastOriginalChild) return;\n let current = peekChild(node);\n while (current) {\n const next = current === lastOriginalChild ? null : current.nextSibling;\n node.removeChild(current);\n current = next;\n }\n setCursor(node, null);\n}\n","/**\n * Interprets every argument passed to a tag builder: strings/numbers become\n * text nodes, objects become attributes, functions become reactive text or\n * nested builders, Nodes are appended as-is.\n */\nimport { applyAttributes } from \"./attributes\";\nimport { createReactiveTextNode } from \"../update/reactive-text\";\nimport { registerReactiveTextNode } from \"../update/registry\";\nimport { logError } from \"../shared/errors\";\nimport { isFunction, isNode, isObject, isPrimitive, isZeroArityFunction } from \"../shared/type-guards\";\nimport { createComment, createDocumentFragment, createTextNode } from \"../shared/dom\";\nimport { isHydrating, isSerializing, claimChild, peekChild, setCursor, skipWhitespaceText } from \"../hydration\";\nimport { isBrowser } from \"../shared/environment\";\n\n/**\n * Caches the probe result of zero-arity function modifiers so the same\n * function is not re-invoked when it reappears during re-renders.\n */\nexport const modifierProbeCache = new WeakMap<() => unknown, { value: unknown; error: boolean }>();\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n\t| NodeMod<TTagName>\n\t| NodeModFn<TTagName>;\n\n/**\n * Shape returned by cn() helper: a plain object with exactly one key `className`.\n * Typed as readonly to signal it should not be mutated after creation.\n */\ninterface ClassNameOnlyObject {\n\treadonly className: string;\n}\n\nfunction isClassNameOnlyObject(v: unknown): v is ClassNameOnlyObject {\n\treturn (\n\t\tisObject(v) &&\n\t\t!isNode(v) &&\n\t\t'className' in v &&\n\t\ttypeof (v as { className: unknown }).className === 'string' &&\n\t\tObject.keys(v).length === 1\n\t);\n}\n\nfunction nextChildIsTextComment(parent: Node): boolean {\n\tskipWhitespaceText(parent);\n\tconst child = peekChild(parent);\n\treturn !!child && child.nodeType === 8 &&\n\t\t(child as Comment).textContent?.trimStart().startsWith('text-') === true;\n}\n\n/**\n * Claims the text node that follows an already-claimed `<!-- text-N -->`\n * marker and patches its content to the client value.\n *\n * The HTML parser drops empty text nodes, so SSR output for an empty string\n * has a marker with no text node after it — in that case a fresh text node is\n * inserted at the cursor to keep the DOM identical to a client render.\n * Content mismatches (data changed between SSR and hydration) are patched so\n * hydration always converges on the client value.\n */\nfunction claimTextAfterMarker(parent: Node, expected: string): Text | null {\n\tconst next = peekChild(parent);\n\tif (next && next.nodeType === 3) {\n\t\tclaimChild(parent);\n\t\tif (next.textContent !== expected) {\n\t\t\tnext.textContent = expected;\n\t\t}\n\t\treturn next as Text;\n\t}\n\tconst created = createTextNode(expected);\n\tif (!created) return null;\n\tparent.insertBefore(created, next);\n\tsetCursor(parent, next);\n\treturn created;\n}\n\nexport function applyNodeModifier<TTagName extends ElementTagName>(\n\tparent: ExpandedElement<TTagName>,\n\tmodifier: NodeModifier<TTagName>,\n\tindex: number,\n): Node | null {\n\tif (modifier == null) return null;\n\n\tif (isFunction(modifier)) {\n\t\t// Handle zero-argument functions (reactive text or reactive className)\n\t\tif (isZeroArityFunction(modifier)) {\n\t\t\ttry {\n\t\t\t\tlet record = modifierProbeCache.get(modifier);\n\t\t\t\tif (!record) {\n\t\t\t\t\tconst value = modifier();\n\t\t\t\t\trecord = { value, error: false };\n\t\t\t\t\tmodifierProbeCache.set(modifier, record);\n\t\t\t\t}\n\t\t\t\tif (record.error) {\n\t\t\t\t\treturn createReactiveTextChild(index, () => \"\");\n\t\t\t\t}\n\t\t\t\tconst v = record.value;\n\n\t\t\t\t// Detect cn() result: plain object with only a `className` string key\n\t\t\t\tif (isClassNameOnlyObject(v)) {\n\t\t\t\t\tconst classNameFn = (): string => {\n\t\t\t\t\t\tconst result = modifier();\n\t\t\t\t\t\treturn isClassNameOnlyObject(result) ? result.className : \"\";\n\t\t\t\t\t};\n\t\t\t\t\tapplyAttributes(parent, { className: classNameFn } as ExpandedElementAttributes<TTagName>);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif (isPrimitive(v)) {\n\t\t\t\t\t// Nullish probes register as empty reactive text instead of being\n\t\t\t\t\t// dropped: a resolver with no value yet (data still loading) must\n\t\t\t\t\t// stay reactive so a later update() can fill it in. The wrapper\n\t\t\t\t\t// also renders values that become nullish again as \"\" — the raw\n\t\t\t\t\t// resolver would produce the string \"null\".\n\t\t\t\t\tconst safeResolver = (): Primitive => {\n\t\t\t\t\t\tconst next = modifier();\n\t\t\t\t\t\treturn isPrimitive(next) && next != null ? (next as Primitive) : \"\";\n\t\t\t\t\t};\n\t\t\t\t\tconst initial: Primitive = v != null ? (v as Primitive) : \"\";\n\t\t\t\t\tif (isHydrating() && nextChildIsTextComment(parent as unknown as Node)) {\n\t\t\t\t\t\tconst parentNode = parent as unknown as Node;\n\t\t\t\t\t\tclaimChild(parentNode); // skip <!-- text-N --> comment\n\t\t\t\t\t\tconst expected = String(initial);\n\t\t\t\t\t\tconst textNode = claimTextAfterMarker(parentNode, expected);\n\t\t\t\t\t\tif (textNode) {\n\t\t\t\t\t\t\tregisterReactiveTextNode(textNode, {\n\t\t\t\t\t\t\t\tresolver: safeResolver,\n\t\t\t\t\t\t\t\tlastValue: expected,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn createReactiveTextChild(index, safeResolver, initial);\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t} catch (error) {\n\t\t\t\tmodifierProbeCache.set(modifier, { value: undefined, error: true });\n\t\t\t\tlogError(\"Error evaluating reactive text function:\", error);\n\t\t\t\treturn createReactiveTextChild(index, () => \"\");\n\t\t\t}\n\t\t}\n\n\t\t// Handle NodeModFn functions\n\t\tconst produced = (modifier as NodeModFn<TTagName>)(parent, index);\n\t\tif (produced == null) return null;\n\t\tif (isPrimitive(produced)) return createStaticTextChild(index, produced);\n\t\tif (isNode(produced)) return produced;\n\t\tif (isObject(produced)) {\n\t\t\tapplyAttributes(parent, produced as ExpandedElementAttributes<TTagName>);\n\t\t}\n\t\treturn null;\n\t}\n\n\t// Handle non-function modifiers\n\tconst candidate = modifier as NodeMod<TTagName>;\n\tif (isPrimitive(candidate)) {\n\t\tif (isHydrating() && nextChildIsTextComment(parent as unknown as Node)) {\n\t\t\tconst parentNode = parent as unknown as Node;\n\t\t\tclaimChild(parentNode); // skip <!-- text-N --> comment\n\t\t\tclaimTextAfterMarker(parentNode, String(candidate));\n\t\t\treturn null;\n\t\t}\n\t\treturn createStaticTextChild(index, candidate);\n\t}\n\tif (isNode(candidate)) return candidate;\n\tapplyAttributes(parent, candidate as ExpandedElementAttributes<TTagName>);\n\treturn null;\n}\n\n/**\n * Wraps a freshly created text node for insertion.\n *\n * The `<!-- text-N -->` marker only exists so hydration can pair an SSR text\n * node with its client resolver. A pure client render never hydrates, so the\n * marker (and the DocumentFragment that carries it) is dead weight: two extra\n * DOM nodes and a fragment allocation per text child that nothing ever reads.\n * In that case we return the bare text node — halving the per-row DOM node\n * count and the DOM inserts in list-heavy renders.\n *\n * SSR (isBrowser === false, or renderToString's serialization mode) and the\n * hydration-mismatch fresh-render path keep the marker so the emitted/repaired\n * DOM stays hydratable. A null text node (document unavailable) is skipped,\n * matching the previous per-path guards.\n */\nfunction wrapTextNode(index: number, textNode: Node | null): Node | null {\n\tif (isBrowser && !isHydrating() && !isSerializing()) {\n\t\treturn textNode;\n\t}\n\tconst fragment = createDocumentFragment();\n\tif (!fragment) {\n\t\tthrow new Error(\"Failed to create document fragment: document not available\");\n\t}\n\tconst comment = createComment(` text-${index} `);\n\tif (comment) fragment.appendChild(comment);\n\tif (textNode) fragment.appendChild(textNode);\n\treturn fragment;\n}\n\nfunction createReactiveTextChild(\n\tindex: number,\n\tresolver: () => Primitive,\n\tpreEvaluated?: unknown\n): Node | null {\n\treturn wrapTextNode(index, createReactiveTextNode(resolver, preEvaluated));\n}\n\nfunction createStaticTextChild(index: number, value: Primitive): Node | null {\n\treturn wrapTextNode(index, createTextNode(String(value)));\n}\n","/**\n * Element creation: builds HTML/SVG elements and applies the modifier list\n * that was passed to a tag builder (children, attributes, text, on(), ...).\n */\nimport { applyNodeModifier, type NodeModifier } from \"./modifiers\";\nimport { createElement, createElementNS, SVG_NAMESPACE } from \"../shared/dom\";\nimport { claimElement, cleanupUnclaimedChildren } from \"../hydration\";\n\nexport type { NodeModifier };\n\n/**\n * Applies modifiers to an element, appending newly produced Nodes while avoiding\n * duplicate DOM insertions (i.e. only appends if parentNode differs).\n *\n * `localIndex` advances once per appended child so each reactive/static text\n * modifier gets a unique `text-N` marker; it is internal bookkeeping only and\n * is not returned (no production caller consumed the previous result object).\n */\nexport function applyModifiers<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): void {\n if (!modifiers || modifiers.length === 0) return;\n\n let localIndex = startIndex;\n const parentNode = element as unknown as Node & ParentNode;\n\n for (let i = 0; i < modifiers.length; i += 1) {\n const mod = modifiers[i];\n // Fast null/undefined skip\n if (mod == null) continue;\n\n const produced = applyNodeModifier(element, mod, localIndex);\n if (!produced) continue;\n\n // Only append if the node isn't already where we expect\n if (produced.parentNode !== parentNode) {\n parentNode.appendChild(produced);\n }\n localIndex += 1;\n }\n}\n\n/**\n * Creates an HTML element with the specified tag name and applies modifiers to it.\n */\nexport function createHtmlElementWithModifiers<TTagName extends ElementTagName>(\n tagName: TTagName,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>\n): ExpandedElement<TTagName> {\n const el = createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, modifiers, 0);\n return el;\n}\n\n/**\n * Creates an SVG element with the specified tag name and applies modifiers to it.\n */\nexport function createSvgElementWithModifiers<TTagName extends keyof SVGElementTagNameMap>(\n tagName: TTagName,\n modifiers: ReadonlyArray<unknown>\n): SVGElementTagNameMap[TTagName] {\n const el = createElementNS(SVG_NAMESPACE, tagName);\n if (!el) {\n throw new Error(`Failed to create SVG element: ${tagName}`);\n }\n applyModifiers(el as unknown as ExpandedElement<ElementTagName>, modifiers as ReadonlyArray<NodeModifier<ElementTagName>>, 0);\n return el as unknown as SVGElementTagNameMap[TTagName];\n}\n\n\n/**\n * Creates an HTML element factory with the given modifiers.\n */\nfunction createHtmlElementFactory<TTagName extends ElementTagName>(\n tagName: TTagName,\n ...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): DetachedExpandedElementFactory<TTagName> {\n return function(_parent?: ExpandedElement<TTagName>, index = 0): ExpandedElement<TTagName> {\n const parentNode = _parent as unknown as Node | undefined;\n const claimed = parentNode ? claimElement(parentNode, tagName) as ExpandedElement<TTagName> | null : null;\n const el = claimed ?? createElement(tagName) as ExpandedElement<TTagName>;\n const elNode = el as unknown as Node;\n const lastOriginalChild = claimed ? elNode.lastChild : null;\n applyModifiers(el, modifiers as ReadonlyArray<NodeModifier<TTagName>>, index);\n if (claimed) {\n cleanupUnclaimedChildren(elNode, lastOriginalChild);\n }\n return el;\n } as DetachedExpandedElementFactory<TTagName>;\n}\n\n/**\n * Creates an SVG element factory with the given modifiers.\n */\nfunction createSvgElementFactory<TTagName extends keyof SVGElementTagNameMap>(\n tagName: TTagName,\n ...modifiers: Array<unknown>\n): DetachedSVGElementFactory<TTagName> {\n return function(_parent?, index = 0): SVGElementTagNameMap[TTagName] {\n const parentNode = _parent as unknown as Node | undefined;\n const claimed = parentNode ? claimElement(parentNode, tagName) as ExpandedElement | null : null;\n const el = claimed ?? createElementNS(SVG_NAMESPACE, tagName);\n if (!el) {\n throw new Error(`Failed to create SVG element: ${tagName}`);\n }\n const elNode = el as unknown as Node;\n const lastOriginalChild = claimed ? elNode.lastChild : null;\n applyModifiers(el as unknown as ExpandedElement<ElementTagName>, modifiers as ReadonlyArray<NodeModifier<ElementTagName>>, index);\n if (claimed) {\n cleanupUnclaimedChildren(elNode, lastOriginalChild);\n }\n return el as unknown as SVGElementTagNameMap[TTagName];\n } as DetachedSVGElementFactory<TTagName>;\n}\n\n/**\n * Creates an HTML tag builder function.\n */\nexport function createHtmlTagBuilder<TTagName extends ElementTagName>(\n tagName: TTagName,\n): ExpandedElementBuilder<TTagName> {\n return (...mods) => createHtmlElementFactory(tagName, ...mods);\n}\n\n/**\n * Creates an SVG tag builder function.\n */\nexport function createSvgTagBuilder<TTagName extends keyof SVGElementTagNameMap>(\n tagName: TTagName,\n): ExpandedSVGElementBuilder<TTagName> {\n return (...mods) => createSvgElementFactory(tagName, ...mods);\n}\n","/**\n * The HTML/SVG tag catalogue and the code that turns every tag into a global\n * builder function (`div(...)`, `span(...)`, `rectSvg(...)`, ...).\n */\nimport { createHtmlTagBuilder, createSvgTagBuilder } from \"./factory\";\n\nexport const HTML_TAGS = [\n \"a\", \"abbr\", \"address\", \"area\", \"article\", \"aside\", \"audio\", \"b\", \"base\",\n \"bdi\", \"bdo\", \"blockquote\", \"body\", \"br\", \"button\", \"canvas\", \"caption\",\n \"cite\", \"code\", \"col\", \"colgroup\", \"data\", \"datalist\", \"dd\", \"del\", \"details\",\n \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\", \"em\", \"embed\", \"fieldset\", \"figcaption\",\n \"figure\", \"footer\", \"form\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\",\n \"header\", \"hgroup\", \"hr\", \"html\", \"i\", \"iframe\", \"img\", \"input\", \"ins\",\n \"kbd\", \"label\", \"legend\", \"li\", \"link\", \"main\", \"map\", \"mark\", \"menu\",\n \"meta\", \"meter\", \"nav\", \"noscript\", \"object\", \"ol\", \"optgroup\", \"option\",\n \"output\", \"p\", \"picture\", \"pre\", \"progress\", \"q\", \"rp\", \"rt\", \"ruby\", \"s\",\n \"samp\", \"script\", \"search\", \"section\", \"select\", \"slot\", \"small\", \"source\",\n \"span\", \"strong\", \"style\", \"sub\", \"summary\", \"sup\", \"table\", \"tbody\", \"td\",\n \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\", \"time\", \"title\", \"tr\",\n \"track\", \"u\", \"ul\", \"var\", \"video\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nexport const SVG_TAGS = [\n \"a\", \"animate\", \"animateMotion\", \"animateTransform\", \"circle\", \"clipPath\",\n \"defs\", \"desc\", \"ellipse\", \"feBlend\", \"feColorMatrix\", \"feComponentTransfer\",\n \"feComposite\", \"feConvolveMatrix\", \"feDiffuseLighting\", \"feDisplacementMap\",\n \"feDistantLight\", \"feDropShadow\", \"feFlood\", \"feFuncA\", \"feFuncB\", \"feFuncG\",\n \"feFuncR\", \"feGaussianBlur\", \"feImage\", \"feMerge\", \"feMergeNode\", \"feMorphology\",\n \"feOffset\", \"fePointLight\", \"feSpecularLighting\", \"feSpotLight\", \"feTile\",\n \"feTurbulence\", \"filter\", \"foreignObject\", \"g\", \"image\", \"line\", \"linearGradient\",\n \"marker\", \"mask\", \"metadata\", \"mpath\", \"path\", \"pattern\", \"polygon\", \"polyline\",\n \"radialGradient\", \"rect\", \"script\", \"set\", \"stop\", \"style\", \"svg\", \"switch\",\n \"symbol\", \"text\", \"textPath\", \"title\", \"tspan\", \"use\", \"view\",\n] as const satisfies ReadonlyArray<keyof SVGElementTagNameMap>;\n\nexport const SELF_CLOSING_TAGS = [\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\", \"link\", \"meta\",\n \"source\", \"track\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\n\nfunction registerHtmlTag(target: Record<string, unknown>, tagName: ElementTagName): void {\n // Don't overwrite non-function properties (safety check)\n if (tagName in target && typeof target[tagName] !== 'function') {\n return;\n }\n const builder = createHtmlTagBuilder(tagName);\n target[tagName] = builder;\n // `var` is a reserved word, so the declared global is `var_` — register it\n // under that name too (the bare `var` key stays for globalThis[\"var\"] access).\n if (tagName === \"var\") {\n target[\"var_\"] = builder;\n }\n}\n\nfunction registerSvgTag(target: Record<string, unknown>, tagName: keyof SVGElementTagNameMap): void {\n // All SVG tags use camelCase Svg suffix: aSvg, rectSvg, pathSvg, etc.\n const exportName = `${tagName}Svg`;\n\n if (!(exportName in target)) {\n target[exportName] = createSvgTagBuilder(tagName);\n }\n}\n\nexport function registerGlobalTagBuilders(target: Record<string, unknown> = globalThis): void {\n const marker = \"__nuclo_tags_registered\";\n if ((target as Record<string, boolean>)[marker]) return;\n\n // Register SVG tags with Svg suffix\n for (let i = 0; i < SVG_TAGS.length; i++) {\n registerSvgTag(target, SVG_TAGS[i]);\n }\n\n // Register HTML tags\n for (let i = 0; i < HTML_TAGS.length; i++) {\n registerHtmlTag(target, HTML_TAGS[i]);\n }\n\n (target as Record<string, boolean>)[marker] = true;\n}\n","import { isFunction, isTagLike } from \"./type-guards\";\n\ntype RenderableInput<TTagName extends ElementTagName = ElementTagName> =\n | NodeModFn<TTagName>\n | DetachedExpandedElementFactory<TTagName>\n | DetachedSVGElementFactory\n | SVGElementModifierFn\n | ExpandedElement<TTagName>\n | SVGElement\n | Node\n | null\n | undefined;\n\nexport function resolveRenderable<TTagName extends ElementTagName = ElementTagName>(\n result: RenderableInput<TTagName>,\n host: ExpandedElement<TTagName>,\n index: number\n): ExpandedElement<TTagName> | null {\n if (isFunction(result)) {\n const element = (result as (parent: ExpandedElement<TTagName>, index: number) => unknown)(host, index);\n if (element && isTagLike(element)) {\n return element as ExpandedElement<TTagName>;\n }\n return null;\n }\n\n if (result && isTagLike(result)) {\n return result as ExpandedElement<TTagName>;\n }\n\n return null;\n}\n","/**\n * Keyed list runtime: renders `list(provider, render)` blocks and keeps their\n * DOM rows in sync with the provider's items on every update().\n *\n * sync() is a keyed diff over item identity (===):\n * 1. skip when the items are unchanged (arraysEqual),\n * 2. trim rows that already back the same item at the same position from both\n * ends — pure appends, prepends, insertions and deletions then need no\n * keying structures at all,\n * 3. key the remaining window by item identity (same-position rows pinned\n * first, duplicate items matched FIFO), remove the rows whose item is gone,\n * 4. place the window anchored backwards from the row after it: survivors on\n * the longest increasing subsequence of old positions never move, and runs\n * of freshly built rows are batched into DocumentFragments.\n */\nimport { createMarkerPair, createComment, safeRemoveChild, isNodeConnected, createDocumentFragment } from \"../shared/dom\";\nimport { resolveRenderable } from \"../shared/renderables\";\nimport { isHydrating, claimChild, peekChild, setCursor, skipWhitespaceText } from \"../hydration\";\nimport type { ListRenderer, ListRuntime, ListItemRecord, ListItemsInput, ListItemsProvider } from \"./types\";\nimport type { UpdateScope } from \"../update/scope\";\nimport { isBrowser } from \"../shared/environment\";\n\nfunction arraysEqual<T>(a: readonly T[], b: readonly T[]): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\n/**\n * Registry of active list runtimes.\n *\n * The iteration set only holds WeakRefs; the runtime itself lives in a\n * WeakMap keyed by its start marker. This keeps the global registry free of\n * strong references to the runtime (which holds the host element, records,\n * and markers), so removing a list's DOM subtree makes the whole runtime\n * collectible — even if update() is never called again. The\n * FinalizationRegistry prunes dead WeakRefs from the set once the marker is\n * collected; updateListRuntimes() also prunes as it iterates.\n */\nconst activeListRuntimes = new Set<WeakRef<Comment>>();\nconst listRuntimeByMarker = new WeakMap<Comment, ListRuntime<unknown, ElementTagName>>();\nconst listMarkerFinalizer = typeof FinalizationRegistry !== \"undefined\"\n ? new FinalizationRegistry<WeakRef<Comment>>((ref) => { activeListRuntimes.delete(ref); })\n : null;\n\nfunction registerListRuntime(startMarker: Comment, runtime: ListRuntime<unknown, ElementTagName>): void {\n const ref = new WeakRef(startMarker);\n activeListRuntimes.add(ref);\n listRuntimeByMarker.set(startMarker, runtime);\n listMarkerFinalizer?.register(startMarker, ref);\n}\n\nfunction normalizeItems<TItem>(items: ListItemsInput<TItem>): readonly TItem[] {\n return Array.isArray(items) ? items : Array.from(items);\n}\n\nfunction renderItem<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>,\n item: TItem,\n index: number,\n): ExpandedElement<TTagName> | null {\n const result = runtime.renderItem(item, index);\n return resolveRenderable<TTagName>(result, runtime.host, index);\n}\n\n/**\n * Detaches one row eagerly: safeRemoveChild walks the subtree to abort\n * listeners and prune reactive registries before removing the node. Used for\n * partial removals, where the walk is cheap; full clears/replaces use\n * bulkClearRecords instead.\n */\nfunction removeRecord<TItem, TTagName extends ElementTagName>(record: ListItemRecord<TItem, TTagName>): void {\n safeRemoveChild(record.element as unknown as Node);\n}\n\n/**\n * Detaches every record's row element from the DOM with a plain removeChild\n * loop — one call per top-level row, never descending into a row's subtree.\n * Each record's element is a direct child of `parent` (the rows between the two\n * list markers), so iterating records removes exactly the same nodes the\n * markers span.\n *\n * This is O(rows): removeChild is O(1) given the node. We deliberately do NOT\n * use Range.deleteContents() here. Its spec-faithful \"is this node contained?\"\n * check (compareBoundaryPointsPosition → isFollowing) re-walks the tree from\n * the range start for *every* spanned node, which is O(nodes²) in non-native\n * DOM implementations (jsdom) and — because the walk visits descendants — scales\n * with nodes-per-row, so a nested `tr>td>td` row template made replace/clear\n * quadratic where a flat `div` row only looked linear.\n *\n * Unlike removeRecord, this does NOT eagerly walk each subtree to abort\n * listeners and prune reactive registries. That walk is the dominant per-row\n * cost when clearing/replacing a large list, and it is redundant here:\n * - Reactive text/attribute registries hold their targets only through\n * WeakRef/WeakMap, and every update() prunes entries whose node became\n * disconnected (which removeChild makes them). The real-GC tests in\n * test/memory/gc-collectability.test.ts prove a detached subtree is\n * collectible with no eager cleanup and no extra update pass.\n * - Event listeners are tracked in a WeakMap keyed by element and registered\n * with an AbortSignal, so they are released when the element is collected.\n *\n * Returns false (and mutates nothing) when the markers aren't both children of\n * `parent`, so the caller can fall back to per-node removal.\n */\nfunction bulkClearRecords<TItem, TTagName extends ElementTagName>(\n records: ReadonlyArray<ListItemRecord<TItem, TTagName>>,\n parent: Node & ParentNode,\n startMarker: Comment,\n endMarker: Comment,\n): boolean {\n if (startMarker.parentNode !== parent || endMarker.parentNode !== parent) return false;\n\n for (let i = 0; i < records.length; i++) {\n const node = records[i].element as unknown as Node | null;\n // Detach the row (guard against an already-moved/detached element so a\n // stale record can't throw). Children of the row go with it in one call.\n if (node && node.parentNode === parent) parent.removeChild(node);\n }\n return true;\n}\n\n/**\n * Computes a longest strictly-increasing subsequence of `arr` and returns the\n * indices (into `arr`) that belong to it, in ascending order. O(n log n).\n *\n * Used so reordering only moves the minimum number of DOM nodes: records whose\n * old position sits on the increasing subsequence are already in the correct\n * relative order and never touched; everything else is repositioned.\n */\nfunction longestIncreasingSubsequence(arr: number[]): number[] {\n const n = arr.length;\n if (n === 0) return [];\n const predecessor = new Array<number>(n);\n // tails[k] = index into arr of the smallest tail of an increasing\n // subsequence of length k+1.\n const tails: number[] = [];\n for (let i = 0; i < n; i++) {\n const x = arr[i];\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (arr[tails[mid]] < x) lo = mid + 1;\n else hi = mid;\n }\n predecessor[i] = lo > 0 ? tails[lo - 1] : -1;\n if (lo === tails.length) tails.push(i);\n else tails[lo] = i;\n }\n let k = tails.length;\n let idx = tails[k - 1];\n const result = new Array<number>(k);\n while (k > 0) {\n result[--k] = idx;\n idx = predecessor[idx];\n }\n return result;\n}\n\n/**\n * Renders items in [startIndex, endIndexExclusive) and inserts their elements\n * before `anchor` as a single DocumentFragment (falling back to per-node\n * insertion when fragments are unavailable). Appends the created records to\n * `targetRecords` in order.\n */\nfunction buildAndInsert<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>,\n parent: Node & ParentNode,\n items: readonly TItem[],\n startIndex: number,\n endIndexExclusive: number,\n anchor: Node,\n targetRecords: ListItemRecord<TItem, TTagName>[],\n): void {\n const fragment = createDocumentFragment();\n let buffered = 0;\n for (let i = startIndex; i < endIndexExclusive; i++) {\n const item = items[i];\n const element = renderItem(runtime, item, i);\n if (!element) continue;\n targetRecords.push({ item, element });\n const node = element as unknown as Node;\n if (fragment) {\n fragment.appendChild(node);\n buffered++;\n } else {\n parent.insertBefore(node, anchor);\n }\n }\n if (fragment && buffered > 0) parent.insertBefore(fragment, anchor);\n}\n\nexport function sync<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>\n): void {\n const { startMarker, endMarker } = runtime;\n const parent = (startMarker.parentNode ?? (runtime.host as unknown as Node & ParentNode)) as\n Node & ParentNode;\n\n const items = normalizeItems(runtime.itemsProvider());\n\n if (arraysEqual(runtime.lastSyncedItems, items)) return;\n\n const oldRecords = runtime.records;\n const oldLen = oldRecords.length;\n const newLen = items.length;\n\n // Fast path — clear: one removeChild per row, skipping the eager per-subtree\n // cleanup walk (see bulkClearRecords).\n if (newLen === 0) {\n if (oldLen > 0 && !bulkClearRecords(oldRecords, parent, startMarker, endMarker)) {\n for (let i = 0; i < oldLen; i++) removeRecord(oldRecords[i]);\n }\n runtime.records = [];\n runtime.lastSyncedItems = [];\n return;\n }\n\n // Trim rows that already back the same item at the same position from both\n // ends. They never move, and most updates (append, prepend, single insert or\n // delete) reduce to an empty window on one side.\n let prefix = 0;\n const maxTrim = Math.min(oldLen, newLen);\n while (prefix < maxTrim && oldRecords[prefix].item === items[prefix]) prefix++;\n let suffix = 0;\n const maxSuffix = maxTrim - prefix;\n while (suffix < maxSuffix && oldRecords[oldLen - 1 - suffix].item === items[newLen - 1 - suffix]) {\n suffix++;\n }\n\n const oldStart = prefix;\n const oldEnd = oldLen - suffix;\n const newStart = prefix;\n const newEnd = newLen - suffix;\n\n // Every old row was trimmed → pure insertion (first render, append, prepend,\n // middle insert). Build the new rows into one fragment before the row that\n // follows the gap. (An empty new window is a no-op here.)\n if (oldStart === oldEnd) {\n const anchor: Node = oldEnd < oldLen ? (oldRecords[oldEnd].element as unknown as Node) : endMarker;\n if (oldEnd === oldLen) {\n buildAndInsert(runtime, parent, items, newStart, newEnd, anchor, oldRecords);\n } else {\n const fresh: ListItemRecord<TItem, TTagName>[] = [];\n buildAndInsert(runtime, parent, items, newStart, newEnd, anchor, fresh);\n runtime.records = oldRecords.slice(0, oldStart).concat(fresh, oldRecords.slice(oldStart));\n }\n runtime.lastSyncedItems = items.slice();\n return;\n }\n\n // Every new row was trimmed → pure removal. This is always partial (a full\n // clear was handled above), so remove each row eagerly.\n if (newStart === newEnd) {\n for (let i = oldStart; i < oldEnd; i++) removeRecord(oldRecords[i]);\n oldRecords.splice(oldStart, oldEnd - oldStart);\n runtime.lastSyncedItems = items.slice();\n return;\n }\n\n // General keyed diff over the window ---------------------------------------\n const oldWinLen = oldEnd - oldStart;\n const newWinLen = newEnd - newStart;\n\n // sources[j] = index into oldRecords of the record backing new position\n // newStart + j, or -1 when the row must be freshly rendered.\n const sources = new Array<number>(newWinLen).fill(-1);\n // claimed[i - oldStart] = the old record was matched to a new position.\n const claimed = new Uint8Array(oldWinLen);\n let reusedCount = 0;\n\n // Pin records whose item is unchanged at the same position. This keeps\n // duplicate item references attached to their original rows.\n const pinEnd = Math.min(oldEnd, newEnd);\n for (let i = prefix; i < pinEnd; i++) {\n if (oldRecords[i].item === items[i]) {\n sources[i - newStart] = i;\n claimed[i - oldStart] = 1;\n reusedCount++;\n }\n }\n\n // Bucket the remaining old records by item identity, in DOM order. The value\n // is a single old index, promoted to an index array only when the same item\n // occurs more than once (duplicates are matched FIFO).\n const buckets = new Map<TItem, number | number[]>();\n for (let i = oldStart; i < oldEnd; i++) {\n if (claimed[i - oldStart]) continue;\n const item = oldRecords[i].item;\n const entry = buckets.get(item);\n if (entry === undefined) buckets.set(item, i);\n else if (typeof entry === \"number\") buckets.set(item, [entry, i]);\n else entry.push(i);\n }\n\n for (let j = 0; j < newWinLen; j++) {\n if (sources[j] !== -1) continue;\n const entry = buckets.get(items[newStart + j]);\n if (entry === undefined) continue;\n let oldIndex: number;\n if (typeof entry === \"number\") {\n oldIndex = entry;\n buckets.delete(items[newStart + j]);\n } else {\n oldIndex = entry.shift()!;\n if (entry.length === 0) buckets.delete(items[newStart + j]);\n }\n sources[j] = oldIndex;\n claimed[oldIndex - oldStart] = 1;\n reusedCount++;\n }\n\n // Nothing survives anywhere → full replace: bulk-detach all old rows and\n // build every new row into a single fragment.\n if (reusedCount === 0 && oldStart === 0 && oldEnd === oldLen) {\n if (!bulkClearRecords(oldRecords, parent, startMarker, endMarker)) {\n for (let i = 0; i < oldLen; i++) removeRecord(oldRecords[i]);\n }\n const fresh: ListItemRecord<TItem, TTagName>[] = [];\n buildAndInsert(runtime, parent, items, 0, newLen, endMarker, fresh);\n runtime.records = fresh;\n runtime.lastSyncedItems = items.slice();\n return;\n }\n\n // Remove stale rows BEFORE placement. A removed element left in the DOM\n // would end up interleaved with the survivors the placement phase leaves\n // untouched.\n for (let i = oldStart; i < oldEnd; i++) {\n if (!claimed[i - oldStart]) removeRecord(oldRecords[i]);\n }\n\n // Determine the minimal set of survivors that must move. Survivors whose old\n // positions form an increasing subsequence are already correctly ordered.\n let stable: Uint8Array | null = null;\n if (reusedCount > 0) {\n const survivorOldIndices: number[] = [];\n const survivorPositions: number[] = [];\n for (let j = 0; j < newWinLen; j++) {\n if (sources[j] !== -1) {\n survivorOldIndices.push(sources[j]);\n survivorPositions.push(j);\n }\n }\n stable = new Uint8Array(newWinLen);\n const lis = longestIncreasingSubsequence(survivorOldIndices);\n for (let k = 0; k < lis.length; k++) stable[survivorPositions[lis[k]]] = 1;\n }\n\n // Place the window anchored backwards from the first row after it. Runs of\n // freshly created rows are batched into a fragment; survivors on the LIS are\n // left untouched.\n const windowRecords = new Array<ListItemRecord<TItem, TTagName> | null>(newWinLen);\n let nullCount = 0;\n let anchor: Node = oldEnd < oldLen ? (oldRecords[oldEnd].element as unknown as Node) : endMarker;\n let fragment: DocumentFragment | null = null;\n\n for (let j = newWinLen - 1; j >= 0; j--) {\n const src = sources[j];\n\n if (src === -1) {\n // Fresh row. Prefer batching consecutive new rows into a fragment (one\n // DOM insert); prepending keeps ascending order.\n const item = items[newStart + j];\n const element = renderItem(runtime, item, newStart + j);\n if (!element) {\n windowRecords[j] = null;\n nullCount++;\n continue;\n }\n windowRecords[j] = { item, element };\n const node = element as unknown as Node;\n if (!fragment) fragment = createDocumentFragment();\n if (fragment) {\n fragment.insertBefore(node, fragment.firstChild);\n } else {\n // No DocumentFragment available — insert directly and advance the\n // anchor so the next (earlier) row lands before this one.\n parent.insertBefore(node, anchor);\n anchor = node;\n }\n continue;\n }\n\n // Survivor: flush any pending fresh rows (they belong after it), moving\n // the anchor to the first flushed node so this row lands before them.\n const record = oldRecords[src];\n windowRecords[j] = record;\n const node = record.element as unknown as Node;\n if (fragment && fragment.firstChild) {\n const firstFlushed = fragment.firstChild;\n parent.insertBefore(fragment, anchor);\n anchor = firstFlushed;\n fragment = null;\n }\n if (!stable || !stable[j]) {\n parent.insertBefore(node, anchor);\n }\n anchor = node;\n }\n if (fragment && fragment.firstChild) parent.insertBefore(fragment, anchor);\n\n // Stitch the untouched prefix and suffix around the window's records.\n const merged = new Array<ListItemRecord<TItem, TTagName>>(\n oldStart + (newWinLen - nullCount) + (oldLen - oldEnd),\n );\n let w = 0;\n for (let i = 0; i < oldStart; i++) merged[w++] = oldRecords[i];\n for (let j = 0; j < newWinLen; j++) {\n const record = windowRecords[j];\n if (record) merged[w++] = record;\n }\n for (let i = oldEnd; i < oldLen; i++) merged[w++] = oldRecords[i];\n runtime.records = merged;\n runtime.lastSyncedItems = items.slice();\n}\n\nexport function createListRuntime<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n renderItem: ListRenderer<TItem, TTagName>,\n host: ExpandedElement<TTagName>,\n index: number,\n): ListRuntime<TItem, TTagName> {\n if (isHydrating()) {\n return hydrateListRuntime(itemsProvider, renderItem, host, index);\n }\n\n return createListRuntimeNormal(itemsProvider, renderItem, host, index);\n}\n\nfunction createListRuntimeNormal<TItem, TTagName extends ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n renderItem: ListRenderer<TItem, TTagName>,\n host: ExpandedElement<TTagName>,\n index: number,\n): ListRuntime<TItem, TTagName> {\n const { start: startMarker, end: endMarker } = createMarkerPair(\"list\", index);\n\n const runtime: ListRuntime<TItem, TTagName> = {\n itemsProvider,\n renderItem,\n startMarker,\n endMarker,\n records: [],\n host,\n lastSyncedItems: [],\n };\n\n const parentNode = host as unknown as Node & ParentNode;\n parentNode.appendChild(startMarker);\n parentNode.appendChild(endMarker);\n\n sync(runtime);\n\n if (isBrowser) {\n // Register for future update() calls — not needed in SSR\n registerListRuntime(startMarker, runtime as ListRuntime<unknown, ElementTagName>);\n }\n\n return runtime;\n}\n\nfunction hydrateListRuntime<TItem, TTagName extends ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n renderFn: ListRenderer<TItem, TTagName>,\n host: ExpandedElement<TTagName>,\n index: number,\n): ListRuntime<TItem, TTagName> {\n const parentNode = host as unknown as Node & ParentNode;\n\n // Check if next child is actually a list-start comment marker.\n // If not, fall back to normal (non-hydration) list creation.\n skipWhitespaceText(parentNode);\n const candidate = peekChild(parentNode);\n if (!candidate || candidate.nodeType !== 8 ||\n !(candidate as Comment).textContent?.startsWith('list-start-')) {\n return createListRuntimeNormal(itemsProvider, renderFn, host, index);\n }\n\n // Claim existing start marker\n const startMarker = claimChild(parentNode) as Comment;\n\n // Find end marker (without claiming) so we know when to stop.\n // Pairs are depth-counted in case nested list markers share this host.\n let depth = 0;\n let scanNode: Node | null = peekChild(parentNode);\n while (scanNode) {\n if (scanNode.nodeType === 8) {\n const text = (scanNode as Comment).textContent || '';\n if (text.startsWith('list-start-')) {\n depth++;\n } else if (text === 'list-end') {\n if (depth === 0) break;\n depth--;\n }\n }\n scanNode = scanNode.nextSibling;\n }\n let endMarker = scanNode as Comment | null;\n if (!endMarker) {\n // Corrupt/truncated SSR output — recreate the end marker; every item\n // claim below will miss and render fresh.\n const created = createComment('list-end');\n if (created) {\n parentNode.insertBefore(created, startMarker.nextSibling);\n endMarker = created;\n }\n }\n if (!endMarker) {\n return createListRuntimeNormal(itemsProvider, renderFn, host, index);\n }\n\n // Get current items and claim existing elements by running render functions\n const currentItems = normalizeItems(itemsProvider());\n const records: ListItemRecord<TItem, TTagName>[] = [];\n\n for (let i = 0; i < currentItems.length; i++) {\n const result = renderFn(currentItems[i], i);\n const element = resolveRenderable<TTagName>(result, host, i);\n if (element) {\n records.push({ item: currentItems[i], element });\n }\n }\n\n // Reconcile server/client mismatches.\n // 1) Server rendered more items than the client has: remove the leftover\n // nodes between the claim cursor and the end marker.\n let leftover = peekChild(parentNode);\n while (leftover && leftover !== endMarker) {\n const next: Node | null = leftover.nextSibling;\n safeRemoveChild(leftover);\n leftover = next;\n }\n\n // 2) Client has items the claim pass could not match: place them in item\n // order, anchored backwards from the end marker (same strategy as sync()).\n let anchor: Node = endMarker;\n for (let i = records.length - 1; i >= 0; i--) {\n const recordNode = records[i].element as unknown as Node;\n if (recordNode.parentNode !== parentNode || recordNode.nextSibling !== anchor) {\n parentNode.insertBefore(recordNode, anchor);\n }\n anchor = recordNode;\n }\n\n // Advance cursor past end marker\n setCursor(parentNode, endMarker.nextSibling);\n\n const runtime: ListRuntime<TItem, TTagName> = {\n itemsProvider,\n renderItem: renderFn,\n startMarker,\n endMarker,\n records,\n host,\n lastSyncedItems: currentItems.slice(),\n };\n\n if (isBrowser) {\n registerListRuntime(startMarker, runtime as ListRuntime<unknown, ElementTagName>);\n }\n\n return runtime;\n}\n\n/**\n * Drops a disconnected runtime's item/element references. The runtime object\n * can outlive its list (it stays reachable through the WeakMap entry while\n * someone still references the detached subtree), so clearing the records\n * keeps it from pinning the items.\n */\nfunction releaseRuntime(runtime: ListRuntime<unknown, ElementTagName>): void {\n for (let i = 0; i < runtime.records.length; i++) {\n const record = runtime.records[i] as { item: unknown; element: unknown };\n record.element = null;\n record.item = null;\n }\n runtime.records = [];\n runtime.lastSyncedItems = [];\n}\n\nexport function updateListRuntimes(scope?: UpdateScope): void {\n const toDelete: WeakRef<Comment>[] = [];\n\n for (const ref of activeListRuntimes) {\n const startMarker = ref.deref();\n\n // Marker was garbage collected\n if (!startMarker) {\n toDelete.push(ref);\n continue;\n }\n\n const runtime = listRuntimeByMarker.get(startMarker);\n if (!runtime) {\n toDelete.push(ref);\n continue;\n }\n\n // Clean up if disconnected from DOM\n if (!isNodeConnected(startMarker) || !isNodeConnected(runtime.endMarker)) {\n releaseRuntime(runtime);\n listRuntimeByMarker.delete(startMarker);\n toDelete.push(ref);\n continue;\n }\n\n // Skip if outside update scope\n if (scope && !scope.contains(startMarker)) continue;\n\n sync(runtime);\n }\n\n // Clean up dead references\n for (const ref of toDelete) {\n activeListRuntimes.delete(ref);\n }\n}\n","import { createListRuntime } from \"./runtime\";\nimport type { ListRenderer, ListItemsProvider } from \"./types\";\n\n/**\n * Maps items to DOM elements, keeping them in sync with changes.\n * Returns a function compatible with both HTML and SVG contexts.\n */\nexport function list<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n render: ListRenderer<TItem, TTagName>,\n): ListModifier<TTagName> {\n return function<TParent extends ElementTagName>(host: ExpandedElement<TParent>, index: number): Comment {\n const runtime = createListRuntime(itemsProvider, render, host as unknown as ExpandedElement<TTagName>, index);\n // Return the start marker comment node\n // Comment is a Node, making this compatible with both HTML and SVG modifiers\n return runtime.startMarker;\n } as unknown as ListModifier<TTagName>;\n}\n","export type ConditionInput = boolean | (() => boolean);\n\nexport function runCondition(\n condition: () => boolean,\n onError?: (error: unknown) => void\n): boolean {\n try {\n return condition();\n } catch (error) {\n if (onError) {\n onError(error);\n return false;\n }\n throw error;\n }\n}\n\nexport function resolveCondition(\n value: ConditionInput,\n onError?: (error: unknown) => void\n): boolean {\n return typeof value === \"function\" ? runCondition(value, onError) : Boolean(value);\n}\n","import { clearBetweenMarkers, insertNodesBefore, isNodeConnected, withScopedInsertion } from \"../shared/dom\";\nimport { resolveCondition } from \"../shared/conditions\";\nimport type { UpdateScope } from \"../update/scope\";\nimport { applyNodeModifier, modifierProbeCache } from \"../element/modifiers\";\nimport { isFunction, isZeroArityFunction } from \"../shared/type-guards\";\nimport { logError } from \"../shared/errors\";\n\nexport type WhenCondition = boolean | (() => boolean);\nexport type WhenContent<TTagName extends ElementTagName = ElementTagName> =\n NodeMod<TTagName> | NodeModFn<TTagName>;\n\nexport interface WhenGroup<TTagName extends ElementTagName = ElementTagName> {\n condition: WhenCondition;\n content: WhenContent<TTagName>[];\n}\n\nexport interface WhenRuntime<TTagName extends ElementTagName = ElementTagName> {\n startMarker: Comment;\n endMarker: Comment;\n host: ExpandedElement<TTagName>;\n index: number;\n groups: WhenGroup<TTagName>[];\n elseContent: WhenContent<TTagName>[];\n /**\n * Tracks which branch is currently rendered:\n * - null: nothing rendered yet (initial state)\n * - -1: else branch is active\n * - >= 0: groups[activeIndex] is active\n */\n activeIndex: number | null;\n update(): void;\n}\n\n/**\n * Registry of active when runtimes.\n *\n * The iteration set only holds WeakRefs; the runtime itself lives in a\n * WeakMap keyed by its start marker. This keeps the global registry free of\n * strong references to the runtime (which holds the host element, branch\n * content, and markers), so removing the surrounding DOM subtree makes the\n * runtime collectible — even if update() is never called again. The\n * FinalizationRegistry prunes dead WeakRefs once the marker is collected;\n * updateWhenRuntimes() also prunes as it iterates.\n */\nconst activeWhenRuntimes = new Set<WeakRef<Comment>>();\nconst whenRuntimeByMarker = new WeakMap<Comment, WhenRuntime<ElementTagName>>();\nconst whenMarkerFinalizer = typeof FinalizationRegistry !== \"undefined\"\n ? new FinalizationRegistry<WeakRef<Comment>>((ref) => { activeWhenRuntimes.delete(ref); })\n : null;\n\n/**\n * Evaluates which condition branch should be active.\n * Returns the index of the first truthy condition, -1 for else branch, or null for no match.\n */\nexport function evaluateActiveCondition<TTagName extends ElementTagName>(\n groups: ReadonlyArray<WhenGroup<TTagName>>,\n elseContent: ReadonlyArray<WhenContent<TTagName>>\n): number | null {\n for (let i = 0; i < groups.length; i++) {\n if (resolveCondition(groups[i].condition)) {\n return i;\n }\n }\n return elseContent.length > 0 ? -1 : null;\n}\n\n/**\n * Main render function for when/else conditionals.\n * Evaluates conditions, clears old content, and renders the active branch.\n */\nexport function renderWhenContent<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const { groups, elseContent, host, index, endMarker } = runtime;\n\n const newActive = evaluateActiveCondition(groups, elseContent);\n\n // No change needed\n if (newActive === runtime.activeIndex) return;\n\n // Clear previous content and update active index\n clearBetweenMarkers(runtime.startMarker, runtime.endMarker);\n runtime.activeIndex = newActive;\n\n // Nothing to render\n if (newActive === null) return;\n\n // Render the active branch\n const contentToRender = newActive >= 0 ? groups[newActive].content : elseContent;\n const nodes = renderContentItems(contentToRender, host, index, endMarker);\n\n insertNodesBefore(nodes, endMarker);\n}\n\n/**\n * Registers a when runtime for tracking and updates.\n * Uses WeakRef to prevent memory leaks when elements are removed.\n * The runtime object itself is mutable and will be updated in place.\n */\nexport function registerWhenRuntime<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const ref = new WeakRef(runtime.startMarker);\n activeWhenRuntimes.add(ref);\n whenRuntimeByMarker.set(runtime.startMarker, runtime as WhenRuntime<ElementTagName>);\n whenMarkerFinalizer?.register(runtime.startMarker, ref);\n}\n\n/**\n * Updates all active when/else conditional runtimes.\n *\n * Re-evaluates all conditional branches and re-renders if the active branch has changed.\n * Automatically cleans up runtimes that are garbage collected or disconnected from DOM.\n *\n * This function should be called after state changes that affect conditional expressions.\n *\n * @example\n * ```ts\n * isLoggedIn.value = true;\n * updateWhenRuntimes(); // All when() conditionals re-evaluate\n * ```\n */\nexport function updateWhenRuntimes(scope?: UpdateScope): void {\n const toDelete: WeakRef<Comment>[] = [];\n\n for (const ref of activeWhenRuntimes) {\n const startMarker = ref.deref();\n\n // Comment node was garbage collected\n if (startMarker === undefined) {\n toDelete.push(ref);\n continue;\n }\n\n const runtime = whenRuntimeByMarker.get(startMarker);\n if (!runtime) {\n toDelete.push(ref);\n continue;\n }\n\n // Check if markers are still connected to DOM\n if (!isNodeConnected(startMarker) || !isNodeConnected(runtime.endMarker)) {\n whenRuntimeByMarker.delete(startMarker);\n toDelete.push(ref);\n continue;\n }\n\n // Skip if outside update scope\n if (scope && !scope.contains(startMarker)) continue;\n\n try {\n runtime.update();\n } catch (error) {\n // Clean up runtimes that throw errors\n logError(\"when() branch threw during update; unregistering this conditional\", error);\n whenRuntimeByMarker.delete(startMarker);\n toDelete.push(ref);\n }\n }\n\n // Clean up dead references\n for (const ref of toDelete) {\n activeWhenRuntimes.delete(ref);\n }\n}\n\n// ─── Content rendering ───────────────────────────────────────────────────────\n/**\n * Renders a single content item and returns the resulting node if any.\n */\nfunction renderContentItem<TTagName extends ElementTagName>(\n item: WhenContent<TTagName>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node | null {\n if (!isFunction(item)) {\n return applyNodeModifier(host, item, index);\n }\n\n // Zero-arity functions need cache cleared\n if (isZeroArityFunction(item)) {\n modifierProbeCache.delete(item);\n return applyNodeModifier(host, item, index);\n }\n\n // Non-zero-arity functions need scoped insertion to insert before endMarker\n return withScopedInsertion(host, endMarker, () => {\n const maybeNode = applyNodeModifier(host, item, index);\n // Only include nodes that weren't already inserted\n return maybeNode && !maybeNode.parentNode ? maybeNode : null;\n });\n}\n\n/**\n * Renders a list of content items and collects the resulting nodes.\n */\nexport function renderContentItems<TTagName extends ElementTagName>(\n items: ReadonlyArray<WhenContent<TTagName>>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node[] {\n const nodes: Node[] = [];\n for (const item of items) {\n const node = renderContentItem(item, host, index, endMarker);\n if (node) {\n nodes.push(node);\n }\n }\n return nodes;\n}\n","import { createMarkerPair, createComment, clearBetweenMarkers, insertNodesBefore, asParentNode } from \"../shared/dom\";\nimport type { WhenCondition, WhenContent, WhenGroup, WhenRuntime } from \"./runtime\";\nimport { renderWhenContent, registerWhenRuntime, evaluateActiveCondition, renderContentItems } from \"./runtime\";\nimport { isBrowser } from \"../shared/environment\";\nimport { isHydrating, claimChild, peekChild, setCursor, skipWhitespaceText, runWithoutHydration } from \"../hydration\";\nimport { applyNodeModifier } from \"../element/modifiers\";\n\n/**\n * Encodes the active branch into the start marker so hydration can detect\n * server/client branch mismatches: `when-start-{index}-b{branch}` where\n * branch is the group index, -1 for the else branch, or `n` for none.\n */\nfunction encodeBranch(index: number, activeIndex: number | null): string {\n return `when-start-${index}-b${activeIndex === null ? 'n' : activeIndex}`;\n}\n\n/**\n * Reads the branch encoded in an SSR start marker.\n * Returns `undefined` for legacy markers without branch info.\n */\nfunction decodeBranch(markerText: string | null): number | null | undefined {\n const match = /-b(n|-?\\d+)$/.exec(markerText || '');\n if (!match) return undefined;\n return match[1] === 'n' ? null : parseInt(match[1], 10);\n}\n\nclass WhenBuilderImpl<TTagName extends ElementTagName = ElementTagName> {\n private groups: WhenGroup<TTagName>[] = [];\n private elseContent: WhenContent<TTagName>[] = [];\n\n constructor(initialCondition: WhenCondition, ...content: WhenContent<TTagName>[]) {\n this.groups.push({ condition: initialCondition, content });\n }\n\n cloneWith(\n additionalGroup?: WhenGroup<TTagName>,\n newElseContent?: WhenContent<TTagName>[],\n ): WhenBuilderImpl<TTagName> {\n const b = Object.create(WhenBuilderImpl.prototype) as WhenBuilderImpl<TTagName>;\n b.groups = [...this.groups];\n if (additionalGroup) b.groups.push(additionalGroup);\n b.elseContent = newElseContent ?? [...this.elseContent];\n return b;\n }\n\n when(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.groups.push({ condition, content });\n return this;\n }\n\n else(...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.elseContent = content;\n return this;\n }\n\n render(host: ExpandedElement<TTagName>, index: number): Node | null {\n if (!globalThis.document) {\n return null;\n }\n\n if (isHydrating()) {\n return this.hydrateRender(host, index);\n }\n\n return this.freshRender(host, index);\n }\n\n private freshRender(host: ExpandedElement<TTagName>, index: number): Node | null {\n const { start: startMarker, end: endMarker } = createMarkerPair(\"when\", index);\n const runtime = this.createRuntimeFromMarkers(host, index, startMarker, endMarker);\n\n const parent = asParentNode(host);\n parent.appendChild(startMarker);\n parent.appendChild(endMarker);\n\n renderWhenContent(runtime);\n\n // Record which branch was rendered so hydration can detect mismatches.\n startMarker.textContent = encodeBranch(index, runtime.activeIndex);\n\n return startMarker;\n }\n\n private hydrateRender(host: ExpandedElement<TTagName>, index: number): Node | null {\n const parentNode = host as unknown as Node & ParentNode;\n\n // Check if next child is actually a when-start comment marker.\n // If the SSR HTML doesn't contain Nuclo comment markers, fall back\n // to normal rendering (create new markers + render from scratch).\n skipWhitespaceText(parentNode);\n const candidate = peekChild(parentNode);\n if (!candidate || candidate.nodeType !== 8 ||\n !(candidate as Comment).textContent?.startsWith('when-start-')) {\n return this.freshRender(host, index);\n }\n\n // Claim existing start marker\n const startMarker = claimChild(parentNode) as Comment;\n\n // Find end marker (without claiming). Directly nested when() blocks\n // share this host, so matching pairs must be depth-counted.\n let depth = 0;\n let scanNode: Node | null = peekChild(parentNode);\n while (scanNode) {\n if (scanNode.nodeType === 8) {\n const text = (scanNode as Comment).textContent || '';\n if (text.startsWith('when-start-')) {\n depth++;\n } else if (text === 'when-end') {\n if (depth === 0) break;\n depth--;\n }\n }\n scanNode = scanNode.nextSibling;\n }\n let endMarker = scanNode as Comment | null;\n let endMarkerMissing = false;\n if (!endMarker) {\n // Corrupt/truncated SSR output — recreate the end marker right after\n // the start marker and render the branch fresh.\n const created = createComment('when-end');\n if (!created) return startMarker;\n parentNode.insertBefore(created, startMarker.nextSibling);\n endMarker = created;\n endMarkerMissing = true;\n }\n\n // Determine which branch the client wants and which the server rendered.\n const activeIndex = evaluateActiveCondition(this.groups, this.elseContent);\n const serverBranch = decodeBranch(startMarker.textContent);\n const branchMatches = !endMarkerMissing &&\n (serverBranch === undefined || serverBranch === activeIndex);\n\n if (branchMatches) {\n // Re-run active branch content to register reactivity on existing nodes\n if (activeIndex !== null) {\n const contentToRender = activeIndex >= 0 ? this.groups[activeIndex].content : this.elseContent;\n for (const item of contentToRender) {\n applyNodeModifier(host, item as NodeMod<TTagName> | NodeModFn<TTagName>, index);\n }\n }\n } else {\n // Server rendered a different branch (or the markup is unusable):\n // drop the server content and render the client branch fresh.\n clearBetweenMarkers(startMarker, endMarker);\n if (activeIndex !== null) {\n const contentToRender = activeIndex >= 0 ? this.groups[activeIndex].content : this.elseContent;\n const end = endMarker;\n runWithoutHydration(() => {\n const nodes = renderContentItems(contentToRender, host, index, end);\n insertNodesBefore(nodes, end);\n });\n }\n }\n\n // Advance cursor past end marker\n setCursor(parentNode, endMarker.nextSibling);\n\n this.createRuntimeFromMarkers(host, index, startMarker, endMarker, activeIndex);\n\n return startMarker;\n }\n\n private createRuntimeFromMarkers(\n host: ExpandedElement<TTagName>,\n index: number,\n startMarker: Comment,\n endMarker: Comment,\n activeIndex: number | null = null,\n ): WhenRuntime<TTagName> {\n const runtime: WhenRuntime<TTagName> = {\n startMarker,\n endMarker,\n host,\n index,\n groups: [...this.groups],\n elseContent: [...this.elseContent],\n activeIndex,\n update: function() { renderWhenContent(runtime); },\n };\n\n if (isBrowser) {\n registerWhenRuntime(runtime);\n }\n\n return runtime;\n }\n}\n\nexport function createWhenBuilderFunction<TTagName extends ElementTagName>(\n builder: WhenBuilderImpl<TTagName>\n): WhenBuilder<TTagName> {\n const nodeModFn = function(host: ExpandedElement<TTagName>, index: number): Node | null {\n return builder.render(host, index);\n };\n\n return Object.assign(nodeModFn, {\n when: function(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> {\n return createWhenBuilderFunction(builder.cloneWith({ condition, content }));\n },\n else: function(...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> {\n return createWhenBuilderFunction(builder.cloneWith(undefined, content));\n },\n }) as unknown as WhenBuilder<TTagName>;\n}\n\nexport { WhenBuilderImpl };\n","import { WhenBuilderImpl, createWhenBuilderFunction } from \"./builder\";\nimport type { WhenCondition, WhenContent } from \"./runtime\";\n\nexport { updateWhenRuntimes } from \"./runtime\";\n\n/**\n * Creates a conditional rendering block (when/else logic).\n *\n * Renders different content based on boolean conditions, similar to if/else statements.\n * Conditions can be static booleans or reactive functions that are re-evaluated on updates.\n *\n * @param condition - Boolean value or function returning a boolean\n * @param content - Content to render when condition is true\n * @returns A builder that allows chaining additional .when() or .else() branches\n *\n * @example\n * ```ts\n * const isLoggedIn = signal(false);\n *\n * div(\n * when(() => isLoggedIn.value,\n * span('Welcome back!')\n * )\n * .else(\n * button('Login', on('click', () => login()))\n * )\n * )\n * ```\n *\n * @example\n * ```ts\n * // Multiple conditions\n * div(\n * when(() => status.value === 'loading',\n * spinner()\n * )\n * .when(() => status.value === 'error',\n * errorMessage()\n * )\n * .else(\n * contentView()\n * )\n * )\n * ```\n */\nexport function when<TTagName extends ElementTagName = ElementTagName>(\n condition: WhenCondition,\n ...content: WhenContent<TTagName>[]\n): WhenBuilder<TTagName> {\n const builder = new WhenBuilderImpl<TTagName>(condition, ...content);\n return createWhenBuilderFunction(builder);\n}\n","import { createHtmlElementWithModifiers, createSvgElementWithModifiers } from \"../element/factory\";\nimport { isBrowser } from \"../shared/environment\";\nimport {\n ConditionalInfo,\n getConditionalInfo,\n storeConditionalInfo,\n getActiveConditionalNodes,\n unregisterConditionalNode,\n} from \"./registry\";\nimport { runCondition } from \"../shared/conditions\";\nimport { replaceNodeSafely, createConditionalComment, createElement, createElementNS, SVG_NAMESPACE } from \"../shared/dom\";\nimport { logError } from \"../shared/errors\";\nimport type { UpdateScope } from \"./scope\";\n\nfunction createElementFromConditionalInfo<TTagName extends ElementTagName>(\n conditionalInfo: ConditionalInfo<TTagName>\n): ExpandedElement<TTagName> | SVGElement {\n try {\n if (conditionalInfo.isSvg) {\n return createSvgElementWithModifiers(conditionalInfo.tagName as keyof SVGElementTagNameMap, conditionalInfo.modifiers);\n }\n return createHtmlElementWithModifiers(conditionalInfo.tagName, conditionalInfo.modifiers);\n } catch (error) {\n logError(`Error applying modifiers in conditional element \"${conditionalInfo.tagName}\"`, error);\n // Return a basic element without modifiers as fallback\n if (conditionalInfo.isSvg) {\n const el = createElementNS(SVG_NAMESPACE, conditionalInfo.tagName);\n if (!el) {\n throw new Error(`Failed to create SVG element: ${conditionalInfo.tagName}`, { cause: error });\n }\n return el as unknown as SVGElement;\n }\n const el = createElement(conditionalInfo.tagName);\n if (!el) {\n throw new Error(`Failed to create element: ${conditionalInfo.tagName}`, { cause: error });\n }\n return el as ExpandedElement<TTagName>;\n }\n}\n\nfunction updateConditionalNode(node: Element | Comment): void {\n const conditionalInfo = getConditionalInfo(node);\n if (!conditionalInfo) {\n return;\n }\n\n const shouldShow = runCondition(conditionalInfo.condition, (error) => {\n logError(\"Error evaluating conditional condition\", error);\n });\n const isElement = node.nodeType === Node.ELEMENT_NODE;\n\n if (shouldShow && !isElement) {\n const element = createElementFromConditionalInfo(conditionalInfo);\n storeConditionalInfo(element as Node, conditionalInfo);\n replaceNodeSafely(node, element as Node);\n } else if (!shouldShow && isElement) {\n const comment = createConditionalComment(conditionalInfo.tagName);\n if (comment) {\n storeConditionalInfo(comment, conditionalInfo);\n replaceNodeSafely(node, comment);\n }\n }\n}\n\nexport function updateConditionalElements(scope?: UpdateScope): void {\n if (!isBrowser) return;\n\n try {\n const nodes = getActiveConditionalNodes();\n for (const node of nodes) {\n if (!node.isConnected) {\n unregisterConditionalNode(node);\n continue;\n }\n\n if (scope && !scope.contains(node)) continue;\n updateConditionalNode(node as Element | Comment);\n }\n } catch (error) {\n logError(\"Error during conditional elements update\", error);\n }\n}\n","/**\n * scope() – tags an element as the root of a named update scope so\n * `update(\"name\")` can refresh just that part of the page.\n */\nimport { isNodeConnected } from \"../shared/dom\";\nimport { isBrowser } from \"../shared/environment\";\n\nexport interface UpdateScope {\n roots: ReadonlyArray<Element>;\n contains(node: Node): boolean;\n}\n\n\ntype ScopeId = string;\n\n/**\n * Stores weak references to scope root elements.\n * Using WeakRef prevents memory leaks - elements can be garbage collected when removed from DOM.\n */\nconst scopeRootsById = new Map<ScopeId, Set<WeakRef<Element>>>();\n\nfunction normalizeScopeIds(ids: readonly string[]): ScopeId[] {\n const normalized: ScopeId[] = [];\n const seen = new Set<ScopeId>();\n\n for (const raw of ids) {\n if (typeof raw !== \"string\") continue;\n const id = raw.trim();\n if (!id) continue;\n if (seen.has(id)) continue;\n seen.add(id);\n normalized.push(id);\n }\n\n return normalized;\n}\n\nfunction addScopeRoot(id: ScopeId, el: Element): void {\n let set = scopeRootsById.get(id);\n if (!set) {\n set = new Set<WeakRef<Element>>();\n scopeRootsById.set(id, set);\n }\n set.add(new WeakRef(el));\n}\n\nexport function getScopeRoots(ids: readonly string[]): Element[] {\n const scopeIds = normalizeScopeIds(ids);\n if (scopeIds.length === 0) return [];\n\n const roots = new Set<Element>();\n\n for (const id of scopeIds) {\n const set = scopeRootsById.get(id);\n if (!set) continue;\n\n const toDelete: WeakRef<Element>[] = [];\n\n for (const ref of set) {\n const el = ref.deref();\n if (el === undefined) {\n // Element was garbage collected\n toDelete.push(ref);\n continue;\n }\n if (!isNodeConnected(el)) {\n // Element is disconnected, clean it up\n toDelete.push(ref);\n continue;\n }\n roots.add(el);\n }\n\n // Clean up dead and disconnected references\n for (const ref of toDelete) {\n set.delete(ref);\n }\n\n if (set.size === 0) scopeRootsById.delete(id);\n }\n\n return Array.from(roots);\n}\n\nexport function scope<TTagName extends ElementTagName = ElementTagName>(\n ...ids: string[]\n): NodeModFn<TTagName> {\n const scopeIds = normalizeScopeIds(ids);\n\n return function(parent: ExpandedElement<TTagName>): void {\n if (!isBrowser) return;\n if (!(parent instanceof Element)) return;\n for (const id of scopeIds) addScopeRoot(id, parent);\n };\n}\n","/**\n * update() – the heart of nuclo's reactivity. Re-runs every registered\n * reactive part of the page: lists, when() blocks, conditional elements,\n * function-valued attributes and text, then fires a global \"update\" event.\n */\nimport { updateListRuntimes } from \"../list/runtime\";\nimport { notifyReactiveElements } from \"./reactive-attributes\";\nimport { notifyReactiveTextNodes } from \"./reactive-text\";\nimport { updateWhenRuntimes } from \"../when\";\nimport { updateConditionalElements } from \"./conditional\";\nimport { getScopeRoots } from \"./scope\";\nimport { logError } from \"../shared/errors\";\nimport type { UpdateScope } from \"./scope\";\n\n// `satisfies` checks every entry matches the signature without widening the tuple type.\nconst updaters = [\n\tupdateListRuntimes,\n\tupdateWhenRuntimes,\n\tupdateConditionalElements,\n\tnotifyReactiveElements,\n\tnotifyReactiveTextNodes,\n\tdispatchGlobalUpdateEvent,\n] satisfies ReadonlyArray<(scope?: UpdateScope) => void>;\n\nexport function update(...scopeIds: string[]): void {\n\tlet scope: UpdateScope | undefined;\n\n\tif (scopeIds.length > 0) {\n\t\tconst roots = getScopeRoots(scopeIds);\n\n\t\tif (roots.length === 1) {\n\t\t\tconst root = roots[0]!;\n\t\t\tscope = {\n\t\t\t\troots,\n\t\t\t\tcontains: (node) => root.contains(node),\n\t\t\t};\n\t\t} else {\n\t\t\tscope = {\n\t\t\t\troots,\n\t\t\t\tcontains: (node) => {\n\t\t\t\t\tfor (const root of roots) {\n\t\t\t\t\t\tif (root.contains(node)) return true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\tfor (const fn of updaters) fn(scope);\n}\n\nexport function dispatchGlobalUpdateEvent(scope?: UpdateScope): void {\n if (typeof document === \"undefined\") return;\n\n // Scoped update: the event fires on the scope roots (bubbling up from\n // there), not on the whole document — listeners outside the scope's\n // ancestor chain must not observe a scoped update. An unknown scope id\n // (zero roots) dispatches nothing.\n // Unscoped: a single dispatch on body (or document as fallback) — the\n // event bubbles to document on its own; dispatching on both would run\n // document-level listeners twice.\n const targets: readonly EventTarget[] = scope\n ? scope.roots\n : [document.body ?? document];\n\n for (const target of targets) {\n try {\n target.dispatchEvent(new Event(\"update\", { bubbles: true }));\n } catch (error) {\n logError(\"Error dispatching global update event\", error);\n }\n }\n}\n","import { startHydration, endHydration, peekChild, setCursor } from \"./hydration\";\nimport { safeRemoveChild } from \"./shared/dom\";\n\n/**\n * Renders a NodeModFn to a parent element by calling it and appending the result.\n *\n * @param nodeModFn The NodeModFn to render (created by tag builders like div(), h1(), etc.)\n * @param parent The parent element to render into (defaults to document.body)\n * @param index The index to pass to the NodeModFn (defaults to 0)\n * @returns The rendered element\n */\nexport function render<TTagName extends ElementTagName = ElementTagName>(\n nodeModFn: NodeModFn<TTagName>,\n parent?: Element,\n index: number = 0\n): ExpandedElement<TTagName> {\n const targetParent = (parent || document.body) as ExpandedElement<TTagName>;\n const element = nodeModFn(targetParent, index) as ExpandedElement<TTagName>;\n (targetParent as unknown as Node).appendChild(element as Node);\n return element;\n}\n\n/**\n * Hydrates an existing server-rendered DOM tree by walking it in parallel with\n * the component tree, reusing existing nodes and re-attaching reactivity.\n *\n * Instead of clearing the container and creating new DOM nodes (like render()),\n * hydrate() claims existing nodes from the SSR output and registers reactive\n * text nodes, attributes, event listeners, list runtimes, and when runtimes\n * on them.\n *\n * @param nodeModFn The NodeModFn to hydrate (same component used for SSR)\n * @param parent The parent element containing the SSR HTML (defaults to document.body)\n * @returns The hydrated root element\n *\n * @example\n * ```ts\n * // Server: const html = renderToString(div(h1(\"Hello\")));\n * // Client:\n * const app = document.getElementById(\"app\")!;\n * // app.innerHTML already contains the SSR HTML\n * hydrate(div(h1(\"Hello\")), app);\n * ```\n */\nexport function hydrate<TTagName extends ElementTagName = ElementTagName>(\n nodeModFn: NodeModFn<TTagName>,\n parent?: Element,\n): ExpandedElement<TTagName> {\n const targetParent = (parent || document.body) as ExpandedElement<TTagName>;\n const parentNode = targetParent as unknown as Node & ParentNode;\n startHydration();\n try {\n const element = nodeModFn(targetParent, 0) as ExpandedElement<TTagName>;\n const elementNode = element as unknown as Node | null | undefined;\n // Claim failed (empty container or tag mismatch): the factory built a\n // fresh, detached root. Replace the mismatched SSR node at the cursor —\n // or append when there is nothing to replace — so the app is always live\n // in the document. Only the single candidate node is touched; siblings\n // (other roots, scripts) are preserved.\n if (elementNode && elementNode.nodeType === 1 && elementNode.parentNode !== parentNode) {\n const stale = peekChild(parentNode);\n if (stale) {\n const after = stale.nextSibling;\n parentNode.insertBefore(elementNode, stale);\n safeRemoveChild(stale);\n setCursor(parentNode, after);\n } else {\n parentNode.appendChild(elementNode);\n setCursor(parentNode, null);\n }\n }\n return element;\n } finally {\n endHydration();\n }\n}\n","/**\n * Shared atomic-CSS engine state.\n *\n * One stylesheet, one rule registry, shared by every `createCss` instance so\n * identical declarations dedupe globally and cascade order stays deterministic:\n * base rules first (insertion order), then one grouping rule per at-rule query\n * in registration order (theme `screens` order).\n *\n * Browser: rules are injected through CSSOM with O(1) appends — no rescans.\n * SSR: rules accumulate in the registry; `getCssText()` serializes them.\n */\n\n// SSR collector — optional hook that receives every newly minted rule string\n// (wrapped in its at-rule, if any). Installed once at server startup.\ntype SSRCollector = (rule: string) => void;\nlet ssrCollector: SSRCollector | null = null;\n\nexport function setSSRCollector(fn: SSRCollector | null): void {\n\tssrCollector = fn;\n}\n\n// Registry — the source of truth for all generated CSS.\n// atomCache: declaration key -> class name (dedup)\n// atomOwner: class name -> conflict key (query|suffix|property), used by cx()\nconst atomCache = new Map<string, string>();\nconst atomOwner = new Map<string, string>();\nconst rawKeys = new Set<string>();\nconst baseRules: string[] = [];\nconst queryRules = new Map<string, string[]>();\n\n// Memoized getCssText() output. SSR calls getCssText() once per request, but the\n// rule set is stable after warmup — so the serialized sheet is recomputed only\n// when a new rule is actually recorded. Invalidated in record() and resetStyles().\nlet cssTextCache: string | null = null;\n\n// Browser CSSOM state. Base rules occupy [0, baseRuleCount); grouping rules\n// (one per query, created in registration order) live after them. CSSRule\n// references stay live when indices shift, so insertion never rescans.\nlet sheet: CSSStyleSheet | null = null;\nlet sheetDocument: Document | null = null;\nlet baseRuleCount = 0;\nconst groupRules = new Map<string, CSSGroupingRule>();\n\n/** Pre-register at-rule queries so their cascade order follows theme order. */\nexport function registerQueries(queries: Iterable<string>): void {\n\tfor (const query of queries) {\n\t\tif (!queryRules.has(query)) queryRules.set(query, []);\n\t}\n}\n\nfunction createGroup(s: CSSStyleSheet, query: string): CSSGroupingRule | null {\n\ttry {\n\t\tconst idx = s.cssRules.length;\n\t\ts.insertRule(query + \"{}\", idx);\n\t\tconst group = s.cssRules[idx] as CSSGroupingRule;\n\t\tgroupRules.set(query, group);\n\t\treturn group;\n\t} catch {\n\t\treturn null; // unsupported at-rule in this environment\n\t}\n}\n\nfunction insertBase(s: CSSStyleSheet, rule: string): void {\n\ttry {\n\t\ts.insertRule(rule, baseRuleCount);\n\t\tbaseRuleCount++;\n\t} catch {\n\t\t// Invalid value/selector: drop the declaration, like browsers do for bad CSS.\n\t}\n}\n\n/**\n * Returns the live stylesheet, (re)binding when the document changes — e.g.\n * fresh jsdom documents between tests. Rebinding replays the whole registry,\n * which replaces v1's per-call classExistsInDOM() DOM scans with a single\n * replay per document.\n */\nfunction ensureSheet(): CSSStyleSheet | null {\n\tif (typeof document === \"undefined\") return null;\n\t// The nuclo SSR polyfill provides a document without getElementById — in\n\t// that context rules accumulate in the registry for getCssText() only.\n\tif (typeof document.getElementById !== \"function\") return null;\n\tif (sheet && sheetDocument === document && sheet.ownerNode && (sheet.ownerNode as Element).isConnected) {\n\t\treturn sheet;\n\t}\n\tlet el = document.getElementById(\"nuclo-styles\") as HTMLStyleElement | null;\n\tif (!el) {\n\t\tel = document.createElement(\"style\");\n\t\tel.id = \"nuclo-styles\";\n\t\tdocument.head.appendChild(el);\n\t}\n\tsheet = el.sheet;\n\tsheetDocument = document;\n\tgroupRules.clear();\n\tbaseRuleCount = 0;\n\tif (!sheet) return null;\n\tfor (const rule of baseRules) insertBase(sheet, rule);\n\tfor (const [query, rules] of queryRules) {\n\t\tconst group = createGroup(sheet, query);\n\t\tif (group) {\n\t\t\tfor (const rule of rules) {\n\t\t\t\ttry {\n\t\t\t\t\tgroup.insertRule(rule, group.cssRules.length);\n\t\t\t\t} catch { /* drop invalid rule */ }\n\t\t\t}\n\t\t}\n\t}\n\treturn sheet;\n}\n\nfunction record(rule: string, query: string | undefined): void {\n\tif (query === undefined) {\n\t\tbaseRules.push(rule);\n\t} else {\n\t\tlet bucket = queryRules.get(query);\n\t\tif (!bucket) {\n\t\t\tbucket = [];\n\t\t\tqueryRules.set(query, bucket);\n\t\t}\n\t\tbucket.push(rule);\n\t}\n\tcssTextCache = null; // a new rule changes the serialized sheet\n\tssrCollector?.(query === undefined ? rule : query + \"{\" + rule + \"}\");\n\n\tconst s = ensureSheet();\n\tif (!s) return;\n\tif (query === undefined) {\n\t\tinsertBase(s, rule);\n\t} else {\n\t\tconst group = groupRules.get(query) ?? createGroup(s, query);\n\t\tif (group) {\n\t\t\ttry {\n\t\t\t\tgroup.insertRule(rule, group.cssRules.length);\n\t\t\t} catch { /* drop invalid rule */ }\n\t\t}\n\t}\n}\n\n/**\n * Order-independent 53-bit content hash (two interleaved FNV-1a style passes).\n * Class names must match between server and client for SSR hydration, so a\n * counter is not an option; 53 bits keeps collision odds negligible (~1e-5 at\n * 10k unique declarations).\n */\nexport function hash(input: string): string {\n\tlet a = 0x811c9dc5;\n\tlet b = 0x7ee3623b;\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst c = input.charCodeAt(i);\n\t\ta = Math.imul(a ^ c, 0x01000193);\n\t\tb = Math.imul(b ^ c, 0x85ebca6b);\n\t}\n\treturn (a >>> 0).toString(36) + ((b >>> 9) % 1296).toString(36);\n}\n\n/** One class per (query, selector-suffix, declaration) — the atomic core. */\nexport function atom(query: string | undefined, suffix: string, property: string, value: string): string {\n\tconst declKey = (query ?? \"\") + \"|\" + suffix + \"|\" + property + \":\" + value;\n\tlet className = atomCache.get(declKey);\n\tif (className !== undefined) {\n\t\t// Touch the sheet so a swapped document (tests) gets the replayed rules.\n\t\tensureSheet();\n\t\treturn className;\n\t}\n\tclassName = \"n\" + hash(declKey);\n\tatomCache.set(declKey, className);\n\tatomOwner.set(className, (query ?? \"\") + \"|\" + suffix + \"|\" + property);\n\trecord(\".\" + className + suffix + \"{\" + property + \":\" + value + \"}\", query);\n\treturn className;\n}\n\n/** Conflict key for a generated class — lets cx() resolve overrides exactly. */\nexport function conflictKeyOf(className: string): string | undefined {\n\treturn atomOwner.get(className);\n}\n\n/** Register a non-atomic rule (keyframes, global styles) once per dedupe key. */\nexport function addRawRule(dedupeKey: string, rule: string): void {\n\tif (rawKeys.has(dedupeKey)) {\n\t\tensureSheet();\n\t\treturn;\n\t}\n\trawKeys.add(dedupeKey);\n\trecord(rule, undefined);\n}\n\n/** All generated CSS — base rules first, then at-rule groups in registration order. */\nexport function getCssText(): string {\n\tif (cssTextCache !== null) return cssTextCache;\n\tlet out = baseRules.join(\"\");\n\tfor (const [query, rules] of queryRules) {\n\t\tif (rules.length > 0) out += query + \"{\" + rules.join(\"\") + \"}\";\n\t}\n\tcssTextCache = out;\n\treturn out;\n}\n\n/** Clear all engine state (test helper). Removes the injected style element. */\nexport function resetStyles(): void {\n\tatomCache.clear();\n\tatomOwner.clear();\n\trawKeys.clear();\n\tbaseRules.length = 0;\n\tqueryRules.clear();\n\tgroupRules.clear();\n\tcssTextCache = null;\n\tbaseRuleCount = 0;\n\tsheet = null;\n\tsheetDocument = null;\n\tif (typeof document !== \"undefined\") {\n\t\tdocument.getElementById(\"nuclo-styles\")?.remove();\n\t}\n}\n","/**\n * nuclo styling — atomic, theme-aware, typed CSS-in-TS.\n *\n * One typed object in, a set of reusable atomic classes out:\n *\n * const { css, cx } = createCss({\n * colors: { primary: \"#6366f1\" },\n * screens: { md: \"(min-width: 768px)\" },\n * });\n * const button = css({ px: 24, py: 12, bg: \"primary\", rounded: 8, hover: { bg: \"#4f46e5\" } });\n * div(button, \"Save\"); // button is { className } — a regular nuclo attributes object\n */\nimport { atom, addRawRule, conflictKeyOf, hash, registerQueries } from \"./engine\";\n\n// ---------------------------------------------------------------------------\n// Types live in types/style.d.ts (shipped with the package) so the published\n// global declarations can import them without reaching into unpublished src/.\n// They are re-exported here so module-style consumers keep the same surface.\n// ---------------------------------------------------------------------------\nimport type {\n\tClassInput,\n\tCssInstance,\n\tFlatStyle,\n\tKeyframeFrames,\n\tPseudo,\n\tStyle,\n\tStyleResult,\n\tThemeConfig,\n\tVariantDefinitions,\n\tVariantProps,\n\tVariantsConfig,\n\tVariantsFn,\n} from \"../../types/style\";\n\nexport type {\n\tClassInput,\n\tCssInstance,\n\tCSSProperties,\n\tFlatStyle,\n\tKeyframeFrames,\n\tKeyframeStop,\n\tPseudo,\n\tSize,\n\tStyle,\n\tStyleResult,\n\tThemeConfig,\n\tVariantDefinitions,\n\tVariantProps,\n\tVariantsConfig,\n\tVariantsFn,\n} from \"../../types/style\";\n\n\nconst PSEUDO = {\n\thover: \":hover\",\n\tfocus: \":focus\",\n\tfocusVisible: \":focus-visible\",\n\tfocusWithin: \":focus-within\",\n\tactive: \":active\",\n\tvisited: \":visited\",\n\tdisabled: \":disabled\",\n\tenabled: \":enabled\",\n\tchecked: \":checked\",\n\trequired: \":required\",\n\tinvalid: \":invalid\",\n\tvalid: \":valid\",\n\treadOnly: \":read-only\",\n\tfirst: \":first-child\",\n\tlast: \":last-child\",\n\tonly: \":only-child\",\n\todd: \":nth-child(odd)\",\n\teven: \":nth-child(even)\",\n\tempty: \":empty\",\n\tplaceholderShown: \":placeholder-shown\",\n\tplaceholder: \"::placeholder\",\n\tbefore: \"::before\",\n\tafter: \"::after\",\n\tselection: \"::selection\",\n\tmarker: \"::marker\",\n\tfirstLine: \"::first-line\",\n\tfirstLetter: \"::first-letter\",\n} as const satisfies Record<Pseudo, string>;\n\n// ---------------------------------------------------------------------------\n// Runtime tables\n// ---------------------------------------------------------------------------\nconst ALIAS: Record<string, readonly string[]> = {\n\tbg: [\"background\"],\n\tp: [\"padding\"],\n\tpx: [\"padding-left\", \"padding-right\"],\n\tpy: [\"padding-top\", \"padding-bottom\"],\n\tpt: [\"padding-top\"], pr: [\"padding-right\"], pb: [\"padding-bottom\"], pl: [\"padding-left\"],\n\tm: [\"margin\"],\n\tmx: [\"margin-left\", \"margin-right\"],\n\tmy: [\"margin-top\", \"margin-bottom\"],\n\tmt: [\"margin-top\"], mr: [\"margin-right\"], mb: [\"margin-bottom\"], ml: [\"margin-left\"],\n\tw: [\"width\"], h: [\"height\"],\n\tminW: [\"min-width\"], maxW: [\"max-width\"], minH: [\"min-height\"], maxH: [\"max-height\"],\n\tsize: [\"width\", \"height\"],\n\ttext: [\"font-size\"],\n\tfont: [\"font-family\"],\n\tweight: [\"font-weight\"],\n\tleading: [\"line-height\"],\n\ttracking: [\"letter-spacing\"],\n\talign: [\"text-align\"],\n\titems: [\"align-items\"],\n\tjustify: [\"justify-content\"],\n\tz: [\"z-index\"],\n\trounded: [\"border-radius\"],\n\tshadow: [\"box-shadow\"],\n\tselect: [\"user-select\"],\n};\n\nconst COMPOSITE: Record<string, Record<string, string>> = {\n\trow: { display: \"flex\", \"flex-direction\": \"row\" },\n\tcol: { display: \"flex\", \"flex-direction\": \"column\" },\n\tcenter: { \"align-items\": \"center\", \"justify-content\": \"center\" },\n\ttruncate: { overflow: \"hidden\", \"text-overflow\": \"ellipsis\", \"white-space\": \"nowrap\" },\n};\n\n/** CSS property → theme token table it resolves against. */\nconst TOKEN_PROP: Record<string, keyof ThemeConfig> = {\n\tbackground: \"colors\",\n\t\"background-color\": \"colors\",\n\tcolor: \"colors\",\n\t\"border-color\": \"colors\",\n\t\"border-top-color\": \"colors\",\n\t\"border-right-color\": \"colors\",\n\t\"border-bottom-color\": \"colors\",\n\t\"border-left-color\": \"colors\",\n\t\"outline-color\": \"colors\",\n\t\"caret-color\": \"colors\",\n\t\"text-decoration-color\": \"colors\",\n\t\"font-family\": \"fonts\",\n\t\"box-shadow\": \"shadows\",\n\t\"border-radius\": \"radii\",\n};\n\n/** Properties where bare numbers stay unitless instead of becoming px. */\nconst UNITLESS = new Set([\n\t\"z-index\", \"opacity\", \"font-weight\", \"line-height\", \"flex\", \"flex-grow\",\n\t\"flex-shrink\", \"order\", \"aspect-ratio\", \"zoom\", \"scale\", \"column-count\",\n\t\"orphans\", \"widows\", \"tab-size\", \"animation-iteration-count\", \"grid-column\", \"grid-row\",\n]);\n\nconst kebabCache = new Map<string, string>();\nfunction kebab(prop: string): string {\n\tlet out = kebabCache.get(prop);\n\tif (out === undefined) {\n\t\tout = prop.replace(/[A-Z]/g, (m) => \"-\" + m.toLowerCase());\n\t\tkebabCache.set(prop, out);\n\t}\n\treturn out;\n}\n\nfunction toQuery(screen: string): string {\n\treturn screen.charCodeAt(0) === 64 /* @ */ ? screen : \"@media \" + screen;\n}\n\nfunction combineQuery(outer: string | undefined, inner: string): string {\n\t// Nested @media conditions combine with \"and\"; other combinations: inner wins.\n\tif (outer !== undefined && outer.startsWith(\"@media\") && inner.startsWith(\"@media\")) {\n\t\treturn outer + \" and\" + inner.slice(6);\n\t}\n\treturn inner;\n}\n\nfunction makeResult(className: string): StyleResult {\n\tconst result = { className } as StyleResult;\n\t// Non-enumerable: attribute application iterates Object.keys() and must\n\t// only see className.\n\tObject.defineProperty(result, \"toString\", {\n\t\tvalue: () => className,\n\t\tenumerable: false,\n\t});\n\treturn result;\n}\n\nfunction collectClasses(inputs: readonly ClassInput[], picked: Map<string, string>): void {\n\tfor (const input of inputs) {\n\t\tif (!input) continue;\n\t\tif (typeof input === \"string\") {\n\t\t\tfor (const name of input.split(\" \")) {\n\t\t\t\tif (name) picked.set(conflictKeyOf(name) ?? name, name);\n\t\t\t}\n\t\t} else if (Array.isArray(input)) {\n\t\t\tcollectClasses(input, picked);\n\t\t} else {\n\t\t\tfor (const name of (input as StyleResult).className.split(\" \")) {\n\t\t\t\tif (name) picked.set(conflictKeyOf(name) ?? name, name);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Compose class lists with exact conflict resolution: when two inputs style\n * the same (query, selector, property), the last one wins. Works because the\n * engine knows what every class it generated means. Nested arrays are flattened,\n * so `cx([a, cond && b], c)` composes the same as `cx(a, cond && b, c)`.\n */\nexport function cx(...inputs: ClassInput[]): StyleResult {\n\tconst picked = new Map<string, string>();\n\tcollectClasses(inputs, picked);\n\tlet className = \"\";\n\tfor (const name of picked.values()) className += (className ? \" \" : \"\") + name;\n\treturn makeResult(className);\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\nexport function createCss<const T extends ThemeConfig>(theme: T = {} as T): CssInstance<T> {\n\tconst screens: Record<string, string> = theme.screens ?? {};\n\tregisterQueries(Object.values(screens).map(toQuery));\n\n\tconst memo = new WeakMap<object, StyleResult>();\n\n\tfunction toCssValue(prop: string, value: string | number): string {\n\t\tif (typeof value === \"number\") {\n\t\t\treturn value === 0 || UNITLESS.has(prop) ? String(value) : value + \"px\";\n\t\t}\n\t\tconst group = TOKEN_PROP[prop];\n\t\tif (group !== undefined) {\n\t\t\tconst hit = (theme[group] as Record<string, string> | undefined)?.[value];\n\t\t\tif (hit !== undefined) return hit;\n\t\t}\n\t\treturn value;\n\t}\n\n\tfunction walk(style: Record<string, unknown>, query: string | undefined, suffix: string, out: string[]): void {\n\t\tfor (const key in style) {\n\t\t\tconst value = style[key];\n\t\t\tif (value == null || value === false) continue;\n\n\t\t\tif (typeof value === \"object\") {\n\t\t\t\tif (key === \"raw\") {\n\t\t\t\t\tconst raws = value as Record<string, string | number>;\n\t\t\t\t\tfor (const prop in raws) out.push(atom(query, suffix, prop, toCssValue(prop, raws[prop])));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst pseudo = (PSEUDO as Record<string, string | undefined>)[key];\n\t\t\t\tif (pseudo !== undefined) {\n\t\t\t\t\twalk(value as Record<string, unknown>, query, suffix + pseudo, out);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst screen = screens[key];\n\t\t\t\tif (screen !== undefined) {\n\t\t\t\t\twalk(value as Record<string, unknown>, combineQuery(query, toQuery(screen)), suffix, out);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst first = key.charCodeAt(0);\n\t\t\t\tif (first === 38 /* & */) {\n\t\t\t\t\twalk(value as Record<string, unknown>, query, suffix + key.slice(1), out);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (first === 64 /* @ */) {\n\t\t\t\t\twalk(value as Record<string, unknown>, combineQuery(query, key), suffix, out);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcontinue; // unknown nested key — unreachable through the typed API\n\t\t\t}\n\n\t\t\tif (value === true) {\n\t\t\t\tconst composite = COMPOSITE[key];\n\t\t\t\tif (composite) for (const prop in composite) out.push(atom(query, suffix, prop, composite[prop]));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst targets = ALIAS[key];\n\t\t\tif (targets !== undefined) {\n\t\t\t\tfor (const prop of targets) out.push(atom(query, suffix, prop, toCssValue(prop, value as string | number)));\n\t\t\t} else {\n\t\t\t\tconst prop = kebab(key);\n\t\t\t\tout.push(atom(query, suffix, prop, toCssValue(prop, value as string | number)));\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Compile a style object into atomic classes. Idempotent and cached. */\n\tfunction css(style: Style<T>): StyleResult {\n\t\tconst hit = memo.get(style);\n\t\tif (hit) return hit;\n\t\tconst classes: string[] = [];\n\t\twalk(style as Record<string, unknown>, undefined, \"\", classes);\n\t\tconst result = makeResult(classes.join(\" \"));\n\t\tmemo.set(style, result);\n\t\treturn result;\n\t}\n\n\tfunction flatDecls(style: Record<string, unknown>): string {\n\t\tlet decls = \"\";\n\t\tconst push = (prop: string, v: string): void => {\n\t\t\tdecls += (decls ? \";\" : \"\") + prop + \":\" + v;\n\t\t};\n\t\tfor (const key in style) {\n\t\t\tconst value = style[key];\n\t\t\tif (value == null || value === false) continue;\n\t\t\tif (key === \"raw\" && typeof value === \"object\") {\n\t\t\t\tconst raws = value as Record<string, string | number>;\n\t\t\t\tfor (const prop in raws) push(prop, toCssValue(prop, raws[prop]));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (typeof value === \"object\") continue;\n\t\t\tif (value === true) {\n\t\t\t\tconst composite = COMPOSITE[key];\n\t\t\t\tif (composite) for (const prop in composite) push(prop, composite[prop]);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst targets = ALIAS[key];\n\t\t\tif (targets !== undefined) {\n\t\t\t\tfor (const prop of targets) push(prop, toCssValue(prop, value as string | number));\n\t\t\t} else {\n\t\t\t\tconst prop = kebab(key);\n\t\t\t\tpush(prop, toCssValue(prop, value as string | number));\n\t\t\t}\n\t\t}\n\t\treturn decls;\n\t}\n\n\t/** Register a @keyframes block; returns its generated name for use in `animation`. */\n\tfunction keyframes(frames: KeyframeFrames<T>): string {\n\t\tlet body = \"\";\n\t\tfor (const stop in frames) {\n\t\t\tbody += stop + \"{\" + flatDecls(frames[stop] as Record<string, unknown>) + \"}\";\n\t\t}\n\t\tconst name = \"nk\" + hash(body);\n\t\taddRawRule(name, \"@keyframes \" + name + \"{\" + body + \"}\");\n\t\treturn name;\n\t}\n\n\t/** Global selector styles (body, resets). Flat properties only. */\n\tfunction globalStyle(selector: string, style: FlatStyle<T>): void {\n\t\tconst rule = selector + \"{\" + flatDecls(style as Record<string, unknown>) + \"}\";\n\t\taddRawRule(\"g|\" + rule, rule);\n\t}\n\n\t/**\n\t * Compile a typed variants recipe into a call-with-props function.\n\t *\n\t * const button = variants({\n\t * base: { rounded: 8, weight: 600 },\n\t * variants: {\n\t * intent: { primary: { bg: \"primary\" }, danger: { bg: \"danger\" } },\n\t * size: { sm: { px: 8, py: 4 }, lg: { px: 16, py: 10 } },\n\t * block: { true: { display: \"block\", w: \"100%\" } },\n\t * },\n\t * defaultVariants: { intent: \"primary\", size: \"sm\" },\n\t * compoundVariants: [{ intent: \"danger\", size: \"lg\", css: { weight: 700 } }],\n\t * });\n\t * div(button({ intent: \"danger\", size: \"lg\" }), \"Delete\");\n\t *\n\t * Every variant style compiles to atomic classes once, at definition time.\n\t * A call resolves defaults + props into a selection, composes the matching\n\t * precompiled results with cx() (last-wins conflict resolution), and caches\n\t * the composed result per selection — so repeated calls are a Map lookup.\n\t */\n\tfunction variants<const V extends VariantDefinitions<T>>(\n\t\tconfig: VariantsConfig<T, V>,\n\t): VariantsFn<V> {\n\t\tconst normalize = (value: unknown): string =>\n\t\t\tvalue === true ? \"true\" : value === false ? \"false\" : String(value);\n\n\t\tconst groups = (config.variants ?? {}) as Record<string, Record<string, Style<T>>>;\n\t\tconst groupNames = Object.keys(groups);\n\t\tconst defaults = (config.defaultVariants ?? {}) as Record<string, unknown>;\n\n\t\tconst baseResult = config.base ? css(config.base) : null;\n\n\t\t// Precompile every variant value's atomic classes once.\n\t\tconst compiled: Record<string, Record<string, StyleResult>> = {};\n\t\tfor (const group of groupNames) {\n\t\t\tconst values = groups[group];\n\t\t\tconst inner: Record<string, StyleResult> = {};\n\t\t\tfor (const value in values) inner[value] = css(values[value]);\n\t\t\tcompiled[group] = inner;\n\t\t}\n\n\t\t// Precompile compound-variant styles with their match conditions.\n\t\tconst compounds = (config.compoundVariants ?? []).map((entry) => {\n\t\t\tconst { css: compoundStyle, ...match } = entry as VariantProps<V> & { css: Style<T> };\n\t\t\tconst conditions: Record<string, string> = {};\n\t\t\tfor (const group in match) conditions[group] = normalize((match as Record<string, unknown>)[group]);\n\t\t\treturn { conditions, result: css(compoundStyle) };\n\t\t});\n\n\t\tconst cache = new Map<string, StyleResult>();\n\n\t\treturn function recipe(props?: VariantProps<V>): StyleResult {\n\t\t\t// Resolve final selection: defaults, overridden by explicit props.\n\t\t\tconst selection: Record<string, string> = {};\n\t\t\tfor (const group of groupNames) {\n\t\t\t\tconst provided = props ? (props as Record<string, unknown>)[group] : undefined;\n\t\t\t\tconst chosen = provided !== undefined && provided !== null ? provided : defaults[group];\n\t\t\t\tif (chosen === undefined || chosen === null) continue;\n\t\t\t\tselection[group] = normalize(chosen);\n\t\t\t}\n\n\t\t\t// Cache the composed result per selection (stable group order).\n\t\t\tlet key = \"\";\n\t\t\tfor (const group of groupNames) key += group + \"=\" + (selection[group] ?? \"\") + \";\";\n\t\t\tconst cached = cache.get(key);\n\t\t\tif (cached) return cached;\n\n\t\t\tconst parts: ClassInput[] = [];\n\t\t\tif (baseResult) parts.push(baseResult);\n\t\t\tfor (const group of groupNames) {\n\t\t\t\tconst value = selection[group];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tconst result = compiled[group][value];\n\t\t\t\t\tif (result) parts.push(result);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const compound of compounds) {\n\t\t\t\tlet matches = true;\n\t\t\t\tfor (const group in compound.conditions) {\n\t\t\t\t\tif (selection[group] !== compound.conditions[group]) {\n\t\t\t\t\t\tmatches = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (matches) parts.push(compound.result);\n\t\t\t}\n\n\t\t\tconst result = cx(...parts);\n\t\t\tcache.set(key, result);\n\t\t\treturn result;\n\t\t};\n\t}\n\n\treturn { css, cx, variants, keyframes, globalStyle, theme };\n}\n\n// ---------------------------------------------------------------------------\n// Default themeless instance — registered as globals by the runtime bootstrap.\n// Apps with design tokens create their own instance via createCss(theme).\n// ---------------------------------------------------------------------------\nconst defaultInstance = createCss({});\n\n/** Themeless css() — full property/variant typing, no tokens or screens. */\nexport const css: (style: Style<object>) => StyleResult = defaultInstance.css;\n/** Themeless variants() recipe helper. */\nexport const variants: <const V extends VariantDefinitions<object>>(\n\tconfig: VariantsConfig<object, V>,\n) => VariantsFn<V> = defaultInstance.variants;\n/** Themeless keyframes() helper. */\nexport const keyframes: (frames: KeyframeFrames<object>) => string = defaultInstance.keyframes;\n/** Themeless globalStyle() helper. */\nexport const globalStyle: (selector: string, style: FlatStyle<object>) => void = defaultInstance.globalStyle;\n","import { registerGlobalTagBuilders } from \"./element/tags\";\nimport { list } from \"./list\";\nimport { update } from \"./update/update\";\nimport { when } from \"./when\";\nimport { on } from \"./element/events\";\nimport { render, hydrate } from \"./render\";\nimport { scope } from \"./update/scope\";\nimport { createCss, css, cx, variants, keyframes, globalStyle } from \"./style\";\n\n/**\n * Initializes the nuclo runtime by exposing tag builders and utilities.\n */\n\nexport function initializeRuntime(): void {\n registerGlobalTagBuilders();\n\n const registry = globalThis as Record<string, unknown>;\n registry.list = list;\n registry.update = update;\n registry.when = when;\n registry.on = on;\n registry.scope = scope;\n registry.render = render;\n registry.hydrate = hydrate;\n\n // Styling — a themeless default instance plus the factory for themed ones.\n // None of these names collide with window/globalThis properties.\n registry.createCss = createCss;\n registry.css = css;\n registry.cx = cx;\n registry.variants = variants;\n registry.keyframes = keyframes;\n registry.globalStyle = globalStyle;\n}\n\ninitializeRuntime();\n"],"mappings":"mEAAA,SAAgB,EAAY,EAAoC,CAC/D,OAAO,IAAU,MAAS,OAAO,GAAU,UAAY,OAAO,GAAU,UACzE,CAEA,SAAgB,EAAU,EAA6B,CAItD,OAHI,aAAiB,KAAa,GAC9B,OAAO,GAAU,WAAY,EAAuB,GAEjD,OAAQ,EAAiC,UAAa,QAC9D,CAEA,SAAgB,EAAS,EAAiC,CACzD,OAAO,OAAO,GAAU,YAAY,CACrC,CAEA,SAAgB,EAAa,EAA6C,CACzE,OAAO,EAAS,CAAK,GAAK,YAAc,CACzC,CAEA,SAAgB,EAAU,EAAkC,CAC3D,OAAO,OAAO,GAAU,SACzB,CAQA,SAAgB,EAAW,EAA0D,CACpF,OAAO,OAAO,GAAU,UACzB,CAEA,SAAgB,EAAoB,EAAwC,CAC3E,OAAO,EAAW,CAAK,GAAM,EAA6B,SAAW,CACtE,CCnCA,SAAgB,EAAS,EAAiB,EAA+B,CACnE,OAAO,QAAY,KAErB,QAAQ,MAAM,UAAU,IAAW,CAAK,CAE5C,CCAA,MAAa,EAAY,OAAO,OAAW,KAAe,OAAO,SAAa,ICmCxE,EAAmB,IAAI,QAK7B,SAAS,EACP,EACA,EACM,CACN,IAAM,EAAO,EAAiB,IAAI,CAAO,EACrC,EACF,EAAK,KAAK,CAAI,EAEd,EAAiB,IAAI,EAAS,CAAC,CAAI,CAAC,CAExC,CAKA,SAAS,EAAe,EA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M,CAC3D,CAMA,MAAM,EAAkB,GAAU,CAAC,CAAC,EAGvB,GAA6C,EAAgB,IAE7D,GAEQ,EAAgB,SAExB,GAAwD,EAAgB,UAExE,GAAoE,EAAgB,YCnbjG,SAAgB,IAA0B,CACxC,GAA0B,EAE1B,IAAM,EAAW,WACjB,EAAS,KAAO,GAChB,EAAS,OAAS,GAClB,EAAS,KAAO,GAChB,EAAS,GAAK,EACd,EAAS,MAAQ,GACjB,EAAS,OAAS,GAClB,EAAS,QAAU,GAInB,EAAS,UAAY,GACrB,EAAS,IAAM,GACf,EAAS,GAAK,GACd,EAAS,SAAW,GACpB,EAAS,UAAY,GACrB,EAAS,YAAc,EACzB,CAEA,GAAkB"}
@@ -0,0 +1,2 @@
1
+ function e(e){return e===null||typeof e!=`object`&&typeof e!=`function`}function t(e){return e instanceof Node?!0:typeof e!=`object`||!e?!1:typeof e.nodeType==`number`}function n(e){return typeof e==`object`&&!!e}function r(e){return n(e)&&`tagName`in e}function i(e){return typeof e==`boolean`}function a(e){return typeof e==`function`}function o(e){return a(e)&&e.length===0}function s(e,t){typeof console<`u`&&console.error(`nuclo: ${e}`,t)}const c=typeof window<`u`&&typeof document<`u`,l=new WeakMap;function u(e,t){let n=l.get(e);n?n.push(t):l.set(e,[t])}function d(e,t){e.removeEventListener(t.type,t.wrapped,t.options)}function f(e,t){let n=l.get(e);if(!n)return;if(t===void 0){for(let t=0;t<n.length;t++)d(e,n[t]);l.delete(e);return}let r=0;for(let i=0;i<n.length;i++){let a=n[i];a.type===t?d(e,a):n[r++]=a}n.length=r,r===0&&l.delete(e)}function p(e,t,n){return function(r){if(!c||!r||typeof r.addEventListener!=`function`)return;let i=r,a=function(n){try{t.call(i,n)}catch(t){s(`Error in '${e}' listener`,t)}};i.addEventListener(e,a,n),u(i,{type:e,wrapped:a,options:n})}}const m=new Set,h=new WeakMap,g=new Set,_=new WeakMap,v=typeof FinalizationRegistry<`u`?new FinalizationRegistry(e=>{m.delete(e)}):null,y=typeof FinalizationRegistry<`u`?new FinalizationRegistry(e=>{g.delete(e)}):null;function b(e,t){let n=h.get(e);if(n){n.info.resolver=t.resolver,n.info.lastValue=t.lastValue;return}let r=new WeakRef(e);m.add(r),h.set(e,{ref:r,info:t}),v?.register(e,r)}function ee(e,t){let n=new WeakRef(e);g.add(n),_.set(e,{ref:n,info:t}),y?.register(e,n)}function x(e){m.delete(e)}function S(e){g.delete(e)}function C(e){let t=h.get(e);t&&(m.delete(t.ref),h.delete(e))}function te(e){let t=_.get(e);t&&(g.delete(t.ref),_.delete(e))}const w=new WeakMap,T=new Set,E=new WeakMap,D=typeof FinalizationRegistry<`u`?new FinalizationRegistry(e=>{T.delete(e)}):null;function ne(e,t){w.set(e,t);let n=new WeakRef(e);T.add(n),E.set(e,n),D?.register(e,n)}function re(e){w.delete(e);let t=E.get(e);t&&(T.delete(t),E.delete(e))}function ie(){let e=[],t=[];for(let n of T){let r=n.deref();r===void 0?t.push(n):e.push(r)}for(let e of t)T.delete(e);return e}function ae(e){return w.get(e)??null}const oe=`http://www.w3.org/2000/svg`;function se(e){return globalThis.document?document.createElement(e):null}function ce(e,t){return globalThis.document?document.createElementNS(e,t):null}function O(e){return globalThis.document?document.createTextNode(e):null}function le(){return globalThis.document?document.createDocumentFragment():null}function ue(e,t){try{return e.appendChild(t),!0}catch(e){return s(`Failed to append child node`,e),!1}}function de(e){if(e.nodeType===Node.ELEMENT_NODE){let t=e;f(t),te(t),re(t)}else e.nodeType===Node.TEXT_NODE?C(e):e.nodeType===Node.COMMENT_NODE&&re(e);if(e.childNodes&&e.childNodes.length>0)for(let t=0;t<e.childNodes.length;t++)de(e.childNodes[t])}function k(e){if(!e?.parentNode)return!1;try{return de(e),e.parentNode.removeChild(e),!0}catch(e){return s(`Failed to remove child node`,e),!1}}function fe(e,t,n){try{return e.insertBefore(t,n),!0}catch(e){return s(`Failed to insert node before reference`,e),!1}}function A(e){return globalThis.document?globalThis.document.createComment(e):null}function pe(e,t=`hidden`){return globalThis.document?globalThis.document.createComment(`conditional-${e}-${t}`):null}function me(e,t){let n=A(`${e}-end`);if(!n)throw Error(`Failed to create comment: document not available`);let r=A(`${e}-start-${t}`);if(!r)throw Error(`Failed to create comment: document not available`);return{start:r,end:n}}function he(e,t){let n=e.nextSibling;for(;n&&n!==t;){let e=n.nextSibling;k(n),n=e}}function ge(e,t){let n=t.parentNode;if(n)for(let r=0;r<e.length;r++)fe(n,e[r],t)}function _e(e,...t){if(!e)return e;for(let n=0;n<t.length;n++){let r=t[n];if(r!=null){let t;if(typeof r==`string`){let e=O(r);if(e)t=e;else continue}else t=r;ue(e,t)}}return e}function j(e){return e?.isConnected===!0}function ve(e,t){if(!e?.parentNode)return!1;try{return e.parentNode.replaceChild(t,e),!0}catch(e){return s(`Error replacing conditional node`,e),!1}}function ye(e){return e}function be(e,t,n){let r=ye(e),i=r.appendChild.bind(r),a=r.insertBefore.bind(r);r.appendChild=function(e){return a(e,t)};try{return n()}finally{r.appendChild=i}}function xe(e,t,n){try{if(n==null||n===``)return e.style[t]=``,!0;let r=String(n);return e.style[t]=r,!0}catch{return!1}}const Se={};let Ce=!1;function we(e){let t=e.target;if(!t||typeof Node>`u`||!(t instanceof Node))return;let n=t;for(;n;){if(n instanceof Element){let e=_.get(n);e&&(j(n)?ke(e.info):(S(e.ref),_.delete(n)))}n=n.parentNode}}function Te(){Ce||typeof document>`u`||typeof document.addEventListener!=`function`||(document.addEventListener(`update`,we,!0),Ce=!0)}function Ee(e){let t=_.get(e);if(t)return t.info;let n={attributeResolvers:new Map};return ee(e,n),n}function De(e){return typeof e!=`object`||!e}function Oe(e,t){let n;try{n=t.resolver()}catch(t){s(`Failed to resolve reactive attribute: ${e}`,t);return}let r=De(n);if(!(r&&Object.is(n,t.lastValue)))try{t.applyValue(n),t.lastValue=r?n:Se}catch(t){s(`Failed to apply reactive attribute: ${e}`,t)}}function ke(e){for(let[t,n]of e.attributeResolvers)Oe(t,n)}function Ae(e,t,n,r){if(!(e instanceof Element)||!t||typeof n!=`function`){s(`Invalid parameters for registerAttributeResolver`);return}let i={resolver:n,applyValue:r,lastValue:Se};if(!c){Oe(t,i);return}Te(),Ee(e).attributeResolvers.set(t,i),Oe(t,i)}function je(e){let t=[];for(let n of g){let r=n.deref();if(r===void 0){t.push(n);continue}let i=_.get(r);if(!i){t.push(n);continue}if(!j(r)){_.delete(r),t.push(n);continue}e&&!e.contains(r)||ke(i.info)}for(let e of t)S(e)}function Me(e,t){if(!(!e?.style||!t))for(let n in t)xe(e,n,t[n])||s(`Failed to set style property '${n}'`)}function Ne(e,t){e&&(a(t)?Ae(e,`style`,t,function(t){Me(e,t)}):Me(e,t))}const M=new WeakMap,Pe=new WeakSet;function N(e,t){let n=t.length,r=0;for(let i=0;i<=n;i++)(i===n||t.charCodeAt(i)===32)&&(i>r&&e.add(t.substring(r,i)),r=i+1)}function Fe(e){let t=``;for(let n of e)t&&(t+=` `),t+=n;return t}function Ie(e){if(e.className&&!M.has(e)){let t=new Set;N(t,e.className),M.set(e,t)}Pe.add(e)}function Le(e){return Pe.has(e)}function Re(e,t){if(!t)return;let n=M.get(e);n||(n=new Set,M.set(e,n)),N(n,t)}function ze(e,t){let n=M.get(e);if(!n||n.size===0){e.className=t||``;return}if(!t){e.className=Fe(n);return}let r=Fe(n),i=t.length,a=0;for(let e=0;e<=i;e++)if(e===i||t.charCodeAt(e)===32){if(e>a){let i=t.substring(a,e);n.has(i)||(r+=` `+i)}a=e+1}e.className=r}function Be(e,t){if(!t)return;let n=e.className;if(n&&n!==t){let r=new Set;N(r,n),N(r,t),e.className=Fe(r)}else e.className=t}function Ve(e,t){if(typeof e!=`function`){s(`Invalid resolver provided to createReactiveTextNode`);let e=O(``);if(!e)throw Error(`Failed to create text node: document not available`);return e}let n;if(arguments.length>1)n=t;else try{n=e()}catch(e){s(`Failed to evaluate reactive text resolver`,e),n=``}let r=n===void 0?``:String(n),i=O(r);if(!i)throw Error(`Failed to create text node: document not available`);return c&&b(i,{resolver:e,lastValue:r}),i}function He(e){let t=[];for(let n of m){let r=n.deref();if(r===void 0){t.push(n);continue}let i=h.get(r);if(!i){t.push(n);continue}let a=i.info;if(!j(r)){h.delete(r),t.push(n);continue}if(e&&!e.contains(r))continue;let o;try{o=a.resolver()}catch(e){s(`Failed to update reactive text node`,e),o=void 0}let c=o===void 0?``:String(o);c!==a.lastValue&&(r.textContent=c,a.lastValue=c)}for(let e of t)x(e)}function Ue(e,t,n,r=!1){if(n==null)return;if(t===`style`){Ne(e,n);return}let i=(n,r=!1)=>{if(n!=null){if(t===`className`&&e instanceof HTMLElement&&r){Be(e,String(n));return}if(e instanceof Element&&e.namespaceURI===`http://www.w3.org/2000/svg`)e.setAttribute(String(t),String(n));else if(t in e)try{e[t]=n}catch{e instanceof Element&&e.setAttribute(String(t),String(n))}else e instanceof Element&&e.setAttribute(String(t),String(n))}};if(a(n)&&n.length===0){let r=n;t===`className`&&e instanceof HTMLElement?(Ie(e),Ae(e,String(t),r,function(t){ze(e,String(t||``))})):Ae(e,String(t),r,function(e){i(e,!1)})}else{if(t===`className`&&e instanceof HTMLElement&&Le(e)){let t=String(n||``);t&&(Re(e,t),Be(e,t));return}i(n,r)}}function P(e,t,n=!0){if(t)for(let r of Object.keys(t)){let i=t[r];Ue(e,r,i,n&&r===`className`)}}let F=!1,We=new WeakMap;function I(){return F}function Ge(){return!1}function Ke(){F=!0,We=new WeakMap}function qe(){F=!1}function Je(e){let t=F;F=!1;try{return e()}finally{F=t}}function L(e){let t=We.get(e);return t===void 0?e.firstChild:t}function R(e,t){We.set(e,t)}function Ye(e){return e.nodeType===3&&!/\S/.test(e.textContent||``)}function z(e){let t=L(e),n=!1;for(;t&&Ye(t);)t=t.nextSibling,n=!0;n&&R(e,t)}function B(e){let t=L(e);return t&&R(e,t.nextSibling),t}function Xe(e,t){if(!F)return null;z(e);let n=L(e);return n&&n.nodeType===1&&n.tagName.toLowerCase()===t?B(e):null}function Ze(e,t){if(!t)return;let n=L(e);for(;n;){let r=n===t?null:n.nextSibling;e.removeChild(n),n=r}R(e,null)}const V=new WeakMap;function Qe(e){return n(e)&&!t(e)&&`className`in e&&typeof e.className==`string`&&Object.keys(e).length===1}function $e(e){z(e);let t=L(e);return!!t&&t.nodeType===8&&t.textContent?.trimStart().startsWith(`text-`)===!0}function et(e,t){let n=L(e);if(n&&n.nodeType===3)return B(e),n.textContent!==t&&(n.textContent=t),n;let r=O(t);return r?(e.insertBefore(r,n),R(e,n),r):null}function H(r,i,c){if(i==null)return null;if(a(i)){if(o(i))try{let t=V.get(i);if(t||(t={value:i(),error:!1},V.set(i,t)),t.error)return nt(c,()=>``);let n=t.value;if(Qe(n))return P(r,{className:()=>{let e=i();return Qe(e)?e.className:``}}),null;if(e(n)){let t=()=>{let t=i();return e(t)&&t!=null?t:``},a=n??``;if(I()&&$e(r)){let e=r;B(e);let n=String(a),i=et(e,n);return i&&b(i,{resolver:t,lastValue:n}),null}return nt(c,t,a)}return null}catch(e){return V.set(i,{value:void 0,error:!0}),s(`Error evaluating reactive text function:`,e),nt(c,()=>``)}let a=i(r,c);return a==null?null:e(a)?rt(c,a):t(a)?a:(n(a)&&P(r,a),null)}let l=i;if(e(l)){if(I()&&$e(r)){let e=r;return B(e),et(e,String(l)),null}return rt(c,l)}return t(l)?l:(P(r,l),null)}function tt(e,t){if(c&&!I()&&!Ge())return t;let n=le();if(!n)throw Error(`Failed to create document fragment: document not available`);let r=A(` text-${e} `);return r&&n.appendChild(r),t&&n.appendChild(t),n}function nt(e,t,n){return tt(e,Ve(t,n))}function rt(e,t){return tt(e,O(String(t)))}function U(e,t,n=0){if(!t||t.length===0)return;let r=n,i=e;for(let n=0;n<t.length;n+=1){let a=t[n];if(a==null)continue;let o=H(e,a,r);o&&(o.parentNode!==i&&i.appendChild(o),r+=1)}}function it(e,t){let n=se(e);return U(n,t,0),n}function at(e,t){let n=ce(oe,e);if(!n)throw Error(`Failed to create SVG element: ${e}`);return U(n,t,0),n}function ot(e,...t){return function(n,r=0){let i=n,a=i?Xe(i,e):null,o=a??se(e),s=o,c=a?s.lastChild:null;return U(o,t,r),a&&Ze(s,c),o}}function st(e,...t){return function(n,r=0){let i=n,a=i?Xe(i,e):null,o=a??ce(`http://www.w3.org/2000/svg`,e);if(!o)throw Error(`Failed to create SVG element: ${e}`);let s=o,c=a?s.lastChild:null;return U(o,t,r),a&&Ze(s,c),o}}function ct(e){return(...t)=>ot(e,...t)}function lt(e){return(...t)=>st(e,...t)}const ut=`a.abbr.address.area.article.aside.audio.b.base.bdi.bdo.blockquote.body.br.button.canvas.caption.cite.code.col.colgroup.data.datalist.dd.del.details.dfn.dialog.div.dl.dt.em.embed.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.iframe.img.input.ins.kbd.label.legend.li.link.main.map.mark.menu.meta.meter.nav.noscript.object.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.script.search.section.select.slot.small.source.span.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.title.tr.track.u.ul.var.video.wbr`.split(`.`),dt=`a.animate.animateMotion.animateTransform.circle.clipPath.defs.desc.ellipse.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.filter.foreignObject.g.image.line.linearGradient.marker.mask.metadata.mpath.path.pattern.polygon.polyline.radialGradient.rect.script.set.stop.style.svg.switch.symbol.text.textPath.title.tspan.use.view`.split(`.`),ft=[`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`source`,`track`,`wbr`];function pt(e,t){if(t in e&&typeof e[t]!=`function`)return;let n=ct(t);e[t]=n,t===`var`&&(e.var_=n)}function mt(e,t){let n=`${t}Svg`;n in e||(e[n]=lt(t))}function ht(e=globalThis){let t=`__nuclo_tags_registered`;if(!e[t]){for(let t=0;t<dt.length;t++)mt(e,dt[t]);for(let t=0;t<ut.length;t++)pt(e,ut[t]);e[t]=!0}}function gt(e,t,n){if(a(e)){let i=e(t,n);return i&&r(i)?i:null}return e&&r(e)?e:null}function _t(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}const W=new Set,vt=new WeakMap,yt=typeof FinalizationRegistry<`u`?new FinalizationRegistry(e=>{W.delete(e)}):null;function bt(e,t){let n=new WeakRef(e);W.add(n),vt.set(e,t),yt?.register(e,n)}function xt(e){return Array.isArray(e)?e:Array.from(e)}function St(e,t,n){return gt(e.renderItem(t,n),e.host,n)}function G(e){k(e.element)}function Ct(e,t,n,r){if(n.parentNode!==t||r.parentNode!==t)return!1;for(let n=0;n<e.length;n++){let r=e[n].element;r&&r.parentNode===t&&t.removeChild(r)}return!0}function wt(e){let t=e.length;if(t===0)return[];let n=Array(t),r=[];for(let i=0;i<t;i++){let t=e[i],a=0,o=r.length;for(;a<o;){let n=a+o>>1;e[r[n]]<t?a=n+1:o=n}n[i]=a>0?r[a-1]:-1,a===r.length?r.push(i):r[a]=i}let i=r.length,a=r[i-1],o=Array(i);for(;i>0;)o[--i]=a,a=n[a];return o}function Tt(e,t,n,r,i,a,o){let s=le(),c=0;for(let l=r;l<i;l++){let r=n[l],i=St(e,r,l);if(!i)continue;o.push({item:r,element:i});let u=i;s?(s.appendChild(u),c++):t.insertBefore(u,a)}s&&c>0&&t.insertBefore(s,a)}function Et(e){let{startMarker:t,endMarker:n}=e,r=t.parentNode??e.host,i=xt(e.itemsProvider());if(_t(e.lastSyncedItems,i))return;let a=e.records,o=a.length,s=i.length;if(s===0){if(o>0&&!Ct(a,r,t,n))for(let e=0;e<o;e++)G(a[e]);e.records=[],e.lastSyncedItems=[];return}let c=0,l=Math.min(o,s);for(;c<l&&a[c].item===i[c];)c++;let u=0,d=l-c;for(;u<d&&a[o-1-u].item===i[s-1-u];)u++;let f=c,p=o-u,m=c,h=s-u;if(f===p){let t=p<o?a[p].element:n;if(p===o)Tt(e,r,i,m,h,t,a);else{let n=[];Tt(e,r,i,m,h,t,n),e.records=a.slice(0,f).concat(n,a.slice(f))}e.lastSyncedItems=i.slice();return}if(m===h){for(let e=f;e<p;e++)G(a[e]);a.splice(f,p-f),e.lastSyncedItems=i.slice();return}let g=p-f,_=h-m,v=Array(_).fill(-1),y=new Uint8Array(g),b=0,ee=Math.min(p,h);for(let e=c;e<ee;e++)a[e].item===i[e]&&(v[e-m]=e,y[e-f]=1,b++);let x=new Map;for(let e=f;e<p;e++){if(y[e-f])continue;let t=a[e].item,n=x.get(t);n===void 0?x.set(t,e):typeof n==`number`?x.set(t,[n,e]):n.push(e)}for(let e=0;e<_;e++){if(v[e]!==-1)continue;let t=x.get(i[m+e]);if(t===void 0)continue;let n;typeof t==`number`?(n=t,x.delete(i[m+e])):(n=t.shift(),t.length===0&&x.delete(i[m+e])),v[e]=n,y[n-f]=1,b++}if(b===0&&f===0&&p===o){if(!Ct(a,r,t,n))for(let e=0;e<o;e++)G(a[e]);let c=[];Tt(e,r,i,0,s,n,c),e.records=c,e.lastSyncedItems=i.slice();return}for(let e=f;e<p;e++)y[e-f]||G(a[e]);let S=null;if(b>0){let e=[],t=[];for(let n=0;n<_;n++)v[n]!==-1&&(e.push(v[n]),t.push(n));S=new Uint8Array(_);let n=wt(e);for(let e=0;e<n.length;e++)S[t[n[e]]]=1}let C=Array(_),te=0,w=p<o?a[p].element:n,T=null;for(let t=_-1;t>=0;t--){let n=v[t];if(n===-1){let n=i[m+t],a=St(e,n,m+t);if(!a){C[t]=null,te++;continue}C[t]={item:n,element:a};let o=a;T||=le(),T?T.insertBefore(o,T.firstChild):(r.insertBefore(o,w),w=o);continue}let o=a[n];C[t]=o;let s=o.element;if(T&&T.firstChild){let e=T.firstChild;r.insertBefore(T,w),w=e,T=null}(!S||!S[t])&&r.insertBefore(s,w),w=s}T&&T.firstChild&&r.insertBefore(T,w);let E=Array(f+(_-te)+(o-p)),D=0;for(let e=0;e<f;e++)E[D++]=a[e];for(let e=0;e<_;e++){let t=C[e];t&&(E[D++]=t)}for(let e=p;e<o;e++)E[D++]=a[e];e.records=E,e.lastSyncedItems=i.slice()}function Dt(e,t,n,r){return I()?kt(e,t,n,r):Ot(e,t,n,r)}function Ot(e,t,n,r){let{start:i,end:a}=me(`list`,r),o={itemsProvider:e,renderItem:t,startMarker:i,endMarker:a,records:[],host:n,lastSyncedItems:[]},s=n;return s.appendChild(i),s.appendChild(a),Et(o),c&&bt(i,o),o}function kt(e,t,n,r){let i=n;z(i);let a=L(i);if(!a||a.nodeType!==8||!a.textContent?.startsWith(`list-start-`))return Ot(e,t,n,r);let o=B(i),s=0,l=L(i);for(;l;){if(l.nodeType===8){let e=l.textContent||``;if(e.startsWith(`list-start-`))s++;else if(e===`list-end`){if(s===0)break;s--}}l=l.nextSibling}let u=l;if(!u){let e=A(`list-end`);e&&(i.insertBefore(e,o.nextSibling),u=e)}if(!u)return Ot(e,t,n,r);let d=xt(e()),f=[];for(let e=0;e<d.length;e++){let r=gt(t(d[e],e),n,e);r&&f.push({item:d[e],element:r})}let p=L(i);for(;p&&p!==u;){let e=p.nextSibling;k(p),p=e}let m=u;for(let e=f.length-1;e>=0;e--){let t=f[e].element;(t.parentNode!==i||t.nextSibling!==m)&&i.insertBefore(t,m),m=t}R(i,u.nextSibling);let h={itemsProvider:e,renderItem:t,startMarker:o,endMarker:u,records:f,host:n,lastSyncedItems:d.slice()};return c&&bt(o,h),h}function At(e){for(let t=0;t<e.records.length;t++){let n=e.records[t];n.element=null,n.item=null}e.records=[],e.lastSyncedItems=[]}function jt(e){let t=[];for(let n of W){let r=n.deref();if(!r){t.push(n);continue}let i=vt.get(r);if(!i){t.push(n);continue}if(!j(r)||!j(i.endMarker)){At(i),vt.delete(r),t.push(n);continue}e&&!e.contains(r)||Et(i)}for(let e of t)W.delete(e)}function Mt(e,t){return function(n,r){return Dt(e,t,n,r).startMarker}}function Nt(e,t){try{return e()}catch(e){if(t)return t(e),!1;throw e}}function Pt(e,t){return typeof e==`function`?Nt(e,t):!!e}const K=new Set,q=new WeakMap,Ft=typeof FinalizationRegistry<`u`?new FinalizationRegistry(e=>{K.delete(e)}):null;function It(e,t){for(let t=0;t<e.length;t++)if(Pt(e[t].condition))return t;return t.length>0?-1:null}function Lt(e){let{groups:t,elseContent:n,host:r,index:i,endMarker:a}=e,o=It(t,n);o!==e.activeIndex&&(he(e.startMarker,e.endMarker),e.activeIndex=o,o!==null&&ge(Vt(o>=0?t[o].content:n,r,i,a),a))}function Rt(e){let t=new WeakRef(e.startMarker);K.add(t),q.set(e.startMarker,e),Ft?.register(e.startMarker,t)}function zt(e){let t=[];for(let n of K){let r=n.deref();if(r===void 0){t.push(n);continue}let i=q.get(r);if(!i){t.push(n);continue}if(!j(r)||!j(i.endMarker)){q.delete(r),t.push(n);continue}if(!(e&&!e.contains(r)))try{i.update()}catch(e){s(`when() branch threw during update; unregistering this conditional`,e),q.delete(r),t.push(n)}}for(let e of t)K.delete(e)}function Bt(e,t,n,r){return a(e)?o(e)?(V.delete(e),H(t,e,n)):be(t,r,()=>{let r=H(t,e,n);return r&&!r.parentNode?r:null}):H(t,e,n)}function Vt(e,t,n,r){let i=[];for(let a of e){let e=Bt(a,t,n,r);e&&i.push(e)}return i}function Ht(e,t){return`when-start-${e}-b${t===null?`n`:t}`}function Ut(e){let t=/-b(n|-?\d+)$/.exec(e||``);if(t)return t[1]===`n`?null:parseInt(t[1],10)}var Wt=class e{groups=[];elseContent=[];constructor(e,...t){this.groups.push({condition:e,content:t})}cloneWith(t,n){let r=Object.create(e.prototype);return r.groups=[...this.groups],t&&r.groups.push(t),r.elseContent=n??[...this.elseContent],r}when(e,...t){return this.groups.push({condition:e,content:t}),this}else(...e){return this.elseContent=e,this}render(e,t){return globalThis.document?I()?this.hydrateRender(e,t):this.freshRender(e,t):null}freshRender(e,t){let{start:n,end:r}=me(`when`,t),i=this.createRuntimeFromMarkers(e,t,n,r),a=ye(e);return a.appendChild(n),a.appendChild(r),Lt(i),n.textContent=Ht(t,i.activeIndex),n}hydrateRender(e,t){let n=e;z(n);let r=L(n);if(!r||r.nodeType!==8||!r.textContent?.startsWith(`when-start-`))return this.freshRender(e,t);let i=B(n),a=0,o=L(n);for(;o;){if(o.nodeType===8){let e=o.textContent||``;if(e.startsWith(`when-start-`))a++;else if(e===`when-end`){if(a===0)break;a--}}o=o.nextSibling}let s=o,c=!1;if(!s){let e=A(`when-end`);if(!e)return i;n.insertBefore(e,i.nextSibling),s=e,c=!0}let l=It(this.groups,this.elseContent),u=Ut(i.textContent);if(!c&&(u===void 0||u===l)){if(l!==null){let n=l>=0?this.groups[l].content:this.elseContent;for(let r of n)H(e,r,t)}}else if(he(i,s),l!==null){let n=l>=0?this.groups[l].content:this.elseContent,r=s;Je(()=>{ge(Vt(n,e,t,r),r)})}return R(n,s.nextSibling),this.createRuntimeFromMarkers(e,t,i,s,l),i}createRuntimeFromMarkers(e,t,n,r,i=null){let a={startMarker:n,endMarker:r,host:e,index:t,groups:[...this.groups],elseContent:[...this.elseContent],activeIndex:i,update:function(){Lt(a)}};return c&&Rt(a),a}};function Gt(e){return Object.assign(function(t,n){return e.render(t,n)},{when:function(t,...n){return Gt(e.cloneWith({condition:t,content:n}))},else:function(...t){return Gt(e.cloneWith(void 0,t))}})}function Kt(e,...t){return Gt(new Wt(e,...t))}function qt(e){try{return e.isSvg?at(e.tagName,e.modifiers):it(e.tagName,e.modifiers)}catch(t){if(s(`Error applying modifiers in conditional element "${e.tagName}"`,t),e.isSvg){let n=ce(oe,e.tagName);if(!n)throw Error(`Failed to create SVG element: ${e.tagName}`,{cause:t});return n}let n=se(e.tagName);if(!n)throw Error(`Failed to create element: ${e.tagName}`,{cause:t});return n}}function Jt(e){let t=ae(e);if(!t)return;let n=Nt(t.condition,e=>{s(`Error evaluating conditional condition`,e)}),r=e.nodeType===Node.ELEMENT_NODE;if(n&&!r){let n=qt(t);ne(n,t),ve(e,n)}else if(!n&&r){let n=pe(t.tagName);n&&(ne(n,t),ve(e,n))}}function Yt(e){if(c)try{let t=ie();for(let n of t){if(!n.isConnected){re(n);continue}e&&!e.contains(n)||Jt(n)}}catch(e){s(`Error during conditional elements update`,e)}}const J=new Map;function Xt(e){let t=[],n=new Set;for(let r of e){if(typeof r!=`string`)continue;let e=r.trim();e&&(n.has(e)||(n.add(e),t.push(e)))}return t}function Zt(e,t){let n=J.get(e);n||(n=new Set,J.set(e,n)),n.add(new WeakRef(t))}function Qt(e){let t=Xt(e);if(t.length===0)return[];let n=new Set;for(let e of t){let t=J.get(e);if(!t)continue;let r=[];for(let e of t){let t=e.deref();if(t===void 0){r.push(e);continue}if(!j(t)){r.push(e);continue}n.add(t)}for(let e of r)t.delete(e);t.size===0&&J.delete(e)}return Array.from(n)}function $t(...e){let t=Xt(e);return function(e){if(c&&e instanceof Element)for(let n of t)Zt(n,e)}}const en=[jt,zt,Yt,je,He,nn];function tn(...e){let t;if(e.length>0){let n=Qt(e);if(n.length===1){let e=n[0];t={roots:n,contains:t=>e.contains(t)}}else t={roots:n,contains:e=>{for(let t of n)if(t.contains(e))return!0;return!1}}}for(let e of en)e(t)}function nn(e){if(typeof document>`u`)return;let t=e?e.roots:[document.body??document];for(let e of t)try{e.dispatchEvent(new Event(`update`,{bubbles:!0}))}catch(e){s(`Error dispatching global update event`,e)}}function rn(e,t,n=0){let r=t||document.body,i=e(r,n);return r.appendChild(i),i}function an(e,t){let n=t||document.body,r=n;Ke();try{let t=e(n,0),i=t;if(i&&i.nodeType===1&&i.parentNode!==r){let e=L(r);if(e){let t=e.nextSibling;r.insertBefore(i,e),k(e),R(r,t)}else r.appendChild(i),R(r,null)}return t}finally{qe()}}let on=null;function sn(e){on=e}const cn=new Map,ln=new Map,un=new Set,Y=[],X=new Map;let Z=null,Q=null,dn=null,fn=0;const pn=new Map;function mn(e){for(let t of e)X.has(t)||X.set(t,[])}function hn(e,t){try{let n=e.cssRules.length;e.insertRule(t+`{}`,n);let r=e.cssRules[n];return pn.set(t,r),r}catch{return null}}function gn(e,t){try{e.insertRule(t,fn),fn++}catch{}}function _n(){if(typeof document>`u`||typeof document.getElementById!=`function`)return null;if(Q&&dn===document&&Q.ownerNode&&Q.ownerNode.isConnected)return Q;let e=document.getElementById(`nuclo-styles`);if(e||(e=document.createElement(`style`),e.id=`nuclo-styles`,document.head.appendChild(e)),Q=e.sheet,dn=document,pn.clear(),fn=0,!Q)return null;for(let e of Y)gn(Q,e);for(let[e,t]of X){let n=hn(Q,e);if(n)for(let e of t)try{n.insertRule(e,n.cssRules.length)}catch{}}return Q}function vn(e,t){if(t===void 0)Y.push(e);else{let n=X.get(t);n||(n=[],X.set(t,n)),n.push(e)}Z=null,on?.(t===void 0?e:t+`{`+e+`}`);let n=_n();if(n)if(t===void 0)gn(n,e);else{let r=pn.get(t)??hn(n,t);if(r)try{r.insertRule(e,r.cssRules.length)}catch{}}}function yn(e){let t=2166136261,n=2128831035;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619),n=Math.imul(n^i,2246822507)}return(t>>>0).toString(36)+((n>>>9)%1296).toString(36)}function bn(e,t,n,r){let i=(e??``)+`|`+t+`|`+n+`:`+r,a=cn.get(i);return a===void 0?(a=`n`+yn(i),cn.set(i,a),ln.set(a,(e??``)+`|`+t+`|`+n),vn(`.`+a+t+`{`+n+`:`+r+`}`,e),a):(_n(),a)}function xn(e){return ln.get(e)}function Sn(e,t){if(un.has(e)){_n();return}un.add(e),vn(t,void 0)}function Cn(){if(Z!==null)return Z;let e=Y.join(``);for(let[t,n]of X)n.length>0&&(e+=t+`{`+n.join(``)+`}`);return Z=e,e}function wn(){cn.clear(),ln.clear(),un.clear(),Y.length=0,X.clear(),pn.clear(),Z=null,fn=0,Q=null,dn=null,typeof document<`u`&&document.getElementById(`nuclo-styles`)?.remove()}const Tn={hover:`:hover`,focus:`:focus`,focusVisible:`:focus-visible`,focusWithin:`:focus-within`,active:`:active`,visited:`:visited`,disabled:`:disabled`,enabled:`:enabled`,checked:`:checked`,required:`:required`,invalid:`:invalid`,valid:`:valid`,readOnly:`:read-only`,first:`:first-child`,last:`:last-child`,only:`:only-child`,odd:`:nth-child(odd)`,even:`:nth-child(even)`,empty:`:empty`,placeholderShown:`:placeholder-shown`,placeholder:`::placeholder`,before:`::before`,after:`::after`,selection:`::selection`,marker:`::marker`,firstLine:`::first-line`,firstLetter:`::first-letter`},En={bg:[`background`],p:[`padding`],px:[`padding-left`,`padding-right`],py:[`padding-top`,`padding-bottom`],pt:[`padding-top`],pr:[`padding-right`],pb:[`padding-bottom`],pl:[`padding-left`],m:[`margin`],mx:[`margin-left`,`margin-right`],my:[`margin-top`,`margin-bottom`],mt:[`margin-top`],mr:[`margin-right`],mb:[`margin-bottom`],ml:[`margin-left`],w:[`width`],h:[`height`],minW:[`min-width`],maxW:[`max-width`],minH:[`min-height`],maxH:[`max-height`],size:[`width`,`height`],text:[`font-size`],font:[`font-family`],weight:[`font-weight`],leading:[`line-height`],tracking:[`letter-spacing`],align:[`text-align`],items:[`align-items`],justify:[`justify-content`],z:[`z-index`],rounded:[`border-radius`],shadow:[`box-shadow`],select:[`user-select`]},Dn={row:{display:`flex`,"flex-direction":`row`},col:{display:`flex`,"flex-direction":`column`},center:{"align-items":`center`,"justify-content":`center`},truncate:{overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}},On={background:`colors`,"background-color":`colors`,color:`colors`,"border-color":`colors`,"border-top-color":`colors`,"border-right-color":`colors`,"border-bottom-color":`colors`,"border-left-color":`colors`,"outline-color":`colors`,"caret-color":`colors`,"text-decoration-color":`colors`,"font-family":`fonts`,"box-shadow":`shadows`,"border-radius":`radii`},kn=new Set([`z-index`,`opacity`,`font-weight`,`line-height`,`flex`,`flex-grow`,`flex-shrink`,`order`,`aspect-ratio`,`zoom`,`scale`,`column-count`,`orphans`,`widows`,`tab-size`,`animation-iteration-count`,`grid-column`,`grid-row`]),An=new Map;function jn(e){let t=An.get(e);return t===void 0&&(t=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),An.set(e,t)),t}function Mn(e){return e.charCodeAt(0)===64?e:`@media `+e}function Nn(e,t){return e!==void 0&&e.startsWith(`@media`)&&t.startsWith(`@media`)?e+` and`+t.slice(6):t}function Pn(e){let t={className:e};return Object.defineProperty(t,"toString",{value:()=>e,enumerable:!1}),t}function Fn(e,t){for(let n of e)if(n)if(typeof n==`string`)for(let e of n.split(` `))e&&t.set(xn(e)??e,e);else if(Array.isArray(n))Fn(n,t);else for(let e of n.className.split(` `))e&&t.set(xn(e)??e,e)}function In(...e){let t=new Map;Fn(e,t);let n=``;for(let e of t.values())n+=(n?` `:``)+e;return Pn(n)}function Ln(e={}){let t=e.screens??{};mn(Object.values(t).map(Mn));let n=new WeakMap;function r(t,n){if(typeof n==`number`)return n===0||kn.has(t)?String(n):n+`px`;let r=On[t];if(r!==void 0){let t=e[r]?.[n];if(t!==void 0)return t}return n}function i(e,n,a,o){for(let s in e){let c=e[s];if(c==null||c===!1)continue;if(typeof c==`object`){if(s===`raw`){let e=c;for(let t in e)o.push(bn(n,a,t,r(t,e[t])));continue}let e=Tn[s];if(e!==void 0){i(c,n,a+e,o);continue}let l=t[s];if(l!==void 0){i(c,Nn(n,Mn(l)),a,o);continue}let u=s.charCodeAt(0);if(u===38){i(c,n,a+s.slice(1),o);continue}if(u===64){i(c,Nn(n,s),a,o);continue}continue}if(c===!0){let e=Dn[s];if(e)for(let t in e)o.push(bn(n,a,t,e[t]));continue}let l=En[s];if(l!==void 0)for(let e of l)o.push(bn(n,a,e,r(e,c)));else{let e=jn(s);o.push(bn(n,a,e,r(e,c)))}}}function a(e){let t=n.get(e);if(t)return t;let r=[];i(e,void 0,``,r);let a=Pn(r.join(` `));return n.set(e,a),a}function o(e){let t=``,n=(e,n)=>{t+=(t?`;`:``)+e+`:`+n};for(let t in e){let i=e[t];if(i==null||i===!1)continue;if(t===`raw`&&typeof i==`object`){let e=i;for(let t in e)n(t,r(t,e[t]));continue}if(typeof i==`object`)continue;if(i===!0){let e=Dn[t];if(e)for(let t in e)n(t,e[t]);continue}let a=En[t];if(a!==void 0)for(let e of a)n(e,r(e,i));else{let e=jn(t);n(e,r(e,i))}}return t}function s(e){let t=``;for(let n in e)t+=n+`{`+o(e[n])+`}`;let n=`nk`+yn(t);return Sn(n,`@keyframes `+n+`{`+t+`}`),n}function c(e,t){let n=e+`{`+o(t)+`}`;Sn(`g|`+n,n)}function l(e){let t=e=>e===!0?`true`:e===!1?`false`:String(e),n=e.variants??{},r=Object.keys(n),i=e.defaultVariants??{},o=e.base?a(e.base):null,s={};for(let e of r){let t=n[e],r={};for(let e in t)r[e]=a(t[e]);s[e]=r}let c=(e.compoundVariants??[]).map(e=>{let{css:n,...r}=e,i={};for(let e in r)i[e]=t(r[e]);return{conditions:i,result:a(n)}}),l=new Map;return function(e){let n={};for(let a of r){let r=(e?e[a]:void 0)??i[a];r!=null&&(n[a]=t(r))}let a=``;for(let e of r)a+=e+`=`+(n[e]??``)+`;`;let u=l.get(a);if(u)return u;let d=[];o&&d.push(o);for(let e of r){let t=n[e];if(t!==void 0){let n=s[e][t];n&&d.push(n)}}for(let e of c){let t=!0;for(let r in e.conditions)if(n[r]!==e.conditions[r]){t=!1;break}t&&d.push(e.result)}let f=In(...d);return l.set(a,f),f}}return{css:a,cx:In,variants:l,keyframes:s,globalStyle:c,theme:e}}const $=Ln({}),Rn=$.css,zn=$.variants,Bn=$.keyframes,Vn=$.globalStyle;function Hn(){ht();let e=globalThis;e.list=Mt,e.update=tn,e.when=Kt,e.on=p,e.scope=$t,e.render=rn,e.hydrate=an,e.createCss=Ln,e.css=Rn,e.cx=In,e.variants=zn,e.keyframes=Bn,e.globalStyle=Vn}Hn();export{ut as HTML_TAGS,ft as SELF_CLOSING_TAGS,dt as SVG_TAGS,_e as appendChildren,P as applyAttributes,H as applyNodeModifier,A as createComment,pe as createConditionalComment,Ln as createCss,it as createHtmlElementWithModifiers,ct as createHtmlTagBuilder,at as createSvgElementWithModifiers,lt as createSvgTagBuilder,Rn as css,In as cx,Cn as getCssText,Vn as globalStyle,an as hydrate,Hn as initializeRuntime,i as isBoolean,c as isBrowser,a as isFunction,t as isNode,n as isObject,e as isPrimitive,r as isTagLike,o as isZeroArityFunction,Bn as keyframes,Mt as list,p as on,ht as registerGlobalTagBuilders,rn as render,ve as replaceNodeSafely,wn as resetStyles,$t as scope,sn as setSSRCollector,tn as update,zn as variants,Kt as when};
2
+ //# sourceMappingURL=nuclo.mjs.map