@stacksjs/stx 0.2.888 → 0.2.889

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 (241) hide show
  1. package/dist/{chunk-c0g30cjs.js → chunk-05x1rd86.js} +2 -2
  2. package/dist/chunk-0g9cceht.js +2 -0
  3. package/dist/chunk-0k437z3q.js +2 -0
  4. package/dist/{chunk-1xpq83mc.js → chunk-0ncafcs2.js} +4 -4
  5. package/dist/chunk-0rpj5t80.js +2 -0
  6. package/dist/{chunk-btsgt6w3.js → chunk-1gyxxfdf.js} +2 -2
  7. package/dist/{chunk-vazk5qbh.js → chunk-1knk403z.js} +2 -2
  8. package/dist/{chunk-6qq3wy3m.js → chunk-1n33yrar.js} +2 -2
  9. package/dist/chunk-1p4q6t48.js +2 -0
  10. package/dist/chunk-1z6pqvmf.js +2 -0
  11. package/dist/{chunk-s29hp1qw.js → chunk-2a5g80mq.js} +3 -3
  12. package/dist/chunk-2ba4zfa0.js +2 -0
  13. package/dist/chunk-2gn2nc2j.js +2 -0
  14. package/dist/chunk-2nqmw4dv.js +2 -0
  15. package/dist/chunk-2wkpksg1.js +2 -0
  16. package/dist/{chunk-xw291tn7.js → chunk-3dqfjpz4.js} +34 -29
  17. package/dist/{chunk-3ed2erm6.js → chunk-3hsv6ejp.js} +4 -4
  18. package/dist/{chunk-w624s5jf.js → chunk-3qk8vf9m.js} +3 -3
  19. package/dist/chunk-3yjyjq0m.js +2 -0
  20. package/dist/chunk-444haxxa.js +2 -0
  21. package/dist/{chunk-y76znqmh.js → chunk-446tb2th.js} +27 -27
  22. package/dist/{chunk-qjy5yq25.js → chunk-48rwqchc.js} +10 -10
  23. package/dist/chunk-4akw3bym.js +2 -0
  24. package/dist/{chunk-mm1eg2pg.js → chunk-4kmg6g5n.js} +9 -9
  25. package/dist/chunk-4rvfeee5.js +2 -0
  26. package/dist/{chunk-605g9qhp.js → chunk-51720m79.js} +5 -5
  27. package/dist/chunk-53kcqdjj.js +2 -0
  28. package/dist/{chunk-0dq9svfb.js → chunk-55tc5w32.js} +3 -3
  29. package/dist/{chunk-7s3j8pqq.js → chunk-58qzyyyv.js} +3 -3
  30. package/dist/chunk-5aa83bpm.js +2 -0
  31. package/dist/{chunk-ah6nc29h.js → chunk-5kqezrjt.js} +2 -2
  32. package/dist/chunk-5ssv10ep.js +2 -0
  33. package/dist/chunk-67rppc5v.js +2 -0
  34. package/dist/{chunk-care745q.js → chunk-6gtecbe7.js} +2 -2
  35. package/dist/{chunk-p33npqjt.js → chunk-6kyqejnq.js} +22 -22
  36. package/dist/{chunk-vjfp8n6p.js → chunk-6pdy7ajr.js} +3 -3
  37. package/dist/{chunk-9tecekzq.js → chunk-6pz5gq6v.js} +9 -9
  38. package/dist/{chunk-wpa3r3b9.js → chunk-700m927w.js} +2 -2
  39. package/dist/{chunk-2assyczz.js → chunk-7212fwzz.js} +2 -2
  40. package/dist/chunk-732gb689.js +2 -0
  41. package/dist/chunk-77c89d23.js +2 -0
  42. package/dist/chunk-79vbkez0.js +2 -0
  43. package/dist/{chunk-whsdyf4t.js → chunk-7hpca9c7.js} +6 -6
  44. package/dist/chunk-80xzjxah.js +2 -0
  45. package/dist/chunk-8354mzpd.js +2 -0
  46. package/dist/{chunk-r561zt9v.js → chunk-87g5xmmr.js} +12 -12
  47. package/dist/{chunk-ry6w43p6.js → chunk-8hwfdwgn.js} +6 -6
  48. package/dist/chunk-8ygf6jnt.js +2 -0
  49. package/dist/{chunk-5ymf5c8m.js → chunk-95sd8h5g.js} +7 -7
  50. package/dist/{chunk-gdtj5rfa.js → chunk-967ydrq4.js} +6 -6
  51. package/dist/chunk-9afkttvz.js +2 -0
  52. package/dist/{chunk-55kwxxm5.js → chunk-9d91h636.js} +2 -2
  53. package/dist/{chunk-kvxdyg7e.js → chunk-9n5h4sqc.js} +2 -2
  54. package/dist/chunk-9ztn7w4y.js +2 -0
  55. package/dist/chunk-ah8az9vv.js +2 -0
  56. package/dist/chunk-ankap9pc.js +2 -0
  57. package/dist/chunk-asnd03sr.js +2 -0
  58. package/dist/chunk-b0b5yr97.js +2 -0
  59. package/dist/chunk-b0e7dgv8.js +3 -0
  60. package/dist/{chunk-372xh1g1.js → chunk-b15c4g3e.js} +5 -5
  61. package/dist/{chunk-7hm1tpw0.js → chunk-b6bf0t02.js} +6 -6
  62. package/dist/chunk-b7jj45bz.js +2 -0
  63. package/dist/{chunk-r57jz09p.js → chunk-bgfs3mbg.js} +5 -5
  64. package/dist/{chunk-fepezvdq.js → chunk-bqtj62ys.js} +8 -8
  65. package/dist/{chunk-wbxmn5gk.js → chunk-bw2m1e7g.js} +5 -5
  66. package/dist/chunk-bwx6w87c.js +2 -0
  67. package/dist/{chunk-9qrgdekg.js → chunk-cgfjrgfw.js} +14 -14
  68. package/dist/{chunk-98mj0es1.js → chunk-ch9028z3.js} +1 -1
  69. package/dist/{chunk-sbwvvjkc.js → chunk-cmg9x1ka.js} +3 -3
  70. package/dist/{chunk-9f31gs4m.js → chunk-cz1sdes5.js} +2 -2
  71. package/dist/{chunk-dj9ztcth.js → chunk-dvjv4c3a.js} +1 -1
  72. package/dist/{chunk-edysherg.js → chunk-dymck524.js} +5 -5
  73. package/dist/chunk-dzqfv801.js +3 -0
  74. package/dist/{chunk-b8528fra.js → chunk-eceeqy74.js} +4 -4
  75. package/dist/{chunk-52mhrbps.js → chunk-eqffvse2.js} +1 -1
  76. package/dist/chunk-ery4tty7.js +20 -0
  77. package/dist/chunk-evwrxsxd.js +3 -0
  78. package/dist/{chunk-6t04tqvh.js → chunk-eyx92t9n.js} +2 -2
  79. package/dist/{chunk-c1b0fy70.js → chunk-f3cyghnb.js} +5 -5
  80. package/dist/chunk-f60k8j9m.js +2 -0
  81. package/dist/chunk-fdqdz018.js +2 -0
  82. package/dist/chunk-g6ap4085.js +2 -0
  83. package/dist/chunk-gz9pknbw.js +1204 -0
  84. package/dist/{chunk-e1qcfesw.js → chunk-hgf7bc50.js} +6 -6
  85. package/dist/chunk-hjb4c8g2.js +2 -0
  86. package/dist/chunk-hk241gt2.js +2 -0
  87. package/dist/{chunk-wscry63p.js → chunk-hm9d40yf.js} +2 -2
  88. package/dist/{chunk-vgr7gd8k.js → chunk-hpzje67q.js} +2 -2
  89. package/dist/{chunk-c3ca056p.js → chunk-htx5yezj.js} +2 -2
  90. package/dist/{chunk-b0jekg4c.js → chunk-hxws025y.js} +3 -3
  91. package/dist/chunk-jhbj9ja2.js +2 -0
  92. package/dist/chunk-k4x680e3.js +2 -0
  93. package/dist/chunk-k9abxnpa.js +2 -0
  94. package/dist/{chunk-c73c0wf9.js → chunk-kbbbpae2.js} +2 -2
  95. package/dist/chunk-kfdmm240.js +2 -0
  96. package/dist/{chunk-5ysv0499.js → chunk-kj43fbzm.js} +1 -1
  97. package/dist/{chunk-303vzq80.js → chunk-kk2p2tgv.js} +3 -3
  98. package/dist/{chunk-r8xper92.js → chunk-ksmn19qw.js} +2 -2
  99. package/dist/{chunk-v47xc2fr.js → chunk-kx09v9ya.js} +7 -7
  100. package/dist/{chunk-wm287dz2.js → chunk-m95sygv4.js} +3 -3
  101. package/dist/{chunk-j51wss7s.js → chunk-mctzpw0w.js} +1 -1
  102. package/dist/{chunk-2rmqmajd.js → chunk-me4yq8c2.js} +3 -3
  103. package/dist/{chunk-11fxbd71.js → chunk-mgh5rst1.js} +2 -2
  104. package/dist/{chunk-1kc0jyhj.js → chunk-mhxg6j6s.js} +1 -1
  105. package/dist/{chunk-wf8pdjq5.js → chunk-mjp1z9kz.js} +1 -1
  106. package/dist/{chunk-znnvq1jp.js → chunk-mt8edb75.js} +46 -46
  107. package/dist/chunk-mvavjydq.js +2 -0
  108. package/dist/{chunk-s7wp7a2x.js → chunk-mw7hacm3.js} +30 -30
  109. package/dist/{chunk-e2ws79vt.js → chunk-nbdscgvj.js} +6 -6
  110. package/dist/{chunk-mk6thhwf.js → chunk-njpva3zq.js} +2 -2
  111. package/dist/{chunk-q3bkxg2n.js → chunk-nkyff7v6.js} +11 -11
  112. package/dist/{chunk-zje94z0k.js → chunk-p8shtje2.js} +32 -32
  113. package/dist/{chunk-0hj5apb9.js → chunk-pctf14yw.js} +1 -1
  114. package/dist/{chunk-0d7ypcjb.js → chunk-pjj54ddk.js} +3 -3
  115. package/dist/{chunk-qsnpqa8q.js → chunk-pnmafbv5.js} +1 -1
  116. package/dist/{chunk-vgsasnwm.js → chunk-pz554g43.js} +3 -3
  117. package/dist/{chunk-6zq3eh7d.js → chunk-q0y8gv18.js} +2 -2
  118. package/dist/{chunk-w50yggy3.js → chunk-q9tc9rdv.js} +2 -2
  119. package/dist/chunk-qqng9545.js +2 -0
  120. package/dist/{chunk-xavx271y.js → chunk-r5ecgcx2.js} +5 -5
  121. package/dist/{chunk-v8e2c2r1.js → chunk-ranjkpc8.js} +2 -2
  122. package/dist/{chunk-zf29ahhd.js → chunk-rb2zbdqd.js} +4 -4
  123. package/dist/{chunk-4nnmrp7w.js → chunk-rf0smj4c.js} +2 -2
  124. package/dist/chunk-rjm515e2.js +2 -0
  125. package/dist/chunk-rye4b2x3.js +2 -0
  126. package/dist/chunk-ryj8139z.js +2 -0
  127. package/dist/{chunk-e9tjxnhn.js → chunk-s0mf56y1.js} +5 -5
  128. package/dist/{chunk-fce8wj3t.js → chunk-s93yh7ed.js} +2 -2
  129. package/dist/chunk-s9b809n2.js +2 -0
  130. package/dist/chunk-sb67wg5x.js +2 -0
  131. package/dist/{chunk-6fsnnj5v.js → chunk-sjjw6y49.js} +6 -6
  132. package/dist/chunk-snkbn5y8.js +2 -0
  133. package/dist/{chunk-7mcs59pr.js → chunk-snv80b1b.js} +2 -2
  134. package/dist/chunk-sqwx2g02.js +2 -0
  135. package/dist/{chunk-4c9p434g.js → chunk-t0ttxayz.js} +2 -2
  136. package/dist/chunk-tbh7r1wh.js +2 -0
  137. package/dist/chunk-tpyekw0q.js +2 -0
  138. package/dist/chunk-v2627s75.js +2 -0
  139. package/dist/chunk-v3jyb8k6.js +2 -0
  140. package/dist/chunk-v98n53nk.js +2 -0
  141. package/dist/{chunk-pm4kn9h2.js → chunk-vc432a0w.js} +9 -9
  142. package/dist/{chunk-7nhgpjjw.js → chunk-vf4ejngv.js} +6 -6
  143. package/dist/{chunk-hxhmhw23.js → chunk-vk2jy6mn.js} +3 -3
  144. package/dist/chunk-w34vvhm7.js +2 -0
  145. package/dist/chunk-w82nk19t.js +2 -0
  146. package/dist/{chunk-mbm3ma63.js → chunk-x5bn2svk.js} +2 -2
  147. package/dist/chunk-x6565mhk.js +2 -0
  148. package/dist/{chunk-3fbgpv1d.js → chunk-xvncq3m5.js} +2 -2
  149. package/dist/chunk-xwgdcc7w.js +2 -0
  150. package/dist/{chunk-1wkp3pks.js → chunk-xy8smv5e.js} +2 -2
  151. package/dist/{chunk-y8p59h6c.js → chunk-y1d3j2j7.js} +4 -4
  152. package/dist/chunk-yjwa7ktk.js +2 -0
  153. package/dist/{chunk-xy4j8t7w.js → chunk-ytjn0gq2.js} +2 -2
  154. package/dist/chunk-z47p2gx8.js +2 -0
  155. package/dist/chunk-z4tdnfxd.js +2 -0
  156. package/dist/chunk-z6kw6sct.js +4 -0
  157. package/dist/{chunk-w1q86c89.js → chunk-zf68afyh.js} +3 -3
  158. package/dist/chunk-zhywjwdr.js +2 -0
  159. package/dist/{chunk-em6fqvjy.js → chunk-zwwhpxp7.js} +2 -2
  160. package/dist/cli.js +21 -21
  161. package/dist/component-library.d.ts +2 -1
  162. package/dist/component-library.js +17 -296
  163. package/dist/craft-entry.js +2 -2
  164. package/dist/craft.js +2 -2
  165. package/dist/directive-arguments.js +39 -6
  166. package/dist/parser/tokenizer.d.ts +2 -1
  167. package/dist/parser/tokenizer.js +7 -5
  168. package/dist/props-declaration.d.ts +64 -0
  169. package/dist/props-declaration.js +354 -0
  170. package/dist/pwa.js +3 -3
  171. package/dist/ssg.js +5 -5
  172. package/dist/utils.js +20 -109
  173. package/package.json +5 -5
  174. package/dist/chunk-000mwmfq.js +0 -1203
  175. package/dist/chunk-043d0en0.js +0 -2
  176. package/dist/chunk-0w66z6eq.js +0 -2
  177. package/dist/chunk-13wd9gf0.js +0 -3
  178. package/dist/chunk-1znqedae.js +0 -2
  179. package/dist/chunk-2drzzjcm.js +0 -2
  180. package/dist/chunk-3c7nt5qp.js +0 -2
  181. package/dist/chunk-3zyzhcd9.js +0 -2
  182. package/dist/chunk-44rb9fk0.js +0 -2
  183. package/dist/chunk-472j3bhp.js +0 -2
  184. package/dist/chunk-4acce1m8.js +0 -2
  185. package/dist/chunk-4kasmp98.js +0 -2
  186. package/dist/chunk-53kkjn23.js +0 -2
  187. package/dist/chunk-5gwvy612.js +0 -2
  188. package/dist/chunk-61vbqrde.js +0 -2
  189. package/dist/chunk-6fpzwryt.js +0 -2
  190. package/dist/chunk-7195598h.js +0 -2
  191. package/dist/chunk-7zvf79vb.js +0 -2
  192. package/dist/chunk-88a735jw.js +0 -2
  193. package/dist/chunk-8v7yjq3b.js +0 -2
  194. package/dist/chunk-97kgrevs.js +0 -4
  195. package/dist/chunk-a8c9j9cj.js +0 -2
  196. package/dist/chunk-acw851e8.js +0 -2
  197. package/dist/chunk-andfvr3g.js +0 -2
  198. package/dist/chunk-aqxh80vh.js +0 -2
  199. package/dist/chunk-ay5zkfdg.js +0 -2
  200. package/dist/chunk-b4gptdtc.js +0 -2
  201. package/dist/chunk-baaw9w7y.js +0 -2
  202. package/dist/chunk-bw2p9h2g.js +0 -2
  203. package/dist/chunk-ce0vv7kz.js +0 -2
  204. package/dist/chunk-d1yj29g2.js +0 -2
  205. package/dist/chunk-dbhmbef1.js +0 -20
  206. package/dist/chunk-dfsykk1r.js +0 -2
  207. package/dist/chunk-e9p596bp.js +0 -2
  208. package/dist/chunk-ftecsa8e.js +0 -2
  209. package/dist/chunk-ge2h5v46.js +0 -2
  210. package/dist/chunk-gqvnz8a7.js +0 -2
  211. package/dist/chunk-j41gp8p3.js +0 -2
  212. package/dist/chunk-jxvccj30.js +0 -2
  213. package/dist/chunk-k5bbre7d.js +0 -2
  214. package/dist/chunk-kd47vgs8.js +0 -2
  215. package/dist/chunk-keqjafdz.js +0 -2
  216. package/dist/chunk-kz3mejc4.js +0 -2
  217. package/dist/chunk-ngkh0t5b.js +0 -2
  218. package/dist/chunk-nx9895m6.js +0 -2
  219. package/dist/chunk-nxgtt1t1.js +0 -2
  220. package/dist/chunk-nyw2ztar.js +0 -2
  221. package/dist/chunk-p5q27adr.js +0 -2
  222. package/dist/chunk-p6hcrg3r.js +0 -3
  223. package/dist/chunk-pa2vt2ej.js +0 -2
  224. package/dist/chunk-pczb7xav.js +0 -2
  225. package/dist/chunk-ps37r6hj.js +0 -2
  226. package/dist/chunk-pvbhk17r.js +0 -2
  227. package/dist/chunk-q252qvsy.js +0 -2
  228. package/dist/chunk-q5b0vpmm.js +0 -2
  229. package/dist/chunk-qg1kw5yf.js +0 -2
  230. package/dist/chunk-sbr85vda.js +0 -2
  231. package/dist/chunk-tkab24xr.js +0 -2
  232. package/dist/chunk-vn59yrjh.js +0 -2
  233. package/dist/chunk-w5zzwe2f.js +0 -2
  234. package/dist/chunk-wa9q1gyv.js +0 -2
  235. package/dist/chunk-wpgxhrd7.js +0 -2
  236. package/dist/chunk-x3azrbpr.js +0 -2
  237. package/dist/chunk-x50hk1hq.js +0 -2
  238. package/dist/chunk-xbkbvfcg.js +0 -2
  239. package/dist/chunk-z55rpt3s.js +0 -3
  240. package/dist/chunk-zwde52kw.js +0 -2
  241. package/dist/chunk-zxff7kq9.js +0 -2
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- import{zl,Hl}from"./chunk-11fxbd71.js";import{J,Ar,Ks,Gs,_i,Ei,Xs,Ie,We,xe,re,Or,Nr,me,se,B,gt,Mr,Ai,jr,Je,s,g,Y,In}from"./chunk-000mwmfq.js";import{m,N,ht,p}from"./chunk-xw291tn7.js";import{r}from"./chunk-13wd9gf0.js";import{fe}from"./chunk-ah6nc29h.js";import{br}from"./chunk-7mcs59pr.js";import{b}from"./chunk-94mpe1ny.js";import{t}from"./chunk-3ed2erm6.js";import{createHash as At}from"crypto";import K from"fs";import V from"path";import Le from"fs";function Ae(e,i,n){let o=Buffer.alloc(n),a=Le.readSync(e,o,0,n,i);return o.subarray(0,a)}function ze(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 n=i(12,16);if(n==="VP8X")return(e[20]&16)!==0;if(n==="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=Le.openSync(e,"r");let n=Ae(i,0,33);if(n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255)return"none";if(n.length>=26&&n[0]===137&&n.toString("latin1",1,4)==="PNG"){let o=n[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ae(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(n.length>=25&&n.toString("latin1",0,4)==="RIFF"&&n.toString("latin1",8,12)==="WEBP"){if(ze(n))return"possible";let o=n.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)Le.closeSync(i)}}import rn from"fs";import Fe from"os";import{fileURLToPath as bt}from"url";var Ee=Symbol("stx.image-worker.unavailable");function sn(e=typeof Fe.availableParallelism==="function"?Fe.availableParallelism():Fe.cpus().length){return Math.max(1,Math.min(2,e-1))}var _e=0,vt=[];async function on(){if(_e<sn()){_e++;return}await new Promise((e)=>vt.push(e)),_e++}function an(){_e--,vt.shift()?.()}var cn="@stacksjs/stx/builtins/image-warmup-worker";function ln(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let n=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(n.protocol==="file:"&&rn.existsSync(bt(n)))return bt(n)}catch{}return br(cn,e)}var xt=!1;function ue(e){if(!xt)xt=!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 Ee}function Pe(e){return e instanceof Error?e.message:String(e)}async function He(e,i){let n;try{n=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Pe(a)}`)}if(typeof n!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=ln();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await on();try{return await new Promise((a,c)=>{let l;try{l=new n(o)}catch(h){a(ue(`could not start ${o}: ${Pe(h)}`));return}let u=!1,f=!1,w=(h)=>{if(f)return;f=!0,h(),l.terminate()};l.on("message",(h)=>{if(h.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(h.type==="result"){w(()=>a(h.value));return}let y=Error(h.error?.message??"image worker failed");if(h.error?.name)y.name=h.error.name;if(h.error?.stack)y.stack=h.error.stack;w(()=>c(y))}),l.on("error",(h)=>{w(()=>u?c(h instanceof Error?h:Error(Pe(h)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Pe(h)}`)))}),l.on("exit",(h)=>{w(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${h} before it was ready`)))})})}finally{an()}}var un=new Set([".avif",".jpeg",".jpg",".png",".webp"]),fn=[320,640,960,1280,1920],ve="/_stx/images",dn=`stx:${ve}:alpha-1`,gn=`stx:${ve}:opaque-1`,pn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ne;function mn(e,i){let n=V.dirname(Bun.resolveSync(e,i));while(n!==V.dirname(n)){let o=V.join(n,"package.json");if(K.existsSync(o)){let a=JSON.parse(K.readFileSync(o,"utf8"));if(a.name===e)return a.version}n=V.dirname(n)}return}function wt(){if(Ne!==void 0)return Ne;let e;try{e=V.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ne=pn.map((i)=>{let n;try{n=e?mn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${n??"unknown"}`}).join("+"),Ne}var $t=Symbol.for("stx.image-delivery");function we(){let e=globalThis;return e[$t]??={catalog:new Map,transparent:new Set},e[$t]}var St=new Set;function hn(e){return`/${e.split(V.sep).map(encodeURIComponent).join("/")}`}function yn(e){let i=V.extname(e),n=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=At("sha256").update(e).digest("hex").slice(0,8);return`${n||"image"}-${o}`}function Ct(e,i=`stx:${ve}`){let n=(o)=>`${ve}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=V.join(e,o);try{let c=await K.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:n(o)}:null}catch{return null}},async write(o,a){let c=V.join(e,o);await K.promises.mkdir(V.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await K.promises.writeFile(l,a),await K.promises.rename(l,c),{bytes:a.byteLength,path:c,url:n(o)}},url:n}}async function It(e,i=e){let n=await K.promises.readdir(i,{withFileTypes:!0});n.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of n){let c=V.join(i,a.name);if(a.isDirectory()){o.push(...await It(e,c));continue}if(!a.isFile()||!un.has(V.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:V.relative(e,c)})}return o}function Rt(e,i){return e.map((n)=>({key:hn(n.relativePath),input:n.absolutePath,name:yn(n.relativePath),...bn(n.absolutePath)?{options:{storage:i}}:{}}))}function bn(e){return Ue(e)==="possible"}function xn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function vn(e){let i=Object.entries(e).filter(([,c])=>c.fallback.format==="png"),n=new Set,o=8;if(i.length===0)return n;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 f=u.variants.filter((w)=>w.format==="png").sort((w,h)=>w.width-h.width)[0];try{let w=await a(new Uint8Array(await K.promises.readFile(f?.path??u.fallback.path)));if(xn(w.data))n.add(l)}catch{n.add(l)}}));return n}function wn(e,i){let n=[];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 f;try{return f=K.openSync(u.path,"r"),!ze(Ae(f,0,32))}catch{return!0}finally{if(f!==void 0)K.closeSync(f)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,n.push(o),!St.has(o))St.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 n}async function $n(e){let i=[],n=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 qe(e){return V.join(e,"undecodable.json")}function Sn(e){try{let i=K.readFileSync(qe(e),"utf-8"),n=JSON.parse(i);return n&&typeof n==="object"?n:{}}catch{return{}}}function Cn(e,i){try{K.mkdirSync(V.dirname(qe(e)),{recursive:!0}),K.writeFileSync(qe(e),JSON.stringify(i))}catch{}}function kt(e){try{let i=K.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function Pt(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 ti(e){let i=Pt(e);return i?we().catalog.get(i):void 0}function ni(e){let i=Pt(e);return i?we().transparent.has(i):!1}function ri(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),n=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<n).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function ay(e){let i=ti(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:ri(i).map(({format:n,srcset:o})=>({type:`image/${n}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:ni(e)?void 0:i.placeholder?.dataUrl}}function _s(){let e=we();e.catalog=new Map,e.transparent=new Set}function Rn(e){let i=we();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function cy(e,i,n={}){if(!e||!K.existsSync(e))return _s(),{count:0,fingerprint:""};if(n.offThread){let d=await He("delivery",{publicDir:e,outputDir:i});if(d!==Ee)return Rn(d.state),d.result}let o=await It(e);if(o.length===0)return _s(),{count:0,fingerprint:""};let a=Sn(i),c=o.filter((d)=>{let v=a[d.relativePath];if(!v)return!0;let k=kt(d.absolutePath);return!k||k.mtimeMs!==v.mtimeMs||k.size!==v.size});if(c.length===0)return _s(),{count:0,fingerprint:""};let l=Ct(V.join(i,"_stx","images"),`${dn}:${wt()}`),u={outDir:V.join(i,"_stx","images"),storage:Ct(V.join(i,"_stx","images"),`${gn}:${wt()}`),baseUrl:ve,widths:fn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:f}=await import("ts-images/delivery"),w=c,h;try{h=await f({...u,entries:Rt(c,l)})}catch(d){if(w=await $n(c),w.length===c.length)throw d;let v=new Set(w.map((A)=>A.relativePath)),k=!1;for(let A of c){if(v.has(A.relativePath))continue;let R=kt(A.absolutePath);if(!R)continue;a[A.relativePath]=R,k=!0}if(k)Cn(i,a);if(w.length===0)return _s(),{count:0,fingerprint:""};h=await f({...u,entries:Rt(w,l)})}let y=await vn(h.entries),C=wn(h.entries,y),S=we();S.catalog=new Map(Object.entries(h.entries)),S.transparent=y;let x=y.size===0&&C.length===0?h.fingerprint:At("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...y].sort(),droppedWebp:C.sort()})).digest("hex");return{count:w.length,fingerprint:x}}class _t{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,n,o){let a=_i(e,o);if(a!==void 0)return a;for(let c of Ei(e,i,n,o))if(await s(c))return c;return null}}var de=new _t;var ne="\x00stx-boolean-attribute";function Xe(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var kn=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 Ze(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||kn.has(i)}function ie(e,i){let n=[];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)n.push(g(c));continue}if(a===ne){n.push(g(c));continue}n.push(`${g(c)}="${In(c,Xe(String(a)))}"`)}return n}function oe(e,i){let n=[];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){n.push(g(c));continue}if(typeof a==="object")continue;n.push(`${g(c)}="${In(c,Xe(String(a)))}"`)}return n}function An(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 Ve={name:"StxLink",aliases:["stx-link"],render(e,i,n){let o=An(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,f=[];if(o.reactive)f.push(`:href="${r(o.value)}"`);else f.push(`href="${r(Or(o.value,"navigable"))}"`);if(a)f.push(`class="${r(a)}"`);if(f.push("data-stx-link"),f.push(`data-stx-active-class="${r(c)}"`),f.push(`data-stx-exact-active-class="${r(l)}"`),u)f.push("data-stx-prefetch");let w=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(w)f.push(`data-stx-active-match="${r(w)}"`);let h=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return f.push(...ie(e,h)),f.push(...oe(e,h)),`<a ${f.join(" ")}>${i}</a>`}};var Pn=new Map;function Ge(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return Pn.get(i)}var _n={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ke=[320,640,768,1024,1280,1536,1920];function H(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}function Oe(e,i,n=!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 n}function Ye(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),n=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=_n[a];if(l)n.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))n.push(`(max-width: ${u}px) ${c}`)}}else n.push(o);return n.join(", ")}function Qe(e,i,n,o){return i.map((a)=>`${$e(e,a,void 0,n,o)} ${a}w`).join(", ")}function En(e,i,n,o,a){return i.map((c)=>{let l=n?n*c:void 0;return`${$e(e,l,void 0,o,a)} ${c}x`}).join(", ")}function $e(e,i,n,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(n)c.push(`h_${n}`);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(n)c.set("h",String(n));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(n)c.set("height",String(n));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function Nn(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function On(e,i,n="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${n}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var et={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,n){let o=H(e,"src")||"",a=ti(o),c=H(e,"alt")||"",l=H(e,"width")||(a?String(a.source.width):void 0),u=H(e,"height")||(a?String(a.source.height):void 0),f=H(e,"sizes"),w=H(e,"srcset"),h=H(e,"densities"),y=H(e,"format"),C=ni(o)||Ge(o)?.transparent===!0,S=H(e,"placeholder")||(a&&!C?"thumbhash":void 0),x=H(e,"placeholderColor")||"#e5e7eb",d=H(e,"provider"),v=H(e,"class")||H(e,"className")||"",k=H(e,"style")||"",A=H(e,"objectFit")||H(e,"fit"),R=H(e,"objectPosition")||H(e,"position"),E=H(e,"quality"),G=Oe(e,"lazy",!0),U=Oe(e,"preload",!1),D=Oe(e,"priority",!1),z=H(e,"loading"),O=H(e,"decoding")||"async",q=!!a||Oe(e,"picture",!1)||!!y,I=l?Number.parseInt(l):void 0,_=u?Number.parseInt(u):void 0,j=w||"",F="";if(a)j=a.sources[a.fallback.format]||"",F=f?Ye(f):"100vw";else if(!j&&f&&d&&d!=="local"&&d!=="static")j=Qe(o,Ke,d,y),F=Ye(f);else if(!j&&h){let Z=h.split(/\s+/).map((P)=>Number.parseFloat(P.replace("x","")));j=En(o,Z,I,d,y)}else if(f)F=Ye(f);let M=[];if(k)M.push(k);if(A)M.push(`object-fit:${A}`);if(R)M.push(`object-position:${R}`);if(I&&_)M.push(`aspect-ratio:${I}/${_}`);let te=[],ae=S==="blur"||S==="color"||S==="thumbhash";if(ae&&!C){let Z=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:x}:Ge(o);if(Z&&S==="color")M.push(`background-color:${Z.color}`),te.push("backgroundColor");else if(Z)M.push(`background-color:${Z.color}`),M.push(`background-image:url(${Z.dataUrl})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat"),te.push("backgroundColor","backgroundImage");else{let P=On(I||16,_||9,x);M.push(`background-image:url(${P})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat"),te.push("backgroundImage")}}else if(!ae&&S&&S!=="empty"&&S!=="none")M.push(`background-image:url(${r(S)})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat"),te.push("backgroundImage");let L=a?.fallback.url||$e(o,I,_,d,y),X=[];if(X.push(`src="${r(Or(L,"fetched"))}"`),X.push(`alt="${r(c)}"`),l)X.push(`width="${r(l)}"`);if(u)X.push(`height="${r(u)}"`);let Re=z||(D||U?"eager":G?"lazy":"");if(Re)X.push(`loading="${r(Re)}"`);if(D)X.push('fetchpriority="high"');if(X.push(`decoding="${r(O)}"`),v)X.push(`class="${r(v)}"`);if(M.length>0)X.push(`style="${r(M.join(";"))}"`);if(j)X.push(`srcset="${r(Or(j,"fetched"))}"`);if(F)X.push(`sizes="${r(F)}"`);let be=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(te.length>0){let Z=typeof e.static.onload==="string"?e.static.onload:"",P=Nn(te)+(Z?`;${Z}`:"");X.push(`onload="${r(P)}"`),be.add("onload")}X.push(...ie(e,be)),X.push(...oe(e,be));let le=`<img ${X.join(" ")} />`,Q="";if(U){let P=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Q=`<link rel="preload" as="image" href="${r(L)}"${P?` type="${P}"`:""}${j?` imagesrcset="${r(j)}"`:""}${F?` imagesizes="${r(F)}"`:""} />
3
- `}if(q){let Z=[];if(a)for(let P of ri(a))Z.push(`<source type="image/${P.format}" srcset="${r(P.srcset)}"${F?` sizes="${r(F)}"`:""} />`);if(!a&&(y==="avif"||y==="auto")){let P=$e(o,I,_,d,"avif"),T=j?Qe(o,Ke,d,"avif"):`${P}`;Z.push(`<source type="image/avif" srcset="${r(T)}"${F?` sizes="${r(F)}"`:""} />`)}if(!a&&(y==="webp"||y==="auto")){let P=$e(o,I,_,d,"webp"),T=j?Qe(o,Ke,d,"webp"):`${P}`;Z.push(`<source type="image/webp" srcset="${r(T)}"${F?` sizes="${r(F)}"`:""} />`)}return`${Q}<picture>
2
+ import{Hl,Vl}from"./chunk-mgh5rst1.js";import{J,Pr,Js,Ys,Ti,Ri,Zs,Ie,We,Se,re,Nr,Mr,he,oe,F,gt,Dr,Oi,Br,Je,s,g,Y,Pn}from"./chunk-gz9pknbw.js";import{m,M,ht,p}from"./chunk-3dqfjpz4.js";import{r}from"./chunk-b0e7dgv8.js";import{ge}from"./chunk-5kqezrjt.js";import{wr}from"./chunk-snv80b1b.js";import{b}from"./chunk-94mpe1ny.js";import{t}from"./chunk-3hsv6ejp.js";import{createHash as At}from"crypto";import K from"fs";import V from"path";import Le from"fs";function Ae(e,i,n){let o=Buffer.alloc(n),a=Le.readSync(e,o,0,n,i);return o.subarray(0,a)}function ze(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 n=i(12,16);if(n==="VP8X")return(e[20]&16)!==0;if(n==="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=Le.openSync(e,"r");let n=Ae(i,0,33);if(n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255)return"none";if(n.length>=26&&n[0]===137&&n.toString("latin1",1,4)==="PNG"){let o=n[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ae(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(n.length>=25&&n.toString("latin1",0,4)==="RIFF"&&n.toString("latin1",8,12)==="WEBP"){if(ze(n))return"possible";let o=n.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)Le.closeSync(i)}}import rn from"fs";import Fe from"os";import{fileURLToPath as bt}from"url";var Ee=Symbol("stx.image-worker.unavailable");function sn(e=typeof Fe.availableParallelism==="function"?Fe.availableParallelism():Fe.cpus().length){return Math.max(1,Math.min(2,e-1))}var _e=0,vt=[];async function on(){if(_e<sn()){_e++;return}await new Promise((e)=>vt.push(e)),_e++}function an(){_e--,vt.shift()?.()}var cn="@stacksjs/stx/builtins/image-warmup-worker";function ln(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let n=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(n.protocol==="file:"&&rn.existsSync(bt(n)))return bt(n)}catch{}return wr(cn,e)}var xt=!1;function ue(e){if(!xt)xt=!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 Ee}function Pe(e){return e instanceof Error?e.message:String(e)}async function He(e,i){let n;try{n=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Pe(a)}`)}if(typeof n!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=ln();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await on();try{return await new Promise((a,c)=>{let l;try{l=new n(o)}catch(h){a(ue(`could not start ${o}: ${Pe(h)}`));return}let u=!1,f=!1,w=(h)=>{if(f)return;f=!0,h(),l.terminate()};l.on("message",(h)=>{if(h.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(h.type==="result"){w(()=>a(h.value));return}let y=Error(h.error?.message??"image worker failed");if(h.error?.name)y.name=h.error.name;if(h.error?.stack)y.stack=h.error.stack;w(()=>c(y))}),l.on("error",(h)=>{w(()=>u?c(h instanceof Error?h:Error(Pe(h)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Pe(h)}`)))}),l.on("exit",(h)=>{w(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${h} before it was ready`)))})})}finally{an()}}var un=new Set([".avif",".jpeg",".jpg",".png",".webp"]),fn=[320,640,960,1280,1920],xe="/_stx/images",dn=`stx:${xe}:alpha-1`,gn=`stx:${xe}:opaque-1`,pn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ne;function mn(e,i){let n=V.dirname(Bun.resolveSync(e,i));while(n!==V.dirname(n)){let o=V.join(n,"package.json");if(K.existsSync(o)){let a=JSON.parse(K.readFileSync(o,"utf8"));if(a.name===e)return a.version}n=V.dirname(n)}return}function wt(){if(Ne!==void 0)return Ne;let e;try{e=V.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ne=pn.map((i)=>{let n;try{n=e?mn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${n??"unknown"}`}).join("+"),Ne}var $t=Symbol.for("stx.image-delivery");function ve(){let e=globalThis;return e[$t]??={catalog:new Map,transparent:new Set},e[$t]}var St=new Set;function hn(e){return`/${e.split(V.sep).map(encodeURIComponent).join("/")}`}function yn(e){let i=V.extname(e),n=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=At("sha256").update(e).digest("hex").slice(0,8);return`${n||"image"}-${o}`}function Ct(e,i=`stx:${xe}`){let n=(o)=>`${xe}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=V.join(e,o);try{let c=await K.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:n(o)}:null}catch{return null}},async write(o,a){let c=V.join(e,o);await K.promises.mkdir(V.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await K.promises.writeFile(l,a),await K.promises.rename(l,c),{bytes:a.byteLength,path:c,url:n(o)}},url:n}}async function It(e,i=e){let n=await K.promises.readdir(i,{withFileTypes:!0});n.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of n){let c=V.join(i,a.name);if(a.isDirectory()){o.push(...await It(e,c));continue}if(!a.isFile()||!un.has(V.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:V.relative(e,c)})}return o}function Rt(e,i){return e.map((n)=>({key:hn(n.relativePath),input:n.absolutePath,name:yn(n.relativePath),...bn(n.absolutePath)?{options:{storage:i}}:{}}))}function bn(e){return Ue(e)==="possible"}function xn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function vn(e){let i=Object.entries(e).filter(([,c])=>c.fallback.format==="png"),n=new Set,o=8;if(i.length===0)return n;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 f=u.variants.filter((w)=>w.format==="png").sort((w,h)=>w.width-h.width)[0];try{let w=await a(new Uint8Array(await K.promises.readFile(f?.path??u.fallback.path)));if(xn(w.data))n.add(l)}catch{n.add(l)}}));return n}function wn(e,i){let n=[];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 f;try{return f=K.openSync(u.path,"r"),!ze(Ae(f,0,32))}catch{return!0}finally{if(f!==void 0)K.closeSync(f)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,n.push(o),!St.has(o))St.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 n}async function $n(e){let i=[],n=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 qe(e){return V.join(e,"undecodable.json")}function Sn(e){try{let i=K.readFileSync(qe(e),"utf-8"),n=JSON.parse(i);return n&&typeof n==="object"?n:{}}catch{return{}}}function Cn(e,i){try{K.mkdirSync(V.dirname(qe(e)),{recursive:!0}),K.writeFileSync(qe(e),JSON.stringify(i))}catch{}}function kt(e){try{let i=K.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function Pt(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 si(e){let i=Pt(e);return i?ve().catalog.get(i):void 0}function oi(e){let i=Pt(e);return i?ve().transparent.has(i):!1}function ii(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),n=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<n).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function cy(e){let i=si(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:ii(i).map(({format:n,srcset:o})=>({type:`image/${n}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:oi(e)?void 0:i.placeholder?.dataUrl}}function Ts(){let e=ve();e.catalog=new Map,e.transparent=new Set}function Rn(e){let i=ve();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function ly(e,i,n={}){if(!e||!K.existsSync(e))return Ts(),{count:0,fingerprint:""};if(n.offThread){let d=await He("delivery",{publicDir:e,outputDir:i});if(d!==Ee)return Rn(d.state),d.result}let o=await It(e);if(o.length===0)return Ts(),{count:0,fingerprint:""};let a=Sn(i),c=o.filter((d)=>{let v=a[d.relativePath];if(!v)return!0;let k=kt(d.absolutePath);return!k||k.mtimeMs!==v.mtimeMs||k.size!==v.size});if(c.length===0)return Ts(),{count:0,fingerprint:""};let l=Ct(V.join(i,"_stx","images"),`${dn}:${wt()}`),u={outDir:V.join(i,"_stx","images"),storage:Ct(V.join(i,"_stx","images"),`${gn}:${wt()}`),baseUrl:xe,widths:fn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:f}=await import("ts-images/delivery"),w=c,h;try{h=await f({...u,entries:Rt(c,l)})}catch(d){if(w=await $n(c),w.length===c.length)throw d;let v=new Set(w.map((A)=>A.relativePath)),k=!1;for(let A of c){if(v.has(A.relativePath))continue;let R=kt(A.absolutePath);if(!R)continue;a[A.relativePath]=R,k=!0}if(k)Cn(i,a);if(w.length===0)return Ts(),{count:0,fingerprint:""};h=await f({...u,entries:Rt(w,l)})}let y=await vn(h.entries),C=wn(h.entries,y),S=ve();S.catalog=new Map(Object.entries(h.entries)),S.transparent=y;let x=y.size===0&&C.length===0?h.fingerprint:At("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...y].sort(),droppedWebp:C.sort()})).digest("hex");return{count:w.length,fingerprint:x}}class _t{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,n,o){let a=Ti(e,o);if(a!==void 0)return a;for(let c of Ri(e,i,n,o))if(await s(c))return c;return null}}var fe=new _t;var ne="\x00stx-boolean-attribute";function Xe(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var kn=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 Ze(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||kn.has(i)}function se(e,i){let n=[];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)n.push(g(c));continue}if(a===ne){n.push(g(c));continue}n.push(`${g(c)}="${Pn(c,Xe(String(a)))}"`)}return n}function ie(e,i){let n=[];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){n.push(g(c));continue}if(typeof a==="object")continue;n.push(`${g(c)}="${Pn(c,Xe(String(a)))}"`)}return n}function An(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 Ve={name:"StxLink",aliases:["stx-link"],render(e,i,n){let o=An(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,f=[];if(o.reactive)f.push(`:href="${r(o.value)}"`);else f.push(`href="${r(Nr(o.value,"navigable"))}"`);if(a)f.push(`class="${r(a)}"`);if(f.push("data-stx-link"),f.push(`data-stx-active-class="${r(c)}"`),f.push(`data-stx-exact-active-class="${r(l)}"`),u)f.push("data-stx-prefetch");let w=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(w)f.push(`data-stx-active-match="${r(w)}"`);let h=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return f.push(...se(e,h)),f.push(...ie(e,h)),`<a ${f.join(" ")}>${i}</a>`}};var In=new Map;function Ge(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return In.get(i)}var _n={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ke=[320,640,768,1024,1280,1536,1920];function H(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}function Oe(e,i,n=!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 n}function Ye(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),n=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=_n[a];if(l)n.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))n.push(`(max-width: ${u}px) ${c}`)}}else n.push(o);return n.join(", ")}function Qe(e,i,n,o){return i.map((a)=>`${we(e,a,void 0,n,o)} ${a}w`).join(", ")}function En(e,i,n,o,a){return i.map((c)=>{let l=n?n*c:void 0;return`${we(e,l,void 0,o,a)} ${c}x`}).join(", ")}function we(e,i,n,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(n)c.push(`h_${n}`);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(n)c.set("h",String(n));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(n)c.set("height",String(n));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function Nn(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function On(e,i,n="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${n}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var et={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,n){let o=H(e,"src")||"",a=si(o),c=H(e,"alt")||"",l=H(e,"width")||(a?String(a.source.width):void 0),u=H(e,"height")||(a?String(a.source.height):void 0),f=H(e,"sizes"),w=H(e,"srcset"),h=H(e,"densities"),y=H(e,"format"),C=oi(o)||Ge(o)?.transparent===!0,S=H(e,"placeholder")||(a&&!C?"thumbhash":void 0),x=H(e,"placeholderColor")||"#e5e7eb",d=H(e,"provider"),v=H(e,"class")||H(e,"className")||"",k=H(e,"style")||"",A=H(e,"objectFit")||H(e,"fit"),R=H(e,"objectPosition")||H(e,"position"),E=H(e,"quality"),G=Oe(e,"lazy",!0),z=Oe(e,"preload",!1),B=Oe(e,"priority",!1),L=H(e,"loading"),N=H(e,"decoding")||"async",q=!!a||Oe(e,"picture",!1)||!!y,I=l?Number.parseInt(l):void 0,_=u?Number.parseInt(u):void 0,T=w||"",U="";if(a)T=a.sources[a.fallback.format]||"",U=f?Ye(f):"100vw";else if(!T&&f&&d&&d!=="local"&&d!=="static")T=Qe(o,Ke,d,y),U=Ye(f);else if(!T&&h){let Z=h.split(/\s+/).map((P)=>Number.parseFloat(P.replace("x","")));T=En(o,Z,I,d,y)}else if(f)U=Ye(f);let D=[];if(k)D.push(k);if(A)D.push(`object-fit:${A}`);if(R)D.push(`object-position:${R}`);if(I&&_)D.push(`aspect-ratio:${I}/${_}`);let te=[],ae=S==="blur"||S==="color"||S==="thumbhash";if(ae&&!C){let Z=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:x}:Ge(o);if(Z&&S==="color")D.push(`background-color:${Z.color}`),te.push("backgroundColor");else if(Z)D.push(`background-color:${Z.color}`),D.push(`background-image:url(${Z.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),te.push("backgroundColor","backgroundImage");else{let P=On(I||16,_||9,x);D.push(`background-image:url(${P})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),te.push("backgroundImage")}}else if(!ae&&S&&S!=="empty"&&S!=="none")D.push(`background-image:url(${r(S)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),te.push("backgroundImage");let j=a?.fallback.url||we(o,I,_,d,y),X=[];if(X.push(`src="${r(Nr(j,"fetched"))}"`),X.push(`alt="${r(c)}"`),l)X.push(`width="${r(l)}"`);if(u)X.push(`height="${r(u)}"`);let Re=L||(B||z?"eager":G?"lazy":"");if(Re)X.push(`loading="${r(Re)}"`);if(B)X.push('fetchpriority="high"');if(X.push(`decoding="${r(N)}"`),v)X.push(`class="${r(v)}"`);if(D.length>0)X.push(`style="${r(D.join(";"))}"`);if(T)X.push(`srcset="${r(Nr(T,"fetched"))}"`);if(U)X.push(`sizes="${r(U)}"`);let be=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(te.length>0){let Z=typeof e.static.onload==="string"?e.static.onload:"",P=Nn(te)+(Z?`;${Z}`:"");X.push(`onload="${r(P)}"`),be.add("onload")}X.push(...se(e,be)),X.push(...ie(e,be));let le=`<img ${X.join(" ")} />`,Q="";if(z){let P=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Q=`<link rel="preload" as="image" href="${r(j)}"${P?` type="${P}"`:""}${T?` imagesrcset="${r(T)}"`:""}${U?` imagesizes="${r(U)}"`:""} />
3
+ `}if(q){let Z=[];if(a)for(let P of ii(a))Z.push(`<source type="image/${P.format}" srcset="${r(P.srcset)}"${U?` sizes="${r(U)}"`:""} />`);if(!a&&(y==="avif"||y==="auto")){let P=we(o,I,_,d,"avif"),O=T?Qe(o,Ke,d,"avif"):`${P}`;Z.push(`<source type="image/avif" srcset="${r(O)}"${U?` sizes="${r(U)}"`:""} />`)}if(!a&&(y==="webp"||y==="auto")){let P=we(o,I,_,d,"webp"),O=T?Qe(o,Ke,d,"webp"):`${P}`;Z.push(`<source type="image/webp" srcset="${r(O)}"${U?` sizes="${r(U)}"`:""} />`)}return`${Q}<picture>
4
4
  ${Z.join(`
5
5
  `)}
6
6
  ${le}
7
- </picture>`}return`${Q}${le}`}};var Et="/images/safe-image-default.svg";function ge(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}var Bn=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${Et}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,tt={name:"SafeImage",aliases:["safe-image","safe-img"],render(e,i,n){let o=ge(e,"src")||"",a=ge(e,"alt")||"",c=ge(e,"fallback")||Et,l=ge(e,"class")||ge(e,"className")||"",u=ge(e,"fallbackClassName")||"",f=[];if(f.push(`src="${r(o)}"`),f.push(`alt="${r(a)}"`),l)f.push(`class="${r(l)}"`);if(f.push(`data-fallback="${r(c)}"`),u)f.push(`data-fallback-class="${r(u)}"`);f.push('onerror="window.__stxSafeImageHandler(this)"');let w=new Set(["src","alt","fallback","class","className","fallbackClassName"]);f.push(...ie(e,w)),f.push(...oe(e,w));let h=`<img ${f.join(" ")} />`,y=n.context;if(!y.__safeImageHandlerEmitted)return y.__safeImageHandlerEmitted=!0,`${Bn}${h}`;return h}};function nt(e){return e.replace(/[;{}()]/g,"").replace(/url/gi,"")}function Se(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}function Be(e,i,n){let o=Se(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return n}var rt={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(e,i,n){let o=nt(Se(e,"color")||"#6366f1"),a=nt(Se(e,"initialColor")||Se(e,"initial-color")||""),c=nt(Se(e,"height")||"3px"),l=Be(e,"duration",2000),u=Be(e,"throttle",200),f=Be(e,"zIndex",999999)||Be(e,"z-index",999999),w=a?`linear-gradient(to right, ${a}, ${o})`:o;return`
7
+ </picture>`}return`${Q}${le}`}};var Et="/images/safe-image-default.svg";function de(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}var Bn=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${Et}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,tt={name:"SafeImage",aliases:["safe-image","safe-img"],render(e,i,n){let o=de(e,"src")||"",a=de(e,"alt")||"",c=de(e,"fallback")||Et,l=de(e,"class")||de(e,"className")||"",u=de(e,"fallbackClassName")||"",f=[];if(f.push(`src="${r(o)}"`),f.push(`alt="${r(a)}"`),l)f.push(`class="${r(l)}"`);if(f.push(`data-fallback="${r(c)}"`),u)f.push(`data-fallback-class="${r(u)}"`);f.push('onerror="window.__stxSafeImageHandler(this)"');let w=new Set(["src","alt","fallback","class","className","fallbackClassName"]);f.push(...se(e,w)),f.push(...ie(e,w));let h=`<img ${f.join(" ")} />`,y=n.context;if(!y.__safeImageHandlerEmitted)return y.__safeImageHandlerEmitted=!0,`${Bn}${h}`;return h}};function nt(e){return e.replace(/[;{}()]/g,"").replace(/url/gi,"")}function $e(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}function Be(e,i,n){let o=$e(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return n}var rt={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(e,i,n){let o=nt($e(e,"color")||"#6366f1"),a=nt($e(e,"initialColor")||$e(e,"initial-color")||""),c=nt($e(e,"height")||"3px"),l=Be(e,"duration",2000),u=Be(e,"throttle",200),f=Be(e,"zIndex",999999)||Be(e,"z-index",999999),w=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:${w};z-index:${f};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>
@@ -37,6 +37,6 @@ ${le}
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 Dn,readFileSync as jn}from"fs";var De=new Map,Dt=new Set;function Mn(e){if(Dt.has(e))return;Dt.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 Ln(e){let i=process.cwd();for(let n 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(Dn(n))return n;for(let n of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return b.resolve(n)}catch{}return null}function zn(e){if(De.has(e))return De.get(e);let i=Ln(e);if(!i)return Mn(e),null;try{let n=JSON.parse(jn(i,"utf8"));return De.set(e,n),n}catch{return null}}function Un(e,i,n,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${n/2} ${o/2})`);if(i.hFlip)a.push(`translate(${n} 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 Fn(e,i){let n=i,o=e.icons[n],a={hFlip:!1,vFlip:!1,rotate:0};for(let u=0;!o&&u<8;u++){let f=e.aliases?.[n];if(!f)return null;if(f.hFlip)a.hFlip=!a.hFlip;if(f.vFlip)a.vFlip=!a.vFlip;if(f.rotate)a.rotate=((a.rotate+f.rotate)%4+4)%4;n=f.parent,o=e.icons[n]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:Un(o.body,a,c,l),width:c,height:l}}function he(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 at={name:"Icon",aliases:["icon","stx-icon"],render(e,i,n){let o=he(e,"name")??he(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let v=o.split(":");a=v[0],c=v[1]}let l=r(he(e,"size")||"24"),u=r(he(e,"color")||"currentColor"),f=r(he(e,"class")||""),w=r(he(e,"style")||""),h=De.get(a)??zn(a);if(!h)return`<!-- Icon: collection "${a}" not loaded -->`;let y=Fn(h,c);if(!y)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${y.width} ${y.height}`,S=y.body;if(u!=="currentColor")S=S.replace(/currentColor/g,u);let x=f?` class="${f}"`:"",d=w?` style="${w}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${x}${d}>${S}</svg>`}};function jt(e,...i){for(let n of i){if(e.serverDynamic[n]!==void 0)return String(e.serverDynamic[n]);let o=e.static[n];if(typeof o==="string")return o}return}function Mt(e,i){let n=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(n);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var ct={name:"Suspense",aliases:["suspense"],render(e,i,n){let o=Mt(i,"fallback"),a=o.rest,c=Mt(a,"error"),l=c.rest,u=o.region??jt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',f=c.region??jt(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>${f}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function je(e,...i){for(let n of i){if(e.serverDynamic[n]!==void 0)return String(e.serverDynamic[n]);let o=e.static[n];if(typeof o==="string")return o}return}var lt={name:"TransitionGroup",aliases:["transition-group"],render(e,i,n){let o=(je(e,"name")||"v").replace(/["'<>]/g,""),a=(je(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=je(e,"class"),l=je(e,"id"),u=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${u}>${i}</${a}>`}};function Lt(e=de){e.registerBuiltin(Ve),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(rt),e.registerBuiltin(st),e.registerBuiltin(it),e.registerBuiltin(ot),e.registerBuiltin(at),e.registerBuiltin(ct),e.registerBuiltin(lt)}var zt=new Map;function Wn(e){let i=zt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),zt.set(e.source,i);return i}var Ut=new WeakMap;function Ft(e){let i=Ut.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),Ut.set(e,i);let n=i;return(o)=>!/[a-z]/.test(o)&&n.has(o.toLowerCase())}function Hn(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function Wt(e,i,n){let o=[],a=0,c=typeof n==="function"?n:n?(l)=>n.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let u=Wn(i);u.lastIndex=l+1;let f=u.exec(e);if(!f){a=l+1;continue}let w=f[1];if(c&&c(w)){let v=l+1+w.length;while(v<e.length&&e[v]!==">")v++;a=v+1;continue}let h=l+1+w.length,y=null,C=h,S=-1,x=!1;while(h<e.length){let v=e[h];if(y){if(v==="\\"&&h+1<e.length){h+=2;continue}if(v===y)y=null;h++;continue}if(v==='"'||v==="'"){y=v,h++;continue}if(v==="/"&&h+1<e.length&&e[h+1]===">"){S=h+2,x=!0;break}if(v===">"){S=h+1;break}h++}if(S===-1){a=l+1;continue}let d=e.slice(C,x?S-2:S-1).trim();if(x)o.push({fullMatch:e.slice(l,S),tagName:w,attributes:d,content:"",startIndex:l,endIndex:S,isSelfClosing:!0}),a=S;else{let v=`<${w}`,k=`</${w}>`,A=1,R=S,E=-1;while(A>0&&R<e.length){let D=e.indexOf(v,R),z=e.indexOf(k,R);if(z===-1)break;if(D!==-1&&D<z){let O=e[D+v.length];if(O===" "||O===">"||O==="/"||O===`
41
- `||O==="\t"){let q=Hn(e,D+v.length);if(e[q-1]!=="/")A++;R=q+1}else R=D+v.length}else{if(A--,A===0){E=z;break}R=z+k.length}}if(E===-1){a=S;continue}let G=e.slice(S,E),U=E+k.length;o.push({fullMatch:e.slice(l,U),tagName:w,attributes:d,content:G,startIndex:l,endIndex:U,isSelfClosing:!1}),a=U}}return o}function ut(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Ht(e,i){try{let n=Buffer.from(e,"base64").toString("utf8");return JSON.parse(n)}catch{}try{let n=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(n)}catch(n){if(i?.debug)console.error("Error decoding __stx_ prop:",n);return e}}function Me(e,i){let n=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==="{")n++;else if(c==="}"){if(n--,n===0)return e.slice(i,a+1)}a++}return e.slice(i)}function qt(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Me(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Xt(e){let i=[],n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o&&e[n]!==l){if(e[n]==="\\"&&n+1<o)n++,c+=e[n];else c+=e[n];n++}if(n<o)n++}else if(e[n]==="{")c=Me(e,n),n+=c.length;else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var qn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Xn=new Set([":for","x-for","v-for","@for"]),Zt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Zn(e){return ft(e).map((i)=>[i.start,i.end])}function ft(e){let i=[],n=new Map;for(let o of Ie(e)){let a=o.name.toLowerCase();if(o.closing){let w=n.get(a)?.pop();if(w)w.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Xt(o.attributes).find((w)=>Xn.has(w.name)):void 0,u=typeof l?.value==="string"?l.value:null,f=u!==null?{start:o.start,end:o.end,names:se(u),tag:a}:null;if(f)i.push(f);if(!o.selfClosing&&!Zt.has(a)){let w=n.get(a);if(!w)w=[],n.set(a,w);w.push(f)}}return i}var Vn=/(?:^|\s)((?:[\w-]+:)*-?space-[xy]-(?!reverse(?:\s|$))[\w./[\]-]+)(?=\s|$)/;function Vt(e){let i=new Map,n=[];for(let o of Ie(e)){let a=o.name.toLowerCase();if(o.closing){for(let l=n.length-1;l>=0;l--)if(n[l].name===a){n.length=l;break}continue}let c=n.at(-1);if(c){if(c.utility&&c.children>0)i.set(o.start,c.utility);if(!/(?:^|\s)hidden(?=[\s=]|$)/.test(o.attributes))c.children++}if(!o.selfClosing&&!Zt.has(a)){let l=/(?:^|\s)class\s*=\s*(["'])([\s\S]*?)\1/.exec(o.attributes)?.[2];n.push({name:a,utility:l?Vn.exec(l)?.[1]??null:null,children:0})}}return i}function Gt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>Gt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function Ic(e,i){if(!/:[\w-]+=/.test(e))return e;let n=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(...Zn(e));let l=new Set([...gt(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function u(y){return a.some(([C,S])=>y>=C&&y<S)}let f=[],w=new Map,h=256;for(let y of Ie(n)){if(y.closing||u(y.start))continue;let C=y.attributes.trimEnd();if(!C||!C.includes(":"))continue;let S=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),x=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,d,v=C,k=!1;while((d=x.exec(C))!==null){if(Nr(C,d.index,!0)?.kind==="attribute")continue;let A=d[1],R=d[2];if(zl(A))continue;if(B(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let E=Object.keys(i),G=Object.values(i),U=R.match(/^([a-zA-Z_$][\w$]*)/);if(U&&!E.includes(U[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(U[1]))continue;let D=JSON.stringify([E,R]),z=w.get(D);if(!z){if(z=Function(...E,`return (${R})`),w.size>=h)w.clear();w.set(D,z)}let O=z(...G);if(A==="class"){let q=Y(Gt(O));if(q){let I=v.match(/\sclass="([^"]*)"/);if(I)v=v.replace(I[0],()=>` class="${I[1]} ${q}"`);else v=v.replace(d[0],()=>` class="${q}"`)}else v=v.replace(d[0],"");k=!0;continue}if(qn.has(A)){if(O)v=v.replace(d[0],` ${A}`);else v=v.replace(d[0],"");k=!0;continue}if(O===null||O===void 0||O===!1)v=v.replace(d[0],"");else{let q=S&&typeof O==="object"?JSON.stringify(O):String(O),I=In(A,q);v=v.replace(d[0],()=>` ${A}="${I}"`)}k=!0}catch(E){if(E instanceof me)throw E;continue}}if(k){let A=y.selfClosing?" /":"",E=`<${y.name}${v}${A}>`;f.push({start:y.start,end:y.end,replacement:E})}}if(f.length>0){let y=Array(f.length*2+1),C=0;for(let S=0;S<f.length;S++){let{start:x,end:d,replacement:v}=f[S];y[S*2]=n.slice(C,x),y[S*2+1]=v,C=d}y[f.length*2]=n.slice(C),n=y.join("")}return n}import Kt from"fs";import Jt from"path";var Yt=!1;function Gn(e,i,n,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=(C)=>{if(l.size===0)return!1;let S=t(C),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let d of l){let v=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${v}\\s*\\(`).test(S))return!0}return!1},f=new Set(Hl),w=(C)=>{if(!C.includes("-")||C.startsWith("@")||C.startsWith(":")||C.startsWith("x-")||C.startsWith("__"))return C;if(C.startsWith("aria-")||C.startsWith("data-"))return C;return C.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},h=(C,S)=>{let x=w(C);if(c.static[x]=S,x!==C)c.staticNames[x]=C},y={...e};for(let[C,S]of Object.entries(e)){let x=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(C);if(!x)continue;delete y[C];let d=x[1]||"modelValue";if(y[`:${d}`]=S,y[`@update:${d}`]=`${S} = $event`,x[2]){let v=x[2].slice(1).split(".").map((k)=>`${k}: true`).join(", ");y[`:${x[1]?`${d}Modifiers`:"modelModifiers"}`]=`{ ${v} }`}}for(let[C,S]of Object.entries(y)){let x=C.startsWith("x-")&&!f.has(C)&&!C.startsWith("x-bind:")&&!C.startsWith("x-on:")?`:${C.slice(2)}`:C;if(x.startsWith("@")){c.events[x]=S;continue}if(x.startsWith("__stx_")){let d=w(x.slice(6));c.serverDynamic[d]=Ht(S,n);continue}if(x.startsWith(":")){let d=w(x.slice(1)),v=S===ne?d:S;if(d==="if"||d==="for"||d==="show"){c.clientReactive[d]=v;continue}if(o){c.clientReactive[d]=v;continue}if(B(v,a)){c.clientReactive[d]=v;continue}if(u(v)){c.clientReactive[d]=v;continue}try{if(!m(v)){if(n.debug)console.error(`Unsafe expression in :${d} binding: ${v}`);c.clientReactive[d]=v;continue}let k=Object.keys(i),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),R=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(ht(v).some((D)=>!A.has(D)&&!k.includes(D)&&(!(D in globalThis)||R.has(D)))){c.clientReactive[d]=v;continue}let U=p(v,k)(...Object.values(i));if(c.serverDynamic[d]=U,d!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[d]=x.slice(1)}catch{c.clientReactive[d]=v}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let d=Qn(S,a);if(d!==null){c.clientReactive[w(x)]=d;continue}let v=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(v)try{let k=v[1];if(m(k)){let R=p(k,Object.keys(i))(...Object.values(i));h(x,R!=null?String(R):"")}else{if(n.debug)console.error(`Unsafe expression in ${x}: ${k}`);h(x,S)}}catch(k){if(n.debug)console.error(`Error evaluating expression for ${x}:`,k);h(x,S)}else{let k=S,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,R;while((R=A.exec(S))!==null)try{let E=R[1];if(!m(E)){if(n.debug)console.error(`Unsafe expression in ${x}: ${E}`);continue}let U=p(E,Object.keys(i))(...Object.values(i));k=k.replace(R[0],String(U??""))}catch(E){if(n.debug)console.error(`Error evaluating expression in ${x}:`,E)}h(x,k)}continue}h(x,S===ne?"true":ut(S))}return c}var dt=new Set;function ly(){dt.clear()}function Kn(e){let i=/^\s*(?:<!--[\s\S]*?-->\s*)*<(?:div|span)\b((?:[^>"']|"[^"]*"|'[^']*')*)>/.exec(e);return!!i&&/\sdata-stx-component-wrapper(?=[\s=]|$)/.test(i[1])&&!/\sstx-hydrate(?=[\s=]|$)/.test(i[1])}function Jn(e,i,n){let o=`${n}\x00${e}\x00${i}`;if(dt.has(o))return;dt.add(o);let a=/space-x-/.test(i)?"flex":"flex flex-col",c=i.replace(/space-[xy]-/,"gap-");console.warn(`[stx] <${e}> in ${n} is a later child of a "${i}" stack, so it gets no spacing: the utility puts its margin on the component's scope wrapper, which generates no box. Use "${a} ${c}" on the parent instead -- gap reaches through the wrapper.`)}var pt=new Set;function uy(){pt.clear()}function Yn(e,i){let n=`${i}\x00${e}`;if(pt.has(n))return;pt.add(n),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 Qn(e,i){if(i.size===0)return null;let n=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(n)];if(!o.some((u)=>B(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,(f)=>`\\${f}`),c+=`\${${u[1]}}`,l=u.index+u[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(u)=>`\\${u}`),`\`${c}\``}var er=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function tr(e,i,n){if(!e.includes("@"))return e;if(!er.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return fe(e,i,n)}catch{return e}}function ye(e){let i={},n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o){let u=e[n];if(u==="\\"&&n+1<o){n++,c+=e[n],n++;continue}if(u===l){n++;break}c+=u,n++}}else if(e[n]==="{"){c=Me(e,n),n+=c.length;let l=qt(c);if(l!==null){i[`:${a}`]=l;continue}}else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i[a]=c}else i[a]=ne}return i}function Qt(e){return Object.entries(e).map(([i,n])=>n===ne?i:`${i}="${nr(n)}"`).join(" ")}function nr(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rr(e){let i=new Set,n=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=n.exec(e))!==null){let a=o[1];if(de.isBuiltin(a))i.add(a)}return[...i].sort()}async function lg(e,i,n,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Jt.dirname(n),u=[],f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(f)){let[C,S,x]=y,d=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,v=x,k,A=[];while((k=d.exec(x))!==null){let[R,E,G,U]=k,D=null,z=null;if(U.startsWith(".")||U.startsWith("/")){let I=Jt.resolve(l,U);if(I.endsWith(".stx"))z=I;else{let _=`${I}.stx`;try{if(Kt.statSync(_).isFile())z=_}catch{try{if(Kt.statSync(I).isDirectory())D=I}catch{}}}}else D=Ks(U,l);if(!D&&!z)continue;let O=!1,q=(I,_)=>{c.set(I,_),c.set(I.toLowerCase(),_);let j=I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(j,_),a.add(_)};if(G&&z)q(G,z),O=!0;else if(E){let I=E.slice(1,-1).split(",").map((j)=>j.trim()).filter(Boolean).map((j)=>{let F=j.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(F)return{source:F[1],local:F[2]};return{source:j,local:j}}),_=D?Ar(D):null;for(let{source:j,local:F}of I){let M=null;if(z)M=z;else if(_)M=_.get(j)??_.get(j.toLowerCase())??_.get(j.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(M)q(F,M),O=!0}}if(O)A.push({start:k.index,end:k.index+R.length})}if(A.length===0)continue;for(let R=A.length-1;R>=0;R--)v=v.slice(0,A[R].start)+v.slice(A[R].end);u.push({start:y.index,end:y.index+C.length,value:`<script${S}>${v}</script>`})}if(u.length===0)return e;let w=[],h=0;for(let y of u)w.push(e.slice(h,y.start),y.value),h=y.end;return w.push(e.slice(h)),w.join("")}async function sr(e,i,n,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,u=/@import\s*\(\s*([^)]+)\s*\)/g,f;while((f=u.exec(c))!==null){let[w,h]=f,y=h.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of y){let S=C.split("/"),d=S[S.length-1].replace(/\.stx$/,""),v=d.includes("-")?d.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):d.charAt(0).toUpperCase()+d.slice(1),k=null,A=Gs(C,n,o);for(let R of A)try{if(await Bun.file(R).exists()){k=R;break}}catch{}if(k){l.set(v,k),l.set(d,k),l.set(d.toLowerCase(),k);let R=v.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,k),a.add(k),o.debug)console.log(`Imported component: ${v} -> ${k}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(w,""),u.lastIndex=0}return c}async function ir(e,i,n,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=/@component\s*\(/g,w;while((w=f.exec(c))!==null){let h=w.index,y=h+w[0].length-1,C=1,S=y+1;while(S<c.length&&C>0){if(c[S]==="(")C++;else if(c[S]===")"){if(C--,C===0)break}S++}if(C!==0)break;let x=c.substring(y+1,S),d=S+1,v=x.match(/^\s*['"]([^'"]+)['"]/);if(!v){f.lastIndex=d;continue}let k=v[1],A,R=x.slice(v[0].length),E=R.match(/^\s*,\s*/);if(E)A=R.slice(E[0].length).trim();let G={};if(A)try{G=N(A,i)}catch(I){let _=I instanceof Error?I.message:String(I);c=c.replace(c.substring(h,d),`[Error parsing component props: ${_}]`);continue}let U="",D=d,O=c.substring(d).match(/^([\s\S]*?)@endcomponent/);if(O)U=O[1].trim(),D=d+O[0].length;let q=await Je(k,G,U,l,i,n,o,u,a);c=c.substring(0,h)+q+c.substring(D),f.lastIndex=0}return c}async function or(e,i,n,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=lr(c);if(f.size>0){let d=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...d,...f])]}let w=re(c);c=w.output;let h=gt(i);return c=await x(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await x(c,/[A-Z][a-zA-Z0-9]*/,!0,Ft(Mr)),c=await x(c,/[a-z][a-z0-9]*/,!1,Mr),c=w.restore(c),c;async function x(d,v,k,A){if(!d)return d;let R=d,E=Wt(R,v,A),G=ft(R),U=!o._nativeHostAttrs&&/space-[xy]-/.test(R),D,z=new Map;for(let I=E.length-1;I>=0;I--){let _=E[I],j=k?J(_.tagName):_.tagName,F=ye(tr(_.attributes,i,n)),M=G.filter(({start:T,end:W})=>_.startIndex>=T&&_.startIndex<W);if(M.some((T)=>T.tag==="template"))Yn(_.tagName,n);let te=M.length>0,ae=new Set(h);for(let T of M)for(let W of T.names)ae.add(W);let L=Gn(F,i,o,te,ae);if(typeof L.clientReactive.for==="string")for(let T of se(L.clientReactive.for))ae.add(T);let X=de.getBuiltin(_.tagName),Re=X?await jr(_.tagName,l,i,n,{...o,_nativePrimitivesFallback:void 0}):!1,be=_.tagName==="Image"&&Xs([...Object.keys(L.static),...Object.keys(L.serverDynamic),...Object.keys(L.clientReactive)],Object.keys(L.events),{...L.static,...L.serverDynamic})&&(o._pluginComponentDirs??[]).some((T)=>Ar(T).has("Image"));if(X&&!Re&&!be){let T={context:i,filePath:n,options:o,dependencies:a},W=X.render(L,_.content,T);if(Object.keys(L.events).length>0){let ce=Qt(L.events);W=W.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ce}`)}if(Object.keys(L.clientReactive).length>0)W=en(W,L.clientReactive);z.set(I,W);continue}if(!k&&_.tagName.includes("-")&&!await jr(j,l,i,n,o))continue;let le={};for(let[T,W]of Object.entries(L.static))le[T]=W;for(let[T,W]of Object.entries(L.serverDynamic))le[T]=W;let Q={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(L.clientReactive),events:Object.keys(L.events)},Z=await Je(j,le,w.restore(_.content),l,i,n,o,u,a,[...ae],Q,_.tagName);if(U&&Kn(Z)){D??=Vt(R);let T=D.get(_.startIndex);if(T)Jn(_.tagName,T,n)}let P=Z;if(P=ar(P,L,Q.declaredProps,Q.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let T=Q.reactiveProps.filter((ee)=>!Q.consumedProps.has(ee)&&!["if","for","show","key","ref"].includes(ee)).map(J),W=mt(P,!0);if(T.length&&W){if(!Object.hasOwn(ye(P.slice(W.insertPos,W.tagEnd)),"data-stx-native-host-root"))P=P.slice(0,W.insertPos)+' data-stx-native-host-root="true"'+P.slice(W.insertPos);let ee=Ce(P);P=P.slice(0,ee.insertPos)+` data-stx-native-forward="${T.join(" ")}"`+P.slice(ee.insertPos)}let ce=mt(P,!0);if(ce){let ee=ye(P.slice(ce.insertPos,ce.tagEnd)),ke=Ce(P),nn=ye(P.slice(ke.insertPos,ke.tagEnd));if(Object.hasOwn(ee,"data-stx-native-host-root")&&!Object.hasOwn(nn,"data-stx-native-host-owner"))P=P.slice(0,ke.insertPos)+" data-stx-native-host-owner"+P.slice(ke.insertPos)}}if(Object.keys(L.events).length>0){let T=Ce(P);if(T){let W=Qt(L.events),ce=Object.keys(L.events).map((ee)=>ee.replace(/^@/,"").split(".")[0]).join(" ");P=P.substring(0,T.insertPos)+` data-stx-parent-events="${ce}" ${W}`+P.substring(T.insertPos)}}if(Object.keys(L.clientReactive).length>0)P=en(P,L.clientReactive);z.set(I,P)}if(z.size===0)return R;let O="",q=0;for(let I=0;I<E.length;I++){let _=z.get(I);if(_===void 0)continue;O+=R.slice(q,E[I].startIndex),O+=_,q=E[I].endIndex}return O+=R.slice(q),O}}function en(e,i){let n=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([h])=>!n.has(h)),c=a.filter(([h])=>!o.has(h)).map(([h])=>J(h)).join(" "),l=e,u=a.length>0?Ce(l):null;if(u){let h=a.map(([C,S])=>`:${J(C)}="${S.replace(/"/g,"&quot;")}"`).join(" "),y=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,u.insertPos)+`${y} ${h}`+l.substring(u.insertPos)}let f=i.if;if(f)l=`<template :if="${f.replace(/"/g,"&quot;")}">${l}</template>`;let w=i.for;if(w){let h=i.key,y=h?` :key="${h.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${w.replace(/"/g,"&quot;")}"${y}>${l}</template>`}return l}function ar(e,i,n=new Set,o=new Set,a=!1){let c=mt(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 x=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,d=x.test(l)?l.replace(x,(v,k,A,R,E)=>`${k}class="${r(`${ut(A??R??E)} ${u}`)}"`):` class="${r(u)}"${l}`;e=e.slice(0,c.insertPos)+d+e.slice(c.tagEnd),c.tagEnd+=d.length-l.length,l=d}let f=a||/\bdata-native(?:\s|=)/i.test(l),w=f?o:n,h=new Set(Object.keys(ye(l))),y=new Set(["class","className"]);for(let x of Object.keys(i.static)){let d=i.staticNames[x]??x;if(h.has(d)||w.has(x)||!f&&!Ze(d))y.add(x)}for(let x of Object.keys(i.serverDynamic)){let d=i.serverDynamicNames?.[x]??x;if(h.has(d)||w.has(x)||!f&&!Ze(d))y.add(x)}let C=[];if(f){for(let[x,d]of Object.entries(i.static)){if(y.has(x)||d!==!0&&d!==ne)continue;y.add(x),C.push(`${r(i.staticNames?.[x]??x)}="true"`)}for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d!==!0)continue;y.add(x),C.push(`${r(i.serverDynamicNames?.[x]??x)}="true"`)}}let S=[...ie(i,y),...oe(i,y),...C];if(f){for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d!==!1)continue;let v=i.serverDynamicNames?.[x]??x;S.push(`${r(v)}="false"`)}for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d===null||typeof d!=="object")continue;let v=JSON.stringify(d);if(v!==void 0){let k=i.serverDynamicNames?.[x]??x;S.push(`${r(k)}="${r(v)}"`)}}}if(S.length===0)return e;return`${e.slice(0,c.insertPos)} ${S.join(" ")}${e.slice(c.insertPos)}`}function Ce(e){let i=tn(e,0);if(i)return i;let n=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(n)return{insertPos:n.index+1+n[1].length,tagEnd:yt(e,n.index+1+n[1].length)};return null}function mt(e,i=!1){let n=Ce(e);if(!n)return null;let o=e.slice(n.insertPos,n.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?tn(e,n.tagEnd+1):n;return a&&i?cr(e,a)??a:a}function cr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let n=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 h=e.indexOf("-->",o+4);if(h<0)return null;o=e.indexOf("<",h+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(),f=o+l[0].length,w=yt(e,f);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 h=new RegExp(`</${u}\\s*>`,"gi");if(h.lastIndex=w+1,!h.exec(e))return null;o=e.indexOf("<",h.lastIndex);continue}else{let h=ye(e.slice(f,w)),y=a>0&&(Object.hasOwn(h,"data-stx-component-wrapper")||Object.hasOwn(h,"data-stx-native-host-owner"));if(c===void 0&&!y&&Object.hasOwn(h,"data-stx-native-host-root"))return{insertPos:f,tagEnd:w};if(!n.has(u)&&e[w-1]!=="/"){if(a++,c===void 0&&y)c=a}else if(a===0)return null}o=e.indexOf("<",w+1)}return null}function tn(e,i){let n=i;while(n<e.length){let o=e.slice(n),a=o.match(/^\s+/);if(a){n+=a[0].length;continue}if(o.startsWith("<!--")){let u=e.indexOf("-->",n+4);if(u===-1)return null;n=u+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let u=`</${c[1].toLowerCase()}>`,f=e.toLowerCase().indexOf(u,n+c[0].length);if(f===-1)return null;n=f+u.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:n+1+l[1].length,tagEnd:yt(e,n+1+l[1].length)}}return null}function yt(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function lr(e){let i=new Set;for(let n of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=n[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of Ai(n[2]))i.add(a);for(let a of n[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 Cs(e,i,n,o,a){if(!Yt)Lt(de),Yt=!0;let c=await lg(e,i,n,o,a);c=await sr(c,i,n,o,a),c=await ir(c,i,n,o,a);let l=[];for(let u=0;u<3;u++){let f=l.length,w=xe(c,We,(y,C)=>`\x00STX_COMPONENT_COMMENT_${f+C}\x00`,`STX_COMPONENT_COMMENT:${f}`);l.push(...w.tokens);let h=c;if(c=await or(w.output,i,n,o,a),c===h)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(u,f)=>l[Number(f)]??"");if(o.debug){let u=rr(c);if(u.length>0)console.warn(`[stx] ${n}: 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{ti,ni,ri,ay,_s,cy,Ic,ly,uy,lg,Cs};
40
+ </style>`}};import{existsSync as Dn,readFileSync as jn}from"fs";var De=new Map,Dt=new Set;function Mn(e){if(Dt.has(e))return;Dt.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 Ln(e){let i=process.cwd();for(let n 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(Dn(n))return n;for(let n of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return b.resolve(n)}catch{}return null}function zn(e){if(De.has(e))return De.get(e);let i=Ln(e);if(!i)return Mn(e),null;try{let n=JSON.parse(jn(i,"utf8"));return De.set(e,n),n}catch{return null}}function Un(e,i,n,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${n/2} ${o/2})`);if(i.hFlip)a.push(`translate(${n} 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 Fn(e,i){let n=i,o=e.icons[n],a={hFlip:!1,vFlip:!1,rotate:0};for(let u=0;!o&&u<8;u++){let f=e.aliases?.[n];if(!f)return null;if(f.hFlip)a.hFlip=!a.hFlip;if(f.vFlip)a.vFlip=!a.vFlip;if(f.rotate)a.rotate=((a.rotate+f.rotate)%4+4)%4;n=f.parent,o=e.icons[n]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:Un(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 at={name:"Icon",aliases:["icon","stx-icon"],render(e,i,n){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 v=o.split(":");a=v[0],c=v[1]}let l=r(me(e,"size")||"24"),u=r(me(e,"color")||"currentColor"),f=r(me(e,"class")||""),w=r(me(e,"style")||""),h=De.get(a)??zn(a);if(!h)return`<!-- Icon: collection "${a}" not loaded -->`;let y=Fn(h,c);if(!y)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${y.width} ${y.height}`,S=y.body;if(u!=="currentColor")S=S.replace(/currentColor/g,u);let x=f?` class="${f}"`:"",d=w?` style="${w}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${x}${d}>${S}</svg>`}};function jt(e,...i){for(let n of i){if(e.serverDynamic[n]!==void 0)return String(e.serverDynamic[n]);let o=e.static[n];if(typeof o==="string")return o}return}function Mt(e,i){let n=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(n);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var ct={name:"Suspense",aliases:["suspense"],render(e,i,n){let o=Mt(i,"fallback"),a=o.rest,c=Mt(a,"error"),l=c.rest,u=o.region??jt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',f=c.region??jt(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>${f}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function je(e,...i){for(let n of i){if(e.serverDynamic[n]!==void 0)return String(e.serverDynamic[n]);let o=e.static[n];if(typeof o==="string")return o}return}var lt={name:"TransitionGroup",aliases:["transition-group"],render(e,i,n){let o=(je(e,"name")||"v").replace(/["'<>]/g,""),a=(je(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=je(e,"class"),l=je(e,"id"),u=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${u}>${i}</${a}>`}};function Lt(e=fe){e.registerBuiltin(Ve),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(rt),e.registerBuiltin(st),e.registerBuiltin(it),e.registerBuiltin(ot),e.registerBuiltin(at),e.registerBuiltin(ct),e.registerBuiltin(lt)}var zt=new Map;function Wn(e){let i=zt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),zt.set(e.source,i);return i}var Ut=new WeakMap;function Ft(e){let i=Ut.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),Ut.set(e,i);let n=i;return(o)=>!/[a-z]/.test(o)&&n.has(o.toLowerCase())}function Hn(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function Wt(e,i,n){let o=[],a=0,c=typeof n==="function"?n:n?(l)=>n.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let u=Wn(i);u.lastIndex=l+1;let f=u.exec(e);if(!f){a=l+1;continue}let w=f[1];if(c&&c(w)){let v=l+1+w.length;while(v<e.length&&e[v]!==">")v++;a=v+1;continue}let h=l+1+w.length,y=null,C=h,S=-1,x=!1;while(h<e.length){let v=e[h];if(y){if(v==="\\"&&h+1<e.length){h+=2;continue}if(v===y)y=null;h++;continue}if(v==='"'||v==="'"){y=v,h++;continue}if(v==="/"&&h+1<e.length&&e[h+1]===">"){S=h+2,x=!0;break}if(v===">"){S=h+1;break}h++}if(S===-1){a=l+1;continue}let d=e.slice(C,x?S-2:S-1).trim();if(x)o.push({fullMatch:e.slice(l,S),tagName:w,attributes:d,content:"",startIndex:l,endIndex:S,isSelfClosing:!0}),a=S;else{let v=`<${w}`,k=`</${w}>`,A=1,R=S,E=-1;while(A>0&&R<e.length){let B=e.indexOf(v,R),L=e.indexOf(k,R);if(L===-1)break;if(B!==-1&&B<L){let N=e[B+v.length];if(N===" "||N===">"||N==="/"||N===`
41
+ `||N==="\t"){let q=Hn(e,B+v.length);if(e[q-1]!=="/")A++;R=q+1}else R=B+v.length}else{if(A--,A===0){E=L;break}R=L+k.length}}if(E===-1){a=S;continue}let G=e.slice(S,E),z=E+k.length;o.push({fullMatch:e.slice(l,z),tagName:w,attributes:d,content:G,startIndex:l,endIndex:z,isSelfClosing:!1}),a=z}}return o}function ut(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Ht(e,i){try{let n=Buffer.from(e,"base64").toString("utf8");return JSON.parse(n)}catch{}try{let n=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(n)}catch(n){if(i?.debug)console.error("Error decoding __stx_ prop:",n);return e}}function Me(e,i){let n=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==="{")n++;else if(c==="}"){if(n--,n===0)return e.slice(i,a+1)}a++}return e.slice(i)}function qt(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Me(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Xt(e){let i=[],n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o&&e[n]!==l){if(e[n]==="\\"&&n+1<o)n++,c+=e[n];else c+=e[n];n++}if(n<o)n++}else if(e[n]==="{")c=Me(e,n),n+=c.length;else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var qn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Xn=new Set([":for","x-for","v-for","@for"]),Zt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Zn(e){return ft(e).map((i)=>[i.start,i.end])}function ft(e){let i=[],n=new Map;for(let o of Ie(e)){let a=o.name.toLowerCase();if(o.closing){let w=n.get(a)?.pop();if(w)w.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Xt(o.attributes).find((w)=>Xn.has(w.name)):void 0,u=typeof l?.value==="string"?l.value:null,f=u!==null?{start:o.start,end:o.end,names:oe(u),tag:a}:null;if(f)i.push(f);if(!o.selfClosing&&!Zt.has(a)){let w=n.get(a);if(!w)w=[],n.set(a,w);w.push(f)}}return i}var Vn=/(?:^|\s)((?:[\w-]+:)*-?space-[xy]-(?!reverse(?:\s|$))[\w./[\]-]+)(?=\s|$)/;function Vt(e){let i=new Map,n=[];for(let o of Ie(e)){let a=o.name.toLowerCase();if(o.closing){for(let l=n.length-1;l>=0;l--)if(n[l].name===a){n.length=l;break}continue}let c=n.at(-1);if(c){if(c.utility&&c.children>0)i.set(o.start,c.utility);if(!/(?:^|\s)hidden(?=[\s=]|$)/.test(o.attributes))c.children++}if(!o.selfClosing&&!Zt.has(a)){let l=/(?:^|\s)class\s*=\s*(["'])([\s\S]*?)\1/.exec(o.attributes)?.[2];n.push({name:a,utility:l?Vn.exec(l)?.[1]??null:null,children:0})}}return i}function Gt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>Gt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function Oc(e,i){if(!/:[\w-]+=/.test(e))return e;let n=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(...Zn(e));let l=new Set([...gt(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function u(y){return a.some(([C,S])=>y>=C&&y<S)}let f=[],w=new Map,h=256;for(let y of Ie(n)){if(y.closing||u(y.start))continue;let C=y.attributes.trimEnd();if(!C||!C.includes(":"))continue;let S=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),x=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,d,v=C,k=!1;while((d=x.exec(C))!==null){if(Mr(C,d.index,!0)?.kind==="attribute")continue;let A=d[1],R=d[2];if(Hl(A))continue;if(F(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let E=Object.keys(i),G=Object.values(i),z=R.match(/^([a-zA-Z_$][\w$]*)/);if(z&&!E.includes(z[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(z[1]))continue;let B=JSON.stringify([E,R]),L=w.get(B);if(!L){if(L=Function(...E,`return (${R})`),w.size>=h)w.clear();w.set(B,L)}let N=L(...G);if(A==="class"){let q=Y(Gt(N));if(q){let I=v.match(/\sclass="([^"]*)"/);if(I)v=v.replace(I[0],()=>` class="${I[1]} ${q}"`);else v=v.replace(d[0],()=>` class="${q}"`)}else v=v.replace(d[0],"");k=!0;continue}if(qn.has(A)){if(N)v=v.replace(d[0],` ${A}`);else v=v.replace(d[0],"");k=!0;continue}if(N===null||N===void 0||N===!1)v=v.replace(d[0],"");else{let q=S&&typeof N==="object"?JSON.stringify(N):String(N),I=Pn(A,q);v=v.replace(d[0],()=>` ${A}="${I}"`)}k=!0}catch(E){if(E instanceof he)throw E;continue}}if(k){let A=y.selfClosing?" /":"",E=`<${y.name}${v}${A}>`;f.push({start:y.start,end:y.end,replacement:E})}}if(f.length>0){let y=Array(f.length*2+1),C=0;for(let S=0;S<f.length;S++){let{start:x,end:d,replacement:v}=f[S];y[S*2]=n.slice(C,x),y[S*2+1]=v,C=d}y[f.length*2]=n.slice(C),n=y.join("")}return n}import Kt from"fs";import Jt from"path";var Yt=!1;function Gn(e,i,n,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=(C)=>{if(l.size===0)return!1;let S=t(C),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let d of l){let v=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${v}\\s*\\(`).test(S))return!0}return!1},f=new Set(Vl),w=(C)=>{if(!C.includes("-")||C.startsWith("@")||C.startsWith(":")||C.startsWith("x-")||C.startsWith("__"))return C;if(C.startsWith("aria-")||C.startsWith("data-"))return C;return C.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},h=(C,S)=>{let x=w(C);if(c.static[x]=S,x!==C)c.staticNames[x]=C},y={...e};for(let[C,S]of Object.entries(e)){let x=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(C);if(!x)continue;delete y[C];let d=x[1]||"modelValue";if(y[`:${d}`]=S,y[`@update:${d}`]=`${S} = $event`,x[2]){let v=x[2].slice(1).split(".").map((k)=>`${k}: true`).join(", ");y[`:${x[1]?`${d}Modifiers`:"modelModifiers"}`]=`{ ${v} }`}}for(let[C,S]of Object.entries(y)){let x=C.startsWith("x-")&&!f.has(C)&&!C.startsWith("x-bind:")&&!C.startsWith("x-on:")?`:${C.slice(2)}`:C;if(x.startsWith("@")){c.events[x]=S;continue}if(x.startsWith("__stx_")){let d=w(x.slice(6));c.serverDynamic[d]=Ht(S,n);continue}if(x.startsWith(":")){let d=w(x.slice(1)),v=S===ne?d:S;if(d==="if"||d==="for"||d==="show"){c.clientReactive[d]=v;continue}if(o){c.clientReactive[d]=v;continue}if(F(v,a)){c.clientReactive[d]=v;continue}if(u(v)){c.clientReactive[d]=v;continue}try{if(!m(v)){if(n.debug)console.error(`Unsafe expression in :${d} binding: ${v}`);c.clientReactive[d]=v;continue}let k=Object.keys(i),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),R=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(ht(v).some((B)=>!A.has(B)&&!k.includes(B)&&(!(B in globalThis)||R.has(B)))){c.clientReactive[d]=v;continue}let z=p(v,k)(...Object.values(i));if(c.serverDynamic[d]=z,d!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[d]=x.slice(1)}catch{c.clientReactive[d]=v}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let d=Qn(S,a);if(d!==null){c.clientReactive[w(x)]=d;continue}let v=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(v)try{let k=v[1];if(m(k)){let R=p(k,Object.keys(i))(...Object.values(i));h(x,R!=null?String(R):"")}else{if(n.debug)console.error(`Unsafe expression in ${x}: ${k}`);h(x,S)}}catch(k){if(n.debug)console.error(`Error evaluating expression for ${x}:`,k);h(x,S)}else{let k=S,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,R;while((R=A.exec(S))!==null)try{let E=R[1];if(!m(E)){if(n.debug)console.error(`Unsafe expression in ${x}: ${E}`);continue}let z=p(E,Object.keys(i))(...Object.values(i));k=k.replace(R[0],String(z??""))}catch(E){if(n.debug)console.error(`Error evaluating expression in ${x}:`,E)}h(x,k)}continue}h(x,S===ne?"true":ut(S))}return c}var dt=new Set;function uy(){dt.clear()}function Kn(e){let i=/^\s*(?:<!--[\s\S]*?-->\s*)*<(?:div|span)\b((?:[^>"']|"[^"]*"|'[^']*')*)>/.exec(e);return!!i&&/\sdata-stx-component-wrapper(?=[\s=]|$)/.test(i[1])&&!/\sstx-hydrate(?=[\s=]|$)/.test(i[1])}function Jn(e,i,n){let o=`${n}\x00${e}\x00${i}`;if(dt.has(o))return;dt.add(o);let a=/space-x-/.test(i)?"flex":"flex flex-col",c=i.replace(/space-[xy]-/,"gap-");console.warn(`[stx] <${e}> in ${n} is a later child of a "${i}" stack, so it gets no spacing: the utility puts its margin on the component's scope wrapper, which generates no box. Use "${a} ${c}" on the parent instead -- gap reaches through the wrapper.`)}var pt=new Set;function dy(){pt.clear()}function Yn(e,i){let n=`${i}\x00${e}`;if(pt.has(n))return;pt.add(n),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 Qn(e,i){if(i.size===0)return null;let n=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(n)];if(!o.some((u)=>F(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,(f)=>`\\${f}`),c+=`\${${u[1]}}`,l=u.index+u[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(u)=>`\\${u}`),`\`${c}\``}var er=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function tr(e,i,n){if(!e.includes("@"))return e;if(!er.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return ge(e,i,n)}catch{return e}}function ye(e){let i={},n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o){let u=e[n];if(u==="\\"&&n+1<o){n++,c+=e[n],n++;continue}if(u===l){n++;break}c+=u,n++}}else if(e[n]==="{"){c=Me(e,n),n+=c.length;let l=qt(c);if(l!==null){i[`:${a}`]=l;continue}}else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i[a]=c}else i[a]=ne}return i}function Qt(e){return Object.entries(e).map(([i,n])=>n===ne?i:`${i}="${nr(n)}"`).join(" ")}function nr(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rr(e){let i=new Set,n=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=n.exec(e))!==null){let a=o[1];if(fe.isBuiltin(a))i.add(a)}return[...i].sort()}async function ug(e,i,n,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Jt.dirname(n),u=[],f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(f)){let[C,S,x]=y,d=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,v=x,k,A=[];while((k=d.exec(x))!==null){let[R,E,G,z]=k,B=null,L=null;if(z.startsWith(".")||z.startsWith("/")){let I=Jt.resolve(l,z);if(I.endsWith(".stx"))L=I;else{let _=`${I}.stx`;try{if(Kt.statSync(_).isFile())L=_}catch{try{if(Kt.statSync(I).isDirectory())B=I}catch{}}}}else B=Js(z,l);if(!B&&!L)continue;let N=!1,q=(I,_)=>{c.set(I,_),c.set(I.toLowerCase(),_);let T=I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(T,_),a.add(_)};if(G&&L)q(G,L),N=!0;else if(E){let I=E.slice(1,-1).split(",").map((T)=>T.trim()).filter(Boolean).map((T)=>{let U=T.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(U)return{source:U[1],local:U[2]};return{source:T,local:T}}),_=B?Pr(B):null;for(let{source:T,local:U}of I){let D=null;if(L)D=L;else if(_)D=_.get(T)??_.get(T.toLowerCase())??_.get(T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(D)q(U,D),N=!0}}if(N)A.push({start:k.index,end:k.index+R.length})}if(A.length===0)continue;for(let R=A.length-1;R>=0;R--)v=v.slice(0,A[R].start)+v.slice(A[R].end);u.push({start:y.index,end:y.index+C.length,value:`<script${S}>${v}</script>`})}if(u.length===0)return e;let w=[],h=0;for(let y of u)w.push(e.slice(h,y.start),y.value),h=y.end;return w.push(e.slice(h)),w.join("")}async function sr(e,i,n,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,u=/@import\s*\(\s*([^)]+)\s*\)/g,f;while((f=u.exec(c))!==null){let[w,h]=f,y=h.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of y){let S=C.split("/"),d=S[S.length-1].replace(/\.stx$/,""),v=d.includes("-")?d.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):d.charAt(0).toUpperCase()+d.slice(1),k=null,A=Ys(C,n,o);for(let R of A)try{if(await Bun.file(R).exists()){k=R;break}}catch{}if(k){l.set(v,k),l.set(d,k),l.set(d.toLowerCase(),k);let R=v.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,k),a.add(k),o.debug)console.log(`Imported component: ${v} -> ${k}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(w,""),u.lastIndex=0}return c}async function ir(e,i,n,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=/@component\s*\(/g,w;while((w=f.exec(c))!==null){let h=w.index,y=h+w[0].length-1,C=1,S=y+1;while(S<c.length&&C>0){if(c[S]==="(")C++;else if(c[S]===")"){if(C--,C===0)break}S++}if(C!==0)break;let x=c.substring(y+1,S),d=S+1,v=x.match(/^\s*['"]([^'"]+)['"]/);if(!v){f.lastIndex=d;continue}let k=v[1],A,R=x.slice(v[0].length),E=R.match(/^\s*,\s*/);if(E)A=R.slice(E[0].length).trim();let G={};if(A)try{G=M(A,i)}catch(I){let _=I instanceof Error?I.message:String(I);c=c.replace(c.substring(h,d),`[Error parsing component props: ${_}]`);continue}let z="",B=d,N=c.substring(d).match(/^([\s\S]*?)@endcomponent/);if(N)z=N[1].trim(),B=d+N[0].length;let q=await Je(k,G,z,l,i,n,o,u,a);c=c.substring(0,h)+q+c.substring(B),f.lastIndex=0}return c}async function or(e,i,n,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=lr(c);if(f.size>0){let d=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...d,...f])]}let w=re(c);c=w.output;let h=gt(i);return c=await x(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await x(c,/[A-Z][a-zA-Z0-9]*/,!0,Ft(Dr)),c=await x(c,/[a-z][a-z0-9]*/,!1,Dr),c=w.restore(c),c;async function x(d,v,k,A){if(!d)return d;let R=d,E=Wt(R,v,A),G=ft(R),z=!o._nativeHostAttrs&&/space-[xy]-/.test(R),B,L=new Map;for(let I=E.length-1;I>=0;I--){let _=E[I],T=k?J(_.tagName):_.tagName,U=ye(tr(_.attributes,i,n)),D=G.filter(({start:O,end:W})=>_.startIndex>=O&&_.startIndex<W);if(D.some((O)=>O.tag==="template"))Yn(_.tagName,n);let te=D.length>0,ae=new Set(h);for(let O of D)for(let W of O.names)ae.add(W);let j=Gn(U,i,o,te,ae);if(typeof j.clientReactive.for==="string")for(let O of oe(j.clientReactive.for))ae.add(O);let X=fe.getBuiltin(_.tagName),Re=X?await Br(_.tagName,l,i,n,{...o,_nativePrimitivesFallback:void 0}):!1,be=_.tagName==="Image"&&Zs([...Object.keys(j.static),...Object.keys(j.serverDynamic),...Object.keys(j.clientReactive)],Object.keys(j.events),{...j.static,...j.serverDynamic})&&(o._pluginComponentDirs??[]).some((O)=>Pr(O).has("Image"));if(X&&!Re&&!be){let O={context:i,filePath:n,options:o,dependencies:a},W=X.render(j,_.content,O);if(Object.keys(j.events).length>0){let ce=Qt(j.events);W=W.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ce}`)}if(Object.keys(j.clientReactive).length>0)W=en(W,j.clientReactive);L.set(I,W);continue}if(!k&&_.tagName.includes("-")&&!await Br(T,l,i,n,o))continue;let le={};for(let[O,W]of Object.entries(j.static))le[O]=W;for(let[O,W]of Object.entries(j.serverDynamic))le[O]=W;let Q={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(j.clientReactive),events:Object.keys(j.events)},Z=await Je(T,le,w.restore(_.content),l,i,n,o,u,a,[...ae],Q,_.tagName);if(z&&Kn(Z)){B??=Vt(R);let O=B.get(_.startIndex);if(O)Jn(_.tagName,O,n)}let P=Z;if(P=ar(P,j,Q.declaredProps,Q.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let O=Q.reactiveProps.filter((ee)=>!Q.consumedProps.has(ee)&&!["if","for","show","key","ref"].includes(ee)).map(J),W=mt(P,!0);if(O.length&&W){if(!Object.hasOwn(ye(P.slice(W.insertPos,W.tagEnd)),"data-stx-native-host-root"))P=P.slice(0,W.insertPos)+' data-stx-native-host-root="true"'+P.slice(W.insertPos);let ee=Ce(P);P=P.slice(0,ee.insertPos)+` data-stx-native-forward="${O.join(" ")}"`+P.slice(ee.insertPos)}let ce=mt(P,!0);if(ce){let ee=ye(P.slice(ce.insertPos,ce.tagEnd)),ke=Ce(P),nn=ye(P.slice(ke.insertPos,ke.tagEnd));if(Object.hasOwn(ee,"data-stx-native-host-root")&&!Object.hasOwn(nn,"data-stx-native-host-owner"))P=P.slice(0,ke.insertPos)+" data-stx-native-host-owner"+P.slice(ke.insertPos)}}if(Object.keys(j.events).length>0){let O=Ce(P);if(O){let W=Qt(j.events),ce=Object.keys(j.events).map((ee)=>ee.replace(/^@/,"").split(".")[0]).join(" ");P=P.substring(0,O.insertPos)+` data-stx-parent-events="${ce}" ${W}`+P.substring(O.insertPos)}}if(Object.keys(j.clientReactive).length>0)P=en(P,j.clientReactive);L.set(I,P)}if(L.size===0)return R;let N="",q=0;for(let I=0;I<E.length;I++){let _=L.get(I);if(_===void 0)continue;N+=R.slice(q,E[I].startIndex),N+=_,q=E[I].endIndex}return N+=R.slice(q),N}}function en(e,i){let n=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([h])=>!n.has(h)),c=a.filter(([h])=>!o.has(h)).map(([h])=>J(h)).join(" "),l=e,u=a.length>0?Ce(l):null;if(u){let h=a.map(([C,S])=>`:${J(C)}="${S.replace(/"/g,"&quot;")}"`).join(" "),y=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,u.insertPos)+`${y} ${h}`+l.substring(u.insertPos)}let f=i.if;if(f)l=`<template :if="${f.replace(/"/g,"&quot;")}">${l}</template>`;let w=i.for;if(w){let h=i.key,y=h?` :key="${h.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${w.replace(/"/g,"&quot;")}"${y}>${l}</template>`}return l}function ar(e,i,n=new Set,o=new Set,a=!1){let c=mt(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 x=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,d=x.test(l)?l.replace(x,(v,k,A,R,E)=>`${k}class="${r(`${ut(A??R??E)} ${u}`)}"`):` class="${r(u)}"${l}`;e=e.slice(0,c.insertPos)+d+e.slice(c.tagEnd),c.tagEnd+=d.length-l.length,l=d}let f=a||/\bdata-native(?:\s|=)/i.test(l),w=f?o:n,h=new Set(Object.keys(ye(l))),y=new Set(["class","className"]);for(let x of Object.keys(i.static)){let d=i.staticNames[x]??x;if(h.has(d)||w.has(x)||!f&&!Ze(d))y.add(x)}for(let x of Object.keys(i.serverDynamic)){let d=i.serverDynamicNames?.[x]??x;if(h.has(d)||w.has(x)||!f&&!Ze(d))y.add(x)}let C=[];if(f){for(let[x,d]of Object.entries(i.static)){if(y.has(x)||d!==!0&&d!==ne)continue;y.add(x),C.push(`${r(i.staticNames?.[x]??x)}="true"`)}for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d!==!0)continue;y.add(x),C.push(`${r(i.serverDynamicNames?.[x]??x)}="true"`)}}let S=[...se(i,y),...ie(i,y),...C];if(f){for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d!==!1)continue;let v=i.serverDynamicNames?.[x]??x;S.push(`${r(v)}="false"`)}for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d===null||typeof d!=="object")continue;let v=JSON.stringify(d);if(v!==void 0){let k=i.serverDynamicNames?.[x]??x;S.push(`${r(k)}="${r(v)}"`)}}}if(S.length===0)return e;return`${e.slice(0,c.insertPos)} ${S.join(" ")}${e.slice(c.insertPos)}`}function Ce(e){let i=tn(e,0);if(i)return i;let n=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(n)return{insertPos:n.index+1+n[1].length,tagEnd:yt(e,n.index+1+n[1].length)};return null}function mt(e,i=!1){let n=Ce(e);if(!n)return null;let o=e.slice(n.insertPos,n.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?tn(e,n.tagEnd+1):n;return a&&i?cr(e,a)??a:a}function cr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let n=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 h=e.indexOf("-->",o+4);if(h<0)return null;o=e.indexOf("<",h+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(),f=o+l[0].length,w=yt(e,f);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 h=new RegExp(`</${u}\\s*>`,"gi");if(h.lastIndex=w+1,!h.exec(e))return null;o=e.indexOf("<",h.lastIndex);continue}else{let h=ye(e.slice(f,w)),y=a>0&&(Object.hasOwn(h,"data-stx-component-wrapper")||Object.hasOwn(h,"data-stx-native-host-owner"));if(c===void 0&&!y&&Object.hasOwn(h,"data-stx-native-host-root"))return{insertPos:f,tagEnd:w};if(!n.has(u)&&e[w-1]!=="/"){if(a++,c===void 0&&y)c=a}else if(a===0)return null}o=e.indexOf("<",w+1)}return null}function tn(e,i){let n=i;while(n<e.length){let o=e.slice(n),a=o.match(/^\s+/);if(a){n+=a[0].length;continue}if(o.startsWith("<!--")){let u=e.indexOf("-->",n+4);if(u===-1)return null;n=u+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let u=`</${c[1].toLowerCase()}>`,f=e.toLowerCase().indexOf(u,n+c[0].length);if(f===-1)return null;n=f+u.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:n+1+l[1].length,tagEnd:yt(e,n+1+l[1].length)}}return null}function yt(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function lr(e){let i=new Set;for(let n of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=n[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of Oi(n[2]))i.add(a);for(let a of n[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 $s(e,i,n,o,a){if(!Yt)Lt(fe),Yt=!0;let c=await ug(e,i,n,o,a);c=await sr(c,i,n,o,a),c=await ir(c,i,n,o,a);let l=[];for(let u=0;u<3;u++){let f=l.length,w=Se(c,We,(y,C)=>`\x00STX_COMPONENT_COMMENT_${f+C}\x00`,`STX_COMPONENT_COMMENT:${f}`);l.push(...w.tokens);let h=c;if(c=await or(w.output,i,n,o,a),c===h)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(u,f)=>l[Number(f)]??"");if(o.debug){let u=rr(c);if(u.length>0)console.warn(`[stx] ${n}: 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{si,oi,ii,cy,Ts,ly,Oc,uy,dy,ug,$s};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Pe,Fi,zi,Dg,Kt,vl,Lg,xl,Ty,qe,$n,Ke}from"./chunk-gz9pknbw.js";import"./chunk-s93yh7ed.js";import"./chunk-eyx92t9n.js";import"./chunk-3dqfjpz4.js";import"./chunk-vk2jy6mn.js";import"./chunk-9n5h4sqc.js";import{jl,t}from"./chunk-3hsv6ejp.js";import"./chunk-2a5g80mq.js";import"./chunk-mgh5rst1.js";export{Pe as BROWSER_CORE_IMPORTS,Dg as STX_AUTO_IMPORTS,Fi as extractAndStripCssImports,qe as extractBridgeData,jl as findInterpolationEnd,xl as generateAutoImportDestructuring,Ty as generateBrowserAutoImportDestructuring,$n as generateServerDataBridge,Kt as injectBrowserCoreAutoImports,Ke as processClientScript,Lg as referencesName,zi as renderVendorStyleTags,t as stripCommentsAndLiterals,vl as transformAutoImports};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Cu,Eu,Tu,$u,Ru,Au,Pu,Iu,Ou,Nu,ch}from"./chunk-vf4ejngv.js";export{Cu as createIslandRegistry,ch as default,Nu as generateIslandManifest,Tu as generatePartialHydrationCSS,Au as hydrateAll,Ru as hydrateByStrategy,$u as hydrateIsland,Pu as isHydrated,Iu as onHydrated,Eu as processPartialHydrationDirectives,Ou as processStaticDirectives};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Ye,F,Gt}from"./chunk-6t04tqvh.js";import{T}from"./chunk-s29hp1qw.js";import{Ct,Le,V,rt,je,Ma,No,Da,Wn}from"./chunk-v47xc2fr.js";import{Nt,ve,dt}from"./chunk-b8528fra.js";import{Jo}from"./chunk-e9tjxnhn.js";import{qn}from"./chunk-c73c0wf9.js";import{$e}from"./chunk-fepezvdq.js";import Z from"fs";import P from"path";var{serve:ae}=globalThis.Bun;import O from"zlib";import{promisify as Y}from"util";var K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function se(t){if(!t)return null;let e=re(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,z=0;function oe(t,e){if(e.length>J/8)return;H.set(t,e),z+=e.length;for(let[a,r]of H){if(z<=J)break;H.delete(a),z-=r.length}}async function zn(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let r=se(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(i.length<(a.threshold??te))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await Y(O.brotliCompress)(i,{params:{[O.constants.BROTLI_PARAM_QUALITY]:h,[O.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Y(O.gzip)(i),oe(g,l);if(l.length>=i.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",V(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Le(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,_=async()=>{let s=await a();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",V(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return i();x=_().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):i()}}var ie={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function _m(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=Ma(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=qn(r.routeRules),f=new G,h=Jo(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?F(l):void 0,v=new Map,_=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Gt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,dt(c.html)),M.set(n.pattern,$e(c.html));let j=P.join(e,n.fragmentPath);if(rt(c.html,r.routerContainer||"main")&&await Bun.file(j).exists()){let A=await Bun.file(j).text();_.set(n.pattern,m?Gt(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:c}=ve(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ae({port:a,async fetch(n){return zn(n,await Ye(m??F(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let j=await h(n);if(j)return j;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),B=ie[R]||"application/octet-stream",X=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":X?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Le(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,B)=>{q[R]=o[B+1]});break}}if(!C){let p=Nt(c)?null:s.get("/404")||null;if(p){let d=v.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let N=i(c),W=Object.keys(N).length>0;return f.respond(n,N.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=_.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...V(),...N.cache?{}:{"Cache-Control":Ct}}})}}let d=No(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...V(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:X,status:I,headers:D}=await Wn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return Da(B,X,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:U}=await import("./chunk-a8c9j9cj.js"),L=new Headers({...V(),...D,"Cache-Control":"private, no-store"});for(let k of X??[])L.append("Set-Cookie",k);if(A&&!d&&rt(o,r.routerContainer||"main")){let k=dt(o);L.set("X-STX-Fragment","true"),L.set("X-STX-Runtime",$e(o)?"true":"false"),L.set("X-STX-Layout",k.layout),L.set("X-STX-Layout-Group",k.group)}return U(S(A&&!d&&rt(o,r.routerContainer||"main")?je(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:I??u.status??200,headers:L})}let w=new Headers({"Content-Type":"text/html",...V(),...N.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of X??[])w.append("Set-Cookie",S);for(let[S,U]of Object.entries(D??{}))w.set(S,U);if(w.set("Vary",V(w.get("Vary")).Vary),A&&!d&&rt(o,r.routerContainer||"main")){let S=dt(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",$e(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(je(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:w})}return new Response(o,{status:I??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
3
- export{zn,_m};
2
+ import{Ye,z,Gt}from"./chunk-eyx92t9n.js";import{T}from"./chunk-2a5g80mq.js";import{Ct,Le,U,rt,je,Da,Lo,La,qn}from"./chunk-kx09v9ya.js";import{Nt,xe,dt}from"./chunk-eceeqy74.js";import{Qo}from"./chunk-s0mf56y1.js";import{Kn}from"./chunk-kbbbpae2.js";import{$e}from"./chunk-bqtj62ys.js";import Z from"fs";import P from"path";var{serve:ae}=globalThis.Bun;import O from"zlib";import{promisify as Y}from"util";var K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function se(t){if(!t)return null;let e=re(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,V=new Map,D=0;function oe(t,e){if(e.length>J/8)return;V.set(t,e),D+=e.length;for(let[a,r]of V){if(D<=J)break;V.delete(a),D-=r.length}}async function Hn(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let r=se(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(i.length<(a.threshold??te))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=V.get(g);if(!l)l=r==="br"?await Y(O.brotliCompress)(i,{params:{[O.constants.BROTLI_PARAM_QUALITY]:h,[O.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Y(O.gzip)(i),oe(g,l);if(l.length>=i.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",U(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Le(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,_=async()=>{let s=await a();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",U(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return i();x=_().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):i()}}var ie={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Cm(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=Da(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=Kn(r.routeRules),f=new G,h=Qo(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?z(l):void 0,v=new Map,_=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Gt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,dt(c.html)),M.set(n.pattern,$e(c.html));let j=P.join(e,n.fragmentPath);if(rt(c.html,r.routerContainer||"main")&&await Bun.file(j).exists()){let A=await Bun.file(j).text();_.set(n.pattern,m?Gt(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:c}=xe(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ae({port:a,async fetch(n){return Hn(n,await Ye(m??z(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let j=await h(n);if(j)return j;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),B=ie[R]||"application/octet-stream",X=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":X?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Le(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,B)=>{q[R]=o[B+1]});break}}if(!C){let p=Nt(c)?null:s.get("/404")||null;if(p){let d=v.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let N=i(c),W=Object.keys(N).length>0;return f.respond(n,N.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=_.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...U(),...N.cache?{}:{"Cache-Control":Ct}}})}}let d=Lo(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...U(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:X,status:H,headers:F}=await qn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return La(B,X,F);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:I}=await import("./chunk-0g9cceht.js"),L=new Headers({...U(),...F,"Cache-Control":"private, no-store"});for(let k of X??[])L.append("Set-Cookie",k);if(A&&!d&&rt(o,r.routerContainer||"main")){let k=dt(o);L.set("X-STX-Fragment","true"),L.set("X-STX-Runtime",$e(o)?"true":"false"),L.set("X-STX-Layout",k.layout),L.set("X-STX-Layout-Group",k.group)}return I(S(A&&!d&&rt(o,r.routerContainer||"main")?je(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:H??u.status??200,headers:L})}let w=new Headers({"Content-Type":"text/html",...U(),...N.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of X??[])w.append("Set-Cookie",S);for(let[S,I]of Object.entries(F??{}))w.set(S,I);if(w.set("Vary",U(w.get("Vary")).Vary),A&&!d&&rt(o,r.routerContainer||"main")){let S=dt(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",$e(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(je(o,r.routerContainer||"main",!0),{status:H??u.status??200,headers:w})}return new Response(o,{status:H??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
3
+ export{Hn,Cm};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{I}from"./chunk-w50yggy3.js";import{tt,Fn}from"./chunk-0dq9svfb.js";function m(e){let t={"cache-first":{className:"CacheFirst",importFrom:"workbox-strategies"},"network-first":{className:"NetworkFirst",importFrom:"workbox-strategies"},"stale-while-revalidate":{className:"StaleWhileRevalidate",importFrom:"workbox-strategies"},"network-only":{className:"NetworkOnly",importFrom:"workbox-strategies"},"cache-only":{className:"CacheOnly",importFrom:"workbox-strategies"}};return t[e]||t["network-first"]}function g(e){return m(e).className}function d(e){let t=e.pwa;if(!t?.enabled)return"";let r=t.routes||[],n=t.cacheStorage,c=[];for(let a of r){let i=g(a.strategy),s=[];if(a.maxAgeSeconds||a.maxEntries||n?.maxEntries){let o=a.maxEntries||n?.maxEntries||100,u=a.maxAgeSeconds||(n?.maxAge?n.maxAge*24*60*60:void 0);s.push(`new ExpirationPlugin({
2
+ import{I}from"./chunk-q9tc9rdv.js";import{tt,zn}from"./chunk-55tc5w32.js";function m(e){let t={"cache-first":{className:"CacheFirst",importFrom:"workbox-strategies"},"network-first":{className:"NetworkFirst",importFrom:"workbox-strategies"},"stale-while-revalidate":{className:"StaleWhileRevalidate",importFrom:"workbox-strategies"},"network-only":{className:"NetworkOnly",importFrom:"workbox-strategies"},"cache-only":{className:"CacheOnly",importFrom:"workbox-strategies"}};return t[e]||t["network-first"]}function g(e){return m(e).className}function d(e){let t=e.pwa;if(!t?.enabled)return"";let r=t.routes||[],n=t.cacheStorage,c=[];for(let a of r){let i=g(a.strategy),s=[];if(a.maxAgeSeconds||a.maxEntries||n?.maxEntries){let o=a.maxEntries||n?.maxEntries||100,u=a.maxAgeSeconds||(n?.maxAge?n.maxAge*24*60*60:void 0);s.push(`new ExpirationPlugin({
3
3
  maxEntries: ${o},
4
4
  ${u?`maxAgeSeconds: ${u},`:""}
5
5
  purgeOnQuotaError: true,
@@ -17,7 +17,7 @@ registerRoute(
17
17
  ],`:""}
18
18
  })
19
19
  );`)}return c.join(`
20
- `)}function p(e){if(e.startsWith("*.")){let t=e.slice(2);return`({ request }) => request.destination === '${f(t)}'`}if(e.endsWith("/**"))return`({ url }) => url.pathname.startsWith('${e.slice(0,-3)}')`;if(e.endsWith("/*")){let t=e.slice(0,-2);return`({ url }) => url.pathname.startsWith('${t}') && !url.pathname.slice(${t.length+1}).includes('/')`}if(e.includes("*")&&!e.startsWith("*")){let[t,r]=e.split("*");return`({ url }) => url.pathname.startsWith('${t}') && url.pathname.endsWith('${r}')`}if(e==="/"||!e.includes("*"))return`({ url }) => url.pathname === '${e}'`;return`new RegExp('${x(e).replace(/\\\*/g,".*")}')`}function f(e){return{js:"script",mjs:"script",css:"style",html:"document",htm:"document",png:"image",jpg:"image",jpeg:"image",gif:"image",svg:"image",webp:"image",avif:"image",ico:"image",woff:"font",woff2:"font",ttf:"font",eot:"font",otf:"font"}[e.toLowerCase()]||"empty"}function h(e){return"stx-"+e.replace(/[^\w]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase().slice(0,30)+"-cache"}function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(e,t){let r=e.pwa;if(!r?.enabled)return{mode:"generate",modules:[],skipWaiting:!0,clientsClaim:!0};let n=r.serviceWorker||{},c=r.routes||[],a=[{name:"workbox-precaching",exports:["precacheAndRoute","cleanupOutdatedCaches"]},{name:"workbox-routing",exports:["registerRoute","NavigationRoute","setDefaultHandler"]}],i=new Set;for(let o of c)i.add(g(o.strategy));if(i.size>0)a.push({name:"workbox-strategies",exports:Array.from(i)});if(c.some((o)=>o.maxAgeSeconds||o.maxEntries)||r.cacheStorage)a.push({name:"workbox-expiration",exports:["ExpirationPlugin"]});if(c.some((o)=>o.strategy==="network-first"||o.strategy==="stale-while-revalidate"))a.push({name:"workbox-cacheable-response",exports:["CacheableResponsePlugin"]});if(r.backgroundSync?.enabled)a.push({name:"workbox-background-sync",exports:["BackgroundSyncPlugin","Queue"]});if(n.navigationPreload)a.push({name:"workbox-navigation-preload",exports:["enable"]});let l=t?tt(t,e):void 0;return{mode:"generate",modules:a,precacheManifest:l?.entries,skipWaiting:n.skipWaiting??!0,clientsClaim:n.clientsClaim??!0,offlineFallback:r.offline?.enabled?"/offline.html":void 0,navigationPreload:n.navigationPreload??!1,cacheVersion:n.cacheVersion||"1.0.0"}}function W(e,t){let r=e.pwa;if(!r?.enabled)return"";let n=b(e,t),c=r.serviceWorker||{},{push:a,backgroundSync:i}=r,s=t?tt(t,e):null,l=s?Fn(s):"[]",o=k(n.modules),u=d(e);return`/**
20
+ `)}function p(e){if(e.startsWith("*.")){let t=e.slice(2);return`({ request }) => request.destination === '${f(t)}'`}if(e.endsWith("/**"))return`({ url }) => url.pathname.startsWith('${e.slice(0,-3)}')`;if(e.endsWith("/*")){let t=e.slice(0,-2);return`({ url }) => url.pathname.startsWith('${t}') && !url.pathname.slice(${t.length+1}).includes('/')`}if(e.includes("*")&&!e.startsWith("*")){let[t,r]=e.split("*");return`({ url }) => url.pathname.startsWith('${t}') && url.pathname.endsWith('${r}')`}if(e==="/"||!e.includes("*"))return`({ url }) => url.pathname === '${e}'`;return`new RegExp('${x(e).replace(/\\\*/g,".*")}')`}function f(e){return{js:"script",mjs:"script",css:"style",html:"document",htm:"document",png:"image",jpg:"image",jpeg:"image",gif:"image",svg:"image",webp:"image",avif:"image",ico:"image",woff:"font",woff2:"font",ttf:"font",eot:"font",otf:"font"}[e.toLowerCase()]||"empty"}function h(e){return"stx-"+e.replace(/[^\w]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase().slice(0,30)+"-cache"}function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(e,t){let r=e.pwa;if(!r?.enabled)return{mode:"generate",modules:[],skipWaiting:!0,clientsClaim:!0};let n=r.serviceWorker||{},c=r.routes||[],a=[{name:"workbox-precaching",exports:["precacheAndRoute","cleanupOutdatedCaches"]},{name:"workbox-routing",exports:["registerRoute","NavigationRoute","setDefaultHandler"]}],i=new Set;for(let o of c)i.add(g(o.strategy));if(i.size>0)a.push({name:"workbox-strategies",exports:Array.from(i)});if(c.some((o)=>o.maxAgeSeconds||o.maxEntries)||r.cacheStorage)a.push({name:"workbox-expiration",exports:["ExpirationPlugin"]});if(c.some((o)=>o.strategy==="network-first"||o.strategy==="stale-while-revalidate"))a.push({name:"workbox-cacheable-response",exports:["CacheableResponsePlugin"]});if(r.backgroundSync?.enabled)a.push({name:"workbox-background-sync",exports:["BackgroundSyncPlugin","Queue"]});if(n.navigationPreload)a.push({name:"workbox-navigation-preload",exports:["enable"]});let l=t?tt(t,e):void 0;return{mode:"generate",modules:a,precacheManifest:l?.entries,skipWaiting:n.skipWaiting??!0,clientsClaim:n.clientsClaim??!0,offlineFallback:r.offline?.enabled?"/offline.html":void 0,navigationPreload:n.navigationPreload??!1,cacheVersion:n.cacheVersion||"1.0.0"}}function W(e,t){let r=e.pwa;if(!r?.enabled)return"";let n=b(e,t),c=r.serviceWorker||{},{push:a,backgroundSync:i}=r,s=t?tt(t,e):null,l=s?zn(s):"[]",o=k(n.modules),u=d(e);return`/**
21
21
  * Service Worker - Generated by stx with Workbox
22
22
  * Cache Version: ${n.cacheVersion}
23
23
  *
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Qr}from"./chunk-0d7ypcjb.js";import{existsSync as m,statSync as x}from"fs";import s from"path";var g=new Map;function M(r){let n=s.extname(r);if(n===".tsx")return"tsx";if(n===".jsx")return"jsx";if(n===".ts"||n===".mts"||n===".cts")return"ts";return"js"}async function j(r,n){let l=Object.entries(n).map(([e,t])=>[s.resolve(r,e),s.resolve(r,t)]),d=l.map(([e,t])=>{try{return`${e}\x00${t}\x00${x(t).mtimeMs}`}catch{return`${e}\x00${t}\x00-`}}).join(`
3
- `),f=`${r}\x00${JSON.stringify(n)}`,o=g.get(f);if(o&&o.signature===d)return o.standIns;let a=new Map;for(let[e,t]of l){let c=s.relative(r,e);if(!m(e))throw Error(`webModules: ${c} does not exist`);if(!m(t))throw Error(`webModules: ${s.relative(r,t)}, the stand-in for ${c}, does not exist`);if(e===t)throw Error(`webModules: ${c} stands in for itself`);let p=await Bun.file(t).text(),u=new Bun.Transpiler({loader:M(t),target:"browser"});if(s.dirname(t)!==s.dirname(e)){let i=u.scanImports(p).find((h)=>/^\.\.?\//.test(h.path));if(i)throw Error(`webModules: ${s.relative(r,t)} imports ${i.path}, which would resolve from ${s.relative(r,s.dirname(e))||"."}; a stand-in imports relatively only from the directory of the module it replaces`)}let w=u.transformSync(p);for(let i of Qr(e))a.set(i,w)}return g.set(f,{signature:d,standIns:a}),a}export{j as loadWebModules};
2
+ import{ns}from"./chunk-pjj54ddk.js";import{existsSync as m,statSync as x}from"fs";import s from"path";var g=new Map;function M(r){let n=s.extname(r);if(n===".tsx")return"tsx";if(n===".jsx")return"jsx";if(n===".ts"||n===".mts"||n===".cts")return"ts";return"js"}async function j(r,n){let l=Object.entries(n).map(([e,t])=>[s.resolve(r,e),s.resolve(r,t)]),d=l.map(([e,t])=>{try{return`${e}\x00${t}\x00${x(t).mtimeMs}`}catch{return`${e}\x00${t}\x00-`}}).join(`
3
+ `),f=`${r}\x00${JSON.stringify(n)}`,o=g.get(f);if(o&&o.signature===d)return o.standIns;let a=new Map;for(let[e,t]of l){let c=s.relative(r,e);if(!m(e))throw Error(`webModules: ${c} does not exist`);if(!m(t))throw Error(`webModules: ${s.relative(r,t)}, the stand-in for ${c}, does not exist`);if(e===t)throw Error(`webModules: ${c} stands in for itself`);let p=await Bun.file(t).text(),u=new Bun.Transpiler({loader:M(t),target:"browser"});if(s.dirname(t)!==s.dirname(e)){let i=u.scanImports(p).find((h)=>/^\.\.?\//.test(h.path));if(i)throw Error(`webModules: ${s.relative(r,t)} imports ${i.path}, which would resolve from ${s.relative(r,s.dirname(e))||"."}; a stand-in imports relatively only from the directory of the module it replaces`)}let w=u.transformSync(p);for(let i of ns(e))a.set(i,w)}return g.set(f,{signature:d,standIns:a}),a}export{j as loadWebModules};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- var i=/<!--[\s\S]*?-->|<(script|style|textarea|title)\b[^>]*>[\s\S]*?<\/\1\s*>|<\/(head|body)\s*>/gi;function o(e,r,t){if(!e.includes(`</${r}`)&&!e.includes(`</${r.toUpperCase()}`))return-1;let n=-1;i.lastIndex=0;for(let s=i.exec(e);s;s=i.exec(e)){if(s[2]?.toLowerCase()!==r)continue;if(n=s.index,t==="first")break}return i.lastIndex=0,n}function D(e){return o(e,"head","first")}function c(e){return o(e,"body","last")}function f(e,r,t=`
3
- `){let n=D(e);if(n===-1)return e;return`${e.slice(0,n)}${r}${t}${e.slice(n)}`}function sa(e,r,t=`
2
+ var i=/<!--[\s\S]*?-->|<(script|style|textarea|title)\b[^>]*>[\s\S]*?<\/\1\s*>|<\/(head|body)\s*>/gi;function o(e,r,t){if(!e.includes(`</${r}`)&&!e.includes(`</${r.toUpperCase()}`))return-1;let n=-1;i.lastIndex=0;for(let s=i.exec(e);s;s=i.exec(e)){if(s[2]?.toLowerCase()!==r)continue;if(n=s.index,t==="first")break}return i.lastIndex=0,n}function L(e){return o(e,"head","first")}function c(e){return o(e,"body","last")}function f(e,r,t=`
3
+ `){let n=L(e);if(n===-1)return e;return`${e.slice(0,n)}${r}${t}${e.slice(n)}`}function oa(e,r,t=`
4
4
  `){let n=c(e);if(n===-1)return`${e}
5
5
  ${r}`;return`${e.slice(0,n)}${r}${t}${e.slice(n)}`}
6
- export{D,c,f,sa};
6
+ export{L,c,f,oa};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ae,lo,qg,Ry,Kg,Ay,An,g,Y,ae,Pn,Oe,Gg,Ui,Xg,Py,P,Wi,Jg,Iy,N,Oy}from"./chunk-gz9pknbw.js";import"./chunk-s93yh7ed.js";import"./chunk-eyx92t9n.js";import"./chunk-3dqfjpz4.js";import"./chunk-vk2jy6mn.js";import"./chunk-9n5h4sqc.js";import"./chunk-2a5g80mq.js";import"./chunk-mgh5rst1.js";export{Jg as applyFilters,Ay as clearCustomFilters,Gg as clientLoopScopes,lo as defaultFilters,Pn as escapeAttributeValue,g as escapeHtml,Y as escapeHtmlValue,ae as escapeInterpolatedHtmlValue,N as evaluateExpression,Ae as findMustacheEnd,Kg as getAllFilters,Xg as interpolateScriptAttributes,Ui as interpolateScriptExpressions,Py as interpolateScriptsInTemplate,P as processExpressions,Wi as processExpressionsChunked,qg as registerFilter,Ry as registerFilters,An as replaceInterpolations,Iy as resetRejectedExpressionWarnings,Oy as unescapeHtml,Oe as usesSignalsInScript};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ru,Sm}from"./chunk-ytjn0gq2.js";export{ru as captureScreenshot,Sm as captureScreenshots};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ye,On,uo,Ki,z,Gt}from"./chunk-eyx92t9n.js";export{On as currentRuntimeConfig,Gt as injectRuntimeConfig,z as resolveRuntimeConfig,Ki as useRuntimeConfig,uo as useServerRuntimeConfig,Ye as withRuntimeConfig};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- function c(i){if(!i.startsWith("/")||/[?#\\]/.test(i))throw Error(`Invalid route rule pattern: ${i}`);let t=i==="/"?[]:i.slice(1).split("/");if(t.some((r,e)=>!r||r.includes("*")&&r!=="*"&&r!=="**"||r==="**"&&e!==t.length-1||r.startsWith(":")&&!/^:[\w]+$/.test(r)))throw Error(`Unsupported route rule pattern: ${i}`);return t}function Mo(i){for(let[t,r]of Object.entries(i)){if(c(t),!r||typeof r!=="object"||Object.keys(r).some((e)=>e!=="rendering"&&e!=="cache"))throw Error(`Unsupported route rule for ${t}`);if(r.rendering!==void 0&&r.rendering!=="prerender"&&r.rendering!=="dynamic")throw Error(`Unsupported rendering mode for ${t}`);if(r.cache!==void 0&&r.cache!==!1){let e=r.cache;if(!e||e.public!==!0||Object.keys(e).some((n)=>!["public","maxAge","swr"].includes(n))||!Number.isFinite(e.maxAge)||e.maxAge<=0||e.swr!==void 0&&(!Number.isFinite(e.swr)||e.swr<0))throw Error(`Route cache for ${t} requires public: true, maxAge > 0 and swr >= 0`);if(r.rendering==="prerender")throw Error(`Prerendered route ${t} cannot revalidate; use dynamic rendering with cache`)}}}function qn(i={}){Mo(i);let t=(e)=>e==="**"?0:e==="*"?1:e.startsWith(":")?2:3,r=Object.entries(i).map(([e,n])=>({pattern:e,parts:c(e),rule:n}));return r.sort((e,n)=>{for(let o=0;o<Math.max(e.parts.length,n.parts.length);o++){let s=(n.parts[o]===void 0?4:t(n.parts[o]))-(e.parts[o]===void 0?4:t(e.parts[o]));if(s)return s}return e.pattern.localeCompare(n.pattern)}),(e)=>{let n=e==="/"?[]:e.replace(/\/$/,"").slice(1).split("/");return r.find(({parts:o})=>o.every((s,u)=>s==="**"||n[u]!==void 0&&(s==="*"||s.startsWith(":")||s===n[u]))&&(o.at(-1)==="**"||o.length===n.length))?.rule??{}}}
3
- export{Mo,qn};
2
+ function c(i){if(!i.startsWith("/")||/[?#\\]/.test(i))throw Error(`Invalid route rule pattern: ${i}`);let t=i==="/"?[]:i.slice(1).split("/");if(t.some((r,e)=>!r||r.includes("*")&&r!=="*"&&r!=="**"||r==="**"&&e!==t.length-1||r.startsWith(":")&&!/^:[\w]+$/.test(r)))throw Error(`Unsupported route rule pattern: ${i}`);return t}function jo(i){for(let[t,r]of Object.entries(i)){if(c(t),!r||typeof r!=="object"||Object.keys(r).some((e)=>e!=="rendering"&&e!=="cache"))throw Error(`Unsupported route rule for ${t}`);if(r.rendering!==void 0&&r.rendering!=="prerender"&&r.rendering!=="dynamic")throw Error(`Unsupported rendering mode for ${t}`);if(r.cache!==void 0&&r.cache!==!1){let e=r.cache;if(!e||e.public!==!0||Object.keys(e).some((n)=>!["public","maxAge","swr"].includes(n))||!Number.isFinite(e.maxAge)||e.maxAge<=0||e.swr!==void 0&&(!Number.isFinite(e.swr)||e.swr<0))throw Error(`Route cache for ${t} requires public: true, maxAge > 0 and swr >= 0`);if(r.rendering==="prerender")throw Error(`Prerendered route ${t} cannot revalidate; use dynamic rendering with cache`)}}}function Kn(i={}){jo(i);let t=(e)=>e==="**"?0:e==="*"?1:e.startsWith(":")?2:3,r=Object.entries(i).map(([e,n])=>({pattern:e,parts:c(e),rule:n}));return r.sort((e,n)=>{for(let o=0;o<Math.max(e.parts.length,n.parts.length);o++){let s=(n.parts[o]===void 0?4:t(n.parts[o]))-(e.parts[o]===void 0?4:t(e.parts[o]));if(s)return s}return e.pattern.localeCompare(n.pattern)}),(e)=>{let n=e==="/"?[]:e.replace(/\/$/,"").slice(1).split("/");return r.find(({parts:o})=>o.every((s,u)=>s==="**"||n[u]!==void 0&&(s==="*"||s.startsWith(":")||s===n[u]))&&(o.at(-1)==="**"||o.length===n.length))?.rule??{}}}
3
+ export{jo,Kn};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{wg,bi}from"./chunk-q0y8gv18.js";export{wg as looksLikeGlob,bi as resolveStxTargets};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-s29hp1qw.js";import"./chunk-xw291tn7.js";import"./chunk-11fxbd71.js";import"./chunk-hxhmhw23.js";import"./chunk-kvxdyg7e.js";import"./chunk-000mwmfq.js";import"./chunk-6t04tqvh.js";import"./chunk-fce8wj3t.js";import"./chunk-6zq3eh7d.js";import"./chunk-7s3j8pqq.js";import{l}from"./chunk-z55rpt3s.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
2
+ import"./chunk-2a5g80mq.js";import"./chunk-3dqfjpz4.js";import"./chunk-mgh5rst1.js";import"./chunk-vk2jy6mn.js";import"./chunk-9n5h4sqc.js";import"./chunk-gz9pknbw.js";import"./chunk-eyx92t9n.js";import"./chunk-s93yh7ed.js";import"./chunk-q0y8gv18.js";import"./chunk-58qzyyyv.js";import{l}from"./chunk-dzqfv801.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
3
3
  `)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import y from"fs";import R from"path";var S="_stx";function F(e){return Bun.hash(e).toString(16).slice(0,8)}function k(e){let t=[],n=(i)=>{for(let s of y.readdirSync(i,{withFileTypes:!0})){let r=R.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(y.existsSync(e))n(e);return t}var z=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-runtime src="${e}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-router src="${e}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(e)=>`<link data-css="generated" rel="stylesheet" href="${e}">`}];function I(e,t=`/${S}`){let n=[],i=new Set,s=0,r=e;for(let o of z)r=r.replace(o.pattern,(g,u,c)=>{if(/\b(?:src|href)\s*=/.test(u)||!c.trim())return g;let a=`${o.prefix}.${F(c)}.${o.extension}`;if(!i.has(a))i.add(a),n.push({filename:a,contents:c,contentType:o.contentType});return s+=c.length,o.replace(`${t}/${a}`)});return{html:r,assets:n,bytesInlined:s}}function xc(e){let t={pages:0,assets:0,bytesInlined:0},n=R.join(e,S),i=new Set;for(let s of k(e)){let r=y.readFileSync(s,"utf8"),{html:o,assets:g,bytesInlined:u}=I(r);if(o===r)continue;for(let c of g){if(i.has(c.filename))continue;i.add(c.filename),y.mkdirSync(n,{recursive:!0}),y.writeFileSync(R.join(n,c.filename),c.contents),t.assets++}y.writeFileSync(s,o),t.bytesInlined+=u,t.pages++}return t}import h from"fs";import T from"path";var L=1024,N=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,_=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function B(e){return Bun.hash(e).toString(16).slice(0,8)}function C(e){let t=[],n=(i)=>{for(let s of h.readdirSync(i,{withFileTypes:!0})){let r=T.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(h.existsSync(e))n(e);return t}function O(e,t){let n=e.match(new RegExp(`\\b${t}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!n)return;return n[2]??n[3]??n[4]??""}function H(e,t,n){if(n.length<L)return!1;if(/\b(?:src|href)\s*=/i.test(t))return!1;if(e.toLowerCase()==="script"){if(!_.has((O(t,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function D(e){let t=[];for(let n of e.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))t.push([n.index,n.index+n[0].length]);return t}function Sc(e){let t={pages:0,assets:0,bytesInlined:0},n=C(e);if(n.length<2)return t;let i=new Map,s=new Map;for(let a of n){let f=h.readFileSync(a,"utf8");i.set(a,f);let M=D(f);for(let d of f.matchAll(N)){let[x,p,l,m]=d;if(!H(p,l,m))continue;if(M.some(([j,A])=>d.index>=j&&d.index<A))continue;let w=`${p.toLowerCase()}\x00${m}`,b=s.get(w);if(b)b.push({file:a,whole:x,tag:p,attrs:l,body:m});else s.set(w,[{file:a,whole:x,tag:p,attrs:l,body:m}])}}let r=[...s.values()].filter((a)=>new Set(a.map((f)=>f.file)).size>1);if(r.length===0)return t;let o=T.join(e,S),g=new Map(i),u=new Map,c=[];for(let a of r){let{tag:f,body:M}=a[0],d=f.toLowerCase()==="script",x=`${d?"chunk":"style"}.${B(M)}.${d?"js":"css"}`;c.push({filename:x,contents:M,contentType:d?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let p=`/${S}/${x}`;for(let l of a){let m=d?`<script${l.attrs} src="${p}"></script>`:`<link${l.attrs} rel="stylesheet" href="${p}">`,w=g.get(l.file),b=w.replace(l.whole,()=>m);if(b===w)continue;g.set(l.file,b),u.set(l.file,(u.get(l.file)??0)+l.body.length)}}h.mkdirSync(o,{recursive:!0});for(let a of c)h.writeFileSync(T.join(o,a.filename),a.contents),t.assets++;for(let[a,f]of g){if(f===i.get(a))continue;h.writeFileSync(a,f),t.pages++,t.bytesInlined+=u.get(a)??0}return t}import E from"fs";import v from"path";var K="layout-types.d.ts";function P(e){let t=[],n=(i,s)=>{let r;try{r=E.readdirSync(i,{withFileTypes:!0})}catch{return}for(let o of r){if(o.name.startsWith("."))continue;let g=v.join(i,o.name);if(o.isDirectory())n(g,s?`${s}/${o.name}`:o.name);else if(o.isFile()&&o.name.endsWith(".stx")&&o.name!=="_layout.stx"){let u=o.name.slice(0,-4);t.push(s?`${s}/${u}`:u)}}};return n(e,""),t.sort()}function W(e){let t=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(e.length===0)return t.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),t.join(`
2
+ import y from"fs";import R from"path";var S="_stx";function F(e){return Bun.hash(e).toString(16).slice(0,8)}function k(e){let t=[],n=(i)=>{for(let s of y.readdirSync(i,{withFileTypes:!0})){let r=R.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(y.existsSync(e))n(e);return t}var z=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-runtime src="${e}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-router src="${e}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(e)=>`<link data-css="generated" rel="stylesheet" href="${e}">`}];function I(e,t=`/${S}`){let n=[],i=new Set,s=0,r=e;for(let o of z)r=r.replace(o.pattern,(g,u,c)=>{if(/\b(?:src|href)\s*=/.test(u)||!c.trim())return g;let a=`${o.prefix}.${F(c)}.${o.extension}`;if(!i.has(a))i.add(a),n.push({filename:a,contents:c,contentType:o.contentType});return s+=c.length,o.replace(`${t}/${a}`)});return{html:r,assets:n,bytesInlined:s}}function Sc(e){let t={pages:0,assets:0,bytesInlined:0},n=R.join(e,S),i=new Set;for(let s of k(e)){let r=y.readFileSync(s,"utf8"),{html:o,assets:g,bytesInlined:u}=I(r);if(o===r)continue;for(let c of g){if(i.has(c.filename))continue;i.add(c.filename),y.mkdirSync(n,{recursive:!0}),y.writeFileSync(R.join(n,c.filename),c.contents),t.assets++}y.writeFileSync(s,o),t.bytesInlined+=u,t.pages++}return t}import h from"fs";import T from"path";var L=1024,N=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,_=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function B(e){return Bun.hash(e).toString(16).slice(0,8)}function C(e){let t=[],n=(i)=>{for(let s of h.readdirSync(i,{withFileTypes:!0})){let r=T.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(h.existsSync(e))n(e);return t}function O(e,t){let n=e.match(new RegExp(`\\b${t}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!n)return;return n[2]??n[3]??n[4]??""}function H(e,t,n){if(n.length<L)return!1;if(/\b(?:src|href)\s*=/i.test(t))return!1;if(e.toLowerCase()==="script"){if(!_.has((O(t,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function D(e){let t=[];for(let n of e.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))t.push([n.index,n.index+n[0].length]);return t}function kc(e){let t={pages:0,assets:0,bytesInlined:0},n=C(e);if(n.length<2)return t;let i=new Map,s=new Map;for(let a of n){let f=h.readFileSync(a,"utf8");i.set(a,f);let M=D(f);for(let d of f.matchAll(N)){let[x,p,l,m]=d;if(!H(p,l,m))continue;if(M.some(([j,A])=>d.index>=j&&d.index<A))continue;let w=`${p.toLowerCase()}\x00${m}`,b=s.get(w);if(b)b.push({file:a,whole:x,tag:p,attrs:l,body:m});else s.set(w,[{file:a,whole:x,tag:p,attrs:l,body:m}])}}let r=[...s.values()].filter((a)=>new Set(a.map((f)=>f.file)).size>1);if(r.length===0)return t;let o=T.join(e,S),g=new Map(i),u=new Map,c=[];for(let a of r){let{tag:f,body:M}=a[0],d=f.toLowerCase()==="script",x=`${d?"chunk":"style"}.${B(M)}.${d?"js":"css"}`;c.push({filename:x,contents:M,contentType:d?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let p=`/${S}/${x}`;for(let l of a){let m=d?`<script${l.attrs} src="${p}"></script>`:`<link${l.attrs} rel="stylesheet" href="${p}">`,w=g.get(l.file),b=w.replace(l.whole,()=>m);if(b===w)continue;g.set(l.file,b),u.set(l.file,(u.get(l.file)??0)+l.body.length)}}h.mkdirSync(o,{recursive:!0});for(let a of c)h.writeFileSync(T.join(o,a.filename),a.contents),t.assets++;for(let[a,f]of g){if(f===i.get(a))continue;h.writeFileSync(a,f),t.pages++,t.bytesInlined+=u.get(a)??0}return t}import E from"fs";import v from"path";var K="layout-types.d.ts";function P(e){let t=[],n=(i,s)=>{let r;try{r=E.readdirSync(i,{withFileTypes:!0})}catch{return}for(let o of r){if(o.name.startsWith("."))continue;let g=v.join(i,o.name);if(o.isDirectory())n(g,s?`${s}/${o.name}`:o.name);else if(o.isFile()&&o.name.endsWith(".stx")&&o.name!=="_layout.stx"){let u=o.name.slice(0,-4);t.push(s?`${s}/${u}`:u)}}};return n(e,""),t.sort()}function W(e){let t=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(e.length===0)return t.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),t.join(`
3
3
  `);return t.push("declare module '@stacksjs/stx' {"," interface KnownLayouts {",...e.map((n)=>` '${n}': true`)," }","}","","export {}",""),t.join(`
4
- `)}function kc(e,t){if(!e)return[];let n=v.isAbsolute(e)?e:v.resolve(process.cwd(),e),i=P(n),s=W(i),r=v.join(t,K);try{if(E.existsSync(r)&&E.readFileSync(r,"utf8")===s)return i;E.mkdirSync(t,{recursive:!0}),E.writeFileSync(r,s)}catch{}return i}
5
- export{xc,Sc,kc};
4
+ `)}function _c(e,t){if(!e)return[];let n=v.isAbsolute(e)?e:v.resolve(process.cwd(),e),i=P(n),s=W(i),r=v.join(t,K);try{if(E.existsSync(r)&&E.readFileSync(r,"utf8")===s)return i;E.mkdirSync(t,{recursive:!0}),E.writeFileSync(r,s)}catch{}return i}
5
+ export{Sc,kc,_c};
@@ -298,5 +298,5 @@ catch (error) {
298
298
  init();
299
299
  }
300
300
  })();
301
- </script>`}var rm={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"},sm={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"},om={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"},im={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"},wo=[rm,sm,om,im];function Uy(t){return[...t,...wo]}
302
- export{rm,sm,om,im,wo,Uy};
301
+ </script>`}var sm={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"},om={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"},im={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"},am={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"},So=[sm,om,im,am];function Wy(t){return[...t,...So]}
302
+ export{sm,om,im,am,So,Wy};