@stacksjs/stx 0.2.917 → 0.2.921

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 (294) hide show
  1. package/dist/app-shell.js +3 -2
  2. package/dist/chunk-0678sab4.js +2 -0
  3. package/dist/chunk-0bnv0aaz.js +2 -0
  4. package/dist/chunk-0bvfm5h5.js +2 -0
  5. package/dist/chunk-0c3q5h03.js +2 -0
  6. package/dist/chunk-0fh84wr5.js +2 -0
  7. package/dist/chunk-0p9x0m5n.js +2 -0
  8. package/dist/{chunk-ngqb22wj.js → chunk-0rq1w0xr.js} +9 -9
  9. package/dist/{chunk-t65f98qv.js → chunk-1pc2p489.js} +2 -2
  10. package/dist/{chunk-1hx6dyy9.js → chunk-1ts1pg90.js} +2 -2
  11. package/dist/{chunk-h0aw9hmc.js → chunk-29cy41z3.js} +5 -5
  12. package/dist/{chunk-952dfmcb.js → chunk-2d0pemtc.js} +3 -3
  13. package/dist/{chunk-0vyytd9v.js → chunk-2qnpr0ty.js} +3 -3
  14. package/dist/chunk-2r2tayyd.js +3 -0
  15. package/dist/chunk-2sfxj244.js +2 -0
  16. package/dist/{chunk-nwef47nx.js → chunk-30d298vs.js} +1 -1
  17. package/dist/chunk-36j2drjv.js +42 -0
  18. package/dist/{chunk-pyyda92j.js → chunk-3d0bjcn7.js} +1 -1
  19. package/dist/chunk-3k9d0h11.js +2 -0
  20. package/dist/chunk-3mc9ew9r.js +25 -0
  21. package/dist/chunk-43r0h76m.js +2 -0
  22. package/dist/{chunk-95j8660f.js → chunk-4f8h38xr.js} +2 -2
  23. package/dist/{chunk-16sfjkc4.js → chunk-4jg8ddfy.js} +2 -2
  24. package/dist/chunk-4jh5t3rz.js +2 -0
  25. package/dist/{chunk-v78hjbz0.js → chunk-4nabpd82.js} +5 -5
  26. package/dist/{chunk-z110bf2c.js → chunk-4w203ddt.js} +9 -9
  27. package/dist/chunk-4y2k14ec.js +2 -0
  28. package/dist/chunk-57xcb1wn.js +2 -0
  29. package/dist/chunk-5ekbye3p.js +2 -0
  30. package/dist/chunk-5s1q4y2j.js +2 -0
  31. package/dist/chunk-6359fekc.js +2 -0
  32. package/dist/{chunk-sdmq09jw.js → chunk-66cz2ph7.js} +2 -2
  33. package/dist/chunk-6bm7t0hm.js +3 -0
  34. package/dist/{chunk-xc5esqcb.js → chunk-6ybq9pfh.js} +2 -2
  35. package/dist/{chunk-nhyv3w4r.js → chunk-7767n5k6.js} +1 -1
  36. package/dist/{chunk-0sj79ha5.js → chunk-78j6c3sf.js} +5 -5
  37. package/dist/{chunk-ftvpz1j4.js → chunk-7d0h2pa3.js} +5 -5
  38. package/dist/{chunk-1hbf5e1h.js → chunk-7g720sk3.js} +2 -2
  39. package/dist/chunk-7nshr15z.js +2 -0
  40. package/dist/{chunk-w98yt4d4.js → chunk-875wejw1.js} +2 -2
  41. package/dist/chunk-8g6cmgn8.js +2 -0
  42. package/dist/chunk-8gfdy17b.js +2 -0
  43. package/dist/{chunk-mgj074y2.js → chunk-8vjsmyrk.js} +5 -5
  44. package/dist/chunk-8yx65vb0.js +2 -0
  45. package/dist/{chunk-frpsrv1e.js → chunk-90ps064x.js} +2 -2
  46. package/dist/chunk-91nwc581.js +2 -0
  47. package/dist/{chunk-mt5ewkbg.js → chunk-94001bha.js} +6 -6
  48. package/dist/chunk-94skx5m6.js +2 -0
  49. package/dist/chunk-9aegppj7.js +2 -0
  50. package/dist/{chunk-11c7xg1z.js → chunk-9ch2qhbw.js} +1 -1
  51. package/dist/{chunk-da05660m.js → chunk-9sk596tw.js} +58 -58
  52. package/dist/{chunk-fn1reean.js → chunk-a3qb13vr.js} +20 -20
  53. package/dist/chunk-a5vzdhsk.js +2 -0
  54. package/dist/{chunk-0jdz31q1.js → chunk-a78k8fkg.js} +3 -3
  55. package/dist/{chunk-jr2r2nh5.js → chunk-ag07tdhn.js} +4 -4
  56. package/dist/chunk-amnfd29h.js +7 -0
  57. package/dist/chunk-aqh48tyw.js +2 -0
  58. package/dist/{chunk-fs43342z.js → chunk-avtq2p0c.js} +2 -2
  59. package/dist/{chunk-phzhmnnm.js → chunk-ayrd026n.js} +3 -3
  60. package/dist/{chunk-eptzpvn0.js → chunk-b0kq5mzq.js} +3 -3
  61. package/dist/chunk-b6am4h24.js +2 -0
  62. package/dist/{chunk-dwt2drzf.js → chunk-b9z4nb1v.js} +8 -8
  63. package/dist/{chunk-qsexsrw2.js → chunk-bwnx71s8.js} +5 -5
  64. package/dist/{chunk-2vx2ben8.js → chunk-c3nmjx26.js} +2 -2
  65. package/dist/chunk-cajg2sz0.js +2 -0
  66. package/dist/{chunk-2f5jjxcj.js → chunk-dhx4m7mf.js} +2 -2
  67. package/dist/chunk-dktqmf4t.js +2 -0
  68. package/dist/chunk-dqwxyk1m.js +2 -0
  69. package/dist/chunk-e2kk1d9z.js +2 -0
  70. package/dist/{chunk-ra2tzsvz.js → chunk-e8aqkt1b.js} +6 -6
  71. package/dist/{chunk-1jxkc6d0.js → chunk-e8hvbc53.js} +2 -2
  72. package/dist/{chunk-p3fepzt9.js → chunk-edjzm0vj.js} +3 -3
  73. package/dist/chunk-ee4ejnk2.js +2 -0
  74. package/dist/chunk-eezp4a40.js +2 -0
  75. package/dist/chunk-eh2ynja3.js +2 -0
  76. package/dist/chunk-emk29htn.js +2 -0
  77. package/dist/{chunk-va4xam1q.js → chunk-eqj8nj5c.js} +1 -1
  78. package/dist/{chunk-xnp031ba.js → chunk-f8sh6289.js} +7 -7
  79. package/dist/{chunk-wj9bqkc0.js → chunk-fb1hyhgf.js} +3 -3
  80. package/dist/chunk-fd0vnz09.js +2 -0
  81. package/dist/chunk-fyhtp2nt.js +2 -0
  82. package/dist/{chunk-ywrpmyzj.js → chunk-g2fxp9zp.js} +3 -3
  83. package/dist/chunk-gbct53j0.js +2 -0
  84. package/dist/{chunk-1jvt9t3r.js → chunk-gsm3rk4j.js} +2 -2
  85. package/dist/{chunk-gfp39bzr.js → chunk-gt9bt8xa.js} +2 -2
  86. package/dist/{chunk-ar6jeqmm.js → chunk-gxdy4qjj.js} +4 -4
  87. package/dist/chunk-gxtq25gr.js +2 -0
  88. package/dist/chunk-h1dnjn9g.js +2 -0
  89. package/dist/chunk-h4nqjks2.js +2 -0
  90. package/dist/{chunk-f0sxbgbm.js → chunk-h7z23fpq.js} +2 -2
  91. package/dist/{chunk-cq4cwfqf.js → chunk-hakevnm1.js} +2 -2
  92. package/dist/chunk-hn7fv830.js +2 -0
  93. package/dist/chunk-hx6tr46s.js +1459 -0
  94. package/dist/chunk-jenk04c8.js +2 -0
  95. package/dist/{chunk-ezqfrea9.js → chunk-jfy0r3hx.js} +28 -28
  96. package/dist/{chunk-3jc6yb02.js → chunk-jh007a8k.js} +9 -9
  97. package/dist/chunk-jh1hdq31.js +3 -0
  98. package/dist/{chunk-fzcqw147.js → chunk-jk1hzawb.js} +3 -3
  99. package/dist/{chunk-wm24jx3t.js → chunk-jya12bfn.js} +2 -2
  100. package/dist/chunk-k1qbgpfy.js +2 -0
  101. package/dist/chunk-kgmwja6f.js +2 -0
  102. package/dist/{chunk-91p8p2cc.js → chunk-khf62zkn.js} +6 -6
  103. package/dist/chunk-kppj8rqa.js +2 -0
  104. package/dist/{chunk-vayzmvf5.js → chunk-m3ra99h8.js} +6 -6
  105. package/dist/{chunk-fznjm7qt.js → chunk-m8rzaqm8.js} +2 -2
  106. package/dist/chunk-msvphygp.js +2 -0
  107. package/dist/chunk-mzbejejf.js +2 -0
  108. package/dist/{chunk-8b8az19t.js → chunk-nkgqhb7s.js} +8 -8
  109. package/dist/{chunk-npj20tj9.js → chunk-p17jeqz0.js} +2 -2
  110. package/dist/{chunk-bvqgq18r.js → chunk-p97h91zx.js} +2 -2
  111. package/dist/{chunk-cxsc37fg.js → chunk-pe5sstex.js} +2 -2
  112. package/dist/chunk-pjv4dskp.js +2 -0
  113. package/dist/chunk-pqr4gn9b.js +4 -0
  114. package/dist/{chunk-zv3rn0ch.js → chunk-prj38cyp.js} +6 -6
  115. package/dist/{chunk-5jc9hmwg.js → chunk-pwg544dw.js} +2 -2
  116. package/dist/chunk-pxvp0cc9.js +3 -0
  117. package/dist/{chunk-hhspwfva.js → chunk-q8snpht6.js} +3 -3
  118. package/dist/chunk-q99y5115.js +3 -0
  119. package/dist/chunk-qnytvyy0.js +2 -0
  120. package/dist/{chunk-23x3k751.js → chunk-qzspvwv6.js} +2 -2
  121. package/dist/chunk-r02asm46.js +2 -0
  122. package/dist/chunk-r7zvrh58.js +70 -0
  123. package/dist/chunk-ra35ptjg.js +3 -0
  124. package/dist/chunk-rc4712qh.js +2 -0
  125. package/dist/chunk-rq7sg012.js +33 -0
  126. package/dist/{chunk-302nw40c.js → chunk-rt4gzqs9.js} +1 -1
  127. package/dist/chunk-rx1xw7q2.js +2 -0
  128. package/dist/{chunk-36cz2v8k.js → chunk-rzmephr2.js} +31 -31
  129. package/dist/{chunk-cwcmmgvz.js → chunk-s1x2pc9b.js} +2 -2
  130. package/dist/{chunk-r7y1196g.js → chunk-s3rhbwgf.js} +4 -4
  131. package/dist/{chunk-0asdv3hk.js → chunk-s6w14v6h.js} +2 -2
  132. package/dist/chunk-sdvv8zge.js +3 -0
  133. package/dist/chunk-sgppgy5e.js +20 -0
  134. package/dist/chunk-sk7pptzf.js +38 -0
  135. package/dist/{chunk-w6ydg43d.js → chunk-sk8x8nw8.js} +3 -3
  136. package/dist/chunk-skjm3zdh.js +2 -0
  137. package/dist/{chunk-388xpdw5.js → chunk-t4exh7c9.js} +76 -36
  138. package/dist/{chunk-yq2krsc9.js → chunk-t64mp8x1.js} +6 -6
  139. package/dist/{chunk-8wqhzzkn.js → chunk-tfpd7aht.js} +3 -3
  140. package/dist/chunk-tsnzhke9.js +2 -0
  141. package/dist/{chunk-c13dv3wm.js → chunk-tt6n2mx6.js} +14 -14
  142. package/dist/chunk-txyze88n.js +2 -0
  143. package/dist/chunk-v1t7sees.js +2 -0
  144. package/dist/chunk-vhp5hqwp.js +54 -0
  145. package/dist/{chunk-88fx8xc1.js → chunk-vn3hsx7v.js} +2 -2
  146. package/dist/chunk-vt410s5m.js +2 -0
  147. package/dist/{chunk-mf5cqv1k.js → chunk-w27j0apm.js} +29 -29
  148. package/dist/{chunk-gg715pj6.js → chunk-w5vxzk5j.js} +6 -6
  149. package/dist/chunk-w81a1e14.js +9 -0
  150. package/dist/{chunk-m8n14s3z.js → chunk-wajvxzt0.js} +2 -2
  151. package/dist/chunk-wrva7jes.js +2 -0
  152. package/dist/chunk-ws25jw6x.js +6 -0
  153. package/dist/{chunk-789yp1tg.js → chunk-ww24mxmd.js} +3 -3
  154. package/dist/chunk-xdprx6tx.js +1331 -0
  155. package/dist/chunk-xgv3gy1b.js +2 -0
  156. package/dist/chunk-xjhv5e5f.js +2 -0
  157. package/dist/{chunk-zkwkhesc.js → chunk-xmy75h5v.js} +2 -2
  158. package/dist/chunk-xnvh4jk2.js +21 -0
  159. package/dist/chunk-xtakhmnb.js +2 -0
  160. package/dist/{chunk-2qk2ppgm.js → chunk-y97g0kwc.js} +1 -1
  161. package/dist/chunk-y9f9d4zv.js +2 -0
  162. package/dist/{chunk-p3x84jj0.js → chunk-yfe380a4.js} +2 -2
  163. package/dist/chunk-ygtz9kc7.js +3 -0
  164. package/dist/chunk-yyypc7s3.js +2 -0
  165. package/dist/chunk-z5j4prza.js +2 -0
  166. package/dist/{chunk-ma5ptt4m.js → chunk-z68teecy.js} +2 -2
  167. package/dist/cli.js +38 -38
  168. package/dist/color-mode-boot.d.ts +1 -8
  169. package/dist/color-mode-boot.js +46 -2
  170. package/dist/composables/use-media-query.js +23 -22
  171. package/dist/craft-entry.js +2 -2
  172. package/dist/craft.js +2 -2
  173. package/dist/document-shell.d.ts +2 -0
  174. package/dist/document-shell.js +15 -3
  175. package/dist/document-tags.d.ts +2 -0
  176. package/dist/document-tags.js +9 -0
  177. package/dist/head-injection.d.ts +2 -0
  178. package/dist/head-injection.js +1 -0
  179. package/dist/head.d.ts +2 -0
  180. package/dist/head.js +2 -2
  181. package/dist/native/accessibility.d.ts +1 -1
  182. package/dist/native/accessibility.js +5 -3
  183. package/dist/native/bridge/protocol.d.ts +1 -0
  184. package/dist/native/compiler/html-to-ir.js +15 -1
  185. package/dist/native/compiler/ir.d.ts +8 -0
  186. package/dist/native/components/primitives.d.ts +2 -0
  187. package/dist/native/event-names.js +6 -0
  188. package/dist/native/prop-names.js +3 -1
  189. package/dist/native/runtime/browser-renderer.d.ts +1 -0
  190. package/dist/native/runtime/browser-renderer.js +27 -6
  191. package/dist/native/runtime/craft-bridge.js +1 -0
  192. package/dist/native/runtime/craft.d.ts +3 -0
  193. package/dist/native/runtime/jsc-globals.js +1 -1
  194. package/dist/native/runtime/native-media.js +8 -3
  195. package/dist/native/runtime/shared-screen.js +8 -3
  196. package/dist/native/testing.d.ts +3 -1
  197. package/dist/native/testing.js +35 -1
  198. package/dist/page-head.js +1 -9
  199. package/dist/process.js +6 -3
  200. package/dist/pwa.js +3 -3
  201. package/dist/signal-processing.d.ts +2 -2
  202. package/dist/signal-processing.js +17 -11
  203. package/dist/ssg.js +13 -13
  204. package/dist/types/config-types.d.ts +1 -1
  205. package/dist/utils.js +2 -1
  206. package/dist/variable-extractor.js +6 -1
  207. package/dist/vue-template.d.ts +2 -0
  208. package/dist/vue-template.js +72 -2
  209. package/package.json +6 -6
  210. package/dist/chunk-0adc8x2h.js +0 -9
  211. package/dist/chunk-0atz8fjx.js +0 -20
  212. package/dist/chunk-0fm6avxt.js +0 -3
  213. package/dist/chunk-0v7555tr.js +0 -42
  214. package/dist/chunk-11rnqey0.js +0 -2
  215. package/dist/chunk-1mx3j280.js +0 -2
  216. package/dist/chunk-20hy5p3p.js +0 -2
  217. package/dist/chunk-29v3b5ks.js +0 -2
  218. package/dist/chunk-2cay3heb.js +0 -2
  219. package/dist/chunk-31yx4sjh.js +0 -2
  220. package/dist/chunk-33fnbw33.js +0 -2
  221. package/dist/chunk-357qjcj1.js +0 -3
  222. package/dist/chunk-38kerh2r.js +0 -2
  223. package/dist/chunk-38y11q8x.js +0 -2
  224. package/dist/chunk-3h4db9yb.js +0 -33
  225. package/dist/chunk-3q80f7mt.js +0 -2
  226. package/dist/chunk-43kz6rx9.js +0 -2
  227. package/dist/chunk-43sgpy4e.js +0 -54
  228. package/dist/chunk-4e18r89n.js +0 -3
  229. package/dist/chunk-4pve3r5a.js +0 -2
  230. package/dist/chunk-4vz17ytv.js +0 -68
  231. package/dist/chunk-5afnyvw5.js +0 -2
  232. package/dist/chunk-5d5dxts6.js +0 -2
  233. package/dist/chunk-5fdsyyfe.js +0 -2
  234. package/dist/chunk-67yr4m5h.js +0 -2
  235. package/dist/chunk-6aqr0e6s.js +0 -2
  236. package/dist/chunk-6bw02d1t.js +0 -2
  237. package/dist/chunk-76mn123c.js +0 -2
  238. package/dist/chunk-7ar11ccn.js +0 -2
  239. package/dist/chunk-7fc0vrs5.js +0 -2
  240. package/dist/chunk-82fg5gp6.js +0 -2
  241. package/dist/chunk-89r7bbsk.js +0 -2
  242. package/dist/chunk-8egbh6z1.js +0 -2
  243. package/dist/chunk-8n9jd8cz.js +0 -2
  244. package/dist/chunk-8tfpv6zf.js +0 -6
  245. package/dist/chunk-8x3yaahc.js +0 -2
  246. package/dist/chunk-94qc4zwb.js +0 -2
  247. package/dist/chunk-9928zdej.js +0 -3
  248. package/dist/chunk-9ay18k46.js +0 -2
  249. package/dist/chunk-9kn81bmp.js +0 -2
  250. package/dist/chunk-9tv0tw7f.js +0 -3
  251. package/dist/chunk-9w9y84t5.js +0 -21
  252. package/dist/chunk-a5h9bwrc.js +0 -2
  253. package/dist/chunk-b5qzed8y.js +0 -1323
  254. package/dist/chunk-bej9kz05.js +0 -2
  255. package/dist/chunk-bh2khcet.js +0 -2
  256. package/dist/chunk-bm6y085n.js +0 -25
  257. package/dist/chunk-c6096ssb.js +0 -2
  258. package/dist/chunk-ccgabq3a.js +0 -2
  259. package/dist/chunk-e0tvd7jj.js +0 -2
  260. package/dist/chunk-e5rag6rh.js +0 -3
  261. package/dist/chunk-fvr3h2fr.js +0 -7
  262. package/dist/chunk-gmmqz698.js +0 -2
  263. package/dist/chunk-hxftzw0x.js +0 -2
  264. package/dist/chunk-js1wayhb.js +0 -2
  265. package/dist/chunk-jz37h2z0.js +0 -4
  266. package/dist/chunk-k2t0w8z1.js +0 -2
  267. package/dist/chunk-k8s3hyh2.js +0 -2
  268. package/dist/chunk-kcpxqsdj.js +0 -2
  269. package/dist/chunk-mjr5fkc2.js +0 -2
  270. package/dist/chunk-n4m50dpk.js +0 -1467
  271. package/dist/chunk-na0e3s88.js +0 -2
  272. package/dist/chunk-new89wh2.js +0 -2
  273. package/dist/chunk-nrap20qt.js +0 -2
  274. package/dist/chunk-p9bghe13.js +0 -2
  275. package/dist/chunk-q2cwzgd0.js +0 -2
  276. package/dist/chunk-q60afqr7.js +0 -2
  277. package/dist/chunk-q9yahsww.js +0 -2
  278. package/dist/chunk-qdwtemy1.js +0 -2
  279. package/dist/chunk-qp0ndbk6.js +0 -2
  280. package/dist/chunk-rzsvxjse.js +0 -2
  281. package/dist/chunk-s2c0ynn9.js +0 -2
  282. package/dist/chunk-senrtnx2.js +0 -2
  283. package/dist/chunk-v1wr2vdx.js +0 -2
  284. package/dist/chunk-v6gkjg5f.js +0 -3
  285. package/dist/chunk-wc10m4tp.js +0 -38
  286. package/dist/chunk-wcxa8xy2.js +0 -2
  287. package/dist/chunk-wgrj0cvs.js +0 -2
  288. package/dist/chunk-wpkwx3wq.js +0 -2
  289. package/dist/chunk-wq17dce6.js +0 -2
  290. package/dist/chunk-wvc6eayq.js +0 -2
  291. package/dist/chunk-xa98a901.js +0 -2
  292. package/dist/chunk-xjt5129x.js +0 -2
  293. package/dist/chunk-yc3frw0z.js +0 -3
  294. package/dist/chunk-yn02d599.js +0 -2
@@ -1,1323 +0,0 @@
1
- // @bun
2
- import{et,Ln,go,Yi,z}from"./chunk-w98yt4d4.js";import{Dn}from"./chunk-p3x84jj0.js";import{Zr,C,Wl,vt,oa,ql}from"./chunk-16sfjkc4.js";import{D}from"./chunk-phzhmnnm.js";import{T,R}from"./chunk-0jdz31q1.js";import{Yr,xo,Hn,Hl,je}from"./chunk-9928zdej.js";import{mo,d,m,Ee,Ur,p,te,K,be,_,yt,wo,Le,nt,vo}from"./chunk-4vz17ytv.js";import{w}from"./chunk-v6gkjg5f.js";import{ne}from"./chunk-e5rag6rh.js";import{t,h}from"./chunk-fvr3h2fr.js";import{c}from"./chunk-8tfpv6zf.js";import Rt from"path";import mn from"process";import{AsyncLocalStorage as ac}from"async_hooks";var ri=new ac;function Pn(e){return e.__stx_server_data??={pending:new Map,values:new Map}}function ii(e,n){return ri.run(Pn(e),n)}async function oi(e,n){let r=ri.getStore();if(!r)throw Error("useServerData must run inside a <script server> render");if(typeof e!=="string"||!e.trim())throw TypeError("useServerData requires a non-empty string key");let i=r.pending.get(e);if(i)return i;let a=Promise.resolve().then(n).then((l)=>{let u=JSON.stringify(l,(v,S)=>{if(S===void 0||typeof S==="function"||typeof S==="symbol"||typeof S==="bigint"||typeof S==="number"&&!Number.isFinite(S))throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);if(S&&typeof S==="object"&&!Array.isArray(S)&&Object.getPrototypeOf(S)!==Object.prototype&&Object.getPrototypeOf(S)!==null)throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);return S}),f=JSON.parse(u);return r.values.set(e,f),f}).catch((l)=>{throw r.pending.delete(e),l});return r.pending.set(e,a),a}function zr(e){let n=e.__stx_server_data;if(!n?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(n.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function G(e,n=!1){let r=t(e),i=[],a=new Set,l=0,u=0,f=r.length,v=()=>{if(l!==0)return;let S=r.slice(u).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(S){if(n&&S[1]==="const")return;let V=S[2];if(!a.has(V))i.push(V),a.add(V);return}let I=r.slice(u).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){if(n&&r.slice(u).startsWith("const"))return;I[1].split(",").forEach((V)=>{let W=V.trim();if(!W)return;let Z=W.indexOf(":"),X=(Z>=0?W.slice(Z+1).trim():W).split(/[\s=]/)[0];if(X&&!a.has(X))i.push(X),a.add(X)});return}let j=r.slice(u).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(j){if(n&&r.slice(u).startsWith("const"))return;j[1].split(",").forEach((V)=>{let W=V.trim().replace(/^\.\.\./,"");if(!W)return;let Z=W.split(/[\s=]/)[0];if(Z&&!a.has(Z))i.push(Z),a.add(Z)});return}if(n)return;let L=r.slice(u).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(L){let V=L[1];if(!a.has(V))i.push(V),a.add(V);return}let M=r.slice(u).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(M){let V=M[1];if(!a.has(V))i.push(V),a.add(V)}};while(u<f){if(r[u]==="{"){l++,u++;continue}if(r[u]==="}"){l--,u++;continue}if(l===0&&/[a-z]/i.test(r[u])&&(u===0||/\s|[;{}()]/.test(r[u-1])))v();u++}return i.join(", ")}function Js(e){return`{ enumerable: true, configurable: true, get() { return ${e} }, set(__stxValue_${e}) { ${e} = __stxValue_${e} } }`}function cc(e,n=G(e).split(",").map((r)=>r.trim()).filter(Boolean)){let r=new Set(G(e,!0).split(",").map((i)=>i.trim()));return n.map((i)=>r.has(i)?`get ${i}() { return ${i} }, set ${i}(__stxValue_${i}) { ${i} = __stxValue_${i} }`:i).join(", ")}function Ys(e,n){let r=`{ ${cc(e,n)} }`;return G(e).split(",").some((i)=>i.trim()==="__stxLiveBindings")?`Object.defineProperties(${r}, Object.getOwnPropertyDescriptors(__stxLiveBindings))`:r}import ln from"fs";import Ue from"path";function J(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var ai=new Map;function Nr(e,n=!0){let r=ai.get(e);if(n&&r)return r;let i=new Map,a=[Ue.join(e,"src"),Ue.join(e,"dist"),e];function l(u,f){if(f>6)return;let v;try{v=ln.readdirSync(u,{withFileTypes:!0})}catch{return}for(let S of v){let I=Ue.join(u,S.name);if(S.isDirectory()){if(S.name==="node_modules"||S.name.startsWith("."))continue;l(I,f+1)}else if(S.isFile()&&S.name.endsWith(".stx")){let j=S.name.slice(0,-4);if(!i.has(j))i.set(j,I);let L=j.toLowerCase();if(!i.has(L))i.set(L,I);let M=J(j);if(!i.has(M))i.set(M,I)}}}for(let u of a)if(l(u,0),i.size>0)break;if(n)ai.set(e,i);return i}function Zs(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let i=Ue.join(r,"node_modules",e);try{if(ln.statSync(i).isDirectory())return i}catch{}let a=Ue.dirname(r);if(a===r)return null;r=a}}function Qs(e,n,r={}){return[Ue.resolve(Ue.dirname(n),`${e}.stx`),Ue.resolve(Ue.dirname(n),e),Ue.resolve(r.componentsDir||"components",`${e}.stx`),Ue.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function ci(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((a)=>a.charAt(0).toUpperCase()+a.slice(1)).join(""),i=J(n);return[n,r,i]}function Ii(e,n){let[r,i,a]=ci(e);for(let l of[r,r.toLowerCase(),i,a]){let u=n?.__importedComponents?.get(l);if(u!==void 0)return u}}function Oi(e,n){let r=n?Ue.resolve(n):void 0,i=Ue.dirname(Ue.resolve(e));for(;;){if(ln.existsSync(Ue.join(i,"package.json")))return r&&i===r?void 0:i;let a=Ue.dirname(i);if(a===i)return;i=a}}var lc=["src/ui","src/components","components","dist"];function us(e,n){let r=Ue.resolve(e);if(!n&&!r.split(Ue.sep).includes("node_modules"))return[];let i=Oi(r,n);if(!i)return[];let a=[];try{let f=JSON.parse(ln.readFileSync(Ue.join(i,"package.json"),"utf8")).stx?.components;if(Array.isArray(f))a=f.filter((v)=>typeof v==="string")}catch{}let l=a.length?a:lc;return[Ue.dirname(Ue.resolve(e)),...l.map((u)=>Ue.resolve(i,u))]}function*Ni(e,n,r={},i){let a=ci(e);if(a[0].startsWith("./")||a[0].startsWith("../")){yield Ue.resolve(Ue.dirname(n),`${a[0]}.stx`);return}let l=[...new Set(a.map((v)=>`${v}.stx`))],u=r.projectRoot||process.cwd(),f=[...us(n,r.projectRoot),...i?.__originalFilePath?[Ue.join(Ue.dirname(i.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],Ue.join(Ue.dirname(n),"components"),Ue.resolve(u,"src/components"),Ue.resolve(u,"components"),...import.meta.dir?[Ue.resolve(import.meta.dir,"components")]:[]];for(let v of new Set(f)){for(let S of l)yield Ue.join(v,S);try{for(let S of ln.readdirSync(v,{withFileTypes:!0}))if(S.isDirectory())for(let I of l)yield Ue.join(v,S.name,I)}catch{}}}function li(e,n,r={},i){let a=Ii(e,i);if(a!==void 0)return a;for(let l of Ni(e,n,r,i))try{if(ln.statSync(l,{throwIfNoEntry:!1})?.isFile())return l}catch{}return null}function eo(e,n=[],r={}){let i=new Set([...e].map((S)=>S.replace(/[-_]/g,"").toLowerCase()));if(!i.has("src")&&!i.has("source")||!i.has("alt")&&!i.has("decorative"))return!1;let a=new Map(Object.entries(r).map(([S,I])=>[S.replace(/[-_]/g,"").toLowerCase(),I])),l=a.get("alt"),u=a.get("decorative"),f=typeof l==="string"&&!!l.trim(),v=typeof u==="string"?!["false","0","off","no"].includes(u.trim().toLowerCase()):Boolean(u);if(!f&&!v)return!1;if(["defaultsource","provider","format","densities","quality","preload","modifiers","preset"].some((S)=>i.has(S)))return!1;if([...n].some((S)=>!["load","error"].includes(S.replace(/^@/,"").split(".")[0].toLowerCase())))return!1;if(i.has("resizemode")&&(i.has("fit")||i.has("objectfit")))return!1;if(i.has("src")&&i.has("source"))return!1;return["fit","objectfit","resizemode","position","objectposition","rounded","aspectratio","zoomonhover","sources","webpsrc","webpsrcset"].some((S)=>i.has(S))}import Ns from"fs";import xe from"path";import Zt from"path";import jn from"fs";var uc=new Set(["touchstart","touchmove","wheel","mousewheel"]);function qs(e,n){if(n.passive)return!0;if(n.prevent||n.nonpassive)return!1;return uc.has(e.toLowerCase())}var ui=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","wheel","keydown","keyup","keypress","submit","reset","change","input","focus","blur","focusin","focusout","select","invalid","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","scroll","resize","load","error","abort","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel","mounted","unmounted"]),pi={enter:"Enter",tab:"Tab",delete:"Delete",backspace:"Backspace",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},pc=new Set(["ctrl","alt","shift","meta"]),gi={left:0,middle:1,right:2};function fi(e){let n={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let r of e){let i=r.toLowerCase();if(i==="prevent")n.prevent=!0;else if(i==="stop")n.stop=!0;else if(i==="once")n.once=!0;else if(i==="capture")n.capture=!0;else if(i==="self")n.self=!0;else if(i==="passive")n.passive=!0;else if(i==="nonpassive")n.nonpassive=!0;else if(pc.has(i))n.systemKeys.push(i);else if(i in gi)n.mouse=i;else if(i in pi||/^[a-z]$/.test(i))n.keys.push(pi[i]||i.toUpperCase());else if(i.startsWith("debounce")){let a=i.match(/debounce(?:\.(\d+))?/);n.debounce=a?.[1]?Number.parseInt(a[1],10):300}else if(i.startsWith("throttle")){let a=i.match(/throttle(?:\.(\d+))?/);n.throttle=a?.[1]?Number.parseInt(a[1],10):300}}return n}function mi(e,n=""){let r=[],i=0,a=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,l;while((l=a.exec(e))!==null){let[u,f,v]=l,S=l.index,I=S+u.length,j=`__stx_evt_${n}${i++}`,L=[],M=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,V;while((V=M.exec(v))!==null){let[,Z,q]=V,X=Z.split("."),U=X[0];if(!ui.has(U))continue;L.push({attribute:`@${Z}`,event:U,handler:q,modifiers:fi(X.slice(1)),elementId:j})}let W=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((V=W.exec(v))!==null){let[,Z,q]=V,X=Z.split("."),U=X[0];if(!ui.has(U))continue;L.push({attribute:`@${Z}`,event:U,handler:q,modifiers:fi(X.slice(1)),elementId:j})}if(L.length>0)r.push({originalTag:u,elementId:j,events:L,startIndex:S,endIndex:I})}return r}function fc(e){let n=[],{modifiers:r}=e;if(r.self)n.push("if ($event.target !== $el) return");for(let i of r.systemKeys)n.push(`if (!$event.${i}Key) return`);if(r.keys.length>0){let i=r.keys.map((a)=>`$event.key === '${a}'`).join(" || ");n.push(`if (!(${i})) return`)}if(r.mouse!==null){let i=gi[r.mouse];n.push(`if ($event.button !== ${i}) return`)}if(r.prevent)n.push("$event.preventDefault()");if(r.stop)n.push("$event.stopPropagation()");return n.join("; ")}function dc(e,n){let r=e;if(n.debounce!==null)r=`__stx_debounce(() => { ${r} }, ${n.debounce})`;else if(n.throttle!==null)r=`__stx_throttle(() => { ${r} }, ${n.throttle})`;return r}function Xs(e){let n=e.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n))return e;return`if (typeof ${n} === 'function' && !${n}._isSignal) ${n}($event);`}function gc(e){let{modifiers:n}=e,r=e.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),i=fc(e),a=dc(Xs(e.handler),n),l=[];if(n.once)l.push("once: true");if(n.capture)l.push("capture: true");if(qs(e.event,n))l.push("passive: true");let u=l.length>0?`, { ${l.join(", ")} }`:"",f=a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(e.event==="mounted")return`
3
- (function() {
4
- var $el = document.getElementById('${r}');
5
- if (!$el) return;
6
- // Run mounted handler immediately (DOM is ready)
7
- var scope = $el.closest('[data-stx-scope]');
8
- if (scope && scope.__stx_execute) {
9
- scope.__stx_execute('${f}', null, $el);
10
- }
11
- else {
12
- __stx_runHandler('${f}', null, $el);
13
- }
14
- })();`;if(e.event==="unmounted")return`
15
- (function() {
16
- var $el = document.getElementById('${r}');
17
- if (!$el) return;
18
- // Set up MutationObserver to detect removal
19
- var observer = new MutationObserver(function(mutations) {
20
- for (var m of mutations) {
21
- for (var node of m.removedNodes) {
22
- if (node === $el || (node.contains && node.contains($el))) {
23
- observer.disconnect();
24
- var scope = $el.closest('[data-stx-scope]');
25
- if (scope && scope.__stx_execute) {
26
- scope.__stx_execute('${f}', null, $el);
27
- }
28
- else {
29
- __stx_runHandler('${f}', null, $el);
30
- }
31
- return;
32
- }
33
- }
34
- }
35
- });
36
- observer.observe(document.body, { childList: true, subtree: true });
37
- // Store observer for cleanup
38
- $el.__stx_unmount_observer = observer;
39
- })();`;return`
40
- (function() {
41
- var $el = document.getElementById('${r}');
42
- if (!$el) return;
43
- // eslint-disable-next-line pickier/no-unused-vars
44
- $el.addEventListener('${e.event}', function($event) {
45
- ${i?i+";":""}
46
- // Find the closest reactive scope and execute within its context
47
- var scope = $el.closest('[data-stx-scope]');
48
- if (scope && scope.__stx_execute) {
49
- scope.__stx_execute('${f}', $event, $el);
50
- }
51
- else {
52
- // Fallback for non-reactive context (entity-safe; decoded + run in memory)
53
- __stx_runHandler('${f}', $event, $el);
54
- }
55
- }${u});
56
- })();`}function Mi(e){if(e.length===0)return"";return`
57
- <script data-stx-events>
58
- (function() {
59
- 'use strict';
60
-
61
- // Utility functions
62
- function __stx_debounce(fn, delay) {
63
- var timeout;
64
- return function() {
65
- var args = arguments;
66
- var ctx = this;
67
- clearTimeout(timeout);
68
- timeout = setTimeout(function() { fn.apply(ctx, args); }, delay);
69
- };
70
- }
71
-
72
- function __stx_throttle(fn, delay) {
73
- var last = 0;
74
- return function() {
75
- var now = Date.now();
76
- if (now - last >= delay) {
77
- last = now;
78
- fn.apply(this, arguments);
79
- }
80
- };
81
- }
82
-
83
- // Non-reactive fallback runner. The handler is embedded HTML-entity-encoded
84
- // so the surrounding script element can never contain raw markup, including
85
- // its own closing tag; we decode it to JS only in memory here, then run it
86
- // with $event/$el in scope.
87
- //
88
- // This comment must not spell that closing tag out. It used to, as an
89
- // example, and a browser ends the script element at the FIRST one it sees \u2014
90
- // so everything below this line, __stx_runHandler included, was emitted as
91
- // page text and no listener was ever bound. The comment about escaping was
92
- // the thing that needed escaping.
93
- function __stx_runHandler(h, $event, $el) {
94
- var code = h
95
- .replace(/&lt;/g, '<')
96
- .replace(/&gt;/g, '>')
97
- .replace(/&quot;/g, '"')
98
- .replace(/&#39;/g, "'")
99
- .replace(/&#x27;/g, "'")
100
- .replace(/&amp;/g, '&');
101
- try {
102
- // eslint-disable-next-line no-new-func
103
- (new Function('$event', '$el', code)).call($el, $event, $el);
104
- }
105
- catch (e) {
106
- if (typeof console !== 'undefined') console.error('[stx] event handler error:', e);
107
- }
108
- }
109
-
110
- // Event listeners
111
- ${e.map(gc).join(`
112
- `)}
113
- })();
114
- </script>`}function mc(e,n=""){let r=mi(e,n);if(r.length===0)return{template:e,bindings:[]};let i=e,a=[];for(let l=r.length-1;l>=0;l--){let u=r[l],f=u.originalTag;if(!f.includes(" id="))f=f.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${u.elementId}"`);else{let v=f.match(/id=["']([^"']+)["']/);if(v)for(let S of u.events)S.elementId=v[1]}for(let v of u.events){let S=v.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),I=new RegExp(`\\s*${S}\\s*=\\s*"[^"]*"`,"g"),j=new RegExp(`\\s*${S}\\s*=\\s*'[^']*'`,"g");f=f.replace(I,""),f=f.replace(j,"")}i=i.slice(0,u.startIndex)+f+i.slice(u.endIndex),a.push(...u.events)}return{template:i,bindings:a}}function di(e){let n=e.$uid;return typeof n==="string"&&n?`${n}_`:""}function al(e,n,r){if(ql(e))return e;if(n.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(e))return e;let{template:f,bindings:v}=mc(e,di(n)),S=n.__stx_event_bindings||[];return n.__stx_event_bindings=[...S,...v],f}let i=mi(e,di(n));if(i.length===0)return e;let a=e;for(let f=i.length-1;f>=0;f--){let v=i[f],S=v.originalTag;if(!S.includes(" id="))S=S.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${v.elementId}"`);else{let I=S.match(/id=["']([^"']+)["']/);if(I)for(let j of v.events)j.elementId=I[1]}for(let I of v.events){let j=I.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),L=new RegExp(`\\s*${j}\\s*=\\s*"[^"]*"`,"g"),M=new RegExp(`\\s*${j}\\s*=\\s*'[^']*'`,"g");S=S.replace(L,""),S=S.replace(M,"")}a=a.slice(0,v.startIndex)+S+a.slice(v.endIndex)}let l=Mi(i.flatMap((f)=>f.events)),u=c(a);if(u!==-1)a=a.slice(0,u)+l+`
115
- `+a.slice(u);else a+=l;return a}function hi(e,n){let r=new Set;for(let i of e.split(",")){let a=i.trim().replace(/^\.\.\./,"").trim();if(!a)continue;if(n){let l=a.lastIndexOf(":");if(l!==-1)a=a.slice(l+1).trim()}if(a=a.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(a))r.add(a)}return r}function Ut(e,n){let r=t(e),{depths:i,balanced:a}=h(r),l=(f)=>!a||i[f]===0,u=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${n}\\b)`,"g");for(let f of r.matchAll(u)){let v=(f.index??0)+f[0].length-f[1].length;if(l(v))return!0}for(let f of r.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(l(f.index??0)&&hi(f[1],!0).has(n))return!0;for(let f of r.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(l(f.index??0)&&hi(f[1],!1).has(n))return!0;return!1}var qe="0.2.917";var xi=Symbol.for(`stx.lazy-module-promises.${qe}`);function xc(){let e=globalThis;return e[xi]??=new Map,e[xi]}function o(e,n){let r=xc(),i=`${import.meta.url}\x00${e}`,a=r.get(i);if(a)return a;let l=n();return r.set(i,l),l.catch(()=>{if(r.get(i)===l)r.delete(i)}),l}var bc=/<\/(script)/gi;function me(e){if(!e||e.indexOf("</")===-1)return e;return e.replace(bc,"<\\/$1")}import bi from"fs";var yi=[];function k(e){let n=new T(e);return yi.push(n),n}function cl(){for(let e of yi)e.clear()}function E(e,...n){return`${n.map((r)=>String(r??"")).join("\x00")}\x00${e.length}\x00${Bun.hash(e)}`}function Mr(e){let n=[];for(let r of new Set(e))try{n.push({path:r,mtimeMs:bi.statSync(r).mtimeMs})}catch{}return n}function to(e){for(let n of e)try{if(bi.statSync(n.path).mtimeMs!==n.mtimeMs)return!1}catch{return!1}return!0}var Oe=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var yc=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function _c(e){if(e.startsWith(".")||e.startsWith("/"))return null;if(e.startsWith("@")){let r=e.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!r)return null;return{pkg:r[1],subpath:r[2]||""}}let n=e.match(/^([^/]+)(\/.*)?$/);if(!n)return null;return{pkg:n[1],subpath:n[2]||""}}function wc(e,n){let r=n;while(!0){let i=Zt.join(r,"node_modules",e,"package.json");if(jn.existsSync(i))return Zt.dirname(i);let a=Zt.dirname(r);if(a===r)return null;r=a}}function vc(e,n){if(!e||typeof e!=="object")return null;let r=(a)=>{if(typeof a==="string")return a;if(a&&typeof a==="object"){if(typeof a.import==="string")return a.import;if(typeof a.default==="string")return a.default;if(typeof a.import==="object")return r(a.import);if(typeof a.default==="object")return r(a.default)}return null};if(Object.prototype.hasOwnProperty.call(e,n))return r(e[n]);let i=null;for(let a of Object.keys(e)){let l=a.indexOf("*");if(l===-1)continue;let u=a.slice(0,l),f=a.slice(l+1);if(!n.startsWith(u)||!n.endsWith(f))continue;if(n.length<u.length+f.length)continue;if(!i||u.length>i.prefix.length)i={pattern:a,prefix:u,suffix:f}}if(i){let a=n.slice(i.prefix.length,n.length-i.suffix.length),l=r(e[i.pattern]);if(l)return l.replace("*",a)}return null}function Sc(e,n){let r=_c(e);if(!r||!r.subpath)return null;let i=wc(r.pkg,n);if(!i)return null;let a;try{a=JSON.parse(jn.readFileSync(Zt.join(i,"package.json"),"utf8"))}catch{return null}let l=`.${r.subpath}`,u=vc(a.exports,l);if(!u)return null;let f=Zt.resolve(i,u);return jn.existsSync(f)?f:null}function Vi(e,n){let r=n.filePath?Zt.dirname(n.filePath):n.projectRoot||process.cwd(),i=n.projectRoot||process.cwd(),a=new Set,l=[],u=[];return{code:e.replace(yc,(v,S)=>{let I;try{if(S.startsWith("./")||S.startsWith("../")||S.startsWith("/")){if(I=S.startsWith("/")?S:Zt.resolve(r,S),!jn.existsSync(I))throw Error(`file not found: ${I}`)}else{let j=null;try{j=Bun.resolveSync(S,i)}catch{j=Sc(S,i)}if(!j)throw Error(`could not resolve ${S} (Bun.resolveSync + exports fallback both failed)`);I=j}}catch(j){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(S)} (from ${n.filePath||"<unknown>"}): ${j?.message||j}`),u.push(S),""}if(a.has(I))return"";a.add(I);try{let j=jn.readFileSync(I,"utf8");l.push({source:S,resolvedPath:I,contents:j})}catch(j){console.warn(`[stx:vendor-css] could not read ${I}: ${j?.message||j}`),u.push(S)}return""}),styles:l,unresolved:u}}function $c(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Wi(e){if(e.length===0)return"";return`${e.map((n)=>`<style data-stx-vendor="${$c(n.source)}" data-stx-layer="vendor">
116
- @layer vendor {
117
- ${n.contents}
118
- }
119
- </style>`).join(`
120
- `)}
121
- `}var Hg=C,_i=k(256);function Gt(e){let n=E(e),r=_i.get(n);if(!r)r=Ec(e),_i.set(n,r);return{code:r.code,imports:[...r.imports],models:[...r.models]}}function Ec(e){let n=t(e),r=new Set;for(let f of e.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let v of f[1].split(",")){let S=v.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(S)r.add(S)}let i=xo(n),a=Oe.filter((f)=>{if(r.has(f)||i.has(f))return!1;return Ug(n,f,!0)}),l=$i(n).filter((f)=>!r.has(f)&&!i.has(f));if(a.length===0&&l.length===0)return{code:e,imports:a,models:l};return{code:`${[a.length>0?`import { ${a.join(", ")} } from '@stacksjs/browser'`:"",l.length>0?"import '@stacksjs/browser'":"",l.length>0?`const { ${l.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
122
- `)}
123
- ${e}`,imports:a,models:l}}var kc=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);function $i(e,n=Yr(e)){let r=new Set,i=xo(e),a=/(?<![\w$.])([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g;for(let l of n.code.matchAll(a)){let u=l[1];if(kc.has(u)||i.has(u)||u.length<3)continue;if(n.shadows(u,l.index??0))continue;r.add(u)}return Array.from(r)}function Cc(e){return xo(e)}var wi=k(128);function El(e){let n=E(e),r=wi.get(n);if(!r)r=Rc(e),wi.set(n,r);return{code:r.code,stxImports:[...r.stxImports],browserImports:[...r.browserImports]}}function Rc(e){let n=new Set,r=new Set,i=e;i=i.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let a=new Set,l=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,u;while((u=l.exec(e))!==null){let M=u[1],V=u[2];if(u[0].includes("import type"))continue;let W=[];for(let q of M.split(",")){let X=q.trim();if(!X||X.startsWith("type "))continue;let U=X.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!U)continue;let H=U[1],re=U[2]||H;if(a.add(H),a.add(re),V==="stx"||V==="@stacksjs/stx")n.add(H);else r.add(H);if(re!==H)W.push(`${re} = ${H}`)}let Z=W.length>0?`var ${W.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";i=i.replace(u[0],Z)}let f=Cc(i),v=Yr(i);for(let M of Hg){if(a.has(M)||f.has(M))continue;if(Gs(v,M,!0))n.add(M)}let S=t(i),I=Yr(S),j=new Set;for(let M of i.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let V of M[1].split(",")){let W=V.trim().replace(/^type\s+/,"").split(/\s+as\s+/);for(let Z of W){let q=Z.trim();if(q)j.add(q)}}for(let M of Oe){if(a.has(M)||f.has(M)||j.has(M))continue;if(Gs(I,M))r.add(M)}let L=$i(S,I);for(let M of L)if(!a.has(M)&&!f.has(M))r.add(M);return{code:i,stxImports:Array.from(n),browserImports:Array.from(r)}}function Ug(e,n,r=!1){return Gs(Yr(e),n,r)}function Gs(e,n,r=!1){let i=e.code,a=new RegExp(`\\b${n.replace(/[$]/g,"\\$")}\\b`,"g");for(let l of i.matchAll(a)){let u=l.index??0;if(e.shadows(n,u))continue;let f=u+n.length,v=u-1;while(v>=0&&/\s/.test(i[v]))v--;if(i[v]==="."&&i.slice(Math.max(0,v-2),v+1)!=="...")continue;let S=f;while(S<i.length&&/\s/.test(i[S]))S++;if(i[S]===":"&&i[S+1]!==":"&&(i[v]==="{"||i[v]===","))continue;if(r&&!/^\s*(?:<[^>]*>)?\s*\(/.test(i.slice(f)))continue;if(Ac(i,f))continue;return!0}return!1}function Ac(e,n){let r=n;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;if(e[r]!=="(")return!1;let i=0;for(;r<e.length;r++){let a=e[r];if(a==="(")i++;else if(a===")"){if(i--,i===0)break}}if(i!==0)return!1;r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;return e[r]==="{"}function Tl(e,n){let r=[];if(e.length>0)r.push(` var { ${e.join(", ")} } = window.stx || window;`);if(n.length>0)r.push(` var { ${n.join(", ")} } = window.StacksBrowser || {};`);if(r.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
124
- ${r.join(`
125
- `)}
126
- ${Tc(e,n)}`;return""}function Oy(e,n=[]){let{browserImports:r}=El(e),i=new Set(n);return Tl([],r.filter((a)=>!i.has(a)))}function Tc(e,n){let r=[...e.map((i)=>`['${i}', typeof ${i}, 'stx']`),...n.map((i)=>`['${i}', typeof ${i}, '@stacksjs/browser']`)];if(r.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
127
- [${r.join(", ")}].forEach(function (e) {
128
- if (e[1] !== 'undefined') return;
129
- console.error(
130
- '[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
131
- + 'but the client runtime does not provide it. Either it is not exported to the browser, '
132
- + 'or it should be imported from a relative path so the bundler includes it.'
133
- );
134
- });
135
- `}function Ge(e){let n=e.__stxClientPayload;if(n&&typeof n==="object"){let i={};for(let a in n){let l=n[a];if(typeof l==="function")continue;i[a]=l}return i.__stxDeclaredPayload=!0,i}let r={};for(let i in e){if(i.startsWith("__")||i.startsWith("$"))continue;let a=e[i];if(typeof a==="function")continue;r[i]=a}return r}var Ic=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,vi=new Set;function Oc(e,n){let r=Ic.test(e),i=n.length>32768;if(!r&&!i)return;if(vi.has(e))return;if(vi.add(e),r)console.warn(`[stx] server\u2192client bridge is publishing "${e}" into the page body. If it holds a credential, rename it with a "__" prefix (never bridged) and pass only what the template needs. See stacksjs/stx#1831.`);if(i)console.warn(`[stx] server\u2192client bridge is publishing ${(n.length/1024).toFixed(1)}KB under "${e}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function In(e,n){if(!n)return"";let r=je(e,new Set(Object.keys(n))),i=n.__stxDeclaredPayload===!0,a=[],l=Object.entries(n).sort(([u],[f])=>u<f?-1:u>f?1:0);for(let[u,f]of l){if(!/^[A-Za-z_$][\w$]*$/.test(u))continue;if(u.startsWith("__")||u.startsWith("$"))continue;if(!i&&!r.has(u))continue;if(Ut(e,u)){if(i)console.warn(`[stx] defineClientPayload declares "${u}", but this client block also declares "${u}" at the top level, so the server value is not published (emitting it would be a duplicate binding). Rename the local, or drop "${u}" from defineClientPayload.`);continue}let v;try{v=JSON.stringify(f)}catch{continue}if(v===void 0)continue;Oc(u,v),a.push(` var ${u} = ${v.replace(/</g,"\\u003c")};`)}if(a.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
136
- ${a.join(`
137
- `)}
138
- `}var jc={left:0,middle:1,right:2};function Pc(e){let n=[];if(e.self)n.push("if ($event.target !== $el) return");for(let r of e.systemKeys)n.push(`if (!$event.${r}Key) return`);if(e.keys.length>0){let r=e.keys.map((i)=>`$event.key === '${i}'`).join(" || ");n.push(`if (!(${r})) return`)}if(e.mouse!==null){let r=jc[e.mouse];n.push(`if ($event.button !== ${r}) return`)}if(e.prevent)n.push("$event.preventDefault()");if(e.stop)n.push("$event.stopPropagation()");return n.join("; ")}function Mc(e,n){let{elementId:r,event:i,modifiers:a}=e,l=Xs(e.handler),u=Pc(a),f=[];if(a.once)f.push("once: true");if(a.capture)f.push("capture: true");if(qs(i,a))f.push("passive: true");let v=f.length>0?`, { ${f.join(", ")} }`:"",S="";if(u)S+=`${u}; `;let I=l.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),j=`var $emit = function(name, detail) {
139
- $el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
140
- };`;function L(M){if(/\$emit\s*\(/.test(M))return`${j}
141
- ${M}`;return`var scope = $el.closest('[data-stx-scope]');
142
- if (scope && scope.__stx_execute) {
143
- scope.__stx_execute('${I}', $event, $el);
144
- }
145
- else {
146
- ${M}
147
- }`}if(a.debounce!==null)return` ;(function() {
148
- // eslint-disable-next-line pickier/no-unused-vars
149
- var $el = document.getElementById('${r}')
150
- if (!$el) return
151
- var __timer
152
- $el.addEventListener('${i}', function($event) {
153
- ${u?u+"; ":""}clearTimeout(__timer)
154
- __timer = setTimeout(function() { ${L(l)} }, ${a.debounce})
155
- }${v})
156
- })()`;if(a.throttle!==null)return` ;(function() {
157
- // eslint-disable-next-line pickier/no-unused-vars
158
- var $el = document.getElementById('${r}')
159
- if (!$el) return
160
- var __last = 0
161
- $el.addEventListener('${i}', function($event) {
162
- ${u?u+"; ":""}var __now = Date.now()
163
- if (__now - __last >= ${a.throttle}) {
164
- __last = __now
165
- ${L(l)}
166
- }
167
- }${v})
168
- })()`;if(/\$emit\s*\(/.test(l))return` var $el = document.getElementById('${r}')
169
- if ($el) $el.addEventListener('${i}', function($event) {
170
- ${S}${j}
171
- ${l}
172
- }${v})`;return` var $el = document.getElementById('${r}')
173
- if ($el) $el.addEventListener('${i}', function($event) {
174
- ${S}var scope = $el.closest('[data-stx-scope]');
175
- if (scope && scope.__stx_execute) {
176
- scope.__stx_execute('${I}', $event, $el);
177
- }
178
- else {
179
- ${l}
180
- }
181
- }${v})`}function Dc(e){if(e.length===0)return"";return`
182
- // STX: auto-generated event bindings
183
- ${e.map((r,i)=>Mc(r,i)).join(`
184
- `)}`}function Si(e){let n=[],r=new Set,i=e.replace(/^\s*import\s+.*$/gm,""),a=0,l=i.length,u=0;while(u<l){let f=i[u];if(f==="'"||f==='"'||f==="`"){let v=f;if(u++,v==="`"){let S=0;while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]==="`"&&S===0){u++;break}if(i[u]==="$"&&i[u+1]==="{"){S++,u+=2;continue}if(i[u]==="}"&&S>0){S--,u++;continue}u++}}else while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]===v){u++;break}u++}continue}if(f==="/"&&i[u+1]==="/"){while(u<l&&i[u]!==`
185
- `)u++;continue}if(f==="/"&&i[u+1]==="*"){u+=2;while(u<l-1&&!(i[u]==="*"&&i[u+1]==="/"))u++;u+=2;continue}if(f==="{"){a++,u++;continue}if(f==="}"){a--,u++;continue}if(a===0){let v=i.slice(u),S=v.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(S){let L=S[1];if(!L.startsWith("_")&&!r.has(L))n.push(L),r.add(L);u+=S[0].length;continue}let I=v.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){I[1].split(",").forEach((L)=>{let M=L.trim(),V=M.indexOf(":"),W=V>=0?M.slice(V+1).trim().split(/[\s=]/)[0]:M.split(/[\s=]/)[0];if(W&&!W.startsWith("_")&&!r.has(W))n.push(W),r.add(W)}),u+=I[0].length;continue}let j=v.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(j){let L=j[1];if(!L.startsWith("_")&&!r.has(L))n.push(L),r.add(L);u+=j[0].length;continue}}u++}return n}var Nc=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"]);function Lc(e){let n=new Set,r=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function i(L){let M;while((M=r.exec(L))!==null){let V=M[0];if(!Nc.has(V))n.add(V)}}let a=/\{\{([\s\S]*?)\}\}/g,l;while((l=a.exec(e))!==null)i(l[1]);let u=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((l=u.exec(e))!==null)i(l[1]);let f=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((l=f.exec(e))!==null)i(l[1]);let v=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((l=v.exec(e))!==null)i(l[1]);let S=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((l=S.exec(e))!==null)i(l[1]);let I=/@model\s*=\s*["']([^"']*)["']/gi;while((l=I.exec(e))!==null)i(l[1]);let j=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((l=j.exec(e))!==null)i(l[1]);return n}async function Je(e,n={}){let r=e,i="",a=!1,l=[],u=Vi(r,{filePath:n.filePath,projectRoot:n.projectRoot});r=u.code;let f=Wi(u.styles),v=Gt(r);r=v.code,l=[...v.imports,...v.models];let{hasUserImports:S,bundleClientScript:I}=await o("stx/client-script-bundler",()=>import("./chunk-wq17dce6.js"));if(S(r))r=await I(r,n.filePath||"",{projectRoot:n.projectRoot,minify:n.production}),a=!0;if(n.autoImports!==!1){let U=El(r);r=U.code,i=Tl(U.stxImports,U.browserImports.filter((H)=>!l.includes(H)))}if(i=`${In(r,n.serverData)}${i}`,r=D(r),!a&&Ye(n.attrs||""))r=Ze(r);let j=Dc(n.eventBindings||[]),L=(n.attrs||"").trim(),M=/\btype\s*=\s*["']module["']/i.test(L),V=n.instanceId?` data-stx-instance="${n.instanceId}"`:"";if(M){let U=L.replace(/\btype\s*=\s*["']module["']/i,"").trim(),H=`type="module" data-stx-scoped${V}${U?` ${U}`:""}`;return`${f}<script ${H}>
186
- ${me(`${i}${r}
187
- ${j}`)}
188
- </script>`}let W=oa(e),Z=/function __stx_setup_/.test(r),q=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(e);function X(U){let H=U.length>0?`
189
- return ${Ys(r,U)};`:"",re=JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`);return`${f}<script data-stx-scoped data-stx-run="always"${V}>
190
- window.stx.mount(function() {
191
- 'use strict';
192
- try {
193
- ${me(`${i}${r}
194
- ${j}${H}`)}
195
- } catch (error) {
196
- console.error(${re}, error);
197
- return {};
198
- }
199
- })</script>`}if(!q&&!Z){if(W)return X(Si(e));if(n.templateContent){let U=Si(e);if(U.length>0){let H=Lc(n.templateContent);if(U.some((ce)=>H.has(ce)))return X(U)}}}return`${f}<script data-stx-scoped data-stx-run="always"${V}>
200
- ;(function() {
201
- 'use strict';
202
- try {
203
- ${me(`${i}${r}
204
- ${j}`)}
205
- } catch (error) {
206
- console.error(${JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`)}, error);
207
- }
208
- })()</script>`}import{createHash as Kc}from"crypto";var er=/\s*/y,tr=/\x00STX_HTML_COMMENT_\d+\x00/y;function Vt(e){let n=0;while(n<e.length){if(er.lastIndex=n,er.exec(e),n=er.lastIndex,e.startsWith("<!--",n)){let r=e.indexOf("-->",n+4);if(r===-1)return n;n=r+3;continue}if(tr.lastIndex=n,tr.test(e)){n=tr.lastIndex;continue}return n}return n}var nr=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,zc=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function Ne(e){let n=[],r=0;while(r<e.length){let i=e.indexOf("<",r);if(i===-1)break;if(e.startsWith("<!--",i)){let L=e.indexOf("-->",i+4);if(L===-1)break;r=L+3;continue}nr.lastIndex=i;let a=nr.exec(e);if(!a){r=i+1;continue}let l=nr.lastIndex,u=l,f=null;for(;u<e.length;u++){let L=e[u];if(f){if(L===f)f=null}else if(L==='"'||L==="'")f=L;else if(L===">")break}if(u===e.length)break;let v=a[1]==="/",S=e[u-1]==="/";n.push({start:i,end:u+1,name:a[2],attributes:e.slice(l,S?u-1:u),closing:v,selfClosing:S}),r=u+1;let I=a[2].toLowerCase();if(!v&&I==="plaintext")break;let j=zc.get(I);if(!v&&(I==="script"||I==="style"||j)){let L=j??(I==="script"?ds:gs);L.lastIndex=r;let M=L.exec(e);if(!M)break;r=M.index}}return n}var ps=/<script\b[^>]*>/iy,ds=/<\/script\s*>/ig,fs=/<style\b[^>]*>/iy,gs=/<\/style\s*>/ig;function Ei(e,n,r,i){r.lastIndex=n;let a=r.exec(e);if(!a||a.index!==n)return-1;i.lastIndex=r.lastIndex;let l=i.exec(e);if(!l)return-1;return l.index+l[0].length}function Q(e,n){return Ei(e,n,ps,ds)}function Tn(e,n){return Ei(e,n,fs,gs)}function Xe(e,n){if(!e.startsWith("<!--",n))return-1;let r=e.indexOf("-->",n+4);if(r===-1)return-1;return r+3}function ki(e,n){if(e.startsWith("<!--",n)){let a=Xe(e,n);return a===-1?e.length:a}if(ps.lastIndex=n,ps.exec(e)?.index===n){ds.lastIndex=ps.lastIndex;let a=ds.exec(e);return a?a.index+a[0].length:e.length}if(fs.lastIndex=n,fs.exec(e)?.index===n){gs.lastIndex=fs.lastIndex;let a=gs.exec(e);return a?a.index+a[0].length:e.length}return-1}function x(e,n){let r=[],i=0,a=e.length,l=!1,u=null;while(i<a){let f=e[i];if(l){if(u){if(f===u)u=null}else if(f==='"'||f==="'")u=f;else if(f===">")l=!1;i++;continue}if(f!=="<"){let j=e.indexOf("<",i+1);if(j===-1)break;i=j;continue}let v=n(e,i);if(v>i){r.push({start:i,end:v,token:e.slice(i,v)}),i=v;continue}let S=ki(e,i);if(S>i){i=S;continue}let I=e.charCodeAt(i+1);if(I>=65&&I<=90||I>=97&&I<=122)l=!0;i++}return r}function Ci(e){let n=0,r=0,i=0,a=!1,l=null;while(i<e.length){if(a){let j=e[i];if(l){if(j===l)l=null}else if(j==='"'||j==="'")l=j;else if(j===">")a=!1;i++;continue}let u=e.indexOf("<",i),f=u===-1?e.length:u;while(i<f){let j=e[i++];if(j==="{")n++;else if(j==="}")r++;if(n>=2&&r>=2)return!0}if(u===-1)break;let v=ki(e,u);if(v>u){i=v;continue}let S=e.charCodeAt(u+1),I=S===47?e.charCodeAt(u+2):S;if(I>=65&&I<=90||I>=97&&I<=122)a=!0;i=u+1}return!1}function ll(e,n){while(e.size>=n){let r=e.keys().next();if(r.done)return;e.delete(r.value)}}var Bc=1024,Wc=16777216,un=new Map,sr=0;function Fc(e,n){un.set(e,n),sr+=e.length+n.output.length;for(let[r,i]of un){if(sr<=Wc)break;un.delete(r),sr-=r.length+i.output.length}}function ke(e,n,r,i){let a=i!==void 0&&e.length>=Bc,l=a?`${i}\x00${e}`:"";if(a){let I=un.get(l);if(I)return un.delete(l),un.set(l,I),{output:I.output,tokens:I.tokens.slice()}}let u=x(e,n);if(u.length===0)return{output:e,tokens:[]};let f=u.map((I)=>I.token),v="",S=0;for(let I=0;I<u.length;I++){let j=u[I];v+=e.slice(S,j.start),v+=r(j.token,I),S=j.end}if(v+=e.slice(S),a)return Fc(l,{output:v,tokens:f}),{output:v,tokens:f.slice()};return{output:v,tokens:f}}var Vc=1024,Uc=16777216,pn=new Map,rr=0;function Hc(e,n){pn.set(e,n),rr+=e.length+n.output.length;for(let[r,i]of pn){if(rr<=Uc)break;pn.delete(r),rr-=r.length+i.output.length}}function ir(e,n,r){return{output:n,scripts:r,restore:(i)=>i===n?e:Dr(i,r)}}function se(e){let n=e.length>=Vc;if(n){let a=pn.get(e);if(a)return pn.delete(e),pn.set(e,a),ir(e,a.output,a.scripts.slice())}let{output:r,tokens:i}=ke(e,Q,(a,l)=>`\x00STX_SCRIPT_${l}\x00`);if(n)return Hc(e,{output:r,scripts:i}),ir(e,r,i.slice());return ir(e,r,i)}function Dr(e,n){if(n.length===0)return e;return e.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(r,i)=>n[+i]??"")}function ee(e){let n=Ne(e),r=[];for(let i=0;i<n.length;i++){let a=n[i],l=n[i+1];if(a.name.toLowerCase()!=="script"||a.closing||l?.name.toLowerCase()!=="script"||!l.closing)continue;r.push({start:a.start,end:l.end,bodyStart:a.end,bodyEnd:l.start,attrs:a.attributes})}return r}var ms="__stx_component_client_factories";function hs(e){let n=e[ms];return n instanceof Map?n:null}function Sl(e){e[ms]=new Map}function or(e,n){let r=hs(e);if(!r)return null;let i=Kc("sha256").update(n).digest("hex").slice(0,16),a=r.get(i);if(a)a.instances++;else r.set(i,{body:n,instances:1});return i}function kl(e,n){let r=hs(n);if(!r?.size)return e;let i=new Map;for(let[I,j]of r)if(j.instances===1)i.set(I,j.body);let a=[];if(i.size>0){let I=[...i.keys()].map((M)=>JSON.stringify(M).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),j=new RegExp(`window\\.__stxComponentFactories\\[(${I})\\]\\(("[^"]+")\\);`,"g"),L=j.exec(e);while(L!==null){let M=i.get(JSON.parse(L[1]));if(M!==void 0)a.push({start:L.index,end:L.index+L[0].length,replacement:me(`(${M})(${L[2]});`)});L=j.exec(e)}}let l=[...r].filter(([,I])=>I.instances>1);if(l.length===0)return Ri(e,a);let u=l.map(([I,j])=>` try { factories[${JSON.stringify(I)}] = factories[${JSON.stringify(I)}] || ${j.body}; }
209
- catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(I)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
210
- `),f=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
211
- (function() {
212
- const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
213
- ${me(u)}
214
- })();
215
- </script>`,v,S=/<(?:template\b|script\b(?=[^>]*\bdata-stx-scoped\b))/iy;return x(e,(I,j)=>{if(v===void 0){if(S.lastIndex=j,S.test(I))v=j}return-1}),a.push({start:v??0,end:v??0,replacement:`${f}
216
- `}),Ri(e,a)}function Ri(e,n){if(n.length===0)return e;n.sort((l,u)=>l.start-u.start||l.end-u.end);let r=Array(n.length*2+1),i=0,a=0;for(let l of n)r[a++]=e.slice(i,l.start),r[a++]=l.replacement,i=l.end;return r[a]=e.slice(i),r.join("")}function Ai(e){let n=hs(e),r=new Map;if(n)for(let[i,a]of n)r.set(i,a.instances);return r}function Ti(e,n){let r=hs(e);if(!r)return[];let i=[];for(let[a,l]of r){let u=l.instances-(n.get(a)??0);if(u>0)i.push({body:l.body,count:u})}return i}function Pi(e,n){for(let{body:r,count:i}of n)for(let a=0;a<i;a++)or(e,r)}function Ie(e,n,r=2){let i=0,a=null;for(let l=n+r;l<e.length;l++){let u=e[l];if(a){if(u==="\\"){l++;continue}if(u===a)a=null;continue}if(u==='"'||u==="'"||u==="`"){a=u;continue}if(u==="{"){i++;continue}if(u==="}"){if(i>0){i--;continue}let f=0;while(e[l+f]==="}")f++;if(f>=r)return l}}return-1}import So from"fs";var Zi=0,ar=new Map;function Pl(){Zi=0,ar.clear()}function xs(e,n){let r=Zi++,i=`<!--__STX_${e.toUpperCase()}_${r}__-->`;return ar.set(i,{type:e,expression:n}),i}function Il(){let e={};for(let[n,r]of ar)e[n]={type:r.type,expression:r.expression};return e}function Ol(e,n){let r=e;for(let[i,a]of n)r=r.split(i).join(a);return r}function Ki(e){return e.includes("<!--__STX_")}var qc=/@(?=[a-zA-Z_]\w*\s*\(|end[a-zA-Z]*\b|else(?:if)?\b|empty\b|case\b|default\b|break\b|continue\b|fallback\b)/g;function Zc(e){return Array.from({length:e},()=>"&#123;").join("&#8288;")}function Ji(e){return e.replace(/\{{2,}/g,(n)=>Zc(n.length)).replace(/\{(?=!)/g,"&#123;&#8288;").replace(qc,"&#64;")}function jr(e,n,r=!1){let{openTag:i,tail:a}=r?Jc(e,n):Xc(e).at(n);return Yc(a,i,r)}function Jc(e,n){let r="",i=0;for(let u=0;u<n;u++){if(!e.startsWith("{{",u))continue;let f=Ie(e,u);if(f<0||f+2>n)break;r+=e.slice(i,u)+"x",u=f+1,i=f+2}r+=e.slice(i,n);let a=-1,l=null;for(let u=0;u<r.length;u++){let f=r[u];if(l){if(f===l)l=null;continue}if(f==='"'||f==="'"){l=f;continue}if(f===">"){a=-1;continue}if(f==="<")a=u}return{openTag:a,tail:a>=0?r.slice(a+1):r}}var bs=null;function Xc(e){if(bs&&bs.source===e)return bs.scanner;let n=Gc(e);return bs={source:e,scanner:n},n}function Gc(e){let n=0,r=-1,i=null,a=-1,l=(f,v)=>{let S=e[f];if(v.quote){if(S===v.quote)v.quote=null;return}if(v.openTag>=0){if(S==='"'||S==="'"){v.quote=S;return}if(S===">"){v.openTag=-1;return}}if(S==="<")v.openTag=f},u=(f,v)=>{if(v.openTag>=0||!e.startsWith("<!--",f))return-1;let S=e.indexOf("-->",f+4);return S<0?e.length:S+3};return{at(f){if(f<n)n=0,r=-1,i=null,a=-1;let v={openTag:r,quote:i},S=!1;while(n<f){if(a<0&&e.startsWith("{{",n)){let W=Ie(e,n);if(W<0)a=n;else if(W+2<=f){n=W+2;continue}else break}let V=u(n,v);if(V>=0){if(V>f){S=!0;break}n=V;continue}l(n,v),n++}if(r=v.openTag,i=v.quote,S)return{openTag:-1,tail:""};let I=a>=0?a:n,j={openTag:r,quote:i};for(let V=n;V<f;V++){let W=u(V,j);if(W>=0){if(W>f)return{openTag:-1,tail:""};V=W-1;continue}l(V,j)}if(j.openTag<0)return{openTag:-1,tail:""};let L="",M=j.openTag+1;for(let V=M;V<Math.min(f,I);V++){if(!e.startsWith("{{",V))continue;let W=Ie(e,V);L+=e.slice(M,V)+"x",V=W+1,M=W+2}return L+=e.slice(M,f),{openTag:j.openTag,tail:L}}}}function Yc(e,n,r){if(n<0&&!r)return null;if(n>=0&&/^\s*[!/?]/.test(e))return/^\s*\/?\s*$/.test(e)?{kind:"tag-name"}:null;if(n>=0&&/^\s*$/.test(e))return{kind:"tag-name"};let i=0;if(n>=0)while(i<e.length&&!/\s/.test(e[i]))i++;while(i<e.length){while(/\s/.test(e[i]??"")&&i<e.length)i++;let a=i;while(i<e.length&&!/[\s=/>]/.test(e[i]))i++;let l=e.slice(a,i);if(!l)break;while(i<e.length&&/\s/.test(e[i]))i++;if(e[i]!=="=")continue;i++;while(i<e.length&&/\s/.test(e[i]))i++;let u=e[i];if(u==='"'||u==="'"){let f=++i,v=e.indexOf(u,i);if(v===-1)return{kind:"attribute",name:l,quote:u,valuePrefix:e.slice(f)};i=v+1}else{let f=i;while(i<e.length&&!/\s/.test(e[i]))i++;if(i===e.length)return{kind:"attribute",name:l,quote:null,valuePrefix:e.slice(f)}}}return{kind:"tag"}}class he extends Error{attribute;near;constructor(e,n){super(`Unsafe interpolation in ${e}: ${n}`);this.name="UnsafeInterpolationContextError",this.attribute=e}locate(e,n){if(this.near===void 0)this.near=e.slice(Math.max(0,n-160),n).replace(/\s+/g," ").trim(),this.message+=` (after: ${JSON.stringify(this.near)})`;return this}}var Qi="unsafe:";var Qc=/^(?:javascript|vbscript|livescript|mocha|view-source):/,el=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,tl=/^data:(?:text\/html|application\/xhtml\+xml)/,nl=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function sl(e){return e.replace(nl,"").toLowerCase()}function cr(e){let n=e.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(n))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(n))return"fetched";return null}function ys(e,n="navigable"){let r=sl(e);if(Qc.test(r))return!0;return n==="navigable"?el.test(r):tl.test(r)}function Lr(e,n="navigable"){return ys(e,n)?"unsafe:"+e:e}function rl(e){let n=e.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!n)return null;if(n[3].trim()!=="")return null;return cr(n[1])}function ho(e,n,r=256){if(n<=r)return e.slice(0,n);let i=e.slice(n-r,n),a=i.search(/[\s"'`/]/);return a===-1?"":i.slice(a)}function bo(e,n,r=n){let i=rl(e);return i&&ys(n,i)?"unsafe:"+r:r}function Wt(e){let n=e.indexOf(" as ");if(n!==-1){let l=e.slice(0,n).trim(),u=e.slice(n+4).trim();return l&&u?{arrayExpr:l,itemVar:u}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let i=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),a=r[2].trim();return i&&a?{arrayExpr:a,itemVar:i}:null}function _s(e){let n=[],r=0,i="",a=0;for(let l=0;l<e.length;l++){let u=e[l];if(i){if(u==="\\")l++;else if(u===i)i="";continue}if(u==="'"||u==='"'||u==="`")i=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0)n.push(e.slice(a,l)),a=l+1}return n.push(e.slice(a)),n}function yo(e,n){let r=0;for(let i=0;i<e.length;i++){let a=e[i];if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===n&&r===0)return i}return-1}function _o(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="("||i==="["||i==="{")n++;else if((i===")"||i==="]"||i==="}")&&--n===0)return r}return-1}function Jt(e,n){let r=e.trim().replace(/^\.\.\./,"").trim(),i=yo(r,"=");if(i!==-1&&r[i+1]!==">")r=r.slice(0,i).trim();if(!r)return;if(r.startsWith("{")&&r.endsWith("}")){for(let a of _s(r.slice(1,-1))){let l=a.trim();if(!l)continue;if(l.startsWith("...")){Jt(l,n);continue}let u=yo(l,":");Jt(u===-1?l:l.slice(u+1),n)}return}if(r.startsWith("[")&&r.endsWith("]")){for(let a of _s(r.slice(1,-1)))Jt(a,n);return}if(/^[A-Z_$][\w$]*$/i.test(r))n.push(r)}function oe(e){let n=e.trim(),r=[],i=0;for(let l=0;l<n.length;l++){let u=n[l];if(u==="("||u==="["||u==="{")i++;else if(u===")"||u==="]"||u==="}")i--;else if(i===0&&/\s/.test(u)){if(!/^\s+(?:in|of)\s/.exec(n.slice(l)))continue;let v=n.slice(0,l).trim();if(v.startsWith("(")&&_o(v)===v.length-1)v=v.slice(1,-1);for(let S of _s(v))Jt(S,r);if(r.length>0)return r;break}}let a=/^[\s\S]+?\s+as\s+([\s\S]+)$/.exec(n);if(a){let l=a[1].trim();if(l.startsWith("(")&&_o(l)===l.length-1)l=l.slice(1,-1);let u=/^([\w$]+)\s*=>\s*([\s\S]+)$/.exec(l);if(u)Jt(u[2],r),Jt(u[1],r);else for(let f of _s(l))Jt(f,r)}return r}function F(e,n){let r=n instanceof Set?n:new Set(n);if(r.size===0)return!1;let u=e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g," ").replace(/`(?:[^`\\$]|\\.|\$(?!\{))*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:(?!:))/g,"$1$2");for(let f of u.match(/[a-zA-Z_$][\w$]*/g)||[])if(r.has(f))return!0;return!1}var ws="__stx_client_loop_names";function mt(e){let n=e?.[ws];return Array.isArray(n)?n:[]}function vs(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],i=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let a of e.matchAll(i)){let l=a[0];if(/^<\/template\s*>$/i.test(l)){let u=r.pop();if(u)u.end=a.index}else if(/^<template\b/i.test(l)&&!/\/\s*>$/.test(l)){let f=[...l.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((I)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(I[1])),v=(f?.[2]??f?.[3])?.trim();if(v&&f?.[1]==="data-stx-slot-binding")try{v=decodeURIComponent(v)}catch{v=void 0}let S=v?{start:a.index+l.length,end:e.length,binding:v}:void 0;if(r.push(S),S)n.push(S)}}return n}var Bn={},$o=new Map;function il(e){let n=$o.get(e);if(!n){let r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`:${r}(?!\\w)`,"g"),$o.set(e,n)}return n.lastIndex=0,n}var fo={uppercase:(e,n)=>e!==void 0&&e!==null?String(e).toUpperCase():"",lowercase:(e,n)=>e!==void 0&&e!==null?String(e).toLowerCase():"",capitalize:(e,n)=>{if(e===void 0||e===null)return"";let r=String(e);return r.charAt(0).toUpperCase()+r.slice(1)},number:(e,n,r=0)=>{if(e===void 0||e===null)return"";try{let i=Number(e);return Number.isNaN(i)?"":i.toFixed(Number.parseInt(String(r),10))}catch{return""}},fmt:(e,n,r="en-US")=>{if(e===void 0||e===null)return"";try{let i=Number(e);if(Number.isNaN(i))return String(e);return i.toLocaleString(r)}catch{return String(e)}},join:(e,n,r=",")=>{if(!Array.isArray(e))return"";return e.join(String(r))},escape:(e,n)=>{if(e===void 0||e===null)return"";return Y(String(e))},translate:(e,n,r={})=>{if(!n||!n.__translations)return e;let i=n.__translations,a=n.__i18nConfig?.fallbackToKey??!0,l=String(e).split("."),u=i;for(let v of l){if(u===void 0||u===null)break;u=u[v]}if(u===void 0||u===null)return a?e:"";let f=String(u);return Object.entries(r).forEach(([v,S])=>{f=f.replace(il(v),()=>String(S))}),f},t:(e,n,r={})=>fo.translate(e,n,r),truncate:(e,n,r=50,i="...")=>{if(e===void 0||e===null)return"";let a=String(e);if(a.length<=r)return a;if(r<=i.length)return i.substring(0,r);return a.substring(0,r-i.length)+i},date:(e,n,r="short",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=e instanceof Date?e:new Date(e);if(Number.isNaN(a.getTime()))return String(e);let l={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(r==="iso")return a.toISOString();return new Intl.DateTimeFormat(i,l[r]||l.short).format(a)}catch{return String(e)}},currency:(e,n,r="USD",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=Number(e);if(Number.isNaN(a))return String(e);return new Intl.NumberFormat(i,{style:"currency",currency:r}).format(a)}catch{return String(e)}},pluralize:(e,n,r,i)=>{let a=Number(e);if(Number.isNaN(a))return r;let l=i||`${r}s`;return a===1?r:l},first:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[0];return String(e).charAt(0)},last:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[e.length-1];let r=String(e);return r.charAt(r.length-1)},length:(e,n)=>{if(e===void 0||e===null)return 0;if(Array.isArray(e)||typeof e==="string")return e.length;if(e instanceof Map||e instanceof Set)return e.size;if(typeof e==="object")return Object.keys(e).length;return 0},json:(e,n,r=!1)=>{if(e===void 0)return"undefined";if(e===null)return"null";try{return r?JSON.stringify(e,null,2):JSON.stringify(e)}catch{return String(e)}},default:(e,n,r="")=>e===void 0||e===null||e===""?r:e,reverse:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return[...e].reverse();return String(e).split("").reverse().join("")},slice:(e,n,r=0,i)=>{if(e===void 0||e===null)return"";if(Array.isArray(e)||typeof e==="string")return e.slice(r,i);return e},replace:(e,n,r,i="")=>{if(e===void 0||e===null)return"";let a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(e).replace(new RegExp(a,"g"),()=>i)},stripTags:(e,n)=>{if(e===void 0||e===null)return"";return String(e).replace(/<[^>]*>/g,"")},urlencode:(e,n)=>{if(e===void 0||e===null)return"";return encodeURIComponent(String(e))},abs:(e,n)=>{let r=Number(e);return Number.isNaN(r)?0:Math.abs(r)},round:(e,n,r=0)=>{let i=Number(e);if(Number.isNaN(i))return 0;let a=10**r;return Math.round(i*a)/a}};function Zg(e,n){if(e in fo)console.warn(`Filter "${e}" already exists as a built-in filter. Custom filter will take precedence.`);Bn[e]=n}function My(e){for(let[n,r]of Object.entries(e))Zg(n,r)}function Qg(){return{...fo,...Bn}}function Dy(){for(let e of Object.keys(Bn))delete Bn[e]}function To(e){let n=e.next();while(!n.done)n=e.next();return n.value}function*Io(e,n,r,i){let a="{".repeat(r);if(!e.includes(a))return e;let l="",u=0,f=0,v=i===Number.POSITIVE_INFINITY?0:performance.now();for(;;){let S=e.indexOf(a,u);if(S===-1)break;let I=Ie(e,S,r);if(I===-1)break;if(l+=e.slice(u,S)+n(e.slice(S,I+r),e.slice(S+r,I),S),u=I+r,++f>=64){f=0;let j=performance.now();if(j-v>=i)v=j,yield}}return u===0?e:l+e.slice(u)}function Nn(e,n,r=2){return To(Io(e,n,r,Number.POSITIVE_INFINITY))}function ol(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=jr(e,n);if(!a||a.kind!=="attribute"||a.quote===i)return!1;if(!/^(?::|@|x-|v-)/.test(a.name))return!1;let l=0;for(let u=0;u<a.valuePrefix.length;u++)if(a.valuePrefix[u]==="\\")u++;else if(a.valuePrefix[u]===i)l++;return l%2===1}function g(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Y(e){return Ji(g(e))}function jl(e){return e.replace(/ /g,"&#32;").replace(/\t/g,"&#9;").replace(/\n/g,"&#10;").replace(/\r/g,"&#13;").replace(/\f/g,"&#12;").replace(/=/g,"&#61;").replace(/`/g,"&#96;")}function Ml(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\([\dA-Fa-f]{1,6})\s?/g,(n,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(/\\([^\r\n])/g,"$1").replace(/[\u0000-\u0020]+/g,"").toLowerCase()}function Dl(e,n){let r=Ml(e);if(/@import|expression\(|behavior:|-moz-binding|(?:image-set|cross-fade)\(/.test(r))throw new he(n,"network-capable or executable CSS is not allowed in an escaped interpolation");let i=/url\(([^)]*)\)/g,a;while((a=i.exec(r))!==null){let l=a[1].replace(/^["']|["']$/g,""),u=l.startsWith("/")&&!l.startsWith("//")||l.startsWith("./")||l.startsWith("../")||l.startsWith("#"),f=/^data:image\/(?:avif|bmp|gif|jpeg|jpg|png|webp);base64,[a-z\d+/=]+$/i.test(l);if(!u&&!f)throw new he(n,"CSS URLs must be local paths or base64 raster images")}}function ae(e,n,r,i=!1,a=0){try{return Nl(e,n,r,i,a)}catch(l){if(l instanceof he)l.locate(e,n);throw l}}function Nl(e,n,r,i,a){let l=jr(e,n,i),u=Y(r);if(!l)return u;if(l.kind==="tag-name"){if(!/^[A-Za-z][A-Za-z0-9:-]*$/.test(r))throw new he("tag name","dynamic tag names may contain only letters, digits, colons, and hyphens");return r}if(l.kind==="tag"){let S=e.slice(n+a).trimStart(),I=r.trim();if(!S.startsWith("=")&&(I===""||I.split(/\s+/).every((j)=>/^(?!on)[A-Za-z_:][\w:.-]*$/.test(j))))return I;throw new he("tag structure","only standalone boolean attributes may be interpolated into tag structure")}let f=l.name.toLowerCase();if(/^on[a-z]/.test(f))throw new he(l.name,"native event-handler attributes execute JavaScript; use an @event binding instead");if(f==="srcdoc")u=Y(u);if(f==="style")Dl(r,l.name);if(l.quote===null)u=jl(u);let v=cr(f);if(v&&l.valuePrefix.trim()===""&&ys(r,v))return Qi+u;return bo(ho(e,n),r,u)}function Mn(e,n){let r=` ${e}="`;return ae(r,r.length,n,!0)}function Oo(e){return e.flatMap((n)=>{let r=n.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);return!r||/\bserver\b|\bsrc\s*=/.test(r[1])?[]:[r[2]]})}function Me(e,n){let{scripts:r}=se(e);for(let i of Oo(r)){if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(i)||Rl.test(i))return!0;if(Zr(i,n))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(e))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(e))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(e))return!0;return!1}function em(e){let n=[],r=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let i=r.exec(e);i;i=r.exec(e)){let a=i[1].toLowerCase(),l=new Set(oe(i[3]));if(l.size===0)continue;let u=i.index+i[0].length;if(i[0].endsWith("/>")){n.push({start:i.index,end:u,names:l});continue}let f=new RegExp(`<(/?)${a}\\b[^>]*?(/?)>`,"gi");f.lastIndex=u;let v=1,S=e.length;for(let I=f.exec(e);I;I=f.exec(e)){if(I[2]==="/")continue;if(v+=I[1]==="/"?-1:1,v===0){S=I.index+I[0].length;break}}n.push({start:i.index,end:S,names:l})}return n}function Eo(e,n,r){let i=t(r);for(let a of e){if(n<a.start||n>=a.end)continue;for(let l of a.names)if(new RegExp(`(?<![.#\\w$])${l.replace(/\$/g,"\\$")}(?![\\w$])`).test(i))return!0}return!1}function ko(e,n){let r=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","URL","URLSearchParams","Intl","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console","new","typeof","instanceof","in","void"],i=e.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),a="",l=!1,u=0;for(let S=0;S<i.length;S++){let I=i[S];if(!l&&I==="`"){l=!0,u=0;continue}if(l){if(I==="`"&&u===0){l=!1;continue}if(I==="$"&&i[S+1]==="{"){u++,S++,a+=" ";continue}if(I==="}"&&u>0){u--;continue}if(u>0){a+=I;continue}continue}a+=I}i=a;let f=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,v;while((v=f.exec(i))!==null){let S=v[1];if(!i.substring(0,v.index).trimEnd().endsWith(".")){if(!r.includes(S)&&!(S in n))return!1}}return!0}function Ll(e,n){let r=t(e);for(let i of r.matchAll(/(?<![.\w$])([A-Z_$][\w$]*)\s*\(/gi))if(typeof n[i[1]]==="function")return!0;return!1}function zl(e,n){let r=n.__stx_serverDeclared;if(!r||r.size===0)return!1;let i=t(e);for(let a of r)if(new RegExp(`(?<![.#\\w$])${a}(?![\\w$])`).test(i))return!0;return!1}var Co=new Set;function Ro(e){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(e.trim())}function Bl(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=0;for(let l=e.lastIndexOf(`
217
- `,n-1)+1;l<n;l++)if(e[l]==="\\")l++;else if(e[l]===i)a++;return a%2===1}function Ao(e,n){let r=`${n??"<unknown>"}\x00${e}`;if(process.env.STX_DEBUG||!Co.has(r))Co.add(r),console.warn(`[stx] {{ ${e} }} in a <script> in ${n??"<unknown>"} has no server value, so it was emitted as undefined. A mustache left in JavaScript is a SyntaxError that takes the whole script down, so give the value a default in <script server>.`);return"undefined"}function Xi(e,n,r){let i=e;return i=i.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>{try{let u=N(l,n);if(u===void 0)return Ro(l)?Ao(l.trim(),r):a;return u===null?"":String(u)}catch{return a}}),i=Nn(i,(a,l,u)=>{let f=l.trim();if(Bl(i,u,l))return a;if(/^__[A-Z_]+__$/.test(f))return a;try{let v=N(l,n);if(v===void 0)return Ro(f)?Ao(f,r):a;return JSON.stringify(v).replace(/</g,"\\u003c").replace(/@/g,"\\u0040").replace(/\{{2,}/g,(S)=>"\\u007b".repeat(S.length)).replace(/\{(?=!)/g,"\\u007b")}catch{return a}}),i}function tm(e,n){if(!e.includes("{"))return e;let r=e;return r=r.replace(/\{!!([\s\S]*?)!!\}/g,(i,a)=>{try{let l=N(a,n);if(l===void 0)return i;return l===null?"":String(l)}catch{return i}}),r=Nn(r,(i,a,l)=>{let u=a.trim();if(/^__[A-Z_]+__$/.test(u))return i;try{let f=N(a,n);if(f===void 0)return i;if(f===null)return"";let v=String(f);return ae(r,l,v,!0,i.length)}catch(f){if(f instanceof he)throw f;return i}}),r}function Ly(e,n,r={}){let{output:i,scripts:a}=se(e),l=a.map((u)=>{let f=u.match(/^<script\b((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>/i),v=u.search(/<\/script\s*>$/i);if(!f||v===-1)return u;let S=f[1],I=u.slice(f[0].length,v);if(/\bdata-raw\b/.test(S))return u;if(r.skipServer&&/\bserver\b/.test(S))return u;let L=`<script${tm(S,n)}>`;if(/\bsrc\s*=/.test(S)||/\btype\s*=\s*["']application\/json["']/.test(S))return L+I+u.slice(v);return L+Xi(I,n)+u.slice(v)});return Dr(i,l)}function*jo(e,n,r,i){let a=e,l=(W,Z)=>{let q=Tn(W,Z);if(q===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(W.slice(Z,q))?-1:q},u=(W,Z,q,X)=>{let U=q.length,{output:H,tokens:re}=ke(W,Z,(ce,le)=>X(U+le));return q.push(...re),H},f=[];a=u(a,l,f,(W)=>`<!--__STX_STYLE_${W}__-->`);let v=[];a=u(a,Q,v,(W)=>`<!--__STX_SCRIPT_EXPR_${W}__-->`);let S=n?.__stx_signals_gate===!0||Me(e),I=new Set([...Array.isArray(n?.__stx_client_signal_names)?n.__stx_client_signal_names:[],...qi(Oo(v))]),j=new Set(Array.isArray(n?.__stx_preserved_client_expressions)?n.__stx_preserved_client_expressions:[]);a=Nn(a,(W,Z,q)=>{if(F(Z,I))return W;try{let X=N(Z,n,!1,(U)=>lr(U,W,r,e));return X!==void 0&&X!==null?String(X):""}catch(X){let U=X instanceof Error?X.message:String(X);return b("Expression",`Error evaluating: {{{ ${Z.trim()}}}}: ${U}`,r,e,q,W)}},3),a=a.replace(/\{!!([\s\S]*?)!!\}/g,(W,Z,q)=>{if(F(Z,I))return W;try{let X=N(Z,n,!1,(U)=>lr(U,W,r,e));if(X===void 0&&n.__stx_buildMode==="compile")return xs("raw",Z.trim());return X!==void 0&&X!==null?String(X):""}catch(X){if(n.__stx_buildMode==="compile")return xs("raw",Z.trim());let U=X instanceof Error?X.message:String(X);return b("Expression",`Error evaluating: {!! ${Z.trim()} !!}: ${U}`,r,e,q,W)}}),a=u(a,Q,v,(W)=>`<!--__STX_SCRIPT_EXPR_${W}__-->`),a=u(a,l,f,(W)=>`<!--__STX_STYLE_${W}__-->`);let L=S?em(a):[],M=vs(a).map((W)=>({...W,names:new Set(oe(`${W.binding} in __slot`))})),V=new Set(mt(n));if(a=yield*Io(a,(W,Z,q)=>{let X=Z.trim();if(ol(a,q,Z))return W;if(Eo(M,q,X))return W;if(F(X,V))return W;if(L.length>0&&Eo(L,q,X))return W;if(j.has(X))return W;let U=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,ce=X.match(H)?.[1],le=ce&&((ce in n)||U.includes(ce)),pe=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,Re=X.match(pe),Ae=Re&&!U.includes(Re[1])&&!(Re[1]in n);if(/^__[A-Z_]+__$/.test(X))return"";if(F(X,I))return W;if(n.__stx_native_screen===!0&&Ll(X,n))return W;let we;try{let fe=N(Z,n,!1,(Fe)=>{we=Fe});if(S&&!ko(X,n))return W;if(we)lr(we,W,r,e);if(n.__stx_buildMode==="compile"&&!S&&(fe===void 0||zl(X,n)))return xs("expr",X);if(fe===void 0||fe===null)return"";let We=String(fe);return ae(a,q,We,!1,W.length)}catch(fe){if(fe instanceof he)throw fe;if(S&&!ko(X,n))return W;if(Ae)return W;let We=fe instanceof Error?fe.message:String(fe);return b("Expression",`Error evaluating: {{ ${X} }}: ${We}`,r,e,q,W)}},2,i),v.length>0)a=a.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(W,Z)=>v[Number(Z)]??W);if(f.length>0)a=a.replace(/<!--__STX_STYLE_(\d+)__-->/g,(W,Z)=>f[Number(Z)]??W);return a}function P(e,n,r){return To(jo(e,n,r,Number.POSITIVE_INFINITY))}var Fl=100;async function Gi(e,n,r,i=Fl){let a=jo(e,n,r,i),l=a.next();while(!l.done)await R(),l=a.next();return l.value}function nm(e,n,r){if(!n.trim())return e;let i=e,a=n.trim();while(a.length>0){let l=a.match(/^(\w+)/);if(!l)break;let u=l[1];a=a.substring(u.length).trim();let f=Bn[u]||fo[u];if(!f)throw Error(`Filter not found: ${u}. Available filters: ${Object.keys(Qg()).join(", ")}`);let v=[];if(a.startsWith(":")){let S=a.match(/^:([^|\s]+)/);if(S){let I=S[1].trim();try{let j=Number(I);v=[Number.isNaN(j)?I:j]}catch{v=[I]}a=a.substring(S[0].length).trim()}}else if(a.startsWith("(")){let S=1,I=1;while(S>0&&I<a.length){if(a[I]==="(")S++;if(a[I]===")")S--;I++}if(S===0){let j=a.substring(1,I-1).trim();if(j)try{if(j.startsWith("{")&&j.endsWith("}"))v=[N(`(${j})`,r,!0)];else{let L=[],M="",V=null,W=0,Z=0,q=0,X=!1;for(let U=0;U<j.length;U++){let H=j[U];if(X){M+=H,X=!1;continue}if(H==="\\"){M+=H,X=!0;continue}if(V){if(M+=H,H===V)V=null;continue}if(H==='"'||H==="'"||H==="`"){V=H,M+=H;continue}if(H==="(")W++;else if(H===")")W--;else if(H==="[")Z++;else if(H==="]")Z--;else if(H==="{")q++;else if(H==="}")q--;if(H===","&&W===0&&Z===0&&q===0){L.push(M),M="";continue}M+=H}if(M)L.push(M);v=L.map((U)=>{let H=U.trim();return N(H,r,!0)})}}catch{v=[j]}a=a.substring(I).trim()}}try{i=f(i,r,...v)}catch(S){let I=S instanceof Error?S.message:String(S);throw Error(`Error applying filter '${u}': ${I}`)}if(a.startsWith("|"))a=a.substring(1).trim();else break}return i}function Vl(e){let n=!1,r="",i=0,a=0,l=0,u=!1;for(let f=0;f<e.length;f++){let v=e[f],S=e[f+1];if(n&&u){u=!1;continue}if(n&&v==="\\"){u=!0;continue}if(u=!1,(v==='"'||v==="'"||v==="`")&&!u){if(!n)n=!0,r=v;else if(v===r)n=!1,r="";continue}if(n&&r==="`"&&v==="$"&&S==="{"){let I=1;f+=2;while(f<e.length&&I>0){if(e[f]==="{")I++;else if(e[f]==="}")I--;if(I>0)f++}continue}if(n)continue;if(v==="(")i++;else if(v===")")i--;else if(v==="[")a++;else if(v==="]")a--;else if(v==="{")l++;else if(v==="}")l--;if(v==="|"&&i===0&&a===0&&l===0){if(S==="|"){f++;continue}if(S==="="){f++;continue}return f}}return-1}var zn=new Set,Ul=1000;function jy(){zn.clear()}function lr(e,n,r,i){if(!ne())return;let a=`${r}\x00${e.expression}`;if(zn.has(a))return;if(zn.size>=Ul)zn.clear();zn.add(a);let l=r,u=i;try{if(r&&So.existsSync(r))u=So.readFileSync(r,"utf8")}catch{}let f=u.indexOf(n);if(f>=0)l=`${r}:${u.slice(0,f).split(`
218
- `).length}`;console.warn(`${l}: stx warning: ${n} rendered as an empty string. The safe evaluator rejected \`${e.expression}\` (${e.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function N(e,n,r=!1,i){try{let a=e.trim(),l=Vl(a);if(l>0){let f=a.substring(0,l).trim(),v=a.substring(l+1).trim(),S=N(f,n,!0,i);return nm(S,v,n)}let u=mo(a);if(u!==null){i?.({expression:a,rule:u});return}try{let f=Object.keys(n),v=Object.values(n);return p(a,f)(...v)}catch{return d(a,n)}}catch(a){if(a instanceof ReferenceError){let l=/(\b\w+)\s+is not defined/.exec(a.message);if(l){let u=l[1],f=Kl(u,Object.keys(n));if(f&&f!==u)a.message=`${a.message} \u2014 did you mean '${f}'?`}}if(!r)console.error(`Error evaluating expression: ${e}`,a);throw a}}function Kl(e,n){let r=null;for(let a of n){if(a===e)continue;let l=Zl(e,a);if(r===null||l<r.dist)r={key:a,dist:l}}if(!r)return null;let i=Math.max(e.length,r.key.length);if(r.dist<=2||r.dist/i<=0.35)return r.key;return null}function Zl(e,n){if(e===n)return 0;if(e.length===0)return n.length;if(n.length===0)return e.length;let[r,i]=e.length<n.length?[e,n]:[n,e],a=Array(r.length+1),l=Array(r.length+1);for(let u=0;u<=r.length;u++)a[u]=u;for(let u=1;u<=i.length;u++){l[0]=u;for(let f=1;f<=r.length;f++){let v=r[f-1]===i[u-1]?0:1;l[f]=Math.min(l[f-1]+1,a[f]+1,a[f-1]+v)}for(let f=0;f<=r.length;f++)a[f]=l[f]}return a[r.length]}function By(e){if(!e)return"";return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}import Jl from"process";function A(e="STX_PUBLIC_"){let n={},r={};for(let[i,a]of Object.entries(Jl.env)){if(!i.startsWith(e)||a===void 0)continue;n[`import.meta.env.${i}`]=JSON.stringify(a),r[i]=a}return n["import.meta.env"]=JSON.stringify(r),n}function Po(e,n=""){let r=`${e}${n}`,i=0;for(let a=0;a<r.length;a++){let l=r.charCodeAt(a);i=(i<<5)-i+l,i=i&i}return`stx-${Math.abs(i).toString(36)}`}function Mo(e,n,r={}){let{prefix:i="",preserveHost:a=!0,scopeKeyframes:l=!0,scopeCustomProperties:u=!1}=r;if(!e.trim())return"";let f=ur(e),v=[],S=new Map;if(l)for(let I of f){let j=I.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(j){let L=j[1],M=`${n}_${L}`;S.set(L,M)}}for(let I of f){let j=Do(I,n,i,a,S,u);v.push(j)}return v.join(`
219
-
220
- `)}function ur(e){let n=[],r=e.replace(/\/\*[\s\S]*?\*\//g,""),i=0,a="",l=!1,u="";for(let f=0;f<r.length;f++){let v=r[f];if(v==="@"&&i===0)l=!0;if(v==="{")i++;else if(v==="}"){if(i--,i===0){if(l){u+=v;let S=u.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(S){let[,I,j,L]=S;if(I==="keyframes")n.push({selector:`@keyframes ${j.trim()}`,declarations:L.trim()});else if(I==="media"||I==="supports"||I==="container"){let M=ur(L);n.push({selector:`@${I} ${j.trim()}`,declarations:M.map((V)=>`${V.selector} { ${V.declarations} }`).join(`
221
- `)})}else n.push({selector:`@${I} ${j.trim()}`,declarations:L.trim()})}u="",l=!1}else if(a.trim()){a+=v;let S=a.match(/([^{]+)\{([^}]*)\}/);if(S)n.push({selector:S[1].trim(),declarations:S[2].trim()});a=""}continue}}if(l)u+=v;else a+=v}return n}function Do(e,n,r,i,a,l){let{selector:u,declarations:f}=e;if(u.startsWith("@")){if(u.startsWith("@keyframes")){let I=u.replace("@keyframes ","").trim();return`@keyframes ${a.get(I)||I} { ${f} }`}if(u.startsWith("@media")||u.startsWith("@supports")||u.startsWith("@container")){let j=ur(`x { ${f} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((L)=>Do(L,n,r,i,a,l)).join(`
222
- `);return`${u} {
223
- ${j}
224
- }`}return`${u} { ${f} }`}let v=Xl(u,n,r,i),S=f;for(let[I,j]of a)S=S.replace(new RegExp(`\\b${I}\\b`,"g"),j);if(l)S=S.replace(/--([a-z-]+)/gi,`--${n}-$1`);return`${v} { ${S} }`}function Xl(e,n,r,i){let a=e.split(",").map((u)=>u.trim()),l=[];for(let u of a){if(u.startsWith(":host")){if(i)l.push(u);else{let S=u.replace(/:host(\([^)]*\))?/,`.${n}$1`);l.push(S)}continue}if(u.includes("::slotted")){l.push(u);continue}if(u===":root"){l.push(`:root .${n}`);continue}let f=r?`${r} .${n}`:`.${n}`;l.push(`${f} ${u}`);let v=Gl(u,n);if(v)l.push(r?`${r} ${v}`:v)}return l.join(", ")}function Gl(e,n){let r=0,i=e.length;for(let v=0;v<e.length;v++){let S=e[v];if(S==="["||S==="(")r++;else if(S==="]"||S===")")r--;else if(r===0&&(S===" "||S===">"||S==="+"||S==="~")){i=v;break}}let a=e.slice(0,i),l=e.slice(i);if(!a)return"";let u=a.length,f=0;for(let v=0;v<a.length;v++){let S=a[v];if(S==="["||S==="(")f++;else if(S==="]"||S===")")f--;else if(r===0&&f===0&&S===":"){u=v;break}}return`${a.slice(0,u)}.${n}${a.slice(u)}${l}`}var zo=String.raw`(?<![\w-])scoped(?![\w-])`,pr=/<style\s+([^>]*)>/gi,No=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,Bo=new RegExp(zo,"i"),Yl=new RegExp(zo,"gi"),fr=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function Ql(e){pr.lastIndex=0;let n=pr.exec(e);while(n!==null){if(Bo.test(n[1]))return!0;n=pr.exec(e)}return!1}function zi(e){let n=new Set,r=[];fr.lastIndex=0;let i=fr.exec(e);while(i!==null){let a=i[0].trim();if(n.has(a))r.push({start:i.index,end:i.index+i[0].length});else n.add(a);i=fr.exec(e)}return r}function Rn(e){let n=zi(e);if(n.length===0)return e;let r=Array(n.length+1),i=0;for(let a=0;a<n.length;a++){let l=n[a];r[a]=e.slice(i,l.start),i=l.end}return r[n.length]=e.slice(i),r.join("")}function ao(e,n){if(!Ql(e))return{html:e,hasScoped:!1};let r=Po(n),i=`data-v-${r}`,a=e,l=!1;if(No.lastIndex=0,a=a.replace(No,(u,f,v)=>{if(!Bo.test(f))return u;l=!0;let S=eu(v,i),I=f.replace(Yl,"").trim(),j=I?` ${I}`:"";return`<style data-stx-scoped="${r}"${j}>${S}</style>`}),!l)return{html:e,hasScoped:!1};return a=nu(a,i),{html:a,hasScoped:!0}}function eu(e,n){return Mo(e,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${n}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${n}]`)}var tu=(e)=>`\x00stx-scope-mask-${e}\x00`,Lo=/\u0000stx-scope-mask-(\d+)\u0000/g;function nu(e,n){let r=ke(e,(a,l)=>{let u=Q(a,l);return u>l?u:Tn(a,l)},(a,l)=>tu(l)),i=su(r.output,n);return Lo.lastIndex=0,i.replace(Lo,(a,l)=>r.tokens[Number(l)])}function su(e,n){let r=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return e.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(i,a,l)=>{if(r.has(a.toLowerCase()))return i;if(i.includes(n))return i;if(a.toLowerCase()==="style"||a.toLowerCase()==="script")return i;if(l)return i.replace(`<${a}${l}`,`<${a} ${n}${l}`);if(i.endsWith("/>"))return`<${a} ${n} />`;return`<${a} ${n}>`})}var Wn=/<\/?template\b[^>]*>/gi,ru=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function iu(e){let n=e.replace(/^<template\b/i,"").replace(/>$/,"");return ru.test(n)}function B(e){Wn.lastIndex=0;let n;while((n=Wn.exec(e))!==null){if(n[0].startsWith("</")||iu(n[0]))continue;let r=n.index,i=Wn.lastIndex,a=1,l;while((l=Wn.exec(e))!==null)if(l[0].startsWith("</")){if(a--,a===0){let u=l.index;return{start:r,openEnd:i,closeStart:u,end:Wn.lastIndex,content:e.slice(i,u)}}}else a++;return null}return null}var ou=0,au=0;function Ss(e,n){let r=/(?:^|\s)([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;for(let i of e.matchAll(r))if(i[1].toLowerCase()===n.toLowerCase())return i[2]??i[3]??i[4]??null;return null}function Fo(e){let n=[],r=/<([a-z][a-z0-9-]*)\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/iy;return x(e,(i,a)=>{r.lastIndex=a;let l=r.exec(i);if(!l||!Ss(l[2],"x-data"))return-1;return n.push({fullMatch:l[0],tagName:l[1],attributes:l[2],startIndex:a,endIndex:r.lastIndex}),r.lastIndex}),n}function cu(e){let n=[];for(let{fullMatch:r,tagName:i,attributes:a,startIndex:l}of Fo(e)){let u=Ss(a,"x-data");if(!u)continue;let f=`__stx_scope_${ou++}`,v=Ss(a,"x-init"),S=lu(e,i,l+r.length),I=e.slice(l,S.endIndex),j=uu(I);n.push({id:f,selector:`[data-stx-scope="${f}"]`,stateExpr:u,initExpr:v,bindings:[],refs:j})}return n}function lu(e,n,r){let i=1,a=r,l=new RegExp(`<${n}(?:\\s|>)`,"gi"),u=new RegExp(`</${n}>`,"gi"),f=new RegExp(`<${n}[^>]*/\\s*>`,"gi");while(i>0&&a<e.length){l.lastIndex=a,u.lastIndex=a,f.lastIndex=a;let v=l.exec(e),S=u.exec(e),I=f.exec(e);if(I&&I.index<(v?.index??1/0)){a=I.index+I[0].length;continue}if(!S)return{endIndex:e.length};if(v&&v.index<S.index)i++,a=v.index+v[0].length;else{if(i--,i===0)return{endIndex:S.index+S[0].length};a=S.index+S[0].length}}return{endIndex:e.length}}function uu(e){let n=new Map,r=e.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),i=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,a;while((a=i.exec(r))!==null){let[,l,u]=a,f=pu(l);n.set(u,f)}return n}function pu(e){let n=e.match(/\bid\s*=\s*["']([^"']*)["']/);if(n)return n[1];return`__stx_el_${au++}`}function fu(){return`
225
- // STX Reactive Runtime - x-cloak and transition CSS
226
- (function() {
227
- var style = document.createElement('style');
228
- style.textContent = [
229
- '[x-cloak] { display: none !important; }',
230
- // Default transition classes
231
- '.stx-enter { opacity: 0; transform: scale(0.95); }',
232
- '.stx-enter-start { opacity: 0; transform: scale(0.95); }',
233
- '.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
234
- '.stx-enter-to { opacity: 1; transform: scale(1); }',
235
- '.stx-leave { opacity: 1; transform: scale(1); }',
236
- '.stx-leave-start { opacity: 1; transform: scale(1); }',
237
- '.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
238
- '.stx-leave-to { opacity: 0; transform: scale(0.95); }'
239
- ].join('\\n');
240
- document.head.appendChild(style);
241
- })();
242
-
243
- // STX Reactive Runtime
244
- /* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
245
- window.__stx_reactive = (function() {
246
- 'use strict';
247
-
248
- // Deep reactive proxy that triggers onChange for any mutation
249
- function reactive(obj, onChange) {
250
- if (!obj || typeof obj !== 'object') return obj;
251
- return new Proxy(obj, {
252
- get(target, prop) {
253
- const value = target[prop];
254
- if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
255
- return reactive(value, onChange);
256
- }
257
- return value;
258
- },
259
- set(target, prop, value) {
260
- target[prop] = value;
261
- onChange(prop, value);
262
- return true;
263
- }
264
- });
265
- }
266
-
267
- // Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
268
- // then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
269
- function initScope(scopeEl, initialState, bindings, refs, initExpr, deferInit) {
270
- // Parse initial state (may contain methods including async init())
271
- var state;
272
- try {
273
- state = new Function('return (' + initialState + ')')();
274
- } catch (e) {
275
- console.error('[stx-reactive] Invalid x-data:', initialState, e);
276
- return;
277
- }
278
-
279
- // Build $refs object
280
- var $refs = {};
281
- for (var name in refs) {
282
- if (Object.prototype.hasOwnProperty.call(refs, name)) {
283
- (function(refName, refId) {
284
- Object.defineProperty($refs, refName, {
285
- get: function() { return document.getElementById(refId); }
286
- });
287
- })(name, refs[name]);
288
- }
289
- }
290
-
291
- // Extract init method from state if present (Alpine.js convention)
292
- var initMethod = state.init;
293
- if (typeof initMethod === 'function') {
294
- delete state.init;
295
- }
296
-
297
- // Make state reactive \u2014 mutations trigger re-render via signals
298
- var scopeId = scopeEl.getAttribute('data-stx-scope');
299
- var stx = window.stx;
300
-
301
- // Create signals for each state property so the signals runtime can track dependencies
302
- var signalState = {};
303
- var rawState = {};
304
- var derivedState = {};
305
- var accessors = {};
306
- // A getter must NOT be read here. Reading one calls it, and the old loop did
307
- // exactly that: the returned value is not a function, so it was wrapped as a
308
- // plain state() -- a snapshot of the answer at construction time, frozen
309
- // forever while plain properties beside it updated (#2053). A getter is a
310
- // derived value, so it is registered as one below, once ctxProxy exists for
311
- // it to read through.
312
- var ownDescriptors = Object.getOwnPropertyDescriptors ? Object.getOwnPropertyDescriptors(state) : {};
313
- for (var key in state) {
314
- if (Object.prototype.hasOwnProperty.call(state, key)) {
315
- var descriptor = ownDescriptors[key];
316
- if (descriptor && typeof descriptor.get === 'function') {
317
- accessors[key] = descriptor;
318
- continue;
319
- }
320
- if (typeof state[key] === 'function') {
321
- // Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
322
- signalState[key] = state[key];
323
- } else {
324
- // Data properties \u2014 wrap in signals for reactivity
325
- signalState[key] = stx.state(state[key]);
326
- rawState[key] = true;
327
- }
328
- }
329
- }
330
-
331
- // Create a proxy context that auto-unwraps signals and writes back through them.
332
- // Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
333
- var ctx = {};
334
- var ctxProxy = new Proxy(ctx, {
335
- get: function(target, prop) {
336
- if (prop === '$refs') return $refs;
337
- if (prop === '$el') return scopeEl;
338
- if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
339
- if (prop === Symbol.unscopables) return undefined;
340
- if (!(prop in signalState)) {
341
- var owner = stx._scopeForBinding(scopeEl, prop);
342
- return owner ? owner[prop] : undefined;
343
- }
344
- var s = signalState[prop];
345
- if (!s) return undefined;
346
- if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
347
- return s.value; // unwrap signal
348
- }
349
- if (typeof s === 'function' && !rawState[prop]) {
350
- return s.bind(ctxProxy); // bind methods to proxy
351
- }
352
- return s;
353
- },
354
- set: function(target, prop, value) {
355
- var accessor = derivedState[prop];
356
- if (accessor) {
357
- // A getter/setter pair writes through its setter. A getter alone has
358
- // nowhere to put the value: a derived has no .value setter, so the
359
- // assignment would be a silent no-op, which is the same class of
360
- // failure as the stale read this replaces.
361
- if (typeof accessor.set === 'function') {
362
- accessor.set.call(ctxProxy, value);
363
- return true;
364
- }
365
- console.warn('[stx-reactive] cannot assign to ' + String(prop) + ': it is a getter in x-data, so its value comes from what it reads. Give it a setter, or make it a plain property.');
366
- return true;
367
- }
368
- var s = signalState[prop];
369
- if (rawState[prop] && s && typeof s === 'function') {
370
- s.value = value; // write through signal \u2014 triggers effects
371
- } else {
372
- signalState[prop] = value;
373
- }
374
- return true;
375
- },
376
- has: function(target, prop) {
377
- return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick' || !!stx._scopeForBinding(scopeEl, prop);
378
- },
379
- ownKeys: function() {
380
- return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
381
- },
382
- getOwnPropertyDescriptor: function(target, prop) {
383
- if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
384
- return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
385
- }
386
- return undefined;
387
- }
388
- });
389
-
390
- // Now that ctxProxy exists, a getter becomes a derived that reads through it,
391
- // so it tracks whatever it touches and recomputes when that changes. derived()
392
- // is lazy, so nothing is evaluated until a binding actually reads it.
393
- //
394
- // Marked rawState as well: that is what makes the proxy unwrap it and what
395
- // exposes the signal itself to the runtime below, which is where dependency
396
- // tracking comes from. A getter needs both, exactly like a data property.
397
- for (var accessorKey in accessors) {
398
- if (Object.prototype.hasOwnProperty.call(accessors, accessorKey)) {
399
- (function(name, descriptor) {
400
- signalState[name] = stx.derived(function() {
401
- return descriptor.get.call(ctxProxy);
402
- });
403
- rawState[name] = true;
404
- derivedState[name] = descriptor;
405
- })(accessorKey, accessors[accessorKey]);
406
- }
407
- }
408
-
409
- // Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
410
- // We need to provide getter/setter descriptors so signals track properly.
411
- var scopeVars = {};
412
- for (var k in signalState) {
413
- if (Object.prototype.hasOwnProperty.call(signalState, k)) {
414
- if (rawState[k]) {
415
- // Data: expose the signal directly so expressions trigger dependency tracking
416
- scopeVars[k] = signalState[k];
417
- } else {
418
- // Method: bind to ctxProxy so 'this' works
419
- scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
420
- }
421
- }
422
- }
423
- scopeVars.$refs = $refs;
424
- scopeVars.$el = scopeEl;
425
- scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
426
-
427
- // Register scope \u2014 merge with any existing vars from partial signal scripts
428
- if (!stx._scopes) stx._scopes = {};
429
- var registered = stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
430
- registered.__el = scopeEl;
431
-
432
- // Store on element for findElementScope
433
- scopeEl.__stx_scope = scopeVars;
434
-
435
- // Run init() if present (supports async)
436
- function runInit() {
437
- var maybePromise;
438
- if (initMethod) {
439
- maybePromise = initMethod.call(ctxProxy);
440
- }
441
- if (initExpr) {
442
- try {
443
- var fn = new Function('with(this){' + initExpr + ';}');
444
- var result = fn.call(ctxProxy);
445
- if (result && typeof result.then === 'function') maybePromise = result;
446
- } catch (e) {
447
- console.warn('[stx-reactive] init expression error:', e);
448
- }
449
- }
450
- // If init is async, signal updates will trigger effects automatically
451
- // when init() resolves and sets this.prop = value (writes through signal)
452
- if (maybePromise && typeof maybePromise.then === 'function') {
453
- maybePromise.catch(function(e) {
454
- console.error('[stx-reactive] async init() error:', e);
455
- });
456
- }
457
- }
458
-
459
- // A component's helper setup follows its markup. Its own mount queue
460
- // starts the initializer after all component factories have registered.
461
- // Standalone x-data retains synchronous initialization.
462
- if (deferInit) {
463
- registered.__mountCallbacks = registered.__mountCallbacks || [];
464
- registered.__mountCallbacks.push(runInit);
465
- } else {
466
- runInit();
467
- }
468
- var destroyExpr = scopeEl.getAttribute('data-stx-xdestroy') || scopeEl.getAttribute('x-destroy');
469
- if (destroyExpr) {
470
- registered.__destroyCallbacks = registered.__destroyCallbacks || [];
471
- var teardown = function() { scopeEl.__stx_execute(destroyExpr); };
472
- registered.__destroyCallbacks.push(teardown);
473
- registered.__destroyHooks = registered.__destroyHooks || [];
474
- registered.__destroyHooks.push(teardown);
475
- }
476
-
477
- // Expose for debugging
478
- scopeEl.__stx_state = ctxProxy;
479
- scopeEl.__stx_execute = function(stmt, $event, $el) {
480
- try {
481
- // Run the statement with the reactive proxy as the lexical scope.
482
- // Wrapping in a with-block on the proxy makes bare reads/writes go
483
- // through it (so foo = bar triggers signal.set()) instead of treating
484
- // each state key as a local function parameter \u2014 bare assignments
485
- // would otherwise just rebind the local and never reach the signal.
486
- var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
487
- fn.call(ctxProxy, $event, $el);
488
- } catch (e) {
489
- console.warn('[stx-reactive] execute error:', e);
490
- }
491
- };
492
- }
493
-
494
- return { initScope: initScope, reactive: reactive };
495
- })();
496
- `}function Wo(e,n){let r=e.replace(/\{!!([\s\S]*?)!!\}/g,(f,v)=>{try{let S=N(v,n,!0);if(S===void 0)return f;return String(S)}catch{return f}}),i="",a=0,l=null;while(a<r.length){let f=r[a];if(l&&f==="\\"){i+=f+(r[a+1]??""),a+=2;continue}if(f==="{"&&r[a+1]==="{"){let v=r.indexOf("}}",a+2);if(v!==-1){let S=r.slice(a,v+2);i+=u(r.slice(a+2,v),S,l),a=v+2;continue}}if(l){if(f===l)l=null}else if(f==="'"||f==='"'||f==="`")l=f;i+=f,a++}return i;function u(f,v,S){let I;try{I=N(f,n,!0)}catch{return v}if(I===void 0)return v;if(S){let j=String(I).replace(/\\/g,"\\\\").replace(new RegExp(S==="`"?"`":S,"g"),`\\${S}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return S==="`"?j.replace(/\$\{/g,"\\${"):j}if(typeof I==="string"){let j=I.trim();if(j.startsWith("{")&&j.endsWith("}")||j.startsWith("[")&&j.endsWith("]"))try{return JSON.parse(j),j}catch{}}return JSON.stringify(I)}}function du(e,n,r){if(e.length===0)return"";let i=e.map((a)=>{let l=JSON.stringify(Object.fromEntries(a.refs)),u=Wo(a.stateExpr,n),f=a.initExpr?Wo(a.initExpr,n):null,v=JSON.stringify(u),S=f?JSON.stringify(f):"null";return`
497
- (function() {
498
- var scopeEl = document.querySelector('${a.selector}');
499
- if (!scopeEl) return;
500
- var refs = ${l};
501
- window.__stx_reactive.initScope(scopeEl, ${v}, [], refs, ${S}${r?", true":""});
502
- })();`}).join(`
503
- `);return`
504
- <script data-stx-scoped data-stx-reactive data-stx-run="always">
505
- ${fu()}
506
- ${i}
507
- </script>`}function bl(e,n,r,i=!1){if(!dr(e))return e;let a=cu(e);if(a.length===0)return e;let l=gu(e,a),u=du(a,n,i),f=c(l);if(f!==-1)l=l.slice(0,f)+u+`
508
- `+l.slice(f);else l+=u;return l}function gu(e,n){let r=[],i=0;for(let[l,u]of Fo(e).entries()){let f=n[l];if(!f)break;r.push(e.slice(i,u.startIndex));let v=Ss(u.attributes,"data-stx-scope");if(v)f.id=v,f.selector=`[data-stx-scope="${f.id}"]`,r.push(u.fullMatch);else r.push(`<${u.tagName} data-stx-scope="${f.id}"${u.attributes}>`);i=u.endIndex}r.push(e.slice(i));let a=r.join("");return a=a.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),a=a.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),a=a.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),a=a.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),a=a.replace(/\s*x-destroy\s*=\s*"([^"]*)"/g,' data-stx-xdestroy="$1"'),a=a.replace(/\s*x-destroy\s*=\s*'([^']*)'/g," data-stx-xdestroy='$1'"),a}function dr(e){return/x-data\s*=\s*["']/.test(e)}function lo(e,n){let r=e,i=/@json\s*\(/g,a;while((a=i.exec(r))!==null){let l=a.index,u=l+a[0].length-1,f=1,v=u+1,S=null,I=!1;while(v<r.length&&f>0){let U=r[v];if(I){I=!1,v++;continue}if(U==="\\"&&S){I=!0,v++;continue}if(S){if(U===S)S=null;v++;continue}if(U==='"'||U==="'"||U==="`"){S=U,v++;continue}if(U==="(")f++;else if(U===")"){if(f--,f===0)break}v++}if(f!==0)break;let j=r.substring(u+1,v).trim(),L=r.substring(l,v+1),M=-1,V=0,W=null,Z=!1;for(let U=0;U<j.length;U++){let H=j[U];if(Z){Z=!1;continue}if(H==="\\"&&W){Z=!0;continue}if(W){if(H===W)W=null;continue}if(H==='"'||H==="'"||H==="`"){W=H;continue}if(H==="("||H==="["||H==="{")V++;else if(H===")"||H==="]"||H==="}")V--;if(H===","&&V===0){M=U;break}}let q=M>=0?j.substring(0,M).trim():j,X=M>=0?j.substring(M+1).trim():void 0;try{let U=q.trim(),H;if(m(U))H=p(U,Object.keys(n))(...Object.values(n));else H=void 0;let re;if(X==="true")re=JSON.stringify(H,null,2);else re=JSON.stringify(H);let ce=re.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");r=r.substring(0,l)+ce+r.substring(v+1),i.lastIndex=l+ce.length}catch(U){K.log(U instanceof Error?U:Error(String(U)),{directive:"@json"},"error"),i.lastIndex=l+L.length}}return r}function uo(e){return e.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function wl(e){let n=e,r=/@memo\s*\(/g,i,a=[];while((i=r.exec(n))!==null){let l=i.index,u=l+i[0].length,f=1,v=u;while(v<n.length&&f>0){if(n[v]==="(")f++;else if(n[v]===")")f--;v++}if(f!==0)continue;let S=n.slice(u,v-1).trim(),I=v,j=n.slice(I),L=j.indexOf("@endmemo");if(L===-1)continue;let M=j.slice(0,L),V=I+L+8,W=Vt(M),Z=M.slice(W),q=M.match(/(\s*)$/),X=q?q[0].length:0,U=Z.slice(0,Z.length-X),H=U.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),re;if(H){let[ce,le,pe="",Re]=H,Ae=`<${le}${pe} data-stx-memo="${S}"${Re}>`;re=M.slice(0,W)+Ae+U.slice(ce.length)+M.slice(W+U.length)}else re=`${M.slice(0,W)}<div data-stx-memo="${S}">${U}</div>${M.slice(W+U.length)}`;a.push({start:l,end:V,replacement:re}),r.lastIndex=V}for(let l=a.length-1;l>=0;l--){let u=a[l];n=n.slice(0,u.start)+u.replacement+n.slice(u.end)}return n.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function Hi(e){let n=e.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return n=n.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),n}function Ko(e,n){let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=x(e,(f,v)=>{r.lastIndex=v;let S=r.exec(f);if(!S||/^(?:script|style)$/i.test(S[1]))return-1;return r.lastIndex}),a=[],l=0,u=[];for(let{start:f,end:v,token:S}of i){let I=/^<\/?([\w-]+)/.exec(S)[1].toLowerCase();if(S.startsWith("</")){while(a.length&&a.pop()!==I);continue}if(!a.length&&!/\sdata-stx-slot-owner\s*=/.test(S))u.push(e.slice(l,f),S.replace(/\s*\/?>$/,(j)=>` data-stx-slot-owner="${n}"${j}`)),l=v;if(!gr.has(I)&&!/\/>$/.test(S))a.push(I)}return u.push(e.slice(l)),u.join("")}function qo(e,n){if(!/\bref\s*=/.test(e))return e;let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=x(e,(v,S)=>{r.lastIndex=S;let I=r.exec(v);if(!I||/^(?:script|style)$/i.test(I[1]))return-1;return r.lastIndex}),a=[],l=0,u=0,f=[];for(let{start:v,end:S,token:I}of i){let j=/^<\/?([\w-]+)/.exec(I)[1].toLowerCase();if(I.startsWith("</")){let W;while(W=a.pop()){if(W.scoped)l--;if(W.name===j)break}continue}let L=/\sdata-stx-scope\s*=/.test(I),M=/\sdata-stx-ref-caller\s*=\s*(["'])(.*?)\1/.exec(I),V=a.find((W)=>W.scoped)?.scopeId;if(M&&V&&M[2]===V)f.push(e.slice(u,v),I.replace(M[0],` data-stx-ref-caller="${n}"`)),u=S;else if(!l&&!L&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(I)&&!/\sdata-stx-ref-caller\s*=/.test(I))f.push(e.slice(u,v),I.replace(/\s*\/?>$/,(W)=>` data-stx-ref-caller="${n}"${W}`)),u=S;if(!gr.has(j)&&!/\/>$/.test(I)){let W=/\sdata-stx-scope\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(I);if(a.push({name:j,scoped:L,scopeId:W?.[1]??W?.[2]}),L)l++}}return f.push(e.slice(u)),f.join("")}var gr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Zo=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,Vo=/<\/?\s*([a-z][\w-]*)/iy,mu=/\s/;function hu(e,n){let r=n-1;while(r>=0&&mu.test(e[r]))r--;return r>=0&&e[r]==="/"}function xu(e,n){let r=!1,i=!1;for(let a=n;a<e.length;a++){let l=e[a];if(r){if(l==="'")r=!1}else if(i){if(l==='"')i=!1}else if(l==="'")r=!0;else if(l==='"')i=!0;else if(l===">")return a}return-1}function bu(e,n){if(e.indexOf("{",n)===-1||e.indexOf("}",n)===-1)return!1;let r=0,i=n,a=!1,l=!1,u=!1;while(i<e.length){let f=e.indexOf("<",i),v=f===-1?e.length:f;if(v>i){if(r===0)while(i<v){let j=e.indexOf(l?"}":"{",i);if(j===-1||j>=v){if(l)u=!1;else a=!1;break}if(j>i)if(l)u=!1;else a=!1;if(l){if(u)return!0;u=!0}else if(a)l=!0,u=!1;else a=!0;i=j+1}i=v;continue}if(e.startsWith("<!--",i)){let j=e.indexOf("-->",i);i=j===-1?e.length:j+3;continue}let S=xu(e,i);if(S===-1)break;Vo.lastIndex=i;let I=Vo.exec(e)?.[1]?.toLowerCase()??"";if(e[i+1]==="/"){if(r===0)break;r--}else if(!hu(e,S)&&!gr.has(I))r++;i=S+1}return!1}var Uo=k(256);function vl(e){if(e.length<1024)return Ho(e);let n=E(e),r=Uo.get(n);if(r!==void 0)return r;let i=Ho(e);return Uo.set(n,i),i}function Ho(e){if(e.length>=32768&&!Ci(e))return e;let r=new RegExp(`<(${"div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i"})\\b`,"gi"),i="",a=0,l;while((l=r.exec(e))!==null){let u=l.index,f=u+l[0].length,v=!1,S=!1,I=-1;while(f<e.length){let L=e[f];if(v){if(L==="'")v=!1}else if(S){if(L==='"')S=!1}else if(L==="'")v=!0;else if(L==='"')S=!0;else if(L===">"){I=f;break}f++}if(I===-1)continue;let j=e.slice(u,I+1);if(Zo.test(j))continue;if(j.includes("x-cloak"))continue;if(bu(e,I+1))i+=e.slice(a,I)+" x-cloak>",a=I+1}return i+=e.slice(a),i}var yu=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,_u=/<\/script>/gi,wu=/<\/style>/gi;function xl(e){let n=/<[a-z][\w-]*/gi,r="",i=0,a;while((a=n.exec(e))!==null){let l=a.index,u=a[0].slice(1).toLowerCase();if(u==="script"||u==="style"){let V=u==="script"?_u:wu;V.lastIndex=l;let W=V.exec(e);if(W!==null)n.lastIndex=W.index+W[0].length;continue}let f=l+a[0].length,v=!1,S=!1,I=-1;while(f<e.length){let V=e[f];if(v){if(V==="'")v=!1}else if(S){if(V==='"')S=!1}else if(V==="'")v=!0;else if(V==='"')S=!0;else if(V===">"){I=f;break}f++}if(I===-1)continue;let j=e.slice(l+a[0].length,I);if(Zo.test(j))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(j))continue;if(!yu.test(j))continue;let L=e[I-1]==="/",M=L?I-1:I;r+=`${e.slice(i,M)} x-cloak${L?" ":""}`,i=M}return r+=e.slice(i),r}function O(e){let n=new Map;for(let r of e.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))n.set(r[1].toLowerCase(),r[2]??r[3]??r[4]??!0);return n}function kt(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}import wa from"path";import mr from"fs";import Vn from"path";function Jo(e,n,r,i){let a=0;for(let l=n;l<e.length;l++)if(e[l]===r)a++;else if(e[l]===i&&!(i===">"&&e[l-1]==="=")){if(--a===0)return l}return-1}function vu(e){let n=t(e),r=0,i=0,a=[];for(let l=0;l<n.length;l++)if("([{".includes(n[l]))r++;else if(")]}".includes(n[l]))r--;else if(n[l]===","&&r===0)a.push(e.slice(i,l).trim()),i=l+1;return a.push(e.slice(i).trim()),a}function Fn(e,n,r=!1){let i=t(e),a=new RegExp(`\\b(?:${n.map((u)=>u.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),l=r?h(i).depths:void 0;for(let u of i.matchAll(a)){if(l&&l[u.index]!==0)continue;let f=u.index+u[0].length,v="";if(i[f]==="<"){let I=Jo(i,f,"<",">");if(I<0)continue;v=e.slice(f+1,I),f=I+1;while(/\s/.test(i[f]||"")&&f<i.length)f++}if(i[f]!=="(")continue;let S=Jo(i,f,"(",")");if(S>=0)return{type:v,args:vu(e.slice(f+1,S)),start:u.index,end:S+1}}return null}var $s=`
509
- type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
510
- type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
511
- type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
512
- type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K : never }[keyof O];
513
- type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
514
- type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
515
- type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
516
- `;function Es(e,n){let r=[],i={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},a=t(e),l=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(L,M,V,W,Z)=>{if(a.slice(Z,Z+6)!=="import")return L;if(W.endsWith(".stx"))return"";let q=`${n}Import${r.length}`;if(r.push(`import * as ${q} from ${JSON.stringify(W)};`),M.startsWith("*"))return`import ${M.replace(/^\*\s+as\s+/,"")} = ${q};`;if(!M.startsWith("{"))return`import ${M} = ${q}.default;`;return M.slice(1,-1).split(",").map((X)=>{let[U,H=U]=X.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!U)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(W)&&U in i)i[U].push(H);return`import ${H} = ${q}.${U};`}).join(`
517
- `)}),u=Fn(e,i.defineProps),f=Fn(e,i.defineEmits),v=Fn(e,i.withDefaults);if(!u&&!f)return{declarations:"",props:null,events:null};let S=[],I=null,j=null;if(u){S.push(`const __options = (${u.args[0]||"{}"}) as const;`),S.push(`const __defaults = (${v?.args[1]||"{}"});`);let L=u.type||"__StxOptions<typeof __options>";S.push(`export type __StxProps = __StxDefaults<${L}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),I=`${n}.__StxProps`}if(f)S.push(`const __events = (${f.args[0]||"[]"}) as const;`),S.push(`export type __StxEvents = ${f.type||"Record<(typeof __events)[number], any[]>"};`),j=`${n}.__StxEvents`;return{declarations:`${r.join(`
518
- `)}
519
- namespace ${n} {
520
- ${l}
521
- ${S.join(`
522
- `)}
523
- }`,props:I,events:j}}var Br=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","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","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Fr(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Br].some((n)=>n.toLowerCase()===e.toLowerCase());return Br.has(e)||/[A-Z]/.test(e)}function*Su(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let i=n.lastIndex,a=[];while(i<e.length){while(/\s/.test(e[i]||""))i++;if(e[i]===">"||e.slice(i,i+2)==="/>"){i+=e[i]===">"?1:2;break}let l=/^[^\s=/>]+/.exec(e.slice(i))?.[0];if(!l){i++;continue}let u=i;i+=l.length;while(/\s/.test(e[i]||""))i++;if(e[i]!=="="){a.push({name:l,value:!0,offset:u,braced:!1});continue}i++;while(/\s/.test(e[i]||""))i++;let f=e[i],v=f==="{",S=f==='"'||f==="'";if(S||v)i++;let I=i;if(v){let j=t(e.slice(i)),L=1,M=0;for(;M<j.length;M++){if(j[M]==="{")L++;if(j[M]==="}"&&--L===0)break}i+=M}else if(S)while(i<e.length&&e[i]!==f)i++;else while(i<e.length&&!/[\s/>]/.test(e[i]))i++;if(a.push({name:l,value:e.slice(I,i),offset:I,braced:v}),S||v)i++}n.lastIndex=i,yield{name:r[1],offset:r.index,attributes:a}}}function Xo(e,n,r){let i=[],a=[$s,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],l=new Map,u=new Map,f=new Map,v=r.scriptCode(e,r.filePath),S=t(v);for(let V of v.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(S.slice(V.index,V.index+6)!=="import")continue;let W=V[2],Z=Vn.isAbsolute(W)||W.startsWith(".")?Vn.resolve(Vn.dirname(r.filePath),W):Zs(W,Vn.dirname(r.filePath));if(!Z)continue;let q=Z.endsWith(".stx")?Z:mr.existsSync(`${Z}.stx`)?`${Z}.stx`:void 0,X=q?null:Nr(Z,!1),U=V[1].startsWith("{")?V[1].slice(1,-1).split(","):[V[1]];for(let H of U){let[re,ce=re]=H.trim().split(/\s+as\s+/),le=q||X?.get(re)||X?.get(re.toLowerCase());if(le)f.set(ce,le),f.set(ce.toLowerCase(),le),f.set(ce.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),le)}}for(let V of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let W of V[1].matchAll(/['"]([^'"]+)['"]/g)){let Z=Qs(W[1],r.filePath,r).find((q)=>mr.statSync(q,{throwIfNoEntry:!1})?.isFile());if(Z)f.set(Vn.basename(W[1]).replace(/\.stx$/,""),Z)}let I={__importedComponents:f},j=new Map,L=(V,W,Z)=>{let q=e.slice(0,V);return{code:W,offset:V,attribute:Z,anchor:!0,kind:"directive",line:q.split(`
524
- `).length,column:V-q.lastIndexOf(`
525
- `)}},M=(V,W,Z)=>i.push({expression:V,statement:{text:W+V.code+Z,prefixLength:W.length}});for(let V of Su(n)){if(Fr(V.name)||V.name==="component")continue;let W=li(V.name,r.filePath,r,I);if(!W)continue;let Z=j.get(W);if(!Z){let X;try{X=r.readComponent?r.readComponent(W):mr.readFileSync(W,"utf8")}catch{continue}if(X===void 0)continue;u.set(W,X),Z=Es(r.scriptCode(X,W),`__StxComponent${j.size}`),j.set(W,Z),a.push(Z.declarations)}let q=[];for(let X of V.attributes){let{name:U,offset:H}=X,re=X.value===!0?"true":X.value;if(U.startsWith("@")||U.startsWith("v-on:")){if(Z.events&&X.value!==!0)l.set(H,`__StxEvent<${Z.events}, ${JSON.stringify(U.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let ce=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(U);if(U.startsWith("v-")&&!U.startsWith("v-bind:")&&!ce)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(U))continue;let le=(ce?ce[1]||"modelValue":U.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(we,fe)=>fe.toUpperCase());if(q.push(le),!Z.props)continue;let pe=U.startsWith(":")||U.startsWith("v-bind:")||!!ce||X.braced,Re=pe?re:X.value!==!0?JSON.stringify(re):"true",Ae=!pe&&X.value!==!0&&(re==="true"||re==="false");M(L(H,Re,U),";void ((",`) satisfies ${Ae?"__StxStaticProp":"__StxProp"}<${Z.props}, ${JSON.stringify(le)}>);`)}if(Z.props){let X=[...new Set(q)].map((H)=>`${JSON.stringify(H)}: undefined as any`).join(", "),U=L(V.offset,`<${V.name}>`);i.push({expression:U,statement:{text:`;void ({ ${X} } satisfies ${Z.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:j.size?a.join(`
526
- `):"",checks:i,events:l,dependencies:u}}import ua from"fs";import wt from"path";var ht=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];function $u(e){let n=new be(e,"javascript").tokenize(),r=e;for(let i of n.reverse())if(i.type==="COMMENT")r=r.slice(0,i.start)+i.value.replace(/[^\r\n]/g," ")+r.slice(i.end);return r}function _t(e,n,r,i){if(e[n]!==r)return-1;let a=0,l=null;for(let u=n;u<e.length;u++){let f=e[u];if(l){if(f==="\\"){u++;continue}if(f===l)l=null;continue}if(f==="'"||f==='"'||f==="`"){l=f;continue}if(f===r)a++;else if(f===i){if(i===">"&&e[u-1]==="=")continue;if(a--,a===0)return u+1}}return-1}function gt(e,n,r){let i=r?"([{<":"([{",a=r?")]}>":")]}",l=[],u=0,f=null,v="";for(let S=0;S<e.length;S++){let I=e[S];if(f){if(v+=I,I==="\\"){v+=e[++S]??"";continue}if(I===f)f=null;continue}if(I==="'"||I==='"'||I==="`"){f=I,v+=I;continue}if(i.includes(I))u++;else if(a.includes(I)&&!(r&&I===">"&&e[S-1]==="="))u--;if(u===0&&n.includes(I)){l.push(v),v="";continue}v+=I}return l.push(v),l.map((S)=>S.trim()).filter(Boolean)}function Eu(e){let n=0,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r=null;continue}if(a==="'"||a==='"'||a==="`"){r=a;continue}if("([{".includes(a))n++;else if(")]}".includes(a))n--;if(n!==0||a!=="=")continue;let l=e[i-1];if(e[i+1]==="="||l==="="||l==="!"||l==="<"||l===">")continue;return i}return-1}function Go(e){switch(e.trim()){case"String":return"string";case"Number":return"number";case"Boolean":return"boolean";case"Array":return"unknown[]";case"Object":return"Record<string, unknown>";default:return}}function fn(e){let n=$u(e);for(let r of new Set(Hn(n).map((i)=>i.start))){let i=ku(n,r);if(i)return{...i,text:e.slice(r,r+i.text.length)}}return null}function ku(e,n){let r=Object.create(null),i=Object.create(null),a=[],l=Object.create(null),u=Object.create(null),f=n+(/^(?:const|let|var)\s+/.exec(e.slice(n))?.[0].length??0),v=()=>{while(f<e.length&&/\s/.test(e[f]))f++},S;if(e[f]==="{"){let q=_t(e,f,"{","}");if(q===-1)return null;S=e.slice(f,q),f=q}else{let q=/^[A-Za-z_$][\w$]*/.exec(e.slice(f));if(!q)return null;S=q[0],f+=q[0].length}if(v(),e[f]!=="=")return null;f++,v();let I=/^withDefaults\s*\(\s*/.exec(e.slice(f)),j=Boolean(I);if(I)f+=I[0].length;let L=/^defineProps\b/.exec(e.slice(f));if(!L)return null;f+=L[0].length;let M="";if(v(),e[f]==="<"){let q=_t(e,f,"<",">");if(q===-1)return null;M=e.slice(f+1,q-1).trim(),f=q}if(v(),e[f]!=="(")return null;let V=_t(e,f,"(",")");if(V===-1)return null;let W=e.slice(f+1,V-1).trim();if(f=V,j){if(v(),e[f]===",")f++,v();if(e[f]==="{"){let q=_t(e,f,"{","}");if(q===-1)return null;for(let[X,U]of ks(e.slice(f,q)))i[X]=U;f=q}if(v(),e[f]===",")f++,v();if(e[f]===")")f++}if(e[f]===";")f++;let Z=/^[A-Za-z_$][\w$]*$/.test(M)?M:void 0;if(M.startsWith("{"))for(let q of gt(M.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let X=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(q);if(X)r[X[1]]=X[2].trim()}if(W.startsWith("{"))for(let[q,X]of ks(W)){if(a.push(q),!X.startsWith("{")){let U=Go(X);if(U)r[q]=U;continue}for(let[U,H]of ks(X))if(U==="default")i[q]=H;else if(U==="type"){let re=Go(H);if(re)r[q]=re}}else if(W.startsWith("["))for(let q of gt(W.slice(1,-1),",",!1))a.push(q.replace(/^['"`]/,"").replace(/['"`]$/,""));if(S.startsWith("{")){a.length=0;for(let q of gt(S.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let X=Eu(q),U=X===-1?q:q.slice(0,X),H=U.split(":")[0].trim().replace(/^\.\.\./,"");if(!H)continue;a.push(H),l[H]=U.trim();let re=U.split(":").at(-1).trim();if(/^[A-Za-z_$][\w$]*$/.test(re))u[H]=re;if(X!==-1)i[H]=q.slice(X+1).trim()}}else if(a.length===0)a.push(...Object.keys(r));return{text:e.slice(n,f),propNames:a,propBindings:l,localBindings:u,defaults:i,declared:r,typeName:Z,identifier:S.startsWith("{")?void 0:S}}function ks(e){let n=e.trim().replace(/^\{/,"").replace(/\}$/,""),r=[],i=0;while(i<n.length){let a=/\s*([A-Za-z_$][\w$]*)\s*:/y;a.lastIndex=i;let l=a.exec(n);if(!l)break;i=a.lastIndex;let u=0,f="",v=i;while(i<n.length){let I=n[i];if(f){if(I==="\\")i++;else if(I===f)f=""}else if(I==="'"||I==='"'||I==="`")f=I;else if(I==="{"||I==="["||I==="(")u++;else if(I==="}"||I==="]"||I===")")u--;else if(I===","&&u===0)break;i++}let S=n.slice(v,i).trim();if(S)r.push([l[1],S]);i++}return r}function hr(e){let n=/^(?:(?:0|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?$/,r=/^(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[bB][01](?:_?[01])*|0[oO][0-7](?:_?[0-7])*)$/;if(!n.test(e)&&!r.test(e))throw Error("Invalid prop number");return Number(e.replaceAll("_",""))}function Cs(e){let n=new be(e,"javascript").tokenize().filter((a)=>!["COMMENT","WHITESPACE","EOF"].includes(a.type)),r=0;function i(a){if(a>64)throw Error("Prop literal too deep");let l=n[r++];if(!l)throw Error("Missing prop literal");if(l.type==="STRING"||l.type==="TEMPLATE_STRING"){let I=yt(l.value);if(I===null)throw Error("Dynamic prop string");return I}if(l.type==="NUMBER")return hr(l.value);if(l.value==="-"||l.value==="+"){let I=n[r++];if(I?.type!=="NUMBER")throw Error("Dynamic prop number");return(l.value==="-"?-1:1)*hr(I.value)}if(l.value==="true")return!0;if(l.value==="false")return!1;if(l.value==="null")return null;if(l.value==="undefined")return;if(l.value!=="["&&l.value!=="{")throw Error("Dynamic prop default");let u=l.value==="[",f=u?"]":"}",v=[],S=[];while(n[r]?.value!==f){if(u)S.push(i(a+1));else{let I=n[r++];if(!I||!["STRING","IDENTIFIER","NUMBER"].includes(I.type))throw Error("Dynamic prop key");let j=I.type==="STRING"?yt(I.value):I.type==="NUMBER"?String(hr(I.value)):I.value;if(j===null||n[r++]?.value!==":")throw Error("Dynamic prop key");v.push([j,i(a+1)])}if(n[r]?.value!==",")break;r++}if(n[r++]?.value!==f)throw Error("Unclosed prop literal");return u?S:Object.fromEntries(v)}try{let a=i(0);return r===n.length?a:void 0}catch{return}}function Rs(e,n){let r=t(e),i=h(r).depths,a=/\b(interface|type)\s+([A-Za-z_$][\w$]*)\b/g;for(let l of r.matchAll(a)){if(l[2]!==n||i[l.index]!==0)continue;let u=l.index+l[0].length,f=r.indexOf("{",u);if(l[1]==="interface"&&f>=0){let v=_t(r,f,"{","}");if(v>=0)return e.slice(f,v)}if(l[1]==="type"){let v=r.indexOf("=",u);if(v<0)continue;let S=e.slice(v+1).trimStart();if(S[0]==="{"){let I=_t(S,0,"{","}");if(I>=0)return S.slice(0,I)}}}}function As(e){let n=e.trim();return/^[A-Za-z_$][\w$]*$/.test(n)?n:yt(n)??void 0}function Yo(e){let n=gt(e.trim().slice(1,-1),",",!0);if(n.length!==1)return e.trim();let r=n[0];if(r.startsWith("..."))return e.trim();let i=/^(?:[A-Za-z_$][\w$]*)(\?)?\s*:\s*([\s\S]+)$/.exec(r),a=i?!!i[1]:r.endsWith("?"),l=i?i[2]:a?r.slice(0,-1).trim():r;return a?`(${l}) | undefined | []`:l}function Un(e){let n=Fn(e,["defineEmits"],!0);if(!n)return null;let r=Object.create(null),i=/^[A-Za-z_$][\w$]*$/.test(n.type.trim())?n.type.trim():void 0,a=i?Rs(e,i):n.type.trim();if(a?.startsWith("{"))for(let l of gt(a.slice(1,-1),`;,
527
- `,!0)){if(l.startsWith("(")){let j=_t(l,0,"(",")");if(j<0)continue;let L=gt(l.slice(1,j-1),",",!0),M=L.shift()||"",V=M.indexOf(":");if(V<0)continue;for(let W of gt(M.slice(V+1),"|",!0)){let Z=As(W);if(Z!==void 0)r[Z]={detailType:Yo(`[${L.join(", ")}]`)}}continue}let u=new be(l,"javascript").tokenize().filter((j)=>!["WHITESPACE","COMMENT","EOF"].includes(j.type)),f=u[0],v=u.findIndex((j)=>j.value===":");if(!f||v<0)continue;let S=As(f.value),I=l.slice(u[v].end).trim();if(S!==void 0)r[S]={detailType:I.startsWith("[")?Yo(I):I}}else{let l=n.args[0]?.trim()||"";if(l.startsWith("["))for(let u of gt(l.slice(1,-1),",",!1)){let f=As(u);if(f!==void 0)r[f]={detailType:"unknown"}}else if(l.startsWith("{"))for(let u of gt(l.slice(1,-1),",",!1)){let f=new be(u,"javascript").tokenize().find((S)=>!["WHITESPACE","COMMENT"].includes(S.type)),v=f&&As(f.value);if(v!==void 0)r[v]={detailType:"unknown"}}}return{...n,text:e.slice(n.start,n.end),typeName:i,events:r}}import{mkdir as Qo,readFile as Cu,readdir as Ru,realpath as Au,stat as ea,writeFile as Tu}from"fs/promises";import rt from"path";import{builtinModules as Iu}from"module";function aa(e){if(e==="connectedCallback")return`method "${e}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(e==="disconnectedCallback")return`method "${e}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${e}" is reserved`}var ca=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]),Ou=new Set(Iu);function ju(e){return e.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function br(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Pu(e){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(e)&&!e.startsWith("xml")&&!/[A-Z]/.test(e)}function Mu(e){if(e===!0)return"open";if(e==="open"||e==="closed")return e;return!1}async function Du(e){let n=[];async function r(i){let a=await Ru(i,{withFileTypes:!0});a.sort((l,u)=>l.name.localeCompare(u.name));for(let l of a){let u=rt.join(i,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await r(u)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))n.push(u)}}return await r(e),n}function Yt(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function yr(e){for(let n of ee(Yt(e))){let r=O(n.attrs);if(!r.has("component")&&!r.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function _r(e,n){let r=yr(e);if(!r)return{};let i=r.code.trim();if(!i)return{};try{let a=JSON.parse(i);if(!a||typeof a!=="object"||Array.isArray(a))throw Error("expected a JSON object");return a}catch(a){throw Error(`${n}: <script component> must contain JSON metadata (${a.message})`)}}function Ts(e,n){let r=t(e),i=new Set(Hn(e).map((v)=>v.start)),a=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,l=[],u=n?void 0:new Bun.Transpiler({loader:"ts"}),f;while(f=a.exec(r)){if(!i.has(f.index+f[0].indexOf("function")))continue;let v=a.lastIndex;while(/\s/.test(r[v]||""))v++;let S=v;if(r[v]==="<")v=_t(r,v,"<",">");if(v<0)continue;let I=e.slice(S,v).trim();while(/\s/.test(r[v]||""))v++;if(r[v]!=="(")continue;let j=v,L=_t(r,v,"(",")");if(L<0)continue;for(v=L;v<e.length;v++){let M=r[v];if(M!=="{"&&M!==";")continue;let V=e.slice(f.index,v).trim();if(n){if(!n(V,M,f[1]))continue}else{let Z;try{Z=u.transformSync(V+(M==="{"?"{}":";"))}catch{continue}if(M==="{"&&!Z.includes(`function ${f[1]}(`))continue;if(M===";"&&Z.trim())continue}let W=M==="{"?_t(r,v,"{","}"):v+1;if(W<0)break;l.push({name:f[1],header:V,generic:I,parameterOffset:j+1,parameters:e.slice(j+1,L-1),returns:e.slice(L,v).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(f[0]),...M==="{"?{source:e.slice(f.index,W)}:{}}),a.lastIndex=W;break}}return l}function Nu(e){let n=gt(e.parameters,",",!0).flatMap((r,i)=>{let a=t(r),l=0,u=-1;for(let W=0;W<a.length;W++){let Z=a[W];if("([{<".includes(Z))l++;else if(")]}>".includes(Z)&&!(Z===">"&&a[W-1]==="="))l--;if(Z==="="&&l===0&&a[W+1]!==">"){u=W;break}}let f=(u<0?r:r.slice(0,u)).trim(),v=gt(f,":",!0),S=v.shift().trim();if(S==="this")return[];let I=/^[A-Za-z_$]|^\.\.\./.test(S)?S:`argument${i}`,j=u<0?"":r.slice(u+1).trim(),L=j==="true"||j==="false"?"boolean":/^-?\d+(?:\.\d+)?$/.test(j)?"number":/^['"`]/.test(j)?"string":I.startsWith("...")?"unknown[]":"unknown",M=v.join(":").trim()||L,V=u>=0&&!I.endsWith("?")&&!I.startsWith("...")?"?":"";return[`${I}${V}: ${M}`]}).join(", ");return`${e.name}${e.generic}(${n}): ${e.returns||(e.async?"Promise<unknown>":"unknown")}`}function Lu(e,n){let r={},i={},a=[],l=[],u=ee(Yt(e)).map((W)=>({code:e.slice(W.bodyStart,W.bodyEnd),attributes:O(W.attrs)})).filter(({attributes:W})=>!["src","server","component","stx:component"].some((Z)=>W.has(Z))&&kt(W)),f=u.map((W)=>W.code).join(`
528
- `),v=fn(f),S=Un(f);for(let W of u){let{code:Z}=W;try{new Bun.Transpiler({loader:"ts"}).transformSync(Z)}catch(le){throw Error(`${n}: failed to transpile <script client> (${le.message})`)}let q=Ts(Z),X=new Set(q.filter((le)=>!le.source).map((le)=>le.name));for(let le of q){if(ca.has(le.name))throw Error(`${n}: client ${aa(le.name)}`);if(le.source)r[le.name]=`${le.name}(...args) { return this._callScopeMethod(${JSON.stringify(le.name)}, args); }`;if(!le.source||!X.has(le.name))(i[le.name]??=[]).push(Nu(le))}for(let le of Z.matchAll(/^\s*import\s+(?:type\s+)?([\s\S]*?)\s+from\s*(['"])([^'"]+)\2\s*;?/gm))l.push({binding:le[1].trim(),module:le[3]});let U=t(Z),H=h(U).depths,re=/(?:export\s+)?(interface|type)\s+[A-Za-z_$][\w$]*/g,ce;while(ce=re.exec(U)){if(H[ce.index]!==0)continue;let le=re.lastIndex,pe=0;for(;le<U.length;le++){let Fe=U[le];if(Fe==="{"){let it=_t(U,le,"{","}");if(it<0)break;if(le=it-1,ce[1]==="interface"&&pe===0){le++;break}continue}if("([<".includes(Fe))pe++;else if(")]>".includes(Fe)&&!(Fe===">"&&U[le-1]==="="))pe--;if(ce[1]==="type"&&pe===0&&(Fe===";"||Fe===`
529
- `)){if(Fe===`
530
- `&&/^[\s]*[|&]/.test(U.slice(le+1)))continue;try{new Bun.Transpiler({loader:"ts"}).transformSync(Z.slice(ce.index,le));break}catch{}}}let Re=Z.slice(ce.index,le),Ae=ce.index,we=/(?:interface|type)\s+([A-Za-z_$][\w$]*)/.exec(ce[0])?.[1],fe=u.map((Fe)=>{let it=Fe===W?Z.slice(0,Ae)+Z.slice(le):Fe.code;return t(it.replace(fn(Fe.code)?.text??"\x00","").replace(Un(Fe.code)?.text??"\x00",""))}).join(`
531
- `);if(!((v?.typeName===we||S?.typeName===we)&&!/^export\s/.test(Re)&&we&&!new RegExp(`\\b${we}\\b`).test(fe)))a.push(Re.replace(/^export\s+/,"").trim());re.lastIndex=le+1}}let I=Object.values(i).flat().join(`
532
- `)+`
533
- `+a.join(`
534
- `)+`
535
- `+Object.values(S?.events||{}).map((W)=>W.detailType).join(`
536
- `),j=new be(I,"javascript").tokenize().filter((W)=>!["WHITESPACE","COMMENT"].includes(W.type)),L=new Set(j.filter((W,Z)=>{if(j[Z-1]?.value===".")return!1;let q=j[Z+1]?.value;return q!==":"&&!(q==="?"&&j[Z+2]?.value===":")}).map((W)=>W.value)),M=l.filter((W)=>(W.binding.match(/[A-Za-z_$][\w$]*/g)||[]).filter((Z)=>!["type","as"].includes(Z)).some((Z)=>L.has(Z)));for(let W of M)if(W.module.startsWith(".")||rt.isAbsolute(W.module))throw Error(`${n}: public method types import ${JSON.stringify(W.module)} outside the generated package; declare these types in the component or import them from a published dependency`);let V=[...new Set(M.map((W)=>`import type ${W.binding.replace(/\btype\s+/g,"")} from ${JSON.stringify(W.module)}`))];return{methods:r,declarations:i,types:a.join(`
537
-
538
- `),typeImports:V.join(`
539
- `)}}function zu(e){let n=e.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:e).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function ta(e){return[...e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].replace(/\r\n?/g,`
540
- `).replaceAll("\x00","\uFFFD").trim()).filter(Boolean).join(`
541
-
542
- `)}function Bu(e){if(!e)return null;let n=e.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(n))return"string";if(/^number$/.test(n))return"number";if(/^boolean$/.test(n))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(n))return"string";return"object"}function Wu(e){if(e===void 0)return"object";if(e==="true"||e==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test(e))return"number";if(/^['"`]/.test(e))return"string";return"object"}function Kn(e,n){if(e[n]!=="(")return null;let r=0,i="";for(let a=n;a<e.length;a++){let l=e[a];if(i!==""){if(l==="\\")a++;else if(l===i)i="";continue}if(l==="'"||l==='"'||l==="`"){i=l;continue}if(l==="(")r++;else if(l===")"){if(r--,r===0)return{expression:e.slice(n+1,a),end:a+1}}}return null}function wr(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function Fu(e,n){let r=[],i=0,a=e.replace(/\{\{--[\s\S]*?--\}\}/g,""),l=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,u,f=(v)=>{if(v==="")return;let S=0,I=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}|(data-stx-on-[\w:-]+=")(\d+)(")/g,j;while(j=I.exec(v)){if(j.index>S)r.push(`out += ${JSON.stringify(v.slice(S,j.index))};`);r.push(j[3]!==void 0?`out += ${JSON.stringify(j[3])} + (this._handlers.push(${n[Number(j[4])]}) - 1) + ${JSON.stringify(j[5])};`:j[1]!==void 0?`out += __raw(${j[1]});`:`out += __escape(${j[2]});`),S=j.index+j[0].length}if(S<v.length)r.push(`out += ${JSON.stringify(v.slice(S))};`)};while(u=l.exec(a)){f(a.slice(i,u.index)),i=u.index+u[0].length;let S=u[1]==="if"||u[1]==="elseif"||u[1]==="foreach"?Kn(a,i):null;if(S)i=S.end,l.lastIndex=S.end;let I=S?.expression;switch(u[1]){case"if":r.push(`if (${I}) {`);break;case"elseif":r.push(`} else if (${I}) {`);break;case"else":r.push("} else {");break;case"endif":case"endforeach":r.push("}");break;case"foreach":{let j=wr(I||"");if(!j){r.push(`out += ${JSON.stringify(u[0]+(S?`(${I})`:""))};`);break}let{iterable:L,key:M,value:V}=j;r.push(M?`for (const [${M}, ${V}] of __entries(${L})) {`:`for (const ${V} of __values(${L})) {`);break}}}return f(a.slice(i)),r.join(`
543
- `)}function la(e){let n=t(e),r=h(n).depths,i=[],a=[];for(let u of n.matchAll(/\bimport\b/g)){let f=u.index;if(r[f]!==0)continue;let v=new be(e.slice(f)).tokenize().filter((V)=>!["COMMENT","WHITESPACE"].includes(V.type));if(v[1]?.value==="("||v[1]?.value===".")continue;let S=v[1]?.type==="STRING"?1:-1,I=0;for(let V=1;S===-1&&V<v.length;V++){let W=v[V];if(W.value===";"||W.type==="EOF")break;if(W.value==="{")I++;else if(W.value==="}")I--;else if(I===0&&W.value==="from"&&v[V+1]?.type==="STRING")S=V+1}if(S===-1)continue;let j=v[S],L=S;if(v[L+1]?.value==="with"&&v[L+2]?.value==="{"){L+=2;let V=1;while(V&&v[L+1]?.type!=="EOF")if(L++,v[L]?.value==="{")V++;else if(v[L]?.value==="}")V--}if(v[L+1]?.value===";")L++;let M=f+v[L].end;if(a.push({start:f,end:M}),!["stx","@stacksjs/stx"].includes(j.value.slice(1,-1)))i.push(e.slice(f,M))}let l=e;for(let u of a.reverse())l=l.slice(0,u.start)+l.slice(u.end);return{imports:i,body:l}}function Vu(e){let r=ee(Yt(e)).filter((q)=>{let X=O(q.attrs);return kt(X)&&!["component","stx:component","server","src"].some((U)=>X.has(U))});if(!r.length)return{imports:[],body:"",propNames:[],propBindings:{},defaults:{},declared:{},apis:[]};let i=r.map((q)=>e.slice(q.bodyStart,q.bodyEnd)).join(`
544
- `),a=[],l=[],u=Object.create(null),f=Object.create(null),v=Object.create(null),S=la(i);a.push(...S.imports),i=S.body;let I=fn(i);if(I)l.push(...I.propNames),Object.assign(u,I.propBindings),Object.assign(f,I.defaults),Object.assign(v,I.declared),i=i.replace(I.text,I.identifier?`const ${I.identifier} = this._props();`:"");if(I?.typeName){let q=Rs(i,I.typeName);if(q)for(let X of gt(q.slice(1,-1),`;,
545
- `,!0)){let U=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:\s*([\s\S]+)$/.exec(X);if(!U)continue;if(v[U[1]]=U[2].trim(),!l.includes(U[1]))l.push(U[1])}}let j=Un(i);if(j)i=i.replace(j.text,"this._emitScope.bind(this)");let L=t(i),M=h(L).depths;for(let q of[...L.matchAll(/\bexport\s+(?=(?:interface|type|const|let|var|async|function)\b)/g)].reverse())if(M[q.index]===0)i=i.slice(0,q.index)+" ".repeat(q[0].length)+i.slice(q.index+q[0].length);let V=new Set(Hn(i).map((q)=>q.name)),W=t(i),Z=["state","derived","effect","batch","onMount","onDestroy"].filter((q)=>!V.has(q)&&new RegExp(`\\b${q}\\s*(?:<|\\()`).test(W));return{imports:a,body:i.trim(),propNames:l,propBindings:u,defaults:f,declared:v,apis:Z}}function Uu(e){let n=new Set,r=[];return{template:e.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([\s\S]*?)\3/gi,(a,l,u,f,v)=>{let S=l.toLowerCase();n.add(S);let I=(u||"").split(".").filter(Boolean).join(" "),j=r.length;return r.push(/^[A-Za-z_$][\w$]*$/.test(v.trim())?`($event) => (typeof ${v} === 'function' ? ${v} : this[${JSON.stringify(v.trim())}]).call(this, $event)`:`($event) => { ${v} }`),` data-stx-on-${S}="${j}"${I?` data-stx-mod-${S}="${I}"`:""}`}),eventTypes:[...n].sort(),handlers:r}}function Hu(e){let n=[];return{template:e.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(i,a,l,u)=>{let f=n.length;return n.push({id:f,name:a,expression:u}),` data-stx-bind-${f}=""`}),bindings:n}}function Ku(e){let n=new Set;for(let r of e.matchAll(/<slot\b([^>]*)>/gi))n.add(r[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...n].map((r)=>({name:r}))}function qu(e){return[...new Set([...e.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((n)=>n[1]))].sort().map((n)=>({name:n}))}function na(e,n){if(!n||!new Set(["string","number","boolean","object","array"]).has(n.type))throw Error(`Property "${e}" must declare one of: string, number, boolean, object, array`);return{...n,reflect:n.reflect??n.attribute!==!1}}async function Zu(e,n,r){let i=rt.isAbsolute(n.file)?n.file:rt.resolve(e,n.file),a=await Cu(i,"utf8"),l=_r(a,i),u=rt.basename(i,".stx"),f=n.name||l.name||ju(u),v=`${br(r.prefix||"stx")}-${br(u)}`,S=n.tag||l.tag||v;if(!f||!/^[A-Za-z_$][\w$]*$/.test(f))throw Error(`${i}: invalid component class name "${f}"`);if(!Pu(S))throw Error(`${i}: invalid custom-element tag "${S}"; tags must be lowercase and contain a hyphen`);let I=n.properties||l.properties||l.props||{},j=Object.fromEntries(Object.entries(I).map(([U,H])=>[U,na(U,H)])),L=Uu(zu(a)),M=Hu(L.template),V=Vu(a);for(let U of ee(Yt(a))){let H=O(U.attrs);if(!H.has("client")||["server","component","stx:component","src"].some((re)=>H.has(re))||!kt(H))continue;V.imports.push(...la(a.slice(U.bodyStart,U.bodyEnd)).imports)}V.imports=[...new Set(V.imports)];let W=Fu(M.template,L.handlers);for(let U of V.propNames){if(j[U])continue;let H=V.defaults[U];j[U]=na(U,{type:Bu(V.declared[U])??Wu(H),...H===void 0?{}:{default:Cs(H)}})}let Z=l.methods||{},q=n.methods||{},X=Lu(a,i);return{file:rt.relative(e,i),sourcePath:i,name:f,tag:S,description:n.description||l.description||"",template:M.template,styles:ta(a),shadowMode:Mu(n.shadowDOM??l.shadowDOM??r.shadowDOM),progressive:n.progressive??l.progressive??r.progressive??!0,properties:j,events:{...Un(ee(Yt(a)).filter((U)=>{let H=O(U.attrs);return kt(H)&&!["server","component","stx:component","src"].some((re)=>H.has(re))}).map((U)=>a.slice(U.bodyStart,U.bodyEnd)).join(`
546
- `))?.events||{},...n.events||l.events||{}},methods:{...Z,...q,...X.methods},methodDeclarations:X.declarations,declarationTypes:X.types,declarationImports:X.typeImports,eventTypes:L.eventTypes,handlers:L.handlers,scopeMethods:Object.keys(X.methods),bindings:M.bindings,slots:Ku(M.template),cssProperties:qu(ta(a)),scope:V,render:W}}function sa(e=!1){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`${e?`import { state as nativeState, derived as nativeDerived, effect as nativeEffect, batch as nativeBatch } from './signals.js';
547
- `:""}const HTMLElementBase = globalThis.HTMLElement || class {};
548
-
549
- const escapeHTML = (value) => String(value ?? '')
550
- .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
551
- .replaceAll('"', '&quot;').replaceAll("'", '&#039;');
552
-
553
- const valueAt = (host, path) => {
554
- const parts = path.trim().split('.');
555
- if (parts[0] === 'this') parts.shift();
556
- if (!parts.length) return host;
557
- const first = parts.shift();
558
- // Render bindings read declared props, including attributes whose names
559
- // also belong to the native DOM API. The public element keeps that API.
560
- let value = host._values && Object.prototype.hasOwnProperty.call(host._values, first)
561
- ? host._values[first]
562
- : host[first];
563
- for (const part of parts) value = value?.[part];
564
- return typeof value === 'function' ? value.call(host) : value;
565
- };
566
-
567
- const deserialize = (value, type, fallback) => {
568
- if (value === null) return type === 'boolean' ? false : fallback;
569
- if (type === 'boolean') return value !== 'false' && value !== '0';
570
- if (type === 'number') return Number(value);
571
- if (type === 'object' || type === 'array') {
572
- try { return JSON.parse(value); }
573
- catch { return fallback; }
574
- }
575
- return value;
576
- };
577
-
578
- const serialize = (value, type) => {
579
- if (value == null || value === false) return null;
580
- if (type === 'boolean') return '';
581
- if (type === 'object' || type === 'array') return JSON.stringify(value);
582
- return String(value);
583
- };
584
-
585
- const cloneDefault = (value, type) => {
586
- if (value == null || (type !== 'object' && type !== 'array')) return value;
587
- if (typeof structuredClone === 'function') return structuredClone(value);
588
- return JSON.parse(JSON.stringify(value));
589
- };
590
-
591
- const defaultFor = property => cloneDefault(
592
- property.default ?? ({ string: '', number: 0, boolean: false, object: {}, array: [] })[property.type],
593
- property.type,
594
- );
595
-
596
- export class StxElement extends HTMLElementBase {
597
- static definition = {};
598
- static get observedAttributes() { return this.definition.observedAttributes || []; }
599
-
600
- constructor() {
601
- super();
602
- this._values = Object.create(null);
603
- this._reflecting = false;
604
- this._connected = false;
605
- this._hasConnected = false;
606
- this._initializing = false;
607
- this._updatePending = false;
608
- this._listeners = new Map();
609
- this._scopeStates = [];
610
- this._scopeDerived = [];
611
- this._scopeEffects = [];
612
- this._scopeSubscriptions = [];
613
- this._scopeMounts = [];
614
- this._scopeDestroys = [];
615
- this._scopeConnectionDestroys = [];
616
- this._scopeMountCleanups = [];
617
- const definition = this.constructor.definition;
618
- for (const [name, property] of Object.entries(definition.properties || {})) {
619
- this._values[name] = defaultFor(property);
620
- }
621
- if (definition.shadowMode && this.attachShadow && !this.shadowRoot) {
622
- this._closedRoot = this.attachShadow({ mode: definition.shadowMode });
623
- }
624
- }
625
-
626
- get updateComplete() { return this._updateComplete || Promise.resolve(); }
627
- get renderRoot() { return this._closedRoot || this.shadowRoot || this; }
628
-
629
- connectedCallback() {
630
- if (this._connected) return;
631
- this._connected = true;
632
- this._initializing = true;
633
- const definition = this.constructor.definition;
634
- for (const [name, property] of Object.entries(definition.properties || {})) {
635
- const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
636
- if (attribute && this.hasAttribute?.(attribute)) this._values[name] = deserialize(this.getAttribute(attribute), property.type, defaultFor(property));
637
- }
638
- // Properties assigned before customElements.define() become own properties.
639
- // Upgrade them after attributes so imperative state wins, matching the
640
- // platform's property-first custom-element initialization convention.
641
- for (const name of Object.keys(definition.properties || {})) this._upgradeProperty(name);
642
- this._initializing = false;
643
- const root = this.renderRoot;
644
- const hasMarkup = [...(root.childNodes || [])].some(node => node.nodeType !== 3 || node.textContent.trim());
645
- const firstConnection = !this._hasConnected;
646
- if (!(firstConnection && definition.progressive && hasMarkup)) this._render();
647
- else {
648
- if (typeof this.render === 'function') this.render(RENDER_HELPERS);
649
- this._upgradeDeclarativeEvents();
650
- }
651
- this._bindEvents();
652
- if (firstConnection) {
653
- this._hasConnected = true;
654
- this.setAttribute?.('hydrated', '');
655
- this.dispatchEvent?.(new CustomEvent('stx:hydrated', { bubbles: true, composed: true }));
656
- }
657
- // Called last, so a component that acquires something sees its own rendered
658
- // markup and its events already bound. Reported rather than rethrown: a
659
- // component that fails to set up must not take the element down with it.
660
- this._runScopeMounts();
661
- try { this.onConnect?.(); }
662
- catch (error) { console.error('[stx] onConnect failed', error); }
663
- }
664
-
665
- disconnectedCallback() {
666
- this._connected = false;
667
- // Called before the framework releases anything, so the element is still
668
- // intact for a component that needs to read it on the way out, and inside
669
- // try/finally so a throwing hook cannot leak the framework's own listeners.
670
- try { this.onDisconnect?.(); }
671
- catch (error) { console.error('[stx] onDisconnect failed', error); }
672
- finally {
673
- this._disposeScopeEffects();
674
- for (const dispose of this._scopeSubscriptions.splice(0)) {
675
- try { dispose?.(); } catch (error) { console.error('[stx] scope subscription cleanup failed', error); }
676
- }
677
- for (const cleanup of [...this._scopeDestroys.splice(0), ...this._scopeConnectionDestroys.splice(0), ...this._scopeMountCleanups.splice(0)]) {
678
- try { cleanup(); } catch (error) { console.error('[stx] scope cleanup failed', error); }
679
- }
680
- for (const [event, listener] of this._listeners) this.renderRoot.removeEventListener(event, listener);
681
- this._listeners.clear();
682
- }
683
- }
684
-
685
- attributeChangedCallback(attribute, oldValue, newValue) {
686
- if (oldValue === newValue || this._reflecting) return;
687
- const definition = this.constructor.definition;
688
- const name = definition.attributeToProperty?.[attribute];
689
- if (!name) return;
690
- const property = definition.properties[name];
691
- const value = deserialize(newValue, property.type, defaultFor(property));
692
- if (!Object.is(this._values[name], value)) {
693
- this._values[name] = value;
694
- this.requestUpdate();
695
- }
696
- }
697
-
698
- /**
699
- * The props a compiled render reads.
700
- *
701
- * Its own method rather than _values directly, so a component that sets a
702
- * property before upgrade still sees it, and so the generated code has one
703
- * name to depend on rather than a private field's shape.
704
- */
705
- _props() {
706
- return this._values;
707
- }
708
-
709
- requestUpdate() {
710
- if (!this._connected || this._initializing || this._updatePending) return this.updateComplete;
711
- this._updatePending = true;
712
- this._updateComplete = new Promise((resolve) => {
713
- queueMicrotask(() => {
714
- this._updatePending = false;
715
- if (this._connected) this._render();
716
- resolve();
717
- });
718
- });
719
- return this._updateComplete;
720
- }
721
-
722
- emit(name, detail, options = {}) {
723
- return this.dispatchEvent(new CustomEvent(name, {
724
- detail, bubbles: true, composed: true, ...options,
725
- }));
726
- }
727
-
728
- _disposeScopeEffects() {
729
- for (const dispose of this._scopeEffects.splice(0)) {
730
- try { dispose(); } catch (error) { console.error('[stx] effect cleanup failed', error); }
731
- }
732
- }
733
-
734
- _runScopeMounts() {
735
- for (const mount of this._scopeMounts) {
736
- try { const cleanup = mount(); if (typeof cleanup === 'function') this._scopeMountCleanups.push(cleanup); }
737
- catch (error) { console.error('[stx] onMount failed', error); }
738
- }
739
- }
740
-
741
- ${e?` _beginScope() {
742
- this._disposeScopeEffects();
743
- this._scopeMounts = [];
744
- this._scopeDestroys = [];
745
- let stateIndex = 0, derivedIndex = 0;
746
- let rendering = true;
747
- return {
748
- finish: () => { rendering = false; },
749
- state: (initial) => {
750
- const index = stateIndex++;
751
- const value = this._scopeStates[index] ||= nativeState(initial);
752
- if (this._connected && !this._scopeSubscriptions[index]) this._scopeSubscriptions[index] = value.subscribe(() => this.requestUpdate());
753
- return value;
754
- },
755
- derived: (compute, options) => {
756
- const index = derivedIndex++;
757
- let entry = this._scopeDerived[index];
758
- if (!entry) {
759
- entry = { compute, revision: nativeState(0) };
760
- entry.value = nativeDerived(() => { entry.revision(); return entry.compute(); }, options);
761
- this._scopeDerived[index] = entry;
762
- } else {
763
- entry.compute = compute;
764
- entry.revision.update(value => value + 1);
765
- }
766
- return entry.value;
767
- },
768
- effect: (callback, options) => {
769
- const dispose = nativeEffect(callback, options);
770
- this._scopeEffects.push(dispose);
771
- return dispose;
772
- },
773
- batch: nativeBatch,
774
- onMount: callback => this._scopeMounts.push(callback),
775
- onDestroy: callback => (rendering ? this._scopeDestroys : this._scopeConnectionDestroys).push(callback),
776
- };
777
- }
778
-
779
- `:""} _emitScope(name, ...args) {
780
- return this.emit(name, args.length === 1 ? args[0] : args, { cancelable: true });
781
- }
782
-
783
- _callScopeMethod(name, args) {
784
- // Template calls already have this render's current prop closures. Refresh
785
- // pending props only for an outside call, otherwise a public helper in the
786
- // template would recursively render while the queued update is pending.
787
- if (!this._scopeRenderDepth && (!this._scopeMethods || this._updatePending)) this.render(RENDER_HELPERS);
788
- return this._scopeMethods[name].apply(this, args);
789
- }
790
-
791
- _upgradeProperty(name) {
792
- if (!Object.prototype.hasOwnProperty.call(this, name)) return;
793
- const value = this[name];
794
- delete this[name];
795
- this[name] = value;
796
- }
797
-
798
- _upgradeDeclarativeEvents() {
799
- for (const element of this.renderRoot.querySelectorAll?.('*') || []) {
800
- const names = element.getAttributeNames?.() || [...(element.attributes || [])].filter(Boolean).map(attribute => attribute.name);
801
- for (const attributeName of names) {
802
- if (!attributeName?.startsWith('@')) continue;
803
- const [event, ...modifiers] = attributeName.slice(1).split('.');
804
- element.setAttribute('data-stx-on-' + event, element.getAttribute(attributeName));
805
- if (modifiers.length) element.setAttribute('data-stx-mod-' + event, modifiers.join(' '));
806
- element.removeAttribute(attributeName);
807
- }
808
- }
809
- }
810
-
811
- _bindEvents() {
812
- for (const event of this.constructor.definition.eventTypes || []) {
813
- if (this._listeners.has(event)) continue;
814
- const listener = ($event) => {
815
- const selector = '[data-stx-on-' + event + ']';
816
- const target = $event.target?.closest?.(selector);
817
- if (!target || !this.renderRoot.contains(target)) return;
818
- const modifiers = (target.getAttribute('data-stx-mod-' + event) || '').split(' ');
819
- if (modifiers.includes('self') && target !== $event.target) return;
820
- if (modifiers.includes('prevent')) $event.preventDefault();
821
- if (modifiers.includes('stop')) $event.stopPropagation();
822
- const method = target.getAttribute('data-stx-on-' + event);
823
- if (this._handlers?.[method]) this._handlers[method]($event);
824
- else if (typeof this[method] === 'function') this[method]($event);
825
- };
826
- this.renderRoot.addEventListener(event, listener);
827
- this._listeners.set(event, listener);
828
- }
829
- }
830
-
831
- _render() {
832
- const definition = this.constructor.definition;
833
- const root = this.renderRoot;
834
- const active = root.activeElement || (root.contains?.(globalThis.document?.activeElement) ? globalThis.document.activeElement : null);
835
- const focusAttribute = active?.getAttribute?.('data-key') ? 'data-key' : active?.id ? 'id' : 'name';
836
- const focusKey = active?.getAttribute?.(focusAttribute);
837
- const focusValue = focusAttribute === 'name' && active?.type === 'radio' ? active.value : null;
838
- const selectionStart = active?.selectionStart, selectionEnd = active?.selectionEnd;
839
- const selection = Number.isInteger(selectionStart) && Number.isInteger(selectionEnd)
840
- ? [selectionStart, selectionEnd, active.selectionDirection] : null;
841
- // A compiled component renders itself: the control flow and the derived
842
- // values were turned into JavaScript at build time, so there is nothing to
843
- // interpret here and nothing that needs an eval the page's CSP forbids.
844
- // The string template remains for components that carry no logic.
845
- let html = typeof this.render === 'function'
846
- ? this.render(RENDER_HELPERS)
847
- : definition.template
848
- .replace(new RegExp(${n}, 'g'), (_match, expression) => String(valueAt(this, expression) ?? ''))
849
- .replace(new RegExp(${r}, 'g'), (_match, expression) => escapeHTML(valueAt(this, expression)));
850
- if (definition.shadowMode && definition.styles) html = '<style>' + definition.styles + '</style>' + html;
851
- root.innerHTML = html;
852
- this._applyBindings();
853
- this._bindEvents();
854
- if (focusKey) {
855
- const escaped = globalThis.CSS?.escape ? globalThis.CSS.escape(focusKey) : focusKey.replace(/["\\\\]/g, '\\$&');
856
- const selector = '[' + focusAttribute + '="' + escaped + '"]';
857
- // Name-only radio groups share a name, but their chosen member must stay focused.
858
- const next = focusValue === null ? root.querySelector(selector)
859
- : [...root.querySelectorAll(selector)].find(element => element.type === 'radio' && element.value === focusValue);
860
- next?.focus?.();
861
- // Several input types expose this method but reject text selection. A
862
- // rerender can also change a text input into one of those types.
863
- if (selection && Number.isInteger(next?.selectionStart) && Number.isInteger(next?.selectionEnd) && typeof next?.setSelectionRange === 'function')
864
- next.setSelectionRange(selection[0], selection[1], selection[2] || 'none');
865
- }
866
- this.dispatchEvent?.(new CustomEvent('stx:updated', { bubbles: false }));
867
- }
868
-
869
- _applyBindings() {
870
- for (const binding of this.constructor.definition.bindings || []) {
871
- const element = this.renderRoot.querySelector('[data-stx-bind-' + binding.id + ']');
872
- if (!element) continue;
873
- const value = valueAt(this, binding.expression);
874
- if (binding.name === 'class') element.className = value || '';
875
- else if (binding.name === 'style' && typeof value === 'object') {
876
- Object.assign(element.style, value);
877
- }
878
- else if (typeof value === 'boolean') {
879
- element.toggleAttribute(binding.name, value);
880
- if (binding.name in element) element[binding.name] = value;
881
- }
882
- else if (value == null || value === false) element.removeAttribute(binding.name);
883
- else element.setAttribute(binding.name, String(value));
884
- }
885
- }
886
- }
887
-
888
- /**
889
- * What a compiled render is handed.
890
- *
891
- * Passed in rather than closed over so the generated code names no globals, and
892
- * a component module stays readable on its own: __escape is visibly a
893
- * parameter, not something the bundler happened to leave in scope.
894
- */
895
- const RENDER_HELPERS = {
896
- escape: escapeHTML,
897
- // The raw form is the author declaring the value is markup. Null becomes an
898
- // empty string rather than the word "null", which is the only sensible
899
- // reading of a missing fragment.
900
- raw: (value) => String(value ?? ''),
901
- // A loop over something absent runs zero times. Throwing here would fail a
902
- // whole page over one empty list, which is never what the author meant.
903
- values: (value) => value == null ? [] : (value[Symbol.iterator] ? value : Object.values(value)),
904
- entries: (value) => value == null ? [] : (Array.isArray(value) ? value.entries() : Object.entries(value)),
905
- };
906
-
907
- export function defineComponent(Component, definition) {
908
- const properties = definition.properties || {};
909
- const attributeToProperty = {};
910
- const observedAttributes = [];
911
- for (const [name, property] of Object.entries(properties)) {
912
- const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
913
- if (attribute) {
914
- attributeToProperty[attribute] = name;
915
- observedAttributes.push(attribute);
916
- }
917
- // A style prop is an attribute value, not a replacement for the browser's
918
- // CSSStyleDeclaration. Native event handler accessors must survive too.
919
- if (name in HTMLElementBase.prototype) {
920
- if (!attribute) throw new TypeError('STX prop "' + name + '" overlaps the native DOM API and needs an attribute binding');
921
- continue;
922
- }
923
- Object.defineProperty(Component.prototype, name, {
924
- configurable: true,
925
- enumerable: true,
926
- get() { return this._values[name]; },
927
- set(value) {
928
- const oldValue = this._values[name];
929
- if (Object.is(oldValue, value)) return;
930
- this._values[name] = value;
931
- if (property.reflect && attribute && !this._reflecting) {
932
- const serialized = serialize(value, property.type);
933
- this._reflecting = true;
934
- if (serialized === null) this.removeAttribute(attribute);
935
- else this.setAttribute(attribute, serialized);
936
- this._reflecting = false;
937
- }
938
- this.requestUpdate();
939
- this.dispatchEvent?.(new CustomEvent(name + '-changed', {
940
- detail: { value, oldValue }, bubbles: true, composed: true,
941
- }));
942
- },
943
- });
944
- }
945
- Component.definition = { ...definition, attributeToProperty, observedAttributes };
946
- const registry = globalThis.customElements || globalThis.window?.customElements;
947
- if (registry && !registry.get(definition.tag)) {
948
- registry.define(definition.tag, Component);
949
- }
950
- return Component;
951
- }
952
- `}function xr(e,n="./runtime.js"){let r=JSON.stringify({tag:e.tag,template:e.template,styles:e.styles,shadowMode:e.shadowMode,progressive:e.progressive,properties:e.properties,eventTypes:e.eventTypes,bindings:e.bindings},null,2),i=Object.entries(e.methods).map(([I,j])=>{if(ca.has(I))throw Error(`${e.sourcePath}: ${aa(I)}`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(j.trim()))return` ${j.trim()}`;return` ${I}($event) {
953
- ${j}
954
- }`}).join(`
955
-
956
- `),a=e.scope,l=new Set(new be([a.body,...a.imports,...Object.keys(e.properties),...Object.values(a.propBindings)].join(`
957
- `)).tokenize().map((I)=>I.value)),u="__stxScope";while(l.has(u))u+="$";let f=[...new Set([...Object.keys(e.properties),...a.propNames])].map((I)=>{let j=a.propBindings[I]||I;return a.defaults[I]===void 0?j:`${j} = ${a.defaults[I]}`}).join(", "),v=(I)=>I.split(`
958
- `).map((j)=>j.trim()===""?j:` ${j}`).join(`
959
- `),S="";if(e.render.trim()!==""||a.body!==""||f!==""){let I=[a.apis.length?`const ${u} = this._beginScope();
960
- const { ${a.apis.join(", ")} } = ${u};`:"",f?`const { ${f} } = this._props();`:"",a.body,e.scopeMethods.length?`this._scopeMethods = { ${e.scopeMethods.join(", ")} };`:"",e.handlers.length?"this._handlers = [];":"","let out = '';",e.render,a.apis.length?`${u}.finish();`:"","return out;"].filter(Boolean).join(`
961
- `),j;try{let L=new Bun.Transpiler({loader:"ts"}).transformSync(`export function __render(__helpers) {
962
- ${I}
963
- }`),M=L.indexOf("{"),V=L.lastIndexOf("}");j=L.slice(M+1,V).trim()}catch(L){throw Error(`${e.sourcePath}: failed to compile render (${L.message})`)}S=`
964
- render(__helpers) {
965
- this._scopeRenderDepth = (this._scopeRenderDepth || 0) + 1;
966
- try {
967
- const { escape: __escape, raw: __raw, values: __values, entries: __entries } = __helpers;
968
- ${v(v(j.trim()))}
969
- } finally {
970
- this._scopeRenderDepth--;
971
- }
972
- }
973
- `}return`import { StxElement, defineComponent } from ${n==="./runtime.js"?"'./runtime.js'":JSON.stringify(n)};
974
- ${a.imports.length?`${a.imports.join(`
975
- `)}
976
- `:""}
977
- /** ${e.description||`${e.name} web component generated from ${e.file}.`} */
978
- export class ${e.name} extends StxElement {
979
- ${i}${S}
980
- }
981
-
982
- defineComponent(${e.name}, ${r});
983
- export default ${e.name};
984
- `}function dn(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function Ju(e){let n=[e.declarationTypes,e.declarationImports,e.name,...Object.values(e.methodDeclarations).flat(),...Object.values(e.events).map((L)=>L.detailType)].join(`
985
- `),r=new Set(new be(n).tokenize().map((L)=>L.value)),i=(L)=>{let M=L;while(r.has(M))M+="$";return r.add(M),M},a=i("__StxSupport"),l=i("__Methods"),u=i("__Details"),f=!!e.declarationTypes,v=Object.entries(e.properties).map(([L,M])=>` ${L}${M.required?"":"?"}: ${dn(M)}`).join(`
986
- `),S=Object.entries(e.events).map(([L,M])=>` ${JSON.stringify(L)}: CustomEvent<${f?`${a}.${u}[${JSON.stringify(L)}]`:M.detailType||"unknown"}>`).join(`
987
- `),I=Object.keys(e.methods).flatMap((L)=>e.methodDeclarations[L]||[`${L}($event?: Event): unknown`]).map((L)=>` ${L}`).join(`
988
- `),j=f?`declare namespace ${a} {
989
- ${e.declarationTypes}
990
- export interface ${l} {
991
- ${I}
992
- }
993
- export interface ${u} {
994
- ${Object.entries(e.events).map(([L,M])=>` ${JSON.stringify(L)}: ${M.detailType||"unknown"}`).join(`
995
- `)}
996
- }
997
- }
998
-
999
- `:"";return`${e.declarationImports?e.declarationImports+`
1000
-
1001
- `:""}${j}export interface ${e.name}Props {
1002
- ${v}
1003
- }
1004
-
1005
- export interface ${e.name}EventMap {
1006
- ${S}
1007
- }
1008
-
1009
- export interface ${e.name} extends Required<Pick<${e.name}Props, Exclude<keyof ${e.name}Props, keyof HTMLElement>>>${f?`, ${a}.${l}`:""} {}
1010
-
1011
- export declare class ${e.name} extends HTMLElement {
1012
- ${f?"":I}
1013
- addEventListener<K extends keyof ${e.name}EventMap>(type: K, listener: (this: ${e.name}, event: ${e.name}EventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void
1014
- addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, event: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void
1015
- addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void
1016
- removeEventListener<K extends keyof ${e.name}EventMap>(type: K, listener: (this: ${e.name}, event: ${e.name}EventMap[K]) => unknown, options?: boolean | EventListenerOptions): void
1017
- removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, event: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void
1018
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void
1019
- readonly updateComplete: Promise<void>
1020
- requestUpdate(): Promise<void>
1021
- emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean
1022
- }
1023
-
1024
- declare global {
1025
- interface HTMLElementTagNameMap {
1026
- ${JSON.stringify(e.tag)}: ${e.name}
1027
- }
1028
- }
1029
-
1030
- export default ${e.name}
1031
- `}function Xu(e){return`declare global {
1032
- namespace JSX {
1033
- interface IntrinsicElements {
1034
- ${e.map((r)=>{let i=Object.entries(r.properties).map(([l,u])=>` ${JSON.stringify(l)}?: ${dn(u)}`).join(`
1035
- `),a=Object.keys(r.events).map((l)=>` ${`on${l.split(/[-:]/).map((f)=>f.charAt(0).toUpperCase()+f.slice(1)).join("")}`}?: (event: import('./${r.tag}.js').${r.name}EventMap[${JSON.stringify(l)}]) => void`).join(`
1036
- `);return` ${JSON.stringify(r.tag)}: {
1037
- ${i}
1038
- ${a}
1039
- children?: unknown
1040
- slot?: string
1041
- class?: string
1042
- className?: string
1043
- }`}).join(`
1044
- `)}
1045
- }
1046
- }
1047
- }
1048
-
1049
- export {}
1050
- `}function Gu(e){return{schemaVersion:"1.0.0",modules:e.map((n)=>({kind:"javascript-module",path:`./${n.tag}.js`,declarations:[{kind:"class",name:n.name,description:n.description||void 0,customElement:!0,tagName:n.tag,members:Object.entries(n.properties).map(([r,i])=>({kind:"field",name:r,description:i.description,type:{text:dn(i)},default:i.default===void 0?void 0:JSON.stringify(i.default),attribute:i.attribute===!1?void 0:i.attribute||br(r),reflects:i.reflect})),events:Object.entries(n.events).map(([r,i])=>({name:r,description:i.description,type:{text:`CustomEvent<${i.detailType||"unknown"}>`}})),slots:n.slots,cssProperties:n.cssProperties}],exports:[{kind:"js",name:n.name,declaration:{name:n.name,module:`./${n.tag}.js`}}]}))}}function ra(e){if(!e.styles)return"";let n=e.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(n))return n;return`@scope (${e.tag}) {
1051
- ${n}
1052
- }`}function ia(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function Yu(e){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),i=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),a=Object.fromEntries(e.map((u)=>[u.tag,{template:u.template,styles:u.styles,shadowMode:u.shadowMode,properties:u.properties}])),l=e.map((u)=>`export const render${u.name} = (props = {}, slots = {}) => renderComponent('${u.tag}', props, slots);`).join(`
1053
- `);return`const definitions = ${JSON.stringify(a,null,2)};
1054
- const escapeHTML = (value) => String(value ?? '')
1055
- .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
1056
- .replaceAll('"', '&quot;').replaceAll("'", '&#039;');
1057
- const valueAt = (values, path) => path.trim().split('.').reduce((value, part) => value?.[part], values);
1058
-
1059
- export function renderComponent(tag, props = {}, slots = {}) {
1060
- const definition = definitions[tag];
1061
- if (!definition) throw new Error('Unknown STX component: ' + tag);
1062
- const values = Object.fromEntries(Object.entries(definition.properties).map(([name, property]) => [name, property.default]));
1063
- Object.assign(values, props);
1064
- let template = definition.template
1065
- .replace(new RegExp(${n}, 'g'), (_match, expression) => String(valueAt(values, expression) ?? ''))
1066
- .replace(new RegExp(${r}, 'g'), (_match, expression) => escapeHTML(valueAt(values, expression)))
1067
- .replace(new RegExp(${i}, 'gi'), (_match, name) => String(slots[name || 'default'] ?? ''));
1068
- const attributes = Object.entries(definition.properties).flatMap(([name, property]) => {
1069
- if (property.attribute === false || !(name in props)) return [];
1070
- const attribute = property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase());
1071
- const value = props[name];
1072
- if (value == null || value === false) return [];
1073
- if (value === true) return [attribute];
1074
- const serialized = typeof value === 'object' ? JSON.stringify(value) : value;
1075
- return [attribute + '=\\"' + escapeHTML(serialized) + '\\"'];
1076
- }).join(' ');
1077
- if (definition.shadowMode) {
1078
- template = '<template shadowrootmode="' + definition.shadowMode + '">' +
1079
- (definition.styles ? '<style>' + definition.styles + '</style>' : '') + template + '</template>' +
1080
- String(slots.default ?? '');
1081
- }
1082
- return '<' + tag + (attributes ? ' ' + attributes : '') + '>' + template + '</' + tag + '>';
1083
- }
1084
-
1085
- ${l}
1086
- `}async function ul(e){let n=rt.resolve(e.inputDir),r=rt.resolve(e.outputDir);if(!(await ea(n).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${n}`);let a=e.components?.length?e.components:(await Du(n)).map((U)=>({file:U}));if(!a.length)throw Error(`No .stx components found in ${n}`);let l=await Promise.all(a.map((U)=>Zu(n,U,e)));l.sort((U,H)=>U.tag.localeCompare(H.tag));let u=l.filter((U,H)=>l.findIndex((re)=>re.tag===U.tag)!==H);if(u.length)throw Error(`Duplicate custom-element tag: ${u[0].tag}`);let f=l.filter((U,H)=>l.findIndex((re)=>re.name===U.name)!==H);if(f.length)throw Error(`Duplicate component class name: ${f[0].name}`);await Qo(r,{recursive:!0});let v=[],S=async(U,H)=>{let re=rt.join(r,U);if(await Qo(rt.dirname(re),{recursive:!0}),await Tu(re,typeof H==="string"&&!H.endsWith(`
1087
- `)?`${H}
1088
- `:H),!v.includes(re))v.push(re);return re},I=l.some((U)=>U.scope.apis.length),j=import.meta.url.endsWith(".ts")?".ts":".js",L=new URL(`./signals-api${j}`,import.meta.url).pathname;if(I)await S("signals.js",`export * from ${JSON.stringify(L)};`);await S("runtime.js",sa(I));for(let U of l){if(await S(`${U.tag}.js`,xr(U)),e.declarations!==!1)await S(`${U.tag}.d.ts`,Ju(U));if(e.css!==!1&&U.styles){let H=U.shadowMode?U.styles:ra(U);await S(`${U.tag}.css`,e.minify?ia(H):H)}}let M=new Bun.Transpiler({loader:"ts"});if(I||l.some((U)=>U.scope.imports.length||M.scanImports(xr(U)).some((H)=>H.kind==="dynamic-import"))){let U=l.map((we)=>rt.join(r,`${we.tag}.js`)),H=new Map(await Promise.all(U.map(async(we,fe)=>[await Au(we),l[fe]])));for(let[we,fe]of U.entries())H.set(fe,l[we]);let re=new Map(l.map((we)=>[rt.join(rt.dirname(we.sourcePath),`.stx-library-${we.tag}.ts`),we])),ce=rt.join(r,"runtime.js"),le=rt.join(r,"signals.js"),pe=rt.join(n,".stx-library-runtime.ts"),Re=rt.join(n,".stx-library-signals.ts");if(U.push(ce),I)U.push(le);let Ae=await Bun.build({entrypoints:U,outdir:r,root:r,target:"browser",format:"esm",splitting:!0,naming:{entry:"[name].js",chunk:"chunks/[name]-[hash].js"},minify:!1,loader:{".js":"ts"},plugins:[{name:"stx-element-runtime",setup(we){we.onResolve({filter:/.*/},(fe)=>{if(fe.path==="bun"||fe.path.startsWith("bun:")||fe.path.startsWith("node:")||Ou.has(fe.path))throw Error(`Server-only import ${JSON.stringify(fe.path)} is not available in a browser component (${fe.importer})`);let We=H.get(fe.path);if(!fe.importer&&We)return{path:rt.join(rt.dirname(We.sourcePath),`.stx-library-${We.tag}.ts`)};if(fe.path===ce)return{path:pe};if(fe.path===le||fe.importer===pe&&fe.path==="./signals.js")return{path:Re};if(/^(?:@stacksjs\/stx|stx)\/signals-api(?:\.[jt]s)?$/.test(fe.path))return{path:L}}),we.onLoad({filter:/\.ts$/},(fe)=>{if(fe.path===pe)return{contents:sa(I),loader:"ts"};if(fe.path===Re)return{contents:`export * from ${JSON.stringify(L)};`,loader:"ts"};let We=re.get(fe.path);if(We)return{contents:xr(We,ce),loader:"ts"}})}}]}).catch((we)=>{let fe=(we instanceof AggregateError?we.errors:[we]).map(String).join(`
1089
- `);throw Error(`Failed to bundle browser component imports
1090
- ${fe}`)});if(!Ae.success)throw Error(`Failed to bundle component imports
1091
- ${Ae.logs.map(String).join(`
1092
- `)}`);for(let we of Ae.outputs)await S(rt.relative(r,we.path),new Uint8Array(await we.arrayBuffer()))}let V=l.map((U)=>`export { ${U.name}, default as ${U.name}Element } from './${U.tag}.js';`).join(`
1093
- `);if(await S("index.js",V),await S("ssr.js",Yu(l)),e.declarations!==!1)await S("index.d.ts",l.map((U)=>`export * from './${U.tag}.js'`).join(`
1094
- `)),await S("custom-elements.d.ts",Xu(l)),await S("ssr.d.ts",`${l.map((U)=>`export declare const render${U.name}: (props?: ${U.name}Props, slots?: Record<string, string>) => string`).join(`
1095
- `)}
1096
- export declare function renderComponent(tag: string, props?: Record<string, unknown>, slots?: Record<string, string>): string
1097
- ${l.map((U)=>`import type { ${U.name}Props } from './${U.tag}.js'`).join(`
1098
- `)}`);let W;if(e.manifest!==!1)W=await S("custom-elements.json",JSON.stringify(Gu(l),null,2));let Z;if(e.css!==!1){let U=l.filter((H)=>!H.shadowMode&&H.styles).map(ra).join(`
1099
-
1100
- `);if(U)Z=await S("bundle.css",e.minify?ia(U):U)}let q;if(e.bundle!==!1){q=rt.join(r,"bundle.js");let U;try{U=await Bun.build({entrypoints:[rt.join(r,"index.js")],outdir:r,naming:"bundle.js",target:"browser",format:"esm",minify:e.minify??!0,sourcemap:e.sourcemap||"none"})}catch(H){let re=H instanceof AggregateError?H.errors:[H],ce=re.map((le)=>String(le).trim()).filter(Boolean).join(`
1101
- `);throw AggregateError(re,`Failed to bundle component library${ce?`
1102
- ${ce}`:""}`)}if(!U.success){let H=U.logs.map((re)=>String(re).trim()).filter(Boolean).join(`
1103
- `);throw AggregateError(U.logs,`Failed to bundle component library${H?`
1104
- ${H}`:""}`)}if(v.push(q),e.sourcemap==="external")v.push(`${q}.map`)}let X=await Promise.all(v.map(async(U)=>(await ea(U)).size));return{components:l.map((U)=>({name:U.name,tag:U.tag,source:U.sourcePath,module:rt.join(r,`${U.tag}.js`),styles:U.styles,shadowMode:U.shadowMode})),files:v,manifest:W,bundle:q,cssBundle:Z,totalBytes:X.reduce((U,H)=>U+H,0)}}var Qu=new Set(ht);function qt(e){let n=Qt(e),r=n.find((j)=>j.name==="InheritedContext");if(!r)return;let i=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(t(r.text).trim()),a=t(e),l=h(a).depths,u=[...a.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((j)=>l[j.index]===0)?.index??0,f=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),v=t(f),S=h(v).depths,I=[...v.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((j)=>S[j.index]===0).map((j)=>j[1]);return{keys:i?I:[],types:n.map((j)=>j.text).join(`
1105
- `),offset:Math.max(0,u),...!i?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function ep(e){let n=[],r=t(e);for(let i of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(i[1]||r.slice(i.index,i.index+6)!=="import")continue;let a=i[2].trim(),l=["stx","@stacksjs/stx"].includes(i[4]);if(/^[A-Za-z_$][\w$]*$/.test(a)){n.push(a);continue}if(!a.startsWith("{")||!a.endsWith("}"))continue;for(let u of a.slice(1,-1).split(",")){if(/^\s*type\s+/.test(u))continue;let[f,v=f]=u.trim().split(/\s+as\s+/);if(v&&!(l&&Qu.has(f)))n.push(v)}}return n}function no(e){let n=qt(e);if(!n||n.unsupported)return"";let r=new Set(ye(e));return n.keys.filter((i)=>!r.has(i)).map((i)=>`declare const ${i}: InheritedContext[${JSON.stringify(i)}];`).join(`
1106
- `)}function pa(e,n){let r=[$s],i=[],a=new Map,l=wt.resolve(n.filePath),u=l.split(wt.sep).lastIndexOf("views"),f=u>=0?l.split(wt.sep).slice(0,u).join(wt.sep):wt.dirname(l),v=wt.resolve(n.partialsDir||wt.join(f,"partials")),S=wt.resolve(n.layoutsDir||wt.join(f,"views/layouts"));if([v,S].some((Z)=>l===Z||l.startsWith(Z+wt.sep)))return{declarations:"",checks:i,dependencies:a};let I=(Z)=>n.readTemplate?.(Z)??(ua.existsSync(Z)?ua.readFileSync(Z,"utf8"):void 0),j=0,L=!1,M=[];function V(Z,q){let X=e.slice(0,Z).split(`
1107
- `).length,U=Z-e.lastIndexOf(`
1108
- `,Z-1),H={code:e.slice(Z,e.indexOf(`
1109
- `,Z)<0?e.length:e.indexOf(`
1110
- `,Z)),line:X,column:U,kind:"directive",offset:Z,anchor:!0};i.push({expression:H,statement:{text:`;${q}`,prefixLength:1}})}function W(Z,q,X,U,H,re){let ce=`__StxInherited${j++}`;while((e+Z+[...a.values()].join("")).includes(ce))ce+="_";let le=_e(Z).filter((Ve)=>Ve.kind==="server").map((Ve)=>Ve.code).join(`
1111
- `),pe=`${ce}ParentValue`,Re=`${ce}ParentType`;r.push(`type ${Re} = ${X};`);let Ae=vr(Is(le,wt.dirname(q)),ce);r.push(...Ae.imports);let we=qt(le);if(we&&H!==void 0){L=!0;let Ve=Ae.imports.length?Ae.aliases.join(`
1112
- `):"",lt=Es(`${Ve}
1113
- ${we.types}
1114
- const __contract = defineProps<InheritedContext>();`,`${ce}Contract`);r.push(lt.declarations),r.push(`declare const ${ce}Input: ${Re};`),V(H,we.unsupported?`({})[${JSON.stringify(we.unsupported)}];`:`${ce}Input satisfies ${lt.props};`)}let fe=[...new Set([...ye(le),...ep(le)])],We=[...new Set([...U,...we?.keys||[]])].filter((Ve)=>!fe.includes(Ve)),Fe=we?`${Re} & ${ce}Contract.__StxProps`:Re,it=$n(Ae.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),ot=[],At=gn(Z),St=/@(include|extends|layout)\s*\(/g,at;while(at=St.exec(At)){let Ve=Kn(At,St.lastIndex-1);if(!Ve)continue;St.lastIndex=Ve.end;let lt=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(Ve.expression);if(!lt){M.push({offset:H??at.index,message:`Inherited context cannot be checked across dynamic @${at[1]}`});continue}let ut=lt[2],De=at[1];if(De!=="include"&&lt[3])M.push({offset:H??at.index,message:`Inherited context cannot be checked for unsupported @${De} data arguments`});let Mt=De==="include"?v:S,Dt=wt.resolve(ut.startsWith(".")?wt.dirname(q):Mt,ut.endsWith(".stx")?ut:ut+".stx");if(I(Dt)===void 0){M.push({offset:H??at.index,message:`Inherited context target cannot be resolved: ${ut}`});continue}ot.push({name:`edge${ot.length}`,target:Dt,kind:De,args:De==="include"?lt[3]||"{}":"{}",offset:H??at.index})}let $t=`{ ...${pe}${fe.length?", "+fe.join(", "):""} }`;r.push(`namespace ${ce} {
1115
- ${Ae.aliases.join(`
1116
- `)}
1117
- export async function read(${pe}: ${H===void 0?"{}":Fe}) {
1118
- ${We.length?`const { ${We.join(", ")} } = ${pe};`:""}
1119
- ${it}
1120
- return { context: ${$t}${ot.map((Ve)=>`, ${Ve.name}: { ...${$t}, ...(${Ve.args}) }`).join("")} };
1121
- }
1122
- }`);for(let Ve of ot){if(re.includes(Ve.target)||re.length>=32){M.push({offset:Ve.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let lt=I(Ve.target);a.set(Ve.target,lt),W(lt,Ve.target,`Awaited<ReturnType<typeof ${ce}.read>>[${JSON.stringify(Ve.name)}]`,[...new Set([...U,...fe])],Ve.offset,[...re,Ve.target])}return ce}if(W(e,l,"{}",[],void 0,[l]),L||n.contractsKnown)for(let Z of M)V(Z.offset,`({})[${JSON.stringify(Z.message)}];`);return{declarations:L?r.join(`
1123
- `):"",checks:i,dependencies:a}}function ro(e,n){let r=Yt(e),i=yr(e);if(!i)return;let a;try{a=_r(e,"component")}catch(H){let re=i.open,ce=H instanceof Error?H.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(ce)}];`,line:e.slice(0,re).split(`
1124
- `).length,column:re-e.lastIndexOf(`
1125
- `,re-1),origin:"component"}],project:(le)=>({code:le,columns:new Map})}}let l=ee(r).filter((H)=>{let re=O(H.attrs);return kt(re)&&re.has("client")&&!re.has("server")&&!re.has("component")&&!re.has("stx:component")&&!re.has("src")}),u=l.map((H)=>e.slice(H.bodyStart,H.bodyEnd)).join(`
1126
- `),f=Ts(u,n),v=Qt(u).some((H)=>H.name==="ComponentState")||Os(u).includes("ComponentState"),S=Object.entries(a.properties||a.props||{}).map(([H,re])=>`${JSON.stringify(H)}: ${dn(re)}`).join("; "),I=[...new Set(f.map((H)=>H.name))],j=[`interface __StxMetadataProperties { ${S} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",v?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",v?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",v?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",v?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${I.map((H)=>JSON.stringify(H)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',v?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...I.map((H)=>`${JSON.stringify(H)}: typeof ${H};`),"}"].filter(Boolean).join(`
1127
- `),L=-1;for(let H of l){let re=H.bodyStart,ce=e.slice(re,H.bodyEnd),le=t(ce),pe=h(le).depths,Re=[...le.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((Ae)=>pe[Ae.index]===0)??(Os(ce).includes("ComponentState")?/\bComponentState\b/.exec(le):void 0);if(Re){L=re+Re.index;break}}let M=v&&L>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,L).split(`
1128
- `).length,column:L-e.lastIndexOf(`
1129
- `,L-1)}]:[],{start:V,code:W}=i,Z=t(W),q=h(Z).depths,X=new Map,U=!1;for(let H of W.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let re=JSON.parse(H[0].slice(0,H[0].lastIndexOf(":")).trim());if(q[H.index]===1&&["properties","props"].includes(re)){U=!0;continue}if(U&&q[H.index]===1)U=!1;if(U&&q[H.index]===2&&!X.has(re))X.set(re,V+H.index)}for(let[H,re]of Object.entries(a.properties||a.props||{})){let ce=X.get(H)??V,le=e.slice(0,ce).split(`
1130
- `).length,pe=ce-e.lastIndexOf(`
1131
- `,ce-1);if(!re||typeof re!=="object"||!["string","number","boolean","object","array"].includes(re.type))M.push({text:`({})[${JSON.stringify(`Property ${H} must declare string, number, boolean, object or array`)}];`,line:le,column:pe,origin:"component"});if(re&&re.default!==void 0)M.push({text:`const __stxDefault${M.length}: ${dn(re)} = ${JSON.stringify(re.default)};`,line:le,column:pe,origin:"component"})}return{declarations:j,checks:M,project(H){let re=new Map,ce=[],le=0;for(let pe of Ts(H,n)){if(/^\s*this\s*:/.test(pe.parameters))continue;let Re=pe.parameterOffset,Ae=`this: __StxNativeComponent${pe.parameters.trim()?", ":""}`;ce.push(H.slice(le,Re),Ae);let we=H.slice(0,Re).split(`
1132
- `).length,fe=Re-H.lastIndexOf(`
1133
- `,Re-1),We=re.get(we)||[],Fe=We.at(-1),it=fe+(Fe?Fe.generatedEnd-Fe.sourceEnd:0);We.push({sourceStart:fe,sourceEnd:fe,generatedStart:it,generatedEnd:it+Ae.length}),re.set(we,We),le=Re}return ce.push(H.slice(le)),{code:ce.join(""),columns:re}}}}function fa(e){let n=[],r=[],i=/@foreach\s*\(|@endforeach\b/g,a;while(a=i.exec(e)){if(a[0].startsWith("@endforeach")){let v=r.pop();if(v)v.end=a.index,n.push(v);continue}let l=Kn(e,i.lastIndex-1);if(!l)continue;let u=wr(l.expression),f=l.end;if(u)r.push({start:f,end:e.length,iterable:u.iterable,binding:u.key?`${u.value}, ${u.key}`:u.value});i.lastIndex=f}return n.sort((l,u)=>l.start-u.start)}function tp(e){let n=(r)=>r.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function _e(e){let n=[],r=tp(e);for(let i of ee(r)){let a=i.attrs.trim(),l=O(a),{bodyStart:u,bodyEnd:f}=i,v=e.slice(u,f);if(l.has("src")||l.has("component")||l.has("stx:component"))continue;if(!kt(l))continue;let S=l.has("server")?"server":l.has("client")?"client":"plain",I=np(e,u);n.push({kind:S,code:v,startLine:I,startColumn:sp(e,u),offset:u,attrs:a})}return n}function np(e,n){let r=1;for(let i=0;i<n&&i<e.length;i++)if(e.charCodeAt(i)===10)r++;return r}function sp(e,n){let r=e.lastIndexOf(`
1134
- `,n-1)+1;return n-r+1}function gn(e){let n=e.split(""),r=(a,l)=>{for(let u=a;u<l&&u<n.length;u++)if(n[u]!==`
1135
- `)n[u]=" "},i=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let a of i){a.lastIndex=0;let l;while((l=a.exec(e))!==null)r(l.index,l.index+l[0].length)}return n.join("")}function va(e){let n=0,r="";for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r="";continue}if(a==='"'||a==="'"||a==="`"){r=a;continue}if(a==="("||a==="["||a==="{"){n++;continue}if(a===")"||a==="]"||a==="}"){n--;continue}if(a==="|"&&n===0){if(e[i+1]==="|"){i++;continue}if(e[i-1]==="|")continue;return e.slice(0,i)}}return e}var Sa=new Set([":for","x-for","v-for"]),js=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,$r="__stx_interpolated",da="__StxElement",$a="__StxTemplateValue",rp=`type ${$a}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function ga(e){return e.replace(/\{\{[\s\S]*?\}\}/g,$r).replace(/\{!![\s\S]*?!!\}/g,$r)}function ip(e,n,r){let i=0;for(let a=n;a<e.length;a++){let l=e[a];if(l==="{"){i++;continue}if(l!=="}"&&l!=="!")continue;if(e.startsWith(r,a)&&i===0)return a;if(l==="}"&&i>0)i--}return-1}function Di(e,n,r="0"){let i=`__stxScript${r}`;while((e+n).includes(i))i+="_";let a=new Map,l=[],u=[],f=t(e),v=kr(e),S=[],I=0;for(let W=0;W<f.length;W++){let Z=f.startsWith("{{",W);if(!Z&&!f.startsWith("{!!",W))continue;let q=Z?2:3,X=Z?"}}":"!!}",U=ip(f,W+q,X);if(U<0)continue;let H=W,re=e.slice(H,U+X.length),ce=re.slice(q,-X.length);W=U+X.length-1;let le=u.length,pe=en(v,H),Re=en(v,H+(Z?2:3));u.push({code:va(ce),...Re});let Ae=`${i}_${le}`,we=re.split(`
1136
- `),fe=we[0].length;we[0]=Ae+" ".repeat(Math.max(0,fe-Ae.length));for(let ot=1;ot<we.length;ot++)we[ot]=we[ot].replace(/[^\r]/g," ");let We=a.get(pe.line)??[],Fe=We.at(-1),it=pe.column+(Fe?Fe.generatedEnd-Fe.sourceEnd:0);We.push({sourceStart:pe.column,sourceEnd:pe.column+fe,generatedStart:it,generatedEnd:it+we[0].length}),a.set(pe.line,We),S.push(e.slice(I,H),we.join(`
1137
- `)),I=H+re.length}S.push(e.slice(I));let j=S.join("");if(!u.length)return{code:j,columns:a,declarations:l};let{imports:L,aliases:M,body:V}=vr(n,i);for(let W of L)l.push({text:W});l.push({text:`namespace ${i}Scope {
1138
- ${M.join(`
1139
- `)}
1140
- export async function read() {
1141
- ${$n(V).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
1142
- return {`});for(let[W,Z]of u.entries())l.push({text:`value${W}: (`}),l.push({text:Z.code,origin:{line:Z.line,column:Z.column}}),l.push({text:"),"});l.push({text:`}
1143
- }
1144
- }`});for(let W=0;W<u.length;W++)l.push({text:`declare var ${i}_${W}: Awaited<ReturnType<typeof ${i}Scope.read>>['value${W}']`});return{code:j,columns:a,declarations:l}}function vr(e,n){let r=[],{imports:i,body:a}=ka(e),l=[],u=0;for(let f of i.split(/\n(?=import\b)/)){if(!f.trim())continue;let v=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(f);if(!v){r.push(f);continue}let S=`${n}Module${u++}`;r.push(`import * as ${S} from ${v[2]}`);let I=v[1],j=/\{([\s\S]*?)\}/.exec(I);for(let W of j?.[1].split(",")??[]){let[Z,q=Z]=W.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(Z==="default")l.push(`const ${q} = ${S}.default; type ${q} = import(${v[2]}).default`);else if(Z)l.push(`import ${q} = ${S}.${Z}`)}let L=I.replace(/\{[\s\S]*?\}/,""),M=/\*\s+as\s+(\w+)/.exec(L);if(M)l.push(`import ${M[1]} = ${S}`);let V=/^\s*([\w$]+)/.exec(L)?.[1];if(V)l.push(`const ${V} = ${S}.default; type ${V} = import(${v[2]}).default`)}return{imports:r,aliases:l,body:a}}function Sr(e,n){let r=0;for(let i of e){if(n<i.generatedStart)break;if(n<i.generatedEnd)return i.sourceStart+Math.min(n-i.generatedStart,i.sourceEnd-i.sourceStart);r=i.sourceEnd-i.generatedEnd}return n+r}var op=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],ap=new RegExp(String.raw`^[ \t]*@(?:${op.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function $n(e){return e.replace(ap,(n)=>n.replace(/[^\n]/g," "))}var ma=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function so(e){let n=gn(e),r=[],i=kr(n),a=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,l;while((l=a.exec(n))!==null){if(l[1]||l[3])continue;let v=l[2]??l[4]??"",S=l[2]!==void 0?2:3,I=va(v);if(!I.trim())continue;let j=l.index+S+(I.length-I.trimStart().length);r.push({code:I.trim(),...en(i,j),offset:j,kind:"interpolation"})}let u=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((l=u.exec(n))!==null){let f=l.index+l[0].length-1,v=0,S=f;for(;S<n.length;S++){let M=n[S];if(M==="(")v++;else if(M===")"){if(v--,v===0)break}}if(v!==0)continue;let I=n.slice(f+1,S),j=I.trim();if(u.lastIndex=S+1,!j)continue;let L=f+1+(I.length-I.trimStart().length);r.push({code:j,...en(i,L),offset:l.index,kind:"condition"})}js.lastIndex=0;while((l=js.exec(n))!==null){let f=l[1],v=l[3]??"",S=f.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(ma.has(S)||ma.has(f))continue;if(!v.trim())continue;let I=l.index+l[0].indexOf(l[2],l[0].indexOf(f)+f.length)+1;if(Sa.has(S)){let L=v.match(/\s+(?:in|of)\s+/);if(!L||L.index===void 0)continue;let M=v.slice(L.index+L[0].length),V=L.index+L[0].length+(M.length-M.trimStart().length);r.push({code:ga(M.trim()),...en(i,I+V),offset:I+V,kind:"directive",attribute:S});continue}let j=v.length-v.trimStart().length;r.push({code:ga(v.trim()),...en(i,I+j),offset:I+j,kind:"directive",attribute:S})}return r.sort((f,v)=>f.line-v.line||f.column-v.column),r}var cp=2000;function lp(e,n){let r=0,i=Math.min(e.length,n+cp);for(let a=n;a<i;a++){let l=e[a];if(l==="(")r++;else if(l===")"){if(r--,r===0)return e.slice(n+1,a)}}return null}function up(e){let n=new Map,r=(f,v)=>{let S=f.split(/[,[\]{}()\s]+/).filter(Boolean);for(let I of S){let j=I.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(j))continue;let L=S.length===1?v:void 0,M=n.get(j);if(!M)n.set(j,{name:j,iterable:L});else if(M.iterable!==L)M.iterable=void 0}},i=/^\$?[A-Z_$][\w$]*$/i,a=(f)=>{let v=f.trim();return i.test(v)?v:void 0};for(let f of e.matchAll(/@for(?:each|else)\s*\(/g)){let v=lp(e,f.index+f[0].length-1);if(v===null)continue;let S=Wt(v);if(!S)continue;r(S.itemVar.replace(/=>/g," "),a(S.arrayExpr))}for(let f of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(f[1],f[2]==="of"?a(f[3]):void 0);for(let f of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(f[1]);let l=gn(e);js.lastIndex=0;let u;while((u=js.exec(l))!==null){let f=u[1].replace(/\..*$/,"");if(!Sa.has(f))continue;let v=u[3].match(/\s+(?:in|of)\s+/);if(!v||v.index===void 0)continue;r(u[3].slice(0,v.index),a(u[3].slice(v.index+v[0].length)))}for(let f of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let v of f[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(v[1]);return[...n.values()].sort((f,v)=>f.name.localeCompare(v.name))}function ye(e){return Hl(e)}var Er=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],pp={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string",$native:"declare var $native: boolean"};function dl(e=new Set){return[...Er.filter((n)=>!e.has(n)).map((n)=>`declare var ${n}: any`),...Object.entries(pp).filter(([n])=>!e.has(n)).map(([,n])=>n)].join(`
1145
- `)}function pl(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function Ea(e){let n=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,r,i=!1,a=new Set,l=t(e);while((r=n.exec(l))!==null){i=!0;for(let u of fp(r[1])){let f=u.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(f))a.add(f)}}return i?[...a]:null}function fp(e){let n=[],r=0,i="";for(let a of e){if(a===","&&r===0){n.push(i),i="";continue}if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;i+=a}return n.push(i),n.filter((a)=>a.trim().length>0)}function ka(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],i=e.replace(n,(a)=>(r.push(a.trim()),a.split(`
1146
- `).map(()=>"").join(`
1147
- `)));return{imports:r.join(`
1148
- `),body:i}}function Qt(e){let n=t(e),r=Array(n.length),i=0;for(let f=0;f<n.length;f++){let v=n[f];if(v==="}"||v===")"||v==="]")i=Math.max(0,i-1);if(r[f]=i,v==="{"||v==="("||v==="[")i++}let a=[],l=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,u;while((u=l.exec(n))!==null){if(r[u.index]!==0)continue;let f=u[1],v=u[2],S;if(f==="interface"){let I=n.indexOf("{",u.index);if(I===-1)continue;let j=0;S=-1;for(let L=I;L<n.length;L++)if(n[L]==="{")j++;else if(n[L]==="}"&&--j===0){S=L+1;break}if(S===-1)continue}else{let I=0;S=n.length;for(let j=n.indexOf("=",u.index)+1;j<n.length;j++){let L=n[j];if(L==="{"||L==="["||L==="("||L==="<")I++;else if(L==="}"||L==="]"||L===")"||L===">")I--;else if(I<=0&&(L===";"||L===`
1149
- `&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,j-40),j)))){S=L===";"?j+1:j;break}}}a.push({name:v,text:e.slice(u.index,S).replace(/^[ \t]*export[ \t]+/,"")}),l.lastIndex=S}return a}function dp(e){let n=t(e),r=[],i=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,a,l=0,u=0;while((a=i.exec(n))!==null){for(;u<a.index;u++){let S=n[u];if(S==="{"||S==="("||S==="[")l++;else if(S==="}"||S===")"||S==="]")l=Math.max(0,l-1)}if(l!==0)continue;let f=0,v=n.length;for(let S=a.index+a[0].length;S<n.length;S++){let I=n[S];if(I==="{"||I==="("||I==="[")f++;else if(I==="}"||I===")"||I==="]")f--;else if(f<=0&&(I===";"||I===`
1150
- `)){v=I===";"?S+1:S;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(a.index,v)))r.push(e.slice(a.index,v).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function Li(e){let n=e.filter((a)=>a.kind==="server").map((a)=>a.code).join(`
1151
- `);if(/\bdefineProps\s*(?:<|\()/.test(t(n)))return n;let r=Ca(n),i=e.filter((a)=>a.kind!=="server").flatMap((a)=>{let l=dp(a.code);if(!l.length)return[];return[...Qt(a.code).filter((u)=>!r.has(u.name)).map((u)=>u.text),...l]});return[n,...i].filter(Boolean).join(`
1152
- `)}function Ca(e){return new Set(Qt(e).map((n)=>n.name))}function fl(e,n=""){let r=Ea(e),i=Ca(n),a=Qt(e).filter((S)=>!i.has(S.name)).map((S)=>S.text);if(!r){let S=ye(e).filter((I)=>!Ut(n,I));if(S.length===0&&a.length===0)return"";return["",`// ${hp}`,...a,...S.map((I)=>`declare var ${I}: any`)].join(`
1153
- `)}if(r.length===0)return a.length>0?["",`// ${xa}`,...a].join(`
1154
- `):"";let{imports:l,body:u}=ka(e),f=u.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),v=["",`// ${xa}`];if(l)v.push(l);return v.push(...a),v.push(`async function ${ba}() {`,f,` return { ${r.join(", ")} }`,"}",`type ${ya} = Awaited<ReturnType<typeof ${ba}>>`,...r.map((S)=>`declare var ${S}: ${ya}[${JSON.stringify(S)}]`)),v.join(`
1155
- `)}function Ra(e){let n=t(e),r=n.split(""),i=[],a=0,l=0;for(let f=0;f<r.length;f++){let v=r[f];if(v===`
1156
- `)l=f+1;if(v==="{"||v==="("||v==="["){if(a===0&&v!=="("&&gp.test(n.slice(l,f))){let S=Aa(n,f);if(S!==-1)i.push(...Ta(n.slice(f,S+1)))}a++;continue}if(v==="}"||v===")"||v==="]"){a=Math.max(0,a-1);continue}if(a>0&&v!==`
1157
- `)r[f]=" "}let u=ye(r.join(""));return i.length===0?u:[...new Set([...u,...i])].sort()}var gp=/^\s*(?:export\s+)?(?:const|let|var)\s*$/;function Aa(e,n){let r=0;for(let i=n;i<e.length;i++){let a=e[i];if(a==="{"||a==="("||a==="[")r++;else if(a==="}"||a===")"||a==="]")r--;if(r===0)return i}return-1}function mp(e){let n=[],r=0,i=0;for(let a=0;a<e.length;a++){let l=e[a];if(l==="{"||l==="("||l==="[")r++;else if(l==="}"||l===")"||l==="]")r--;else if(l===","&&r===0)n.push(e.slice(i,a)),i=a+1}return n.push(e.slice(i)),n}function ha(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="{"||i==="("||i==="[")n++;else if(i==="}"||i===")"||i==="]")n--;else if(n===0&&(i===":"||i==="="))return{index:r,char:i}}return null}function Ta(e){let n=[],r=(a)=>{let l=a.trim().replace(/^\.\.\./,"").trim();if(l.startsWith("{")||l.startsWith("[")){let f=Aa(l,0);if(f!==-1)n.push(...Ta(l.slice(0,f+1)));return}let u=ha(l);if(u)l=l.slice(0,u.index).trim();if(/^[A-Z_$][\w$]*$/i.test(l))n.push(l)},i=e.slice(1,-1);for(let a of mp(i)){if(!a.trim())continue;if(e[0]==="["){r(a);continue}let l=ha(a);r(l?.char===":"?a.slice(l.index+1):a)}return n}function gl(e,n){if(Ea(e)!==null)return[];let r=Ra(e),i=je(n,new Set(r)),a=new Set(C);return r.filter((l)=>{if(a.has(l))return!1;if(Ut(n,l))return!1;return i.has(l)})}var xa="stx: types for the declared client payload (#1868)",hp="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",ba="__stxServerScope",ya="__StxClientPayload";var _a=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];var xp=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function bp(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let i of e){let a=t(i),{depths:l,balanced:u}=h(a);if(!u)continue;let f=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let v of a.matchAll(f)){let S=v.index??0;if(l[S+v[1].length]!==0)continue;let I=v[2],j=S+v[0].length-v[3].length,L=i.slice(j,S+v[0].length).trim().replace(/;$/,"").trim(),M=v[3],V=r.test(M)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(M)&&!/[,+\-*/%&|?:=]$/.test(L)&&h(M).balanced;n.set(I,n.has(I)||!V?null:L)}}return new Map([...n].filter((i)=>i[1]!==null))}function Ia(e,n,r=0,i=new Set){if(n.size===0||r>=5)return e;let a=t(e),l="",u=0;for(let f of a.matchAll(/[A-Za-z_$][\w$]*/g)){let v=f.index??0,S=f[0],I=n.get(S);if(!I||i.has(S))continue;let j=a.slice(0,v).trimEnd(),L=a.slice(v+S.length).trimStart();if(j.endsWith(".")||/^:(?!:)/.test(L)&&/[{,]$/.test(j))continue;if(v>0&&/[\w$]/.test(a[v-1]))continue;l+=`${e.slice(u,v)}(${Ia(I,n,r+1,new Set([...i,S]))})`,u=v+S.length}return l+e.slice(u)}function yp(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,i=[],a;while((a=r.exec(e))!==null){if(a.index>n)break;let l=a[1];if(a.index===n){if(l==="elseif"){let f=i[i.length-1];if(f?.current)f.seen.push(f.current);if(f)f.current=null}break}if(l==="endif"||l==="endunless"){i.pop();continue}let u="";if(a[2]==="("){let f=0,v=a.index+a[0].length-1,S=v+1;for(;v<e.length;v++){let I=e[v];if(I==="(")f++;else if(I===")"){if(f--,f===0)break}}u=e.slice(S,v).trim(),r.lastIndex=v+1}if(l==="if")i.push({seen:[],current:u});else if(l==="unless")i.push({seen:[],current:`!(${u})`});else if(l==="elseif"||l==="else"){let f=i[i.length-1];if(!f)continue;if(f.current)f.seen.push(f.current);f.current=l==="elseif"?u:null}}return i.flatMap((l)=>[...l.seen.map((u)=>`!(${u})`),...l.current?[l.current]:[]]).filter(Boolean)}function _p(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(xp.test(n))return null;let i=";(($event: any): void => { ";return{text:`${i}${n} });`,prefixLength:i.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var wp=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Is(e,n){return oo(e,n).code}function oo(e,n){let r=new Map;if(!n)return{code:e,columns:r};let i=kr(e),a=[],l=0;for(let u of e.matchAll(wp)){let f=u.index,[v,S,I,j]=u,L=wa.resolve(n,j).replace(/\\/g,"/"),M=`${S}${I}${L}${I}`;if(a.push(e.slice(l,f),M),l=f+v.length,v.includes(`
1158
- `))continue;let V=en(i,f),W=r.get(V.line)??[],Z=W.at(-1),q=V.column+(Z?Z.generatedEnd-Z.sourceEnd:0);W.push({sourceStart:V.column,sourceEnd:V.column+v.length,generatedStart:q,generatedEnd:q+M.length}),r.set(V.line,W)}return a.push(e.slice(l)),{code:a.join(""),columns:r}}function vp(e,n,r){let i=Sr(e.importColumns?.get(n)??[],r);return Sr(e.scriptColumns?.get(n)??[],Sr(e.componentColumns?.get(n)??[],i))}function ji(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function Os(e){let n=new Set,r=t(e);for(let i of r.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let a=i[1],l=/\{([^}]*)\}/.exec(a);for(let S of l?.[1].split(",")??[]){let I=S.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(I&&/^[A-Z_$][\w$]*$/i.test(I))n.add(I)}let u=a.replace(/\{[^}]*\}/,""),f=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(u);if(f)n.add(f[1]);let v=/^\s*([A-Z_$][\w$]*)/i.exec(u);if(v&&v[1]!=="type")n.add(v[1])}return[...n].sort()}function Bi(e,n={}){let r=_e(e),i=n.scriptKinds?r.filter((H)=>n.scriptKinds.includes(H.kind)):r,a=ro(e,n.componentMethodValidator),l=n.filePath&&n.templateExpressions!==!1?pa(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,u=new Map,f=e.split(`
1159
- `),v=Array.from({length:f.length},()=>""),S=new Map,I=new Map,j=new Map,L=[],M=Li(r),V=n.filePath&&n.templateExpressions!==!1?Xo(e,gn(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(H,re)=>_e(H).map((ce)=>Is(ce.code,wa.dirname(re))).join(`
1160
- `)}):void 0,W=new Set,Z=[];for(let[H,re]of i.entries()){let ce=Di(ji(re)+re.code,M,String(H));for(let[we,fe]of ce.columns)I.set(re.startLine+we-1,fe);for(let we of ce.declarations)L.push({text:Is(we.text,n.originDir??""),origin:we.origin?{...we.origin,line:we.origin.line+re.startLine-1}:void 0});let le=re.kind==="client"&&a?a.project(ce.code):void 0;for(let[we,fe]of le?.columns??[])u.set(re.startLine+we-1,fe);let pe=$n(le?.code??ce.code),Re=oo(pe,n.originDir??"");for(let[we,fe]of Re.columns)j.set(re.startLine+we-1,fe);let Ae=Re.code.split(`
1161
- `);Ae.forEach((we,fe)=>{let We=re.startLine-1+fe;if(We<v.length)v[We]=we,W.add(We)}),Z.push(re.startLine-1+Ae.length-1)}for(let H of Z){let re=v[H]?.trim()===""?H:H+1;if(re<v.length&&v[re].trim()===""&&(re===H||!W.has(re)))v[re]=";"}let q=(H,re)=>{for(let[ce,le]of H.split(`
1162
- `).entries())if(v.push(le),re)S.set(v.length,ce===0?re:{...re,line:re.line+ce,column:1,prefixLength:0})},X=no(i.filter((H)=>H.kind==="server").map((H)=>H.code).join(`
1163
- `));if(X)q(X);for(let H of i.filter((re)=>re.kind==="server")){let re=qt(H.code);if(!re?.unsupported)continue;let ce=H.code.slice(0,re.offset),le=H.startLine+ce.split(`
1164
- `).length-1,pe=re.offset-H.code.lastIndexOf(`
1165
- `,re.offset-1)+(le===H.startLine?(H.startColumn??1)-1:0);q(`;({})[${JSON.stringify(re.unsupported)}];`,{line:le,column:pe,anchor:!0})}if(l?.declarations)q(l.declarations);for(let H of L)q(H.text,H.origin);if(a){if(q(a.declarations),n.nativeChecks!==!1)for(let H of a.checks)q(H.text,{line:H.line,column:H.column,diagnosticOrigin:H.origin,anchor:!0})}if(n.globals!==!1){q("");let H=new Set([...i.flatMap((pe)=>ye(pe.code)),...i.flatMap((pe)=>Os(pe.code))]),re=(pe)=>{if(!H.has(pe)&&!n.declaredGlobals?.includes(pe))q(`declare var ${pe}: any`)};if(n.runtimeGlobals!==!1){if(!H.has("window"))q("declare var window: any");for(let pe of C)re(pe)}let ce=[...new Set([...Er,...Oe,..._a])].filter((pe)=>!n.declaredGlobals?.includes(pe)&&(n.runtimeGlobals!==!1||!C.includes(pe)));if(n.contextScope==="global"){q("declare global {");for(let pe of ce)q(` var ${pe}: any`);q("}")}else{for(let pe of Er)re(pe);for(let pe of Oe)re(pe);for(let pe of _a)re(pe)}q(`declare var ${$r}: any`);let le=new Set(i.flatMap((pe)=>ye(pe.code)));q(`type ${da}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let pe of a?[]:up(e)){if(le.has(pe.name))continue;let Re=pe.iterable&&le.has(pe.iterable)?`${da}<typeof ${pe.iterable}>`:"any";q(`declare var ${pe.name}: ${Re}`)}}if(n.templateExpressions!==!1){if(V?.declarations)for(let re of V.declarations.split(`
1166
- `))q(re);let H=so(e).map((re)=>{let ce=V?.events.get(re.offset??-1);if(ce){re.anchor=!0;let le=re.code.trim(),pe=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(le),Re=pe?`void ((${pe[2]}) satisfies __StxAssignedValue<typeof ${pe[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(le)?`${le} satisfies (($event: ${ce}) => unknown)`:le,Ae=`;(($event: ${ce}): void => { `;return{expression:re,statement:{text:`${Ae}${Re} });`,prefixLength:Ae.length}}}return{expression:re,statement:_p(re)}}).filter((re)=>re.statement!==null);if(H.push(...V?.checks||[],...l?.checks||[]),H.length>0){let re=gn(e),ce=vs(re),le=a?fa(re):[];if(a)q("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let pe=bp(i.map((fe)=>fe.code)),Ae=[...new Set(i.flatMap((fe)=>ye(fe.code)))].filter((fe)=>/^[A-Z_$][\w$]*$/i.test(fe)),we=0;if(a)q("function __stxNativeTemplate(this: __StxNativeComponent) {");if(Ae.length>0){q(rp);for(let fe of Ae)q(`function __StxRead_${fe}() { return ${fe} }`),q(`type __StxT_${fe} = ${$a}<ReturnType<typeof __StxRead_${fe}>>`);q(`;((${Ae.map((fe)=>`${fe}: __StxT_${fe}`).join(", ")}) => {`),we=1}for(let{expression:fe,statement:We}of H){let Fe=" ".repeat(we),it=fe.offset===void 0?[]:ce.filter((De)=>fe.offset>=De.start&&fe.offset<De.end),ot=fe.offset===void 0?[]:le.filter((De)=>fe.offset>=De.start&&fe.offset<De.end),At=ot.map((De)=>`;__stxEach(${De.iterable}, (${De.binding}) => { `).join(""),St=" });".repeat(ot.length),at=At+it.map((De)=>`;((${De.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),$t=" });".repeat(it.length)+St,Ve=fe.offset===void 0?[]:yp(re,fe.offset),lt=Ve.length>0?`${Ve.map((De)=>`if (${Ia(De,pe)}) `).join("")}{ `:"",ut=Ve.length>0?" }":"";q(Fe+at+lt+We.text+ut+$t,{line:fe.line,column:fe.column,expression:fe,prefixLength:We.prefixLength+Fe.length+at.length+lt.length,guardPrefixLength:Fe.length+at.length+lt.length})}if(we>0)q("});");if(a)q("}")}}let U=!1;if(n.reference&&v[0]!==void 0&&v[0].trim()==="")v[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,U=!0;return q("export {}"),{text:v.join(`
1167
- `),lineMap:S,sourceLineCount:f.length,componentDependencies:new Map([...V?.dependencies??[],...l?.dependencies??[]]),referenced:U,scriptColumns:I,importColumns:j,componentColumns:u}}function kr(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function en(e,n){let r=0,i=e.length-1;while(r<i){let a=Math.ceil((r+i)/2);if(e[a]<=n)r=a;else i=a-1}return{line:r+1,column:n-e[r]+1}}function ml(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Fi(e,n,r){let i=e.lineMap.get(n);if(!i)return n<=e.sourceLineCount?{line:n,column:vp(e,n,r)}:null;let a=i.anchor||i.expression?.anchor||i.diagnosticOrigin==="component"?0:Math.max(0,r-1-(i.prefixLength??0));return{line:i.line,column:i.column+a,expression:i.expression,diagnosticOrigin:i.diagnosticOrigin,inGuard:r<=(i.guardPrefixLength??0)}}function io(e){let n=new Set;for(let r of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let i=r[1];if(!/\bclient\b/.test(i)||/\bserver\b/.test(i))continue;for(let a of Ra(r[2]))n.add(a);for(let a of r[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])n.add(a[1]);if(a[3])n.add(a[3]);for(let l of(a[2]??"").split(",")){let u=l.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(u))n.add(u)}}}return n}var Cr=k(256),Sp=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/(?:\bwindow\.)?localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables \u2014 or, where this must run before first paint and the runtime does not exist yet, the colorMode config for a light/dark theme, or @appearanceBootstrap when there is a second appearance axis"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}],Oa=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function $p(e){let n=Array.from(e,(a)=>a===`
1168
- `?`
1169
- `:" "),r=0,i="";while(r<e.length){let a=e[r],l=e[r+1];if(i){if(a==="\\"){r+=2;continue}if(a===i)i="";r++;continue}if(a==='"'||a==="'"||a==="`"){i=a,r++;continue}if(a==="/"&&l==="/"){while(r<e.length&&e[r]!==`
1170
- `)n[r]=e[r],r++;continue}if(a==="/"&&l==="*"){let u=e.indexOf("*/",r+2),f=u===-1?e.length:u+2;for(;r<f;r++)n[r]=e[r];continue}if(a==="{"&&l==="{"&&e.slice(r,r+4)==="{{--"){let u=e.indexOf("--}}",r+4),f=u===-1?e.length:u+4;for(;r<f;r++)n[r]=e[r];continue}r++}return n.join("")}function Ep(e){let n=new Map,r=$p(e).split(`
1171
- `),i=e.split(`
1172
- `);return r.forEach((a,l)=>{Oa.lastIndex=0;for(let u of a.matchAll(Oa)){let f=u[1]==="-next-line",v=(i[l]??"").slice(0,u.index).trim(),S=f||v===""?l+2:l+1,j=(u[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),L=j.filter((V)=>/\w/.test(V));if(j.length>0&&L.length===0)continue;let M=n.get(S);if(M&&M.size===0)continue;if(L.length===0){n.set(S,new Set);continue}if(M)L.forEach((V)=>M.add(V));else n.set(S,new Set(L))}}),n}function kp(e,n,r){let i=e.get(n);if(!i)return!1;if(i.size===0)return!0;return[...i].some((a)=>r.includes(a))}function Ke(e,n,r,i){let a=typeof r==="boolean"?{enabled:r,failOnViolation:r}:r??{enabled:!1};if(!a.enabled)return;let l=E(e,n,i,JSON.stringify(a)),u=Cr.get(l);if(u!==void 0){if(u&&a.failOnViolation)throw new te(u,i??n);return}let f=a.allowPatterns??[],v=Ep(e),S=[],I=t(e.replace(/\{\{--[\s\S]*?--\}\}/g,(V)=>V.replace(/[^\n]/g," ")));for(let{pattern:V,message:W,suggestion:Z}of Sp){if(f.some((X)=>/\w/.test(X)&&W.includes(X)))continue;V.lastIndex=0;let q=I.match(V);if(q&&q.length>0){let X=I.split(`
1173
- `),U=e.split(`
1174
- `),H=[];if(X.forEach((pe,Re)=>{if(V.lastIndex=0,V.test(pe)&&!kp(v,Re+1,W))H.push(Re+1)}),H.length===0&&X.some((pe)=>(V.lastIndex=0,V.test(pe))))continue;let re=H.length>0?` (script line${H.length>1?"s":""} ${H.join(", ")})`:"",ce=H.slice(0,3).map((pe)=>` ${pe} | ${(U[pe-1]??"").trim().slice(0,100)}`).join(`
1175
- `),le=ce?`
1176
- ${ce}`:"";S.push(` \u2717 ${W}${re}
1177
- \u2192 ${Z}${le}`)}}if(S.length===0){Cr.set(l,"");return}let j=(V)=>{let W=`${process.cwd()}/`;return V.startsWith(W)?V.slice(W.length):V},M=`[STX] DOM API violation in ${i&&i!==n?`${j(i)} (composed into ${j(n)})`:j(n)}:
1178
- ${S.join(`
1179
- `)}
1180
- Tip: prefer useRef(), navigate(), and composables for component code`;if(Cr.set(l,M),console.warn(M),a.failOnViolation)throw new te(M,i??n)}var Cp=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],Rp=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],Ap=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}];function Vg(e){let n=[],r=[];return Tp(e,n),Ip(e,n,r),Op(e,r),jp(e,n),{valid:n.length===0,errors:n,warnings:r}}function Tp(e,n){let r=(e.match(/\{\{/g)||[]).length,i=(e.match(/\}\}/g)||[]).length;if(r!==i)n.push({type:"expression",message:`Unclosed expression brackets: found ${r} opening '{{' and ${i} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function Ip(e,n,r){for(let i of Cp){let a=new RegExp(`${i.open}(?:\\s|\\()`,"g"),l=new RegExp(i.close,"g"),u=(e.match(a)||[]).length,f=(e.match(l)||[]).length;if(i.altClose){let v=new RegExp(i.altClose,"g");f+=(e.match(v)||[]).length}if(u>f)n.push({type:"directive",message:`Unclosed @${i.name} directive: found ${u} opening and ${f} closing`,suggestion:`Add ${u-f} missing ${i.close} tag(s)`});else if(f>u)r.push({type:"directive",message:`Extra ${i.close} found: ${f-u} more closing than opening`,suggestion:`Check for orphaned ${i.close} tags`})}}function Op(e,n){for(let r of Rp)if(r.pattern.test(e))n.push({type:"syntax",message:r.message,suggestion:r.suggestion})}function jp(e,n){for(let r of Ap)if(r.pattern.test(e))n.push({type:"expression",message:`Security warning: ${r.message}`,suggestion:"Remove dangerous code from template expressions"})}function Wg(e,n){let r=e.slice(0,n).split(`
1181
- `);return{line:r.length,column:r[r.length-1].length+1}}function qg(e,n,r){let i=[];switch(e){case"if":case"elseif":case"unless":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a condition`,suggestion:`Use @${e}(condition)`});break;case"foreach":if(r.length===0||!r[0].includes(" as "))i.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(r.length===0)i.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(r.length===0)i.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(r.length===0)i.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a path`,suggestion:`Use @${e}('path/to/template')`});break}return i}function Kg(e){return/@[a-z]+/i.test(e)||/\{\{/.test(e)}function Xg(e){let n=e.matchAll(/@([a-z]+)/gi),r=new Set;for(let i of n){let a=i[1].toLowerCase();if(!a.startsWith("end"))r.add(a)}return Array.from(r)}function ja(e,n,r){let i=/^<script\b([^>]*)>/i.exec(e);if(!i||!/(?:^|\s)src\s*=/i.test(i[1]??""))return null;return P(i[0],n,r)+e.slice(i[0].length)}var qn=new T(500),Tr=new Map;function Pa(e){try{let n=Ns.statSync(e);return`${n.size}:${n.mtimeMs}`}catch{return""}}var Ms=new T(1000),Ir=new Map,Or=new T(2000),Pr=new T(500),Va=33554432,Wr=Va;function Pp(e){let n=e.componentRenderCacheBytes;if(typeof n!=="number"||n<0||n===Wr)return;Wr=n,Ds.setMaxBytes(n)}var Ds=new T(2000,{maxBytes:Va,sizeOf:(e)=>e.output.length});function Mp(e){let n=new WeakSet;try{let r=(i)=>{if(i===void 0)return{__stxType:"undefined"};if(typeof i==="bigint")return{__stxType:"bigint",value:i.toString()};if(typeof i==="function"||typeof i==="symbol")throw TypeError("Non-serializable component input");if(i===null||typeof i!=="object")return i;if(n.has(i))throw TypeError("Circular component input");n.add(i);try{if(i instanceof Date)return{__stxType:"date",value:i.toISOString()};if(Array.isArray(i))return i.map(r);let a=Object.getPrototypeOf(i);if(a!==Object.prototype&&a!==null)throw TypeError("Non-plain component input");let l={};for(let u of Object.keys(i).sort())l[u]=r(i[u]);return l}finally{n.delete(i)}};return JSON.stringify(r(e))}catch{return null}}function Dp(e){let n={};for(let[r,i]of Object.entries(e))if(!r.startsWith("__")||r==="__stxServeContext")n[r]=i;return n}function Rr(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function po(e){let n=process.cwd(),r=`${n}\x00${e}`,i=Ma.get(r);if(i===void 0)i=Bun.hash(Ua(e,n).split(xe.sep).join("/")).toString(36).slice(0,6),Ma.set(r,i);return i}var Ma=new Map;function Ua(e,n){if(!xe.isAbsolute(e))return e;let r=(i)=>{try{return Ns.realpathSync(i)}catch{return i}};return xe.relative(r(n),r(e))}function Gg(e){return/\bjs\b/.test(e)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(e)}function Ye(e){return!Gg(e)}var Ps=new Map;function ie(e){let n;try{n=JSON.stringify(e)}catch{return new Bun.Transpiler(e)}let r=Ps.get(n);if(r)return r;if(Ps.size>=16)Ps.clear();let i=new Bun.Transpiler(e);return Ps.set(n,i),i}var Da=new WeakMap,Np=256;function Ze(e){try{let n=ie({loader:"ts",target:"browser",define:A()}),r=Da.get(n);if(!r)r=new Map,Da.set(n,r);let i=r.get(e);if(i!==void 0)return i;let a=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");a=a.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let l=[];a=a.replace(/\{!![\s\S]*?!!\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{\{[\s\S]*?\}\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{[\s\S]*?\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`});let u=n.transformSync(a);for(let f=0;f<l.length;f++)u=u.replace(`"__STX_EXPR_${f}__"`,l[f]),u=u.replace(`'__STX_EXPR_${f}__'`,l[f]);if(r.size>=Np){let f=r.keys().next();if(!f.done)r.delete(f.value)}return r.set(e,u),u}catch(n){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",n);return e}}function Lp(e){let n=[],r=new Set,i=0,a=0,l=e.length,u=(M)=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]===M){a++;return}a++}},f=()=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]==="`"){a++;return}if(e[a]==="$"&&e[a+1]==="{"){a+=2;let M=1;while(a<l&&M>0)if(e[a]==="{")M++,a++;else if(e[a]==="}")M--,a++;else if(e[a]==="'"||e[a]==='"')u(e[a]);else if(e[a]==="`")f();else a++;continue}a++}},v=()=>{if(e[a]==="/"&&e[a+1]==="/"){while(a<l&&e[a]!==`
1182
- `)a++;return!0}if(e[a]==="/"&&e[a+1]==="*"){a+=2;while(a<l-1&&!(e[a]==="*"&&e[a+1]==="/"))a++;return a+=2,!0}return!1},S=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]),I=()=>{let M=a-1;while(M>=0&&/\s/.test(e[M]))M--;if(M<0)return!0;let V=e[M];if("(,=:[!&|?{};+-*%<>~^".includes(V))return!0;if(!/[\w$]/.test(V))return!1;let W=M;while(W>0&&/[\w$]/.test(e[W-1]))W--;return S.has(e.slice(W,M+1))},j=()=>{a++;let M=!1;while(a<l&&e[a]!==`
1183
- `){let V=e[a];if(V==="\\"){a+=2;continue}if(V==="[")M=!0;else if(V==="]")M=!1;else if(V==="/"&&!M){a++;while(a<l&&/[a-z]/i.test(e[a]))a++;return}a++}},L=()=>{if(i!==0)return;let M=e.slice(a).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(M){let q=M[2].split(",").map((X)=>{let U=X.trim().split(":");return U[U.length-1].trim()});for(let X of q)if(X&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(X)&&!r.has(X))n.push(X),r.add(X);return}let V=e.slice(a).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(V){let q=V[2];if(!r.has(q))n.push(q),r.add(q);return}let W=e.slice(a).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(W){let q=W[1];if(!r.has(q))n.push(q),r.add(q);return}let Z=e.slice(a).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Z){let q=Z[1];if(!r.has(q))n.push(q),r.add(q)}};while(a<l){if(v())continue;if(e[a]==="'"||e[a]==='"'){u(e[a]);continue}if(e[a]==="`"){f();continue}if(e[a]==="/"&&I()){j();continue}if(e[a]==="{"){i++,a++;continue}if(e[a]==="}"){i--,a++;continue}if(i===0&&/[a-z]/i.test(e[a])&&(a===0||/\s|[;{}()]/.test(e[a-1])))L();a++}return n}function zp(e,n,r){for(let i of ee(e)){let a=O(i.attrs);if(["server","src","component","stx:component"].some((f)=>a.has(f))||!kt(a))continue;let l=fn(e.slice(i.bodyStart,i.bodyEnd));if(!l)continue;let u=Object.assign(Object.create(null),r);for(let[f,v]of Object.entries(l.defaults))if(u[f]===void 0)u[f]=Cs(v);for(let f of new Set([...l.propNames,...Object.keys(l.defaults)])){let v=l.localBindings[f]??(l.propBindings[f]?void 0:f);if(v)Object.defineProperty(n,v,{value:u[f],writable:!0,enumerable:!0,configurable:!0})}if(l.identifier)Object.defineProperty(n,l.identifier,{value:u,writable:!0,enumerable:!0,configurable:!0})}}var Bp=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function Jg(e,n){let r=Vt(e),i=e.slice(r).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/);if(!i)return null;let a=i[1].toLowerCase();if(!Bp.has(a))return null;let l=new RegExp(`<\\/?${a}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),u=x(e,(I,j)=>(l.lastIndex=j,l.exec(I)?.index===j?l.lastIndex:-1));if(a==="span"&&/\sdata-stx-scope\s*=/.test(u[0]?.token||""))return null;let f=0,v=!1;for(let I of u){if(f+=I.token.startsWith("</")?-1:1,f<0)return null;if(f===0){if(e.slice(I.end).trim())return null;v=!0;break}}if(!v)return null;let S=r+i[0].length;return e.slice(0,S)+n+e.slice(S)}function Ha(e,n){if(!e)return!1;return[...n.additionalComponentsDirs??[],...n.fallbackComponentsDir?[n.fallbackComponentsDir]:[]].some((i)=>{let a=xe.relative(xe.resolve(i),xe.resolve(e));return!a.startsWith("..")&&!xe.isAbsolute(a)})}async function Hr(e,n,r,i,a){let l=e.endsWith(".stx")?e.slice(0,-4):e,u=(ce)=>ce.split("-").map((le)=>le.charAt(0).toUpperCase()+le.slice(1)).join(""),f=r.__importedComponents;if(f){for(let ce of[l,l.toLowerCase(),u(l),J(l)])if(f.has(ce))return!0}let v=[...new Set([`${l}.stx`,`${u(l)}.stx`,`${J(l)}.stx`])],S=typeof a.root==="string"?xe.resolve(a.root):void 0,I=S??xe.dirname(i),j=[],L=(ce)=>{if(ce&&!j.includes(ce))j.push(ce)};for(let ce of us(i,S))L(ce);let M=r.__originalFilePath;if(M)L(xe.join(xe.dirname(M),"components"));if(Ha(n,a))L(a._rootComponentsDir);L(n),L(a._rootComponentsDir),L(xe.join(xe.dirname(i),"components")),L(a.componentsDir);for(let ce of a.additionalComponentsDirs??[])L(ce);let V=a._targetComponentFallbackNames?.some((ce)=>ce.toLowerCase()===l.toLowerCase());if(!V)for(let ce of a._targetComponentDirs??[])L(ce);if(S)L(xe.resolve(S,"resources/views/components")),L(xe.resolve(S,"resources/components")),L(xe.resolve(S,"src/components")),L(xe.resolve(S,"components"));for(let ce of a._layerComponentDirs??[])L(ce);let W=a._pluginComponentDirs;if(Array.isArray(W))for(let ce of W)L(typeof ce==="string"?ce:null);if(L(a.fallbackComponentsDir),V)for(let ce of a._targetComponentDirs??[])L(ce);let Z=a._nativePrimitivesFallback;if(Z&&!Z.except.some((ce)=>ce.toLowerCase()===l.toLowerCase()))L(Z.dir);if(l.startsWith("./")||l.startsWith("../"))return s(xe.resolve(xe.dirname(i),`${l}.stx`));let q=Na(xe.resolve(import.meta.dir,"components")),X=j.map((ce)=>xe.isAbsolute(ce)?ce:xe.resolve(I,ce)),U=`${v.join("\x00")}\x00\x00${X.join("\x00")}`,H=Or.get(U);if(H!==void 0)return H;let re=!1;e:for(let ce of X){if(Na(ce)===q)continue;for(let le of v)if(await s(xe.join(ce,le))){re=!0;break e}}return Or.set(U,re),re}function Na(e){let n=Pr.get(e);if(n!==void 0)return n;let r=e;try{r=Ns.realpathSync(e)}catch{}return Pr.set(e,r),r}function Yg(e){return e==="visible"||e==="idle"||e==="interaction"||e.startsWith("media:")}function $l(e){if(!e)return!1;let n=e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(n)}function Wp(e,n,r){if(!e.includes("{{")&&!e.includes("{!!"))return e;let i=(a,l)=>{let u;try{u=N(a,n)}catch{return l}if(u===void 0||u===null)return"";let f=String(u);if(/<\/style/i.test(f))return console.warn(`[stx] a <style> expression in ${r??"<unknown>"} evaluated to CSS containing a closing style tag, which would end the element early, so it was dropped rather than emitted.`),"";return f};return e.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>i(l,a)).replace(/\{\{([\s\S]*?)\}\}/g,(a,l)=>i(l,a))}var La=new Set;function za(e,n,r,i){let a=`${e}\x00${n}\x00${i??""}`;if(!process.env.STX_DEBUG&&La.has(a))return;La.add(a);let l=n?` used in ${n}`:"",u=i?` Cause: ${i}.`:"",f=r.length>0?`
1184
- searched:
1185
- ${r.map((v)=>` - ${v}`).join(`
1186
- `)}`:"";console.error(`[stx] component <${e}> could not be resolved${l}, so it rendered as nothing.${u}${f}`)}function Ba(e){return`<!-- stx: component "${e.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}var Fp=new Set(["for","if","show","key","ref","class","className","style"]),Wa=new Set,Ka="useMediaQuery|useDark|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useDocumentVisibility|useScrollLock",Rl=new RegExp(`\\b(?:${Ka})\\s*(?:<[^>]*>)?\\s*\\(`);function qi(e){let n=new Set,r=new RegExp(`\\b(?:const|let|var)\\s+([a-zA-Z_$][\\w$]*)\\s*=\\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue|${Ka})\\s*(?:<[^>]*>)?\\s*\\(`,"g");for(let i of e){let a;while((a=r.exec(i))!==null)n.add(a[1]);r.lastIndex=0}return[...n]}async function Qe(e,n,r,i,a,l,u,f=new Set,v,S=mt(a),I,j=e){let{extractVariables:L}=await o("stx/variable-extractor",()=>import("./chunk-4pve3r5a.js")),M=f??new Set;if(M.has(e))return`[Circular component reference: ${e}]`;let V=new Set(M);V.add(e);let W=typeof n.client==="string"?n.client.trim():"";if("client"in n)delete n.client;let Z=W&&W!=="load"&&Yg(W)?W:"";try{let q=(ge)=>ge.split("-").map((ve)=>ve.charAt(0).toUpperCase()+ve.slice(1)).join(""),X=j.endsWith(".stx")?j.slice(0,-4):j,U=null,H=a.__importedComponents;if(H){let ge=[X,X.toLowerCase(),q(X),J(X)];for(let ve of ge)if(H.has(ve)){U=H.get(ve);break}}let re=[];if(!U){let ge=[`${X}.stx`,`${q(X)}.stx`,`${J(X)}.stx`],ve=[...new Set(ge)],ze=a.__originalFilePath,Se=[];for(let Pe of us(l))if(!Se.includes(Pe))Se.push(Pe);let pt=Se.length;for(let Pe of u._layerComponentDirs??[])if(!Se.includes(Pe))Se.push(Pe);if(ze){let Pe=xe.join(xe.dirname(ze),"components");Se.push(Pe)}let tt=u._rootComponentsDir;if(typeof tt==="string"&&Ha(i,u)&&!Se.includes(tt))Se.push(tt);if(i&&!Se.includes(i))Se.push(i);if(typeof tt==="string"&&!Se.includes(tt))Se.push(tt);let It=xe.join(xe.dirname(l),"components");if(!Se.includes(It))Se.push(It);if(u.componentsDir&&u.componentsDir!==i&&!Se.includes(u.componentsDir))Se.push(u.componentsDir);for(let Pe of u.additionalComponentsDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let sn=u._nativeHostAttrs&&/^(?:checkbox|switch)$/i.test(X),Pt=(I?.events??[]).map((Pe)=>Pe.replace(/^@/,"").split(".")[0].toLowerCase().replace(/-/g,"")),es=Object.hasOwn(n,"checked")||Boolean(I?.reactiveProps?.includes("checked")),Bs=Object.hasOwn(n,"value")||Boolean(I?.reactiveProps?.includes("value")),Ws=!Pt.includes("valuechange")&&(es||Pt.includes("change")&&!Bs),Ft=u._nativeHostAttrs&&/^textinput$/i.test(X),rn=Pt.includes("update:value")&&!Pt.includes("input"),Cn=u._nativeHostAttrs&&/^video$/i.test(X),Fs=u._nativeHostAttrs&&/^image$/i.test(X),ts=eo([...Object.keys(n),...I?.reactiveProps??[]],I?.events,n),on=Object.hasOwn(n,"src")||Boolean(I?.reactiveProps?.includes("src")),ns=Object.hasOwn(n,"source")||Boolean(I?.reactiveProps?.includes("source")),ss=Cn&&(on||ns)&&(I?.events??[]).every((Pe)=>/^(?:play|pause|ended|timeupdate|loadedmetadata|loadstart|error)$/.test(Pe.replace(/^@/,"").split(".")[0])),rs=new Set(["","primary","secondary","outline","ghost","danger"]),is=typeof n.variant==="string"?n.variant.trim().toLowerCase():"",os=u._nativeHostAttrs&&/^button$/i.test(X)&&!rs.has(is),Qr=u._targetComponentFallbackNames?.some((Pe)=>Pe.toLowerCase()===X.toLowerCase())??!1,Vs=Qr&&(!sn||Ws)&&(!Ft||rn)&&(!Cn||ss)&&(!Fs||ts)&&!os;for(let Pe of Vs?[]:u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let an=typeof u.root==="string"?xe.resolve(u.root):void 0,ei=an??xe.dirname(l),cn=[];if(an)cn.push(xe.resolve(an,"resources/views/components")),cn.push(xe.resolve(an,"resources/components")),cn.push(xe.resolve(an,"src/components")),cn.push(xe.resolve(an,"components"));cn.push(xe.resolve(import.meta.dir,"components"));for(let Pe of cn)if(!Se.includes(Pe))Se.push(Pe);if(Qr){let Pe=(u._componentPackageDirs??[]).filter((bt)=>typeof bt==="string"&&bt.length>0),Ot=(Vs?Pe.length?Pe:u._pluginComponentDirs??[]:u._targetComponentDirs??[]).filter((bt)=>typeof bt==="string"&&bt.length>0);if(Ot.length){let bt=Se.slice(pt).map((dt)=>xe.isAbsolute(dt)?dt:xe.resolve(ei,dt)).filter((dt)=>!Ot.includes(dt)),cs=`${X}\x00${bt.join("\x00")}`,Ct=Ir.get(cs);if(Ct===void 0){Ct=!1;for(let dt of bt){for(let Ht of ve)if(await s(xe.join(dt,Ht))){Ct=!0;break}if(Ct)break}Ir.set(cs,Ct)}if(!Ct){for(let dt of Ot){let Ht=Se.indexOf(dt);if(Ht>=0)Se.splice(Ht,1)}Se.splice(pt,0,...Ot)}}}let ti=u._pluginComponentDirs;if(Array.isArray(ti)){for(let Pe of ti)if(typeof Pe==="string"&&!Se.includes(Pe))Se.push(Pe)}if(u.fallbackComponentsDir&&!Se.includes(u.fallbackComponentsDir))Se.push(u.fallbackComponentsDir);if(Vs){for(let Pe of u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe)}let as=u._nativePrimitivesFallback;if(as&&!as.except.some((Pe)=>Pe.toLowerCase()===X.toLowerCase())&&!Se.includes(as.dir))Se.push(as.dir);let ni=[...new Set(Se.map((Pe)=>{if(!Pe)return Pe;return xe.isAbsolute(Pe)?Pe:xe.resolve(ei,Pe)}))];Se.length=0,Se.push(...ni);let Us=`${X}\x00${l}\x00${ni.join("\x00")}`,Hs=Ms.get(Us);if(Hs)if(await s(Hs))U=Hs;else Ms.delete(Us);if(!U&&(X.startsWith("./")||X.startsWith("../")))U=xe.resolve(xe.dirname(l),`${X}.stx`),re.push(U);else if(!U)for(let Pe of Se){if(!Pe)continue;for(let Ot of ve){let bt=xe.join(Pe,Ot);if(re.push(bt),await s(bt)){U=bt;break}}if(U)break;if(!U)try{let Ot=await import("fs");if(!Ot.statSync(Pe,{throwIfNoEntry:!1})?.isDirectory())continue;let cs=8,Ct=[{path:Pe,depth:0}];while(Ct.length>0&&!U){let dt=Ct.pop();if(dt.depth>=cs)continue;let Ht;try{Ht=Ot.readdirSync(dt.path,{withFileTypes:!0})}catch{continue}for(let ls of Ht){if(!ls.isDirectory())continue;if(ls.name==="node_modules"||ls.name.startsWith("."))continue;let si=xe.join(dt.path,ls.name);for(let oc of ve){let Ks=xe.join(si,oc);if(re.push(Ks),await s(Ks)){U=Ks;break}}if(U)break;Ct.push({path:si,depth:dt.depth+1})}}}catch{}if(U)break}if(U)Ms.set(Us,U)}if(!U||!await s(U))return za(e,l,re),Ba(e);v.add(U);let ce;if(qn.has(U)&&Tr.get(U)===Pa(U))ce=qn.get(U);else try{let ge=Pa(U);ce=await Bun.file(U).text(),qn.set(U,ce),Tr.set(U,ge)}catch(ge){let ve=ge instanceof Error?ge.message:String(ge);return za(e,l,[U],ve),Ba(e)}if(I)for(let ge of new Set([...Object.keys(n),...I.reactiveProps??[]])){let ve=ge.toLowerCase();if(ve.startsWith("aria-")||ve.startsWith("data-"))continue;let ze=ge.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${ze}\\b`).test(ce))I.declaredProps.add(ge);if(new RegExp(`\\$props\\s*(?:\\.\\s*${ze}\\b|\\[\\s*['"]${ze}['"]\\s*\\])`).test(ce)||new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${ze}['"]`).test(ce))I.consumedProps?.add(ge)}if(I?.reactiveProps?.length&&/\bdefineProps\s*(?:<[^>]*>)?\s*\(/.test(ce))for(let ge of I.reactiveProps){if(Fp.has(ge)||I.consumedProps?.has(ge))continue;if(new RegExp(`\\buse(?:ReactiveProp|Model)\\s*\\(\\s*['"]${ge.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(ce))continue;let ve=`${U}\x00${ge}`;if(Wa.has(ve))continue;Wa.add(ve),console.warn(`[stx] ${xe.basename(U)} reads \`${ge}\` with defineProps(), which is not live, but ${xe.basename(l)} binds it (:${ge}): the value can arrive empty or stale (on a native screen, and for a :for's rows, it does not arrive at all). Read it with useReactiveProp('${ge}').`)}let le=new Set(["__originalFilePath","__importedComponents",ms,"__stx_client_signal_names","__stx_client_declared_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),pe={};for(let[ge,ve]of Object.entries(a))if(!ge.startsWith("__")||le.has(ge))pe[ge]=ve;let Re=S.length>0?{[ws]:[...S]}:{},Ae=r;if(r.includes("@include")){let{processIncludes:ge}=await o("stx/includes",()=>import("./chunk-67yr4m5h.js"));Ae=await ge(r,a,l,u,v)}if(/<[A-Z][\w.-]*[\s/>]/.test(Ae)){let{processComponents:ge}=await o("stx/component-renderer",()=>import("./chunk-7ar11ccn.js")),ve={...a,__processedComponents:M,...Re};Ae=await ge(Ae,ve,l,u,v);let ze=ve.__stx_preserved_client_expressions;if(Array.isArray(ze)&&ze.length>0)a.__stx_preserved_client_expressions=[...new Set([...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...ze])]}let we=[];if($l(Ae)){let{processExpressions:ge}=await o("stx/expressions",()=>import("./chunk-kcpxqsdj.js")),ve=a.__stx_signals_gate===void 0?{...a,__stx_signals_gate:!0,...Re}:S.length>0?{...a,...Re}:a;Ae=ge(Ae,ve,l);for(let ze of Ae.matchAll(/\{\{([\s\S]*?)\}\}/g))we.push(ze[1].trim())}let fe=new Set(Array.isArray(a.__stx_client_declared_names)?a.__stx_client_declared_names:[]),We=[];if(fe.size>0&&Ae)for(let ge of Ae.matchAll(/<[A-Z][\w.-]*\b([^>]*)>/g))for(let ve of ge[1].matchAll(/\s(?:v-model(?::[\w-]+)?|:[\w-]+)\s*=\s*"([^"]*)"/g)){let ze=ve[1].trim();try{if(ze&&Ee(ze).some((Se)=>fe.has(Se)))We.push(ze)}catch{}}let Fe=se(Ae),it=[],ot=Fe.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(ge,ve)=>{let ze=Fe.scripts[Number(ve)]||"",Se=ze.match(/^<script\b([^>]*)>/i)?.[1]||"",pt=Se.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),tt=!pt||["module","text/javascript","application/javascript"].includes(pt),It=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${Se}`);if(!/\bserver\b/i.test(Se)&&tt&&!It)return it.push(ze),"";return ze}),{extractSlotContent:At}=await o("stx/slots",()=>import("./chunk-wgrj0cvs.js")),St=At(ot),at={};if(St.defaultSlot?.trim())at.default=St.defaultSlot;for(let[ge,ve]of St.namedSlots)at[ge]=ve.content;let $t=a.__stx_scope_seq??={n:0,key:po(String(a.__filename??l))},Ve=Ua(e,process.cwd()),ut=`stx_${(Ve.endsWith(".stx")?Ve.slice(0,-4):Ve).replace(/[^a-zA-Z0-9]/g,"_")}_${++$t.n}_${$t.key}`,De={...pe,$uid:ut,$native:u._nativeHostAttrs===!0,...n,props:n,slot:ot,$slots:at,__processedComponents:V,__sections:{},__stx_signals_gate:Me(ce)||$l(r),__stx_preserved_client_expressions:[...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...we],__stx_caller_client_bindings:[...Array.isArray(a.__stx_caller_client_bindings)?a.__stx_caller_client_bindings:[],...We]};if(/import\s/.test(ce)){De.__importedComponents=new Map(De.__importedComponents);let{processESImports:ge}=await o("stx/component-renderer",()=>import("./chunk-7ar11ccn.js"));ce=await ge(ce,De,U,u,v)}zp(ce,De,n);let Mt=ce,Dt=B(Mt);if(Dt)Mt=Dt.content.trim();let zs=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,hn=[...ce.matchAll(zs)];for(let[,ge,ve]of hn)if(!/\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(ge))Ke(ve,U,u.strict);let xt=[],xn=null,Nt=hn.some((ge)=>/\bserver\b/.test(ge[1]||"")&&/\bcache\b/.test(ge[1]||"")),tn=null,bn=null,yn=null,Jn=0,_n=null;if(Pp(u),Nt&&Wr>0){let ge=Mp({props:n,slot:Ae,slotContext:r.trim()?Dp(pe):void 0,buildMode:u.buildMode??"",skipEventDirectives:u.skipEventDirectives===!0,native:u._nativeHostAttrs===!0,clientLoopNames:[...S].sort(),layers:u._layerGraph?.layers.map((ve)=>ve.configFile),uid:ut});if(ge!==null){tn=`${U}\x00${E(ce)}\x00${ge}`;let ve=Ds.get(tn);if(ve){for(let ze of ve.dependencies)v.add(ze);if(Pi(a,ve.clientFactories),$t.n+=ve.uidsConsumed,ve.preservedClientExpressions.length>0){let ze=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let Se of ve.preservedClientExpressions)ze.add(Se);a.__stx_preserved_client_expressions=[...ze]}return ve.output}bn=new Set(v),yn=Ai(a),Jn=$t.n,_n=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[])}}let Tt=new Set;for(let ge of hn){let ve=ge[1]||"",ze=ge[2]||"",Se=ve.includes("server");if(Ye(ve)&&ze.trim())ze=Ze(ze);if(Se&&ze){for(let tt of ye(ze))Tt.add(tt);try{await L(ze,De,U,{onFailure:(tt)=>{if(tt.kind!=="unknown")xn=tt.kind}})}catch(tt){}}if(!Se){let tt=ze.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),It=tt.includes("{{")&&tt.includes("}}"),sn=tt.includes("{!!")&&tt.includes("!!}");if(It||sn)tt=Xi(tt,De,U);let Pt=ve.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");xt.push(`<script${Pt}>${tt}</script>`)}}let jt=se(ce).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),wn=jt?jt[1]:"",ue=jt?jt[2]:"",de="",$e=wn&&/\bscoped\b/i.test(wn);if(jt)de=`<style${wn}>${Wp(ue,De,U)}</style>`;let Te=Mt;if(Te=Te.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),jt)Te=Te.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let ge=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,ve=[];if(Te=Te.replace(ge,(ze,Se)=>{let pt=Se.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(pt)ve.push(`<style${pt[1]}>${pt[2]}</style>`);return""}),Te=Te.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),ve.length>0)de=`${de}${ve.join(`
1187
- `)}`}if(r&&Te.includes("{{ text || slot }}"))Te=Te.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>r);let{applySlots:st}=await o("stx/slots",()=>import("./chunk-wgrj0cvs.js")),{defaultSlot:ct,namedSlots:nn}=St,Gr=a.__stx_signals_gate===!0&&/\s(?:@[\w:.-]+|x-on:[\w:.-]+)\s*=/.test(ot),Lt=xt.length>0&&dr(Te)||u._nativeHostAttrs===!0&&xt.length>0||Gr&&xt.length>0||xt.some((ge)=>/\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(ge)),Xn=(ge)=>Lt?qo(ge,ut):ge,Gn=new Map([...nn].map(([ge,ve])=>[ge,{...ve,content:Xn(ve.content)}]));Te=await st(Te,Lt?Ko(Xn(ct),ut):ct,Gn,De,Lt?ut:"");let vn=qi(xt),Sn=(Array.isArray(De.__stx_client_signal_names)?De.__stx_client_signal_names:[]).filter((ge)=>!Tt.has(ge));if(vn.length>0||Sn.length>0)De.__stx_client_signal_names=[...new Set([...Sn,...vn])];else delete De.__stx_client_signal_names;let En=io(xt.join(`
1188
- `)),kn=(Array.isArray(De.__stx_client_declared_names)?De.__stx_client_declared_names:[]).filter((ge)=>!Tt.has(ge)&&!(ge in n));if(En.size>0||kn.length>0)De.__stx_client_declared_names=[...new Set([...kn,...En])];else delete De.__stx_client_declared_names;let zt=S.filter((ge)=>!Tt.has(ge)&&!(ge in n));if(zt.length>0)De[ws]=zt;let Yn={...u,_rootComponentsDir:u._rootComponentsDir||u.componentsDir,componentsDir:xe.dirname(U),skipSignalsRuntime:!0,skipEventDirectives:u._nativeHostAttrs===!0||Lt||xt.length===0,defaultLayout:void 0};De.__stxProcessingDepth=(a.__stxProcessingDepth||0)+1;let{processDirectives:Qn}=await o("stx/process",()=>import("./chunk-31yx4sjh.js")),Be=await Qn(Te,De,U,Yn,v),Et=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let ge of Be.matchAll(/\{\{([\s\S]*?)\}\}/g))Et.add(ge[1].trim());if(Et.size>0)a.__stx_preserved_client_expressions=[...Et];let Bt=ut,ft=Be;if(Lt){let ge="";if(Object.keys(n).length>0)try{ge=` data-stx-props="${Rr(JSON.stringify(n))}"`}catch{}let ve=Z?` stx-hydrate="${Rr(Z)}"`:"",ze=Object.fromEntries(Object.entries(at).map(([Ft,rn])=>[Ft,Boolean(rn)])),Se=Object.keys(ze).length>0?` data-stx-slots="${Rr(JSON.stringify(ze))}"`:"",pt=` data-stx-scope="${Bt}"${ge}${Se}${ve}`,tt=Be.slice(Vt(Be)),It=/^<span(?=[\s/>])/i.test(tt),sn=/^<[^>]+\bdata-stx-layout-root(?:\s|=|>)/i.test(tt),Pt=/^<[^>]+\bdata-stx-fill-root(?:\s|=|>)/i.test(tt),es=It?"span":"div",Bs=sn&&u._nativeHostAttrs?' style="display:flex;flex-direction:column;flex:1;min-height:0;min-width:0"':Pt&&u._nativeHostAttrs?' style="width:100%;height:100%"':It||sn?' style="display:contents"':"";ft=Jg(Be,pt)??`<${es}${pt} data-stx-component-wrapper${Bs}>${Be}</${es}>`;let Ws=await Promise.all(xt.map(async(Ft)=>{let rn=Ft.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!rn)return Ft;let[,Cn,Fs]=rn,ts=ja(Ft,De,U);if(ts!==null)return ts;let on=await Up(Fs,U,u.buildMode==="compile"),ns=In(on.clientCode,Ge(De)),{vendorStyleTags:ss}=on,rs=ns?`function(__scopeId) {
1189
- ${ns}
1190
- return (${on.factoryBody})(__scopeId);
1191
- }`:on.factoryBody,is=Z?null:or(a,rs),os=is?`window.__stxComponentFactories[${JSON.stringify(is)}](${JSON.stringify(Bt)});`:`(${rs})(${JSON.stringify(Bt)});`;if(Z)return`${ss}<script type="stx/island" data-stx-island="${Bt}" data-stx-scoped data-stx-owner="${Bt}"${Cn}>${me(os)}</script>`;return`${ss}<script data-stx-scoped data-stx-run="always" data-stx-owner="${Bt}"${Cn}>${me(os)}</script>`}));if(ft=ft+`
1192
- `+Ws.join(`
1193
- `),de)ft+=`
1194
- `+de}else{if(de)ft+=`
1195
- `+de;if(xt.length>0){let ge=De.__stx_event_bindings||[],ve=Ge(De),ze=await Promise.all(xt.map(async(Se)=>{let pt=ja(Se,De,U);if(pt!==null)return pt;let tt=Se.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!tt)return Se;return await Je(tt[1],{eventBindings:ge,templateContent:ft,filePath:U,projectRoot:process.cwd(),serverData:ve,instanceId:ut})}));ft+=`
1196
- `+ze.join(`
1197
- `),De.__stx_event_bindings=[]}}if($e){let ge=ao(ft,U);if(ge.hasScoped)ft=ge.html}if(tn&&bn){let ge=Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[];Ds.set(tn,{output:ft,dependencies:[...v].filter((ve)=>!bn.has(ve)),clientFactories:yn?Ti(a,yn):[],uidsConsumed:$t.n-Jn,preservedClientExpressions:_n?ge.filter((ve)=>!_n.has(ve)):[]})}if(xn)ft=`<!--stx-render-failed:${xn}-->${ft}`;return it.length>0?`${ft}
1198
- ${it.join(`
1199
- `)}`:ft}catch(q){if(q instanceof te)throw q;return`[Error processing component: ${q instanceof Error?q.message:String(q)}]`}finally{M.delete(e)}}async function s(e){return Bun.file(e).exists()}function Vr(e,n){let r=xe.resolve(n),i=xe.resolve(e),a=r.endsWith(xe.sep)?r:r+xe.sep;if(i===r||i.startsWith(a))return i;return null}async function Fa(e,n,r,i){let a=n.startsWith("layouts/")?n.slice(8):n,l=xe.join(e,a);for(let u of l.endsWith(".stx")?[l]:[l,`${l}.stx`])if(await s(u)){if(i)console.log(`Found layout in ${e}: ${u}`);return r?.add(u),u}return null}async function On(e,n,r,i){let a=await Vp(e,n,r,i);if(a===null)return null;let l=Vr(a,process.cwd());if(l)return l;let u=[r.root,r.layoutsDir,r.fallbackLayoutsDir,r.componentsDir,r.partialsDir,r.pagesDir,...r._layerLayoutDirs??[]].filter((f)=>typeof f==="string"&&f.length>0);for(let f of u){let v=xe.isAbsolute(f)?f:xe.resolve(process.cwd(),f);if(Vr(a,v))return xe.resolve(a)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${a} (template: ${e}, from: ${n})`),null}async function Vp(e,n,r,i){if(r.debug)console.log(`Resolving template path: ${e} from ${n}`);let a=xe.dirname(n),l=process.cwd();if(e.startsWith("/")){let M=xe.join(l,e),V=Vr(M,l);if(!V)return console.warn(`[stx] rejected template path that escapes project root: ${e} (from ${n})`),null;if(r.debug)console.log(`Checking absolute path: ${V}`);if(await s(V)&&i)i.add(V);return V}let u=async(M)=>{if(!r.layoutsDir||!r.fallbackLayoutsDir)return M;let V=xe.relative(xe.resolve(l,r.fallbackLayoutsDir),M);if(V.startsWith("..")||xe.isAbsolute(V))return M;return await Fa(xe.resolve(l,r.layoutsDir),e,i,r.debug)??M},f=xe.join(a,e);if(await s(f)){if(r.debug)console.log(`Found direct path: ${f}`);let M=await u(f);if(i)i.add(M);return M}if(!e.endsWith(".stx")&&!e.endsWith(".jsx")&&!e.endsWith(".tsx"))for(let M of[".stx",".tsx",".jsx"]){let V=`${f}${M}`;if(await s(V)){if(r.debug)console.log(`Found direct path with extension: ${V}`);let W=await u(V);if(i)i.add(W);return W}}let v=[];if(v.push(...r._layerLayoutDirs??[]),r.layoutsDir)v.push(xe.isAbsolute(r.layoutsDir)?r.layoutsDir:xe.resolve(process.cwd(),r.layoutsDir));let S=xe.resolve(a),I=process.cwd();for(let M=0;M<10;M++){let V=xe.join(S,"layouts"),W=!1;try{W=Ns.statSync(V,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(W){v.push(V);break}let Z=xe.dirname(S);if(Z===S||Z.length<I.length)break;S=Z}for(let M of v){let V=await Fa(M,e,i,r.debug);if(V)return V}if(r.fallbackLayoutsDir){let M=xe.isAbsolute(r.fallbackLayoutsDir)?r.fallbackLayoutsDir:xe.resolve(process.cwd(),r.fallbackLayoutsDir),V=e.startsWith("layouts/")?e.slice(8):e,W=[xe.join(M,V)];if(!e.endsWith(".stx"))W.push(`${W[0]}.stx`);for(let Z of W)if(await s(Z)){if(r.debug)console.log(`Found in options.fallbackLayoutsDir: ${Z}`);if(i)i.add(Z);return Z}}if(e.startsWith("layouts/")||e.includes("/layouts/")){let M=e.split("layouts/"),V=xe.join(r.partialsDir||a,"layouts",M[1]);if(await s(V)){if(r.debug)console.log(`Found in layouts path: ${V}`);if(i)i.add(V);return V}if(!V.endsWith(".stx")){let W=`${V}.stx`;if(await s(W)){if(r.debug)console.log(`Found in layouts path with extension: ${W}`);if(i)i.add(W);return W}}}if(r.partialsDir){let M=xe.join(r.partialsDir,"layouts");if(await s(M)){let V=xe.join(M,e);if(await s(V)){if(r.debug)console.log(`Found in partials layouts dir: ${V}`);if(i)i.add(V);return V}if(!e.endsWith(".stx")){let W=`${V}.stx`;if(await s(W)){if(r.debug)console.log(`Found in partials layouts dir with extension: ${W}`);if(i)i.add(W);return W}}}}let j=r.partialsDir||xe.join(process.cwd(),"views"),L=xe.join(j,e);if(await s(L)){if(r.debug)console.log(`Found in views path: ${L}`);if(i)i.add(L);return L}if(!e.endsWith(".stx")){let M=`${L}.stx`;if(await s(M)){if(r.debug)console.log(`Found in views path with extension: ${M}`);if(i)i.add(M);return M}}if(a.includes("temp")){let M=xe.join(xe.dirname(a),"layouts",e);if(await s(M)){if(r.debug)console.log(`Found in temp layouts dir: ${M}`);if(i)i.add(M);return M}if(!e.endsWith(".stx")){let V=`${M}.stx`;if(await s(V)){if(r.debug)console.log(`Found in temp layouts dir with extension: ${V}`);if(i)i.add(V);return V}}}if(r.debug)console.warn(`Template not found after trying all paths: ${e} (referenced from ${n})`);else console.warn(`Template not found: ${e} (referenced from ${n})`);return null}function Al(e,n,r){let i=0,a="",l="";try{if(typeof n==="number"&&n>=0){let u=e.split(`
1200
- `),f=0;for(let v=0;v<u.length;v++)if(f+=u[v].length+1,f>=n){i=v+1,a=u[v].trim();let S=Math.max(0,v-2),I=Math.min(u.length,v+3);l=u.slice(S,I).map((j,L)=>{let M=S+L+1;return`${M===i?"> ":" "}${M}: ${j}`}).join(`
1201
- `);break}}else if(r){let u=e.indexOf(r);if(u>=0)return Al(e,u)}}catch{}return{lineNumber:i,lineContent:a,context:l}}var He={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"};function b(e,n,r,i,a,l){let{lineNumber:u,context:f}=Al(i,a,l),v=r.split("/").pop(),S=0;if(typeof a==="number"&&a>=0&&i){let j=i.lastIndexOf(`
1202
- `,Math.max(0,a-1));S=a-(j+1)+1}let I="";if(u>0)I+=`
1203
- ${r}:${u}${S>0?`:${S}`:""}: ${e.toLowerCase()} error: ${n}
1204
- `;if(I+=`
1205
- ${He.bold}${He.red}\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E${He.reset}
1206
- `,I+=`${He.bold}${He.red}\u2502${He.reset} ${He.bold}${He.bgRed} ERROR ${He.reset} ${He.red}${e} Error${He.reset}${" ".repeat(Math.max(0,43-e.length))}${He.bold}${He.red}\u2502${He.reset}
1207
- `,I+=`${He.bold}${He.red}\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F${He.reset}
1208
- `,I+=`
1209
- ${He.cyan}${He.bold}File:${He.reset} ${He.dim}${v}${He.reset}`,u>0)I+=` ${He.gray}(line ${u}${S>0?`, col ${S}`:""})${He.reset}`;if(I+=`
1210
- ${He.yellow}${He.bold}Message:${He.reset} ${n}
1211
- `,f)I+=`
1212
- ${He.blue}${He.bold}Context:${He.reset}
1213
- ${He.dim}${f}${He.reset}
1214
- `;return I}function Ce(){qn.clear(),Tr.clear(),Ms.clear(),Ir.clear(),Or.clear(),Pr.clear(),Ds.clear()}function Ny(){return{size:qn.size,maxSize:500}}var Ar=k(128);async function Up(e,n,r){let i=E(e,n,r),a=Ar.get(i);if(a){if(to(a.deps))return a;Ar.delete(i)}let l=Vi(e,{filePath:n,projectRoot:process.cwd()}),u=l.code,f=Wi(l.styles);u=Gt(u).code;let{hasUserImports:v,bundleClientScript:S}=await o("stx/client-script-bundler",()=>import("./chunk-wq17dce6.js")),I=[],j=!1;if(v(u)){let X=u;u=await S(X,n,{projectRoot:process.cwd(),minify:r,collectInputs:I}),j=u===X}let{stripStxRuntimeImports:L}=await o("stx/signal-processing",()=>import("./chunk-8x3yaahc.js"));u=L(u);let M=D(u),V=Lp(M),W=new Set(G(M,!0).split(",").map((X)=>X.trim())),Z=`function(__scopeId) {
1215
- ${vt("const",[...Wl,...V],M)}
1216
- const __scope = window.stx._scopes = window.stx._scopes || {};
1217
- const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
1218
- __scopeVars.$refs = __scopeVars.$refs || {};
1219
- const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
1220
- const __previousCurrentProps = window.__STX_CURRENT_PROPS__;
1221
- // A clone the runtime is setting up may not be in the document yet (rows
1222
- // a loop builds inside a closed :if), where a lookup cannot see it, so the
1223
- // runtime hands its root over in __STX_SETUP_ROOT__ (signals.ts).
1224
- const __setupRoot = window.__STX_SETUP_ROOT__;
1225
- const __componentElement = (__setupRoot && __setupRoot.getAttribute('data-stx-scope') === __scopeId && __setupRoot) || document.querySelector('[data-stx-scope="' + __scopeId + '"]');
1226
- __scopeVars.$slots = Object.create(null);
1227
- if (__componentElement) {
1228
- try { Object.assign(__scopeVars.$slots, JSON.parse(__componentElement.getAttribute('data-stx-slots') || '{}')); }
1229
- catch {}
1230
- }
1231
- window.__STX_CURRENT_ELEMENT__ = __componentElement;
1232
- let __componentProps = __componentElement && __componentElement.__stx_props;
1233
- if (!__componentProps && __componentElement) {
1234
- try { __componentProps = JSON.parse(__componentElement.getAttribute('data-stx-props') || '{}'); }
1235
- catch { __componentProps = {}; }
1236
- }
1237
- window.__STX_CURRENT_PROPS__ = __componentProps && typeof __componentProps === 'object' && !Array.isArray(__componentProps) ? __componentProps : {};
1238
- const __scopeProps = window.__STX_CURRENT_PROPS__;
1239
- Object.defineProperty(__scopeVars, '$props', { configurable: true, enumerable: true, get: function() {
1240
- return (__componentElement && __componentElement.__stx_props) || __scopeProps;
1241
- } });
1242
-
1243
- // Scope-specific lifecycle callbacks. The queues drain as they run; the
1244
- // hook lists keep what setup registered, because a component behind an :if
1245
- // unmounts at each hide and mounts again at each show (signals.ts,
1246
- // suspendSubtreeScopes).
1247
- if (__scopeVars.__suspended && !__scopeVars.__mounted) {
1248
- // Set up again after an :if hid it -- a <template :if> clones the
1249
- // component afresh on every show, and the clone's script runs. This run's
1250
- // hooks close over this run's state, so they replace the ones the hide
1251
- // kept for a re-show rather than queueing beside them.
1252
- __scopeVars.__mountCallbacks = [];
1253
- __scopeVars.__destroyCallbacks = [];
1254
- __scopeVars.__mountHooks = [];
1255
- __scopeVars.__destroyHooks = [];
1256
- // So do its effects: the last run's watched a clone that is gone.
1257
- if (typeof __scopeVars.__disposeEffects === 'function') __scopeVars.__disposeEffects();
1258
- __scopeVars.__disposeEffects = null;
1259
- }
1260
- __scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
1261
- __scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
1262
- __scopeVars.__mountHooks = __scopeVars.__mountHooks || [];
1263
- __scopeVars.__destroyHooks = __scopeVars.__destroyHooks || [];
1264
- let __registeringSetupHooks = true;
1265
- const onMount = (fn) => { __scopeVars.__mountCallbacks.push(fn); __scopeVars.__mountHooks.push(fn); };
1266
- const onDestroy = (fn) => {
1267
- __scopeVars.__destroyCallbacks.push(fn);
1268
- // A teardown registered inside onMount belongs to this mount alone.
1269
- // Replaying it AND registering the next mount's teardown doubles cleanup.
1270
- if (__registeringSetupHooks) __scopeVars.__destroyHooks.push(fn);
1271
- };
1272
- // The effects this setup makes (effect, watch) belong to the scope and are
1273
- // disposed with it (disposeSubtreeScopes in the runtime), as its bindings
1274
- // are. Untracked, one reading a store kept running for a component the
1275
- // router had long swapped out.
1276
- const __endEffects = window.stx._beginEffects ? window.stx._beginEffects() : null;
1277
-
1278
- try {
1279
- ${M}
1280
-
1281
- // Register all defined signals and functions in this scope
1282
- const __localVars = {};
1283
- try {
1284
- ${V.map((X)=>W.has(X)?`Object.defineProperty(__localVars, '${X}', ${Js(X)});`:`if (typeof ${X} !== 'undefined') __localVars['${X}'] = ${X};`).join(`
1285
- `)}
1286
- }
1287
- catch (e) {}
1288
- Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__localVars));
1289
- if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__stxLiveBindings));
1290
- }
1291
- finally {
1292
- __registeringSetupHooks = false;
1293
- if (__endEffects) {
1294
- const __previousDispose = __scopeVars.__disposeEffects;
1295
- const __disposeSetup = __endEffects();
1296
- __scopeVars.__disposeEffects = typeof __previousDispose === 'function'
1297
- ? function() { __previousDispose(); __disposeSetup(); }
1298
- : __disposeSetup;
1299
- }
1300
- window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
1301
- window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
1302
- }
1303
- }`,q={vendorStyleTags:f,factoryBody:Z,clientCode:M,deps:Mr([...I,...l.styles.map((X)=>X.resolvedPath)])};if(!j&&l.unresolved.length===0)Ar.set(i,q);return q}var Hp=100,Kp=599,qr="__stxResponseStatus",Zn="__stxResponseHeaders";function Ls(e){return typeof e==="number"&&Number.isInteger(e)&&e>=Hp&&e<=Kp}function An(e){for(let n of e.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let r=n[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!r)continue;let i=Number(r[1]);if(Ls(i))return i}return}function Kr(e,n){if(!e||typeof e!=="object")return!1;let r=typeof n==="string"&&/^\d+$/.test(n.trim())?Number(n.trim()):n;if(!Ls(r))return!1;return e[qr]=r,!0}function qp(e,n,r){if(!e||typeof e!=="object")return;let i=String(n??"").trim();if(!i)return;e[Zn]={...e[Zn],[i]:String(r)}}function Kt(e){let n=e?.[qr];return Ls(n)?n:void 0}function Xt(e){let n=e?.[Zn];if(!n||typeof n!=="object")return;let r=Object.entries(n).map(([i,a])=>[i,String(a)]);return r.length>0?Object.fromEntries(r):void 0}function hl(e,n){if(!e||!n||e===n||typeof n!=="object")return;let r=Kt(e);if(r!==void 0)n[qr]=r;let i=Xt(e);if(i)n[Zn]={...n[Zn],...i}}function co(e){return{setResponseStatus:(n)=>{Kr(e,n)},notFound:(n=404)=>{let r=Ls(n)&&n>=400?n:404;Kr(e,r)},setResponseHeader:(n,r)=>{qp(e,n,r)}}}function yl(e,n,r={}){if(!e.includes("@status"))return e;let{filePath:i,buildMode:a}=r,l=a==="compile",u="",f=0,v=/@status\s*\(/g,S;while((S=v.exec(e))!==null){let I=Zp(e,S.index+S[0].length-1);if(I<0)break;let j=e.slice(S.index+S[0].length,I).trim(),L=/^\d+$/.test(j)?Number(j):d(j,n),M=i?` in ${i}`:"";if(l)console.warn(`[stx] @status(${j})${M} is skipped when precompiling: the build has no request, so the branch it sits in is not the one a visitor will get. Call notFound() or setResponseStatus(${j}) from <script server> instead \u2014 that runs per request.`);else if(!Kr(n,L))console.warn(`[stx] @status(${j})${M} is not an HTTP status (100-599) \u2014 ignoring it.`);u+=e.slice(f,S.index),f=I+1+(e.slice(I+1).match(/^[^\S\n]*\n?/)?.[0].length??0),v.lastIndex=f}return f===0?e:u+e.slice(f)}function Zp(e,n){let r=1,i=null,a=!1;for(let l=n+1;l<e.length;l++){let u=e[l];if(a){a=!1;continue}if(i){if(u==="\\")a=!0;else if(u===i)i=null;continue}if(u==='"'||u==="'"||u==="`"){i=u;continue}if(u==="(")r++;else if(u===")"&&--r===0)return l}return-1}var qa=new Set(ht),Jp=new Set(["props","$props","defineProps"]),Xp=new Set(["stx","@stacksjs/stx"]),Za=k(128),Ja=k(64);function Gp(e){let n=[],r=0,i=e.split(`
1304
- `);for(let a of i){let l=r,u=null,f=!1;for(let v=0;v<a.length;v++){let S=a[v];if(f){f=!1;continue}if(S==="\\"){f=!0;continue}if(u){if(S===u)u=null;continue}if(S==="'"||S==='"'||S==="`"){u=S;continue}if(S==="/"&&v+1<a.length&&a[v+1]==="/")break;if(S==="{")r++;else if(S==="}")r--}if(l===0){let v=a.match(/(?:const|let|var)\s+(\w+)\s*=/);if(v)n.push(v[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(a)){let S=a.match(/(?:const|let|var)\s+(\w+)/);if(S)n.push(S[1])}else{let S=a.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(S){let j=S[1].slice(1,-1).split(",").map((L)=>{let M=L.split(":");return(M.length>1?M[1]:M[0]).trim()}).filter((L)=>/^\w+$/.test(L));n.push(...j)}}}}return[...new Set(n)]}function Mg(e){let n=e;n=n.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),n=n.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),n=n.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function r(i){if(!i.includes(":"))return i;let a=[],l="",u=0,f=0,v=null;for(let S=0;S<i.length;S++){let I=i[S];if(v){if(l+=I,I===v)v=null;continue}if(I==='"'||I==="'"||I==="`"){v=I,l+=I;continue}if(I==="<")u++;else if(I===">"&&u>0)u--;else if(I==="(")f++;else if(I===")")f--;if(I===","&&u===0&&f===0){a.push(l),l="";continue}l+=I}if(l)a.push(l);return a.map((S)=>{let I=S.trim(),j=I.startsWith("..."),L=j?I.slice(3):I,M=-1,V=0;for(let re=0;re<L.length;re++)if(L[re]==="<")V++;else if(L[re]===">")V--;else if(L[re]===":"&&V===0){M=re;break}if(M===-1)return S;let Z=L.substring(0,M).trim().replace(/\?$/,""),q=L.substring(M+1),X=-1,U=0;for(let re=0;re<q.length;re++)if(q[re]==="<")U++;else if(q[re]===">")U--;else if(q[re]==="="&&U===0){X=re;break}let H=j?"...":"";if(X!==-1)return`${H}${Z} = ${q.substring(X+1).trim()}`;return`${H}${Z}`}).join(", ")}n=n.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(i,a,l)=>{if(!l.includes(":"))return i;return`${a}(${r(l)})`});{let i=/\b(function\s+\w*\s*)\(/g,a,l=[];while((a=i.exec(n))!==null){let u=a.index+a[0].length-1,f=1,v=u+1,S=0,I=null;while(v<n.length&&f>0){let M=n[v];if(I){if(M===I)I=null;v++;continue}if(M==='"'||M==="'"||M==="`"){I=M,v++;continue}if(M==="<")S++;else if(M===">"&&S>0)S--;else if(S===0){if(M==="(")f++;else if(M===")")f--}if(f>0)v++}if(f!==0)continue;let j=n.substring(u+1,v);if(!j.includes(":"))continue;let L=r(j);l.push({start:u+1,end:v,replacement:L})}for(let u=l.length-1;u>=0;u--){let{start:f,end:v,replacement:S}=l[u];n=n.substring(0,f)+S+n.substring(v)}}return n=n.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(i,a)=>{if(!a.includes(":"))return i;if(a.includes("{")||a.includes("}"))return i;return`(${a.split(",").map((u)=>{let[f,...v]=u.split("="),S=f.split(":")[0].trim();if(v.length>0)return`${S} = ${v.join("=").trim()}`;return S}).join(", ")}) =>`}),n=n.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),n=n.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),n=n.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),n=n.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),n=n.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),n=n.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),n=n.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),n=n.replace(/\n\s*\n\s*\n/g,`
1305
-
1306
- `),n}function Dg(e){return e.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(n,...r)=>{let[,i,a]=r,l=i??a;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(l)?"":n})}function Lg(e){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(e)}function jg(e){if(e instanceof SyntaxError)return!0;let n=e instanceof Error?e.message:String(e);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(n)}function Bg(e){if(!/is not defined|can't find variable/i.test(e))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(e)}var Xa=new Set;async function y(e,n,r,i={}){if(!e.trim())return;let a=A(),l=E(e,JSON.stringify(a)),u=Za.get(l);if(u===void 0){try{let ue=ie({loader:"ts",target:"browser",define:a}),de=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");de=de.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),u=ue.transformSync(de)}catch{u=Mg(e)}Za.set(l,u)}let f={exports:{}},v=f.exports,S=mn.cwd(),I={},j=[...u.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((ue)=>ue[1]).filter((ue)=>!ue.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(ue)),L=new Map;for(let ue of j)try{if(ue.startsWith(".")){I[ue]=await import(Rt.resolve(Rt.dirname(r),ue));continue}let de=Rt.resolve(S,"node_modules",ue),$e=Rt.join(de,"package.json"),Te=JSON.parse(w("fs").readFileSync($e,"utf8")),st=Te.main||"index.js";if(Te.exports){let ct=typeof Te.exports==="string"?Te.exports:Te.exports["."];if(typeof ct==="string")st=ct;else if(ct?.bun)st=ct.bun;else if(ct?.import)st=ct.import;else if(ct?.default)st=ct.default}I[ue]=await import(Rt.resolve(de,st))}catch(de){if(ue.startsWith("."))L.set(ue,de instanceof Error?de.message:String(de))}let M=(ue)=>{if(I[ue])return I[ue];let de=L.get(ue);if(de!==void 0)throw Error(`Cannot require '${ue}' from ${r}: ${de}`);return w(ue)},V=n.props||{},W=(ue)=>{if(!ue)return V;let de={};for(let[$e,Te]of Object.entries(ue)){let st=V[$e];if(st!==void 0)de[$e]=st;else if(typeof Te==="function")de[$e]=Te();else de[$e]=Te}return de};for(let[ue,de]of Object.entries(V))Object.defineProperty(W,ue,{value:de,enumerable:!0,configurable:!0,writable:!0});let Z=(ue,de=!1)=>{if(ue===void 0||ue===null)return de;if(typeof ue==="string"){let $e=ue.trim().toLowerCase();if($e===""||$e==="true"||$e==="1"||$e==="on"||$e==="yes")return!0;if($e==="false"||$e==="0"||$e==="off"||$e==="no")return!1;return!0}return Boolean(ue)},q=(ue,de=0)=>{if(ue===void 0||ue===null)return de;if(typeof ue==="string"){let Te=ue.trim();if(Te==="")return de;let st=Number(Te);return Number.isFinite(st)?st:de}let $e=Number(ue);return Number.isFinite($e)?$e:de};for(let ue of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(V,ue))continue;try{Object.defineProperty(W,ue,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let X=(ue)=>{if(!ue)return V;let de={...V};for(let[$e,Te]of Object.entries(ue)){let st=Te&&typeof Te==="object"&&!Array.isArray(Te)?Te:{type:Te};if(de[$e]===void 0&&st.default!==void 0)de[$e]=typeof st.default==="function"?st.default():st.default}return de},U=()=>n.slots||{},H=(ue,de)=>{let $e={...ue};for(let[Te,st]of Object.entries(de))if($e[Te]===void 0)if(typeof st==="function")$e[Te]=st();else $e[Te]=st;return $e},re=(ue)=>{let de=()=>ue;return de.set=($e)=>{},de.update=($e)=>{},de},ce=(ue)=>{let de,$e=!1;return()=>{if(!$e)try{de=ue(),$e=!0}catch{de=void 0}return de}},le=(ue)=>{},pe=(ue)=>ue(),Re=(ue)=>{},Ae=(ue)=>{},we=co(n);function fe(ue){let de=ue||{};if(de.title!==void 0||de.description!==void 0)At({title:de.title,description:de.description})}function We(ue){if(!ue||typeof ue!=="object")return;let de=n.__stxClientPayload??{};Object.assign(de,ue),n.__stxClientPayload=de}let Fe=()=>{let ue=n.__stxServeContext,de=n.__stxServeSearch??ue?.search??"",$e=ue?.path??"",Te=Object.fromEntries(new URLSearchParams(de)),st=n.query,ct=Object.keys(Te).length>0?Te:st??{},nn=de||(Object.keys(ct).length>0?`?${new URLSearchParams(ct).toString()}`:"");return{params:n.params??{},query:ct,path:$e,name:"",fullPath:$e+nn,hash:"",matched:[]}},it=()=>({push:(ue)=>{},replace:(ue)=>{},back:()=>{},forward:()=>{},go:(ue)=>{}}),ot=(ue)=>{let de=n.__stx_runtime_head||{};n.__stx_runtime_head=nt(de,Le(ue||{},{known:wo,source:"useHead()"}))},At=(ue)=>{ot(vo(ue||{}))},St=(ue)=>({value:ue}),at=(ue)=>ue,$t=(ue)=>({value:typeof ue==="function"?ue():ue}),Ve=(ue,de)=>{},lt=(ue)=>{},ut=(ue)=>{},De=(ue)=>ue?ue():Promise.resolve(),Mt=(ue)=>(de,...$e)=>{},Dt=(ue)=>{},zs=(ue,de)=>{},hn=(ue,de)=>de,xt=()=>({value:"light"}),xn=()=>re(!1),Nt=(ue)=>re(!1),tn=()=>re(!1),bn=()=>Nt("(prefers-color-scheme: dark)"),yn=()=>Nt("(prefers-color-scheme: light)"),Jn=()=>Nt("(prefers-reduced-motion: reduce)"),_n=()=>Nt("(prefers-contrast: more)"),Tt={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},Xr=new Proxy(Tt,{get(ue,de){if(de in ue)return ue[de];return},set(ue,de,$e){return ue[de]=$e,!0}}),jt={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},wn=console;try{let ue=Ui(u,r),de=new Set(Object.keys(V)),$e=Object.keys(n).filter((Be)=>!de.has(Be)&&!Jp.has(Be)&&Ur(Be)),Te=$e.map((Be)=>n[Be]);if(!$e.includes("__stxServeContext"))$e.push("__stxServeContext"),Te.push(void 0);if(!de.has("cookies")){let Be=n.cookies??n.__stxServeContext?.cookies??{},Et=$e.indexOf("cookies");if(Et<0)$e.push("cookies"),Te.push(Be);else Te[Et]=Be}let st=new Set(["async","module","exports","require","params","window","document","console","state","derived","effect"]),ct=[],nn=[];for(let[Be,Et]of Object.entries(V)){if(!Ur(Be))continue;if(st.has(Be))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${Be}\\b`).test(ue))continue;ct.push(Be),nn.push(Et)}let Lt=Gp(ue).map((Be)=>`module.exports.${Be} = typeof ${Be} !== 'undefined' ? ${Be} : module.exports.${Be};`).join(`
1307
- `),Xn=n.params??{},Gn=[],vn=[];for(let Be=0;Be<$e.length;Be++){if($e[Be]==="params")continue;Gn.push($e[Be]),vn.push(Te[Be])}let Sn=[...ht,...ct,...Gn],En=`return (async () => {
1308
- ${ue}
1309
- ${Lt}
1310
- return module.exports
1311
- })()`,kn=E(En,Sn.join("\x00")),zt=Ja.get(kn);if(!zt)zt=Function(...Sn,En),Ja.set(kn,zt);let Yn=n.__stx_options?.runtimeConfig;if(Yn||/\buse(?:Server)?RuntimeConfig\b/.test(u))await Dn(n,r,Yn);let Qn=await et(n.__stx_runtime_config??Ln()??z(),()=>ii(n,()=>zt(f,v,M,V,W,Z,q,X,H,We,oi,Yi,go,re,ce,le,pe,Re,Ae,fe,Fe,it,ot,At,we.setResponseStatus,we.setResponseHeader,we.notFound,St,at,$t,Ve,lt,ut,De,Mt,Dt,U,zs,hn,xt,xn,Nt,tn,bn,yn,Jn,_n,Xr,jt,wn,Tt.confirm,Tt.alert,Tt.fetch,Xn,...nn,...vn)));if(i.preserveExisting){for(let[Be,Et]of Object.entries(Qn))if(!(Be in n)||n[Be]===void 0)n[Be]=Et}else Object.assign(n,Qn);for(let[Be,Et]of Object.entries(V))if(!(Be in n))n[Be]=Et}catch(ue){if(n.__stx_strict_hydration)throw ue;let de=Dg(ue instanceof Error?ue.message:String(ue));if(Lg(de))console.warn(`[stx] server <script> in ${r??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${de}`),i.onFailure?.({kind:"module-resolution",message:de,error:ue});else if(jg(ue))console.warn(`[stx] server <script> in ${r??"<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${de}`),i.onFailure?.({kind:"syntax",message:de,error:ue});else if(Bg(de))console.warn(`[stx] server <script> in ${r??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${de}`),i.onFailure?.({kind:"missing-binding",message:de,error:ue});else{let $e=`${r??"<unknown>"}\x00${de}`;if(mn.env.STX_DEBUG||!Xa.has($e))Xa.add($e),console.warn(`[stx] server <script> in ${r??"<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${de}`);i.onFailure?.({kind:"unknown",message:de,error:ue})}try{await sf(u,n,r)}catch($e){if(mn.env.STX_DEBUG){let Te=$e instanceof Error?$e.message:String($e);console.warn(`[stx] fallback extraction also failed in ${r??"<unknown>"}: ${Te}`)}}}}function Fg(e){let n=0,r=null,i=!1,a=!1;for(let l=0;l<e.length;l++){let u=e[l];if(r){if(u===r){if(r=null,i||n===0)a=!0}continue}if(u==="'"||u==='"'||u==="`"){r=u;continue}if(u==="{")n++;else if(u==="}")n--;else if(e.startsWith("from",l)&&n===0)i=!0}return r===null&&n===0&&a}var Yp=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function Ui(e,n){let r=n?Rt.dirname(n):mn.cwd(),i=mn.cwd(),a=e.split(`
1312
- `),l=[],u=0;while(u<a.length){let f=a[u].trim();if(f.startsWith("interface ")||f.startsWith("export interface ")||f.startsWith("type ")||f.startsWith("export type ")){if(f.includes("{")&&!f.includes("}")){let v=0;for(;u<a.length;u++){for(let S of a[u])if(S==="{")v++;else if(S==="}")v--;if(v<=0)break}}u++;continue}if(f.startsWith("definePageMeta(")){let v=0,S=!1,I=u;for(let M=u;M<a.length&&!S;M++){let V=null,W=!1,Z=a[M];for(let q=0;q<Z.length;q++){let X=Z[q];if(W){W=!1;continue}if(X==="\\"){W=!0;continue}if(V){if(X===V)V=null;continue}if(X==='"'||X==="'"||X==="`"){V=X;continue}if(X==="(")v++;else if(X===")"){if(v--,v===0){u=M+1,S=!0;break}}}}if(!S)u=a.length;let j=a.slice(I,u).join(`
1313
- `),L=[];for(let M of["title","description"]){let V=new RegExp(`\\b${M}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(j);if(V)L.push(`${M}: ${JSON.stringify(V[2])}`)}if(L.length>0)l.push(`useSeoMeta({ ${L.join(", ")} });`);continue}if(f.startsWith("import ")||f==="import"||f.startsWith("import{")||/^import['"]/.test(f)){let v=f,S=0;while(!Fg(v)&&u+S+1<a.length)S++,v=`${v} ${a[u+S].trim()}`;u+=S;let I=v.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),j=v.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),L=v.match(/^import\s*['"](.+?)['"]/),M=v,V=(W)=>{if(W.startsWith("."))return Rt.resolve(r,W);if(W.startsWith("~/")||W.startsWith("@/"))return Rt.resolve(i,W.slice(2));try{return Bun.resolveSync(W,r)}catch{return W}};if(I){let[,W,Z]=I,q=V(Z);l.push(`const ${W} = (await import('${q}')).default`),l.push(`module.exports.${W} = ${W};`)}else if(j){let[,W,Z]=j,q=V(Z),X=[],U=[],H=Xp.has(Z);for(let re of W.split(",")){let ce=re.trim();if(!ce)continue;let le=ce.split(/\s+as\s+/);if(le.length===2){let[pe,Re]=[le[0].trim(),le[1].trim()];if(H&&qa.has(pe)){l.push(`const ${Re} = ${pe};`);continue}X.push(`${pe}: ${Re}`),U.push(Re)}else{if(H&&qa.has(ce))continue;X.push(ce),U.push(ce)}}if(X.length>0)l.push(`const { ${X.join(", ")} } = await import('${q}')`);for(let re of U)l.push(`module.exports.${re} = ${re};`)}else if(L){let W=V(L[1]);l.push(`await import('${W}')`)}else l.push(M);u++;continue}if(Yp.test(f))l.push(a[u]),u++;else if(f.startsWith("export const ")||f.startsWith("export let ")||f.startsWith("export var ")){let v=Ya(a,u),{type:S,name:I,value:j}=v;l.push(`${S} ${I} = ${j};`),l.push(`module.exports.${I} = ${I};`),u=v.nextIndex}else if(f.startsWith("export function ")||f.startsWith("export async function ")){let v=Jr(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("const ")||f.startsWith("let ")||f.startsWith("var ")){let v=Ya(a,u),{type:S,name:I,value:j}=v;l.push(`${S} ${I} = ${j};`),l.push(`module.exports.${I} = ${I};`),u=v.nextIndex}else if(f.startsWith("function ")||f.startsWith("async function ")){let v=Jr(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("export default function ")||f.startsWith("export default async function ")){let v=a[u].replace(/^(\s*)export\s+default\s+/,"$1"),S=[...a];S[u]=v;let I=Jr(S,u);if(l.push(I.functionCode),I.name)l.push(`module.exports.default = ${I.name};`);u=I.nextIndex}else if(f.startsWith("export default ")){let v=f.replace(/^export\s+default\s+/,"").replace(/;$/,"");l.push(`module.exports.default = ${v};`),u++}else if(f.startsWith("class ")||f.startsWith("export class ")){let v=f.match(/(?:export\s+)?class\s+(\w+)/);if(v){let S=v[1],I=a[u].replace(/^export\s+/,""),j=0,L=u;for(;L<a.length;L++){let M=a[L];for(let V of M)if(V==="{")j++;else if(V==="}")j--;if(L>u)I+=`
1314
- `+M;if(j<=0&&L>=u)break}l.push(I),l.push(`module.exports.${S} = ${S};`),u=L+1}else l.push(f),u++}else if(f.includes("module.exports"))l.push(f),u++;else if(f.trim()&&!f.startsWith("//"))l.push(f),u++;else u++}return Qp(l.join(`
1315
- `),r,i)}function Qp(e,n,r){let i=e.length,a="",l=0,u=null,f=!1,v=!1,S=0;while(l<i){let I=e[l],j=e[l+1];if(f){if(a+=I,I===`
1316
- `)f=!1;l++;continue}if(v){if(a+=I,I==="*"&&j==="/"){a+=j,l+=2,v=!1;continue}l++;continue}if(!u&&I==="/"&&j==="/"){f=!0,a+=I,l++;continue}if(!u&&I==="/"&&j==="*"){v=!0,a+=I,l++;continue}if(u){if(a+=I,I==="\\"){a+=j,l+=2;continue}if(I===u&&u!=="`"){u=null,l++;continue}if(u==="`"){if(I==="$"&&j==="{"){S++,a+=j,l+=2;continue}if(I==="`"){u=null,l++;continue}}l++;continue}if(S>0){if(I==="{")S++;else if(I==="}")S--}if(I==='"'||I==="'"||I==="`"){u=I,a+=I,l++;continue}if(I==="a"&&e.startsWith("await",l)){let L=ef(e,l);if(L){let{quote:M,path:V,end:W}=L;if(V.startsWith(".")||V.startsWith("~/")||V.startsWith("@/")){let Z=V.startsWith(".")?Rt.resolve(n,V):Rt.resolve(r,V.slice(2));a+=`await import(${M}${Z}${M})`,l=W;continue}}}a+=I,l++}return a}function ef(e,n){let r=n+5;if(r>=e.length)return null;if(!/\s/.test(e[r]))return null;while(r<e.length&&/\s/.test(e[r]))r++;if(!e.startsWith("import",r))return null;r+=6;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!=="(")return null;r++;while(r<e.length&&/\s/.test(e[r]))r++;let i=e[r];if(i!=="'"&&i!=='"')return null;r++;let a=r;while(r<e.length&&e[r]!==i)if(e[r]==="\\")r+=2;else r++;if(r>=e.length)return null;let l=e.slice(a,r);r++;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!==")")return null;return{quote:i,path:l,end:r+1}}function nc(e,n){let r=e[n];if(r!=="{"&&r!=="[")return null;let a=_(e,r,r==="{"?"}":"]",n);if(a===-1)return null;return{pattern:e.slice(n,a+1),endPos:a+1}}function sc(e){let n=[],r=e.slice(1,-1).trim();if(!r)return n;let i=0,a=0,l="";while(i<r.length){let u=r[i];if(u==="{"||u==="["){let f=a===0?nc(r,i):null;if(f){n.push(...sc(f.pattern)),i=f.endPos,l="";continue}a++}else if(u==="}"||u==="]")a--;if(a>0){i++;continue}if(u===","){if(l.trim())n.push(l.trim());l="",i++;continue}if(u===":"){l="",i++;continue}if(u==="="){if(l.trim())n.push(l.trim());l="",i++;while(i<r.length&&r[i]!==","&&a===0){if(r[i]==="{"||r[i]==="[")a++;else if(r[i]==="}"||r[i]==="]")a--;i++}continue}if(/[\w$]/.test(u))l+=u;i++}if(l.trim())n.push(l.trim());return n}function zg(e){let n=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(e);if(!n)return null;let r=n[0].length,i=(a)=>a===" "||a==="\t";while(r<e.length&&i(e[r]))r++;if(e[r]===":"){let a=0,l=null;r++;for(;r<e.length;r++){let u=e[r];if(l){if(u==="\\"){r++;continue}if(u===l)l=null;continue}if(u==="'"||u==='"'||u==="`"){l=u;continue}if(u==="("||u==="["||u==="{"||u==="<"){a++;continue}if(u===")"||u==="]"||u==="}"||u===">"){a--;continue}if(u==="="&&a<=0){let f=e[r+1],v=e[r-1];if(f!=="="&&f!==">"&&v!=="="&&v!=="!"&&v!=="<"&&v!==">")break}}if(e[r]!=="=")return null}while(r<e.length&&i(e[r]))r++;if(e[r]!=="=")return null;return{type:n[1],name:n[2],value:e.slice(r+1).trim()}}function Ga(e,n,r,i){let a=null,l=!1;for(let u of e){if(l){l=!1;continue}if(u==="\\"){l=!0;continue}if(a){if(u===a)a=null;continue}if(u==="'"||u==='"'||u==="`"){a=u;continue}if(u===n)i++;else if(u===r)i--}return i}function Ya(e,n){let r=e[n].trim(),i=zg(r),a=i?[r,i.type,i.name,i.value]:null;if(!a){let I=r.match(/^(?:export\s+)?(const|let|var)\s+/);if(I){let j=r.slice(I[0].length),L=n;if(j.startsWith("{")||j.startsWith("[")){let V=j[0],W=V==="{"?"}":"]",Z=Ga(j,V,W,0),q=j;for(let X=n+1;X<e.length&&Z>0;X++)q+=` ${e[X].trim()}`,L=X,Z=Ga(e[X],V,W,Z);if(Z>0)q=j,L=n;j=q}let M=nc(j,0);if(M){let V=I[1],W=M.pattern,Z=j.slice(M.endPos).trim();if(Z.startsWith("=")){let q=Z.slice(1).trim(),X=q,U=Math.max(L,n);if(Qa(q)){let le=ec(e,U,q);X=le.value,U=le.nextIndex}else U=U+1;X=X.trim().replace(/;$/,"");let H=sc(W),re=`__stx_src_${n}`,ce=H.map((le)=>`module.exports.${le} = ${le};`).join(`
1317
- `);return{type:V,name:re,value:`${X}; ${V} ${W} = ${re};
1318
- ${ce}`,nextIndex:U}}}}throw Error(`Failed to parse variable declaration: ${r}`)}let[,l,u,f]=a,v=f,S=n;if(Qa(f)){let I=ec(e,n,f);v=I.value,S=I.nextIndex}else S=n+1;while(S<e.length){let I=e[S].trim();if(I.startsWith(".")||I.startsWith("?."))v+=`
1319
- ${e[S]}`,S++;else break}return v=v.trim().replace(/;$/,""),{type:l,name:u,value:v,nextIndex:S}}function Jr(e,n){let r=e[n].trim(),i=r.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!i)throw Error(`Failed to parse function declaration: ${r}`);let[,a]=i,l=r.replace(/^export\s+/,""),u=n;if(tf(r)){let f=nf(e,n,l);l=f.functionCode,u=f.nextIndex}else u=n+1;return{name:a,functionCode:l,nextIndex:u}}function Qa(e){let n=e.trim();if(n.startsWith("{"))return _(n,"{","}",0)===-1;if(n.startsWith("["))return _(n,"[","]",0)===-1;return!rc(n)}function rc(e){let n={paren:0,bracket:0,brace:0},r=null,i=0;for(let a=0;a<e.length;a++){let l=e[a];if((a>0?e[a-1]:"")==="\\"&&r)continue;if((l==='"'||l==="'")&&!r){r=l;continue}if(l===r&&r!=="`"){r=null;continue}if(l==="`"&&!r){r="`";continue}if(l==="`"&&r==="`"&&i===0){r=null;continue}if(r==="`"&&l==="$"&&e[a+1]==="{"){i++,a++;continue}if(i>0&&l==="{"){i++;continue}if(i>0&&l==="}"){i--;continue}if(r)continue;if(l==="(")n.paren++;else if(l===")")n.paren--;else if(l==="[")n.bracket++;else if(l==="]")n.bracket--;else if(l==="{")n.brace++;else if(l==="}")n.brace--}return n.paren===0&&n.bracket===0&&n.brace===0&&r===null}function ic(e){let n=e.indexOf("(");if(n===-1)return e.indexOf("{");let r=_(e,"(",")",n);if(r===-1)return-1;return e.indexOf("{",r)}function tf(e){let n=ic(e);if(n===-1)return!0;return _(e,"{","}",n)===-1}function ec(e,n,r){let i=r,a=n+1;while(a<e.length&&!rc(i)){let l=e[a];i+=`
1320
- ${l}`,a++}while(a<e.length){let l=e[a].trim();if(l.startsWith(".")||l.startsWith("?."))i+=`
1321
- ${e[a]}`,a++;else break}return{value:i,nextIndex:a}}function nf(e,n,r){let i=r,a=n+1;while(a<e.length){let l=ic(i);if(l!==-1){if(_(i,"{","}",l)!==-1)break}let u=e[a];i+=`
1322
- ${u}`,a++}return{functionCode:i,nextIndex:a}}function tc(e,n){let r=d(e,n)??d(`(${e})`,n);if(r!==void 0)return r;if(!/\bprocess\b/.test(e))return;let i={...n,process:Object.freeze({env:{...mn.env}})},a=Object.keys(i).filter(Ur),l=a.map((u)=>i[u]);try{return Function(...a,`'use strict'; return (${e});`)(...l)}catch{try{return Function(...a,`'use strict'; return ${e};`)(...l)}catch{return}}}async function sf(e,n,r){let i=e.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let l of i){let[,,u,f]=l;try{let v=f.trim().replace(/;$/,""),S=tc(v,n);if(S!==void 0)n[u]=S}catch(v){console.warn(`Failed to parse export ${u} in fallback:`,v)}}let a=e.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let l of a){let[,,u,f]=l;if(!(u in n))try{let v=f.trim().replace(/;$/,""),S=tc(v,n);if(S!==void 0)n[u]=S}catch{}}}function _l(e){let n=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),r=n?n[1]:"",i=n?e.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):e;return{scriptContent:r,templateWithoutScript:i}}function Cl(e){let n=e.trim();if(!n)return!1;return/(?:const|let|var|function)\s+\w+/.test(n)}
1323
- export{qe,Ie,G,Js,Ys,J,Nr,Zs,Qs,Ii,Oi,Ni,eo,Mi,al,Ut,o,me,k,cl,E,Mr,to,Oe,A,Ke,B,Vt,Ne,Q,Tn,Xe,x,ll,ke,se,Dr,ee,Lr,jr,he,Wt,oe,F,mt,O,Br,Fr,ht,ul,qt,no,ro,_e,Di,$n,so,ye,dl,pl,Li,fl,gl,oo,ji,Bi,ml,Fi,io,zi,Rn,ao,An,Kt,Xt,hl,co,yl,bl,Pn,zr,lo,uo,wl,Hi,vl,xl,Sl,kl,Mg,Dg,Lg,jg,Bg,y,Fg,Ui,zg,_l,Cl,Vi,Wi,Hg,Gt,El,Ug,Tl,Oy,Ge,In,Je,Vg,Wg,qg,Kg,Xg,po,Gg,Ye,ie,Ze,Jg,Hr,Yg,$l,Rl,qi,Qe,s,On,Al,b,Ce,Ny,Pl,Il,Ol,Ki,fo,Zg,My,Qg,Dy,Nn,g,Y,ae,Mn,Me,em,Xi,tm,Ly,P,Gi,nm,jy,N,By};