@stacksjs/stx 0.2.915 → 0.2.919

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 (280) hide show
  1. package/dist/app-shell.js +3 -2
  2. package/dist/{chunk-frpsrv1e.js → chunk-09xqy448.js} +2 -2
  3. package/dist/chunk-0ebaf0pr.js +2 -0
  4. package/dist/chunk-0jjq552g.js +2 -0
  5. package/dist/chunk-0wctbtad.js +7 -0
  6. package/dist/{chunk-r7y1196g.js → chunk-0xyfs691.js} +4 -4
  7. package/dist/{chunk-w98yt4d4.js → chunk-14df2jzs.js} +2 -2
  8. package/dist/chunk-15rc8t28.js +2 -0
  9. package/dist/chunk-1a2c4pv8.js +54 -0
  10. package/dist/{chunk-1jakr6f2.js → chunk-1baxccfq.js} +18 -18
  11. package/dist/{chunk-0vyytd9v.js → chunk-1bf0grbf.js} +3 -3
  12. package/dist/chunk-1jrhjn2b.js +2 -0
  13. package/dist/chunk-1svffhzq.js +2 -0
  14. package/dist/{chunk-1hx6dyy9.js → chunk-1ts1pg90.js} +2 -2
  15. package/dist/{chunk-88fx8xc1.js → chunk-1vsjmwr1.js} +2 -2
  16. package/dist/{chunk-cxsc37fg.js → chunk-2f46pcg0.js} +2 -2
  17. package/dist/{chunk-pcwq66w3.js → chunk-2jm7map2.js} +2 -2
  18. package/dist/chunk-2m4ydym0.js +33 -0
  19. package/dist/chunk-2mv29s6w.js +9 -0
  20. package/dist/{chunk-d1ka4dvr.js → chunk-2szhk8mh.js} +5 -5
  21. package/dist/{chunk-gg715pj6.js → chunk-2zb642qr.js} +6 -6
  22. package/dist/chunk-3aayrnbh.js +21 -0
  23. package/dist/chunk-3br07y64.js +20 -0
  24. package/dist/{chunk-2f5jjxcj.js → chunk-3efpqm1f.js} +2 -2
  25. package/dist/chunk-3ftrv1f7.js +182 -0
  26. package/dist/{chunk-barb4gka.js → chunk-3hfv217t.js} +6 -6
  27. package/dist/{chunk-eptzpvn0.js → chunk-3kpxkjgm.js} +3 -3
  28. package/dist/{chunk-4w8t0a9e.js → chunk-3tcy9r6r.js} +27 -27
  29. package/dist/{chunk-zv3rn0ch.js → chunk-40j2pmnb.js} +6 -6
  30. package/dist/chunk-426gq0g5.js +2 -0
  31. package/dist/chunk-4ge80k8j.js +2 -0
  32. package/dist/chunk-4vdfqr64.js +2 -0
  33. package/dist/chunk-4yz33vzb.js +2 -0
  34. package/dist/chunk-4zcswx6x.js +2 -0
  35. package/dist/{chunk-smnt37jq.js → chunk-50zzar2c.js} +3 -3
  36. package/dist/{chunk-vayzmvf5.js → chunk-514yg4dr.js} +6 -6
  37. package/dist/{chunk-vnk582z7.js → chunk-5fdc8pej.js} +102 -36
  38. package/dist/chunk-5ht628zp.js +2 -0
  39. package/dist/chunk-67zy5p7x.js +2 -0
  40. package/dist/chunk-6bm7t0hm.js +3 -0
  41. package/dist/{chunk-7qzanp9y.js → chunk-6n6kndk0.js} +1 -1
  42. package/dist/chunk-6x5a2w5a.js +3 -0
  43. package/dist/{chunk-xc5esqcb.js → chunk-6ybq9pfh.js} +2 -2
  44. package/dist/{chunk-23x3k751.js → chunk-7axtwg1f.js} +2 -2
  45. package/dist/chunk-8153bfpx.js +2 -0
  46. package/dist/{chunk-16sfjkc4.js → chunk-858p3hkz.js} +2 -2
  47. package/dist/chunk-86p0m920.js +2 -0
  48. package/dist/chunk-88texeh4.js +2 -0
  49. package/dist/chunk-8mye65n9.js +2 -0
  50. package/dist/chunk-8ycgk8w6.js +2 -0
  51. package/dist/{chunk-npj20tj9.js → chunk-9707zz6v.js} +2 -2
  52. package/dist/{chunk-pyyda92j.js → chunk-9gr7m3tb.js} +1 -1
  53. package/dist/{chunk-952dfmcb.js → chunk-9mack1g8.js} +3 -3
  54. package/dist/chunk-9xcsn4pb.js +2 -0
  55. package/dist/{chunk-3jc6yb02.js → chunk-9zwmfkfg.js} +9 -9
  56. package/dist/chunk-a5tg553d.js +2 -0
  57. package/dist/chunk-agxxqjjt.js +2 -0
  58. package/dist/{chunk-phzhmnnm.js → chunk-ayrd026n.js} +3 -3
  59. package/dist/chunk-b44pvac7.js +2 -0
  60. package/dist/chunk-b4yp16a2.js +2 -0
  61. package/dist/{chunk-95j8660f.js → chunk-cbqe84g3.js} +2 -2
  62. package/dist/{chunk-qsexsrw2.js → chunk-d4xjwebv.js} +5 -5
  63. package/dist/{chunk-pmn9kynz.js → chunk-d69k67bn.js} +11 -11
  64. package/dist/chunk-ex6dne7e.js +3 -0
  65. package/dist/chunk-fb63xppz.js +2 -0
  66. package/dist/chunk-ffqqkeye.js +2 -0
  67. package/dist/chunk-fjpt8arw.js +3 -0
  68. package/dist/{chunk-mgj074y2.js → chunk-fn0y9z1t.js} +5 -5
  69. package/dist/{chunk-ar6jeqmm.js → chunk-ft34x0h1.js} +4 -4
  70. package/dist/{chunk-7x3tt27s.js → chunk-fwxgzktt.js} +2 -2
  71. package/dist/chunk-g1v12bjm.js +2 -0
  72. package/dist/chunk-gg0kkn2e.js +2 -0
  73. package/dist/chunk-ggg8b8n1.js +2 -0
  74. package/dist/chunk-ggrcg7k7.js +2 -0
  75. package/dist/{chunk-11c7xg1z.js → chunk-gjyz5ma7.js} +1 -1
  76. package/dist/chunk-gmn9ba8f.js +3 -0
  77. package/dist/chunk-gqe574d9.js +2 -0
  78. package/dist/chunk-h4nqjks2.js +2 -0
  79. package/dist/chunk-hajamm16.js +2 -0
  80. package/dist/chunk-hg2n2264.js +2 -0
  81. package/dist/{chunk-6t8ce21j.js → chunk-hht7n4zd.js} +2 -2
  82. package/dist/chunk-hxabvt31.js +2 -0
  83. package/dist/chunk-j3sat6vn.js +2 -0
  84. package/dist/chunk-j9gbnqxq.js +2 -0
  85. package/dist/{chunk-1hbf5e1h.js → chunk-jgtn9t5n.js} +2 -2
  86. package/dist/chunk-jj2z4nxa.js +2 -0
  87. package/dist/{chunk-0jdz31q1.js → chunk-jjq7c8s2.js} +3 -3
  88. package/dist/chunk-k289127j.js +2 -0
  89. package/dist/{chunk-p3fepzt9.js → chunk-kk9h53xg.js} +3 -3
  90. package/dist/{chunk-xnp031ba.js → chunk-ktv65e3n.js} +7 -7
  91. package/dist/chunk-m1hfh2t4.js +2 -0
  92. package/dist/{chunk-9b2wdkbq.js → chunk-m390z8w8.js} +11 -11
  93. package/dist/chunk-m3qwqhxp.js +2 -0
  94. package/dist/{chunk-t85zac4y.js → chunk-m6hrb7rm.js} +58 -58
  95. package/dist/{chunk-7gwysmrs.js → chunk-m86sjbx7.js} +3 -3
  96. package/dist/chunk-m9smh7fs.js +2 -0
  97. package/dist/{chunk-1jvt9t3r.js → chunk-m9ta0640.js} +2 -2
  98. package/dist/chunk-mhnjtc42.js +2 -0
  99. package/dist/{chunk-hhspwfva.js → chunk-mn9t5fnv.js} +2 -2
  100. package/dist/{chunk-36cz2v8k.js → chunk-mnpfvxpa.js} +31 -31
  101. package/dist/{chunk-2vx2ben8.js → chunk-mr9pp5cf.js} +2 -2
  102. package/dist/{chunk-1jxkc6d0.js → chunk-mztjpp7m.js} +2 -2
  103. package/dist/chunk-n4bxb2hx.js +2 -0
  104. package/dist/chunk-n958bxm6.js +2 -0
  105. package/dist/{chunk-8wqhzzkn.js → chunk-neymp1bb.js} +3 -3
  106. package/dist/chunk-nkbnsbb0.js +3 -0
  107. package/dist/chunk-nkr1aa5z.js +2 -0
  108. package/dist/{chunk-nhyv3w4r.js → chunk-p0xqm2ne.js} +1 -1
  109. package/dist/chunk-p3vswt0f.js +2 -0
  110. package/dist/{chunk-z110bf2c.js → chunk-p3x7kwb5.js} +7 -7
  111. package/dist/chunk-p4twxjfs.js +6 -0
  112. package/dist/chunk-p8wnp4p1.js +2 -0
  113. package/dist/{chunk-bvqgq18r.js → chunk-p97h91zx.js} +2 -2
  114. package/dist/chunk-pjv4dskp.js +2 -0
  115. package/dist/{chunk-5jc9hmwg.js → chunk-pwg544dw.js} +2 -2
  116. package/dist/chunk-pxvp0cc9.js +3 -0
  117. package/dist/chunk-q3z252d9.js +2 -0
  118. package/dist/{chunk-q9gbdzw0.js → chunk-qda8tmk9.js} +2 -2
  119. package/dist/chunk-qfkak3jb.js +2 -0
  120. package/dist/chunk-qnytvyy0.js +2 -0
  121. package/dist/{chunk-fznjm7qt.js → chunk-qsnw0qyp.js} +2 -2
  122. package/dist/{chunk-ftvpz1j4.js → chunk-qtzfbv7e.js} +5 -5
  123. package/dist/{chunk-9xmx8hc7.js → chunk-qzqqzraq.js} +8 -8
  124. package/dist/{chunk-47z0m17p.js → chunk-rk16391e.js} +3 -3
  125. package/dist/chunk-rt7xy537.js +2 -0
  126. package/dist/chunk-rwjye578.js +2 -0
  127. package/dist/{chunk-cwcmmgvz.js → chunk-s1x2pc9b.js} +2 -2
  128. package/dist/{chunk-zbpvmgjn.js → chunk-sbr3wg75.js} +65 -65
  129. package/dist/chunk-sftznswb.js +2 -0
  130. package/dist/{chunk-cq4cwfqf.js → chunk-sxrcac01.js} +2 -2
  131. package/dist/{chunk-fzcqw147.js → chunk-tb4be5ct.js} +3 -3
  132. package/dist/{chunk-m8n14s3z.js → chunk-tnbzg7fd.js} +2 -2
  133. package/dist/{chunk-jr2r2nh5.js → chunk-txk2z7v0.js} +4 -4
  134. package/dist/chunk-tz5ktd6d.js +2 -0
  135. package/dist/{chunk-302nw40c.js → chunk-v060015m.js} +1 -1
  136. package/dist/chunk-v1a5h1tc.js +38 -0
  137. package/dist/{chunk-7anbc757.js → chunk-v1x96kjr.js} +8 -8
  138. package/dist/chunk-vb609vbj.js +1323 -0
  139. package/dist/chunk-vf7tpgqz.js +70 -0
  140. package/dist/chunk-vtcyber4.js +2 -0
  141. package/dist/chunk-vtj3dwhh.js +4 -0
  142. package/dist/{chunk-p9fyn5k4.js → chunk-whnzf9hn.js} +5 -5
  143. package/dist/chunk-wq2bpt0w.js +2 -0
  144. package/dist/{chunk-sdmq09jw.js → chunk-wv0wsavj.js} +2 -2
  145. package/dist/chunk-wv8zt78c.js +2 -0
  146. package/dist/{chunk-whc4jptx.js → chunk-wxqay5c2.js} +1 -1
  147. package/dist/{chunk-gfp39bzr.js → chunk-x40j67z1.js} +2 -2
  148. package/dist/chunk-xakqpa4z.js +3 -0
  149. package/dist/{chunk-dgt9kfkp.js → chunk-xap1f1bw.js} +2 -2
  150. package/dist/{chunk-zk5g49p5.js → chunk-xk7hdpq5.js} +3 -3
  151. package/dist/{chunk-zkwkhesc.js → chunk-xmy75h5v.js} +2 -2
  152. package/dist/{chunk-dp6r6gtb.js → chunk-xpsg91dh.js} +5 -5
  153. package/dist/{chunk-va4xam1q.js → chunk-xq5s4vc1.js} +1 -1
  154. package/dist/chunk-xy3ex6ht.js +2 -0
  155. package/dist/chunk-y899wtm8.js +2 -0
  156. package/dist/chunk-ye45znz5.js +2 -0
  157. package/dist/chunk-yegp50jb.js +2 -0
  158. package/dist/chunk-yq9aqpk8.js +2 -0
  159. package/dist/{chunk-5xbx0r3k.js → chunk-yvaqgdv1.js} +2 -2
  160. package/dist/{chunk-etmq1qny.js → chunk-yye2pec5.js} +14 -14
  161. package/dist/{chunk-47nzpbvm.js → chunk-yzqb7y45.js} +6 -6
  162. package/dist/{chunk-n0nf8n0h.js → chunk-z6nyyt3n.js} +6 -6
  163. package/dist/{chunk-fs43342z.js → chunk-zaj3nnvv.js} +2 -2
  164. package/dist/{chunk-2qk2ppgm.js → chunk-zb6my502.js} +1 -1
  165. package/dist/{chunk-ra2tzsvz.js → chunk-zrxvj3zf.js} +5 -5
  166. package/dist/chunk-zt45dqfx.js +2 -0
  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/craft-entry.js +2 -2
  171. package/dist/craft.js +2 -2
  172. package/dist/dev-server/ts-css.d.ts +1 -1
  173. package/dist/dev-server/ts-css.js +2 -2
  174. package/dist/document-shell.d.ts +2 -0
  175. package/dist/document-shell.js +15 -3
  176. package/dist/document-tags.d.ts +2 -0
  177. package/dist/document-tags.js +9 -0
  178. package/dist/head-injection.d.ts +2 -0
  179. package/dist/head-injection.js +1 -0
  180. package/dist/head.d.ts +2 -0
  181. package/dist/head.js +2 -2
  182. package/dist/native/compiler/html-to-ir.d.ts +3 -1
  183. package/dist/native/compiler/html-to-ir.js +31 -0
  184. package/dist/native/compiler/ir.d.ts +1 -0
  185. package/dist/native/components/primitives.d.ts +1 -0
  186. package/dist/native/event-names.js +2 -0
  187. package/dist/native/runtime/browser-renderer.d.ts +1 -0
  188. package/dist/native/runtime/browser-renderer.js +23 -6
  189. package/dist/native/testing.d.ts +1 -0
  190. package/dist/native/testing.js +33 -0
  191. package/dist/page-head.js +1 -9
  192. package/dist/process.js +1 -1
  193. package/dist/pwa.js +3 -3
  194. package/dist/ssg.js +13 -13
  195. package/dist/types/config-types.d.ts +2 -1
  196. package/dist/variable-extractor.js +6 -1
  197. package/package.json +5 -5
  198. package/dist/chunk-0adc8x2h.js +0 -9
  199. package/dist/chunk-1gj46s0g.js +0 -2
  200. package/dist/chunk-1mx3j280.js +0 -2
  201. package/dist/chunk-1p6gaaf3.js +0 -3
  202. package/dist/chunk-1rfzs48h.js +0 -2
  203. package/dist/chunk-20hy5p3p.js +0 -2
  204. package/dist/chunk-29v3b5ks.js +0 -2
  205. package/dist/chunk-2cay3heb.js +0 -2
  206. package/dist/chunk-33fnbw33.js +0 -2
  207. package/dist/chunk-357qjcj1.js +0 -3
  208. package/dist/chunk-38y11q8x.js +0 -2
  209. package/dist/chunk-3q80f7mt.js +0 -2
  210. package/dist/chunk-43kz6rx9.js +0 -2
  211. package/dist/chunk-490rrkrp.js +0 -2
  212. package/dist/chunk-49980am3.js +0 -2
  213. package/dist/chunk-4a9bqc8f.js +0 -33
  214. package/dist/chunk-4e18r89n.js +0 -3
  215. package/dist/chunk-4r0028av.js +0 -1323
  216. package/dist/chunk-4vz17ytv.js +0 -68
  217. package/dist/chunk-4w9pvpfd.js +0 -2
  218. package/dist/chunk-5afnyvw5.js +0 -2
  219. package/dist/chunk-5pb1x7x6.js +0 -2
  220. package/dist/chunk-6n50b07t.js +0 -2
  221. package/dist/chunk-76mn123c.js +0 -2
  222. package/dist/chunk-8egbh6z1.js +0 -2
  223. package/dist/chunk-8n9jd8cz.js +0 -2
  224. package/dist/chunk-8tfpv6zf.js +0 -6
  225. package/dist/chunk-94qc4zwb.js +0 -2
  226. package/dist/chunk-9928zdej.js +0 -3
  227. package/dist/chunk-9ay18k46.js +0 -2
  228. package/dist/chunk-9tv0tw7f.js +0 -3
  229. package/dist/chunk-a5h9bwrc.js +0 -2
  230. package/dist/chunk-am7xmh9p.js +0 -2
  231. package/dist/chunk-bdkst2wp.js +0 -2
  232. package/dist/chunk-bej9kz05.js +0 -2
  233. package/dist/chunk-ccgabq3a.js +0 -2
  234. package/dist/chunk-cv6d4zr5.js +0 -2
  235. package/dist/chunk-e5rag6rh.js +0 -3
  236. package/dist/chunk-eqdg72re.js +0 -2
  237. package/dist/chunk-fvr3h2fr.js +0 -7
  238. package/dist/chunk-g0hkknzm.js +0 -2
  239. package/dist/chunk-g44932zc.js +0 -2
  240. package/dist/chunk-g4w3wms2.js +0 -2
  241. package/dist/chunk-gmmqz698.js +0 -2
  242. package/dist/chunk-hxftzw0x.js +0 -2
  243. package/dist/chunk-j3d3q3g7.js +0 -2
  244. package/dist/chunk-jmggm1ep.js +0 -3
  245. package/dist/chunk-jz37h2z0.js +0 -4
  246. package/dist/chunk-k8s3hyh2.js +0 -2
  247. package/dist/chunk-m8mmasgc.js +0 -2
  248. package/dist/chunk-man5ap64.js +0 -54
  249. package/dist/chunk-mdgcjzcn.js +0 -38
  250. package/dist/chunk-mjny8x91.js +0 -2
  251. package/dist/chunk-mjr5fkc2.js +0 -2
  252. package/dist/chunk-n1y82svg.js +0 -2
  253. package/dist/chunk-na0e3s88.js +0 -2
  254. package/dist/chunk-new89wh2.js +0 -2
  255. package/dist/chunk-nrap20qt.js +0 -2
  256. package/dist/chunk-q85wy43m.js +0 -2
  257. package/dist/chunk-q9yahsww.js +0 -2
  258. package/dist/chunk-qdwtemy1.js +0 -2
  259. package/dist/chunk-qp0ndbk6.js +0 -2
  260. package/dist/chunk-r1fhahnn.js +0 -2
  261. package/dist/chunk-r4e17p2x.js +0 -2
  262. package/dist/chunk-rnsa5zz5.js +0 -2
  263. package/dist/chunk-rzsvxjse.js +0 -2
  264. package/dist/chunk-senrtnx2.js +0 -2
  265. package/dist/chunk-sw5g5mbd.js +0 -2
  266. package/dist/chunk-t63y6qd5.js +0 -2
  267. package/dist/chunk-v1wr2vdx.js +0 -2
  268. package/dist/chunk-v6gkjg5f.js +0 -3
  269. package/dist/chunk-vq7m7xcz.js +0 -182
  270. package/dist/chunk-wsfqb5jk.js +0 -2
  271. package/dist/chunk-wvc6eayq.js +0 -2
  272. package/dist/chunk-wz44vmgn.js +0 -21
  273. package/dist/chunk-x1kzqxj5.js +0 -2
  274. package/dist/chunk-xa98a901.js +0 -2
  275. package/dist/chunk-xj95sk0y.js +0 -2
  276. package/dist/chunk-xtf3sab5.js +0 -2
  277. package/dist/chunk-yga49yw3.js +0 -2
  278. package/dist/chunk-yn02d599.js +0 -2
  279. package/dist/chunk-z5nx021e.js +0 -20
  280. package/dist/chunk-z9wwa50p.js +0 -2
@@ -0,0 +1,1323 @@
1
+ // @bun
2
+ import{Qe,Bn,mo,Qi,z}from"./chunk-14df2jzs.js";import{jn}from"./chunk-qda8tmk9.js";import{es,C,Xl,St,aa,Gl}from"./chunk-858p3hkz.js";import{L}from"./chunk-ayrd026n.js";import{T,R}from"./chunk-jjq7c8s2.js";import{Qr,ko,qn,Wl,Be}from"./chunk-ex6dne7e.js";import{ho,d,h,Ee,qr,p,te,K,be,_,bt,vt,U,tn,g,jl,we,ne,Hn,Q,xo,je,rt,So}from"./chunk-vf7tpgqz.js";import{x}from"./chunk-6bm7t0hm.js";import{re}from"./chunk-gmn9ba8f.js";import{t,y}from"./chunk-0wctbtad.js";import{c}from"./chunk-p4twxjfs.js";import Ct from"path";import fn from"process";import{AsyncLocalStorage as Ua}from"async_hooks";var Pr=new Ua;function On(e){return e.__stx_server_data??={pending:new Map,values:new Map}}function Mr(e,n){return Pr.run(On(e),n)}async function Dr(e,n){let r=Pr.getStore();if(!r)throw Error("useServerData must run inside a <script server> render");if(typeof e!=="string"||!e.trim())throw TypeError("useServerData requires a non-empty string key");let i=r.pending.get(e);if(i)return i;let a=Promise.resolve().then(n).then((l)=>{let u=JSON.stringify(l,(v,S)=>{if(S===void 0||typeof S==="function"||typeof S==="symbol"||typeof S==="bigint"||typeof S==="number"&&!Number.isFinite(S))throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);if(S&&typeof S==="object"&&!Array.isArray(S)&&Object.getPrototypeOf(S)!==Object.prototype&&Object.getPrototypeOf(S)!==null)throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);return S}),f=JSON.parse(u);return r.values.set(e,f),f}).catch((l)=>{throw r.pending.delete(e),l});return r.pending.set(e,a),a}function Vr(e){let n=e.__stx_server_data;if(!n?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(n.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function J(e,n=!1){let r=t(e),i=[],a=new Set,l=0,u=0,f=r.length,v=()=>{if(l!==0)return;let S=r.slice(u).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(S){if(n&&S[1]==="const")return;let W=S[2];if(!a.has(W))i.push(W),a.add(W);return}let j=r.slice(u).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(j){if(n&&r.slice(u).startsWith("const"))return;j[1].split(",").forEach((W)=>{let D=W.trim();if(!D)return;let G=D.indexOf(":"),ee=(G>=0?D.slice(G+1).trim():D).split(/[\s=]/)[0];if(ee&&!a.has(ee))i.push(ee),a.add(ee)});return}let I=r.slice(u).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(I){if(n&&r.slice(u).startsWith("const"))return;I[1].split(",").forEach((W)=>{let D=W.trim().replace(/^\.\.\./,"");if(!D)return;let G=D.split(/[\s=]/)[0];if(G&&!a.has(G))i.push(G),a.add(G)});return}if(n)return;let V=r.slice(u).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(V){let W=V[1];if(!a.has(W))i.push(W),a.add(W);return}let O=r.slice(u).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(O){let W=O[1];if(!a.has(W))i.push(W),a.add(W)}};while(u<f){if(r[u]==="{"){l++,u++;continue}if(r[u]==="}"){l--,u++;continue}if(l===0&&/[a-z]/i.test(r[u])&&(u===0||/\s|[;{}()]/.test(r[u-1])))v();u++}return i.join(", ")}function Ys(e){return`{ enumerable: true, configurable: true, get() { return ${e} }, set(__stxValue_${e}) { ${e} = __stxValue_${e} } }`}function Ha(e,n=J(e).split(",").map((r)=>r.trim()).filter(Boolean)){let r=new Set(J(e,!0).split(",").map((i)=>i.trim()));return n.map((i)=>r.has(i)?`get ${i}() { return ${i} }, set ${i}(__stxValue_${i}) { ${i} = __stxValue_${i} }`:i).join(", ")}function Zs(e,n){let r=`{ ${Ha(e,n)} }`;return J(e).split(",").some((i)=>i.trim()==="__stxLiveBindings")?`Object.defineProperties(${r}, Object.getOwnPropertyDescriptors(__stxLiveBindings))`:r}import cn from"fs";import Ve from"path";function Y(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var Nr=new Map;function jr(e,n=!0){let r=Nr.get(e);if(n&&r)return r;let i=new Map,a=[Ve.join(e,"src"),Ve.join(e,"dist"),e];function l(u,f){if(f>6)return;let v;try{v=cn.readdirSync(u,{withFileTypes:!0})}catch{return}for(let S of v){let j=Ve.join(u,S.name);if(S.isDirectory()){if(S.name==="node_modules"||S.name.startsWith("."))continue;l(j,f+1)}else if(S.isFile()&&S.name.endsWith(".stx")){let I=S.name.slice(0,-4);if(!i.has(I))i.set(I,j);let V=I.toLowerCase();if(!i.has(V))i.set(V,j);let O=Y(I);if(!i.has(O))i.set(O,j)}}}for(let u of a)if(l(u,0),i.size>0)break;if(n)Nr.set(e,i);return i}function Qs(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let i=Ve.join(r,"node_modules",e);try{if(cn.statSync(i).isDirectory())return i}catch{}let a=Ve.dirname(r);if(a===r)return null;r=a}}function eo(e,n,r={}){return[Ve.resolve(Ve.dirname(n),`${e}.stx`),Ve.resolve(Ve.dirname(n),e),Ve.resolve(r.componentsDir||"components",`${e}.stx`),Ve.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function Lr(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((a)=>a.charAt(0).toUpperCase()+a.slice(1)).join(""),i=Y(n);return[n,r,i]}function Ni(e,n){let[r,i,a]=Lr(e);for(let l of[r,r.toLowerCase(),i,a]){let u=n?.__importedComponents?.get(l);if(u!==void 0)return u}}function Mi(e,n){let r=n?Ve.resolve(n):void 0,i=Ve.dirname(Ve.resolve(e));for(;;){if(cn.existsSync(Ve.join(i,"package.json")))return r&&i===r?void 0:i;let a=Ve.dirname(i);if(a===i)return;i=a}}var Ka=["src/ui","src/components","components","dist"];function cs(e,n){let r=Ve.resolve(e);if(!n&&!r.split(Ve.sep).includes("node_modules"))return[];let i=Mi(r,n);if(!i)return[];let a=[];try{let f=JSON.parse(cn.readFileSync(Ve.join(i,"package.json"),"utf8")).stx?.components;if(Array.isArray(f))a=f.filter((v)=>typeof v==="string")}catch{}let l=a.length?a:Ka;return[Ve.dirname(Ve.resolve(e)),...l.map((u)=>Ve.resolve(i,u))]}function*Di(e,n,r={},i){let a=Lr(e);if(a[0].startsWith("./")||a[0].startsWith("../")){yield Ve.resolve(Ve.dirname(n),`${a[0]}.stx`);return}let l=[...new Set(a.map((v)=>`${v}.stx`))],u=r.projectRoot||process.cwd(),f=[...cs(n,r.projectRoot),...i?.__originalFilePath?[Ve.join(Ve.dirname(i.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],Ve.join(Ve.dirname(n),"components"),Ve.resolve(u,"src/components"),Ve.resolve(u,"components"),...import.meta.dir?[Ve.resolve(import.meta.dir,"components")]:[]];for(let v of new Set(f)){for(let S of l)yield Ve.join(v,S);try{for(let S of cn.readdirSync(v,{withFileTypes:!0}))if(S.isDirectory())for(let j of l)yield Ve.join(v,S.name,j)}catch{}}}function Kr(e,n,r={},i){let a=Ni(e,i);if(a!==void 0)return a;for(let l of Di(e,n,r,i))try{if(cn.statSync(l,{throwIfNoEntry:!1})?.isFile())return l}catch{}return null}function to(e,n=[],r={}){let i=new Set([...e].map((S)=>S.replace(/[-_]/g,"").toLowerCase()));if(!i.has("src")&&!i.has("source")||!i.has("alt")&&!i.has("decorative"))return!1;let a=new Map(Object.entries(r).map(([S,j])=>[S.replace(/[-_]/g,"").toLowerCase(),j])),l=a.get("alt"),u=a.get("decorative"),f=typeof l==="string"&&!!l.trim(),v=typeof u==="string"?!["false","0","off","no"].includes(u.trim().toLowerCase()):Boolean(u);if(!f&&!v)return!1;if(["defaultsource","provider","format","densities","quality","preload","modifiers","preset"].some((S)=>i.has(S)))return!1;if([...n].some((S)=>!["load","error"].includes(S.replace(/^@/,"").split(".")[0].toLowerCase())))return!1;if(i.has("resizemode")&&(i.has("fit")||i.has("objectfit")))return!1;if(i.has("src")&&i.has("source"))return!1;return["fit","objectfit","resizemode","position","objectposition","rounded","aspectratio","zoomonhover","sources","webpsrc","webpsrcset"].some((S)=>i.has(S))}import js from"fs";import xe from"path";import Ut from"path";import Sn from"fs";var Za=new Set(["touchstart","touchmove","wheel","mousewheel"]);function Ws(e,n){if(n.passive)return!0;if(n.prevent||n.nonpassive)return!1;return Za.has(e.toLowerCase())}var Zr=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","wheel","keydown","keyup","keypress","submit","reset","change","input","focus","blur","focusin","focusout","select","invalid","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","scroll","resize","load","error","abort","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel","mounted","unmounted"]),Jr={enter:"Enter",tab:"Tab",delete:"Delete",backspace:"Backspace",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},Ja=new Set(["ctrl","alt","shift","meta"]),Yr={left:0,middle:1,right:2};function Xr(e){let n={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let r of e){let i=r.toLowerCase();if(i==="prevent")n.prevent=!0;else if(i==="stop")n.stop=!0;else if(i==="once")n.once=!0;else if(i==="capture")n.capture=!0;else if(i==="self")n.self=!0;else if(i==="passive")n.passive=!0;else if(i==="nonpassive")n.nonpassive=!0;else if(Ja.has(i))n.systemKeys.push(i);else if(i in Yr)n.mouse=i;else if(i in Jr||/^[a-z]$/.test(i))n.keys.push(Jr[i]||i.toUpperCase());else if(i.startsWith("debounce")){let a=i.match(/debounce(?:\.(\d+))?/);n.debounce=a?.[1]?Number.parseInt(a[1],10):300}else if(i.startsWith("throttle")){let a=i.match(/throttle(?:\.(\d+))?/);n.throttle=a?.[1]?Number.parseInt(a[1],10):300}}return n}function ei(e,n=""){let r=[],i=0,a=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,l;while((l=a.exec(e))!==null){let[u,f,v]=l,S=l.index,j=S+u.length,I=`__stx_evt_${n}${i++}`,V=[],O=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,W;while((W=O.exec(v))!==null){let[,G,X]=W,ee=G.split("."),H=ee[0];if(!Zr.has(H))continue;V.push({attribute:`@${G}`,event:H,handler:X,modifiers:Xr(ee.slice(1)),elementId:I})}let D=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((W=D.exec(v))!==null){let[,G,X]=W,ee=G.split("."),H=ee[0];if(!Zr.has(H))continue;V.push({attribute:`@${G}`,event:H,handler:X,modifiers:Xr(ee.slice(1)),elementId:I})}if(V.length>0)r.push({originalTag:u,elementId:I,events:V,startIndex:S,endIndex:j})}return r}function qa(e){let n=[],{modifiers:r}=e;if(r.self)n.push("if ($event.target !== $el) return");for(let i of r.systemKeys)n.push(`if (!$event.${i}Key) return`);if(r.keys.length>0){let i=r.keys.map((a)=>`$event.key === '${a}'`).join(" || ");n.push(`if (!(${i})) return`)}if(r.mouse!==null){let i=Yr[r.mouse];n.push(`if ($event.button !== ${i}) return`)}if(r.prevent)n.push("$event.preventDefault()");if(r.stop)n.push("$event.stopPropagation()");return n.join("; ")}function Xa(e,n){let r=e;if(n.debounce!==null)r=`__stx_debounce(() => { ${r} }, ${n.debounce})`;else if(n.throttle!==null)r=`__stx_throttle(() => { ${r} }, ${n.throttle})`;return r}function Fs(e){let n=e.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n))return e;return`if (typeof ${n} === 'function' && !${n}._isSignal) ${n}($event);`}function Ga(e){let{modifiers:n}=e,r=e.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),i=qa(e),a=Xa(Fs(e.handler),n),l=[];if(n.once)l.push("once: true");if(n.capture)l.push("capture: true");if(Ws(e.event,n))l.push("passive: true");let u=l.length>0?`, { ${l.join(", ")} }`:"",f=a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(e.event==="mounted")return`
3
+ (function() {
4
+ var $el = document.getElementById('${r}');
5
+ if (!$el) return;
6
+ // Run mounted handler immediately (DOM is ready)
7
+ var scope = $el.closest('[data-stx-scope]');
8
+ if (scope && scope.__stx_execute) {
9
+ scope.__stx_execute('${f}', null, $el);
10
+ }
11
+ else {
12
+ __stx_runHandler('${f}', null, $el);
13
+ }
14
+ })();`;if(e.event==="unmounted")return`
15
+ (function() {
16
+ var $el = document.getElementById('${r}');
17
+ if (!$el) return;
18
+ // Set up MutationObserver to detect removal
19
+ var observer = new MutationObserver(function(mutations) {
20
+ for (var m of mutations) {
21
+ for (var node of m.removedNodes) {
22
+ if (node === $el || (node.contains && node.contains($el))) {
23
+ observer.disconnect();
24
+ var scope = $el.closest('[data-stx-scope]');
25
+ if (scope && scope.__stx_execute) {
26
+ scope.__stx_execute('${f}', null, $el);
27
+ }
28
+ else {
29
+ __stx_runHandler('${f}', null, $el);
30
+ }
31
+ return;
32
+ }
33
+ }
34
+ }
35
+ });
36
+ observer.observe(document.body, { childList: true, subtree: true });
37
+ // Store observer for cleanup
38
+ $el.__stx_unmount_observer = observer;
39
+ })();`;return`
40
+ (function() {
41
+ var $el = document.getElementById('${r}');
42
+ if (!$el) return;
43
+ // eslint-disable-next-line pickier/no-unused-vars
44
+ $el.addEventListener('${e.event}', function($event) {
45
+ ${i?i+";":""}
46
+ // Find the closest reactive scope and execute within its context
47
+ var scope = $el.closest('[data-stx-scope]');
48
+ if (scope && scope.__stx_execute) {
49
+ scope.__stx_execute('${f}', $event, $el);
50
+ }
51
+ else {
52
+ // Fallback for non-reactive context (entity-safe; decoded + run in memory)
53
+ __stx_runHandler('${f}', $event, $el);
54
+ }
55
+ }${u});
56
+ })();`}function Li(e){if(e.length===0)return"";return`
57
+ <script data-stx-events>
58
+ (function() {
59
+ 'use strict';
60
+
61
+ // Utility functions
62
+ function __stx_debounce(fn, delay) {
63
+ var timeout;
64
+ return function() {
65
+ var args = arguments;
66
+ var ctx = this;
67
+ clearTimeout(timeout);
68
+ timeout = setTimeout(function() { fn.apply(ctx, args); }, delay);
69
+ };
70
+ }
71
+
72
+ function __stx_throttle(fn, delay) {
73
+ var last = 0;
74
+ return function() {
75
+ var now = Date.now();
76
+ if (now - last >= delay) {
77
+ last = now;
78
+ fn.apply(this, arguments);
79
+ }
80
+ };
81
+ }
82
+
83
+ // Non-reactive fallback runner. The handler is embedded HTML-entity-encoded
84
+ // so the surrounding script element can never contain raw markup, including
85
+ // its own closing tag; we decode it to JS only in memory here, then run it
86
+ // with $event/$el in scope.
87
+ //
88
+ // This comment must not spell that closing tag out. It used to, as an
89
+ // example, and a browser ends the script element at the FIRST one it sees \u2014
90
+ // so everything below this line, __stx_runHandler included, was emitted as
91
+ // page text and no listener was ever bound. The comment about escaping was
92
+ // the thing that needed escaping.
93
+ function __stx_runHandler(h, $event, $el) {
94
+ var code = h
95
+ .replace(/&lt;/g, '<')
96
+ .replace(/&gt;/g, '>')
97
+ .replace(/&quot;/g, '"')
98
+ .replace(/&#39;/g, "'")
99
+ .replace(/&#x27;/g, "'")
100
+ .replace(/&amp;/g, '&');
101
+ try {
102
+ // eslint-disable-next-line no-new-func
103
+ (new Function('$event', '$el', code)).call($el, $event, $el);
104
+ }
105
+ catch (e) {
106
+ if (typeof console !== 'undefined') console.error('[stx] event handler error:', e);
107
+ }
108
+ }
109
+
110
+ // Event listeners
111
+ ${e.map(Ga).join(`
112
+ `)}
113
+ })();
114
+ </script>`}function Ya(e,n=""){let r=ei(e,n);if(r.length===0)return{template:e,bindings:[]};let i=e,a=[];for(let l=r.length-1;l>=0;l--){let u=r[l],f=u.originalTag;if(!f.includes(" id="))f=f.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${u.elementId}"`);else{let v=f.match(/id=["']([^"']+)["']/);if(v)for(let S of u.events)S.elementId=v[1]}for(let v of u.events){let S=v.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`\\s*${S}\\s*=\\s*"[^"]*"`,"g"),I=new RegExp(`\\s*${S}\\s*=\\s*'[^']*'`,"g");f=f.replace(j,""),f=f.replace(I,"")}i=i.slice(0,u.startIndex)+f+i.slice(u.endIndex),a.push(...u.events)}return{template:i,bindings:a}}function Gr(e){let n=e.$uid;return typeof n==="string"&&n?`${n}_`:""}function ll(e,n,r){if(Gl(e))return e;if(n.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(e))return e;let{template:f,bindings:v}=Ya(e,Gr(n)),S=n.__stx_event_bindings||[];return n.__stx_event_bindings=[...S,...v],f}let i=ei(e,Gr(n));if(i.length===0)return e;let a=e;for(let f=i.length-1;f>=0;f--){let v=i[f],S=v.originalTag;if(!S.includes(" id="))S=S.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${v.elementId}"`);else{let j=S.match(/id=["']([^"']+)["']/);if(j)for(let I of v.events)I.elementId=j[1]}for(let j of v.events){let I=j.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),V=new RegExp(`\\s*${I}\\s*=\\s*"[^"]*"`,"g"),O=new RegExp(`\\s*${I}\\s*=\\s*'[^']*'`,"g");S=S.replace(V,""),S=S.replace(O,"")}a=a.slice(0,v.startIndex)+S+a.slice(v.endIndex)}let l=Li(i.flatMap((f)=>f.events)),u=c(a);if(u!==-1)a=a.slice(0,u)+l+`
115
+ `+a.slice(u);else a+=l;return a}function ti(e,n){let r=new Set;for(let i of e.split(",")){let a=i.trim().replace(/^\.\.\./,"").trim();if(!a)continue;if(n){let l=a.lastIndexOf(":");if(l!==-1)a=a.slice(l+1).trim()}if(a=a.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(a))r.add(a)}return r}function Vt(e,n){let r=t(e),{depths:i,balanced:a}=y(r),l=(f)=>!a||i[f]===0,u=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${n}\\b)`,"g");for(let f of r.matchAll(u)){let v=(f.index??0)+f[0].length-f[1].length;if(l(v))return!0}for(let f of r.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(l(f.index??0)&&ti(f[1],!0).has(n))return!0;for(let f of r.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(l(f.index??0)&&ti(f[1],!1).has(n))return!0;return!1}var qe="0.2.919";var ni=Symbol.for(`stx.lazy-module-promises.${qe}`);function ec(){let e=globalThis;return e[ni]??=new Map,e[ni]}function o(e,n){let r=ec(),i=`${import.meta.url}\x00${e}`,a=r.get(i);if(a)return a;let l=n();return r.set(i,l),l.catch(()=>{if(r.get(i)===l)r.delete(i)}),l}var tc=/<\/(script)/gi;function me(e){if(!e||e.indexOf("</")===-1)return e;return e.replace(tc,"<\\/$1")}import si from"fs";var ri=[];function k(e){let n=new T(e);return ri.push(n),n}function ul(){for(let e of ri)e.clear()}function E(e,...n){return`${n.map((r)=>String(r??"")).join("\x00")}\x00${e.length}\x00${Bun.hash(e)}`}function Br(e){let n=[];for(let r of new Set(e))try{n.push({path:r,mtimeMs:si.statSync(r).mtimeMs})}catch{}return n}function no(e){for(let n of e)try{if(si.statSync(n.path).mtimeMs!==n.mtimeMs)return!1}catch{return!1}return!0}var Oe=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var nc=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function sc(e){if(e.startsWith(".")||e.startsWith("/"))return null;if(e.startsWith("@")){let r=e.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!r)return null;return{pkg:r[1],subpath:r[2]||""}}let n=e.match(/^([^/]+)(\/.*)?$/);if(!n)return null;return{pkg:n[1],subpath:n[2]||""}}function rc(e,n){let r=n;while(!0){let i=Ut.join(r,"node_modules",e,"package.json");if(Sn.existsSync(i))return Ut.dirname(i);let a=Ut.dirname(r);if(a===r)return null;r=a}}function ic(e,n){if(!e||typeof e!=="object")return null;let r=(a)=>{if(typeof a==="string")return a;if(a&&typeof a==="object"){if(typeof a.import==="string")return a.import;if(typeof a.default==="string")return a.default;if(typeof a.import==="object")return r(a.import);if(typeof a.default==="object")return r(a.default)}return null};if(Object.prototype.hasOwnProperty.call(e,n))return r(e[n]);let i=null;for(let a of Object.keys(e)){let l=a.indexOf("*");if(l===-1)continue;let u=a.slice(0,l),f=a.slice(l+1);if(!n.startsWith(u)||!n.endsWith(f))continue;if(n.length<u.length+f.length)continue;if(!i||u.length>i.prefix.length)i={pattern:a,prefix:u,suffix:f}}if(i){let a=n.slice(i.prefix.length,n.length-i.suffix.length),l=r(e[i.pattern]);if(l)return l.replace("*",a)}return null}function oc(e,n){let r=sc(e);if(!r||!r.subpath)return null;let i=rc(r.pkg,n);if(!i)return null;let a;try{a=JSON.parse(Sn.readFileSync(Ut.join(i,"package.json"),"utf8"))}catch{return null}let l=`.${r.subpath}`,u=ic(a.exports,l);if(!u)return null;let f=Ut.resolve(i,u);return Sn.existsSync(f)?f:null}function qi(e,n){let r=n.filePath?Ut.dirname(n.filePath):n.projectRoot||process.cwd(),i=n.projectRoot||process.cwd(),a=new Set,l=[],u=[];return{code:e.replace(nc,(v,S)=>{let j;try{if(S.startsWith("./")||S.startsWith("../")||S.startsWith("/")){if(j=S.startsWith("/")?S:Ut.resolve(r,S),!Sn.existsSync(j))throw Error(`file not found: ${j}`)}else{let I=null;try{I=Bun.resolveSync(S,i)}catch{I=oc(S,i)}if(!I)throw Error(`could not resolve ${S} (Bun.resolveSync + exports fallback both failed)`);j=I}}catch(I){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(S)} (from ${n.filePath||"<unknown>"}): ${I?.message||I}`),u.push(S),""}if(a.has(j))return"";a.add(j);try{let I=Sn.readFileSync(j,"utf8");l.push({source:S,resolvedPath:j,contents:I})}catch(I){console.warn(`[stx:vendor-css] could not read ${j}: ${I?.message||I}`),u.push(S)}return""}),styles:l,unresolved:u}}function ac(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ki(e){if(e.length===0)return"";return`${e.map((n)=>`<style data-stx-vendor="${ac(n.source)}" data-stx-layer="vendor">
116
+ @layer vendor {
117
+ ${n.contents}
118
+ }
119
+ </style>`).join(`
120
+ `)}
121
+ `}var Wg=C,ii=k(256);function Gt(e){let n=E(e),r=ii.get(n);if(!r)r=cc(e),ii.set(n,r);return{code:r.code,imports:[...r.imports],models:[...r.models]}}function cc(e){let n=t(e),r=new Set;for(let f of e.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let v of f[1].split(",")){let S=v.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(S)r.add(S)}let i=ko(n),a=Oe.filter((f)=>{if(r.has(f)||i.has(f))return!1;return qg(n,f,!0)}),l=li(n).filter((f)=>!r.has(f)&&!i.has(f));if(a.length===0&&l.length===0)return{code:e,imports:a,models:l};return{code:`${[a.length>0?`import { ${a.join(", ")} } from '@stacksjs/browser'`:"",l.length>0?"import '@stacksjs/browser'":"",l.length>0?`const { ${l.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
122
+ `)}
123
+ ${e}`,imports:a,models:l}}var lc=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);function li(e,n=Qr(e)){let r=new Set,i=ko(e),a=/(?<![\w$.])([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g;for(let l of n.code.matchAll(a)){let u=l[1];if(lc.has(u)||i.has(u)||u.length<3)continue;if(n.shadows(u,l.index??0))continue;r.add(u)}return Array.from(r)}function uc(e){return ko(e)}var oi=k(128);function Tl(e){let n=E(e),r=oi.get(n);if(!r)r=pc(e),oi.set(n,r);return{code:r.code,stxImports:[...r.stxImports],browserImports:[...r.browserImports]}}function pc(e){let n=new Set,r=new Set,i=e;i=i.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let a=new Set,l=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,u;while((u=l.exec(e))!==null){let O=u[1],W=u[2];if(u[0].includes("import type"))continue;let D=[];for(let X of O.split(",")){let ee=X.trim();if(!ee||ee.startsWith("type "))continue;let H=ee.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!H)continue;let q=H[1],se=H[2]||q;if(a.add(q),a.add(se),W==="stx"||W==="@stacksjs/stx")n.add(q);else r.add(q);if(se!==q)D.push(`${se} = ${q}`)}let G=D.length>0?`var ${D.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";i=i.replace(u[0],G)}let f=uc(i),v=Qr(i);for(let O of Wg){if(a.has(O)||f.has(O))continue;if(Vs(v,O,!0))n.add(O)}let S=t(i),j=Qr(S),I=new Set;for(let O of i.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let W of O[1].split(",")){let D=W.trim().replace(/^type\s+/,"").split(/\s+as\s+/);for(let G of D){let X=G.trim();if(X)I.add(X)}}for(let O of Oe){if(a.has(O)||f.has(O)||I.has(O))continue;if(Vs(j,O))r.add(O)}let V=li(S,j);for(let O of V)if(!a.has(O)&&!f.has(O))r.add(O);return{code:i,stxImports:Array.from(n),browserImports:Array.from(r)}}function qg(e,n,r=!1){return Vs(Qr(e),n,r)}function Vs(e,n,r=!1){let i=e.code,a=new RegExp(`\\b${n.replace(/[$]/g,"\\$")}\\b`,"g");for(let l of i.matchAll(a)){let u=l.index??0;if(e.shadows(n,u))continue;let f=u+n.length,v=u-1;while(v>=0&&/\s/.test(i[v]))v--;if(i[v]==="."&&i.slice(Math.max(0,v-2),v+1)!=="...")continue;let S=f;while(S<i.length&&/\s/.test(i[S]))S++;if(i[S]===":"&&i[S+1]!==":"&&(i[v]==="{"||i[v]===","))continue;if(r&&!/^\s*(?:<[^>]*>)?\s*\(/.test(i.slice(f)))continue;if(fc(i,f))continue;return!0}return!1}function fc(e,n){let r=n;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;if(e[r]!=="(")return!1;let i=0;for(;r<e.length;r++){let a=e[r];if(a==="(")i++;else if(a===")"){if(i--,i===0)break}}if(i!==0)return!1;r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;return e[r]==="{"}function $l(e,n){let r=[];if(e.length>0)r.push(` var { ${e.join(", ")} } = window.stx || window;`);if(n.length>0)r.push(` var { ${n.join(", ")} } = window.StacksBrowser || {};`);if(r.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
124
+ ${r.join(`
125
+ `)}
126
+ ${dc(e,n)}`;return""}function Dy(e,n=[]){let{browserImports:r}=Tl(e),i=new Set(n);return $l([],r.filter((a)=>!i.has(a)))}function dc(e,n){let r=[...e.map((i)=>`['${i}', typeof ${i}, 'stx']`),...n.map((i)=>`['${i}', typeof ${i}, '@stacksjs/browser']`)];if(r.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
127
+ [${r.join(", ")}].forEach(function (e) {
128
+ if (e[1] !== 'undefined') return;
129
+ console.error(
130
+ '[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
131
+ + 'but the client runtime does not provide it. Either it is not exported to the browser, '
132
+ + 'or it should be imported from a relative path so the bundler includes it.'
133
+ );
134
+ });
135
+ `}function Xe(e){let n=e.__stxClientPayload;if(n&&typeof n==="object"){let i={};for(let a in n){let l=n[a];if(typeof l==="function")continue;i[a]=l}return i.__stxDeclaredPayload=!0,i}let r={};for(let i in e){if(i.startsWith("__")||i.startsWith("$"))continue;let a=e[i];if(typeof a==="function")continue;r[i]=a}return r}var gc=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,ai=new Set;function mc(e,n){let r=gc.test(e),i=n.length>32768;if(!r&&!i)return;if(ai.has(e))return;if(ai.add(e),r)console.warn(`[stx] server\u2192client bridge is publishing "${e}" into the page body. If it holds a credential, rename it with a "__" prefix (never bridged) and pass only what the template needs. See stacksjs/stx#1831.`);if(i)console.warn(`[stx] server\u2192client bridge is publishing ${(n.length/1024).toFixed(1)}KB under "${e}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function Nn(e,n){if(!n)return"";let r=Be(e,new Set(Object.keys(n))),i=n.__stxDeclaredPayload===!0,a=[],l=Object.entries(n).sort(([u],[f])=>u<f?-1:u>f?1:0);for(let[u,f]of l){if(!/^[A-Za-z_$][\w$]*$/.test(u))continue;if(u.startsWith("__")||u.startsWith("$"))continue;if(!i&&!r.has(u))continue;if(Vt(e,u)){if(i)console.warn(`[stx] defineClientPayload declares "${u}", but this client block also declares "${u}" at the top level, so the server value is not published (emitting it would be a duplicate binding). Rename the local, or drop "${u}" from defineClientPayload.`);continue}let v;try{v=JSON.stringify(f)}catch{continue}if(v===void 0)continue;mc(u,v),a.push(` var ${u} = ${v.replace(/</g,"\\u003c")};`)}if(a.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
136
+ ${a.join(`
137
+ `)}
138
+ `}var hc={left:0,middle:1,right:2};function xc(e){let n=[];if(e.self)n.push("if ($event.target !== $el) return");for(let r of e.systemKeys)n.push(`if (!$event.${r}Key) return`);if(e.keys.length>0){let r=e.keys.map((i)=>`$event.key === '${i}'`).join(" || ");n.push(`if (!(${r})) return`)}if(e.mouse!==null){let r=hc[e.mouse];n.push(`if ($event.button !== ${r}) return`)}if(e.prevent)n.push("$event.preventDefault()");if(e.stop)n.push("$event.stopPropagation()");return n.join("; ")}function bc(e,n){let{elementId:r,event:i,modifiers:a}=e,l=Fs(e.handler),u=xc(a),f=[];if(a.once)f.push("once: true");if(a.capture)f.push("capture: true");if(Ws(i,a))f.push("passive: true");let v=f.length>0?`, { ${f.join(", ")} }`:"",S="";if(u)S+=`${u}; `;let j=l.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),I=`var $emit = function(name, detail) {
139
+ $el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
140
+ };`;function V(O){if(/\$emit\s*\(/.test(O))return`${I}
141
+ ${O}`;return`var scope = $el.closest('[data-stx-scope]');
142
+ if (scope && scope.__stx_execute) {
143
+ scope.__stx_execute('${j}', $event, $el);
144
+ }
145
+ else {
146
+ ${O}
147
+ }`}if(a.debounce!==null)return` ;(function() {
148
+ // eslint-disable-next-line pickier/no-unused-vars
149
+ var $el = document.getElementById('${r}')
150
+ if (!$el) return
151
+ var __timer
152
+ $el.addEventListener('${i}', function($event) {
153
+ ${u?u+"; ":""}clearTimeout(__timer)
154
+ __timer = setTimeout(function() { ${V(l)} }, ${a.debounce})
155
+ }${v})
156
+ })()`;if(a.throttle!==null)return` ;(function() {
157
+ // eslint-disable-next-line pickier/no-unused-vars
158
+ var $el = document.getElementById('${r}')
159
+ if (!$el) return
160
+ var __last = 0
161
+ $el.addEventListener('${i}', function($event) {
162
+ ${u?u+"; ":""}var __now = Date.now()
163
+ if (__now - __last >= ${a.throttle}) {
164
+ __last = __now
165
+ ${V(l)}
166
+ }
167
+ }${v})
168
+ })()`;if(/\$emit\s*\(/.test(l))return` var $el = document.getElementById('${r}')
169
+ if ($el) $el.addEventListener('${i}', function($event) {
170
+ ${S}${I}
171
+ ${l}
172
+ }${v})`;return` var $el = document.getElementById('${r}')
173
+ if ($el) $el.addEventListener('${i}', function($event) {
174
+ ${S}var scope = $el.closest('[data-stx-scope]');
175
+ if (scope && scope.__stx_execute) {
176
+ scope.__stx_execute('${j}', $event, $el);
177
+ }
178
+ else {
179
+ ${l}
180
+ }
181
+ }${v})`}function yc(e){if(e.length===0)return"";return`
182
+ // STX: auto-generated event bindings
183
+ ${e.map((r,i)=>bc(r,i)).join(`
184
+ `)}`}function ci(e){let n=[],r=new Set,i=e.replace(/^\s*import\s+.*$/gm,""),a=0,l=i.length,u=0;while(u<l){let f=i[u];if(f==="'"||f==='"'||f==="`"){let v=f;if(u++,v==="`"){let S=0;while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]==="`"&&S===0){u++;break}if(i[u]==="$"&&i[u+1]==="{"){S++,u+=2;continue}if(i[u]==="}"&&S>0){S--,u++;continue}u++}}else while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]===v){u++;break}u++}continue}if(f==="/"&&i[u+1]==="/"){while(u<l&&i[u]!==`
185
+ `)u++;continue}if(f==="/"&&i[u+1]==="*"){u+=2;while(u<l-1&&!(i[u]==="*"&&i[u+1]==="/"))u++;u+=2;continue}if(f==="{"){a++,u++;continue}if(f==="}"){a--,u++;continue}if(a===0){let v=i.slice(u),S=v.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(S){let V=S[1];if(!V.startsWith("_")&&!r.has(V))n.push(V),r.add(V);u+=S[0].length;continue}let j=v.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(j){j[1].split(",").forEach((V)=>{let O=V.trim(),W=O.indexOf(":"),D=W>=0?O.slice(W+1).trim().split(/[\s=]/)[0]:O.split(/[\s=]/)[0];if(D&&!D.startsWith("_")&&!r.has(D))n.push(D),r.add(D)}),u+=j[0].length;continue}let I=v.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(I){let V=I[1];if(!V.startsWith("_")&&!r.has(V))n.push(V),r.add(V);u+=I[0].length;continue}}u++}return n}var _c=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"]);function wc(e){let n=new Set,r=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function i(V){let O;while((O=r.exec(V))!==null){let W=O[0];if(!_c.has(W))n.add(W)}}let a=/\{\{([\s\S]*?)\}\}/g,l;while((l=a.exec(e))!==null)i(l[1]);let u=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((l=u.exec(e))!==null)i(l[1]);let f=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((l=f.exec(e))!==null)i(l[1]);let v=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((l=v.exec(e))!==null)i(l[1]);let S=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((l=S.exec(e))!==null)i(l[1]);let j=/@model\s*=\s*["']([^"']*)["']/gi;while((l=j.exec(e))!==null)i(l[1]);let I=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((l=I.exec(e))!==null)i(l[1]);return n}async function Ge(e,n={}){let r=e,i="",a=!1,l=[],u=qi(r,{filePath:n.filePath,projectRoot:n.projectRoot});r=u.code;let f=Ki(u.styles),v=Gt(r);r=v.code,l=[...v.imports,...v.models];let{hasUserImports:S,bundleClientScript:j}=await o("stx/client-script-bundler",()=>import("./chunk-xy3ex6ht.js"));if(S(r))r=await j(r,n.filePath||"",{projectRoot:n.projectRoot,minify:n.production}),a=!0;if(n.autoImports!==!1){let H=Tl(r);r=H.code,i=$l(H.stxImports,H.browserImports.filter((q)=>!l.includes(q)))}if(i=`${Nn(r,n.serverData)}${i}`,r=L(r),!a&&Je(n.attrs||""))r=Ye(r);let I=yc(n.eventBindings||[]),V=(n.attrs||"").trim(),O=/\btype\s*=\s*["']module["']/i.test(V),W=n.instanceId?` data-stx-instance="${n.instanceId}"`:"";if(O){let H=V.replace(/\btype\s*=\s*["']module["']/i,"").trim(),q=`type="module" data-stx-scoped${W}${H?` ${H}`:""}`;return`${f}<script ${q}>
186
+ ${me(`${i}${r}
187
+ ${I}`)}
188
+ </script>`}let D=aa(e),G=/function __stx_setup_/.test(r),X=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(e);function ee(H){let q=H.length>0?`
189
+ return ${Zs(r,H)};`:"",se=JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`);return`${f}<script data-stx-scoped data-stx-run="always"${W}>
190
+ window.stx.mount(function() {
191
+ 'use strict';
192
+ try {
193
+ ${me(`${i}${r}
194
+ ${I}${q}`)}
195
+ } catch (error) {
196
+ console.error(${se}, error);
197
+ return {};
198
+ }
199
+ })</script>`}if(!X&&!G){if(D)return ee(ci(e));if(n.templateContent){let H=ci(e);if(H.length>0){let q=wc(n.templateContent);if(H.some((ce)=>q.has(ce)))return ee(H)}}}return`${f}<script data-stx-scoped data-stx-run="always"${W}>
200
+ ;(function() {
201
+ 'use strict';
202
+ try {
203
+ ${me(`${i}${r}
204
+ ${I}`)}
205
+ } catch (error) {
206
+ console.error(${JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`)}, error);
207
+ }
208
+ })()</script>`}import{createHash as vc}from"crypto";var ls="__stx_component_client_factories";function us(e){let n=e[ls];return n instanceof Map?n:null}function kl(e){e[ls]=new Map}function Us(e,n){let r=us(e);if(!r)return null;let i=vc("sha256").update(n).digest("hex").slice(0,16),a=r.get(i);if(a)a.instances++;else r.set(i,{body:n,instances:1});return i}function _l(e,n){let r=us(n);if(!r?.size)return e;let i=new Map;for(let[j,I]of r)if(I.instances===1)i.set(j,I.body);let a=[];if(i.size>0){let j=[...i.keys()].map((O)=>JSON.stringify(O).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),I=new RegExp(`window\\.__stxComponentFactories\\[(${j})\\]\\(("[^"]+")\\);`,"g"),V=I.exec(e);while(V!==null){let O=i.get(JSON.parse(V[1]));if(O!==void 0)a.push({start:V.index,end:V.index+V[0].length,replacement:me(`(${O})(${V[2]});`)});V=I.exec(e)}}let l=[...r].filter(([,j])=>j.instances>1);if(l.length===0)return ui(e,a);let u=l.map(([j,I])=>` try { factories[${JSON.stringify(j)}] = factories[${JSON.stringify(j)}] || ${I.body}; }
209
+ catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(j)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
210
+ `),f=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
211
+ (function() {
212
+ const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
213
+ ${me(u)}
214
+ })();
215
+ </script>`,v,S=/<(?:template\b|script\b(?=[^>]*\bdata-stx-scoped\b))/iy;return g(e,(j,I)=>{if(v===void 0){if(S.lastIndex=I,S.test(j))v=I}return-1}),a.push({start:v??0,end:v??0,replacement:`${f}
216
+ `}),ui(e,a)}function ui(e,n){if(n.length===0)return e;n.sort((l,u)=>l.start-u.start||l.end-u.end);let r=Array(n.length*2+1),i=0,a=0;for(let l of n)r[a++]=e.slice(i,l.start),r[a++]=l.replacement,i=l.end;return r[a]=e.slice(i),r.join("")}function pi(e){let n=us(e),r=new Map;if(n)for(let[i,a]of n)r.set(i,a.instances);return r}function fi(e,n){let r=us(e);if(!r)return[];let i=[];for(let[a,l]of r){let u=l.instances-(n.get(a)??0);if(u>0)i.push({body:l.body,count:u})}return i}function di(e,n){for(let{body:r,count:i}of n)for(let a=0;a<i;a++)Us(e,r)}function Ie(e,n,r=2){let i=0,a=null;for(let l=n+r;l<e.length;l++){let u=e[l];if(a){if(u==="\\"){l++;continue}if(u===a)a=null;continue}if(u==='"'||u==="'"||u==="`"){a=u;continue}if(u==="{"){i++;continue}if(u==="}"){if(i>0){i--;continue}let f=0;while(e[l+f]==="}")f++;if(f>=r)return l}}return-1}import wi from"fs";var gi=0,Hs=new Map;function Il(){gi=0,Hs.clear()}function ps(e,n){let r=gi++,i=`<!--__STX_${e.toUpperCase()}_${r}__-->`;return Hs.set(i,{type:e,expression:n}),i}function Ol(){let e={};for(let[n,r]of Hs)e[n]={type:r.type,expression:r.expression};return e}function Nl(e,n){let r=e;for(let[i,a]of n)r=r.split(i).join(a);return r}function Gi(e){return e.includes("<!--__STX_")}var $c=/@(?=[a-zA-Z_]\w*\s*\(|end[a-zA-Z]*\b|else(?:if)?\b|empty\b|case\b|default\b|break\b|continue\b|fallback\b)/g;function Sc(e){return Array.from({length:e},()=>"&#123;").join("&#8288;")}function mi(e){return e.replace(/\{{2,}/g,(n)=>Sc(n.length)).replace(/\{(?=!)/g,"&#123;&#8288;").replace($c,"&#64;")}function zr(e,n,r=!1){let{openTag:i,tail:a}=r?Ec(e,n):kc(e).at(n);return Rc(a,i,r)}function Ec(e,n){let r="",i=0;for(let u=0;u<n;u++){if(!e.startsWith("{{",u))continue;let f=Ie(e,u);if(f<0||f+2>n)break;r+=e.slice(i,u)+"x",u=f+1,i=f+2}r+=e.slice(i,n);let a=-1,l=null;for(let u=0;u<r.length;u++){let f=r[u];if(l){if(f===l)l=null;continue}if(f==='"'||f==="'"){l=f;continue}if(f===">"){a=-1;continue}if(f==="<")a=u}return{openTag:a,tail:a>=0?r.slice(a+1):r}}var fs=null;function kc(e){if(fs&&fs.source===e)return fs.scanner;let n=Cc(e);return fs={source:e,scanner:n},n}function Cc(e){let n=0,r=-1,i=null,a=-1,l=(f,v)=>{let S=e[f];if(v.quote){if(S===v.quote)v.quote=null;return}if(v.openTag>=0){if(S==='"'||S==="'"){v.quote=S;return}if(S===">"){v.openTag=-1;return}}if(S==="<")v.openTag=f},u=(f,v)=>{if(v.openTag>=0||!e.startsWith("<!--",f))return-1;let S=e.indexOf("-->",f+4);return S<0?e.length:S+3};return{at(f){if(f<n)n=0,r=-1,i=null,a=-1;let v={openTag:r,quote:i},S=!1;while(n<f){if(a<0&&e.startsWith("{{",n)){let D=Ie(e,n);if(D<0)a=n;else if(D+2<=f){n=D+2;continue}else break}let W=u(n,v);if(W>=0){if(W>f){S=!0;break}n=W;continue}l(n,v),n++}if(r=v.openTag,i=v.quote,S)return{openTag:-1,tail:""};let j=a>=0?a:n,I={openTag:r,quote:i};for(let W=n;W<f;W++){let D=u(W,I);if(D>=0){if(D>f)return{openTag:-1,tail:""};W=D-1;continue}l(W,I)}if(I.openTag<0)return{openTag:-1,tail:""};let V="",O=I.openTag+1;for(let W=O;W<Math.min(f,j);W++){if(!e.startsWith("{{",W))continue;let D=Ie(e,W);V+=e.slice(O,W)+"x",W=D+1,O=D+2}return V+=e.slice(O,f),{openTag:I.openTag,tail:V}}}}function Rc(e,n,r){if(n<0&&!r)return null;if(n>=0&&/^\s*[!/?]/.test(e))return/^\s*\/?\s*$/.test(e)?{kind:"tag-name"}:null;if(n>=0&&/^\s*$/.test(e))return{kind:"tag-name"};let i=0;if(n>=0)while(i<e.length&&!/\s/.test(e[i]))i++;while(i<e.length){while(/\s/.test(e[i]??"")&&i<e.length)i++;let a=i;while(i<e.length&&!/[\s=/>]/.test(e[i]))i++;let l=e.slice(a,i);if(!l)break;while(i<e.length&&/\s/.test(e[i]))i++;if(e[i]!=="=")continue;i++;while(i<e.length&&/\s/.test(e[i]))i++;let u=e[i];if(u==='"'||u==="'"){let f=++i,v=e.indexOf(u,i);if(v===-1)return{kind:"attribute",name:l,quote:u,valuePrefix:e.slice(f)};i=v+1}else{let f=i;while(i<e.length&&!/\s/.test(e[i]))i++;if(i===e.length)return{kind:"attribute",name:l,quote:null,valuePrefix:e.slice(f)}}}return{kind:"tag"}}class he extends Error{attribute;near;constructor(e,n){super(`Unsafe interpolation in ${e}: ${n}`);this.name="UnsafeInterpolationContextError",this.attribute=e}locate(e,n){if(this.near===void 0)this.near=e.slice(Math.max(0,n-160),n).replace(/\s+/g," ").trim(),this.message+=` (after: ${JSON.stringify(this.near)})`;return this}}var hi="unsafe:";var Ac=/^(?:javascript|vbscript|livescript|mocha|view-source):/,Tc=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,jc=/^data:(?:text\/html|application\/xhtml\+xml)/,Ic=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function Oc(e){return e.replace(Ic,"").toLowerCase()}function Ks(e){let n=e.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(n))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(n))return"fetched";return null}function ds(e,n="navigable"){let r=Oc(e);if(Ac.test(r))return!0;return n==="navigable"?Tc.test(r):jc.test(r)}function Fr(e,n="navigable"){return ds(e,n)?"unsafe:"+e:e}function Pc(e){let n=e.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!n)return null;if(n[3].trim()!=="")return null;return Ks(n[1])}function xi(e,n,r=256){if(n<=r)return e.slice(0,n);let i=e.slice(n-r,n),a=i.search(/[\s"'`/]/);return a===-1?"":i.slice(a)}function bi(e,n,r=n){let i=Pc(e);return i&&ds(n,i)?"unsafe:"+r:r}function Wt(e){let n=e.indexOf(" as ");if(n!==-1){let l=e.slice(0,n).trim(),u=e.slice(n+4).trim();return l&&u?{arrayExpr:l,itemVar:u}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let i=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),a=r[2].trim();return i&&a?{arrayExpr:a,itemVar:i}:null}function gs(e){let n=[],r=0,i="",a=0;for(let l=0;l<e.length;l++){let u=e[l];if(i){if(u==="\\")l++;else if(u===i)i="";continue}if(u==="'"||u==='"'||u==="`")i=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0)n.push(e.slice(a,l)),a=l+1}return n.push(e.slice(a)),n}function yi(e,n){let r=0;for(let i=0;i<e.length;i++){let a=e[i];if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===n&&r===0)return i}return-1}function _i(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="("||i==="["||i==="{")n++;else if((i===")"||i==="]"||i==="}")&&--n===0)return r}return-1}function Ht(e,n){let r=e.trim().replace(/^\.\.\./,"").trim(),i=yi(r,"=");if(i!==-1&&r[i+1]!==">")r=r.slice(0,i).trim();if(!r)return;if(r.startsWith("{")&&r.endsWith("}")){for(let a of gs(r.slice(1,-1))){let l=a.trim();if(!l)continue;if(l.startsWith("...")){Ht(l,n);continue}let u=yi(l,":");Ht(u===-1?l:l.slice(u+1),n)}return}if(r.startsWith("[")&&r.endsWith("]")){for(let a of gs(r.slice(1,-1)))Ht(a,n);return}if(/^[A-Z_$][\w$]*$/i.test(r))n.push(r)}function oe(e){let n=e.trim(),r=[],i=0;for(let l=0;l<n.length;l++){let u=n[l];if(u==="("||u==="["||u==="{")i++;else if(u===")"||u==="]"||u==="}")i--;else if(i===0&&/\s/.test(u)){if(!/^\s+(?:in|of)\s/.exec(n.slice(l)))continue;let v=n.slice(0,l).trim();if(v.startsWith("(")&&_i(v)===v.length-1)v=v.slice(1,-1);for(let S of gs(v))Ht(S,r);if(r.length>0)return r;break}}let a=/^[\s\S]+?\s+as\s+([\s\S]+)$/.exec(n);if(a){let l=a[1].trim();if(l.startsWith("(")&&_i(l)===l.length-1)l=l.slice(1,-1);let u=/^([\w$]+)\s*=>\s*([\s\S]+)$/.exec(l);if(u)Ht(u[2],r),Ht(u[1],r);else for(let f of gs(l))Ht(f,r)}return r}function F(e,n){let r=n instanceof Set?n:new Set(n);if(r.size===0)return!1;let u=e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g," ").replace(/`(?:[^`\\$]|\\.|\$(?!\{))*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:(?!:))/g,"$1$2");for(let f of u.match(/[a-zA-Z_$][\w$]*/g)||[])if(r.has(f))return!0;return!1}var ms="__stx_client_loop_names";function ht(e){let n=e?.[ms];return Array.isArray(n)?n:[]}function hs(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],i=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let a of e.matchAll(i)){let l=a[0];if(/^<\/template\s*>$/i.test(l)){let u=r.pop();if(u)u.end=a.index}else if(/^<template\b/i.test(l)&&!/\/\s*>$/.test(l)){let f=[...l.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((j)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(j[1])),v=(f?.[2]??f?.[3])?.trim();if(v&&f?.[1]==="data-stx-slot-binding")try{v=decodeURIComponent(v)}catch{v=void 0}let S=v?{start:a.index+l.length,end:e.length,binding:v}:void 0;if(r.push(S),S)n.push(S)}}return n}var kn={},vi=new Map;function Mc(e){let n=vi.get(e);if(!n){let r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`:${r}(?!\\w)`,"g"),vi.set(e,n)}return n.lastIndex=0,n}var go={uppercase:(e,n)=>e!==void 0&&e!==null?String(e).toUpperCase():"",lowercase:(e,n)=>e!==void 0&&e!==null?String(e).toLowerCase():"",capitalize:(e,n)=>{if(e===void 0||e===null)return"";let r=String(e);return r.charAt(0).toUpperCase()+r.slice(1)},number:(e,n,r=0)=>{if(e===void 0||e===null)return"";try{let i=Number(e);return Number.isNaN(i)?"":i.toFixed(Number.parseInt(String(r),10))}catch{return""}},fmt:(e,n,r="en-US")=>{if(e===void 0||e===null)return"";try{let i=Number(e);if(Number.isNaN(i))return String(e);return i.toLocaleString(r)}catch{return String(e)}},join:(e,n,r=",")=>{if(!Array.isArray(e))return"";return e.join(String(r))},escape:(e,n)=>{if(e===void 0||e===null)return"";return Z(String(e))},translate:(e,n,r={})=>{if(!n||!n.__translations)return e;let i=n.__translations,a=n.__i18nConfig?.fallbackToKey??!0,l=String(e).split("."),u=i;for(let v of l){if(u===void 0||u===null)break;u=u[v]}if(u===void 0||u===null)return a?e:"";let f=String(u);return Object.entries(r).forEach(([v,S])=>{f=f.replace(Mc(v),()=>String(S))}),f},t:(e,n,r={})=>go.translate(e,n,r),truncate:(e,n,r=50,i="...")=>{if(e===void 0||e===null)return"";let a=String(e);if(a.length<=r)return a;if(r<=i.length)return i.substring(0,r);return a.substring(0,r-i.length)+i},date:(e,n,r="short",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=e instanceof Date?e:new Date(e);if(Number.isNaN(a.getTime()))return String(e);let l={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(r==="iso")return a.toISOString();return new Intl.DateTimeFormat(i,l[r]||l.short).format(a)}catch{return String(e)}},currency:(e,n,r="USD",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=Number(e);if(Number.isNaN(a))return String(e);return new Intl.NumberFormat(i,{style:"currency",currency:r}).format(a)}catch{return String(e)}},pluralize:(e,n,r,i)=>{let a=Number(e);if(Number.isNaN(a))return r;let l=i||`${r}s`;return a===1?r:l},first:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[0];return String(e).charAt(0)},last:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[e.length-1];let r=String(e);return r.charAt(r.length-1)},length:(e,n)=>{if(e===void 0||e===null)return 0;if(Array.isArray(e)||typeof e==="string")return e.length;if(e instanceof Map||e instanceof Set)return e.size;if(typeof e==="object")return Object.keys(e).length;return 0},json:(e,n,r=!1)=>{if(e===void 0)return"undefined";if(e===null)return"null";try{return r?JSON.stringify(e,null,2):JSON.stringify(e)}catch{return String(e)}},default:(e,n,r="")=>e===void 0||e===null||e===""?r:e,reverse:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return[...e].reverse();return String(e).split("").reverse().join("")},slice:(e,n,r=0,i)=>{if(e===void 0||e===null)return"";if(Array.isArray(e)||typeof e==="string")return e.slice(r,i);return e},replace:(e,n,r,i="")=>{if(e===void 0||e===null)return"";let a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(e).replace(new RegExp(a,"g"),()=>i)},stripTags:(e,n)=>{if(e===void 0||e===null)return"";return String(e).replace(/<[^>]*>/g,"")},urlencode:(e,n)=>{if(e===void 0||e===null)return"";return encodeURIComponent(String(e))},abs:(e,n)=>{let r=Number(e);return Number.isNaN(r)?0:Math.abs(r)},round:(e,n,r=0)=>{let i=Number(e);if(Number.isNaN(i))return 0;let a=10**r;return Math.round(i*a)/a}};function tm(e,n){if(e in go)console.warn(`Filter "${e}" already exists as a built-in filter. Custom filter will take precedence.`);kn[e]=n}function jy(e){for(let[n,r]of Object.entries(e))tm(n,r)}function nm(){return{...go,...kn}}function By(){for(let e of Object.keys(kn))delete kn[e]}function Ri(e){let n=e.next();while(!n.done)n=e.next();return n.value}function*Ai(e,n,r,i){let a="{".repeat(r);if(!e.includes(a))return e;let l="",u=0,f=0,v=i===Number.POSITIVE_INFINITY?0:performance.now();for(;;){let S=e.indexOf(a,u);if(S===-1)break;let j=Ie(e,S,r);if(j===-1)break;if(l+=e.slice(u,S)+n(e.slice(S,j+r),e.slice(S+r,j),S),u=j+r,++f>=64){f=0;let I=performance.now();if(I-v>=i)v=I,yield}}return u===0?e:l+e.slice(u)}function Dn(e,n,r=2){return Ri(Ai(e,n,r,Number.POSITIVE_INFINITY))}function Dc(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=zr(e,n);if(!a||a.kind!=="attribute"||a.quote===i)return!1;if(!/^(?::|@|x-|v-)/.test(a.name))return!1;let l=0;for(let u=0;u<a.valuePrefix.length;u++)if(a.valuePrefix[u]==="\\")u++;else if(a.valuePrefix[u]===i)l++;return l%2===1}function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Z(e){return mi(m(e))}function Nc(e){return e.replace(/ /g,"&#32;").replace(/\t/g,"&#9;").replace(/\n/g,"&#10;").replace(/\r/g,"&#13;").replace(/\f/g,"&#12;").replace(/=/g,"&#61;").replace(/`/g,"&#96;")}function Lc(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\([\dA-Fa-f]{1,6})\s?/g,(n,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(/\\([^\r\n])/g,"$1").replace(/[\u0000-\u0020]+/g,"").toLowerCase()}function zc(e,n){let r=Lc(e);if(/@import|expression\(|behavior:|-moz-binding|(?:image-set|cross-fade)\(/.test(r))throw new he(n,"network-capable or executable CSS is not allowed in an escaped interpolation");let i=/url\(([^)]*)\)/g,a;while((a=i.exec(r))!==null){let l=a[1].replace(/^["']|["']$/g,""),u=l.startsWith("/")&&!l.startsWith("//")||l.startsWith("./")||l.startsWith("../")||l.startsWith("#"),f=/^data:image\/(?:avif|bmp|gif|jpeg|jpg|png|webp);base64,[a-z\d+/=]+$/i.test(l);if(!u&&!f)throw new he(n,"CSS URLs must be local paths or base64 raster images")}}function ae(e,n,r,i=!1,a=0){try{return Bc(e,n,r,i,a)}catch(l){if(l instanceof he)l.locate(e,n);throw l}}function Bc(e,n,r,i,a){let l=zr(e,n,i),u=Z(r);if(!l)return u;if(l.kind==="tag-name"){if(!/^[A-Za-z][A-Za-z0-9:-]*$/.test(r))throw new he("tag name","dynamic tag names may contain only letters, digits, colons, and hyphens");return r}if(l.kind==="tag"){let S=e.slice(n+a).trimStart(),j=r.trim();if(!S.startsWith("=")&&(j===""||j.split(/\s+/).every((I)=>/^(?!on)[A-Za-z_:][\w:.-]*$/.test(I))))return j;throw new he("tag structure","only standalone boolean attributes may be interpolated into tag structure")}let f=l.name.toLowerCase();if(/^on[a-z]/.test(f))throw new he(l.name,"native event-handler attributes execute JavaScript; use an @event binding instead");if(f==="srcdoc")u=Z(u);if(f==="style")zc(r,l.name);if(l.quote===null)u=Nc(u);let v=Ks(f);if(v&&l.valuePrefix.trim()===""&&ds(r,v))return hi+u;return bi(xi(e,n),r,u)}function Ln(e,n){let r=` ${e}="`;return ae(r,r.length,n,!0)}function Ti(e){return e.flatMap((n)=>{let r=n.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);return!r||/\bserver\b|\bsrc\s*=/.test(r[1])?[]:[r[2]]})}function Ne(e,n){let{scripts:r}=ne(e);for(let i of Ti(r)){if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(i)||Al.test(i))return!0;if(es(i,n))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(e))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(e))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(e))return!0;return!1}function rm(e){let n=[],r=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let i=r.exec(e);i;i=r.exec(e)){let a=i[1].toLowerCase(),l=new Set(oe(i[3]));if(l.size===0)continue;let u=i.index+i[0].length;if(i[0].endsWith("/>")){n.push({start:i.index,end:u,names:l});continue}let f=new RegExp(`<(/?)${a}\\b[^>]*?(/?)>`,"gi");f.lastIndex=u;let v=1,S=e.length;for(let j=f.exec(e);j;j=f.exec(e)){if(j[2]==="/")continue;if(v+=j[1]==="/"?-1:1,v===0){S=j.index+j[0].length;break}}n.push({start:i.index,end:S,names:l})}return n}function $i(e,n,r){let i=t(r);for(let a of e){if(n<a.start||n>=a.end)continue;for(let l of a.names)if(new RegExp(`(?<![.#\\w$])${l.replace(/\$/g,"\\$")}(?![\\w$])`).test(i))return!0}return!1}function Si(e,n){let r=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","URL","URLSearchParams","Intl","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console","new","typeof","instanceof","in","void"],i=e.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),a="",l=!1,u=0;for(let S=0;S<i.length;S++){let j=i[S];if(!l&&j==="`"){l=!0,u=0;continue}if(l){if(j==="`"&&u===0){l=!1;continue}if(j==="$"&&i[S+1]==="{"){u++,S++,a+=" ";continue}if(j==="}"&&u>0){u--;continue}if(u>0){a+=j;continue}continue}a+=j}i=a;let f=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,v;while((v=f.exec(i))!==null){let S=v[1];if(!i.substring(0,v.index).trimEnd().endsWith(".")){if(!r.includes(S)&&!(S in n))return!1}}return!0}function Wc(e,n){let r=t(e);for(let i of r.matchAll(/(?<![.\w$])([A-Z_$][\w$]*)\s*\(/gi))if(typeof n[i[1]]==="function")return!0;return!1}function Fc(e,n){let r=n.__stx_serverDeclared;if(!r||r.size===0)return!1;let i=t(e);for(let a of r)if(new RegExp(`(?<![.#\\w$])${a}(?![\\w$])`).test(i))return!0;return!1}var Ei=new Set;function ki(e){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(e.trim())}function Vc(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=0;for(let l=e.lastIndexOf(`
217
+ `,n-1)+1;l<n;l++)if(e[l]==="\\")l++;else if(e[l]===i)a++;return a%2===1}function Ci(e,n){let r=`${n??"<unknown>"}\x00${e}`;if(process.env.STX_DEBUG||!Ei.has(r))Ei.add(r),console.warn(`[stx] {{ ${e} }} in a <script> in ${n??"<unknown>"} has no server value, so it was emitted as undefined. A mustache left in JavaScript is a SyntaxError that takes the whole script down, so give the value a default in <script server>.`);return"undefined"}function Ji(e,n,r){let i=e;return i=i.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>{try{let u=M(l,n);if(u===void 0)return ki(l)?Ci(l.trim(),r):a;return u===null?"":String(u)}catch{return a}}),i=Dn(i,(a,l,u)=>{let f=l.trim();if(Vc(i,u,l))return a;if(/^__[A-Z_]+__$/.test(f))return a;try{let v=M(l,n);if(v===void 0)return ki(f)?Ci(f,r):a;return JSON.stringify(v).replace(/</g,"\\u003c").replace(/@/g,"\\u0040").replace(/\{{2,}/g,(S)=>"\\u007b".repeat(S.length)).replace(/\{(?=!)/g,"\\u007b")}catch{return a}}),i}function sm(e,n){if(!e.includes("{"))return e;let r=e;return r=r.replace(/\{!!([\s\S]*?)!!\}/g,(i,a)=>{try{let l=M(a,n);if(l===void 0)return i;return l===null?"":String(l)}catch{return i}}),r=Dn(r,(i,a,l)=>{let u=a.trim();if(/^__[A-Z_]+__$/.test(u))return i;try{let f=M(a,n);if(f===void 0)return i;if(f===null)return"";let v=String(f);return ae(r,l,v,!0,i.length)}catch(f){if(f instanceof he)throw f;return i}}),r}function Fy(e,n,r={}){let{output:i,scripts:a}=ne(e),l=a.map((u)=>{let f=u.match(/^<script\b((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>/i),v=u.search(/<\/script\s*>$/i);if(!f||v===-1)return u;let S=f[1],j=u.slice(f[0].length,v);if(/\bdata-raw\b/.test(S))return u;if(r.skipServer&&/\bserver\b/.test(S))return u;let V=`<script${sm(S,n)}>`;if(/\bsrc\s*=/.test(S)||/\btype\s*=\s*["']application\/json["']/.test(S))return V+j+u.slice(v);return V+Ji(j,n)+u.slice(v)});return Hn(i,l)}function*Ii(e,n,r,i){let a=e,l=(D,G)=>{let X=tn(D,G);if(X===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(D.slice(G,X))?-1:X},u=(D,G,X,ee)=>{let H=X.length,{output:q,tokens:se}=we(D,G,(ce,le)=>ee(H+le));return X.push(...se),q},f=[];a=u(a,l,f,(D)=>`<!--__STX_STYLE_${D}__-->`);let v=[];a=u(a,U,v,(D)=>`<!--__STX_SCRIPT_EXPR_${D}__-->`);let S=n?.__stx_signals_gate===!0||Ne(e),j=new Set([...Array.isArray(n?.__stx_client_signal_names)?n.__stx_client_signal_names:[],...Xi(Ti(v))]),I=new Set(Array.isArray(n?.__stx_preserved_client_expressions)?n.__stx_preserved_client_expressions:[]);a=Dn(a,(D,G,X)=>{if(F(G,j))return D;try{let ee=M(G,n,!1,(H)=>Js(H,D,r,e));return ee!==void 0&&ee!==null?String(ee):""}catch(ee){let H=ee instanceof Error?ee.message:String(ee);return w("Expression",`Error evaluating: {{{ ${G.trim()}}}}: ${H}`,r,e,X,D)}},3),a=a.replace(/\{!!([\s\S]*?)!!\}/g,(D,G,X)=>{if(F(G,j))return D;try{let ee=M(G,n,!1,(H)=>Js(H,D,r,e));if(ee===void 0&&n.__stx_buildMode==="compile")return ps("raw",G.trim());return ee!==void 0&&ee!==null?String(ee):""}catch(ee){if(n.__stx_buildMode==="compile")return ps("raw",G.trim());let H=ee instanceof Error?ee.message:String(ee);return w("Expression",`Error evaluating: {!! ${G.trim()} !!}: ${H}`,r,e,X,D)}}),a=u(a,U,v,(D)=>`<!--__STX_SCRIPT_EXPR_${D}__-->`),a=u(a,l,f,(D)=>`<!--__STX_STYLE_${D}__-->`);let V=S?rm(a):[],O=hs(a).map((D)=>({...D,names:new Set(oe(`${D.binding} in __slot`))})),W=new Set(ht(n));if(a=yield*Ai(a,(D,G,X)=>{let ee=G.trim();if(Dc(a,X,G))return D;if($i(O,X,ee))return D;if(F(ee,W))return D;if(V.length>0&&$i(V,X,ee))return D;if(I.has(ee))return D;let H=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],q=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,ce=ee.match(q)?.[1],le=ce&&((ce in n)||H.includes(ce)),pe=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,Re=ee.match(pe),Ae=Re&&!H.includes(Re[1])&&!(Re[1]in n);if(/^__[A-Z_]+__$/.test(ee))return"";if(F(ee,j))return D;if(n.__stx_native_screen===!0&&Wc(ee,n))return D;let ve;try{let fe=M(G,n,!1,(We)=>{ve=We});if(S&&!Si(ee,n))return D;if(ve)Js(ve,D,r,e);if(n.__stx_buildMode==="compile"&&!S&&(fe===void 0||Fc(ee,n)))return ps("expr",ee);if(fe===void 0||fe===null)return"";let ze=String(fe);return ae(a,X,ze,!1,D.length)}catch(fe){if(fe instanceof he)throw fe;if(S&&!Si(ee,n))return D;if(Ae)return D;let ze=fe instanceof Error?fe.message:String(fe);return w("Expression",`Error evaluating: {{ ${ee} }}: ${ze}`,r,e,X,D)}},2,i),v.length>0)a=a.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(D,G)=>v[Number(G)]??D);if(f.length>0)a=a.replace(/<!--__STX_STYLE_(\d+)__-->/g,(D,G)=>f[Number(G)]??D);return a}function P(e,n,r){return Ri(Ii(e,n,r,Number.POSITIVE_INFINITY))}var Uc=100;async function Yi(e,n,r,i=Uc){let a=Ii(e,n,r,i),l=a.next();while(!l.done)await R(),l=a.next();return l.value}function om(e,n,r){if(!n.trim())return e;let i=e,a=n.trim();while(a.length>0){let l=a.match(/^(\w+)/);if(!l)break;let u=l[1];a=a.substring(u.length).trim();let f=kn[u]||go[u];if(!f)throw Error(`Filter not found: ${u}. Available filters: ${Object.keys(nm()).join(", ")}`);let v=[];if(a.startsWith(":")){let S=a.match(/^:([^|\s]+)/);if(S){let j=S[1].trim();try{let I=Number(j);v=[Number.isNaN(I)?j:I]}catch{v=[j]}a=a.substring(S[0].length).trim()}}else if(a.startsWith("(")){let S=1,j=1;while(S>0&&j<a.length){if(a[j]==="(")S++;if(a[j]===")")S--;j++}if(S===0){let I=a.substring(1,j-1).trim();if(I)try{if(I.startsWith("{")&&I.endsWith("}"))v=[M(`(${I})`,r,!0)];else{let V=[],O="",W=null,D=0,G=0,X=0,ee=!1;for(let H=0;H<I.length;H++){let q=I[H];if(ee){O+=q,ee=!1;continue}if(q==="\\"){O+=q,ee=!0;continue}if(W){if(O+=q,q===W)W=null;continue}if(q==='"'||q==="'"||q==="`"){W=q,O+=q;continue}if(q==="(")D++;else if(q===")")D--;else if(q==="[")G++;else if(q==="]")G--;else if(q==="{")X++;else if(q==="}")X--;if(q===","&&D===0&&G===0&&X===0){V.push(O),O="";continue}O+=q}if(O)V.push(O);v=V.map((H)=>{let q=H.trim();return M(q,r,!0)})}}catch{v=[I]}a=a.substring(j).trim()}}try{i=f(i,r,...v)}catch(S){let j=S instanceof Error?S.message:String(S);throw Error(`Error applying filter '${u}': ${j}`)}if(a.startsWith("|"))a=a.substring(1).trim();else break}return i}function Hc(e){let n=!1,r="",i=0,a=0,l=0,u=!1;for(let f=0;f<e.length;f++){let v=e[f],S=e[f+1];if(n&&u){u=!1;continue}if(n&&v==="\\"){u=!0;continue}if(u=!1,(v==='"'||v==="'"||v==="`")&&!u){if(!n)n=!0,r=v;else if(v===r)n=!1,r="";continue}if(n&&r==="`"&&v==="$"&&S==="{"){let j=1;f+=2;while(f<e.length&&j>0){if(e[f]==="{")j++;else if(e[f]==="}")j--;if(j>0)f++}continue}if(n)continue;if(v==="(")i++;else if(v===")")i--;else if(v==="[")a++;else if(v==="]")a--;else if(v==="{")l++;else if(v==="}")l--;if(v==="|"&&i===0&&a===0&&l===0){if(S==="|"){f++;continue}if(S==="="){f++;continue}return f}}return-1}var En=new Set,Kc=1000;function zy(){En.clear()}function Js(e,n,r,i){if(!re())return;let a=`${r}\x00${e.expression}`;if(En.has(a))return;if(En.size>=Kc)En.clear();En.add(a);let l=r,u=i;try{if(r&&wi.existsSync(r))u=wi.readFileSync(r,"utf8")}catch{}let f=u.indexOf(n);if(f>=0)l=`${r}:${u.slice(0,f).split(`
218
+ `).length}`;console.warn(`${l}: stx warning: ${n} rendered as an empty string. The safe evaluator rejected \`${e.expression}\` (${e.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function M(e,n,r=!1,i){try{let a=e.trim(),l=Hc(a);if(l>0){let f=a.substring(0,l).trim(),v=a.substring(l+1).trim(),S=M(f,n,!0,i);return om(S,v,n)}let u=ho(a);if(u!==null){i?.({expression:a,rule:u});return}try{let f=Object.keys(n),v=Object.values(n);return p(a,f)(...v)}catch{return d(a,n)}}catch(a){if(a instanceof ReferenceError){let l=/(\b\w+)\s+is not defined/.exec(a.message);if(l){let u=l[1],f=Zc(u,Object.keys(n));if(f&&f!==u)a.message=`${a.message} \u2014 did you mean '${f}'?`}}if(!r)console.error(`Error evaluating expression: ${e}`,a);throw a}}function Zc(e,n){let r=null;for(let a of n){if(a===e)continue;let l=Jc(e,a);if(r===null||l<r.dist)r={key:a,dist:l}}if(!r)return null;let i=Math.max(e.length,r.key.length);if(r.dist<=2||r.dist/i<=0.35)return r.key;return null}function Jc(e,n){if(e===n)return 0;if(e.length===0)return n.length;if(n.length===0)return e.length;let[r,i]=e.length<n.length?[e,n]:[n,e],a=Array(r.length+1),l=Array(r.length+1);for(let u=0;u<=r.length;u++)a[u]=u;for(let u=1;u<=i.length;u++){l[0]=u;for(let f=1;f<=r.length;f++){let v=r[f-1]===i[u-1]?0:1;l[f]=Math.min(l[f-1]+1,a[f]+1,a[f-1]+v)}for(let f=0;f<=r.length;f++)a[f]=l[f]}return a[r.length]}function Hy(e){if(!e)return"";return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}import qc from"process";function A(e="STX_PUBLIC_"){let n={},r={};for(let[i,a]of Object.entries(qc.env)){if(!i.startsWith(e)||a===void 0)continue;n[`import.meta.env.${i}`]=JSON.stringify(a),r[i]=a}return n["import.meta.env"]=JSON.stringify(r),n}function Oi(e,n=""){let r=`${e}${n}`,i=0;for(let a=0;a<r.length;a++){let l=r.charCodeAt(a);i=(i<<5)-i+l,i=i&i}return`stx-${Math.abs(i).toString(36)}`}function Pi(e,n,r={}){let{prefix:i="",preserveHost:a=!0,scopeKeyframes:l=!0,scopeCustomProperties:u=!1}=r;if(!e.trim())return"";let f=qs(e),v=[],S=new Map;if(l)for(let j of f){let I=j.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(I){let V=I[1],O=`${n}_${V}`;S.set(V,O)}}for(let j of f){let I=Zi(j,n,i,a,S,u);v.push(I)}return v.join(`
219
+
220
+ `)}function qs(e){let n=[],r=e.replace(/\/\*[\s\S]*?\*\//g,""),i=0,a="",l=!1,u="";for(let f=0;f<r.length;f++){let v=r[f];if(v==="@"&&i===0)l=!0;if(v==="{")i++;else if(v==="}"){if(i--,i===0){if(l){u+=v;let S=u.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(S){let[,j,I,V]=S;if(j==="keyframes")n.push({selector:`@keyframes ${I.trim()}`,declarations:V.trim()});else if(j==="media"||j==="supports"||j==="container"){let O=qs(V);n.push({selector:`@${j} ${I.trim()}`,declarations:O.map((W)=>`${W.selector} { ${W.declarations} }`).join(`
221
+ `)})}else n.push({selector:`@${j} ${I.trim()}`,declarations:V.trim()})}u="",l=!1}else if(a.trim()){a+=v;let S=a.match(/([^{]+)\{([^}]*)\}/);if(S)n.push({selector:S[1].trim(),declarations:S[2].trim()});a=""}continue}}if(l)u+=v;else a+=v}return n}function Zi(e,n,r,i,a,l){let{selector:u,declarations:f}=e;if(u.startsWith("@")){if(u.startsWith("@keyframes")){let j=u.replace("@keyframes ","").trim();return`@keyframes ${a.get(j)||j} { ${f} }`}if(u.startsWith("@media")||u.startsWith("@supports")||u.startsWith("@container")){let I=qs(`x { ${f} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((V)=>Zi(V,n,r,i,a,l)).join(`
222
+ `);return`${u} {
223
+ ${I}
224
+ }`}return`${u} { ${f} }`}let v=Xc(u,n,r,i),S=f;for(let[j,I]of a)S=S.replace(new RegExp(`\\b${j}\\b`,"g"),I);if(l)S=S.replace(/--([a-z-]+)/gi,`--${n}-$1`);return`${v} { ${S} }`}function Xc(e,n,r,i){let a=e.split(",").map((u)=>u.trim()),l=[];for(let u of a){if(u.startsWith(":host")){if(i)l.push(u);else{let S=u.replace(/:host(\([^)]*\))?/,`.${n}$1`);l.push(S)}continue}if(u.includes("::slotted")){l.push(u);continue}if(u===":root"){l.push(`:root .${n}`);continue}let f=r?`${r} .${n}`:`.${n}`;l.push(`${f} ${u}`);let v=Gc(u,n);if(v)l.push(r?`${r} ${v}`:v)}return l.join(", ")}function Gc(e,n){let r=0,i=e.length;for(let v=0;v<e.length;v++){let S=e[v];if(S==="["||S==="(")r++;else if(S==="]"||S===")")r--;else if(r===0&&(S===" "||S===">"||S==="+"||S==="~")){i=v;break}}let a=e.slice(0,i),l=e.slice(i);if(!a)return"";let u=a.length,f=0;for(let v=0;v<a.length;v++){let S=a[v];if(S==="["||S==="(")f++;else if(S==="]"||S===")")f--;else if(r===0&&f===0&&S===":"){u=v;break}}return`${a.slice(0,u)}.${n}${a.slice(u)}${l}`}var _o=String.raw`(?<![\w-])scoped(?![\w-])`,Xs=/<style\s+([^>]*)>/gi,bo=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,wo=new RegExp(_o,"i"),Yc=new RegExp(_o,"gi"),Gs=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function Qc(e){Xs.lastIndex=0;let n=Xs.exec(e);while(n!==null){if(wo.test(n[1]))return!0;n=Xs.exec(e)}return!1}function Ui(e){let n=new Set,r=[];Gs.lastIndex=0;let i=Gs.exec(e);while(i!==null){let a=i[0].trim();if(n.has(a))r.push({start:i.index,end:i.index+i[0].length});else n.add(a);i=Gs.exec(e)}return r}function Pn(e){let n=Ui(e);if(n.length===0)return e;let r=Array(n.length+1),i=0;for(let a=0;a<n.length;a++){let l=n[a];r[a]=e.slice(i,l.start),i=l.end}return r[n.length]=e.slice(i),r.join("")}function co(e,n){if(!Qc(e))return{html:e,hasScoped:!1};let r=Oi(n),i=`data-v-${r}`,a=e,l=!1;if(bo.lastIndex=0,a=a.replace(bo,(u,f,v)=>{if(!wo.test(f))return u;l=!0;let S=el(v,i),j=f.replace(Yc,"").trim(),I=j?` ${j}`:"";return`<style data-stx-scoped="${r}"${I}>${S}</style>`}),!l)return{html:e,hasScoped:!1};return a=nl(a,i),{html:a,hasScoped:!0}}function el(e,n){return Pi(e,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${n}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${n}]`)}var tl=(e)=>`\x00stx-scope-mask-${e}\x00`,yo=/\u0000stx-scope-mask-(\d+)\u0000/g;function nl(e,n){let r=we(e,(a,l)=>{let u=U(a,l);return u>l?u:tn(a,l)},(a,l)=>tl(l)),i=sl(r.output,n);return yo.lastIndex=0,i.replace(yo,(a,l)=>r.tokens[Number(l)])}function sl(e,n){let r=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return e.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(i,a,l)=>{if(r.has(a.toLowerCase()))return i;if(i.includes(n))return i;if(a.toLowerCase()==="style"||a.toLowerCase()==="script")return i;if(l)return i.replace(`<${a}${l}`,`<${a} ${n}${l}`);if(i.endsWith("/>"))return`<${a} ${n} />`;return`<${a} ${n}>`})}var Cn=/<\/?template\b[^>]*>/gi,rl=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function il(e){let n=e.replace(/^<template\b/i,"").replace(/>$/,"");return rl.test(n)}function B(e){Cn.lastIndex=0;let n;while((n=Cn.exec(e))!==null){if(n[0].startsWith("</")||il(n[0]))continue;let r=n.index,i=Cn.lastIndex,a=1,l;while((l=Cn.exec(e))!==null)if(l[0].startsWith("</")){if(a--,a===0){let u=l.index;return{start:r,openEnd:i,closeStart:u,end:Cn.lastIndex,content:e.slice(i,u)}}}else a++;return null}return null}var ol=0,al=0;function xs(e,n){let r=/(?:^|\s)([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;for(let i of e.matchAll(r))if(i[1].toLowerCase()===n.toLowerCase())return i[2]??i[3]??i[4]??null;return null}function $o(e){let n=[],r=/<([a-z][a-z0-9-]*)\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/iy;return g(e,(i,a)=>{r.lastIndex=a;let l=r.exec(i);if(!l||!xs(l[2],"x-data"))return-1;return n.push({fullMatch:l[0],tagName:l[1],attributes:l[2],startIndex:a,endIndex:r.lastIndex}),r.lastIndex}),n}function cl(e){let n=[];for(let{fullMatch:r,tagName:i,attributes:a,startIndex:l}of $o(e)){let u=xs(a,"x-data");if(!u)continue;let f=`__stx_scope_${ol++}`,v=xs(a,"x-init"),S=Ml(e,i,l+r.length),j=e.slice(l,S.endIndex),I=Dl(j);n.push({id:f,selector:`[data-stx-scope="${f}"]`,stateExpr:u,initExpr:v,bindings:[],refs:I})}return n}function Ml(e,n,r){let i=1,a=r,l=new RegExp(`<${n}(?:\\s|>)`,"gi"),u=new RegExp(`</${n}>`,"gi"),f=new RegExp(`<${n}[^>]*/\\s*>`,"gi");while(i>0&&a<e.length){l.lastIndex=a,u.lastIndex=a,f.lastIndex=a;let v=l.exec(e),S=u.exec(e),j=f.exec(e);if(j&&j.index<(v?.index??1/0)){a=j.index+j[0].length;continue}if(!S)return{endIndex:e.length};if(v&&v.index<S.index)i++,a=v.index+v[0].length;else{if(i--,i===0)return{endIndex:S.index+S[0].length};a=S.index+S[0].length}}return{endIndex:e.length}}function Dl(e){let n=new Map,r=e.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),i=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,a;while((a=i.exec(r))!==null){let[,l,u]=a,f=Ll(l);n.set(u,f)}return n}function Ll(e){let n=e.match(/\bid\s*=\s*["']([^"']*)["']/);if(n)return n[1];return`__stx_el_${al++}`}function zl(){return`
225
+ // STX Reactive Runtime - x-cloak and transition CSS
226
+ (function() {
227
+ var style = document.createElement('style');
228
+ style.textContent = [
229
+ '[x-cloak] { display: none !important; }',
230
+ // Default transition classes
231
+ '.stx-enter { opacity: 0; transform: scale(0.95); }',
232
+ '.stx-enter-start { opacity: 0; transform: scale(0.95); }',
233
+ '.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
234
+ '.stx-enter-to { opacity: 1; transform: scale(1); }',
235
+ '.stx-leave { opacity: 1; transform: scale(1); }',
236
+ '.stx-leave-start { opacity: 1; transform: scale(1); }',
237
+ '.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
238
+ '.stx-leave-to { opacity: 0; transform: scale(0.95); }'
239
+ ].join('\\n');
240
+ document.head.appendChild(style);
241
+ })();
242
+
243
+ // STX Reactive Runtime
244
+ /* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
245
+ window.__stx_reactive = (function() {
246
+ 'use strict';
247
+
248
+ // Deep reactive proxy that triggers onChange for any mutation
249
+ function reactive(obj, onChange) {
250
+ if (!obj || typeof obj !== 'object') return obj;
251
+ return new Proxy(obj, {
252
+ get(target, prop) {
253
+ const value = target[prop];
254
+ if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
255
+ return reactive(value, onChange);
256
+ }
257
+ return value;
258
+ },
259
+ set(target, prop, value) {
260
+ target[prop] = value;
261
+ onChange(prop, value);
262
+ return true;
263
+ }
264
+ });
265
+ }
266
+
267
+ // Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
268
+ // then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
269
+ function initScope(scopeEl, initialState, bindings, refs, initExpr, deferInit) {
270
+ // Parse initial state (may contain methods including async init())
271
+ var state;
272
+ try {
273
+ state = new Function('return (' + initialState + ')')();
274
+ } catch (e) {
275
+ console.error('[stx-reactive] Invalid x-data:', initialState, e);
276
+ return;
277
+ }
278
+
279
+ // Build $refs object
280
+ var $refs = {};
281
+ for (var name in refs) {
282
+ if (Object.prototype.hasOwnProperty.call(refs, name)) {
283
+ (function(refName, refId) {
284
+ Object.defineProperty($refs, refName, {
285
+ get: function() { return document.getElementById(refId); }
286
+ });
287
+ })(name, refs[name]);
288
+ }
289
+ }
290
+
291
+ // Extract init method from state if present (Alpine.js convention)
292
+ var initMethod = state.init;
293
+ if (typeof initMethod === 'function') {
294
+ delete state.init;
295
+ }
296
+
297
+ // Make state reactive \u2014 mutations trigger re-render via signals
298
+ var scopeId = scopeEl.getAttribute('data-stx-scope');
299
+ var stx = window.stx;
300
+
301
+ // Create signals for each state property so the signals runtime can track dependencies
302
+ var signalState = {};
303
+ var rawState = {};
304
+ var derivedState = {};
305
+ var accessors = {};
306
+ // A getter must NOT be read here. Reading one calls it, and the old loop did
307
+ // exactly that: the returned value is not a function, so it was wrapped as a
308
+ // plain state() -- a snapshot of the answer at construction time, frozen
309
+ // forever while plain properties beside it updated (#2053). A getter is a
310
+ // derived value, so it is registered as one below, once ctxProxy exists for
311
+ // it to read through.
312
+ var ownDescriptors = Object.getOwnPropertyDescriptors ? Object.getOwnPropertyDescriptors(state) : {};
313
+ for (var key in state) {
314
+ if (Object.prototype.hasOwnProperty.call(state, key)) {
315
+ var descriptor = ownDescriptors[key];
316
+ if (descriptor && typeof descriptor.get === 'function') {
317
+ accessors[key] = descriptor;
318
+ continue;
319
+ }
320
+ if (typeof state[key] === 'function') {
321
+ // Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
322
+ signalState[key] = state[key];
323
+ } else {
324
+ // Data properties \u2014 wrap in signals for reactivity
325
+ signalState[key] = stx.state(state[key]);
326
+ rawState[key] = true;
327
+ }
328
+ }
329
+ }
330
+
331
+ // Create a proxy context that auto-unwraps signals and writes back through them.
332
+ // Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
333
+ var ctx = {};
334
+ var ctxProxy = new Proxy(ctx, {
335
+ get: function(target, prop) {
336
+ if (prop === '$refs') return $refs;
337
+ if (prop === '$el') return scopeEl;
338
+ if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
339
+ if (prop === Symbol.unscopables) return undefined;
340
+ if (!(prop in signalState)) {
341
+ var owner = stx._scopeForBinding(scopeEl, prop);
342
+ return owner ? owner[prop] : undefined;
343
+ }
344
+ var s = signalState[prop];
345
+ if (!s) return undefined;
346
+ if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
347
+ return s.value; // unwrap signal
348
+ }
349
+ if (typeof s === 'function' && !rawState[prop]) {
350
+ return s.bind(ctxProxy); // bind methods to proxy
351
+ }
352
+ return s;
353
+ },
354
+ set: function(target, prop, value) {
355
+ var accessor = derivedState[prop];
356
+ if (accessor) {
357
+ // A getter/setter pair writes through its setter. A getter alone has
358
+ // nowhere to put the value: a derived has no .value setter, so the
359
+ // assignment would be a silent no-op, which is the same class of
360
+ // failure as the stale read this replaces.
361
+ if (typeof accessor.set === 'function') {
362
+ accessor.set.call(ctxProxy, value);
363
+ return true;
364
+ }
365
+ console.warn('[stx-reactive] cannot assign to ' + String(prop) + ': it is a getter in x-data, so its value comes from what it reads. Give it a setter, or make it a plain property.');
366
+ return true;
367
+ }
368
+ var s = signalState[prop];
369
+ if (rawState[prop] && s && typeof s === 'function') {
370
+ s.value = value; // write through signal \u2014 triggers effects
371
+ } else {
372
+ signalState[prop] = value;
373
+ }
374
+ return true;
375
+ },
376
+ has: function(target, prop) {
377
+ return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick' || !!stx._scopeForBinding(scopeEl, prop);
378
+ },
379
+ ownKeys: function() {
380
+ return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
381
+ },
382
+ getOwnPropertyDescriptor: function(target, prop) {
383
+ if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
384
+ return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
385
+ }
386
+ return undefined;
387
+ }
388
+ });
389
+
390
+ // Now that ctxProxy exists, a getter becomes a derived that reads through it,
391
+ // so it tracks whatever it touches and recomputes when that changes. derived()
392
+ // is lazy, so nothing is evaluated until a binding actually reads it.
393
+ //
394
+ // Marked rawState as well: that is what makes the proxy unwrap it and what
395
+ // exposes the signal itself to the runtime below, which is where dependency
396
+ // tracking comes from. A getter needs both, exactly like a data property.
397
+ for (var accessorKey in accessors) {
398
+ if (Object.prototype.hasOwnProperty.call(accessors, accessorKey)) {
399
+ (function(name, descriptor) {
400
+ signalState[name] = stx.derived(function() {
401
+ return descriptor.get.call(ctxProxy);
402
+ });
403
+ rawState[name] = true;
404
+ derivedState[name] = descriptor;
405
+ })(accessorKey, accessors[accessorKey]);
406
+ }
407
+ }
408
+
409
+ // Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
410
+ // We need to provide getter/setter descriptors so signals track properly.
411
+ var scopeVars = {};
412
+ for (var k in signalState) {
413
+ if (Object.prototype.hasOwnProperty.call(signalState, k)) {
414
+ if (rawState[k]) {
415
+ // Data: expose the signal directly so expressions trigger dependency tracking
416
+ scopeVars[k] = signalState[k];
417
+ } else {
418
+ // Method: bind to ctxProxy so 'this' works
419
+ scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
420
+ }
421
+ }
422
+ }
423
+ scopeVars.$refs = $refs;
424
+ scopeVars.$el = scopeEl;
425
+ scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
426
+
427
+ // Register scope \u2014 merge with any existing vars from partial signal scripts
428
+ if (!stx._scopes) stx._scopes = {};
429
+ var registered = stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
430
+ registered.__el = scopeEl;
431
+
432
+ // Store on element for findElementScope
433
+ scopeEl.__stx_scope = scopeVars;
434
+
435
+ // Run init() if present (supports async)
436
+ function runInit() {
437
+ var maybePromise;
438
+ if (initMethod) {
439
+ maybePromise = initMethod.call(ctxProxy);
440
+ }
441
+ if (initExpr) {
442
+ try {
443
+ var fn = new Function('with(this){' + initExpr + ';}');
444
+ var result = fn.call(ctxProxy);
445
+ if (result && typeof result.then === 'function') maybePromise = result;
446
+ } catch (e) {
447
+ console.warn('[stx-reactive] init expression error:', e);
448
+ }
449
+ }
450
+ // If init is async, signal updates will trigger effects automatically
451
+ // when init() resolves and sets this.prop = value (writes through signal)
452
+ if (maybePromise && typeof maybePromise.then === 'function') {
453
+ maybePromise.catch(function(e) {
454
+ console.error('[stx-reactive] async init() error:', e);
455
+ });
456
+ }
457
+ }
458
+
459
+ // A component's helper setup follows its markup. Its own mount queue
460
+ // starts the initializer after all component factories have registered.
461
+ // Standalone x-data retains synchronous initialization.
462
+ if (deferInit) {
463
+ registered.__mountCallbacks = registered.__mountCallbacks || [];
464
+ registered.__mountCallbacks.push(runInit);
465
+ } else {
466
+ runInit();
467
+ }
468
+ var destroyExpr = scopeEl.getAttribute('data-stx-xdestroy') || scopeEl.getAttribute('x-destroy');
469
+ if (destroyExpr) {
470
+ registered.__destroyCallbacks = registered.__destroyCallbacks || [];
471
+ var teardown = function() { scopeEl.__stx_execute(destroyExpr); };
472
+ registered.__destroyCallbacks.push(teardown);
473
+ registered.__destroyHooks = registered.__destroyHooks || [];
474
+ registered.__destroyHooks.push(teardown);
475
+ }
476
+
477
+ // Expose for debugging
478
+ scopeEl.__stx_state = ctxProxy;
479
+ scopeEl.__stx_execute = function(stmt, $event, $el) {
480
+ try {
481
+ // Run the statement with the reactive proxy as the lexical scope.
482
+ // Wrapping in a with-block on the proxy makes bare reads/writes go
483
+ // through it (so foo = bar triggers signal.set()) instead of treating
484
+ // each state key as a local function parameter \u2014 bare assignments
485
+ // would otherwise just rebind the local and never reach the signal.
486
+ var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
487
+ fn.call(ctxProxy, $event, $el);
488
+ } catch (e) {
489
+ console.warn('[stx-reactive] execute error:', e);
490
+ }
491
+ };
492
+ }
493
+
494
+ return { initScope: initScope, reactive: reactive };
495
+ })();
496
+ `}function vo(e,n){let r=e.replace(/\{!!([\s\S]*?)!!\}/g,(f,v)=>{try{let S=M(v,n,!0);if(S===void 0)return f;return String(S)}catch{return f}}),i="",a=0,l=null;while(a<r.length){let f=r[a];if(l&&f==="\\"){i+=f+(r[a+1]??""),a+=2;continue}if(f==="{"&&r[a+1]==="{"){let v=r.indexOf("}}",a+2);if(v!==-1){let S=r.slice(a,v+2);i+=u(r.slice(a+2,v),S,l),a=v+2;continue}}if(l){if(f===l)l=null}else if(f==="'"||f==='"'||f==="`")l=f;i+=f,a++}return i;function u(f,v,S){let j;try{j=M(f,n,!0)}catch{return v}if(j===void 0)return v;if(S){let I=String(j).replace(/\\/g,"\\\\").replace(new RegExp(S==="`"?"`":S,"g"),`\\${S}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return S==="`"?I.replace(/\$\{/g,"\\${"):I}if(typeof j==="string"){let I=j.trim();if(I.startsWith("{")&&I.endsWith("}")||I.startsWith("[")&&I.endsWith("]"))try{return JSON.parse(I),I}catch{}}return JSON.stringify(j)}}function Bl(e,n,r){if(e.length===0)return"";let i=e.map((a)=>{let l=JSON.stringify(Object.fromEntries(a.refs)),u=vo(a.stateExpr,n),f=a.initExpr?vo(a.initExpr,n):null,v=JSON.stringify(u),S=f?JSON.stringify(f):"null";return`
497
+ (function() {
498
+ var scopeEl = document.querySelector('${a.selector}');
499
+ if (!scopeEl) return;
500
+ var refs = ${l};
501
+ window.__stx_reactive.initScope(scopeEl, ${v}, [], refs, ${S}${r?", true":""});
502
+ })();`}).join(`
503
+ `);return`
504
+ <script data-stx-scoped data-stx-reactive data-stx-run="always">
505
+ ${zl()}
506
+ ${i}
507
+ </script>`}function wl(e,n,r,i=!1){if(!er(e))return e;let a=cl(e);if(a.length===0)return e;let l=Fl(e,a),u=Bl(a,n,i),f=c(l);if(f!==-1)l=l.slice(0,f)+u+`
508
+ `+l.slice(f);else l+=u;return l}function Fl(e,n){let r=[],i=0;for(let[l,u]of $o(e).entries()){let f=n[l];if(!f)break;r.push(e.slice(i,u.startIndex));let v=xs(u.attributes,"data-stx-scope");if(v)f.id=v,f.selector=`[data-stx-scope="${f.id}"]`,r.push(u.fullMatch);else r.push(`<${u.tagName} data-stx-scope="${f.id}"${u.attributes}>`);i=u.endIndex}r.push(e.slice(i));let a=r.join("");return a=a.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),a=a.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),a=a.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),a=a.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),a=a.replace(/\s*x-destroy\s*=\s*"([^"]*)"/g,' data-stx-xdestroy="$1"'),a=a.replace(/\s*x-destroy\s*=\s*'([^']*)'/g," data-stx-xdestroy='$1'"),a}function er(e){return/x-data\s*=\s*["']/.test(e)}function uo(e,n){let r=e,i=/@json\s*\(/g,a;while((a=i.exec(r))!==null){let l=a.index,u=l+a[0].length-1,f=1,v=u+1,S=null,j=!1;while(v<r.length&&f>0){let H=r[v];if(j){j=!1,v++;continue}if(H==="\\"&&S){j=!0,v++;continue}if(S){if(H===S)S=null;v++;continue}if(H==='"'||H==="'"||H==="`"){S=H,v++;continue}if(H==="(")f++;else if(H===")"){if(f--,f===0)break}v++}if(f!==0)break;let I=r.substring(u+1,v).trim(),V=r.substring(l,v+1),O=-1,W=0,D=null,G=!1;for(let H=0;H<I.length;H++){let q=I[H];if(G){G=!1;continue}if(q==="\\"&&D){G=!0;continue}if(D){if(q===D)D=null;continue}if(q==='"'||q==="'"||q==="`"){D=q;continue}if(q==="("||q==="["||q==="{")W++;else if(q===")"||q==="]"||q==="}")W--;if(q===","&&W===0){O=H;break}}let X=O>=0?I.substring(0,O).trim():I,ee=O>=0?I.substring(O+1).trim():void 0;try{let H=X.trim(),q;if(h(H))q=p(H,Object.keys(n))(...Object.values(n));else q=void 0;let se;if(ee==="true")se=JSON.stringify(q,null,2);else se=JSON.stringify(q);let ce=se.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");r=r.substring(0,l)+ce+r.substring(v+1),i.lastIndex=l+ce.length}catch(H){K.log(H instanceof Error?H:Error(String(H)),{directive:"@json"},"error"),i.lastIndex=l+V.length}}return r}function po(e){return e.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function vl(e){let n=e,r=/@memo\s*\(/g,i,a=[];while((i=r.exec(n))!==null){let l=i.index,u=l+i[0].length,f=1,v=u;while(v<n.length&&f>0){if(n[v]==="(")f++;else if(n[v]===")")f--;v++}if(f!==0)continue;let S=n.slice(u,v-1).trim(),j=v,I=n.slice(j),V=I.indexOf("@endmemo");if(V===-1)continue;let O=I.slice(0,V),W=j+V+8,D=vt(O),G=O.slice(D),X=O.match(/(\s*)$/),ee=X?X[0].length:0,H=G.slice(0,G.length-ee),q=H.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),se;if(q){let[ce,le,pe="",Re]=q,Ae=`<${le}${pe} data-stx-memo="${S}"${Re}>`;se=O.slice(0,D)+Ae+H.slice(ce.length)+O.slice(D+H.length)}else se=`${O.slice(0,D)}<div data-stx-memo="${S}">${H}</div>${O.slice(D+H.length)}`;a.push({start:l,end:W,replacement:se}),r.lastIndex=W}for(let l=a.length-1;l>=0;l--){let u=a[l];n=n.slice(0,u.start)+u.replacement+n.slice(u.end)}return n.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function Vi(e){let n=e.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return n=n.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),n}function Ao(e,n){let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=g(e,(f,v)=>{r.lastIndex=v;let S=r.exec(f);if(!S||/^(?:script|style)$/i.test(S[1]))return-1;return r.lastIndex}),a=[],l=0,u=[];for(let{start:f,end:v,token:S}of i){let j=/^<\/?([\w-]+)/.exec(S)[1].toLowerCase();if(S.startsWith("</")){while(a.length&&a.pop()!==j);continue}if(!a.length&&!/\sdata-stx-slot-owner\s*=/.test(S))u.push(e.slice(l,f),S.replace(/\s*\/?>$/,(I)=>` data-stx-slot-owner="${n}"${I}`)),l=v;if(!tr.has(j)&&!/\/>$/.test(S))a.push(j)}return u.push(e.slice(l)),u.join("")}function To(e,n){if(!/\bref\s*=/.test(e))return e;let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=g(e,(v,S)=>{r.lastIndex=S;let j=r.exec(v);if(!j||/^(?:script|style)$/i.test(j[1]))return-1;return r.lastIndex}),a=[],l=0,u=0,f=[];for(let{start:v,end:S,token:j}of i){let I=/^<\/?([\w-]+)/.exec(j)[1].toLowerCase();if(j.startsWith("</")){let D;while(D=a.pop()){if(D.scoped)l--;if(D.name===I)break}continue}let V=/\sdata-stx-scope\s*=/.test(j),O=/\sdata-stx-ref-caller\s*=\s*(["'])(.*?)\1/.exec(j),W=a.find((D)=>D.scoped)?.scopeId;if(O&&W&&O[2]===W)f.push(e.slice(u,v),j.replace(O[0],` data-stx-ref-caller="${n}"`)),u=S;else if(!l&&!V&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(j)&&!/\sdata-stx-ref-caller\s*=/.test(j))f.push(e.slice(u,v),j.replace(/\s*\/?>$/,(D)=>` data-stx-ref-caller="${n}"${D}`)),u=S;if(!tr.has(I)&&!/\/>$/.test(j)){let D=/\sdata-stx-scope\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(j);if(a.push({name:I,scoped:V,scopeId:D?.[1]??D?.[2]}),V)l++}}return f.push(e.slice(u)),f.join("")}var tr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),jo=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,Eo=/<\/?\s*([a-z][\w-]*)/iy,Vl=/\s/;function Ul(e,n){let r=n-1;while(r>=0&&Vl.test(e[r]))r--;return r>=0&&e[r]==="/"}function Hl(e,n){let r=!1,i=!1;for(let a=n;a<e.length;a++){let l=e[a];if(r){if(l==="'")r=!1}else if(i){if(l==='"')i=!1}else if(l==="'")r=!0;else if(l==='"')i=!0;else if(l===">")return a}return-1}function Kl(e,n){if(e.indexOf("{",n)===-1||e.indexOf("}",n)===-1)return!1;let r=0,i=n,a=!1,l=!1,u=!1;while(i<e.length){let f=e.indexOf("<",i),v=f===-1?e.length:f;if(v>i){if(r===0)while(i<v){let I=e.indexOf(l?"}":"{",i);if(I===-1||I>=v){if(l)u=!1;else a=!1;break}if(I>i)if(l)u=!1;else a=!1;if(l){if(u)return!0;u=!0}else if(a)l=!0,u=!1;else a=!0;i=I+1}i=v;continue}if(e.startsWith("<!--",i)){let I=e.indexOf("-->",i);i=I===-1?e.length:I+3;continue}let S=Hl(e,i);if(S===-1)break;Eo.lastIndex=i;let j=Eo.exec(e)?.[1]?.toLowerCase()??"";if(e[i+1]==="/"){if(r===0)break;r--}else if(!Ul(e,S)&&!tr.has(j))r++;i=S+1}return!1}var Co=k(256);function xl(e){if(e.length<1024)return Ro(e);let n=E(e),r=Co.get(n);if(r!==void 0)return r;let i=Ro(e);return Co.set(n,i),i}function Ro(e){if(e.length>=32768&&!jl(e))return e;let r=new RegExp(`<(${"div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i"})\\b`,"gi"),i="",a=0,l;while((l=r.exec(e))!==null){let u=l.index,f=u+l[0].length,v=!1,S=!1,j=-1;while(f<e.length){let V=e[f];if(v){if(V==="'")v=!1}else if(S){if(V==='"')S=!1}else if(V==="'")v=!0;else if(V==='"')S=!0;else if(V===">"){j=f;break}f++}if(j===-1)continue;let I=e.slice(u,j+1);if(jo.test(I))continue;if(I.includes("x-cloak"))continue;if(Kl(e,j+1))i+=e.slice(a,j)+" x-cloak>",a=j+1}return i+=e.slice(a),i}var Zl=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,Jl=/<\/script>/gi,ql=/<\/style>/gi;function Sl(e){let n=/<[a-z][\w-]*/gi,r="",i=0,a;while((a=n.exec(e))!==null){let l=a.index,u=a[0].slice(1).toLowerCase();if(u==="script"||u==="style"){let W=u==="script"?Jl:ql;W.lastIndex=l;let D=W.exec(e);if(D!==null)n.lastIndex=D.index+D[0].length;continue}let f=l+a[0].length,v=!1,S=!1,j=-1;while(f<e.length){let W=e[f];if(v){if(W==="'")v=!1}else if(S){if(W==='"')S=!1}else if(W==="'")v=!0;else if(W==='"')S=!0;else if(W===">"){j=f;break}f++}if(j===-1)continue;let I=e.slice(l+a[0].length,j);if(jo.test(I))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(I))continue;if(!Zl.test(I))continue;let V=e[j-1]==="/",O=V?j-1:j;r+=`${e.slice(i,O)} x-cloak${V?" ":""}`,i=O}return r+=e.slice(i),r}function N(e){let n=new Map;for(let r of e.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))n.set(r[1].toLowerCase(),r[2]??r[3]??r[4]??!0);return n}function Et(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}import sa from"path";import nr from"fs";import Tn from"path";function Io(e,n,r,i){let a=0;for(let l=n;l<e.length;l++)if(e[l]===r)a++;else if(e[l]===i&&!(i===">"&&e[l-1]==="=")){if(--a===0)return l}return-1}function Yl(e){let n=t(e),r=0,i=0,a=[];for(let l=0;l<n.length;l++)if("([{".includes(n[l]))r++;else if(")]}".includes(n[l]))r--;else if(n[l]===","&&r===0)a.push(e.slice(i,l).trim()),i=l+1;return a.push(e.slice(i).trim()),a}function Rn(e,n,r=!1){let i=t(e),a=new RegExp(`\\b(?:${n.map((u)=>u.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),l=r?y(i).depths:void 0;for(let u of i.matchAll(a)){if(l&&l[u.index]!==0)continue;let f=u.index+u[0].length,v="";if(i[f]==="<"){let j=Io(i,f,"<",">");if(j<0)continue;v=e.slice(f+1,j),f=j+1;while(/\s/.test(i[f]||"")&&f<i.length)f++}if(i[f]!=="(")continue;let S=Io(i,f,"(",")");if(S>=0)return{type:v,args:Yl(e.slice(f+1,S)),start:u.index,end:S+1}}return null}var bs=`
509
+ type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
510
+ type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
511
+ type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
512
+ type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K : never }[keyof O];
513
+ type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
514
+ type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
515
+ type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
516
+ `;function ys(e,n){let r=[],i={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},a=t(e),l=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(V,O,W,D,G)=>{if(a.slice(G,G+6)!=="import")return V;if(D.endsWith(".stx"))return"";let X=`${n}Import${r.length}`;if(r.push(`import * as ${X} from ${JSON.stringify(D)};`),O.startsWith("*"))return`import ${O.replace(/^\*\s+as\s+/,"")} = ${X};`;if(!O.startsWith("{"))return`import ${O} = ${X}.default;`;return O.slice(1,-1).split(",").map((ee)=>{let[H,q=H]=ee.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!H)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(D)&&H in i)i[H].push(q);return`import ${q} = ${X}.${H};`}).join(`
517
+ `)}),u=Rn(e,i.defineProps),f=Rn(e,i.defineEmits),v=Rn(e,i.withDefaults);if(!u&&!f)return{declarations:"",props:null,events:null};let S=[],j=null,I=null;if(u){S.push(`const __options = (${u.args[0]||"{}"}) as const;`),S.push(`const __defaults = (${v?.args[1]||"{}"});`);let V=u.type||"__StxOptions<typeof __options>";S.push(`export type __StxProps = __StxDefaults<${V}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),j=`${n}.__StxProps`}if(f)S.push(`const __events = (${f.args[0]||"[]"}) as const;`),S.push(`export type __StxEvents = ${f.type||"Record<(typeof __events)[number], any[]>"};`),I=`${n}.__StxEvents`;return{declarations:`${r.join(`
518
+ `)}
519
+ namespace ${n} {
520
+ ${l}
521
+ ${S.join(`
522
+ `)}
523
+ }`,props:j,events:I}}var Hr=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Ur(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Hr].some((n)=>n.toLowerCase()===e.toLowerCase());return Hr.has(e)||/[A-Z]/.test(e)}function*Ql(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let i=n.lastIndex,a=[];while(i<e.length){while(/\s/.test(e[i]||""))i++;if(e[i]===">"||e.slice(i,i+2)==="/>"){i+=e[i]===">"?1:2;break}let l=/^[^\s=/>]+/.exec(e.slice(i))?.[0];if(!l){i++;continue}let u=i;i+=l.length;while(/\s/.test(e[i]||""))i++;if(e[i]!=="="){a.push({name:l,value:!0,offset:u,braced:!1});continue}i++;while(/\s/.test(e[i]||""))i++;let f=e[i],v=f==="{",S=f==='"'||f==="'";if(S||v)i++;let j=i;if(v){let I=t(e.slice(i)),V=1,O=0;for(;O<I.length;O++){if(I[O]==="{")V++;if(I[O]==="}"&&--V===0)break}i+=O}else if(S)while(i<e.length&&e[i]!==f)i++;else while(i<e.length&&!/[\s/>]/.test(e[i]))i++;if(a.push({name:l,value:e.slice(j,i),offset:j,braced:v}),S||v)i++}n.lastIndex=i,yield{name:r[1],offset:r.index,attributes:a}}}function Oo(e,n,r){let i=[],a=[bs,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],l=new Map,u=new Map,f=new Map,v=r.scriptCode(e,r.filePath),S=t(v);for(let W of v.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(S.slice(W.index,W.index+6)!=="import")continue;let D=W[2],G=Tn.isAbsolute(D)||D.startsWith(".")?Tn.resolve(Tn.dirname(r.filePath),D):Qs(D,Tn.dirname(r.filePath));if(!G)continue;let X=G.endsWith(".stx")?G:nr.existsSync(`${G}.stx`)?`${G}.stx`:void 0,ee=X?null:jr(G,!1),H=W[1].startsWith("{")?W[1].slice(1,-1).split(","):[W[1]];for(let q of H){let[se,ce=se]=q.trim().split(/\s+as\s+/),le=X||ee?.get(se)||ee?.get(se.toLowerCase());if(le)f.set(ce,le),f.set(ce.toLowerCase(),le),f.set(ce.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),le)}}for(let W of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let D of W[1].matchAll(/['"]([^'"]+)['"]/g)){let G=eo(D[1],r.filePath,r).find((X)=>nr.statSync(X,{throwIfNoEntry:!1})?.isFile());if(G)f.set(Tn.basename(D[1]).replace(/\.stx$/,""),G)}let j={__importedComponents:f},I=new Map,V=(W,D,G)=>{let X=e.slice(0,W);return{code:D,offset:W,attribute:G,anchor:!0,kind:"directive",line:X.split(`
524
+ `).length,column:W-X.lastIndexOf(`
525
+ `)}},O=(W,D,G)=>i.push({expression:W,statement:{text:D+W.code+G,prefixLength:D.length}});for(let W of Ql(n)){if(Ur(W.name)||W.name==="component")continue;let D=Kr(W.name,r.filePath,r,j);if(!D)continue;let G=I.get(D);if(!G){let ee;try{ee=r.readComponent?r.readComponent(D):nr.readFileSync(D,"utf8")}catch{continue}if(ee===void 0)continue;u.set(D,ee),G=ys(r.scriptCode(ee,D),`__StxComponent${I.size}`),I.set(D,G),a.push(G.declarations)}let X=[];for(let ee of W.attributes){let{name:H,offset:q}=ee,se=ee.value===!0?"true":ee.value;if(H.startsWith("@")||H.startsWith("v-on:")){if(G.events&&ee.value!==!0)l.set(q,`__StxEvent<${G.events}, ${JSON.stringify(H.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let ce=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(H);if(H.startsWith("v-")&&!H.startsWith("v-bind:")&&!ce)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(H))continue;let le=(ce?ce[1]||"modelValue":H.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(ve,fe)=>fe.toUpperCase());if(X.push(le),!G.props)continue;let pe=H.startsWith(":")||H.startsWith("v-bind:")||!!ce||ee.braced,Re=pe?se:ee.value!==!0?JSON.stringify(se):"true",Ae=!pe&&ee.value!==!0&&(se==="true"||se==="false");O(V(q,Re,H),";void ((",`) satisfies ${Ae?"__StxStaticProp":"__StxProp"}<${G.props}, ${JSON.stringify(le)}>);`)}if(G.props){let ee=[...new Set(X)].map((q)=>`${JSON.stringify(q)}: undefined as any`).join(", "),H=V(W.offset,`<${W.name}>`);i.push({expression:H,statement:{text:`;void ({ ${ee} } satisfies ${G.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:I.size?a.join(`
526
+ `):"",checks:i,events:l,dependencies:u}}import Ko from"fs";import xt from"path";var yt=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];function eu(e){let n=new be(e,"javascript").tokenize(),r=e;for(let i of n.reverse())if(i.type==="COMMENT")r=r.slice(0,i.start)+i.value.replace(/[^\r\n]/g," ")+r.slice(i.end);return r}function mt(e,n,r,i){if(e[n]!==r)return-1;let a=0,l=null;for(let u=n;u<e.length;u++){let f=e[u];if(l){if(f==="\\"){u++;continue}if(f===l)l=null;continue}if(f==="'"||f==='"'||f==="`"){l=f;continue}if(f===r)a++;else if(f===i){if(i===">"&&e[u-1]==="=")continue;if(a--,a===0)return u+1}}return-1}function ft(e,n,r){let i=r?"([{<":"([{",a=r?")]}>":")]}",l=[],u=0,f=null,v="";for(let S=0;S<e.length;S++){let j=e[S];if(f){if(v+=j,j==="\\"){v+=e[++S]??"";continue}if(j===f)f=null;continue}if(j==="'"||j==='"'||j==="`"){f=j,v+=j;continue}if(i.includes(j))u++;else if(a.includes(j)&&!(r&&j===">"&&e[S-1]==="="))u--;if(u===0&&n.includes(j)){l.push(v),v="";continue}v+=j}return l.push(v),l.map((S)=>S.trim()).filter(Boolean)}function tu(e){let n=0,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r=null;continue}if(a==="'"||a==='"'||a==="`"){r=a;continue}if("([{".includes(a))n++;else if(")]}".includes(a))n--;if(n!==0||a!=="=")continue;let l=e[i-1];if(e[i+1]==="="||l==="="||l==="!"||l==="<"||l===">")continue;return i}return-1}function Po(e){switch(e.trim()){case"String":return"string";case"Number":return"number";case"Boolean":return"boolean";case"Array":return"unknown[]";case"Object":return"Record<string, unknown>";default:return}}function ln(e){let n=eu(e);for(let r of new Set(qn(n).map((i)=>i.start))){let i=nu(n,r);if(i)return{...i,text:e.slice(r,r+i.text.length)}}return null}function nu(e,n){let r=Object.create(null),i=Object.create(null),a=[],l=Object.create(null),u=Object.create(null),f=n+(/^(?:const|let|var)\s+/.exec(e.slice(n))?.[0].length??0),v=()=>{while(f<e.length&&/\s/.test(e[f]))f++},S;if(e[f]==="{"){let X=mt(e,f,"{","}");if(X===-1)return null;S=e.slice(f,X),f=X}else{let X=/^[A-Za-z_$][\w$]*/.exec(e.slice(f));if(!X)return null;S=X[0],f+=X[0].length}if(v(),e[f]!=="=")return null;f++,v();let j=/^withDefaults\s*\(\s*/.exec(e.slice(f)),I=Boolean(j);if(j)f+=j[0].length;let V=/^defineProps\b/.exec(e.slice(f));if(!V)return null;f+=V[0].length;let O="";if(v(),e[f]==="<"){let X=mt(e,f,"<",">");if(X===-1)return null;O=e.slice(f+1,X-1).trim(),f=X}if(v(),e[f]!=="(")return null;let W=mt(e,f,"(",")");if(W===-1)return null;let D=e.slice(f+1,W-1).trim();if(f=W,I){if(v(),e[f]===",")f++,v();if(e[f]==="{"){let X=mt(e,f,"{","}");if(X===-1)return null;for(let[ee,H]of _s(e.slice(f,X)))i[ee]=H;f=X}if(v(),e[f]===",")f++,v();if(e[f]===")")f++}if(e[f]===";")f++;let G=/^[A-Za-z_$][\w$]*$/.test(O)?O:void 0;if(O.startsWith("{"))for(let X of ft(O.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let ee=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(X);if(ee)r[ee[1]]=ee[2].trim()}if(D.startsWith("{"))for(let[X,ee]of _s(D)){if(a.push(X),!ee.startsWith("{")){let H=Po(ee);if(H)r[X]=H;continue}for(let[H,q]of _s(ee))if(H==="default")i[X]=q;else if(H==="type"){let se=Po(q);if(se)r[X]=se}}else if(D.startsWith("["))for(let X of ft(D.slice(1,-1),",",!1))a.push(X.replace(/^['"`]/,"").replace(/['"`]$/,""));if(S.startsWith("{")){a.length=0;for(let X of ft(S.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let ee=tu(X),H=ee===-1?X:X.slice(0,ee),q=H.split(":")[0].trim().replace(/^\.\.\./,"");if(!q)continue;a.push(q),l[q]=H.trim();let se=H.split(":").at(-1).trim();if(/^[A-Za-z_$][\w$]*$/.test(se))u[q]=se;if(ee!==-1)i[q]=X.slice(ee+1).trim()}}else if(a.length===0)a.push(...Object.keys(r));return{text:e.slice(n,f),propNames:a,propBindings:l,localBindings:u,defaults:i,declared:r,typeName:G,identifier:S.startsWith("{")?void 0:S}}function _s(e){let n=e.trim().replace(/^\{/,"").replace(/\}$/,""),r=[],i=0;while(i<n.length){let a=/\s*([A-Za-z_$][\w$]*)\s*:/y;a.lastIndex=i;let l=a.exec(n);if(!l)break;i=a.lastIndex;let u=0,f="",v=i;while(i<n.length){let j=n[i];if(f){if(j==="\\")i++;else if(j===f)f=""}else if(j==="'"||j==='"'||j==="`")f=j;else if(j==="{"||j==="["||j==="(")u++;else if(j==="}"||j==="]"||j===")")u--;else if(j===","&&u===0)break;i++}let S=n.slice(v,i).trim();if(S)r.push([l[1],S]);i++}return r}function sr(e){let n=/^(?:(?:0|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?$/,r=/^(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[bB][01](?:_?[01])*|0[oO][0-7](?:_?[0-7])*)$/;if(!n.test(e)&&!r.test(e))throw Error("Invalid prop number");return Number(e.replaceAll("_",""))}function ws(e){let n=new be(e,"javascript").tokenize().filter((a)=>!["COMMENT","WHITESPACE","EOF"].includes(a.type)),r=0;function i(a){if(a>64)throw Error("Prop literal too deep");let l=n[r++];if(!l)throw Error("Missing prop literal");if(l.type==="STRING"||l.type==="TEMPLATE_STRING"){let j=bt(l.value);if(j===null)throw Error("Dynamic prop string");return j}if(l.type==="NUMBER")return sr(l.value);if(l.value==="-"||l.value==="+"){let j=n[r++];if(j?.type!=="NUMBER")throw Error("Dynamic prop number");return(l.value==="-"?-1:1)*sr(j.value)}if(l.value==="true")return!0;if(l.value==="false")return!1;if(l.value==="null")return null;if(l.value==="undefined")return;if(l.value!=="["&&l.value!=="{")throw Error("Dynamic prop default");let u=l.value==="[",f=u?"]":"}",v=[],S=[];while(n[r]?.value!==f){if(u)S.push(i(a+1));else{let j=n[r++];if(!j||!["STRING","IDENTIFIER","NUMBER"].includes(j.type))throw Error("Dynamic prop key");let I=j.type==="STRING"?bt(j.value):j.type==="NUMBER"?String(sr(j.value)):j.value;if(I===null||n[r++]?.value!==":")throw Error("Dynamic prop key");v.push([I,i(a+1)])}if(n[r]?.value!==",")break;r++}if(n[r++]?.value!==f)throw Error("Unclosed prop literal");return u?S:Object.fromEntries(v)}try{let a=i(0);return r===n.length?a:void 0}catch{return}}function vs(e,n){let r=t(e),i=y(r).depths,a=/\b(interface|type)\s+([A-Za-z_$][\w$]*)\b/g;for(let l of r.matchAll(a)){if(l[2]!==n||i[l.index]!==0)continue;let u=l.index+l[0].length,f=r.indexOf("{",u);if(l[1]==="interface"&&f>=0){let v=mt(r,f,"{","}");if(v>=0)return e.slice(f,v)}if(l[1]==="type"){let v=r.indexOf("=",u);if(v<0)continue;let S=e.slice(v+1).trimStart();if(S[0]==="{"){let j=mt(S,0,"{","}");if(j>=0)return S.slice(0,j)}}}}function $s(e){let n=e.trim();return/^[A-Za-z_$][\w$]*$/.test(n)?n:bt(n)??void 0}function Mo(e){let n=ft(e.trim().slice(1,-1),",",!0);if(n.length!==1)return e.trim();let r=n[0];if(r.startsWith("..."))return e.trim();let i=/^(?:[A-Za-z_$][\w$]*)(\?)?\s*:\s*([\s\S]+)$/.exec(r),a=i?!!i[1]:r.endsWith("?"),l=i?i[2]:a?r.slice(0,-1).trim():r;return a?`(${l}) | undefined | []`:l}function zn(e){let n=Rn(e,["defineEmits"],!0);if(!n)return null;let r=Object.create(null),i=/^[A-Za-z_$][\w$]*$/.test(n.type.trim())?n.type.trim():void 0,a=i?vs(e,i):n.type.trim();if(a?.startsWith("{"))for(let l of ft(a.slice(1,-1),`;,
527
+ `,!0)){if(l.startsWith("(")){let I=mt(l,0,"(",")");if(I<0)continue;let V=ft(l.slice(1,I-1),",",!0),O=V.shift()||"",W=O.indexOf(":");if(W<0)continue;for(let D of ft(O.slice(W+1),"|",!0)){let G=$s(D);if(G!==void 0)r[G]={detailType:Mo(`[${V.join(", ")}]`)}}continue}let u=new be(l,"javascript").tokenize().filter((I)=>!["WHITESPACE","COMMENT","EOF"].includes(I.type)),f=u[0],v=u.findIndex((I)=>I.value===":");if(!f||v<0)continue;let S=$s(f.value),j=l.slice(u[v].end).trim();if(S!==void 0)r[S]={detailType:j.startsWith("[")?Mo(j):j}}else{let l=n.args[0]?.trim()||"";if(l.startsWith("["))for(let u of ft(l.slice(1,-1),",",!1)){let f=$s(u);if(f!==void 0)r[f]={detailType:"unknown"}}else if(l.startsWith("{"))for(let u of ft(l.slice(1,-1),",",!1)){let f=new be(u,"javascript").tokenize().find((S)=>!["WHITESPACE","COMMENT"].includes(S.type)),v=f&&$s(f.value);if(v!==void 0)r[v]={detailType:"unknown"}}}return{...n,text:e.slice(n.start,n.end),typeName:i,events:r}}import{mkdir as Do,readFile as su,readdir as ru,realpath as iu,stat as No,writeFile as ou}from"fs/promises";import tt from"path";import{builtinModules as au}from"module";function Vo(e){if(e==="connectedCallback")return`method "${e}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(e==="disconnectedCallback")return`method "${e}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${e}" is reserved`}var Uo=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]),cu=new Set(au);function lu(e){return e.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function ir(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function uu(e){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(e)&&!e.startsWith("xml")&&!/[A-Z]/.test(e)}function pu(e){if(e===!0)return"open";if(e==="open"||e==="closed")return e;return!1}async function fu(e){let n=[];async function r(i){let a=await ru(i,{withFileTypes:!0});a.sort((l,u)=>l.name.localeCompare(u.name));for(let l of a){let u=tt.join(i,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await r(u)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))n.push(u)}}return await r(e),n}function Zt(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function or(e){for(let n of Q(Zt(e))){let r=N(n.attrs);if(!r.has("component")&&!r.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function ar(e,n){let r=or(e);if(!r)return{};let i=r.code.trim();if(!i)return{};try{let a=JSON.parse(i);if(!a||typeof a!=="object"||Array.isArray(a))throw Error("expected a JSON object");return a}catch(a){throw Error(`${n}: <script component> must contain JSON metadata (${a.message})`)}}function Ss(e,n){let r=t(e),i=new Set(qn(e).map((v)=>v.start)),a=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,l=[],u=n?void 0:new Bun.Transpiler({loader:"ts"}),f;while(f=a.exec(r)){if(!i.has(f.index+f[0].indexOf("function")))continue;let v=a.lastIndex;while(/\s/.test(r[v]||""))v++;let S=v;if(r[v]==="<")v=mt(r,v,"<",">");if(v<0)continue;let j=e.slice(S,v).trim();while(/\s/.test(r[v]||""))v++;if(r[v]!=="(")continue;let I=v,V=mt(r,v,"(",")");if(V<0)continue;for(v=V;v<e.length;v++){let O=r[v];if(O!=="{"&&O!==";")continue;let W=e.slice(f.index,v).trim();if(n){if(!n(W,O,f[1]))continue}else{let G;try{G=u.transformSync(W+(O==="{"?"{}":";"))}catch{continue}if(O==="{"&&!G.includes(`function ${f[1]}(`))continue;if(O===";"&&G.trim())continue}let D=O==="{"?mt(r,v,"{","}"):v+1;if(D<0)break;l.push({name:f[1],header:W,generic:j,parameterOffset:I+1,parameters:e.slice(I+1,V-1),returns:e.slice(V,v).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(f[0]),...O==="{"?{source:e.slice(f.index,D)}:{}}),a.lastIndex=D;break}}return l}function du(e){let n=ft(e.parameters,",",!0).flatMap((r,i)=>{let a=t(r),l=0,u=-1;for(let D=0;D<a.length;D++){let G=a[D];if("([{<".includes(G))l++;else if(")]}>".includes(G)&&!(G===">"&&a[D-1]==="="))l--;if(G==="="&&l===0&&a[D+1]!==">"){u=D;break}}let f=(u<0?r:r.slice(0,u)).trim(),v=ft(f,":",!0),S=v.shift().trim();if(S==="this")return[];let j=/^[A-Za-z_$]|^\.\.\./.test(S)?S:`argument${i}`,I=u<0?"":r.slice(u+1).trim(),V=I==="true"||I==="false"?"boolean":/^-?\d+(?:\.\d+)?$/.test(I)?"number":/^['"`]/.test(I)?"string":j.startsWith("...")?"unknown[]":"unknown",O=v.join(":").trim()||V,W=u>=0&&!j.endsWith("?")&&!j.startsWith("...")?"?":"";return[`${j}${W}: ${O}`]}).join(", ");return`${e.name}${e.generic}(${n}): ${e.returns||(e.async?"Promise<unknown>":"unknown")}`}function gu(e,n){let r={},i={},a=[],l=[],u=Q(Zt(e)).map((D)=>({code:e.slice(D.bodyStart,D.bodyEnd),attributes:N(D.attrs)})).filter(({attributes:D})=>!["src","server","component","stx:component"].some((G)=>D.has(G))&&Et(D)),f=u.map((D)=>D.code).join(`
528
+ `),v=ln(f),S=zn(f);for(let D of u){let{code:G}=D;try{new Bun.Transpiler({loader:"ts"}).transformSync(G)}catch(le){throw Error(`${n}: failed to transpile <script client> (${le.message})`)}let X=Ss(G),ee=new Set(X.filter((le)=>!le.source).map((le)=>le.name));for(let le of X){if(Uo.has(le.name))throw Error(`${n}: client ${Vo(le.name)}`);if(le.source)r[le.name]=`${le.name}(...args) { return this._callScopeMethod(${JSON.stringify(le.name)}, args); }`;if(!le.source||!ee.has(le.name))(i[le.name]??=[]).push(du(le))}for(let le of G.matchAll(/^\s*import\s+(?:type\s+)?([\s\S]*?)\s+from\s*(['"])([^'"]+)\2\s*;?/gm))l.push({binding:le[1].trim(),module:le[3]});let H=t(G),q=y(H).depths,se=/(?:export\s+)?(interface|type)\s+[A-Za-z_$][\w$]*/g,ce;while(ce=se.exec(H)){if(q[ce.index]!==0)continue;let le=se.lastIndex,pe=0;for(;le<H.length;le++){let We=H[le];if(We==="{"){let nt=mt(H,le,"{","}");if(nt<0)break;if(le=nt-1,ce[1]==="interface"&&pe===0){le++;break}continue}if("([<".includes(We))pe++;else if(")]>".includes(We)&&!(We===">"&&H[le-1]==="="))pe--;if(ce[1]==="type"&&pe===0&&(We===";"||We===`
529
+ `)){if(We===`
530
+ `&&/^[\s]*[|&]/.test(H.slice(le+1)))continue;try{new Bun.Transpiler({loader:"ts"}).transformSync(G.slice(ce.index,le));break}catch{}}}let Re=G.slice(ce.index,le),Ae=ce.index,ve=/(?:interface|type)\s+([A-Za-z_$][\w$]*)/.exec(ce[0])?.[1],fe=u.map((We)=>{let nt=We===D?G.slice(0,Ae)+G.slice(le):We.code;return t(nt.replace(ln(We.code)?.text??"\x00","").replace(zn(We.code)?.text??"\x00",""))}).join(`
531
+ `);if(!((v?.typeName===ve||S?.typeName===ve)&&!/^export\s/.test(Re)&&ve&&!new RegExp(`\\b${ve}\\b`).test(fe)))a.push(Re.replace(/^export\s+/,"").trim());se.lastIndex=le+1}}let j=Object.values(i).flat().join(`
532
+ `)+`
533
+ `+a.join(`
534
+ `)+`
535
+ `+Object.values(S?.events||{}).map((D)=>D.detailType).join(`
536
+ `),I=new be(j,"javascript").tokenize().filter((D)=>!["WHITESPACE","COMMENT"].includes(D.type)),V=new Set(I.filter((D,G)=>{if(I[G-1]?.value===".")return!1;let X=I[G+1]?.value;return X!==":"&&!(X==="?"&&I[G+2]?.value===":")}).map((D)=>D.value)),O=l.filter((D)=>(D.binding.match(/[A-Za-z_$][\w$]*/g)||[]).filter((G)=>!["type","as"].includes(G)).some((G)=>V.has(G)));for(let D of O)if(D.module.startsWith(".")||tt.isAbsolute(D.module))throw Error(`${n}: public method types import ${JSON.stringify(D.module)} outside the generated package; declare these types in the component or import them from a published dependency`);let W=[...new Set(O.map((D)=>`import type ${D.binding.replace(/\btype\s+/g,"")} from ${JSON.stringify(D.module)}`))];return{methods:r,declarations:i,types:a.join(`
537
+
538
+ `),typeImports:W.join(`
539
+ `)}}function mu(e){let n=e.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:e).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Lo(e){return[...e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].replace(/\r\n?/g,`
540
+ `).replaceAll("\x00","\uFFFD").trim()).filter(Boolean).join(`
541
+
542
+ `)}function hu(e){if(!e)return null;let n=e.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(n))return"string";if(/^number$/.test(n))return"number";if(/^boolean$/.test(n))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(n))return"string";return"object"}function xu(e){if(e===void 0)return"object";if(e==="true"||e==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test(e))return"number";if(/^['"`]/.test(e))return"string";return"object"}function Wn(e,n){if(e[n]!=="(")return null;let r=0,i="";for(let a=n;a<e.length;a++){let l=e[a];if(i!==""){if(l==="\\")a++;else if(l===i)i="";continue}if(l==="'"||l==='"'||l==="`"){i=l;continue}if(l==="(")r++;else if(l===")"){if(r--,r===0)return{expression:e.slice(n+1,a),end:a+1}}}return null}function cr(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function bu(e,n){let r=[],i=0,a=e.replace(/\{\{--[\s\S]*?--\}\}/g,""),l=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,u,f=(v)=>{if(v==="")return;let S=0,j=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}|(data-stx-on-[\w:-]+=")(\d+)(")/g,I;while(I=j.exec(v)){if(I.index>S)r.push(`out += ${JSON.stringify(v.slice(S,I.index))};`);r.push(I[3]!==void 0?`out += ${JSON.stringify(I[3])} + (this._handlers.push(${n[Number(I[4])]}) - 1) + ${JSON.stringify(I[5])};`:I[1]!==void 0?`out += __raw(${I[1]});`:`out += __escape(${I[2]});`),S=I.index+I[0].length}if(S<v.length)r.push(`out += ${JSON.stringify(v.slice(S))};`)};while(u=l.exec(a)){f(a.slice(i,u.index)),i=u.index+u[0].length;let S=u[1]==="if"||u[1]==="elseif"||u[1]==="foreach"?Wn(a,i):null;if(S)i=S.end,l.lastIndex=S.end;let j=S?.expression;switch(u[1]){case"if":r.push(`if (${j}) {`);break;case"elseif":r.push(`} else if (${j}) {`);break;case"else":r.push("} else {");break;case"endif":case"endforeach":r.push("}");break;case"foreach":{let I=cr(j||"");if(!I){r.push(`out += ${JSON.stringify(u[0]+(S?`(${j})`:""))};`);break}let{iterable:V,key:O,value:W}=I;r.push(O?`for (const [${O}, ${W}] of __entries(${V})) {`:`for (const ${W} of __values(${V})) {`);break}}}return f(a.slice(i)),r.join(`
543
+ `)}function Ho(e){let n=t(e),r=y(n).depths,i=[],a=[];for(let u of n.matchAll(/\bimport\b/g)){let f=u.index;if(r[f]!==0)continue;let v=new be(e.slice(f)).tokenize().filter((W)=>!["COMMENT","WHITESPACE"].includes(W.type));if(v[1]?.value==="("||v[1]?.value===".")continue;let S=v[1]?.type==="STRING"?1:-1,j=0;for(let W=1;S===-1&&W<v.length;W++){let D=v[W];if(D.value===";"||D.type==="EOF")break;if(D.value==="{")j++;else if(D.value==="}")j--;else if(j===0&&D.value==="from"&&v[W+1]?.type==="STRING")S=W+1}if(S===-1)continue;let I=v[S],V=S;if(v[V+1]?.value==="with"&&v[V+2]?.value==="{"){V+=2;let W=1;while(W&&v[V+1]?.type!=="EOF")if(V++,v[V]?.value==="{")W++;else if(v[V]?.value==="}")W--}if(v[V+1]?.value===";")V++;let O=f+v[V].end;if(a.push({start:f,end:O}),!["stx","@stacksjs/stx"].includes(I.value.slice(1,-1)))i.push(e.slice(f,O))}let l=e;for(let u of a.reverse())l=l.slice(0,u.start)+l.slice(u.end);return{imports:i,body:l}}function yu(e){let r=Q(Zt(e)).filter((X)=>{let ee=N(X.attrs);return Et(ee)&&!["component","stx:component","server","src"].some((H)=>ee.has(H))});if(!r.length)return{imports:[],body:"",propNames:[],propBindings:{},defaults:{},declared:{},apis:[]};let i=r.map((X)=>e.slice(X.bodyStart,X.bodyEnd)).join(`
544
+ `),a=[],l=[],u=Object.create(null),f=Object.create(null),v=Object.create(null),S=Ho(i);a.push(...S.imports),i=S.body;let j=ln(i);if(j)l.push(...j.propNames),Object.assign(u,j.propBindings),Object.assign(f,j.defaults),Object.assign(v,j.declared),i=i.replace(j.text,j.identifier?`const ${j.identifier} = this._props();`:"");if(j?.typeName){let X=vs(i,j.typeName);if(X)for(let ee of ft(X.slice(1,-1),`;,
545
+ `,!0)){let H=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:\s*([\s\S]+)$/.exec(ee);if(!H)continue;if(v[H[1]]=H[2].trim(),!l.includes(H[1]))l.push(H[1])}}let I=zn(i);if(I)i=i.replace(I.text,"this._emitScope.bind(this)");let V=t(i),O=y(V).depths;for(let X of[...V.matchAll(/\bexport\s+(?=(?:interface|type|const|let|var|async|function)\b)/g)].reverse())if(O[X.index]===0)i=i.slice(0,X.index)+" ".repeat(X[0].length)+i.slice(X.index+X[0].length);let W=new Set(qn(i).map((X)=>X.name)),D=t(i),G=["state","derived","effect","batch","onMount","onDestroy"].filter((X)=>!W.has(X)&&new RegExp(`\\b${X}\\s*(?:<|\\()`).test(D));return{imports:a,body:i.trim(),propNames:l,propBindings:u,defaults:f,declared:v,apis:G}}function _u(e){let n=new Set,r=[];return{template:e.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([\s\S]*?)\3/gi,(a,l,u,f,v)=>{let S=l.toLowerCase();n.add(S);let j=(u||"").split(".").filter(Boolean).join(" "),I=r.length;return r.push(/^[A-Za-z_$][\w$]*$/.test(v.trim())?`($event) => (typeof ${v} === 'function' ? ${v} : this[${JSON.stringify(v.trim())}]).call(this, $event)`:`($event) => { ${v} }`),` data-stx-on-${S}="${I}"${j?` data-stx-mod-${S}="${j}"`:""}`}),eventTypes:[...n].sort(),handlers:r}}function wu(e){let n=[];return{template:e.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(i,a,l,u)=>{let f=n.length;return n.push({id:f,name:a,expression:u}),` data-stx-bind-${f}=""`}),bindings:n}}function vu(e){let n=new Set;for(let r of e.matchAll(/<slot\b([^>]*)>/gi))n.add(r[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...n].map((r)=>({name:r}))}function $u(e){return[...new Set([...e.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((n)=>n[1]))].sort().map((n)=>({name:n}))}function zo(e,n){if(!n||!new Set(["string","number","boolean","object","array"]).has(n.type))throw Error(`Property "${e}" must declare one of: string, number, boolean, object, array`);return{...n,reflect:n.reflect??n.attribute!==!1}}async function Su(e,n,r){let i=tt.isAbsolute(n.file)?n.file:tt.resolve(e,n.file),a=await su(i,"utf8"),l=ar(a,i),u=tt.basename(i,".stx"),f=n.name||l.name||lu(u),v=`${ir(r.prefix||"stx")}-${ir(u)}`,S=n.tag||l.tag||v;if(!f||!/^[A-Za-z_$][\w$]*$/.test(f))throw Error(`${i}: invalid component class name "${f}"`);if(!uu(S))throw Error(`${i}: invalid custom-element tag "${S}"; tags must be lowercase and contain a hyphen`);let j=n.properties||l.properties||l.props||{},I=Object.fromEntries(Object.entries(j).map(([H,q])=>[H,zo(H,q)])),V=_u(mu(a)),O=wu(V.template),W=yu(a);for(let H of Q(Zt(a))){let q=N(H.attrs);if(!q.has("client")||["server","component","stx:component","src"].some((se)=>q.has(se))||!Et(q))continue;W.imports.push(...Ho(a.slice(H.bodyStart,H.bodyEnd)).imports)}W.imports=[...new Set(W.imports)];let D=bu(O.template,V.handlers);for(let H of W.propNames){if(I[H])continue;let q=W.defaults[H];I[H]=zo(H,{type:hu(W.declared[H])??xu(q),...q===void 0?{}:{default:ws(q)}})}let G=l.methods||{},X=n.methods||{},ee=gu(a,i);return{file:tt.relative(e,i),sourcePath:i,name:f,tag:S,description:n.description||l.description||"",template:O.template,styles:Lo(a),shadowMode:pu(n.shadowDOM??l.shadowDOM??r.shadowDOM),progressive:n.progressive??l.progressive??r.progressive??!0,properties:I,events:{...zn(Q(Zt(a)).filter((H)=>{let q=N(H.attrs);return Et(q)&&!["server","component","stx:component","src"].some((se)=>q.has(se))}).map((H)=>a.slice(H.bodyStart,H.bodyEnd)).join(`
546
+ `))?.events||{},...n.events||l.events||{}},methods:{...G,...X,...ee.methods},methodDeclarations:ee.declarations,declarationTypes:ee.types,declarationImports:ee.typeImports,eventTypes:V.eventTypes,handlers:V.handlers,scopeMethods:Object.keys(ee.methods),bindings:O.bindings,slots:vu(O.template),cssProperties:$u(Lo(a)),scope:W,render:D}}function Bo(e=!1){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`${e?`import { state as nativeState, derived as nativeDerived, effect as nativeEffect, batch as nativeBatch } from './signals.js';
547
+ `:""}const HTMLElementBase = globalThis.HTMLElement || class {};
548
+
549
+ const escapeHTML = (value) => String(value ?? '')
550
+ .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
551
+ .replaceAll('"', '&quot;').replaceAll("'", '&#039;');
552
+
553
+ const valueAt = (host, path) => {
554
+ const parts = path.trim().split('.');
555
+ if (parts[0] === 'this') parts.shift();
556
+ if (!parts.length) return host;
557
+ const first = parts.shift();
558
+ // Render bindings read declared props, including attributes whose names
559
+ // also belong to the native DOM API. The public element keeps that API.
560
+ let value = host._values && Object.prototype.hasOwnProperty.call(host._values, first)
561
+ ? host._values[first]
562
+ : host[first];
563
+ for (const part of parts) value = value?.[part];
564
+ return typeof value === 'function' ? value.call(host) : value;
565
+ };
566
+
567
+ const deserialize = (value, type, fallback) => {
568
+ if (value === null) return type === 'boolean' ? false : fallback;
569
+ if (type === 'boolean') return value !== 'false' && value !== '0';
570
+ if (type === 'number') return Number(value);
571
+ if (type === 'object' || type === 'array') {
572
+ try { return JSON.parse(value); }
573
+ catch { return fallback; }
574
+ }
575
+ return value;
576
+ };
577
+
578
+ const serialize = (value, type) => {
579
+ if (value == null || value === false) return null;
580
+ if (type === 'boolean') return '';
581
+ if (type === 'object' || type === 'array') return JSON.stringify(value);
582
+ return String(value);
583
+ };
584
+
585
+ const cloneDefault = (value, type) => {
586
+ if (value == null || (type !== 'object' && type !== 'array')) return value;
587
+ if (typeof structuredClone === 'function') return structuredClone(value);
588
+ return JSON.parse(JSON.stringify(value));
589
+ };
590
+
591
+ const defaultFor = property => cloneDefault(
592
+ property.default ?? ({ string: '', number: 0, boolean: false, object: {}, array: [] })[property.type],
593
+ property.type,
594
+ );
595
+
596
+ export class StxElement extends HTMLElementBase {
597
+ static definition = {};
598
+ static get observedAttributes() { return this.definition.observedAttributes || []; }
599
+
600
+ constructor() {
601
+ super();
602
+ this._values = Object.create(null);
603
+ this._reflecting = false;
604
+ this._connected = false;
605
+ this._hasConnected = false;
606
+ this._initializing = false;
607
+ this._updatePending = false;
608
+ this._listeners = new Map();
609
+ this._scopeStates = [];
610
+ this._scopeDerived = [];
611
+ this._scopeEffects = [];
612
+ this._scopeSubscriptions = [];
613
+ this._scopeMounts = [];
614
+ this._scopeDestroys = [];
615
+ this._scopeConnectionDestroys = [];
616
+ this._scopeMountCleanups = [];
617
+ const definition = this.constructor.definition;
618
+ for (const [name, property] of Object.entries(definition.properties || {})) {
619
+ this._values[name] = defaultFor(property);
620
+ }
621
+ if (definition.shadowMode && this.attachShadow && !this.shadowRoot) {
622
+ this._closedRoot = this.attachShadow({ mode: definition.shadowMode });
623
+ }
624
+ }
625
+
626
+ get updateComplete() { return this._updateComplete || Promise.resolve(); }
627
+ get renderRoot() { return this._closedRoot || this.shadowRoot || this; }
628
+
629
+ connectedCallback() {
630
+ if (this._connected) return;
631
+ this._connected = true;
632
+ this._initializing = true;
633
+ const definition = this.constructor.definition;
634
+ for (const [name, property] of Object.entries(definition.properties || {})) {
635
+ const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
636
+ if (attribute && this.hasAttribute?.(attribute)) this._values[name] = deserialize(this.getAttribute(attribute), property.type, defaultFor(property));
637
+ }
638
+ // Properties assigned before customElements.define() become own properties.
639
+ // Upgrade them after attributes so imperative state wins, matching the
640
+ // platform's property-first custom-element initialization convention.
641
+ for (const name of Object.keys(definition.properties || {})) this._upgradeProperty(name);
642
+ this._initializing = false;
643
+ const root = this.renderRoot;
644
+ const hasMarkup = [...(root.childNodes || [])].some(node => node.nodeType !== 3 || node.textContent.trim());
645
+ const firstConnection = !this._hasConnected;
646
+ if (!(firstConnection && definition.progressive && hasMarkup)) this._render();
647
+ else {
648
+ if (typeof this.render === 'function') this.render(RENDER_HELPERS);
649
+ this._upgradeDeclarativeEvents();
650
+ }
651
+ this._bindEvents();
652
+ if (firstConnection) {
653
+ this._hasConnected = true;
654
+ this.setAttribute?.('hydrated', '');
655
+ this.dispatchEvent?.(new CustomEvent('stx:hydrated', { bubbles: true, composed: true }));
656
+ }
657
+ // Called last, so a component that acquires something sees its own rendered
658
+ // markup and its events already bound. Reported rather than rethrown: a
659
+ // component that fails to set up must not take the element down with it.
660
+ this._runScopeMounts();
661
+ try { this.onConnect?.(); }
662
+ catch (error) { console.error('[stx] onConnect failed', error); }
663
+ }
664
+
665
+ disconnectedCallback() {
666
+ this._connected = false;
667
+ // Called before the framework releases anything, so the element is still
668
+ // intact for a component that needs to read it on the way out, and inside
669
+ // try/finally so a throwing hook cannot leak the framework's own listeners.
670
+ try { this.onDisconnect?.(); }
671
+ catch (error) { console.error('[stx] onDisconnect failed', error); }
672
+ finally {
673
+ this._disposeScopeEffects();
674
+ for (const dispose of this._scopeSubscriptions.splice(0)) {
675
+ try { dispose?.(); } catch (error) { console.error('[stx] scope subscription cleanup failed', error); }
676
+ }
677
+ for (const cleanup of [...this._scopeDestroys.splice(0), ...this._scopeConnectionDestroys.splice(0), ...this._scopeMountCleanups.splice(0)]) {
678
+ try { cleanup(); } catch (error) { console.error('[stx] scope cleanup failed', error); }
679
+ }
680
+ for (const [event, listener] of this._listeners) this.renderRoot.removeEventListener(event, listener);
681
+ this._listeners.clear();
682
+ }
683
+ }
684
+
685
+ attributeChangedCallback(attribute, oldValue, newValue) {
686
+ if (oldValue === newValue || this._reflecting) return;
687
+ const definition = this.constructor.definition;
688
+ const name = definition.attributeToProperty?.[attribute];
689
+ if (!name) return;
690
+ const property = definition.properties[name];
691
+ const value = deserialize(newValue, property.type, defaultFor(property));
692
+ if (!Object.is(this._values[name], value)) {
693
+ this._values[name] = value;
694
+ this.requestUpdate();
695
+ }
696
+ }
697
+
698
+ /**
699
+ * The props a compiled render reads.
700
+ *
701
+ * Its own method rather than _values directly, so a component that sets a
702
+ * property before upgrade still sees it, and so the generated code has one
703
+ * name to depend on rather than a private field's shape.
704
+ */
705
+ _props() {
706
+ return this._values;
707
+ }
708
+
709
+ requestUpdate() {
710
+ if (!this._connected || this._initializing || this._updatePending) return this.updateComplete;
711
+ this._updatePending = true;
712
+ this._updateComplete = new Promise((resolve) => {
713
+ queueMicrotask(() => {
714
+ this._updatePending = false;
715
+ if (this._connected) this._render();
716
+ resolve();
717
+ });
718
+ });
719
+ return this._updateComplete;
720
+ }
721
+
722
+ emit(name, detail, options = {}) {
723
+ return this.dispatchEvent(new CustomEvent(name, {
724
+ detail, bubbles: true, composed: true, ...options,
725
+ }));
726
+ }
727
+
728
+ _disposeScopeEffects() {
729
+ for (const dispose of this._scopeEffects.splice(0)) {
730
+ try { dispose(); } catch (error) { console.error('[stx] effect cleanup failed', error); }
731
+ }
732
+ }
733
+
734
+ _runScopeMounts() {
735
+ for (const mount of this._scopeMounts) {
736
+ try { const cleanup = mount(); if (typeof cleanup === 'function') this._scopeMountCleanups.push(cleanup); }
737
+ catch (error) { console.error('[stx] onMount failed', error); }
738
+ }
739
+ }
740
+
741
+ ${e?` _beginScope() {
742
+ this._disposeScopeEffects();
743
+ this._scopeMounts = [];
744
+ this._scopeDestroys = [];
745
+ let stateIndex = 0, derivedIndex = 0;
746
+ let rendering = true;
747
+ return {
748
+ finish: () => { rendering = false; },
749
+ state: (initial) => {
750
+ const index = stateIndex++;
751
+ const value = this._scopeStates[index] ||= nativeState(initial);
752
+ if (this._connected && !this._scopeSubscriptions[index]) this._scopeSubscriptions[index] = value.subscribe(() => this.requestUpdate());
753
+ return value;
754
+ },
755
+ derived: (compute, options) => {
756
+ const index = derivedIndex++;
757
+ let entry = this._scopeDerived[index];
758
+ if (!entry) {
759
+ entry = { compute, revision: nativeState(0) };
760
+ entry.value = nativeDerived(() => { entry.revision(); return entry.compute(); }, options);
761
+ this._scopeDerived[index] = entry;
762
+ } else {
763
+ entry.compute = compute;
764
+ entry.revision.update(value => value + 1);
765
+ }
766
+ return entry.value;
767
+ },
768
+ effect: (callback, options) => {
769
+ const dispose = nativeEffect(callback, options);
770
+ this._scopeEffects.push(dispose);
771
+ return dispose;
772
+ },
773
+ batch: nativeBatch,
774
+ onMount: callback => this._scopeMounts.push(callback),
775
+ onDestroy: callback => (rendering ? this._scopeDestroys : this._scopeConnectionDestroys).push(callback),
776
+ };
777
+ }
778
+
779
+ `:""} _emitScope(name, ...args) {
780
+ return this.emit(name, args.length === 1 ? args[0] : args, { cancelable: true });
781
+ }
782
+
783
+ _callScopeMethod(name, args) {
784
+ // Template calls already have this render's current prop closures. Refresh
785
+ // pending props only for an outside call, otherwise a public helper in the
786
+ // template would recursively render while the queued update is pending.
787
+ if (!this._scopeRenderDepth && (!this._scopeMethods || this._updatePending)) this.render(RENDER_HELPERS);
788
+ return this._scopeMethods[name].apply(this, args);
789
+ }
790
+
791
+ _upgradeProperty(name) {
792
+ if (!Object.prototype.hasOwnProperty.call(this, name)) return;
793
+ const value = this[name];
794
+ delete this[name];
795
+ this[name] = value;
796
+ }
797
+
798
+ _upgradeDeclarativeEvents() {
799
+ for (const element of this.renderRoot.querySelectorAll?.('*') || []) {
800
+ const names = element.getAttributeNames?.() || [...(element.attributes || [])].filter(Boolean).map(attribute => attribute.name);
801
+ for (const attributeName of names) {
802
+ if (!attributeName?.startsWith('@')) continue;
803
+ const [event, ...modifiers] = attributeName.slice(1).split('.');
804
+ element.setAttribute('data-stx-on-' + event, element.getAttribute(attributeName));
805
+ if (modifiers.length) element.setAttribute('data-stx-mod-' + event, modifiers.join(' '));
806
+ element.removeAttribute(attributeName);
807
+ }
808
+ }
809
+ }
810
+
811
+ _bindEvents() {
812
+ for (const event of this.constructor.definition.eventTypes || []) {
813
+ if (this._listeners.has(event)) continue;
814
+ const listener = ($event) => {
815
+ const selector = '[data-stx-on-' + event + ']';
816
+ const target = $event.target?.closest?.(selector);
817
+ if (!target || !this.renderRoot.contains(target)) return;
818
+ const modifiers = (target.getAttribute('data-stx-mod-' + event) || '').split(' ');
819
+ if (modifiers.includes('self') && target !== $event.target) return;
820
+ if (modifiers.includes('prevent')) $event.preventDefault();
821
+ if (modifiers.includes('stop')) $event.stopPropagation();
822
+ const method = target.getAttribute('data-stx-on-' + event);
823
+ if (this._handlers?.[method]) this._handlers[method]($event);
824
+ else if (typeof this[method] === 'function') this[method]($event);
825
+ };
826
+ this.renderRoot.addEventListener(event, listener);
827
+ this._listeners.set(event, listener);
828
+ }
829
+ }
830
+
831
+ _render() {
832
+ const definition = this.constructor.definition;
833
+ const root = this.renderRoot;
834
+ const active = root.activeElement || (root.contains?.(globalThis.document?.activeElement) ? globalThis.document.activeElement : null);
835
+ const focusAttribute = active?.getAttribute?.('data-key') ? 'data-key' : active?.id ? 'id' : 'name';
836
+ const focusKey = active?.getAttribute?.(focusAttribute);
837
+ const focusValue = focusAttribute === 'name' && active?.type === 'radio' ? active.value : null;
838
+ const selectionStart = active?.selectionStart, selectionEnd = active?.selectionEnd;
839
+ const selection = Number.isInteger(selectionStart) && Number.isInteger(selectionEnd)
840
+ ? [selectionStart, selectionEnd, active.selectionDirection] : null;
841
+ // A compiled component renders itself: the control flow and the derived
842
+ // values were turned into JavaScript at build time, so there is nothing to
843
+ // interpret here and nothing that needs an eval the page's CSP forbids.
844
+ // The string template remains for components that carry no logic.
845
+ let html = typeof this.render === 'function'
846
+ ? this.render(RENDER_HELPERS)
847
+ : definition.template
848
+ .replace(new RegExp(${n}, 'g'), (_match, expression) => String(valueAt(this, expression) ?? ''))
849
+ .replace(new RegExp(${r}, 'g'), (_match, expression) => escapeHTML(valueAt(this, expression)));
850
+ if (definition.shadowMode && definition.styles) html = '<style>' + definition.styles + '</style>' + html;
851
+ root.innerHTML = html;
852
+ this._applyBindings();
853
+ this._bindEvents();
854
+ if (focusKey) {
855
+ const escaped = globalThis.CSS?.escape ? globalThis.CSS.escape(focusKey) : focusKey.replace(/["\\\\]/g, '\\$&');
856
+ const selector = '[' + focusAttribute + '="' + escaped + '"]';
857
+ // Name-only radio groups share a name, but their chosen member must stay focused.
858
+ const next = focusValue === null ? root.querySelector(selector)
859
+ : [...root.querySelectorAll(selector)].find(element => element.type === 'radio' && element.value === focusValue);
860
+ next?.focus?.();
861
+ // Several input types expose this method but reject text selection. A
862
+ // rerender can also change a text input into one of those types.
863
+ if (selection && Number.isInteger(next?.selectionStart) && Number.isInteger(next?.selectionEnd) && typeof next?.setSelectionRange === 'function')
864
+ next.setSelectionRange(selection[0], selection[1], selection[2] || 'none');
865
+ }
866
+ this.dispatchEvent?.(new CustomEvent('stx:updated', { bubbles: false }));
867
+ }
868
+
869
+ _applyBindings() {
870
+ for (const binding of this.constructor.definition.bindings || []) {
871
+ const element = this.renderRoot.querySelector('[data-stx-bind-' + binding.id + ']');
872
+ if (!element) continue;
873
+ const value = valueAt(this, binding.expression);
874
+ if (binding.name === 'class') element.className = value || '';
875
+ else if (binding.name === 'style' && typeof value === 'object') {
876
+ Object.assign(element.style, value);
877
+ }
878
+ else if (typeof value === 'boolean') {
879
+ element.toggleAttribute(binding.name, value);
880
+ if (binding.name in element) element[binding.name] = value;
881
+ }
882
+ else if (value == null || value === false) element.removeAttribute(binding.name);
883
+ else element.setAttribute(binding.name, String(value));
884
+ }
885
+ }
886
+ }
887
+
888
+ /**
889
+ * What a compiled render is handed.
890
+ *
891
+ * Passed in rather than closed over so the generated code names no globals, and
892
+ * a component module stays readable on its own: __escape is visibly a
893
+ * parameter, not something the bundler happened to leave in scope.
894
+ */
895
+ const RENDER_HELPERS = {
896
+ escape: escapeHTML,
897
+ // The raw form is the author declaring the value is markup. Null becomes an
898
+ // empty string rather than the word "null", which is the only sensible
899
+ // reading of a missing fragment.
900
+ raw: (value) => String(value ?? ''),
901
+ // A loop over something absent runs zero times. Throwing here would fail a
902
+ // whole page over one empty list, which is never what the author meant.
903
+ values: (value) => value == null ? [] : (value[Symbol.iterator] ? value : Object.values(value)),
904
+ entries: (value) => value == null ? [] : (Array.isArray(value) ? value.entries() : Object.entries(value)),
905
+ };
906
+
907
+ export function defineComponent(Component, definition) {
908
+ const properties = definition.properties || {};
909
+ const attributeToProperty = {};
910
+ const observedAttributes = [];
911
+ for (const [name, property] of Object.entries(properties)) {
912
+ const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
913
+ if (attribute) {
914
+ attributeToProperty[attribute] = name;
915
+ observedAttributes.push(attribute);
916
+ }
917
+ // A style prop is an attribute value, not a replacement for the browser's
918
+ // CSSStyleDeclaration. Native event handler accessors must survive too.
919
+ if (name in HTMLElementBase.prototype) {
920
+ if (!attribute) throw new TypeError('STX prop "' + name + '" overlaps the native DOM API and needs an attribute binding');
921
+ continue;
922
+ }
923
+ Object.defineProperty(Component.prototype, name, {
924
+ configurable: true,
925
+ enumerable: true,
926
+ get() { return this._values[name]; },
927
+ set(value) {
928
+ const oldValue = this._values[name];
929
+ if (Object.is(oldValue, value)) return;
930
+ this._values[name] = value;
931
+ if (property.reflect && attribute && !this._reflecting) {
932
+ const serialized = serialize(value, property.type);
933
+ this._reflecting = true;
934
+ if (serialized === null) this.removeAttribute(attribute);
935
+ else this.setAttribute(attribute, serialized);
936
+ this._reflecting = false;
937
+ }
938
+ this.requestUpdate();
939
+ this.dispatchEvent?.(new CustomEvent(name + '-changed', {
940
+ detail: { value, oldValue }, bubbles: true, composed: true,
941
+ }));
942
+ },
943
+ });
944
+ }
945
+ Component.definition = { ...definition, attributeToProperty, observedAttributes };
946
+ const registry = globalThis.customElements || globalThis.window?.customElements;
947
+ if (registry && !registry.get(definition.tag)) {
948
+ registry.define(definition.tag, Component);
949
+ }
950
+ return Component;
951
+ }
952
+ `}function rr(e,n="./runtime.js"){let r=JSON.stringify({tag:e.tag,template:e.template,styles:e.styles,shadowMode:e.shadowMode,progressive:e.progressive,properties:e.properties,eventTypes:e.eventTypes,bindings:e.bindings},null,2),i=Object.entries(e.methods).map(([j,I])=>{if(Uo.has(j))throw Error(`${e.sourcePath}: ${Vo(j)}`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(I.trim()))return` ${I.trim()}`;return` ${j}($event) {
953
+ ${I}
954
+ }`}).join(`
955
+
956
+ `),a=e.scope,l=new Set(new be([a.body,...a.imports,...Object.keys(e.properties),...Object.values(a.propBindings)].join(`
957
+ `)).tokenize().map((j)=>j.value)),u="__stxScope";while(l.has(u))u+="$";let f=[...new Set([...Object.keys(e.properties),...a.propNames])].map((j)=>{let I=a.propBindings[j]||j;return a.defaults[j]===void 0?I:`${I} = ${a.defaults[j]}`}).join(", "),v=(j)=>j.split(`
958
+ `).map((I)=>I.trim()===""?I:` ${I}`).join(`
959
+ `),S="";if(e.render.trim()!==""||a.body!==""||f!==""){let j=[a.apis.length?`const ${u} = this._beginScope();
960
+ const { ${a.apis.join(", ")} } = ${u};`:"",f?`const { ${f} } = this._props();`:"",a.body,e.scopeMethods.length?`this._scopeMethods = { ${e.scopeMethods.join(", ")} };`:"",e.handlers.length?"this._handlers = [];":"","let out = '';",e.render,a.apis.length?`${u}.finish();`:"","return out;"].filter(Boolean).join(`
961
+ `),I;try{let V=new Bun.Transpiler({loader:"ts"}).transformSync(`export function __render(__helpers) {
962
+ ${j}
963
+ }`),O=V.indexOf("{"),W=V.lastIndexOf("}");I=V.slice(O+1,W).trim()}catch(V){throw Error(`${e.sourcePath}: failed to compile render (${V.message})`)}S=`
964
+ render(__helpers) {
965
+ this._scopeRenderDepth = (this._scopeRenderDepth || 0) + 1;
966
+ try {
967
+ const { escape: __escape, raw: __raw, values: __values, entries: __entries } = __helpers;
968
+ ${v(v(I.trim()))}
969
+ } finally {
970
+ this._scopeRenderDepth--;
971
+ }
972
+ }
973
+ `}return`import { StxElement, defineComponent } from ${n==="./runtime.js"?"'./runtime.js'":JSON.stringify(n)};
974
+ ${a.imports.length?`${a.imports.join(`
975
+ `)}
976
+ `:""}
977
+ /** ${e.description||`${e.name} web component generated from ${e.file}.`} */
978
+ export class ${e.name} extends StxElement {
979
+ ${i}${S}
980
+ }
981
+
982
+ defineComponent(${e.name}, ${r});
983
+ export default ${e.name};
984
+ `}function un(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function Eu(e){let n=[e.declarationTypes,e.declarationImports,e.name,...Object.values(e.methodDeclarations).flat(),...Object.values(e.events).map((V)=>V.detailType)].join(`
985
+ `),r=new Set(new be(n).tokenize().map((V)=>V.value)),i=(V)=>{let O=V;while(r.has(O))O+="$";return r.add(O),O},a=i("__StxSupport"),l=i("__Methods"),u=i("__Details"),f=!!e.declarationTypes,v=Object.entries(e.properties).map(([V,O])=>` ${V}${O.required?"":"?"}: ${un(O)}`).join(`
986
+ `),S=Object.entries(e.events).map(([V,O])=>` ${JSON.stringify(V)}: CustomEvent<${f?`${a}.${u}[${JSON.stringify(V)}]`:O.detailType||"unknown"}>`).join(`
987
+ `),j=Object.keys(e.methods).flatMap((V)=>e.methodDeclarations[V]||[`${V}($event?: Event): unknown`]).map((V)=>` ${V}`).join(`
988
+ `),I=f?`declare namespace ${a} {
989
+ ${e.declarationTypes}
990
+ export interface ${l} {
991
+ ${j}
992
+ }
993
+ export interface ${u} {
994
+ ${Object.entries(e.events).map(([V,O])=>` ${JSON.stringify(V)}: ${O.detailType||"unknown"}`).join(`
995
+ `)}
996
+ }
997
+ }
998
+
999
+ `:"";return`${e.declarationImports?e.declarationImports+`
1000
+
1001
+ `:""}${I}export interface ${e.name}Props {
1002
+ ${v}
1003
+ }
1004
+
1005
+ export interface ${e.name}EventMap {
1006
+ ${S}
1007
+ }
1008
+
1009
+ export interface ${e.name} extends Required<Pick<${e.name}Props, Exclude<keyof ${e.name}Props, keyof HTMLElement>>>${f?`, ${a}.${l}`:""} {}
1010
+
1011
+ export declare class ${e.name} extends HTMLElement {
1012
+ ${f?"":j}
1013
+ addEventListener<K extends keyof ${e.name}EventMap>(type: K, listener: (this: ${e.name}, event: ${e.name}EventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void
1014
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, event: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void
1015
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void
1016
+ removeEventListener<K extends keyof ${e.name}EventMap>(type: K, listener: (this: ${e.name}, event: ${e.name}EventMap[K]) => unknown, options?: boolean | EventListenerOptions): void
1017
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, event: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void
1018
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void
1019
+ readonly updateComplete: Promise<void>
1020
+ requestUpdate(): Promise<void>
1021
+ emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean
1022
+ }
1023
+
1024
+ declare global {
1025
+ interface HTMLElementTagNameMap {
1026
+ ${JSON.stringify(e.tag)}: ${e.name}
1027
+ }
1028
+ }
1029
+
1030
+ export default ${e.name}
1031
+ `}function ku(e){return`declare global {
1032
+ namespace JSX {
1033
+ interface IntrinsicElements {
1034
+ ${e.map((r)=>{let i=Object.entries(r.properties).map(([l,u])=>` ${JSON.stringify(l)}?: ${un(u)}`).join(`
1035
+ `),a=Object.keys(r.events).map((l)=>` ${`on${l.split(/[-:]/).map((f)=>f.charAt(0).toUpperCase()+f.slice(1)).join("")}`}?: (event: import('./${r.tag}.js').${r.name}EventMap[${JSON.stringify(l)}]) => void`).join(`
1036
+ `);return` ${JSON.stringify(r.tag)}: {
1037
+ ${i}
1038
+ ${a}
1039
+ children?: unknown
1040
+ slot?: string
1041
+ class?: string
1042
+ className?: string
1043
+ }`}).join(`
1044
+ `)}
1045
+ }
1046
+ }
1047
+ }
1048
+
1049
+ export {}
1050
+ `}function Cu(e){return{schemaVersion:"1.0.0",modules:e.map((n)=>({kind:"javascript-module",path:`./${n.tag}.js`,declarations:[{kind:"class",name:n.name,description:n.description||void 0,customElement:!0,tagName:n.tag,members:Object.entries(n.properties).map(([r,i])=>({kind:"field",name:r,description:i.description,type:{text:un(i)},default:i.default===void 0?void 0:JSON.stringify(i.default),attribute:i.attribute===!1?void 0:i.attribute||ir(r),reflects:i.reflect})),events:Object.entries(n.events).map(([r,i])=>({name:r,description:i.description,type:{text:`CustomEvent<${i.detailType||"unknown"}>`}})),slots:n.slots,cssProperties:n.cssProperties}],exports:[{kind:"js",name:n.name,declaration:{name:n.name,module:`./${n.tag}.js`}}]}))}}function Wo(e){if(!e.styles)return"";let n=e.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(n))return n;return`@scope (${e.tag}) {
1051
+ ${n}
1052
+ }`}function Fo(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function Ru(e){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),i=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),a=Object.fromEntries(e.map((u)=>[u.tag,{template:u.template,styles:u.styles,shadowMode:u.shadowMode,properties:u.properties}])),l=e.map((u)=>`export const render${u.name} = (props = {}, slots = {}) => renderComponent('${u.tag}', props, slots);`).join(`
1053
+ `);return`const definitions = ${JSON.stringify(a,null,2)};
1054
+ const escapeHTML = (value) => String(value ?? '')
1055
+ .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
1056
+ .replaceAll('"', '&quot;').replaceAll("'", '&#039;');
1057
+ const valueAt = (values, path) => path.trim().split('.').reduce((value, part) => value?.[part], values);
1058
+
1059
+ export function renderComponent(tag, props = {}, slots = {}) {
1060
+ const definition = definitions[tag];
1061
+ if (!definition) throw new Error('Unknown STX component: ' + tag);
1062
+ const values = Object.fromEntries(Object.entries(definition.properties).map(([name, property]) => [name, property.default]));
1063
+ Object.assign(values, props);
1064
+ let template = definition.template
1065
+ .replace(new RegExp(${n}, 'g'), (_match, expression) => String(valueAt(values, expression) ?? ''))
1066
+ .replace(new RegExp(${r}, 'g'), (_match, expression) => escapeHTML(valueAt(values, expression)))
1067
+ .replace(new RegExp(${i}, 'gi'), (_match, name) => String(slots[name || 'default'] ?? ''));
1068
+ const attributes = Object.entries(definition.properties).flatMap(([name, property]) => {
1069
+ if (property.attribute === false || !(name in props)) return [];
1070
+ const attribute = property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase());
1071
+ const value = props[name];
1072
+ if (value == null || value === false) return [];
1073
+ if (value === true) return [attribute];
1074
+ const serialized = typeof value === 'object' ? JSON.stringify(value) : value;
1075
+ return [attribute + '=\\"' + escapeHTML(serialized) + '\\"'];
1076
+ }).join(' ');
1077
+ if (definition.shadowMode) {
1078
+ template = '<template shadowrootmode="' + definition.shadowMode + '">' +
1079
+ (definition.styles ? '<style>' + definition.styles + '</style>' : '') + template + '</template>' +
1080
+ String(slots.default ?? '');
1081
+ }
1082
+ return '<' + tag + (attributes ? ' ' + attributes : '') + '>' + template + '</' + tag + '>';
1083
+ }
1084
+
1085
+ ${l}
1086
+ `}async function dl(e){let n=tt.resolve(e.inputDir),r=tt.resolve(e.outputDir);if(!(await No(n).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${n}`);let a=e.components?.length?e.components:(await fu(n)).map((H)=>({file:H}));if(!a.length)throw Error(`No .stx components found in ${n}`);let l=await Promise.all(a.map((H)=>Su(n,H,e)));l.sort((H,q)=>H.tag.localeCompare(q.tag));let u=l.filter((H,q)=>l.findIndex((se)=>se.tag===H.tag)!==q);if(u.length)throw Error(`Duplicate custom-element tag: ${u[0].tag}`);let f=l.filter((H,q)=>l.findIndex((se)=>se.name===H.name)!==q);if(f.length)throw Error(`Duplicate component class name: ${f[0].name}`);await Do(r,{recursive:!0});let v=[],S=async(H,q)=>{let se=tt.join(r,H);if(await Do(tt.dirname(se),{recursive:!0}),await ou(se,typeof q==="string"&&!q.endsWith(`
1087
+ `)?`${q}
1088
+ `:q),!v.includes(se))v.push(se);return se},j=l.some((H)=>H.scope.apis.length),I=import.meta.url.endsWith(".ts")?".ts":".js",V=new URL(`./signals-api${I}`,import.meta.url).pathname;if(j)await S("signals.js",`export * from ${JSON.stringify(V)};`);await S("runtime.js",Bo(j));for(let H of l){if(await S(`${H.tag}.js`,rr(H)),e.declarations!==!1)await S(`${H.tag}.d.ts`,Eu(H));if(e.css!==!1&&H.styles){let q=H.shadowMode?H.styles:Wo(H);await S(`${H.tag}.css`,e.minify?Fo(q):q)}}let O=new Bun.Transpiler({loader:"ts"});if(j||l.some((H)=>H.scope.imports.length||O.scanImports(rr(H)).some((q)=>q.kind==="dynamic-import"))){let H=l.map((ve)=>tt.join(r,`${ve.tag}.js`)),q=new Map(await Promise.all(H.map(async(ve,fe)=>[await iu(ve),l[fe]])));for(let[ve,fe]of H.entries())q.set(fe,l[ve]);let se=new Map(l.map((ve)=>[tt.join(tt.dirname(ve.sourcePath),`.stx-library-${ve.tag}.ts`),ve])),ce=tt.join(r,"runtime.js"),le=tt.join(r,"signals.js"),pe=tt.join(n,".stx-library-runtime.ts"),Re=tt.join(n,".stx-library-signals.ts");if(H.push(ce),j)H.push(le);let Ae=await Bun.build({entrypoints:H,outdir:r,root:r,target:"browser",format:"esm",splitting:!0,naming:{entry:"[name].js",chunk:"chunks/[name]-[hash].js"},minify:!1,loader:{".js":"ts"},plugins:[{name:"stx-element-runtime",setup(ve){ve.onResolve({filter:/.*/},(fe)=>{if(fe.path==="bun"||fe.path.startsWith("bun:")||fe.path.startsWith("node:")||cu.has(fe.path))throw Error(`Server-only import ${JSON.stringify(fe.path)} is not available in a browser component (${fe.importer})`);let ze=q.get(fe.path);if(!fe.importer&&ze)return{path:tt.join(tt.dirname(ze.sourcePath),`.stx-library-${ze.tag}.ts`)};if(fe.path===ce)return{path:pe};if(fe.path===le||fe.importer===pe&&fe.path==="./signals.js")return{path:Re};if(/^(?:@stacksjs\/stx|stx)\/signals-api(?:\.[jt]s)?$/.test(fe.path))return{path:V}}),ve.onLoad({filter:/\.ts$/},(fe)=>{if(fe.path===pe)return{contents:Bo(j),loader:"ts"};if(fe.path===Re)return{contents:`export * from ${JSON.stringify(V)};`,loader:"ts"};let ze=se.get(fe.path);if(ze)return{contents:rr(ze,ce),loader:"ts"}})}}]}).catch((ve)=>{let fe=(ve instanceof AggregateError?ve.errors:[ve]).map(String).join(`
1089
+ `);throw Error(`Failed to bundle browser component imports
1090
+ ${fe}`)});if(!Ae.success)throw Error(`Failed to bundle component imports
1091
+ ${Ae.logs.map(String).join(`
1092
+ `)}`);for(let ve of Ae.outputs)await S(tt.relative(r,ve.path),new Uint8Array(await ve.arrayBuffer()))}let W=l.map((H)=>`export { ${H.name}, default as ${H.name}Element } from './${H.tag}.js';`).join(`
1093
+ `);if(await S("index.js",W),await S("ssr.js",Ru(l)),e.declarations!==!1)await S("index.d.ts",l.map((H)=>`export * from './${H.tag}.js'`).join(`
1094
+ `)),await S("custom-elements.d.ts",ku(l)),await S("ssr.d.ts",`${l.map((H)=>`export declare const render${H.name}: (props?: ${H.name}Props, slots?: Record<string, string>) => string`).join(`
1095
+ `)}
1096
+ export declare function renderComponent(tag: string, props?: Record<string, unknown>, slots?: Record<string, string>): string
1097
+ ${l.map((H)=>`import type { ${H.name}Props } from './${H.tag}.js'`).join(`
1098
+ `)}`);let D;if(e.manifest!==!1)D=await S("custom-elements.json",JSON.stringify(Cu(l),null,2));let G;if(e.css!==!1){let H=l.filter((q)=>!q.shadowMode&&q.styles).map(Wo).join(`
1099
+
1100
+ `);if(H)G=await S("bundle.css",e.minify?Fo(H):H)}let X;if(e.bundle!==!1){X=tt.join(r,"bundle.js");let H;try{H=await Bun.build({entrypoints:[tt.join(r,"index.js")],outdir:r,naming:"bundle.js",target:"browser",format:"esm",minify:e.minify??!0,sourcemap:e.sourcemap||"none"})}catch(q){let se=q instanceof AggregateError?q.errors:[q],ce=se.map((le)=>String(le).trim()).filter(Boolean).join(`
1101
+ `);throw AggregateError(se,`Failed to bundle component library${ce?`
1102
+ ${ce}`:""}`)}if(!H.success){let q=H.logs.map((se)=>String(se).trim()).filter(Boolean).join(`
1103
+ `);throw AggregateError(H.logs,`Failed to bundle component library${q?`
1104
+ ${q}`:""}`)}if(v.push(X),e.sourcemap==="external")v.push(`${X}.map`)}let ee=await Promise.all(v.map(async(H)=>(await No(H)).size));return{components:l.map((H)=>({name:H.name,tag:H.tag,source:H.sourcePath,module:tt.join(r,`${H.tag}.js`),styles:H.styles,shadowMode:H.shadowMode})),files:v,manifest:D,bundle:X,cssBundle:G,totalBytes:ee.reduce((H,q)=>H+q,0)}}var Au=new Set(yt);function qt(e){let n=Jt(e),r=n.find((I)=>I.name==="InheritedContext");if(!r)return;let i=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(t(r.text).trim()),a=t(e),l=y(a).depths,u=[...a.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((I)=>l[I.index]===0)?.index??0,f=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),v=t(f),S=y(v).depths,j=[...v.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((I)=>S[I.index]===0).map((I)=>I[1]);return{keys:i?j:[],types:n.map((I)=>I.text).join(`
1105
+ `),offset:Math.max(0,u),...!i?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function Tu(e){let n=[],r=t(e);for(let i of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(i[1]||r.slice(i.index,i.index+6)!=="import")continue;let a=i[2].trim(),l=["stx","@stacksjs/stx"].includes(i[4]);if(/^[A-Za-z_$][\w$]*$/.test(a)){n.push(a);continue}if(!a.startsWith("{")||!a.endsWith("}"))continue;for(let u of a.slice(1,-1).split(",")){if(/^\s*type\s+/.test(u))continue;let[f,v=f]=u.trim().split(/\s+as\s+/);if(v&&!(l&&Au.has(f)))n.push(v)}}return n}function ro(e){let n=qt(e);if(!n||n.unsupported)return"";let r=new Set(ye(e));return n.keys.filter((i)=>!r.has(i)).map((i)=>`declare const ${i}: InheritedContext[${JSON.stringify(i)}];`).join(`
1106
+ `)}function Zo(e,n){let r=[bs],i=[],a=new Map,l=xt.resolve(n.filePath),u=l.split(xt.sep).lastIndexOf("views"),f=u>=0?l.split(xt.sep).slice(0,u).join(xt.sep):xt.dirname(l),v=xt.resolve(n.partialsDir||xt.join(f,"partials")),S=xt.resolve(n.layoutsDir||xt.join(f,"views/layouts"));if([v,S].some((G)=>l===G||l.startsWith(G+xt.sep)))return{declarations:"",checks:i,dependencies:a};let j=(G)=>n.readTemplate?.(G)??(Ko.existsSync(G)?Ko.readFileSync(G,"utf8"):void 0),I=0,V=!1,O=[];function W(G,X){let ee=e.slice(0,G).split(`
1107
+ `).length,H=G-e.lastIndexOf(`
1108
+ `,G-1),q={code:e.slice(G,e.indexOf(`
1109
+ `,G)<0?e.length:e.indexOf(`
1110
+ `,G)),line:ee,column:H,kind:"directive",offset:G,anchor:!0};i.push({expression:q,statement:{text:`;${X}`,prefixLength:1}})}function D(G,X,ee,H,q,se){let ce=`__StxInherited${I++}`;while((e+G+[...a.values()].join("")).includes(ce))ce+="_";let le=_e(G).filter((Fe)=>Fe.kind==="server").map((Fe)=>Fe.code).join(`
1111
+ `),pe=`${ce}ParentValue`,Re=`${ce}ParentType`;r.push(`type ${Re} = ${ee};`);let Ae=lr(Es(le,xt.dirname(X)),ce);r.push(...Ae.imports);let ve=qt(le);if(ve&&q!==void 0){V=!0;let Fe=Ae.imports.length?Ae.aliases.join(`
1112
+ `):"",at=ys(`${Fe}
1113
+ ${ve.types}
1114
+ const __contract = defineProps<InheritedContext>();`,`${ce}Contract`);r.push(at.declarations),r.push(`declare const ${ce}Input: ${Re};`),W(q,ve.unsupported?`({})[${JSON.stringify(ve.unsupported)}];`:`${ce}Input satisfies ${at.props};`)}let fe=[...new Set([...ye(le),...Tu(le)])],ze=[...new Set([...H,...ve?.keys||[]])].filter((Fe)=>!fe.includes(Fe)),We=ve?`${Re} & ${ce}Contract.__StxProps`:Re,nt=An(Ae.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),st=[],Rt=pn(G),_t=/@(include|extends|layout)\s*\(/g,it;while(it=_t.exec(Rt)){let Fe=Wn(Rt,_t.lastIndex-1);if(!Fe)continue;_t.lastIndex=Fe.end;let at=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(Fe.expression);if(!at){O.push({offset:q??it.index,message:`Inherited context cannot be checked across dynamic @${it[1]}`});continue}let ct=at[2],Me=it[1];if(Me!=="include"&&at[3])O.push({offset:q??it.index,message:`Inherited context cannot be checked for unsupported @${Me} data arguments`});let Pt=Me==="include"?v:S,Mt=xt.resolve(ct.startsWith(".")?xt.dirname(X):Pt,ct.endsWith(".stx")?ct:ct+".stx");if(j(Mt)===void 0){O.push({offset:q??it.index,message:`Inherited context target cannot be resolved: ${ct}`});continue}st.push({name:`edge${st.length}`,target:Mt,kind:Me,args:Me==="include"?at[3]||"{}":"{}",offset:q??it.index})}let wt=`{ ...${pe}${fe.length?", "+fe.join(", "):""} }`;r.push(`namespace ${ce} {
1115
+ ${Ae.aliases.join(`
1116
+ `)}
1117
+ export async function read(${pe}: ${q===void 0?"{}":We}) {
1118
+ ${ze.length?`const { ${ze.join(", ")} } = ${pe};`:""}
1119
+ ${nt}
1120
+ return { context: ${wt}${st.map((Fe)=>`, ${Fe.name}: { ...${wt}, ...(${Fe.args}) }`).join("")} };
1121
+ }
1122
+ }`);for(let Fe of st){if(se.includes(Fe.target)||se.length>=32){O.push({offset:Fe.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let at=j(Fe.target);a.set(Fe.target,at),D(at,Fe.target,`Awaited<ReturnType<typeof ${ce}.read>>[${JSON.stringify(Fe.name)}]`,[...new Set([...H,...fe])],Fe.offset,[...se,Fe.target])}return ce}if(D(e,l,"{}",[],void 0,[l]),V||n.contractsKnown)for(let G of O)W(G.offset,`({})[${JSON.stringify(G.message)}];`);return{declarations:V?r.join(`
1123
+ `):"",checks:i,dependencies:a}}function so(e,n){let r=Zt(e),i=or(e);if(!i)return;let a;try{a=ar(e,"component")}catch(q){let se=i.open,ce=q instanceof Error?q.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(ce)}];`,line:e.slice(0,se).split(`
1124
+ `).length,column:se-e.lastIndexOf(`
1125
+ `,se-1),origin:"component"}],project:(le)=>({code:le,columns:new Map})}}let l=Q(r).filter((q)=>{let se=N(q.attrs);return Et(se)&&se.has("client")&&!se.has("server")&&!se.has("component")&&!se.has("stx:component")&&!se.has("src")}),u=l.map((q)=>e.slice(q.bodyStart,q.bodyEnd)).join(`
1126
+ `),f=Ss(u,n),v=Jt(u).some((q)=>q.name==="ComponentState")||ks(u).includes("ComponentState"),S=Object.entries(a.properties||a.props||{}).map(([q,se])=>`${JSON.stringify(q)}: ${un(se)}`).join("; "),j=[...new Set(f.map((q)=>q.name))],I=[`interface __StxMetadataProperties { ${S} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",v?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",v?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",v?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",v?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${j.map((q)=>JSON.stringify(q)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',v?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...j.map((q)=>`${JSON.stringify(q)}: typeof ${q};`),"}"].filter(Boolean).join(`
1127
+ `),V=-1;for(let q of l){let se=q.bodyStart,ce=e.slice(se,q.bodyEnd),le=t(ce),pe=y(le).depths,Re=[...le.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((Ae)=>pe[Ae.index]===0)??(ks(ce).includes("ComponentState")?/\bComponentState\b/.exec(le):void 0);if(Re){V=se+Re.index;break}}let O=v&&V>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,V).split(`
1128
+ `).length,column:V-e.lastIndexOf(`
1129
+ `,V-1)}]:[],{start:W,code:D}=i,G=t(D),X=y(G).depths,ee=new Map,H=!1;for(let q of D.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let se=JSON.parse(q[0].slice(0,q[0].lastIndexOf(":")).trim());if(X[q.index]===1&&["properties","props"].includes(se)){H=!0;continue}if(H&&X[q.index]===1)H=!1;if(H&&X[q.index]===2&&!ee.has(se))ee.set(se,W+q.index)}for(let[q,se]of Object.entries(a.properties||a.props||{})){let ce=ee.get(q)??W,le=e.slice(0,ce).split(`
1130
+ `).length,pe=ce-e.lastIndexOf(`
1131
+ `,ce-1);if(!se||typeof se!=="object"||!["string","number","boolean","object","array"].includes(se.type))O.push({text:`({})[${JSON.stringify(`Property ${q} must declare string, number, boolean, object or array`)}];`,line:le,column:pe,origin:"component"});if(se&&se.default!==void 0)O.push({text:`const __stxDefault${O.length}: ${un(se)} = ${JSON.stringify(se.default)};`,line:le,column:pe,origin:"component"})}return{declarations:I,checks:O,project(q){let se=new Map,ce=[],le=0;for(let pe of Ss(q,n)){if(/^\s*this\s*:/.test(pe.parameters))continue;let Re=pe.parameterOffset,Ae=`this: __StxNativeComponent${pe.parameters.trim()?", ":""}`;ce.push(q.slice(le,Re),Ae);let ve=q.slice(0,Re).split(`
1132
+ `).length,fe=Re-q.lastIndexOf(`
1133
+ `,Re-1),ze=se.get(ve)||[],We=ze.at(-1),nt=fe+(We?We.generatedEnd-We.sourceEnd:0);ze.push({sourceStart:fe,sourceEnd:fe,generatedStart:nt,generatedEnd:nt+Ae.length}),se.set(ve,ze),le=Re}return ce.push(q.slice(le)),{code:ce.join(""),columns:se}}}}function Jo(e){let n=[],r=[],i=/@foreach\s*\(|@endforeach\b/g,a;while(a=i.exec(e)){if(a[0].startsWith("@endforeach")){let v=r.pop();if(v)v.end=a.index,n.push(v);continue}let l=Wn(e,i.lastIndex-1);if(!l)continue;let u=cr(l.expression),f=l.end;if(u)r.push({start:f,end:e.length,iterable:u.iterable,binding:u.key?`${u.value}, ${u.key}`:u.value});i.lastIndex=f}return n.sort((l,u)=>l.start-u.start)}function ju(e){let n=(r)=>r.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function _e(e){let n=[],r=ju(e);for(let i of Q(r)){let a=i.attrs.trim(),l=N(a),{bodyStart:u,bodyEnd:f}=i,v=e.slice(u,f);if(l.has("src")||l.has("component")||l.has("stx:component"))continue;if(!Et(l))continue;let S=l.has("server")?"server":l.has("client")?"client":"plain",j=Iu(e,u);n.push({kind:S,code:v,startLine:j,startColumn:Ou(e,u),offset:u,attrs:a})}return n}function Iu(e,n){let r=1;for(let i=0;i<n&&i<e.length;i++)if(e.charCodeAt(i)===10)r++;return r}function Ou(e,n){let r=e.lastIndexOf(`
1134
+ `,n-1)+1;return n-r+1}function pn(e){let n=e.split(""),r=(a,l)=>{for(let u=a;u<l&&u<n.length;u++)if(n[u]!==`
1135
+ `)n[u]=" "},i=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let a of i){a.lastIndex=0;let l;while((l=a.exec(e))!==null)r(l.index,l.index+l[0].length)}return n.join("")}function ra(e){let n=0,r="";for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r="";continue}if(a==='"'||a==="'"||a==="`"){r=a;continue}if(a==="("||a==="["||a==="{"){n++;continue}if(a===")"||a==="]"||a==="}"){n--;continue}if(a==="|"&&n===0){if(e[i+1]==="|"){i++;continue}if(e[i-1]==="|")continue;return e.slice(0,i)}}return e}var ia=new Set([":for","x-for","v-for"]),Cs=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,pr="__stx_interpolated",qo="__StxElement",oa="__StxTemplateValue",Pu=`type ${oa}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function Xo(e){return e.replace(/\{\{[\s\S]*?\}\}/g,pr).replace(/\{!![\s\S]*?!!\}/g,pr)}function Mu(e,n,r){let i=0;for(let a=n;a<e.length;a++){let l=e[a];if(l==="{"){i++;continue}if(l!=="}"&&l!=="!")continue;if(e.startsWith(r,a)&&i===0)return a;if(l==="}"&&i>0)i--}return-1}function ji(e,n,r="0"){let i=`__stxScript${r}`;while((e+n).includes(i))i+="_";let a=new Map,l=[],u=[],f=t(e),v=dr(e),S=[],j=0;for(let D=0;D<f.length;D++){let G=f.startsWith("{{",D);if(!G&&!f.startsWith("{!!",D))continue;let X=G?2:3,ee=G?"}}":"!!}",H=Mu(f,D+X,ee);if(H<0)continue;let q=D,se=e.slice(q,H+ee.length),ce=se.slice(X,-ee.length);D=H+ee.length-1;let le=u.length,pe=Yt(v,q),Re=Yt(v,q+(G?2:3));u.push({code:ra(ce),...Re});let Ae=`${i}_${le}`,ve=se.split(`
1136
+ `),fe=ve[0].length;ve[0]=Ae+" ".repeat(Math.max(0,fe-Ae.length));for(let st=1;st<ve.length;st++)ve[st]=ve[st].replace(/[^\r]/g," ");let ze=a.get(pe.line)??[],We=ze.at(-1),nt=pe.column+(We?We.generatedEnd-We.sourceEnd:0);ze.push({sourceStart:pe.column,sourceEnd:pe.column+fe,generatedStart:nt,generatedEnd:nt+ve[0].length}),a.set(pe.line,ze),S.push(e.slice(j,q),ve.join(`
1137
+ `)),j=q+se.length}S.push(e.slice(j));let I=S.join("");if(!u.length)return{code:I,columns:a,declarations:l};let{imports:V,aliases:O,body:W}=lr(n,i);for(let D of V)l.push({text:D});l.push({text:`namespace ${i}Scope {
1138
+ ${O.join(`
1139
+ `)}
1140
+ export async function read() {
1141
+ ${An(W).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
1142
+ return {`});for(let[D,G]of u.entries())l.push({text:`value${D}: (`}),l.push({text:G.code,origin:{line:G.line,column:G.column}}),l.push({text:"),"});l.push({text:`}
1143
+ }
1144
+ }`});for(let D=0;D<u.length;D++)l.push({text:`declare var ${i}_${D}: Awaited<ReturnType<typeof ${i}Scope.read>>['value${D}']`});return{code:I,columns:a,declarations:l}}function lr(e,n){let r=[],{imports:i,body:a}=la(e),l=[],u=0;for(let f of i.split(/\n(?=import\b)/)){if(!f.trim())continue;let v=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(f);if(!v){r.push(f);continue}let S=`${n}Module${u++}`;r.push(`import * as ${S} from ${v[2]}`);let j=v[1],I=/\{([\s\S]*?)\}/.exec(j);for(let D of I?.[1].split(",")??[]){let[G,X=G]=D.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(G==="default")l.push(`const ${X} = ${S}.default; type ${X} = import(${v[2]}).default`);else if(G)l.push(`import ${X} = ${S}.${G}`)}let V=j.replace(/\{[\s\S]*?\}/,""),O=/\*\s+as\s+(\w+)/.exec(V);if(O)l.push(`import ${O[1]} = ${S}`);let W=/^\s*([\w$]+)/.exec(V)?.[1];if(W)l.push(`const ${W} = ${S}.default; type ${W} = import(${v[2]}).default`)}return{imports:r,aliases:l,body:a}}function ur(e,n){let r=0;for(let i of e){if(n<i.generatedStart)break;if(n<i.generatedEnd)return i.sourceStart+Math.min(n-i.generatedStart,i.sourceEnd-i.sourceStart);r=i.sourceEnd-i.generatedEnd}return n+r}var Du=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Nu=new RegExp(String.raw`^[ \t]*@(?:${Du.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function An(e){return e.replace(Nu,(n)=>n.replace(/[^\n]/g," "))}var Go=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function oo(e){let n=pn(e),r=[],i=dr(n),a=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,l;while((l=a.exec(n))!==null){if(l[1]||l[3])continue;let v=l[2]??l[4]??"",S=l[2]!==void 0?2:3,j=ra(v);if(!j.trim())continue;let I=l.index+S+(j.length-j.trimStart().length);r.push({code:j.trim(),...Yt(i,I),offset:I,kind:"interpolation"})}let u=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((l=u.exec(n))!==null){let f=l.index+l[0].length-1,v=0,S=f;for(;S<n.length;S++){let O=n[S];if(O==="(")v++;else if(O===")"){if(v--,v===0)break}}if(v!==0)continue;let j=n.slice(f+1,S),I=j.trim();if(u.lastIndex=S+1,!I)continue;let V=f+1+(j.length-j.trimStart().length);r.push({code:I,...Yt(i,V),offset:l.index,kind:"condition"})}Cs.lastIndex=0;while((l=Cs.exec(n))!==null){let f=l[1],v=l[3]??"",S=f.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Go.has(S)||Go.has(f))continue;if(!v.trim())continue;let j=l.index+l[0].indexOf(l[2],l[0].indexOf(f)+f.length)+1;if(ia.has(S)){let V=v.match(/\s+(?:in|of)\s+/);if(!V||V.index===void 0)continue;let O=v.slice(V.index+V[0].length),W=V.index+V[0].length+(O.length-O.trimStart().length);r.push({code:Xo(O.trim()),...Yt(i,j+W),offset:j+W,kind:"directive",attribute:S});continue}let I=v.length-v.trimStart().length;r.push({code:Xo(v.trim()),...Yt(i,j+I),offset:j+I,kind:"directive",attribute:S})}return r.sort((f,v)=>f.line-v.line||f.column-v.column),r}var Lu=2000;function zu(e,n){let r=0,i=Math.min(e.length,n+Lu);for(let a=n;a<i;a++){let l=e[a];if(l==="(")r++;else if(l===")"){if(r--,r===0)return e.slice(n+1,a)}}return null}function Bu(e){let n=new Map,r=(f,v)=>{let S=f.split(/[,[\]{}()\s]+/).filter(Boolean);for(let j of S){let I=j.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(I))continue;let V=S.length===1?v:void 0,O=n.get(I);if(!O)n.set(I,{name:I,iterable:V});else if(O.iterable!==V)O.iterable=void 0}},i=/^\$?[A-Z_$][\w$]*$/i,a=(f)=>{let v=f.trim();return i.test(v)?v:void 0};for(let f of e.matchAll(/@for(?:each|else)\s*\(/g)){let v=zu(e,f.index+f[0].length-1);if(v===null)continue;let S=Wt(v);if(!S)continue;r(S.itemVar.replace(/=>/g," "),a(S.arrayExpr))}for(let f of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(f[1],f[2]==="of"?a(f[3]):void 0);for(let f of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(f[1]);let l=pn(e);Cs.lastIndex=0;let u;while((u=Cs.exec(l))!==null){let f=u[1].replace(/\..*$/,"");if(!ia.has(f))continue;let v=u[3].match(/\s+(?:in|of)\s+/);if(!v||v.index===void 0)continue;r(u[3].slice(0,v.index),a(u[3].slice(v.index+v[0].length)))}for(let f of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let v of f[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(v[1]);return[...n.values()].sort((f,v)=>f.name.localeCompare(v.name))}function ye(e){return Wl(e)}var fr=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],Wu={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string",$native:"declare var $native: boolean"};function pl(e=new Set){return[...fr.filter((n)=>!e.has(n)).map((n)=>`declare var ${n}: any`),...Object.entries(Wu).filter(([n])=>!e.has(n)).map(([,n])=>n)].join(`
1145
+ `)}function fl(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function ca(e){let n=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,r,i=!1,a=new Set,l=t(e);while((r=n.exec(l))!==null){i=!0;for(let u of Fu(r[1])){let f=u.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(f))a.add(f)}}return i?[...a]:null}function Fu(e){let n=[],r=0,i="";for(let a of e){if(a===","&&r===0){n.push(i),i="";continue}if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;i+=a}return n.push(i),n.filter((a)=>a.trim().length>0)}function la(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],i=e.replace(n,(a)=>(r.push(a.trim()),a.split(`
1146
+ `).map(()=>"").join(`
1147
+ `)));return{imports:r.join(`
1148
+ `),body:i}}function Jt(e){let n=t(e),r=Array(n.length),i=0;for(let f=0;f<n.length;f++){let v=n[f];if(v==="}"||v===")"||v==="]")i=Math.max(0,i-1);if(r[f]=i,v==="{"||v==="("||v==="[")i++}let a=[],l=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,u;while((u=l.exec(n))!==null){if(r[u.index]!==0)continue;let f=u[1],v=u[2],S;if(f==="interface"){let j=n.indexOf("{",u.index);if(j===-1)continue;let I=0;S=-1;for(let V=j;V<n.length;V++)if(n[V]==="{")I++;else if(n[V]==="}"&&--I===0){S=V+1;break}if(S===-1)continue}else{let j=0;S=n.length;for(let I=n.indexOf("=",u.index)+1;I<n.length;I++){let V=n[I];if(V==="{"||V==="["||V==="("||V==="<")j++;else if(V==="}"||V==="]"||V===")"||V===">")j--;else if(j<=0&&(V===";"||V===`
1149
+ `&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,I-40),I)))){S=V===";"?I+1:I;break}}}a.push({name:v,text:e.slice(u.index,S).replace(/^[ \t]*export[ \t]+/,"")}),l.lastIndex=S}return a}function Vu(e){let n=t(e),r=[],i=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,a,l=0,u=0;while((a=i.exec(n))!==null){for(;u<a.index;u++){let S=n[u];if(S==="{"||S==="("||S==="[")l++;else if(S==="}"||S===")"||S==="]")l=Math.max(0,l-1)}if(l!==0)continue;let f=0,v=n.length;for(let S=a.index+a[0].length;S<n.length;S++){let j=n[S];if(j==="{"||j==="("||j==="[")f++;else if(j==="}"||j===")"||j==="]")f--;else if(f<=0&&(j===";"||j===`
1150
+ `)){v=j===";"?S+1:S;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(a.index,v)))r.push(e.slice(a.index,v).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function Bi(e){let n=e.filter((a)=>a.kind==="server").map((a)=>a.code).join(`
1151
+ `);if(/\bdefineProps\s*(?:<|\()/.test(t(n)))return n;let r=ua(n),i=e.filter((a)=>a.kind!=="server").flatMap((a)=>{let l=Vu(a.code);if(!l.length)return[];return[...Jt(a.code).filter((u)=>!r.has(u.name)).map((u)=>u.text),...l]});return[n,...i].filter(Boolean).join(`
1152
+ `)}function ua(e){return new Set(Jt(e).map((n)=>n.name))}function gl(e,n=""){let r=ca(e),i=ua(n),a=Jt(e).filter((S)=>!i.has(S.name)).map((S)=>S.text);if(!r){let S=ye(e).filter((j)=>!Vt(n,j));if(S.length===0&&a.length===0)return"";return["",`// ${Ku}`,...a,...S.map((j)=>`declare var ${j}: any`)].join(`
1153
+ `)}if(r.length===0)return a.length>0?["",`// ${Qo}`,...a].join(`
1154
+ `):"";let{imports:l,body:u}=la(e),f=u.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),v=["",`// ${Qo}`];if(l)v.push(l);return v.push(...a),v.push(`async function ${ea}() {`,f,` return { ${r.join(", ")} }`,"}",`type ${ta} = Awaited<ReturnType<typeof ${ea}>>`,...r.map((S)=>`declare var ${S}: ${ta}[${JSON.stringify(S)}]`)),v.join(`
1155
+ `)}function pa(e){let n=t(e),r=n.split(""),i=[],a=0,l=0;for(let f=0;f<r.length;f++){let v=r[f];if(v===`
1156
+ `)l=f+1;if(v==="{"||v==="("||v==="["){if(a===0&&v!=="("&&Uu.test(n.slice(l,f))){let S=fa(n,f);if(S!==-1)i.push(...da(n.slice(f,S+1)))}a++;continue}if(v==="}"||v===")"||v==="]"){a=Math.max(0,a-1);continue}if(a>0&&v!==`
1157
+ `)r[f]=" "}let u=ye(r.join(""));return i.length===0?u:[...new Set([...u,...i])].sort()}var Uu=/^\s*(?:export\s+)?(?:const|let|var)\s*$/;function fa(e,n){let r=0;for(let i=n;i<e.length;i++){let a=e[i];if(a==="{"||a==="("||a==="[")r++;else if(a==="}"||a===")"||a==="]")r--;if(r===0)return i}return-1}function Hu(e){let n=[],r=0,i=0;for(let a=0;a<e.length;a++){let l=e[a];if(l==="{"||l==="("||l==="[")r++;else if(l==="}"||l===")"||l==="]")r--;else if(l===","&&r===0)n.push(e.slice(i,a)),i=a+1}return n.push(e.slice(i)),n}function Yo(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="{"||i==="("||i==="[")n++;else if(i==="}"||i===")"||i==="]")n--;else if(n===0&&(i===":"||i==="="))return{index:r,char:i}}return null}function da(e){let n=[],r=(a)=>{let l=a.trim().replace(/^\.\.\./,"").trim();if(l.startsWith("{")||l.startsWith("[")){let f=fa(l,0);if(f!==-1)n.push(...da(l.slice(0,f+1)));return}let u=Yo(l);if(u)l=l.slice(0,u.index).trim();if(/^[A-Z_$][\w$]*$/i.test(l))n.push(l)},i=e.slice(1,-1);for(let a of Hu(i)){if(!a.trim())continue;if(e[0]==="["){r(a);continue}let l=Yo(a);r(l?.char===":"?a.slice(l.index+1):a)}return n}function ml(e,n){if(ca(e)!==null)return[];let r=pa(e),i=Be(n,new Set(r)),a=new Set(C);return r.filter((l)=>{if(a.has(l))return!1;if(Vt(n,l))return!1;return i.has(l)})}var Qo="stx: types for the declared client payload (#1868)",Ku="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",ea="__stxServerScope",ta="__StxClientPayload";var na=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];var Zu=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Ju(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let i of e){let a=t(i),{depths:l,balanced:u}=y(a);if(!u)continue;let f=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let v of a.matchAll(f)){let S=v.index??0;if(l[S+v[1].length]!==0)continue;let j=v[2],I=S+v[0].length-v[3].length,V=i.slice(I,S+v[0].length).trim().replace(/;$/,"").trim(),O=v[3],W=r.test(O)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(O)&&!/[,+\-*/%&|?:=]$/.test(V)&&y(O).balanced;n.set(j,n.has(j)||!W?null:V)}}return new Map([...n].filter((i)=>i[1]!==null))}function ga(e,n,r=0,i=new Set){if(n.size===0||r>=5)return e;let a=t(e),l="",u=0;for(let f of a.matchAll(/[A-Za-z_$][\w$]*/g)){let v=f.index??0,S=f[0],j=n.get(S);if(!j||i.has(S))continue;let I=a.slice(0,v).trimEnd(),V=a.slice(v+S.length).trimStart();if(I.endsWith(".")||/^:(?!:)/.test(V)&&/[{,]$/.test(I))continue;if(v>0&&/[\w$]/.test(a[v-1]))continue;l+=`${e.slice(u,v)}(${ga(j,n,r+1,new Set([...i,S]))})`,u=v+S.length}return l+e.slice(u)}function qu(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,i=[],a;while((a=r.exec(e))!==null){if(a.index>n)break;let l=a[1];if(a.index===n){if(l==="elseif"){let f=i[i.length-1];if(f?.current)f.seen.push(f.current);if(f)f.current=null}break}if(l==="endif"||l==="endunless"){i.pop();continue}let u="";if(a[2]==="("){let f=0,v=a.index+a[0].length-1,S=v+1;for(;v<e.length;v++){let j=e[v];if(j==="(")f++;else if(j===")"){if(f--,f===0)break}}u=e.slice(S,v).trim(),r.lastIndex=v+1}if(l==="if")i.push({seen:[],current:u});else if(l==="unless")i.push({seen:[],current:`!(${u})`});else if(l==="elseif"||l==="else"){let f=i[i.length-1];if(!f)continue;if(f.current)f.seen.push(f.current);f.current=l==="elseif"?u:null}}return i.flatMap((l)=>[...l.seen.map((u)=>`!(${u})`),...l.current?[l.current]:[]]).filter(Boolean)}function Xu(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(Zu.test(n))return null;let i=";(($event: any): void => { ";return{text:`${i}${n} });`,prefixLength:i.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var Gu=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Es(e,n){return io(e,n).code}function io(e,n){let r=new Map;if(!n)return{code:e,columns:r};let i=dr(e),a=[],l=0;for(let u of e.matchAll(Gu)){let f=u.index,[v,S,j,I]=u,V=sa.resolve(n,I).replace(/\\/g,"/"),O=`${S}${j}${V}${j}`;if(a.push(e.slice(l,f),O),l=f+v.length,v.includes(`
1158
+ `))continue;let W=Yt(i,f),D=r.get(W.line)??[],G=D.at(-1),X=W.column+(G?G.generatedEnd-G.sourceEnd:0);D.push({sourceStart:W.column,sourceEnd:W.column+v.length,generatedStart:X,generatedEnd:X+O.length}),r.set(W.line,D)}return a.push(e.slice(l)),{code:a.join(""),columns:r}}function Yu(e,n,r){let i=ur(e.importColumns?.get(n)??[],r);return ur(e.scriptColumns?.get(n)??[],ur(e.componentColumns?.get(n)??[],i))}function Fi(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function ks(e){let n=new Set,r=t(e);for(let i of r.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let a=i[1],l=/\{([^}]*)\}/.exec(a);for(let S of l?.[1].split(",")??[]){let j=S.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(j&&/^[A-Z_$][\w$]*$/i.test(j))n.add(j)}let u=a.replace(/\{[^}]*\}/,""),f=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(u);if(f)n.add(f[1]);let v=/^\s*([A-Z_$][\w$]*)/i.exec(u);if(v&&v[1]!=="type")n.add(v[1])}return[...n].sort()}function zi(e,n={}){let r=_e(e),i=n.scriptKinds?r.filter((q)=>n.scriptKinds.includes(q.kind)):r,a=so(e,n.componentMethodValidator),l=n.filePath&&n.templateExpressions!==!1?Zo(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,u=new Map,f=e.split(`
1159
+ `),v=Array.from({length:f.length},()=>""),S=new Map,j=new Map,I=new Map,V=[],O=Bi(r),W=n.filePath&&n.templateExpressions!==!1?Oo(e,pn(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(q,se)=>_e(q).map((ce)=>Es(ce.code,sa.dirname(se))).join(`
1160
+ `)}):void 0,D=new Set,G=[];for(let[q,se]of i.entries()){let ce=ji(Fi(se)+se.code,O,String(q));for(let[ve,fe]of ce.columns)j.set(se.startLine+ve-1,fe);for(let ve of ce.declarations)V.push({text:Es(ve.text,n.originDir??""),origin:ve.origin?{...ve.origin,line:ve.origin.line+se.startLine-1}:void 0});let le=se.kind==="client"&&a?a.project(ce.code):void 0;for(let[ve,fe]of le?.columns??[])u.set(se.startLine+ve-1,fe);let pe=An(le?.code??ce.code),Re=io(pe,n.originDir??"");for(let[ve,fe]of Re.columns)I.set(se.startLine+ve-1,fe);let Ae=Re.code.split(`
1161
+ `);Ae.forEach((ve,fe)=>{let ze=se.startLine-1+fe;if(ze<v.length)v[ze]=ve,D.add(ze)}),G.push(se.startLine-1+Ae.length-1)}for(let q of G){let se=v[q]?.trim()===""?q:q+1;if(se<v.length&&v[se].trim()===""&&(se===q||!D.has(se)))v[se]=";"}let X=(q,se)=>{for(let[ce,le]of q.split(`
1162
+ `).entries())if(v.push(le),se)S.set(v.length,ce===0?se:{...se,line:se.line+ce,column:1,prefixLength:0})},ee=ro(i.filter((q)=>q.kind==="server").map((q)=>q.code).join(`
1163
+ `));if(ee)X(ee);for(let q of i.filter((se)=>se.kind==="server")){let se=qt(q.code);if(!se?.unsupported)continue;let ce=q.code.slice(0,se.offset),le=q.startLine+ce.split(`
1164
+ `).length-1,pe=se.offset-q.code.lastIndexOf(`
1165
+ `,se.offset-1)+(le===q.startLine?(q.startColumn??1)-1:0);X(`;({})[${JSON.stringify(se.unsupported)}];`,{line:le,column:pe,anchor:!0})}if(l?.declarations)X(l.declarations);for(let q of V)X(q.text,q.origin);if(a){if(X(a.declarations),n.nativeChecks!==!1)for(let q of a.checks)X(q.text,{line:q.line,column:q.column,diagnosticOrigin:q.origin,anchor:!0})}if(n.globals!==!1){X("");let q=new Set([...i.flatMap((pe)=>ye(pe.code)),...i.flatMap((pe)=>ks(pe.code))]),se=(pe)=>{if(!q.has(pe)&&!n.declaredGlobals?.includes(pe))X(`declare var ${pe}: any`)};if(n.runtimeGlobals!==!1){if(!q.has("window"))X("declare var window: any");for(let pe of C)se(pe)}let ce=[...new Set([...fr,...Oe,...na])].filter((pe)=>!n.declaredGlobals?.includes(pe)&&(n.runtimeGlobals!==!1||!C.includes(pe)));if(n.contextScope==="global"){X("declare global {");for(let pe of ce)X(` var ${pe}: any`);X("}")}else{for(let pe of fr)se(pe);for(let pe of Oe)se(pe);for(let pe of na)se(pe)}X(`declare var ${pr}: any`);let le=new Set(i.flatMap((pe)=>ye(pe.code)));X(`type ${qo}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let pe of a?[]:Bu(e)){if(le.has(pe.name))continue;let Re=pe.iterable&&le.has(pe.iterable)?`${qo}<typeof ${pe.iterable}>`:"any";X(`declare var ${pe.name}: ${Re}`)}}if(n.templateExpressions!==!1){if(W?.declarations)for(let se of W.declarations.split(`
1166
+ `))X(se);let q=oo(e).map((se)=>{let ce=W?.events.get(se.offset??-1);if(ce){se.anchor=!0;let le=se.code.trim(),pe=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(le),Re=pe?`void ((${pe[2]}) satisfies __StxAssignedValue<typeof ${pe[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(le)?`${le} satisfies (($event: ${ce}) => unknown)`:le,Ae=`;(($event: ${ce}): void => { `;return{expression:se,statement:{text:`${Ae}${Re} });`,prefixLength:Ae.length}}}return{expression:se,statement:Xu(se)}}).filter((se)=>se.statement!==null);if(q.push(...W?.checks||[],...l?.checks||[]),q.length>0){let se=pn(e),ce=hs(se),le=a?Jo(se):[];if(a)X("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let pe=Ju(i.map((fe)=>fe.code)),Ae=[...new Set(i.flatMap((fe)=>ye(fe.code)))].filter((fe)=>/^[A-Z_$][\w$]*$/i.test(fe)),ve=0;if(a)X("function __stxNativeTemplate(this: __StxNativeComponent) {");if(Ae.length>0){X(Pu);for(let fe of Ae)X(`function __StxRead_${fe}() { return ${fe} }`),X(`type __StxT_${fe} = ${oa}<ReturnType<typeof __StxRead_${fe}>>`);X(`;((${Ae.map((fe)=>`${fe}: __StxT_${fe}`).join(", ")}) => {`),ve=1}for(let{expression:fe,statement:ze}of q){let We=" ".repeat(ve),nt=fe.offset===void 0?[]:ce.filter((Me)=>fe.offset>=Me.start&&fe.offset<Me.end),st=fe.offset===void 0?[]:le.filter((Me)=>fe.offset>=Me.start&&fe.offset<Me.end),Rt=st.map((Me)=>`;__stxEach(${Me.iterable}, (${Me.binding}) => { `).join(""),_t=" });".repeat(st.length),it=Rt+nt.map((Me)=>`;((${Me.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),wt=" });".repeat(nt.length)+_t,Fe=fe.offset===void 0?[]:qu(se,fe.offset),at=Fe.length>0?`${Fe.map((Me)=>`if (${ga(Me,pe)}) `).join("")}{ `:"",ct=Fe.length>0?" }":"";X(We+it+at+ze.text+ct+wt,{line:fe.line,column:fe.column,expression:fe,prefixLength:ze.prefixLength+We.length+it.length+at.length,guardPrefixLength:We.length+it.length+at.length})}if(ve>0)X("});");if(a)X("}")}}let H=!1;if(n.reference&&v[0]!==void 0&&v[0].trim()==="")v[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,H=!0;return X("export {}"),{text:v.join(`
1167
+ `),lineMap:S,sourceLineCount:f.length,componentDependencies:new Map([...W?.dependencies??[],...l?.dependencies??[]]),referenced:H,scriptColumns:j,importColumns:I,componentColumns:u}}function dr(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function Yt(e,n){let r=0,i=e.length-1;while(r<i){let a=Math.ceil((r+i)/2);if(e[a]<=n)r=a;else i=a-1}return{line:r+1,column:n-e[r]+1}}function hl(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Hi(e,n,r){let i=e.lineMap.get(n);if(!i)return n<=e.sourceLineCount?{line:n,column:Yu(e,n,r)}:null;let a=i.anchor||i.expression?.anchor||i.diagnosticOrigin==="component"?0:Math.max(0,r-1-(i.prefixLength??0));return{line:i.line,column:i.column+a,expression:i.expression,diagnosticOrigin:i.diagnosticOrigin,inGuard:r<=(i.guardPrefixLength??0)}}function ao(e){let n=new Set;for(let r of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let i=r[1];if(!/\bclient\b/.test(i)||/\bserver\b/.test(i))continue;for(let a of pa(r[2]))n.add(a);for(let a of r[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])n.add(a[1]);if(a[3])n.add(a[3]);for(let l of(a[2]??"").split(",")){let u=l.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(u))n.add(u)}}}return n}var gr=k(256),Qu=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/(?:\bwindow\.)?localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables \u2014 or, where this must run before first paint and the runtime does not exist yet, the colorMode config for a light/dark theme, or @appearanceBootstrap when there is a second appearance axis"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}],ma=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function ep(e){let n=Array.from(e,(a)=>a===`
1168
+ `?`
1169
+ `:" "),r=0,i="";while(r<e.length){let a=e[r],l=e[r+1];if(i){if(a==="\\"){r+=2;continue}if(a===i)i="";r++;continue}if(a==='"'||a==="'"||a==="`"){i=a,r++;continue}if(a==="/"&&l==="/"){while(r<e.length&&e[r]!==`
1170
+ `)n[r]=e[r],r++;continue}if(a==="/"&&l==="*"){let u=e.indexOf("*/",r+2),f=u===-1?e.length:u+2;for(;r<f;r++)n[r]=e[r];continue}if(a==="{"&&l==="{"&&e.slice(r,r+4)==="{{--"){let u=e.indexOf("--}}",r+4),f=u===-1?e.length:u+4;for(;r<f;r++)n[r]=e[r];continue}r++}return n.join("")}function tp(e){let n=new Map,r=ep(e).split(`
1171
+ `),i=e.split(`
1172
+ `);return r.forEach((a,l)=>{ma.lastIndex=0;for(let u of a.matchAll(ma)){let f=u[1]==="-next-line",v=(i[l]??"").slice(0,u.index).trim(),S=f||v===""?l+2:l+1,I=(u[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),V=I.filter((W)=>/\w/.test(W));if(I.length>0&&V.length===0)continue;let O=n.get(S);if(O&&O.size===0)continue;if(V.length===0){n.set(S,new Set);continue}if(O)V.forEach((W)=>O.add(W));else n.set(S,new Set(V))}}),n}function np(e,n,r){let i=e.get(n);if(!i)return!1;if(i.size===0)return!0;return[...i].some((a)=>r.includes(a))}function Ke(e,n,r,i){let a=typeof r==="boolean"?{enabled:r,failOnViolation:r}:r??{enabled:!1};if(!a.enabled)return;let l=E(e,n,i,JSON.stringify(a)),u=gr.get(l);if(u!==void 0){if(u&&a.failOnViolation)throw new te(u,i??n);return}let f=a.allowPatterns??[],v=tp(e),S=[],j=t(e.replace(/\{\{--[\s\S]*?--\}\}/g,(W)=>W.replace(/[^\n]/g," ")));for(let{pattern:W,message:D,suggestion:G}of Qu){if(f.some((ee)=>/\w/.test(ee)&&D.includes(ee)))continue;W.lastIndex=0;let X=j.match(W);if(X&&X.length>0){let ee=j.split(`
1173
+ `),H=e.split(`
1174
+ `),q=[];if(ee.forEach((pe,Re)=>{if(W.lastIndex=0,W.test(pe)&&!np(v,Re+1,D))q.push(Re+1)}),q.length===0&&ee.some((pe)=>(W.lastIndex=0,W.test(pe))))continue;let se=q.length>0?` (script line${q.length>1?"s":""} ${q.join(", ")})`:"",ce=q.slice(0,3).map((pe)=>` ${pe} | ${(H[pe-1]??"").trim().slice(0,100)}`).join(`
1175
+ `),le=ce?`
1176
+ ${ce}`:"";S.push(` \u2717 ${D}${se}
1177
+ \u2192 ${G}${le}`)}}if(S.length===0){gr.set(l,"");return}let I=(W)=>{let D=`${process.cwd()}/`;return W.startsWith(D)?W.slice(D.length):W},O=`[STX] DOM API violation in ${i&&i!==n?`${I(i)} (composed into ${I(n)})`:I(n)}:
1178
+ ${S.join(`
1179
+ `)}
1180
+ Tip: prefer useRef(), navigate(), and composables for component code`;if(gr.set(l,O),console.warn(O),a.failOnViolation)throw new te(O,i??n)}var sp=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],rp=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],ip=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}];function Kg(e){let n=[],r=[];return op(e,n),ap(e,n,r),cp(e,r),lp(e,n),{valid:n.length===0,errors:n,warnings:r}}function op(e,n){let r=(e.match(/\{\{/g)||[]).length,i=(e.match(/\}\}/g)||[]).length;if(r!==i)n.push({type:"expression",message:`Unclosed expression brackets: found ${r} opening '{{' and ${i} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function ap(e,n,r){for(let i of sp){let a=new RegExp(`${i.open}(?:\\s|\\()`,"g"),l=new RegExp(i.close,"g"),u=(e.match(a)||[]).length,f=(e.match(l)||[]).length;if(i.altClose){let v=new RegExp(i.altClose,"g");f+=(e.match(v)||[]).length}if(u>f)n.push({type:"directive",message:`Unclosed @${i.name} directive: found ${u} opening and ${f} closing`,suggestion:`Add ${u-f} missing ${i.close} tag(s)`});else if(f>u)r.push({type:"directive",message:`Extra ${i.close} found: ${f-u} more closing than opening`,suggestion:`Check for orphaned ${i.close} tags`})}}function cp(e,n){for(let r of rp)if(r.pattern.test(e))n.push({type:"syntax",message:r.message,suggestion:r.suggestion})}function lp(e,n){for(let r of ip)if(r.pattern.test(e))n.push({type:"expression",message:`Security warning: ${r.message}`,suggestion:"Remove dangerous code from template expressions"})}function Xg(e,n){let r=e.slice(0,n).split(`
1181
+ `);return{line:r.length,column:r[r.length-1].length+1}}function Gg(e,n,r){let i=[];switch(e){case"if":case"elseif":case"unless":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a condition`,suggestion:`Use @${e}(condition)`});break;case"foreach":if(r.length===0||!r[0].includes(" as "))i.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(r.length===0)i.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(r.length===0)i.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(r.length===0)i.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a path`,suggestion:`Use @${e}('path/to/template')`});break}return i}function Jg(e){return/@[a-z]+/i.test(e)||/\{\{/.test(e)}function Yg(e){let n=e.matchAll(/@([a-z]+)/gi),r=new Set;for(let i of n){let a=i[1].toLowerCase();if(!a.startsWith("end"))r.add(a)}return Array.from(r)}function ha(e,n,r){let i=/^<script\b([^>]*)>/i.exec(e);if(!i||!/(?:^|\s)src\s*=/i.test(i[1]??""))return null;return P(i[0],n,r)+e.slice(i[0].length)}var Fn=new T(500),xr=new Map;function xa(e){try{let n=js.statSync(e);return`${n.size}:${n.mtimeMs}`}catch{return""}}var As=new T(1000),br=new Map,yr=new T(2000),_r=new T(500),ka=33554432,wr=ka;function up(e){let n=e.componentRenderCacheBytes;if(typeof n!=="number"||n<0||n===wr)return;wr=n,Ts.setMaxBytes(n)}var Ts=new T(2000,{maxBytes:ka,sizeOf:(e)=>e.output.length});function pp(e){let n=new WeakSet;try{let r=(i)=>{if(i===void 0)return{__stxType:"undefined"};if(typeof i==="bigint")return{__stxType:"bigint",value:i.toString()};if(typeof i==="function"||typeof i==="symbol")throw TypeError("Non-serializable component input");if(i===null||typeof i!=="object")return i;if(n.has(i))throw TypeError("Circular component input");n.add(i);try{if(i instanceof Date)return{__stxType:"date",value:i.toISOString()};if(Array.isArray(i))return i.map(r);let a=Object.getPrototypeOf(i);if(a!==Object.prototype&&a!==null)throw TypeError("Non-plain component input");let l={};for(let u of Object.keys(i).sort())l[u]=r(i[u]);return l}finally{n.delete(i)}};return JSON.stringify(r(e))}catch{return null}}function fp(e){let n={};for(let[r,i]of Object.entries(e))if(!r.startsWith("__")||r==="__stxServeContext")n[r]=i;return n}function mr(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function fo(e){let n=process.cwd(),r=`${n}\x00${e}`,i=ba.get(r);if(i===void 0)i=Bun.hash(Ca(e,n).split(xe.sep).join("/")).toString(36).slice(0,6),ba.set(r,i);return i}var ba=new Map;function Ca(e,n){if(!xe.isAbsolute(e))return e;let r=(i)=>{try{return js.realpathSync(i)}catch{return i}};return xe.relative(r(n),r(e))}function Zg(e){return/\bjs\b/.test(e)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(e)}function Je(e){return!Zg(e)}var Rs=new Map;function ie(e){let n;try{n=JSON.stringify(e)}catch{return new Bun.Transpiler(e)}let r=Rs.get(n);if(r)return r;if(Rs.size>=16)Rs.clear();let i=new Bun.Transpiler(e);return Rs.set(n,i),i}var ya=new WeakMap,dp=256;function Ye(e){try{let n=ie({loader:"ts",target:"browser",define:A()}),r=ya.get(n);if(!r)r=new Map,ya.set(n,r);let i=r.get(e);if(i!==void 0)return i;let a=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");a=a.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let l=[];a=a.replace(/\{!![\s\S]*?!!\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{\{[\s\S]*?\}\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{[\s\S]*?\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`});let u=n.transformSync(a);for(let f=0;f<l.length;f++)u=u.replace(`"__STX_EXPR_${f}__"`,l[f]),u=u.replace(`'__STX_EXPR_${f}__'`,l[f]);if(r.size>=dp){let f=r.keys().next();if(!f.done)r.delete(f.value)}return r.set(e,u),u}catch(n){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",n);return e}}function gp(e){let n=[],r=new Set,i=0,a=0,l=e.length,u=(O)=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]===O){a++;return}a++}},f=()=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]==="`"){a++;return}if(e[a]==="$"&&e[a+1]==="{"){a+=2;let O=1;while(a<l&&O>0)if(e[a]==="{")O++,a++;else if(e[a]==="}")O--,a++;else if(e[a]==="'"||e[a]==='"')u(e[a]);else if(e[a]==="`")f();else a++;continue}a++}},v=()=>{if(e[a]==="/"&&e[a+1]==="/"){while(a<l&&e[a]!==`
1182
+ `)a++;return!0}if(e[a]==="/"&&e[a+1]==="*"){a+=2;while(a<l-1&&!(e[a]==="*"&&e[a+1]==="/"))a++;return a+=2,!0}return!1},S=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]),j=()=>{let O=a-1;while(O>=0&&/\s/.test(e[O]))O--;if(O<0)return!0;let W=e[O];if("(,=:[!&|?{};+-*%<>~^".includes(W))return!0;if(!/[\w$]/.test(W))return!1;let D=O;while(D>0&&/[\w$]/.test(e[D-1]))D--;return S.has(e.slice(D,O+1))},I=()=>{a++;let O=!1;while(a<l&&e[a]!==`
1183
+ `){let W=e[a];if(W==="\\"){a+=2;continue}if(W==="[")O=!0;else if(W==="]")O=!1;else if(W==="/"&&!O){a++;while(a<l&&/[a-z]/i.test(e[a]))a++;return}a++}},V=()=>{if(i!==0)return;let O=e.slice(a).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(O){let X=O[2].split(",").map((ee)=>{let H=ee.trim().split(":");return H[H.length-1].trim()});for(let ee of X)if(ee&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(ee)&&!r.has(ee))n.push(ee),r.add(ee);return}let W=e.slice(a).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(W){let X=W[2];if(!r.has(X))n.push(X),r.add(X);return}let D=e.slice(a).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(D){let X=D[1];if(!r.has(X))n.push(X),r.add(X);return}let G=e.slice(a).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(G){let X=G[1];if(!r.has(X))n.push(X),r.add(X)}};while(a<l){if(v())continue;if(e[a]==="'"||e[a]==='"'){u(e[a]);continue}if(e[a]==="`"){f();continue}if(e[a]==="/"&&j()){I();continue}if(e[a]==="{"){i++,a++;continue}if(e[a]==="}"){i--,a++;continue}if(i===0&&/[a-z]/i.test(e[a])&&(a===0||/\s|[;{}()]/.test(e[a-1])))V();a++}return n}function mp(e,n,r){for(let i of Q(e)){let a=N(i.attrs);if(["server","src","component","stx:component"].some((f)=>a.has(f))||!Et(a))continue;let l=ln(e.slice(i.bodyStart,i.bodyEnd));if(!l)continue;let u=Object.assign(Object.create(null),r);for(let[f,v]of Object.entries(l.defaults))if(u[f]===void 0)u[f]=ws(v);for(let f of new Set([...l.propNames,...Object.keys(l.defaults)])){let v=l.localBindings[f]??(l.propBindings[f]?void 0:f);if(v)Object.defineProperty(n,v,{value:u[f],writable:!0,enumerable:!0,configurable:!0})}if(l.identifier)Object.defineProperty(n,l.identifier,{value:u,writable:!0,enumerable:!0,configurable:!0})}}var hp=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function Qg(e,n){let r=vt(e),i=e.slice(r).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/);if(!i)return null;let a=i[1].toLowerCase();if(!hp.has(a))return null;let l=new RegExp(`<\\/?${a}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),u=g(e,(j,I)=>(l.lastIndex=I,l.exec(j)?.index===I?l.lastIndex:-1));if(a==="span"&&/\sdata-stx-scope\s*=/.test(u[0]?.token||""))return null;let f=0,v=!1;for(let j of u){if(f+=j.token.startsWith("</")?-1:1,f<0)return null;if(f===0){if(e.slice(j.end).trim())return null;v=!0;break}}if(!v)return null;let S=r+i[0].length;return e.slice(0,S)+n+e.slice(S)}function Ra(e,n){if(!e)return!1;return[...n.additionalComponentsDirs??[],...n.fallbackComponentsDir?[n.fallbackComponentsDir]:[]].some((i)=>{let a=xe.relative(xe.resolve(i),xe.resolve(e));return!a.startsWith("..")&&!xe.isAbsolute(a)})}async function Wr(e,n,r,i,a){let l=e.endsWith(".stx")?e.slice(0,-4):e,u=(ce)=>ce.split("-").map((le)=>le.charAt(0).toUpperCase()+le.slice(1)).join(""),f=r.__importedComponents;if(f){for(let ce of[l,l.toLowerCase(),u(l),Y(l)])if(f.has(ce))return!0}let v=[...new Set([`${l}.stx`,`${u(l)}.stx`,`${Y(l)}.stx`])],S=typeof a.root==="string"?xe.resolve(a.root):void 0,j=S??xe.dirname(i),I=[],V=(ce)=>{if(ce&&!I.includes(ce))I.push(ce)};for(let ce of cs(i,S))V(ce);let O=r.__originalFilePath;if(O)V(xe.join(xe.dirname(O),"components"));if(Ra(n,a))V(a._rootComponentsDir);V(n),V(a._rootComponentsDir),V(xe.join(xe.dirname(i),"components")),V(a.componentsDir);for(let ce of a.additionalComponentsDirs??[])V(ce);let W=a._targetComponentFallbackNames?.some((ce)=>ce.toLowerCase()===l.toLowerCase());if(!W)for(let ce of a._targetComponentDirs??[])V(ce);if(S)V(xe.resolve(S,"resources/views/components")),V(xe.resolve(S,"resources/components")),V(xe.resolve(S,"src/components")),V(xe.resolve(S,"components"));for(let ce of a._layerComponentDirs??[])V(ce);let D=a._pluginComponentDirs;if(Array.isArray(D))for(let ce of D)V(typeof ce==="string"?ce:null);if(V(a.fallbackComponentsDir),W)for(let ce of a._targetComponentDirs??[])V(ce);let G=a._nativePrimitivesFallback;if(G&&!G.except.some((ce)=>ce.toLowerCase()===l.toLowerCase()))V(G.dir);if(l.startsWith("./")||l.startsWith("../"))return s(xe.resolve(xe.dirname(i),`${l}.stx`));let X=_a(xe.resolve(import.meta.dir,"components")),ee=I.map((ce)=>xe.isAbsolute(ce)?ce:xe.resolve(j,ce)),H=`${v.join("\x00")}\x00\x00${ee.join("\x00")}`,q=yr.get(H);if(q!==void 0)return q;let se=!1;e:for(let ce of ee){if(_a(ce)===X)continue;for(let le of v)if(await s(xe.join(ce,le))){se=!0;break e}}return yr.set(H,se),se}function _a(e){let n=_r.get(e);if(n!==void 0)return n;let r=e;try{r=js.realpathSync(e)}catch{}return _r.set(e,r),r}function em(e){return e==="visible"||e==="idle"||e==="interaction"||e.startsWith("media:")}function Rl(e){if(!e)return!1;let n=e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(n)}function xp(e,n,r){if(!e.includes("{{")&&!e.includes("{!!"))return e;let i=(a,l)=>{let u;try{u=M(a,n)}catch{return l}if(u===void 0||u===null)return"";let f=String(u);if(/<\/style/i.test(f))return console.warn(`[stx] a <style> expression in ${r??"<unknown>"} evaluated to CSS containing a closing style tag, which would end the element early, so it was dropped rather than emitted.`),"";return f};return e.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>i(l,a)).replace(/\{\{([\s\S]*?)\}\}/g,(a,l)=>i(l,a))}var wa=new Set;function va(e,n,r,i){let a=`${e}\x00${n}\x00${i??""}`;if(!process.env.STX_DEBUG&&wa.has(a))return;wa.add(a);let l=n?` used in ${n}`:"",u=i?` Cause: ${i}.`:"",f=r.length>0?`
1184
+ searched:
1185
+ ${r.map((v)=>` - ${v}`).join(`
1186
+ `)}`:"";console.error(`[stx] component <${e}> could not be resolved${l}, so it rendered as nothing.${u}${f}`)}function $a(e){return`<!-- stx: component "${e.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}var bp=new Set(["for","if","show","key","ref","class","className","style"]),Sa=new Set,Aa="useMediaQuery|useDark|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useDocumentVisibility|useScrollLock",Al=new RegExp(`\\b(?:${Aa})\\s*(?:<[^>]*>)?\\s*\\(`);function Xi(e){let n=new Set,r=new RegExp(`\\b(?:const|let|var)\\s+([a-zA-Z_$][\\w$]*)\\s*=\\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue|${Aa})\\s*(?:<[^>]*>)?\\s*\\(`,"g");for(let i of e){let a;while((a=r.exec(i))!==null)n.add(a[1]);r.lastIndex=0}return[...n]}async function Ze(e,n,r,i,a,l,u,f=new Set,v,S=ht(a),j,I=e){let{extractVariables:V}=await o("stx/variable-extractor",()=>import("./chunk-ggrcg7k7.js")),O=f??new Set;if(O.has(e))return`[Circular component reference: ${e}]`;let W=new Set(O);W.add(e);let D=typeof n.client==="string"?n.client.trim():"";if("client"in n)delete n.client;let G=D&&D!=="load"&&em(D)?D:"";try{let X=(ge)=>ge.split("-").map(($e)=>$e.charAt(0).toUpperCase()+$e.slice(1)).join(""),ee=I.endsWith(".stx")?I.slice(0,-4):I,H=null,q=a.__importedComponents;if(q){let ge=[ee,ee.toLowerCase(),X(ee),Y(ee)];for(let $e of ge)if(q.has($e)){H=q.get($e);break}}let se=[];if(!H){let ge=[`${ee}.stx`,`${X(ee)}.stx`,`${Y(ee)}.stx`],$e=[...new Set(ge)],De=a.__originalFilePath,Se=[];for(let Pe of cs(l))if(!Se.includes(Pe))Se.push(Pe);let lt=Se.length;for(let Pe of u._layerComponentDirs??[])if(!Se.includes(Pe))Se.push(Pe);if(De){let Pe=xe.join(xe.dirname(De),"components");Se.push(Pe)}let He=u._rootComponentsDir;if(typeof He==="string"&&Ra(i,u)&&!Se.includes(He))Se.push(He);if(i&&!Se.includes(i))Se.push(i);if(typeof He==="string"&&!Se.includes(He))Se.push(He);let Tt=xe.join(xe.dirname(l),"components");if(!Se.includes(Tt))Se.push(Tt);if(u.componentsDir&&u.componentsDir!==i&&!Se.includes(u.componentsDir))Se.push(u.componentsDir);for(let Pe of u.additionalComponentsDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let nn=u._nativeHostAttrs&&/^(?:checkbox|switch)$/i.test(ee),Ot=(j?.events??[]).map((Pe)=>Pe.replace(/^@/,"").split(".")[0].toLowerCase().replace(/-/g,"")),Gn=Object.hasOwn(n,"checked")||Boolean(j?.reactiveProps?.includes("checked")),Ps=Object.hasOwn(n,"value")||Boolean(j?.reactiveProps?.includes("value")),Ms=!Ot.includes("valuechange")&&(Gn||Ot.includes("change")&&!Ps),Bt=u._nativeHostAttrs&&/^textinput$/i.test(ee),sn=Ot.includes("update:value")&&!Ot.includes("input"),$n=u._nativeHostAttrs&&/^video$/i.test(ee),Ds=u._nativeHostAttrs&&/^image$/i.test(ee),Yn=to([...Object.keys(n),...j?.reactiveProps??[]],j?.events,n),rn=Object.hasOwn(n,"src")||Boolean(j?.reactiveProps?.includes("src")),Qn=Object.hasOwn(n,"source")||Boolean(j?.reactiveProps?.includes("source")),ts=$n&&(rn||Qn)&&(j?.events??[]).every((Pe)=>/^(?:play|pause|ended|timeupdate|loadedmetadata|loadstart|error)$/.test(Pe.replace(/^@/,"").split(".")[0])),ns=new Set(["","primary","secondary","outline","ghost","danger"]),ss=typeof n.variant==="string"?n.variant.trim().toLowerCase():"",rs=u._nativeHostAttrs&&/^button$/i.test(ee)&&!ns.has(ss),Rr=u._targetComponentFallbackNames?.some((Pe)=>Pe.toLowerCase()===ee.toLowerCase())??!1,Ns=Rr&&(!nn||Ms)&&(!Bt||sn)&&(!$n||ts)&&(!Ds||Yn)&&!rs;for(let Pe of Ns?[]:u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let on=typeof u.root==="string"?xe.resolve(u.root):void 0,Ar=on??xe.dirname(l),an=[];if(on)an.push(xe.resolve(on,"resources/views/components")),an.push(xe.resolve(on,"resources/components")),an.push(xe.resolve(on,"src/components")),an.push(xe.resolve(on,"components"));an.push(xe.resolve(import.meta.dir,"components"));for(let Pe of an)if(!Se.includes(Pe))Se.push(Pe);if(Rr){let Pe=(u._componentPackageDirs??[]).filter((gt)=>typeof gt==="string"&&gt.length>0),jt=(Ns?Pe.length?Pe:u._pluginComponentDirs??[]:u._targetComponentDirs??[]).filter((gt)=>typeof gt==="string"&&gt.length>0);if(jt.length){let gt=Se.slice(lt).map((pt)=>xe.isAbsolute(pt)?pt:xe.resolve(Ar,pt)).filter((pt)=>!jt.includes(pt)),os=`${ee}\x00${gt.join("\x00")}`,kt=br.get(os);if(kt===void 0){kt=!1;for(let pt of gt){for(let Ft of $e)if(await s(xe.join(pt,Ft))){kt=!0;break}if(kt)break}br.set(os,kt)}if(!kt){for(let pt of jt){let Ft=Se.indexOf(pt);if(Ft>=0)Se.splice(Ft,1)}Se.splice(lt,0,...jt)}}}let Tr=u._pluginComponentDirs;if(Array.isArray(Tr)){for(let Pe of Tr)if(typeof Pe==="string"&&!Se.includes(Pe))Se.push(Pe)}if(u.fallbackComponentsDir&&!Se.includes(u.fallbackComponentsDir))Se.push(u.fallbackComponentsDir);if(Ns){for(let Pe of u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe)}let is=u._nativePrimitivesFallback;if(is&&!is.except.some((Pe)=>Pe.toLowerCase()===ee.toLowerCase())&&!Se.includes(is.dir))Se.push(is.dir);let Ir=[...new Set(Se.map((Pe)=>{if(!Pe)return Pe;return xe.isAbsolute(Pe)?Pe:xe.resolve(Ar,Pe)}))];Se.length=0,Se.push(...Ir);let Ls=`${ee}\x00${l}\x00${Ir.join("\x00")}`,zs=As.get(Ls);if(zs)if(await s(zs))H=zs;else As.delete(Ls);if(!H&&(ee.startsWith("./")||ee.startsWith("../")))H=xe.resolve(xe.dirname(l),`${ee}.stx`),se.push(H);else if(!H)for(let Pe of Se){if(!Pe)continue;for(let jt of $e){let gt=xe.join(Pe,jt);if(se.push(gt),await s(gt)){H=gt;break}}if(H)break;if(!H)try{let jt=await import("fs");if(!jt.statSync(Pe,{throwIfNoEntry:!1})?.isDirectory())continue;let os=8,kt=[{path:Pe,depth:0}];while(kt.length>0&&!H){let pt=kt.pop();if(pt.depth>=os)continue;let Ft;try{Ft=jt.readdirSync(pt.path,{withFileTypes:!0})}catch{continue}for(let as of Ft){if(!as.isDirectory())continue;if(as.name==="node_modules"||as.name.startsWith("."))continue;let Or=xe.join(pt.path,as.name);for(let Va of $e){let Bs=xe.join(Or,Va);if(se.push(Bs),await s(Bs)){H=Bs;break}}if(H)break;kt.push({path:Or,depth:pt.depth+1})}}}catch{}if(H)break}if(H)As.set(Ls,H)}if(!H||!await s(H))return va(e,l,se),$a(e);v.add(H);let ce;if(Fn.has(H)&&xr.get(H)===xa(H))ce=Fn.get(H);else try{let ge=xa(H);ce=await Bun.file(H).text(),Fn.set(H,ce),xr.set(H,ge)}catch(ge){let $e=ge instanceof Error?ge.message:String(ge);return va(e,l,[H],$e),$a(e)}if(j)for(let ge of new Set([...Object.keys(n),...j.reactiveProps??[]])){let $e=ge.toLowerCase();if($e.startsWith("aria-")||$e.startsWith("data-"))continue;let De=ge.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${De}\\b`).test(ce))j.declaredProps.add(ge);if(new RegExp(`\\$props\\s*(?:\\.\\s*${De}\\b|\\[\\s*['"]${De}['"]\\s*\\])`).test(ce)||new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${De}['"]`).test(ce))j.consumedProps?.add(ge)}if(j?.reactiveProps?.length&&/\bdefineProps\s*(?:<[^>]*>)?\s*\(/.test(ce))for(let ge of j.reactiveProps){if(bp.has(ge)||j.consumedProps?.has(ge))continue;if(new RegExp(`\\buse(?:ReactiveProp|Model)\\s*\\(\\s*['"]${ge.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(ce))continue;let $e=`${H}\x00${ge}`;if(Sa.has($e))continue;Sa.add($e),console.warn(`[stx] ${xe.basename(H)} reads \`${ge}\` with defineProps(), which is not live, but ${xe.basename(l)} binds it (:${ge}): the value can arrive empty or stale (on a native screen, and for a :for's rows, it does not arrive at all). Read it with useReactiveProp('${ge}').`)}let le=new Set(["__originalFilePath","__importedComponents",ls,"__stx_client_signal_names","__stx_client_declared_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),pe={};for(let[ge,$e]of Object.entries(a))if(!ge.startsWith("__")||le.has(ge))pe[ge]=$e;let Re=S.length>0?{[ms]:[...S]}:{},Ae=r;if(r.includes("@include")){let{processIncludes:ge}=await o("stx/includes",()=>import("./chunk-agxxqjjt.js"));Ae=await ge(r,a,l,u,v)}if(/<[A-Z][\w.-]*[\s/>]/.test(Ae)){let{processComponents:ge}=await o("stx/component-renderer",()=>import("./chunk-gg0kkn2e.js")),$e={...a,__processedComponents:O,...Re};Ae=await ge(Ae,$e,l,u,v);let De=$e.__stx_preserved_client_expressions;if(Array.isArray(De)&&De.length>0)a.__stx_preserved_client_expressions=[...new Set([...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...De])]}let ve=[];if(Rl(Ae)){let{processExpressions:ge}=await o("stx/expressions",()=>import("./chunk-p8wnp4p1.js")),$e=a.__stx_signals_gate===void 0?{...a,__stx_signals_gate:!0,...Re}:S.length>0?{...a,...Re}:a;Ae=ge(Ae,$e,l);for(let De of Ae.matchAll(/\{\{([\s\S]*?)\}\}/g))ve.push(De[1].trim())}let fe=new Set(Array.isArray(a.__stx_client_declared_names)?a.__stx_client_declared_names:[]),ze=[];if(fe.size>0&&Ae)for(let ge of Ae.matchAll(/<[A-Z][\w.-]*\b([^>]*)>/g))for(let $e of ge[1].matchAll(/\s(?:v-model(?::[\w-]+)?|:[\w-]+)\s*=\s*"([^"]*)"/g)){let De=$e[1].trim();try{if(De&&Ee(De).some((Se)=>fe.has(Se)))ze.push(De)}catch{}}let We=ne(Ae),nt=[],st=We.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(ge,$e)=>{let De=We.scripts[Number($e)]||"",Se=De.match(/^<script\b([^>]*)>/i)?.[1]||"",lt=Se.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),He=!lt||["module","text/javascript","application/javascript"].includes(lt),Tt=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${Se}`);if(!/\bserver\b/i.test(Se)&&He&&!Tt)return nt.push(De),"";return De}),{extractSlotContent:Rt}=await o("stx/slots",()=>import("./chunk-8mye65n9.js")),_t=Rt(st),it={};if(_t.defaultSlot?.trim())it.default=_t.defaultSlot;for(let[ge,$e]of _t.namedSlots)it[ge]=$e.content;let wt=a.__stx_scope_seq??={n:0,key:fo(String(a.__filename??l))},Fe=Ca(e,process.cwd()),ct=`stx_${(Fe.endsWith(".stx")?Fe.slice(0,-4):Fe).replace(/[^a-zA-Z0-9]/g,"_")}_${++wt.n}_${wt.key}`,Me={...pe,$uid:ct,$native:u._nativeHostAttrs===!0,...n,props:n,slot:st,$slots:it,__processedComponents:W,__sections:{},__stx_signals_gate:Ne(ce)||Rl(r),__stx_preserved_client_expressions:[...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...ve],__stx_caller_client_bindings:[...Array.isArray(a.__stx_caller_client_bindings)?a.__stx_caller_client_bindings:[],...ze]};if(/import\s/.test(ce)){Me.__importedComponents=new Map(Me.__importedComponents);let{processESImports:ge}=await o("stx/component-renderer",()=>import("./chunk-gg0kkn2e.js"));ce=await ge(ce,Me,H,u,v)}mp(ce,Me,n);let Pt=ce,Mt=B(Pt);if(Mt)Pt=Mt.content.trim();let Os=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,dn=[...ce.matchAll(Os)];for(let[,ge,$e]of dn)if(!/\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(ge))Ke($e,H,u.strict);let dt=[],gn=null,Dt=dn.some((ge)=>/\bserver\b/.test(ge[1]||"")&&/\bcache\b/.test(ge[1]||"")),Qt=null,mn=null,hn=null,Un=0,xn=null;if(up(u),Dt&&wr>0){let ge=pp({props:n,slot:Ae,slotContext:r.trim()?fp(pe):void 0,buildMode:u.buildMode??"",skipEventDirectives:u.skipEventDirectives===!0,native:u._nativeHostAttrs===!0,clientLoopNames:[...S].sort(),layers:u._layerGraph?.layers.map(($e)=>$e.configFile),uid:ct});if(ge!==null){Qt=`${H}\x00${E(ce)}\x00${ge}`;let $e=Ts.get(Qt);if($e){for(let De of $e.dependencies)v.add(De);if(di(a,$e.clientFactories),wt.n+=$e.uidsConsumed,$e.preservedClientExpressions.length>0){let De=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let Se of $e.preservedClientExpressions)De.add(Se);a.__stx_preserved_client_expressions=[...De]}return $e.output}mn=new Set(v),hn=pi(a),Un=wt.n,xn=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[])}}let At=new Set;for(let ge of dn){let $e=ge[1]||"",De=ge[2]||"",Se=$e.includes("server");if(Je($e)&&De.trim())De=Ye(De);if(Se&&De){for(let He of ye(De))At.add(He);try{await V(De,Me,H,{onFailure:(He)=>{if(He.kind!=="unknown")gn=He.kind}})}catch(He){}}if(!Se){let He=De.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),Tt=He.includes("{{")&&He.includes("}}"),nn=He.includes("{!!")&&He.includes("!!}");if(Tt||nn)He=Ji(He,Me,H);let Ot=$e.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");dt.push(`<script${Ot}>${He}</script>`)}}let It=ne(ce).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),bn=It?It[1]:"",ue=It?It[2]:"",de="",ke=bn&&/\bscoped\b/i.test(bn);if(It)de=`<style${bn}>${xp(ue,Me,H)}</style>`;let Te=Pt;if(Te=Te.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),It)Te=Te.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let ge=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,$e=[];if(Te=Te.replace(ge,(De,Se)=>{let lt=Se.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(lt)$e.push(`<style${lt[1]}>${lt[2]}</style>`);return""}),Te=Te.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),$e.length>0)de=`${de}${$e.join(`
1187
+ `)}`}if(r&&Te.includes("{{ text || slot }}"))Te=Te.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>r);let{applySlots:et}=await o("stx/slots",()=>import("./chunk-8mye65n9.js")),{defaultSlot:ot,namedSlots:en}=_t,Cr=a.__stx_signals_gate===!0&&/\s(?:@[\w:.-]+|x-on:[\w:.-]+)\s*=/.test(st),Nt=dt.length>0&&er(Te)||u._nativeHostAttrs===!0&&dt.length>0||Cr&&dt.length>0||dt.some((ge)=>/\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(ge)),Kn=(ge)=>Nt?To(ge,ct):ge,Zn=new Map([...en].map(([ge,$e])=>[ge,{...$e,content:Kn($e.content)}]));Te=await et(Te,Nt?Ao(Kn(ot),ct):ot,Zn,Me,Nt?ct:"");let yn=Xi(dt),_n=(Array.isArray(Me.__stx_client_signal_names)?Me.__stx_client_signal_names:[]).filter((ge)=>!At.has(ge));if(yn.length>0||_n.length>0)Me.__stx_client_signal_names=[...new Set([..._n,...yn])];else delete Me.__stx_client_signal_names;let wn=ao(dt.join(`
1188
+ `)),vn=(Array.isArray(Me.__stx_client_declared_names)?Me.__stx_client_declared_names:[]).filter((ge)=>!At.has(ge)&&!(ge in n));if(wn.size>0||vn.length>0)Me.__stx_client_declared_names=[...new Set([...vn,...wn])];else delete Me.__stx_client_declared_names;let Lt=S.filter((ge)=>!At.has(ge)&&!(ge in n));if(Lt.length>0)Me[ms]=Lt;let Jn={...u,_rootComponentsDir:u._rootComponentsDir||u.componentsDir,componentsDir:xe.dirname(H),skipSignalsRuntime:!0,skipEventDirectives:u._nativeHostAttrs===!0||Nt||dt.length===0,defaultLayout:void 0};Me.__stxProcessingDepth=(a.__stxProcessingDepth||0)+1;let{processDirectives:Xn}=await o("stx/process",()=>import("./chunk-yegp50jb.js")),Le=await Xn(Te,Me,H,Jn,v),$t=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let ge of Le.matchAll(/\{\{([\s\S]*?)\}\}/g))$t.add(ge[1].trim());if($t.size>0)a.__stx_preserved_client_expressions=[...$t];let zt=ct,ut=Le;if(Nt){let ge="";if(Object.keys(n).length>0)try{ge=` data-stx-props="${mr(JSON.stringify(n))}"`}catch{}let $e=G?` stx-hydrate="${mr(G)}"`:"",De=Object.fromEntries(Object.entries(it).map(([Bt,sn])=>[Bt,Boolean(sn)])),Se=Object.keys(De).length>0?` data-stx-slots="${mr(JSON.stringify(De))}"`:"",lt=` data-stx-scope="${zt}"${ge}${Se}${$e}`,He=Le.slice(vt(Le)),Tt=/^<span(?=[\s/>])/i.test(He),nn=/^<[^>]+\bdata-stx-layout-root(?:\s|=|>)/i.test(He),Ot=/^<[^>]+\bdata-stx-fill-root(?:\s|=|>)/i.test(He),Gn=Tt?"span":"div",Ps=nn&&u._nativeHostAttrs?' style="display:flex;flex-direction:column;flex:1;min-height:0;min-width:0"':Ot&&u._nativeHostAttrs?' style="width:100%;height:100%"':Tt||nn?' style="display:contents"':"";ut=Qg(Le,lt)??`<${Gn}${lt} data-stx-component-wrapper${Ps}>${Le}</${Gn}>`;let Ms=await Promise.all(dt.map(async(Bt)=>{let sn=Bt.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!sn)return Bt;let[,$n,Ds]=sn,Yn=ha(Bt,Me,H);if(Yn!==null)return Yn;let rn=await _p(Ds,H,u.buildMode==="compile"),Qn=Nn(rn.clientCode,Xe(Me)),{vendorStyleTags:ts}=rn,ns=Qn?`function(__scopeId) {
1189
+ ${Qn}
1190
+ return (${rn.factoryBody})(__scopeId);
1191
+ }`:rn.factoryBody,ss=G?null:Us(a,ns),rs=ss?`window.__stxComponentFactories[${JSON.stringify(ss)}](${JSON.stringify(zt)});`:`(${ns})(${JSON.stringify(zt)});`;if(G)return`${ts}<script type="stx/island" data-stx-island="${zt}" data-stx-scoped data-stx-owner="${zt}"${$n}>${me(rs)}</script>`;return`${ts}<script data-stx-scoped data-stx-run="always" data-stx-owner="${zt}"${$n}>${me(rs)}</script>`}));if(ut=ut+`
1192
+ `+Ms.join(`
1193
+ `),de)ut+=`
1194
+ `+de}else{if(de)ut+=`
1195
+ `+de;if(dt.length>0){let ge=Me.__stx_event_bindings||[],$e=Xe(Me),De=await Promise.all(dt.map(async(Se)=>{let lt=ha(Se,Me,H);if(lt!==null)return lt;let He=Se.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!He)return Se;return await Ge(He[1],{eventBindings:ge,templateContent:ut,filePath:H,projectRoot:process.cwd(),serverData:$e,instanceId:ct})}));ut+=`
1196
+ `+De.join(`
1197
+ `),Me.__stx_event_bindings=[]}}if(ke){let ge=co(ut,H);if(ge.hasScoped)ut=ge.html}if(Qt&&mn){let ge=Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[];Ts.set(Qt,{output:ut,dependencies:[...v].filter(($e)=>!mn.has($e)),clientFactories:hn?fi(a,hn):[],uidsConsumed:wt.n-Un,preservedClientExpressions:xn?ge.filter(($e)=>!xn.has($e)):[]})}if(gn)ut=`<!--stx-render-failed:${gn}-->${ut}`;return nt.length>0?`${ut}
1198
+ ${nt.join(`
1199
+ `)}`:ut}catch(X){if(X instanceof te)throw X;return`[Error processing component: ${X instanceof Error?X.message:String(X)}]`}finally{O.delete(e)}}async function s(e){return Bun.file(e).exists()}function vr(e,n){let r=xe.resolve(n),i=xe.resolve(e),a=r.endsWith(xe.sep)?r:r+xe.sep;if(i===r||i.startsWith(a))return i;return null}async function Ea(e,n,r,i){let a=n.startsWith("layouts/")?n.slice(8):n,l=xe.join(e,a);for(let u of l.endsWith(".stx")?[l]:[l,`${l}.stx`])if(await s(u)){if(i)console.log(`Found layout in ${e}: ${u}`);return r?.add(u),u}return null}async function Mn(e,n,r,i){let a=await yp(e,n,r,i);if(a===null)return null;let l=vr(a,process.cwd());if(l)return l;let u=[r.root,r.layoutsDir,r.fallbackLayoutsDir,r.componentsDir,r.partialsDir,r.pagesDir,...r._layerLayoutDirs??[]].filter((f)=>typeof f==="string"&&f.length>0);for(let f of u){let v=xe.isAbsolute(f)?f:xe.resolve(process.cwd(),f);if(vr(a,v))return xe.resolve(a)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${a} (template: ${e}, from: ${n})`),null}async function yp(e,n,r,i){if(r.debug)console.log(`Resolving template path: ${e} from ${n}`);let a=xe.dirname(n),l=process.cwd();if(e.startsWith("/")){let O=xe.join(l,e),W=vr(O,l);if(!W)return console.warn(`[stx] rejected template path that escapes project root: ${e} (from ${n})`),null;if(r.debug)console.log(`Checking absolute path: ${W}`);if(await s(W)&&i)i.add(W);return W}let u=async(O)=>{if(!r.layoutsDir||!r.fallbackLayoutsDir)return O;let W=xe.relative(xe.resolve(l,r.fallbackLayoutsDir),O);if(W.startsWith("..")||xe.isAbsolute(W))return O;return await Ea(xe.resolve(l,r.layoutsDir),e,i,r.debug)??O},f=xe.join(a,e);if(await s(f)){if(r.debug)console.log(`Found direct path: ${f}`);let O=await u(f);if(i)i.add(O);return O}if(!e.endsWith(".stx")&&!e.endsWith(".jsx")&&!e.endsWith(".tsx"))for(let O of[".stx",".tsx",".jsx"]){let W=`${f}${O}`;if(await s(W)){if(r.debug)console.log(`Found direct path with extension: ${W}`);let D=await u(W);if(i)i.add(D);return D}}let v=[];if(v.push(...r._layerLayoutDirs??[]),r.layoutsDir)v.push(xe.isAbsolute(r.layoutsDir)?r.layoutsDir:xe.resolve(process.cwd(),r.layoutsDir));let S=xe.resolve(a),j=process.cwd();for(let O=0;O<10;O++){let W=xe.join(S,"layouts"),D=!1;try{D=js.statSync(W,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(D){v.push(W);break}let G=xe.dirname(S);if(G===S||G.length<j.length)break;S=G}for(let O of v){let W=await Ea(O,e,i,r.debug);if(W)return W}if(r.fallbackLayoutsDir){let O=xe.isAbsolute(r.fallbackLayoutsDir)?r.fallbackLayoutsDir:xe.resolve(process.cwd(),r.fallbackLayoutsDir),W=e.startsWith("layouts/")?e.slice(8):e,D=[xe.join(O,W)];if(!e.endsWith(".stx"))D.push(`${D[0]}.stx`);for(let G of D)if(await s(G)){if(r.debug)console.log(`Found in options.fallbackLayoutsDir: ${G}`);if(i)i.add(G);return G}}if(e.startsWith("layouts/")||e.includes("/layouts/")){let O=e.split("layouts/"),W=xe.join(r.partialsDir||a,"layouts",O[1]);if(await s(W)){if(r.debug)console.log(`Found in layouts path: ${W}`);if(i)i.add(W);return W}if(!W.endsWith(".stx")){let D=`${W}.stx`;if(await s(D)){if(r.debug)console.log(`Found in layouts path with extension: ${D}`);if(i)i.add(D);return D}}}if(r.partialsDir){let O=xe.join(r.partialsDir,"layouts");if(await s(O)){let W=xe.join(O,e);if(await s(W)){if(r.debug)console.log(`Found in partials layouts dir: ${W}`);if(i)i.add(W);return W}if(!e.endsWith(".stx")){let D=`${W}.stx`;if(await s(D)){if(r.debug)console.log(`Found in partials layouts dir with extension: ${D}`);if(i)i.add(D);return D}}}}let I=r.partialsDir||xe.join(process.cwd(),"views"),V=xe.join(I,e);if(await s(V)){if(r.debug)console.log(`Found in views path: ${V}`);if(i)i.add(V);return V}if(!e.endsWith(".stx")){let O=`${V}.stx`;if(await s(O)){if(r.debug)console.log(`Found in views path with extension: ${O}`);if(i)i.add(O);return O}}if(a.includes("temp")){let O=xe.join(xe.dirname(a),"layouts",e);if(await s(O)){if(r.debug)console.log(`Found in temp layouts dir: ${O}`);if(i)i.add(O);return O}if(!e.endsWith(".stx")){let W=`${O}.stx`;if(await s(W)){if(r.debug)console.log(`Found in temp layouts dir with extension: ${W}`);if(i)i.add(W);return W}}}if(r.debug)console.warn(`Template not found after trying all paths: ${e} (referenced from ${n})`);else console.warn(`Template not found: ${e} (referenced from ${n})`);return null}function Pl(e,n,r){let i=0,a="",l="";try{if(typeof n==="number"&&n>=0){let u=e.split(`
1200
+ `),f=0;for(let v=0;v<u.length;v++)if(f+=u[v].length+1,f>=n){i=v+1,a=u[v].trim();let S=Math.max(0,v-2),j=Math.min(u.length,v+3);l=u.slice(S,j).map((I,V)=>{let O=S+V+1;return`${O===i?"> ":" "}${O}: ${I}`}).join(`
1201
+ `);break}}else if(r){let u=e.indexOf(r);if(u>=0)return Pl(e,u)}}catch{}return{lineNumber:i,lineContent:a,context:l}}var Ue={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"};function w(e,n,r,i,a,l){let{lineNumber:u,context:f}=Pl(i,a,l),v=r.split("/").pop(),S=0;if(typeof a==="number"&&a>=0&&i){let I=i.lastIndexOf(`
1202
+ `,Math.max(0,a-1));S=a-(I+1)+1}let j="";if(u>0)j+=`
1203
+ ${r}:${u}${S>0?`:${S}`:""}: ${e.toLowerCase()} error: ${n}
1204
+ `;if(j+=`
1205
+ ${Ue.bold}${Ue.red}\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E${Ue.reset}
1206
+ `,j+=`${Ue.bold}${Ue.red}\u2502${Ue.reset} ${Ue.bold}${Ue.bgRed} ERROR ${Ue.reset} ${Ue.red}${e} Error${Ue.reset}${" ".repeat(Math.max(0,43-e.length))}${Ue.bold}${Ue.red}\u2502${Ue.reset}
1207
+ `,j+=`${Ue.bold}${Ue.red}\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F${Ue.reset}
1208
+ `,j+=`
1209
+ ${Ue.cyan}${Ue.bold}File:${Ue.reset} ${Ue.dim}${v}${Ue.reset}`,u>0)j+=` ${Ue.gray}(line ${u}${S>0?`, col ${S}`:""})${Ue.reset}`;if(j+=`
1210
+ ${Ue.yellow}${Ue.bold}Message:${Ue.reset} ${n}
1211
+ `,f)j+=`
1212
+ ${Ue.blue}${Ue.bold}Context:${Ue.reset}
1213
+ ${Ue.dim}${f}${Ue.reset}
1214
+ `;return j}function Ce(){Fn.clear(),xr.clear(),As.clear(),br.clear(),yr.clear(),_r.clear(),Ts.clear()}function Ly(){return{size:Fn.size,maxSize:500}}var hr=k(128);async function _p(e,n,r){let i=E(e,n,r),a=hr.get(i);if(a){if(no(a.deps))return a;hr.delete(i)}let l=qi(e,{filePath:n,projectRoot:process.cwd()}),u=l.code,f=Ki(l.styles);u=Gt(u).code;let{hasUserImports:v,bundleClientScript:S}=await o("stx/client-script-bundler",()=>import("./chunk-xy3ex6ht.js")),j=[],I=!1;if(v(u)){let ee=u;u=await S(ee,n,{projectRoot:process.cwd(),minify:r,collectInputs:j}),I=u===ee}let{stripStxRuntimeImports:V}=await o("stx/signal-processing",()=>import("./chunk-67zy5p7x.js"));u=V(u);let O=L(u),W=gp(O),D=new Set(J(O,!0).split(",").map((ee)=>ee.trim())),G=`function(__scopeId) {
1215
+ ${St("const",[...Xl,...W],O)}
1216
+ const __scope = window.stx._scopes = window.stx._scopes || {};
1217
+ const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
1218
+ __scopeVars.$refs = __scopeVars.$refs || {};
1219
+ const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
1220
+ const __previousCurrentProps = window.__STX_CURRENT_PROPS__;
1221
+ // A clone the runtime is setting up may not be in the document yet (rows
1222
+ // a loop builds inside a closed :if), where a lookup cannot see it, so the
1223
+ // runtime hands its root over in __STX_SETUP_ROOT__ (signals.ts).
1224
+ const __setupRoot = window.__STX_SETUP_ROOT__;
1225
+ const __componentElement = (__setupRoot && __setupRoot.getAttribute('data-stx-scope') === __scopeId && __setupRoot) || document.querySelector('[data-stx-scope="' + __scopeId + '"]');
1226
+ __scopeVars.$slots = Object.create(null);
1227
+ if (__componentElement) {
1228
+ try { Object.assign(__scopeVars.$slots, JSON.parse(__componentElement.getAttribute('data-stx-slots') || '{}')); }
1229
+ catch {}
1230
+ }
1231
+ window.__STX_CURRENT_ELEMENT__ = __componentElement;
1232
+ let __componentProps = __componentElement && __componentElement.__stx_props;
1233
+ if (!__componentProps && __componentElement) {
1234
+ try { __componentProps = JSON.parse(__componentElement.getAttribute('data-stx-props') || '{}'); }
1235
+ catch { __componentProps = {}; }
1236
+ }
1237
+ window.__STX_CURRENT_PROPS__ = __componentProps && typeof __componentProps === 'object' && !Array.isArray(__componentProps) ? __componentProps : {};
1238
+ const __scopeProps = window.__STX_CURRENT_PROPS__;
1239
+ Object.defineProperty(__scopeVars, '$props', { configurable: true, enumerable: true, get: function() {
1240
+ return (__componentElement && __componentElement.__stx_props) || __scopeProps;
1241
+ } });
1242
+
1243
+ // Scope-specific lifecycle callbacks. The queues drain as they run; the
1244
+ // hook lists keep what setup registered, because a component behind an :if
1245
+ // unmounts at each hide and mounts again at each show (signals.ts,
1246
+ // suspendSubtreeScopes).
1247
+ if (__scopeVars.__suspended && !__scopeVars.__mounted) {
1248
+ // Set up again after an :if hid it -- a <template :if> clones the
1249
+ // component afresh on every show, and the clone's script runs. This run's
1250
+ // hooks close over this run's state, so they replace the ones the hide
1251
+ // kept for a re-show rather than queueing beside them.
1252
+ __scopeVars.__mountCallbacks = [];
1253
+ __scopeVars.__destroyCallbacks = [];
1254
+ __scopeVars.__mountHooks = [];
1255
+ __scopeVars.__destroyHooks = [];
1256
+ // So do its effects: the last run's watched a clone that is gone.
1257
+ if (typeof __scopeVars.__disposeEffects === 'function') __scopeVars.__disposeEffects();
1258
+ __scopeVars.__disposeEffects = null;
1259
+ }
1260
+ __scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
1261
+ __scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
1262
+ __scopeVars.__mountHooks = __scopeVars.__mountHooks || [];
1263
+ __scopeVars.__destroyHooks = __scopeVars.__destroyHooks || [];
1264
+ let __registeringSetupHooks = true;
1265
+ const onMount = (fn) => { __scopeVars.__mountCallbacks.push(fn); __scopeVars.__mountHooks.push(fn); };
1266
+ const onDestroy = (fn) => {
1267
+ __scopeVars.__destroyCallbacks.push(fn);
1268
+ // A teardown registered inside onMount belongs to this mount alone.
1269
+ // Replaying it AND registering the next mount's teardown doubles cleanup.
1270
+ if (__registeringSetupHooks) __scopeVars.__destroyHooks.push(fn);
1271
+ };
1272
+ // The effects this setup makes (effect, watch) belong to the scope and are
1273
+ // disposed with it (disposeSubtreeScopes in the runtime), as its bindings
1274
+ // are. Untracked, one reading a store kept running for a component the
1275
+ // router had long swapped out.
1276
+ const __endEffects = window.stx._beginEffects ? window.stx._beginEffects() : null;
1277
+
1278
+ try {
1279
+ ${O}
1280
+
1281
+ // Register all defined signals and functions in this scope
1282
+ const __localVars = {};
1283
+ try {
1284
+ ${W.map((ee)=>D.has(ee)?`Object.defineProperty(__localVars, '${ee}', ${Ys(ee)});`:`if (typeof ${ee} !== 'undefined') __localVars['${ee}'] = ${ee};`).join(`
1285
+ `)}
1286
+ }
1287
+ catch (e) {}
1288
+ Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__localVars));
1289
+ if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__stxLiveBindings));
1290
+ }
1291
+ finally {
1292
+ __registeringSetupHooks = false;
1293
+ if (__endEffects) {
1294
+ const __previousDispose = __scopeVars.__disposeEffects;
1295
+ const __disposeSetup = __endEffects();
1296
+ __scopeVars.__disposeEffects = typeof __previousDispose === 'function'
1297
+ ? function() { __previousDispose(); __disposeSetup(); }
1298
+ : __disposeSetup;
1299
+ }
1300
+ window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
1301
+ window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
1302
+ }
1303
+ }`,X={vendorStyleTags:f,factoryBody:G,clientCode:O,deps:Br([...j,...l.styles.map((ee)=>ee.resolvedPath)])};if(!I&&l.unresolved.length===0)hr.set(i,X);return X}var wp=100,vp=599,Sr="__stxResponseStatus",Vn="__stxResponseHeaders";function Is(e){return typeof e==="number"&&Number.isInteger(e)&&e>=wp&&e<=vp}function In(e){for(let n of e.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let r=n[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!r)continue;let i=Number(r[1]);if(Is(i))return i}return}function $r(e,n){if(!e||typeof e!=="object")return!1;let r=typeof n==="string"&&/^\d+$/.test(n.trim())?Number(n.trim()):n;if(!Is(r))return!1;return e[Sr]=r,!0}function $p(e,n,r){if(!e||typeof e!=="object")return;let i=String(n??"").trim();if(!i)return;e[Vn]={...e[Vn],[i]:String(r)}}function Kt(e){let n=e?.[Sr];return Is(n)?n:void 0}function Xt(e){let n=e?.[Vn];if(!n||typeof n!=="object")return;let r=Object.entries(n).map(([i,a])=>[i,String(a)]);return r.length>0?Object.fromEntries(r):void 0}function yl(e,n){if(!e||!n||e===n||typeof n!=="object")return;let r=Kt(e);if(r!==void 0)n[Sr]=r;let i=Xt(e);if(i)n[Vn]={...n[Vn],...i}}function lo(e){return{setResponseStatus:(n)=>{$r(e,n)},notFound:(n=404)=>{let r=Is(n)&&n>=400?n:404;$r(e,r)},setResponseHeader:(n,r)=>{$p(e,n,r)}}}function bl(e,n,r={}){if(!e.includes("@status"))return e;let{filePath:i,buildMode:a}=r,l=a==="compile",u="",f=0,v=/@status\s*\(/g,S;while((S=v.exec(e))!==null){let j=Sp(e,S.index+S[0].length-1);if(j<0)break;let I=e.slice(S.index+S[0].length,j).trim(),V=/^\d+$/.test(I)?Number(I):d(I,n),O=i?` in ${i}`:"";if(l)console.warn(`[stx] @status(${I})${O} is skipped when precompiling: the build has no request, so the branch it sits in is not the one a visitor will get. Call notFound() or setResponseStatus(${I}) from <script server> instead \u2014 that runs per request.`);else if(!$r(n,V))console.warn(`[stx] @status(${I})${O} is not an HTTP status (100-599) \u2014 ignoring it.`);u+=e.slice(f,S.index),f=j+1+(e.slice(j+1).match(/^[^\S\n]*\n?/)?.[0].length??0),v.lastIndex=f}return f===0?e:u+e.slice(f)}function Sp(e,n){let r=1,i=null,a=!1;for(let l=n+1;l<e.length;l++){let u=e[l];if(a){a=!1;continue}if(i){if(u==="\\")a=!0;else if(u===i)i=null;continue}if(u==='"'||u==="'"||u==="`"){i=u;continue}if(u==="(")r++;else if(u===")"&&--r===0)return l}return-1}var Ta=new Set(yt),Ep=new Set(["props","$props","defineProps"]),kp=new Set(["stx","@stacksjs/stx"]),ja=k(128),Ia=k(64);function Cp(e){let n=[],r=0,i=e.split(`
1304
+ `);for(let a of i){let l=r,u=null,f=!1;for(let v=0;v<a.length;v++){let S=a[v];if(f){f=!1;continue}if(S==="\\"){f=!0;continue}if(u){if(S===u)u=null;continue}if(S==="'"||S==='"'||S==="`"){u=S;continue}if(S==="/"&&v+1<a.length&&a[v+1]==="/")break;if(S==="{")r++;else if(S==="}")r--}if(l===0){let v=a.match(/(?:const|let|var)\s+(\w+)\s*=/);if(v)n.push(v[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(a)){let S=a.match(/(?:const|let|var)\s+(\w+)/);if(S)n.push(S[1])}else{let S=a.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(S){let I=S[1].slice(1,-1).split(",").map((V)=>{let O=V.split(":");return(O.length>1?O[1]:O[0]).trim()}).filter((V)=>/^\w+$/.test(V));n.push(...I)}}}}return[...new Set(n)]}function jg(e){let n=e;n=n.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),n=n.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),n=n.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function r(i){if(!i.includes(":"))return i;let a=[],l="",u=0,f=0,v=null;for(let S=0;S<i.length;S++){let j=i[S];if(v){if(l+=j,j===v)v=null;continue}if(j==='"'||j==="'"||j==="`"){v=j,l+=j;continue}if(j==="<")u++;else if(j===">"&&u>0)u--;else if(j==="(")f++;else if(j===")")f--;if(j===","&&u===0&&f===0){a.push(l),l="";continue}l+=j}if(l)a.push(l);return a.map((S)=>{let j=S.trim(),I=j.startsWith("..."),V=I?j.slice(3):j,O=-1,W=0;for(let se=0;se<V.length;se++)if(V[se]==="<")W++;else if(V[se]===">")W--;else if(V[se]===":"&&W===0){O=se;break}if(O===-1)return S;let G=V.substring(0,O).trim().replace(/\?$/,""),X=V.substring(O+1),ee=-1,H=0;for(let se=0;se<X.length;se++)if(X[se]==="<")H++;else if(X[se]===">")H--;else if(X[se]==="="&&H===0){ee=se;break}let q=I?"...":"";if(ee!==-1)return`${q}${G} = ${X.substring(ee+1).trim()}`;return`${q}${G}`}).join(", ")}n=n.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(i,a,l)=>{if(!l.includes(":"))return i;return`${a}(${r(l)})`});{let i=/\b(function\s+\w*\s*)\(/g,a,l=[];while((a=i.exec(n))!==null){let u=a.index+a[0].length-1,f=1,v=u+1,S=0,j=null;while(v<n.length&&f>0){let O=n[v];if(j){if(O===j)j=null;v++;continue}if(O==='"'||O==="'"||O==="`"){j=O,v++;continue}if(O==="<")S++;else if(O===">"&&S>0)S--;else if(S===0){if(O==="(")f++;else if(O===")")f--}if(f>0)v++}if(f!==0)continue;let I=n.substring(u+1,v);if(!I.includes(":"))continue;let V=r(I);l.push({start:u+1,end:v,replacement:V})}for(let u=l.length-1;u>=0;u--){let{start:f,end:v,replacement:S}=l[u];n=n.substring(0,f)+S+n.substring(v)}}return n=n.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(i,a)=>{if(!a.includes(":"))return i;if(a.includes("{")||a.includes("}"))return i;return`(${a.split(",").map((u)=>{let[f,...v]=u.split("="),S=f.split(":")[0].trim();if(v.length>0)return`${S} = ${v.join("=").trim()}`;return S}).join(", ")}) =>`}),n=n.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),n=n.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),n=n.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),n=n.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),n=n.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),n=n.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),n=n.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),n=n.replace(/\n\s*\n\s*\n/g,`
1305
+
1306
+ `),n}function Bg(e){return e.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(n,...r)=>{let[,i,a]=r,l=i??a;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(l)?"":n})}function Fg(e){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(e)}function zg(e){if(e instanceof SyntaxError)return!0;let n=e instanceof Error?e.message:String(e);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(n)}function Hg(e){if(!/is not defined|can't find variable/i.test(e))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(e)}var Oa=new Set;async function b(e,n,r,i={}){if(!e.trim())return;let a=A(),l=E(e,JSON.stringify(a)),u=ja.get(l);if(u===void 0){try{let ue=ie({loader:"ts",target:"browser",define:a}),de=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");de=de.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),u=ue.transformSync(de)}catch{u=jg(e)}ja.set(l,u)}let f={exports:{}},v=f.exports,S=fn.cwd(),j={},I=[...u.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((ue)=>ue[1]).filter((ue)=>!ue.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(ue)),V=new Map;for(let ue of I)try{if(ue.startsWith(".")){j[ue]=await import(Ct.resolve(Ct.dirname(r),ue));continue}let de=Ct.resolve(S,"node_modules",ue),ke=Ct.join(de,"package.json"),Te=JSON.parse(x("fs").readFileSync(ke,"utf8")),et=Te.main||"index.js";if(Te.exports){let ot=typeof Te.exports==="string"?Te.exports:Te.exports["."];if(typeof ot==="string")et=ot;else if(ot?.bun)et=ot.bun;else if(ot?.import)et=ot.import;else if(ot?.default)et=ot.default}j[ue]=await import(Ct.resolve(de,et))}catch(de){if(ue.startsWith("."))V.set(ue,de instanceof Error?de.message:String(de))}let O=(ue)=>{if(j[ue])return j[ue];let de=V.get(ue);if(de!==void 0)throw Error(`Cannot require '${ue}' from ${r}: ${de}`);return x(ue)},W=n.props||{},D=(ue)=>{if(!ue)return W;let de={};for(let[ke,Te]of Object.entries(ue)){let et=W[ke];if(et!==void 0)de[ke]=et;else if(typeof Te==="function")de[ke]=Te();else de[ke]=Te}return de};for(let[ue,de]of Object.entries(W))Object.defineProperty(D,ue,{value:de,enumerable:!0,configurable:!0,writable:!0});let G=(ue,de=!1)=>{if(ue===void 0||ue===null)return de;if(typeof ue==="string"){let ke=ue.trim().toLowerCase();if(ke===""||ke==="true"||ke==="1"||ke==="on"||ke==="yes")return!0;if(ke==="false"||ke==="0"||ke==="off"||ke==="no")return!1;return!0}return Boolean(ue)},X=(ue,de=0)=>{if(ue===void 0||ue===null)return de;if(typeof ue==="string"){let Te=ue.trim();if(Te==="")return de;let et=Number(Te);return Number.isFinite(et)?et:de}let ke=Number(ue);return Number.isFinite(ke)?ke:de};for(let ue of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(W,ue))continue;try{Object.defineProperty(D,ue,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let ee=(ue)=>{if(!ue)return W;let de={...W};for(let[ke,Te]of Object.entries(ue)){let et=Te&&typeof Te==="object"&&!Array.isArray(Te)?Te:{type:Te};if(de[ke]===void 0&&et.default!==void 0)de[ke]=typeof et.default==="function"?et.default():et.default}return de},H=()=>n.slots||{},q=(ue,de)=>{let ke={...ue};for(let[Te,et]of Object.entries(de))if(ke[Te]===void 0)if(typeof et==="function")ke[Te]=et();else ke[Te]=et;return ke},se=(ue)=>{let de=()=>ue;return de.set=(ke)=>{},de.update=(ke)=>{},de},ce=(ue)=>{let de,ke=!1;return()=>{if(!ke)try{de=ue(),ke=!0}catch{de=void 0}return de}},le=(ue)=>{},pe=(ue)=>ue(),Re=(ue)=>{},Ae=(ue)=>{},ve=lo(n);function fe(ue){let de=ue||{};if(de.cache===!1)n.__stx_skip_cache=!0;if(de.title!==void 0||de.description!==void 0)Rt({title:de.title,description:de.description})}function ze(ue){if(!ue||typeof ue!=="object")return;let de=n.__stxClientPayload??{};Object.assign(de,ue),n.__stxClientPayload=de}let We=()=>{let ue=n.__stxServeContext,de=n.__stxServeSearch??ue?.search??"",ke=ue?.path??"",Te=Object.fromEntries(new URLSearchParams(de)),et=n.query,ot=Object.keys(Te).length>0?Te:et??{},en=de||(Object.keys(ot).length>0?`?${new URLSearchParams(ot).toString()}`:"");return{params:n.params??{},query:ot,path:ke,name:"",fullPath:ke+en,hash:"",matched:[]}},nt=()=>({push:(ue)=>{},replace:(ue)=>{},back:()=>{},forward:()=>{},go:(ue)=>{}}),st=(ue)=>{let de=n.__stx_runtime_head||{};n.__stx_runtime_head=rt(de,je(ue||{},{known:xo,source:"useHead()"}))},Rt=(ue)=>{st(So(ue||{}))},_t=(ue)=>({value:ue}),it=(ue)=>ue,wt=(ue)=>({value:typeof ue==="function"?ue():ue}),Fe=(ue,de)=>{},at=(ue)=>{},ct=(ue)=>{},Me=(ue)=>ue?ue():Promise.resolve(),Pt=(ue)=>(de,...ke)=>{},Mt=(ue)=>{},Os=(ue,de)=>{},dn=(ue,de)=>de,dt=()=>({value:"light"}),gn=()=>se(!1),Dt=(ue)=>se(!1),Qt=()=>se(!1),mn=()=>Dt("(prefers-color-scheme: dark)"),hn=()=>Dt("(prefers-color-scheme: light)"),Un=()=>Dt("(prefers-reduced-motion: reduce)"),xn=()=>Dt("(prefers-contrast: more)"),At={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},kr=new Proxy(At,{get(ue,de){if(de in ue)return ue[de];return},set(ue,de,ke){return ue[de]=ke,!0}}),It={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},bn=console;try{let ue=Wi(u,r),de=new Set(Object.keys(W)),ke=Object.keys(n).filter((Le)=>!de.has(Le)&&!Ep.has(Le)&&qr(Le)),Te=ke.map((Le)=>n[Le]);if(!ke.includes("__stxServeContext"))ke.push("__stxServeContext"),Te.push(void 0);if(!de.has("cookies")){let Le=n.cookies??n.__stxServeContext?.cookies??{},$t=ke.indexOf("cookies");if($t<0)ke.push("cookies"),Te.push(Le);else Te[$t]=Le}let et=new Set(["async","module","exports","require","params","window","document","console","state","derived","effect"]),ot=[],en=[];for(let[Le,$t]of Object.entries(W)){if(!qr(Le))continue;if(et.has(Le))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${Le}\\b`).test(ue))continue;ot.push(Le),en.push($t)}let Nt=Cp(ue).map((Le)=>`module.exports.${Le} = typeof ${Le} !== 'undefined' ? ${Le} : module.exports.${Le};`).join(`
1307
+ `),Kn=n.params??{},Zn=[],yn=[];for(let Le=0;Le<ke.length;Le++){if(ke[Le]==="params")continue;Zn.push(ke[Le]),yn.push(Te[Le])}let _n=[...yt,...ot,...Zn],wn=`return (async () => {
1308
+ ${ue}
1309
+ ${Nt}
1310
+ return module.exports
1311
+ })()`,vn=E(wn,_n.join("\x00")),Lt=Ia.get(vn);if(!Lt)Lt=Function(..._n,wn),Ia.set(vn,Lt);let Jn=n.__stx_options?.runtimeConfig;if(Jn||/\buse(?:Server)?RuntimeConfig\b/.test(u))await jn(n,r,Jn);let Xn=await Qe(n.__stx_runtime_config??Bn()??z(),()=>Mr(n,()=>Lt(f,v,O,W,D,G,X,ee,q,ze,Dr,Qi,mo,se,ce,le,pe,Re,Ae,fe,We,nt,st,Rt,ve.setResponseStatus,ve.setResponseHeader,ve.notFound,_t,it,wt,Fe,at,ct,Me,Pt,Mt,H,Os,dn,dt,gn,Dt,Qt,mn,hn,Un,xn,kr,It,bn,At.confirm,At.alert,At.fetch,Kn,...en,...yn)));if(i.preserveExisting){for(let[Le,$t]of Object.entries(Xn))if(!(Le in n)||n[Le]===void 0)n[Le]=$t}else Object.assign(n,Xn);for(let[Le,$t]of Object.entries(W))if(!(Le in n))n[Le]=$t}catch(ue){if(n.__stx_strict_hydration)throw ue;let de=Bg(ue instanceof Error?ue.message:String(ue));if(Fg(de))console.warn(`[stx] server <script> in ${r??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${de}`),i.onFailure?.({kind:"module-resolution",message:de,error:ue});else if(zg(ue))console.warn(`[stx] server <script> in ${r??"<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${de}`),i.onFailure?.({kind:"syntax",message:de,error:ue});else if(Hg(de))console.warn(`[stx] server <script> in ${r??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${de}`),i.onFailure?.({kind:"missing-binding",message:de,error:ue});else{let ke=`${r??"<unknown>"}\x00${de}`;if(fn.env.STX_DEBUG||!Oa.has(ke))Oa.add(ke),console.warn(`[stx] server <script> in ${r??"<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${de}`);i.onFailure?.({kind:"unknown",message:de,error:ue})}try{await Op(u,n,r)}catch(ke){if(fn.env.STX_DEBUG){let Te=ke instanceof Error?ke.message:String(ke);console.warn(`[stx] fallback extraction also failed in ${r??"<unknown>"}: ${Te}`)}}}}function Ug(e){let n=0,r=null,i=!1,a=!1;for(let l=0;l<e.length;l++){let u=e[l];if(r){if(u===r){if(r=null,i||n===0)a=!0}continue}if(u==="'"||u==='"'||u==="`"){r=u;continue}if(u==="{")n++;else if(u==="}")n--;else if(e.startsWith("from",l)&&n===0)i=!0}return r===null&&n===0&&a}var Rp=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function Wi(e,n){let r=n?Ct.dirname(n):fn.cwd(),i=fn.cwd(),a=e.split(`
1312
+ `),l=[],u=0;while(u<a.length){let f=a[u].trim();if(f.startsWith("interface ")||f.startsWith("export interface ")||f.startsWith("type ")||f.startsWith("export type ")){if(f.includes("{")&&!f.includes("}")){let v=0;for(;u<a.length;u++){for(let S of a[u])if(S==="{")v++;else if(S==="}")v--;if(v<=0)break}}u++;continue}if(f.startsWith("definePageMeta(")){let v=0,S=!1,j=u;for(let O=u;O<a.length&&!S;O++){let W=null,D=!1,G=a[O];for(let X=0;X<G.length;X++){let ee=G[X];if(D){D=!1;continue}if(ee==="\\"){D=!0;continue}if(W){if(ee===W)W=null;continue}if(ee==='"'||ee==="'"||ee==="`"){W=ee;continue}if(ee==="(")v++;else if(ee===")"){if(v--,v===0){u=O+1,S=!0;break}}}}if(!S)u=a.length;let I=a.slice(j,u).join(`
1313
+ `);if(/\bcache\s*:\s*false\s*[,}]/.test(I))l.push("definePageMeta({ cache: false });");let V=[];for(let O of["title","description"]){let W=new RegExp(`\\b${O}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(I);if(W)V.push(`${O}: ${JSON.stringify(W[2])}`)}if(V.length>0)l.push(`useSeoMeta({ ${V.join(", ")} });`);continue}if(f.startsWith("import ")||f==="import"||f.startsWith("import{")||/^import['"]/.test(f)){let v=f,S=0;while(!Ug(v)&&u+S+1<a.length)S++,v=`${v} ${a[u+S].trim()}`;u+=S;let j=v.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),I=v.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),V=v.match(/^import\s*['"](.+?)['"]/),O=v,W=(D)=>{if(D.startsWith("."))return Ct.resolve(r,D);if(D.startsWith("~/")||D.startsWith("@/"))return Ct.resolve(i,D.slice(2));try{return Bun.resolveSync(D,r)}catch{return D}};if(j){let[,D,G]=j,X=W(G);l.push(`const ${D} = (await import('${X}')).default`),l.push(`module.exports.${D} = ${D};`)}else if(I){let[,D,G]=I,X=W(G),ee=[],H=[],q=kp.has(G);for(let se of D.split(",")){let ce=se.trim();if(!ce)continue;let le=ce.split(/\s+as\s+/);if(le.length===2){let[pe,Re]=[le[0].trim(),le[1].trim()];if(q&&Ta.has(pe)){l.push(`const ${Re} = ${pe};`);continue}ee.push(`${pe}: ${Re}`),H.push(Re)}else{if(q&&Ta.has(ce))continue;ee.push(ce),H.push(ce)}}if(ee.length>0)l.push(`const { ${ee.join(", ")} } = await import('${X}')`);for(let se of H)l.push(`module.exports.${se} = ${se};`)}else if(V){let D=W(V[1]);l.push(`await import('${D}')`)}else l.push(O);u++;continue}if(Rp.test(f))l.push(a[u]),u++;else if(f.startsWith("export const ")||f.startsWith("export let ")||f.startsWith("export var ")){let v=Ma(a,u),{type:S,name:j,value:I}=v;l.push(`${S} ${j} = ${I};`),l.push(`module.exports.${j} = ${j};`),u=v.nextIndex}else if(f.startsWith("export function ")||f.startsWith("export async function ")){let v=Er(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("const ")||f.startsWith("let ")||f.startsWith("var ")){let v=Ma(a,u),{type:S,name:j,value:I}=v;l.push(`${S} ${j} = ${I};`),l.push(`module.exports.${j} = ${j};`),u=v.nextIndex}else if(f.startsWith("function ")||f.startsWith("async function ")){let v=Er(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("export default function ")||f.startsWith("export default async function ")){let v=a[u].replace(/^(\s*)export\s+default\s+/,"$1"),S=[...a];S[u]=v;let j=Er(S,u);if(l.push(j.functionCode),j.name)l.push(`module.exports.default = ${j.name};`);u=j.nextIndex}else if(f.startsWith("export default ")){let v=f.replace(/^export\s+default\s+/,"").replace(/;$/,"");l.push(`module.exports.default = ${v};`),u++}else if(f.startsWith("class ")||f.startsWith("export class ")){let v=f.match(/(?:export\s+)?class\s+(\w+)/);if(v){let S=v[1],j=a[u].replace(/^export\s+/,""),I=0,V=u;for(;V<a.length;V++){let O=a[V];for(let W of O)if(W==="{")I++;else if(W==="}")I--;if(V>u)j+=`
1314
+ `+O;if(I<=0&&V>=u)break}l.push(j),l.push(`module.exports.${S} = ${S};`),u=V+1}else l.push(f),u++}else if(f.includes("module.exports"))l.push(f),u++;else if(f.trim()&&!f.startsWith("//"))l.push(f),u++;else u++}return Ap(l.join(`
1315
+ `),r,i)}function Ap(e,n,r){let i=e.length,a="",l=0,u=null,f=!1,v=!1,S=0;while(l<i){let j=e[l],I=e[l+1];if(f){if(a+=j,j===`
1316
+ `)f=!1;l++;continue}if(v){if(a+=j,j==="*"&&I==="/"){a+=I,l+=2,v=!1;continue}l++;continue}if(!u&&j==="/"&&I==="/"){f=!0,a+=j,l++;continue}if(!u&&j==="/"&&I==="*"){v=!0,a+=j,l++;continue}if(u){if(a+=j,j==="\\"){a+=I,l+=2;continue}if(j===u&&u!=="`"){u=null,l++;continue}if(u==="`"){if(j==="$"&&I==="{"){S++,a+=I,l+=2;continue}if(j==="`"){u=null,l++;continue}}l++;continue}if(S>0){if(j==="{")S++;else if(j==="}")S--}if(j==='"'||j==="'"||j==="`"){u=j,a+=j,l++;continue}if(j==="a"&&e.startsWith("await",l)){let V=Tp(e,l);if(V){let{quote:O,path:W,end:D}=V;if(W.startsWith(".")||W.startsWith("~/")||W.startsWith("@/")){let G=W.startsWith(".")?Ct.resolve(n,W):Ct.resolve(r,W.slice(2));a+=`await import(${O}${G}${O})`,l=D;continue}}}a+=j,l++}return a}function Tp(e,n){let r=n+5;if(r>=e.length)return null;if(!/\s/.test(e[r]))return null;while(r<e.length&&/\s/.test(e[r]))r++;if(!e.startsWith("import",r))return null;r+=6;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!=="(")return null;r++;while(r<e.length&&/\s/.test(e[r]))r++;let i=e[r];if(i!=="'"&&i!=='"')return null;r++;let a=r;while(r<e.length&&e[r]!==i)if(e[r]==="\\")r+=2;else r++;if(r>=e.length)return null;let l=e.slice(a,r);r++;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!==")")return null;return{quote:i,path:l,end:r+1}}function za(e,n){let r=e[n];if(r!=="{"&&r!=="[")return null;let a=_(e,r,r==="{"?"}":"]",n);if(a===-1)return null;return{pattern:e.slice(n,a+1),endPos:a+1}}function Ba(e){let n=[],r=e.slice(1,-1).trim();if(!r)return n;let i=0,a=0,l="";while(i<r.length){let u=r[i];if(u==="{"||u==="["){let f=a===0?za(r,i):null;if(f){n.push(...Ba(f.pattern)),i=f.endPos,l="";continue}a++}else if(u==="}"||u==="]")a--;if(a>0){i++;continue}if(u===","){if(l.trim())n.push(l.trim());l="",i++;continue}if(u===":"){l="",i++;continue}if(u==="="){if(l.trim())n.push(l.trim());l="",i++;while(i<r.length&&r[i]!==","&&a===0){if(r[i]==="{"||r[i]==="[")a++;else if(r[i]==="}"||r[i]==="]")a--;i++}continue}if(/[\w$]/.test(u))l+=u;i++}if(l.trim())n.push(l.trim());return n}function Vg(e){let n=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(e);if(!n)return null;let r=n[0].length,i=(a)=>a===" "||a==="\t";while(r<e.length&&i(e[r]))r++;if(e[r]===":"){let a=0,l=null;r++;for(;r<e.length;r++){let u=e[r];if(l){if(u==="\\"){r++;continue}if(u===l)l=null;continue}if(u==="'"||u==='"'||u==="`"){l=u;continue}if(u==="("||u==="["||u==="{"||u==="<"){a++;continue}if(u===")"||u==="]"||u==="}"||u===">"){a--;continue}if(u==="="&&a<=0){let f=e[r+1],v=e[r-1];if(f!=="="&&f!==">"&&v!=="="&&v!=="!"&&v!=="<"&&v!==">")break}}if(e[r]!=="=")return null}while(r<e.length&&i(e[r]))r++;if(e[r]!=="=")return null;return{type:n[1],name:n[2],value:e.slice(r+1).trim()}}function Pa(e,n,r,i){let a=null,l=!1;for(let u of e){if(l){l=!1;continue}if(u==="\\"){l=!0;continue}if(a){if(u===a)a=null;continue}if(u==="'"||u==='"'||u==="`"){a=u;continue}if(u===n)i++;else if(u===r)i--}return i}function Ma(e,n){let r=e[n].trim(),i=Vg(r),a=i?[r,i.type,i.name,i.value]:null;if(!a){let j=r.match(/^(?:export\s+)?(const|let|var)\s+/);if(j){let I=r.slice(j[0].length),V=n;if(I.startsWith("{")||I.startsWith("[")){let W=I[0],D=W==="{"?"}":"]",G=Pa(I,W,D,0),X=I;for(let ee=n+1;ee<e.length&&G>0;ee++)X+=` ${e[ee].trim()}`,V=ee,G=Pa(e[ee],W,D,G);if(G>0)X=I,V=n;I=X}let O=za(I,0);if(O){let W=j[1],D=O.pattern,G=I.slice(O.endPos).trim();if(G.startsWith("=")){let X=G.slice(1).trim(),ee=X,H=Math.max(V,n);if(Da(X)){let le=Na(e,H,X);ee=le.value,H=le.nextIndex}else H=H+1;ee=ee.trim().replace(/;$/,"");let q=Ba(D),se=`__stx_src_${n}`,ce=q.map((le)=>`module.exports.${le} = ${le};`).join(`
1317
+ `);return{type:W,name:se,value:`${ee}; ${W} ${D} = ${se};
1318
+ ${ce}`,nextIndex:H}}}}throw Error(`Failed to parse variable declaration: ${r}`)}let[,l,u,f]=a,v=f,S=n;if(Da(f)){let j=Na(e,n,f);v=j.value,S=j.nextIndex}else S=n+1;while(S<e.length){let j=e[S].trim();if(j.startsWith(".")||j.startsWith("?."))v+=`
1319
+ ${e[S]}`,S++;else break}return v=v.trim().replace(/;$/,""),{type:l,name:u,value:v,nextIndex:S}}function Er(e,n){let r=e[n].trim(),i=r.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!i)throw Error(`Failed to parse function declaration: ${r}`);let[,a]=i,l=r.replace(/^export\s+/,""),u=n;if(jp(r)){let f=Ip(e,n,l);l=f.functionCode,u=f.nextIndex}else u=n+1;return{name:a,functionCode:l,nextIndex:u}}function Da(e){let n=e.trim();if(n.startsWith("{"))return _(n,"{","}",0)===-1;if(n.startsWith("["))return _(n,"[","]",0)===-1;return!Wa(n)}function Wa(e){let n={paren:0,bracket:0,brace:0},r=null,i=0;for(let a=0;a<e.length;a++){let l=e[a];if((a>0?e[a-1]:"")==="\\"&&r)continue;if((l==='"'||l==="'")&&!r){r=l;continue}if(l===r&&r!=="`"){r=null;continue}if(l==="`"&&!r){r="`";continue}if(l==="`"&&r==="`"&&i===0){r=null;continue}if(r==="`"&&l==="$"&&e[a+1]==="{"){i++,a++;continue}if(i>0&&l==="{"){i++;continue}if(i>0&&l==="}"){i--;continue}if(r)continue;if(l==="(")n.paren++;else if(l===")")n.paren--;else if(l==="[")n.bracket++;else if(l==="]")n.bracket--;else if(l==="{")n.brace++;else if(l==="}")n.brace--}return n.paren===0&&n.bracket===0&&n.brace===0&&r===null}function Fa(e){let n=e.indexOf("(");if(n===-1)return e.indexOf("{");let r=_(e,"(",")",n);if(r===-1)return-1;return e.indexOf("{",r)}function jp(e){let n=Fa(e);if(n===-1)return!0;return _(e,"{","}",n)===-1}function Na(e,n,r){let i=r,a=n+1;while(a<e.length&&!Wa(i)){let l=e[a];i+=`
1320
+ ${l}`,a++}while(a<e.length){let l=e[a].trim();if(l.startsWith(".")||l.startsWith("?."))i+=`
1321
+ ${e[a]}`,a++;else break}return{value:i,nextIndex:a}}function Ip(e,n,r){let i=r,a=n+1;while(a<e.length){let l=Fa(i);if(l!==-1){if(_(i,"{","}",l)!==-1)break}let u=e[a];i+=`
1322
+ ${u}`,a++}return{functionCode:i,nextIndex:a}}function La(e,n){let r=d(e,n)??d(`(${e})`,n);if(r!==void 0)return r;if(!/\bprocess\b/.test(e))return;let i={...n,process:Object.freeze({env:{...fn.env}})},a=Object.keys(i).filter(qr),l=a.map((u)=>i[u]);try{return Function(...a,`'use strict'; return (${e});`)(...l)}catch{try{return Function(...a,`'use strict'; return ${e};`)(...l)}catch{return}}}async function Op(e,n,r){let i=e.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let l of i){let[,,u,f]=l;try{let v=f.trim().replace(/;$/,""),S=La(v,n);if(S!==void 0)n[u]=S}catch(v){console.warn(`Failed to parse export ${u} in fallback:`,v)}}let a=e.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let l of a){let[,,u,f]=l;if(!(u in n))try{let v=f.trim().replace(/;$/,""),S=La(v,n);if(S!==void 0)n[u]=S}catch{}}}function Cl(e){let n=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),r=n?n[1]:"",i=n?e.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):e;return{scriptContent:r,templateWithoutScript:i}}function El(e){let n=e.trim();if(!n)return!1;return/(?:const|let|var|function)\s+\w+/.test(n)}
1323
+ export{qe,Ie,J,Ys,Zs,Y,jr,Qs,eo,Ni,Mi,Di,to,Li,ll,Vt,o,me,k,ul,E,Br,no,Oe,A,Ke,B,Fr,zr,he,Wt,oe,F,ht,N,Hr,Ur,yt,dl,qt,ro,so,_e,ji,An,oo,ye,pl,fl,Bi,gl,ml,io,Fi,zi,hl,Hi,ao,Ui,Pn,co,In,Kt,Xt,yl,lo,bl,wl,On,Vr,uo,po,vl,Vi,xl,Sl,kl,_l,jg,Bg,Fg,zg,Hg,b,Ug,Wi,Vg,Cl,El,qi,Ki,Wg,Gt,Tl,qg,$l,Dy,Xe,Nn,Ge,Kg,Xg,Gg,Jg,Yg,fo,Zg,Je,ie,Ye,Qg,Wr,em,Rl,Al,Xi,Ze,s,Mn,Pl,w,Ce,Ly,Il,Ol,Nl,Gi,go,tm,jy,nm,By,Dn,m,Z,ae,Ln,Ne,rm,Ji,sm,Fy,P,Yi,om,zy,M,Hy};