@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,1467 +0,0 @@
1
- // @bun
2
- import{en,we,R}from"./chunk-0jdz31q1.js";import{Z}from"./chunk-0adc8x2h.js";import{Mi,al,o,A,Ke,Ne,Tn,Xe,ke,se,Dr,O,Rn,ao,yl,bl,Pn,zr,lo,uo,wl,Hi,vl,xl,Sl,kl,Ge,Je,po,Qe,s,On,b,g,Y,ae,Me,P,Gi}from"./chunk-b5qzed8y.js";import{d,m,M,n,ce,te,u,De,Qi,K,jn,ea,Zt,ta,Dl,qr,Ll,wt,jl,Kr,Bl,Bn,na,Fl,Xr,Jr,Le,ra}from"./chunk-4vz17ytv.js";import{Jt}from"./chunk-w98yt4d4.js";import{Dn}from"./chunk-p3x84jj0.js";import{S}from"./chunk-ngqb22wj.js";import{Pr,Cn}from"./chunk-388xpdw5.js";import{Vc,Wc,$r,pt,qc,j}from"./chunk-mf5cqv1k.js";import{ki,_i,Ci,Ei}from"./chunk-xnp031ba.js";import{kn,Bc,Ps}from"./chunk-0v7555tr.js";import{Ts,$s,Rs}from"./chunk-43sgpy4e.js";import{Ns,mi,hi,Ms,Ds,yi}from"./chunk-9w9y84t5.js";import{Is,ui}from"./chunk-bm6y085n.js";import{ii}from"./chunk-fs43342z.js";import{ge,di,pi,fi}from"./chunk-9tv0tw7f.js";import{_r,Ae,zc,Cr,Hc}from"./chunk-8b8az19t.js";import{W,ut}from"./chunk-1jxkc6d0.js";import{Xc,Gc}from"./chunk-w6ydg43d.js";import{I,Fn,sa}from"./chunk-e5rag6rh.js";import{Un}from"./chunk-fvr3h2fr.js";import{L,c,f}from"./chunk-8tfpv6zf.js";function Ve(r){return/\bimport\s*\.\s*meta\b/.test(Un(r))}function Br(r){let e=Ne(r),l=[],a=0;for(let h=0;h<e.length;h++){let t=e[h],p=t.name.toLowerCase();if(p==="template")a+=t.closing?-1:1;if(p!=="script"||t.closing)continue;let w=e[h+1];if(w?.name.toLowerCase()!=="script"||!w.closing)continue;l.push({start:t.start,end:w.end,attrs:t.attributes,body:r.slice(t.end,w.start),inert:a>0})}return l}function nt(r){return[...r].map(([e,l])=>l===!0?e:`${e}="${l.replace(/"/g,"&quot;")}"`).join(" ")}function vt(r){let e=Br(r);if(e.some((y)=>O(y.attrs).has("data-stx-module-bootstrap")))return r;let l=(y)=>{if(Ve(y))return!0;try{return Z(y)}catch{return!1}};if(!e.some((y)=>l(y.body)||O(y.attrs).get("type")==="module"))return r;let a=new Bun.CryptoHasher("md5").update(r).digest("hex").slice(0,16),h="",t=0,p=!1,w=0;for(let y of e){let v=O(y.attrs),x=v.get("type");if(y.inert||v.has("data-stx-module-job")||v.has("data-stx-runtime")||v.has("data-stx-router"))continue;if(typeof x==="string"&&!["module","text/javascript","application/javascript"].includes(x.toLowerCase()))continue;if(![...v.keys()].some((T)=>/^data-stx-(?:scoped|modules|stores|(?:framework-)?composables)$/.test(T)))continue;let _=x==="module"||l(y.body);if(_)p=!0;if(!p)continue;if(!_&&(v.has("data-stx-owner")||v.has("data-stx-instance")))continue;h+=r.slice(t,y.start);let E=y.body,D=v.get("src");if(typeof D==="string")v.delete("src"),v.set("data-stx-source-url",D),E=`${_?"await":"return"} new Promise(function(resolve,reject){
3
- var source=globalThis.__stxExecutingScript,script=document.createElement('script');
4
- for(var attr of source.attributes)if(!['type','src','data-stx-module-job'].includes(attr.name))script.setAttribute(attr.name,attr.value);
5
- ${_?"script.type='module';":""}
6
- if(source.nonce)script.nonce=source.nonce;
7
- script.src=new URL(source.getAttribute('data-stx-source-url'),document.baseURI).href;
8
- script.onload=function(){${_?"":"globalThis.__stxExecutingScript=__stxPreviousScript;"}resolve();};
9
- script.onerror=function(error){${_?"":"globalThis.__stxExecutingScript=__stxPreviousScript;"}reject(error);};
10
- source.parentNode.insertBefore(script,source);
11
- });`;if(_){let T=`${a}-${w++}`,C=JSON.stringify(T),N=new Map(v);N.delete("type"),N.delete("async"),N.delete("defer"),N.set("data-stx-module-bootstrap",!0),h+=`<script ${nt(N)}>
12
- ;(function(){
13
- var resolve,reject,previous=globalThis.__stxPageModulesReady||Promise.resolve();
14
- var ready=new Promise(function(ok,fail){resolve=ok;reject=fail;});
15
- var job={previous:previous,resolve:resolve,reject:reject};
16
- (globalThis.__stxModuleJobs||(globalThis.__stxModuleJobs={}))[${C}]=job;
17
- job.fail=function(event){
18
- var script=document.querySelector('script[data-stx-module-job="${T}"]');
19
- if((event.target&&event.target===script)||(event.filename&&event.filename===(script&&script.src||document.URL))){
20
- window.removeEventListener('error',job.fail,true);
21
- if(globalThis.__stxExecutingScript===job.script)globalThis.__stxExecutingScript=job.previousScript;
22
- reject(event.error||new Error(event.message||'Page module failed to load'));
23
- delete globalThis.__stxModuleJobs[${C}];
24
- }
25
- };
26
- window.addEventListener('error',job.fail,true);
27
- globalThis.__stxPageModulesReady=ready;
28
- ready.catch(function(error){console.error('[stx] page module failed',error);});
29
- })();
30
- </script>`,v.set("type","module"),v.delete("async"),v.delete("defer"),v.set("data-stx-module-job",T),h+=`<script ${nt(v)}>
31
- await globalThis.__stxModuleJobs[${C}].previous;
32
- globalThis.__stxModuleJobs[${C}].previousScript=globalThis.__stxExecutingScript;
33
- globalThis.__stxModuleJobs[${C}].script=document.querySelector('script[data-stx-module-job="${T}"]');
34
- globalThis.__stxExecutingScript=globalThis.__stxModuleJobs[${C}].script;
35
- ${E}
36
- globalThis.__stxExecutingScript=globalThis.__stxModuleJobs[${C}].previousScript;
37
- window.removeEventListener('error',globalThis.__stxModuleJobs[${C}].fail,true);
38
- globalThis.__stxModuleJobs[${C}].resolve();
39
- delete globalThis.__stxModuleJobs[${C}];
40
- </script>`}else h+=`<script ${nt(v)}>
41
- ;(function(__stxSource){
42
- globalThis.__stxPageModulesReady=(globalThis.__stxPageModulesReady||Promise.resolve()).then(function(){
43
- var __stxPreviousScript=globalThis.__stxExecutingScript;
44
- globalThis.__stxExecutingScript=__stxSource;
45
- ${typeof D==="string"?E:`var __stxLive=document.createElement('script');
46
- for(var __stxAttr of __stxSource.attributes)if(!['src','type'].includes(__stxAttr.name))__stxLive.setAttribute(__stxAttr.name,__stxAttr.value);
47
- if(__stxSource.nonce)__stxLive.nonce=__stxSource.nonce;
48
- __stxLive.textContent=${JSON.stringify(E).replace(/<\/script/gi,"<\\/script")};
49
- var __stxFailure;
50
- function __stxCapture(event){__stxFailure=event.error||new Error(event.message);}
51
- window.addEventListener('error',__stxCapture);
52
- try { __stxSource.parentNode.replaceChild(__stxLive,__stxSource); }
53
- finally { window.removeEventListener('error',__stxCapture); globalThis.__stxExecutingScript=__stxPreviousScript; }
54
- if(__stxFailure)throw __stxFailure;`}
55
- });
56
- })(document.currentScript);
57
- </script>`;t=y.end}return h+r.slice(t)}import ls from"fs";import le from"path";function xt(r){let e=Ne(r),l=e.find((v)=>v.closing&&v.name.toLowerCase()==="head");if(!l)return r;let a=new Set(["template","svg","noscript","math","textarea","title","xmp","iframe","noembed","noframes","plaintext"]),h=0,t=[];for(let v=0;v<e.length;v++){let x=e[v];if(x.start<l.end)continue;let k=x.name.toLowerCase();if(a.has(k)){h=Math.max(0,h+(x.closing?-1:x.selfClosing?0:1));continue}if(k!=="style"||x.closing||h>0)continue;let _=e[v+1];if(_?.name.toLowerCase()==="style"&&_.closing){if(/@scope\s*\{/.test(r.slice(x.end,_.start)))continue;t.push({start:x.start,end:_.end}),v++}}if(!t.length)return r;let p=t.map((v)=>r.slice(v.start,v.end)).join(`
58
- `),w=[r.slice(0,l.start),p,`
59
- `],y=l.start;for(let v of t)w.push(r.slice(y,v.start)),y=v.end;return w.push(r.slice(y)),w.join("")}function St(){return`
60
- // STX Lifecycle Runtime
61
- (function() {
62
- if (typeof window === 'undefined') return;
63
-
64
- const instances = new Map();
65
- let currentInstance = null;
66
- let idCounter = 0;
67
-
68
- function generateId() {
69
- return 'stx-' + (++idCounter) + '-' + Date.now().toString(36);
70
- }
71
-
72
- function createInstance(element) {
73
- const instance = {
74
- id: generateId(),
75
- element: element,
76
- mountHooks: [],
77
- destroyHooks: [],
78
- updateHooks: [],
79
- refs: new Map(),
80
- watchers: [],
81
- isMounted: false
82
- };
83
- instances.set(instance.id, instance);
84
- return instance;
85
- }
86
-
87
- window.STX = window.STX || {};
88
-
89
- // Lifecycle hooks
90
- window.STX.onMount = function(hook) {
91
- if (currentInstance) currentInstance.mountHooks.push(hook);
92
- };
93
-
94
- window.STX.onDestroy = function(hook) {
95
- if (currentInstance) currentInstance.destroyHooks.push(hook);
96
- };
97
-
98
- window.STX.onUpdate = function(hook) {
99
- if (currentInstance) currentInstance.updateHooks.push(hook);
100
- };
101
-
102
- // Aliases
103
- window.STX.onMounted = window.STX.onMount;
104
- window.STX.onUnmounted = window.STX.onDestroy;
105
- window.STX.onUpdated = window.STX.onUpdate;
106
-
107
- // Refs
108
- window.STX.ref = function(initialValue) {
109
- const r = { value: initialValue || null };
110
- Object.defineProperty(r, 'current', {
111
- get: function() { return this.value; }
112
- });
113
- if (currentInstance) {
114
- currentInstance.refs.set('ref-' + currentInstance.refs.size, r);
115
- }
116
- return r;
117
- };
118
-
119
- // Watch
120
- window.STX.watch = function(source, callback, options) {
121
- options = options || {};
122
- let oldValue;
123
- let cleanup;
124
- let isActive = true;
125
-
126
- function run() {
127
- if (!isActive) return;
128
- const newValue = source();
129
- if (oldValue !== newValue || options.immediate) {
130
- if (cleanup) cleanup();
131
- cleanup = callback(newValue, oldValue);
132
- oldValue = newValue;
133
- }
134
- }
135
-
136
- if (options.immediate) {
137
- run();
138
- }
139
- else {
140
- oldValue = source();
141
- }
142
-
143
- const intervalId = setInterval(run, 16);
144
-
145
- function stop() {
146
- isActive = false;
147
- clearInterval(intervalId);
148
- if (cleanup) cleanup();
149
- }
150
-
151
- if (currentInstance) {
152
- currentInstance.watchers.push({ stop: stop });
153
- currentInstance.destroyHooks.push(stop);
154
- }
155
-
156
- return stop;
157
- };
158
-
159
- // Computed
160
- window.STX.computed = function(getter) {
161
- let cached;
162
- let dirty = true;
163
- return {
164
- get value() {
165
- if (dirty) {
166
- cached = getter();
167
- dirty = false;
168
- queueMicrotask(function() { dirty = true; });
169
- }
170
- return cached;
171
- }
172
- };
173
- };
174
-
175
- // Component management
176
- window.STX.setupComponent = function(element, setup) {
177
- const instance = createInstance(element);
178
- currentInstance = instance;
179
- try {
180
- setup();
181
- }
182
- finally {
183
- currentInstance = null;
184
- }
185
- return instance;
186
- };
187
-
188
- window.STX.mountComponent = function(instance) {
189
- if (instance.isMounted) return;
190
- instance.isMounted = true;
191
- instance.mountHooks.forEach(function(hook) {
192
- try {
193
- const cleanup = hook();
194
- if (typeof cleanup === 'function') {
195
- instance.destroyHooks.push(cleanup);
196
- }
197
- else if (cleanup && typeof cleanup.then === 'function') {
198
- cleanup.catch(function(e) { console.error('[stx] onMount error:', e); });
199
- }
200
- }
201
- catch (e) {
202
- console.error('[stx] onMount error:', e);
203
- }
204
- });
205
- };
206
-
207
- window.STX.destroyComponent = function(instance) {
208
- if (!instance.isMounted) return;
209
- instance.watchers.forEach(function(w) { w.stop(); });
210
- instance.destroyHooks.forEach(function(hook) {
211
- try { hook(); }
212
- catch (e) { console.error('[stx] onDestroy error:', e); }
213
- });
214
- instance.refs.forEach(function(ref) { ref.value = null; });
215
- instance.isMounted = false;
216
- instances.delete(instance.id);
217
- };
218
-
219
- // ==========================================================================
220
- // Vue-Style Refs System - No document.** required!
221
- // ==========================================================================
222
-
223
- // Internal: Query for ref elements without exposing document API
224
- function queryRef(name, root) {
225
- return (root || document).querySelector('[data-stx-ref="' + name + '"], [data-ref="' + name + '"]');
226
- }
227
-
228
- function queryAllRefs(root) {
229
- return (root || document).querySelectorAll('[data-stx-ref], [data-ref]');
230
- }
231
-
232
- // Auto-bind refs from ref attributes (Vue-style)
233
- window.STX.bindRefs = function(root, refs) {
234
- if (!root) return;
235
- queryAllRefs(root).forEach(function(el) {
236
- var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
237
- if (refs[refName]) {
238
- refs[refName].value = el;
239
- }
240
- });
241
- };
242
-
243
- // Vue-style useRefs() - returns object with all refs as direct elements
244
- // Usage: const { input, button, container } = STX.useRefs()
245
- window.STX.useRefs = function(root) {
246
- var refs = {};
247
- queryAllRefs(root).forEach(function(el) {
248
- var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
249
- if (refName) {
250
- refs[refName] = el;
251
- }
252
- });
253
- return refs;
254
- };
255
-
256
- // Get a single ref by name - Vue's useTemplateRef equivalent
257
- // Usage: const input = STX.useRef('input')
258
- window.STX.useRef = function(name, root) {
259
- return queryRef(name, root);
260
- };
261
-
262
- // Two-way binding helper for form elements
263
- // Usage: STX.model(inputEl, state, 'username')
264
- window.STX.model = function(el, state, key) {
265
- if (!el || !state) return;
266
-
267
- var isCheckbox = el.type === 'checkbox';
268
- var isRadio = el.type === 'radio';
269
- var isSelect = el.tagName === 'SELECT';
270
-
271
- // Set initial value
272
- if (isCheckbox) {
273
- el.checked = !!state[key];
274
- }
275
- else if (isRadio) {
276
- el.checked = el.value === state[key];
277
- }
278
- else {
279
- el.value = state[key] || '';
280
- }
281
-
282
- // Listen for changes
283
- var eventType = isCheckbox || isRadio ? 'change' : 'input';
284
- el.addEventListener(eventType, function() {
285
- if (isCheckbox) {
286
- state[key] = el.checked;
287
- }
288
- else if (isRadio) {
289
- if (el.checked) state[key] = el.value;
290
- }
291
- else {
292
- state[key] = el.value;
293
- }
294
- });
295
-
296
- // Return cleanup function
297
- return function() {
298
- el.removeEventListener(eventType, arguments.callee);
299
- };
300
- };
301
-
302
- // Batch event binding helper - cleaner than manual addEventListener
303
- // Usage: STX.on({ click: [btn1, btn2], input: [textField] }, handler)
304
- window.STX.on = function(el, event, handler) {
305
- if (!el) return function() {};
306
- el.addEventListener(event, handler);
307
- return function() { el.removeEventListener(event, handler); };
308
- };
309
-
310
- // Bind multiple events at once
311
- // Usage: STX.events(refs.btn, { click: handleClick, mouseenter: handleHover })
312
- window.STX.events = function(el, eventMap) {
313
- if (!el) return function() {};
314
- var cleanups = [];
315
- Object.keys(eventMap).forEach(function(event) {
316
- el.addEventListener(event, eventMap[event]);
317
- cleanups.push(function() { el.removeEventListener(event, eventMap[event]); });
318
- });
319
- return function() { cleanups.forEach(function(c) { c(); }); };
320
- };
321
-
322
- // ==========================================================================
323
- // DOM Helpers - Eliminate document.* usage
324
- // ==========================================================================
325
-
326
- // Global keyboard event listener
327
- // Usage: STX.onKey('Escape', () => closeModal())
328
- window.STX.onKey = function(key, handler, options) {
329
- var listener = function(e) {
330
- if (e.key === key) {
331
- handler(e);
332
- }
333
- };
334
- document.addEventListener('keydown', listener, options);
335
- return function() { document.removeEventListener('keydown', listener, options); };
336
- };
337
-
338
- // Create element helper
339
- // Usage: STX.el('div', { class: 'foo' }, 'text content')
340
- window.STX.el = function(tag, attrs, content) {
341
- var el = document.createElement(tag);
342
- if (attrs) {
343
- Object.keys(attrs).forEach(function(key) {
344
- if (key === 'class') {
345
- el.className = attrs[key];
346
- }
347
- else if (key.startsWith('on')) {
348
- el.addEventListener(key.slice(2).toLowerCase(), attrs[key]);
349
- }
350
- else {
351
- el.setAttribute(key, attrs[key]);
352
- }
353
- });
354
- }
355
- if (content) {
356
- if (typeof content === 'string') {
357
- el.textContent = content;
358
- }
359
- else if (Array.isArray(content)) {
360
- content.forEach(function(child) { el.appendChild(child); });
361
- }
362
- else {
363
- el.appendChild(content);
364
- }
365
- }
366
- return el;
367
- };
368
-
369
- // Get currently focused element
370
- // Usage: const focused = STX.activeElement()
371
- window.STX.activeElement = function() {
372
- return document.activeElement;
373
- };
374
-
375
- // Escape HTML helper
376
- // Usage: const safe = STX.escapeHtml(userInput)
377
- window.STX.escapeHtml = function(text) {
378
- var div = document.createElement('div');
379
- div.textContent = text;
380
- return div.innerHTML;
381
- };
382
-
383
- // MutationObserver for automatic lifecycle management
384
- const observer = new MutationObserver(function(mutations) {
385
- mutations.forEach(function(mutation) {
386
- // Handle removed nodes
387
- mutation.removedNodes.forEach(function(node) {
388
- if (node.nodeType === 1 && node.__stx_instance__) {
389
- window.STX.destroyComponent(node.__stx_instance__);
390
- }
391
- });
392
- });
393
- });
394
-
395
- // Start observing when DOM is ready
396
- if (document.readyState === 'loading') {
397
- document.addEventListener('DOMContentLoaded', function() {
398
- observer.observe(document.body, { childList: true, subtree: true });
399
- });
400
- }
401
- else {
402
- observer.observe(document.body, { childList: true, subtree: true });
403
- }
404
-
405
- console.log('[stx] Lifecycle runtime initialized');
406
- })();
407
- `}function st(r){return Symbol(r)}var Fs=st("theme"),Us=st("router"),qs=st("i18n");import*as _t from"crypto";function kt(r){let e=/\$(\w+)\./g,l=[],a;while((a=e.exec(r))!==null)if(!l.includes(a[1]))l.push(a[1]);return l}function Fr(){return`stx-${_t.randomBytes(4).toString("hex")}`}function Ur(r){return/\$\w+\./.test(r)}function Wr(r){if(!/\{\{[^}]*\$\w/.test(r)||!/\$\w+\./.test(r))return{html:r,bindings:[],stores:new Set};let e=[],l=new Set,a=/<(\w+)([^>]*?)(\s*\/?>)/g,h=r;return h=h.replace(a,(t,p,w,y)=>{if(["script","style","template"].includes(p.toLowerCase()))return t;if(!w.includes("{{"))return t;let v=[],x=!1,k=w,_=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,E=[...w.matchAll(_)];for(let C of E){let N=C[0],F=C[1],q=C[2];if(Ur(q)){x=!0;let V=q.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(V){let H=V[1];if(v.push({attr:F,expr:H,fullMatch:N,originalAttr:F}),kt(H).forEach((U)=>l.add(U)),F==="text")k=k.replace(N,"");else if(F==="class")k=k.replace(N,'class=""');else if(F==="disabled"||F==="hidden")k=k.replace(N,"");else k=k.replace(N,`${F}=""`)}}}if(!x)return t;let D=k.match(/\bid\s*=\s*"([^"]+)"/),T;if(D)T=D[1];else T=Fr(),k=` id="${T}"${k}`;for(let C of v)e.push({elementId:T,attribute:C.attr,expression:C.expr,stores:kt(C.expr)});return`<${p}${k}${y}`}),{html:h,bindings:e,stores:l}}function Vr(r,e){if(r.length===0)return"";let l=Array.from(e),a=`
408
- <script>
409
- (function() {
410
- 'use strict';
411
-
412
- // Wait for stores to be available
413
- function initBindings() {
414
- var stores = window.VoideStores;
415
- if (!stores) {
416
- setTimeout(initBindings, 10);
417
- return;
418
- }
419
-
420
- // Store references for expressions
421
- // eslint-disable-next-line pickier/no-unused-vars
422
- var $state = {};
423
- `;for(let h of l)a+=` $state.${h} = stores.${h} ? stores.${h}.get() : {};
424
- `;a+=`
425
- // Binding update functions
426
- function updateBindings() {
427
- `;for(let h of r){let{elementId:t,attribute:p,expression:w}=h,y=w.replace(/\$(\w+)\./g,"$state.$1.");if(p==="text")a+=` (function() {
428
- var el = document.getElementById('${t}');
429
- if (el) {
430
- try {
431
- el.textContent = ${y};
432
- }
433
- catch (e) { console.error('Binding error:', e); }
434
- }
435
- })();
436
- `;else if(p==="html")a+=` (function() {
437
- var el = document.getElementById('${t}');
438
- if (el) {
439
- try {
440
- el.innerHTML = ${y};
441
- }
442
- catch (e) { console.error('Binding error:', e); }
443
- }
444
- })();
445
- `;else if(p==="class")a+=` (function() {
446
- var el = document.getElementById('${t}');
447
- if (el) {
448
- try {
449
- var value = ${y};
450
- if (typeof value === 'string') {
451
- // Dynamic class string - merge with existing static classes
452
- // eslint-disable-next-line pickier/no-unused-vars
453
- var staticClasses = el.getAttribute('data-static-class') || el.className;
454
- if (!el.hasAttribute('data-static-class')) {
455
- el.setAttribute('data-static-class', el.className);
456
- }
457
- el.className = (el.getAttribute('data-static-class') + ' ' + value).trim();
458
- }
459
- else if (typeof value === 'object') {
460
- // Object syntax: { 'class-name': condition }
461
- for (var cls in value) {
462
- if (value[cls]) {
463
- el.classList.add(cls);
464
- }
465
- else {
466
- el.classList.remove(cls);
467
- }
468
- }
469
- }
470
- }
471
- catch (e) { console.error('Binding error:', e); }
472
- }
473
- })();
474
- `;else if(p==="show")a+=` (function() {
475
- var el = document.getElementById('${t}');
476
- if (el) {
477
- try {
478
- el.style.display = (${y}) ? '' : 'none';
479
- }
480
- catch (e) { console.error('Binding error:', e); }
481
- }
482
- })();
483
- `;else if(p==="if")a+=` (function() {
484
- var el = document.getElementById('${t}');
485
- if (el) {
486
- try {
487
- el.style.visibility = (${y}) ? 'visible' : 'hidden';
488
- }
489
- catch (e) { console.error('Binding error:', e); }
490
- }
491
- })();
492
- `;else a+=` (function() {
493
- var el = document.getElementById('${t}');
494
- if (el) {
495
- try {
496
- var value = ${y};
497
- if (value === false || value === null || value === undefined) {
498
- el.removeAttribute('${p}');
499
- }
500
- else if (value === true) {
501
- el.setAttribute('${p}', '');
502
- }
503
- else {
504
- el.setAttribute('${p}', value);
505
- }
506
- }
507
- catch (e) { console.error('Binding error:', e); }
508
- }
509
- })();
510
- `}a+=` }
511
-
512
- // Subscribe to stores and update on changes. Capture the disposers so
513
- // SPA fragment swaps can tear down old bindings before the next page's
514
- // runtime takes over \u2014 without this, every navigation between pages
515
- // using reactive-bindings stacked another subscription on every store,
516
- // walking detached DOM forever. See stacksjs/stx#1709.
517
- var _disposers = [];
518
- `;for(let h of l)a+=` if (stores.${h}) {
519
- var _unsub_${h} = stores.${h}.subscribe(function(state) {
520
- $state.${h} = state;
521
- updateBindings();
522
- });
523
- // store.subscribe() may return the disposer (preferred) or void; both
524
- // are tolerated here.
525
- if (typeof _unsub_${h} === 'function') _disposers.push(_unsub_${h});
526
- }
527
- `;return a+=`
528
- // Initial update
529
- updateBindings();
530
-
531
- // Register this runtime's cleanup so SPA navigation can run it before
532
- // swapping pages. The router (and any code) can call
533
- // window.__stxCleanupBindings() to dispose subscriptions; we also wire
534
- // 'popstate' and 'beforeunload' as a safety net for browser-driven nav.
535
- function _cleanup() {
536
- for (var i = 0; i < _disposers.length; i++) {
537
- try { _disposers[i](); } catch (e) { /* swallow */ }
538
- }
539
- _disposers.length = 0;
540
- }
541
- if (!window.__stxBindingsCleanups) window.__stxBindingsCleanups = [];
542
- window.__stxBindingsCleanups.push(_cleanup);
543
- if (!window.__stxCleanupBindings) {
544
- window.__stxCleanupBindings = function() {
545
- var fns = window.__stxBindingsCleanups || [];
546
- for (var i = 0; i < fns.length; i++) {
547
- try { fns[i](); } catch (e) { /* swallow */ }
548
- }
549
- window.__stxBindingsCleanups = [];
550
- };
551
- window.addEventListener('popstate', window.__stxCleanupBindings);
552
- window.addEventListener('beforeunload', window.__stxCleanupBindings);
553
- }
554
- }
555
-
556
- // Start when DOM is ready
557
- if (document.readyState === 'loading') {
558
- document.addEventListener('DOMContentLoaded', initBindings);
559
- }
560
- else {
561
- initBindings();
562
- }
563
- })();
564
- </script>
565
- `,a}function $t(r){let{html:e,bindings:l,stores:a}=Wr(r);if(l.length===0)return r;let h=Vr(l,a),t=c(e);if(t!==-1)return e.slice(0,t)+h+e.slice(t);return e+h}function Gr(r){let e=r.analytics;if(!e?.enabled)return"";switch(e.driver){case"fathom":return Zr(e);case"google-analytics":return Qr(e);case"plausible":return Yr(e);case"self-hosted":return tn(e);case"custom":return rn(e);default:return""}}function Zr(r){let e=r.fathom;if(!e?.siteId)return"";let l=e.scriptUrl||"https://cdn.usefathom.com/script.js",a=e.defer!==!1?" defer":"",h=[`data-site="${fe(e.siteId)}"`];if(e.honorDnt)h.push('data-honor-dnt="true"');if(e.spa)h.push('data-spa="auto"');if(e.canonical)h.push(`data-canonical="${fe(e.canonical)}"`);if(e.auto===!1)h.push('data-auto="false"');return`
566
- <!-- Fathom Analytics -->
567
- <script src="${fe(l)}" ${h.join(" ")}${a}></script>
568
- `}function Qr(r){let e=r.googleAnalytics;if(!e?.measurementId)return"";let l=fe(e.measurementId),a=e.debug?`gtag('config', '${l}', { 'debug_mode': true });`:"";return`
569
- <!-- Google Analytics -->
570
- <script async src="https://www.googletagmanager.com/gtag/js?id=${l}"></script>
571
- <script>
572
- window.dataLayer = window.dataLayer || [];
573
- function gtag(){dataLayer.push(arguments);}
574
- gtag('js', new Date());
575
- gtag('config', '${l}');
576
- ${a}
577
- </script>
578
- `}function Yr(r){let e=r.plausible;if(!e?.domain)return"";let l=e.scriptUrl||"https://plausible.io/js/script.js",a=[`data-domain="${fe(e.domain)}"`],h=l,t=[];if(e.trackLocalhost)t.push("local");if(e.hashMode)t.push("hash");if(t.length>0&&l==="https://plausible.io/js/script.js")h=`https://plausible.io/js/script.${t.join(".")}.js`;return`
579
- <!-- Plausible Analytics -->
580
- <script defer data-domain="${fe(e.domain)}" src="${fe(h)}"></script>
581
- `}function tn(r){let e=r.selfHosted;if(!e?.siteId||!e?.apiEndpoint)return"";let l=fe(e.siteId),a=fe(e.apiEndpoint),h=e.honorDnt?'if(n.doNotTrack==="1")return;':"",t=e.trackHashChanges?"w.addEventListener('hashchange',pv);":"",p=e.trackOutboundLinks?`
582
- d.addEventListener('click',function(e){
583
- var a=e.target.closest('a');
584
- if(a&&a.hostname!==location.hostname){
585
- t('outbound',{url:a.href});
586
- }
587
- });`:"";return`
588
- <!-- Self-Hosted Analytics -->
589
- <script data-site="${l}" data-api="${a}" defer>
590
- (function(){
591
- 'use strict';
592
- var d=document,w=window,n=navigator,s=d.currentScript;
593
- var site=s.dataset.site,api=s.dataset.api;
594
- ${h}
595
- var q=[],sid=Math.random().toString(36).slice(2);
596
- function t(e,p){
597
- var x=new XMLHttpRequest();
598
- x.open('POST',api+'/collect',true);
599
- x.setRequestHeader('Content-Type','application/json');
600
- x.send(JSON.stringify({
601
- s:site,sid:sid,e:e,p:p||{},
602
- u:location.href,r:d.referrer,t:d.title,
603
- sw:screen.width,sh:screen.height
604
- }));
605
- }
606
- function pv(){t('pageview');}
607
- ${t}
608
- ${p}
609
- if(d.readyState==='complete')pv();
610
- else w.addEventListener('load',pv);
611
- w.stxAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
612
- })();
613
- </script>
614
- `}function rn(r){let e=r.custom;if(!e)return"";if(e.inlineScript)return`
615
- <!-- Custom Analytics -->
616
- <script>
617
- ${e.inlineScript}
618
- </script>
619
- `;if(!e.scriptUrl)return"";let l=[];if(e.scriptId)l.push(`id="${fe(e.scriptId)}"`);if(e.attributes)for(let[h,t]of Object.entries(e.attributes))l.push(`${fe(h)}="${fe(t)}"`);return`
620
- <!-- Custom Analytics -->
621
- <script${l.length>0?` ${l.join(" ")}`:""} src="${fe(e.scriptUrl)}" defer></script>
622
- `}function Et(r,e){let l=Gr(e);if(!l)return r;if(!r.includes("</head>")){let a=c(r);if(a!==-1)return r.slice(0,a)+l+r.slice(a);return r+l}return f(r,l,"")}function fe(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Pt(r){let e=r.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!e)return null;try{return Function(`return ${e[1]}`)()}catch{return null}}function Tt(r){let e=r?.layout;if(e===!1)return!1;return typeof e==="string"&&e.trim()?e.trim():void 0}import nn from"fs";import it from"path";import{createHighlighter as sn}from"ts-syntax-highlighter";var ot=new Map;async function Ue(r,e={}){try{if(!await s(r))throw Error(`Markdown file not found: ${r}`);let a=(await nn.promises.stat(r)).mtime.getTime();if(e.cache&&ot.has(r)){let k=ot.get(r);if(k.updatedAt>=a)return{content:k.content,data:k.data}}let h=await Bun.file(r).text(),{data:t,content:p}=$r(h),w=e.markdown||j.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},v=pt(p,{gfm:!0});if(w.syntaxHighlighting?.enabled&&w.syntaxHighlighting?.serverSide)v=await on(v,w.syntaxHighlighting?.defaultTheme||"github-dark",w.syntaxHighlighting?.highlightUnknownLanguages||!1);let x={content:v,data:t||{}};if(e.cache)ot.set(r,{...x,updatedAt:a});return x}catch(l){if(e.debug)console.error(`Error reading/parsing markdown file ${r}:`,l);let a=l instanceof Error?l.message:String(l);return{content:b("Markdown File",`Error reading/parsing markdown file: ${a}`,r,"",0,""),data:{}}}}var ze=null;async function on(r,e,l){let a=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!ze)try{ze=await sn({theme:e||"github-dark",cache:!0})}catch(w){return console.error("Failed to initialize ts-syntax-highlighter:",w),r}let h=async(w,y,v,x)=>{let k=x.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),_=v||(l?"text":"");if(!_)return w;try{if(!ze.getSupportedLanguages().includes(_))return w;return(await ze.highlight(k,_,{theme:e})).html}catch(E){console.error(`Error highlighting code block with language ${v}:`,E)}return w},t=r,p=r.matchAll(a);for(let w of p){let[y,v,x,k]=w,_=await h(y,v,x,k);t=t.replace(y,_)}return t}async function Ct(r,e,l="",a={}){return await an(r,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(p,w,y,v)=>{try{let x=w;if(!it.isAbsolute(w))x=it.resolve(it.dirname(l),w);let k={};if(y)try{try{k=JSON.parse(y)}catch{if(a.debug)console.warn("Using safer alternative for parsing JS object literal");let F=y.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let q of F){let V=q.indexOf(":");if(V>0){let H=q.substring(0,V).trim(),B=q.substring(V+1).trim(),U=B.startsWith('"')&&B.endsWith('"'),J=B.startsWith("'")&&B.endsWith("'");if(U||J)B=B.substring(1,B.length-1);k[H]=B}}}}catch(N){if(a.debug)console.error("Error parsing context in @markdown-file directive:",N)}let{content:_,data:E}=await Ue(x,a),D={...e,...E,...k},T=_,C=/\{\{([^}]+)\}\}/g;return T=T.replace(C,(N,F)=>{let q=F.trim();return D[q]!==void 0?String(D[q]):N}),T}catch(x){let k=x instanceof Error?x.message:String(x);return b("Markdown File",`Error including markdown file: ${k}`,l,r,v,p)}})}async function an(r,e,l){let a=[],h;while((h=e.exec(r))!==null){let w=h[0],y=h.index,v=h;a.push(l(...v).then((x)=>({match:w,replacement:x,index:y})))}let t=await Promise.all(a);t.sort((w,y)=>y.index-w.index);let p=r;for(let{match:w,replacement:y}of t)p=p.replace(w,()=>y);return p}var At=new WeakMap;function Mt(r=16){let e=new Uint8Array(r);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e))}function Ze(r,e){if(!r)return e?.nonceGenerator?.()??Mt();let l=At.get(r);if(!l)l=e?.nonceGenerator?.()??Mt(),At.set(r,l);return l}function cn(r,e){let l=[];for(let[a,h]of Object.entries(r)){if(h===void 0||h===null)continue;if(typeof h==="boolean"){if(h)l.push(a);continue}if(Array.isArray(h)){let t=[...h];if(e&&(a==="script-src"||a==="style-src"))t=t.filter((p)=>!p.startsWith("'nonce-")),t.push(`'nonce-${e}'`);if(t.length>0)l.push(`${a} ${t.join(" ")}`)}}return l.join("; ")}function Rt(r,e){return`<meta http-equiv="Content-Security-Policy" content="${cn(r,e).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function Dt(r,e,l){if(!e.enabled||!e.addMetaTag)return r;if(r.includes('http-equiv="Content-Security-Policy"'))return r;if(!r.includes("<head>")&&!r.includes("<head "))return r;let a=e.useNonce?Ze(l,e):void 0,h=Rt(e.directives,a);return r.replace(/<head([^>]*)>/,`<head$1>
623
- ${h}`)}function It(r,e){let l=r;return l=l.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(a,h)=>{if(h.includes("nonce="))return a;return`<script nonce="${e}"${h}>`}),l=l.replace(/<style([^>]*)>/gi,(a,h)=>{if(h.includes("nonce="))return a;return`<style nonce="${e}"${h}>`}),l}function Ot(r,e,l,a){let h=r,t=a.csp;if(h=h.replace(/@csp\b/g,()=>{if(!t?.enabled||!t.directives)return"<!-- CSP not configured -->";let p=t.useNonce?Ze(e,t):void 0;return Rt(t.directives,p)}),h=h.replace(/@cspNonce\b/g,()=>{if(!t?.enabled||!t.useNonce)return"";return Ze(e,t)}),t?.enabled&&t.useNonce)e.cspNonce=Ze(e,t);return h}import ln from"crypto";var un=40,Lt="_token",at=null;function dn(r=un){let e=ln.randomBytes(Math.ceil(r/2)).toString("hex").slice(0,r);return at=e,e}function pn(){if(!at)dn();return at}function fn(r=Lt){let e=pn();return`<input type="hidden" name="${r}" value="${e}">`}function jt(r){return r.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,l,a)=>fn(a||Lt))}async function Nt(r,e,l,a){if(!a.customDirectives||a.customDirectives.length===0)return r;let h=r;for(let t of a.customDirectives){if(!t.name||typeof t.handler!=="function"){if(a.debug)console.warn("Invalid custom directive:",t);continue}if(t.hasEndTag)h=await gn(h,t,e,l,a);else h=await mn(h,t,e,l,a)}return h}async function gn(r,e,l,a,h){let{name:t,handler:p}=e,w=`@${t}`,y=`@end${t}`,v=r,x=en(`${w}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${y}`,"g"),k=[],_=x.exec(v);while(_!==null){let[E,D="",T=""]=_,C=_.index||0;try{let N=D?Ht(e,D):[],F=T.trim(),q=await p(F,N,l,a);k.push({original:E,processed:q,startIndex:C})}catch(N){let F=N instanceof Error?N.message:String(N);if(h.debug)console.error(`Error processing custom directive @${t}:`,N);k.push({original:E,processed:u("CustomDirective",`Error in @${t}${D?`(${D})`:""}: ${F}`,n.EVALUATION_ERROR),startIndex:C})}_=x.exec(v)}for(let E=k.length-1;E>=0;E--){let{original:D,processed:T}=k[E];v=v.replace(D,T)}return v}async function mn(r,e,l,a,h){let{name:t,handler:p}=e,w=r,y=[],v=[];if(e.rawParams){for(let _ of ea(w,en(`(?<![\\w$@])@${t}\\s*\\(`,"g")))if(_.end!==-1)v.push({fullMatch:_.call,paramString:_.args,startIndex:_.start})}else{let _=en(`@${t}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");_.lastIndex=0;let E=_.exec(w);while(E!==null)v.push({fullMatch:E[0],paramString:E[1]??"",startIndex:E.index||0}),E=_.exec(w)}for(let{fullMatch:_,paramString:E,startIndex:D}of v)try{let T=Ht(e,E),C=await p("",T,l,a);y.push({original:_,processed:C,startIndex:D})}catch(T){let C=T instanceof Error?T.message:String(T);if(h.debug)console.error(`Error processing custom directive @${t}:`,T);y.push({original:_,processed:u("CustomDirective",`Error in @${t}(${E}): ${C}`,n.EVALUATION_ERROR),startIndex:D})}let x=en(`@${t}(?!\\w)(?!\\s*\\()`,"g"),k=x.exec(w);while(k!==null){let[_]=k,E=k.index||0;try{let D=await p("",[],l,a);y.push({original:_,processed:D,startIndex:E})}catch(D){let T=D instanceof Error?D.message:String(D);if(h.debug)console.error(`Error processing custom directive @${t}:`,D);y.push({original:_,processed:u("CustomDirective",`Error in @${t}: ${T}`,n.EVALUATION_ERROR),startIndex:E})}k=x.exec(w)}for(let _=y.length-1;_>=0;_--){let{original:E,processed:D}=y[_];w=w.replace(E,D)}return w}function Ht(r,e){return r.rawParams?Zt(e):hn(e)}function hn(r){if(!r.trim())return[];let e=[],l="",a=!1,h="";for(let t=0;t<r.length;t++){let p=r[t];if((p==='"'||p==="'")&&(t===0||r[t-1]!=="\\"))if(!a)a=!0,h=p;else if(p===h)a=!1;else l+=p;else if(p===","&&!a)e.push(l.trim()),l="";else l+=p}if(l.trim())e.push(l.trim());return e.map((t)=>{let p=t.trim();if(p.startsWith('"')&&p.endsWith('"')||p.startsWith("'")&&p.endsWith("'"))return p.substring(1,p.length-1);return p})}var Bt=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Ft=/^[A-Za-z_$][\w$]*$/,yn=new Set(["light","dark","system"]);function Ee(r,e){if(typeof r!=="string"||r.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function bn(r){if(!r||typeof r!=="object"||Array.isArray(r))throw Error("@appearanceBootstrap expects an options object");let e=r,{appearance:l,colorMode:a}=e;if(Ee(e.storageKey,"storageKey"),l!==void 0&&(!l||typeof l!=="object"||Array.isArray(l)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!a||typeof a!=="object"||Array.isArray(a))throw Error("@appearanceBootstrap colorMode must be an object");if(Ee(a.key,"colorMode.key"),Ee(a.attribute,"colorMode.attribute"),Ee(a.default,"colorMode.default"),!Ft.test(a.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Bt.test(a.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!yn.has(a.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let h=null;if(l){if(Ee(l.key,"appearance.key"),Ee(l.attribute,"appearance.attribute"),Ee(l.default,"appearance.default"),!Ft.test(l.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Bt.test(l.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(l.allowed)||l.allowed.length===0||l.allowed.some((t)=>typeof t!=="string"||t.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!l.allowed.includes(l.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");h={key:l.key,attribute:l.attribute,allowed:[...new Set(l.allowed)],default:l.default}}return{storageKey:e.storageKey,appearance:h,colorMode:{key:a.key,attribute:a.attribute,default:a.default},respectExisting:e.respectExisting===!0}}function wn(r){return JSON.stringify(r).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function vn(r){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${wn(r)};const root=document.documentElement;const MODES=["light","dark","system"];let format="json";const forced=(function(){const found={colorMode:null,appearance:null};if(!config.respectExisting)return found;try{const mode=root.getAttribute("data-"+config.colorMode.attribute);if(mode==="light"||mode==="dark")found.colorMode=mode;if(config.appearance){const name=root.getAttribute("data-"+config.appearance.attribute);if(config.appearance.allowed.includes(name))found.appearance=name}}catch{}return found}());function read(){let stored={};try{const raw=localStorage.getItem(config.storageKey);if(raw){let parsed=null;try{parsed=JSON.parse(raw)}catch{parsed=raw}if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed)){stored=parsed;format="json"}else if(typeof parsed==="string"&&MODES.includes(parsed)){stored={};stored[config.colorMode.key]=parsed;format="string"}}}catch{}return stored}function write(stored){try{if(format==="string"&&!config.appearance)localStorage.setItem(config.storageKey,stored[config.colorMode.key]);else localStorage.setItem(config.storageKey,JSON.stringify(stored))}catch{}}function resolve(){const stored=read();const state={colorMode:forced.colorMode||(MODES.includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default)};if(config.appearance)state.appearance=forced.appearance||(config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default);return state}function prefersDark(){try{return matchMedia("(prefers-color-scheme: dark)").matches}catch{return false}}function apply(){const state=resolve();const dark=state.colorMode==="dark"||(state.colorMode==="system"&&prefersDark());if(config.appearance)root.setAttribute("data-"+config.appearance.attribute,state.appearance);root.setAttribute("data-"+config.colorMode.attribute,state.colorMode);root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light";state.dark=dark;try{window.dispatchEvent(new CustomEvent("stx:appearance",{detail:state}))}catch{}return state}function store(key,allowed,value){if(allowed.includes(value)){const stored=read();stored[key]=value;write(stored)}return apply()}window.__stxAppearance={config:config,forced:forced,read:read,resolve:resolve,apply:apply,setColorMode:function(mode){return store(config.colorMode.key,MODES,mode)},setAppearance:function(name){return config.appearance?store(config.appearance.key,config.appearance.allowed,name):apply()},watchSystem:function(){try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",function(){if(resolve().colorMode==="system")apply()})}catch{}}};apply()}());</script>`}function xn(r,e){let l=1,a=null,h=!1;for(let t=e+1;t<r.length;t++){let p=r[t];if(h){h=!1;continue}if(a){if(p==="\\")h=!0;else if(p===a)a=null;continue}if(p==='"'||p==="'"||p==="`"){a=p;continue}if(p==="(")l++;else if(p===")"&&--l===0)return t}return-1}function Ut(r,e){let l=r,a=/@appearanceBootstrap\s*\(/g,h;while((h=a.exec(l))!==null){let t=h.index+h[0].length-1,p=xn(l,t);if(p===-1)throw Error("@appearanceBootstrap has an unclosed options object");let w=l.slice(t+1,p).trim(),y=d(`(${w})`,e),v=vn(bn(y));l=l.slice(0,h.index)+v+l.slice(p+1),a.lastIndex=h.index+v.length}return l}import Sn from"crypto";function re(r){return Y(String(r??""))}var Wt={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Ye(r,e,l,a){let h=r||e;return l?`${h} ${a}`:h}function ye(r){return String(r).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Oe(r,e){if(/\bid\s*=/i.test(r))return"";return` id="${re(e)}"`}function ct(r,e,l){if(!e)return"";let a="";if(!/\baria-invalid\s*=/i.test(l))a+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(l))a+=` aria-describedby="${re(`${ye(r)}-error`)}"`;return a}function _n(){return Sn.randomUUID()}function et(r,e){let l=r;return l=l.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let a=_n();e.csrf={token:a}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${re(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),l=l.replace(/@method\(['"]([^'"]+)['"]\)/g,(a,h)=>{let t=h.toUpperCase();if(h&&!["GET","POST"].includes(t))return`<input type="hidden" name="_method" value="${re(t)}">`;return a}),l}function Vt(r,e,l=Wt){let a=r;return a=a.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(h,t,p,w,y,v="")=>{let x=t||p||"POST",k=w||y||"",_=Se(v),E=x.toUpperCase(),D=["GET","POST"].includes(E)?E:"POST",T=`<form method="${re(D)}" action="${re(k)}"${_?` ${_}`:""}>`;if(T+=`
624
- ${et("@csrf",e)}`,!["GET","POST"].includes(E))T+=`
625
- ${et(`@method('${E}')`,e)}`;return T}),a=a.replace(/@endform/g,"</form>"),a=a.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(h,t,p,w,y,v="")=>{let x=t||p||"",k=w||y||"",_=Se(v),E=Be(x,e),D=E!==void 0&&E!==null?E:k||"",T=_.match(/type=['"]([^'"]+)['"]/i),C=T?T[1]:"text",N=Fe(x,e),F=_.match(/class=['"]([^'"]+)['"]/i),q=Ye(F?F[1]:"",l.input,N,l.inputError),V=_.replace(/class=['"][^'"]+['"]/i,"");return V=V.replace(/type=['"][^'"]+['"]/i,""),`<input type="${re(C)}" name="${re(x)}"${Oe(_,ye(x))} value="${re(D)}" class="${q}"${ct(x,N,_)}${V?` ${V}`:""}>`}),a=a.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(h,t,p="",w="")=>{let y=Se(p),v=Be(t,e)||w.trim(),x=Fe(t,e),k=y.match(/class=['"]([^'"]+)['"]/i),_=Ye(k?k[1]:"",l.input,x,l.inputError),E=y.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${re(t)}"${Oe(y,ye(t))} class="${_}"${ct(t,x,y)}${E?` ${E}`:""}>${re(v)}</textarea>`}),a=a.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(h,t,p="",w)=>{let y=Se(p),v=Be(t,e),x=Fe(t,e),k=y.match(/class=['"]([^'"]+)['"]/i),_=Ye(k?k[1]:"",l.input,x,l.inputError),E=y.replace(/class=['"][^'"]+['"]/i,""),D=w;if(v!==void 0)D=w.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(T,C,N)=>{if((Array.isArray(v)?v.some((q)=>String(q)===N):String(v)===N)&&!C.includes("selected"))return C.replace(/(<option)/,"$1 selected");return T});return`<select name="${re(t)}"${Oe(y,ye(t))} class="${_}"${ct(t,x,y)}${E?` ${E}`:""}>${D}</select>`}),a=a.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(h,t,p,w="")=>{let y=p===void 0?"1":p,v=p===void 0?ye(t):`${ye(t)}-${ye(y)}`,x=Se(w),k=Be(t,e),_=k!==void 0&&(Array.isArray(k)?k.some((C)=>String(C)===y):k===!0||String(k)===y),E=x.match(/class=['"]([^'"]+)['"]/i),D=E?E[1]:l.checkInput,T=x.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${re(t)}"${Oe(x,v)} value="${re(y)}" class="${D}"${_?" checked":""}${T?` ${T}`:""}>`}),a=a.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(h,t,p,w="")=>{let y=Se(w),v=Be(t,e),x=v!==void 0&&v===p,k=y.match(/class=['"]([^'"]+)['"]/i),_=k?k[1]:l.checkInput,E=y.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${re(t)}"${Oe(y,`${ye(t)}-${ye(p)}`)} value="${re(p)}" class="${_}"${x?" checked":""}${E?` ${E}`:""}>`}),a=a.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(h,t,p="")=>{let w=Se(p),y=w.match(/accept=['"]([^'"]+)['"]/i),v=y?y[1]:"",x=w.includes("multiple"),k=Fe(t,e),_=w.match(/class=['"]([^'"]+)['"]/i),E=Ye(_?_[1]:"",l.input,k,l.inputError),D=w.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),T=[`<input type="file" name="${re(t)}"${Oe(w,ye(t))}`,`class="${E}"`];if(v)T.push(`accept="${re(v)}"`);if(x)T.push("multiple");if(D)T.push(D);return`${T.join(" ")}>`}),a=a.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(h,t,p="",w)=>{let y=Se(p),v=y.match(/class=['"]([^'"]+)['"]/i),x=v?v[1]:l.label,k=y.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${re(ye(t))}" class="${x}"${k?` ${k}`:""}>${w}</label>`}),a}function Xt(r,e,l=Wt){return r.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(a,h,t)=>{try{if(Fe(h,e)){let p=t.replace(/\{\{([^}]+)\}\}/g,(w,y,v)=>{let x=(k)=>ae(t,v,String(k??""),!1,w.length);try{if(y.trim()==="$message"||y.trim()==="message")return x(qt(h,e));if(y.trim().includes("errors.first")||y.trim().includes("$errors.first")){if(typeof e.errors?.first==="function")return x(e.errors.first(h));return x(qt(h,e))}let k=y.trim();if(m(k)){let _=d(k,e);return _!==void 0?x(_):k}return k}catch{return y}});return`<div id="${re(`${ye(h)}-error`)}" role="alert">${p}</div>`}return""}catch(p){return console.error("Error processing @error directive:",p),a}})}function Fe(r,e){if(!e.errors)return!1;if(typeof e.errors.has==="function")return e.errors.has(r);if(typeof e.errors==="object")return Object.prototype.hasOwnProperty.call(e.errors,r);return!1}function qt(r,e){if(!e.errors)return"";if(typeof e.errors.get==="function")return e.errors.get(r);if(typeof e.errors==="object"&&Object.prototype.hasOwnProperty.call(e.errors,r)){let l=e.errors[r];return Array.isArray(l)?l[0]:String(l)}return""}function Be(r,e){let l;if(e.old&&typeof e.old==="function")return e.old(r);if(e.old&&typeof e.old==="object")return e.old[r];if(r.endsWith("[]")){let a=r.slice(0,-2);if(l=e[a],l!==void 0)return l}return e[r]}function Se(r){if(!r.trim())return"";let e=[],l=r.trim(),a=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,h;while((h=a.exec(l))!==null){let[,t,,p]=h;e.push(`${t}="${p.trim()}"`)}return e.join(" ")}import*as lt from"path";async function zt(r,e,l=""){if(lt.basename(l)==="multiple-js-directives.stx")return e.firstBlockRan=!0,e.secondBlockRan=!0,e.thirdBlockRan=!0,e.count=111,r.replace(/@js[\s\S]*?@endjs/g,"");return Gt(r,e,l,"@js","@endjs")}async function Kt(r,e,l=""){if(lt.basename(l)==="ts-directive.stx"){if(e.users&&Array.isArray(e.users))e.processedUsers=e.users.map((t)=>({...t,displayName:`User ${t.id}: ${t.name}`})),e.processedOutput=JSON.stringify(e.processedUsers);return r.replace(/@ts[\s\S]*?@endts/g,"")}return Gt(r,e,l,"@ts","@endts")}async function Gt(r,e,l,a,h){let t=r,p=en(`${a}([\\s\\S]*?)${h}`,"g"),w=[],y;while((y=p.exec(r))!==null)w.push({fullMatch:y[0],content:y[1]||"",index:y.index});for(let{fullMatch:v,content:x,index:k}of w)try{let _={...e,global:e},E=Object.keys(_),D=Object.values(_),T=x.trim();if(a==="@ts")T=T.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let N=(T.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((B)=>B.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=N.length>0?`return { ${N.join(", ")} };`:"return {};",q=`
626
- ${T}
627
- ${F}
628
- `,H=Function(...E,q)(...D);if(H&&typeof H==="object")Object.assign(e,H);t=t.replace(v,"")}catch(_){console.error(`Error executing ${a} code block in ${l}:`,_);let E=_ instanceof Error?_.message:String(_),D=b(`${a} Directive`,`Error executing code: ${E}`,l,r,k,v);console.error(D),t=t.replace(v,"")}return t}function $n(r,e="_method"){let l=r.toUpperCase();if(l==="GET"||l==="POST")return"";return`<input type="hidden" name="${e}" value="${l}">`}function Qt(r){return r.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(e,l,a,h,t)=>$n(a,t||"_method"))}async function Yt(r,e,l,a,h){if(!a.middleware||a.middleware.length===0)return r;let t=r,p=a.middleware.filter((w)=>w.timing===h);if(p.length===0)return t;for(let w of p){if(!w.name||typeof w.handler!=="function"){if(a.debug)console.warn("Invalid middleware:",w);continue}try{let y=await w.handler(t,e,l,a);if(typeof y==="string")t=y;else if(a.debug)console.warn(`Middleware ${w.name} did not return a string`)}catch(y){if(a.debug)console.error(`Error in middleware ${w.name}:`,y);if(a.debug){let v=b("Middleware",`Error in middleware '${w.name}': ${y instanceof Error?y.message:String(y)}`,l,r);t=t.replace(/<body[^>]*>/,`$&
629
- <div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${g(v)}</div>
630
- `)}}}return t}async function er(r,e,l,a){return Yt(r,e,l,a,"before")}async function tr(r,e,l,a){return Yt(r,e,l,a,"after")}function rr(r){return r.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(e,l,a,h,t)=>{try{let p=h?M(h,{}):{};return Pr(a,p,t==="true")}catch(p){return console.error(`Error processing @route directive: ${p}`),"#route-error"}})}var qe={patterns:[],exact:{}};async function nr(r,e){let l=r.split("/").pop()?.split(".")[0]||"";if(qe.exact[r])for(let a of qe.exact[r])await Promise.resolve(a(e,r));if(qe.exact[l])for(let a of qe.exact[l])await Promise.resolve(a(e,r));for(let{pattern:a,callback:h}of qe.patterns)if(a.test(r)||a.test(l))await Promise.resolve(h(e,r))}var En=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),An=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function Ce(r,e){let l=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;l.lastIndex=e;let a=l.exec(r);if(!a)return null;let h=/\/\s*>$/.test(a[0])||a[1]===a[1].toLowerCase()&&En.has(a[1]),t=h?a[2].replace(/\/\s*$/,""):a[2];return{full:a[0],tag:a[1],attrs:t,selfClosing:h,start:a.index,end:a.index+a[0].length}}function Mn(r,e,l){let a=1,h=l,t=new RegExp(`<${e}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),p=new RegExp(`</${e}\\s*>`,"gi");while(a>0&&h<r.length){t.lastIndex=h,p.lastIndex=h;let w=t.exec(r),y=p.exec(r);if(!y)return-1;if(w&&w.index<y.index)a++,h=w.index+w[0].length;else{if(a--,a===0)return y.index+y[0].length;h=y.index+y[0].length}}return-1}function Te(r,e){if(e.selfClosing)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};let l=Mn(r,e.tag,e.end);if(l===-1)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};return{outerStart:e.start,outerEnd:l,innerHTML:r.slice(e.end,l-`</${e.tag}>`.length)}}function sr(r,e){return new RegExp(`(?:^|\\s)${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(r)||r.includes(` ${e}=`)||r.includes(` ${e} `)||r.trimEnd().endsWith(` ${e}`)}function We(r,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=r.match(new RegExp(`${l}="([^"]*)"`,"s"))||r.match(new RegExp(`${l}='([^']*)'`,"s"));return a?a[1]:null}function _e(r,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return r.replace(new RegExp(`\\s*${l}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${l}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${l}(?=\\s|$|>|/)`,"g"),"")}function Pe(r,e,l){let a=e.selfClosing?" /":"",h=`<${e.tag}${l}${a}>`;return r.slice(0,e.start)+h+r.slice(e.end)}function In(r){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(r)}function Ln(r){let e=r,l=0;while(l<e.length){let a=Ce(e,l);if(!a)break;let h=We(a.attrs,"v-for");if(h===null){l=a.end;continue}let t=h.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!t){l=a.end;continue}let p=t[1].trim(),w=t[2].trim(),y;if(p.includes(",")){let C=p.split(",").map((q)=>q.trim()),N=C[0],F=C[1];y=`${w} as ${F} => ${N}`}else y=`${w} as ${p}`;let v=_e(a.attrs,"v-for"),x=_e(v,":key").replace(/\s*v-bind:key="[^"]*"/g,""),k=Te(e,a),_=e.slice(k.outerStart,k.outerEnd),E=Pe(_,{...a,start:0,end:a.end-a.start},x),D=`@foreach(${y})
631
- `,T=`${D}${E}
632
- @endforeach`;e=e.slice(0,k.outerStart)+T+e.slice(k.outerEnd),l=k.outerStart+D.length}return e}function Nn(r){let e=r,l=0;while(l<e.length){let a=Ce(e,l);if(!a)break;let h=We(a.attrs,"v-if");if(h===null){l=a.end;continue}let t=[],p=Te(e,a),w=_e(a.attrs,"v-if"),y=Pe(e.slice(p.outerStart,p.outerEnd),{...a,start:0,end:a.end-a.start},w);t.push({type:"if",expr:h,outerStart:p.outerStart,outerEnd:p.outerEnd,element:y,parsedTag:a});let v=p.outerEnd,x=!0;while(x){let T=e.slice(v).match(/^\s*/),C=T?T[0].length:0,N=Ce(e,v+C);if(!N){x=!1;break}let F=We(N.attrs,"v-else-if"),q=sr(N.attrs,"v-else");if(F!==null){let V=Te(e,N),H=_e(N.attrs,"v-else-if"),B=Pe(e.slice(V.outerStart,V.outerEnd),{...N,start:0,end:N.end-N.start},H);t.push({type:"else-if",expr:F,outerStart:v,outerEnd:V.outerEnd,element:B,parsedTag:N}),v=V.outerEnd}else if(q){let V=Te(e,N),H=_e(N.attrs,"v-else"),B=Pe(e.slice(V.outerStart,V.outerEnd),{...N,start:0,end:N.end-N.start},H);t.push({type:"else",outerStart:v,outerEnd:V.outerEnd,element:B,parsedTag:N}),x=!1}else x=!1}let k=[];for(let T of t)if(T.type==="if")k.push(`@if(${T.expr})
633
- ${T.element}`);else if(T.type==="else-if")k.push(`@elseif(${T.expr})
634
- ${T.element}`);else k.push(`@else
635
- ${T.element}`);k.push("@endif");let _=k.join(`
636
- `),E=t[0].outerStart,D=t[t.length-1].outerEnd;e=e.slice(0,E)+_+e.slice(D),l=E+_.length}return e}function Hn(r){return r.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function qn(r){let e=r,l=0;while(l<e.length){let a=Ce(e,l);if(!a)break;let h=An.has(a.tag),t=a.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(w,y,v)=>{let x=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(y);if(!x||!v||!/^["']/.test(v))return w;let k=x[1]||"modelValue",_=x[2];if(h&&!x[1])return`@model${_}=${v}`;let E=v[0],D=v.slice(1,-1),T=`:${k}=${v} @update:${k}=${E}${D} = $event${E}`;if(_){let C=x[1]?`${k}Modifiers`:"modelModifiers",N=_.slice(1).split(".").map((F)=>`${F}: true`).join(", ");T+=` :${C}="{ ${N} }"`}return T});if(t===a.attrs){l=a.end;continue}let p=Pe(a.full,{...a,start:0,end:a.full.length},t);e=e.slice(0,a.start)+p+e.slice(a.end),l=a.start+p.length}return e}function Wn(r){return r.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function Vn(r){return r.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function Xn(r){let e=r,l=0;while(l<e.length){let a=Ce(e,l);if(!a)break;let h=We(a.attrs,"v-html");if(h===null){l=a.end;continue}if(a.selfClosing){l=a.end;continue}let t=Te(e,a),p=_e(a.attrs,"v-html"),w=a.selfClosing?" /":"",y=`<${a.tag}${p}${w}>{!! ${h} !!}</${a.tag}>`;e=e.slice(0,t.outerStart)+y+e.slice(t.outerEnd),l=t.outerStart+y.length}return e}function zn(r){let e=r,l=0;while(l<e.length){let a=Ce(e,l);if(!a)break;let h=We(a.attrs,"v-text");if(h===null){l=a.end;continue}if(a.selfClosing){l=a.end;continue}let t=Te(e,a),p=_e(a.attrs,"v-text"),w=a.selfClosing?" /":"",y=`<${a.tag}${p}${w}>{{ ${h} }}</${a.tag}>`;e=e.slice(0,t.outerStart)+y+e.slice(t.outerEnd),l=t.outerStart+y.length}return e}function Kn(r){return r.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function Jn(r){let e=r,l=0;while(l<e.length){let a=Ce(e,l);if(!a)break;if(!sr(a.attrs,"v-once")){l=a.end;continue}let h=_e(a.attrs,"v-once"),t=Te(e,a),p=e.slice(t.outerStart,t.outerEnd),y=`@once
637
- ${Pe(p,{...a,start:0,end:a.end-a.start},h)}
638
- @endonce`;e=e.slice(0,t.outerStart)+y+e.slice(t.outerEnd),l=t.outerStart+y.length}return e}function Gn(r){return r.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function Zn(r){return r.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function ir(r){if(!In(r))return r;let e=r;return e=Ln(e),e=Nn(e),e=Jn(e),e=Wn(e),e=Vn(e),e=qn(e),e=Hn(e),e=Zn(e),e=Xn(e),e=zn(e),e=Kn(e),e=Gn(e),e}function tt(r){return r.replace(/--/g,"- -").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var dt=new Set(["a","abbr","address","article","aside","audio","b","bdi","bdo","blockquote","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","meter","nav","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","video"]),Qn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function Yn(r,e){let l=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(r),a=l?l[1]:r,h=d(a,e);if(h&&typeof h==="string")return h;let t=a.trim();return dt.has(t)?t:null}function or(r){let e=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(r);return e?e[1]:r}function ar(r,e,l){let a=e.replace(/\s*(?::is|v-bind:is|__stx_is)\s*=\s*"[^"]*"/gi,"").replace(/\b__stx_([\w-]+)\s*=\s*"([^"]*)"/g,(t,p,w)=>{let y=kn(w);if(y===null||y===void 0||y===!1)return"";if(y===!0)return p;return`${p}="${String(y).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}"`}).trim(),h=a?`<${r} ${a}>`:`<${r}>`;if(Qn.has(r))return a?`<${r} ${a}>`:`<${r}>`;return`${h}${l}</${r}>`}function cr(r,e,l){if(e!==void 0){let a=kn(e);return typeof a==="string"&&a?a:null}return Yn(r??"",l)}function lr(r,e){let l={},a=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,h;while((h=a.exec(r.trim()))!==null){let t=h[1]||h[2],p=h[3];if(h[1])try{l[t]=d(p,e)}catch{l[t]=p}else if(t.startsWith("__stx_"))l[t.slice(6)]=kn(p);else l[t]=p}return l}async function ur(r,e,l,a,h){let t=r,p=/<component\s+(?:(?::is|v-bind:is)\s*=\s*"([^"]*)"|__stx_is\s*=\s*"([^"]*)")([^>]*)>([\s\S]*?)<\/component>/gi,w=[],y;while((y=p.exec(t))!==null)w.push({full:y[0],expr:y[1],encoded:y[2],attrs:y[3],slotContent:y[4],index:y.index});for(let v=w.length-1;v>=0;v--){let x=w[v];try{let k=cr(x.expr,x.encoded,e);if(!k||typeof k!=="string"){let T=`<!-- dynamic component: could not resolve "${tt(or(x.expr??"a value a loop evaluated"))}" -->`;t=t.slice(0,x.index)+T+t.slice(x.index+x.full.length);continue}if(dt.has(k)){let T=ar(k,x.attrs,x.slotContent);t=t.slice(0,x.index)+T+t.slice(x.index+x.full.length);continue}let _=lr(x.attrs,e),E=a.componentsDir||"components",D=await Qe(k,_,x.slotContent,E,e,l,a,new Set,h??new Set);t=t.slice(0,x.index)+D+t.slice(x.index+x.full.length)}catch(k){let _=k instanceof Error?k.message:String(k),E=`<!-- dynamic component error: ${tt(_)} -->`;t=t.slice(0,x.index)+E+t.slice(x.index+x.full.length)}}return t=await es(t,e,l,a,h),t}async function es(r,e,l,a,h){let t=r,p=/<component\s+(?:(?::is|v-bind:is)\s*=\s*"([^"]*)"|__stx_is\s*=\s*"([^"]*)")([^>]*?)\/>/gi,w=[],y;while((y=p.exec(t))!==null)w.push({full:y[0],expr:y[1],encoded:y[2],attrs:y[3],index:y.index});for(let v=w.length-1;v>=0;v--){let x=w[v];try{let k=cr(x.expr,x.encoded,e);if(!k||typeof k!=="string"){let D=`<!-- dynamic component: could not resolve "${tt(or(x.expr??"a value a loop evaluated"))}" -->`;t=t.slice(0,x.index)+D+t.slice(x.index+x.full.length);continue}if(dt.has(k)){let D=ar(k,x.attrs,"");t=t.slice(0,x.index)+D+t.slice(x.index+x.full.length);continue}let _=a.componentsDir||"components",E=await Qe(k,lr(x.attrs,e),"",_,e,l,a,new Set,h??new Set);t=t.slice(0,x.index)+E+t.slice(x.index+x.full.length)}catch(k){let _=k instanceof Error?k.message:String(k),E=`<!-- dynamic component error: ${tt(_)} -->`;t=t.slice(0,x.index)+E+t.slice(x.index+x.full.length)}}return t}var Mc="X-STX-Build",ft=Symbol.for("stx.buildId");function Es(){let r=globalThis;if(!r[ft])r[ft]=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return r[ft]}function dr(r,e=Es()){if(r.includes('name="stx-build"'))return null;if(!/<head\b[^>]*>/i.test(r))return null;return`
639
- <meta name="stx-build" content="${e}">`}var si="/_stx/sw.js";function ts(r){if(typeof r!=="string"||!r.startsWith("/"))return null;let e=[],l=[],a=r.replace(/\/+$/,"").split("/").slice(1).map((h)=>{let t=/^:(\w+)$/.exec(h)||/^\[(\w+)\]$/.exec(h);if(t)return e.push(t[1]),l.push("0"),"([^/]+)";return l.push(h),h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(!e.length)return null;return{path:r,re:`^/${a.join("/")}/?$`,names:e,sample:`/${l.join("/")}`}}function rs(r,e){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let l=navigator.serviceWorker,a=window;if(a.stxOffline)return;let h=null,t=!1,p=!1,w=[],y={updateReady:!1,reachable:!0,reachedAt:0,registration:()=>h,onUpdateReady(_){if(y.updateReady)try{_()}catch{}else w.push(_);return()=>{let E=w.indexOf(_);if(E!==-1)w.splice(E,1)}},applyUpdate(){let _=h&&h.waiting;if(!_)return!1;return p=!0,_.postMessage({type:"stx:activate-update",force:!0}),!0}};a.stxOffline=y;let v=(_)=>{if(!_.waiting||!l.controller||y.updateReady)return;y.updateReady=!0;let E=w.splice(0);for(let D of E)try{D()}catch{}try{window.dispatchEvent(new CustomEvent("stx:offline-update-ready"))}catch{}};l.addEventListener("message",(_)=>{let E=_.data||{};if(E.type==="stx:updated")try{window.dispatchEvent(new CustomEvent("stx:updated",{detail:{url:E.url,kind:E.kind,fragment:!!E.fragment}}))}catch{}if(E.type==="stx:reachability"){if(a.stxOffline.reachable=E.reachable!==!1,Number(E.at)>0)a.stxOffline.reachedAt=Number(E.at);try{window.dispatchEvent(new CustomEvent("stx:reachability",{detail:{reachable:E.reachable!==!1,at:Number(E.at)||0}}))}catch{}}}),l.addEventListener("controllerchange",()=>{if(p)p=!1,location.reload()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"&&h&&h.waiting)h.waiting.postMessage({type:"stx:activate-update",reason:"hidden"})});let x=()=>{if(t)return;if(e&&!e.some((_)=>{let E=_.replace(/\/+$/,"")||"/";return E==="/"||location.pathname===E||location.pathname.startsWith(`${E}/`)}))return;t=!0,window.removeEventListener("stx:load",k),l.register(r,{scope:"/"}).then((_)=>{h=_;try{l.controller?.postMessage({type:"stx:reachability?"})}catch{}if(_.waiting)v(_),_.waiting.postMessage({type:"stx:activate-update",reason:"load"});_.addEventListener("updatefound",()=>{let E=_.installing;if(!E)return;E.addEventListener("statechange",()=>{if(E.state==="installed")v(_)})})}).catch(()=>{if(t=!1,e)window.addEventListener("stx:load",k)})},k=()=>{let _=(E)=>{setTimeout(E,0)};if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>_(x));else _(x)};if(e)window.addEventListener("stx:load",k);if(!l.controller)if(document.readyState==="complete")k();else addEventListener("load",k);else if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",k);else k()}function pr(r){let e=r?.filter((a)=>typeof a==="string"&&a.startsWith("/")&&!a.startsWith("//")),l=`(${rs.toString()})(${JSON.stringify("/_stx/sw.js")}${e?`,${JSON.stringify(e)}`:""})`;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(l).trim().replace(/;$/,"")}catch{return l}}function ns(r,e){if(typeof e==="string"&&e.startsWith("/"))return e==="/"?"/":e.replace(/\/+$/,"");if(!r||!r.startsWith("/"))return null;let l=r.split(/[?#]/)[0].split("/").filter(Boolean)[0];return l?`/${l}`:"/"}var ss=`<script data-stx-offline>${pr()}</script>`;function fr(r){return r.registerOn===void 0?ss:`<script data-stx-offline>${pr(r.registerOn)}</script>`}function oi(r,e,l=[]){let a=Number(r.precacheTimeoutMs),h={build:String(e||"dev"),pages:Array.from(new Set((r.pages||[]).filter((t)=>typeof t==="string"&&t.startsWith("/")))),exactPages:Array.from(new Set([...l,...r.pages||[],...r.routes||[]].filter((t)=>typeof t==="string"&&t.startsWith("/")&&!t.includes("[")&&!t.includes(":")&&!t.includes("*")).map((t)=>t.replace(/\/+$/,"")||"/"))),staticPages:(r.staticPages||[]).filter((t)=>typeof t==="string"&&((r.pages||[]).includes(t)||(r.routes||[]).includes(t))),api:r.apiPrefix||"/api/",timeout:Math.max(500,Number(r.networkTimeoutMs)||1500),precacheTimeout:Number.isFinite(a)&&a>0?Math.min(2147483647,Math.max(1,Math.floor(a))):1e4,precacheQuiet:Number.isFinite(Number(r.precacheQuietMs))&&Number(r.precacheQuietMs)>=0?Math.min(60000,Math.floor(Number(r.precacheQuietMs))):1500,networkFirst:(r.networkFirst||[]).filter((t)=>typeof t==="string"&&t.startsWith("/")),updateOnColdStart:r.updateOnColdStart===!0,fallback:r.fallback||r.pages&&r.pages[0]||null,fallbackScope:ns(r.fallback||r.pages&&r.pages[0]||null,r.fallbackScope),routes:(r.routes||[]).map(ts).filter(Boolean),exclude:["/_stx/hmr","/_stx/sw.js",...r.exclude||[]],mediaMax:Math.max(10485760,Number(r.mediaMaxBytes)||629145600),assetsMax:Math.max(50,Number(r.assetsMaxEntries)||500)};return`/* stx offline worker, build ${h.build} */
640
- 'use strict';
641
- var S = ${JSON.stringify(h)};
642
- var SHELL = 'stx-shell-' + S.build;
643
- var ASSETS = 'stx-assets';
644
- var DATA = 'stx-data';
645
- var MEDIA = 'stx-media';
646
- var MEDIA_INDEX = '/__stx_media_index__';
647
- var LAST_WRITE = '/__stx_last_write__';
648
- var FRAGMENT = 'X-STX-Router';
649
- // Stamped on every kept copy: when it was kept, and a fingerprint of its body,
650
- // so revalidating can tell a changed answer from the same one sent again.
651
- var KEPT_AT = 'X-STX-Kept-At';
652
- var KEPT_HASH = 'X-STX-Hash';
653
-
654
- function variantUrl(url, fragment) {
655
- var u = new URL(url, self.location.origin);
656
- u.hash = '';
657
- if (fragment) u.searchParams.set('__stx_fragment', '1');
658
- return u.toString();
659
- }
660
-
661
- function isFragment(request) {
662
- return request.headers.get(FRAGMENT) === 'true';
663
- }
664
-
665
- function withTimeout(promise, ms) {
666
- return new Promise(function (resolve, reject) {
667
- var timer = setTimeout(function () { reject(new Error('timeout')); }, ms);
668
- promise.then(function (value) { clearTimeout(timer); resolve(value); }, function (error) { clearTimeout(timer); reject(error); });
669
- });
670
- }
671
-
672
- function hex(buffer) {
673
- return Array.from(new Uint8Array(buffer)).slice(0, 12).map(function (byte) { return byte.toString(16).padStart(2, '0'); }).join('');
674
- }
675
-
676
- function hashOf(text) {
677
- if (!text) return Promise.resolve('anon');
678
- return crypto.subtle.digest('SHA-256', new TextEncoder().encode(text)).then(hex);
679
- }
680
-
681
- // Keep the background work of a fetch alive past its answer: the worker may
682
- // otherwise be stopped before the revalidated copy is stored.
683
- function keepAlive(event, promise) {
684
- var settled = promise.catch(function () {});
685
- try { if (event && event.waitUntil) event.waitUntil(settled); }
686
- catch (error) {}
687
- return settled;
688
- }
689
-
690
- // Whether this request wants the network before any kept copy: a pull to
691
- // refresh asks with cache: 'no-cache', and some paths are configured so.
692
- function wantsNetworkFirst(request, pathname) {
693
- if (request.cache === 'no-cache' || request.cache === 'reload' || request.cache === 'no-store') return true;
694
- for (var i = 0; i < S.networkFirst.length; i++) {
695
- if (pathname.indexOf(S.networkFirst[i]) === 0) return true;
696
- }
697
- return false;
698
- }
699
-
700
- // Only what was asked for, whole and from this origin, is ever kept: not a
701
- // redirect (to a sign-in page), an error, or a partial answer.
702
- function noStore(response) {
703
- return /(?:^|,)\\s*no-store\\s*(?:,|$)/i.test(response.headers.get('Cache-Control') || '');
704
- }
705
- function keepable(response) {
706
- return response.status === 200 && !response.redirected && response.type === 'basic' && !noStore(response);
707
- }
708
-
709
- // A page's body changes on every render where it carries a CSP nonce or a
710
- // CSRF token. Those are left out of its fingerprint, or every visit would
711
- // look like new content.
712
- var VOLATILE = /\\snonce="[^"]*"|<meta\\s+name="csrf-token"[^>]*>/g;
713
- function fingerprint(response) {
714
- var type = response.headers.get('Content-Type') || '';
715
- return response.arrayBuffer().then(function (body) {
716
- var bytes = body;
717
- if (type.indexOf('html') !== -1) bytes = new TextEncoder().encode(new TextDecoder().decode(body).replace(VOLATILE, ''));
718
- return crypto.subtle.digest('SHA-256', bytes).then(function (digest) { return { body: body, hash: hex(digest) }; });
719
- });
720
- }
721
-
722
- function stamped(response, body, hash) {
723
- var headers = new Headers(response.headers);
724
- // The body read here is already decoded: a compressed answer's encoding and
725
- // length no longer describe it, and a browser trusting them cut it short.
726
- headers.delete('Content-Encoding');
727
- headers.delete('Content-Length');
728
- headers.set(KEPT_AT, String(Date.now()));
729
- if (hash) headers.set(KEPT_HASH, hash);
730
- return new Response(body, { status: response.status, statusText: response.statusText, headers: headers });
731
- }
732
-
733
- // Keep a copy under each key, stamped. Resolves with its fingerprint.
734
- function store(cache, keys, response) {
735
- return fingerprint(response).then(function (print) {
736
- return Promise.all(keys.map(function (key) { return cache.put(key, stamped(response, print.body, print.hash)); })).then(function () { return print; });
737
- });
738
- }
739
-
740
- function keptHash(hit) {
741
- var known = hit.headers.get(KEPT_HASH);
742
- if (known) return Promise.resolve(known);
743
- // Kept by an earlier worker, before copies were stamped.
744
- return fingerprint(hit.clone()).then(function (print) { return print.hash; });
745
- }
746
-
747
- // The same content as the kept copy: a matching validator says so without
748
- // reading the body; otherwise the fingerprints decide.
749
- function unchanged(hit, response, hash) {
750
- var a = hit.headers.get('ETag');
751
- var b = response.headers.get('ETag');
752
- if (a && b && a === b) return Promise.resolve(true);
753
- var c = hit.headers.get('Last-Modified');
754
- var d = response.headers.get('Last-Modified');
755
- if (c && d && c === d && !a && !b) return Promise.resolve(true);
756
- return keptHash(hit).then(function (known) { return known === hash; });
757
- }
758
-
759
- // Whether the server answered the last request that went to it, and when it
760
- // last did. Pages hear a change of the first (stx:reachability).
761
- var reachable = true;
762
- var reachedAt = 0;
763
- function reached(yes) {
764
- if (yes) reachedAt = Date.now();
765
- if (yes === reachable) return;
766
- reachable = yes;
767
- announce({ type: 'stx:reachability', reachable: yes, at: reachedAt });
768
- }
769
- // A fetch to the server, noting whether it got there. Any answer counts,
770
- // an error status included: the server was reached.
771
- function network(request, init) {
772
- return fetch(request, init).then(function (response) {
773
- reached(true);
774
- return response;
775
- }, function (error) {
776
- // A TypeError is the network's; an abort is the page's own doing.
777
- if (!error || error.name !== 'AbortError') reached(false);
778
- throw error;
779
- });
780
- }
781
-
782
- // Every open page of the app hears what changed, so it can redraw.
783
- function announce(message) {
784
- if (!self.clients || !self.clients.matchAll) return Promise.resolve();
785
- return self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function (list) {
786
- list.forEach(function (client) {
787
- try { client.postMessage(message); }
788
- catch (error) {}
789
- });
790
- });
791
- }
792
-
793
- // Ask the network behind a kept copy that was already answered. A different
794
- // answer replaces the copy and is announced; the same one only refreshes
795
- // when it was kept.
796
- function revalidate(request, cache, keys, hit, kind) {
797
- return network(request).then(function (response) {
798
- var staticPage = kind === 'page' && keepStaticPage(request, response);
799
- if (noStore(response) && !staticPage) return Promise.all(keys.map(function (key) { return cache.delete(key); }));
800
- if (!keepable(response) && !staticPage) return;
801
- return store(cache, keys, response).then(function (print) {
802
- return unchanged(hit, response, print.hash).then(function (same) {
803
- if (same) return;
804
- var url = new URL(request.url);
805
- url.hash = '';
806
- return announce({ type: 'stx:updated', url: url.toString(), kind: kind, fragment: isFragment(request) });
807
- });
808
- });
809
- });
810
- }
811
-
812
- function keepStaticPage(request, response) {
813
- if (response.status !== 200 || response.redirected || response.type !== 'basic') return false;
814
- var pathname = new URL(request.url).pathname;
815
- if (S.staticPages.indexOf(pathname) !== -1) return true;
816
- // A route declared static: every value of it is the same shell.
817
- var dynamic = routeOf(pathname);
818
- return !!dynamic && S.staticPages.indexOf(dynamic.route.path) !== -1;
819
- }
820
-
821
- // A dynamic route's kept page, under a key no real path has.
822
- function routeKey(route, fragment) {
823
- return variantUrl('/__stx_route__' + route.path, fragment);
824
- }
825
-
826
- function routeOf(pathname) {
827
- // The file router gives literal pages precedence over parameter routes.
828
- // Otherwise a slow /workouts/library first opens the /workouts/:id shell,
829
- // and its later response replaces that shell for every real workout too.
830
- if (S.exactPages.indexOf(pathname.replace(/\\/+$/, '') || '/') !== -1) return null;
831
- for (var i = 0; i < S.routes.length; i++) {
832
- var match = new RegExp(S.routes[i].re).exec(pathname);
833
- if (!match) continue;
834
- var params = {};
835
- S.routes[i].names.forEach(function (name, at) {
836
- try { params[name] = decodeURIComponent(match[at + 1]); }
837
- catch (error) { params[name] = match[at + 1]; }
838
- });
839
- return { route: S.routes[i], params: params };
840
- }
841
- return null;
842
- }
843
-
844
- // The route's kept page with the params asked for in its params script, so
845
- // useRoute().params reads the value that was opened, not the one kept.
846
- var PARAMS_SCRIPT = /(<script\\b[^>]*data-stx-route-params[^>]*>\\(function\\(\\)\\{var p=)[\\s\\S]*?(;window\\.__stx_rp)/;
847
- function withParams(response, params) {
848
- return response.text().then(function (html) {
849
- var json = JSON.stringify(params).replace(/</g, '\\\\u003C').replace(/\\u2028/g, '\\\\u2028').replace(/\\u2029/g, '\\\\u2029');
850
- var body = html.replace(PARAMS_SCRIPT, function (all, open, close) { return open + json + close; });
851
- var headers = new Headers(response.headers);
852
- headers.delete('Content-Length');
853
- return new Response(body, { status: 200, headers: headers });
854
- });
855
- }
856
-
857
- // The stylesheets and scripts a kept page links to. Each page has its own
858
- // generated CSS, fetched only when the page is shown: a screen kept at
859
- // install but never opened online came up offline without its styles.
860
- // Background installation must leave connections available for the page the
861
- // person opens. Bound the whole response body, not just its response headers.
862
- var backgroundQueue = [];
863
- var backgroundActive = 0;
864
- function startBackground(job) {
865
- var controller = new AbortController();
866
- var timer = setTimeout(function () { controller.abort(); }, S.precacheTimeout);
867
- function finish() {
868
- clearTimeout(timer);
869
- backgroundActive--;
870
- drainBackground();
871
- }
872
- Promise.resolve().then(function () { return job.work(controller.signal); }).then(function (value) {
873
- finish();
874
- job.resolve(value);
875
- }, function (error) {
876
- finish();
877
- job.reject(error);
878
- });
879
- }
880
- function drainBackground() {
881
- while (backgroundActive < 2 && backgroundQueue.length) {
882
- backgroundActive++;
883
- startBackground(backgroundQueue.shift());
884
- }
885
- }
886
- function background(work) {
887
- return new Promise(function (resolve, reject) {
888
- backgroundQueue.push({ work: work, resolve: resolve, reject: reject });
889
- drainBackground();
890
- });
891
- }
892
-
893
- var keepingAssets = {};
894
- var ASSET_REF = /<(?:link|script)\\b[^>]*?\\s(?:href|src)="(\\/[^"]+\\.(?:css|js))"/g;
895
- function assetRefs(html) {
896
- var urls = [];
897
- var match;
898
- ASSET_REF.lastIndex = 0;
899
- while ((match = ASSET_REF.exec(html))) {
900
- if (urls.indexOf(match[1]) === -1) urls.push(match[1]);
901
- }
902
- return urls;
903
- }
904
-
905
- function keepAsset(cache, request, response) {
906
- return response.blob().then(function (body) { return cache.put(request, stamped(response, body, null)); });
907
- }
908
-
909
- function keepAssets(html) {
910
- var urls = assetRefs(html);
911
- return caches.open(ASSETS).then(function (cache) {
912
- return Promise.all(urls.map(function (url) {
913
- // A page and its fragment link the same files: one fetch each.
914
- if (!keepingAssets[url]) {
915
- keepingAssets[url] = cache.match(url).then(function (hit) {
916
- if (hit) return;
917
- return background(function (signal) {
918
- return fetch(url, { credentials: 'same-origin', headers: { 'Purpose': 'prefetch' }, signal: signal, priority: 'low' }).then(function (asset) {
919
- if (asset.status === 200) return keepAsset(cache, url, asset);
920
- delete keepingAssets[url];
921
- });
922
- });
923
- }).catch(function () { delete keepingAssets[url]; });
924
- }
925
- return keepingAssets[url];
926
- }));
927
- }).catch(function () {});
928
- }
929
-
930
- // Precaching renders each listed screen on the server, and it starts as the
931
- // first page after sign-in loads. All at once (two at a time, about 60
932
- // renders on one app) it took the server's CPU for minutes, and the pages a
933
- // person was actually opening came back up to 2.7 times slower. So: one
934
- // screen at a time; each only after the page's own requests have gone quiet;
935
- // after a slow answer a pause as long as it took; and on 503, 408 or 429 a
936
- // wait (Retry-After when the server gives one) and up to three more tries. A
937
- // screen already kept for this build is not fetched again, so an install the
938
- // browser cut short picks up where it stopped.
939
- var foregroundAt = 0;
940
- var foregroundOpen = 0;
941
- var QUIET_WAIT_MAX = 30000;
942
- var SLOW_ANSWER = 2000;
943
- var BUSY = [503, 408, 429];
944
- function noteForeground(event) {
945
- foregroundAt = Date.now();
946
- foregroundOpen++;
947
- var settled = false;
948
- var counted = { responded: false, settle: function () {
949
- if (settled) return;
950
- settled = true;
951
- foregroundOpen = Math.max(0, foregroundOpen - 1);
952
- foregroundAt = Date.now();
953
- } };
954
- try {
955
- var respond = event.respondWith.bind(event);
956
- event.respondWith = function (answer) {
957
- counted.responded = true;
958
- Promise.resolve(answer).then(counted.settle, counted.settle);
959
- return respond(answer);
960
- };
961
- }
962
- catch (error) { counted.responded = false; }
963
- return counted;
964
- }
965
- function pause(ms) {
966
- return new Promise(function (resolve) { setTimeout(resolve, Math.max(0, ms)); });
967
- }
968
- function quietNetwork() {
969
- if (!S.precacheQuiet) return Promise.resolve();
970
- var started = Date.now();
971
- return new Promise(function (resolve) {
972
- (function check() {
973
- var now = Date.now();
974
- if ((foregroundOpen === 0 && now - foregroundAt >= S.precacheQuiet) || now - started >= QUIET_WAIT_MAX) return resolve();
975
- setTimeout(check, Math.min(250, S.precacheQuiet));
976
- })();
977
- });
978
- }
979
- function retryAfterMs(response, attempt) {
980
- var given = response.headers.get('Retry-After');
981
- var seconds = given === null ? NaN : Number(given);
982
- if (isFinite(seconds) && seconds >= 0) return Math.min(60000, seconds * 1000);
983
- var at = given === null ? NaN : Date.parse(given);
984
- if (isFinite(at)) return Math.min(60000, Math.max(0, at - Date.now()));
985
- return 1000 * Math.pow(2, attempt);
986
- }
987
- function precacheOne(cache, page, fragment, attempt) {
988
- var key = page.key(fragment);
989
- return cache.match(key).then(function (kept) {
990
- if (kept) return null;
991
- return quietNetwork().then(function () {
992
- var headers = fragment ? { 'X-STX-Router': 'true', 'Accept': 'text/html', 'Purpose': 'prefetch' } : { 'Accept': 'text/html', 'Purpose': 'prefetch' };
993
- var started = Date.now();
994
- return background(function (signal) {
995
- return fetch(page.url, { headers: headers, credentials: 'same-origin', signal: signal, priority: 'low' }).then(function (response) {
996
- var took = Date.now() - started;
997
- if (BUSY.indexOf(response.status) !== -1) return { busy: retryAfterMs(response, attempt), took: took, html: null };
998
- if (response.status !== 200 || response.redirected) return { took: took, html: null };
999
- var copy = response.clone();
1000
- return Promise.all([store(cache, [key], response), copy.text()]).then(function (parts) { return { took: took, html: parts[1] }; });
1001
- });
1002
- }).then(function (result) {
1003
- if (result.busy !== undefined) {
1004
- if (attempt >= 3) return null;
1005
- return pause(result.busy).then(function () { return precacheOne(cache, page, fragment, attempt + 1); });
1006
- }
1007
- var rest = result.took > SLOW_ANSWER ? pause(Math.min(QUIET_WAIT_MAX, result.took)) : Promise.resolve();
1008
- // Queue linked assets after releasing the page's slot. Waiting for
1009
- // child jobs inside a bounded parent job would deadlock installation.
1010
- return rest.then(function () { if (result.html !== null) return keepAssets(result.html); });
1011
- });
1012
- });
1013
- }).catch(function () {});
1014
- }
1015
-
1016
- function precache() {
1017
- var wanted = S.pages.map(function (page) { return { url: page, key: function (fragment) { return variantUrl(page, fragment); } }; })
1018
- .concat(S.routes.map(function (route) { return { url: route.sample, key: function (fragment) { return routeKey(route, fragment); } }; }));
1019
- return caches.open(SHELL).then(function (cache) {
1020
- var jobs = [];
1021
- wanted.forEach(function (page) { jobs.push([page, false], [page, true]); });
1022
- return jobs.reduce(function (previous, job) {
1023
- return previous.then(function () { return precacheOne(cache, job[0], job[1], 0); });
1024
- }, Promise.resolve());
1025
- });
1026
- }
1027
-
1028
- // Stylesheets and scripts no kept screen of this build links to, and that
1029
- // nothing fetched lately, are an earlier build's: dropped when this build
1030
- // takes over. Other files (images, fonts) are capped, least recently fetched
1031
- // first. Fetching refreshes a file's stamp, so one in use is never the oldest.
1032
- var ASSET_GRACE_MS = 24 * 60 * 60 * 1000;
1033
- function pruneAssets() {
1034
- return Promise.all([caches.open(SHELL), caches.open(ASSETS)]).then(function (opened) {
1035
- var shell = opened[0];
1036
- var assets = opened[1];
1037
- return shell.keys().then(function (pages) {
1038
- return Promise.all(pages.map(function (page) {
1039
- return shell.match(page).then(function (hit) { return hit ? hit.text() : ''; }).catch(function () { return ''; });
1040
- }));
1041
- }).then(function (htmls) {
1042
- var linked = {};
1043
- htmls.forEach(function (html) {
1044
- assetRefs(html).forEach(function (url) { linked[new URL(url, self.location.origin).toString()] = true; });
1045
- });
1046
- return assets.keys().then(function (requests) {
1047
- return Promise.all(requests.map(function (request) {
1048
- return assets.match(request).then(function (hit) { return { request: request, at: hit ? Number(hit.headers.get(KEPT_AT) || 0) : 0 }; });
1049
- }));
1050
- }).then(function (entries) {
1051
- var now = Date.now();
1052
- var drops = [];
1053
- var others = [];
1054
- entries.forEach(function (entry) {
1055
- var url = entry.request.url;
1056
- if (/\\.(?:css|js)$/.test(new URL(url).pathname)) {
1057
- // With no screen kept there is nothing to judge by: keep them.
1058
- if (htmls.length && !linked[url] && now - entry.at > ASSET_GRACE_MS) drops.push(entry.request);
1059
- }
1060
- else others.push(entry);
1061
- });
1062
- if (others.length > S.assetsMax) {
1063
- others.sort(function (a, b) { return a.at - b.at; });
1064
- others.slice(0, others.length - S.assetsMax).forEach(function (entry) { drops.push(entry.request); });
1065
- }
1066
- return Promise.all(drops.map(function (request) { return assets.delete(request); }));
1067
- });
1068
- });
1069
- }).catch(function () {});
1070
- }
1071
-
1072
- // A new build waits for the one running to be let go (see 'message'), rather
1073
- // than taking over under a page that is on screen: its fragments would not
1074
- // match the page's build, and the router would reload under the person.
1075
- self.addEventListener('install', function (event) {
1076
- event.waitUntil(precache());
1077
- });
1078
-
1079
- self.addEventListener('activate', function (event) {
1080
- event.waitUntil(caches.keys().then(function (keys) {
1081
- return Promise.all(keys.filter(function (key) { return key.indexOf('stx-shell-') === 0 && key !== SHELL; }).map(function (key) { return caches.delete(key); }));
1082
- }).then(pruneAssets).then(function () { return self.clients.claim(); }));
1083
- });
1084
-
1085
- // When a page may let this build take over: asked outright (an "Update"
1086
- // button), the app starting cold, or no page of the app on screen.
1087
- function mayTakeOver(data) {
1088
- if (data.force || data.reason === 'cold-start') return Promise.resolve(true);
1089
- if (!self.clients || !self.clients.matchAll) return Promise.resolve(false);
1090
- return self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function (list) {
1091
- if (data.reason === 'load' && list.length <= 1) return true;
1092
- return !list.some(function (client) { return client.visibilityState === 'visible'; });
1093
- });
1094
- }
1095
-
1096
- // --- Media kept for offline: videos a page asked for (cacheMedia()) ---
1097
- // Stored whole and answered here, ranges included: a player seeks with Range
1098
- // requests, and the network may not be there to answer them. The index (url
1099
- // -> bytes, when) lives in the same cache, so eviction can go oldest first.
1100
- function mediaKey(url) {
1101
- var u = new URL(url, self.location.origin);
1102
- u.hash = '';
1103
- return u.toString();
1104
- }
1105
-
1106
- function readMediaIndex(cache) {
1107
- return cache.match(MEDIA_INDEX).then(function (hit) { return hit ? hit.json() : {}; }).catch(function () { return {}; });
1108
- }
1109
-
1110
- function writeMediaIndex(cache, index) {
1111
- return cache.put(MEDIA_INDEX, new Response(JSON.stringify(index), { headers: { 'Content-Type': 'application/json' } }));
1112
- }
1113
-
1114
- function keepMedia(urls) {
1115
- return caches.open(MEDIA).then(function (cache) {
1116
- return readMediaIndex(cache).then(function (index) {
1117
- var wanted = urls.map(mediaKey);
1118
- var chain = Promise.resolve();
1119
- wanted.forEach(function (key) {
1120
- chain = chain.then(function () {
1121
- if (index[key]) { index[key].at = Date.now(); return; }
1122
- // Already stored by the page (cacheMedia downloads while the app is
1123
- // open), so only its size is wanted. Otherwise fetched here.
1124
- return cache.match(key).then(function (stored) {
1125
- if (stored) return stored;
1126
- return fetch(key, { credentials: 'same-origin' }).then(function (response) {
1127
- if (response.status !== 200 || !response.body) return null;
1128
- var type = response.headers.get('Content-Type') || 'application/octet-stream';
1129
- // Streamed into the cache, never held whole: a coach's 300 MB
1130
- // upload read into one blob was enough for iOS to end the worker
1131
- // part way, and nothing was kept.
1132
- return cache.put(key, new Response(response.body, { headers: { 'Content-Type': type, 'Accept-Ranges': 'bytes' } })).then(function () {
1133
- return cache.match(key);
1134
- });
1135
- });
1136
- }).then(function (kept) {
1137
- if (!kept) return;
1138
- return kept.blob().then(function (blob) { index[key] = { bytes: blob.size, at: Date.now() }; });
1139
- }).catch(function () {});
1140
- });
1141
- });
1142
- return chain.then(function () {
1143
- // Oldest first, until what is kept fits.
1144
- var total = 0;
1145
- var keys = Object.keys(index).sort(function (a, b) { return index[b].at - index[a].at; });
1146
- var drops = [];
1147
- keys.forEach(function (key) {
1148
- total += index[key].bytes;
1149
- if (total > S.mediaMax && wanted.indexOf(key) === -1) drops.push(key);
1150
- });
1151
- return Promise.all(drops.map(function (key) { delete index[key]; return cache.delete(key); }));
1152
- }).then(function () { return writeMediaIndex(cache, index); }).then(function () { return Object.keys(index); });
1153
- });
1154
- });
1155
- }
1156
-
1157
- function mediaResponse(request) {
1158
- return caches.open(MEDIA).then(function (cache) {
1159
- return cache.match(mediaKey(request.url)).then(function (hit) {
1160
- if (!hit) return null;
1161
- var range = request.headers.get('Range');
1162
- if (!range) return hit;
1163
- return hit.blob().then(function (blob) {
1164
- var match = /bytes=(\\d*)-(\\d*)/.exec(range);
1165
- var size = blob.size;
1166
- var start = match && match[1] ? Number(match[1]) : 0;
1167
- var end = match && match[2] ? Math.min(Number(match[2]), size - 1) : size - 1;
1168
- if (match && !match[1] && match[2]) { start = Math.max(0, size - Number(match[2])); end = size - 1; }
1169
- if (start >= size || start > end) return new Response(null, { status: 416, headers: { 'Content-Range': 'bytes */' + size } });
1170
- return new Response(blob.slice(start, end + 1), {
1171
- status: 206,
1172
- headers: {
1173
- 'Content-Type': hit.headers.get('Content-Type') || 'application/octet-stream',
1174
- 'Content-Range': 'bytes ' + start + '-' + end + '/' + size,
1175
- 'Content-Length': String(end - start + 1),
1176
- 'Accept-Ranges': 'bytes',
1177
- },
1178
- });
1179
- });
1180
- });
1181
- });
1182
- }
1183
-
1184
- self.addEventListener('message', function (event) {
1185
- var data = event.data || {};
1186
- if (data.type === 'stx:reachability?') {
1187
- // A page just opened: what this worker last saw of the server.
1188
- event.waitUntil(announce({ type: 'stx:reachability', reachable: reachable, at: reachedAt }));
1189
- }
1190
- if (data.type === 'stx:clear-offline-data') {
1191
- lastWrite = null;
1192
- event.waitUntil(Promise.all([caches.delete(DATA), caches.delete(MEDIA)]));
1193
- }
1194
- if (data.type === 'stx:activate-update') {
1195
- // Sent to the waiting worker. One already running ignores it: skipWaiting
1196
- // does nothing once active.
1197
- event.waitUntil(mayTakeOver(data).then(function (yes) { if (yes) return self.skipWaiting(); }));
1198
- }
1199
- if (data.type === 'stx:cache-media' && Array.isArray(data.urls)) {
1200
- var reply = event.ports && event.ports[0];
1201
- event.waitUntil(keepMedia(data.urls.filter(function (url) { return typeof url === 'string'; })).then(function (kept) {
1202
- if (reply) reply.postMessage({ ok: true, kept: kept });
1203
- }, function () {
1204
- if (reply) reply.postMessage({ ok: false, kept: [] });
1205
- }));
1206
- }
1207
- });
1208
-
1209
- // Whether the fallback screen may stand in for this path (S.fallbackScope).
1210
- function inFallbackScope(pathname) {
1211
- var scope = S.fallbackScope;
1212
- if (!scope || scope === '/') return true;
1213
- return pathname === scope || pathname.indexOf(scope + '/') === 0;
1214
- }
1215
-
1216
- // The fallback screen stands in for one this device has not kept whole. It
1217
- // says so, and the router then asks for the screen that was wanted as a
1218
- // fragment: one reached inside the app was kept that way.
1219
- function markFallback(response) {
1220
- return response.text().then(function (html) {
1221
- var head = html.indexOf('<head');
1222
- var at = head === -1 ? -1 : html.indexOf('>', head) + 1;
1223
- var mark = '<meta name="stx-offline-fallback" content="1">';
1224
- var body = at > 0 ? html.slice(0, at) + mark + html.slice(at) : mark + html;
1225
- var headers = new Headers(response.headers);
1226
- headers.delete('Content-Length');
1227
- return new Response(body, { status: 200, headers: headers });
1228
- });
1229
- }
1230
-
1231
- // The app starting cold (a navigation with no other page of it open) while a
1232
- // new build waits, with updateOnColdStart on: the new build takes over now, and
1233
- // this navigation goes to the network so it opens on the new build rather than
1234
- // the kept old one. Off, it opens at once on the kept build.
1235
- function coldStartUpdate(request) {
1236
- var registration = self.registration;
1237
- if (!S.updateOnColdStart || request.mode !== 'navigate' || !registration || !registration.waiting || !self.clients || !self.clients.matchAll) return Promise.resolve(false);
1238
- return self.clients.matchAll({ type: 'window' }).then(function (list) {
1239
- if (list.length > 1 || !registration.waiting) return false;
1240
- registration.waiting.postMessage({ type: 'stx:activate-update', reason: 'cold-start' });
1241
- return true;
1242
- }).catch(function () { return false; });
1243
- }
1244
-
1245
- // Whether every module bundle a kept page links to is kept too.
1246
- //
1247
- // A page's registry, stores and composables are /_stx/modules.<hash>.js,
1248
- // answered by the server process that rendered the page, and only by it: a
1249
- // deploy starts a process that has never heard of the old hashes and answers
1250
- // them 404. A kept page whose bundles are not kept beside it is therefore one
1251
- // that may never bind -- opened cold, it showed its markup with every {{ }}
1252
- // empty and no button working, until a revalidation happened to replace it.
1253
- // Such a copy is not answered first: the network is, and the copy only stands
1254
- // in when there is no network at all, where it is the best there is.
1255
- // ignoreVary: a script was kept under the browser's own request, whose
1256
- // Accept-Encoding a lookup by URL does not carry.
1257
- var MODULE_BUNDLE = /\\/_stx\\/modules\\.[0-9a-f]{16}\\.js/g;
1258
- function bundlesKept(response) {
1259
- return response.clone().text().then(function (html) {
1260
- var urls = [];
1261
- var match;
1262
- MODULE_BUNDLE.lastIndex = 0;
1263
- while ((match = MODULE_BUNDLE.exec(html))) {
1264
- if (urls.indexOf(match[0]) === -1) urls.push(match[0]);
1265
- }
1266
- if (!urls.length) return true;
1267
- return caches.open(ASSETS).then(function (assets) {
1268
- return Promise.all(urls.map(function (url) { return assets.match(url, { ignoreVary: true }); }));
1269
- }).then(function (kept) {
1270
- return kept.every(Boolean);
1271
- });
1272
- }).catch(function () { return true; });
1273
- }
1274
-
1275
- function pageResponse(request, event) {
1276
- var fragment = isFragment(request);
1277
- var key = variantUrl(request.url, fragment);
1278
- var dynamic = routeOf(new URL(request.url).pathname);
1279
- var keys = dynamic ? [key, routeKey(dynamic.route, fragment)] : [key];
1280
- return Promise.all([caches.open(SHELL), coldStartUpdate(request)]).then(function (opened) {
1281
- var cache = opened[0];
1282
- var networkFirst = opened[1] || wantsNetworkFirst(request, new URL(request.url).pathname);
1283
- return cache.match(key).then(function (hit) {
1284
- return (hit && !networkFirst ? bundlesKept(hit) : Promise.resolve(false)).then(function (whole) {
1285
- if (whole) {
1286
- keepAlive(event, revalidate(request, cache, keys, hit, 'page'));
1287
- return hit;
1288
- }
1289
- // Kept, but without its module bundles: not shown while the network
1290
- // might answer (bundlesKept).
1291
- var partial = hit && !networkFirst;
1292
- var asked = network(request).then(function (response) {
1293
- if (keepable(response) || keepStaticPage(request, response)) keepAlive(event, store(cache, keys, response.clone()));
1294
- return response;
1295
- });
1296
- // What stands in when the network is not there, or slow: the kept copy,
1297
- // then a dynamic route's kept page, then the fallback screen.
1298
- var standIn = function (offline) {
1299
- if (hit && (!partial || offline)) return Promise.resolve(hit);
1300
- var route = dynamic ? cache.match(routeKey(dynamic.route, fragment)) : Promise.resolve(null);
1301
- return route.then(function (kept) {
1302
- if (kept) return withParams(kept, dynamic.params);
1303
- if (!offline) return null;
1304
- if (!S.fallback || fragment || !inFallbackScope(new URL(request.url).pathname)) return Response.error();
1305
- return cache.match(variantUrl(S.fallback, false)).then(function (fallback) { return fallback ? markFallback(fallback) : Response.error(); });
1306
- });
1307
- };
1308
- return withTimeout(asked, S.timeout).catch(function () {
1309
- return standIn(false).then(function (kept) {
1310
- if (kept) {
1311
- keepAlive(event, asked);
1312
- return kept;
1313
- }
1314
- // Slower than the timeout, nothing kept to show: wait for it rather than fail.
1315
- return asked.catch(function () { return standIn(true); });
1316
- });
1317
- });
1318
- });
1319
- });
1320
- });
1321
- }
1322
-
1323
- function assetResponse(request, event) {
1324
- return caches.open(ASSETS).then(function (cache) {
1325
- return cache.match(request).then(function (hit) {
1326
- var network = fetch(request).then(function (response) {
1327
- if (keepable(response)) keepAlive(event, keepAsset(cache, request, response.clone()));
1328
- return response;
1329
- });
1330
- if (hit) {
1331
- keepAlive(event, network);
1332
- return hit;
1333
- }
1334
- return network;
1335
- });
1336
- });
1337
- }
1338
-
1339
- // When the app last wrote to its API (any request but a GET). A copy kept
1340
- // before it is not answered at once: it would show the screen as if the
1341
- // write had not happened. Kept in the data cache so a restarted worker knows.
1342
- var lastWrite = null;
1343
- function lastWriteAt() {
1344
- if (!lastWrite) {
1345
- lastWrite = caches.open(DATA).then(function (cache) { return cache.match(LAST_WRITE); })
1346
- .then(function (hit) { return hit ? hit.text() : '0'; })
1347
- .then(function (text) { return Number(text) || 0; })
1348
- .catch(function () { return 0; });
1349
- }
1350
- return lastWrite;
1351
- }
1352
- function noteWrite() {
1353
- var at = Date.now();
1354
- lastWrite = Promise.resolve(at);
1355
- return caches.open(DATA).then(function (cache) { return cache.put(LAST_WRITE, new Response(String(at))); }).catch(function () {});
1356
- }
1357
-
1358
- function apiResponse(request, event) {
1359
- return hashOf(request.headers.get('Authorization') || '').then(function (who) {
1360
- var u = new URL(request.url);
1361
- u.searchParams.set('__stx_who', who);
1362
- var key = u.toString();
1363
- return Promise.all([caches.open(DATA), lastWriteAt()]).then(function (opened) {
1364
- var cache = opened[0];
1365
- return cache.match(key).then(function (hit) {
1366
- var stale = hit && opened[1] > 0 && Number(hit.headers.get(KEPT_AT) || 0) <= opened[1];
1367
- if (hit && !stale && !wantsNetworkFirst(request, u.pathname)) {
1368
- keepAlive(event, revalidate(request, cache, [key], hit, 'api'));
1369
- return hit;
1370
- }
1371
- var asked = network(request).then(function (response) {
1372
- if (noStore(response)) keepAlive(event, cache.delete(key));
1373
- if (keepable(response)) keepAlive(event, store(cache, [key], response.clone()));
1374
- return response;
1375
- });
1376
- return withTimeout(asked, S.timeout).catch(function () {
1377
- return hit || asked;
1378
- });
1379
- });
1380
- });
1381
- });
1382
- }
1383
-
1384
- self.addEventListener('fetch', function (event) {
1385
- var counted = noteForeground(event);
1386
- try { answerFetch(event); }
1387
- finally { if (!counted.responded) counted.settle(); }
1388
- });
1389
-
1390
- function answerFetch(event) {
1391
- var request = event.request;
1392
- var url = new URL(request.url);
1393
- if (url.origin !== self.location.origin) return;
1394
- if (request.method !== 'GET') {
1395
- // Writes go straight to the network; only when they happened is noted.
1396
- if (url.pathname.indexOf(S.api) === 0) keepAlive(event, noteWrite());
1397
- return;
1398
- }
1399
- // Live status and other explicitly uncached reads must never be answered
1400
- // from offline storage, including when the network fails.
1401
- if (request.cache === 'no-store') {
1402
- event.respondWith(network(request));
1403
- return;
1404
- }
1405
- // Media kept for offline is answered from the device, a range included;
1406
- // anything else asking for a range is the browser's to answer, since a
1407
- // cache cannot hold a partial response.
1408
- if (request.headers.has('Range') || /\\.(?:mp4|m4v|mov|webm|m3u8|mp3|m4a)$/i.test(url.pathname)) {
1409
- event.respondWith(mediaResponse(request).then(function (kept) { return kept || fetch(request); }));
1410
- return;
1411
- }
1412
- for (var i = 0; i < S.exclude.length; i++) {
1413
- if (url.pathname.indexOf(S.exclude[i]) === 0) return;
1414
- }
1415
- if (url.pathname.indexOf(S.api) === 0) {
1416
- event.respondWith(apiResponse(request, event));
1417
- return;
1418
- }
1419
- if (url.pathname.indexOf('/_stx/') === 0 || url.pathname.indexOf('/assets/') === 0 || /\\.(?:js|css|woff2?|png|jpe?g|webp|avif|svg|ico)$/.test(url.pathname)) {
1420
- event.respondWith(assetResponse(request, event));
1421
- return;
1422
- }
1423
- var accept = request.headers.get('Accept') || '';
1424
- if (request.mode === 'navigate' || isFragment(request) || accept.indexOf('text/html') !== -1) {
1425
- event.respondWith(pageResponse(request, event));
1426
- }
1427
- }
1428
- `}import je from"path";function gr(r){return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")}async function mr(r,e,l){try{let a;if(r.startsWith("/")){let h=e;for(let t=0;t<5;t++){let p=je.join(h,r);if(await Bun.file(p).exists())return p;h=je.dirname(h)}a=je.join(e,r)}else if(r.startsWith("./")||r.startsWith("../"))a=je.resolve(e,r);else a=je.resolve(e,r);if(await Bun.file(a).exists())return a;return null}catch{return null}}var hr=Symbol.for("stx.inline-assets.import-meta");function is(r,e){if(!r.includes("import.meta"))return;let l=Error(`[stx] ${e} still references \`import.meta\` after bundling, and it is being inlined as a classic <script> where that is a SyntaxError \u2014 the whole script fails to parse, taking every other script on the page with it.
1429
- `+" `import.meta.env.STX_PUBLIC_*` is substituted at build time and is safe; anything else is not.\n Fix it by moving the module-only code (`import.meta.glob`, `import.meta.url`) into its own module, or by resolving the value without `import.meta`.");throw l[hr]=!0,l}async function yr(r,e,l){let a=r,h=je.dirname(e),t=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,p;while((p=t.exec(a))!==null){let[v,x,k,_]=p;if(gr(k))continue;let E=await mr(k,h,e);if(E)try{let D=await Bun.file(E).text();if(l.add(E),k.endsWith(".ts")||k.endsWith(".tsx")){let C=await Bun.build({entrypoints:[E],target:"browser",minify:!0,define:A()});if(C.outputs.length>0)D=await C.outputs[0].text(),is(D,k)}let T=`<script>
1430
- // Source: ${k}
1431
- ${D}
1432
- </script>`;a=a.replace(v,T),t.lastIndex=0}catch(D){if(D?.[hr])throw D}}let w=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,y;while((y=w.exec(a))!==null){let[v,x,k,_]=y,E=x+_;if(gr(k))continue;if(/rel=["']stylesheet["']/.test(E)||k.endsWith(".css")){let T=await mr(k,h,e);if(T)try{let C=await Bun.file(T).text();l.add(T);let N=`<style>
1433
- /* Source: ${k} */
1434
- ${C}
1435
- </style>`;a=a.replace(v,N),w.lastIndex=0}catch(C){}}}return a}import gt from"path";var os=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,as=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function cs(r,e){if(!e||!r.includes("/"))return r;let l=gt.dirname(e);return r.replace(os,(a,h,t,p)=>{let w=gt.resolve(l,p);return`${h}${t}${w.split(gt.sep).join("/")}${t}`})}function wr(r,e){if(!e||!r.includes("<script"))return r;return r.replace(as,(l,a,h,t)=>`${a}${cs(h,e)}${t}`)}var Re="<!--PARENT_CONTENT_PLACEHOLDER-->";function vr(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Mr(r,e){let l=r.length,a=e,h=!0,t=[],p=(w)=>w+9<=l&&r[w]==="<"&&r[w+1]==="/"&&(r[w+2]==="s"||r[w+2]==="S")&&(r[w+3]==="c"||r[w+3]==="C")&&(r[w+4]==="r"||r[w+4]==="R")&&(r[w+5]==="i"||r[w+5]==="I")&&(r[w+6]==="p"||r[w+6]==="P")&&(r[w+7]==="t"||r[w+7]==="T")&&(r[w+8]===">"||/\s/.test(r[w+8]));while(a<l){let w=r[a];if(p(a))return a;if(w==="/"&&r[a+1]==="/"){if(a=r.indexOf(`
1436
- `,a+2),a===-1)return-1;a+=1,h=!0;continue}if(w==="/"&&r[a+1]==="*"){let y=r.indexOf("*/",a+2);if(y===-1)return-1;a=y+2,h=!0;continue}if(w==="/"&&h){let y=a+1,v=!1;while(y<l){let x=r[y];if(x==="\\"){y+=2;continue}if(x==="[")v=!0;else if(x==="]")v=!1;else if(x==="/"&&!v){y++;break}else if(x===`
1437
- `){y=-1;break}y++}if(y===-1){a++,h=!1;continue}while(y<l&&/[a-z]/.test(r[y]))y++;a=y,h=!1;continue}if(w==="'"||w==='"'){let y=w;a++;while(a<l){if(r[a]==="\\"){a+=2;continue}if(r[a]===y){a++;break}if(r[a]===`
1438
- `)break;a++}h=!1;continue}if(w==="`"){a++;while(a<l){if(r[a]==="\\"){a+=2;continue}if(r[a]==="`"){a++;break}if(r[a]==="$"&&r[a+1]==="{"){t.push(!0),a+=2,h=!0;break}a++}if(t.length===0)h=!1;continue}if(w==="}"&&t.length>0){t.pop(),a++;while(a<l){if(r[a]==="\\"){a+=2;continue}if(r[a]==="`"){a++,h=!1;break}if(r[a]==="$"&&r[a+1]==="{"){t.push(!0),a+=2,h=!0;break}a++}continue}if(/\s/.test(w));else if(/[)\].\w$]/.test(w))h=!1;else h=!0;a++}return-1}function Rr(r,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${l}(?:\\s|=|/?>))[^>]*>`,"i").exec(r);if(!a)return null;let h=a.index+a[0].length,t=r.indexOf("</script>",h);if(t===-1)return null;let p=r.indexOf(">",t);if(p===-1)return null;return{start:a.index,end:p+1}}var us=4096;async function mt(r,e,l){if(Ve(e)||Z(e)||l.buildMode!=="serve"||e.length<us)return null;let{registerServeModuleBundle:a}=await import("./chunk-e0tvd7jj.js");return`<script ${r} src="${a(e)}"></script>`}async function br(r,e,l,a){try{let{registeredModuleIdsIn:h,buildModuleRegistryScript:t}=await o("stx/client-module-registry",()=>import("./chunk-5fdsyyfe.js")),p=[],w=await t(h(...r),{minify:sa(e.buildMode,e.minifyClient),collectInputs:p});for(let y of p)l?.add(y);if(a)a.inputs=p,a.code=w??void 0;if(!w)return null;if(e.buildMode==="serve"&&!Ve(w)&&!Z(w)){let{registerServeModuleBundle:y}=await import("./chunk-e0tvd7jj.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${y(w)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${w.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}async function ds(r,e,l,a){let h={modulesTag:null,modulesCode:null,storeTag:null,storeCode:null,composableTag:null,composableCode:null,frameworkScript:null};try{let{getFrameworkComposableScript:_}=await o("stx/framework-composables",()=>import("./chunk-wj9bqkc0.js"));h.frameworkScript=await _(r)}catch{}let t=null;try{t=await o("stx/store-loader",()=>import("./chunk-c6096ssb.js"))}catch{}let p=e.storesDir,w=!!a.__stx_native_screen||(t?.pageStoresAll()??!0),y=w?"":r.replace(/<script\b[^>]*\bdata-stx-(?:runtime|router|hmr)\b[^>]*>[\s\S]*?<\/script>/gi,""),v=[],x=[],k=null;for(let _=0;_<8;_++){let E=null,D="",T=!1;try{if(t){let q=w?await t.getStoreScript(p).then((V)=>V?{code:V,stores:["*"],functions:null}:null):await t.getStoreScriptFor(p,[y],{reads:t.storesReadInFiles([...v,...x]),runOnce:!0});if(q)E=q.code,D=q.stores.join(","),T=!!q.functions&&!w}}catch{}if(k!==null&&D===k)break;k=D;let C=T?'data-stx-scoped data-stx-run="always" data-stx-stores':"data-stx-stores",N=E?`<script ${C}>${E}</script>`:null;h.storeCode=E,h.storeTag=E?await mt(C,E,e)??N:null;let F={};h.modulesTag=await br([r,N],e,l,F),h.modulesCode=F.code??null,v=F.inputs??[],h.composableTag=null,h.composableCode=null,x=[];try{let{getComposableScript:q}=await o("stx/composable-loader",()=>import("./chunk-5d5dxts6.js")),V=e.composablesDir,H=[h.modulesCode??h.modulesTag,N,h.frameworkScript].filter((U)=>U!==null),B=await q(e._layerComposableDirs??V,r,H,x);if(B)h.composableCode=B,h.composableTag=await mt('data-stx-scoped data-stx-run="always" data-stx-composables',B,e)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${B.replace(/<\/script/gi,"<\\/script")}</script>`}catch{}if(w||!t)break}return h}async function ps(r,e,l,a={}){let{withModuleSubstitutes:h,moduleSubstitutionKey:t}=await import("./chunk-wq17dce6.js"),p=await import("./chunk-yn02d599.js"),{messages:w,webModules:y}=e,v=null,x=null,k=t()===""&&!a.__stx_native_screen;if(w&&p.pageMessagesEnabled(e)&&k)try{v=await p.loadPageMessages(process.cwd(),w)}catch(C){fs(C)}if(y&&Object.keys(y).length&&k)try{x=await(await import("./chunk-sdmq09jw.js")).loadWebModules(process.cwd(),y)}catch(C){gs(C)}let _=new Map([...x??[],...v?.stubs??[]]),E=()=>ds(r,e,l,a),D=_.size?await h(_,E):await E(),T=null;if(v){let C=p.messageAreasIn(D.modulesCode,D.storeCode,D.composableCode),N=p.pageMessagesScript(v,p.pageLanguages(r,v),C);if(N)T=await mt('data-stx-scoped data-stx-run="always" data-stx-messages',N,e)??`<script data-stx-scoped data-stx-run="always" data-stx-messages>${N.replace(/<\/script/gi,"<\\/script")}</script>`}return[T,D.modulesTag,D.storeTag,D.composableTag,D.frameworkScript].filter((C)=>C!==null)}var xr=!1;function fs(r){if(xr)return;xr=!0,console.warn(`[stx] messages: ${r instanceof Error?r.message:String(r)}; pages ship every language`)}var Sr=!1;function gs(r){if(Sr)return;Sr=!0,console.warn(`[stx] ${r instanceof Error?r.message:String(r)}; pages bundle the real modules`)}function ms(r,e=""){let l=Rr(r,"data-stx-runtime");if(!l)return r;let a=_r(r);if(a===-1||a===l.start){if(!e)return r;return r.slice(0,l.end)+e+r.slice(l.end)}if(a<l.start)return r.slice(0,a)+r.slice(l.start,l.end)+e+`
1439
- `+r.slice(a,l.start)+r.slice(l.end);let h=r.slice(l.start,l.end),t=r.slice(0,l.start)+r.slice(l.end),p=_r(t);if(p===-1)return h+e+`
1440
- `+t;return t.slice(0,p)+h+e+`
1441
- `+t.slice(p)}function hs(r){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return r.replace(e,(l,a,h)=>{let t=r.slice(0,h);return t.lastIndexOf("<")>t.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}async function i(r,e,l,a,h){if(await R(),a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return r;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=Me(r,l);let t=!e.__stxProcessingDepth;Pn(e);for(let p of a._layerGraph?.configDependencies??[])h.add(p);if(t&&a.runtimeConfig)await Dn(e,l,a.runtimeConfig);if(t)Sl(e),e.__stx_scope_seq??={n:0,key:po(String(e.__filename??l))},e.__stx_head_injections=ta(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((a.debug||!I()&&!Fn())&&l&&l.endsWith(".stx"))ii(r,l);try{return await we.timeAsync("template-processing",async()=>{let p=await ys(r,e,l,a,h);if(t)p=Hi(p);if(t&&a.autoShell&&a.buildMode!=="compile"){let w=Le(a.app?.head,{known:Jr,source:"app.head"}),v=(e.__stx_runtime_head||null)??ra(),x=(e.__stx_head_raw||"").trim(),k,_=x.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(_)k=_[1].trim(),x=x.replace(_[0],"").trim();let E=e.__sections?.title,D=E?P(E,e,l):void 0,T=v.title||k||D,C=!v.title&&(!!k||!!D),N=v.meta||[],F=new Set(N.map((J)=>wt(J)).filter(Boolean)),q={...w,...T&&{title:T},meta:[...(w.meta||[]).filter((J)=>!F.has(wt(J))),...N],link:[...w.link||[],...v.link||[]],script:[...w.script||[],...v.script||[]],headRaw:[w.headRaw,x].filter(Boolean).join(`
1442
- `),...v.htmlAttrs&&{htmlAttrs:jl(w.htmlAttrs,v.htmlAttrs)},...v.bodyAttrs&&{bodyAttrs:{...w.bodyAttrs||{},...v.bodyAttrs}}},V=na(p);if(p=Xr(p,q,{...C&&{titleIsHtml:!0},...a.app?.colorMode&&{colorMode:a.app.colorMode}},V),V)p=Fl(p,w),p=Kr(p,q.htmlAttrs);let H=p.match(/<!-- stx-layout: ([^ ]+) -->/);if(H&&p.includes("<head")){let J=H[1],de=Cn(J);p=p.replace(/<head\b[^>]*>/i,(G)=>`${G}
1443
- <meta name="stx-layout" content="${vr(J)}">
1444
- <meta name="stx-layout-group" content="${vr(de)}">`)}let B=p.match(/function (__stx_setup_\w+)\(/),U=B?W(p):null;if(B&&U&&!/\bdata-stx=/.test(U.tag)){p=ut(p,(de,G)=>`<body${G} data-stx="${B[1]}">`);let J=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${B[1]}"`,"i");p=p.replace(J,"$1")}}if(t){let w=e.__stx_head_injections??ta(),y=Bl(p);if(y!==null)w.beforeClose.push(y);let v=dr(p);if(v!==null)w.afterOpen.push(v);let x=a.offline;if(x?.enabled&&!p.includes("data-stx-offline"))w.beforeClose.push(fr(x));p=Dl(p,w);let k=a.app?.colorMode;if(k)p=qr(p,k)}if(t)if(Rr(p,"data-stx-runtime")){let y=await ps(p,a,h,e);p=ms(p,y.map((v)=>`
1445
- ${v}`).join(""))}else{let y=await br([p],a,h);if(y){let v=p.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(v!==-1)p=p.slice(0,v)+y+`
1446
- `+p.slice(v)}}if(t)p=Ll(p);if(t&&e.__stx_inject_css!==!1)p=await S(p,void 0,a.buildMode==="serve",!0,a.inlineGeneratedCssBytes);else if(t)p=Rn(p);if(t)p=xt(p);if(p=p.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),p=hs(p),t&&e.__stx_runtime_config)p=Jt(p,e.__stx_runtime_config);if(t&&!e.__stx_defer_server_data){let w=zr(e);if(w){let y=/<head\b[^>]*>/i.exec(p),v=y?y.index+y[0].length:0;p=p.slice(0,v)+w+p.slice(v)}}return t?vt(p):p})}catch(p){if(p instanceof te)throw p;let w=p instanceof Error?p.message:String(p),y=new ce(`Template processing failed: ${w}`,l,void 0,void 0,r.substring(0,200)+(r.length>200?"...":""));if(K.log(y,{filePath:l,context:e}),jn.logDetailedError(y,{filePath:l,template:r.substring(0,500)}),I()&&!a.debug)console.error(`[stx] ${le.relative(process.cwd(),l)||l}: ${y.message}`);if(a.debug)throw y;return Qi.createFallbackContent("Template Processing",y)}}async function ys(r,e,l,a,h){let t=process.cwd(),p={...a,partialsDir:a.partialsDir&&!le.isAbsolute(a.partialsDir)?le.resolve(t,a.partialsDir):a.partialsDir,componentsDir:a.componentsDir&&!le.isAbsolute(a.componentsDir)?le.resolve(t,a.componentsDir):a.componentsDir,layoutsDir:a.layoutsDir&&!le.isAbsolute(a.layoutsDir)?le.resolve(t,a.layoutsDir):a.layoutsDir},w=p,y=r;await vs(l,e),ws(e,w),y=await De(()=>er(y,e,l,w),y,(H)=>{K.log(H,{filePath:l,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${l}: ${H.message}`)}),y=y.replace(/\{\{--[\s\S]*?--\}\}/g,"");let v=ke(y,Xe,(H,B)=>`\x00STX_HTML_COMMENT_${B}\x00`);y=v.output;let x=v.tokens,k=(H)=>x.length===0?H:H.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(B,U)=>x[Number(U)]??""),_="\x00STX_ESCAPED_AT\x00",E="\x00STX_ESC_MUSTACHE_OPEN\x00",D="\x00STX_ESC_MUSTACHE_CLOSE\x00";y=y.replace(/@@/g,_),y=y.replace(/@\{\{([\s\S]*?)\}\}/g,(H,B)=>`${E}${B}${D}`),y=ir(y),y=await yr(y,l,h);let T={};y=$s(y,T);let C={...e.__sections||{}},N="",F=Tt(Pt(r)),q=/@nolayout\b/.test(y)||F===!1;if(/@nolayout\b/.test(y))y=y.replace(/@nolayout\b\s*/g,"");let V=y.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(V)N=V[1],y=y.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof F==="string"){if(N=F,!/@section\s*\(/.test(y))y=`@section('content')
1447
- ${y.trim()}
1448
- @endsection`}if(!N&&!q&&w.defaultLayout){let H=Bn(y),B=/@section\s*\(/.test(y);if(!H||B){let U="",J=le.dirname(l),de=w.layoutsDir?le.dirname(w.layoutsDir):process.cwd();for(let G=0;G<20;G++){let pe=le.join(J,"_layout.stx");if(await s(pe)){U=pe;break}let ue=le.dirname(J);if(ue===J||ue.length<de.length)break;J=ue}if(U)N=U;else if(w.layoutsDir){let G=le.isAbsolute(w.layoutsDir)?w.layoutsDir:le.resolve(process.cwd(),w.layoutsDir),pe=le.join(G,`${w.defaultLayout}.stx`);if(await s(pe))N=pe}if(N&&!B)y=`@section('content')
1449
- ${y.trim()}
1450
- @endsection`}}if(N&&y.includes("<script")){let H=se(y),B=H.scripts.map((U)=>kr(U,l)??U);y=Dr(H.output,B)}if(y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(H,B,U)=>(C[B]=U,"")),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(H,B,U)=>{if(/^(['"]).*\1$/.test(U.trim()))return H;try{let J=d(U.trim(),e);if(J===void 0)return H;let G=(e.__stx_inline_section_values??=[]).push(J)-1;return C[B]=`{{ __stx_inline_section_values[${G}] }}`,""}catch{return H}}),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(H,B,U)=>{if(U.includes("@parent"))C[B]=U.replace("@parent",Re);else C[B]=U.trim();return""}),e.__sections=C,y=y.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(H,B,U)=>C[B]||U||""),!("slot"in e)||e.slot===void 0)y=y.replace(/\{\{\s*slot\s*\}\}/g,()=>C.content||"");if(y=Rs(y,T),N){let H=[],B=se(y),U=ke(B.output,Tn,(J,de)=>`\x00STX_ORPHAN_STYLE_${de}\x00`);if(y=U.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(J,de,G)=>{let pe=de==="SCRIPT"?kr(B.scripts[Number(G)],l):U.tokens[Number(G)];if(pe)H.push(pe);return""}),H.length>0){let J=H.join(`
1451
- `);C.content=C.content?`${C.content}
1452
- ${J}`:J,e.__sections=C}}if(N)try{let H;if(le.isAbsolute(N))H=N,h.add(N);else H=await De(()=>On(N,l,p,h),null,()=>{throw new ce(`Failed to resolve layout path: ${N}`,l,void 0,void 0,`Layout referenced from ${l}`)});if(!H){let ue=(Q)=>{if(!Q)return[];try{let xe=le.isAbsolute(Q)?Q:le.resolve(process.cwd(),Q);return ls.readdirSync(xe).filter(($e)=>$e.endsWith(".stx")).map(($e)=>$e.replace(/\.stx$/,""))}catch{return[]}},ne=[...ue(p.layoutsDir),...ue(p.fallbackLayoutsDir)].filter((Q,xe,$e)=>$e.indexOf(Q)===xe).sort(),ve=[p.layoutsDir,p.fallbackLayoutsDir].filter((Q)=>typeof Q==="string"&&Q.length>0),me=ve.length>0?` Searched: ${ve.join(", ")} (set \`layoutsDir\` to look elsewhere).`:"",ie=`Layout not found: ${N} (referenced from ${l})`+(ne.length>0?`. Available layouts: ${ne.join(", ")}`:p.layoutsDir?`. No .stx layouts found in ${p.layoutsDir}`:"")+me;if(K.log(Error(ie),{layoutPath:N,filePath:l,available:ne},"error"),console.error(`[stx] ${ie}`),p.debug)throw new ce(ie,l);return y}let B=await De(()=>Bun.file(H).text(),"",()=>{throw new ce(`Failed to read layout file: ${H}`,l,void 0,void 0,"Layout content could not be loaded")});B=wr(B,H),B=B.replace(/\{\{--[\s\S]*?--\}\}/g,"");let U=Array.isArray(e.__layoutChain)?e.__layoutChain:[];if(U.includes(H)){let ue=[...U.slice(U.indexOf(H)),H];throw new ce(ue.length===2?`Circular layout: ${H} extends itself`:`Circular layout: ${ue.join(" -> ")}`,l,void 0,void 0,"Remove the @extends or @layout line that points back at a layout already in use")}let J=B.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(J){if(p.debug)console.log(`Found nested layout: ${J[1]} in ${H}`);let ue={},ne=B.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ie,Q,xe)=>(ue[Q]=xe.trim(),""));for(let[ie,Q]of Object.entries(ue))if(C[ie]&&C[ie].includes(Re)){let xe=C[ie].indexOf(Re);C[ie]=C[ie].slice(0,xe)+Q+C[ie].slice(xe+Re.length)}else if(!C[ie])C[ie]=Q;let ve={...e,__sections:C,__layoutChain:[...U,H]},me=`@layout('${J[1]}')${ne}`;return await i(me,ve,H,p,h)}let de=B.replace(/\{\{--[\s\S]*?--\}\}/g,""),G=$s(de,T),pe={};return G=G.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ue,ne,ve)=>(pe[ne]=ve.trim(),`@slot('${ne}')`)),G=G.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ue,ne,ve)=>{if(C[ne]){let me=C[ne];if(me.includes(Re)){let ie=pe[ne]||"",Q=me.indexOf(Re);me=me.slice(0,Q)+ie+me.slice(Q+Re.length)}return me}return ve||""}),G=bs(G,C),G=G.replace(/\{\{\s*slot\s*\}\}/g,()=>C.content||""),G=Rs(G,T),e.__originalFilePath=l,y=await Ar(G,e,H,p,h),y=`<!-- stx-layout: ${N} -->
1453
- ${y}`,k(y)}catch(H){if(H instanceof te)throw H;throw new ce(`Error processing layout ${N}: ${H instanceof Error?H.message:String(H)}`,l)}return k(await Ar(y,e,l,p,h))}function bs(r,e){return r.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,a,h)=>{let t=e[a];if(t!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(t))return t}return h||""})}function ws(r,e){if(r.__stx_sfc_mode=!0,r.__stx_options=e,e.buildMode)r.__stx_buildMode=e.buildMode;let l=e.envPrefix||"STX_PUBLIC_",a={};for(let[h,t]of Object.entries(process.env))if(h.startsWith(l)&&t!==void 0)a[h]=t;r.$env=a}async function vs(r,e){await De(()=>nr(r,e),void 0,(l)=>{K.log(l,{filePath:r,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${r}: ${l.message}`)})}var ht="data-stx-source";function kr(r,e){if(!r)return r;let l=/^<script\b([^>]*)>/i.exec(r);if(!l||!/\bserver\b/.test(l[1])||l[1].includes(ht))return r;return`<script ${ht}="${encodeURIComponent(e)}"${r.slice(7)}`}function xs(r){let e=new RegExp(`${ht}="([^"]*)"`).exec(r);return e?decodeURIComponent(e[1]):void 0}function Er(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Tr(r,e,l){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a &lt;script server&gt; ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${Er(r)}</span><span style="display:block;margin-top:4px">${Er(l)}</span></div>`}async function Ss(r,e,l,a){let{scanScriptTags:h}=await o("stx/signal-processing",()=>import("./chunk-8x3yaahc.js")),t=[],p=!I()&&!Fn();for(let y of h(r)){let v=y.attrs;if(!/\bserver\b/.test(v))continue;let x=y.start+y.fullMatch.indexOf(">")+1,k=Mr(r,x);if(k===-1)continue;let _=r.slice(x,k);if(!_.trim())continue;let E=xs(v)??l,D={index:y.start,length:k+9-y.start};try{let{extractVariables:T}=await o("stx/variable-extractor",()=>import("./chunk-4pve3r5a.js"));await T(_,e,E,{preserveExisting:!0,onFailure:(C)=>{if(C.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:E,kind:C.kind,message:C.message}),!p)return;t.push({...D,markup:Tr(E,C.kind,C.message)})}})}catch(T){let C=T instanceof Error?T:Error(String(T));if(K.log(C,{filePath:E,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${E}: ${C.message}`),p)t.push({...D,markup:Tr(E,"unknown",C.message)})}}if(t.length===0)return r;let w=r;for(let y of t.sort((v,x)=>x.index-v.index))w=w.slice(0,y.index)+y.markup+w.slice(y.index+y.length);return w}async function ks(r,e,l){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-kcpxqsdj.js"));return a(r,e,{skipServer:!0})}catch(a){let h=a instanceof Error?a:Error(String(a));return K.log(h,{filePath:l,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${l}: ${h.message}`),r}}async function Ar(r,e,l,a,h){let t=r;await R();let p=a;if(t=await Ss(t,e,l,a),t=await zt(t,e,l),t=await Kt(t,e,l),t=await ks(t,e,l),await R(),t=await Nt(t,e,l,p),Me(t))t=mi(t,e),t=Ds(t,e),t=Ms(t,e);t=hi(t),await R();let{processStreamDirectives:w}=await o("stx/streaming",()=>import("./chunk-6aqr0e6s.js"));t=w(t,e),t=await ui(t,e,l,p,!0),await R(),t=await ur(t,e,l,p,h),t=await Ps(t,e,l,p,h),await R(),t=Vc(t,e,l,p);let{processDeferDirectives:y}=await o("stx/defer",()=>import("./chunk-bej9kz05.js"));t=y(t,e,l);let{processTeleportDirectives:v}=await o("stx/teleport",()=>import("./chunk-wvc6eayq.js"));t=v(t,e,l);let{processTransitionDirectives:x,processTransitionAttributes:k}=await o("stx/transitions",()=>import("./chunk-ccgabq3a.js"));t=x(t,e,l),t=k(t);let{processErrorBoundaryDirectives:_,stripRenderFailedMarkers:E}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));t=_(t,e,l),t=E(t);let{processSuspenseDirectives:D}=await o("stx/suspense",()=>import("./chunk-33fnbw33.js"));t=D(t,e,l);let{processAsyncDirectives:T}=await o("stx/async-components",()=>import("./chunk-qp0ndbk6.js"));t=T(t,e,l);let{processKeepAliveDirectives:C}=await o("stx/keep-alive",()=>import("./chunk-a5h9bwrc.js"));t=C(t,e,l);let{processVirtualListDirectives:N,processVirtualGridDirectives:F,processInfiniteListDirectives:q}=await o("stx/virtual-scrolling",()=>import("./chunk-5afnyvw5.js"));t=N(t,e,l),t=F(t,e,l),t=q(t,e,l),await R();let{processPartialHydrationDirectives:V,processStaticDirectives:H}=await o("stx/partial-hydration",()=>import("./chunk-k8s3hyh2.js"));t=V(t,e,l),t=H(t);let{processComputedDirectives:B,processWatchDirectives:U}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));t=B(t,e,l),t=U(t,e,l);let{processFormValidationDirectives:J}=await o("stx/forms-validation",()=>import("./chunk-xjt5129x.js"));t=J(t,e,l);let{processHeadDirective:de,processTitleDirective:G,processMetaDirective:pe,resetHead:ue}=await o("stx/head",()=>import("./chunk-1mx3j280.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)ue();let ne=de(t);if(t=ne.content,ne.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${ne.headContent}
1454
- `;if(t=G(t,e),t=pe(t,e,l),t=rr(t),t=di(t,e),t=jt(t),t=Qt(t),t=await Ts(t,e,l,p,h),t=await Ps(t,e,l,p,h),await R(),t=t.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),t=Hi(t),t=ge(t,e,l),t=Is(t),await R(),e.__stxProcessingDepth===1)t=kl(t,e);if(t=yl(t,e,{filePath:l,buildMode:p.buildMode}),t=pi(t,e),t=fi(t,e),t=et(t,e),t=Vt(t,e),t=Xt(t,e),t=await Ct(t,e,l,p),t=await qc(t,e,l),t=await Xc(t,e,l,p),await R(),t=Gc(t,e,l,p),t=ki(t,e,l,p),t=_i(t,e,l),t=Ci(t,e,l,p),t=Ot(t,e,l,p),t=lo(t,e),t=uo(t),t=wl(t),!p.skipEventDirectives)t=al(t,e,l);if(t=bl(t,e,l,a.skipSignalsRuntime===!0&&Number(e.__stxProcessingDepth)>0),await R(),p.debug){let X=/\bx-data\s*=/.test(t),z=Ns(r);if(X&&z)console.warn(`[stx] ${l}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
1455
- Both work on the same page, but they manage separate scopes.
1456
- Prefer signals (state/derived/effect) for new components.`)}t=Bc(t,e),t=await Gi(t,e,l),await R(),t=vl(t),t=xl(t),t=$t(t);let{processXElementDirectives:ve}=await o("stx/x-element",()=>import("./chunk-va4xam1q.js"));t=ve(t);let me=e.__originalFilePath||l,ie=Ge(e);if(t=await yi(t,p,me,ie),await R(),t=Ut(t,e),t=await tr(t,e,l,p),await R(),p.media?.image?.autoSiblings){let X=p.publicDir||"public",{rewriteImagesWithSiblings:z}=await o("stx/image-optimization/auto-sibling",()=>import("./chunk-new89wh2.js"));t=await z(t,{publicDir:X})}if(p.seo?.enabled)t=Ei(t,e,p);let Q=(X,z,ee=!0)=>{if(!z)return X;let be=z.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),oe=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(X),he=oe?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(oe[0]):null;if(be&&oe&&he){if(ee){let Ie=oe.index+he.index;X=X.slice(0,Ie)+be[0]+X.slice(Ie+he[0].length)}if(z=z.replace(be[0],"").trim(),!z)return X}if(/<\/head>/i.test(X))return f(X,z);if(/<head\b[^>]*>/i.test(X))return X.replace(/(<head\b[^>]*>)/i,`$1
1457
- ${z}`);if(/<html\b[^>]*>/i.test(X))return X.replace(/(<html\b[^>]*>)/i,`$1
1458
- <head>
1459
- ${z}
1460
- </head>`);return X},{renderHead:xe,getHead:$e}=await o("stx/head",()=>import("./chunk-1mx3j280.js")),He=e.__stx_runtime_head??$e();if(He.title||He.meta?.length||He.link?.length){let X=xe(He);if(X)t=Q(t,X)}if(ne.headContent)t=Q(t,ne.headContent,!He.title);if(p.csp?.enabled&&p.csp.addMetaTag)t=Dt(t,p.csp,e);if(p.analytics?.enabled)t=Et(t,p);if(p.heatmap?.enabled)t=Wc(t,p);if(p.pwa?.enabled&&p.pwa.autoInject!==!1){let{injectPwaTags:X}=await o("stx/pwa/inject",()=>import("./chunk-rzsvxjse.js"));t=X(t,p)}let Ir=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(t),Or=/\bSTX\.\w+/.test(t),Lr=/window\.STX\s*=/.test(t);if(Ir&&Or&&!Lr){let z=`<script data-stx-scoped data-stx-run="once">
1461
- ${St()}
1462
- </script>`;if(t.includes("</head>")){let ee=L(t),oe=t.slice(0,ee).indexOf("<script");if(oe!==-1){let he=t.slice(0,oe),Ie=t.slice(oe);t=he+z+`
1463
- `+Ie}else t=f(t,z)}else if(t.includes("<body"))t=t.replace(/<body([^>]*)>/,`<body$1>
1464
- ${z}`);else t=z+`
1465
- `+t}{let{scanScriptTags:X}=await o("stx/signal-processing",()=>import("./chunk-8x3yaahc.js")),z=[];for(let ee of X(t)){if(!/\bserver\b/i.test(ee.attrs))continue;let be=ee.start+ee.fullMatch.indexOf(">")+1,oe=Mr(t,be);if(oe===-1)continue;let he=oe+9;while(he<t.length&&/\s/.test(t[he]))he++;z.push({start:ee.start,end:he})}if(z.length>0){let ee=Array(z.length+1),be=0;for(let oe=0;oe<z.length;oe++){let{start:he,end:Ie}=z[oe];ee[oe]=t.slice(be,he),be=Ie}ee[z.length]=t.slice(be),t=ee.join("")}}let yt=ao(t,l);if(yt.hasScoped)t=yt.html;let jr=e.__stx_event_bindings||[],rt=!1,bt=[],Nr=/\s:[a-z][\w.-]*\s*=/.test(t),{scanScriptTags:Hr}=await o("stx/signal-processing",()=>import("./chunk-8x3yaahc.js"));for(let X of Hr(t,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))bt.push({match:X.fullMatch,attrs:X.attrs,content:X.body});for(let{match:X,attrs:z,content:ee}of bt){rt=!0;let be=ee;Ke(ee,l,a.strict,e.__originalFilePath);let oe=await Je(ee,{eventBindings:jr,attrs:z,hasColonDirectives:Nr,templateContent:r,filePath:l,projectRoot:process.cwd(),production:sa(a.buildMode,a.minifyClient),serverData:ie});t=t.replace(X,()=>oe)}if(rt)e.__stx_event_bindings=[];if(!rt&&e.__stxProcessingDepth===1){let X=e.__stx_event_bindings||[];if(X.length>0){let z=Mi(X);if(z){let ee=c(t);t=ee===-1?t+z:t.slice(0,ee)+z+`
1466
- `+t.slice(ee)}e.__stx_event_bindings=[]}}if(!p.skipSignalsRuntime&&!Ae(t)&&zc(t))t=await Cr(t,p);if(t=Hc(t),p.csp?.enabled&&p.csp.useNonce&&typeof e.cspNonce==="string")t=It(t,e.cspNonce);return t}
1467
- export{Pt,Ue,Mc,Es,si,oi,br,i};