@stacksjs/stx 0.2.845 → 0.2.847

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 (237) hide show
  1. package/dist/app-shell.d.ts +2 -1
  2. package/dist/app-shell.js +3 -3
  3. package/dist/builtins/image-worker.d.ts +1 -17
  4. package/dist/builtins/image-worker.js +3 -16
  5. package/dist/{chunk-rb6vr5v9.js → chunk-09412heg.js} +7 -7
  6. package/dist/chunk-0d4zhbjz.js +2 -0
  7. package/dist/chunk-0g05v7m1.js +2 -0
  8. package/dist/chunk-0vbt87cv.js +2 -0
  9. package/dist/{chunk-n91sm385.js → chunk-0wms5teg.js} +2 -2
  10. package/dist/{chunk-6x6w0v1k.js → chunk-110s34yg.js} +3 -3
  11. package/dist/chunk-11snc6n0.js +2 -0
  12. package/dist/{chunk-py5x8fkq.js → chunk-12r22pf0.js} +2 -2
  13. package/dist/chunk-14cvwsy1.js +3 -0
  14. package/dist/chunk-1menbxwb.js +2 -0
  15. package/dist/chunk-1na30z8t.js +2 -0
  16. package/dist/chunk-1p968nww.js +2 -0
  17. package/dist/chunk-1pf4y2yr.js +2 -0
  18. package/dist/chunk-1rban2td.js +2 -0
  19. package/dist/{chunk-3rjgm7qk.js → chunk-25m74mh1.js} +5 -5
  20. package/dist/{chunk-79wb76ya.js → chunk-2j3gttzf.js} +1 -1
  21. package/dist/{chunk-ka5ea34g.js → chunk-2ts9pb6s.js} +2 -2
  22. package/dist/{chunk-ntg8ttm4.js → chunk-2xf323h9.js} +3 -3
  23. package/dist/chunk-31rtwv90.js +2 -0
  24. package/dist/chunk-341c732h.js +2 -0
  25. package/dist/chunk-343hxxq1.js +2 -0
  26. package/dist/chunk-37bzsnr7.js +2 -0
  27. package/dist/{chunk-97bvpszy.js → chunk-3c2hgvag.js} +3 -3
  28. package/dist/chunk-3m6n90sk.js +2 -0
  29. package/dist/{chunk-9vg3jtzw.js → chunk-3qyz80d6.js} +6 -6
  30. package/dist/{chunk-47n5s7wk.js → chunk-46t924aw.js} +2 -2
  31. package/dist/{chunk-c6yc6qsv.js → chunk-4fc8zs15.js} +5 -5
  32. package/dist/{chunk-6tyjvxgb.js → chunk-5aqvfnvy.js} +8 -8
  33. package/dist/chunk-5bm8hmwd.js +2 -0
  34. package/dist/{chunk-vhxrrqrg.js → chunk-5ghw26vq.js} +2 -2
  35. package/dist/{chunk-4rfedg2f.js → chunk-5m0nyt8d.js} +3 -3
  36. package/dist/{chunk-md84j62m.js → chunk-5njk2ba0.js} +10 -10
  37. package/dist/{chunk-fg80w4zk.js → chunk-5wr1qqz3.js} +2 -2
  38. package/dist/{chunk-7r4p7zjn.js → chunk-5x8q6e1q.js} +6 -6
  39. package/dist/chunk-6bemqsdj.js +2 -0
  40. package/dist/chunk-6hd83cj4.js +2 -0
  41. package/dist/{chunk-k7am94hr.js → chunk-6peq9s4s.js} +5 -5
  42. package/dist/{chunk-1h6pb8d1.js → chunk-6xcmeev9.js} +5 -5
  43. package/dist/chunk-77fs8281.js +2 -0
  44. package/dist/chunk-79pgjds2.js +2 -0
  45. package/dist/chunk-7ycmnsh5.js +2 -0
  46. package/dist/{chunk-78q3apyy.js → chunk-81ysx0tc.js} +2 -2
  47. package/dist/{chunk-s68p10zh.js → chunk-8586a2hh.js} +2 -2
  48. package/dist/chunk-86z8zrn9.js +3 -0
  49. package/dist/chunk-8xb9ecb9.js +2 -0
  50. package/dist/{chunk-mveqaxkr.js → chunk-907zya76.js} +9 -9
  51. package/dist/{chunk-fs5mshcs.js → chunk-93c08def.js} +5 -5
  52. package/dist/chunk-9c6yvh3p.js +2 -0
  53. package/dist/chunk-9fxeqf0e.js +2 -0
  54. package/dist/chunk-9m96yv69.js +2 -0
  55. package/dist/{chunk-6hb75r07.js → chunk-9qxx2teq.js} +6 -6
  56. package/dist/{chunk-rk2ex6qx.js → chunk-9sjtph54.js} +3 -3
  57. package/dist/{chunk-0gg7k9cj.js → chunk-acwdf0cf.js} +5 -5
  58. package/dist/chunk-atsjexk0.js +2 -0
  59. package/dist/{chunk-hc1f1yq8.js → chunk-b3n1m4m5.js} +2 -2
  60. package/dist/chunk-bcefawtc.js +2 -0
  61. package/dist/{chunk-8g5dsjr0.js → chunk-bttvkzxh.js} +6 -6
  62. package/dist/chunk-byjjz7h8.js +2 -0
  63. package/dist/chunk-c0azgkss.js +2 -0
  64. package/dist/{chunk-tzdwg9rw.js → chunk-c541s99z.js} +4 -4
  65. package/dist/chunk-cbz7jtzf.js +2 -0
  66. package/dist/chunk-cq06hsm4.js +2 -0
  67. package/dist/{chunk-5a7etvxz.js → chunk-cv0rmntr.js} +5 -5
  68. package/dist/{chunk-48vnw9t9.js → chunk-cww1zk8y.js} +2 -2
  69. package/dist/{chunk-010yhk6m.js → chunk-cz2s176s.js} +5 -5
  70. package/dist/chunk-dsh91n7n.js +2 -0
  71. package/dist/{chunk-2cafvex6.js → chunk-dv9q56r7.js} +2 -2
  72. package/dist/{chunk-r8xwd8r1.js → chunk-eg2p1cyw.js} +14 -14
  73. package/dist/{chunk-r4jwhy37.js → chunk-emf6ee94.js} +3 -3
  74. package/dist/{chunk-dhgjq9jx.js → chunk-eqbx4yj1.js} +6 -6
  75. package/dist/chunk-evdskc25.js +2 -0
  76. package/dist/chunk-f18rxz70.js +2 -0
  77. package/dist/chunk-f8akfzzn.js +2 -0
  78. package/dist/chunk-f8wmxwa3.js +2 -0
  79. package/dist/{chunk-b6qf7w2b.js → chunk-fa3ygt8c.js} +4 -4
  80. package/dist/{chunk-fm8gfj2g.js → chunk-fez9828r.js} +2 -2
  81. package/dist/chunk-fhyvdxhw.js +4 -0
  82. package/dist/{chunk-nqj1mkkz.js → chunk-fr658fhd.js} +2 -2
  83. package/dist/chunk-fseqwysr.js +2 -0
  84. package/dist/{chunk-zwxncs2e.js → chunk-fxk08je0.js} +9 -9
  85. package/dist/chunk-g891ftgz.js +2 -0
  86. package/dist/{chunk-8qjf16yr.js → chunk-ga650crj.js} +5 -5
  87. package/dist/chunk-gc7gh0g0.js +2 -0
  88. package/dist/chunk-gzx1f8ay.js +2 -0
  89. package/dist/chunk-h526qmg2.js +2 -0
  90. package/dist/{chunk-y06rw18j.js → chunk-h9778nxm.js} +2 -2
  91. package/dist/chunk-hazd1sh8.js +2 -0
  92. package/dist/{chunk-kbv5nwwd.js → chunk-he9dzchk.js} +1 -1
  93. package/dist/{chunk-xr8hg79c.js → chunk-hpaj7zjv.js} +4 -4
  94. package/dist/{chunk-4y6hes3h.js → chunk-hpwtjb4a.js} +2 -2
  95. package/dist/chunk-j08r18x1.js +2 -0
  96. package/dist/chunk-j1sm889p.js +2 -0
  97. package/dist/chunk-j539dz72.js +2 -0
  98. package/dist/{chunk-11kp389s.js → chunk-jaf44web.js} +1 -1
  99. package/dist/{chunk-5p96rafz.js → chunk-jcwtw3hd.js} +2 -2
  100. package/dist/{chunk-tpyk6b4c.js → chunk-jh36gqcq.js} +2 -2
  101. package/dist/chunk-jj5fz0fq.js +12 -0
  102. package/dist/{chunk-x0dx1pyf.js → chunk-jm0qsr3s.js} +3 -3
  103. package/dist/chunk-jmqwpnpd.js +2 -0
  104. package/dist/chunk-jqngvqby.js +2 -0
  105. package/dist/{chunk-9mtyxvhk.js → chunk-jtccqpwa.js} +2 -2
  106. package/dist/chunk-k33kgf8a.js +2 -0
  107. package/dist/{chunk-jabw4ck5.js → chunk-k44qj40k.js} +2 -2
  108. package/dist/chunk-ke8rxpp9.js +2 -0
  109. package/dist/{chunk-302gek13.js → chunk-ks0dwtp0.js} +3 -3
  110. package/dist/chunk-kvttzk86.js +2 -0
  111. package/dist/{chunk-87ksn02m.js → chunk-ma9yq04p.js} +2 -2
  112. package/dist/{chunk-6trgwvt0.js → chunk-mbcqpcyt.js} +12 -12
  113. package/dist/chunk-mfbqjkgp.js +3 -0
  114. package/dist/chunk-my8257pf.js +2 -0
  115. package/dist/{chunk-jf0a5ew8.js → chunk-na1x46xm.js} +3 -3
  116. package/dist/chunk-nm04926f.js +2 -0
  117. package/dist/chunk-nnnf8cjv.js +2 -0
  118. package/dist/{chunk-ncrrxp60.js → chunk-nws4zm4k.js} +4 -4
  119. package/dist/chunk-p2fkggw4.js +3 -0
  120. package/dist/{chunk-c62wxswd.js → chunk-prnebmz1.js} +39 -39
  121. package/dist/chunk-q18508s2.js +2 -0
  122. package/dist/{chunk-k1tbgnhf.js → chunk-q61r0m6r.js} +1 -1
  123. package/dist/chunk-qay7pgnq.js +2 -0
  124. package/dist/{chunk-rpapxkdm.js → chunk-qpz9jrvw.js} +3 -3
  125. package/dist/chunk-r6085mp4.js +2 -0
  126. package/dist/{chunk-7s411sa9.js → chunk-r96ahk8s.js} +5 -5
  127. package/dist/chunk-rke4q3jk.js +2 -0
  128. package/dist/{chunk-r3jf8v5a.js → chunk-rqjskxpw.js} +32 -32
  129. package/dist/chunk-rsa9ssz7.js +33 -0
  130. package/dist/{chunk-y7aqf8r7.js → chunk-s4wcksaw.js} +2 -2
  131. package/dist/{chunk-vf0xbptq.js → chunk-s6td2c1k.js} +2 -2
  132. package/dist/chunk-se79v0pe.js +2 -0
  133. package/dist/{chunk-rncmfgpk.js → chunk-sz2nax5v.js} +32 -32
  134. package/dist/{chunk-kxj5sp5w.js → chunk-t4dkcf28.js} +114 -25
  135. package/dist/{chunk-4dxq7ft1.js → chunk-t5q31st4.js} +2 -2
  136. package/dist/{chunk-5y3m5vzg.js → chunk-tb5h85ag.js} +2 -2
  137. package/dist/{chunk-02qbawwq.js → chunk-tm5t3hh3.js} +3 -3
  138. package/dist/{chunk-bqsrtvad.js → chunk-trgbdydw.js} +2 -2
  139. package/dist/chunk-twfx2scr.js +2 -0
  140. package/dist/{chunk-hgk1v60t.js → chunk-txs1vxas.js} +10 -10
  141. package/dist/{chunk-315q48qy.js → chunk-v5tzcd49.js} +7 -7
  142. package/dist/chunk-v7d7m4k1.js +2 -0
  143. package/dist/chunk-vdb3p2v3.js +2 -0
  144. package/dist/chunk-vm2y05sr.js +2 -0
  145. package/dist/{chunk-f34ce0pn.js → chunk-vm68yvgf.js} +6 -6
  146. package/dist/{chunk-69b8mr68.js → chunk-wdwx2aa6.js} +2 -2
  147. package/dist/{chunk-1c6kczkt.js → chunk-wp14sf2j.js} +2 -2
  148. package/dist/{chunk-2ytaezad.js → chunk-wzyc9da7.js} +2 -2
  149. package/dist/chunk-xc1k2zza.js +2 -0
  150. package/dist/{chunk-ndsygfeb.js → chunk-xn0ebqgw.js} +14 -14
  151. package/dist/{chunk-zjqvbcwa.js → chunk-xppm4cs4.js} +2 -2
  152. package/dist/{chunk-3ba0nqwm.js → chunk-y1cneng3.js} +2 -2
  153. package/dist/{chunk-tjnf4a8g.js → chunk-ybgzr6wn.js} +64 -64
  154. package/dist/{chunk-3sskqw4b.js → chunk-yrmppd8r.js} +1 -1
  155. package/dist/{chunk-pb9347sn.js → chunk-ysqzz2h3.js} +3 -3
  156. package/dist/{chunk-28zze2wm.js → chunk-z57xq46m.js} +1 -1
  157. package/dist/{chunk-mnt7jbek.js → chunk-zfb2wnha.js} +3 -3
  158. package/dist/cli.js +20 -20
  159. package/dist/craft-entry.js +2 -2
  160. package/dist/craft.js +2 -2
  161. package/dist/framework-composables.js +13 -1
  162. package/dist/installed-entry.d.ts +8 -0
  163. package/dist/installed-entry.js +19 -0
  164. package/dist/page-head.d.ts +15 -0
  165. package/dist/page-head.js +35 -10
  166. package/dist/pwa.js +3 -3
  167. package/dist/ssg.js +6 -6
  168. package/dist/template-compiler.js +2 -2
  169. package/package.json +5 -5
  170. package/dist/chunk-01gwdj2y.js +0 -2
  171. package/dist/chunk-07hvjvj1.js +0 -2
  172. package/dist/chunk-12tkqtrv.js +0 -2
  173. package/dist/chunk-168fwztf.js +0 -2
  174. package/dist/chunk-1cdxe8yt.js +0 -2
  175. package/dist/chunk-1k751fgt.js +0 -2
  176. package/dist/chunk-3qa40hgd.js +0 -2
  177. package/dist/chunk-3qstewq3.js +0 -2
  178. package/dist/chunk-40r740w1.js +0 -2
  179. package/dist/chunk-469nzheq.js +0 -2
  180. package/dist/chunk-5hhyqze9.js +0 -2
  181. package/dist/chunk-60jtrz9f.js +0 -2
  182. package/dist/chunk-64evx0my.js +0 -2
  183. package/dist/chunk-6vcpmt0y.js +0 -2
  184. package/dist/chunk-7tdwa595.js +0 -2
  185. package/dist/chunk-7xp2ec0v.js +0 -2
  186. package/dist/chunk-8hy5g1hq.js +0 -32
  187. package/dist/chunk-8nq2snvy.js +0 -2
  188. package/dist/chunk-8s27mteq.js +0 -2
  189. package/dist/chunk-8weaawqm.js +0 -2
  190. package/dist/chunk-afyvnpr9.js +0 -2
  191. package/dist/chunk-as6x6be8.js +0 -2
  192. package/dist/chunk-aw45yjrw.js +0 -2
  193. package/dist/chunk-b30fzxwd.js +0 -2
  194. package/dist/chunk-b3wcs8bk.js +0 -2
  195. package/dist/chunk-bygxt820.js +0 -3
  196. package/dist/chunk-c3y7cxe7.js +0 -2
  197. package/dist/chunk-d5bjpjbv.js +0 -2
  198. package/dist/chunk-dmmt4psb.js +0 -12
  199. package/dist/chunk-e1vf62ck.js +0 -2
  200. package/dist/chunk-eaz30495.js +0 -4
  201. package/dist/chunk-emzz6seq.js +0 -2
  202. package/dist/chunk-exr9599h.js +0 -2
  203. package/dist/chunk-f1wv2q2z.js +0 -2
  204. package/dist/chunk-fpc1n3je.js +0 -2
  205. package/dist/chunk-fyesbfvr.js +0 -2
  206. package/dist/chunk-fz433ybr.js +0 -2
  207. package/dist/chunk-hbkh87n2.js +0 -2
  208. package/dist/chunk-hpw6hq7p.js +0 -2
  209. package/dist/chunk-j274w1ac.js +0 -2
  210. package/dist/chunk-jf37tpj2.js +0 -2
  211. package/dist/chunk-jv2z9qb7.js +0 -2
  212. package/dist/chunk-k609nyan.js +0 -2
  213. package/dist/chunk-msd0ezxm.js +0 -2
  214. package/dist/chunk-n4c8srx8.js +0 -2
  215. package/dist/chunk-nfxd6y75.js +0 -2
  216. package/dist/chunk-pj1xj34h.js +0 -2
  217. package/dist/chunk-pv2mrc9g.js +0 -2
  218. package/dist/chunk-pwdnqe30.js +0 -2
  219. package/dist/chunk-qeej9h56.js +0 -2
  220. package/dist/chunk-rapk2r7b.js +0 -2
  221. package/dist/chunk-rrj3gv46.js +0 -3
  222. package/dist/chunk-sss23kn5.js +0 -2
  223. package/dist/chunk-st75663x.js +0 -2
  224. package/dist/chunk-sv52qc36.js +0 -3
  225. package/dist/chunk-t4n23dh5.js +0 -2
  226. package/dist/chunk-vkrxrt0a.js +0 -2
  227. package/dist/chunk-vzpbxgg7.js +0 -2
  228. package/dist/chunk-wvwca1e9.js +0 -2
  229. package/dist/chunk-xjbc3bhs.js +0 -2
  230. package/dist/chunk-xtbmntht.js +0 -2
  231. package/dist/chunk-xvd3vdrw.js +0 -2
  232. package/dist/chunk-xvtp7nyj.js +0 -2
  233. package/dist/chunk-xy45tx27.js +0 -2
  234. package/dist/chunk-yg5a54pj.js +0 -2
  235. package/dist/chunk-yhzakgpp.js +0 -2
  236. package/dist/chunk-z3qgv971.js +0 -2
  237. package/dist/chunk-zztfp9qh.js +0 -2
@@ -1,17 +1,17 @@
1
1
  // @bun
2
- import{yl,bl}from"./chunk-n91sm385.js";import{f,P,ot,d}from"./chunk-r8xwd8r1.js";import{U,wr,Ds,Ms,ci,li,Ls,fn,De,fe,J,Sr,kr,ie,Y,N,st,_r,pi,Tr,ze,r,p,W,Sn}from"./chunk-tjnf4a8g.js";import{n}from"./chunk-sv52qc36.js";import{oe}from"./chunk-48vnw9t9.js";import{s}from"./chunk-x0dx1pyf.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Ct}from"crypto";import Q from"fs";import Z from"path";import Me from"fs";function Ce(e,i,t){let o=Buffer.alloc(t),a=Me.readSync(e,o,0,t,i);return o.subarray(0,a)}function Le(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let t=i(12,16);if(t==="VP8X")return(e[20]&16)!==0;if(t==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Ue(e){let i;try{i=Me.openSync(e,"r");let t=Ce(i,0,33);if(t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255)return"none";if(t.length>=26&&t[0]===137&&t.toString("latin1",1,4)==="PNG"){let o=t[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(i,a,8);if(l.length<8)return"unknown";let u=l.toString("latin1",4,8);if(u==="tRNS")return"possible";if(u==="IDAT"||u==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(t.length>=25&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){if(Le(t))return"possible";let o=t.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)Me.closeSync(i)}}import Yt from"fs";import ke from"os";import{join as pt}from"path";import{fileURLToPath as mt}from"url";var Pe=Symbol("stx.image-worker.unavailable");function Qt(e=typeof ke.availableParallelism==="function"?ke.availableParallelism():ke.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function en(){if(Ae<Qt()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function tn(){Ae--,yt.shift()?.()}var nn="@stacksjs/stx/builtins/image-warmup-worker";function rn(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let t=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(t.protocol==="file:"&&Yt.existsSync(mt(t)))return mt(t)}catch{}try{let t=typeof Bun<"u"?Bun.resolveSync(nn,e):void 0;return t&&sn(t)?t:void 0}catch{return}}function sn(e,i=process.env){let t=e.replace(/\\/g,"/");if(t.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![i.BUN_INSTALL_CACHE_DIR,pt(i.BUN_INSTALL||pt(ke.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>t.startsWith(a))}var ht=!1;function ue(e){if(!ht)ht=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return Pe}function Re(e){return e instanceof Error?e.message:String(e)}async function Fe(e,i){let t;try{t=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Re(a)}`)}if(typeof t!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=rn();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await en();try{return await new Promise((a,c)=>{let l;try{l=new t(o)}catch(y){a(ue(`could not start ${o}: ${Re(y)}`));return}let u=!1,m=!1,v=(y)=>{if(m)return;m=!0,y(),l.terminate()};l.on("message",(y)=>{if(y.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(y.type==="result"){v(()=>a(y.value));return}let h=Error(y.error?.message??"image worker failed");if(y.error?.name)h.name=y.error.name;if(y.error?.stack)h.stack=y.error.stack;v(()=>c(h))}),l.on("error",(y)=>{v(()=>u?c(y instanceof Error?y:Error(Re(y)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Re(y)}`)))}),l.on("exit",(y)=>{v(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${y} before it was ready`)))})})}finally{tn()}}var on=new Set([".avif",".jpeg",".jpg",".png",".webp"]),an=[320,640,960,1280,1920],ye="/_stx/images",cn=`stx:${ye}:alpha-1`,ln=`stx:${ye}:opaque-1`,un=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ie;function dn(e,i){let t=Z.dirname(Bun.resolveSync(e,i));while(t!==Z.dirname(t)){let o=Z.join(t,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}t=Z.dirname(t)}return}function bt(){if(Ie!==void 0)return Ie;let e;try{e=Z.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ie=un.map((i)=>{let t;try{t=e?dn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${t??"unknown"}`}).join("+"),Ie}var vt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[vt]??={catalog:new Map,transparent:new Set},e[vt]}var xt=new Set;function gn(e){return`/${e.split(Z.sep).map(encodeURIComponent).join("/")}`}function pn(e){let i=Z.extname(e),t=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Ct("sha256").update(e).digest("hex").slice(0,8);return`${t||"image"}-${o}`}function wt(e,i=`stx:${ye}`){let t=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=Z.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:t(o)}:null}catch{return null}},async write(o,a){let c=Z.join(e,o);await Q.promises.mkdir(Z.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:t(o)}},url:t}}async function Rt(e,i=e){let t=await Q.promises.readdir(i,{withFileTypes:!0});t.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of t){let c=Z.join(i,a.name);if(a.isDirectory()){o.push(...await Rt(e,c));continue}if(!a.isFile()||!on.has(Z.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Z.relative(e,c)})}return o}function $t(e,i){return e.map((t)=>({key:gn(t.relativePath),input:t.absolutePath,name:pn(t.relativePath),...mn(t.absolutePath)?{options:{storage:i}}:{}}))}function mn(e){return Ue(e)==="possible"}function hn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function yn(e){let i=Object.entries(e).filter(([,c])=>c.fallback.format==="png"),t=new Set,o=8;if(i.length===0)return t;let{decode:a}=await import("ts-images");for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async([l,u])=>{let m=u.variants.filter((v)=>v.format==="png").sort((v,y)=>v.width-y.width)[0];try{let v=await a(new Uint8Array(await Q.promises.readFile(m?.path??u.fallback.path)));if(hn(v.data))t.add(l)}catch{t.add(l)}}));return t}function bn(e,i){let t=[];for(let o of i){let a=e[o],c=a?.variants.filter((u)=>u.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((u)=>{let m;try{return m=Q.openSync(u.path,"r"),!Le(Ce(m,0,32))}catch{return!0}finally{if(m!==void 0)Q.closeSync(m)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,t.push(o),!xt.has(o))xt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return t}async function vn(e){let i=[],t=8;if(e.length===0)return i;let{generateThumbHash:o}=await import("ts-images");for(let a=0;a<e.length;a+=8){let c=e.slice(a,a+8),l=await Promise.all(c.map(async(u)=>{try{return await o(u.absolutePath),u}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${u.relativePath}`),null}}));i.push(...l.filter((u)=>u!==null))}return i}function We(e){return Z.join(e,"undecodable.json")}function xn(e){try{let i=Q.readFileSync(We(e),"utf-8"),t=JSON.parse(i);return t&&typeof t==="object"?t:{}}catch{return{}}}function wn(e,i){try{Q.mkdirSync(Z.dirname(We(e)),{recursive:!0}),Q.writeFileSync(We(e),JSON.stringify(i))}catch{}}function St(e){try{let i=Q.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function kt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Bo(e){let i=kt(e);return i?be().catalog.get(i):void 0}function Fo(e){let i=kt(e);return i?be().transparent.has(i):!1}function zo(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),t=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<t).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Mh(e){let i=Bo(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:zo(i).map(({format:t,srcset:o})=>({type:`image/${t}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:Fo(e)?void 0:i.placeholder?.dataUrl}}function ds(){let e=be();e.catalog=new Map,e.transparent=new Set}function $n(e){let i=be();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function Lh(e,i,t={}){if(!e||!Q.existsSync(e))return ds(),{count:0,fingerprint:""};if(t.offThread){let b=await Fe("delivery",{publicDir:e,outputDir:i});if(b!==Pe)return $n(b.state),b.result}let o=await Rt(e);if(o.length===0)return ds(),{count:0,fingerprint:""};let a=xn(i),c=o.filter((b)=>{let w=a[b.relativePath];if(!w)return!0;let A=St(b.absolutePath);return!A||A.mtimeMs!==w.mtimeMs||A.size!==w.size});if(c.length===0)return ds(),{count:0,fingerprint:""};let l=wt(Z.join(i,"_stx","images"),`${cn}:${bt()}`),u={outDir:Z.join(i,"_stx","images"),storage:wt(Z.join(i,"_stx","images"),`${ln}:${bt()}`),baseUrl:ye,widths:an,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:m}=await import("ts-images/delivery"),v=c,y;try{y=await m({...u,entries:$t(c,l)})}catch(b){if(v=await vn(c),v.length===c.length)throw b;let w=new Set(v.map((k)=>k.relativePath)),A=!1;for(let k of c){if(w.has(k.relativePath))continue;let R=St(k.absolutePath);if(!R)continue;a[k.relativePath]=R,A=!0}if(A)wn(i,a);if(v.length===0)return ds(),{count:0,fingerprint:""};y=await m({...u,entries:$t(v,l)})}let h=await yn(y.entries),C=bn(y.entries,h),x=be();x.catalog=new Map(Object.entries(y.entries)),x.transparent=h;let S=h.size===0&&C.length===0?y.fingerprint:Ct("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...h].sort(),droppedWebp:C.sort()})).digest("hex");return{count:v.length,fingerprint:S}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,t,o){let a=ci(e,o);if(a!==void 0)return a;for(let c of li(e,i,t,o))if(await r(c))return c;return null}}var de=new At;var re="\x00stx-boolean-attribute";function He(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function qe(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||Cn.has(i)}function se(e,i){let t=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)t.push(p(c));continue}if(a===re){t.push(p(c));continue}t.push(`${p(c)}="${Sn(c,He(String(a)))}"`)}return t}function ae(e,i){let t=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){t.push(p(c));continue}if(typeof a==="object")continue;t.push(`${p(c)}="${Sn(c,He(String(a)))}"`)}return t}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Xe={name:"StxLink",aliases:["stx-link"],render(e,i,t){let o=Rn(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",u=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,m=[];if(o.reactive)m.push(`:href="${n(o.value)}"`);else m.push(`href="${n(Sr(o.value,"navigable"))}"`);if(a)m.push(`class="${n(a)}"`);if(m.push("data-stx-link"),m.push(`data-stx-active-class="${n(c)}"`),m.push(`data-stx-exact-active-class="${n(l)}"`),u)m.push("data-stx-prefetch");let v=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(v)m.push(`data-stx-active-match="${n(v)}"`);let y=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return m.push(...se(e,y)),m.push(...ae(e,y)),`<a ${m.join(" ")}>${i}</a>`}};var kn=new Map;function Ve(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return kn.get(i)}var An={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function V(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function _e(e,i,t=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return t}function Ge(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),t=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=An[a];if(l)t.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))t.push(`(max-width: ${u}px) ${c}`)}}else t.push(o);return t.join(", ")}function Ke(e,i,t,o){return i.map((a)=>`${ve(e,a,void 0,t,o)} ${a}w`).join(", ")}function Pn(e,i,t,o,a){return i.map((c)=>{let l=t?t*c:void 0;return`${ve(e,l,void 0,o,a)} ${c}x`}).join(", ")}function ve(e,i,t,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(t)c.push(`h_${t}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(t)c.set("h",String(t));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(t)c.set("height",String(t));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function In(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function _n(e,i,t="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${t}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Je={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,t){let o=V(e,"src")||"",a=Bo(o),c=V(e,"alt")||"",l=V(e,"width")||(a?String(a.source.width):void 0),u=V(e,"height")||(a?String(a.source.height):void 0),m=V(e,"sizes"),v=V(e,"srcset"),y=V(e,"densities"),h=V(e,"format"),C=Fo(o)||Ve(o)?.transparent===!0,x=V(e,"placeholder")||(a&&!C?"thumbhash":void 0),S=V(e,"placeholderColor")||"#e5e7eb",b=V(e,"provider"),w=V(e,"class")||V(e,"className")||"",A=V(e,"style")||"",k=V(e,"objectFit")||V(e,"fit"),R=V(e,"objectPosition")||V(e,"position"),T=V(e,"quality"),G=_e(e,"lazy",!0),M=_e(e,"preload",!1),F=_e(e,"priority",!1),H=V(e,"loading"),E=V(e,"decoding")||"async",O=!!a||_e(e,"picture",!1)||!!h,B=l?Number.parseInt(l):void 0,q=u?Number.parseInt(u):void 0,L=v||"",X="";if(a)L=a.sources[a.fallback.format]||"",X=m?Ge(m):"100vw";else if(!L&&m&&b&&b!=="local"&&b!=="static")L=Ke(o,Ze,b,h),X=Ge(m);else if(!L&&y){let I=y.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));L=Pn(o,I,B,b,h)}else if(m)X=Ge(m);let z=[];if(A)z.push(A);if(k)z.push(`object-fit:${k}`);if(R)z.push(`object-position:${R}`);if(B&&q)z.push(`aspect-ratio:${B}/${q}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:S}:Ve(o);if(I&&x==="color")z.push(`background-color:${I.color}`),D.push("backgroundColor");else if(I)z.push(`background-color:${I.color}`),z.push(`background-image:url(${I.dataUrl})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let _=_n(B||16,q||9,S);z.push(`background-image:url(${_})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")z.push(`background-image:url(${n(x)})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||ve(o,B,q,b,h),K=[];if(K.push(`src="${n(Sr($e,"fetched"))}"`),K.push(`alt="${n(c)}"`),l)K.push(`width="${n(l)}"`);if(u)K.push(`height="${n(u)}"`);let le=H||(F||M?"eager":G?"lazy":"");if(le)K.push(`loading="${n(le)}"`);if(F)K.push('fetchpriority="high"');if(K.push(`decoding="${n(E)}"`),w)K.push(`class="${n(w)}"`);if(z.length>0)K.push(`style="${n(z.join(";"))}"`);if(L)K.push(`srcset="${n(Sr(L,"fetched"))}"`);if(X)K.push(`sizes="${n(X)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(D.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=In(D)+(I?`;${I}`:"");K.push(`onload="${n(_)}"`),te.add("onload")}K.push(...se(e,te)),K.push(...ae(e,te));let je=`<img ${K.join(" ")} />`,j="";if(M){let _=h==="webp"?"image/webp":h==="avif"?"image/avif":"";j=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${L?` imagesrcset="${n(L)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
3
- `}if(O){let I=[];if(a)for(let _ of zo(a))I.push(`<source type="image/${_.format}" srcset="${n(_.srcset)}"${X?` sizes="${n(X)}"`:""} />`);if(!a&&(h==="avif"||h==="auto")){let _=ve(o,B,q,b,"avif"),ee=L?Ke(o,Ze,b,"avif"):`${_}`;I.push(`<source type="image/avif" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}if(!a&&(h==="webp"||h==="auto")){let _=ve(o,B,q,b,"webp"),ee=L?Ke(o,Ze,b,"webp"):`${_}`;I.push(`<source type="image/webp" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}return`${j}<picture>
2
+ import{wl,vl}from"./chunk-0wms5teg.js";import{f,P,ot,d}from"./chunk-eg2p1cyw.js";import{U,xr,Ls,js,ui,di,Bs,gn,De,fe,J,_r,Cr,ie,Y,N,st,Er,gi,Rr,ze,r,p,W,kn}from"./chunk-ybgzr6wn.js";import{n}from"./chunk-mfbqjkgp.js";import{oe}from"./chunk-cww1zk8y.js";import{lr}from"./chunk-14cvwsy1.js";import{s}from"./chunk-jm0qsr3s.js";import{g}from"./chunk-0dve54ne.js";import{createHash as St}from"crypto";import Q from"fs";import Z from"path";import je from"fs";function Ce(e,i,t){let o=Buffer.alloc(t),a=je.readSync(e,o,0,t,i);return o.subarray(0,a)}function Me(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let t=i(12,16);if(t==="VP8X")return(e[20]&16)!==0;if(t==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Le(e){let i;try{i=je.openSync(e,"r");let t=Ce(i,0,33);if(t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255)return"none";if(t.length>=26&&t[0]===137&&t.toString("latin1",1,4)==="PNG"){let o=t[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(i,a,8);if(l.length<8)return"unknown";let u=l.toString("latin1",4,8);if(u==="tRNS")return"possible";if(u==="IDAT"||u==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(t.length>=25&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){if(Me(t))return"possible";let o=t.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)je.closeSync(i)}}import Jt from"fs";import Fe from"os";import{fileURLToPath as pt}from"url";var Ae=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Fe.availableParallelism==="function"?Fe.availableParallelism():Fe.cpus().length){return Math.max(1,Math.min(2,e-1))}var ke=0,ht=[];async function Qt(){if(ke<Yt()){ke++;return}await new Promise((e)=>ht.push(e)),ke++}function en(){ke--,ht.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let t=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(t.protocol==="file:"&&Jt.existsSync(pt(t)))return pt(t)}catch{}return lr(tn,e)}var mt=!1;function ue(e){if(!mt)mt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return Ae}function Re(e){return e instanceof Error?e.message:String(e)}async function Ue(e,i){let t;try{t=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Re(a)}`)}if(typeof t!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=nn();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((a,c)=>{let l;try{l=new t(o)}catch(y){a(ue(`could not start ${o}: ${Re(y)}`));return}let u=!1,m=!1,v=(y)=>{if(m)return;m=!0,y(),l.terminate()};l.on("message",(y)=>{if(y.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(y.type==="result"){v(()=>a(y.value));return}let h=Error(y.error?.message??"image worker failed");if(y.error?.name)h.name=y.error.name;if(y.error?.stack)h.stack=y.error.stack;v(()=>c(h))}),l.on("error",(y)=>{v(()=>u?c(y instanceof Error?y:Error(Re(y)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Re(y)}`)))}),l.on("exit",(y)=>{v(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${y} before it was ready`)))})})}finally{en()}}var rn=new Set([".avif",".jpeg",".jpg",".png",".webp"]),sn=[320,640,960,1280,1920],ye="/_stx/images",on=`stx:${ye}:alpha-1`,an=`stx:${ye}:opaque-1`,cn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function ln(e,i){let t=Z.dirname(Bun.resolveSync(e,i));while(t!==Z.dirname(t)){let o=Z.join(t,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}t=Z.dirname(t)}return}function yt(){if(Pe!==void 0)return Pe;let e;try{e=Z.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=cn.map((i)=>{let t;try{t=e?ln(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${t??"unknown"}`}).join("+"),Pe}var bt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[bt]??={catalog:new Map,transparent:new Set},e[bt]}var vt=new Set;function un(e){return`/${e.split(Z.sep).map(encodeURIComponent).join("/")}`}function fn(e){let i=Z.extname(e),t=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=St("sha256").update(e).digest("hex").slice(0,8);return`${t||"image"}-${o}`}function xt(e,i=`stx:${ye}`){let t=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=Z.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:t(o)}:null}catch{return null}},async write(o,a){let c=Z.join(e,o);await Q.promises.mkdir(Z.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:t(o)}},url:t}}async function Ct(e,i=e){let t=await Q.promises.readdir(i,{withFileTypes:!0});t.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of t){let c=Z.join(i,a.name);if(a.isDirectory()){o.push(...await Ct(e,c));continue}if(!a.isFile()||!rn.has(Z.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Z.relative(e,c)})}return o}function wt(e,i){return e.map((t)=>({key:un(t.relativePath),input:t.absolutePath,name:fn(t.relativePath),...dn(t.absolutePath)?{options:{storage:i}}:{}}))}function dn(e){return Le(e)==="possible"}function pn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function mn(e){let i=Object.entries(e).filter(([,c])=>c.fallback.format==="png"),t=new Set,o=8;if(i.length===0)return t;let{decode:a}=await import("ts-images");for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async([l,u])=>{let m=u.variants.filter((v)=>v.format==="png").sort((v,y)=>v.width-y.width)[0];try{let v=await a(new Uint8Array(await Q.promises.readFile(m?.path??u.fallback.path)));if(pn(v.data))t.add(l)}catch{t.add(l)}}));return t}function hn(e,i){let t=[];for(let o of i){let a=e[o],c=a?.variants.filter((u)=>u.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((u)=>{let m;try{return m=Q.openSync(u.path,"r"),!Me(Ce(m,0,32))}catch{return!0}finally{if(m!==void 0)Q.closeSync(m)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,t.push(o),!vt.has(o))vt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return t}async function yn(e){let i=[],t=8;if(e.length===0)return i;let{generateThumbHash:o}=await import("ts-images");for(let a=0;a<e.length;a+=8){let c=e.slice(a,a+8),l=await Promise.all(c.map(async(u)=>{try{return await o(u.absolutePath),u}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${u.relativePath}`),null}}));i.push(...l.filter((u)=>u!==null))}return i}function We(e){return Z.join(e,"undecodable.json")}function bn(e){try{let i=Q.readFileSync(We(e),"utf-8"),t=JSON.parse(i);return t&&typeof t==="object"?t:{}}catch{return{}}}function vn(e,i){try{Q.mkdirSync(Z.dirname(We(e)),{recursive:!0}),Q.writeFileSync(We(e),JSON.stringify(i))}catch{}}function $t(e){try{let i=Q.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function Rt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function zo(e){let i=Rt(e);return i?be().catalog.get(i):void 0}function Ho(e){let i=Rt(e);return i?be().transparent.has(i):!1}function Vo(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),t=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<t).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function jh(e){let i=zo(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:Vo(i).map(({format:t,srcset:o})=>({type:`image/${t}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:Ho(e)?void 0:i.placeholder?.dataUrl}}function gs(){let e=be();e.catalog=new Map,e.transparent=new Set}function xn(e){let i=be();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function Bh(e,i,t={}){if(!e||!Q.existsSync(e))return gs(),{count:0,fingerprint:""};if(t.offThread){let b=await Ue("delivery",{publicDir:e,outputDir:i});if(b!==Ae)return xn(b.state),b.result}let o=await Ct(e);if(o.length===0)return gs(),{count:0,fingerprint:""};let a=bn(i),c=o.filter((b)=>{let w=a[b.relativePath];if(!w)return!0;let A=$t(b.absolutePath);return!A||A.mtimeMs!==w.mtimeMs||A.size!==w.size});if(c.length===0)return gs(),{count:0,fingerprint:""};let l=xt(Z.join(i,"_stx","images"),`${on}:${yt()}`),u={outDir:Z.join(i,"_stx","images"),storage:xt(Z.join(i,"_stx","images"),`${an}:${yt()}`),baseUrl:ye,widths:sn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:m}=await import("ts-images/delivery"),v=c,y;try{y=await m({...u,entries:wt(c,l)})}catch(b){if(v=await yn(c),v.length===c.length)throw b;let w=new Set(v.map((k)=>k.relativePath)),A=!1;for(let k of c){if(w.has(k.relativePath))continue;let R=$t(k.absolutePath);if(!R)continue;a[k.relativePath]=R,A=!0}if(A)vn(i,a);if(v.length===0)return gs(),{count:0,fingerprint:""};y=await m({...u,entries:wt(v,l)})}let h=await mn(y.entries),C=hn(y.entries,h),x=be();x.catalog=new Map(Object.entries(y.entries)),x.transparent=h;let S=h.size===0&&C.length===0?y.fingerprint:St("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...h].sort(),droppedWebp:C.sort()})).digest("hex");return{count:v.length,fingerprint:S}}class kt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,t,o){let a=ui(e,o);if(a!==void 0)return a;for(let c of di(e,i,t,o))if(await r(c))return c;return null}}var de=new kt;var re="\x00stx-boolean-attribute";function He(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var wn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function qe(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||wn.has(i)}function se(e,i){let t=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)t.push(p(c));continue}if(a===re){t.push(p(c));continue}t.push(`${p(c)}="${kn(c,He(String(a)))}"`)}return t}function ae(e,i){let t=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){t.push(p(c));continue}if(typeof a==="object")continue;t.push(`${p(c)}="${kn(c,He(String(a)))}"`)}return t}function $n(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Xe={name:"StxLink",aliases:["stx-link"],render(e,i,t){let o=$n(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",u=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,m=[];if(o.reactive)m.push(`:href="${n(o.value)}"`);else m.push(`href="${n(_r(o.value,"navigable"))}"`);if(a)m.push(`class="${n(a)}"`);if(m.push("data-stx-link"),m.push(`data-stx-active-class="${n(c)}"`),m.push(`data-stx-exact-active-class="${n(l)}"`),u)m.push("data-stx-prefetch");let v=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(v)m.push(`data-stx-active-match="${n(v)}"`);let y=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return m.push(...se(e,y)),m.push(...ae(e,y)),`<a ${m.join(" ")}>${i}</a>`}};var Sn=new Map;function Ve(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return Sn.get(i)}var Cn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function V(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function Ie(e,i,t=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return t}function Ge(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),t=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=Cn[a];if(l)t.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))t.push(`(max-width: ${u}px) ${c}`)}}else t.push(o);return t.join(", ")}function Ke(e,i,t,o){return i.map((a)=>`${ve(e,a,void 0,t,o)} ${a}w`).join(", ")}function Rn(e,i,t,o,a){return i.map((c)=>{let l=t?t*c:void 0;return`${ve(e,l,void 0,o,a)} ${c}x`}).join(", ")}function ve(e,i,t,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(t)c.push(`h_${t}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(t)c.set("h",String(t));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(t)c.set("height",String(t));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function An(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function Pn(e,i,t="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${t}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Je={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,t){let o=V(e,"src")||"",a=zo(o),c=V(e,"alt")||"",l=V(e,"width")||(a?String(a.source.width):void 0),u=V(e,"height")||(a?String(a.source.height):void 0),m=V(e,"sizes"),v=V(e,"srcset"),y=V(e,"densities"),h=V(e,"format"),C=Ho(o)||Ve(o)?.transparent===!0,x=V(e,"placeholder")||(a&&!C?"thumbhash":void 0),S=V(e,"placeholderColor")||"#e5e7eb",b=V(e,"provider"),w=V(e,"class")||V(e,"className")||"",A=V(e,"style")||"",k=V(e,"objectFit")||V(e,"fit"),R=V(e,"objectPosition")||V(e,"position"),T=V(e,"quality"),G=Ie(e,"lazy",!0),M=Ie(e,"preload",!1),F=Ie(e,"priority",!1),H=V(e,"loading"),E=V(e,"decoding")||"async",O=!!a||Ie(e,"picture",!1)||!!h,B=l?Number.parseInt(l):void 0,q=u?Number.parseInt(u):void 0,L=v||"",X="";if(a)L=a.sources[a.fallback.format]||"",X=m?Ge(m):"100vw";else if(!L&&m&&b&&b!=="local"&&b!=="static")L=Ke(o,Ze,b,h),X=Ge(m);else if(!L&&y){let I=y.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));L=Rn(o,I,B,b,h)}else if(m)X=Ge(m);let z=[];if(A)z.push(A);if(k)z.push(`object-fit:${k}`);if(R)z.push(`object-position:${R}`);if(B&&q)z.push(`aspect-ratio:${B}/${q}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:S}:Ve(o);if(I&&x==="color")z.push(`background-color:${I.color}`),D.push("backgroundColor");else if(I)z.push(`background-color:${I.color}`),z.push(`background-image:url(${I.dataUrl})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let _=Pn(B||16,q||9,S);z.push(`background-image:url(${_})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")z.push(`background-image:url(${n(x)})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||ve(o,B,q,b,h),K=[];if(K.push(`src="${n(_r($e,"fetched"))}"`),K.push(`alt="${n(c)}"`),l)K.push(`width="${n(l)}"`);if(u)K.push(`height="${n(u)}"`);let le=H||(F||M?"eager":G?"lazy":"");if(le)K.push(`loading="${n(le)}"`);if(F)K.push('fetchpriority="high"');if(K.push(`decoding="${n(E)}"`),w)K.push(`class="${n(w)}"`);if(z.length>0)K.push(`style="${n(z.join(";"))}"`);if(L)K.push(`srcset="${n(_r(L,"fetched"))}"`);if(X)K.push(`sizes="${n(X)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(D.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=An(D)+(I?`;${I}`:"");K.push(`onload="${n(_)}"`),te.add("onload")}K.push(...se(e,te)),K.push(...ae(e,te));let Te=`<img ${K.join(" ")} />`,j="";if(M){let _=h==="webp"?"image/webp":h==="avif"?"image/avif":"";j=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${L?` imagesrcset="${n(L)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
3
+ `}if(O){let I=[];if(a)for(let _ of Vo(a))I.push(`<source type="image/${_.format}" srcset="${n(_.srcset)}"${X?` sizes="${n(X)}"`:""} />`);if(!a&&(h==="avif"||h==="auto")){let _=ve(o,B,q,b,"avif"),ee=L?Ke(o,Ze,b,"avif"):`${_}`;I.push(`<source type="image/avif" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}if(!a&&(h==="webp"||h==="auto")){let _=ve(o,B,q,b,"webp"),ee=L?Ke(o,Ze,b,"webp"):`${_}`;I.push(`<source type="image/webp" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}return`${j}<picture>
4
4
  ${I.join(`
5
5
  `)}
6
- ${je}
7
- </picture>`}return`${j}${je}`}};var Pt="/images/safe-image-default.svg";function ge(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var En=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${Pt}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,Ye={name:"SafeImage",aliases:["safe-image","safe-img"],render(e,i,t){let o=ge(e,"src")||"",a=ge(e,"alt")||"",c=ge(e,"fallback")||Pt,l=ge(e,"class")||ge(e,"className")||"",u=ge(e,"fallbackClassName")||"",m=[];if(m.push(`src="${n(o)}"`),m.push(`alt="${n(a)}"`),l)m.push(`class="${n(l)}"`);if(m.push(`data-fallback="${n(c)}"`),u)m.push(`data-fallback-class="${n(u)}"`);m.push('onerror="window.__stxSafeImageHandler(this)"');let v=new Set(["src","alt","fallback","class","className","fallbackClassName"]);m.push(...se(e,v)),m.push(...ae(e,v));let y=`<img ${m.join(" ")} />`,h=t.context;if(!h.__safeImageHandlerEmitted)return h.__safeImageHandlerEmitted=!0,`${En}${y}`;return y}};function Qe(e){return e.replace(/[;{}()]/g,"").replace(/url/gi,"")}function xe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function Ee(e,i,t){let o=xe(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var et={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(e,i,t){let o=Qe(xe(e,"color")||"#6366f1"),a=Qe(xe(e,"initialColor")||xe(e,"initial-color")||""),c=Qe(xe(e,"height")||"3px"),l=Ee(e,"duration",2000),u=Ee(e,"throttle",200),m=Ee(e,"zIndex",999999)||Ee(e,"z-index",999999),v=a?`linear-gradient(to right, ${a}, ${o})`:o;return`
6
+ ${Te}
7
+ </picture>`}return`${j}${Te}`}};var At="/images/safe-image-default.svg";function ge(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var In=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${At}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,Ye={name:"SafeImage",aliases:["safe-image","safe-img"],render(e,i,t){let o=ge(e,"src")||"",a=ge(e,"alt")||"",c=ge(e,"fallback")||At,l=ge(e,"class")||ge(e,"className")||"",u=ge(e,"fallbackClassName")||"",m=[];if(m.push(`src="${n(o)}"`),m.push(`alt="${n(a)}"`),l)m.push(`class="${n(l)}"`);if(m.push(`data-fallback="${n(c)}"`),u)m.push(`data-fallback-class="${n(u)}"`);m.push('onerror="window.__stxSafeImageHandler(this)"');let v=new Set(["src","alt","fallback","class","className","fallbackClassName"]);m.push(...se(e,v)),m.push(...ae(e,v));let y=`<img ${m.join(" ")} />`,h=t.context;if(!h.__safeImageHandlerEmitted)return h.__safeImageHandlerEmitted=!0,`${In}${y}`;return y}};function Qe(e){return e.replace(/[;{}()]/g,"").replace(/url/gi,"")}function xe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function _e(e,i,t){let o=xe(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var et={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(e,i,t){let o=Qe(xe(e,"color")||"#6366f1"),a=Qe(xe(e,"initialColor")||xe(e,"initial-color")||""),c=Qe(xe(e,"height")||"3px"),l=_e(e,"duration",2000),u=_e(e,"throttle",200),m=_e(e,"zIndex",999999)||_e(e,"z-index",999999),v=a?`linear-gradient(to right, ${a}, ${o})`:o;return`
8
8
  <div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${c};background:${v};z-index:${m};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
9
9
  <div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
10
10
  </div>
11
11
  <style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
12
12
  <script>
13
13
  (function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${u})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
14
- </script>`}};function _t(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function Nn(e,i,t){let o=_t(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var It={"top-right":"top:1rem;right:1rem","top-left":"top:1rem;left:1rem","top-center":"top:1rem;left:50%;transform:translateX(-50%)","bottom-right":"bottom:1rem;right:1rem","bottom-left":"bottom:1rem;left:1rem","bottom-center":"bottom:1rem;left:50%;transform:translateX(-50%)"},tt={name:"StxToast",aliases:["stx-toast"],render(e,i,t){let o=n(_t(e,"position")||"top-right"),a=Nn(e,"max",5),c=It[o]||It["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${o}" data-stx-toast-max="${a}" style="position:fixed;${c};z-index:999999;display:flex;flex-direction:column;gap:0.5rem;pointer-events:none;max-width:24rem;width:100%"></div>
14
+ </script>`}};function It(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function _n(e,i,t){let o=It(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var Pt={"top-right":"top:1rem;right:1rem","top-left":"top:1rem;left:1rem","top-center":"top:1rem;left:50%;transform:translateX(-50%)","bottom-right":"bottom:1rem;right:1rem","bottom-left":"bottom:1rem;left:1rem","bottom-center":"bottom:1rem;left:50%;transform:translateX(-50%)"},tt={name:"StxToast",aliases:["stx-toast"],render(e,i,t){let o=n(It(e,"position")||"top-right"),a=_n(e,"max",5),c=Pt[o]||Pt["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${o}" data-stx-toast-max="${a}" style="position:fixed;${c};z-index:999999;display:flex;flex-direction:column;gap:0.5rem;pointer-events:none;max-width:24rem;width:100%"></div>
15
15
  <style>
16
16
  @keyframes stx-toast-in{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}
17
17
  @keyframes stx-toast-out{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(100%)}}
@@ -19,7 +19,7 @@ ${je}
19
19
  @keyframes stx-toast-out-left{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(-100%)}}
20
20
  @keyframes stx-toast-in-center{from{opacity:0;transform:translateY(-1rem)}to{opacity:1;transform:translateY(0)}}
21
21
  @keyframes stx-toast-out-center{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-1rem)}}
22
- </style>`}};function Ne(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var Et={sm:"max-width:24rem",md:"max-width:32rem",lg:"max-width:42rem",xl:"max-width:56rem",full:"max-width:calc(100vw - 2rem);max-height:calc(100vh - 2rem)"},nt={name:"StxModal",aliases:["stx-modal"],render(e,i,t){let o=Ne(e,"id");if(!o)return console.warn('[stx] <StxModal> requires an "id" prop'),"<!-- StxModal: missing id prop -->";let a=n(o),c=Ne(e,"size")||"md",l=Ne(e,"closeOnBackdrop")!=="false",u=Ne(e,"closeOnEscape")!=="false",m=Et[c]||Et.md;return`<div id="stx-modal-${a}" class="stx-modal-backdrop" data-stx-modal="${a}" data-close-backdrop="${l}" data-close-escape="${u}" style="display:none;position:fixed;inset:0;z-index:99999;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(2px);opacity:0;transition:opacity 0.2s ease" aria-modal="true" role="dialog">
22
+ </style>`}};function Ee(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var _t={sm:"max-width:24rem",md:"max-width:32rem",lg:"max-width:42rem",xl:"max-width:56rem",full:"max-width:calc(100vw - 2rem);max-height:calc(100vh - 2rem)"},nt={name:"StxModal",aliases:["stx-modal"],render(e,i,t){let o=Ee(e,"id");if(!o)return console.warn('[stx] <StxModal> requires an "id" prop'),"<!-- StxModal: missing id prop -->";let a=n(o),c=Ee(e,"size")||"md",l=Ee(e,"closeOnBackdrop")!=="false",u=Ee(e,"closeOnEscape")!=="false",m=_t[c]||_t.md;return`<div id="stx-modal-${a}" class="stx-modal-backdrop" data-stx-modal="${a}" data-close-backdrop="${l}" data-close-escape="${u}" style="display:none;position:fixed;inset:0;z-index:99999;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(2px);opacity:0;transition:opacity 0.2s ease" aria-modal="true" role="dialog">
23
23
  <div class="stx-modal-panel" style="${m};width:100%;margin:1rem;border-radius:0.75rem;box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow:hidden;transform:scale(0.95) translateY(8px);transition:transform 0.2s ease,opacity 0.2s ease;opacity:0;background:var(--stx-modal-bg,#fff);color:var(--stx-modal-text,#1f2937)">
24
24
  <div style="padding:1.5rem">${i}</div>
25
25
  </div>
@@ -28,7 +28,7 @@ ${je}
28
28
  @media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
29
29
  .stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
30
30
  .stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
31
- </style>`}};function pe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var Nt={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},rt={name:"StxDrawer",aliases:["stx-drawer"],render(e,i,t){let o=pe(e,"id");if(!o)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let a=n(o),c=pe(e,"side")||"right",l=pe(e,"size")||"md",u=pe(e,"closeOnBackdrop")!=="false",m=pe(e,"closeOnEscape")!=="false",v=pe(e,"overlay")!=="false",y=Nt[l]||Nt.md,h=c==="left",C=h?"left:0":"right:0",x=h?"translateX(-100%)":"translateX(100%)",S=h?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${a}" class="stx-drawer-backdrop" data-stx-drawer="${a}" data-close-backdrop="${u}" data-close-escape="${m}" style="display:none;position:fixed;inset:0;z-index:99999;${v?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
31
+ </style>`}};function pe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var Et={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},rt={name:"StxDrawer",aliases:["stx-drawer"],render(e,i,t){let o=pe(e,"id");if(!o)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let a=n(o),c=pe(e,"side")||"right",l=pe(e,"size")||"md",u=pe(e,"closeOnBackdrop")!=="false",m=pe(e,"closeOnEscape")!=="false",v=pe(e,"overlay")!=="false",y=Et[l]||Et.md,h=c==="left",C=h?"left:0":"right:0",x=h?"translateX(-100%)":"translateX(100%)",S=h?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${a}" class="stx-drawer-backdrop" data-stx-drawer="${a}" data-close-backdrop="${u}" data-close-escape="${m}" style="display:none;position:fixed;inset:0;z-index:99999;${v?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
32
32
  <div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${C};width:${y};max-width:100vw;transform:${x};transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);background:var(--stx-drawer-bg,#fff);color:var(--stx-drawer-text,#1f2937);box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow-y:auto;pointer-events:auto">
33
33
  <div style="padding:1.5rem">${i}</div>
34
34
  </div>
@@ -37,6 +37,6 @@ ${je}
37
37
  @media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
38
38
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
39
39
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
40
- </style>`}};import{existsSync as On,readFileSync as Bn}from"fs";var Oe=new Map,Ot=new Set;function Tn(e){if(Ot.has(e))return;Ot.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Dn(e){let i=process.cwd();for(let t of[`${i}/node_modules/@iconify-json/${e}/icons.json`,`${i}/pantry/@iconify-json/${e}/icons.json`,`${i}/node_modules/@iconify/json/json/${e}.json`,`${i}/pantry/@iconify/json/json/${e}.json`])if(On(t))return t;for(let t of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(t)}catch{}return null}function jn(e){if(Oe.has(e))return Oe.get(e);let i=Dn(e);if(!i)return Tn(e),null;try{let t=JSON.parse(Bn(i,"utf8"));return Oe.set(e,t),t}catch{return null}}function Mn(e,i,t,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${t/2} ${o/2})`);if(i.hFlip)a.push(`translate(${t} 0) scale(-1 1)`);if(i.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function Ln(e,i){let t=i,o=e.icons[t],a={hFlip:!1,vFlip:!1,rotate:0};for(let u=0;!o&&u<8;u++){let m=e.aliases?.[t];if(!m)return null;if(m.hFlip)a.hFlip=!a.hFlip;if(m.vFlip)a.vFlip=!a.vFlip;if(m.rotate)a.rotate=((a.rotate+m.rotate)%4+4)%4;t=m.parent,o=e.icons[t]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:Mn(o.body,a,c,l),width:c,height:l}}function me(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);if(e.static[i]!==void 0)return String(e.static[i]);if(e.clientReactive[i]!==void 0)return e.clientReactive[i];return}var it={name:"Icon",aliases:["icon","stx-icon"],render(e,i,t){let o=me(e,"name")??me(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let w=o.split(":");a=w[0],c=w[1]}let l=n(me(e,"size")||"24"),u=n(me(e,"color")||"currentColor"),m=n(me(e,"class")||""),v=n(me(e,"style")||""),y=Oe.get(a)??jn(a);if(!y)return`<!-- Icon: collection "${a}" not loaded -->`;let h=Ln(y,c);if(!h)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${h.width} ${h.height}`,x=h.body;if(u!=="currentColor")x=x.replace(/currentColor/g,u);let S=m?` class="${m}"`:"",b=v?` style="${v}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${S}${b}>${x}</svg>`}};function Bt(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}function Tt(e,i){let t=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(t);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var at={name:"Suspense",aliases:["suspense"],render(e,i,t){let o=Tt(i,"fallback"),a=o.rest,c=Tt(a,"error"),l=c.rest,u=o.region??Bt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',m=c.region??Bt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${u}</div><div data-stx-suspense-error hidden>${m}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function Be(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}var ct={name:"TransitionGroup",aliases:["transition-group"],render(e,i,t){let o=(Be(e,"name")||"v").replace(/["'<>]/g,""),a=(Be(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Be(e,"class"),l=Be(e,"id"),u=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${u}>${i}</${a}>`}};function Dt(e=de){e.registerBuiltin(Xe),e.registerBuiltin(Je),e.registerBuiltin(Ye),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(nt),e.registerBuiltin(rt),e.registerBuiltin(it),e.registerBuiltin(at),e.registerBuiltin(ct)}var jt=new Map;function zn(e){let i=jt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),jt.set(e.source,i);return i}var Mt=new WeakMap;function Lt(e){let i=Mt.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),Mt.set(e,i);let t=i;return(o)=>!/[a-z]/.test(o)&&t.has(o.toLowerCase())}function Un(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function zt(e,i,t){let o=[],a=0,c=typeof t==="function"?t:t?(l)=>t.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let u=zn(i);u.lastIndex=l+1;let m=u.exec(e);if(!m){a=l+1;continue}let v=m[1];if(c&&c(v)){let w=l+1+v.length;while(w<e.length&&e[w]!==">")w++;a=w+1;continue}let y=l+1+v.length,h=null,C=y,x=-1,S=!1;while(y<e.length){let w=e[y];if(h){if(w==="\\"&&y+1<e.length){y+=2;continue}if(w===h)h=null;y++;continue}if(w==='"'||w==="'"){h=w,y++;continue}if(w==="/"&&y+1<e.length&&e[y+1]===">"){x=y+2,S=!0;break}if(w===">"){x=y+1;break}y++}if(x===-1){a=l+1;continue}let b=e.slice(C,S?x-2:x-1).trim();if(S)o.push({fullMatch:e.slice(l,x),tagName:v,attributes:b,content:"",startIndex:l,endIndex:x,isSelfClosing:!0}),a=x;else{let w=`<${v}`,A=`</${v}>`,k=1,R=x,T=-1;while(k>0&&R<e.length){let F=e.indexOf(w,R),H=e.indexOf(A,R);if(H===-1)break;if(F!==-1&&F<H){let E=e[F+w.length];if(E===" "||E===">"||E==="/"||E===`
41
- `||E==="\t"){let O=Un(e,F+w.length);if(e[O-1]!=="/")k++;R=O+1}else R=F+w.length}else{if(k--,k===0){T=H;break}R=H+A.length}}if(T===-1){a=x;continue}let G=e.slice(x,T),M=T+A.length;o.push({fullMatch:e.slice(l,M),tagName:v,attributes:b,content:G,startIndex:l,endIndex:M,isSelfClosing:!1}),a=M}}return o}function lt(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Ut(e,i){try{let t=Buffer.from(e,"base64").toString("utf8");return JSON.parse(t)}catch{}try{let t=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(t)}catch(t){if(i?.debug)console.error("Error decoding __stx_ prop:",t);return e}}function Te(e,i){let t=0,o="",a=i;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")t++;else if(c==="}"){if(t--,t===0)return e.slice(i,a+1)}a++}return e.slice(i)}function Ft(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Te(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Wt(e){let i=[],t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o&&e[t]!==l){if(e[t]==="\\"&&t+1<o)t++,c+=e[t];else c+=e[t];t++}if(t<o)t++}else if(e[t]==="{")c=Te(e,t),t+=c.length;else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var Fn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Wn=new Set([":for","x-for","v-for","@for"]),Hn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function qn(e){return ut(e).map((i)=>[i.start,i.end])}function ut(e){let i=[],t=new Map;for(let o of fn(e)){let a=o.name.toLowerCase();if(o.closing){let v=t.get(a)?.pop();if(v)v.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Wt(o.attributes).find((v)=>Wn.has(v.name)):void 0,u=typeof l?.value==="string"?l.value:null,m=u!==null?{start:o.start,end:o.end,names:Y(u),tag:a}:null;if(m)i.push(m);if(!o.selfClosing&&!Hn.has(a)){let v=t.get(a);if(!v)v=[],t.set(a,v);v.push(m)}}return i}function Ht(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>Ht(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function dc(e,i){if(!/:[\w-]+=/.test(e))return e;let t=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...qn(e));let l=new Set([...st(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function u(h){return a.some(([C,x])=>h>=C&&h<x)}let m=[],v=new Map,y=256;for(let h of fn(t)){if(h.closing||u(h.start))continue;let C=h.attributes.trimEnd();if(!C||!C.includes(":"))continue;let x=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),S=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,b,w=C,A=!1;while((b=S.exec(C))!==null){if(kr(C,b.index,!0)?.kind==="attribute")continue;let k=b[1],R=b[2];if(yl(k))continue;if(N(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let T=Object.keys(i),G=Object.values(i),M=R.match(/^([a-zA-Z_$][\w$]*)/);if(M&&!T.includes(M[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(M[1]))continue;let F=JSON.stringify([T,R]),H=v.get(F);if(!H){if(H=Function(...T,`return (${R})`),v.size>=y)v.clear();v.set(F,H)}let E=H(...G);if(k==="class"){let O=W(Ht(E));if(O){let B=w.match(/\sclass="([^"]*)"/);if(B)w=w.replace(B[0],()=>` class="${B[1]} ${O}"`);else w=w.replace(b[0],()=>` class="${O}"`)}else w=w.replace(b[0],"");A=!0;continue}if(Fn.has(k)){if(E)w=w.replace(b[0],` ${k}`);else w=w.replace(b[0],"");A=!0;continue}if(E===null||E===void 0||E===!1)w=w.replace(b[0],"");else{let O=x&&typeof E==="object"?JSON.stringify(E):String(E),B=Sn(k,O);w=w.replace(b[0],()=>` ${k}="${B}"`)}A=!0}catch(T){if(T instanceof ie)throw T;continue}}if(A){let k=h.selfClosing?" /":"",T=`<${h.name}${w}${k}>`;m.push({start:h.start,end:h.end,replacement:T})}}if(m.length>0){let h=Array(m.length*2+1),C=0;for(let x=0;x<m.length;x++){let{start:S,end:b,replacement:w}=m[x];h[x*2]=t.slice(C,S),h[x*2+1]=w,C=b}h[m.length*2]=t.slice(C),t=h.join("")}return t}import qt from"fs";import Xt from"path";var Vt=!1;function Xn(e,i,t,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(i.__stx_client_signal_names)?i.__stx_client_signal_names:[]),u=(h)=>{if(l.size===0)return!1;let C=s(h),x=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let S of l){let b=S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(C))return!0}return!1},m=new Set(bl),v=(h)=>{if(!h.includes("-")||h.startsWith("@")||h.startsWith(":")||h.startsWith("x-")||h.startsWith("__"))return h;if(h.startsWith("aria-")||h.startsWith("data-"))return h;return h.replace(/-([a-z0-9])/g,(C,x)=>x.toUpperCase())},y=(h,C)=>{let x=v(h);if(c.static[x]=C,x!==h)c.staticNames[x]=h};for(let[h,C]of Object.entries(e)){let x=h.startsWith("x-")&&!m.has(h)&&!h.startsWith("x-bind:")&&!h.startsWith("x-on:")?`:${h.slice(2)}`:h;if(x.startsWith("@")){c.events[x]=C;continue}if(x.startsWith("__stx_")){let S=v(x.slice(6));c.serverDynamic[S]=Ut(C,t);continue}if(x.startsWith(":")){let S=v(x.slice(1)),b=C===re?S:C;if(S==="if"||S==="for"||S==="show"){c.clientReactive[S]=b;continue}if(o){c.clientReactive[S]=b;continue}if(N(b,a)){c.clientReactive[S]=b;continue}if(u(b)){c.clientReactive[S]=b;continue}try{if(!f(b)){if(t.debug)console.error(`Unsafe expression in :${S} binding: ${b}`);c.clientReactive[S]=b;continue}let w=Object.keys(i),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),k=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(ot(b).some((M)=>!A.has(M)&&!w.includes(M)&&(!(M in globalThis)||k.has(M)))){c.clientReactive[S]=b;continue}let G=d(b,w)(...Object.values(i));if(c.serverDynamic[S]=G,S!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[S]=x.slice(1)}catch{c.clientReactive[S]=b}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let S=Zn(C,a);if(S!==null){c.clientReactive[v(x)]=S;continue}let b=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(f(w)){let k=d(w,Object.keys(i))(...Object.values(i));y(x,k!=null?String(k):"")}else{if(t.debug)console.error(`Unsafe expression in ${x}: ${w}`);y(x,C)}}catch(w){if(t.debug)console.error(`Error evaluating expression for ${x}:`,w);y(x,C)}else{let w=C,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,k;while((k=A.exec(C))!==null)try{let R=k[1];if(!f(R)){if(t.debug)console.error(`Unsafe expression in ${x}: ${R}`);continue}let G=d(R,Object.keys(i))(...Object.values(i));w=w.replace(k[0],String(G??""))}catch(R){if(t.debug)console.error(`Error evaluating expression in ${x}:`,R)}y(x,w)}continue}y(x,C===re?"true":lt(C))}return c}var ft=new Set;function jh(){ft.clear()}function Vn(e,i){let t=`${i}\x00${e}`;if(ft.has(t))return;ft.add(t),console.warn(`[stx] <${e}> in ${i} is inside a <template :for>, so its props and slot expressions will not see the loop variables and render empty. Put the directive on the element the loop repeats instead -- <tr :for="..."> or <span :for="..." class="contents"> -- which binds correctly.`)}function Zn(e,i){if(i.size===0)return null;let t=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(t)];if(!o.some((u)=>N(u[1],i)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let u of o)c+=e.slice(l,u.index).replace(/[`\\$]/g,(m)=>`\\${m}`),c+=`\${${u[1]}}`,l=u.index+u[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(u)=>`\\${u}`),`\`${c}\``}var Gn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Kn(e,i,t){if(!e.includes("@"))return e;if(!Gn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return oe(e,i,t)}catch{return e}}function he(e){let i={},t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o){let u=e[t];if(u==="\\"&&t+1<o){t++,c+=e[t],t++;continue}if(u===l){t++;break}c+=u,t++}}else if(e[t]==="{"){c=Te(e,t),t+=c.length;let l=Ft(c);if(l!==null){i[`:${a}`]=l;continue}}else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i[a]=c}else i[a]=re}return i}function Zt(e){return Object.entries(e).map(([i,t])=>t===re?i:`${i}="${Jn(t)}"`).join(" ")}function Jn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Yn(e){let i=new Set,t=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=t.exec(e))!==null){let a=o[1];if(de.isBuiltin(a))i.add(a)}return[...i].sort()}async function Lf(e,i,t,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Xt.dirname(t),u=[],m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let h of e.matchAll(m)){let[C,x,S]=h,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=S,A,k=[];while((A=b.exec(S))!==null){let[R,T,G,M]=A,F=null,H=null;if(M.startsWith(".")||M.startsWith("/")){let B=Xt.resolve(l,M);if(B.endsWith(".stx"))H=B;else{let q=`${B}.stx`;try{if(qt.statSync(q).isFile())H=q}catch{try{if(qt.statSync(B).isDirectory())F=B}catch{}}}}else F=Ds(M,l);if(!F&&!H)continue;let E=!1,O=(B,q)=>{c.set(B,q),c.set(B.toLowerCase(),q);let L=B.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(L,q),a.add(q)};if(G&&H)O(G,H),E=!0;else if(T){let B=T.slice(1,-1).split(",").map((L)=>L.trim()).filter(Boolean).map((L)=>{let X=L.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(X)return{source:X[1],local:X[2]};return{source:L,local:L}}),q=F?wr(F):null;for(let{source:L,local:X}of B){let z=null;if(H)z=H;else if(q)z=q.get(L)??q.get(L.toLowerCase())??q.get(L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(z)O(X,z),E=!0}}if(E)k.push({start:A.index,end:A.index+R.length})}if(k.length===0)continue;for(let R=k.length-1;R>=0;R--)w=w.slice(0,k[R].start)+w.slice(k[R].end);u.push({start:h.index,end:h.index+C.length,value:`<script${x}>${w}</script>`})}if(u.length===0)return e;let v=[],y=0;for(let h of u)v.push(e.slice(y,h.start),h.value),y=h.end;return v.push(e.slice(y)),v.join("")}async function Qn(e,i,t,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,u=/@import\s*\(\s*([^)]+)\s*\)/g,m;while((m=u.exec(c))!==null){let[v,y]=m,h=y.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of h){let x=C.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),A=null,k=Ms(C,t,o);for(let R of k)try{if(await Bun.file(R).exists()){A=R;break}}catch{}if(A){l.set(w,A),l.set(b,A),l.set(b.toLowerCase(),A);let R=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,A),a.add(A),o.debug)console.log(`Imported component: ${w} -> ${A}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(v,""),u.lastIndex=0}return c}async function er(e,i,t,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,m=/@component\s*\(/g,v;while((v=m.exec(c))!==null){let y=v.index,h=y+v[0].length-1,C=1,x=h+1;while(x<c.length&&C>0){if(c[x]==="(")C++;else if(c[x]===")"){if(C--,C===0)break}x++}if(C!==0)break;let S=c.substring(h+1,x),b=x+1,w=S.match(/^\s*['"]([^'"]+)['"]/);if(!w){m.lastIndex=b;continue}let A=w[1],k,R=S.slice(w[0].length),T=R.match(/^\s*,\s*/);if(T)k=R.slice(T[0].length).trim();let G={};if(k)try{G=P(k,i)}catch(B){let q=B instanceof Error?B.message:String(B);c=c.replace(c.substring(y,b),`[Error parsing component props: ${q}]`);continue}let M="",F=b,E=c.substring(b).match(/^([\s\S]*?)@endcomponent/);if(E)M=E[1].trim(),F=b+E[0].length;let O=await ze(A,G,M,l,i,t,o,u,a);c=c.substring(0,y)+O+c.substring(F),m.lastIndex=0}return c}async function tr(e,i,t,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,m=sr(c);if(m.size>0){let b=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...b,...m])]}let v=J(c);c=v.output;let y=st(i);return c=await S(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await S(c,/[A-Z][a-zA-Z0-9]*/,!0,Lt(_r)),c=await S(c,/[a-z][a-z0-9]*/,!1,_r),c=v.restore(c),c;async function S(b,w,A,k){if(!b)return b;let R=b,T=zt(R,w,k),G=ut(R),M=new Map;for(let E=T.length-1;E>=0;E--){let O=T[E],B=A?U(O.tagName):O.tagName,q=he(Kn(O.attributes,i,t)),L=G.filter(({start:I,end:_})=>O.startIndex>=I&&O.startIndex<_);if(L.some((I)=>I.tag==="template"))Vn(O.tagName,t);let X=L.length>0,z=new Set(y);for(let I of L)for(let _ of I.names)z.add(_);let D=Xn(q,i,o,X,z);if(typeof D.clientReactive.for==="string")for(let I of Y(D.clientReactive.for))z.add(I);let ce=de.getBuiltin(O.tagName),$e=ce?await Tr(O.tagName,l,i,t,o):!1,K=O.tagName==="Image"&&Ls([...Object.keys(D.static),...Object.keys(D.serverDynamic),...Object.keys(D.clientReactive)],Object.keys(D.events),{...D.static,...D.serverDynamic})&&(o._pluginComponentDirs??[]).some((I)=>wr(I).has("Image"));if(ce&&!$e&&!K){let I={context:i,filePath:t,options:o,dependencies:a},_=ce.render(D,O.content,I);if(Object.keys(D.events).length>0){let ee=Zt(D.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(D.clientReactive).length>0)_=Gt(_,D.clientReactive);M.set(E,_);continue}if(!A&&O.tagName.includes("-")&&!await Tr(B,l,i,t,o))continue;let le={};for(let[I,_]of Object.entries(D.static))le[I]=_;for(let[I,_]of Object.entries(D.serverDynamic))le[I]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(D.clientReactive),events:Object.keys(D.events)},j=await ze(B,le,v.restore(O.content),l,i,t,o,u,a,[...z],te,O.tagName);if(j=nr(j,D,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let I=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(U),_=dt(j,!0);if(I.length&&_){if(!Object.hasOwn(he(j.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))j=j.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+j.slice(_.insertPos);let ne=we(j);j=j.slice(0,ne.insertPos)+` data-stx-native-forward="${I.join(" ")}"`+j.slice(ne.insertPos)}let ee=dt(j,!0);if(ee){let ne=he(j.slice(ee.insertPos,ee.tagEnd)),Se=we(j),Jt=he(j.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Jt,"data-stx-native-host-owner"))j=j.slice(0,Se.insertPos)+" data-stx-native-host-owner"+j.slice(Se.insertPos)}}if(Object.keys(D.events).length>0){let I=we(j);if(I){let _=Zt(D.events),ee=Object.keys(D.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");j=j.substring(0,I.insertPos)+` data-stx-parent-events="${ee}" ${_}`+j.substring(I.insertPos)}}if(Object.keys(D.clientReactive).length>0)j=Gt(j,D.clientReactive);M.set(E,j)}if(M.size===0)return R;let F="",H=0;for(let E=0;E<T.length;E++){let O=M.get(E);if(O===void 0)continue;F+=R.slice(H,T[E].startIndex),F+=O,H=T[E].endIndex}return F+=R.slice(H),F}}function Gt(e,i){let t=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([y])=>!t.has(y)),c=a.filter(([y])=>!o.has(y)).map(([y])=>U(y)).join(" "),l=e,u=a.length>0?we(l):null;if(u){let y=a.map(([C,x])=>`:${U(C)}="${x.replace(/"/g,"&quot;")}"`).join(" "),h=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,u.insertPos)+`${h} ${y}`+l.substring(u.insertPos)}let m=i.if;if(m)l=`<template :if="${m.replace(/"/g,"&quot;")}">${l}</template>`;let v=i.for;if(v){let y=i.key,h=y?` :key="${y.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${v.replace(/"/g,"&quot;")}"${h}>${l}</template>`}return l}function nr(e,i,t=new Set,o=new Set,a=!1){let c=dt(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),u=i.serverDynamic.class??i.static.class;if(a&&typeof u==="string"&&u&&!o.has("class")){let S=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=S.test(l)?l.replace(S,(w,A,k,R,T)=>`${A}class="${n(`${lt(k??R??T)} ${u}`)}"`):` class="${n(u)}"${l}`;e=e.slice(0,c.insertPos)+b+e.slice(c.tagEnd),c.tagEnd+=b.length-l.length,l=b}let m=a||/\bdata-native(?:\s|=)/i.test(l),v=m?o:t,y=new Set(Object.keys(he(l))),h=new Set(["class","className"]);for(let S of Object.keys(i.static)){let b=i.staticNames[S]??S;if(y.has(b)||v.has(S)||!m&&!qe(b))h.add(S)}for(let S of Object.keys(i.serverDynamic)){let b=i.serverDynamicNames?.[S]??S;if(y.has(b)||v.has(S)||!m&&!qe(b))h.add(S)}let C=[];if(m){for(let[S,b]of Object.entries(i.static)){if(h.has(S)||b!==!0&&b!==re)continue;h.add(S),C.push(`${n(i.staticNames?.[S]??S)}="true"`)}for(let[S,b]of Object.entries(i.serverDynamic)){if(h.has(S)||b!==!0)continue;h.add(S),C.push(`${n(i.serverDynamicNames?.[S]??S)}="true"`)}}let x=[...se(i,h),...ae(i,h),...C];if(m){for(let[S,b]of Object.entries(i.serverDynamic)){if(h.has(S)||b!==!1)continue;let w=i.serverDynamicNames?.[S]??S;x.push(`${n(w)}="false"`)}for(let[S,b]of Object.entries(i.serverDynamic)){if(h.has(S)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let A=i.serverDynamicNames?.[S]??S;x.push(`${n(A)}="${n(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,c.insertPos)} ${x.join(" ")}${e.slice(c.insertPos)}`}function we(e){let i=Kt(e,0);if(i)return i;let t=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(t)return{insertPos:t.index+1+t[1].length,tagEnd:gt(e,t.index+1+t[1].length)};return null}function dt(e,i=!1){let t=we(e);if(!t)return null;let o=e.slice(t.insertPos,t.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Kt(e,t.tagEnd+1):t;return a&&i?rr(e,a)??a:a}function rr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let t=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",i.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let y=e.indexOf("-->",o+4);if(y<0)return null;o=e.indexOf("<",y+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let u=l[2].toLowerCase(),m=o+l[0].length,v=gt(e,m);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(u==="script"||u==="style"){let y=new RegExp(`</${u}\\s*>`,"gi");if(y.lastIndex=v+1,!y.exec(e))return null;o=e.indexOf("<",y.lastIndex);continue}else{let y=he(e.slice(m,v)),h=a>0&&(Object.hasOwn(y,"data-stx-component-wrapper")||Object.hasOwn(y,"data-stx-native-host-owner"));if(c===void 0&&!h&&Object.hasOwn(y,"data-stx-native-host-root"))return{insertPos:m,tagEnd:v};if(!t.has(u)&&e[v-1]!=="/"){if(a++,c===void 0&&h)c=a}else if(a===0)return null}o=e.indexOf("<",v+1)}return null}function Kt(e,i){let t=i;while(t<e.length){let o=e.slice(t),a=o.match(/^\s+/);if(a){t+=a[0].length;continue}if(o.startsWith("<!--")){let u=e.indexOf("-->",t+4);if(u===-1)return null;t=u+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let u=`</${c[1].toLowerCase()}>`,m=e.toLowerCase().indexOf(u,t+c[0].length);if(m===-1)return null;t=m+u.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:t+1+l[1].length,tagEnd:gt(e,t+1+l[1].length)}}return null}function gt(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function sr(e){let i=new Set;for(let t of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=t[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of pi(t[2]))i.add(a);for(let a of t[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])i.add(a[1]);if(a[3])i.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))i.add(l)}}}return i}async function ps(e,i,t,o,a){if(!Vt)Dt(de),Vt=!0;let c=await Lf(e,i,t,o,a);c=await Qn(c,i,t,o,a),c=await er(c,i,t,o,a);let l=[];for(let u=0;u<3;u++){let m=l.length,v=fe(c,De,(h,C)=>`\x00STX_COMPONENT_COMMENT_${m+C}\x00`,`STX_COMPONENT_COMMENT:${m}`);l.push(...v.tokens);let y=c;if(c=await tr(v.output,i,t,o,a),c===y)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(u,m)=>l[Number(m)]??"");if(o.debug){let u=Yn(c);if(u.length>0)console.warn(`[stx] ${t}: unresolved component tag(s) after render passes: ${u.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
42
- export{Bo,Fo,zo,Mh,ds,Lh,dc,jh,Lf,ps};
40
+ </style>`}};import{existsSync as En,readFileSync as Nn}from"fs";var Ne=new Map,Nt=new Set;function On(e){if(Nt.has(e))return;Nt.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Bn(e){let i=process.cwd();for(let t of[`${i}/node_modules/@iconify-json/${e}/icons.json`,`${i}/pantry/@iconify-json/${e}/icons.json`,`${i}/node_modules/@iconify/json/json/${e}.json`,`${i}/pantry/@iconify/json/json/${e}.json`])if(En(t))return t;for(let t of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(t)}catch{}return null}function Tn(e){if(Ne.has(e))return Ne.get(e);let i=Bn(e);if(!i)return On(e),null;try{let t=JSON.parse(Nn(i,"utf8"));return Ne.set(e,t),t}catch{return null}}function Dn(e,i,t,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${t/2} ${o/2})`);if(i.hFlip)a.push(`translate(${t} 0) scale(-1 1)`);if(i.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function jn(e,i){let t=i,o=e.icons[t],a={hFlip:!1,vFlip:!1,rotate:0};for(let u=0;!o&&u<8;u++){let m=e.aliases?.[t];if(!m)return null;if(m.hFlip)a.hFlip=!a.hFlip;if(m.vFlip)a.vFlip=!a.vFlip;if(m.rotate)a.rotate=((a.rotate+m.rotate)%4+4)%4;t=m.parent,o=e.icons[t]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:Dn(o.body,a,c,l),width:c,height:l}}function me(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);if(e.static[i]!==void 0)return String(e.static[i]);if(e.clientReactive[i]!==void 0)return e.clientReactive[i];return}var it={name:"Icon",aliases:["icon","stx-icon"],render(e,i,t){let o=me(e,"name")??me(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let w=o.split(":");a=w[0],c=w[1]}let l=n(me(e,"size")||"24"),u=n(me(e,"color")||"currentColor"),m=n(me(e,"class")||""),v=n(me(e,"style")||""),y=Ne.get(a)??Tn(a);if(!y)return`<!-- Icon: collection "${a}" not loaded -->`;let h=jn(y,c);if(!h)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${h.width} ${h.height}`,x=h.body;if(u!=="currentColor")x=x.replace(/currentColor/g,u);let S=m?` class="${m}"`:"",b=v?` style="${v}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${S}${b}>${x}</svg>`}};function Ot(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}function Bt(e,i){let t=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(t);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var at={name:"Suspense",aliases:["suspense"],render(e,i,t){let o=Bt(i,"fallback"),a=o.rest,c=Bt(a,"error"),l=c.rest,u=o.region??Ot(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',m=c.region??Ot(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${u}</div><div data-stx-suspense-error hidden>${m}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function Oe(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}var ct={name:"TransitionGroup",aliases:["transition-group"],render(e,i,t){let o=(Oe(e,"name")||"v").replace(/["'<>]/g,""),a=(Oe(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Oe(e,"class"),l=Oe(e,"id"),u=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${u}>${i}</${a}>`}};function Tt(e=de){e.registerBuiltin(Xe),e.registerBuiltin(Je),e.registerBuiltin(Ye),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(nt),e.registerBuiltin(rt),e.registerBuiltin(it),e.registerBuiltin(at),e.registerBuiltin(ct)}var Dt=new Map;function Mn(e){let i=Dt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),Dt.set(e.source,i);return i}var jt=new WeakMap;function Mt(e){let i=jt.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),jt.set(e,i);let t=i;return(o)=>!/[a-z]/.test(o)&&t.has(o.toLowerCase())}function Ln(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function Lt(e,i,t){let o=[],a=0,c=typeof t==="function"?t:t?(l)=>t.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let u=Mn(i);u.lastIndex=l+1;let m=u.exec(e);if(!m){a=l+1;continue}let v=m[1];if(c&&c(v)){let w=l+1+v.length;while(w<e.length&&e[w]!==">")w++;a=w+1;continue}let y=l+1+v.length,h=null,C=y,x=-1,S=!1;while(y<e.length){let w=e[y];if(h){if(w==="\\"&&y+1<e.length){y+=2;continue}if(w===h)h=null;y++;continue}if(w==='"'||w==="'"){h=w,y++;continue}if(w==="/"&&y+1<e.length&&e[y+1]===">"){x=y+2,S=!0;break}if(w===">"){x=y+1;break}y++}if(x===-1){a=l+1;continue}let b=e.slice(C,S?x-2:x-1).trim();if(S)o.push({fullMatch:e.slice(l,x),tagName:v,attributes:b,content:"",startIndex:l,endIndex:x,isSelfClosing:!0}),a=x;else{let w=`<${v}`,A=`</${v}>`,k=1,R=x,T=-1;while(k>0&&R<e.length){let F=e.indexOf(w,R),H=e.indexOf(A,R);if(H===-1)break;if(F!==-1&&F<H){let E=e[F+w.length];if(E===" "||E===">"||E==="/"||E===`
41
+ `||E==="\t"){let O=Ln(e,F+w.length);if(e[O-1]!=="/")k++;R=O+1}else R=F+w.length}else{if(k--,k===0){T=H;break}R=H+A.length}}if(T===-1){a=x;continue}let G=e.slice(x,T),M=T+A.length;o.push({fullMatch:e.slice(l,M),tagName:v,attributes:b,content:G,startIndex:l,endIndex:M,isSelfClosing:!1}),a=M}}return o}function lt(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function zt(e,i){try{let t=Buffer.from(e,"base64").toString("utf8");return JSON.parse(t)}catch{}try{let t=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(t)}catch(t){if(i?.debug)console.error("Error decoding __stx_ prop:",t);return e}}function Be(e,i){let t=0,o="",a=i;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")t++;else if(c==="}"){if(t--,t===0)return e.slice(i,a+1)}a++}return e.slice(i)}function Ft(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Be(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Ut(e){let i=[],t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o&&e[t]!==l){if(e[t]==="\\"&&t+1<o)t++,c+=e[t];else c+=e[t];t++}if(t<o)t++}else if(e[t]==="{")c=Be(e,t),t+=c.length;else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Fn=new Set([":for","x-for","v-for","@for"]),Un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wn(e){return ut(e).map((i)=>[i.start,i.end])}function ut(e){let i=[],t=new Map;for(let o of gn(e)){let a=o.name.toLowerCase();if(o.closing){let v=t.get(a)?.pop();if(v)v.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Ut(o.attributes).find((v)=>Fn.has(v.name)):void 0,u=typeof l?.value==="string"?l.value:null,m=u!==null?{start:o.start,end:o.end,names:Y(u),tag:a}:null;if(m)i.push(m);if(!o.selfClosing&&!Un.has(a)){let v=t.get(a);if(!v)v=[],t.set(a,v);v.push(m)}}return i}function Wt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>Wt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function fc(e,i){if(!/:[\w-]+=/.test(e))return e;let t=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...Wn(e));let l=new Set([...st(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function u(h){return a.some(([C,x])=>h>=C&&h<x)}let m=[],v=new Map,y=256;for(let h of gn(t)){if(h.closing||u(h.start))continue;let C=h.attributes.trimEnd();if(!C||!C.includes(":"))continue;let x=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),S=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,b,w=C,A=!1;while((b=S.exec(C))!==null){if(Cr(C,b.index,!0)?.kind==="attribute")continue;let k=b[1],R=b[2];if(wl(k))continue;if(N(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let T=Object.keys(i),G=Object.values(i),M=R.match(/^([a-zA-Z_$][\w$]*)/);if(M&&!T.includes(M[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(M[1]))continue;let F=JSON.stringify([T,R]),H=v.get(F);if(!H){if(H=Function(...T,`return (${R})`),v.size>=y)v.clear();v.set(F,H)}let E=H(...G);if(k==="class"){let O=W(Wt(E));if(O){let B=w.match(/\sclass="([^"]*)"/);if(B)w=w.replace(B[0],()=>` class="${B[1]} ${O}"`);else w=w.replace(b[0],()=>` class="${O}"`)}else w=w.replace(b[0],"");A=!0;continue}if(zn.has(k)){if(E)w=w.replace(b[0],` ${k}`);else w=w.replace(b[0],"");A=!0;continue}if(E===null||E===void 0||E===!1)w=w.replace(b[0],"");else{let O=x&&typeof E==="object"?JSON.stringify(E):String(E),B=kn(k,O);w=w.replace(b[0],()=>` ${k}="${B}"`)}A=!0}catch(T){if(T instanceof ie)throw T;continue}}if(A){let k=h.selfClosing?" /":"",T=`<${h.name}${w}${k}>`;m.push({start:h.start,end:h.end,replacement:T})}}if(m.length>0){let h=Array(m.length*2+1),C=0;for(let x=0;x<m.length;x++){let{start:S,end:b,replacement:w}=m[x];h[x*2]=t.slice(C,S),h[x*2+1]=w,C=b}h[m.length*2]=t.slice(C),t=h.join("")}return t}import Ht from"fs";import qt from"path";var Xt=!1;function Hn(e,i,t,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(i.__stx_client_signal_names)?i.__stx_client_signal_names:[]),u=(h)=>{if(l.size===0)return!1;let C=s(h),x=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let S of l){let b=S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(C))return!0}return!1},m=new Set(vl),v=(h)=>{if(!h.includes("-")||h.startsWith("@")||h.startsWith(":")||h.startsWith("x-")||h.startsWith("__"))return h;if(h.startsWith("aria-")||h.startsWith("data-"))return h;return h.replace(/-([a-z0-9])/g,(C,x)=>x.toUpperCase())},y=(h,C)=>{let x=v(h);if(c.static[x]=C,x!==h)c.staticNames[x]=h};for(let[h,C]of Object.entries(e)){let x=h.startsWith("x-")&&!m.has(h)&&!h.startsWith("x-bind:")&&!h.startsWith("x-on:")?`:${h.slice(2)}`:h;if(x.startsWith("@")){c.events[x]=C;continue}if(x.startsWith("__stx_")){let S=v(x.slice(6));c.serverDynamic[S]=zt(C,t);continue}if(x.startsWith(":")){let S=v(x.slice(1)),b=C===re?S:C;if(S==="if"||S==="for"||S==="show"){c.clientReactive[S]=b;continue}if(o){c.clientReactive[S]=b;continue}if(N(b,a)){c.clientReactive[S]=b;continue}if(u(b)){c.clientReactive[S]=b;continue}try{if(!f(b)){if(t.debug)console.error(`Unsafe expression in :${S} binding: ${b}`);c.clientReactive[S]=b;continue}let w=Object.keys(i),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),k=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(ot(b).some((M)=>!A.has(M)&&!w.includes(M)&&(!(M in globalThis)||k.has(M)))){c.clientReactive[S]=b;continue}let G=d(b,w)(...Object.values(i));if(c.serverDynamic[S]=G,S!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[S]=x.slice(1)}catch{c.clientReactive[S]=b}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let S=Xn(C,a);if(S!==null){c.clientReactive[v(x)]=S;continue}let b=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(f(w)){let k=d(w,Object.keys(i))(...Object.values(i));y(x,k!=null?String(k):"")}else{if(t.debug)console.error(`Unsafe expression in ${x}: ${w}`);y(x,C)}}catch(w){if(t.debug)console.error(`Error evaluating expression for ${x}:`,w);y(x,C)}else{let w=C,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,k;while((k=A.exec(C))!==null)try{let R=k[1];if(!f(R)){if(t.debug)console.error(`Unsafe expression in ${x}: ${R}`);continue}let G=d(R,Object.keys(i))(...Object.values(i));w=w.replace(k[0],String(G??""))}catch(R){if(t.debug)console.error(`Error evaluating expression in ${x}:`,R)}y(x,w)}continue}y(x,C===re?"true":lt(C))}return c}var ft=new Set;function Fh(){ft.clear()}function qn(e,i){let t=`${i}\x00${e}`;if(ft.has(t))return;ft.add(t),console.warn(`[stx] <${e}> in ${i} is inside a <template :for>, so its props and slot expressions will not see the loop variables and render empty. Put the directive on the element the loop repeats instead -- <tr :for="..."> or <span :for="..." class="contents"> -- which binds correctly.`)}function Xn(e,i){if(i.size===0)return null;let t=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(t)];if(!o.some((u)=>N(u[1],i)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let u of o)c+=e.slice(l,u.index).replace(/[`\\$]/g,(m)=>`\\${m}`),c+=`\${${u[1]}}`,l=u.index+u[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(u)=>`\\${u}`),`\`${c}\``}var Vn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Zn(e,i,t){if(!e.includes("@"))return e;if(!Vn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return oe(e,i,t)}catch{return e}}function he(e){let i={},t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o){let u=e[t];if(u==="\\"&&t+1<o){t++,c+=e[t],t++;continue}if(u===l){t++;break}c+=u,t++}}else if(e[t]==="{"){c=Be(e,t),t+=c.length;let l=Ft(c);if(l!==null){i[`:${a}`]=l;continue}}else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i[a]=c}else i[a]=re}return i}function Vt(e){return Object.entries(e).map(([i,t])=>t===re?i:`${i}="${Gn(t)}"`).join(" ")}function Gn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Kn(e){let i=new Set,t=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=t.exec(e))!==null){let a=o[1];if(de.isBuiltin(a))i.add(a)}return[...i].sort()}async function Bf(e,i,t,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=qt.dirname(t),u=[],m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let h of e.matchAll(m)){let[C,x,S]=h,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=S,A,k=[];while((A=b.exec(S))!==null){let[R,T,G,M]=A,F=null,H=null;if(M.startsWith(".")||M.startsWith("/")){let B=qt.resolve(l,M);if(B.endsWith(".stx"))H=B;else{let q=`${B}.stx`;try{if(Ht.statSync(q).isFile())H=q}catch{try{if(Ht.statSync(B).isDirectory())F=B}catch{}}}}else F=Ls(M,l);if(!F&&!H)continue;let E=!1,O=(B,q)=>{c.set(B,q),c.set(B.toLowerCase(),q);let L=B.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(L,q),a.add(q)};if(G&&H)O(G,H),E=!0;else if(T){let B=T.slice(1,-1).split(",").map((L)=>L.trim()).filter(Boolean).map((L)=>{let X=L.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(X)return{source:X[1],local:X[2]};return{source:L,local:L}}),q=F?xr(F):null;for(let{source:L,local:X}of B){let z=null;if(H)z=H;else if(q)z=q.get(L)??q.get(L.toLowerCase())??q.get(L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(z)O(X,z),E=!0}}if(E)k.push({start:A.index,end:A.index+R.length})}if(k.length===0)continue;for(let R=k.length-1;R>=0;R--)w=w.slice(0,k[R].start)+w.slice(k[R].end);u.push({start:h.index,end:h.index+C.length,value:`<script${x}>${w}</script>`})}if(u.length===0)return e;let v=[],y=0;for(let h of u)v.push(e.slice(y,h.start),h.value),y=h.end;return v.push(e.slice(y)),v.join("")}async function Jn(e,i,t,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,u=/@import\s*\(\s*([^)]+)\s*\)/g,m;while((m=u.exec(c))!==null){let[v,y]=m,h=y.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of h){let x=C.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),A=null,k=js(C,t,o);for(let R of k)try{if(await Bun.file(R).exists()){A=R;break}}catch{}if(A){l.set(w,A),l.set(b,A),l.set(b.toLowerCase(),A);let R=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,A),a.add(A),o.debug)console.log(`Imported component: ${w} -> ${A}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(v,""),u.lastIndex=0}return c}async function Yn(e,i,t,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,m=/@component\s*\(/g,v;while((v=m.exec(c))!==null){let y=v.index,h=y+v[0].length-1,C=1,x=h+1;while(x<c.length&&C>0){if(c[x]==="(")C++;else if(c[x]===")"){if(C--,C===0)break}x++}if(C!==0)break;let S=c.substring(h+1,x),b=x+1,w=S.match(/^\s*['"]([^'"]+)['"]/);if(!w){m.lastIndex=b;continue}let A=w[1],k,R=S.slice(w[0].length),T=R.match(/^\s*,\s*/);if(T)k=R.slice(T[0].length).trim();let G={};if(k)try{G=P(k,i)}catch(B){let q=B instanceof Error?B.message:String(B);c=c.replace(c.substring(y,b),`[Error parsing component props: ${q}]`);continue}let M="",F=b,E=c.substring(b).match(/^([\s\S]*?)@endcomponent/);if(E)M=E[1].trim(),F=b+E[0].length;let O=await ze(A,G,M,l,i,t,o,u,a);c=c.substring(0,y)+O+c.substring(F),m.lastIndex=0}return c}async function Qn(e,i,t,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,m=nr(c);if(m.size>0){let b=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...b,...m])]}let v=J(c);c=v.output;let y=st(i);return c=await S(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await S(c,/[A-Z][a-zA-Z0-9]*/,!0,Mt(Er)),c=await S(c,/[a-z][a-z0-9]*/,!1,Er),c=v.restore(c),c;async function S(b,w,A,k){if(!b)return b;let R=b,T=Lt(R,w,k),G=ut(R),M=new Map;for(let E=T.length-1;E>=0;E--){let O=T[E],B=A?U(O.tagName):O.tagName,q=he(Zn(O.attributes,i,t)),L=G.filter(({start:I,end:_})=>O.startIndex>=I&&O.startIndex<_);if(L.some((I)=>I.tag==="template"))qn(O.tagName,t);let X=L.length>0,z=new Set(y);for(let I of L)for(let _ of I.names)z.add(_);let D=Hn(q,i,o,X,z);if(typeof D.clientReactive.for==="string")for(let I of Y(D.clientReactive.for))z.add(I);let ce=de.getBuiltin(O.tagName),$e=ce?await Rr(O.tagName,l,i,t,o):!1,K=O.tagName==="Image"&&Bs([...Object.keys(D.static),...Object.keys(D.serverDynamic),...Object.keys(D.clientReactive)],Object.keys(D.events),{...D.static,...D.serverDynamic})&&(o._pluginComponentDirs??[]).some((I)=>xr(I).has("Image"));if(ce&&!$e&&!K){let I={context:i,filePath:t,options:o,dependencies:a},_=ce.render(D,O.content,I);if(Object.keys(D.events).length>0){let ee=Vt(D.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(D.clientReactive).length>0)_=Zt(_,D.clientReactive);M.set(E,_);continue}if(!A&&O.tagName.includes("-")&&!await Rr(B,l,i,t,o))continue;let le={};for(let[I,_]of Object.entries(D.static))le[I]=_;for(let[I,_]of Object.entries(D.serverDynamic))le[I]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(D.clientReactive),events:Object.keys(D.events)},j=await ze(B,le,v.restore(O.content),l,i,t,o,u,a,[...z],te,O.tagName);if(j=er(j,D,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let I=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(U),_=dt(j,!0);if(I.length&&_){if(!Object.hasOwn(he(j.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))j=j.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+j.slice(_.insertPos);let ne=we(j);j=j.slice(0,ne.insertPos)+` data-stx-native-forward="${I.join(" ")}"`+j.slice(ne.insertPos)}let ee=dt(j,!0);if(ee){let ne=he(j.slice(ee.insertPos,ee.tagEnd)),Se=we(j),Kt=he(j.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Kt,"data-stx-native-host-owner"))j=j.slice(0,Se.insertPos)+" data-stx-native-host-owner"+j.slice(Se.insertPos)}}if(Object.keys(D.events).length>0){let I=we(j);if(I){let _=Vt(D.events),ee=Object.keys(D.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");j=j.substring(0,I.insertPos)+` data-stx-parent-events="${ee}" ${_}`+j.substring(I.insertPos)}}if(Object.keys(D.clientReactive).length>0)j=Zt(j,D.clientReactive);M.set(E,j)}if(M.size===0)return R;let F="",H=0;for(let E=0;E<T.length;E++){let O=M.get(E);if(O===void 0)continue;F+=R.slice(H,T[E].startIndex),F+=O,H=T[E].endIndex}return F+=R.slice(H),F}}function Zt(e,i){let t=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([y])=>!t.has(y)),c=a.filter(([y])=>!o.has(y)).map(([y])=>U(y)).join(" "),l=e,u=a.length>0?we(l):null;if(u){let y=a.map(([C,x])=>`:${U(C)}="${x.replace(/"/g,"&quot;")}"`).join(" "),h=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,u.insertPos)+`${h} ${y}`+l.substring(u.insertPos)}let m=i.if;if(m)l=`<template :if="${m.replace(/"/g,"&quot;")}">${l}</template>`;let v=i.for;if(v){let y=i.key,h=y?` :key="${y.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${v.replace(/"/g,"&quot;")}"${h}>${l}</template>`}return l}function er(e,i,t=new Set,o=new Set,a=!1){let c=dt(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),u=i.serverDynamic.class??i.static.class;if(a&&typeof u==="string"&&u&&!o.has("class")){let S=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=S.test(l)?l.replace(S,(w,A,k,R,T)=>`${A}class="${n(`${lt(k??R??T)} ${u}`)}"`):` class="${n(u)}"${l}`;e=e.slice(0,c.insertPos)+b+e.slice(c.tagEnd),c.tagEnd+=b.length-l.length,l=b}let m=a||/\bdata-native(?:\s|=)/i.test(l),v=m?o:t,y=new Set(Object.keys(he(l))),h=new Set(["class","className"]);for(let S of Object.keys(i.static)){let b=i.staticNames[S]??S;if(y.has(b)||v.has(S)||!m&&!qe(b))h.add(S)}for(let S of Object.keys(i.serverDynamic)){let b=i.serverDynamicNames?.[S]??S;if(y.has(b)||v.has(S)||!m&&!qe(b))h.add(S)}let C=[];if(m){for(let[S,b]of Object.entries(i.static)){if(h.has(S)||b!==!0&&b!==re)continue;h.add(S),C.push(`${n(i.staticNames?.[S]??S)}="true"`)}for(let[S,b]of Object.entries(i.serverDynamic)){if(h.has(S)||b!==!0)continue;h.add(S),C.push(`${n(i.serverDynamicNames?.[S]??S)}="true"`)}}let x=[...se(i,h),...ae(i,h),...C];if(m){for(let[S,b]of Object.entries(i.serverDynamic)){if(h.has(S)||b!==!1)continue;let w=i.serverDynamicNames?.[S]??S;x.push(`${n(w)}="false"`)}for(let[S,b]of Object.entries(i.serverDynamic)){if(h.has(S)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let A=i.serverDynamicNames?.[S]??S;x.push(`${n(A)}="${n(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,c.insertPos)} ${x.join(" ")}${e.slice(c.insertPos)}`}function we(e){let i=Gt(e,0);if(i)return i;let t=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(t)return{insertPos:t.index+1+t[1].length,tagEnd:gt(e,t.index+1+t[1].length)};return null}function dt(e,i=!1){let t=we(e);if(!t)return null;let o=e.slice(t.insertPos,t.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Gt(e,t.tagEnd+1):t;return a&&i?tr(e,a)??a:a}function tr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let t=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",i.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let y=e.indexOf("-->",o+4);if(y<0)return null;o=e.indexOf("<",y+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let u=l[2].toLowerCase(),m=o+l[0].length,v=gt(e,m);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(u==="script"||u==="style"){let y=new RegExp(`</${u}\\s*>`,"gi");if(y.lastIndex=v+1,!y.exec(e))return null;o=e.indexOf("<",y.lastIndex);continue}else{let y=he(e.slice(m,v)),h=a>0&&(Object.hasOwn(y,"data-stx-component-wrapper")||Object.hasOwn(y,"data-stx-native-host-owner"));if(c===void 0&&!h&&Object.hasOwn(y,"data-stx-native-host-root"))return{insertPos:m,tagEnd:v};if(!t.has(u)&&e[v-1]!=="/"){if(a++,c===void 0&&h)c=a}else if(a===0)return null}o=e.indexOf("<",v+1)}return null}function Gt(e,i){let t=i;while(t<e.length){let o=e.slice(t),a=o.match(/^\s+/);if(a){t+=a[0].length;continue}if(o.startsWith("<!--")){let u=e.indexOf("-->",t+4);if(u===-1)return null;t=u+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let u=`</${c[1].toLowerCase()}>`,m=e.toLowerCase().indexOf(u,t+c[0].length);if(m===-1)return null;t=m+u.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:t+1+l[1].length,tagEnd:gt(e,t+1+l[1].length)}}return null}function gt(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function nr(e){let i=new Set;for(let t of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=t[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of gi(t[2]))i.add(a);for(let a of t[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])i.add(a[1]);if(a[3])i.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))i.add(l)}}}return i}async function ms(e,i,t,o,a){if(!Xt)Tt(de),Xt=!0;let c=await Bf(e,i,t,o,a);c=await Jn(c,i,t,o,a),c=await Yn(c,i,t,o,a);let l=[];for(let u=0;u<3;u++){let m=l.length,v=fe(c,De,(h,C)=>`\x00STX_COMPONENT_COMMENT_${m+C}\x00`,`STX_COMPONENT_COMMENT:${m}`);l.push(...v.tokens);let y=c;if(c=await Qn(v.output,i,t,o,a),c===y)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(u,m)=>l[Number(m)]??"");if(o.debug){let u=Kn(c);if(u.length>0)console.warn(`[stx] ${t}: unresolved component tag(s) after render passes: ${u.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
42
+ export{zo,Ho,Vo,jh,gs,Bh,fc,Fh,Bf,ms};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{R,u,f,P,d,K}from"./chunk-r8xwd8r1.js";import{V,Os,Ne,pe,Pt,Cr,Be,Fe,r,h,ke,E}from"./chunk-tjnf4a8g.js";import{ct}from"./chunk-n91sm385.js";import{I}from"./chunk-zjqvbcwa.js";import{oe}from"./chunk-48vnw9t9.js";import{B,Ze}from"./chunk-ybq56wam.js";import{T,Tn}from"./chunk-jabw4ck5.js";import C from"path";import{existsSync as ye}from"fs";function ae(c,e){let a=0;for(let n=e;n<c.length;n++){let S=c[n];if(S==="("||S==="["||S==="{")a++;else if(S===")"||S==="]"||S==="}")a--;else if(S===","&&a===0)return n}return-1}function $e(c,e,a){let n=c,S=new RegExp(`${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),s=S.exec(n);while(s){let g=s.index,t=g+s[0].length-1,D=1,W=t+1;while(W<n.length&&D>0){if(n[W]==="(")D++;else if(n[W]===")")D--;W++}if(D!==0)break;let re=n.substring(t+1,W-1),N=`${a}(${re})`;n=n.substring(0,g)+N+n.substring(W),S.lastIndex=g+N.length,s=S.exec(n)}return n}function Ee(c){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(c)}function he(c){let e=c,a=[],n=new Set,S=0,s=0,g=e.length,t=(N)=>{s++;while(s<g){if(e[s]==="\\"){s+=2;continue}if(e[s]===N){s++;return}s++}},D=()=>{s++;while(s<g){if(e[s]==="\\"){s+=2;continue}if(e[s]==="`"){s++;return}if(e[s]==="$"&&e[s+1]==="{"){s+=2;let N=1;while(s<g&&N>0)if(e[s]==="{")N++,s++;else if(e[s]==="}")N--,s++;else if(e[s]==="'"||e[s]==='"')t(e[s]);else if(e[s]==="`")D();else s++;continue}s++}},W=()=>{if(e[s]==="/"&&e[s+1]==="/"){while(s<g&&e[s]!==`
2
+ import{R,u,f,P,d,K}from"./chunk-eg2p1cyw.js";import{V,Ds,Ne,pe,Pt,Tr,Be,Fe,r,h,ke,E}from"./chunk-ybgzr6wn.js";import{ct}from"./chunk-0wms5teg.js";import{I}from"./chunk-xppm4cs4.js";import{oe}from"./chunk-cww1zk8y.js";import{B,Ze}from"./chunk-ybq56wam.js";import{T,$n}from"./chunk-k44qj40k.js";import C from"path";import{existsSync as ye}from"fs";function ae(c,e){let a=0;for(let n=e;n<c.length;n++){let S=c[n];if(S==="("||S==="["||S==="{")a++;else if(S===")"||S==="]"||S==="}")a--;else if(S===","&&a===0)return n}return-1}function $e(c,e,a){let n=c,S=new RegExp(`${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),s=S.exec(n);while(s){let g=s.index,t=g+s[0].length-1,D=1,W=t+1;while(W<n.length&&D>0){if(n[W]==="(")D++;else if(n[W]===")")D--;W++}if(D!==0)break;let re=n.substring(t+1,W-1),N=`${a}(${re})`;n=n.substring(0,g)+N+n.substring(W),S.lastIndex=g+N.length,s=S.exec(n)}return n}function Ee(c){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(c)}function he(c){let e=c,a=[],n=new Set,S=0,s=0,g=e.length,t=(N)=>{s++;while(s<g){if(e[s]==="\\"){s+=2;continue}if(e[s]===N){s++;return}s++}},D=()=>{s++;while(s<g){if(e[s]==="\\"){s+=2;continue}if(e[s]==="`"){s++;return}if(e[s]==="$"&&e[s+1]==="{"){s+=2;let N=1;while(s<g&&N>0)if(e[s]==="{")N++,s++;else if(e[s]==="}")N--,s++;else if(e[s]==="'"||e[s]==='"')t(e[s]);else if(e[s]==="`")D();else s++;continue}s++}},W=()=>{if(e[s]==="/"&&e[s+1]==="/"){while(s<g&&e[s]!==`
3
3
  `)s++;return!0}if(e[s]==="/"&&e[s+1]==="*"){s+=2;while(s<g-1&&!(e[s]==="*"&&e[s+1]==="/"))s++;return s+=2,!0}return!1},re=()=>{if(S!==0)return;let N=e.slice(s).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(N){let Z=N[2];if(!n.has(Z))a.push(Z),n.add(Z);return}let te=e.slice(s).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(te){let Z=te[1];if(!n.has(Z))a.push(Z),n.add(Z);return}let Y=e.slice(s).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let Z=Y[1];if(!n.has(Z))a.push(Z),n.add(Z)}};while(s<g){if(W())continue;if(e[s]==="'"||e[s]==='"'){t(e[s]);continue}if(e[s]==="`"){D();continue}if(e[s]==="{"){S++,s++;continue}if(e[s]==="}"){S--,s++;continue}if(S===0&&/[a-z]/i.test(e[s])&&(s===0||/\s|[;{}()]/.test(e[s-1])))re();s++}return a.join(", ")}function ve(c,e=""){let a=he(c).split(",").map((n)=>n.trim()).filter(Boolean);return`
4
4
  (function() {
5
5
  ${ct("var",a)}
@@ -9,7 +9,7 @@ import{R,u,f,P,d,K}from"./chunk-r8xwd8r1.js";import{V,Os,Ne,pe,Pt,Cr,Be,Fe,r,h,k
9
9
 
10
10
  ${c}
11
11
  ${e}})();
12
- `}function Re(c,e){let n=he(c).split(",").map((g)=>g.trim()).filter(Boolean),S=new Set(V(c,!0).split(",").map((g)=>g.trim())),s=n.map((g)=>S.has(g)?` try { ${g}; Object.defineProperty(__scopeRegistration, ${JSON.stringify(g)}, ${Os(g)}); } catch (e) { /* not actually top-level */ }`:` try { __scopeRegistration[${JSON.stringify(g)}] = ${g}; } catch (e) { /* not actually top-level */ }`).join(`
12
+ `}function Re(c,e){let n=he(c).split(",").map((g)=>g.trim()).filter(Boolean),S=new Set(V(c,!0).split(",").map((g)=>g.trim())),s=n.map((g)=>S.has(g)?` try { ${g}; Object.defineProperty(__scopeRegistration, ${JSON.stringify(g)}, ${Ds(g)}); } catch (e) { /* not actually top-level */ }`:` try { __scopeRegistration[${JSON.stringify(g)}] = ${g}; } catch (e) { /* not actually top-level */ }`).join(`
13
13
  `);return`
14
14
  // Register scope variables for STX runtime
15
15
  if (!window.stx._scopes) window.stx._scopes = {};
@@ -44,11 +44,11 @@ ${s}
44
44
  }
45
45
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
46
46
  }
47
- })();`;return a+c+n}function Te(c,e){if(B(c)){let s=B(c).tag.match(/data-stx-scope="([^"]*)"/);if(s)return{html:c,mergedIntoExisting:s[1],stamped:!0,root:"body"};return{html:Ze(c,(g,t)=>`<body${t} data-stx-scope="${e}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let a=Pt(c),n=c.slice(a).match(/^(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(n){let S=n[1]+n[2],s=n[1].slice(1),g=S.match(/data-stx-scope="([^"]*)"/);if(g)return{html:c,mergedIntoExisting:g[1],stamped:!0,root:s};let t=c.slice(0,a),D=n[1],W=n[2];return{html:`${t}${D} data-stx-scope="${e}"${W}${c.slice(a+n[0].length)}`,mergedIntoExisting:null,stamped:!0,root:s}}return{html:c,mergedIntoExisting:null,stamped:!1,root:null}}var Ae=0;function fe(c,e){let a=C.basename(c,".stx").replace(/[^a-zA-Z0-9]/g,"_"),n=e.__stx_scope_seq;return n?`stx_scope_${a}_${++n.n}_${n.key}`:`stx_scope_${a}_${++Ae}`}var le=new Set,de=new Set;function Nh(){le.clear(),de.clear()}var Ce=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Mf(c){let e=(t)=>t.replace(/[^\n]/g," "),a=c.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,e).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,e).replace(/<!--[\s\S]*?-->/g,e).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,e).replace(/\{\{[\s\S]*?\}\}/g,e).replace(/\{!![\s\S]*?!!\}/g,e),n=[],S=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,g;while((g=s.exec(a))!==null){let t=g[1]==="/",D=g[2],W=g[3]==="/"||Ce.has(D.toLowerCase());if(t){S=Math.max(0,S-1);continue}if(S===0)n.push(D);if(!W)S++}return n}function me(c){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(c)}var Ye=new R(500),uc=new Set;function Dh(){uc.clear()}function De(c){if(c.__onceStore instanceof Set)return c.__onceStore;return uc}async function cs(c,e,a,n,S,s=new Set){let g=n.partialsDir||C.join(C.dirname(a),"partials");if(g&&!C.isAbsolute(g))g=C.resolve(process.cwd(),g);let t=$e(c,"@partial","@include"),D=De(e);t=t.replace(/@once([\s\S]*?)@endonce/g,(m,k,x)=>{let p=k.trim(),i=`${a}:${p}`;if(D.has(i))return"";return D.add(i),k});{let m=/@includeIf\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")")i--;_++}if(i!==0)break;let l=t.substring(p+1,_-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){m.lastIndex=_;continue}let O=o[1],z=W(O,g,a),v="";if(z&&await Bun.file(z).exists())S.add(z),v=`@include(${l})`;t=t.substring(0,x)+v+t.substring(_),m.lastIndex=0}}for(let[m,k]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),p;while((p=x.exec(t))!==null){let i=p.index,_=i+p[0].length-1,l=1,o=_+1;while(o<t.length&&l>0){if(t[o]==="(")l++;else if(t[o]===")")l--;o++}if(l!==0)break;let O=t.substring(_+1,o-1),z=ae(O,0);if(z===-1){x.lastIndex=o;continue}let v=O.substring(0,z).trim(),H=O.substring(z+1).trim(),F=H.match(/^\s*['"]([^'"]+)['"]/);if(!F){x.lastIndex=o;continue}let w=F[1],J=H.substring(F[0].length),j,M=ae(J,0);if(M!==-1)j=J.substring(M+1).trim();try{let A=`Boolean(${v})`,L;if(f(A)){let ie=d(A,Object.keys(e));L=Boolean(ie(...Object.values(e)))}else L=Boolean(u(A,e));let ee=k?!L:L,ne="";if(ee){let ie=W(w,g,a);if(ie&&await Bun.file(ie).exists())S.add(ie);ne=`@include('${w}'${j?`, ${j}`:""})`}t=t.substring(0,i)+ne+t.substring(o),x.lastIndex=0}catch(A){let L=A instanceof Error?A.message:String(A),ee=h("Include",`Error evaluating ${m} condition: ${L}`,a,c,i);t=t.substring(0,i)+ee+t.substring(o),x.lastIndex=0}}}{let m=/@each\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")"){if(i--,i===0)break}_++}if(i!==0)break;let l=t.substring(p+1,_),o=t.substring(x,_+1),O=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){m.lastIndex=0,t=t.replace(o,"");continue}let[,z,v,H,F]=O;try{let w,J=v.trim();if(f(J))w=d(J,Object.keys(e))(...Object.values(e));else w=u(J,e);let j="";if(Array.isArray(w)&&w.length>0)for(let M of w){let A={...e,[H]:M},L=await te(z,A,c,x);j+=L}else if(F)j=await te(F,{},c,x);t=t.substring(0,x)+j+t.substring(_+1),m.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);t=t.substring(0,x)+h("Each",`Error in @each: ${J}`,a,c,x)+t.substring(_+1),m.lastIndex=0}}}{let m=/@includeFirst\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")"){if(i--,i===0)break}_++}if(i!==0)break;let l=t.substring(p+1,_),o=t.substring(x,_+1),O=l.match(/^\s*(\[[^\]]+\])/);if(!O){m.lastIndex=0,t=t.replace(o,"");continue}let z=O[1],v=l.slice(O[0].length),H,F=v.match(/^\s*,\s*\{/);if(F){v=v.slice(F[0].length-1);let j=1,M=1;while(M<v.length&&j>0){if(v[M]==="{")j++;else if(v[M]==="}"){if(j--,j===0)break}M++}H=v.substring(0,M+1),v=v.slice(M+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let j=JSON.parse(z.replace(/'/g,'"')),M={};if(H)try{M=P(H,e)}catch(L){let ee=L instanceof Error?L.message:String(L);if(n.debug){let ne=h("Include",`Error parsing includeFirst variables: ${ee}`,a,c,x,o);t=t.replace(o,()=>ne)}else t=t.replace(o,()=>w||"");continue}let A=!1;for(let L of j){let ee=W(L,g,a);if(!ee)continue;if(await r(ee)){let ne=await te(L,M,c,x);t=t.replace(o,()=>ne),A=!0;break}}if(!A)if(w!==void 0)t=t.replace(o,()=>w);else if(n.debug){let L=h("Include",`None of the includeFirst paths exist: ${z}`,a,c,x,o);t=t.replace(o,()=>L)}else t=t.replace(o,"")}catch(j){let M=j instanceof Error?j.message:String(j),A=h("Include",`Error processing @includeFirst: ${M}`,a,c,x,o);t=t.replace(o,()=>A)}m.lastIndex=0}}function W(m,k,x){try{let p=m;if(!m.endsWith(".stx"))p=`${m}.stx`;let i=C.resolve(k),_=C.resolve(C.dirname(x)),l;if(!p.startsWith("./")&&!p.startsWith("../")){for(let F of n._layerPartialDirs??[]){let w=C.resolve(F,p);if(w.startsWith(`${C.resolve(F)}${C.sep}`)&&ye(w))return w}l=C.resolve(k,p)}else l=C.resolve(_,p);let o=C.normalize(l),O=o.startsWith(i+C.sep)||o===i,z=o.startsWith(_+C.sep)||o===_,v=!1,H=C.dirname(_);if(o.startsWith(H+C.sep)){if(!C.relative(H,o).split(C.sep).some((j)=>j.startsWith(".")&&j!=="."&&j!==".."))v=!0}if(!O&&!z&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${m}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${i}, ${_}`),null;return o}catch(p){return console.error(`Error resolving path ${m}: ${p}`),null}}let re=C.resolve(a);s.add(re);function N(m,k,x,p){return n.onIncludeError?.({includePath:m,templatePath:a,message:k,partialsDir:g}),h("Include",k,a,x,p)}async function te(m,k={},x,p){let i=W(m,g,a);if(!i)return N(m,`Could not resolve path for include: ${m}`,x,p);let _=C.resolve(i);if(s.has(_)){let l=[...s,_].map((o)=>C.basename(o)).join(" -> ");return N(m,`Circular include detected: ${l}`,x,p)}try{S.add(i);let l;if(!l)try{l=await Bun.file(i).text()}catch(y){let q=y instanceof Error?y.message:String(y);return N(m,`Error loading include file ${m}: ${q}`,x,p)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-exr9599h.js");l=y(l,e)}if(l&&(n.debug||!T()&&!Tn()))try{let{warnUnbalancedTags:y}=await import("./chunk-yg5a54pj.js");y(l,i)}catch{}try{let{processESImports:y}=await import("./chunk-afyvnpr9.js");l=await y(l,e,i,n,S)}catch(y){if(n.debug)console.warn(`[stx] partial ES import extraction skipped for ${i}:`,y instanceof Error?y.message:y)}let o=l,O=pe(o);if(O)o=O.content.trim();let v=l.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),H="";if(v)H=`<style${v[1]}>${v[2]}</style>`;let F=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(y,q,b)=>{if(!me(q))return"";return F.push({attrs:q,body:b}),`__STX_DATA_BLOCK_${F.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let w={...e};w.__stx_signals_gate=ke(l,i);for(let[y,q]of Object.entries(k))w[y]=q;let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,j=[...l.matchAll(J)].sort((y,q)=>{let b=(y[1]||"").includes("server"),X=(q[1]||"").includes("server");return Number(X)-Number(b)}),M="",A=null,L=!1,ee=!1;for(let y of j){let q=y[1]||"",b=y[2]||"";if(me(q))continue;let X=q.includes("server"),be=Be(q);if(!X&&!/\bsrc\s*=/i.test(q))Ne(b,i,n.strict);if(!X&&b.trim()){let{interpolateScriptExpressions:U}=await import("./chunk-xjbc3bhs.js");b=U(b,w,m)}let ce="";try{let{extractAndStripCssImports:U,renderVendorStyleTags:Q}=await import("./chunk-wvwca1e9.js"),se=U(b,{filePath:i,projectRoot:process.cwd()});b=se.code,ce=Q(se.styles)}catch(U){if(n.debug)console.warn(`[stx] vendor-css extractor skipped for ${i}:`,U instanceof Error?U.message:U)}if(be&&b.trim())b=Fe(b);if(!X){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-wvwca1e9.js");b=Q(b).code;let{hasUserImports:se,bundleClientScript:Se}=await import("./chunk-fz433ybr.js");if(se(b))b=await Se(b,i,{projectRoot:process.cwd()})}catch(Q){if(n.debug)console.warn(`[stx] bundler skipped for ${i}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:U}=await import("./chunk-1k751fgt.js");b=U(b)}let ge=Ee(b);if(!X){let{extractBridgeData:U,generateServerDataBridge:Q}=await import("./chunk-wvwca1e9.js"),se=Q(b,U(w));if(se)b=`${se}
47
+ })();`;return a+c+n}function Te(c,e){if(B(c)){let s=B(c).tag.match(/data-stx-scope="([^"]*)"/);if(s)return{html:c,mergedIntoExisting:s[1],stamped:!0,root:"body"};return{html:Ze(c,(g,t)=>`<body${t} data-stx-scope="${e}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let a=Pt(c),n=c.slice(a).match(/^(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(n){let S=n[1]+n[2],s=n[1].slice(1),g=S.match(/data-stx-scope="([^"]*)"/);if(g)return{html:c,mergedIntoExisting:g[1],stamped:!0,root:s};let t=c.slice(0,a),D=n[1],W=n[2];return{html:`${t}${D} data-stx-scope="${e}"${W}${c.slice(a+n[0].length)}`,mergedIntoExisting:null,stamped:!0,root:s}}return{html:c,mergedIntoExisting:null,stamped:!1,root:null}}var Ae=0;function fe(c,e){let a=C.basename(c,".stx").replace(/[^a-zA-Z0-9]/g,"_"),n=e.__stx_scope_seq;return n?`stx_scope_${a}_${++n.n}_${n.key}`:`stx_scope_${a}_${++Ae}`}var le=new Set,de=new Set;function Mh(){le.clear(),de.clear()}var Ce=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function jf(c){let e=(t)=>t.replace(/[^\n]/g," "),a=c.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,e).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,e).replace(/<!--[\s\S]*?-->/g,e).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,e).replace(/\{\{[\s\S]*?\}\}/g,e).replace(/\{!![\s\S]*?!!\}/g,e),n=[],S=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,g;while((g=s.exec(a))!==null){let t=g[1]==="/",D=g[2],W=g[3]==="/"||Ce.has(D.toLowerCase());if(t){S=Math.max(0,S-1);continue}if(S===0)n.push(D);if(!W)S++}return n}function me(c){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(c)}var Ye=new R(500),pc=new Set;function Lh(){pc.clear()}function De(c){if(c.__onceStore instanceof Set)return c.__onceStore;return pc}async function us(c,e,a,n,S,s=new Set){let g=n.partialsDir||C.join(C.dirname(a),"partials");if(g&&!C.isAbsolute(g))g=C.resolve(process.cwd(),g);let t=$e(c,"@partial","@include"),D=De(e);t=t.replace(/@once([\s\S]*?)@endonce/g,(m,k,x)=>{let p=k.trim(),i=`${a}:${p}`;if(D.has(i))return"";return D.add(i),k});{let m=/@includeIf\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")")i--;_++}if(i!==0)break;let l=t.substring(p+1,_-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){m.lastIndex=_;continue}let O=o[1],z=W(O,g,a),v="";if(z&&await Bun.file(z).exists())S.add(z),v=`@include(${l})`;t=t.substring(0,x)+v+t.substring(_),m.lastIndex=0}}for(let[m,k]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),p;while((p=x.exec(t))!==null){let i=p.index,_=i+p[0].length-1,l=1,o=_+1;while(o<t.length&&l>0){if(t[o]==="(")l++;else if(t[o]===")")l--;o++}if(l!==0)break;let O=t.substring(_+1,o-1),z=ae(O,0);if(z===-1){x.lastIndex=o;continue}let v=O.substring(0,z).trim(),H=O.substring(z+1).trim(),F=H.match(/^\s*['"]([^'"]+)['"]/);if(!F){x.lastIndex=o;continue}let w=F[1],J=H.substring(F[0].length),j,M=ae(J,0);if(M!==-1)j=J.substring(M+1).trim();try{let A=`Boolean(${v})`,L;if(f(A)){let ie=d(A,Object.keys(e));L=Boolean(ie(...Object.values(e)))}else L=Boolean(u(A,e));let ee=k?!L:L,ne="";if(ee){let ie=W(w,g,a);if(ie&&await Bun.file(ie).exists())S.add(ie);ne=`@include('${w}'${j?`, ${j}`:""})`}t=t.substring(0,i)+ne+t.substring(o),x.lastIndex=0}catch(A){let L=A instanceof Error?A.message:String(A),ee=h("Include",`Error evaluating ${m} condition: ${L}`,a,c,i);t=t.substring(0,i)+ee+t.substring(o),x.lastIndex=0}}}{let m=/@each\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")"){if(i--,i===0)break}_++}if(i!==0)break;let l=t.substring(p+1,_),o=t.substring(x,_+1),O=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){m.lastIndex=0,t=t.replace(o,"");continue}let[,z,v,H,F]=O;try{let w,J=v.trim();if(f(J))w=d(J,Object.keys(e))(...Object.values(e));else w=u(J,e);let j="";if(Array.isArray(w)&&w.length>0)for(let M of w){let A={...e,[H]:M},L=await te(z,A,c,x);j+=L}else if(F)j=await te(F,{},c,x);t=t.substring(0,x)+j+t.substring(_+1),m.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);t=t.substring(0,x)+h("Each",`Error in @each: ${J}`,a,c,x)+t.substring(_+1),m.lastIndex=0}}}{let m=/@includeFirst\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")"){if(i--,i===0)break}_++}if(i!==0)break;let l=t.substring(p+1,_),o=t.substring(x,_+1),O=l.match(/^\s*(\[[^\]]+\])/);if(!O){m.lastIndex=0,t=t.replace(o,"");continue}let z=O[1],v=l.slice(O[0].length),H,F=v.match(/^\s*,\s*\{/);if(F){v=v.slice(F[0].length-1);let j=1,M=1;while(M<v.length&&j>0){if(v[M]==="{")j++;else if(v[M]==="}"){if(j--,j===0)break}M++}H=v.substring(0,M+1),v=v.slice(M+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let j=JSON.parse(z.replace(/'/g,'"')),M={};if(H)try{M=P(H,e)}catch(L){let ee=L instanceof Error?L.message:String(L);if(n.debug){let ne=h("Include",`Error parsing includeFirst variables: ${ee}`,a,c,x,o);t=t.replace(o,()=>ne)}else t=t.replace(o,()=>w||"");continue}let A=!1;for(let L of j){let ee=W(L,g,a);if(!ee)continue;if(await r(ee)){let ne=await te(L,M,c,x);t=t.replace(o,()=>ne),A=!0;break}}if(!A)if(w!==void 0)t=t.replace(o,()=>w);else if(n.debug){let L=h("Include",`None of the includeFirst paths exist: ${z}`,a,c,x,o);t=t.replace(o,()=>L)}else t=t.replace(o,"")}catch(j){let M=j instanceof Error?j.message:String(j),A=h("Include",`Error processing @includeFirst: ${M}`,a,c,x,o);t=t.replace(o,()=>A)}m.lastIndex=0}}function W(m,k,x){try{let p=m;if(!m.endsWith(".stx"))p=`${m}.stx`;let i=C.resolve(k),_=C.resolve(C.dirname(x)),l;if(!p.startsWith("./")&&!p.startsWith("../")){for(let F of n._layerPartialDirs??[]){let w=C.resolve(F,p);if(w.startsWith(`${C.resolve(F)}${C.sep}`)&&ye(w))return w}l=C.resolve(k,p)}else l=C.resolve(_,p);let o=C.normalize(l),O=o.startsWith(i+C.sep)||o===i,z=o.startsWith(_+C.sep)||o===_,v=!1,H=C.dirname(_);if(o.startsWith(H+C.sep)){if(!C.relative(H,o).split(C.sep).some((j)=>j.startsWith(".")&&j!=="."&&j!==".."))v=!0}if(!O&&!z&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${m}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${i}, ${_}`),null;return o}catch(p){return console.error(`Error resolving path ${m}: ${p}`),null}}let re=C.resolve(a);s.add(re);function N(m,k,x,p){return n.onIncludeError?.({includePath:m,templatePath:a,message:k,partialsDir:g}),h("Include",k,a,x,p)}async function te(m,k={},x,p){let i=W(m,g,a);if(!i)return N(m,`Could not resolve path for include: ${m}`,x,p);let _=C.resolve(i);if(s.has(_)){let l=[...s,_].map((o)=>C.basename(o)).join(" -> ");return N(m,`Circular include detected: ${l}`,x,p)}try{S.add(i);let l;if(!l)try{l=await Bun.file(i).text()}catch(y){let q=y instanceof Error?y.message:String(y);return N(m,`Error loading include file ${m}: ${q}`,x,p)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-79pgjds2.js");l=y(l,e)}if(l&&(n.debug||!T()&&!$n()))try{let{warnUnbalancedTags:y}=await import("./chunk-7ycmnsh5.js");y(l,i)}catch{}try{let{processESImports:y}=await import("./chunk-9m96yv69.js");l=await y(l,e,i,n,S)}catch(y){if(n.debug)console.warn(`[stx] partial ES import extraction skipped for ${i}:`,y instanceof Error?y.message:y)}let o=l,O=pe(o);if(O)o=O.content.trim();let v=l.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),H="";if(v)H=`<style${v[1]}>${v[2]}</style>`;let F=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(y,q,b)=>{if(!me(q))return"";return F.push({attrs:q,body:b}),`__STX_DATA_BLOCK_${F.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let w={...e};w.__stx_signals_gate=ke(l,i);for(let[y,q]of Object.entries(k))w[y]=q;let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,j=[...l.matchAll(J)].sort((y,q)=>{let b=(y[1]||"").includes("server"),X=(q[1]||"").includes("server");return Number(X)-Number(b)}),M="",A=null,L=!1,ee=!1;for(let y of j){let q=y[1]||"",b=y[2]||"";if(me(q))continue;let X=q.includes("server"),be=Be(q);if(!X&&!/\bsrc\s*=/i.test(q))Ne(b,i,n.strict);if(!X&&b.trim()){let{interpolateScriptExpressions:U}=await import("./chunk-6bemqsdj.js");b=U(b,w,m)}let ce="";try{let{extractAndStripCssImports:U,renderVendorStyleTags:Q}=await import("./chunk-nm04926f.js"),se=U(b,{filePath:i,projectRoot:process.cwd()});b=se.code,ce=Q(se.styles)}catch(U){if(n.debug)console.warn(`[stx] vendor-css extractor skipped for ${i}:`,U instanceof Error?U.message:U)}if(be&&b.trim())b=Fe(b);if(!X){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-nm04926f.js");b=Q(b).code;let{hasUserImports:se,bundleClientScript:Se}=await import("./chunk-se79v0pe.js");if(se(b))b=await Se(b,i,{projectRoot:process.cwd()})}catch(Q){if(n.debug)console.warn(`[stx] bundler skipped for ${i}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:U}=await import("./chunk-j1sm889p.js");b=U(b)}let ge=Ee(b);if(!X){let{extractBridgeData:U,generateServerDataBridge:Q}=await import("./chunk-nm04926f.js"),se=Q(b,U(w));if(se)b=`${se}
48
48
  ${b}`}if(ge&&!X){L=!0,A=fe(i,e);let U=I(b),Q=ue(U,A);M+=`${ce}<script data-stx-scoped data-stx-run="always" data-stx-owner="${A}">${Q}</script>
49
- `;continue}if(X)try{let{extractVariables:U}=await import("./chunk-rapk2r7b.js");await U(b,w,i)}catch(U){if(n.debug)console.warn(`Warning: Could not extract variables from server script in ${i}:`,U)}if(!X&&!ge){let U=q.replace(/\bclient\b/i,"").trim();A=fe(i,e);let Q=I(b),se=ue(Q,A);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(se))ee=!0;M+=`${ce}<script data-stx-scoped data-stx-run="always" data-stx-owner="${A}"${U?` ${U}`:""}>${se}</script>
50
- `}}if(F.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-xjbc3bhs.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(q,b)=>{let X=F[Number(b)];return`<script${X.attrs}>${y(X.body,w,m)}</script>`})}if(A){let y=Te(o,A);if(o=y.html,y.mergedIntoExisting){let b=A,X=y.mergedIntoExisting;M=M.split(`'${b}'`).join(`'${X}'`).split(`"${b}"`).join(`"${X}"`),A=X}else if(!y.stamped&&L&&!le.has(i))le.add(i),console.warn(`[stx] ${C.relative(process.cwd(),i)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(y.stamped&&y.root!=="body"&&(L||ee)&&!de.has(i)){let b=Mf(o);if(b.length>1)de.add(i),console.warn(`[stx] ${C.relative(process.cwd(),i)} declares ${L?"signals":"bindings"} and has ${b.length} top-level elements (${b.map((X)=>`<${X}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let q=y.stamped&&y.root!==null&&Cr(y.root);M=Ie(M,q?A:null)}if(o.includes("@include")||o.includes("@partial"))o=await cs(o,w,i,n,S,s);let{processLoops:ne,reportDeferredLoopWarnings:ie}=await import("./chunk-xtbmntht.js"),G=ne(o,w,i,void 0,!0);G=oe(G,w,i),G=ie(G);let{processMetaDirectives:xe,processSeoDirective:_e,processStructuredData:we}=await import("./chunk-fyesbfvr.js");if(G=xe(G,w,i,n),G=we(G,w,i),G=_e(G,w,i,n),G=E(G,w,i),H)G+=`
49
+ `;continue}if(X)try{let{extractVariables:U}=await import("./chunk-kvttzk86.js");await U(b,w,i)}catch(U){if(n.debug)console.warn(`Warning: Could not extract variables from server script in ${i}:`,U)}if(!X&&!ge){let U=q.replace(/\bclient\b/i,"").trim();A=fe(i,e);let Q=I(b),se=ue(Q,A);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(se))ee=!0;M+=`${ce}<script data-stx-scoped data-stx-run="always" data-stx-owner="${A}"${U?` ${U}`:""}>${se}</script>
50
+ `}}if(F.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-6bemqsdj.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(q,b)=>{let X=F[Number(b)];return`<script${X.attrs}>${y(X.body,w,m)}</script>`})}if(A){let y=Te(o,A);if(o=y.html,y.mergedIntoExisting){let b=A,X=y.mergedIntoExisting;M=M.split(`'${b}'`).join(`'${X}'`).split(`"${b}"`).join(`"${X}"`),A=X}else if(!y.stamped&&L&&!le.has(i))le.add(i),console.warn(`[stx] ${C.relative(process.cwd(),i)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(y.stamped&&y.root!=="body"&&(L||ee)&&!de.has(i)){let b=jf(o);if(b.length>1)de.add(i),console.warn(`[stx] ${C.relative(process.cwd(),i)} declares ${L?"signals":"bindings"} and has ${b.length} top-level elements (${b.map((X)=>`<${X}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let q=y.stamped&&y.root!==null&&Tr(y.root);M=Ie(M,q?A:null)}if(o.includes("@include")||o.includes("@partial"))o=await us(o,w,i,n,S,s);let{processLoops:ne,reportDeferredLoopWarnings:ie}=await import("./chunk-dsh91n7n.js"),G=ne(o,w,i,void 0,!0);G=oe(G,w,i),G=ie(G);let{processMetaDirectives:xe,processSeoDirective:_e,processStructuredData:we}=await import("./chunk-6hd83cj4.js");if(G=xe(G,w,i,n),G=we(G,w,i),G=_e(G,w,i,n),G=E(G,w,i),H)G+=`
51
51
  `+H;if(M)G+=`
52
- `+M;return G}catch(l){if(l instanceof K)throw l;let o=l instanceof Error?l.message:String(l);return N(m,`Error processing include ${m}: ${o}`,x,p)}}let Y=/@include\s*\(/g,Z;while((Z=Y.exec(t))!==null){let m=Z.index,k=m+Z[0].length-1,x=1,p=k+1;while(p<t.length&&x>0){if(t[p]==="(")x++;else if(t[p]===")")x--;p++}if(x!==0)break;let i=t.substring(m,p),_=t.substring(k+1,p-1),l=_.match(/^\s*['"]([^'"]+)['"]/);if(!l){Y.lastIndex=p;continue}let o=l[1],O,z=_.substring(l[0].length),v=ae(z,0);if(v!==-1)O=z.substring(v+1).trim();let H={};if(O)try{H=P(O,e)}catch(w){let J=w instanceof Error?w.message:String(w);t=t.replace(i,h("Include",`Error parsing include variables for ${o}: ${J}`,a,c,m)),Y.lastIndex=0;continue}let F=await te(o,H,c,m);t=t.substring(0,m)+F+t.substring(p),Y.lastIndex=0}return t}function ls(c,e){let a=c;function n(S,s,g,t){let D=S,W=!0;while(W){W=!1;let re=new RegExp(`@${s}\\(['"]([^'"]+)['"]\\)`),N=D.match(re);if(!N||N.index===void 0)break;let te=N.index,Y=N[1],Z=te+N[0].length,m=new RegExp(`@${s}\\(`),k=new RegExp(`@${g}(?![a-z])`),x=1,p=Z,i=-1;while(x>0&&p<D.length){let l=D.slice(p),o=l.match(m),O=l.match(k),z=o?p+o.index:1/0,v=O?p+O.index:1/0;if(z<v)x++,p=z+(o[0].length||1);else if(v<1/0){if(x--,x===0){i=v;break}p=v+g.length+1}else break}if(i===-1)break;let _=D.slice(Z,i);if(!e[Y])e[Y]=[];if(t)e[Y].unshift(_);else e[Y].push(_);D=D.substring(0,te)+D.substring(i+`@${g}`.length),W=!0}return D}return a=n(a,"push","endpush",!1),a=n(a,"prepend","endprepend",!0),a}function us(c,e){return c.replace(/@stack\(['"]([^'"]+)['"]\)/g,(a,n)=>{if(!e[n]||e[n].length===0)return"";return e[n].join(`
52
+ `+M;return G}catch(l){if(l instanceof K)throw l;let o=l instanceof Error?l.message:String(l);return N(m,`Error processing include ${m}: ${o}`,x,p)}}let Y=/@include\s*\(/g,Z;while((Z=Y.exec(t))!==null){let m=Z.index,k=m+Z[0].length-1,x=1,p=k+1;while(p<t.length&&x>0){if(t[p]==="(")x++;else if(t[p]===")")x--;p++}if(x!==0)break;let i=t.substring(m,p),_=t.substring(k+1,p-1),l=_.match(/^\s*['"]([^'"]+)['"]/);if(!l){Y.lastIndex=p;continue}let o=l[1],O,z=_.substring(l[0].length),v=ae(z,0);if(v!==-1)O=z.substring(v+1).trim();let H={};if(O)try{H=P(O,e)}catch(w){let J=w instanceof Error?w.message:String(w);t=t.replace(i,h("Include",`Error parsing include variables for ${o}: ${J}`,a,c,m)),Y.lastIndex=0;continue}let F=await te(o,H,c,m);t=t.substring(0,m)+F+t.substring(p),Y.lastIndex=0}return t}function ds(c,e){let a=c;function n(S,s,g,t){let D=S,W=!0;while(W){W=!1;let re=new RegExp(`@${s}\\(['"]([^'"]+)['"]\\)`),N=D.match(re);if(!N||N.index===void 0)break;let te=N.index,Y=N[1],Z=te+N[0].length,m=new RegExp(`@${s}\\(`),k=new RegExp(`@${g}(?![a-z])`),x=1,p=Z,i=-1;while(x>0&&p<D.length){let l=D.slice(p),o=l.match(m),O=l.match(k),z=o?p+o.index:1/0,v=O?p+O.index:1/0;if(z<v)x++,p=z+(o[0].length||1);else if(v<1/0){if(x--,x===0){i=v;break}p=v+g.length+1}else break}if(i===-1)break;let _=D.slice(Z,i);if(!e[Y])e[Y]=[];if(t)e[Y].unshift(_);else e[Y].push(_);D=D.substring(0,te)+D.substring(i+`@${g}`.length),W=!0}return D}return a=n(a,"push","endpush",!1),a=n(a,"prepend","endprepend",!0),a}function ps(c,e){return c.replace(/@stack\(['"]([^'"]+)['"]\)/g,(a,n)=>{if(!e[n]||e[n].length===0)return"";return e[n].join(`
53
53
  `)})}
54
- export{Nh,Mf,Ye,uc,Dh,cs,ls,us};
54
+ export{Mh,jf,Ye,pc,Lh,us,ds,ps};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{zr,co,qg,Pl,lo}from"./chunk-eqbx4yj1.js";export{qg as buildModuleRegistryScript,lo as buildSharedModuleRegistries,Pl as exportsMutableBinding,zr as registeredModuleIdsIn,co as registeredModuleNamesIn};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Oi,ly,uy,ml,Ue,Tg,to,dy,py,fy,gy,my,hy,yy,by,wy}from"./chunk-eg2p1cyw.js";export{hy as applyHead,dy as definePageMeta,Oi as getHead,ly as getPageMeta,Ue as mergeHeadConfigs,yy as processHeadDirective,wy as processMetaDirective,by as processTitleDirective,my as renderBodyAttrs,fy as renderHead,gy as renderHtmlAttrs,uy as resetHead,to as seoMetaToHeadConfig,ml as useHead,py as usePageTitle,Tg as useSeoMeta,py as useTitle};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ih,ah,ch,lh,uh}from"./chunk-25m74mh1.js";export{ah as createSSRSuspense,lh as generateSuspenseCSS,uh as generateSuspenseRuntime,ih as processSuspenseDirectives,ch as renderSSRSuspense};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{m,h,p}from"./chunk-tjnf4a8g.js";import{F}from"./chunk-md84j62m.js";import{i}from"./chunk-rncmfgpk.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Bm(e,t={},o={}){let n={...F,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,y,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,y,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
2
+ import{m,h,p}from"./chunk-ybgzr6wn.js";import{F}from"./chunk-5njk2ba0.js";import{i}from"./chunk-sz2nax5v.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function zm(e,t={},o={}){let n={...F,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,y,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,y,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),w.set(d.name,i(d.content,y,e,n,l))}r.enqueue(`
5
5
  <script>
@@ -17,13 +17,13 @@ import{m,h,p}from"./chunk-tjnf4a8g.js";import{F}from"./chunk-md84j62m.js";import
17
17
  }
18
18
  };
19
19
  })();
20
- </script>`);let x=Array.from(w.entries()).map(async([d,u])=>{r.enqueue(await Sa(d,u))});await Promise.all(x)}r.close()}catch(a){r.error(a)}}})}async function Sa(e,t){try{let n=(await t).replace(/`/g,"\\`").replace(/<\/script>/gi,"<\\/script>");return`
20
+ </script>`);let x=Array.from(w.entries()).map(async([d,u])=>{r.enqueue(await _a(d,u))});await Promise.all(x)}r.close()}catch(a){r.error(a)}}})}async function _a(e,t){try{let n=(await t).replace(/`/g,"\\`").replace(/<\/script>/gi,"<\\/script>");return`
21
21
  <script>
22
22
  window.__stxSuspense.resolve('${e}', \`${n}\`);
23
23
  </script>`}catch(o){let n=o instanceof Error?o.message:String(o);return`
24
24
  <script>
25
25
  window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading content: ${p(n)}</div>');
26
- </script>`}}var gu=`
26
+ </script>`}}var hu=`
27
27
  <script>
28
28
  (function(){
29
29
  window.__stxSuspense = window.__stxSuspense || {
@@ -43,12 +43,12 @@ window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading conte
43
43
  }
44
44
  };
45
45
  })();
46
- </script>`;function z(e,t,o){if(!t||t<=0)return e;let n,s=new Promise((r,a)=>{n=setTimeout(()=>a(Error(`streaming boundary "${o}" timed out after ${t}ms`)),t)});return Promise.race([e,s]).finally(()=>clearTimeout(n))}function Fm(e,t=[],o={}){let n=o.timeoutMs??0;return new ReadableStream({async start(s){try{if(s.enqueue(e),t.length>0)s.enqueue(gu),await Promise.all(t.map(async(r)=>{let a=z(r.render(),n,r.id);s.enqueue(await Sa(r.id,a))}));s.close()}catch(r){s.error(r)}}})}var A=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;function zm(e,t){return e.replace(A,(o,n,s)=>{let r=n.trim(),a=s.split(/@fallback/i),S=a[0].trim(),g=a.length>1?a.slice(1).join("@fallback").trim():"";if(!t.__streamTemplates)t.__streamTemplates={};return t.__streamTemplates[r]=S,`<div data-suspense="${r}">${g}</div>`})}function Hm(e){let t=e?.streamBoundaries;if(!t||typeof t!=="object")return;let o=Object.entries(t).filter(([,n])=>typeof n==="function");return o.length>0?o.map(([n,s])=>({id:n,render:s})):void 0}async function Vm(e,t={},o={}){let n={...F,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=new Set,l=n.streaming?.strategy||"auto",R=new RegExp(T.source,"g");if(!(l!=="manual"&&R.test(c))){let x=await i(c,y,e,n,E);for(let d=0;d<x.length;d+=s)r.enqueue(x.slice(d,d+s))}else{let x=[],d=new RegExp(T.source,"g"),u;while((u=d.exec(c))!==null)x.push({name:u[1],content:u[2],start:u.index,end:u.index+u[0].length});let b=0;for(let f of x){if(f.start>b){let _=c.slice(b,f.start);if(_.trim()){let C=await i(_,y,e,n,E);r.enqueue(C)}}let v=await i(f.content,y,e,n,E);r.enqueue(v),b=f.end}if(b<c.length){let f=c.slice(b);if(f.trim()){let v=await i(f,y,e,n,E);r.enqueue(v)}}}r.close()}catch(a){r.error(a)}}})}async function Um(e,t={}){let o={...F,...t,streaming:{...q,...t.streaming}},n=await Bun.file(e).text(),s=n.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),r=s?s[1]:"",a=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S=a,g={},c;T.lastIndex=0;while((c=T.exec(a))!==null){let l=c[1],R=c[2];g[l]=R}let y=a.replace(T,"");return{renderShell:async(l={})=>{let R={...l,__filename:e,__dirname:k.dirname(e)};return await m(r,R,e),i(y,R,e,o,new Set)},renderSection:async(l,R={})=>{try{if(!g[l])return`<div class="error-message">Section "${p(l)}" not found in template "${p(e)}"</div>`;let w={...R,__filename:e,__dirname:k.dirname(e)};await m(r,w,e);let x=new Set;return await i(g[l],w,e,o,x)}catch(w){let x=w instanceof Error?w.message:String(w);return h("Expression",x,e,g[l]||"",0,g[l]||"")}},getSections:()=>Object.keys(g),getTemplate:()=>S}}var mu={name:"suspense",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Suspense directive requires a name parameter");let s=t[0].replace(/['"`]/g,"");return`<!-- @suspense:${s} -->${e}<!-- @endsuspense:${s} -->`}},hu={name:"island",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Island directive requires a name parameter");let s=t[0].replace(/['"`]/g,""),r=t[1]?t[1].replace(/['"`]/g,""):"lazy",a=`island-${s}-${Math.random().toString(36).substring(2,9)}`,S=e.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),g=S?S[1].trim():"",c=S?e.replace(S[0],""):e;return`<div data-island="${s}" data-island-id="${a}" data-priority="${r}">
46
+ </script>`;function z(e,t,o){if(!t||t<=0)return e;let n,s=new Promise((r,a)=>{n=setTimeout(()=>a(Error(`streaming boundary "${o}" timed out after ${t}ms`)),t)});return Promise.race([e,s]).finally(()=>clearTimeout(n))}function Hm(e,t=[],o={}){let n=o.timeoutMs??0;return new ReadableStream({async start(s){try{if(s.enqueue(e),t.length>0)s.enqueue(hu),await Promise.all(t.map(async(r)=>{let a=z(r.render(),n,r.id);s.enqueue(await _a(r.id,a))}));s.close()}catch(r){s.error(r)}}})}var A=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;function Vm(e,t){return e.replace(A,(o,n,s)=>{let r=n.trim(),a=s.split(/@fallback/i),S=a[0].trim(),g=a.length>1?a.slice(1).join("@fallback").trim():"";if(!t.__streamTemplates)t.__streamTemplates={};return t.__streamTemplates[r]=S,`<div data-suspense="${r}">${g}</div>`})}function Um(e){let t=e?.streamBoundaries;if(!t||typeof t!=="object")return;let o=Object.entries(t).filter(([,n])=>typeof n==="function");return o.length>0?o.map(([n,s])=>({id:n,render:s})):void 0}async function Wm(e,t={},o={}){let n={...F,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=new Set,l=n.streaming?.strategy||"auto",R=new RegExp(T.source,"g");if(!(l!=="manual"&&R.test(c))){let x=await i(c,y,e,n,E);for(let d=0;d<x.length;d+=s)r.enqueue(x.slice(d,d+s))}else{let x=[],d=new RegExp(T.source,"g"),u;while((u=d.exec(c))!==null)x.push({name:u[1],content:u[2],start:u.index,end:u.index+u[0].length});let b=0;for(let f of x){if(f.start>b){let _=c.slice(b,f.start);if(_.trim()){let C=await i(_,y,e,n,E);r.enqueue(C)}}let v=await i(f.content,y,e,n,E);r.enqueue(v),b=f.end}if(b<c.length){let f=c.slice(b);if(f.trim()){let v=await i(f,y,e,n,E);r.enqueue(v)}}}r.close()}catch(a){r.error(a)}}})}async function qm(e,t={}){let o={...F,...t,streaming:{...q,...t.streaming}},n=await Bun.file(e).text(),s=n.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),r=s?s[1]:"",a=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S=a,g={},c;T.lastIndex=0;while((c=T.exec(a))!==null){let l=c[1],R=c[2];g[l]=R}let y=a.replace(T,"");return{renderShell:async(l={})=>{let R={...l,__filename:e,__dirname:k.dirname(e)};return await m(r,R,e),i(y,R,e,o,new Set)},renderSection:async(l,R={})=>{try{if(!g[l])return`<div class="error-message">Section "${p(l)}" not found in template "${p(e)}"</div>`;let w={...R,__filename:e,__dirname:k.dirname(e)};await m(r,w,e);let x=new Set;return await i(g[l],w,e,o,x)}catch(w){let x=w instanceof Error?w.message:String(w);return h("Expression",x,e,g[l]||"",0,g[l]||"")}},getSections:()=>Object.keys(g),getTemplate:()=>S}}var yu={name:"suspense",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Suspense directive requires a name parameter");let s=t[0].replace(/['"`]/g,"");return`<!-- @suspense:${s} -->${e}<!-- @endsuspense:${s} -->`}},bu={name:"island",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Island directive requires a name parameter");let s=t[0].replace(/['"`]/g,""),r=t[1]?t[1].replace(/['"`]/g,""):"lazy",a=`island-${s}-${Math.random().toString(36).substring(2,9)}`,S=e.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),g=S?S[1].trim():"",c=S?e.replace(S[0],""):e;return`<div data-island="${s}" data-island-id="${a}" data-priority="${r}">
47
47
  ${c}
48
48
  <script type="application/json" data-island-props="${a}">
49
49
  ${g?`{${g}}`:"{}"}
50
50
  </script>
51
- </div>`}};function Wm(e={}){let t=[];if(e.streaming?.enabled)t.push(mu);if(e.hydration?.enabled)t.push(hu);return t}async function qm(e,t,o,n={}){return e}function Km(e,t={}){let o=new TextEncoder,n=e.pipeThrough(new TransformStream({transform(r,a){a.enqueue(o.encode(r))}})),s=new Headers(t.headers);if(!s.has("Content-Type"))s.set("Content-Type","text/html; charset=utf-8");if(!s.has("Transfer-Encoding"))s.set("Transfer-Encoding","chunked");if(!s.has("X-Content-Type-Options"))s.set("X-Content-Type-Options","nosniff");if(!s.has("X-Accel-Buffering"))s.set("X-Accel-Buffering","no");return new Response(n,{...t,headers:s})}function Xm(e={mode:"full"}){let{mode:t,components:o={},dynamicImports:n=!0}=e,s=Object.entries(o).map(([r,a])=>`'${r}': ${n?`() => import('${a}')`:`require('${a}')`}`).join(`,
51
+ </div>`}};function Km(e={}){let t=[];if(e.streaming?.enabled)t.push(yu);if(e.hydration?.enabled)t.push(bu);return t}async function Xm(e,t,o,n={}){return e}function Gm(e,t={}){let o=new TextEncoder,n=e.pipeThrough(new TransformStream({transform(r,a){a.enqueue(o.encode(r))}})),s=new Headers(t.headers);if(!s.has("Content-Type"))s.set("Content-Type","text/html; charset=utf-8");if(!s.has("Transfer-Encoding"))s.set("Transfer-Encoding","chunked");if(!s.has("X-Content-Type-Options"))s.set("X-Content-Type-Options","nosniff");if(!s.has("X-Accel-Buffering"))s.set("X-Accel-Buffering","no");return new Response(n,{...t,headers:s})}function Jm(e={mode:"full"}){let{mode:t,components:o={},dynamicImports:n=!0}=e,s=Object.entries(o).map(([r,a])=>`'${r}': ${n?`() => import('${a}')`:`require('${a}')`}`).join(`,
52
52
  `);if(t==="loader")return`
53
53
  (function() {
54
54
  window.__stx = window.__stx || {};
@@ -191,4 +191,4 @@ else {
191
191
  stx.hydrate();
192
192
  }
193
193
  })();`}
194
- export{Bm,Sa,gu,Fm,zm,Hm,Vm,Um,mu,hu,Wm,qm,Km,Xm};
194
+ export{zm,_a,hu,Hm,Vm,Um,Wm,qm,yu,bu,Km,Xm,Gm,Jm};
@@ -298,5 +298,5 @@ catch (error) {
298
298
  init();
299
299
  }
300
300
  })();
301
- </script>`}var Ig={name:"pwa.installButton",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return r(t,n)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},Og={name:"pwa.updatePrompt",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return p(t,n)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},Ng={name:"pwa.offlineIndicator",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return d(t,n)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},Dg={name:"pwa.pushSubscribe",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return l(t,n)},hasEndTag:!0,description:"Renders a push notification subscription button"},ro=[Ig,Og,Ng,Dg];function by(t){return[...t,...ro]}
302
- export{Ig,Og,Ng,Dg,ro,by};
301
+ </script>`}var Ng={name:"pwa.installButton",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return r(t,n)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},Dg={name:"pwa.updatePrompt",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return p(t,n)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},Mg={name:"pwa.offlineIndicator",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return d(t,n)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},Lg={name:"pwa.pushSubscribe",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return l(t,n)},hasEndTag:!0,description:"Renders a push notification subscription button"},oo=[Ng,Dg,Mg,Lg];function vy(t){return[...t,...oo]}
302
+ export{Ng,Dg,Mg,Lg,oo,vy};