@stacksjs/stx 0.2.405 → 0.2.407

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 (212) hide show
  1. package/dist/app-service-worker.d.ts +120 -0
  2. package/dist/chunk-00g9x6w2.js +2 -0
  3. package/dist/chunk-02g67164.js +2 -0
  4. package/dist/chunk-04tgatyy.js +2 -0
  5. package/dist/{chunk-et9knn3s.js → chunk-0a315nbf.js} +3 -3
  6. package/dist/{chunk-zwb8wv5p.js → chunk-0akydm2d.js} +1 -1
  7. package/dist/{chunk-tfy07tmv.js → chunk-0btmm4m2.js} +1 -1
  8. package/dist/{chunk-g0w8dyat.js → chunk-0c2h69k2.js} +1 -1
  9. package/dist/{chunk-aa4ss5pb.js → chunk-0pkk226n.js} +1 -1
  10. package/dist/{chunk-6de3hczw.js → chunk-0we9nw1d.js} +1 -1
  11. package/dist/chunk-178n9c40.js +2 -0
  12. package/dist/{chunk-2r399td7.js → chunk-1fs9jvpb.js} +1 -1
  13. package/dist/chunk-1hc58sh2.js +2 -0
  14. package/dist/chunk-1q4jrkhw.js +2 -0
  15. package/dist/chunk-1qembpzh.js +2 -0
  16. package/dist/chunk-1qq26zt0.js +2 -0
  17. package/dist/{chunk-7q06md6v.js → chunk-1te8k8gp.js} +1 -1
  18. package/dist/{chunk-jw6s8rkk.js → chunk-1ws3xcea.js} +2 -2
  19. package/dist/{chunk-z9a0ft6h.js → chunk-213jwgpx.js} +1 -1
  20. package/dist/{chunk-c7n0gsxa.js → chunk-26r88x1t.js} +2 -2
  21. package/dist/{chunk-k4x5we49.js → chunk-27fgag95.js} +2 -2
  22. package/dist/chunk-2c6t60vw.js +2 -0
  23. package/dist/{chunk-x7qyx7vn.js → chunk-2fw05hs2.js} +1 -1
  24. package/dist/{chunk-0seyntda.js → chunk-38wvkv3s.js} +1 -1
  25. package/dist/chunk-3w6z6tw9.js +2 -0
  26. package/dist/chunk-3za7m29m.js +2 -0
  27. package/dist/{chunk-ypw4egcv.js → chunk-4m7ajama.js} +1 -1
  28. package/dist/{chunk-1309n807.js → chunk-4zcbj36p.js} +2 -2
  29. package/dist/{chunk-yh9apppb.js → chunk-50pszj17.js} +1 -1
  30. package/dist/{chunk-59pakqdv.js → chunk-563shnkz.js} +2 -2
  31. package/dist/{chunk-zcrb5hgk.js → chunk-5r4s9s38.js} +2 -2
  32. package/dist/chunk-603x5gb2.js +2 -0
  33. package/dist/{chunk-afwbqeb2.js → chunk-6jrczd12.js} +2 -2
  34. package/dist/{chunk-abs56gdt.js → chunk-6kd5jjwc.js} +1 -1
  35. package/dist/{chunk-ewxbx67c.js → chunk-6kdrncsx.js} +1 -1
  36. package/dist/{chunk-pkspqh0m.js → chunk-72rwcbp6.js} +1 -1
  37. package/dist/{chunk-4m4n1sfc.js → chunk-76w34xne.js} +1 -1
  38. package/dist/chunk-7ypm243n.js +2 -0
  39. package/dist/{chunk-kdabbmbf.js → chunk-8036mdat.js} +2 -2
  40. package/dist/{chunk-46zx4pt8.js → chunk-82pd4b5w.js} +1 -1
  41. package/dist/chunk-8ds7rrdc.js +2 -0
  42. package/dist/chunk-8w2mqdnv.js +2 -0
  43. package/dist/chunk-8x05b790.js +2 -0
  44. package/dist/{chunk-pqhpcxsd.js → chunk-90b2vt2n.js} +1 -1
  45. package/dist/{chunk-g6c4f67z.js → chunk-920779jx.js} +2 -2
  46. package/dist/chunk-934eeghd.js +2 -0
  47. package/dist/{chunk-245ft0zp.js → chunk-9e8t0twa.js} +1 -1
  48. package/dist/{chunk-wpsx5avz.js → chunk-9fqp72ze.js} +1 -1
  49. package/dist/chunk-9wze2290.js +2 -0
  50. package/dist/{chunk-dj658wyq.js → chunk-9xew0kgf.js} +1 -1
  51. package/dist/{chunk-ca57sg6v.js → chunk-akwd34xt.js} +2 -2
  52. package/dist/{chunk-rqr735w8.js → chunk-anydpa34.js} +1 -1
  53. package/dist/{chunk-ffdxdgep.js → chunk-aq1xq0r4.js} +2 -2
  54. package/dist/{chunk-2xr974bj.js → chunk-avaywwsc.js} +2 -2
  55. package/dist/{chunk-36rnwhn2.js → chunk-bbt3tp6f.js} +1 -1
  56. package/dist/{chunk-n4197kjq.js → chunk-bjar18jd.js} +1 -1
  57. package/dist/{chunk-twg0y6ga.js → chunk-bjcsc6wx.js} +1 -1
  58. package/dist/{chunk-akzmq0jr.js → chunk-bn1edb1y.js} +2 -2
  59. package/dist/{chunk-503wfstj.js → chunk-btd7ds3x.js} +1 -1
  60. package/dist/{chunk-8mm86z5w.js → chunk-bwsxym3d.js} +1 -1
  61. package/dist/{chunk-c1f1vtjt.js → chunk-cj3adc77.js} +1 -1
  62. package/dist/{chunk-w9b94q64.js → chunk-cqchpe34.js} +396 -165
  63. package/dist/chunk-ct1jwd4r.js +2 -0
  64. package/dist/{chunk-c8kfqw8x.js → chunk-ej16bgrr.js} +2 -2
  65. package/dist/{chunk-s68jqmva.js → chunk-esq1k7fj.js} +2 -2
  66. package/dist/{chunk-fnabq4w1.js → chunk-f6s7d1jq.js} +2 -2
  67. package/dist/{chunk-bds4s9d8.js → chunk-fcnrgxck.js} +1 -1
  68. package/dist/chunk-fphs5g19.js +2 -0
  69. package/dist/{chunk-stdkw5st.js → chunk-fpwzacpm.js} +1 -1
  70. package/dist/chunk-gbmeh7jg.js +3 -0
  71. package/dist/{chunk-81zw5vw5.js → chunk-gc06g35w.js} +1 -1
  72. package/dist/{chunk-a389vxsn.js → chunk-gcvj5zdy.js} +3 -3
  73. package/dist/{chunk-yt9mq4m7.js → chunk-gengvwb7.js} +3 -3
  74. package/dist/{chunk-78rd6wxv.js → chunk-gjrgr367.js} +2 -2
  75. package/dist/{chunk-h8ej17sj.js → chunk-gna6dc48.js} +169 -169
  76. package/dist/{chunk-pyyccs6a.js → chunk-gvbf1mhs.js} +1 -1
  77. package/dist/chunk-h1r17awz.js +2 -0
  78. package/dist/chunk-ha46rg9g.js +2 -0
  79. package/dist/chunk-hcvjstmr.js +2 -0
  80. package/dist/{chunk-a01sf1sc.js → chunk-hdysywd8.js} +1 -1
  81. package/dist/{chunk-55g4qm7m.js → chunk-hx998w7n.js} +1 -1
  82. package/dist/chunk-j3r97xs5.js +2 -0
  83. package/dist/chunk-j5qeaprt.js +2 -0
  84. package/dist/chunk-jxvmf02k.js +2 -0
  85. package/dist/{chunk-8t3h7fsk.js → chunk-k80sn8d1.js} +1 -1
  86. package/dist/chunk-kajym1cx.js +2 -0
  87. package/dist/{chunk-6efr4j9h.js → chunk-kbwhs5df.js} +2 -2
  88. package/dist/{chunk-4n6ekt06.js → chunk-kmsyvaex.js} +1 -1
  89. package/dist/{chunk-4tsjysng.js → chunk-kvmx7dnb.js} +1 -1
  90. package/dist/{chunk-y8hp05y6.js → chunk-m072c38p.js} +2 -2
  91. package/dist/{chunk-jpnja3jy.js → chunk-mgrckqww.js} +1 -1
  92. package/dist/{chunk-971yqxa2.js → chunk-mq5ewmz6.js} +1 -1
  93. package/dist/{chunk-sptvg80e.js → chunk-mrahwn5v.js} +1 -1
  94. package/dist/{chunk-vyq86x5c.js → chunk-n2swas11.js} +1 -1
  95. package/dist/{chunk-rwwt24e3.js → chunk-n9cqrw9j.js} +1 -1
  96. package/dist/{chunk-3sea73fx.js → chunk-naw4jt7j.js} +1 -1
  97. package/dist/{chunk-1n2ng8nx.js → chunk-ny67c03k.js} +1 -1
  98. package/dist/chunk-p0m4ty6g.js +2 -0
  99. package/dist/chunk-p32x2apf.js +2 -0
  100. package/dist/{chunk-8bg1qmhg.js → chunk-p4zrvt5f.js} +1 -1
  101. package/dist/{chunk-0tnsyynz.js → chunk-p5wp0ce6.js} +2 -2
  102. package/dist/{chunk-mywrb5fy.js → chunk-pcxp4r9n.js} +1 -1
  103. package/dist/{chunk-5fwgczvh.js → chunk-pdfjy3at.js} +2 -2
  104. package/dist/chunk-pjrn29gg.js +2 -0
  105. package/dist/chunk-q738pwv6.js +2 -0
  106. package/dist/{chunk-w6n5c479.js → chunk-qmmp5kb5.js} +1 -1
  107. package/dist/{chunk-015p3jq5.js → chunk-qn5srnj3.js} +1 -1
  108. package/dist/{chunk-1vrk5y92.js → chunk-qvnbnsv9.js} +1 -1
  109. package/dist/{chunk-z8zmp74b.js → chunk-rt3cx932.js} +1025 -58
  110. package/dist/{chunk-7ba7x6jt.js → chunk-rz9f3zqz.js} +2 -2
  111. package/dist/{chunk-dxjtszaa.js → chunk-s8jd13nb.js} +1 -1
  112. package/dist/{chunk-qem2tw9r.js → chunk-s9za1vvd.js} +1 -1
  113. package/dist/{chunk-r909bddf.js → chunk-spxsw4mp.js} +1 -1
  114. package/dist/chunk-ssn5k77d.js +2 -0
  115. package/dist/chunk-sy9pfe3h.js +2 -0
  116. package/dist/{chunk-0nhpymyy.js → chunk-t1htzg9e.js} +1 -1
  117. package/dist/{chunk-rkzfwgr8.js → chunk-t1tdjjht.js} +1 -1
  118. package/dist/{chunk-1x6c4ys1.js → chunk-t5ja7qkn.js} +131 -34
  119. package/dist/{chunk-rx0cntdm.js → chunk-td08rnk3.js} +2 -2
  120. package/dist/chunk-tgadbsd4.js +2 -0
  121. package/dist/{chunk-xakdgn9h.js → chunk-tgrpp58r.js} +1 -1
  122. package/dist/{chunk-pgeh4g3a.js → chunk-tkyrk66a.js} +1 -1
  123. package/dist/chunk-tpcmn119.js +2 -0
  124. package/dist/{chunk-0n054h7w.js → chunk-v3nwkveg.js} +1 -1
  125. package/dist/{chunk-83tefmh1.js → chunk-vsbmc9kt.js} +1 -1
  126. package/dist/{chunk-qcpnfw0k.js → chunk-vx86cf4r.js} +1 -1
  127. package/dist/{chunk-n9cgqg0x.js → chunk-w6hqh4z5.js} +2 -2
  128. package/dist/{chunk-nqpd84vs.js → chunk-w9n12yzf.js} +3 -3
  129. package/dist/chunk-wkanrfb3.js +2 -0
  130. package/dist/chunk-wvegegmb.js +2 -0
  131. package/dist/{chunk-seqmzr8k.js → chunk-xq1acw1r.js} +1 -1
  132. package/dist/{chunk-vtjegbgy.js → chunk-xsng1mtq.js} +1 -1
  133. package/dist/chunk-xv9bhvye.js +12 -0
  134. package/dist/{chunk-a8ypw36d.js → chunk-z52f4zcy.js} +2 -2
  135. package/dist/{chunk-vtmhh3dp.js → chunk-z5rwnnk1.js} +2 -2
  136. package/dist/{chunk-m8bdy2wt.js → chunk-zcz9rs6p.js} +1 -1
  137. package/dist/{chunk-1phxzej9.js → chunk-zpcnbdhn.js} +2 -2
  138. package/dist/{chunk-wxkn47vk.js → chunk-zq4ssxj9.js} +1 -1
  139. package/dist/cli.js +14 -14
  140. package/dist/composables/index.d.ts +10 -1
  141. package/dist/composables/index.js +6 -1
  142. package/dist/composables/use-cached-query.d.ts +18 -0
  143. package/dist/composables/use-cached-query.js +27 -0
  144. package/dist/composables/use-offline.d.ts +18 -0
  145. package/dist/composables/use-offline.js +17 -0
  146. package/dist/composables/use-outbox.d.ts +19 -27
  147. package/dist/composables/use-outbox.js +100 -16
  148. package/dist/composables/use-query.d.ts +2 -0
  149. package/dist/composables/use-storage.d.ts +7 -3
  150. package/dist/composables/use-storage.js +22 -13
  151. package/dist/craft-entry.js +1 -1
  152. package/dist/craft.js +1 -1
  153. package/dist/database.js +1 -1
  154. package/dist/index.d.ts +10 -0
  155. package/dist/index.js +5 -0
  156. package/dist/offline/app-service-worker.d.ts +61 -13
  157. package/dist/offline/app-service-worker.js +398 -58
  158. package/dist/offline/kept-store.d.ts +67 -0
  159. package/dist/offline/kept-store.js +252 -0
  160. package/dist/offline/query-cache.d.ts +137 -0
  161. package/dist/offline/query-cache.js +260 -0
  162. package/dist/pwa.js +2 -2
  163. package/dist/runtime-globals.js +3 -0
  164. package/dist/signal-processing.js +5 -0
  165. package/dist/signals.js +123 -24
  166. package/dist/ssg.js +2 -2
  167. package/dist/stx-module.d.ts +3 -0
  168. package/dist/stx.d.ts +48 -1
  169. package/dist/unresolved-identifiers.js +2 -0
  170. package/dist/visual-testing.js +1 -1
  171. package/package.json +5 -5
  172. package/stx-module.d.ts +3 -0
  173. package/stx.d.ts +48 -1
  174. package/dist/chunk-0ek2mj5x.js +0 -2
  175. package/dist/chunk-241cvbas.js +0 -2
  176. package/dist/chunk-2ryg907a.js +0 -2
  177. package/dist/chunk-4k471790.js +0 -2
  178. package/dist/chunk-4md4tj27.js +0 -3
  179. package/dist/chunk-65yty69p.js +0 -2
  180. package/dist/chunk-68gspceh.js +0 -2
  181. package/dist/chunk-ad7q7zff.js +0 -2
  182. package/dist/chunk-anwxcm8j.js +0 -2
  183. package/dist/chunk-cvtxk36x.js +0 -2
  184. package/dist/chunk-dgd8jyaz.js +0 -2
  185. package/dist/chunk-emx4ey5d.js +0 -2
  186. package/dist/chunk-fg48tp2x.js +0 -2
  187. package/dist/chunk-fwvbmmb3.js +0 -2
  188. package/dist/chunk-gg3hm3kq.js +0 -2
  189. package/dist/chunk-hs9g1dpr.js +0 -2
  190. package/dist/chunk-jndc710n.js +0 -2
  191. package/dist/chunk-jqm6tbtb.js +0 -2
  192. package/dist/chunk-jrzw9782.js +0 -2
  193. package/dist/chunk-k66qphdp.js +0 -2
  194. package/dist/chunk-n1yz08j4.js +0 -2
  195. package/dist/chunk-nsese4as.js +0 -2
  196. package/dist/chunk-pmy5k4kn.js +0 -12
  197. package/dist/chunk-pvzbsjcw.js +0 -2
  198. package/dist/chunk-qdc3yj82.js +0 -2
  199. package/dist/chunk-rjkgqegg.js +0 -2
  200. package/dist/chunk-rrkjjyqb.js +0 -2
  201. package/dist/chunk-rstz7e7c.js +0 -2
  202. package/dist/chunk-sgmqfphy.js +0 -2
  203. package/dist/chunk-sw89c1b7.js +0 -2
  204. package/dist/chunk-vfjccz8p.js +0 -2
  205. package/dist/chunk-w9v7fstr.js +0 -2
  206. package/dist/chunk-wj66sab5.js +0 -2
  207. package/dist/chunk-wqgyb4zb.js +0 -2
  208. package/dist/chunk-wz7ca99x.js +0 -2
  209. package/dist/chunk-xw23twxw.js +0 -2
  210. package/dist/chunk-y3cz15x3.js +0 -2
  211. package/dist/chunk-ybm9ac7z.js +0 -2
  212. package/dist/chunk-yf0v44v8.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$e as z$}from"./chunk-kdabbmbf.js";import{ag as n8,eg as j$,fg as a6,gg as x6,ig as L1,jg as s6,kg as B5,lg as O$,mg as N$,og as r6,pg as n6,tg as O5}from"./chunk-a389vxsn.js";import{fj as c5}from"./chunk-1x6c4ys1.js";import{Aj as a$,Cj as e5,vj as l1,wj as I1,xj as R1,yj as r$,zj as n$}from"./chunk-245ft0zp.js";import{Zj as _$,_j as U$}from"./chunk-6efr4j9h.js";import{Bk as s5,Ck as r5}from"./chunk-afwbqeb2.js";import{Ik as G3,Jk as W3}from"./chunk-rqr735w8.js";import{bl as B1}from"./chunk-78rd6wxv.js";import{wl as I5,xl as N7}from"./chunk-yt9mq4m7.js";import{Bq as e0,Fm as o0,Fr as C$,Hr as n0,Ir as C0,Mr as k0,Po as E0,Vp as I0,Ym as p6,_l as R7,_o as t0,an as L5,dn as T1,do as K$,en as C1,oo as H$,op as t8,qo as c6,rm as r8,ro as D6,sr as B$,vp as l6,wp as i6,wq as L6,xq as x1}from"./chunk-w9b94q64.js";import{Ts as W5,lt as B,st as L$,tt as F$,xt as J0}from"./chunk-et9knn3s.js";import{Ct as p0}from"./chunk-pgeh4g3a.js";import{Su as s1,_u as Y5,av as J5,dv as r1,hv as G5,kv as W$,lv as R6,xv as B6}from"./chunk-akzmq0jr.js";import{Dw as v6,Ew as g6,Fw as f6,Gw as h6,Hw as d6,Iw as u6,Kw as m6,Pw as k6,iw as U5,jw as C6,nw as b6,ow as y6}from"./chunk-z8zmp74b.js";import{Ww as L3,Xw as I6,Zw as K5}from"./chunk-59pakqdv.js";import{bx as s}from"./chunk-x7qyx7vn.js";var $6={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function j3($,X,Z={}){let{storage:Q="local",serializer:Y=$6,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Z,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Q==="session"?sessionStorage:localStorage},U=()=>{let L=_();if(!L)return X;try{let O=L.getItem($);if(O===null)return X;let N=Y.read(O);if(J&&typeof X==="object"&&X!==null)return{...X,...N};return N}catch{return X}},F=(L)=>{let O=_();if(!O)return;try{if(L===null||L===void 0)O.removeItem($);else O.setItem($,Y.write(L))}catch(N){console.warn(`[useStorage] Failed to write key "${$}":`,N)}},z=U(),j=(L,O)=>{for(let N of W)try{N(L,O)}catch(V){console.error("[useStorage] Subscriber error:",V)}};if(K&&G){let L=(N)=>{if(N.key===$&&N.storageArea===_()){let V=z;try{z=N.newValue?Y.read(N.newValue):X}catch(M){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,M);return}j(z,V)}};window.addEventListener("storage",L);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",L))}let H={get value(){return z},set value(L){let O=z;z=L,F(L),j(L,O)},get:()=>z,set:(L)=>{H.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let O=z;z=X,j(X,O)}},subscribe:(L)=>{return W.add(L),L(z,void 0),()=>W.delete(L)}};return H}function s$($,X,Z,Q,Y={}){let{serializer:J=$6,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(j)=>{if(j===null||j===void 0)return Q;try{let H=J.read(j);if(G&&typeof Q==="object"&&Q!==null)return{...Q,...H};return H}catch(H){return console.warn(`[${X}] Failed to read key "${Z}":`,H),Q}},z=a$((()=>{let j=_();if(!j)return Q;try{return U(j.getItem(Z))}catch(H){return console.warn(`[${X}] Cannot read "${Z}":`,H),Q}})());if(e5(()=>{let j=z(),H=_();if(!H)return;try{if(j===null||j===void 0)H.removeItem(Z);else H.setItem(Z,J.write(j))}catch(L){console.warn(`[${X}] Cannot persist "${Z}":`,L)}}),K&&W){let j=(L)=>{if(L.key!==Z)return;if(L.storageArea&&L.storageArea!==_())return;z.set(U(L.newValue))};window.addEventListener("storage",j);let H=globalThis.onDestroy;if(typeof H==="function")H(()=>window.removeEventListener("storage",j))}return z}function H3($,X,Z){return s$("local","useLocalStorage",$,X,Z)}function O3($,X,Z){return s$("session","useSessionStorage",$,X,Z)}function N3($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function q3($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function A3($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Z=0;for(let Q in X)if(Object.prototype.hasOwnProperty.call(X,Q))Z+=(Q.length+(X.getItem(Q)?.length||0))*2;return Z}var X6="stx:kept:";function Z6($){return`${X6}${$===void 0||$===null||$===""||$===!1?"":`${$}:`}`}function V3($,X){return`${Z6(X)}${$}`}function M3($,X,Z={}){let{scope:Q}=Z;if(Q===!1||Q===null||Q==="")return a$(X);return s$("local","keptState",V3($,Q),X)}function E3($){if(typeof localStorage>"u")return;try{let X=Z6($);for(let Z=localStorage.length-1;Z>=0;Z--){let Q=localStorage.key(Z);if(Q?.startsWith(X))localStorage.removeItem(Q)}}catch{}}var t=null;function c1($,X,Z=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Z.has($))return!0;if(Z.add($),$ instanceof Date&&X instanceof Date)return $.getTime()===X.getTime();if($ instanceof RegExp&&X instanceof RegExp)return $.source===X.source&&$.flags===X.flags;if(Array.isArray($)){if(!Array.isArray(X)||$.length!==X.length)return!1;for(let J=0;J<$.length;J++)if(!c1($[J],X[J],Z))return!1;return!0}if(Array.isArray(X))return!1;if($ instanceof Map){if(!(X instanceof Map)||$.size!==X.size)return!1;for(let[J,G]of $)if(!X.has(J)||!c1(G,X.get(J),Z))return!1;return!0}if(X instanceof Map)return!1;if($ instanceof Set){if(!(X instanceof Set)||$.size!==X.size)return!1;for(let J of $)if(!X.has(J))return!1;return!0}if(X instanceof Set)return!1;let Q=Object.keys($),Y=Object.keys(X);if(Q.length!==Y.length)return!1;for(let J of Q){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!c1($[J],X[J],Z))return!1}return!0}function VJ($){t=$}function MJ(){return t}function EJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:I3()}}function I3(){return{refs:new Map,effects:new Set,cleanups:[]}}function IJ($){let X=new Set,Z=new Set,Q=$,Y=Symbol("ref"),J={get value(){let G=l1();if(G)Z.add(G);return Q},set value(G){if(!Object.is(G,Q)){let W=Q;Q=G;for(let K of X)K(G,W);for(let K of Z)if(r$())n$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(t)t.scope.refs.set(Y,J);return J}var Q6=new WeakMap;function R3($){let X=Q6.get($);if(X)return X;let Z=new Map,Q=(G)=>{let W=Z.get(G);if(!W)return;for(let K of[...W])if(r$())n$(K);else K()},Y=(G,W)=>{if(!Z.has(G))Z.set(G,new Set);return Z.get(G).add(W),()=>{Z.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=l1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let F=Object.getPrototypeOf(_);if(F===Object.prototype||F===null)return R3(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),F=Reflect.set(G,W,K,_);if(!Object.is(K,U))Q(W);return F},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Q(W),K}});return Q6.set($,J),J}function RJ($){let X,Z=!0,Q=new Set,Y=new Set,J=()=>{Z=!0,G()},G=()=>{if(Z){let K=X,_=I1(J);if(X=$(),R1(_),Z=!1,!Object.is(X,K)){for(let U of Q)U(X,K);for(let U of Y)U()}}},W=I1(J);return X=$(),Z=!1,R1(W),{get value(){let K=l1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Q.add(K),()=>{Q.delete(K)}}}}function D3($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function DJ($,X,Z={}){let{immediate:Q=!1,deep:Y=!1,flush:J="post"}=Z,G,W,K=!1,_=()=>{if(K)return;let H=j();if((Y?!c1(H,G):!Object.is(H,G))||Q)if(X(H,G),Y&&H!==null&&typeof H==="object")try{G=structuredClone(H)}catch{G=H}else G=H},U=(H)=>{if(J==="sync")H();else if(J==="pre")Promise.resolve().then(H);else D3(H)},F=!1,z=()=>{if(K||F)return;F=!0,U(()=>{F=!1,_()})},j=()=>{if(typeof $==="function"){let H=I1(z);try{return $()}finally{R1(H)}}return $.value};if(typeof $!=="function"){let H=$.subscribe(()=>{U(_)});W=()=>{K=!0,H()}}else W=()=>{K=!0};if(G=j(),Q)U(_);if(t)t.scope.cleanups.push(()=>W?.());return()=>W?.()}function wJ($,X,Z={}){let Q=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Q.push(G)}if(Z.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Q)J()}}function TJ($){let X,Z=!1,Q=()=>{if(Z)return;if(X)X();let Y=I1(Q);X=$(),R1(Y)};if(Q(),t)t.scope.cleanups.push(()=>{if(Z=!0,X)X()});return()=>{if(Z=!0,X)X()}}function CJ($){if(t)t.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function kJ($){if(t)t.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function xJ($){if(t)t.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function SJ($){if(t)t.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function PJ($){if(t)t.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function bJ($){if(t)t.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function J1($,X){let Z=$.hooks[X];for(let Q of Z)await Q()}async function yJ($){await J1($,"beforeMount"),$.isMounted=!0,await J1($,"mounted")}async function vJ($){if(!$.isMounted||$.isUnmounted)return;await J1($,"beforeUpdate"),await J1($,"updated")}async function gJ($){if($.isUnmounted)return;await J1($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await J1($,"unmounted")}function fJ(){return`
2
+ import{cf as O$}from"./chunk-8036mdat.js";import{dg as Y3,hg as N$,ig as X7,jg as h6,lg as F1,mg as Z7,ng as z5,og as q$,pg as V$,rg as Q7,sg as Y7,wg as q5}from"./chunk-gcvj5zdy.js";import{ij as a5,vj as Z6,wj as Q6,xj as Y6,yj as J6}from"./chunk-t5ja7qkn.js";import{Cj as s1,Dj as D1,Ej as w1,Fj as t$,Gj as e$,Hj as J1,Jj as G6}from"./chunk-9e8t0twa.js";import{ek as L$,fk as F$}from"./chunk-kbwhs5df.js";import{Ik as o5,Jk as t5}from"./chunk-6jrczd12.js";import{Pk as z3,Qk as j3}from"./chunk-anydpa34.js";import{il as L1}from"./chunk-gjrgr367.js";import{Dl as w5,El as D7}from"./chunk-gengvwb7.js";import{Cp as e6,Dp as $7,Dq as q6,Eq as P1,Iq as e0,Mm as o0,Mr as S$,Or as n0,Pr as C0,Tr as k0,Wo as E0,aq as I0,dn as o6,fm as P7,fp as t0,hn as j5,kn as k1,ko as B$,ln as x1,vo as A$,vp as G3,xo as t6,ym as Q3,yo as b6,zr as z$}from"./chunk-cqchpe34.js";import{At as H$,Et as J0,_s as U5,st as B,zt as j$}from"./chunk-0a315nbf.js";import{Jt as p0}from"./chunk-tkyrk66a.js";import{Ev as A6,Zu as o1,fv as W5,hv as K5,kv as t1,ov as _5,rv as U$,sv as P6}from"./chunk-bn1edb1y.js";import{Kw as c6,Lw as l6,Mw as i6,Nw as a6,Ow as s6,Pw as r6,Rw as n6,Ww as f6,pw as F5,qw as g6,uw as m6,vw as p6}from"./chunk-rt3cx932.js";import{bx as q3,cx as S6,ex as B5}from"./chunk-563shnkz.js";import{ix as s}from"./chunk-2fw05hs2.js";var n$=null,o$=null;function R1(){if(!n$)n$=Q6(void 0,Z6);return n$}function i1(){if(!o$)o$=J6({state:J1,kept:R1(),matches:Y6});return o$}function E3($,X){return i1().cachedQuery($,X)}function I3($){i1().setScope($)}function R3(){return R1().flush()}var W6={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function D3($,X,Z={}){let{storage:Q="local",serializer:Y=W6,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Z,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Q==="session"?sessionStorage:localStorage},U=()=>{let L=_();if(!L)return X;try{let O=L.getItem($);if(O===null)return X;let N=Y.read(O);if(J&&typeof X==="object"&&X!==null)return{...X,...N};return N}catch{return X}},F=(L)=>{let O=_();if(!O)return;try{if(L===null||L===void 0)O.removeItem($);else O.setItem($,Y.write(L))}catch(N){console.warn(`[useStorage] Failed to write key "${$}":`,N)}},z=U(),j=(L,O)=>{for(let N of W)try{N(L,O)}catch(V){console.error("[useStorage] Subscriber error:",V)}};if(K&&G){let L=(N)=>{if(N.key===$&&N.storageArea===_()){let V=z;try{z=N.newValue?Y.read(N.newValue):X}catch(M){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,M);return}j(z,V)}};window.addEventListener("storage",L);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",L))}let H={get value(){return z},set value(L){let O=z;z=L,F(L),j(L,O)},get:()=>z,set:(L)=>{H.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let O=z;z=X,j(X,O)}},subscribe:(L)=>{return W.add(L),L(z,void 0),()=>W.delete(L)}};return H}function K6($,X,Z,Q,Y={}){let{serializer:J=W6,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(j)=>{if(j===null||j===void 0)return Q;try{let H=J.read(j);if(G&&typeof Q==="object"&&Q!==null)return{...Q,...H};return H}catch(H){return console.warn(`[${X}] Failed to read key "${Z}":`,H),Q}},z=J1((()=>{let j=_();if(!j)return Q;try{return U(j.getItem(Z))}catch(H){return console.warn(`[${X}] Cannot read "${Z}":`,H),Q}})());if(G6(()=>{let j=z(),H=_();if(!H)return;try{if(j===null||j===void 0)H.removeItem(Z);else H.setItem(Z,J.write(j))}catch(L){console.warn(`[${X}] Cannot persist "${Z}":`,L)}}),K&&W){let j=(L)=>{if(L.key!==Z)return;if(L.storageArea&&L.storageArea!==_())return;z.set(U(L.newValue))};window.addEventListener("storage",j);let H=globalThis.onDestroy;if(typeof H==="function")H(()=>window.removeEventListener("storage",j))}return z}function w3($,X,Z){return K6("local","useLocalStorage",$,X,Z)}function T3($,X,Z){return K6("session","useSessionStorage",$,X,Z)}function C3($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function k3($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function x3($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Z=0;for(let Q in X)if(Object.prototype.hasOwnProperty.call(X,Q))Z+=(Q.length+(X.getItem(Q)?.length||0))*2;return Z}var _6="stx:kept:";function U6($){return`${_6}${$===void 0||$===null||$===""||$===!1?"":`${$}:`}`}function S3($,X){return`${U6(X)}${$}`}function P3($,X,Z={}){let Q=Z.scope===void 0?i1().scope():Z.scope;if(Q===!1||Q===null||Q===""||typeof window>"u")return J1(X);let Y=S3($,Q),J=R1(),G=J.peek(Y),W=J1(G?G.value:X),K={},_=!1;if(W.subscribe((U)=>{if(U===K)return;_=!0,J.set(Y,U)}),!G)J.load(Y).then((U)=>{if(!U||_)return;K=U.value,W.set(U.value)});return W}function b3($){if(typeof window>"u")return Promise.resolve();return R1().forget(U6($))}var t=null;function a1($,X,Z=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Z.has($))return!0;if(Z.add($),$ instanceof Date&&X instanceof Date)return $.getTime()===X.getTime();if($ instanceof RegExp&&X instanceof RegExp)return $.source===X.source&&$.flags===X.flags;if(Array.isArray($)){if(!Array.isArray(X)||$.length!==X.length)return!1;for(let J=0;J<$.length;J++)if(!a1($[J],X[J],Z))return!1;return!0}if(Array.isArray(X))return!1;if($ instanceof Map){if(!(X instanceof Map)||$.size!==X.size)return!1;for(let[J,G]of $)if(!X.has(J)||!a1(G,X.get(J),Z))return!1;return!0}if(X instanceof Map)return!1;if($ instanceof Set){if(!(X instanceof Set)||$.size!==X.size)return!1;for(let J of $)if(!X.has(J))return!1;return!0}if(X instanceof Set)return!1;let Q=Object.keys($),Y=Object.keys(X);if(Q.length!==Y.length)return!1;for(let J of Q){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!a1($[J],X[J],Z))return!1}return!0}function gJ($){t=$}function fJ(){return t}function hJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:y3()}}function y3(){return{refs:new Map,effects:new Set,cleanups:[]}}function dJ($){let X=new Set,Z=new Set,Q=$,Y=Symbol("ref"),J={get value(){let G=s1();if(G)Z.add(G);return Q},set value(G){if(!Object.is(G,Q)){let W=Q;Q=G;for(let K of X)K(G,W);for(let K of Z)if(t$())e$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(t)t.scope.refs.set(Y,J);return J}var B6=new WeakMap;function v3($){let X=B6.get($);if(X)return X;let Z=new Map,Q=(G)=>{let W=Z.get(G);if(!W)return;for(let K of[...W])if(t$())e$(K);else K()},Y=(G,W)=>{if(!Z.has(G))Z.set(G,new Set);return Z.get(G).add(W),()=>{Z.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=s1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let F=Object.getPrototypeOf(_);if(F===Object.prototype||F===null)return v3(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),F=Reflect.set(G,W,K,_);if(!Object.is(K,U))Q(W);return F},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Q(W),K}});return B6.set($,J),J}function uJ($){let X,Z=!0,Q=new Set,Y=new Set,J=()=>{Z=!0,G()},G=()=>{if(Z){let K=X,_=D1(J);if(X=$(),w1(_),Z=!1,!Object.is(X,K)){for(let U of Q)U(X,K);for(let U of Y)U()}}},W=D1(J);return X=$(),Z=!1,w1(W),{get value(){let K=s1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Q.add(K),()=>{Q.delete(K)}}}}function g3($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function mJ($,X,Z={}){let{immediate:Q=!1,deep:Y=!1,flush:J="post"}=Z,G,W,K=!1,_=()=>{if(K)return;let H=j();if((Y?!a1(H,G):!Object.is(H,G))||Q)if(X(H,G),Y&&H!==null&&typeof H==="object")try{G=structuredClone(H)}catch{G=H}else G=H},U=(H)=>{if(J==="sync")H();else if(J==="pre")Promise.resolve().then(H);else g3(H)},F=!1,z=()=>{if(K||F)return;F=!0,U(()=>{F=!1,_()})},j=()=>{if(typeof $==="function"){let H=D1(z);try{return $()}finally{w1(H)}}return $.value};if(typeof $!=="function"){let H=$.subscribe(()=>{U(_)});W=()=>{K=!0,H()}}else W=()=>{K=!0};if(G=j(),Q)U(_);if(t)t.scope.cleanups.push(()=>W?.());return()=>W?.()}function pJ($,X,Z={}){let Q=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Q.push(G)}if(Z.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Q)J()}}function cJ($){let X,Z=!1,Q=()=>{if(Z)return;if(X)X();let Y=D1(Q);X=$(),w1(Y)};if(Q(),t)t.scope.cleanups.push(()=>{if(Z=!0,X)X()});return()=>{if(Z=!0,X)X()}}function lJ($){if(t)t.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function iJ($){if(t)t.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function aJ($){if(t)t.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function sJ($){if(t)t.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function rJ($){if(t)t.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function nJ($){if(t)t.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function G1($,X){let Z=$.hooks[X];for(let Q of Z)await Q()}async function oJ($){await G1($,"beforeMount"),$.isMounted=!0,await G1($,"mounted")}async function tJ($){if(!$.isMounted||$.isUnmounted)return;await G1($,"beforeUpdate"),await G1($,"updated")}async function eJ($){if($.isUnmounted)return;await G1($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await G1($,"unmounted")}function $G(){return`
3
3
  <script data-stx-client-runtime>
4
4
  (function() {
5
5
  'use strict';
@@ -178,11 +178,11 @@ import{$e as z$}from"./chunk-kdabbmbf.js";import{ag as n8,eg as j$,fg as a6,gg a
178
178
  });
179
179
  window.provide = provide;
180
180
  })();
181
- </script>`}function G1($,X){if(typeof window>"u")return X;return window[$]??X}function i1($,X){if(typeof window>"u")return;window[$]=X}function Y6($){let Z=G1("__STX_STORES__",{})[$];if(!Z)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Z}function dJ($){return Y6($)}function uJ($,X=5000){return new Promise((Z,Q)=>{let Y=Date.now(),J=()=>{let G=Y6($);if(G)Z(G);else if(Date.now()-Y>X)Q(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(J)};J()})}function w3(){return G1("__STX_ROUTE_PARAMS__",{})}function T3($){return w3()[$]}function mJ($){let X=T3($);if(X===void 0)throw Error(`Route parameter "${$}" not found`);return X}function C3(){return G1("__STX_MIDDLEWARE_STATE__",{})}function pJ($){return C3()[$]}function cJ(){if(typeof window>"u")return;if(!G1("__STX_STORES__",null))i1("__STX_STORES__",{})}function lJ($,X){let Z=G1("__STX_STORES__",{});Z[$]=X,i1("__STX_STORES__",Z)}function iJ(){return G1("__STX_STORE_STATE__",null)}function aJ($){i1("__STX_ROUTE_PARAMS__",$)}function sJ($){i1("__STX_MIDDLEWARE_STATE__",$)}function k3(){return typeof window>"u"}function x3(){return typeof window<"u"}function rJ($){if(x3())$()}function nJ($){if(k3())$()}K5();async function S3($){try{let X=await Bun.file($).text(),Z=P3(X),Q=b3(X,$),Y=y3(X,Z),J=v3(X,Z);return{file:$,metrics:Z,issues:Q,suggestions:Y,performance:J}}catch(X){throw Error(`Failed to analyze template ${$}: ${X instanceof Error?X.message:String(X)}`)}}function P3($){let X=$.split(`
181
+ </script>`}function W1($,X){if(typeof window>"u")return X;return window[$]??X}function r1($,X){if(typeof window>"u")return;window[$]=X}function L6($){let Z=W1("__STX_STORES__",{})[$];if(!Z)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Z}function ZG($){return L6($)}function QG($,X=5000){return new Promise((Z,Q)=>{let Y=Date.now(),J=()=>{let G=L6($);if(G)Z(G);else if(Date.now()-Y>X)Q(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(J)};J()})}function f3(){return W1("__STX_ROUTE_PARAMS__",{})}function h3($){return f3()[$]}function YG($){let X=h3($);if(X===void 0)throw Error(`Route parameter "${$}" not found`);return X}function d3(){return W1("__STX_MIDDLEWARE_STATE__",{})}function JG($){return d3()[$]}function GG(){if(typeof window>"u")return;if(!W1("__STX_STORES__",null))r1("__STX_STORES__",{})}function WG($,X){let Z=W1("__STX_STORES__",{});Z[$]=X,r1("__STX_STORES__",Z)}function KG(){return W1("__STX_STORE_STATE__",null)}function _G($){r1("__STX_ROUTE_PARAMS__",$)}function UG($){r1("__STX_MIDDLEWARE_STATE__",$)}function u3(){return typeof window>"u"}function m3(){return typeof window<"u"}function BG($){if(m3())$()}function LG($){if(u3())$()}B5();async function p3($){try{let X=await Bun.file($).text(),Z=c3(X),Q=l3(X,$),Y=i3(X,Z),J=a3(X,Z);return{file:$,metrics:Z,issues:Q,suggestions:Y,performance:J}}catch(X){throw Error(`Failed to analyze template ${$}: ${X instanceof Error?X.message:String(X)}`)}}function c3($){let X=$.split(`
182
182
  `),Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=(Z?Z[1]:"").split(`
183
- `).length,J={conditionals:($.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:($.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:($.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};J.total=J.conditionals+J.loops+J.includes+J.custom;let G=($.match(/\{\{[\s\S]*?\}\}/g)||[]).length,W=($.match(/\{!![\s\S]*?!!\}/g)||[]).length,K=($.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,_=G+W+K,U=($.match(/<[A-Z][^>]*>/g)||[]).length,F=($.match(/@(?:layout|extends)\(/g)||[]).length,z=0,j=0;for(let O of X)if(/@(?:if|unless|foreach|for|while|section)\b/.test(O)&&!/@end/.test(O)&&!/@else/.test(O))j++,z=Math.max(z,j);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(O))j--;let H=z>=4?3:0,L=Math.min(10,Math.ceil(J.total*0.5+_*0.1+U*0.3+(Y>10?Y*0.05:0)+H));return{lines:X.length,characters:$.length,directives:J,expressions:_,components:U,layouts:F,scriptLines:Y,complexity:L}}function b3($,X){let Z=[],Q=J6($,"if","endif");if(Q>0)Z.push({type:"error",category:"syntax",message:`Found ${Q} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let Y=J6($,"foreach","endforeach");if(Y>0)Z.push({type:"error",category:"syntax",message:`Found ${Y} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let J=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(J&&J.length>0)Z.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let G=($.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(G>0)Z.push({type:"warning",category:"security",message:`Found ${G} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let W=$.match(/<img[^>]*>/g);if(W){let U=W.filter((F)=>!F.includes("alt="));if(U.length>0)Z.push({type:"warning",category:"accessibility",message:`Found ${U.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let K=$.split(`
184
- `).filter((U)=>U.length>120);if(K.length>0)Z.push({type:"info",category:"maintainability",message:`Found ${K.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let _=($.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(_>3)Z.push({type:"info",category:"maintainability",message:`Found ${_} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return Z}function y3($,X){let Z=[];if(X.complexity>7)Z.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(X.complexity>5&&X.directives.total>8)Z.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(X.lines>100&&X.components===0)Z.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(X.expressions>20)Z.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let Q=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(Q&&Q.length>0)Z.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(X.directives.total===0&&X.expressions<5)Z.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(X.scriptLines>50)Z.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return Z}function v3($,X){let Z=1;if(Z+=X.directives.conditionals*0.1,Z+=X.directives.loops*0.5,Z+=X.directives.includes*2,Z+=X.expressions*0.05,Z+=X.components*1,X.scriptLines>10)Z+=X.scriptLines*0.1;let Q;if(X.expressions===0&&X.directives.total===0)Q="high";else if(X.expressions<5&&X.directives.total<3)Q="medium";else Q="low";let Y=[];if(Z>10)Y.push("Consider optimizing template complexity");if(Q==="low"&&X.directives.total>5)Y.push("Reduce dynamic content for better caching");if(X.components===0&&X.lines>40)Y.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(Z*100)/100,complexityScore:X.complexity,cacheability:Q,recommendations:Y}}function J6($,X,Z){let Q=$.replace(/<!--[\s\S]*?-->/g,""),Y=(Q.match(new RegExp(`@${X}\\b`,"g"))||[]).length,J=(Q.match(new RegExp(`@${Z}\\b`,"g"))||[]).length;return Math.abs(Y-J)}async function tJ($=["**/*.stx"],X){let Z=[],Q=[];for(let J of $){let G=await Array.fromAsync(new Bun.Glob(J).scan({cwd:X||process.cwd(),onlyFiles:!0,absolute:!0}));Q.push(...G.filter((W)=>W.endsWith(".stx")))}for(let J of Q)try{let G=await S3(J);Z.push(G)}catch(G){console.warn(`Failed to analyze ${J}:`,G)}let Y=g3(Z);return{results:Z,summary:Y}}function g3($){let X=$.length,Z=$.reduce((_,U)=>_+U.metrics.lines,0),Q=X>0?$.reduce((_,U)=>_+U.metrics.complexity,0)/X:0,Y=$.reduce((_,U)=>_+U.issues.length,0),J={};$.forEach((_)=>{_.issues.forEach((U)=>{J[U.category]=(J[U.category]||0)+1})});let G=X>0?$.reduce((_,U)=>_+U.performance.estimatedRenderTime,0)/X:0,W=Math.max(1,Math.min(10,Math.round(10-G/2-Q/2))),K=[];if(Q>6)K.push("Project has high average complexity. Consider refactoring complex templates.");if(Y>X*2)K.push("High number of issues detected. Run detailed analysis on individual files.");if(J.security>0)K.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:X,totalLines:Z,avgComplexity:Math.round(Q*100)/100,totalIssues:Y,issuesByCategory:J,performanceScore:W,recommendations:K}}import a1 from"path";var G6=/<script\b[^>]*\bserver\b/i,f3=/<script\b[^>]*\bclient\b/i;async function ZG($){let X=performance.now(),Z=await n0($),Q=$||Z.root||process.cwd(),Y=[Z.build?.pagesDir||Z.pagesDir||"pages",Z.componentsDir||"components",Z.layoutsDir||"layouts",Z.partialsDir||"partials"].map((W)=>a1.resolve(Q,W)),J=[],G=0;for(let W of Y){let K=await W6(W);for(let _ of K){G++;let U=await Bun.file(_).text();if(G6.test(U))J.push(a1.relative(Q,_))}}return{mode:J.length>0?"ssr":"ssg",serverScriptFiles:J,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-X)}}async function QG($){let X=await n0($),Z=$||X.root||process.cwd(),Q=a1.resolve(Z,X.componentsDir||"components"),Y=[],J=await W6(Q);for(let G of J){let W=await Bun.file(G).text(),K=G6.test(W),_=f3.test(W)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(W)&&!K;if(K&&_){let U=a1.relative(Z,G);Y.push({file:U,message:`Component "${U}" has both <script server> and <script client>. `+"Components should be server OR client \u2014 compose them via props/slots."})}}return Y}async function W6($){let X=[];try{let Z=new Bun.Glob("**/*.stx");for await(let Q of Z.scan({cwd:$,absolute:!0}))X.push(Q)}catch{}return X}var K6={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},_6=["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty","extends","section","endsection","yield","parent","include","includeIf","includeWhen","includeFirst","once","endonce","push","endpush","prepend","endprepend","stack","component","endcomponent","slot","endslot","props","auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole","csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file","translate","lang","choice","meta","title","seo","jsonld","canonical","robots","sitemap","ts","endts","js","endjs","css","endcss","markdown","endmarkdown","verbatim","endverbatim","env","production","debug","isset","endisset","empty","endempty"];function U6($){let X=new Map,Z=/@(\w+)/g,Q,Y=1,J=0;while((Q=Z.exec($))!==null){let G=Q[1],W=$.slice(J,Q.index);Y+=(W.match(/\n/g)||[]).length,J=Q.index;let K=Q.index-$.lastIndexOf(`
185
- `,Q.index-1);if(_6.includes(G)){let _=X.get(G);if(_)_.count++,_.locations.push({line:Y,column:K});else X.set(G,{name:G,count:1,locations:[{line:Y,column:K}]})}}return Array.from(X.values())}function h3($,X=[]){let Z=U6($),Q=new Set(Z.map((Y)=>Y.name));for(let Y of X)Q.add(Y);for(let Y of Array.from(Q))if(!Y.startsWith("end"))Q.add(`end${Y}`);return _6.filter((Y)=>!Q.has(Y))}function d3($){let X=[],Z={conditionals:["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","isset","endisset"],loops:["for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty"],includes:["include","includeIf","includeWhen","includeFirst","once","endonce","extends","section","endsection","yield","parent","push","endpush","prepend","endprepend","stack"],components:["component","endcomponent","slot","endslot","props"],auth:["auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole"],forms:["csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file"],i18n:["translate","lang","choice"],seo:["meta","title","seo","jsonld","canonical","robots","sitemap"]},Q=new Set;for(let J of $)for(let[G,W]of Object.entries(Z))if(W.includes(J)){Q.add(G);break}for(let J of Q)X.push(`import { process${a3(J)} } from './${J}'`);let Y=$.filter((J)=>!J.startsWith("end")).map((J)=>` '${J}': true`).join(`,
183
+ `).length,J={conditionals:($.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:($.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:($.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};J.total=J.conditionals+J.loops+J.includes+J.custom;let G=($.match(/\{\{[\s\S]*?\}\}/g)||[]).length,W=($.match(/\{!![\s\S]*?!!\}/g)||[]).length,K=($.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,_=G+W+K,U=($.match(/<[A-Z][^>]*>/g)||[]).length,F=($.match(/@(?:layout|extends)\(/g)||[]).length,z=0,j=0;for(let O of X)if(/@(?:if|unless|foreach|for|while|section)\b/.test(O)&&!/@end/.test(O)&&!/@else/.test(O))j++,z=Math.max(z,j);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(O))j--;let H=z>=4?3:0,L=Math.min(10,Math.ceil(J.total*0.5+_*0.1+U*0.3+(Y>10?Y*0.05:0)+H));return{lines:X.length,characters:$.length,directives:J,expressions:_,components:U,layouts:F,scriptLines:Y,complexity:L}}function l3($,X){let Z=[],Q=F6($,"if","endif");if(Q>0)Z.push({type:"error",category:"syntax",message:`Found ${Q} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let Y=F6($,"foreach","endforeach");if(Y>0)Z.push({type:"error",category:"syntax",message:`Found ${Y} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let J=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(J&&J.length>0)Z.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let G=($.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(G>0)Z.push({type:"warning",category:"security",message:`Found ${G} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let W=$.match(/<img[^>]*>/g);if(W){let U=W.filter((F)=>!F.includes("alt="));if(U.length>0)Z.push({type:"warning",category:"accessibility",message:`Found ${U.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let K=$.split(`
184
+ `).filter((U)=>U.length>120);if(K.length>0)Z.push({type:"info",category:"maintainability",message:`Found ${K.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let _=($.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(_>3)Z.push({type:"info",category:"maintainability",message:`Found ${_} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return Z}function i3($,X){let Z=[];if(X.complexity>7)Z.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(X.complexity>5&&X.directives.total>8)Z.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(X.lines>100&&X.components===0)Z.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(X.expressions>20)Z.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let Q=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(Q&&Q.length>0)Z.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(X.directives.total===0&&X.expressions<5)Z.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(X.scriptLines>50)Z.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return Z}function a3($,X){let Z=1;if(Z+=X.directives.conditionals*0.1,Z+=X.directives.loops*0.5,Z+=X.directives.includes*2,Z+=X.expressions*0.05,Z+=X.components*1,X.scriptLines>10)Z+=X.scriptLines*0.1;let Q;if(X.expressions===0&&X.directives.total===0)Q="high";else if(X.expressions<5&&X.directives.total<3)Q="medium";else Q="low";let Y=[];if(Z>10)Y.push("Consider optimizing template complexity");if(Q==="low"&&X.directives.total>5)Y.push("Reduce dynamic content for better caching");if(X.components===0&&X.lines>40)Y.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(Z*100)/100,complexityScore:X.complexity,cacheability:Q,recommendations:Y}}function F6($,X,Z){let Q=$.replace(/<!--[\s\S]*?-->/g,""),Y=(Q.match(new RegExp(`@${X}\\b`,"g"))||[]).length,J=(Q.match(new RegExp(`@${Z}\\b`,"g"))||[]).length;return Math.abs(Y-J)}async function zG($=["**/*.stx"],X){let Z=[],Q=[];for(let J of $){let G=await Array.fromAsync(new Bun.Glob(J).scan({cwd:X||process.cwd(),onlyFiles:!0,absolute:!0}));Q.push(...G.filter((W)=>W.endsWith(".stx")))}for(let J of Q)try{let G=await p3(J);Z.push(G)}catch(G){console.warn(`Failed to analyze ${J}:`,G)}let Y=s3(Z);return{results:Z,summary:Y}}function s3($){let X=$.length,Z=$.reduce((_,U)=>_+U.metrics.lines,0),Q=X>0?$.reduce((_,U)=>_+U.metrics.complexity,0)/X:0,Y=$.reduce((_,U)=>_+U.issues.length,0),J={};$.forEach((_)=>{_.issues.forEach((U)=>{J[U.category]=(J[U.category]||0)+1})});let G=X>0?$.reduce((_,U)=>_+U.performance.estimatedRenderTime,0)/X:0,W=Math.max(1,Math.min(10,Math.round(10-G/2-Q/2))),K=[];if(Q>6)K.push("Project has high average complexity. Consider refactoring complex templates.");if(Y>X*2)K.push("High number of issues detected. Run detailed analysis on individual files.");if(J.security>0)K.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:X,totalLines:Z,avgComplexity:Math.round(Q*100)/100,totalIssues:Y,issuesByCategory:J,performanceScore:W,recommendations:K}}import n1 from"path";var z6=/<script\b[^>]*\bserver\b/i,r3=/<script\b[^>]*\bclient\b/i;async function NG($){let X=performance.now(),Z=await n0($),Q=$||Z.root||process.cwd(),Y=[Z.build?.pagesDir||Z.pagesDir||"pages",Z.componentsDir||"components",Z.layoutsDir||"layouts",Z.partialsDir||"partials"].map((W)=>n1.resolve(Q,W)),J=[],G=0;for(let W of Y){let K=await j6(W);for(let _ of K){G++;let U=await Bun.file(_).text();if(z6.test(U))J.push(n1.relative(Q,_))}}return{mode:J.length>0?"ssr":"ssg",serverScriptFiles:J,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-X)}}async function AG($){let X=await n0($),Z=$||X.root||process.cwd(),Q=n1.resolve(Z,X.componentsDir||"components"),Y=[],J=await j6(Q);for(let G of J){let W=await Bun.file(G).text(),K=z6.test(W),_=r3.test(W)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(W)&&!K;if(K&&_){let U=n1.relative(Z,G);Y.push({file:U,message:`Component "${U}" has both <script server> and <script client>. `+"Components should be server OR client \u2014 compose them via props/slots."})}}return Y}async function j6($){let X=[];try{let Z=new Bun.Glob("**/*.stx");for await(let Q of Z.scan({cwd:$,absolute:!0}))X.push(Q)}catch{}return X}var H6={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},O6=["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty","extends","section","endsection","yield","parent","include","includeIf","includeWhen","includeFirst","once","endonce","push","endpush","prepend","endprepend","stack","component","endcomponent","slot","endslot","props","auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole","csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file","translate","lang","choice","meta","title","seo","jsonld","canonical","robots","sitemap","ts","endts","js","endjs","css","endcss","markdown","endmarkdown","verbatim","endverbatim","env","production","debug","isset","endisset","empty","endempty"];function N6($){let X=new Map,Z=/@(\w+)/g,Q,Y=1,J=0;while((Q=Z.exec($))!==null){let G=Q[1],W=$.slice(J,Q.index);Y+=(W.match(/\n/g)||[]).length,J=Q.index;let K=Q.index-$.lastIndexOf(`
185
+ `,Q.index-1);if(O6.includes(G)){let _=X.get(G);if(_)_.count++,_.locations.push({line:Y,column:K});else X.set(G,{name:G,count:1,locations:[{line:Y,column:K}]})}}return Array.from(X.values())}function n3($,X=[]){let Z=N6($),Q=new Set(Z.map((Y)=>Y.name));for(let Y of X)Q.add(Y);for(let Y of Array.from(Q))if(!Y.startsWith("end"))Q.add(`end${Y}`);return O6.filter((Y)=>!Q.has(Y))}function o3($){let X=[],Z={conditionals:["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","isset","endisset"],loops:["for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty"],includes:["include","includeIf","includeWhen","includeFirst","once","endonce","extends","section","endsection","yield","parent","push","endpush","prepend","endprepend","stack"],components:["component","endcomponent","slot","endslot","props"],auth:["auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole"],forms:["csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file"],i18n:["translate","lang","choice"],seo:["meta","title","seo","jsonld","canonical","robots","sitemap"]},Q=new Set;for(let J of $)for(let[G,W]of Object.entries(Z))if(W.includes(J)){Q.add(G);break}for(let J of Q)X.push(`import { process${Y4(J)} } from './${J}'`);let Y=$.filter((J)=>!J.startsWith("end")).map((J)=>` '${J}': true`).join(`,
186
186
  `);return`// Tree-shaken directive bundle
187
187
  // Only includes: ${$.join(", ")}
188
188
  ${X.join(`
@@ -195,10 +195,10 @@ ${Y}
195
195
  export function isDirectiveActive(name: string): boolean {
196
196
  return name in activeDirectives
197
197
  }
198
- `}function u3($,X={}){let Z=[],Q=/@if\(([^)]+)\)[\s\S]*?@endif/g,Y=$.matchAll(Q);for(let _ of Y){let U=_[1].trim();if(o$(U,X)===!1)Z.push({start:_.index,end:_.index+_[0].length,reason:`@if condition always false: ${U}`})}let J=/@unless\(([^)]+)\)[\s\S]*?@endunless/g,G=$.matchAll(J);for(let _ of G){let U=_[1].trim();if(o$(U,X)===!0)Z.push({start:_.index,end:_.index+_[0].length,reason:`@unless condition always true: ${U}`})}let W=/@env\(['"]development['"]\)[\s\S]*?@endenv/g;if(X.__ENV__==="production"){let _=$.matchAll(W);for(let U of _)Z.push({start:U.index,end:U.index+U[0].length,reason:"Development-only code in production build"})}let K=/@debug[\s\S]*?@enddebug/g;if(X.__ENV__==="production"){let _=$.matchAll(K);for(let U of _)Z.push({start:U.index,end:U.index+U[0].length,reason:"Debug code in production build"})}return Z}function m3($,X={}){let Z=u3($,X),Q=[];Z.sort((J,G)=>G.start-J.start);let Y=$;for(let J of Z)Y=Y.slice(0,J.start)+Y.slice(J.end),Q.push(J.reason);return{content:Y,removed:Q}}function o$($,X){if($==="true")return!0;if($==="false")return!1;if($==="null")return null;if(/^\d+$/.test($))return Number.parseInt($,10);if(/^\d+\.\d+$/.test($))return Number.parseFloat($);if(/^['"].*['"]$/.test($))return $.slice(1,-1);if($ in X)return X[$];let Z=$.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(Z){let[,Q,Y,J]=Z,G=Q in X?X[Q]:void 0,W=o$(J,X);if(G!==void 0&&W!==void 0)switch(Y){case"==":case"===":return G===W;case"!=":case"!==":return G!==W;case">":return G>W;case"<":return G<W;case">=":return G>=W;case"<=":return G<=W}}return}function p3($,X){let Z=[],Q=$;return Q=Q.replace(/\{\{\s*(\w+)\s*\}\}/g,(Y,J)=>{if(J in X)return Z.push(`{{ ${J} }} -> ${X[J]}`),String(X[J]);return Y}),Q=Q.replace(/\{\{\s*(\d+)\s*([+\-*])\s*(\d+)\s*\}\}/g,(Y,J,G,W)=>{let K=Number.parseInt(J,10),_=Number.parseInt(W,10),U;switch(G){case"+":U=K+_;break;case"-":U=K-_;break;case"*":U=K*_;break;default:return Y}return Z.push(`{{ ${J} ${G} ${W} }} -> ${U}`),String(U)}),{content:Q,folded:Z}}function c3($){let X=$,Z=[],Q=0;X=X.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(Y)=>{let J=`__PRESERVE_${Q++}__`;return Z.push({marker:J,content:Y}),J}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(Y)=>{let J=`__PRESERVE_${Q++}__`;return Z.push({marker:J,content:Y}),J}),X=X.replace(/\{\{--([\s\S]*?)--\}\}/g,""),X=X.replace(/<!--[\s\S]*?-->/g,""),X=X.replace(/>\s+</g,"><"),X=X.replace(/^\s+/gm,""),X=X.replace(/\s+$/gm,""),X=X.replace(/\s{2,}/g," ");for(let{marker:Y,content:J}of Z){let G=X.indexOf(Y);if(G!==-1)X=X.slice(0,G)+J+X.slice(G+Y.length)}return X.trim()}function l3($){let X=new Map,Z=new Map,Q=/(['"])([^'"]{10,})\1/g,Y;while((Y=Q.exec($))!==null){let W=Y[2];Z.set(W,(Z.get(W)||0)+1)}let J=0,G=$;for(let[W,K]of Z)if(K>1){let _=`__STR_${J++}__`;X.set(_,W);let U=W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),F=new RegExp(`(['"])${U}\\1`,"g");G=G.replace(F,_)}return{content:G,pool:X,count:X.size}}function i3($,X={}){let Z={...K6,...X},Q=new Blob([$]).size,Y=$,J=[],G=[],W=[],K=[],_=0;if(Z.target==="production")Z.constants={...Z.constants,__ENV__:"production"};if(Z.deadCodeElimination){let z=m3(Y,Z.constants);if(Y=z.content,z.removed.length>0)J.push("Dead code elimination"),G.push(...z.removed.map((j)=>`Removed: ${j}`))}if(Z.constantFolding&&Object.keys(Z.constants).length>0){let z=p3(Y,Z.constants);if(Y=z.content,K=z.folded,K.length>0)J.push("Constant folding")}if(Z.treeShake){if(W=h3(Y,Z.preserveDirectives),W.length>0)J.push("Tree shaking")}if(Z.stringPooling){let z=l3(Y);if(Y=z.content,_=z.count,_>0)J.push("String pooling")}if(Z.minifyHtml){let z=c3(Y);if(z.length<Y.length)Y=z,J.push("HTML minification")}let U=new Blob([Y]).size,F=Q>0?Math.round((1-U/Q)*100):0;return{content:Y,originalSize:Q,optimizedSize:U,reduction:F,appliedOptimizations:J,removedDirectives:W,foldedConstants:K,pooledStrings:_,warnings:G}}async function JG($,X={}){let Z={...K6,...X},Q=new Map,Y=[],J=0,G=0,W=new Set;for(let[F,z]of $){let j=i3(z,Z);Q.set(F,j),J+=j.originalSize,G+=j.optimizedSize,Y.push(...j.warnings.map((L)=>`${F}: ${L}`));let H=U6(z);for(let L of H)W.add(L.name)}let K;if(Z.treeShake)K=d3(Array.from(W));let _;if(Z.stringPooling)_=new Map;let U=J>0?Math.round((1-G/J)*100):0;return{templates:Q,directiveBundle:K,stringPool:_,totalOriginalSize:J,totalOptimizedSize:G,overallReduction:U,warnings:Y}}function a3($){return $.charAt(0).toUpperCase()+$.slice(1)}function F6($,X){let Z={},Q=$.trim();if(Q.startsWith("{"))Q=Q.slice(1);if(Q.endsWith("}"))Q=Q.slice(0,-1);if(Q=Q.trim(),!Q)return Z;let Y=0;while(Y<Q.length){while(Y<Q.length&&/\s/.test(Q[Y]))Y++;if(Y>=Q.length)break;let J="";if(Q[Y]==='"'||Q[Y]==="'"){let K=Q[Y];Y++;while(Y<Q.length&&Q[Y]!==K)if(Q[Y]==="\\"&&Y+1<Q.length)J+=Q[Y+1],Y+=2;else J+=Q[Y],Y++;Y++}else while(Y<Q.length&&/[\w$]/.test(Q[Y]))J+=Q[Y],Y++;while(Y<Q.length&&/\s/.test(Q[Y]))Y++;if(Q[Y]===":")Y++;while(Y<Q.length&&/\s/.test(Q[Y]))Y++;let G,W=Y;if(Q[Y]==='"'||Q[Y]==="'"){let K=Q[Y];Y++;let _="";while(Y<Q.length&&Q[Y]!==K)if(Q[Y]==="\\"&&Y+1<Q.length)_+=Q[Y+1],Y+=2;else _+=Q[Y],Y++;Y++,G=_}else if(Q[Y]==="{"){let K=1;Y++;while(Y<Q.length&&K>0){if(Q[Y]==="{")K++;else if(Q[Y]==="}")K--;else if(Q[Y]==='"'||Q[Y]==="'"){let U=Q[Y];Y++;while(Y<Q.length&&Q[Y]!==U){if(Q[Y]==="\\")Y++;Y++}}Y++}let _=Q.slice(W,Y);G=F6(_,X)}else if(Q[Y]==="["){let K=1;Y++;while(Y<Q.length&&K>0){if(Q[Y]==="[")K++;else if(Q[Y]==="]")K--;else if(Q[Y]==='"'||Q[Y]==="'"){let U=Q[Y];Y++;while(Y<Q.length&&Q[Y]!==U){if(Q[Y]==="\\")Y++;Y++}}Y++}let _=Q.slice(W,Y);try{G=JSON.parse(_.replace(/'/g,'"'))}catch{G=_}}else{let K="";while(Y<Q.length&&Q[Y]!==","&&!/\s/.test(Q[Y]))K+=Q[Y],Y++;if(K=K.trim(),K==="true")G=!0;else if(K==="false")G=!1;else if(K==="null")G=null;else if(K==="undefined")G=void 0;else if(/^-?\d+(\.\d+)?$/.test(K))G=Number(K);else if(K in X)G=X[K];else G=K}if(J)Z[J]=G;while(Y<Q.length&&/\s/.test(Q[Y]))Y++;if(Q[Y]===",")Y++}return Z}function UG($,X,Z){let Q=[];for(let[Y,J]of Object.entries(X)){let G=$[Y];if(J.required&&(G===void 0||G===null)){Q.push(`Component "${Z}": Missing required prop "${Y}"`);continue}if(G===void 0||G===null)continue;let W=Array.isArray(J.type)?J.type:[J.type];if(!W.includes("any")){let K=s3(G);if(!W.includes(K))Q.push(`Component "${Z}": Prop "${Y}" expected ${W.join(" | ")}, got ${K}`)}if(J.validator&&!J.validator(G))Q.push(`Component "${Z}": Prop "${Y}" failed custom validation`)}return Q}function BG($,X){let Z={...$};for(let[Q,Y]of Object.entries(X))if(Z[Q]===void 0&&Y.default!==void 0)Z[Q]=typeof Y.default==="function"?Y.default():Y.default;return Z}function s3($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}var r3={name:"component",handler:async($,X,Z,Q)=>{if(X.length<1)return r1("Component","component directive requires at least the component name",s1.INVALID_DIRECTIVE_SYNTAX);let Y=X[0].replace(/['"]/g,""),J={};if(X.length>1)try{let U=X.slice(1).join(",").trim();if(U.startsWith("{")){if(J=B6(U,Z),Object.keys(J).length===0)J=F6(U,Z)}else{let F=U.trim(),z=Z[F];if(z&&typeof z==="object"&&!Array.isArray(z))J=z}}catch(U){let F=U instanceof Error?U.message:String(U);return console.error("Component props parsing error:",F),r1("Component",`Error parsing component props: ${F}`,s1.EVALUATION_ERROR)}let G=Z.__stx_options||{},W=G.componentsDir||"components",K=new Set;if(!Z.__processedComponents)Z.__processedComponents=new Set;let _=Z.__processedComponents;try{return await L6(Y,J,"",W,Z,Q,G,_,K)}catch(U){console.error("Component rendering error:",U);let F=U instanceof Error?U.message:String(U);return r1("Component",`Error rendering component: ${F}`,s1.COMPONENT_RENDER_ERROR)}},hasEndTag:!1};function LG(){return[r3]}import{mkdir as n3,readFile as o3,readdir as t3,stat as z6,writeFile as e3}from"fs/promises";import B0 from"path";function A6($){if($==="connectedCallback")return`method "${$}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if($==="disconnectedCallback")return`method "${$}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${$}" is reserved`}var V6=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function $4($){return $.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join("")}function $5($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function X4($){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test($)&&!$.startsWith("xml")&&!/[A-Z]/.test($)}function Z4($){if($===!0)return"open";if($==="open"||$==="closed")return $;return!1}async function Q4($){let X=[];async function Z(Q){let Y=await t3(Q,{withFileTypes:!0});Y.sort((J,G)=>J.name.localeCompare(G.name));for(let J of Y){let G=B0.join(Q,J.name);if(J.isDirectory()){if(!J.name.startsWith(".")&&J.name!=="node_modules")await Z(G)}else if(J.isFile()&&J.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(J.name))X.push(G)}}return await Z($),X}function Y4($,X){let Z=$.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!Z)return{};let Q=Z[1].trim();if(!Q)return{};try{return JSON.parse(Q)}catch(Y){throw Error(`${X}: <script component> must contain JSON metadata (${Y.message})`)}}function J4($,X){let Z={},Q=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let Y of Q){if(!/\bclient\b/i.test(Y[1])||/\bcomponent\b|\bstx:component\b/i.test(Y[1]))continue;let J;try{J=new Bun.Transpiler({loader:"ts"}).transformSync(Y[2])}catch(K){throw Error(`${X}: failed to transpile <script client> (${K.message})`)}let G=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,W;while(W=G.exec(J)){let K=W[1];if(V6.has(K))throw Error(`${X}: client ${A6(K)}`);let _=G.lastIndex,U=1,F="",z=!1,j=_;for(;j<J.length&&U>0;j++){let L=J[j];if(z){z=!1;continue}if(F){if(L==="\\")z=!0;else if(L===F)F="";continue}if(L==='"'||L==="'"||L==="`")F=L;else if(L==="{")U++;else if(L==="}")U--}if(U!==0)throw Error(`${X}: unterminated client function "${K}"`);let H=W[0].includes("async")?"async ":"";Z[K]=`${H}${K}(${W[2]}) {${J.slice(_,j-1)}}`,G.lastIndex=j}}return Z}function G4($){let X=$.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(X?X[1]:$).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function j6($){return[...$.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((X)=>X[1].trim()).filter(Boolean).join(`
198
+ `}function t3($,X={}){let Z=[],Q=/@if\(([^)]+)\)[\s\S]*?@endif/g,Y=$.matchAll(Q);for(let _ of Y){let U=_[1].trim();if($5(U,X)===!1)Z.push({start:_.index,end:_.index+_[0].length,reason:`@if condition always false: ${U}`})}let J=/@unless\(([^)]+)\)[\s\S]*?@endunless/g,G=$.matchAll(J);for(let _ of G){let U=_[1].trim();if($5(U,X)===!0)Z.push({start:_.index,end:_.index+_[0].length,reason:`@unless condition always true: ${U}`})}let W=/@env\(['"]development['"]\)[\s\S]*?@endenv/g;if(X.__ENV__==="production"){let _=$.matchAll(W);for(let U of _)Z.push({start:U.index,end:U.index+U[0].length,reason:"Development-only code in production build"})}let K=/@debug[\s\S]*?@enddebug/g;if(X.__ENV__==="production"){let _=$.matchAll(K);for(let U of _)Z.push({start:U.index,end:U.index+U[0].length,reason:"Debug code in production build"})}return Z}function e3($,X={}){let Z=t3($,X),Q=[];Z.sort((J,G)=>G.start-J.start);let Y=$;for(let J of Z)Y=Y.slice(0,J.start)+Y.slice(J.end),Q.push(J.reason);return{content:Y,removed:Q}}function $5($,X){if($==="true")return!0;if($==="false")return!1;if($==="null")return null;if(/^\d+$/.test($))return Number.parseInt($,10);if(/^\d+\.\d+$/.test($))return Number.parseFloat($);if(/^['"].*['"]$/.test($))return $.slice(1,-1);if($ in X)return X[$];let Z=$.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(Z){let[,Q,Y,J]=Z,G=Q in X?X[Q]:void 0,W=$5(J,X);if(G!==void 0&&W!==void 0)switch(Y){case"==":case"===":return G===W;case"!=":case"!==":return G!==W;case">":return G>W;case"<":return G<W;case">=":return G>=W;case"<=":return G<=W}}return}function $4($,X){let Z=[],Q=$;return Q=Q.replace(/\{\{\s*(\w+)\s*\}\}/g,(Y,J)=>{if(J in X)return Z.push(`{{ ${J} }} -> ${X[J]}`),String(X[J]);return Y}),Q=Q.replace(/\{\{\s*(\d+)\s*([+\-*])\s*(\d+)\s*\}\}/g,(Y,J,G,W)=>{let K=Number.parseInt(J,10),_=Number.parseInt(W,10),U;switch(G){case"+":U=K+_;break;case"-":U=K-_;break;case"*":U=K*_;break;default:return Y}return Z.push(`{{ ${J} ${G} ${W} }} -> ${U}`),String(U)}),{content:Q,folded:Z}}function X4($){let X=$,Z=[],Q=0;X=X.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(Y)=>{let J=`__PRESERVE_${Q++}__`;return Z.push({marker:J,content:Y}),J}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(Y)=>{let J=`__PRESERVE_${Q++}__`;return Z.push({marker:J,content:Y}),J}),X=X.replace(/\{\{--([\s\S]*?)--\}\}/g,""),X=X.replace(/<!--[\s\S]*?-->/g,""),X=X.replace(/>\s+</g,"><"),X=X.replace(/^\s+/gm,""),X=X.replace(/\s+$/gm,""),X=X.replace(/\s{2,}/g," ");for(let{marker:Y,content:J}of Z){let G=X.indexOf(Y);if(G!==-1)X=X.slice(0,G)+J+X.slice(G+Y.length)}return X.trim()}function Z4($){let X=new Map,Z=new Map,Q=/(['"])([^'"]{10,})\1/g,Y;while((Y=Q.exec($))!==null){let W=Y[2];Z.set(W,(Z.get(W)||0)+1)}let J=0,G=$;for(let[W,K]of Z)if(K>1){let _=`__STR_${J++}__`;X.set(_,W);let U=W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),F=new RegExp(`(['"])${U}\\1`,"g");G=G.replace(F,_)}return{content:G,pool:X,count:X.size}}function Q4($,X={}){let Z={...H6,...X},Q=new Blob([$]).size,Y=$,J=[],G=[],W=[],K=[],_=0;if(Z.target==="production")Z.constants={...Z.constants,__ENV__:"production"};if(Z.deadCodeElimination){let z=e3(Y,Z.constants);if(Y=z.content,z.removed.length>0)J.push("Dead code elimination"),G.push(...z.removed.map((j)=>`Removed: ${j}`))}if(Z.constantFolding&&Object.keys(Z.constants).length>0){let z=$4(Y,Z.constants);if(Y=z.content,K=z.folded,K.length>0)J.push("Constant folding")}if(Z.treeShake){if(W=n3(Y,Z.preserveDirectives),W.length>0)J.push("Tree shaking")}if(Z.stringPooling){let z=Z4(Y);if(Y=z.content,_=z.count,_>0)J.push("String pooling")}if(Z.minifyHtml){let z=X4(Y);if(z.length<Y.length)Y=z,J.push("HTML minification")}let U=new Blob([Y]).size,F=Q>0?Math.round((1-U/Q)*100):0;return{content:Y,originalSize:Q,optimizedSize:U,reduction:F,appliedOptimizations:J,removedDirectives:W,foldedConstants:K,pooledStrings:_,warnings:G}}async function VG($,X={}){let Z={...H6,...X},Q=new Map,Y=[],J=0,G=0,W=new Set;for(let[F,z]of $){let j=Q4(z,Z);Q.set(F,j),J+=j.originalSize,G+=j.optimizedSize,Y.push(...j.warnings.map((L)=>`${F}: ${L}`));let H=N6(z);for(let L of H)W.add(L.name)}let K;if(Z.treeShake)K=o3(Array.from(W));let _;if(Z.stringPooling)_=new Map;let U=J>0?Math.round((1-G/J)*100):0;return{templates:Q,directiveBundle:K,stringPool:_,totalOriginalSize:J,totalOptimizedSize:G,overallReduction:U,warnings:Y}}function Y4($){return $.charAt(0).toUpperCase()+$.slice(1)}function V6($,X){let Z={},Q=$.trim();if(Q.startsWith("{"))Q=Q.slice(1);if(Q.endsWith("}"))Q=Q.slice(0,-1);if(Q=Q.trim(),!Q)return Z;let Y=0;while(Y<Q.length){while(Y<Q.length&&/\s/.test(Q[Y]))Y++;if(Y>=Q.length)break;let J="";if(Q[Y]==='"'||Q[Y]==="'"){let K=Q[Y];Y++;while(Y<Q.length&&Q[Y]!==K)if(Q[Y]==="\\"&&Y+1<Q.length)J+=Q[Y+1],Y+=2;else J+=Q[Y],Y++;Y++}else while(Y<Q.length&&/[\w$]/.test(Q[Y]))J+=Q[Y],Y++;while(Y<Q.length&&/\s/.test(Q[Y]))Y++;if(Q[Y]===":")Y++;while(Y<Q.length&&/\s/.test(Q[Y]))Y++;let G,W=Y;if(Q[Y]==='"'||Q[Y]==="'"){let K=Q[Y];Y++;let _="";while(Y<Q.length&&Q[Y]!==K)if(Q[Y]==="\\"&&Y+1<Q.length)_+=Q[Y+1],Y+=2;else _+=Q[Y],Y++;Y++,G=_}else if(Q[Y]==="{"){let K=1;Y++;while(Y<Q.length&&K>0){if(Q[Y]==="{")K++;else if(Q[Y]==="}")K--;else if(Q[Y]==='"'||Q[Y]==="'"){let U=Q[Y];Y++;while(Y<Q.length&&Q[Y]!==U){if(Q[Y]==="\\")Y++;Y++}}Y++}let _=Q.slice(W,Y);G=V6(_,X)}else if(Q[Y]==="["){let K=1;Y++;while(Y<Q.length&&K>0){if(Q[Y]==="[")K++;else if(Q[Y]==="]")K--;else if(Q[Y]==='"'||Q[Y]==="'"){let U=Q[Y];Y++;while(Y<Q.length&&Q[Y]!==U){if(Q[Y]==="\\")Y++;Y++}}Y++}let _=Q.slice(W,Y);try{G=JSON.parse(_.replace(/'/g,'"'))}catch{G=_}}else{let K="";while(Y<Q.length&&Q[Y]!==","&&!/\s/.test(Q[Y]))K+=Q[Y],Y++;if(K=K.trim(),K==="true")G=!0;else if(K==="false")G=!1;else if(K==="null")G=null;else if(K==="undefined")G=void 0;else if(/^-?\d+(\.\d+)?$/.test(K))G=Number(K);else if(K in X)G=X[K];else G=K}if(J)Z[J]=G;while(Y<Q.length&&/\s/.test(Q[Y]))Y++;if(Q[Y]===",")Y++}return Z}function DG($,X,Z){let Q=[];for(let[Y,J]of Object.entries(X)){let G=$[Y];if(J.required&&(G===void 0||G===null)){Q.push(`Component "${Z}": Missing required prop "${Y}"`);continue}if(G===void 0||G===null)continue;let W=Array.isArray(J.type)?J.type:[J.type];if(!W.includes("any")){let K=J4(G);if(!W.includes(K))Q.push(`Component "${Z}": Prop "${Y}" expected ${W.join(" | ")}, got ${K}`)}if(J.validator&&!J.validator(G))Q.push(`Component "${Z}": Prop "${Y}" failed custom validation`)}return Q}function wG($,X){let Z={...$};for(let[Q,Y]of Object.entries(X))if(Z[Q]===void 0&&Y.default!==void 0)Z[Q]=typeof Y.default==="function"?Y.default():Y.default;return Z}function J4($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}var G4={name:"component",handler:async($,X,Z,Q)=>{if(X.length<1)return t1("Component","component directive requires at least the component name",o1.INVALID_DIRECTIVE_SYNTAX);let Y=X[0].replace(/['"]/g,""),J={};if(X.length>1)try{let U=X.slice(1).join(",").trim();if(U.startsWith("{")){if(J=A6(U,Z),Object.keys(J).length===0)J=V6(U,Z)}else{let F=U.trim(),z=Z[F];if(z&&typeof z==="object"&&!Array.isArray(z))J=z}}catch(U){let F=U instanceof Error?U.message:String(U);return console.error("Component props parsing error:",F),t1("Component",`Error parsing component props: ${F}`,o1.EVALUATION_ERROR)}let G=Z.__stx_options||{},W=G.componentsDir||"components",K=new Set;if(!Z.__processedComponents)Z.__processedComponents=new Set;let _=Z.__processedComponents;try{return await q6(Y,J,"",W,Z,Q,G,_,K)}catch(U){console.error("Component rendering error:",U);let F=U instanceof Error?U.message:String(U);return t1("Component",`Error rendering component: ${F}`,o1.COMPONENT_RENDER_ERROR)}},hasEndTag:!1};function TG(){return[G4]}import{mkdir as W4,readFile as K4,readdir as _4,stat as M6,writeFile as U4}from"fs/promises";import B0 from"path";function T6($){if($==="connectedCallback")return`method "${$}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if($==="disconnectedCallback")return`method "${$}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${$}" is reserved`}var C6=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function B4($){return $.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join("")}function Q5($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function L4($){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test($)&&!$.startsWith("xml")&&!/[A-Z]/.test($)}function F4($){if($===!0)return"open";if($==="open"||$==="closed")return $;return!1}async function z4($){let X=[];async function Z(Q){let Y=await _4(Q,{withFileTypes:!0});Y.sort((J,G)=>J.name.localeCompare(G.name));for(let J of Y){let G=B0.join(Q,J.name);if(J.isDirectory()){if(!J.name.startsWith(".")&&J.name!=="node_modules")await Z(G)}else if(J.isFile()&&J.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(J.name))X.push(G)}}return await Z($),X}function j4($,X){let Z=$.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!Z)return{};let Q=Z[1].trim();if(!Q)return{};try{return JSON.parse(Q)}catch(Y){throw Error(`${X}: <script component> must contain JSON metadata (${Y.message})`)}}function H4($,X){let Z={},Q=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let Y of Q){if(!/\bclient\b/i.test(Y[1])||/\bcomponent\b|\bstx:component\b/i.test(Y[1]))continue;let J;try{J=new Bun.Transpiler({loader:"ts"}).transformSync(Y[2])}catch(K){throw Error(`${X}: failed to transpile <script client> (${K.message})`)}let G=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,W;while(W=G.exec(J)){let K=W[1];if(C6.has(K))throw Error(`${X}: client ${T6(K)}`);let _=G.lastIndex,U=1,F="",z=!1,j=_;for(;j<J.length&&U>0;j++){let L=J[j];if(z){z=!1;continue}if(F){if(L==="\\")z=!0;else if(L===F)F="";continue}if(L==='"'||L==="'"||L==="`")F=L;else if(L==="{")U++;else if(L==="}")U--}if(U!==0)throw Error(`${X}: unterminated client function "${K}"`);let H=W[0].includes("async")?"async ":"";Z[K]=`${H}${K}(${W[2]}) {${J.slice(_,j-1)}}`,G.lastIndex=j}}return Z}function O4($){let X=$.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(X?X[1]:$).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function E6($){return[...$.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((X)=>X[1].trim()).filter(Boolean).join(`
199
199
 
200
- `)}function W4($){if(!$)return null;let X=$.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(X))return"string";if(/^number$/.test(X))return"number";if(/^boolean$/.test(X))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(X))return"string";return"object"}function K4($){if($===void 0)return"object";if($==="true"||$==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test($))return"number";if(/^['"`]/.test($))return"string";return"object"}function _4($){if($==="true")return!0;if($==="false")return!1;if(/^-?\d+(?:\.\d+)?$/.test($))return Number($);if(/^['"`]/.test($))return $.slice(1,-1);try{return JSON.parse($)}catch{return}}function U4($){let X=[],Z=0,Q=$.replace(/\{\{--[\s\S]*?--\}\}/g,""),Y=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,J,G=(K)=>{if(Q[K]!=="(")return null;let _=0,U="";for(let F=K;F<Q.length;F++){let z=Q[F];if(U!==""){if(z==="\\")F++;else if(z===U)U="";continue}if(z==="'"||z==='"'||z==="`"){U=z;continue}if(z==="(")_++;else if(z===")"){if(_--,_===0)return{expression:Q.slice(K+1,F),end:F+1}}}return null},W=(K)=>{if(K==="")return;let _=0,U=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}/g,F;while(F=U.exec(K)){if(F.index>_)X.push(`out += ${JSON.stringify(K.slice(_,F.index))};`);X.push(F[1]!==void 0?`out += __raw(${F[1]});`:`out += __escape(${F[2]});`),_=F.index+F[0].length}if(_<K.length)X.push(`out += ${JSON.stringify(K.slice(_))};`)};while(J=Y.exec(Q)){W(Q.slice(Z,J.index)),Z=J.index+J[0].length;let _=J[1]==="if"||J[1]==="elseif"||J[1]==="foreach"?G(Z):null;if(_)Z=_.end,Y.lastIndex=_.end;let U=_?.expression;switch(J[1]){case"if":X.push(`if (${U}) {`);break;case"elseif":X.push(`} else if (${U}) {`);break;case"else":X.push("} else {");break;case"endif":case"endforeach":X.push("}");break;case"foreach":{let F=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec((U||"").trim());if(!F){X.push(`out += ${JSON.stringify(J[0]+(_?`(${U})`:""))};`);break}let[,z,j,H]=F;X.push(j?`for (const [${j}, ${H}] of __entries(${z})) {`:`for (const ${H} of __values(${z})) {`);break}}}return W(Q.slice(Z)),X.join(`
201
- `)}function n1($,X,Z,Q){if($[X]!==Z)return-1;let Y=0,J=null;for(let G=X;G<$.length;G++){let W=$[G];if(J){if(W==="\\"){G++;continue}if(W===J)J=null;continue}if(W==="'"||W==='"'||W==="`"){J=W;continue}if(W===Z)Y++;else if(W===Q){if(Q===">"&&$[G-1]==="=")continue;if(Y--,Y===0)return G+1}}return-1}function t$($,X,Z){let Q=Z?"([{<":"([{",Y=Z?")]}>":")]}",J=[],G=0,W=null,K="";for(let _=0;_<$.length;_++){let U=$[_];if(W){if(K+=U,U==="\\"){K+=$[++_]??"";continue}if(U===W)W=null;continue}if(U==="'"||U==='"'||U==="`"){W=U,K+=U;continue}if(Q.includes(U))G++;else if(Y.includes(U))G--;if(G===0&&X.includes(U)){J.push(K),K="";continue}K+=U}return J.push(K),J.map((_)=>_.trim()).filter(Boolean)}function B4($){let X=0,Z=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Z){if(Y==="\\"){Q++;continue}if(Y===Z)Z=null;continue}if(Y==="'"||Y==='"'||Y==="`"){Z=Y;continue}if("([{".includes(Y))X++;else if(")]}".includes(Y))X--;if(X!==0||Y!=="=")continue;let J=$[Q-1];if($[Q+1]==="="||J==="="||J==="!"||J==="<"||J===">")continue;return Q}return-1}function H6($){switch($.trim()){case"String":return"string";case"Number":return"number";case"Boolean":return"boolean";case"Array":return"unknown[]";case"Object":return"Record<string, unknown>";default:return}}function L4($){let X=/\bdefineProps\b/.exec($);if(!X)return null;let Z=/(?:^|[\s;{}()])(const|let|var)\s+/g,Q=-1;for(let N=Z.exec($);N&&N.index<X.index;N=Z.exec($))Q=N.index+N[0].indexOf(N[1]);if(Q===-1)return null;let Y={},J={},G=[],W=Q+(/^(?:const|let|var)\s+/.exec($.slice(Q))?.[0].length??0),K=()=>{while(W<$.length&&/\s/.test($[W]))W++},_;if($[W]==="{"){let N=n1($,W,"{","}");if(N===-1)return null;_=$.slice(W,N),W=N}else{let N=/^[A-Za-z_$][\w$]*/.exec($.slice(W));if(!N)return null;_=N[0],W+=N[0].length}if(K(),$[W]!=="=")return null;W++,K();let U=/^withDefaults\s*\(\s*/.exec($.slice(W)),F=Boolean(U);if(U)W+=U[0].length;let z=/^defineProps\b/.exec($.slice(W));if(!z)return null;W+=z[0].length;let j="";if(K(),$[W]==="<"){let N=n1($,W,"<",">");if(N===-1)return null;j=$.slice(W+1,N-1).trim(),W=N}if(K(),$[W]!=="(")return null;let H=n1($,W,"(",")");if(H===-1)return null;let L=$.slice(W+1,H-1).trim();if(W=H,F){if(K(),$[W]===",")W++,K();if($[W]==="{"){let N=n1($,W,"{","}");if(N===-1)return null;for(let[V,M]of e$($.slice(W,N)))J[V]=M;W=N}if(K(),$[W]===",")W++,K();if($[W]===")")W++}if($[W]===";")W++;let O=/^[A-Za-z_$][\w$]*$/.test(j)?j:void 0;if(j.startsWith("{"))for(let N of t$(j.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let V=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(N);if(V)Y[V[1]]=V[2].trim()}if(L.startsWith("{"))for(let[N,V]of e$(L)){if(G.push(N),!V.startsWith("{")){let M=H6(V);if(M)Y[N]=M;continue}for(let[M,q]of e$(V))if(M==="default")J[N]=q;else if(M==="type"){let A=H6(q);if(A)Y[N]=A}}else if(L.startsWith("["))for(let N of t$(L.slice(1,-1),",",!1))G.push(N.replace(/^['"`]/,"").replace(/['"`]$/,""));if(_.startsWith("{")){G.length=0;for(let N of t$(_.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let V=B4(N),q=(V===-1?N:N.slice(0,V)).split(":")[0].trim().replace(/^\.\.\./,"");if(!q)continue;if(G.push(q),V!==-1)J[q]=N.slice(V+1).trim()}}else if(G.length===0)G.push(...Object.keys(Y));return{text:$.slice(Q,W),propNames:G,defaults:J,declared:Y,typeName:O}}function e$($){let X=$.trim().replace(/^\{/,"").replace(/\}$/,""),Z=[],Q=0;while(Q<X.length){let Y=/\s*([A-Za-z_$][\w$]*)\s*:/y;Y.lastIndex=Q;let J=Y.exec(X);if(!J)break;Q=Y.lastIndex;let G=0,W="",K=Q;while(Q<X.length){let U=X[Q];if(W){if(U==="\\")Q++;else if(U===W)W=""}else if(U==="'"||U==='"'||U==="`")W=U;else if(U==="{"||U==="["||U==="(")G++;else if(U==="}"||U==="]"||U===")")G--;else if(U===","&&G===0)break;Q++}let _=X.slice(K,Q).trim();if(_)Z.push([J[1],_]);Q++}return Z}function F4($,X,Z){let Y=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].find((z)=>!/\bcomponent\b|\bstx:component\b|\bclient\b/i.test(z[1]));if(!Y)return{imports:[],body:"",propNames:[],defaults:{},declared:{}};let J=Y[2],G=[],W=[],K={},_={};J=J.replace(/^\s*import\s+[\s\S]*?from\s*['"][^'"]+['"];?\s*$/gm,(z)=>{if(/from\s*['"]stx['"]/.test(z))return"";return G.push(z.trim().replace(/(from\s*['"])(\.[^'"]*)(['"])/,(j,H,L,O)=>{let N=B0.resolve(B0.dirname(X),L),V=B0.relative(Z,N);return`${H}${V.startsWith(".")?V:`./${V}`}${O}`})),""});let U=L4(J);if(U)W.push(...U.propNames),Object.assign(K,U.defaults),Object.assign(_,U.declared),J=J.replace(U.text,"");let F={};for(let z of J.matchAll(/(?:export\s+)?interface\s+([A-Za-z_$][\w$]*)\s*\{([\s\S]*?)\n\}/g)){let j=[];for(let H of z[2].matchAll(/^\s*(?:\/\*\*[\s\S]*?\*\/\s*)?([A-Za-z_$][\w$]*)\??\s*:\s*([^\n;]+)/gm))_[H[1]]=H[2].trim(),j.push(H[1]);F[z[1]]=j}if(U&&U.propNames.length===0&&U.typeName){for(let z of F[U.typeName]??[])if(!W.includes(z))W.push(z)}return J=J.replace(/(?:export\s+)?interface\s+[A-Za-z_$][\w$]*\s*\{[\s\S]*?\n\}/g,""),{imports:G,body:J.trim(),propNames:W,defaults:K,declared:_}}function z4($){let X=new Set;return{template:$.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(Q,Y,J,G,W)=>{let K=Y.toLowerCase();X.add(K);let _=(J||"").split(".").filter(Boolean).join(" ");return` data-stx-on-${K}="${W}"${_?` data-stx-mod-${K}="${_}"`:""}`}),eventTypes:[...X].sort()}}function j4($){let X=[];return{template:$.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(Q,Y,J,G)=>{let W=X.length;return X.push({id:W,name:Y,expression:G}),` data-stx-bind-${W}=""`}),bindings:X}}function H4($){let X=new Set;for(let Z of $.matchAll(/<slot\b([^>]*)>/gi))X.add(Z[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...X].map((Z)=>({name:Z}))}function O4($){return[...new Set([...$.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((X)=>X[1]))].sort().map((X)=>({name:X}))}function O6($,X){if(!X||!new Set(["string","number","boolean","object","array"]).has(X.type))throw Error(`Property "${$}" must declare one of: string, number, boolean, object, array`);return{...X,reflect:X.reflect??X.attribute!==!1}}async function N4($,X,Z){let Q=B0.isAbsolute(X.file)?X.file:B0.resolve($,X.file),Y=await o3(Q,"utf8"),J=Y4(Y,Q),G=B0.basename(Q,".stx"),W=X.name||J.name||$4(G),K=`${$5(Z.prefix||"stx")}-${$5(G)}`,_=X.tag||J.tag||K;if(!W||!/^[A-Za-z_$][\w$]*$/.test(W))throw Error(`${Q}: invalid component class name "${W}"`);if(!X4(_))throw Error(`${Q}: invalid custom-element tag "${_}"; tags must be lowercase and contain a hyphen`);let U=X.properties||J.properties||J.props||{},F=Object.fromEntries(Object.entries(U).map(([M,q])=>[M,O6(M,q)])),z=z4(G4(Y)),j=j4(z.template),H=F4(Y,Q,B0.resolve(Z.outputDir)),L=U4(j.template);for(let M of H.propNames){if(F[M])continue;let q=H.defaults[M];F[M]=O6(M,{type:W4(H.declared[M])??K4(q),...q===void 0?{}:{default:_4(q)}})}let O=J.methods||{},N=X.methods||{},V=J4(Y,Q);return{file:B0.relative($,Q),sourcePath:Q,name:W,tag:_,description:X.description||J.description||"",template:j.template,styles:j6(Y),shadowMode:Z4(X.shadowDOM??J.shadowDOM??Z.shadowDOM),progressive:X.progressive??J.progressive??Z.progressive??!0,properties:F,events:X.events||J.events||{},methods:{...O,...N,...V},eventTypes:z.eventTypes,bindings:j.bindings,slots:H4(j.template),cssProperties:O4(j6(Y)),scope:H,render:L}}function q4(){let $=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),X=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
200
+ `)}function N4($){if(!$)return null;let X=$.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(X))return"string";if(/^number$/.test(X))return"number";if(/^boolean$/.test(X))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(X))return"string";return"object"}function A4($){if($===void 0)return"object";if($==="true"||$==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test($))return"number";if(/^['"`]/.test($))return"string";return"object"}function q4($){if($==="true")return!0;if($==="false")return!1;if(/^-?\d+(?:\.\d+)?$/.test($))return Number($);if(/^['"`]/.test($))return $.slice(1,-1);try{return JSON.parse($)}catch{return}}function V4($){let X=[],Z=0,Q=$.replace(/\{\{--[\s\S]*?--\}\}/g,""),Y=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,J,G=(K)=>{if(Q[K]!=="(")return null;let _=0,U="";for(let F=K;F<Q.length;F++){let z=Q[F];if(U!==""){if(z==="\\")F++;else if(z===U)U="";continue}if(z==="'"||z==='"'||z==="`"){U=z;continue}if(z==="(")_++;else if(z===")"){if(_--,_===0)return{expression:Q.slice(K+1,F),end:F+1}}}return null},W=(K)=>{if(K==="")return;let _=0,U=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}/g,F;while(F=U.exec(K)){if(F.index>_)X.push(`out += ${JSON.stringify(K.slice(_,F.index))};`);X.push(F[1]!==void 0?`out += __raw(${F[1]});`:`out += __escape(${F[2]});`),_=F.index+F[0].length}if(_<K.length)X.push(`out += ${JSON.stringify(K.slice(_))};`)};while(J=Y.exec(Q)){W(Q.slice(Z,J.index)),Z=J.index+J[0].length;let _=J[1]==="if"||J[1]==="elseif"||J[1]==="foreach"?G(Z):null;if(_)Z=_.end,Y.lastIndex=_.end;let U=_?.expression;switch(J[1]){case"if":X.push(`if (${U}) {`);break;case"elseif":X.push(`} else if (${U}) {`);break;case"else":X.push("} else {");break;case"endif":case"endforeach":X.push("}");break;case"foreach":{let F=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec((U||"").trim());if(!F){X.push(`out += ${JSON.stringify(J[0]+(_?`(${U})`:""))};`);break}let[,z,j,H]=F;X.push(j?`for (const [${j}, ${H}] of __entries(${z})) {`:`for (const ${H} of __values(${z})) {`);break}}}return W(Q.slice(Z)),X.join(`
201
+ `)}function e1($,X,Z,Q){if($[X]!==Z)return-1;let Y=0,J=null;for(let G=X;G<$.length;G++){let W=$[G];if(J){if(W==="\\"){G++;continue}if(W===J)J=null;continue}if(W==="'"||W==='"'||W==="`"){J=W;continue}if(W===Z)Y++;else if(W===Q){if(Q===">"&&$[G-1]==="=")continue;if(Y--,Y===0)return G+1}}return-1}function X5($,X,Z){let Q=Z?"([{<":"([{",Y=Z?")]}>":")]}",J=[],G=0,W=null,K="";for(let _=0;_<$.length;_++){let U=$[_];if(W){if(K+=U,U==="\\"){K+=$[++_]??"";continue}if(U===W)W=null;continue}if(U==="'"||U==='"'||U==="`"){W=U,K+=U;continue}if(Q.includes(U))G++;else if(Y.includes(U))G--;if(G===0&&X.includes(U)){J.push(K),K="";continue}K+=U}return J.push(K),J.map((_)=>_.trim()).filter(Boolean)}function M4($){let X=0,Z=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Z){if(Y==="\\"){Q++;continue}if(Y===Z)Z=null;continue}if(Y==="'"||Y==='"'||Y==="`"){Z=Y;continue}if("([{".includes(Y))X++;else if(")]}".includes(Y))X--;if(X!==0||Y!=="=")continue;let J=$[Q-1];if($[Q+1]==="="||J==="="||J==="!"||J==="<"||J===">")continue;return Q}return-1}function I6($){switch($.trim()){case"String":return"string";case"Number":return"number";case"Boolean":return"boolean";case"Array":return"unknown[]";case"Object":return"Record<string, unknown>";default:return}}function E4($){let X=/\bdefineProps\b/.exec($);if(!X)return null;let Z=/(?:^|[\s;{}()])(const|let|var)\s+/g,Q=-1;for(let N=Z.exec($);N&&N.index<X.index;N=Z.exec($))Q=N.index+N[0].indexOf(N[1]);if(Q===-1)return null;let Y={},J={},G=[],W=Q+(/^(?:const|let|var)\s+/.exec($.slice(Q))?.[0].length??0),K=()=>{while(W<$.length&&/\s/.test($[W]))W++},_;if($[W]==="{"){let N=e1($,W,"{","}");if(N===-1)return null;_=$.slice(W,N),W=N}else{let N=/^[A-Za-z_$][\w$]*/.exec($.slice(W));if(!N)return null;_=N[0],W+=N[0].length}if(K(),$[W]!=="=")return null;W++,K();let U=/^withDefaults\s*\(\s*/.exec($.slice(W)),F=Boolean(U);if(U)W+=U[0].length;let z=/^defineProps\b/.exec($.slice(W));if(!z)return null;W+=z[0].length;let j="";if(K(),$[W]==="<"){let N=e1($,W,"<",">");if(N===-1)return null;j=$.slice(W+1,N-1).trim(),W=N}if(K(),$[W]!=="(")return null;let H=e1($,W,"(",")");if(H===-1)return null;let L=$.slice(W+1,H-1).trim();if(W=H,F){if(K(),$[W]===",")W++,K();if($[W]==="{"){let N=e1($,W,"{","}");if(N===-1)return null;for(let[V,M]of Z5($.slice(W,N)))J[V]=M;W=N}if(K(),$[W]===",")W++,K();if($[W]===")")W++}if($[W]===";")W++;let O=/^[A-Za-z_$][\w$]*$/.test(j)?j:void 0;if(j.startsWith("{"))for(let N of X5(j.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let V=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(N);if(V)Y[V[1]]=V[2].trim()}if(L.startsWith("{"))for(let[N,V]of Z5(L)){if(G.push(N),!V.startsWith("{")){let M=I6(V);if(M)Y[N]=M;continue}for(let[M,A]of Z5(V))if(M==="default")J[N]=A;else if(M==="type"){let q=I6(A);if(q)Y[N]=q}}else if(L.startsWith("["))for(let N of X5(L.slice(1,-1),",",!1))G.push(N.replace(/^['"`]/,"").replace(/['"`]$/,""));if(_.startsWith("{")){G.length=0;for(let N of X5(_.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let V=M4(N),A=(V===-1?N:N.slice(0,V)).split(":")[0].trim().replace(/^\.\.\./,"");if(!A)continue;if(G.push(A),V!==-1)J[A]=N.slice(V+1).trim()}}else if(G.length===0)G.push(...Object.keys(Y));return{text:$.slice(Q,W),propNames:G,defaults:J,declared:Y,typeName:O}}function Z5($){let X=$.trim().replace(/^\{/,"").replace(/\}$/,""),Z=[],Q=0;while(Q<X.length){let Y=/\s*([A-Za-z_$][\w$]*)\s*:/y;Y.lastIndex=Q;let J=Y.exec(X);if(!J)break;Q=Y.lastIndex;let G=0,W="",K=Q;while(Q<X.length){let U=X[Q];if(W){if(U==="\\")Q++;else if(U===W)W=""}else if(U==="'"||U==='"'||U==="`")W=U;else if(U==="{"||U==="["||U==="(")G++;else if(U==="}"||U==="]"||U===")")G--;else if(U===","&&G===0)break;Q++}let _=X.slice(K,Q).trim();if(_)Z.push([J[1],_]);Q++}return Z}function I4($,X,Z){let Y=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].find((z)=>!/\bcomponent\b|\bstx:component\b|\bclient\b/i.test(z[1]));if(!Y)return{imports:[],body:"",propNames:[],defaults:{},declared:{}};let J=Y[2],G=[],W=[],K={},_={};J=J.replace(/^\s*import\s+[\s\S]*?from\s*['"][^'"]+['"];?\s*$/gm,(z)=>{if(/from\s*['"]stx['"]/.test(z))return"";return G.push(z.trim().replace(/(from\s*['"])(\.[^'"]*)(['"])/,(j,H,L,O)=>{let N=B0.resolve(B0.dirname(X),L),V=B0.relative(Z,N);return`${H}${V.startsWith(".")?V:`./${V}`}${O}`})),""});let U=E4(J);if(U)W.push(...U.propNames),Object.assign(K,U.defaults),Object.assign(_,U.declared),J=J.replace(U.text,"");let F={};for(let z of J.matchAll(/(?:export\s+)?interface\s+([A-Za-z_$][\w$]*)\s*\{([\s\S]*?)\n\}/g)){let j=[];for(let H of z[2].matchAll(/^\s*(?:\/\*\*[\s\S]*?\*\/\s*)?([A-Za-z_$][\w$]*)\??\s*:\s*([^\n;]+)/gm))_[H[1]]=H[2].trim(),j.push(H[1]);F[z[1]]=j}if(U&&U.propNames.length===0&&U.typeName){for(let z of F[U.typeName]??[])if(!W.includes(z))W.push(z)}return J=J.replace(/(?:export\s+)?interface\s+[A-Za-z_$][\w$]*\s*\{[\s\S]*?\n\}/g,""),{imports:G,body:J.trim(),propNames:W,defaults:K,declared:_}}function R4($){let X=new Set;return{template:$.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(Q,Y,J,G,W)=>{let K=Y.toLowerCase();X.add(K);let _=(J||"").split(".").filter(Boolean).join(" ");return` data-stx-on-${K}="${W}"${_?` data-stx-mod-${K}="${_}"`:""}`}),eventTypes:[...X].sort()}}function D4($){let X=[];return{template:$.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(Q,Y,J,G)=>{let W=X.length;return X.push({id:W,name:Y,expression:G}),` data-stx-bind-${W}=""`}),bindings:X}}function w4($){let X=new Set;for(let Z of $.matchAll(/<slot\b([^>]*)>/gi))X.add(Z[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...X].map((Z)=>({name:Z}))}function T4($){return[...new Set([...$.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((X)=>X[1]))].sort().map((X)=>({name:X}))}function R6($,X){if(!X||!new Set(["string","number","boolean","object","array"]).has(X.type))throw Error(`Property "${$}" must declare one of: string, number, boolean, object, array`);return{...X,reflect:X.reflect??X.attribute!==!1}}async function C4($,X,Z){let Q=B0.isAbsolute(X.file)?X.file:B0.resolve($,X.file),Y=await K4(Q,"utf8"),J=j4(Y,Q),G=B0.basename(Q,".stx"),W=X.name||J.name||B4(G),K=`${Q5(Z.prefix||"stx")}-${Q5(G)}`,_=X.tag||J.tag||K;if(!W||!/^[A-Za-z_$][\w$]*$/.test(W))throw Error(`${Q}: invalid component class name "${W}"`);if(!L4(_))throw Error(`${Q}: invalid custom-element tag "${_}"; tags must be lowercase and contain a hyphen`);let U=X.properties||J.properties||J.props||{},F=Object.fromEntries(Object.entries(U).map(([M,A])=>[M,R6(M,A)])),z=R4(O4(Y)),j=D4(z.template),H=I4(Y,Q,B0.resolve(Z.outputDir)),L=V4(j.template);for(let M of H.propNames){if(F[M])continue;let A=H.defaults[M];F[M]=R6(M,{type:N4(H.declared[M])??A4(A),...A===void 0?{}:{default:q4(A)}})}let O=J.methods||{},N=X.methods||{},V=H4(Y,Q);return{file:B0.relative($,Q),sourcePath:Q,name:W,tag:_,description:X.description||J.description||"",template:j.template,styles:E6(Y),shadowMode:F4(X.shadowDOM??J.shadowDOM??Z.shadowDOM),progressive:X.progressive??J.progressive??Z.progressive??!0,properties:F,events:X.events||J.events||{},methods:{...O,...N,...V},eventTypes:z.eventTypes,bindings:j.bindings,slots:w4(j.template),cssProperties:T4(E6(Y)),scope:H,render:L}}function k4(){let $=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),X=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
202
202
 
203
203
  const escapeHTML = (value) => String(value ?? '')
204
204
  .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
@@ -496,7 +496,7 @@ export function defineComponent(Component, definition) {
496
496
  }
497
497
  return Component;
498
498
  }
499
- `}function A4($){let X=JSON.stringify({tag:$.tag,template:$.template,styles:$.styles,shadowMode:$.shadowMode,progressive:$.progressive,properties:$.properties,eventTypes:$.eventTypes,bindings:$.bindings},null,2),Z=Object.entries($.methods).map(([W,K])=>{if(V6.has(W))throw Error(`${$.sourcePath}: ${A6(W)}`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(K.trim()))return` ${K.trim()}`;return` ${W}($event) {
499
+ `}function x4($){let X=JSON.stringify({tag:$.tag,template:$.template,styles:$.styles,shadowMode:$.shadowMode,progressive:$.progressive,properties:$.properties,eventTypes:$.eventTypes,bindings:$.bindings},null,2),Z=Object.entries($.methods).map(([W,K])=>{if(C6.has(W))throw Error(`${$.sourcePath}: ${T6(W)}`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(K.trim()))return` ${K.trim()}`;return` ${W}($event) {
500
500
  ${K}
501
501
  }`}).join(`
502
502
 
@@ -521,8 +521,8 @@ ${Z}${G}
521
521
 
522
522
  defineComponent(${$.name}, ${X});
523
523
  export default ${$.name};
524
- `}function o1($){switch($.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function V4($){let X=Object.entries($.properties).map(([J,G])=>` ${J}${G.required?"":"?"}: ${o1(G)}`).join(`
525
- `),Z=Object.entries($.properties).map(([J,G])=>` ${J}: ${o1(G)}`).join(`
524
+ `}function $$($){switch($.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function S4($){let X=Object.entries($.properties).map(([J,G])=>` ${J}${G.required?"":"?"}: ${$$(G)}`).join(`
525
+ `),Z=Object.entries($.properties).map(([J,G])=>` ${J}: ${$$(G)}`).join(`
526
526
  `),Q=Object.entries($.events).map(([J,G])=>` ${JSON.stringify(J)}: CustomEvent<${G.detailType||"unknown"}>`).join(`
527
527
  `),Y=Object.keys($.methods).map((J)=>` ${J}($event?: Event): unknown`).join(`
528
528
  `);return`export interface ${$.name}Props {
@@ -548,10 +548,10 @@ declare global {
548
548
  }
549
549
 
550
550
  export default ${$.name}
551
- `}function M4($){return`declare global {
551
+ `}function P4($){return`declare global {
552
552
  namespace JSX {
553
553
  interface IntrinsicElements {
554
- ${$.map((Z)=>{let Q=Object.entries(Z.properties).map(([J,G])=>` ${JSON.stringify(J)}?: ${o1(G)}`).join(`
554
+ ${$.map((Z)=>{let Q=Object.entries(Z.properties).map(([J,G])=>` ${JSON.stringify(J)}?: ${$$(G)}`).join(`
555
555
  `),Y=Object.keys(Z.events).map((J)=>{return` ${`on${J.split(/[-:]/).map((W)=>W.charAt(0).toUpperCase()+W.slice(1)).join("")}`}?: (event: CustomEvent<${Z.events[J].detailType||"unknown"}>) => void`}).join(`
556
556
  `);return` ${JSON.stringify(Z.tag)}: {
557
557
  ${Q}
@@ -567,9 +567,9 @@ ${Y}
567
567
  }
568
568
 
569
569
  export {}
570
- `}function E4($){return{schemaVersion:"1.0.0",modules:$.map((X)=>({kind:"javascript-module",path:`./${X.tag}.js`,declarations:[{kind:"class",name:X.name,description:X.description||void 0,customElement:!0,tagName:X.tag,members:Object.entries(X.properties).map(([Z,Q])=>({kind:"field",name:Z,description:Q.description,type:{text:o1(Q)},default:Q.default===void 0?void 0:JSON.stringify(Q.default),attribute:Q.attribute===!1?void 0:Q.attribute||$5(Z),reflects:Q.reflect})),events:Object.entries(X.events).map(([Z,Q])=>({name:Z,description:Q.description,type:{text:`CustomEvent<${Q.detailType||"unknown"}>`}})),slots:X.slots,cssProperties:X.cssProperties}],exports:[{kind:"js",name:X.name,declaration:{name:X.name,module:`./${X.tag}.js`}}]}))}}function N6($){if(!$.styles)return"";let X=$.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(X))return X;return`@scope (${$.tag}) {
570
+ `}function b4($){return{schemaVersion:"1.0.0",modules:$.map((X)=>({kind:"javascript-module",path:`./${X.tag}.js`,declarations:[{kind:"class",name:X.name,description:X.description||void 0,customElement:!0,tagName:X.tag,members:Object.entries(X.properties).map(([Z,Q])=>({kind:"field",name:Z,description:Q.description,type:{text:$$(Q)},default:Q.default===void 0?void 0:JSON.stringify(Q.default),attribute:Q.attribute===!1?void 0:Q.attribute||Q5(Z),reflects:Q.reflect})),events:Object.entries(X.events).map(([Z,Q])=>({name:Z,description:Q.description,type:{text:`CustomEvent<${Q.detailType||"unknown"}>`}})),slots:X.slots,cssProperties:X.cssProperties}],exports:[{kind:"js",name:X.name,declaration:{name:X.name,module:`./${X.tag}.js`}}]}))}}function D6($){if(!$.styles)return"";let X=$.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(X))return X;return`@scope (${$.tag}) {
571
571
  ${X}
572
- }`}function q6($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function I4($){let X=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),Z=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),Q=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),Y=Object.fromEntries($.map((G)=>[G.tag,{template:G.template,styles:G.styles,shadowMode:G.shadowMode,properties:G.properties}])),J=$.map((G)=>`export const render${G.name} = (props = {}, slots = {}) => renderComponent('${G.tag}', props, slots);`).join(`
572
+ }`}function w6($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function y4($){let X=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),Z=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),Q=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),Y=Object.fromEntries($.map((G)=>[G.tag,{template:G.template,styles:G.styles,shadowMode:G.shadowMode,properties:G.properties}])),J=$.map((G)=>`export const render${G.name} = (props = {}, slots = {}) => renderComponent('${G.tag}', props, slots);`).join(`
573
573
  `);return`const definitions = ${JSON.stringify(Y,null,2)};
574
574
  const escapeHTML = (value) => String(value ?? '')
575
575
  .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
@@ -603,21 +603,21 @@ export function renderComponent(tag, props = {}, slots = {}) {
603
603
  }
604
604
 
605
605
  ${J}
606
- `}async function HG($){let X=B0.resolve($.inputDir),Z=B0.resolve($.outputDir);if(!(await z6(X).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${X}`);let Y=$.components?.length?$.components:(await Q4(X)).map((L)=>({file:L}));if(!Y.length)throw Error(`No .stx components found in ${X}`);let J=await Promise.all(Y.map((L)=>N4(X,L,$)));J.sort((L,O)=>L.tag.localeCompare(O.tag));let G=J.filter((L,O)=>J.findIndex((N)=>N.tag===L.tag)!==O);if(G.length)throw Error(`Duplicate custom-element tag: ${G[0].tag}`);let W=J.filter((L,O)=>J.findIndex((N)=>N.name===L.name)!==O);if(W.length)throw Error(`Duplicate component class name: ${W[0].name}`);await n3(Z,{recursive:!0});let K=[],_=async(L,O)=>{let N=B0.join(Z,L);return await e3(N,O.endsWith(`
606
+ `}async function SG($){let X=B0.resolve($.inputDir),Z=B0.resolve($.outputDir);if(!(await M6(X).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${X}`);let Y=$.components?.length?$.components:(await z4(X)).map((L)=>({file:L}));if(!Y.length)throw Error(`No .stx components found in ${X}`);let J=await Promise.all(Y.map((L)=>C4(X,L,$)));J.sort((L,O)=>L.tag.localeCompare(O.tag));let G=J.filter((L,O)=>J.findIndex((N)=>N.tag===L.tag)!==O);if(G.length)throw Error(`Duplicate custom-element tag: ${G[0].tag}`);let W=J.filter((L,O)=>J.findIndex((N)=>N.name===L.name)!==O);if(W.length)throw Error(`Duplicate component class name: ${W[0].name}`);await W4(Z,{recursive:!0});let K=[],_=async(L,O)=>{let N=B0.join(Z,L);return await U4(N,O.endsWith(`
607
607
  `)?O:`${O}
608
- `,"utf8"),K.push(N),N};await _("runtime.js",q4());for(let L of J){if(await _(`${L.tag}.js`,A4(L)),$.declarations!==!1)await _(`${L.tag}.d.ts`,V4(L));if($.css!==!1&&L.styles){let O=L.shadowMode?L.styles:N6(L);await _(`${L.tag}.css`,$.minify?q6(O):O)}}let U=J.map((L)=>`export { ${L.name}, default as ${L.name}Element } from './${L.tag}.js';`).join(`
609
- `);if(await _("index.js",U),await _("ssr.js",I4(J)),$.declarations!==!1)await _("index.d.ts",J.map((L)=>`export * from './${L.tag}.js'`).join(`
610
- `)),await _("custom-elements.d.ts",M4(J)),await _("ssr.d.ts",`${J.map((L)=>`export declare const render${L.name}: (props?: ${L.name}Props, slots?: Record<string, string>) => string`).join(`
608
+ `,"utf8"),K.push(N),N};await _("runtime.js",k4());for(let L of J){if(await _(`${L.tag}.js`,x4(L)),$.declarations!==!1)await _(`${L.tag}.d.ts`,S4(L));if($.css!==!1&&L.styles){let O=L.shadowMode?L.styles:D6(L);await _(`${L.tag}.css`,$.minify?w6(O):O)}}let U=J.map((L)=>`export { ${L.name}, default as ${L.name}Element } from './${L.tag}.js';`).join(`
609
+ `);if(await _("index.js",U),await _("ssr.js",y4(J)),$.declarations!==!1)await _("index.d.ts",J.map((L)=>`export * from './${L.tag}.js'`).join(`
610
+ `)),await _("custom-elements.d.ts",P4(J)),await _("ssr.d.ts",`${J.map((L)=>`export declare const render${L.name}: (props?: ${L.name}Props, slots?: Record<string, string>) => string`).join(`
611
611
  `)}
612
612
  export declare function renderComponent(tag: string, props?: Record<string, unknown>, slots?: Record<string, string>): string
613
613
  ${J.map((L)=>`import type { ${L.name}Props } from './${L.tag}.js'`).join(`
614
- `)}`);let F;if($.manifest!==!1)F=await _("custom-elements.json",JSON.stringify(E4(J),null,2));let z;if($.css!==!1){let L=J.filter((O)=>!O.shadowMode&&O.styles).map(N6).join(`
614
+ `)}`);let F;if($.manifest!==!1)F=await _("custom-elements.json",JSON.stringify(b4(J),null,2));let z;if($.css!==!1){let L=J.filter((O)=>!O.shadowMode&&O.styles).map(D6).join(`
615
615
 
616
- `);if(L)z=await _("bundle.css",$.minify?q6(L):L)}let j;if($.bundle!==!1){j=B0.join(Z,"bundle.js");let L;try{L=await Bun.build({entrypoints:[B0.join(Z,"index.js")],outdir:Z,naming:"bundle.js",target:"browser",format:"esm",minify:$.minify??!0,sourcemap:$.sourcemap||"none"})}catch(O){let N=O instanceof AggregateError?O.errors:[O],V=N.map((M)=>String(M).trim()).filter(Boolean).join(`
616
+ `);if(L)z=await _("bundle.css",$.minify?w6(L):L)}let j;if($.bundle!==!1){j=B0.join(Z,"bundle.js");let L;try{L=await Bun.build({entrypoints:[B0.join(Z,"index.js")],outdir:Z,naming:"bundle.js",target:"browser",format:"esm",minify:$.minify??!0,sourcemap:$.sourcemap||"none"})}catch(O){let N=O instanceof AggregateError?O.errors:[O],V=N.map((M)=>String(M).trim()).filter(Boolean).join(`
617
617
  `);throw AggregateError(N,`Failed to bundle component library${V?`
618
618
  ${V}`:""}`)}if(!L.success){let O=L.logs.map((N)=>String(N).trim()).filter(Boolean).join(`
619
619
  `);throw AggregateError(L.logs,`Failed to bundle component library${O?`
620
- ${O}`:""}`)}if(K.push(j),$.sourcemap==="external")K.push(`${j}.map`)}let H=await Promise.all(K.map(async(L)=>(await z6(L)).size));return{components:J.map((L)=>({name:L.name,tag:L.tag,source:L.sourcePath,module:B0.join(Z,`${L.tag}.js`)})),files:K,manifest:F,bundle:j,cssBundle:z,totalBytes:H.reduce((L,O)=>L+O,0)}}var{serve:P4}=globalThis.Bun;import Z5 from"fs";import K1 from"path";function t1(){return`
620
+ ${O}`:""}`)}if(K.push(j),$.sourcemap==="external")K.push(`${j}.map`)}let H=await Promise.all(K.map(async(L)=>(await M6(L)).size));return{components:J.map((L)=>({name:L.name,tag:L.tag,source:L.sourcePath,module:B0.join(Z,`${L.tag}.js`)})),files:K,manifest:F,bundle:j,cssBundle:z,totalBytes:H.reduce((L,O)=>L+O,0)}}var{serve:c4}=globalThis.Bun;import J5 from"fs";import _1 from"path";function X$(){return`
621
621
  /* Theme selector for code blocks */
622
622
  .theme-selector {
623
623
  margin: 1rem 0;
@@ -667,13 +667,13 @@ ${O}`:""}`)}if(K.push(j),$.sourcemap==="external")K.push(`${j}.map`)}let H=await
667
667
 
668
668
  body.dark-mode a {
669
669
  color: #58a6ff;
670
- }`}function e1($){return`
670
+ }`}function Z$($){return`
671
671
  <div class="theme-selector">
672
672
  Theme:
673
673
  <select id="themeSelector" onchange="changeTheme()">
674
674
  ${$}
675
675
  </select>
676
- </div>`}function $$(){return`
676
+ </div>`}function Q$(){return`
677
677
  function changeTheme() {
678
678
  const theme = document.getElementById('themeSelector').value;
679
679
 
@@ -689,7 +689,7 @@ else {
689
689
  }
690
690
 
691
691
  // Initialize theme on page load
692
- document.addEventListener('DOMContentLoaded', changeTheme);`}function X$($){if(Object.keys($).length===0)return"";return`
692
+ document.addEventListener('DOMContentLoaded', changeTheme);`}function Y$($){if(Object.keys($).length===0)return"";return`
693
693
  <div class="frontmatter">
694
694
  <h3>Frontmatter</h3>
695
695
  ${Object.entries($).map(([X,Z])=>`
@@ -697,19 +697,19 @@ else {
697
697
  <span class="frontmatter-label">${X}:</span>
698
698
  <span>${Array.isArray(Z)?Z.join(", "):String(Z)}</span>
699
699
  </div>`).join("")}
700
- </div>`}import M6 from"net";async function R4($){return new Promise((X)=>{let Z=M6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"0.0.0.0")})}async function D4($){return new Promise((X)=>{let Z=M6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"::")})}async function w4($){if(!await R4($))return!1;return await D4($)}async function u0($,X=20){$=Number($);for(let Z=0;Z<X;Z++){let Q=$+Z;if(await w4(Q))return Q}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var T4={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function C4(){try{let $=await import("./chunk-pyyccs6a.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function W1($,X={}){let Z={...T4,...X},Q=await C4();if(!Q)return console.log(`${B.yellow}\u26A0${B.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let Y=await Q.openDevWindow($,{title:Z.title,width:Z.width,height:Z.height,darkMode:Z.darkMode,hotReload:Z.hotReload,titlebarHidden:Z.titlebarHidden,nativeSidebar:Z.nativeSidebar,sidebarWidth:Z.sidebarWidth,sidebarConfig:Z.sidebarConfig});if(Y&&Z.nativeSidebar)console.log(`${B.green}\u2713${B.reset} Native sidebar enabled (macOS Tahoe style)`);return Y}catch(Y){return console.log(`${B.red}\u2717${B.reset} Could not open native window:`,Y),!1}}function Z$($){if($.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let Y=$.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(Y){let J=Y[1];try{let G=`
700
+ </div>`}import k6 from"net";async function v4($){return new Promise((X)=>{let Z=k6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"0.0.0.0")})}async function g4($){return new Promise((X)=>{let Z=k6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"::")})}async function f4($){if(!await v4($))return!1;return await g4($)}async function u0($,X=20){$=Number($);for(let Z=0;Z<X;Z++){let Q=$+Z;if(await f4(Q))return Q}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var h4={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function d4(){try{let $=await import("./chunk-gvbf1mhs.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function K1($,X={}){let Z={...h4,...X},Q=await d4();if(!Q)return console.log(`${B.yellow}\u26A0${B.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let Y=await Q.openDevWindow($,{title:Z.title,width:Z.width,height:Z.height,darkMode:Z.darkMode,hotReload:Z.hotReload,titlebarHidden:Z.titlebarHidden,nativeSidebar:Z.nativeSidebar,sidebarWidth:Z.sidebarWidth,sidebarConfig:Z.sidebarConfig});if(Y&&Z.nativeSidebar)console.log(`${B.green}\u2713${B.reset} Native sidebar enabled (macOS Tahoe style)`);return Y}catch(Y){return console.log(`${B.red}\u2717${B.reset} Could not open native window:`,Y),!1}}function J$($){if($.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let Y=$.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(Y){let J=Y[1];try{let G=`
701
701
  ${J}
702
702
  return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
703
- `,K=Function(G)();if(K)return K}catch(G){console.warn("Invalid sidebarConfig:",G)}}return{sections:[]}}let Z=$.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(Z)try{return JSON.parse(Z[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let Q=$.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(Q)try{let Y=Q[1].match(/(?:export\s+(?:default\s+)?|const\s+\w+\s*=\s*)(\{[\s\S]*\})/m);if(Y)return Function(`return ${Y[1]}`)()}catch(Y){console.warn("Invalid native-sidebar script configuration:",Y)}return}function X5(){console.log(`
704
- Keyboard shortcuts:`),console.log(` ${B.cyan}o${B.reset} + Enter - Open in browser`),console.log(` ${B.cyan}c${B.reset} + Enter - Clear console`),console.log(` ${B.cyan}q${B.reset} + Enter (or ${B.cyan}Ctrl+C${B.reset}) - Quit server`),console.log(` ${B.cyan}h${B.reset} + Enter - Show this help`)}function k4($){console.log(`${B.green}Server running at ${B.cyan}${$}${B.reset}`),console.log(`Press ${B.cyan}Ctrl+C${B.reset} to stop the server`),X5()}function x4($){console.log(`${B.dim}Opening ${B.cyan}${$}${B.dim} in your browser...${B.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function m0($,X,Z){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),X5();let Q="";process.stdin.on("data",(Y)=>{if(Y==="\x03"){if(Z?.onQuit)Z.onQuit();X(),process.exit(0)}if(Q+=Y,Q.endsWith("\r")||Q.endsWith(`
705
- `)){let J=Q.trim().toLowerCase();Q="",S4(J,$,X,Z)}})}function S4($,X,Z,Q){switch($){case"o":if(Q?.onOpen)Q.onOpen();else x4(X);break;case"c":if(Q?.onClear)Q.onClear();else console.clear(),k4(X);break;case"q":if(Q?.onQuit)Q.onQuit();console.log(`${B.yellow}Stopping server...${B.reset}`),Z(),process.exit(0);break;case"h":if(Q?.onHelp)Q.onHelp();else X5();break;default:break}}async function Q5($,X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=K1.resolve($);if(!Z5.existsSync(Y))return console.error(`${B.red}Error: File not found: ${B.bright}${Y}${B.reset}`),!1;if(!Y.endsWith(".md"))return console.error(`${B.red}Error: File must have .md extension: ${B.bright}${Y}${B.reset}`),!1;console.log(`${B.blue}Processing${B.reset} ${B.bright}${$}${B.reset}...`);let J=null,G=async()=>{try{let{content:F,data:z}=await k0(Y,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:C0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),j=X.markdown?.syntaxHighlighting||C0.markdown?.syntaxHighlighting,H=j?.defaultTheme||"github-dark",L=["github-dark"],O=j?.additionalThemes||[],V=[...new Set([...L,...O])].map((M)=>`<option value="${M}"${M===H?" selected":""}>${M}</option>`).join(`
703
+ `,K=Function(G)();if(K)return K}catch(G){console.warn("Invalid sidebarConfig:",G)}}return{sections:[]}}let Z=$.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(Z)try{return JSON.parse(Z[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let Q=$.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(Q)try{let Y=Q[1].match(/(?:export\s+(?:default\s+)?|const\s+\w+\s*=\s*)(\{[\s\S]*\})/m);if(Y)return Function(`return ${Y[1]}`)()}catch(Y){console.warn("Invalid native-sidebar script configuration:",Y)}return}function Y5(){console.log(`
704
+ Keyboard shortcuts:`),console.log(` ${B.cyan}o${B.reset} + Enter - Open in browser`),console.log(` ${B.cyan}c${B.reset} + Enter - Clear console`),console.log(` ${B.cyan}q${B.reset} + Enter (or ${B.cyan}Ctrl+C${B.reset}) - Quit server`),console.log(` ${B.cyan}h${B.reset} + Enter - Show this help`)}function u4($){console.log(`${B.green}Server running at ${B.cyan}${$}${B.reset}`),console.log(`Press ${B.cyan}Ctrl+C${B.reset} to stop the server`),Y5()}function m4($){console.log(`${B.dim}Opening ${B.cyan}${$}${B.dim} in your browser...${B.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function m0($,X,Z){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),Y5();let Q="";process.stdin.on("data",(Y)=>{if(Y==="\x03"){if(Z?.onQuit)Z.onQuit();X(),process.exit(0)}if(Q+=Y,Q.endsWith("\r")||Q.endsWith(`
705
+ `)){let J=Q.trim().toLowerCase();Q="",p4(J,$,X,Z)}})}function p4($,X,Z,Q){switch($){case"o":if(Q?.onOpen)Q.onOpen();else m4(X);break;case"c":if(Q?.onClear)Q.onClear();else console.clear(),u4(X);break;case"q":if(Q?.onQuit)Q.onQuit();console.log(`${B.yellow}Stopping server...${B.reset}`),Z(),process.exit(0);break;case"h":if(Q?.onHelp)Q.onHelp();else Y5();break;default:break}}async function G5($,X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=_1.resolve($);if(!J5.existsSync(Y))return console.error(`${B.red}Error: File not found: ${B.bright}${Y}${B.reset}`),!1;if(!Y.endsWith(".md"))return console.error(`${B.red}Error: File must have .md extension: ${B.bright}${Y}${B.reset}`),!1;console.log(`${B.blue}Processing${B.reset} ${B.bright}${$}${B.reset}...`);let J=null,G=async()=>{try{let{content:F,data:z}=await k0(Y,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:C0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),j=X.markdown?.syntaxHighlighting||C0.markdown?.syntaxHighlighting,H=j?.defaultTheme||"github-dark",L=["github-dark"],O=j?.additionalThemes||[],V=[...new Set([...L,...O])].map((M)=>`<option value="${M}"${M===H?" selected":""}>${M}</option>`).join(`
706
706
  `);return J=`
707
707
  <!DOCTYPE html>
708
708
  <html lang="en">
709
709
  <head>
710
710
  <meta charset="UTF-8">
711
711
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
712
- <title>${b4(z.title||K1.basename(Y))}</title>
712
+ <title>${l4(z.title||_1.basename(Y))}</title>
713
713
  <!-- Syntax highlighting styles -->
714
714
  <style id="syntax-theme">
715
715
  :root {
@@ -851,26 +851,26 @@ Keyboard shortcuts:`),console.log(` ${B.cyan}o${B.reset} + Enter - Open in brow
851
851
  min-width: 100px;
852
852
  color: #555;
853
853
  }
854
- ${t1()}
854
+ ${X$()}
855
855
  </style>
856
856
  </head>
857
857
  <body>
858
- ${X$(z)}
859
- ${e1(V)}
858
+ ${Y$(z)}
859
+ ${Z$(V)}
860
860
 
861
861
  ${F}
862
862
 
863
863
  <script>
864
- ${$$()}
864
+ ${Q$()}
865
865
  </script>
866
866
  </body>
867
867
  </html>
868
- `,!0}catch(F){return console.error(`${B.red}Error processing Markdown file:${B.reset}`,F),!1}};if(!await G())return!1;let K=Z;try{if(K=await u0(Z),K!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${K} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${K}/${B.reset}...`);let _=P4({port:K,fetch(F){if(new URL(F.url).pathname==="/")return new Response(J,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}});return new Response("Not Found",{status:404})},error(F){return new Response(`<pre>${F}
868
+ `,!0}catch(F){return console.error(`${B.red}Error processing Markdown file:${B.reset}`,F),!1}};if(!await G())return!1;let K=Z;try{if(K=await u0(Z),K!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${K} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${K}/${B.reset}...`);let _=c4({port:K,fetch(F){if(new URL(F.url).pathname==="/")return new Response(J,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}});return new Response("Not Found",{status:404})},error(F){return new Response(`<pre>${F}
869
869
  ${F.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
870
870
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
871
871
  ${B.bright}\u2192 ${B.cyan}http://localhost:${K}/${B.reset}`),console.log(`
872
- ${B.yellow}Routes:${B.reset}`);let U=K1.relative(process.cwd(),Y);if(console.log(` ${B.green}\u2514\u2500 /${B.reset} \u2192 ${B.bright}${U}${B.reset}`),console.log(`
873
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(_.url.toString(),()=>{if(Q)Z5.watch(K1.dirname(Y),{recursive:!0}).close();_.stop()}),X.native)await W1(K,{title:K1.basename(Y,".md")});if(Q){let F=K1.dirname(Y);console.log(`${B.blue}Watching ${B.bright}${F}${B.reset} for changes...`);let z=Z5.watch(F,{recursive:!0},async(j,H)=>{if(H&&H.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${H}${B.yellow} changed, reprocessing...${B.reset}`),await G()});process.on("SIGINT",()=>{z.close(),_.stop(),process.exit(0)})}return!0}function b4($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:v4}=globalThis.Bun;import R0 from"fs";import Q0 from"path";class E6{clients=new Set;server=null;options;constructor($={}){this.options={wsPort:$.wsPort??3001,showOverlay:$.showOverlay??!0,reconnectInterval:$.reconnectInterval??1000,maxReconnectAttempts:$.maxReconnectAttempts??10,verbose:$.verbose??!1}}start($){let X=$??this.options.wsPort,Z=20;for(let Q=0;Q<Z;Q++)try{if(this.server=Bun.serve({port:X,fetch(Y,J){if(J.upgrade(Y,{data:{}}))return;return new Response("stx Hot Reload Server",{headers:{"Content-Type":"text/plain"}})},websocket:{open:(Y)=>{if(this.clients.add(Y),this.options.verbose)console.log(`[HMR] Client connected (${this.clients.size} total)`);Y.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close:(Y)=>{if(this.clients.delete(Y),this.options.verbose)console.log(`[HMR] Client disconnected (${this.clients.size} total)`)},message:(Y,J)=>{let G=typeof J==="string"?J:J.toString();if(G==="ping")return;try{let W=JSON.parse(G);if(W.type==="console"&&Array.isArray(W.args)){let K=W.args.join(" "),U={log:"\x1B[36m",warn:"\x1B[33m",error:"\x1B[31m",info:"\x1B[34m"}[W.level]??"\x1B[36m";console.log(`${U}[browser]${W.level!=="log"?` ${W.level}`:""}\x1B[0m ${K}`)}}catch{}}}}),this.options.verbose)console.log(`[HMR] WebSocket server started on port ${X}`);return X}catch(Y){if(Y?.code==="EADDRINUSE"){X++;continue}throw Y}throw Error(`Could not find an available port after ${Z} attempts starting from ${$??this.options.wsPort}`)}stop(){for(let $ of this.clients)try{$.close()}catch{}if(this.clients.clear(),this.server)this.server.stop(),this.server=null;if(this.options.verbose)console.log("[HMR] Server stopped")}broadcast($){let X=JSON.stringify($),Z=0;for(let Q of this.clients)try{if(Q.readyState===1)Q.send(X),Z++}catch{this.clients.delete(Q)}if(this.options.verbose&&Z>0)console.log(`[HMR] Broadcast ${$.type} to ${Z} client(s)`)}reload($){if(this.options.verbose)console.log(`[HMR] Sending reload to ${this.clients.size} client(s) for: ${$||"all"}`);this.broadcast({type:"reload",path:$,timestamp:Date.now()})}updateCss($,X){this.broadcast({type:"css-update",path:$,content:X,timestamp:Date.now()})}error($){this.broadcast({type:"error",content:$,timestamp:Date.now()})}get clientCount(){return this.clients.size}get port(){return this.options.wsPort}}function y4($,X={}){let{showOverlay:Z=!0,reconnectInterval:Q=1000,maxReconnectAttempts:Y=10}=X;return`
872
+ ${B.yellow}Routes:${B.reset}`);let U=_1.relative(process.cwd(),Y);if(console.log(` ${B.green}\u2514\u2500 /${B.reset} \u2192 ${B.bright}${U}${B.reset}`),console.log(`
873
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(_.url.toString(),()=>{if(Q)J5.watch(_1.dirname(Y),{recursive:!0}).close();_.stop()}),X.native)await K1(K,{title:_1.basename(Y,".md")});if(Q){let F=_1.dirname(Y);console.log(`${B.blue}Watching ${B.bright}${F}${B.reset} for changes...`);let z=J5.watch(F,{recursive:!0},async(j,H)=>{if(H&&H.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${H}${B.yellow} changed, reprocessing...${B.reset}`),await G()});process.on("SIGINT",()=>{z.close(),_.stop(),process.exit(0)})}return!0}function l4($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:a4}=globalThis.Bun;import R0 from"fs";import Q0 from"path";class x6{clients=new Set;server=null;options;constructor($={}){this.options={wsPort:$.wsPort??3001,showOverlay:$.showOverlay??!0,reconnectInterval:$.reconnectInterval??1000,maxReconnectAttempts:$.maxReconnectAttempts??10,verbose:$.verbose??!1}}start($){let X=$??this.options.wsPort,Z=20;for(let Q=0;Q<Z;Q++)try{if(this.server=Bun.serve({port:X,fetch(Y,J){if(J.upgrade(Y,{data:{}}))return;return new Response("stx Hot Reload Server",{headers:{"Content-Type":"text/plain"}})},websocket:{open:(Y)=>{if(this.clients.add(Y),this.options.verbose)console.log(`[HMR] Client connected (${this.clients.size} total)`);Y.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close:(Y)=>{if(this.clients.delete(Y),this.options.verbose)console.log(`[HMR] Client disconnected (${this.clients.size} total)`)},message:(Y,J)=>{let G=typeof J==="string"?J:J.toString();if(G==="ping")return;try{let W=JSON.parse(G);if(W.type==="console"&&Array.isArray(W.args)){let K=W.args.join(" "),U={log:"\x1B[36m",warn:"\x1B[33m",error:"\x1B[31m",info:"\x1B[34m"}[W.level]??"\x1B[36m";console.log(`${U}[browser]${W.level!=="log"?` ${W.level}`:""}\x1B[0m ${K}`)}}catch{}}}}),this.options.verbose)console.log(`[HMR] WebSocket server started on port ${X}`);return X}catch(Y){if(Y?.code==="EADDRINUSE"){X++;continue}throw Y}throw Error(`Could not find an available port after ${Z} attempts starting from ${$??this.options.wsPort}`)}stop(){for(let $ of this.clients)try{$.close()}catch{}if(this.clients.clear(),this.server)this.server.stop(),this.server=null;if(this.options.verbose)console.log("[HMR] Server stopped")}broadcast($){let X=JSON.stringify($),Z=0;for(let Q of this.clients)try{if(Q.readyState===1)Q.send(X),Z++}catch{this.clients.delete(Q)}if(this.options.verbose&&Z>0)console.log(`[HMR] Broadcast ${$.type} to ${Z} client(s)`)}reload($){if(this.options.verbose)console.log(`[HMR] Sending reload to ${this.clients.size} client(s) for: ${$||"all"}`);this.broadcast({type:"reload",path:$,timestamp:Date.now()})}updateCss($,X){this.broadcast({type:"css-update",path:$,content:X,timestamp:Date.now()})}error($){this.broadcast({type:"error",content:$,timestamp:Date.now()})}get clientCount(){return this.clients.size}get port(){return this.options.wsPort}}function i4($,X={}){let{showOverlay:Z=!0,reconnectInterval:Q=1000,maxReconnectAttempts:Y=10}=X;return`
874
874
  <script>
875
875
  (function() {
876
876
  // stx Hot Reload Client
@@ -1069,10 +1069,10 @@ else {
1069
1069
  };
1070
1070
  })();
1071
1071
  </script>
1072
- `}function y0($,X,Z={}){let Q=y4(X,Z),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Q+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Q}</html>`);return $+Q}function Q$($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function Y$($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Q)=>X.endsWith(Q))}function J$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Z)=>Z.test($))}var _1=null;function G$($){if(!_1)_1=new E6($);return _1}function D1(){if(_1)_1.stop(),_1=null}import w1 from"path";K5();var U1={name:"bun-plugin-stx",async setup($){let Z={...await n0(),...$.config?.stx},Q=new Set,Y=Z.webComponents?.enabled?`./${w1.relative(w1.dirname($.config?.outdir||"dist"),Z.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Z.webComponents?.enabled)try{let G=await B$(Z,Q);if(J.push(...G),Z.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let W=new Set;if(Z.cache&&Z.cachePath){let L=await _$(G,Z);if(L){if(Z.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await G5(()=>Bun.file(G).text(),"",(L)=>{throw new J5(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new J5(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:F}=W5.time("script-extraction",()=>{let L=K,O=K$(K);if(O)L=O.content.trim();let N=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],V="",M=[];for(let A of N){let I=A.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",E=A.match(/<script\b([^>]*)>/i),w=E?E[1]:"";if(/\bserver\b/i.test(w))V=I;else M.push(A)}let q=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:V,templateContent:q,allScripts:M}}),z={__filename:G,__dirname:w1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await G5(()=>E0(_,z,G),void 0,(L)=>{let O=new Y5(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(W$.log(O,{filePath:G,scriptContent:_}),Z.debug)throw O});let H=await W5.timeAsync("directive-processing",async()=>{return await I0(U,z,G,Z,W)});if(F.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-jndc710n.js"),O=L(F.join(`
1072
+ `}function y0($,X,Z={}){let Q=i4(X,Z),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Q+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Q}</html>`);return $+Q}function G$($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function W$($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Q)=>X.endsWith(Q))}function K$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Z)=>Z.test($))}var U1=null;function _$($){if(!U1)U1=new x6($);return U1}function T1(){if(U1)U1.stop(),U1=null}import C1 from"path";B5();var B1={name:"bun-plugin-stx",async setup($){let Z={...await n0(),...$.config?.stx},Q=new Set,Y=Z.webComponents?.enabled?`./${C1.relative(C1.dirname($.config?.outdir||"dist"),Z.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Z.webComponents?.enabled)try{let G=await z$(Z,Q);if(J.push(...G),Z.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let W=new Set;if(Z.cache&&Z.cachePath){let L=await L$(G,Z);if(L){if(Z.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await _5(()=>Bun.file(G).text(),"",(L)=>{throw new K5(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new K5(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:F}=U5.time("script-extraction",()=>{let L=K,O=B$(K);if(O)L=O.content.trim();let N=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],V="",M=[];for(let q of N){let I=q.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",E=q.match(/<script\b([^>]*)>/i),w=E?E[1]:"";if(/\bserver\b/i.test(w))V=I;else M.push(q)}let A=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:V,templateContent:A,allScripts:M}}),z={__filename:G,__dirname:C1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await _5(()=>E0(_,z,G),void 0,(L)=>{let O=new W5(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(U$.log(O,{filePath:G,scriptContent:_}),Z.debug)throw O});let H=await U5.timeAsync("directive-processing",async()=>{return await I0(U,z,G,Z,W)});if(F.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-7ypm243n.js"),O=L(F.join(`
1073
1073
  `),z),N=H.search(/<\/body>/i);if(N!==-1)H=H.slice(0,N)+O+`
1074
1074
  `+H.slice(N);else H+=`
1075
- ${O}`}if(H=await D6(H),W.forEach((L)=>Q.add(L)),Z.cache&&Z.cachePath){if(await U$(G,H,W,Z),Z.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:H,loader:"html"}}catch(W){let K=W instanceof Error?W:new Y5(`Plugin processing failed: ${String(W)}`,G);if(W$.log(K,{filePath:G,buildConfig:$.config}),R6.logDetailedError(K,{filePath:G,plugin:"bun-plugin-stx"}),Z.debug)console.error("stx Plugin Error:",K);let _=K,U=_.line||null,F=_.context||null;return{contents:Z.debug||I6()?`<!DOCTYPE html>
1075
+ ${O}`}if(H=await b6(H),W.forEach((L)=>Q.add(L)),Z.cache&&Z.cachePath){if(await F$(G,H,W,Z),Z.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:H,loader:"html"}}catch(W){let K=W instanceof Error?W:new W5(`Plugin processing failed: ${String(W)}`,G);if(U$.log(K,{filePath:G,buildConfig:$.config}),P6.logDetailedError(K,{filePath:G,plugin:"bun-plugin-stx"}),Z.debug)console.error("stx Plugin Error:",K);let _=K,U=_.line||null,F=_.context||null;return{contents:Z.debug||S6()?`<!DOCTYPE html>
1076
1076
  <html lang="en">
1077
1077
  <head>
1078
1078
  <meta charset="UTF-8">
@@ -1113,7 +1113,7 @@ ${O}`}if(H=await D6(H),W.forEach((L)=>Q.add(L)),Z.cache&&Z.cachePath){if(await U
1113
1113
  <li>Check the syntax of your stx directives (e.g., @if, @foreach)</li>
1114
1114
  <li>Verify that all variables used in the template are properly defined</li>
1115
1115
  <li>Ensure script tags have valid JavaScript/TypeScript syntax</li>
1116
- <li>Run <code>stx debug ${o0(w1.basename(G))}</code> for detailed analysis</li>
1116
+ <li>Run <code>stx debug ${o0(C1.basename(G))}</code> for detailed analysis</li>
1117
1117
  <li>Enable debug mode in your stx config for more detailed error messages</li>
1118
1118
  </ul>
1119
1119
  </div>
@@ -1132,12 +1132,12 @@ ${O}`}if(H=await D6(H),W.forEach((L)=>Q.add(L)),Z.cache&&Z.cachePath){if(await U
1132
1132
  <h1>Something went wrong</h1>
1133
1133
  <p>An internal error occurred. Please try again later.</p>
1134
1134
  </body>
1135
- </html>`,loader:"html"}}})}};async function g4($,X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=Q0.resolve($);if(!R0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return Q5(W,X);else if(!W.endsWith(".stx"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${W}${B.reset}. Only .stx and .md files are supported.`),!1;let K=p0(process.cwd(),"output");R0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let I={name:"public-assets",setup(T){T.onResolve({filter:/^\/(images|fonts|assets|public)\//},(f)=>{return{path:f.path,external:!0}})}},E=await Bun.build({entrypoints:[W],outdir:K,plugins:[I,U1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!E.success)return console.error(`${B.red}Build failed:${B.reset}`,E.logs),!1;let w=E.outputs.find((T)=>T.path.endsWith(".html"));if(!w)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(w.path).text(),!0}catch(I){return console.error(`${B.red}Error building stx file:${B.reset}`,I),!1}};if(!await U())return!1;let z=Q0.dirname(W);await L$(z);let j=Z;try{if(j=await u0(Z),j!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${j} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let I=X.hmrPort||j+1;J=G$({wsPort:I,verbose:!1}),G=J.start(I)}let H={},L=null,O;try{let{loadStxConfig:I}=await import("./chunk-rstz7e7c.js"),E=await I();if(O=X.stxOptions?.serverApi??E.serverApi,E?.apiRouter)L=E?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(E?.apiRoutes){H=E.apiRoutes;let w=Object.keys(H).length;if(w>0)console.log(`${B.blue}Loaded ${B.bright}${w} API route${w>1?"s":""}${B.reset}`)}if(E?.broadcasting?.enabled)try{let{startBroadcasting:w,loadChannels:D}=await import("./chunk-w6n5c479.js"),T=E.broadcasting;await w(T);let f=T.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${f}/ws${B.reset}`);let c=Q0.join(process.cwd(),"channels.ts");if(R0.existsSync(c))try{let v=await D(c);console.log(`${B.blue}Loaded ${B.bright}${v} broadcast channel${v!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(v){console.warn(`${B.yellow}Failed to load channels.ts: ${v.message}${B.reset}`)}}catch(w){console.warn(`${B.yellow}Broadcasting failed to start: ${w.message}${B.reset}`)}}catch{}let{createServerApi:N,isServerApiSource:V}=await import("./chunk-241cvbas.js"),M=await N(process.cwd(),O);if(console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${j}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let q=v4({port:j,async fetch(I){return z$(I,await(async()=>{let E=new URL(I.url);if([K,Q0.dirname(W),Q0.join(process.cwd(),"public")].some((v)=>V(Q0.join(v,E.pathname),process.cwd(),O)))return new Response("Not Found",{status:404});if(L)try{let v=await L.handleRequest(I);if(v.status!==404)return v}catch{}if(H[E.pathname])try{return await H[E.pathname](I)}catch(v){return new Response(JSON.stringify({error:v.message}),{status:500,headers:{"Content-Type":"application/json"}})}let w=await M(I);if(w)return w;if(E.pathname==="/")return(async()=>{let S=await J0(_||"");if(Y)S=y0(S,G);if(X.native)if(S.includes("<head>"))S=S.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else S="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+S;if(X.titlebarHidden)if(S.includes("<head>"))S=S.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else S=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${S}`;return S})().then((S)=>new Response(S,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let D=Q0.join(K,E.pathname);if(R0.existsSync(D)&&R0.statSync(D).isFile()){let v=Bun.file(D),S=Q0.extname(D).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let N0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),W0=await v.text(),r0=N0.transformSync(W0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let T=Q0.dirname(W),f=Q0.join(T,E.pathname);if(R0.existsSync(f)&&R0.statSync(f).isFile()){let v=Bun.file(f),S=Q0.extname(f).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let N0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),W0=await v.text(),r0=N0.transformSync(W0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let c=Q0.join(process.cwd(),"public",E.pathname);if(R0.existsSync(c)&&R0.statSync(c).isFile()){let v=Bun.file(c),S=Q0.extname(c).toLowerCase(),k="application/octet-stream";if(S===".ts"||S===".tsx"){let N0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),W0=await v.text(),r0=N0.transformSync(W0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
1135
+ </html>`,loader:"html"}}})}};async function s4($,X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=Q0.resolve($);if(!R0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return G5(W,X);else if(!W.endsWith(".stx"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${W}${B.reset}. Only .stx and .md files are supported.`),!1;let K=p0(process.cwd(),"output");R0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let I={name:"public-assets",setup(T){T.onResolve({filter:/^\/(images|fonts|assets|public)\//},(f)=>{return{path:f.path,external:!0}})}},E=await Bun.build({entrypoints:[W],outdir:K,plugins:[I,B1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!E.success)return console.error(`${B.red}Build failed:${B.reset}`,E.logs),!1;let w=E.outputs.find((T)=>T.path.endsWith(".html"));if(!w)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(w.path).text(),!0}catch(I){return console.error(`${B.red}Error building stx file:${B.reset}`,I),!1}};if(!await U())return!1;let z=Q0.dirname(W);await j$(z);let j=Z;try{if(j=await u0(Z),j!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${j} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let I=X.hmrPort||j+1;J=_$({wsPort:I,verbose:!1}),G=J.start(I)}let H={},L=null,O;try{let{loadStxConfig:I}=await import("./chunk-j5qeaprt.js"),E=await I();if(O=X.stxOptions?.serverApi??E.serverApi,E?.apiRouter)L=E?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(E?.apiRoutes){H=E.apiRoutes;let w=Object.keys(H).length;if(w>0)console.log(`${B.blue}Loaded ${B.bright}${w} API route${w>1?"s":""}${B.reset}`)}if(E?.broadcasting?.enabled)try{let{startBroadcasting:w,loadChannels:D}=await import("./chunk-qmmp5kb5.js"),T=E.broadcasting;await w(T);let f=T.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${f}/ws${B.reset}`);let c=Q0.join(process.cwd(),"channels.ts");if(R0.existsSync(c))try{let v=await D(c);console.log(`${B.blue}Loaded ${B.bright}${v} broadcast channel${v!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(v){console.warn(`${B.yellow}Failed to load channels.ts: ${v.message}${B.reset}`)}}catch(w){console.warn(`${B.yellow}Broadcasting failed to start: ${w.message}${B.reset}`)}}catch{}let{createServerApi:N,isServerApiSource:V}=await import("./chunk-ha46rg9g.js"),M=await N(process.cwd(),O);if(console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${j}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let A=a4({port:j,async fetch(I){return O$(I,await(async()=>{let E=new URL(I.url);if([K,Q0.dirname(W),Q0.join(process.cwd(),"public")].some((v)=>V(Q0.join(v,E.pathname),process.cwd(),O)))return new Response("Not Found",{status:404});if(L)try{let v=await L.handleRequest(I);if(v.status!==404)return v}catch{}if(H[E.pathname])try{return await H[E.pathname](I)}catch(v){return new Response(JSON.stringify({error:v.message}),{status:500,headers:{"Content-Type":"application/json"}})}let w=await M(I);if(w)return w;if(E.pathname==="/")return(async()=>{let S=await J0(_||"");if(Y)S=y0(S,G);if(X.native)if(S.includes("<head>"))S=S.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else S="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+S;if(X.titlebarHidden)if(S.includes("<head>"))S=S.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else S=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${S}`;return S})().then((S)=>new Response(S,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let D=Q0.join(K,E.pathname);if(R0.existsSync(D)&&R0.statSync(D).isFile()){let v=Bun.file(D),S=Q0.extname(D).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let N0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),W0=await v.text(),r0=N0.transformSync(W0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let T=Q0.dirname(W),f=Q0.join(T,E.pathname);if(R0.existsSync(f)&&R0.statSync(f).isFile()){let v=Bun.file(f),S=Q0.extname(f).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let N0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),W0=await v.text(),r0=N0.transformSync(W0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let c=Q0.join(process.cwd(),"public",E.pathname);if(R0.existsSync(c)&&R0.statSync(c).isFile()){let v=Bun.file(c),S=Q0.extname(c).toLowerCase(),k="application/octet-stream";if(S===".ts"||S===".tsx"){let N0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),W0=await v.text(),r0=N0.transformSync(W0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
1136
1136
  ${I.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1137
1137
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
1138
1138
  ${B.bright}\u2192 ${B.cyan}http://localhost:${j}/${B.reset}`),console.log(`
1139
- ${B.yellow}Routes:${B.reset}`);let A=Q0.relative(process.cwd(),W);if(console.log(` ${B.green}\u2514\u2500 /${B.reset} \u2192 ${B.bright}${A}${B.reset}`),console.log(`
1140
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(q.url.toString(),()=>{if(Q)R0.watch(Q0.dirname(W),{recursive:!0}).close();q.stop()}),X.native){let I=await Bun.file(W).text(),E=Z$(I);await W1(j,{title:Q0.basename(W,".stx"),titlebarHidden:X.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(Q){let I=Q0.dirname(W);console.log(`${B.blue}Watching ${B.bright}${I}${B.reset} for changes...`);let E=R0.watch(I,{recursive:!0},async(w,D)=>{if(!D||J$(D))return;if(Y$(D)){console.log(`${B.yellow}File ${B.bright}${D}${B.yellow} changed, rebuilding...${B.reset}`),t0.clear(),e0();let T=await U();if(await F$(z),Y&&J)if(T)J.reload(D);else J.error("Build failed - check console for details")}else if(Q$(D)){if(console.log(`${B.cyan}CSS ${B.bright}${D}${B.cyan} changed${B.reset}`),Y&&J)J.updateCss(D)}});process.on("SIGINT",()=>{if(E.close(),J)D1();q.stop(),process.exit(0)})}return!0}var{serve:f4}=globalThis.Bun;import c0 from"fs";import L0 from"path";var w6=`
1139
+ ${B.yellow}Routes:${B.reset}`);let q=Q0.relative(process.cwd(),W);if(console.log(` ${B.green}\u2514\u2500 /${B.reset} \u2192 ${B.bright}${q}${B.reset}`),console.log(`
1140
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(A.url.toString(),()=>{if(Q)R0.watch(Q0.dirname(W),{recursive:!0}).close();A.stop()}),X.native){let I=await Bun.file(W).text(),E=J$(I);await K1(j,{title:Q0.basename(W,".stx"),titlebarHidden:X.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(Q){let I=Q0.dirname(W);console.log(`${B.blue}Watching ${B.bright}${I}${B.reset} for changes...`);let E=R0.watch(I,{recursive:!0},async(w,D)=>{if(!D||K$(D))return;if(W$(D)){console.log(`${B.yellow}File ${B.bright}${D}${B.yellow} changed, rebuilding...${B.reset}`),t0.clear(),e0();let T=await U();if(await H$(z),Y&&J)if(T)J.reload(D);else J.error("Build failed - check console for details")}else if(G$(D)){if(console.log(`${B.cyan}CSS ${B.bright}${D}${B.cyan} changed${B.reset}`),Y&&J)J.updateCss(D)}});process.on("SIGINT",()=>{if(E.close(),J)T1();A.stop(),process.exit(0)})}return!0}var{serve:r4}=globalThis.Bun;import c0 from"fs";import L0 from"path";var y6=`
1141
1141
  <script data-stx-helpers>
1142
1142
  (function() {
1143
1143
  'use strict'
@@ -1448,14 +1448,14 @@ else {
1448
1448
 
1449
1449
  })()
1450
1450
  </script>
1451
- `;k6();function S6($){if($.length===0)return"";if($.length===1)return $[0];let X=$.map((Q)=>Q.split(L0.sep)),Z=[];for(let Q=0;Q<X[0].length;Q++){let Y=X[0][Q];if(X.every((J)=>J[Q]===Y))Z.push(Y);else break}return Z.join(L0.sep)}async function h4($,X={}){let Z=X.port||3000,Q=X.watch!==!1;for(let H of $){let L=L0.resolve(H);if(!c0.existsSync(L))return console.error(`${B.red}Error: File not found: ${B.bright}${L}${B.reset}`),!1;if(!L.endsWith(".stx")&&!L.endsWith(".md"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${L}${B.reset}. Only .stx and .md files are supported.`),!1}let Y=p0(process.cwd(),"output");c0.mkdirSync(Y,{recursive:!0});let J=S6($.map((H)=>L0.dirname(L0.resolve(H))));console.log(`${B.blue}Processing ${B.bright}${$.length}${B.reset} files...`);let G={},W=[],K=async()=>{try{for(let H of $){let L=L0.resolve(H);if(L.endsWith(".md"))try{let{content:N,data:V}=await k0(L,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:C0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),M=X.markdown?.syntaxHighlighting||C0.markdown?.syntaxHighlighting,q=M?.defaultTheme||"github-dark",A=["github-dark"],I=M?.additionalThemes||[],w=[...new Set([...A,...I])].map((c)=>`<option value="${c}"${c===q?" selected":""}>${c}</option>`).join(`
1451
+ `;f6();function d6($){if($.length===0)return"";if($.length===1)return $[0];let X=$.map((Q)=>Q.split(L0.sep)),Z=[];for(let Q=0;Q<X[0].length;Q++){let Y=X[0][Q];if(X.every((J)=>J[Q]===Y))Z.push(Y);else break}return Z.join(L0.sep)}async function n4($,X={}){let Z=X.port||3000,Q=X.watch!==!1;for(let H of $){let L=L0.resolve(H);if(!c0.existsSync(L))return console.error(`${B.red}Error: File not found: ${B.bright}${L}${B.reset}`),!1;if(!L.endsWith(".stx")&&!L.endsWith(".md"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${L}${B.reset}. Only .stx and .md files are supported.`),!1}let Y=p0(process.cwd(),"output");c0.mkdirSync(Y,{recursive:!0});let J=d6($.map((H)=>L0.dirname(L0.resolve(H))));console.log(`${B.blue}Processing ${B.bright}${$.length}${B.reset} files...`);let G={},W=[],K=async()=>{try{for(let H of $){let L=L0.resolve(H);if(L.endsWith(".md"))try{let{content:N,data:V}=await k0(L,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:C0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),M=X.markdown?.syntaxHighlighting||C0.markdown?.syntaxHighlighting,A=M?.defaultTheme||"github-dark",q=["github-dark"],I=M?.additionalThemes||[],w=[...new Set([...q,...I])].map((c)=>`<option value="${c}"${c===A?" selected":""}>${c}</option>`).join(`
1452
1452
  `),D=`
1453
1453
  <!DOCTYPE html>
1454
1454
  <html lang="en">
1455
1455
  <head>
1456
1456
  <meta charset="UTF-8">
1457
1457
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
1458
- <title>${T6(V.title||L0.basename(L))}</title>
1458
+ <title>${v6(V.title||L0.basename(L))}</title>
1459
1459
  <!-- Syntax highlighting styles -->
1460
1460
  <style id="syntax-theme">
1461
1461
  :root {
@@ -1597,34 +1597,34 @@ else {
1597
1597
  min-width: 100px;
1598
1598
  color: #555;
1599
1599
  }
1600
- ${t1()}
1600
+ ${X$()}
1601
1601
  </style>
1602
1602
  </head>
1603
1603
  <body>
1604
- ${X$(V)}
1605
- ${e1(w)}
1604
+ ${Y$(V)}
1605
+ ${Z$(w)}
1606
1606
 
1607
1607
  ${N}
1608
1608
 
1609
1609
  <script>
1610
- ${$$()}
1610
+ ${Q$()}
1611
1611
  </script>
1612
1612
  </body>
1613
1613
  </html>
1614
- `,f=`/${L0.relative(J,L).replace(/\.md$/,"")}`;if(f.endsWith("/index"))f=f.slice(0,-6)||"/";G[f||"/"]={filePath:L,content:D,fileType:"md"}}catch(N){console.error(`${B.red}Error processing Markdown file ${B.bright}${H}${B.reset}:`,N);continue}else{let N={name:"public-assets",setup(A){A.onResolve({filter:/^\/(images|fonts|assets|public)\//},(I)=>{return{path:I.path,external:!0}})}},V;try{let A=await Bun.build({entrypoints:[L],outdir:Y,plugins:[N,U1],define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!A.success){console.error(`${B.red}Build failed for ${B.bright}${H}${B.reset}:`,B1(A.logs,L));continue}let I=A.outputs.find((E)=>E.path.endsWith(".html"));if(!I){console.error(`${B.red}No HTML output found for ${B.bright}${H}${B.reset}`);continue}V=await Bun.file(I.path).text()}catch(A){console.error(`${B.red}Build failed for ${B.bright}${H}${B.reset}:
1615
- ${B1(A,L)}`);continue}let q=`/${L0.relative(J,L).replace(/\.stx$/,"")}`;if(q.endsWith("/index"))q=q.slice(0,-6)||"/";if(q.includes("[")){let{regex:A,params:I}=C6(q);W.push({pattern:A,paramNames:I,filePath:L,routeTemplate:q,fileType:"stx"}),G[q]={filePath:L,content:V,fileType:"stx"}}else G[q||"/"]={filePath:L,content:V,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${B.red}No files were successfully processed${B.reset}`),!1;return!0}catch(H){return console.error(`${B.red}Error processing files:${B.reset}`,B1(H)),!1}};if(!await K())return!1;let U=Z;try{if(U=await u0(Z),U!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${U} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${U}/${B.reset}...`);let F=f4({port:U,async fetch(H){let L=new URL(H.url),O=L0.join(process.cwd(),"public",L.pathname);if(c0.existsSync(O)&&c0.statSync(O).isFile()){let M=Bun.file(O),q=L0.extname(O).toLowerCase(),A="application/octet-stream";if(q===".ts"||q===".tsx"){let I=new Bun.Transpiler({loader:q===".tsx"?"tsx":"ts"}),E=await M.text(),w=I.transformSync(E);return new Response(w,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(q){case".html":A="text/html";break;case".css":A="text/css";break;case".js":A="text/javascript";break;case".json":A="application/json";break;case".png":A="image/png";break;case".jpg":case".jpeg":A="image/jpeg";break;case".gif":A="image/gif";break;case".svg":A="image/svg+xml";break;case".ico":A="image/x-icon";break;case".woff":A="font/woff";break;case".woff2":A="font/woff2";break;case".ttf":A="font/ttf";break;case".otf":A="font/otf";break;case".eot":A="application/vnd.ms-fontobject";break}return new Response(M,{headers:{"Content-Type":A}})}let N=G[L.pathname];if(!N&&!L.pathname.endsWith("/"))N=G[`${L.pathname}/`];if(!N)for(let M of W){let q=L.pathname.match(M.pattern);if(q){let A=G[M.routeTemplate];if(A){let I={};for(let D=0;D<M.paramNames.length;D++)I[M.paramNames[D]]=decodeURIComponent(q[D+1]);let E=A.content,w=`<script>window.__routeParams = ${JSON.stringify(I)};</script>`;if(E.includes("</head>"))E=E.replace("</head>",`${w}
1616
- </head>`);else E=w+E;N={...A,content:E}}break}}if(N)return J0(N.content).then((M)=>{if(M.includes("</head>"))M=M.replace("</head>",`${w6}
1617
- </head>`);return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let V=L0.join(Y,L.pathname);if(c0.existsSync(V)&&c0.statSync(V).isFile()){let M=Bun.file(V),q=L0.extname(V).toLowerCase(),A="text/plain";if(q===".ts"||q===".tsx"){let I=new Bun.Transpiler({loader:q===".tsx"?"tsx":"ts"}),E=await M.text(),w=I.transformSync(E);return new Response(w,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(q){case".html":A="text/html";break;case".css":A="text/css";break;case".js":A="text/javascript";break;case".json":A="application/json";break;case".png":A="image/png";break;case".jpg":case".jpeg":A="image/jpeg";break;case".gif":A="image/gif";break;case".svg":A="image/svg+xml";break;case".ico":A="image/x-icon";break;case".woff":A="font/woff";break;case".woff2":A="font/woff2";break;case".ttf":A="font/ttf";break;case".otf":A="font/otf";break;case".eot":A="application/vnd.ms-fontobject";break}return new Response(M,{headers:{"Content-Type":A}})}if(L.pathname!=="/"&&G["/"]){let M=x6(H);return J0(G["/"].content).then((q)=>{if(M){let A=q.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(A){let I=q.match(/<title[^>]*>([\s\S]*?)<\/title>/i),E=I?I[1]:"",w=`<!DOCTYPE html><html><head><title>${T6(E)}</title></head><body><main>${A[1]}</main></body></html>`;return new Response(w,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...L1(),"Cache-Control":j$,Pragma:"no-cache",Expires:"0"}})}}return new Response(q,{headers:{"Content-Type":"text/html",...L1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(H){return new Response(`<pre>${H}
1614
+ `,f=`/${L0.relative(J,L).replace(/\.md$/,"")}`;if(f.endsWith("/index"))f=f.slice(0,-6)||"/";G[f||"/"]={filePath:L,content:D,fileType:"md"}}catch(N){console.error(`${B.red}Error processing Markdown file ${B.bright}${H}${B.reset}:`,N);continue}else{let N={name:"public-assets",setup(q){q.onResolve({filter:/^\/(images|fonts|assets|public)\//},(I)=>{return{path:I.path,external:!0}})}},V;try{let q=await Bun.build({entrypoints:[L],outdir:Y,plugins:[N,B1],define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!q.success){console.error(`${B.red}Build failed for ${B.bright}${H}${B.reset}:`,L1(q.logs,L));continue}let I=q.outputs.find((E)=>E.path.endsWith(".html"));if(!I){console.error(`${B.red}No HTML output found for ${B.bright}${H}${B.reset}`);continue}V=await Bun.file(I.path).text()}catch(q){console.error(`${B.red}Build failed for ${B.bright}${H}${B.reset}:
1615
+ ${L1(q,L)}`);continue}let A=`/${L0.relative(J,L).replace(/\.stx$/,"")}`;if(A.endsWith("/index"))A=A.slice(0,-6)||"/";if(A.includes("[")){let{regex:q,params:I}=g6(A);W.push({pattern:q,paramNames:I,filePath:L,routeTemplate:A,fileType:"stx"}),G[A]={filePath:L,content:V,fileType:"stx"}}else G[A||"/"]={filePath:L,content:V,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${B.red}No files were successfully processed${B.reset}`),!1;return!0}catch(H){return console.error(`${B.red}Error processing files:${B.reset}`,L1(H)),!1}};if(!await K())return!1;let U=Z;try{if(U=await u0(Z),U!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${U} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${U}/${B.reset}...`);let F=r4({port:U,async fetch(H){let L=new URL(H.url),O=L0.join(process.cwd(),"public",L.pathname);if(c0.existsSync(O)&&c0.statSync(O).isFile()){let M=Bun.file(O),A=L0.extname(O).toLowerCase(),q="application/octet-stream";if(A===".ts"||A===".tsx"){let I=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),E=await M.text(),w=I.transformSync(E);return new Response(w,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":q="text/html";break;case".css":q="text/css";break;case".js":q="text/javascript";break;case".json":q="application/json";break;case".png":q="image/png";break;case".jpg":case".jpeg":q="image/jpeg";break;case".gif":q="image/gif";break;case".svg":q="image/svg+xml";break;case".ico":q="image/x-icon";break;case".woff":q="font/woff";break;case".woff2":q="font/woff2";break;case".ttf":q="font/ttf";break;case".otf":q="font/otf";break;case".eot":q="application/vnd.ms-fontobject";break}return new Response(M,{headers:{"Content-Type":q}})}let N=G[L.pathname];if(!N&&!L.pathname.endsWith("/"))N=G[`${L.pathname}/`];if(!N)for(let M of W){let A=L.pathname.match(M.pattern);if(A){let q=G[M.routeTemplate];if(q){let I={};for(let D=0;D<M.paramNames.length;D++)I[M.paramNames[D]]=decodeURIComponent(A[D+1]);let E=q.content,w=`<script>window.__routeParams = ${JSON.stringify(I)};</script>`;if(E.includes("</head>"))E=E.replace("</head>",`${w}
1616
+ </head>`);else E=w+E;N={...q,content:E}}break}}if(N)return J0(N.content).then((M)=>{if(M.includes("</head>"))M=M.replace("</head>",`${y6}
1617
+ </head>`);return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let V=L0.join(Y,L.pathname);if(c0.existsSync(V)&&c0.statSync(V).isFile()){let M=Bun.file(V),A=L0.extname(V).toLowerCase(),q="text/plain";if(A===".ts"||A===".tsx"){let I=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),E=await M.text(),w=I.transformSync(E);return new Response(w,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":q="text/html";break;case".css":q="text/css";break;case".js":q="text/javascript";break;case".json":q="application/json";break;case".png":q="image/png";break;case".jpg":case".jpeg":q="image/jpeg";break;case".gif":q="image/gif";break;case".svg":q="image/svg+xml";break;case".ico":q="image/x-icon";break;case".woff":q="font/woff";break;case".woff2":q="font/woff2";break;case".ttf":q="font/ttf";break;case".otf":q="font/otf";break;case".eot":q="application/vnd.ms-fontobject";break}return new Response(M,{headers:{"Content-Type":q}})}if(L.pathname!=="/"&&G["/"]){let M=h6(H);return J0(G["/"].content).then((A)=>{if(M){let q=A.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(q){let I=A.match(/<title[^>]*>([\s\S]*?)<\/title>/i),E=I?I[1]:"",w=`<!DOCTYPE html><html><head><title>${v6(E)}</title></head><body><main>${q[1]}</main></body></html>`;return new Response(w,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...F1(),"Cache-Control":N$,Pragma:"no-cache",Expires:"0"}})}}return new Response(A,{headers:{"Content-Type":"text/html",...F1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(H){return new Response(`<pre>${H}
1618
1618
  ${H.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1619
1619
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
1620
1620
  ${B.bright}\u2192 ${B.cyan}http://localhost:${U}/${B.reset}`),console.log(`
1621
1621
  ${B.yellow}Routes:${B.reset}`);let z=new Set(W.map((H)=>H.routeTemplate)),j=Object.entries(G).filter(([H])=>!z.has(H)).sort(([H],[L])=>H.localeCompare(L)).map(([H,L])=>({route:H==="/"?"/":H,filePath:L0.relative(process.cwd(),L.filePath),fileType:L.fileType}));for(let H of W){let L=H.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");j.push({route:L,filePath:L0.relative(process.cwd(),H.filePath),fileType:"stx"})}if(j.sort((H,L)=>H.route.localeCompare(L.route)),j.forEach((H,L)=>{let N=L===j.length-1?"\u2514\u2500 ":"\u251C\u2500 ",V=H.fileType==="md"?`${B.magenta}(markdown)${B.reset}`:"";console.log(` ${B.green}${N}${H.route}${B.reset} \u2192 ${B.bright}${H.filePath}${B.reset} ${V}`)}),console.log(`
1622
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(F.url.toString(),()=>{if(Q)c0.watch(J,{recursive:!0}).close();F.stop()}),Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let H=c0.watch(J,{recursive:!0},async(L,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${O}${B.yellow} changed, rebuilding...${B.reset}`),t0.clear(),e0(),await K()});process.on("SIGINT",()=>{H.close(),F.stop(),process.exit(0)})}return!0}function T6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:d4}=globalThis.Bun;import e from"fs";import m from"path";async function P6($){try{return L5(await Bun.file($).text())}catch{return}}function _5($){let X=Bun.file($),Z=m.extname($).toLowerCase(),Q={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},J=[".js",".css",".json"].includes(Z)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Q[Z]||"application/octet-stream",...J}})}async function u4($=".",X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=m.resolve($),{loadStxConfig:K}=await import("./chunk-rstz7e7c.js"),_=await K(W),{createServerApi:U,isServerApiSource:F}=await import("./chunk-241cvbas.js"),z=X.stxOptions?.serverApi??_.serverApi,j=await U(W,z),H=_.root&&_.root!=="."?m.join(W,_.root):W,L=X.pagesDir||_.pagesDir||"pages",O=m.join(H,L);if(!e.existsSync(O)&&!_._layerPageDirs?.some((R)=>e.existsSync(R)))return console.error(`${B.red}Error: No '${L}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${O}${B.reset}`),console.log(`${B.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${B.reset}`),console.log(`${B.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${B.reset}`),console.log(`${B.dim}Starting fresh? Create ${L}/index.stx for the homepage.${B.reset}`),!1;let N=H$(H,{pagesDir:L,pagesDirs:_._layerPageDirs?[O,..._._layerPageDirs.slice(1)]:void 0});if(N.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${O}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${N.length}${B.blue} routes${B.reset}`);let V=_?._pluginPageDirs||[],M=[];for(let{dir:R,prefix:x}of V)if(e.existsSync(R)){let P=H$(m.dirname(R),{pagesDir:m.basename(R)});for(let y of P){let Z0=x==="/"?y.pattern:`${x}${y.pattern==="/"?"":y.pattern}`;M.push({route:{...y,pattern:Z0},prefix:x})}if(P.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${P.length}${B.blue} routes at ${B.cyan}${x}${B.reset}`)}let q=new Map,A=null,I=null;if(X.stxOptions?.shell!==!1){if(I=await s6(W,X.stxOptions?.shell),I){if(A=await B5(I,X.stxOptions||{}),A)console.log(`${B.blue}Using app shell: ${B.bright}${m.relative(W,I)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}v6(),await f6(W);let E=g6();if(E.length>0)console.log(`${B.blue}Loaded ${B.bright}${E.length}${B.blue} middleware: ${B.dim}${E.join(", ")}${B.reset}`);let w={},D=null;try{let{loadStxConfig:R}=await import("./chunk-rstz7e7c.js"),x=await R(W);if(x?.apiRouter)D=x?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(x?.apiRoutes){w=x.apiRoutes;let P=Object.keys(w).length;if(P>0)console.log(`${B.blue}Loaded ${B.bright}${P} API route${P>1?"s":""}${B.reset}`)}if(x?.broadcasting?.enabled)try{let{startBroadcasting:P,loadChannels:y}=await import("./chunk-w6n5c479.js"),Z0=x.broadcasting;await P(Z0);let w0=Z0.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${w0}/ws${B.reset}`);let h0=m.join(process.cwd(),"channels.ts");if(e.existsSync(h0))try{let p=await y(h0);console.log(`${B.blue}Loaded ${B.bright}${p} broadcast channel${p!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(p){console.warn(`${B.yellow}Failed to load channels.ts: ${p.message}${B.reset}`)}}catch(P){console.warn(`${B.yellow}Broadcasting failed to start: ${P.message}${B.reset}`)}}catch{}let T=p0(W,"output");e.mkdirSync(T,{recursive:!0});let f=new Map,c=new Set,v=async(R)=>{let x=b6(O,R);if(!x)return null;try{let P=await Bun.build({entrypoints:[x],outdir:T,plugins:[U1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!P.success)return null;let y=P.outputs.find((Z0)=>Z0.path.endsWith(".html"));if(!y)return null;return await Bun.file(y.path).text()}catch{return null}},S=new Map,k=async(R,x)=>{try{let{processDirectives:P,extractVariables:y,defaultConfig:Z0,loadStxConfig:w0,injectRouterScript:h0}=await import("./chunk-rstz7e7c.js"),{checkCache:p,cacheTemplate:u,readFileCached:g,templateCache:h}=await import("./chunk-gg3hm3kq.js"),Y0=await w0(W),d0=(i)=>{if(!i)return i;if(m.isAbsolute(i))return i;return m.resolve(W,i)},C={...Z0,...Y0,...X.stxOptions,autoShell:!0};if(X.debugDirectives)C.debug=!0;C.partialsDir=d0(C.partialsDir),C.componentsDir=d0(C.componentsDir),C.layoutsDir=d0(C.layoutsDir),C.storesDir=d0(C.storesDir||"stores"),C.cachePath=d0(C.cachePath)??p0(W,"cache");let X0=!x&&!X.profile,a=C.cache!==!1;if(a&&X0){let i=h.get(R.filePath);if(i)try{if((await e.promises.stat(R.filePath)).mtime.getTime()<=i.mtime){let M0=!0;for(let U0 of i.dependencies){if(!e.existsSync(U0)){M0=!1;break}if((await e.promises.stat(U0)).mtime.getTime()>i.mtime){M0=!1;break}}if(M0){let U0=i.output;if(A)U0=N$(U0,{preserveHead:!0});let E1=S.get(R.filePath);return{route:R,content:U0,status:E1?.status??await P6(R.filePath),headers:E1?.headers}}}}catch{}let A0=await p(R.filePath,C);if(A0){let V0=A0;if(A)V0=N$(V0,{preserveHead:!0});let M0=S.get(R.filePath);return{route:R,content:V0,status:M0?.status??await P6(R.filePath),headers:M0?.headers}}}let o=a?await g(R.filePath):await Bun.file(R.filePath).text(),_0=L5(o),{classifyAllScripts:d}=await import("./chunk-rstz7e7c.js"),q0=d(o),T0=q0.server.map((i)=>i.content),r=o;for(let i of q0.server)r=r.replace(i.fullTag,"");let n={__filename:R.filePath,__dirname:m.dirname(R.filePath),__stx_options:C,params:x??{},__stx_runtime_head:{}};for(let i of T0)try{await y(i,n,R.filePath)}catch(A0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",R.filePath,A0?.message||A0)}let b0=new Set,H0;if(X.profile){let i=performance.now();H0=await P(r,n,R.filePath,C,b0);let A0=performance.now()-i,V0=m.relative(W,R.filePath)||R.filePath;console.log(`[stx:profile] ${V0} \u2192 ${A0.toFixed(2)}ms`)}else H0=await P(r,n,R.filePath,C,b0);if(!A)H0=await h0(H0,{router:C.router});{let{interpolateScriptExpressions:i}=await import("./chunk-jndc710n.js");H0=H0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(A0,V0,M0)=>{if(!/function\s+__stx_setup_/.test(M0))return A0;return`<script${V0}>${i(M0,n)}</script>`})}if(A)H0=N$(H0,{preserveHead:!0});if(a&&X0)await u(R.filePath,H0,b0,C);let{extractStreamBoundaries:z3}=await import("./chunk-4k471790.js"),Y1=z3(n),M1=n.__streamTemplates;if(M1&&typeof M1==="object"&&Object.keys(M1).length>0){let i=n.streamBoundaries||{},A0={...C,autoShell:!1},V0=Object.keys(M1).map((U0)=>({id:U0,render:async()=>{let E1=typeof i[U0]==="function"?await i[U0]():void 0;return P(M1[U0],{...n,$boundary:E1},R.filePath,A0,new Set)}})),M0=new Set(V0.map((U0)=>U0.id));Y1=[...(Y1||[]).filter((U0)=>!M0.has(U0.id)),...V0]}if(Y1&&Y1.length>0)c.add(R.pattern);else Y1=void 0;let o5=T1(n),t5=C1(n);if(X0)S.set(R.filePath,{status:o5,headers:t5});return{route:R,content:H0,status:o5??_0,headers:t5,boundaries:Y1}}catch(P){return console.error(`${B.red}Error building ${B.bright}${R.pattern}${B.reset}:`,P),null}},N0=8,W0=async()=>{f.clear(),q.clear();for(let R=0;R<N.length;R+=N0){let x=N.slice(R,R+N0),P=await Promise.all(x.map((y)=>k(y)));for(let y of P)if(y)f.set(y.route.pattern,y)}for(let R=0;R<M.length;R+=N0){let x=M.slice(R,R+N0),P=await Promise.all(x.map(({route:y})=>k(y)));for(let y of P)if(y)q.set(y.route.pattern,y)}return f.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await W0())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await L$(W);let f0=Z;try{if(f0=await u0(Z),f0!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${f0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let R=X.hmrPort||f0+1;J=G$({wsPort:R,verbose:!1}),G=J.start(R)}let j0=(R,x)=>{let y=`<script data-stx-route-params>(function(){var p=${JSON.stringify(x).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(R.includes("</head>"))return R.replace("</head>",`${y}</head>`);if(R.includes("<body"))return R.replace(/<body([^>]*)>/,`<body$1>${y}`);return y+R};console.log(`${B.blue}Starting server...${B.reset}`);let Q1=d4({port:f0,async fetch(R){let x=new URL(R.url),P=_?.publicDir||"public",y=m.join(W,P,x.pathname),Z0=m.join(W,x.pathname),w0=m.join(T,x.pathname);if([y,Z0,w0].some((C)=>F(C,W,z)))return new Response("Not Found",{status:404});let[h0,p,u]=await Promise.all([e.promises.stat(y).catch(()=>null),e.promises.stat(Z0).catch(()=>null),e.promises.stat(w0).catch(()=>null)]);if(h0?.isFile()&&!F(y,W,z))return _5(y);if(p?.isFile()&&!F(Z0,W,z))return _5(Z0);if(u?.isFile()&&!F(w0,W,z))return _5(w0);if(x.pathname.startsWith("/_stx/component/")){let C=decodeURIComponent(x.pathname.slice(16));if(C)try{let X0=`<${C} />`,a={...buildConfig,autoShell:!1},o=await processDirectives(X0,{},m.join(W,"components",`${C}.stx`),a,new Set);return new Response(o,{headers:{"Content-Type":"text/html"}})}catch(X0){return new Response(`<div class="stx-async-error">${X0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(x.pathname==="/_stx/img"){let{handleImageRequest:C}=await import("./chunk-sgmqfphy.js"),X0=await C(R,{publicDir:m.join(W,P),cacheDir:p0(W,"cache","img")});if(X0)return X0}if(D)try{let C=await D.handleRequest(R);if(C.status!==404)return C}catch{}if(w[x.pathname])try{return await w[x.pathname](R)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=await j(R);if(g)return g;let h=U5(x.pathname,N);if(h){let C=f.get(h.route.pattern),X0=c.has(h.route.pattern);if(h.route.isDynamic&&Object.keys(h.params).length>0||X0){let a=await k(h.route,h.params);if(a)C=a}if(C){let a=C.status??200,o=C.headers??{},_0=(h.route.filePath?p6(await Bun.file(h.route.filePath).text().catch(()=>"")):null)??{};if(_0.validate){if(!await _0.validate({params:h.params})){let T0=await v(404);if(T0){let r=T0;if(r=await J0(r,W),Y)r=y0(r,G);return new Response(r,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(_0.middleware){let q0=h6(x.pathname,h.params,_0,x.search),T0=d6(q0,null,R,{isServer:!0}),r=await u6(_0.middleware,T0);if(r.redirect){let n=r.redirect.path,b0=r.redirect.options.redirectCode||302,H0=new Headers(r.responseHeaders);return H0.set("Location",n),new Response(null,{status:b0,headers:H0})}if(r.abort){let{statusCode:n,message:b0}=r.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${n}</title></head><body><h1>Error ${n}</h1><p>${b0}</p></body></html>`,{status:n,headers:{"Content-Type":"text/html"}})}if(Object.keys(r.state).length>0){let n=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(r.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;C.content=C.content.replace("</head>",`${n}</head>`)}}let d=C.content;if(A&&r6(R)){let q0=m6(d),T0=c6(d),r=d.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=r?a6(r[1].trim()):"";if(Object.keys(h.params).length>0)d=j0(d,h.params);d=await J0(d,W);let b0=_?.router?.container||"main";return d=n6(d,b0),new Response(d,{status:a,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":q0.layout,"X-STX-Layout-Group":q0.group,"X-STX-Runtime":T0?"true":"false",...n&&{"X-STX-Title":encodeURIComponent(n)},[l6]:i6(),...L1(),"Cache-Control":j$}})}if(A)d=O$(A,d);if(Object.keys(h.params).length>0)d=j0(d,h.params);if(d=await J0(d,W),Y)d=y0(d,G);if(X.native)if(d.includes("<head>"))d=d.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else d="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+d;if(X.titlebarHidden)if(d.includes("<head>"))d=d.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else d=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${d}`;if(C.boundaries&&C.boundaries.length>0){let{renderStreamingPage:q0,streamToResponse:T0}=await import("./chunk-4k471790.js");return T0(q0(d,C.boundaries,{timeoutMs:30000}),{status:a,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(d,{status:a,headers:{"Content-Type":"text/html",...L1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...o}})}}if(M.length>0){let C=M.map((a)=>a.route),X0=U5(x.pathname,C);if(X0){let a=q.get(X0.route.pattern);if(a){let o=a.content;if(A)o=O$(A,o);if(Object.keys(X0.params).length>0)o=j0(o,X0.params);if(o=await J0(o,W),Y)o=y0(o,G);return new Response(o,{status:a.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of V)if(a!=="/"&&x.pathname.startsWith(a)){let o=q.get(a)||q.get(a+"/");if(o){let _0=o.content;if(A)_0=O$(A,_0);if(_0=await J0(_0,W),Y)_0=y0(_0,G);return new Response(_0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let Y0=f.get("/");if(Y0){let C=Y0.content;if(C=await J0(C,W),Y)C=y0(C,G);if(X.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let d0=await v(404);if(d0){let C=d0;if(C=await J0(C,W),Y)C=y0(C,G);return new Response(C,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(R){let x=await v(500);if(x)return new Response(x,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${R}
1622
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(F.url.toString(),()=>{if(Q)c0.watch(J,{recursive:!0}).close();F.stop()}),Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let H=c0.watch(J,{recursive:!0},async(L,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${O}${B.yellow} changed, rebuilding...${B.reset}`),t0.clear(),e0(),await K()});process.on("SIGINT",()=>{H.close(),F.stop(),process.exit(0)})}return!0}function v6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:o4}=globalThis.Bun;import e from"fs";import m from"path";async function u6($){try{return j5(await Bun.file($).text())}catch{return}}function L5($){let X=Bun.file($),Z=m.extname($).toLowerCase(),Q={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},J=[".js",".css",".json"].includes(Z)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Q[Z]||"application/octet-stream",...J}})}async function t4($=".",X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=m.resolve($),{loadStxConfig:K}=await import("./chunk-j5qeaprt.js"),_=await K(W),{createServerApi:U,isServerApiSource:F}=await import("./chunk-ha46rg9g.js"),z=X.stxOptions?.serverApi??_.serverApi,j=await U(W,z),H=_.root&&_.root!=="."?m.join(W,_.root):W,L=X.pagesDir||_.pagesDir||"pages",O=m.join(H,L);if(!e.existsSync(O)&&!_._layerPageDirs?.some((R)=>e.existsSync(R)))return console.error(`${B.red}Error: No '${L}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${O}${B.reset}`),console.log(`${B.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${B.reset}`),console.log(`${B.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${B.reset}`),console.log(`${B.dim}Starting fresh? Create ${L}/index.stx for the homepage.${B.reset}`),!1;let N=A$(H,{pagesDir:L,pagesDirs:_._layerPageDirs?[O,..._._layerPageDirs.slice(1)]:void 0});if(N.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${O}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${N.length}${B.blue} routes${B.reset}`);let V=_?._pluginPageDirs||[],M=[];for(let{dir:R,prefix:x}of V)if(e.existsSync(R)){let P=A$(m.dirname(R),{pagesDir:m.basename(R)});for(let y of P){let Z0=x==="/"?y.pattern:`${x}${y.pattern==="/"?"":y.pattern}`;M.push({route:{...y,pattern:Z0},prefix:x})}if(P.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${P.length}${B.blue} routes at ${B.cyan}${x}${B.reset}`)}let A=new Map,q=null,I=null;if(X.stxOptions?.shell!==!1){if(I=await Z7(W,X.stxOptions?.shell),I){if(q=await z5(I,X.stxOptions||{}),q)console.log(`${B.blue}Using app shell: ${B.bright}${m.relative(W,I)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}c6(),await i6(W);let E=l6();if(E.length>0)console.log(`${B.blue}Loaded ${B.bright}${E.length}${B.blue} middleware: ${B.dim}${E.join(", ")}${B.reset}`);let w={},D=null;try{let{loadStxConfig:R}=await import("./chunk-j5qeaprt.js"),x=await R(W);if(x?.apiRouter)D=x?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(x?.apiRoutes){w=x.apiRoutes;let P=Object.keys(w).length;if(P>0)console.log(`${B.blue}Loaded ${B.bright}${P} API route${P>1?"s":""}${B.reset}`)}if(x?.broadcasting?.enabled)try{let{startBroadcasting:P,loadChannels:y}=await import("./chunk-qmmp5kb5.js"),Z0=x.broadcasting;await P(Z0);let w0=Z0.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${w0}/ws${B.reset}`);let h0=m.join(process.cwd(),"channels.ts");if(e.existsSync(h0))try{let p=await y(h0);console.log(`${B.blue}Loaded ${B.bright}${p} broadcast channel${p!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(p){console.warn(`${B.yellow}Failed to load channels.ts: ${p.message}${B.reset}`)}}catch(P){console.warn(`${B.yellow}Broadcasting failed to start: ${P.message}${B.reset}`)}}catch{}let T=p0(W,"output");e.mkdirSync(T,{recursive:!0});let f=new Map,c=new Set,v=async(R)=>{let x=m6(O,R);if(!x)return null;try{let P=await Bun.build({entrypoints:[x],outdir:T,plugins:[B1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!P.success)return null;let y=P.outputs.find((Z0)=>Z0.path.endsWith(".html"));if(!y)return null;return await Bun.file(y.path).text()}catch{return null}},S=new Map,k=async(R,x)=>{try{let{processDirectives:P,extractVariables:y,defaultConfig:Z0,loadStxConfig:w0,injectRouterScript:h0}=await import("./chunk-j5qeaprt.js"),{checkCache:p,cacheTemplate:u,readFileCached:g,templateCache:h}=await import("./chunk-sy9pfe3h.js"),Y0=await w0(W),d0=(i)=>{if(!i)return i;if(m.isAbsolute(i))return i;return m.resolve(W,i)},C={...Z0,...Y0,...X.stxOptions,autoShell:!0};if(X.debugDirectives)C.debug=!0;C.partialsDir=d0(C.partialsDir),C.componentsDir=d0(C.componentsDir),C.layoutsDir=d0(C.layoutsDir),C.storesDir=d0(C.storesDir||"stores"),C.cachePath=d0(C.cachePath)??p0(W,"cache");let X0=!x&&!X.profile,a=C.cache!==!1;if(a&&X0){let i=h.get(R.filePath);if(i)try{if((await e.promises.stat(R.filePath)).mtime.getTime()<=i.mtime){let M0=!0;for(let U0 of i.dependencies){if(!e.existsSync(U0)){M0=!1;break}if((await e.promises.stat(U0)).mtime.getTime()>i.mtime){M0=!1;break}}if(M0){let U0=i.output;if(q)U0=V$(U0,{preserveHead:!0});let I1=S.get(R.filePath);return{route:R,content:U0,status:I1?.status??await u6(R.filePath),headers:I1?.headers}}}}catch{}let q0=await p(R.filePath,C);if(q0){let V0=q0;if(q)V0=V$(V0,{preserveHead:!0});let M0=S.get(R.filePath);return{route:R,content:V0,status:M0?.status??await u6(R.filePath),headers:M0?.headers}}}let o=a?await g(R.filePath):await Bun.file(R.filePath).text(),_0=j5(o),{classifyAllScripts:d}=await import("./chunk-j5qeaprt.js"),A0=d(o),T0=A0.server.map((i)=>i.content),r=o;for(let i of A0.server)r=r.replace(i.fullTag,"");let n={__filename:R.filePath,__dirname:m.dirname(R.filePath),__stx_options:C,params:x??{},__stx_runtime_head:{}};for(let i of T0)try{await y(i,n,R.filePath)}catch(q0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",R.filePath,q0?.message||q0)}let b0=new Set,H0;if(X.profile){let i=performance.now();H0=await P(r,n,R.filePath,C,b0);let q0=performance.now()-i,V0=m.relative(W,R.filePath)||R.filePath;console.log(`[stx:profile] ${V0} \u2192 ${q0.toFixed(2)}ms`)}else H0=await P(r,n,R.filePath,C,b0);if(!q)H0=await h0(H0,{router:C.router});{let{interpolateScriptExpressions:i}=await import("./chunk-7ypm243n.js");H0=H0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(q0,V0,M0)=>{if(!/function\s+__stx_setup_/.test(M0))return q0;return`<script${V0}>${i(M0,n)}</script>`})}if(q)H0=V$(H0,{preserveHead:!0});if(a&&X0)await u(R.filePath,H0,b0,C);let{extractStreamBoundaries:M3}=await import("./chunk-8x05b790.js"),Y1=M3(n),E1=n.__streamTemplates;if(E1&&typeof E1==="object"&&Object.keys(E1).length>0){let i=n.streamBoundaries||{},q0={...C,autoShell:!1},V0=Object.keys(E1).map((U0)=>({id:U0,render:async()=>{let I1=typeof i[U0]==="function"?await i[U0]():void 0;return P(E1[U0],{...n,$boundary:I1},R.filePath,q0,new Set)}})),M0=new Set(V0.map((U0)=>U0.id));Y1=[...(Y1||[]).filter((U0)=>!M0.has(U0.id)),...V0]}if(Y1&&Y1.length>0)c.add(R.pattern);else Y1=void 0;let $6=k1(n),X6=x1(n);if(X0)S.set(R.filePath,{status:$6,headers:X6});return{route:R,content:H0,status:$6??_0,headers:X6,boundaries:Y1}}catch(P){return console.error(`${B.red}Error building ${B.bright}${R.pattern}${B.reset}:`,P),null}},N0=8,W0=async()=>{f.clear(),A.clear();for(let R=0;R<N.length;R+=N0){let x=N.slice(R,R+N0),P=await Promise.all(x.map((y)=>k(y)));for(let y of P)if(y)f.set(y.route.pattern,y)}for(let R=0;R<M.length;R+=N0){let x=M.slice(R,R+N0),P=await Promise.all(x.map(({route:y})=>k(y)));for(let y of P)if(y)A.set(y.route.pattern,y)}return f.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await W0())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await j$(W);let f0=Z;try{if(f0=await u0(Z),f0!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${f0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let R=X.hmrPort||f0+1;J=_$({wsPort:R,verbose:!1}),G=J.start(R)}let j0=(R,x)=>{let y=`<script data-stx-route-params>(function(){var p=${JSON.stringify(x).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(R.includes("</head>"))return R.replace("</head>",`${y}</head>`);if(R.includes("<body"))return R.replace(/<body([^>]*)>/,`<body$1>${y}`);return y+R};console.log(`${B.blue}Starting server...${B.reset}`);let Q1=o4({port:f0,async fetch(R){let x=new URL(R.url),P=_?.publicDir||"public",y=m.join(W,P,x.pathname),Z0=m.join(W,x.pathname),w0=m.join(T,x.pathname);if([y,Z0,w0].some((C)=>F(C,W,z)))return new Response("Not Found",{status:404});let[h0,p,u]=await Promise.all([e.promises.stat(y).catch(()=>null),e.promises.stat(Z0).catch(()=>null),e.promises.stat(w0).catch(()=>null)]);if(h0?.isFile()&&!F(y,W,z))return L5(y);if(p?.isFile()&&!F(Z0,W,z))return L5(Z0);if(u?.isFile()&&!F(w0,W,z))return L5(w0);if(x.pathname.startsWith("/_stx/component/")){let C=decodeURIComponent(x.pathname.slice(16));if(C)try{let X0=`<${C} />`,a={...buildConfig,autoShell:!1},o=await processDirectives(X0,{},m.join(W,"components",`${C}.stx`),a,new Set);return new Response(o,{headers:{"Content-Type":"text/html"}})}catch(X0){return new Response(`<div class="stx-async-error">${X0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(x.pathname==="/_stx/img"){let{handleImageRequest:C}=await import("./chunk-3w6z6tw9.js"),X0=await C(R,{publicDir:m.join(W,P),cacheDir:p0(W,"cache","img")});if(X0)return X0}if(D)try{let C=await D.handleRequest(R);if(C.status!==404)return C}catch{}if(w[x.pathname])try{return await w[x.pathname](R)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=await j(R);if(g)return g;let h=F5(x.pathname,N);if(h){let C=f.get(h.route.pattern),X0=c.has(h.route.pattern);if(h.route.isDynamic&&Object.keys(h.params).length>0||X0){let a=await k(h.route,h.params);if(a)C=a}if(C){let a=C.status??200,o=C.headers??{},_0=(h.route.filePath?o6(await Bun.file(h.route.filePath).text().catch(()=>"")):null)??{};if(_0.validate){if(!await _0.validate({params:h.params})){let T0=await v(404);if(T0){let r=T0;if(r=await J0(r,W),Y)r=y0(r,G);return new Response(r,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(_0.middleware){let A0=a6(x.pathname,h.params,_0,x.search),T0=s6(A0,null,R,{isServer:!0}),r=await r6(_0.middleware,T0);if(r.redirect){let n=r.redirect.path,b0=r.redirect.options.redirectCode||302,H0=new Headers(r.responseHeaders);return H0.set("Location",n),new Response(null,{status:b0,headers:H0})}if(r.abort){let{statusCode:n,message:b0}=r.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${n}</title></head><body><h1>Error ${n}</h1><p>${b0}</p></body></html>`,{status:n,headers:{"Content-Type":"text/html"}})}if(Object.keys(r.state).length>0){let n=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(r.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;C.content=C.content.replace("</head>",`${n}</head>`)}}let d=C.content;if(q&&Q7(R)){let A0=n6(d),T0=t6(d),r=d.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=r?X7(r[1].trim()):"";if(Object.keys(h.params).length>0)d=j0(d,h.params);d=await J0(d,W);let b0=_?.router?.container||"main";return d=Y7(d,b0),new Response(d,{status:a,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":A0.layout,"X-STX-Layout-Group":A0.group,"X-STX-Runtime":T0?"true":"false",...n&&{"X-STX-Title":encodeURIComponent(n)},[e6]:$7(),...F1(),"Cache-Control":N$}})}if(q)d=q$(q,d);if(Object.keys(h.params).length>0)d=j0(d,h.params);if(d=await J0(d,W),Y)d=y0(d,G);if(X.native)if(d.includes("<head>"))d=d.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else d="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+d;if(X.titlebarHidden)if(d.includes("<head>"))d=d.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else d=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${d}`;if(C.boundaries&&C.boundaries.length>0){let{renderStreamingPage:A0,streamToResponse:T0}=await import("./chunk-8x05b790.js");return T0(A0(d,C.boundaries,{timeoutMs:30000}),{status:a,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(d,{status:a,headers:{"Content-Type":"text/html",...F1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...o}})}}if(M.length>0){let C=M.map((a)=>a.route),X0=F5(x.pathname,C);if(X0){let a=A.get(X0.route.pattern);if(a){let o=a.content;if(q)o=q$(q,o);if(Object.keys(X0.params).length>0)o=j0(o,X0.params);if(o=await J0(o,W),Y)o=y0(o,G);return new Response(o,{status:a.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of V)if(a!=="/"&&x.pathname.startsWith(a)){let o=A.get(a)||A.get(a+"/");if(o){let _0=o.content;if(q)_0=q$(q,_0);if(_0=await J0(_0,W),Y)_0=y0(_0,G);return new Response(_0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let Y0=f.get("/");if(Y0){let C=Y0.content;if(C=await J0(C,W),Y)C=y0(C,G);if(X.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let d0=await v(404);if(d0){let C=d0;if(C=await J0(C,W),Y)C=y0(C,G);return new Response(C,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(R){let x=await v(500);if(x)return new Response(x,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${R}
1623
1623
  ${R.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
1624
1624
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
1625
1625
  ${B.bright}\u2192 ${B.cyan}http://localhost:${f0}/${B.reset}`),Y)console.log(`${B.dim} HMR: ws://localhost:${G}${B.reset}`);console.log(`
1626
- ${B.yellow}Routes:${B.reset}`);let K0=[...y6(N,W)];for(let{route:R}of M)K0.push(`${R.pattern}`);if(K0.forEach((R,x)=>{let y=x===K0.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${B.green}${y}${B.reset}${R}`)}),console.log(`
1627
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(Q1.url.toString(),()=>{if(J)D1();Q1.stop()}),X.native){let R,x=m.join(O,"index.stx");if(e.existsSync(x)){let y=await Bun.file(x).text();R=Z$(y)}let P=_?.app?.window??{};await W1(f0,{title:_?.app?.head?.title||m.basename(W)||"stx App",width:P.width,height:P.height,darkMode:P.darkMode,hotReload:P.hotReload,titlebarHidden:P.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!R,sidebarConfig:R})}if(Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let R=(p)=>{return p.startsWith("public/")||p.startsWith("public\\")},x=(p)=>{let u=p.toLowerCase();return u.endsWith(".stx")||u.endsWith(".html")||u.endsWith(".md")},P=new Map,y=()=>{let p=new Set([W,..._._layerGraph?.layers.map((u)=>u.root)??[],..._._layerGraph?.configDependencies.map((u)=>m.dirname(u))??[]].filter((u)=>e.existsSync(u)).map((u)=>e.realpathSync(u)));for(let u of _._layerGraph?.layers??[])for(let g of Object.values(u.resources)){if(!e.existsSync(g))continue;let h=e.realpathSync(g);if(![...p].some((Y0)=>h===Y0||h.startsWith(`${Y0}${m.sep}`)))p.add(h)}for(let[u,g]of P)if(!p.has(u))g.close(),P.delete(u);for(let u of p)if(!P.has(u)&&e.existsSync(u))P.set(u,e.watch(u,{recursive:!0},(g,h)=>{w0(u,g,h).catch((Y0)=>console.error("[stx] Layer rebuild failed:",Y0))}))},Z0=Promise.resolve(),w0=(p,u,g)=>{return Z0=Z0.catch(()=>{}).then(()=>h0(p,u,g)),Z0},h0=async(p,u,g)=>{if(!g||J$(g))return;if(Y$(g)){if(_._layerGraph){let h=await K(W);Object.assign(_,h),N.splice(0,N.length,...H$(H,{pagesDir:L,pagesDirs:h._layerPageDirs?[O,...h._layerPageDirs.slice(1)]:void 0})),y()}if(R(g)){if(console.log(`${B.cyan}${g} changed${B.reset}`),Y&&J)J.reload(g)}else if(x(g)){console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),t0.clear(),e0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-gg3hm3kq.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(I&&g){if(m.resolve(p,g)===I||m.basename(I)===g){let Y0=await B5(I,X.stxOptions||{});if(Y0)A=Y0}}if(await W0(),await F$(W),Y&&J)J.reload(g)}else{console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),t0.clear(),e0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-gg3hm3kq.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(await W0(),Y&&J)J.reload(g)}}else if(Q$(g)){if(console.log(`${B.cyan}CSS ${g} changed${B.reset}`),Y&&J)J.updateCss(g)}};y(),process.on("SIGINT",()=>{for(let p of P.values())p.close();if(J)D1();Q1.stop(),process.exit(0)})}return!0}var b={enabled:!1,components:new Map,stores:new Map,events:[],performance:[],selectedComponent:null,selectedStore:null,maxEvents:1000,maxPerformance:500};function m4($={}){if(typeof window>"u")return;b.enabled=!0,b.maxEvents=$.maxEvents||1000,b.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>b,getComponents:()=>Array.from(b.components.values()),getComponent:(X)=>b.components.get(X),getStores:()=>Array.from(b.stores.values()),getStore:(X)=>b.stores.get(X),getEvents:()=>b.events,getPerformance:()=>b.performance,selectComponent:(X)=>z5(X),selectStore:(X)=>c4(X),inspectElement:(X)=>l4(X),highlightComponent:(X)=>X7(X),clearHighlight:()=>Z7(),logComponentTree:()=>i4(),logStoreState:(X)=>a4(X),timeTravel:(X,Z)=>s4(X,Z)},n4(),r4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function p4(){b.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function o6($){if(!b.enabled)return;let X=b.components.get($);if(X){if(X.parentId){let Z=b.components.get(X.parentId);if(Z)Z.children=Z.children.filter((Q)=>Q!==$)}b.components.delete($),F5({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function e6($,X,Z={},Q=[]){if(!b.enabled)return;let Y={id:$,state:X,getters:Z,actions:Q,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};b.stores.set($,Y),F5({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function $7($,X,Z,Q,Y="state"){if(!b.enabled)return;let J=b.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Z,newValue:Q,stack:Error().stack};if(J.history.push(G),J.history.length>100)J.history=J.history.slice(-100);if(Y==="state")J.state={...J.state,[X]:Q};F5({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Z,newValue:Q}})}}function F5($){if(!b.enabled)return;if(b.events.push($),b.events.length>b.maxEvents)b.events=b.events.slice(-b.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function z5($){b.selectedComponent=$;let X=b.components.get($);if(X)X7($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function c4($){b.selectedStore=$;let X=b.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function l4($){let X=$;while(X){let Z=X.getAttribute("data-stx-component-id");if(Z)return z5(Z);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function X7($){Z7();let X=b.components.get($);if(X?.element){let Z=document.createElement("div");Z.id="stx-devtools-highlight",Z.style.cssText=`
1626
+ ${B.yellow}Routes:${B.reset}`);let K0=[...p6(N,W)];for(let{route:R}of M)K0.push(`${R.pattern}`);if(K0.forEach((R,x)=>{let y=x===K0.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${B.green}${y}${B.reset}${R}`)}),console.log(`
1627
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(Q1.url.toString(),()=>{if(J)T1();Q1.stop()}),X.native){let R,x=m.join(O,"index.stx");if(e.existsSync(x)){let y=await Bun.file(x).text();R=J$(y)}let P=_?.app?.window??{};await K1(f0,{title:_?.app?.head?.title||m.basename(W)||"stx App",width:P.width,height:P.height,darkMode:P.darkMode,hotReload:P.hotReload,titlebarHidden:P.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!R,sidebarConfig:R})}if(Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let R=(p)=>{return p.startsWith("public/")||p.startsWith("public\\")},x=(p)=>{let u=p.toLowerCase();return u.endsWith(".stx")||u.endsWith(".html")||u.endsWith(".md")},P=new Map,y=()=>{let p=new Set([W,..._._layerGraph?.layers.map((u)=>u.root)??[],..._._layerGraph?.configDependencies.map((u)=>m.dirname(u))??[]].filter((u)=>e.existsSync(u)).map((u)=>e.realpathSync(u)));for(let u of _._layerGraph?.layers??[])for(let g of Object.values(u.resources)){if(!e.existsSync(g))continue;let h=e.realpathSync(g);if(![...p].some((Y0)=>h===Y0||h.startsWith(`${Y0}${m.sep}`)))p.add(h)}for(let[u,g]of P)if(!p.has(u))g.close(),P.delete(u);for(let u of p)if(!P.has(u)&&e.existsSync(u))P.set(u,e.watch(u,{recursive:!0},(g,h)=>{w0(u,g,h).catch((Y0)=>console.error("[stx] Layer rebuild failed:",Y0))}))},Z0=Promise.resolve(),w0=(p,u,g)=>{return Z0=Z0.catch(()=>{}).then(()=>h0(p,u,g)),Z0},h0=async(p,u,g)=>{if(!g||K$(g))return;if(W$(g)){if(_._layerGraph){let h=await K(W);Object.assign(_,h),N.splice(0,N.length,...A$(H,{pagesDir:L,pagesDirs:h._layerPageDirs?[O,...h._layerPageDirs.slice(1)]:void 0})),y()}if(R(g)){if(console.log(`${B.cyan}${g} changed${B.reset}`),Y&&J)J.reload(g)}else if(x(g)){console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),t0.clear(),e0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-sy9pfe3h.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(I&&g){if(m.resolve(p,g)===I||m.basename(I)===g){let Y0=await z5(I,X.stxOptions||{});if(Y0)q=Y0}}if(await W0(),await H$(W),Y&&J)J.reload(g)}else{console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),t0.clear(),e0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-sy9pfe3h.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(await W0(),Y&&J)J.reload(g)}}else if(G$(g)){if(console.log(`${B.cyan}CSS ${g} changed${B.reset}`),Y&&J)J.updateCss(g)}};y(),process.on("SIGINT",()=>{for(let p of P.values())p.close();if(J)T1();Q1.stop(),process.exit(0)})}return!0}var b={enabled:!1,components:new Map,stores:new Map,events:[],performance:[],selectedComponent:null,selectedStore:null,maxEvents:1000,maxPerformance:500};function e4($={}){if(typeof window>"u")return;b.enabled=!0,b.maxEvents=$.maxEvents||1000,b.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>b,getComponents:()=>Array.from(b.components.values()),getComponent:(X)=>b.components.get(X),getStores:()=>Array.from(b.stores.values()),getStore:(X)=>b.stores.get(X),getEvents:()=>b.events,getPerformance:()=>b.performance,selectComponent:(X)=>O5(X),selectStore:(X)=>XX(X),inspectElement:(X)=>ZX(X),highlightComponent:(X)=>_7(X),clearHighlight:()=>U7(),logComponentTree:()=>QX(),logStoreState:(X)=>YX(X),timeTravel:(X,Z)=>JX(X,Z)},WX(),GX(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function $X(){b.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function J7($){if(!b.enabled)return;let X=b.components.get($);if(X){if(X.parentId){let Z=b.components.get(X.parentId);if(Z)Z.children=Z.children.filter((Q)=>Q!==$)}b.components.delete($),H5({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function W7($,X,Z={},Q=[]){if(!b.enabled)return;let Y={id:$,state:X,getters:Z,actions:Q,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};b.stores.set($,Y),H5({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function K7($,X,Z,Q,Y="state"){if(!b.enabled)return;let J=b.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Z,newValue:Q,stack:Error().stack};if(J.history.push(G),J.history.length>100)J.history=J.history.slice(-100);if(Y==="state")J.state={...J.state,[X]:Q};H5({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Z,newValue:Q}})}}function H5($){if(!b.enabled)return;if(b.events.push($),b.events.length>b.maxEvents)b.events=b.events.slice(-b.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function O5($){b.selectedComponent=$;let X=b.components.get($);if(X)_7($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function XX($){b.selectedStore=$;let X=b.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function ZX($){let X=$;while(X){let Z=X.getAttribute("data-stx-component-id");if(Z)return O5(Z);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function _7($){U7();let X=b.components.get($);if(X?.element){let Z=document.createElement("div");Z.id="stx-devtools-highlight",Z.style.cssText=`
1628
1628
  position: absolute;
1629
1629
  background: rgba(59, 130, 246, 0.2);
1630
1630
  border: 2px solid #3b82f6;
@@ -1642,7 +1642,7 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(Q1.
1642
1642
  font-family: monospace;
1643
1643
  border-radius: 4px;
1644
1644
  white-space: nowrap;
1645
- `,Y.textContent=`<${X.name}>`,Z.appendChild(Y),document.body.appendChild(Z)}}function Z7(){let $=document.getElementById("stx-devtools-highlight");if($)$.remove()}function i4(){console.group("%c[STX DevTools] Component Tree","color: #10b981; font-weight: bold;");let $=Array.from(b.components.values()).filter((Z)=>!Z.parentId);function X(Z,Q){let Y=" ".repeat(Q);if(console.log(`${Y}%c<${Z.name}>%c id=${Z.id} renders=${Z.renderCount}`,"color: #3b82f6;","color: #6b7280;"),Object.keys(Z.props).length>0)console.log(`${Y} props:`,Z.props);if(Object.keys(Z.state).length>0)console.log(`${Y} state:`,Z.state);for(let J of Z.children){let G=b.components.get(J);if(G)X(G,Q+1)}}for(let Z of $)X(Z,0);console.groupEnd()}function a4($){console.group("%c[STX DevTools] Store State","color: #8b5cf6; font-weight: bold;");let X=$?[b.stores.get($)].filter(Boolean):Array.from(b.stores.values());for(let Z of X)if(Z)console.group(`Store: ${Z.id}`),console.log("State:",Z.state),console.log("Getters:",Z.getters),console.log("Actions:",Z.actions),console.log("History:",Z.history),console.groupEnd();console.groupEnd()}function s4($,X){let Z=b.stores.get(X);if(!Z)return;if($<0||$>=Z.history.length){console.warn("[STX DevTools] Invalid history index");return}let Q={};for(let Y=0;Y<=$;Y++){let J=Z.history[Y];if(J.type==="state"&&J.name!=="__init__")Q[J.name]=J.newValue;else if(J.name==="__init__")Object.assign(Q,J.newValue)}if(console.log(`%c[STX DevTools] Time traveled to index ${$}`,"color: #f59e0b;",Q),typeof window<"u"&&window.__STX_STORES__){let J=window.__STX_STORES__[X];if(J&&typeof J.$patch==="function")J.$patch(Q)}}function r4(){if(typeof MutationObserver>"u")return;new MutationObserver((X)=>{for(let Z of X)Z.removedNodes.forEach((Q)=>{if(Q instanceof HTMLElement){let Y=Q.getAttribute("data-stx-component-id");if(Y)o6(Y);Q.querySelectorAll("[data-stx-component-id]").forEach((J)=>{let G=J.getAttribute("data-stx-component-id");if(G)o6(G)})}})}).observe(document.body,{childList:!0,subtree:!0})}function n4(){if(typeof document>"u")return;if(document.getElementById("stx-devtools-panel"))return;let $=document.createElement("div");$.id="stx-devtools-panel",$.innerHTML=`
1645
+ `,Y.textContent=`<${X.name}>`,Z.appendChild(Y),document.body.appendChild(Z)}}function U7(){let $=document.getElementById("stx-devtools-highlight");if($)$.remove()}function QX(){console.group("%c[STX DevTools] Component Tree","color: #10b981; font-weight: bold;");let $=Array.from(b.components.values()).filter((Z)=>!Z.parentId);function X(Z,Q){let Y=" ".repeat(Q);if(console.log(`${Y}%c<${Z.name}>%c id=${Z.id} renders=${Z.renderCount}`,"color: #3b82f6;","color: #6b7280;"),Object.keys(Z.props).length>0)console.log(`${Y} props:`,Z.props);if(Object.keys(Z.state).length>0)console.log(`${Y} state:`,Z.state);for(let J of Z.children){let G=b.components.get(J);if(G)X(G,Q+1)}}for(let Z of $)X(Z,0);console.groupEnd()}function YX($){console.group("%c[STX DevTools] Store State","color: #8b5cf6; font-weight: bold;");let X=$?[b.stores.get($)].filter(Boolean):Array.from(b.stores.values());for(let Z of X)if(Z)console.group(`Store: ${Z.id}`),console.log("State:",Z.state),console.log("Getters:",Z.getters),console.log("Actions:",Z.actions),console.log("History:",Z.history),console.groupEnd();console.groupEnd()}function JX($,X){let Z=b.stores.get(X);if(!Z)return;if($<0||$>=Z.history.length){console.warn("[STX DevTools] Invalid history index");return}let Q={};for(let Y=0;Y<=$;Y++){let J=Z.history[Y];if(J.type==="state"&&J.name!=="__init__")Q[J.name]=J.newValue;else if(J.name==="__init__")Object.assign(Q,J.newValue)}if(console.log(`%c[STX DevTools] Time traveled to index ${$}`,"color: #f59e0b;",Q),typeof window<"u"&&window.__STX_STORES__){let J=window.__STX_STORES__[X];if(J&&typeof J.$patch==="function")J.$patch(Q)}}function GX(){if(typeof MutationObserver>"u")return;new MutationObserver((X)=>{for(let Z of X)Z.removedNodes.forEach((Q)=>{if(Q instanceof HTMLElement){let Y=Q.getAttribute("data-stx-component-id");if(Y)J7(Y);Q.querySelectorAll("[data-stx-component-id]").forEach((J)=>{let G=J.getAttribute("data-stx-component-id");if(G)J7(G)})}})}).observe(document.body,{childList:!0,subtree:!0})}function WX(){if(typeof document>"u")return;if(document.getElementById("stx-devtools-panel"))return;let $=document.createElement("div");$.id="stx-devtools-panel",$.innerHTML=`
1646
1646
  <style>
1647
1647
  #stx-devtools-panel {
1648
1648
  position: fixed;
@@ -1751,7 +1751,7 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(Q1.
1751
1751
  <div id="stx-devtools-content">
1752
1752
  <div id="stx-devtools-components-tab"></div>
1753
1753
  </div>
1754
- `,document.body.appendChild($);let X=$.querySelector("#stx-devtools-header"),Z=$.querySelector("#stx-devtools-toggle");X?.addEventListener("click",()=>{if($.classList.toggle("open"),Z)Z.textContent=$.classList.contains("open")?"\u25BC":"\u25B2"});let Q=$.querySelectorAll(".stx-devtools-tab");Q.forEach((Y)=>{Y.addEventListener("click",()=>{Q.forEach((J)=>J.classList.remove("active")),Y.classList.add("active"),t6(Y.getAttribute("data-tab")||"components")})}),setInterval(()=>{let Y=$.querySelector(".stx-devtools-tab.active");if(Y&&$.classList.contains("open"))t6(Y.getAttribute("data-tab")||"components")},1000)}function t6($){let X=document.getElementById("stx-devtools-content");if(!X)return;switch($){case"components":X.innerHTML=o4();break;case"stores":X.innerHTML=t4();break;case"events":X.innerHTML=e4();break}X.querySelectorAll(".stx-devtools-component").forEach((Z)=>{Z.addEventListener("click",()=>{let Q=Z.getAttribute("data-id");if(Q)z5(Q)})})}function o4(){let X=Array.from(b.components.values()).filter((Q)=>!Q.parentId);function Z(Q,Y){let J=Q.children.map((G)=>b.components.get(G)).filter(Boolean).map((G)=>Z(G,Y+1)).join("");return`
1754
+ `,document.body.appendChild($);let X=$.querySelector("#stx-devtools-header"),Z=$.querySelector("#stx-devtools-toggle");X?.addEventListener("click",()=>{if($.classList.toggle("open"),Z)Z.textContent=$.classList.contains("open")?"\u25BC":"\u25B2"});let Q=$.querySelectorAll(".stx-devtools-tab");Q.forEach((Y)=>{Y.addEventListener("click",()=>{Q.forEach((J)=>J.classList.remove("active")),Y.classList.add("active"),G7(Y.getAttribute("data-tab")||"components")})}),setInterval(()=>{let Y=$.querySelector(".stx-devtools-tab.active");if(Y&&$.classList.contains("open"))G7(Y.getAttribute("data-tab")||"components")},1000)}function G7($){let X=document.getElementById("stx-devtools-content");if(!X)return;switch($){case"components":X.innerHTML=KX();break;case"stores":X.innerHTML=_X();break;case"events":X.innerHTML=UX();break}X.querySelectorAll(".stx-devtools-component").forEach((Z)=>{Z.addEventListener("click",()=>{let Q=Z.getAttribute("data-id");if(Q)O5(Q)})})}function KX(){let X=Array.from(b.components.values()).filter((Q)=>!Q.parentId);function Z(Q,Y){let J=Q.children.map((G)=>b.components.get(G)).filter(Boolean).map((G)=>Z(G,Y+1)).join("");return`
1755
1755
  <div class="stx-devtools-component ${b.selectedComponent===Q.id?"selected":""}"
1756
1756
  data-id="${Q.id}"
1757
1757
  style="padding-left: ${Y*16+8}px">
@@ -1759,25 +1759,25 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(Q1.
1759
1759
  <span class="stx-devtools-component-id">${Q.id}</span>
1760
1760
  </div>
1761
1761
  ${J}
1762
- `}if(X.length===0)return'<div style="color: #6b7280; padding: 8px;">No components registered</div>';return X.map((Q)=>Z(Q,0)).join("")}function t4(){let $=Array.from(b.stores.values());if($.length===0)return'<div style="color: #6b7280; padding: 8px;">No stores registered</div>';return $.map((X)=>`
1762
+ `}if(X.length===0)return'<div style="color: #6b7280; padding: 8px;">No components registered</div>';return X.map((Q)=>Z(Q,0)).join("")}function _X(){let $=Array.from(b.stores.values());if($.length===0)return'<div style="color: #6b7280; padding: 8px;">No stores registered</div>';return $.map((X)=>`
1763
1763
  <div class="stx-devtools-section">
1764
1764
  <div class="stx-devtools-section-title">${X.id}</div>
1765
1765
  <div class="stx-devtools-json">${JSON.stringify(X.state,null,2)}</div>
1766
1766
  </div>
1767
- `).join("")}function e4(){let $=b.events.slice(-20).reverse();if($.length===0)return'<div style="color: #6b7280; padding: 8px;">No events recorded</div>';return $.map((X)=>`
1767
+ `).join("")}function UX(){let $=b.events.slice(-20).reverse();if($.length===0)return'<div style="color: #6b7280; padding: 8px;">No events recorded</div>';return $.map((X)=>`
1768
1768
  <div style="padding: 4px 0; border-bottom: 1px solid #374151;">
1769
1769
  <span style="color: #60a5fa;">${X.type}</span>
1770
1770
  <span style="color: #6b7280; font-size: 10px; margin-left: 8px;">
1771
1771
  ${new Date(X.timestamp).toLocaleTimeString()}
1772
1772
  </span>
1773
1773
  </div>
1774
- `).join("")}import j5 from"fs";import k1 from"path";async function $X($){try{let Z=(await Bun.file($).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!Z)return[];let Q=Z[1],Y=[],J=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,G;while((G=J.exec(Q))!==null){let W=G[1],K=G[2]||G[3]||G[4];if(!K)continue;let _={name:K},U=W.match(/@type\s+\{([^}]+)\}/i);if(U)_.type=U[1].trim();if(W.match(/@required/i))_.required=!0;let z=W.match(/@default\s+(.+?)(?:\s+|$)/i);if(z)_.default=z[1].trim();let j=W.split(`
1775
- `).map((H)=>H.trim().replace(/^\*\s*/,"")).filter((H)=>!H.startsWith("@")&&H.length>0);_.description=j.join(" ").trim(),Y.push(_)}if(Y.length===0){let W=Q.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(W){let _=W[1].split(",").map((U)=>U.trim()).filter(Boolean);for(let U of _){let[F]=U.split(":").map((z)=>z.trim());if(F)Y.push({name:F})}}}return Y}catch(X){return console.error(`Error extracting props from ${$}:`,X),[]}}async function XX($){try{let X=await Bun.file($).text(),Z=X.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||X.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(Z)return Z[1].split(`
1776
- `).map((Q)=>Q.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function ZX($,X=!1,Z){let Q=k1.basename($,".stx"),Y=await $X($),J=await XX($),G="";if(X&&Z)G=`<${Z}></${Z}>`;else{let W=Y.map((K)=>{if(K.type==="boolean")return`:${K.name}="true"`;return`${K.name}="value"`}).join(`
1774
+ `).join("")}import N5 from"fs";import S1 from"path";async function BX($){try{let Z=(await Bun.file($).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!Z)return[];let Q=Z[1],Y=[],J=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,G;while((G=J.exec(Q))!==null){let W=G[1],K=G[2]||G[3]||G[4];if(!K)continue;let _={name:K},U=W.match(/@type\s+\{([^}]+)\}/i);if(U)_.type=U[1].trim();if(W.match(/@required/i))_.required=!0;let z=W.match(/@default\s+(.+?)(?:\s+|$)/i);if(z)_.default=z[1].trim();let j=W.split(`
1775
+ `).map((H)=>H.trim().replace(/^\*\s*/,"")).filter((H)=>!H.startsWith("@")&&H.length>0);_.description=j.join(" ").trim(),Y.push(_)}if(Y.length===0){let W=Q.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(W){let _=W[1].split(",").map((U)=>U.trim()).filter(Boolean);for(let U of _){let[F]=U.split(":").map((z)=>z.trim());if(F)Y.push({name:F})}}}return Y}catch(X){return console.error(`Error extracting props from ${$}:`,X),[]}}async function LX($){try{let X=await Bun.file($).text(),Z=X.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||X.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(Z)return Z[1].split(`
1776
+ `).map((Q)=>Q.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function FX($,X=!1,Z){let Q=S1.basename($,".stx"),Y=await BX($),J=await LX($),G="";if(X&&Z)G=`<${Z}></${Z}>`;else{let W=Y.map((K)=>{if(K.type==="boolean")return`:${K.name}="true"`;return`${K.name}="value"`}).join(`
1777
1777
  `);G=`<${Q}
1778
1778
  ${W}
1779
- />`}return{name:Q,path:$,description:J,props:Y,example:G,isWebComponent:X,tag:Z}}async function Q7($){try{if(!await x1($))return console.warn(`Components directory does not exist: ${$}`),[];let X=await j5.promises.readdir($,{withFileTypes:!0}),Z=[];for(let Q of X){let Y=k1.join($,Q.name);if(Q.isDirectory()){let J=await Q7(Y);Z.push(...J)}else if(Q.isFile()&&Q.name.endsWith(".stx"))Z.push(Y)}return Z}catch(X){return console.error(`Error finding component files in ${$}:`,X),[]}}async function QX($,X){try{if(!await x1($))return[];let Z=await Q7($),Q=[],Y=new Map;if(X?.components?.length)for(let J of X.components)Y.set(J.file,J);for(let J of Z){let G=Y.get(J),W=!!G,K=G?.tag,_=await ZX(J,W,K);Q.push(_)}return Q}catch(Z){return console.error("Error generating component docs:",Z),[]}}async function YX($){try{if(!await x1($))return[];let X=await j5.promises.readdir($,{withFileTypes:!0}),Z=[];for(let Q of X){if(!Q.isFile()||!Q.name.endsWith(".stx"))continue;let Y=k1.join($,Q.name),J=await Bun.file(Y).text(),G=k1.basename(Y,".stx"),W=J.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||J.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//),K=W?W[1].split(`
1780
- `).map((L)=>L.trim().replace(/^\*\s*/,"")).join(" ").trim():"",_=/@component\(\s*['"]([^'"]+)['"]/g,U=/<([A-Z][a-zA-Z0-9]*|[a-z]+-[a-z0-9-]+)(?:\s[^>]*)?\/?>|\{\{\s*slot\s*\}\}/g,F=new Set,z;while((z=_.exec(J))!==null)F.add(z[1]);while((z=U.exec(J))!==null)if(z[1]&&z[1]!=="slot")F.add(z[1]);let j=/@([a-z]+)(?:\s*\(|\s+|$)/g,H=new Set;while((z=j.exec(J))!==null)H.add(z[1]);Z.push({name:G,path:Y,description:K,components:[...F],directives:[...H]})}return Z}catch(X){return console.error("Error generating template docs:",X),[]}}async function JX($=[]){try{let X=[{name:"if",description:"Conditionally render content based on a condition",hasEndTag:!0,example:`@if(user.isLoggedIn)
1779
+ />`}return{name:Q,path:$,description:J,props:Y,example:G,isWebComponent:X,tag:Z}}async function B7($){try{if(!await P1($))return console.warn(`Components directory does not exist: ${$}`),[];let X=await N5.promises.readdir($,{withFileTypes:!0}),Z=[];for(let Q of X){let Y=S1.join($,Q.name);if(Q.isDirectory()){let J=await B7(Y);Z.push(...J)}else if(Q.isFile()&&Q.name.endsWith(".stx"))Z.push(Y)}return Z}catch(X){return console.error(`Error finding component files in ${$}:`,X),[]}}async function zX($,X){try{if(!await P1($))return[];let Z=await B7($),Q=[],Y=new Map;if(X?.components?.length)for(let J of X.components)Y.set(J.file,J);for(let J of Z){let G=Y.get(J),W=!!G,K=G?.tag,_=await FX(J,W,K);Q.push(_)}return Q}catch(Z){return console.error("Error generating component docs:",Z),[]}}async function jX($){try{if(!await P1($))return[];let X=await N5.promises.readdir($,{withFileTypes:!0}),Z=[];for(let Q of X){if(!Q.isFile()||!Q.name.endsWith(".stx"))continue;let Y=S1.join($,Q.name),J=await Bun.file(Y).text(),G=S1.basename(Y,".stx"),W=J.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||J.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//),K=W?W[1].split(`
1780
+ `).map((L)=>L.trim().replace(/^\*\s*/,"")).join(" ").trim():"",_=/@component\(\s*['"]([^'"]+)['"]/g,U=/<([A-Z][a-zA-Z0-9]*|[a-z]+-[a-z0-9-]+)(?:\s[^>]*)?\/?>|\{\{\s*slot\s*\}\}/g,F=new Set,z;while((z=_.exec(J))!==null)F.add(z[1]);while((z=U.exec(J))!==null)if(z[1]&&z[1]!=="slot")F.add(z[1]);let j=/@([a-z]+)(?:\s*\(|\s+|$)/g,H=new Set;while((z=j.exec(J))!==null)H.add(z[1]);Z.push({name:G,path:Y,description:K,components:[...F],directives:[...H]})}return Z}catch(X){return console.error("Error generating template docs:",X),[]}}async function HX($=[]){try{let X=[{name:"if",description:"Conditionally render content based on a condition",hasEndTag:!0,example:`@if(user.isLoggedIn)
1781
1781
  <p>Welcome, {{ user.name }}!</p>
1782
1782
  @endif`},{name:"else",description:"Provides an alternative if a condition is not met",hasEndTag:!1,example:`@if(user.isLoggedIn)
1783
1783
  <p>Welcome back!</p>
@@ -1797,7 +1797,7 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(Q1.
1797
1797
  <p>Page {{ page }}</p>
1798
1798
  @endwhile`},{name:"component",description:"Include a component in the template",hasEndTag:!1,example:'@component("alert", { type: "warning", title: "Warning", message: "This is a warning" })'},{name:"include",description:"Include a partial template",hasEndTag:!1,example:'@include("partials/header")'},{name:"raw",description:"Display content without processing expressions",hasEndTag:!0,example:`@raw
1799
1799
  {{ This will be displayed as-is }}
1800
- @endraw`},{name:"translate",description:"Translate a string using the i18n system",hasEndTag:!1,example:'@translate("welcome.message", { name: user.name })'},{name:"t",description:"Short alias for translate directive",hasEndTag:!1,example:'@t("welcome.message", { name: user.name })'}];for(let Z of $)X.push({name:Z.name,description:Z.description||"",hasEndTag:Z.hasEndTag||!1,example:""});return X}catch(X){return console.error("Error generating directive docs:",X),[]}}function GX($=[],X=[],Z=[],Q){let Y=`# stx Documentation
1800
+ @endraw`},{name:"translate",description:"Translate a string using the i18n system",hasEndTag:!1,example:'@translate("welcome.message", { name: user.name })'},{name:"t",description:"Short alias for translate directive",hasEndTag:!1,example:'@t("welcome.message", { name: user.name })'}];for(let Z of $)X.push({name:Z.name,description:Z.description||"",hasEndTag:Z.hasEndTag||!1,example:""});return X}catch(X){return console.error("Error generating directive docs:",X),[]}}function OX($=[],X=[],Z=[],Q){let Y=`# stx Documentation
1801
1801
 
1802
1802
  `;if(Q)Y+=`${Q}
1803
1803
 
@@ -1839,7 +1839,7 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(Q1.
1839
1839
 
1840
1840
  `,Y+=`#### Example
1841
1841
 
1842
- `,Y+="```html\n",Y+=J.example,Y+="\n```\n\n"}return Y}function WX($=[],X=[],Z=[],Q){let Y=`<!DOCTYPE html>
1842
+ `,Y+="```html\n",Y+=J.example,Y+="\n```\n\n"}return Y}function NX($=[],X=[],Z=[],Q){let Y=`<!DOCTYPE html>
1843
1843
  <html lang="en">
1844
1844
  <head>
1845
1845
  <meta charset="UTF-8">
@@ -1910,15 +1910,15 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),m0(Q1.
1910
1910
  <td>@${J.name}</td>
1911
1911
  <td>${J.description||"-"}</td>
1912
1912
  <td>${J.hasEndTag?"Yes":"No"}</td>
1913
- </tr>`;Y+="</tbody></table>";for(let J of Z)if(J.example)Y+=`<h3>@${J.name}</h3>`,Y+=`<p>${J.description||""}</p>`,Y+="<h4>Example</h4>",Y+=`<pre><code>${J.example.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}</code></pre>`}return Y+="</body></html>",Y}function KX($=[],X=[],Z=[],Q){return JSON.stringify({components:$,templates:X,directives:Z,extraContent:Q||""},null,2)}async function _X($){try{let{componentsDir:X,templatesDir:Z,webComponentsConfig:Q,customDirectives:Y,config:J}=$;if(!J.enabled)return!1;let G=J.outputDir||"docs";if(await j5.promises.mkdir(G,{recursive:!0}),console.log("Generating documentation..."),X)console.log(`Components directory: ${X}`);if(Z)console.log(`Templates directory: ${Z}`);console.log(`Output directory: ${G}`);let W=[];if(J.components!==!1&&X)console.log("Generating component documentation..."),W=await QX(X,Q),console.log(`Found ${W.length} components`);let K=[];if(J.templates!==!1&&Z)console.log("Generating template documentation..."),K=await YX(Z),console.log(`Found ${K.length} templates`);let _=[];if(J.directives!==!1)console.log("Generating directive documentation..."),_=await JX(Y),console.log(`Found ${_.length} directives`);let U=J.format||"markdown",F=J.extraContent,z="",j="";switch(U){case"markdown":z=GX(W,K,_,F),j="md";break;case"html":z=WX(W,K,_,F),j="html";break;case"json":z=KX(W,K,_,F),j="json";break;default:throw Error(`Unsupported documentation format: ${U}`)}let H=k1.join(G,`stx-docs.${j}`);return await Bun.write(H,z),console.log(`Documentation generated: ${H}`),!0}catch(X){return console.error("Error generating documentation:",X),!1}}async function e2($){let X={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Z=$.componentsDir||C0.componentsDir,Q=$.templatesDir||".";return _X({componentsDir:Z,templatesDir:Q,webComponentsConfig:C0.webComponents,customDirectives:C0.customDirectives,config:X})}import F1 from"process";function S1(){if(typeof globalThis<"u"&&"caches"in globalThis&&"CF"in globalThis)return{platform:"cloudflare",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","r2","d1","durable-objects","queues"]};if(typeof globalThis<"u"&&"Deno"in globalThis)return{platform:"deno",version:globalThis.Deno.version?.deno,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","deploy","ffi"]};if(typeof globalThis<"u"&&"Bun"in globalThis)return{platform:"bun",version:globalThis.Bun.version,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["sqlite","ffi","native-modules"]};if(typeof globalThis<"u"&&"EdgeRuntime"in globalThis)return{platform:"vercel",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["edge-config","blob"]};if(typeof globalThis<"u"&&"Netlify"in globalThis)return{platform:"netlify",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!1,capabilities:["blobs","edge-functions"]};if(typeof globalThis<"u"&&"fastly"in globalThis)return{platform:"fastly",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["dictionary","backend","geolocation"]};if(F1.versions?.node)return{platform:"node",version:F1.versions.node,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["fs","child-process","native-modules"]};return{platform:"unknown",supportsStreaming:!1,supportsCrypto:!1,supportsKV:!1,supportsCache:!1,capabilities:[]}}function QW(){let $=S1();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function YW(){return S1().platform!=="unknown"}function UX($){return{get(X){if($&&X in $){let Z=$[X];return typeof Z==="string"?Z:void 0}if(typeof globalThis<"u"&&"Deno"in globalThis)return globalThis.Deno.env.get(X);if(F1.env)return F1.env[X];return},getOrThrow(X){let Z=this.get(X);if(Z===void 0)throw Error(`Environment variable "${X}" is not set`);return Z},has(X){return this.get(X)!==void 0},all(){let X={};if($){for(let[Z,Q]of Object.entries($))if(typeof Q==="string")X[Z]=Q}if(typeof globalThis<"u"&&"Deno"in globalThis){let Z=globalThis.Deno.env.toObject();Object.assign(X,Z)}if(F1.env){for(let[Z,Q]of Object.entries(F1.env))if(Q!==void 0)X[Z]=Q}return X}}}function BX($){let X=S1();if(X.platform==="cloudflare"&&$)return $;if(X.platform==="deno"&&"Deno"in globalThis)return LX();if(X.platform==="node"||X.platform==="bun")return FX();return}function LX(){let $=null,X=async()=>{if(!$)$=await globalThis.Deno.openKv();return $};return{async get(Z){return(await(await X()).get(["stx",Z])).value},async getWithMetadata(Z){let Q=await X(),Y=await Q.get(["stx",Z]),J=await Q.get(["stx-meta",Z]);return{value:Y.value,metadata:J.value}},async put(Z,Q,Y){let J=await X(),G=Y?.expirationTtl?Y.expirationTtl*1000:void 0;if(await J.set(["stx",Z],Q,G?{expireIn:G}:void 0),Y?.metadata)await J.set(["stx-meta",Z],Y.metadata,G?{expireIn:G}:void 0)},async delete(Z){let Q=await X();await Q.delete(["stx",Z]),await Q.delete(["stx-meta",Z])},async list(Z){let Q=await X(),Y=Z?.prefix?["stx",Z.prefix]:["stx"],J=Q.list({prefix:Y,limit:Z?.limit||100}),G=[];for await(let W of J){let _=W.key.slice(1).join("/");if(!_.startsWith("stx-meta/"))G.push({name:_})}return{keys:G,list_complete:!0}}}}function FX(){let $=new Map,X=()=>{let Z=Date.now();for(let[Q,Y]of $.entries())if(Y.expiration&&Y.expiration<Z)$.delete(Q)};return{async get(Z){X();let Q=$.get(Z);if(!Q)return null;if(Q.expiration&&Q.expiration<Date.now())return $.delete(Z),null;return Q.value},async getWithMetadata(Z){X();let Q=$.get(Z);if(!Q)return{value:null,metadata:null};if(Q.expiration&&Q.expiration<Date.now())return $.delete(Z),{value:null,metadata:null};return{value:Q.value,metadata:Q.metadata||null}},async put(Z,Q,Y){let J=Y?.expiration?Y.expiration*1000:Y?.expirationTtl?Date.now()+Y.expirationTtl*1000:void 0;$.set(Z,{value:Q,metadata:Y?.metadata,expiration:J})},async delete(Z){$.delete(Z)},async list(Z){X();let Q=[];for(let[Y,J]of $.entries()){if(Z?.prefix&&!Y.startsWith(Z.prefix))continue;if(Q.push({name:Y,expiration:J.expiration,metadata:J.metadata}),Z?.limit&&Q.length>=Z.limit)break}return{keys:Q,list_complete:!0}}}}function zX(){let $=S1();if($.platform==="cloudflare"&&"caches"in globalThis)return jX();if($.supportsStreaming)return HX();return}function jX(){return{async match($){return(await caches.default).match($)},async put($,X){await(await caches.default).put($,X.clone())},async delete($){return(await caches.default).delete($)}}}function HX(){let $=new Map,X=60000;return{async match(Z){let Q=Z.url,Y=$.get(Q);if(!Y)return;if(Date.now()>Y.expiration){$.delete(Q);return}return Y.response.clone()},async put(Z,Q){let Y=Z.url,J=Q.headers.get("Cache-Control"),G=60000;if(J){let W=J.match(/max-age=(\d+)/);if(W)G=Number.parseInt(W[1],10)*1000}$.set(Y,{response:Q.clone(),expiration:Date.now()+G})},async delete(Z){return $.delete(Z.url)}}}function OX(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function NX($,X){if(X.platform==="cloudflare"){let Z=$.cf;if(Z)return{city:Z.city,country:Z.country,countryCode:Z.country,region:Z.region,latitude:Z.latitude?Number.parseFloat(Z.latitude):void 0,longitude:Z.longitude?Number.parseFloat(Z.longitude):void 0,timezone:Z.timezone}}if(X.platform==="vercel"){let Z={},Q=$.headers.get("x-vercel-ip-city"),Y=$.headers.get("x-vercel-ip-country"),J=$.headers.get("x-vercel-ip-country-region"),G=$.headers.get("x-vercel-ip-latitude"),W=$.headers.get("x-vercel-ip-longitude");if(Q)Z.city=decodeURIComponent(Q);if(Y)Z.countryCode=Y;if(J)Z.region=J;if(G)Z.latitude=Number.parseFloat(G);if(W)Z.longitude=Number.parseFloat(W);return Object.keys(Z).length>0?Z:void 0}if(X.platform==="netlify"){let Z={},Q=$.headers.get("x-nf-geo-city"),Y=$.headers.get("x-nf-geo-country");if(Q)Z.city=Q;if(Y)Z.countryCode=Y;return Object.keys(Z).length>0?Z:void 0}return}function H5($,X,Z){let Q=new Headers($.headers);if(X.origins==="*")Q.set("Access-Control-Allow-Origin","*");else if(X.origins&&Z&&X.origins.includes(Z))Q.set("Access-Control-Allow-Origin",Z),Q.set("Vary","Origin");if(X.methods)Q.set("Access-Control-Allow-Methods",X.methods.join(", "));if(X.headers)Q.set("Access-Control-Allow-Headers",X.headers.join(", "));if(X.exposeHeaders)Q.set("Access-Control-Expose-Headers",X.exposeHeaders.join(", "));if(X.credentials)Q.set("Access-Control-Allow-Credentials","true");if(X.maxAge)Q.set("Access-Control-Max-Age",String(X.maxAge));return new Response($.body,{status:$.status,statusText:$.statusText,headers:Q})}function q$($){let X=S1();return async(Z,Q)=>{let Y=performance.now(),J=OX(),G={runtime:X,platform:Q||{},requestId:J,geo:NX(Z,X),timing:{start:Y,getElapsed:()=>performance.now()-Y},kv:BX(Q?.KV),cache:zX(),env:UX(Q?.env)};try{if(Z.method==="OPTIONS"&&$.cors){let K=new Response(null,{status:204});return K=H5(K,$.cors,Z.headers.get("Origin")||void 0),K}if($.cache?.enabled&&Z.method==="GET"&&G.cache){if(Y7(Z,$.cache)){let _=await G.cache.match(Z);if(_){let U=new Response(_.body,_);return U.headers.set("X-Cache","HIT"),U.headers.set("X-Request-Id",J),$.cors?H5(U,$.cors,Z.headers.get("Origin")||void 0):U}}}let W;if($.middleware&&$.middleware.length>0)W=await qX(Z,G,$.middleware,async()=>{let K=await $.render(Z,G);return typeof K==="string"?new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}}):K});else{let K=await $.render(Z,G);W=typeof K==="string"?new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}}):K}if(W.headers.set("X-Request-Id",J),W.headers.set("X-Response-Time",`${G.timing.getElapsed().toFixed(2)}ms`),$.cache?.enabled&&Z.method==="GET"&&G.cache){if(Y7(Z,$.cache)&&W.status===200){let _=$.cache.ttl||60,U=W.clone();U.headers.set("Cache-Control",`public, max-age=${_}`),await G.cache.put(Z,U),W.headers.set("X-Cache","MISS")}}if($.cors)W=H5(W,$.cors,Z.headers.get("Origin")||void 0);return W}catch(W){let K=W instanceof Error?W:Error(String(W));if($.onError)return $.onError(K,Z);return new Response(`Internal Server Error: ${K.message}`,{status:500,headers:{"Content-Type":"text/plain","X-Request-Id":J}})}}}function Y7($,X){let Q=new URL($.url).pathname;if(X.excludePaths){for(let Y of X.excludePaths)if(Y.test(Q))return!1}if(X.includePaths){for(let Y of X.includePaths)if(Y.test(Q))return!0;return!1}return!0}async function qX($,X,Z,Q){let Y=0,J=async()=>{if(Y>=Z.length)return Q();let G=Z[Y];return Y++,G($,X,J)};return J()}function JW($,X){let Z=new Headers(X?.headers);return Z.set("Content-Type","text/html; charset=utf-8"),Z.set("Transfer-Encoding","chunked"),new Response($,{...X,headers:Z})}function GW(){let $=new TextEncoder;return new TransformStream({transform(X,Z){Z.enqueue($.encode(X))}})}function WW($){let X=new TextEncoder;return new ReadableStream({async start(Z){for await(let Q of $)Z.enqueue(X.encode(Q));Z.close()}})}function KW($){let X=q$($);return{async fetch(Z,Q,Y){return X(Z,{env:Q,ctx:Y,KV:Q.KV})}}}function _W($){let X=q$($);return(Z)=>X(Z,{})}function UW($){let X=q$($);return(Z)=>X(Z,{})}function BW($){let X=q$($);return(Z,Q)=>{return X(Z,{netlifyContext:Q})}}function LW($){let X=$.headers.get("Cookie");if(!X)return{};let Z={};for(let Q of X.split(";")){let[Y,J]=Q.split("=").map((G)=>G.trim());if(Y&&J)Z[Y]=decodeURIComponent(J)}return Z}function FW($,X,Z){return O5($,X,Z)}function zW($,X){let Z=new Headers(X?.headers);return Z.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify($),{...X,headers:Z})}function jW($,X=302){return new Response(null,{status:X,headers:{Location:$}})}function HW($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var G7={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function AX($,X={}){let Z={...G7,...X};if($.trim()==="")return`
1914
- `;let Q=$;if(Z.trimTrailingWhitespace)Q=Q.replace(/[ \t]+$/gm,"");if(Q=MX(Q,Z),Q=DX(Q,Z),Q=EX(Q,Z),Z.trimTrailingWhitespace)Q=Q.replace(/[ \t]+$/gm,""),Q=Q.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(Q=Q.replace(/\r\n/g,`
1913
+ </tr>`;Y+="</tbody></table>";for(let J of Z)if(J.example)Y+=`<h3>@${J.name}</h3>`,Y+=`<p>${J.description||""}</p>`,Y+="<h4>Example</h4>",Y+=`<pre><code>${J.example.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}</code></pre>`}return Y+="</body></html>",Y}function AX($=[],X=[],Z=[],Q){return JSON.stringify({components:$,templates:X,directives:Z,extraContent:Q||""},null,2)}async function qX($){try{let{componentsDir:X,templatesDir:Z,webComponentsConfig:Q,customDirectives:Y,config:J}=$;if(!J.enabled)return!1;let G=J.outputDir||"docs";if(await N5.promises.mkdir(G,{recursive:!0}),console.log("Generating documentation..."),X)console.log(`Components directory: ${X}`);if(Z)console.log(`Templates directory: ${Z}`);console.log(`Output directory: ${G}`);let W=[];if(J.components!==!1&&X)console.log("Generating component documentation..."),W=await zX(X,Q),console.log(`Found ${W.length} components`);let K=[];if(J.templates!==!1&&Z)console.log("Generating template documentation..."),K=await jX(Z),console.log(`Found ${K.length} templates`);let _=[];if(J.directives!==!1)console.log("Generating directive documentation..."),_=await HX(Y),console.log(`Found ${_.length} directives`);let U=J.format||"markdown",F=J.extraContent,z="",j="";switch(U){case"markdown":z=OX(W,K,_,F),j="md";break;case"html":z=NX(W,K,_,F),j="html";break;case"json":z=AX(W,K,_,F),j="json";break;default:throw Error(`Unsupported documentation format: ${U}`)}let H=S1.join(G,`stx-docs.${j}`);return await Bun.write(H,z),console.log(`Documentation generated: ${H}`),!0}catch(X){return console.error("Error generating documentation:",X),!1}}async function jW($){let X={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Z=$.componentsDir||C0.componentsDir,Q=$.templatesDir||".";return qX({componentsDir:Z,templatesDir:Q,webComponentsConfig:C0.webComponents,customDirectives:C0.customDirectives,config:X})}import z1 from"process";function b1(){if(typeof globalThis<"u"&&"caches"in globalThis&&"CF"in globalThis)return{platform:"cloudflare",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","r2","d1","durable-objects","queues"]};if(typeof globalThis<"u"&&"Deno"in globalThis)return{platform:"deno",version:globalThis.Deno.version?.deno,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","deploy","ffi"]};if(typeof globalThis<"u"&&"Bun"in globalThis)return{platform:"bun",version:globalThis.Bun.version,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["sqlite","ffi","native-modules"]};if(typeof globalThis<"u"&&"EdgeRuntime"in globalThis)return{platform:"vercel",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["edge-config","blob"]};if(typeof globalThis<"u"&&"Netlify"in globalThis)return{platform:"netlify",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!1,capabilities:["blobs","edge-functions"]};if(typeof globalThis<"u"&&"fastly"in globalThis)return{platform:"fastly",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["dictionary","backend","geolocation"]};if(z1.versions?.node)return{platform:"node",version:z1.versions.node,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["fs","child-process","native-modules"]};return{platform:"unknown",supportsStreaming:!1,supportsCrypto:!1,supportsKV:!1,supportsCache:!1,capabilities:[]}}function AW(){let $=b1();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function qW(){return b1().platform!=="unknown"}function VX($){return{get(X){if($&&X in $){let Z=$[X];return typeof Z==="string"?Z:void 0}if(typeof globalThis<"u"&&"Deno"in globalThis)return globalThis.Deno.env.get(X);if(z1.env)return z1.env[X];return},getOrThrow(X){let Z=this.get(X);if(Z===void 0)throw Error(`Environment variable "${X}" is not set`);return Z},has(X){return this.get(X)!==void 0},all(){let X={};if($){for(let[Z,Q]of Object.entries($))if(typeof Q==="string")X[Z]=Q}if(typeof globalThis<"u"&&"Deno"in globalThis){let Z=globalThis.Deno.env.toObject();Object.assign(X,Z)}if(z1.env){for(let[Z,Q]of Object.entries(z1.env))if(Q!==void 0)X[Z]=Q}return X}}}function MX($){let X=b1();if(X.platform==="cloudflare"&&$)return $;if(X.platform==="deno"&&"Deno"in globalThis)return EX();if(X.platform==="node"||X.platform==="bun")return IX();return}function EX(){let $=null,X=async()=>{if(!$)$=await globalThis.Deno.openKv();return $};return{async get(Z){return(await(await X()).get(["stx",Z])).value},async getWithMetadata(Z){let Q=await X(),Y=await Q.get(["stx",Z]),J=await Q.get(["stx-meta",Z]);return{value:Y.value,metadata:J.value}},async put(Z,Q,Y){let J=await X(),G=Y?.expirationTtl?Y.expirationTtl*1000:void 0;if(await J.set(["stx",Z],Q,G?{expireIn:G}:void 0),Y?.metadata)await J.set(["stx-meta",Z],Y.metadata,G?{expireIn:G}:void 0)},async delete(Z){let Q=await X();await Q.delete(["stx",Z]),await Q.delete(["stx-meta",Z])},async list(Z){let Q=await X(),Y=Z?.prefix?["stx",Z.prefix]:["stx"],J=Q.list({prefix:Y,limit:Z?.limit||100}),G=[];for await(let W of J){let _=W.key.slice(1).join("/");if(!_.startsWith("stx-meta/"))G.push({name:_})}return{keys:G,list_complete:!0}}}}function IX(){let $=new Map,X=()=>{let Z=Date.now();for(let[Q,Y]of $.entries())if(Y.expiration&&Y.expiration<Z)$.delete(Q)};return{async get(Z){X();let Q=$.get(Z);if(!Q)return null;if(Q.expiration&&Q.expiration<Date.now())return $.delete(Z),null;return Q.value},async getWithMetadata(Z){X();let Q=$.get(Z);if(!Q)return{value:null,metadata:null};if(Q.expiration&&Q.expiration<Date.now())return $.delete(Z),{value:null,metadata:null};return{value:Q.value,metadata:Q.metadata||null}},async put(Z,Q,Y){let J=Y?.expiration?Y.expiration*1000:Y?.expirationTtl?Date.now()+Y.expirationTtl*1000:void 0;$.set(Z,{value:Q,metadata:Y?.metadata,expiration:J})},async delete(Z){$.delete(Z)},async list(Z){X();let Q=[];for(let[Y,J]of $.entries()){if(Z?.prefix&&!Y.startsWith(Z.prefix))continue;if(Q.push({name:Y,expiration:J.expiration,metadata:J.metadata}),Z?.limit&&Q.length>=Z.limit)break}return{keys:Q,list_complete:!0}}}}function RX(){let $=b1();if($.platform==="cloudflare"&&"caches"in globalThis)return DX();if($.supportsStreaming)return wX();return}function DX(){return{async match($){return(await caches.default).match($)},async put($,X){await(await caches.default).put($,X.clone())},async delete($){return(await caches.default).delete($)}}}function wX(){let $=new Map,X=60000;return{async match(Z){let Q=Z.url,Y=$.get(Q);if(!Y)return;if(Date.now()>Y.expiration){$.delete(Q);return}return Y.response.clone()},async put(Z,Q){let Y=Z.url,J=Q.headers.get("Cache-Control"),G=60000;if(J){let W=J.match(/max-age=(\d+)/);if(W)G=Number.parseInt(W[1],10)*1000}$.set(Y,{response:Q.clone(),expiration:Date.now()+G})},async delete(Z){return $.delete(Z.url)}}}function TX(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function CX($,X){if(X.platform==="cloudflare"){let Z=$.cf;if(Z)return{city:Z.city,country:Z.country,countryCode:Z.country,region:Z.region,latitude:Z.latitude?Number.parseFloat(Z.latitude):void 0,longitude:Z.longitude?Number.parseFloat(Z.longitude):void 0,timezone:Z.timezone}}if(X.platform==="vercel"){let Z={},Q=$.headers.get("x-vercel-ip-city"),Y=$.headers.get("x-vercel-ip-country"),J=$.headers.get("x-vercel-ip-country-region"),G=$.headers.get("x-vercel-ip-latitude"),W=$.headers.get("x-vercel-ip-longitude");if(Q)Z.city=decodeURIComponent(Q);if(Y)Z.countryCode=Y;if(J)Z.region=J;if(G)Z.latitude=Number.parseFloat(G);if(W)Z.longitude=Number.parseFloat(W);return Object.keys(Z).length>0?Z:void 0}if(X.platform==="netlify"){let Z={},Q=$.headers.get("x-nf-geo-city"),Y=$.headers.get("x-nf-geo-country");if(Q)Z.city=Q;if(Y)Z.countryCode=Y;return Object.keys(Z).length>0?Z:void 0}return}function A5($,X,Z){let Q=new Headers($.headers);if(X.origins==="*")Q.set("Access-Control-Allow-Origin","*");else if(X.origins&&Z&&X.origins.includes(Z))Q.set("Access-Control-Allow-Origin",Z),Q.set("Vary","Origin");if(X.methods)Q.set("Access-Control-Allow-Methods",X.methods.join(", "));if(X.headers)Q.set("Access-Control-Allow-Headers",X.headers.join(", "));if(X.exposeHeaders)Q.set("Access-Control-Expose-Headers",X.exposeHeaders.join(", "));if(X.credentials)Q.set("Access-Control-Allow-Credentials","true");if(X.maxAge)Q.set("Access-Control-Max-Age",String(X.maxAge));return new Response($.body,{status:$.status,statusText:$.statusText,headers:Q})}function M$($){let X=b1();return async(Z,Q)=>{let Y=performance.now(),J=TX(),G={runtime:X,platform:Q||{},requestId:J,geo:CX(Z,X),timing:{start:Y,getElapsed:()=>performance.now()-Y},kv:MX(Q?.KV),cache:RX(),env:VX(Q?.env)};try{if(Z.method==="OPTIONS"&&$.cors){let K=new Response(null,{status:204});return K=A5(K,$.cors,Z.headers.get("Origin")||void 0),K}if($.cache?.enabled&&Z.method==="GET"&&G.cache){if(L7(Z,$.cache)){let _=await G.cache.match(Z);if(_){let U=new Response(_.body,_);return U.headers.set("X-Cache","HIT"),U.headers.set("X-Request-Id",J),$.cors?A5(U,$.cors,Z.headers.get("Origin")||void 0):U}}}let W;if($.middleware&&$.middleware.length>0)W=await kX(Z,G,$.middleware,async()=>{let K=await $.render(Z,G);return typeof K==="string"?new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}}):K});else{let K=await $.render(Z,G);W=typeof K==="string"?new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}}):K}if(W.headers.set("X-Request-Id",J),W.headers.set("X-Response-Time",`${G.timing.getElapsed().toFixed(2)}ms`),$.cache?.enabled&&Z.method==="GET"&&G.cache){if(L7(Z,$.cache)&&W.status===200){let _=$.cache.ttl||60,U=W.clone();U.headers.set("Cache-Control",`public, max-age=${_}`),await G.cache.put(Z,U),W.headers.set("X-Cache","MISS")}}if($.cors)W=A5(W,$.cors,Z.headers.get("Origin")||void 0);return W}catch(W){let K=W instanceof Error?W:Error(String(W));if($.onError)return $.onError(K,Z);return new Response(`Internal Server Error: ${K.message}`,{status:500,headers:{"Content-Type":"text/plain","X-Request-Id":J}})}}}function L7($,X){let Q=new URL($.url).pathname;if(X.excludePaths){for(let Y of X.excludePaths)if(Y.test(Q))return!1}if(X.includePaths){for(let Y of X.includePaths)if(Y.test(Q))return!0;return!1}return!0}async function kX($,X,Z,Q){let Y=0,J=async()=>{if(Y>=Z.length)return Q();let G=Z[Y];return Y++,G($,X,J)};return J()}function VW($,X){let Z=new Headers(X?.headers);return Z.set("Content-Type","text/html; charset=utf-8"),Z.set("Transfer-Encoding","chunked"),new Response($,{...X,headers:Z})}function MW(){let $=new TextEncoder;return new TransformStream({transform(X,Z){Z.enqueue($.encode(X))}})}function EW($){let X=new TextEncoder;return new ReadableStream({async start(Z){for await(let Q of $)Z.enqueue(X.encode(Q));Z.close()}})}function IW($){let X=M$($);return{async fetch(Z,Q,Y){return X(Z,{env:Q,ctx:Y,KV:Q.KV})}}}function RW($){let X=M$($);return(Z)=>X(Z,{})}function DW($){let X=M$($);return(Z)=>X(Z,{})}function wW($){let X=M$($);return(Z,Q)=>{return X(Z,{netlifyContext:Q})}}function TW($){let X=$.headers.get("Cookie");if(!X)return{};let Z={};for(let Q of X.split(";")){let[Y,J]=Q.split("=").map((G)=>G.trim());if(Y&&J)Z[Y]=decodeURIComponent(J)}return Z}function CW($,X,Z){return q5($,X,Z)}function kW($,X){let Z=new Headers(X?.headers);return Z.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify($),{...X,headers:Z})}function xW($,X=302){return new Response(null,{status:X,headers:{Location:$}})}function SW($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var z7={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function xX($,X={}){let Z={...z7,...X};if($.trim()==="")return`
1914
+ `;let Q=$;if(Z.trimTrailingWhitespace)Q=Q.replace(/[ \t]+$/gm,"");if(Q=PX(Q,Z),Q=gX(Q,Z),Q=bX(Q,Z),Z.trimTrailingWhitespace)Q=Q.replace(/[ \t]+$/gm,""),Q=Q.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(Q=Q.replace(/\r\n/g,`
1915
1915
  `).replace(/\r/g,`
1916
1916
  `),!Q.endsWith(`
1917
1917
  `))Q+=`
1918
- `;return Q}function NW($,X={}){let Z={...G7,...X};if($.trim()==="")return`
1918
+ `;return Q}function bW($,X={}){let Z={...z7,...X};if($.trim()==="")return`
1919
1919
  `;let Q=$;if(Q=Q.replace(/^( *)```(html|stx)\n([\s\S]*?)^( *)```/gm,(Y,J,G,W,K)=>{let _=W.split(`
1920
1920
  `),U=_.filter((L)=>L.trim().length>0);if(U.length===0)return Y;let F=Math.min(...U.map((L)=>{let O=L.match(/^( *)/);return O?O[1].length:0})),z=_.map((L)=>{if(L.trim().length===0)return"";return L.substring(F)}).join(`
1921
- `),H=AX(z,Z).trimEnd().split(`
1921
+ `),H=xX(z,Z).trimEnd().split(`
1922
1922
  `).map((L)=>{if(L.trim().length===0)return"";return J+L}).join(`
1923
1923
  `);return`${J}\`\`\`${G}
1924
1924
  ${H}
@@ -1926,7 +1926,7 @@ ${J}\`\`\``}),Z.trimTrailingWhitespace)Q=Q.replace(/[ \t]+$/gm,"");if(Q=Q.replac
1926
1926
  `).replace(/\r/g,`
1927
1927
  `),!Q.endsWith(`
1928
1928
  `))Q+=`
1929
- `;return Q}function VX($){let X=$,Z=[],Q="__PROTECTED_BLOCK_";return X=X.replace(/(<(?:pre|code|textarea)[^>]*>)([\s\S]*?)(<\/(?:pre|code|textarea)>)/gi,(Y)=>{let J=Z.length;return Z.push(Y),`${Q}${J}__`}),X=X.replace(/(@(?:if|foreach|for|while|unless|section|component|slot|push|prepend|error|auth|guest|can)(?:\((?:[^()'"]|'[^']*'|"[^"]*"|\((?:[^()'"]|'[^']*'|"[^"]*")*\))*\))?)/g,`
1929
+ `;return Q}function SX($){let X=$,Z=[],Q="__PROTECTED_BLOCK_";return X=X.replace(/(<(?:pre|code|textarea)[^>]*>)([\s\S]*?)(<\/(?:pre|code|textarea)>)/gi,(Y)=>{let J=Z.length;return Z.push(Y),`${Q}${J}__`}),X=X.replace(/(@(?:if|foreach|for|while|unless|section|component|slot|push|prepend|error|auth|guest|can)(?:\((?:[^()'"]|'[^']*'|"[^"]*"|\((?:[^()'"]|'[^']*'|"[^"]*")*\))*\))?)/g,`
1930
1930
  $1
1931
1931
  `),X=X.replace(/(@end\w+)/g,`
1932
1932
  $1
@@ -1940,10 +1940,10 @@ ${G}`}),X=X.replace(/(<\/[^>]+>)(?=<|$)/g,(Y,J,G,W)=>{let K=W.substring(Math.max
1940
1940
  `}),X=X.replace(new RegExp(`${Q}(\\d+)__`,"g"),(Y,J)=>{return Z[Number.parseInt(J,10)]}),X=X.replace(/\n{2,}/g,`
1941
1941
  `),X=X.split(`
1942
1942
  `).map((Y)=>Y.trim()).join(`
1943
- `),X=X.replace(/^\n+/,"").replace(/\n+$/,""),X}function MX($,X){let Q=VX($).split(`
1944
- `),Y=[],J=0,G=!1,W=X.useTabs?"\t":" ".repeat(X.indentSize);for(let K=0;K<Q.length;K++){let _=Q[K],U=_.trim();if(U===""){Y.push("");continue}let F=U.match(/<script\b/i),z=U.match(/<\/script>/i);if(G&&!z){Y.push(_);continue}let j=U===">";if(J7(U)&&!U.startsWith("<")&&!U.startsWith("@")){Y.push(W.repeat(J)+U);continue}let H=U.startsWith("@end"),L=U.startsWith("@else")||U.startsWith("@elseif"),O=U.startsWith("@")&&RX(U),N=U.startsWith("<!DOCTYPE")||U.startsWith("<!doctype"),V=U.startsWith("<!--"),M=U.startsWith("</"),q=U.startsWith("<")&&!M&&!V&&!N,A=U.includes("/>")||IX(U),I=J7(U);if(M||H)J=Math.max(0,J-1);let E=L?Math.max(0,J-1):J;if(j)Y.push(_);else Y.push(W.repeat(E)+U);if(q&&!A&&!I&&!j||O)J++;if(F)G=!0;if(z)G=!1}return Y.join(`
1945
- `)}function EX($,X){if($=$.replace(/@(if|elseif|foreach|for|while)\s*\(\s*([^)]+)\s*\)/g,(Z,Q,Y)=>{let J=Y.trim().replace(/\s+/g," ");return`@${Q}(${J})`}),$=$.replace(/@(csrf|method)\s*\(\s*([^)]*)\s*\)/g,(Z,Q,Y)=>{if(Y.trim()==="")return`@${Q}`;return`@${Q}(${Y.trim()})`}),X.normalizeWhitespace)$=$.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Z,Q)=>{return`{{ ${Q.trim()} }}`}),$=$.replace(/\{!!\s*([^!]+)\s*!!\}/g,(Z,Q)=>{return`{!! ${Q.trim()} !!}`});return $}function IX($){let X=["br","hr","img","input","meta","link","area","base","col","embed","source","track","wbr"];if($.includes("/>"))return!0;let Z=$.match(/<(\w+)/);if(Z){let Q=Z[1];return X.includes(Q.toLowerCase())}return!1}function J7($){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test($)}function RX($){let X=["if","unless","foreach","for","while","section","push","component","slot","markdown","wrap","error"];for(let Z of X)if($.startsWith(`@${Z}`))return!$.includes(`@end${Z}`);return!1}function DX($,X){if(!X.sortAttributes)return $;return $.replace(/<(\w+)([^>]*)>/g,(Z,Q,Y)=>{if(!Y.trim())return Z;if(Y.includes("<")||Y.includes(`
1946
- `)||Y.includes("@"))return Z;let J=/(\w+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,G=[],W;while((W=J.exec(Y))!==null)G.push({name:W[1],value:W[2]});G.sort((_,U)=>{if(_.name==="id")return-1;if(U.name==="id")return 1;if(_.name==="class")return-1;if(U.name==="class")return 1;return _.name.localeCompare(U.name)});let K=G.map((_)=>_.value?`${_.name}=${_.value}`:_.name).join(" ");return`<${Q}${K?` ${K}`:""}>`})}import W7 from"fs";import N5 from"path";var MW={basic:{description:"Simple page with script, style, and template sections"},component:{description:"Reusable component with props and slots"},layout:{description:"Layout template with sections and yields"},blog:{description:"Blog post with frontmatter-style variables"},api:{description:"API endpoint template with JSON response"},app:{description:"Full app with stores and components"}};async function EW($="index.stx",X={}){try{let Z=X.force||!1,Q=N5.resolve(process.cwd(),$);if(await Bun.file(Q).exists()){if(!Z)throw Error(`File ${$} already exists. Use --force to overwrite.`);console.warn(`File ${$} already exists. Overwriting...`)}let Y=N5.dirname(Q);if(!W7.existsSync(Y))W7.mkdirSync(Y,{recursive:!0});let J;if(X.template){let G=N5.resolve(process.cwd(),X.template);if(!await Bun.file(G).exists())throw Error(`Template file ${X.template} does not exist.`);if(!G.endsWith(".stx"))console.warn(`Warning: Template file ${X.template} does not have a .stx extension. Using it anyway.`);J=await Bun.file(G).text(),console.warn(`Using template from ${X.template}`)}else if(X.preset)J=K7(X.preset),console.warn(`Using '${X.preset}' preset template`);else J=K7("basic");return await Bun.write(Q,J),console.warn(`Created new stx file: ${$}`),!0}catch(Z){return console.error(`Error creating file: ${Z instanceof Error?Z.message:String(Z)}`),!1}}function K7($){switch($){case"basic":return _7();case"component":return wX();case"layout":return TX();case"blog":return CX();case"api":return kX();case"app":return xX();default:return _7()}}function _7(){return`<script>
1943
+ `),X=X.replace(/^\n+/,"").replace(/\n+$/,""),X}function PX($,X){let Q=SX($).split(`
1944
+ `),Y=[],J=0,G=!1,W=X.useTabs?"\t":" ".repeat(X.indentSize);for(let K=0;K<Q.length;K++){let _=Q[K],U=_.trim();if(U===""){Y.push("");continue}let F=U.match(/<script\b/i),z=U.match(/<\/script>/i);if(G&&!z){Y.push(_);continue}let j=U===">";if(F7(U)&&!U.startsWith("<")&&!U.startsWith("@")){Y.push(W.repeat(J)+U);continue}let H=U.startsWith("@end"),L=U.startsWith("@else")||U.startsWith("@elseif"),O=U.startsWith("@")&&vX(U),N=U.startsWith("<!DOCTYPE")||U.startsWith("<!doctype"),V=U.startsWith("<!--"),M=U.startsWith("</"),A=U.startsWith("<")&&!M&&!V&&!N,q=U.includes("/>")||yX(U),I=F7(U);if(M||H)J=Math.max(0,J-1);let E=L?Math.max(0,J-1):J;if(j)Y.push(_);else Y.push(W.repeat(E)+U);if(A&&!q&&!I&&!j||O)J++;if(F)G=!0;if(z)G=!1}return Y.join(`
1945
+ `)}function bX($,X){if($=$.replace(/@(if|elseif|foreach|for|while)\s*\(\s*([^)]+)\s*\)/g,(Z,Q,Y)=>{let J=Y.trim().replace(/\s+/g," ");return`@${Q}(${J})`}),$=$.replace(/@(csrf|method)\s*\(\s*([^)]*)\s*\)/g,(Z,Q,Y)=>{if(Y.trim()==="")return`@${Q}`;return`@${Q}(${Y.trim()})`}),X.normalizeWhitespace)$=$.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Z,Q)=>{return`{{ ${Q.trim()} }}`}),$=$.replace(/\{!!\s*([^!]+)\s*!!\}/g,(Z,Q)=>{return`{!! ${Q.trim()} !!}`});return $}function yX($){let X=["br","hr","img","input","meta","link","area","base","col","embed","source","track","wbr"];if($.includes("/>"))return!0;let Z=$.match(/<(\w+)/);if(Z){let Q=Z[1];return X.includes(Q.toLowerCase())}return!1}function F7($){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test($)}function vX($){let X=["if","unless","foreach","for","while","section","push","component","slot","markdown","wrap","error"];for(let Z of X)if($.startsWith(`@${Z}`))return!$.includes(`@end${Z}`);return!1}function gX($,X){if(!X.sortAttributes)return $;return $.replace(/<(\w+)([^>]*)>/g,(Z,Q,Y)=>{if(!Y.trim())return Z;if(Y.includes("<")||Y.includes(`
1946
+ `)||Y.includes("@"))return Z;let J=/(\w+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,G=[],W;while((W=J.exec(Y))!==null)G.push({name:W[1],value:W[2]});G.sort((_,U)=>{if(_.name==="id")return-1;if(U.name==="id")return 1;if(_.name==="class")return-1;if(U.name==="class")return 1;return _.name.localeCompare(U.name)});let K=G.map((_)=>_.value?`${_.name}=${_.value}`:_.name).join(" ");return`<${Q}${K?` ${K}`:""}>`})}import j7 from"fs";import V5 from"path";var fW={basic:{description:"Simple page with script, style, and template sections"},component:{description:"Reusable component with props and slots"},layout:{description:"Layout template with sections and yields"},blog:{description:"Blog post with frontmatter-style variables"},api:{description:"API endpoint template with JSON response"},app:{description:"Full app with stores and components"}};async function hW($="index.stx",X={}){try{let Z=X.force||!1,Q=V5.resolve(process.cwd(),$);if(await Bun.file(Q).exists()){if(!Z)throw Error(`File ${$} already exists. Use --force to overwrite.`);console.warn(`File ${$} already exists. Overwriting...`)}let Y=V5.dirname(Q);if(!j7.existsSync(Y))j7.mkdirSync(Y,{recursive:!0});let J;if(X.template){let G=V5.resolve(process.cwd(),X.template);if(!await Bun.file(G).exists())throw Error(`Template file ${X.template} does not exist.`);if(!G.endsWith(".stx"))console.warn(`Warning: Template file ${X.template} does not have a .stx extension. Using it anyway.`);J=await Bun.file(G).text(),console.warn(`Using template from ${X.template}`)}else if(X.preset)J=H7(X.preset),console.warn(`Using '${X.preset}' preset template`);else J=H7("basic");return await Bun.write(Q,J),console.warn(`Created new stx file: ${$}`),!0}catch(Z){return console.error(`Error creating file: ${Z instanceof Error?Z.message:String(Z)}`),!1}}function H7($){switch($){case"basic":return O7();case"component":return fX();case"layout":return hX();case"blog":return dX();case"api":return uX();case"app":return mX();default:return O7()}}function O7(){return`<script>
1947
1947
  const title = "My stx Page"
1948
1948
  const description = "A page built with stx"
1949
1949
  const features = [
@@ -1968,7 +1968,7 @@ const features = [
1968
1968
  </div>
1969
1969
  @endforeach
1970
1970
  </main>
1971
- @endsection`}function wX(){return`{{-- Component: Card --}}
1971
+ @endsection`}function fX(){return`{{-- Component: Card --}}
1972
1972
  {{-- Props: title, variant, collapsible --}}
1973
1973
  {{-- Usage: @component('card', { title: "Hello", variant: "primary", collapsible: true }) Content @endcomponent --}}
1974
1974
  <script>
@@ -2013,7 +2013,7 @@ const features = [
2013
2013
  .card.collapsed .card__toggle { transform: rotate(-90deg); }
2014
2014
  .card__body { padding: 1rem; }
2015
2015
  .card.collapsed .card__body { display: none; }
2016
- </style>`}function TX(){return`<!DOCTYPE html>
2016
+ </style>`}function hX(){return`<!DOCTYPE html>
2017
2017
  <html lang="en">
2018
2018
  <head>
2019
2019
  <meta charset="UTF-8">
@@ -2064,7 +2064,7 @@ const features = [
2064
2064
 
2065
2065
  @yield('scripts')
2066
2066
  </body>
2067
- </html>`}function CX(){return`<script>
2067
+ </html>`}function dX(){return`<script>
2068
2068
  // Article metadata
2069
2069
  const title = "My Blog Post"
2070
2070
  const author = "Your Name"
@@ -2109,7 +2109,7 @@ const features = [
2109
2109
  <p>Wrap up your thoughts here.</p>
2110
2110
  </div>
2111
2111
  </article>
2112
- @endsection`}function kX(){return`<script>
2112
+ @endsection`}function uX(){return`<script>
2113
2113
  // API endpoint configuration
2114
2114
  const endpoint = "/api/data"
2115
2115
  const method = "GET"
@@ -2144,7 +2144,7 @@ const features = [
2144
2144
  }
2145
2145
  @else
2146
2146
  {{ JSON.stringify(data, null, 2) }}
2147
- @endif`}function xX(){return`<!DOCTYPE html>
2147
+ @endif`}function mX(){return`<!DOCTYPE html>
2148
2148
  <html lang="en">
2149
2149
  <head>
2150
2150
  <meta charset="UTF-8">
@@ -2369,8 +2369,8 @@ const features = [
2369
2369
  })();
2370
2370
  </script>
2371
2371
  </body>
2372
- </html>`}import{createHash as SX}from"crypto";import{existsSync as P1,mkdirSync as PX,readFileSync as q5,writeFileSync as bX,readdirSync as yX,statSync as vX}from"fs";import{basename as b1,dirname as v0,extname as y1,join as x0,relative as U7}from"path";import{gzipSync as gX}from"zlib";var B7={outDir:"dist",publicPath:"/",sourcemaps:!0,minify:{js:!0,css:!0,html:!0,dropConsole:!0,dropDebugger:!0,mangle:!0},splitting:{vendor:!0,minSize:20000,maxSize:250000,chunkNames:"deterministic"},css:{extract:!0,minify:!0,filename:"assets/[name].[hash].css"},assets:{inlineLimit:4096,filename:"assets/[name].[hash][ext]",hash:!0,hashLength:8,include:["png","jpg","jpeg","gif","svg","webp","woff","woff2","ttf","eot"]},compression:{gzip:!0,brotli:!0,threshold:1024,deleteOriginal:!1}};class A5{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...B7,...$}}async build(){this.startTime=Date.now(),this.outputs=[],this.chunks=[],this.assets=[],this.warnings=[],this.errors=[];try{this.ensureDir(this.config.outDir),await this.runPluginHook("setup"),await this.runPluginHook("buildStart");let $=this.collectEntries();for(let[Z,Q]of $)await this.buildEntry(Z,Q);if(this.config.css?.extract)await this.extractCss();if(await this.processAssets(),this.config.splitting)await this.performCodeSplitting();if(this.config.minify)await this.minifyOutputs();if(this.config.sourcemaps)await this.generateSourceMaps();if(await this.fingerprintAssets(),this.config.compression)await this.compressOutputs();if(this.config.analyze)await this.analyzeBundle();let X=this.getResult();return await this.runPluginHook("buildEnd",X),X}catch($){return this.errors.push(String($)),this.getResult()}}collectEntries(){let $=new Map,{entry:X}=this.config;if(typeof X==="string")$.set("main",X);else if(Array.isArray(X))X.forEach((Z,Q)=>{let Y=b1(Z,y1(Z));$.set(Y,Z)});else if(typeof X==="object")Object.entries(X).forEach(([Z,Q])=>{$.set(Z,Q)});return $}async buildEntry($,X){if(!await Bun.file(X).exists()){this.errors.push(`Entry point not found: ${X}`);return}let Z=await Bun.file(X).text(),Q=y1(X),Y=Z,J="js";if(Q===".stx"||Q===".html")J="html",Y=await this.processTemplate(Z,X);else if(Q===".css")J="css",Y=await this.processCss(Z,X);else if(Q===".js"||Q===".ts")J="js",Y=await this.processScript(Z,X);Y=await this.runPluginTransform(Y,X);let G=this.generateHash(Y),W=this.getOutputName($,J,G),K=x0(this.config.outDir,W);this.ensureDir(v0(K)),await Bun.write(K,Y),this.outputs.push({path:K,type:J,size:Buffer.byteLength(Y),hash:G,sources:[X],isEntry:!0})}resolveRelativePath($,X){if(X.startsWith("/"))return x0(v0($),"..",X);return x0(v0($),X)}async processTemplate($,X){let Z=$,Q=[],Y=[];if(Z=Z.replace(/<script\b([^>]*)\bstx-inline\b([^>]*)(?:><\/script>|><\/script>|\/>)/gi,(J,G,W)=>{let K=(G+W).match(/src=["']([^"']+)["']/);if(K){let _=this.resolveRelativePath(X,K[1]);if(P1(_)){let U=q5(_,"utf-8");Q.push(`// Source: ${K[1]}
2373
- ${U}`)}else this.warnings.push(`External script not found: ${_}`)}return""}),Z=Z.replace(/<link\b([^>]*)\bstx-inline\b([^>]*)(?:\/>|>)/gi,(J,G,W)=>{let K=(G+W).match(/href=["']([^"']+)["']/);if(K){let _=this.resolveRelativePath(X,K[1]);if(P1(_)){let U=q5(_,"utf-8");Y.push(`/* Source: ${K[1]} */
2372
+ </html>`}import{createHash as pX}from"crypto";import{existsSync as y1,mkdirSync as cX,readFileSync as M5,writeFileSync as lX,readdirSync as iX,statSync as aX}from"fs";import{basename as v1,dirname as v0,extname as g1,join as x0,relative as N7}from"path";import{gzipSync as sX}from"zlib";var A7={outDir:"dist",publicPath:"/",sourcemaps:!0,minify:{js:!0,css:!0,html:!0,dropConsole:!0,dropDebugger:!0,mangle:!0},splitting:{vendor:!0,minSize:20000,maxSize:250000,chunkNames:"deterministic"},css:{extract:!0,minify:!0,filename:"assets/[name].[hash].css"},assets:{inlineLimit:4096,filename:"assets/[name].[hash][ext]",hash:!0,hashLength:8,include:["png","jpg","jpeg","gif","svg","webp","woff","woff2","ttf","eot"]},compression:{gzip:!0,brotli:!0,threshold:1024,deleteOriginal:!1}};class E5{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...A7,...$}}async build(){this.startTime=Date.now(),this.outputs=[],this.chunks=[],this.assets=[],this.warnings=[],this.errors=[];try{this.ensureDir(this.config.outDir),await this.runPluginHook("setup"),await this.runPluginHook("buildStart");let $=this.collectEntries();for(let[Z,Q]of $)await this.buildEntry(Z,Q);if(this.config.css?.extract)await this.extractCss();if(await this.processAssets(),this.config.splitting)await this.performCodeSplitting();if(this.config.minify)await this.minifyOutputs();if(this.config.sourcemaps)await this.generateSourceMaps();if(await this.fingerprintAssets(),this.config.compression)await this.compressOutputs();if(this.config.analyze)await this.analyzeBundle();let X=this.getResult();return await this.runPluginHook("buildEnd",X),X}catch($){return this.errors.push(String($)),this.getResult()}}collectEntries(){let $=new Map,{entry:X}=this.config;if(typeof X==="string")$.set("main",X);else if(Array.isArray(X))X.forEach((Z,Q)=>{let Y=v1(Z,g1(Z));$.set(Y,Z)});else if(typeof X==="object")Object.entries(X).forEach(([Z,Q])=>{$.set(Z,Q)});return $}async buildEntry($,X){if(!await Bun.file(X).exists()){this.errors.push(`Entry point not found: ${X}`);return}let Z=await Bun.file(X).text(),Q=g1(X),Y=Z,J="js";if(Q===".stx"||Q===".html")J="html",Y=await this.processTemplate(Z,X);else if(Q===".css")J="css",Y=await this.processCss(Z,X);else if(Q===".js"||Q===".ts")J="js",Y=await this.processScript(Z,X);Y=await this.runPluginTransform(Y,X);let G=this.generateHash(Y),W=this.getOutputName($,J,G),K=x0(this.config.outDir,W);this.ensureDir(v0(K)),await Bun.write(K,Y),this.outputs.push({path:K,type:J,size:Buffer.byteLength(Y),hash:G,sources:[X],isEntry:!0})}resolveRelativePath($,X){if(X.startsWith("/"))return x0(v0($),"..",X);return x0(v0($),X)}async processTemplate($,X){let Z=$,Q=[],Y=[];if(Z=Z.replace(/<script\b([^>]*)\bstx-inline\b([^>]*)(?:><\/script>|><\/script>|\/>)/gi,(J,G,W)=>{let K=(G+W).match(/src=["']([^"']+)["']/);if(K){let _=this.resolveRelativePath(X,K[1]);if(y1(_)){let U=M5(_,"utf-8");Q.push(`// Source: ${K[1]}
2373
+ ${U}`)}else this.warnings.push(`External script not found: ${_}`)}return""}),Z=Z.replace(/<link\b([^>]*)\bstx-inline\b([^>]*)(?:\/>|>)/gi,(J,G,W)=>{let K=(G+W).match(/href=["']([^"']+)["']/);if(K){let _=this.resolveRelativePath(X,K[1]);if(y1(_)){let U=M5(_,"utf-8");Y.push(`/* Source: ${K[1]} */
2374
2374
  ${U}`)}else this.warnings.push(`External stylesheet not found: ${_}`)}return""}),Z=Z.replace(/<script\b(?![^>]*\bstx-inline\b)([^>]*)>([\s\S]*?)<\/script>/gi,(J,G,W)=>{if(/\bsrc=/.test(G))return J;if(W.trim())Q.push(W);return""}),Z=Z.replace(/<style\b[^>]*>([\s\S]*?)<\/style>/gi,(J,G)=>{if(G.trim())Y.push(G);return""}),Q.length>0){let J=Q.join(`
2375
2375
 
2376
2376
  `),G=this.generateHash(J).slice(0,8),W=`assets/app.${G}.js`,K=x0(this.config.outDir,W);this.ensureDir(v0(K)),await Bun.write(K,J),this.outputs.push({path:K,type:"js",size:Buffer.byteLength(J),hash:G,sources:[X]});let _=Z.lastIndexOf("</body>");if(_!==-1)Z=Z.slice(0,_)+`<script src="${this.config.publicPath}${W}"></script>
@@ -2378,7 +2378,7 @@ ${U}`)}else this.warnings.push(`External stylesheet not found: ${_}`)}return""})
2378
2378
 
2379
2379
  `),G=this.generateHash(J).slice(0,8),W=`assets/app.${G}.css`,K=x0(this.config.outDir,W);this.ensureDir(v0(K)),await Bun.write(K,J),this.outputs.push({path:K,type:"css",size:Buffer.byteLength(J),hash:G,sources:[X]}),Z=Z.replace("</head>",`<link rel="stylesheet" href="${this.config.publicPath}${W}">
2380
2380
  </head>`)}return Z}async processCss($,X){let Z=$;if(typeof this.config.minify==="object"&&this.config.minify.css)Z=this.minifyCss(Z);return Z}async processScript($,X){let Z=$;if(this.config.define)for(let[Q,Y]of Object.entries(this.config.define))Z=Z.replace(new RegExp(Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),Y);return Z}async extractCss(){let $=[];for(let J of this.outputs)if(J.type==="css"){let G=await Bun.file(J.path).text();$.push(G)}if($.length===0)return;let X=$.join(`
2381
- `),Z=this.generateHash(X).slice(0,8),Q=(this.config.css?.filename||"assets/[name].[hash].css").replace("[name]","styles").replace("[hash]",Z),Y=x0(this.config.outDir,Q);this.ensureDir(v0(Y)),await Bun.write(Y,X),this.outputs.push({path:Y,type:"css",size:Buffer.byteLength(X),hash:Z})}async processAssets(){let $=x0(v0(this.config.outDir),"public");if(!P1($))return;let X=this.config.assets||{},Z=X.include||[];this.walkDir($,(Q)=>{let Y=y1(Q).slice(1).toLowerCase();if(!Z.includes(Y))return;let J=q5(Q),G=J.length;if(X.inlineLimit&&G<X.inlineLimit)return;let W=X.hash?this.generateHash(J).slice(0,X.hashLength||8):"",K=(X.filename||"assets/[name].[hash][ext]").replace("[name]",b1(Q,y1(Q))).replace("[hash]",W).replace("[ext]",y1(Q)),_=x0(this.config.outDir,K);this.ensureDir(v0(_)),bX(_,J),this.assetHashes.set(Q,K),this.assets.push({name:b1(Q),file:K,size:G,source:Q}),this.outputs.push({path:_,type:"asset",size:G,hash:W,sources:[Q]})})}async performCodeSplitting(){if((typeof this.config.splitting==="object"?this.config.splitting:{}).vendor){let X=[];this.chunks.push({name:"vendor",file:"assets/vendor.js",size:0,modules:X,isVendor:!0,imports:[],dynamicImports:[]})}}async minifyOutputs(){let $=typeof this.config.minify==="object"?this.config.minify:{};for(let X of this.outputs){let Z=await Bun.file(X.path).text(),Q=Z;if(X.type==="js"&&$.js)Q=this.minifyJs(Z);else if(X.type==="css"&&$.css)Q=this.minifyCss(Z);else if(X.type==="html"&&$.html)Q=this.minifyHtml(Z);if(Q!==Z)await Bun.write(X.path,Q),X.size=Buffer.byteLength(Q)}}minifyJs($){let X=typeof this.config.minify==="object"?this.config.minify:{},Z=$;if(Z=Z.replace(/\/\*[\s\S]*?\*\//g,""),Z=Z.replace(/\/\/.*$/gm,""),X.dropConsole)Z=Z.replace(/console\.(log|debug|info|warn)\([^)]*\);?/g,"");if(X.dropDebugger)Z=Z.replace(/debugger;?/g,"");return Z=Z.replace(/\s+/g," "),Z=Z.replace(/\s*([{};,:])\s*/g,"$1"),Z=Z.replace(/;\}/g,"}"),Z.trim()}minifyCss($){let X=$;return X=X.replace(/\/\*[\s\S]*?\*\//g,""),X=X.replace(/\s+/g," "),X=X.replace(/\s*([{};:,>+~])\s*/g,"$1"),X=X.replace(/;}/g,"}"),X=X.replace(/[^{}]+\{\s*\}/g,""),X.trim()}minifyHtml($){let X=$;return X=X.replace(/<!--(?!\[if)[\s\S]*?-->/g,""),X=X.replace(/>\s+</g,"><"),X=X.replace(/\s+>/g,">"),X=X.replace(/<\s+/g,"<"),X=X.replace(/\s{2,}/g," "),X.trim()}async generateSourceMaps(){if(!this.config.sourcemaps)return;for(let $ of this.outputs)if($.type==="js"||$.type==="css"){let X=await Bun.file($.path).text(),Z=[];for(let W of $.sources||[])if(await Bun.file(W).exists())Z.push(await Bun.file(W).text());else Z.push(null);let Q={version:3,file:b1($.path),sources:$.sources||[],sourcesContent:Z,mappings:"",names:[]},Y=`${$.path}.map`;await Bun.write(Y,JSON.stringify(Q));let J=new Uint8Array([10,47,47,35,32,115,111,117,114,99,101,77,97,112,112,105,110,103,85,82,76,61]),G=this.config.sourcemaps==="inline"?`data:application/json;base64,${Buffer.from(JSON.stringify(Q)).toString("base64")}`:b1(Y);if(this.config.sourcemaps!=="hidden")await Bun.write($.path,Buffer.concat([Buffer.from(X),Buffer.from(J),Buffer.from(G)]));this.outputs.push({path:Y,type:"map",size:vX(Y).size})}}async fingerprintAssets(){for(let $ of this.outputs)if($.type==="html"){let X=await Bun.file($.path).text();for(let[Z,Q]of this.assetHashes){let Y=U7(v0($.path),Z);X=X.replace(new RegExp(Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),`${this.config.publicPath}${Q}`)}await Bun.write($.path,X)}}async compressOutputs(){let $=this.config.compression||{},X=$.threshold||1024;for(let Z of this.outputs){if(Z.type==="map")continue;if(Z.size<X)continue;let Q=Buffer.from(await Bun.file(Z.path).arrayBuffer());if($.gzip){let Y=gX(Q,{level:9}),J=`${Z.path}.gz`;await Bun.write(J,Y),Z.gzipSize=Y.length}if($.brotli)try{let{brotliCompressSync:Y}=await import("zlib"),J=Y(Q);await Bun.write(`${Z.path}.br`,J)}catch{}}}async analyzeBundle(){let $=typeof this.config.analyze==="object"?this.config.analyze:{},X=$.format||"text",Z={outputs:this.outputs.map((G)=>({path:U7(this.config.outDir,G.path),type:G.type,size:G.size,gzipSize:G.gzipSize,sizeFormatted:this.formatSize(G.size),gzipSizeFormatted:G.gzipSize?this.formatSize(G.gzipSize):void 0})),chunks:this.chunks,assets:this.assets,totalSize:this.outputs.reduce((G,W)=>G+W.size,0),totalGzipSize:this.outputs.reduce((G,W)=>G+(W.gzipSize||0),0)},Q;if(X==="json")Q=JSON.stringify(Z,null,2);else if(X==="html")Q=this.generateAnalysisHtml(Z);else Q=this.generateAnalysisText(Z);let Y=$.filename||`bundle-analysis.${X==="html"?"html":X==="json"?"json":"txt"}`,J=x0(this.config.outDir,Y);await Bun.write(J,Q),console.log(`
2381
+ `),Z=this.generateHash(X).slice(0,8),Q=(this.config.css?.filename||"assets/[name].[hash].css").replace("[name]","styles").replace("[hash]",Z),Y=x0(this.config.outDir,Q);this.ensureDir(v0(Y)),await Bun.write(Y,X),this.outputs.push({path:Y,type:"css",size:Buffer.byteLength(X),hash:Z})}async processAssets(){let $=x0(v0(this.config.outDir),"public");if(!y1($))return;let X=this.config.assets||{},Z=X.include||[];this.walkDir($,(Q)=>{let Y=g1(Q).slice(1).toLowerCase();if(!Z.includes(Y))return;let J=M5(Q),G=J.length;if(X.inlineLimit&&G<X.inlineLimit)return;let W=X.hash?this.generateHash(J).slice(0,X.hashLength||8):"",K=(X.filename||"assets/[name].[hash][ext]").replace("[name]",v1(Q,g1(Q))).replace("[hash]",W).replace("[ext]",g1(Q)),_=x0(this.config.outDir,K);this.ensureDir(v0(_)),lX(_,J),this.assetHashes.set(Q,K),this.assets.push({name:v1(Q),file:K,size:G,source:Q}),this.outputs.push({path:_,type:"asset",size:G,hash:W,sources:[Q]})})}async performCodeSplitting(){if((typeof this.config.splitting==="object"?this.config.splitting:{}).vendor){let X=[];this.chunks.push({name:"vendor",file:"assets/vendor.js",size:0,modules:X,isVendor:!0,imports:[],dynamicImports:[]})}}async minifyOutputs(){let $=typeof this.config.minify==="object"?this.config.minify:{};for(let X of this.outputs){let Z=await Bun.file(X.path).text(),Q=Z;if(X.type==="js"&&$.js)Q=this.minifyJs(Z);else if(X.type==="css"&&$.css)Q=this.minifyCss(Z);else if(X.type==="html"&&$.html)Q=this.minifyHtml(Z);if(Q!==Z)await Bun.write(X.path,Q),X.size=Buffer.byteLength(Q)}}minifyJs($){let X=typeof this.config.minify==="object"?this.config.minify:{},Z=$;if(Z=Z.replace(/\/\*[\s\S]*?\*\//g,""),Z=Z.replace(/\/\/.*$/gm,""),X.dropConsole)Z=Z.replace(/console\.(log|debug|info|warn)\([^)]*\);?/g,"");if(X.dropDebugger)Z=Z.replace(/debugger;?/g,"");return Z=Z.replace(/\s+/g," "),Z=Z.replace(/\s*([{};,:])\s*/g,"$1"),Z=Z.replace(/;\}/g,"}"),Z.trim()}minifyCss($){let X=$;return X=X.replace(/\/\*[\s\S]*?\*\//g,""),X=X.replace(/\s+/g," "),X=X.replace(/\s*([{};:,>+~])\s*/g,"$1"),X=X.replace(/;}/g,"}"),X=X.replace(/[^{}]+\{\s*\}/g,""),X.trim()}minifyHtml($){let X=$;return X=X.replace(/<!--(?!\[if)[\s\S]*?-->/g,""),X=X.replace(/>\s+</g,"><"),X=X.replace(/\s+>/g,">"),X=X.replace(/<\s+/g,"<"),X=X.replace(/\s{2,}/g," "),X.trim()}async generateSourceMaps(){if(!this.config.sourcemaps)return;for(let $ of this.outputs)if($.type==="js"||$.type==="css"){let X=await Bun.file($.path).text(),Z=[];for(let W of $.sources||[])if(await Bun.file(W).exists())Z.push(await Bun.file(W).text());else Z.push(null);let Q={version:3,file:v1($.path),sources:$.sources||[],sourcesContent:Z,mappings:"",names:[]},Y=`${$.path}.map`;await Bun.write(Y,JSON.stringify(Q));let J=new Uint8Array([10,47,47,35,32,115,111,117,114,99,101,77,97,112,112,105,110,103,85,82,76,61]),G=this.config.sourcemaps==="inline"?`data:application/json;base64,${Buffer.from(JSON.stringify(Q)).toString("base64")}`:v1(Y);if(this.config.sourcemaps!=="hidden")await Bun.write($.path,Buffer.concat([Buffer.from(X),Buffer.from(J),Buffer.from(G)]));this.outputs.push({path:Y,type:"map",size:aX(Y).size})}}async fingerprintAssets(){for(let $ of this.outputs)if($.type==="html"){let X=await Bun.file($.path).text();for(let[Z,Q]of this.assetHashes){let Y=N7(v0($.path),Z);X=X.replace(new RegExp(Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),`${this.config.publicPath}${Q}`)}await Bun.write($.path,X)}}async compressOutputs(){let $=this.config.compression||{},X=$.threshold||1024;for(let Z of this.outputs){if(Z.type==="map")continue;if(Z.size<X)continue;let Q=Buffer.from(await Bun.file(Z.path).arrayBuffer());if($.gzip){let Y=sX(Q,{level:9}),J=`${Z.path}.gz`;await Bun.write(J,Y),Z.gzipSize=Y.length}if($.brotli)try{let{brotliCompressSync:Y}=await import("zlib"),J=Y(Q);await Bun.write(`${Z.path}.br`,J)}catch{}}}async analyzeBundle(){let $=typeof this.config.analyze==="object"?this.config.analyze:{},X=$.format||"text",Z={outputs:this.outputs.map((G)=>({path:N7(this.config.outDir,G.path),type:G.type,size:G.size,gzipSize:G.gzipSize,sizeFormatted:this.formatSize(G.size),gzipSizeFormatted:G.gzipSize?this.formatSize(G.gzipSize):void 0})),chunks:this.chunks,assets:this.assets,totalSize:this.outputs.reduce((G,W)=>G+W.size,0),totalGzipSize:this.outputs.reduce((G,W)=>G+(W.gzipSize||0),0)},Q;if(X==="json")Q=JSON.stringify(Z,null,2);else if(X==="html")Q=this.generateAnalysisHtml(Z);else Q=this.generateAnalysisText(Z);let Y=$.filename||`bundle-analysis.${X==="html"?"html":X==="json"?"json":"txt"}`,J=x0(this.config.outDir,Y);await Bun.write(J,Q),console.log(`
2382
2382
  \uD83D\uDCCA Bundle Analysis`),console.log("\u2500".repeat(50));for(let G of Z.outputs){let W=G.gzipSizeFormatted?` (gzip: ${G.gzipSizeFormatted})`:"";console.log(` ${G.path}: ${G.sizeFormatted}${W}`)}console.log("\u2500".repeat(50)),console.log(` Total: ${this.formatSize(Z.totalSize)} (gzip: ${this.formatSize(Z.totalGzipSize)})`),console.log("")}generateAnalysisHtml($){return`<!DOCTYPE html>
2383
2383
  <html>
2384
2384
  <head>
@@ -2419,14 +2419,14 @@ ${U}`)}else this.warnings.push(`External stylesheet not found: ${_}`)}return""})
2419
2419
  </table>
2420
2420
  </body>
2421
2421
  </html>`}generateAnalysisText($){let X=["Bundle Analysis","=".repeat(50),""];for(let Z of $.outputs)X.push(`${Z.path}`),X.push(` Size: ${Z.sizeFormatted}${Z.gzipSizeFormatted?` (gzip: ${Z.gzipSizeFormatted})`:""}`),X.push("");return X.push("=".repeat(50)),X.push(`Total: ${this.formatSize($.totalSize)} (gzip: ${this.formatSize($.totalGzipSize)})`),X.join(`
2422
- `)}async runPluginHook($,X){if(!this.config.plugins)return;for(let Z of this.config.plugins){let Q=Z[$];if(typeof Q==="function")await Q.call(Z,X||this)}}async runPluginTransform($,X){if(!this.config.plugins)return $;let Z=$;for(let Q of this.config.plugins)if(Q.transform){let Y=await Q.transform(Z,X);if(Y!=null)Z=Y}return Z}generateHash($){return SX("sha256").update($).digest("hex")}getOutputName($,X,Z){let Q=X==="html"?".html":X==="css"?".css":X==="js"?".js":"";return`${$}.${Z.slice(0,8)}${Q}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!P1($))PX($,{recursive:!0})}walkDir($,X){if(!P1($))return;let Z=yX($,{withFileTypes:!0});for(let Q of Z){let Y=x0($,Q.name);if(Q.isDirectory())this.walkDir(Y,X);else X(Y)}}getResult(){let $=Date.now()-this.startTime,X=this.outputs.reduce((Q,Y)=>Q+Y.size,0),Z=this.outputs.reduce((Q,Y)=>Q+(Y.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:X,gzipSize:Z,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function kW($){return new A5($).build()}function xW($){return new A5($)}function SW($){return{...B7,...$}}function fX($){return $}var yW="f9c3713";import{existsSync as v1,mkdirSync as V5}from"fs";import{join as l0,dirname as hX}from"path";import{execSync as L7}from"child_process";var uW={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}};async function mW($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.template||"default",Y=l0(process.cwd(),$);if(v1(Y))return Z.success=!1,Z.message=`Directory ${$} already exists`,Z;try{V5(Y,{recursive:!0});let J=dX(Q);for(let W of J)V5(l0(Y,W),{recursive:!0});let G=uX(Q,$,X);for(let[W,K]of Object.entries(G)){let _=l0(Y,W);g1(hX(_)),await Bun.write(_,K),Z.files.push(W)}if(!X.skipGit)try{L7("git init",{cwd:Y,stdio:"ignore"}),await Bun.write(l0(Y,".gitignore"),nX()),Z.files.push(".gitignore")}catch{Z.errors.push("Failed to initialize git repository")}if(!X.skipInstall){let W=X.packageManager||OZ();try{console.log(`
2423
- Installing dependencies with ${W}...`),L7(`${W} install`,{cwd:Y,stdio:"inherit"})}catch{Z.errors.push("Failed to install dependencies")}}Z.message=`Created project: ${$}`,console.log(`
2422
+ `)}async runPluginHook($,X){if(!this.config.plugins)return;for(let Z of this.config.plugins){let Q=Z[$];if(typeof Q==="function")await Q.call(Z,X||this)}}async runPluginTransform($,X){if(!this.config.plugins)return $;let Z=$;for(let Q of this.config.plugins)if(Q.transform){let Y=await Q.transform(Z,X);if(Y!=null)Z=Y}return Z}generateHash($){return pX("sha256").update($).digest("hex")}getOutputName($,X,Z){let Q=X==="html"?".html":X==="css"?".css":X==="js"?".js":"";return`${$}.${Z.slice(0,8)}${Q}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!y1($))cX($,{recursive:!0})}walkDir($,X){if(!y1($))return;let Z=iX($,{withFileTypes:!0});for(let Q of Z){let Y=x0($,Q.name);if(Q.isDirectory())this.walkDir(Y,X);else X(Y)}}getResult(){let $=Date.now()-this.startTime,X=this.outputs.reduce((Q,Y)=>Q+Y.size,0),Z=this.outputs.reduce((Q,Y)=>Q+(Y.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:X,gzipSize:Z,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function iW($){return new E5($).build()}function aW($){return new E5($)}function sW($){return{...A7,...$}}function rX($){return $}var oW="f9c3713";import{existsSync as f1,mkdirSync as I5}from"fs";import{join as l0,dirname as nX}from"path";import{execSync as q7}from"child_process";var QK={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}};async function YK($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.template||"default",Y=l0(process.cwd(),$);if(f1(Y))return Z.success=!1,Z.message=`Directory ${$} already exists`,Z;try{I5(Y,{recursive:!0});let J=oX(Q);for(let W of J)I5(l0(Y,W),{recursive:!0});let G=tX(Q,$,X);for(let[W,K]of Object.entries(G)){let _=l0(Y,W);h1(nX(_)),await Bun.write(_,K),Z.files.push(W)}if(!X.skipGit)try{q7("git init",{cwd:Y,stdio:"ignore"}),await Bun.write(l0(Y,".gitignore"),WZ()),Z.files.push(".gitignore")}catch{Z.errors.push("Failed to initialize git repository")}if(!X.skipInstall){let W=X.packageManager||TZ();try{console.log(`
2423
+ Installing dependencies with ${W}...`),q7(`${W} install`,{cwd:Y,stdio:"inherit"})}catch{Z.errors.push("Failed to install dependencies")}}Z.message=`Created project: ${$}`,console.log(`
2424
2424
  \u2705 ${Z.message}
2425
2425
 
2426
2426
  Next steps:
2427
2427
  cd ${$}
2428
2428
  ${X.packageManager||"bun"} run dev
2429
- `)}catch(J){Z.success=!1,Z.message=`Failed to create project: ${J}`}return Z}function dX($){let X=["pages","components","layouts","partials","public"];switch($){case"minimal":return["src","public"];case"full":return[...X,"src/stores","src/api","src/i18n","src/utils","test"];case"blog":return[...X,"src/posts","src/utils"];case"dashboard":return[...X,"src/stores","src/api","src/utils"];case"landing":return[...X,"src/sections"];default:return[...X,"src/stores"]}}function uX($,X,Z){let Q={};if(Q["package.json"]=iX(X,$,Z),Q["stx.config.ts"]=aX($,Z),Q["README.md"]=rX(X,$),Z.typescript!==!1)Q["tsconfig.json"]=sX();switch($){case"minimal":Q["src/index.stx"]=oX();break;case"blog":Q["pages/index.stx"]=XZ(),Q["pages/[slug].stx"]=ZZ(),Q["layouts/app.stx"]=QZ(),Q["components/PostCard.stx"]=YZ();break;case"dashboard":Q["pages/index.stx"]=JZ(),Q["pages/settings.stx"]=GZ(),Q["layouts/app.stx"]=WZ(),Q["components/Sidebar.stx"]=KZ(),Q["components/StatsCard.stx"]=_Z(),Q["src/stores/dashboard.ts"]=UZ();break;case"landing":Q["pages/index.stx"]=BZ(),Q["layouts/app.stx"]=LZ(),Q["src/sections/Hero.stx"]=FZ(),Q["src/sections/Features.stx"]=zZ(),Q["src/sections/Pricing.stx"]=jZ(),Q["components/Button.stx"]=HZ();break;case"full":Q["pages/index.stx"]=F7(),Q["pages/about.stx"]=tX(),Q["layouts/app.stx"]=z7(),Q["components/Header.stx"]=j7(),Q["components/Footer.stx"]=H7(),Q["src/stores/app.ts"]=O7(),Q["src/i18n/en.json"]=eX("en"),Q["test/example.test.ts"]=$Z();break;default:Q["pages/index.stx"]=F7(),Q["layouts/app.stx"]=z7(),Q["components/Header.stx"]=j7(),Q["components/Footer.stx"]=H7(),Q["src/stores/app.ts"]=O7()}return Q}async function pW($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.dir||"components",Y=M5($),J=l0(Q,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Z.success=!1,Z.message=`Component ${Y} already exists. Use --force to overwrite.`,Z;try{g1(Q);let G=mX(Y,X);await Bun.write(J,G),Z.files.push(J),Z.message=`Created component: ${J}`,console.log(`\u2705 ${Z.message}`)}catch(G){Z.success=!1,Z.message=`Failed to create component: ${G}`}return Z}async function cW($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.dir||"pages",Y=$.toLowerCase().replace(/\s+/g,"-"),J=l0(Q,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Z.success=!1,Z.message=`Page ${Y} already exists. Use --force to overwrite.`,Z;try{g1(Q);let G=pX(Y,X);await Bun.write(J,G),Z.files.push(J),Z.message=`Created page: ${J}`,console.log(`\u2705 ${Z.message}`)}catch(G){Z.success=!1,Z.message=`Failed to create page: ${G}`}return Z}async function lW($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.dir||"src/stores",Y=NZ($),J=l0(Q,`${Y}.ts`);if(await Bun.file(J).exists()&&!X.force)return Z.success=!1,Z.message=`Store ${Y} already exists. Use --force to overwrite.`,Z;try{g1(Q);let G=cX(Y,X);await Bun.write(J,G),Z.files.push(J),Z.message=`Created store: ${J}`,console.log(`\u2705 ${Z.message}`)}catch(G){Z.success=!1,Z.message=`Failed to create store: ${G}`}return Z}async function iW($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.dir||"layouts",Y=$.toLowerCase().replace(/\s+/g,"-"),J=l0(Q,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Z.success=!1,Z.message=`Layout ${Y} already exists. Use --force to overwrite.`,Z;try{g1(Q);let G=lX(Y,X);await Bun.write(J,G),Z.files.push(J),Z.message=`Created layout: ${J}`,console.log(`\u2705 ${Z.message}`)}catch(G){Z.success=!1,Z.message=`Failed to create layout: ${G}`}return Z}function mX($,X){let Z=[];if(Z.push(`{{-- Component: ${$} --}}`),X.props!==!1)Z.push(`<script>
2429
+ `)}catch(J){Z.success=!1,Z.message=`Failed to create project: ${J}`}return Z}function oX($){let X=["pages","components","layouts","partials","public"];switch($){case"minimal":return["src","public"];case"full":return[...X,"src/stores","src/api","src/i18n","src/utils","test"];case"blog":return[...X,"src/posts","src/utils"];case"dashboard":return[...X,"src/stores","src/api","src/utils"];case"landing":return[...X,"src/sections"];default:return[...X,"src/stores"]}}function tX($,X,Z){let Q={};if(Q["package.json"]=QZ(X,$,Z),Q["stx.config.ts"]=YZ($,Z),Q["README.md"]=GZ(X,$),Z.typescript!==!1)Q["tsconfig.json"]=JZ();switch($){case"minimal":Q["src/index.stx"]=KZ();break;case"blog":Q["pages/index.stx"]=LZ(),Q["pages/[slug].stx"]=FZ(),Q["layouts/app.stx"]=zZ(),Q["components/PostCard.stx"]=jZ();break;case"dashboard":Q["pages/index.stx"]=HZ(),Q["pages/settings.stx"]=OZ(),Q["layouts/app.stx"]=NZ(),Q["components/Sidebar.stx"]=AZ(),Q["components/StatsCard.stx"]=qZ(),Q["src/stores/dashboard.ts"]=VZ();break;case"landing":Q["pages/index.stx"]=MZ(),Q["layouts/app.stx"]=EZ(),Q["src/sections/Hero.stx"]=IZ(),Q["src/sections/Features.stx"]=RZ(),Q["src/sections/Pricing.stx"]=DZ(),Q["components/Button.stx"]=wZ();break;case"full":Q["pages/index.stx"]=V7(),Q["pages/about.stx"]=_Z(),Q["layouts/app.stx"]=M7(),Q["components/Header.stx"]=E7(),Q["components/Footer.stx"]=I7(),Q["src/stores/app.ts"]=R7(),Q["src/i18n/en.json"]=UZ("en"),Q["test/example.test.ts"]=BZ();break;default:Q["pages/index.stx"]=V7(),Q["layouts/app.stx"]=M7(),Q["components/Header.stx"]=E7(),Q["components/Footer.stx"]=I7(),Q["src/stores/app.ts"]=R7()}return Q}async function JK($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.dir||"components",Y=R5($),J=l0(Q,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Z.success=!1,Z.message=`Component ${Y} already exists. Use --force to overwrite.`,Z;try{h1(Q);let G=eX(Y,X);await Bun.write(J,G),Z.files.push(J),Z.message=`Created component: ${J}`,console.log(`\u2705 ${Z.message}`)}catch(G){Z.success=!1,Z.message=`Failed to create component: ${G}`}return Z}async function GK($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.dir||"pages",Y=$.toLowerCase().replace(/\s+/g,"-"),J=l0(Q,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Z.success=!1,Z.message=`Page ${Y} already exists. Use --force to overwrite.`,Z;try{h1(Q);let G=$Z(Y,X);await Bun.write(J,G),Z.files.push(J),Z.message=`Created page: ${J}`,console.log(`\u2705 ${Z.message}`)}catch(G){Z.success=!1,Z.message=`Failed to create page: ${G}`}return Z}async function WK($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.dir||"src/stores",Y=CZ($),J=l0(Q,`${Y}.ts`);if(await Bun.file(J).exists()&&!X.force)return Z.success=!1,Z.message=`Store ${Y} already exists. Use --force to overwrite.`,Z;try{h1(Q);let G=XZ(Y,X);await Bun.write(J,G),Z.files.push(J),Z.message=`Created store: ${J}`,console.log(`\u2705 ${Z.message}`)}catch(G){Z.success=!1,Z.message=`Failed to create store: ${G}`}return Z}async function KK($,X={}){let Z={success:!0,message:"",files:[],errors:[]},Q=X.dir||"layouts",Y=$.toLowerCase().replace(/\s+/g,"-"),J=l0(Q,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Z.success=!1,Z.message=`Layout ${Y} already exists. Use --force to overwrite.`,Z;try{h1(Q);let G=ZZ(Y,X);await Bun.write(J,G),Z.files.push(J),Z.message=`Created layout: ${J}`,console.log(`\u2705 ${Z.message}`)}catch(G){Z.success=!1,Z.message=`Failed to create layout: ${G}`}return Z}function eX($,X){let Z=[];if(Z.push(`{{-- Component: ${$} --}}`),X.props!==!1)Z.push(`<script>
2430
2430
  // Props
2431
2431
  const title = props.title || '${$}'
2432
2432
  const variant = props.variant || 'default'
@@ -2456,7 +2456,7 @@ const variant = props.variant || 'default'
2456
2456
  margin-top: 0.5rem;
2457
2457
  }
2458
2458
  </style>`);return Z.join(`
2459
- `)}function pX($,X){let Z=M5($.replace(/-/g," ")),Q=[];if(Q.push(`<script>
2459
+ `)}function $Z($,X){let Z=R5($.replace(/-/g," ")),Q=[];if(Q.push(`<script>
2460
2460
  const title = '${Z}'
2461
2461
  const description = 'Page description'
2462
2462
  </script>
@@ -2469,7 +2469,7 @@ const description = 'Page description'
2469
2469
  <p>{{ description }}</p>
2470
2470
  </div>
2471
2471
  @endsection`),Q.join(`
2472
- `)}function cX($,X){let Z=`${$}Store`,Q=`${M5($)}State`,Y=`import { defineStore } from 'stx'
2472
+ `)}function XZ($,X){let Z=`${$}Store`,Q=`${R5($)}State`,Y=`import { defineStore } from 'stx'
2473
2473
 
2474
2474
  interface ${Q} {
2475
2475
  // Add your state properties here
@@ -2517,7 +2517,7 @@ finally {
2517
2517
  ],
2518
2518
  },
2519
2519
  `;return Y+=`})
2520
- `,Y}function lX($,X){let Z=`<!DOCTYPE html>
2520
+ `,Y}function ZZ($,X){let Z=`<!DOCTYPE html>
2521
2521
  <html lang="en">
2522
2522
  <head>
2523
2523
  <meta charset="UTF-8">
@@ -2564,7 +2564,7 @@ finally {
2564
2564
 
2565
2565
  `;return Z+=` @yield('scripts')
2566
2566
  </body>
2567
- </html>`,Z}function iX($,X,Z){let Q={name:$,version:"0.0.1",type:"module",scripts:{dev:"stx dev pages/index.stx",build:"stx build",preview:"stx serve dist"},dependencies:{stx:"latest"},devDependencies:{}};if(Z.typescript!==!1)Q.devDependencies.typescript="^5.0.0";if(Z.tailwind)Q.devDependencies.tailwindcss="^3.0.0";if(X==="full")Q.scripts.test="bun test",Q.scripts.lint="bun run lint";return JSON.stringify(Q,null,2)}function aX($,X){return`import { defineConfig } from 'stx'
2567
+ </html>`,Z}function QZ($,X,Z){let Q={name:$,version:"0.0.1",type:"module",scripts:{dev:"stx dev pages/index.stx",build:"stx build",preview:"stx serve dist"},dependencies:{stx:"latest"},devDependencies:{}};if(Z.typescript!==!1)Q.devDependencies.typescript="^5.0.0";if(Z.tailwind)Q.devDependencies.tailwindcss="^3.0.0";if(X==="full")Q.scripts.test="bun test",Q.scripts.lint="bun run lint";return JSON.stringify(Q,null,2)}function YZ($,X){return`import { defineConfig } from 'stx'
2568
2568
 
2569
2569
  export default defineConfig({
2570
2570
  // Template directories
@@ -2585,7 +2585,7 @@ ${X.pwa?` pwa: { enabled: true },
2585
2585
  // Analytics (configure when ready)
2586
2586
  // analytics: { enabled: true, driver: 'fathom', fathom: { siteId: 'YOUR_SITE_ID' } },
2587
2587
  })
2588
- `}function sX(){return JSON.stringify({compilerOptions:{target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,skipLibCheck:!0,esModuleInterop:!0,types:["bun-types"]},include:["src/**/*","test/**/*"]},null,2)}function rX($,X){return`# ${$}
2588
+ `}function JZ(){return JSON.stringify({compilerOptions:{target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,skipLibCheck:!0,esModuleInterop:!0,types:["bun-types"]},include:["src/**/*","test/**/*"]},null,2)}function GZ($,X){return`# ${$}
2589
2589
 
2590
2590
  A stx project created with the \`${X}\` template.
2591
2591
 
@@ -2617,7 +2617,7 @@ src/
2617
2617
 
2618
2618
  - [stx Documentation](https://stx.dev/docs)
2619
2619
  - [stx GitHub](https://github.com/stacksjs/stx)
2620
- `}function nX(){return`# Dependencies
2620
+ `}function WZ(){return`# Dependencies
2621
2621
  node_modules/
2622
2622
  .bun/
2623
2623
 
@@ -2642,7 +2642,7 @@ Thumbs.db
2642
2642
 
2643
2643
  # Logs
2644
2644
  *.log
2645
- `}function oX(){return`<!DOCTYPE html>
2645
+ `}function KZ(){return`<!DOCTYPE html>
2646
2646
  <html lang="en">
2647
2647
  <head>
2648
2648
  <meta charset="UTF-8">
@@ -2658,7 +2658,7 @@ Thumbs.db
2658
2658
  <p>Edit <code>src/index.stx</code> to get started.</p>
2659
2659
  </body>
2660
2660
  </html>
2661
- `}function F7(){return`<script>
2661
+ `}function V7(){return`<script>
2662
2662
  const title = 'Welcome to stx'
2663
2663
  const features = [
2664
2664
  { icon: '\u26A1', name: 'Fast', desc: 'Built on Bun for blazing speed' },
@@ -2687,7 +2687,7 @@ const features = [
2687
2687
  @endforeach
2688
2688
  </div>
2689
2689
  @endsection
2690
- `}function tX(){return`<script>
2690
+ `}function _Z(){return`<script>
2691
2691
  const title = 'About'
2692
2692
  </script>
2693
2693
 
@@ -2699,7 +2699,7 @@ const title = 'About'
2699
2699
  <h1>{{ title }}</h1>
2700
2700
  <p>This is the about page.</p>
2701
2701
  @endsection
2702
- `}function z7(){return`<!DOCTYPE html>
2702
+ `}function M7(){return`<!DOCTYPE html>
2703
2703
  <html lang="en">
2704
2704
  <head>
2705
2705
  <meta charset="UTF-8">
@@ -2722,7 +2722,7 @@ const title = 'About'
2722
2722
  @yield('scripts')
2723
2723
  </body>
2724
2724
  </html>
2725
- `}function j7(){return`<header class="header">
2725
+ `}function E7(){return`<header class="header">
2726
2726
  <nav class="nav container">
2727
2727
  <a href="/" class="logo">stx</a>
2728
2728
  <div class="nav-links">
@@ -2739,7 +2739,7 @@ const title = 'About'
2739
2739
  .nav-links a { color: rgba(255,255,255,0.8); margin-left: 1.5rem; text-decoration: none; }
2740
2740
  .nav-links a:hover { color: white; }
2741
2741
  </style>
2742
- `}function H7(){return`<footer class="footer">
2742
+ `}function I7(){return`<footer class="footer">
2743
2743
  <div class="container">
2744
2744
  <p>&copy; {{ new Date().getFullYear() }} Built with stx</p>
2745
2745
  </div>
@@ -2748,7 +2748,7 @@ const title = 'About'
2748
2748
  <style scoped>
2749
2749
  .footer { background: #f8f9fa; padding: 2rem 0; margin-top: 4rem; text-align: center; color: #666; }
2750
2750
  </style>
2751
- `}function O7(){return`import { defineStore } from 'stx'
2751
+ `}function R7(){return`import { defineStore } from 'stx'
2752
2752
 
2753
2753
  interface AppState {
2754
2754
  theme: 'light' | 'dark'
@@ -2775,14 +2775,14 @@ export const appStore = defineStore('app', {
2775
2775
  strategies: [{ key: 'app-preferences', storage: localStorage }],
2776
2776
  },
2777
2777
  })
2778
- `}function eX($){return JSON.stringify({common:{welcome:"Welcome",home:"Home",about:"About",contact:"Contact"},messages:{loading:"Loading...",error:"An error occurred"}},null,2)}function $Z(){return`import { describe, expect, it } from 'bun:test'
2778
+ `}function UZ($){return JSON.stringify({common:{welcome:"Welcome",home:"Home",about:"About",contact:"Contact"},messages:{loading:"Loading...",error:"An error occurred"}},null,2)}function BZ(){return`import { describe, expect, it } from 'bun:test'
2779
2779
 
2780
2780
  describe('Example', () => {
2781
2781
  it('should work', () => {
2782
2782
  expect(1 + 1).toBe(2)
2783
2783
  })
2784
2784
  })
2785
- `}function XZ(){return"<!-- Blog index -->"}function ZZ(){return"<!-- Blog post -->"}function QZ(){return`<!DOCTYPE html>
2785
+ `}function LZ(){return"<!-- Blog index -->"}function FZ(){return"<!-- Blog post -->"}function zZ(){return`<!DOCTYPE html>
2786
2786
  <html lang="en">
2787
2787
  <head>
2788
2788
  <meta charset="UTF-8">
@@ -2822,7 +2822,7 @@ describe('Example', () => {
2822
2822
  </footer>
2823
2823
  @yield('scripts')
2824
2824
  </body>
2825
- </html>`}function YZ(){return"<!-- Post card -->"}function JZ(){return"<!-- Dashboard index -->"}function GZ(){return"<!-- Settings -->"}function WZ(){return`<!DOCTYPE html>
2825
+ </html>`}function jZ(){return"<!-- Post card -->"}function HZ(){return"<!-- Dashboard index -->"}function OZ(){return"<!-- Settings -->"}function NZ(){return`<!DOCTYPE html>
2826
2826
  <html lang="en">
2827
2827
  <head>
2828
2828
  <meta charset="UTF-8">
@@ -2858,7 +2858,7 @@ describe('Example', () => {
2858
2858
  </div>
2859
2859
  @yield('scripts')
2860
2860
  </body>
2861
- </html>`}function KZ(){return"<!-- Sidebar -->"}function _Z(){return"<!-- Stats card -->"}function UZ(){return"// Dashboard store"}function BZ(){return"<!-- Landing page -->"}function LZ(){return`<!DOCTYPE html>
2861
+ </html>`}function AZ(){return"<!-- Sidebar -->"}function qZ(){return"<!-- Stats card -->"}function VZ(){return"// Dashboard store"}function MZ(){return"<!-- Landing page -->"}function EZ(){return`<!DOCTYPE html>
2862
2862
  <html lang="en">
2863
2863
  <head>
2864
2864
  <meta charset="UTF-8">
@@ -2893,17 +2893,17 @@ describe('Example', () => {
2893
2893
  </footer>
2894
2894
  @yield('scripts')
2895
2895
  </body>
2896
- </html>`}function FZ(){return"<!-- Hero section -->"}function zZ(){return"<!-- Features -->"}function jZ(){return"<!-- Pricing -->"}function HZ(){return"<!-- Button -->"}function g1($){if(!v1($))V5($,{recursive:!0})}function OZ(){if(v1("bun.lockb"))return"bun";if(v1("pnpm-lock.yaml"))return"pnpm";if(v1("yarn.lock"))return"yarn";return"bun"}function M5($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function NZ($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function $1($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:qZ}=globalThis.Bun;import f1 from"fs";import D0 from"path";function YK($,X=200,Z={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Z}})}async function E5($){let{loadStxConfig:X}=await import("./chunk-cvtxk36x.js");return{...await X($.configDir??process.cwd()),...$.stxOptions??{}}}async function AZ($={}){let{port:X=3000,root:Z=".",watch:Q=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=D0.resolve(Z),U=await E5($),F=D0.resolve($.configDir??process.cwd()),z=await I5(F,U.serverApi),j=new Map;async function H(q){let A=f1.statSync(q),I=`${q}:${A.mtimeMs}`,E=j.get(I);if(E)return{content:E.content,status:E.status,headers:E.headers};for(let K0 of j.keys())if(K0.startsWith(`${q}:`)&&K0!==I)j.delete(K0);let w=await Bun.file(q).text(),D=w,T=K$(w);if(T)D=T.content.trim();let f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],v=[],S;while((S=f.exec(w))!==null){let K0=S[1],R=S[2],x=S[0];if(K0.includes("server"))v.push(R);else c.push(x)}let k=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],N0=D.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),W0={__filename:q,__dirname:D0.dirname(q),__stx_options:U};for(let K0 of v)await E0(K0,W0,q);let j0=await I0(N0,W0,q,U,new Set);if(k.length>0){let K0=k.join(`
2896
+ </html>`}function IZ(){return"<!-- Hero section -->"}function RZ(){return"<!-- Features -->"}function DZ(){return"<!-- Pricing -->"}function wZ(){return"<!-- Button -->"}function h1($){if(!f1($))I5($,{recursive:!0})}function TZ(){if(f1("bun.lockb"))return"bun";if(f1("pnpm-lock.yaml"))return"pnpm";if(f1("yarn.lock"))return"yarn";return"bun"}function R5($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function CZ($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function $1($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:kZ}=globalThis.Bun;import d1 from"fs";import D0 from"path";function qK($,X=200,Z={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Z}})}async function D5($){let{loadStxConfig:X}=await import("./chunk-hcvjstmr.js");return{...await X($.configDir??process.cwd()),...$.stxOptions??{}}}async function xZ($={}){let{port:X=3000,root:Z=".",watch:Q=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=D0.resolve(Z),U=await D5($),F=D0.resolve($.configDir??process.cwd()),z=await w5(F,U.serverApi),j=new Map;async function H(A){let q=d1.statSync(A),I=`${A}:${q.mtimeMs}`,E=j.get(I);if(E)return{content:E.content,status:E.status,headers:E.headers};for(let K0 of j.keys())if(K0.startsWith(`${A}:`)&&K0!==I)j.delete(K0);let w=await Bun.file(A).text(),D=w,T=B$(w);if(T)D=T.content.trim();let f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],v=[],S;while((S=f.exec(w))!==null){let K0=S[1],R=S[2],x=S[0];if(K0.includes("server"))v.push(R);else c.push(x)}let k=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],N0=D.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),W0={__filename:A,__dirname:D0.dirname(A),__stx_options:U};for(let K0 of v)await E0(K0,W0,A);let j0=await I0(N0,W0,A,U,new Set);if(k.length>0){let K0=k.join(`
2897
2897
  `);if(j0.match(/(<\/head>)/i))j0=j0.replace(/(<\/head>)/i,`${K0}
2898
- $1`)}if(c.length>0){let{interpolateScriptsInTemplate:K0}=await import("./chunk-jndc710n.js"),R=K0(c.join(`
2898
+ $1`)}if(c.length>0){let{interpolateScriptsInTemplate:K0}=await import("./chunk-7ypm243n.js"),R=K0(c.join(`
2899
2899
  `),W0);if(j0.match(/(<\/body>)/i))j0=j0.replace(/(<\/body>)/i,`${R}
2900
2900
  $1`);else j0+=`
2901
- ${R}`}let Q1=T1(W0),i$=C1(W0);return j.set(I,{content:j0,mtime:A.mtimeMs,status:Q1,headers:i$}),{content:j0,status:Q1,headers:i$}}async function L(q){let A=f1.statSync(q),I=`${q}:${A.mtimeMs}`,E=j.get(I);if(E)return E.content;let{content:w}=await k0(q,U);return j.set(I,{content:w,mtime:A.mtimeMs}),w}function O(q){let A=q.startsWith("/")?q.slice(1):q,I=[A,`${A}.stx`,`${A}.md`,`${A}.html`,D0.join(A,"index.stx"),D0.join(A,"index.md"),D0.join(A,"index.html")];for(let E of[_,...U._layerPageDirs??[]])for(let w of I){let D=D0.resolve(E,w);if(!D.startsWith(`${D0.resolve(E)}${D0.sep}`))continue;if(f1.existsSync(D)&&f1.statSync(D).isFile())return D}return null}async function N(q){if(U._layerGraph){let E=await E5($);if(E._layerGraph!==U._layerGraph)Object.assign(U,E),j.clear()}let A=new URL(q.url),I=async()=>{if(J[A.pathname])return await J[A.pathname](q);if(Y){let D=await Y(q);if(D)return D}if(U.apiRouter){let D=await U.apiRouter.handleRequest(q);if(D.status!==404)return D}if(U.apiRoutes?.[A.pathname])return U.apiRoutes[A.pathname](q);let E=await z(q);if(E)return E;let w=O(A.pathname);if(!w||N7(w,F,U.serverApi)){if(W)return await W(q);return new Response("Not Found",{status:404})}try{let D,T="text/html",f,c;if(w.endsWith(".stx")){let v=await H(w);D=v.content,f=v.status,c=v.headers}else if(w.endsWith(".md"))D=await L(w);else if(w.endsWith(".html"))D=await Bun.file(w).text();else if(w.endsWith(".css"))D=await Bun.file(w).text(),T="text/css";else if(w.endsWith(".js"))D=await Bun.file(w).text(),T="text/javascript";else if(w.endsWith(".json"))D=await Bun.file(w).text(),T="application/json";else return new Response(Bun.file(w));return new Response(D,{status:f??200,headers:{"Content-Type":T,...c}})}catch(D){if(K)return await K(D,q);let T=D instanceof Error?D.message:String(D),c=U?.debug===!0?`<h1>Error</h1><pre>${T}
2902
- ${D instanceof Error?D.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(c,{status:500,headers:{"Content-Type":"text/html"}})}};for(let E=G.length-1;E>=0;E--){let w=G[E],D=I;I=async()=>await w(q,D)}return await I()}let V=qZ({port:X,fetch:async(q)=>z$(q,await N(q))}),M=null;if(Q)M=f1.watch(_,{recursive:!0},(q,A)=>{if(A&&(A.endsWith(".stx")||A.endsWith(".md")||A.endsWith(".html")))j.clear()});return{server:V,url:V.url.toString(),stop(){if(M)M.close();V.stop()}}}async function JK($,X={}){let Z=D0.resolve($);if(!await Bun.file(Z).exists())throw Error(`File not found: ${Z}`);let Q=Z.endsWith(".md"),Y=Z.endsWith(".stx");if(!Q&&!Y)throw Error(`Unsupported file type: ${Z}. Only .stx and .md files are supported.`);let J=await E5(X);return await AZ({...X,root:D0.dirname(Z),routes:{"/":async()=>{let G,W=200,K;if(Q){let{content:_}=await k0(Z,J);G=_}else{let _=await Bun.file(Z).text(),U=[],F=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,z;while((z=F.exec(_))!==null)if(z[1].includes("server"))U.push(z[2]);let j=U.join(`
2903
- `),H=_.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),L={__stx_options:J};if(j.trim())await E0(j,L,Z);G=await I0(H,L,Z,J,new Set),W=T1(L)??200,K=C1(L)}return new Response(G,{status:W,headers:{"Content-Type":"text/html",...K}})},...X.routes}})}function VZ($){return $}function MZ($){return $}import{existsSync as EZ,readFileSync as IZ}from"fs";var RZ={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},q7={console:{kind:"object",properties:{log:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},error:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},warn:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}}}},Math:{kind:"object",properties:{abs:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},floor:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},ceil:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},round:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},max:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},min:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},random:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},PI:{kind:"primitive",value:"number"},E:{kind:"primitive",value:"number"}}},JSON:{kind:"object",properties:{stringify:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},parse:{kind:"function",params:[{name:"text",type:{kind:"primitive",value:"string"}}],returnType:{kind:"primitive",value:"any"}}}},Date:{kind:"function",returnType:{kind:"object",properties:{getTime:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},toISOString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}},toLocaleDateString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}}}}},Array:{kind:"object",properties:{isArray:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},from:{kind:"function",params:[{name:"arrayLike",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},Object:{kind:"object",properties:{keys:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}},values:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}},entries:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},String:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},Number:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"number"}},Boolean:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},props:{kind:"object",properties:{}},slot:{kind:"primitive",value:"string"},loop:{kind:"object",properties:{index:{kind:"primitive",value:"number"},iteration:{kind:"primitive",value:"number"},first:{kind:"primitive",value:"boolean"},last:{kind:"primitive",value:"boolean"},even:{kind:"primitive",value:"boolean"},odd:{kind:"primitive",value:"boolean"},count:{kind:"primitive",value:"number"},remaining:{kind:"primitive",value:"number"},depth:{kind:"primitive",value:"number"},parent:{kind:"object",properties:{}}}}};class A7{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...RZ,...$},this.options.includeBuiltins)Object.entries(q7).forEach(([X,Z])=>{this.variables.set(X,Z)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([X,Z])=>{this.variables.set(X,Z)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!EZ($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let X=IZ($,"utf-8");return this.checkTemplate(X,$)}checkTemplate($,X="<inline>"){this.currentFile=X,this.errors=[],this.warnings=[];let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Z)this.analyzeScript(Z[1],$.indexOf(Z[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,X){let Z=$.split(`
2901
+ ${R}`}let Q1=k1(W0),r$=x1(W0);return j.set(I,{content:j0,mtime:q.mtimeMs,status:Q1,headers:r$}),{content:j0,status:Q1,headers:r$}}async function L(A){let q=d1.statSync(A),I=`${A}:${q.mtimeMs}`,E=j.get(I);if(E)return E.content;let{content:w}=await k0(A,U);return j.set(I,{content:w,mtime:q.mtimeMs}),w}function O(A){let q=A.startsWith("/")?A.slice(1):A,I=[q,`${q}.stx`,`${q}.md`,`${q}.html`,D0.join(q,"index.stx"),D0.join(q,"index.md"),D0.join(q,"index.html")];for(let E of[_,...U._layerPageDirs??[]])for(let w of I){let D=D0.resolve(E,w);if(!D.startsWith(`${D0.resolve(E)}${D0.sep}`))continue;if(d1.existsSync(D)&&d1.statSync(D).isFile())return D}return null}async function N(A){if(U._layerGraph){let E=await D5($);if(E._layerGraph!==U._layerGraph)Object.assign(U,E),j.clear()}let q=new URL(A.url),I=async()=>{if(J[q.pathname])return await J[q.pathname](A);if(Y){let D=await Y(A);if(D)return D}if(U.apiRouter){let D=await U.apiRouter.handleRequest(A);if(D.status!==404)return D}if(U.apiRoutes?.[q.pathname])return U.apiRoutes[q.pathname](A);let E=await z(A);if(E)return E;let w=O(q.pathname);if(!w||D7(w,F,U.serverApi)){if(W)return await W(A);return new Response("Not Found",{status:404})}try{let D,T="text/html",f,c;if(w.endsWith(".stx")){let v=await H(w);D=v.content,f=v.status,c=v.headers}else if(w.endsWith(".md"))D=await L(w);else if(w.endsWith(".html"))D=await Bun.file(w).text();else if(w.endsWith(".css"))D=await Bun.file(w).text(),T="text/css";else if(w.endsWith(".js"))D=await Bun.file(w).text(),T="text/javascript";else if(w.endsWith(".json"))D=await Bun.file(w).text(),T="application/json";else return new Response(Bun.file(w));return new Response(D,{status:f??200,headers:{"Content-Type":T,...c}})}catch(D){if(K)return await K(D,A);let T=D instanceof Error?D.message:String(D),c=U?.debug===!0?`<h1>Error</h1><pre>${T}
2902
+ ${D instanceof Error?D.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(c,{status:500,headers:{"Content-Type":"text/html"}})}};for(let E=G.length-1;E>=0;E--){let w=G[E],D=I;I=async()=>await w(A,D)}return await I()}let V=kZ({port:X,fetch:async(A)=>O$(A,await N(A))}),M=null;if(Q)M=d1.watch(_,{recursive:!0},(A,q)=>{if(q&&(q.endsWith(".stx")||q.endsWith(".md")||q.endsWith(".html")))j.clear()});return{server:V,url:V.url.toString(),stop(){if(M)M.close();V.stop()}}}async function VK($,X={}){let Z=D0.resolve($);if(!await Bun.file(Z).exists())throw Error(`File not found: ${Z}`);let Q=Z.endsWith(".md"),Y=Z.endsWith(".stx");if(!Q&&!Y)throw Error(`Unsupported file type: ${Z}. Only .stx and .md files are supported.`);let J=await D5(X);return await xZ({...X,root:D0.dirname(Z),routes:{"/":async()=>{let G,W=200,K;if(Q){let{content:_}=await k0(Z,J);G=_}else{let _=await Bun.file(Z).text(),U=[],F=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,z;while((z=F.exec(_))!==null)if(z[1].includes("server"))U.push(z[2]);let j=U.join(`
2903
+ `),H=_.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),L={__stx_options:J};if(j.trim())await E0(j,L,Z);G=await I0(H,L,Z,J,new Set),W=k1(L)??200,K=x1(L)}return new Response(G,{status:W,headers:{"Content-Type":"text/html",...K}})},...X.routes}})}function SZ($){return $}function PZ($){return $}import{existsSync as bZ,readFileSync as yZ}from"fs";var vZ={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},w7={console:{kind:"object",properties:{log:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},error:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},warn:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}}}},Math:{kind:"object",properties:{abs:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},floor:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},ceil:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},round:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},max:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},min:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},random:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},PI:{kind:"primitive",value:"number"},E:{kind:"primitive",value:"number"}}},JSON:{kind:"object",properties:{stringify:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},parse:{kind:"function",params:[{name:"text",type:{kind:"primitive",value:"string"}}],returnType:{kind:"primitive",value:"any"}}}},Date:{kind:"function",returnType:{kind:"object",properties:{getTime:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},toISOString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}},toLocaleDateString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}}}}},Array:{kind:"object",properties:{isArray:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},from:{kind:"function",params:[{name:"arrayLike",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},Object:{kind:"object",properties:{keys:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}},values:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}},entries:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},String:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},Number:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"number"}},Boolean:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},props:{kind:"object",properties:{}},slot:{kind:"primitive",value:"string"},loop:{kind:"object",properties:{index:{kind:"primitive",value:"number"},iteration:{kind:"primitive",value:"number"},first:{kind:"primitive",value:"boolean"},last:{kind:"primitive",value:"boolean"},even:{kind:"primitive",value:"boolean"},odd:{kind:"primitive",value:"boolean"},count:{kind:"primitive",value:"number"},remaining:{kind:"primitive",value:"number"},depth:{kind:"primitive",value:"number"},parent:{kind:"object",properties:{}}}}};class T7{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...vZ,...$},this.options.includeBuiltins)Object.entries(w7).forEach(([X,Z])=>{this.variables.set(X,Z)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([X,Z])=>{this.variables.set(X,Z)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!bZ($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let X=yZ($,"utf-8");return this.checkTemplate(X,$)}checkTemplate($,X="<inline>"){this.currentFile=X,this.errors=[],this.warnings=[];let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Z)this.analyzeScript(Z[1],$.indexOf(Z[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,X){let Z=$.split(`
2904
2904
  `),Q=this.getLineNumber(X);for(let Y=0;Y<Z.length;Y++){let J=Z[Y],G=Q+Y;this.extractTypedVariables(J,G),this.extractInterfaces(J,Z,Y,G),this.extractTypeAliases(J,G)}}extractTypedVariables($,X){let Z=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*:\s*([^=]+?)\s*=/);if(Z){let[,J,G]=Z,W=this.parseTypeAnnotation(G.trim());this.variables.set(J,W);return}let Q=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(.+)/);if(Q){let[,J,G]=Q,W=this.inferType(G.trim());this.variables.set(J,W);return}let Y=$.match(/(?:export\s+)?function\s+(\w+)\s*\(([^)]*)\)(?:\s*:\s*(\w+))?/);if(Y){let[,J,G,W]=Y,K=this.parseParams(G),_=W?this.parseTypeAnnotation(W):{kind:"primitive",value:"any"};this.variables.set(J,{kind:"function",params:K,returnType:_})}}extractInterfaces($,X,Z,Q){let Y=$.match(/(?:export\s+)?interface\s+(\w+)\s*\{/);if(Y){let[,J]=Y,G={},W=1,K=Z+1;while(K<X.length&&W>0){let _=X[K].trim();if(_.includes("{"))W++;if(_.includes("}"))W--;let U=_.match(/(\w+)\??\s*:\s*([^;]+)/);if(U&&W>0){let[,F,z]=U;G[F]=this.parseTypeAnnotation(z.trim())}K++}this.variables.set(J,{kind:"object",name:J,properties:G})}}extractTypeAliases($,X){let Z=$.match(/(?:export\s+)?type\s+(\w+)\s*=\s*(.+)/);if(Z){let[,Q,Y]=Z,J=this.parseTypeAnnotation(Y.trim());J.name=Q,this.variables.set(Q,J)}}parseTypeAnnotation($){let X=$.trim();if(X.includes("|"))return{kind:"union",types:X.split("|").map((J)=>this.parseTypeAnnotation(J.trim()))};if(X.includes("&"))return{kind:"intersection",types:X.split("&").map((J)=>this.parseTypeAnnotation(J.trim()))};if(X.endsWith("[]"))return{kind:"array",elementType:this.parseTypeAnnotation(X.slice(0,-2))};let Z=X.match(/^Array<(.+)>$/);if(Z)return{kind:"array",elementType:this.parseTypeAnnotation(Z[1])};if(X.startsWith("{")&&X.endsWith("}")){let Y={},J=X.slice(1,-1).trim();if(J){let G=this.splitByComma(J);for(let W of G){let K=W.match(/(\w+)\??\s*:\s*(.+)/);if(K){let[,_,U]=K;Y[_]=this.parseTypeAnnotation(U.trim())}}}return{kind:"object",properties:Y}}if(X.startsWith('"')||X.startsWith("'"))return{kind:"literal",value:X.slice(1,-1)};if(/^\d+$/.test(X))return{kind:"literal",value:X};if(X==="true"||X==="false")return{kind:"literal",value:X};if(["string","number","boolean","null","undefined","any","unknown","void","never"].includes(X))return{kind:"primitive",value:X};if(this.variables.has(X))return this.variables.get(X);return{kind:"primitive",value:"any"}}inferType($){let X=$.trim().replace(/;$/,"");if(X.startsWith('"')&&X.endsWith('"')||X.startsWith("'")&&X.endsWith("'")||X.startsWith("`")&&X.endsWith("`"))return{kind:"primitive",value:"string"};if(/^-?\d+(\.\d+)?$/.test(X))return{kind:"primitive",value:"number"};if(X==="true"||X==="false")return{kind:"primitive",value:"boolean"};if(X==="null")return{kind:"primitive",value:"null"};if(X==="undefined")return{kind:"primitive",value:"undefined"};if(X.startsWith("[")){let Z=X.slice(1,-1).trim();if(Z){let Q=this.splitByComma(Z)[0];if(Q)return{kind:"array",elementType:this.inferType(Q.trim())}}return{kind:"array",elementType:{kind:"primitive",value:"any"}}}if(X.startsWith("{")){let Z={},Q=this.extractObjectLiteral(X);for(let[Y,J]of Object.entries(Q))Z[Y]=this.inferType(J);return{kind:"object",properties:Z}}if(X.includes("=>")){let Z=X.match(/^\(([^)]*)\)\s*(?::\s*(\w+))?\s*=>/);if(Z){let Q=this.parseParams(Z[1]),Y=Z[2]?this.parseTypeAnnotation(Z[2]):{kind:"primitive",value:"any"};return{kind:"function",params:Q,returnType:Y}}}if(/^\w+$/.test(X)&&this.variables.has(X))return this.variables.get(X);if(X.includes("."))return this.resolvePropertyAccess(X);if(X.includes("(")){let Z=X.split("(")[0],Q=this.variables.get(Z);if(Q?.kind==="function"&&Q.returnType)return Q.returnType}return{kind:"primitive",value:"any"}}parseParams($){if(!$.trim())return[];let X=[],Z=this.splitByComma($);for(let Q of Z){let Y=Q.trim(),J=Y.includes("?"),G=Y.match(/(\w+)\??\s*(?::\s*([^=]+))?(?:\s*=)?/);if(G){let[,W,K]=G,_=K?this.parseTypeAnnotation(K.trim()):{kind:"primitive",value:"any"};X.push({name:W,type:_,optional:J})}}return X}checkExpressions($){let X=/\{\{([\s\S]*?)\}\}/g,Z;while((Z=X.exec($))!==null){let Y=Z[1].trim(),J=Z.index,G=this.getLineNumber(J,$),W=this.getColumn(J,$);if(!Y)continue;if(Y.startsWith("!")||Y.endsWith("!"))continue;this.checkExpression(Y,G,W)}let Q=/\{!!([\s\S]*?)!!\}/g;while((Z=Q.exec($))!==null){let Y=Z[1].trim(),J=Z.index,G=this.getLineNumber(J,$),W=this.getColumn(J,$);if(!Y)continue;this.checkExpression(Y,G,W)}}checkExpression($,X,Z){if($.includes("?")&&$.includes(":")){let J=$.split("?");this.checkExpression(J[0].trim(),X,Z);let G=J.slice(1).join("?").split(":");if(G.length>=2)this.checkExpression(G[0].trim(),X,Z),this.checkExpression(G.slice(1).join(":").trim(),X,Z);return}for(let J of["&&","||","??"])if($.includes(J)){$.split(J).forEach((W)=>this.checkExpression(W.trim(),X,Z));return}for(let J of["===","!==","==","!=",">=","<=",">","<"])if($.includes(J)){$.split(J).forEach((W)=>this.checkExpression(W.trim(),X,Z));return}if($.startsWith("!")){this.checkExpression($.slice(1).trim(),X,Z);return}if(this.isLiteral($))return;let Q=$.match(/^(\w+(?:\.\w+)*)\s*\(/);if(Q){let J=Q[1],G=this.resolvePropertyAccess(J);if(G.kind!=="function"&&G.value!=="any")this.addWarning(`'${J}' is not a function`,X,Z,$);return}if($.includes(".")){if(this.resolvePropertyAccess($).value==="undefined"&&this.options.checkPropertyAccess)this.addWarning(`Property access '${$}' may be undefined`,X,Z,$);return}let Y=$.match(/^\w+/)?.[0];if(Y&&!this.variables.has(Y))this.addError(`Variable '${Y}' is not defined`,X,Z,$)}checkDirectives($){let X=/@if\s*\(([^)]+)\)/g,Z;while((Z=X.exec($))!==null){let G=Z[1].trim(),W=Z.index,K=this.getLineNumber(W,$),_=this.getColumn(W,$);this.checkExpression(G,K,_)}let Q=/@foreach\s*\((\w+)\s+(?:as|in)\s+(\w+)(?:\s*,\s*(\w+))?\)/g;while((Z=Q.exec($))!==null){let[,G,W,K]=Z,_=Z.index,U=this.getLineNumber(_,$),F=this.getColumn(_,$);if(!this.variables.has(G))this.addError(`Collection '${G}' is not defined`,U,F,Z[0]);else{let z=this.variables.get(G);if(z.kind==="array"&&z.elementType)this.variables.set(W,z.elementType);else this.variables.set(W,{kind:"primitive",value:"any"});if(K)this.variables.set(K,{kind:"primitive",value:"number"})}}let Y=/@unless\s*\(([^)]+)\)/g;while((Z=Y.exec($))!==null){let G=Z[1].trim(),W=Z.index,K=this.getLineNumber(W,$),_=this.getColumn(W,$);this.checkExpression(G,K,_)}let J=/@switch\s*\(([^)]+)\)/g;while((Z=J.exec($))!==null){let G=Z[1].trim(),W=Z.index,K=this.getLineNumber(W,$),_=this.getColumn(W,$);this.checkExpression(G,K,_)}}resolvePropertyAccess($){let X=$.split("."),Z=this.variables.get(X[0])||{kind:"primitive",value:"any"};for(let Q=1;Q<X.length;Q++){let Y=X[Q].replace(/\(\)$/,"");if(Z.kind==="object"&&Z.properties)if(Z.properties[Y])Z=Z.properties[Y];else if(!this.options.allowAny)return{kind:"primitive",value:"undefined"};else Z={kind:"primitive",value:"any"};else if(Z.kind==="array"&&Z.elementType)if(["length"].includes(Y))Z={kind:"primitive",value:"number"};else if(["map","filter","find","forEach","some","every","reduce"].includes(Y))Z={kind:"function",returnType:{kind:"primitive",value:"any"}};else if(["join"].includes(Y))Z={kind:"function",returnType:{kind:"primitive",value:"string"}};else Z={kind:"primitive",value:"any"};else if(Z.kind==="primitive"&&Z.value==="string")if(["length"].includes(Y))Z={kind:"primitive",value:"number"};else if(["toUpperCase","toLowerCase","trim","slice","substring"].includes(Y))Z={kind:"function",returnType:{kind:"primitive",value:"string"}};else if(["split"].includes(Y))Z={kind:"function",returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}};else Z={kind:"primitive",value:"any"};else Z={kind:"primitive",value:"any"}}return Z}isLiteral($){let X=$.trim();if(X.startsWith('"')&&X.endsWith('"')||X.startsWith("'")&&X.endsWith("'")||X.startsWith("`")&&X.endsWith("`"))return!0;if(/^-?\d+(\.\d+)?$/.test(X))return!0;if(X==="true"||X==="false")return!0;if(X==="null"||X==="undefined")return!0;return!1}extractObjectLiteral($){let X={},Z=$.slice(1,-1).trim();if(!Z)return X;let Q=this.splitByComma(Z);for(let Y of Q){let J=Y.indexOf(":");if(J>0){let G=Y.slice(0,J).trim(),W=Y.slice(J+1).trim();X[G]=W}}return X}splitByComma($){let X=[],Z="",Q=0,Y=null;for(let J=0;J<$.length;J++){let G=$[J],W=J>0?$[J-1]:"";if((G==='"'||G==="'"||G==="`")&&W!=="\\"){if(Y===G)Y=null;else if(!Y)Y=G}if(!Y){if(G==="{"||G==="["||G==="(")Q++;if(G==="}"||G==="]"||G===")")Q--;if(G===","&&Q===0){X.push(Z.trim()),Z="";continue}}Z+=G}if(Z.trim())X.push(Z.trim());return X}getLineNumber($,X){return((X||"").slice(0,$).match(/\n/g)||[]).length+1}getColumn($,X){let Q=X.slice(0,$).lastIndexOf(`
2905
- `);return $-Q}addError($,X,Z,Q,Y,J){this.errors.push({message:$,file:this.currentFile,line:X,column:Z,expression:Q,expected:Y,received:J,severity:"error"})}addWarning($,X,Z,Q,Y,J){let G={message:$,file:this.currentFile,line:X,column:Z,expression:Q,expected:Y,received:J,severity:"warning"};if(this.options.strict)this.errors.push(G);else this.warnings.push(G)}getResult(){return{valid:this.errors.length===0,errors:this.errors,warnings:this.warnings,variables:new Map(this.variables)}}addVariable($,X){this.variables.set($,X)}reset(){if(this.errors=[],this.warnings=[],this.variables.clear(),this.options.includeBuiltins)Object.entries(q7).forEach(([$,X])=>{this.variables.set($,X)})}}function V7($){return new A7($)}function KK($,X){return V7(X).checkFile($)}function _K($,X){return V7(X).checkTemplate($)}function UK($){let X=[];for(let Z of $.errors){if(X.push(`\x1B[31merror\x1B[0m: ${Z.message}`),X.push(` --> ${Z.file}:${Z.line}:${Z.column}`),Z.expression)X.push(" |"),X.push(` | ${Z.expression}`),X.push(" |");if(Z.expected&&Z.received)X.push(` expected: ${Z.expected}`),X.push(` received: ${Z.received}`);X.push("")}for(let Z of $.warnings){if(X.push(`\x1B[33mwarning\x1B[0m: ${Z.message}`),X.push(` --> ${Z.file}:${Z.line}:${Z.column}`),Z.expression)X.push(" |"),X.push(` | ${Z.expression}`),X.push(" |");X.push("")}if($.valid)X.push("\x1B[32m\u2713 No type errors found\x1B[0m");else X.push(`\x1B[31m\u2717 Found ${$.errors.length} error(s) and ${$.warnings.length} warning(s)\x1B[0m`);return X.join(`
2906
- `)}var D5=typeof window<"u"&&typeof document<"u";async function R5($,X,Z){if(!D5)return;try{let Q=$.getAttribute("data-island-id"),Y=document.querySelector(`script[data-island-props="${Q}"]`),J=Y?JSON.parse(Y.textContent||"{}"):{},G=await Z(),W=G.default||G.hydrate;if(typeof W!=="function"){console.error(`Island handler for "${X}" does not export a valid hydration function`);return}await W($,J),$.setAttribute("data-hydrated","true")}catch(Q){console.error(`Failed to hydrate island "${X}":`,Q)}}function LK($){if(!D5)return;let X=document.querySelectorAll("[data-island]"),Z=[];if(X.forEach((Q)=>{let Y=Q.getAttribute("data-island"),J=Q.getAttribute("data-priority")||"lazy";if(!Y||!$[Y]||Q.getAttribute("data-hydrated")==="true")return;if(J==="eager")R5(Q,Y,$[Y]);else Z.push([Q,Y])}),Z.length>0&&"IntersectionObserver"in window){let Q=new IntersectionObserver((Y)=>{Y.forEach((J)=>{if(J.isIntersecting){let G=J.target,W=G.getAttribute("data-island");if(W&&$[W]&&G.getAttribute("data-hydrated")!=="true")R5(G,W,$[W]),Q.unobserve(G)}})},{rootMargin:"200px",threshold:0});Z.forEach(([Y])=>{Q.observe(Y)})}else setTimeout(()=>{Z.forEach(([Q,Y])=>{if(Q.getAttribute("data-hydrated")!=="true")R5(Q,Y,$[Y])})},1000)}function FK($){if(!D5)return;Object.entries($).forEach(([X,Z])=>{try{let Y=Z.toString().match(/import\(['"](.+)['"]\)/);if(Y&&Y[1]){let J=document.createElement("link");J.rel="modulepreload",J.href=Y[1],J.setAttribute("data-island-module",X),document.head.appendChild(J)}}catch(Q){console.warn(`Failed to preload island handler for "${X}":`,Q)}})}var j1=typeof window<"u"&&typeof document<"u",T5={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999},z0=null,S0=0,h1=!1,w5=null,z1=null,g0=null;function M7($){if(!j1)return null;let X=document.getElementById("stx-loading-indicator");if(X)X.remove();let Z=document.createElement("div");Z.id="stx-loading-indicator";let Q=$.initialColor?`linear-gradient(to right, ${$.initialColor}, ${$.color})`:$.color;Z.style.cssText=`
2905
+ `);return $-Q}addError($,X,Z,Q,Y,J){this.errors.push({message:$,file:this.currentFile,line:X,column:Z,expression:Q,expected:Y,received:J,severity:"error"})}addWarning($,X,Z,Q,Y,J){let G={message:$,file:this.currentFile,line:X,column:Z,expression:Q,expected:Y,received:J,severity:"warning"};if(this.options.strict)this.errors.push(G);else this.warnings.push(G)}getResult(){return{valid:this.errors.length===0,errors:this.errors,warnings:this.warnings,variables:new Map(this.variables)}}addVariable($,X){this.variables.set($,X)}reset(){if(this.errors=[],this.warnings=[],this.variables.clear(),this.options.includeBuiltins)Object.entries(w7).forEach(([$,X])=>{this.variables.set($,X)})}}function C7($){return new T7($)}function IK($,X){return C7(X).checkFile($)}function RK($,X){return C7(X).checkTemplate($)}function DK($){let X=[];for(let Z of $.errors){if(X.push(`\x1B[31merror\x1B[0m: ${Z.message}`),X.push(` --> ${Z.file}:${Z.line}:${Z.column}`),Z.expression)X.push(" |"),X.push(` | ${Z.expression}`),X.push(" |");if(Z.expected&&Z.received)X.push(` expected: ${Z.expected}`),X.push(` received: ${Z.received}`);X.push("")}for(let Z of $.warnings){if(X.push(`\x1B[33mwarning\x1B[0m: ${Z.message}`),X.push(` --> ${Z.file}:${Z.line}:${Z.column}`),Z.expression)X.push(" |"),X.push(` | ${Z.expression}`),X.push(" |");X.push("")}if($.valid)X.push("\x1B[32m\u2713 No type errors found\x1B[0m");else X.push(`\x1B[31m\u2717 Found ${$.errors.length} error(s) and ${$.warnings.length} warning(s)\x1B[0m`);return X.join(`
2906
+ `)}var C5=typeof window<"u"&&typeof document<"u";async function T5($,X,Z){if(!C5)return;try{let Q=$.getAttribute("data-island-id"),Y=document.querySelector(`script[data-island-props="${Q}"]`),J=Y?JSON.parse(Y.textContent||"{}"):{},G=await Z(),W=G.default||G.hydrate;if(typeof W!=="function"){console.error(`Island handler for "${X}" does not export a valid hydration function`);return}await W($,J),$.setAttribute("data-hydrated","true")}catch(Q){console.error(`Failed to hydrate island "${X}":`,Q)}}function TK($){if(!C5)return;let X=document.querySelectorAll("[data-island]"),Z=[];if(X.forEach((Q)=>{let Y=Q.getAttribute("data-island"),J=Q.getAttribute("data-priority")||"lazy";if(!Y||!$[Y]||Q.getAttribute("data-hydrated")==="true")return;if(J==="eager")T5(Q,Y,$[Y]);else Z.push([Q,Y])}),Z.length>0&&"IntersectionObserver"in window){let Q=new IntersectionObserver((Y)=>{Y.forEach((J)=>{if(J.isIntersecting){let G=J.target,W=G.getAttribute("data-island");if(W&&$[W]&&G.getAttribute("data-hydrated")!=="true")T5(G,W,$[W]),Q.unobserve(G)}})},{rootMargin:"200px",threshold:0});Z.forEach(([Y])=>{Q.observe(Y)})}else setTimeout(()=>{Z.forEach(([Q,Y])=>{if(Q.getAttribute("data-hydrated")!=="true")T5(Q,Y,$[Y])})},1000)}function CK($){if(!C5)return;Object.entries($).forEach(([X,Z])=>{try{let Y=Z.toString().match(/import\(['"](.+)['"]\)/);if(Y&&Y[1]){let J=document.createElement("link");J.rel="modulepreload",J.href=Y[1],J.setAttribute("data-island-module",X),document.head.appendChild(J)}}catch(Q){console.warn(`Failed to preload island handler for "${X}":`,Q)}})}var H1=typeof window<"u"&&typeof document<"u",x5={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999},z0=null,S0=0,u1=!1,k5=null,j1=null,g0=null;function k7($){if(!H1)return null;let X=document.getElementById("stx-loading-indicator");if(X)X.remove();let Z=document.createElement("div");Z.id="stx-loading-indicator";let Q=$.initialColor?`linear-gradient(to right, ${$.initialColor}, ${$.color})`:$.color;Z.style.cssText=`
2907
2907
  position: fixed;
2908
2908
  top: 0;
2909
2909
  left: 0;
@@ -2934,7 +2934,7 @@ ${D instanceof Error?D.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An err
2934
2934
  0% { transform: translateX(-100%); }
2935
2935
  100% { transform: translateX(100%); }
2936
2936
  }
2937
- `,document.head.appendChild(J)}return document.body.appendChild(Z),Z}function A$($,X){if(!j1||!z0)return;if(S0=Math.min(Math.max($,0),100),w5)cancelAnimationFrame(w5);w5=requestAnimationFrame(()=>{if(!z0)return;z0.style.opacity=S0>0?"1":"0",z0.style.transform=`scaleX(${S0/100})`})}function DZ($){if(!j1)return;if(h1=!0,S0=0,!z0)z0=M7($);if(z1)clearTimeout(z1);if(g0)clearInterval(g0);A$(10,$),g0=setInterval(()=>{if(!h1)return;let X=90-S0,Z=Math.max(0.5,X*0.1);if(S0<90)A$(S0+Z,$)},$.throttle)}function wZ($){if(!j1)return;if(h1=!1,g0)clearInterval(g0),g0=null;A$(100,$),z1=setTimeout(()=>{if(z0)z0.style.opacity="0";setTimeout(()=>{if(S0=0,z0)z0.style.transform="scaleX(0)"},300)},200)}function TZ(){if(!j1)return;if(h1=!1,S0=0,g0)clearInterval(g0),g0=null;if(z1)clearTimeout(z1),z1=null;if(z0)z0.style.opacity="0",z0.style.transform="scaleX(0)"}function CZ($){let X={...T5,...$};return{start:()=>DZ(X),set:(Z)=>A$(Z,X),finish:()=>wZ(X),clear:()=>TZ(),get state(){return{isLoading:h1,progress:S0,error:!1}}}}var X1=null;function jK($){if(!j1)return;if(X1)X1(),X1=null;let X={...T5,...$},Z=CZ(X);z0=M7(X);let Q=!1,Y=(U)=>{let z=U.target.closest("a");if(!z)return;let j=z.getAttribute("href");if(!j)return;if(j.startsWith("http")||j.startsWith("#")||j.startsWith("mailto:")||j.startsWith("tel:")||z.target==="_blank"||z.hasAttribute("download"))return;Q=!0,Z.start()},J=()=>{if(!Q)Z.start(),Q=!0},G=()=>{if(Q||X.autoFinish)Z.finish(),Q=!1};document.addEventListener("click",Y),window.addEventListener("popstate",J),window.addEventListener("load",G);let W=window.fetch,K=0,_=async function(...U){let F=typeof U[0]==="string"?U[0]:U[0].url,z=F.includes("/api/")||F.startsWith("/api");if(z){if(K++,K===1&&!Q)Z.start()}try{return await W.apply(this,U)}finally{if(z){if(K--,K===0&&!Q)Z.finish()}}};window.fetch=_,X1=()=>{if(document.removeEventListener("click",Y),window.removeEventListener("popstate",J),window.removeEventListener("load",G),window.fetch===_)window.fetch=W}}function HK(){if(X1)X1(),X1=null}function OK($){let X={...T5,...$},Z=X.initialColor?`linear-gradient(to right, ${X.initialColor}, ${X.color})`:X.color;return`
2937
+ `,document.head.appendChild(J)}return document.body.appendChild(Z),Z}function E$($,X){if(!H1||!z0)return;if(S0=Math.min(Math.max($,0),100),k5)cancelAnimationFrame(k5);k5=requestAnimationFrame(()=>{if(!z0)return;z0.style.opacity=S0>0?"1":"0",z0.style.transform=`scaleX(${S0/100})`})}function gZ($){if(!H1)return;if(u1=!0,S0=0,!z0)z0=k7($);if(j1)clearTimeout(j1);if(g0)clearInterval(g0);E$(10,$),g0=setInterval(()=>{if(!u1)return;let X=90-S0,Z=Math.max(0.5,X*0.1);if(S0<90)E$(S0+Z,$)},$.throttle)}function fZ($){if(!H1)return;if(u1=!1,g0)clearInterval(g0),g0=null;E$(100,$),j1=setTimeout(()=>{if(z0)z0.style.opacity="0";setTimeout(()=>{if(S0=0,z0)z0.style.transform="scaleX(0)"},300)},200)}function hZ(){if(!H1)return;if(u1=!1,S0=0,g0)clearInterval(g0),g0=null;if(j1)clearTimeout(j1),j1=null;if(z0)z0.style.opacity="0",z0.style.transform="scaleX(0)"}function dZ($){let X={...x5,...$};return{start:()=>gZ(X),set:(Z)=>E$(Z,X),finish:()=>fZ(X),clear:()=>hZ(),get state(){return{isLoading:u1,progress:S0,error:!1}}}}var X1=null;function xK($){if(!H1)return;if(X1)X1(),X1=null;let X={...x5,...$},Z=dZ(X);z0=k7(X);let Q=!1,Y=(U)=>{let z=U.target.closest("a");if(!z)return;let j=z.getAttribute("href");if(!j)return;if(j.startsWith("http")||j.startsWith("#")||j.startsWith("mailto:")||j.startsWith("tel:")||z.target==="_blank"||z.hasAttribute("download"))return;Q=!0,Z.start()},J=()=>{if(!Q)Z.start(),Q=!0},G=()=>{if(Q||X.autoFinish)Z.finish(),Q=!1};document.addEventListener("click",Y),window.addEventListener("popstate",J),window.addEventListener("load",G);let W=window.fetch,K=0,_=async function(...U){let F=typeof U[0]==="string"?U[0]:U[0].url,z=F.includes("/api/")||F.startsWith("/api");if(z){if(K++,K===1&&!Q)Z.start()}try{return await W.apply(this,U)}finally{if(z){if(K--,K===0&&!Q)Z.finish()}}};window.fetch=_,X1=()=>{if(document.removeEventListener("click",Y),window.removeEventListener("popstate",J),window.removeEventListener("load",G),window.fetch===_)window.fetch=W}}function SK(){if(X1)X1(),X1=null}function PK($){let X={...x5,...$},Z=X.initialColor?`linear-gradient(to right, ${X.initialColor}, ${X.color})`:X.color;return`
2938
2938
  <div id="stx-loading-indicator" style="
2939
2939
  position: fixed;
2940
2940
  top: 0;
@@ -3028,11 +3028,11 @@ ${D instanceof Error?D.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An err
3028
3028
  window.addEventListener('load', function() { window.stxLoading.finish(); });
3029
3029
  })();
3030
3030
  </script>
3031
- `}function qK($,X){let Z=[],Q=`${X}=`;for(let Y=0;Y<$.length;Y++){let J=$[Y];if(J.startsWith(Q)){let G=J.slice(Q.length);if(G)Z.push(G);continue}if(J===X){let G=$[Y+1];if(G!==void 0&&!G.startsWith("-"))Z.push(G),Y++}}return Z}class E7{instances=new Map;componentsByFile=new Map;stateSnapshots=new Map;config;constructor($={}){this.config={preserveState:$.preserveState??!0,maxStateAge:$.maxStateAge??30000,errorRecovery:$.errorRecovery??!0,verbose:$.verbose??!1,serializeState:$.serializeState??this.defaultSerializeState.bind(this),deserializeState:$.deserializeState??this.defaultDeserializeState.bind(this)}}register($){if(this.instances.set($.id,$),!this.componentsByFile.has($.name))this.componentsByFile.set($.name,new Set);if(this.componentsByFile.get($.name).add($.id),this.config.verbose)console.log(`[HMR] Registered component: ${$.name} (${$.id})`)}unregister($){let X=this.instances.get($);if(!X)return;if(this.componentsByFile.get(X.name)?.delete($),this.componentsByFile.get(X.name)?.size===0)this.componentsByFile.delete(X.name);if(this.stateSnapshots.delete($),X.cleanup?.(),this.instances.delete($),this.config.verbose)console.log(`[HMR] Unregistered component: ${X.name} (${$})`)}getInstancesByFile($){let X=this.componentsByFile.get($)||new Set;return Array.from(X).map((Z)=>this.instances.get(Z)).filter(Boolean)}getInstance($){return this.instances.get($)}captureState($){let X=this.instances.get($);if(!X||!this.config.preserveState)return;let Z=this.config.serializeState(X);if(this.stateSnapshots.set($,Z),this.config.verbose)console.log(`[HMR] Captured state for: ${X.name}`)}restoreState($){let X=this.instances.get($),Z=this.stateSnapshots.get($);if(!X||!Z||!this.config.preserveState)return!1;if(Date.now()-Z.timestamp>this.config.maxStateAge){if(this.stateSnapshots.delete($),this.config.verbose)console.log(`[HMR] State expired for: ${X.name}`);return!1}try{if(this.config.deserializeState(Z,X),this.config.verbose)console.log(`[HMR] Restored state for: ${X.name}`);return!0}catch(Q){return console.error(`[HMR] Failed to restore state for ${X.name}:`,Q),!1}}defaultSerializeState($){let X={},Z={};if($.element)$.element.querySelectorAll("[data-stx-ref]").forEach((Y)=>{let J=Y.getAttribute("data-stx-ref"),G=Y.getAttribute("data-stx-value");if(J&&G)try{X[J]=JSON.parse(G)}catch{X[J]=G}});return{refs:X,reactiveObjects:Z,custom:$.state?.custom||{},timestamp:Date.now()}}defaultDeserializeState($,X){if(X.element)Object.entries($.refs).forEach(([Z,Q])=>{let Y=X.element.querySelector(`[data-stx-ref="${Z}"]`);if(Y)Y.setAttribute("data-stx-value",JSON.stringify(Q)),Y.dispatchEvent(new CustomEvent("stx:state-restored",{detail:{name:Z,value:Q},bubbles:!0}))});X.state={...$,timestamp:Date.now()}}getAllInstances(){return Array.from(this.instances.values())}clear(){for(let $ of this.instances.values())$.cleanup?.();this.instances.clear(),this.componentsByFile.clear(),this.stateSnapshots.clear()}}class I7{registry;config;pendingUpdates=new Map;updateQueue=Promise.resolve();constructor($={}){this.config={preserveState:$.preserveState??!0,maxStateAge:$.maxStateAge??30000,errorRecovery:$.errorRecovery??!0,verbose:$.verbose??!1,serializeState:$.serializeState??(()=>({refs:{},reactiveObjects:{},custom:{},timestamp:Date.now()})),deserializeState:$.deserializeState??(()=>{})},this.registry=new E7(this.config)}register($){this.registry.register($)}unregister($){this.registry.unregister($)}async handleUpdate($){return this.updateQueue=this.updateQueue.then(()=>this.processUpdate($)),this.updateQueue}async processUpdate($){let X=this.registry.getInstancesByFile($.file);if(X.length===0){if(this.config.verbose)console.log(`[HMR] No instances found for: ${$.file}`);return}if(this.config.verbose)console.log(`[HMR] Updating ${X.length} instance(s) of: ${$.file}`);for(let Z of X)await this.updateInstance(Z,$);if(typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hmr-update",{detail:{file:$.file,count:X.length}}))}async updateInstance($,X){this.registry.captureState($.id);let Z=!1,Q=$.element?.innerHTML||"";try{if($.element?.dispatchEvent(new CustomEvent("stx:before-hmr-update",{bubbles:!0})),$.cleanup?.(),X.type==="style")await this.updateStyles($,X);else await this.updateComponent($,X);let Y=this.registry.restoreState($.id);if(!Y&&$.setup)await $.setup();$.element?.dispatchEvent(new CustomEvent("stx:after-hmr-update",{detail:{stateRestored:Y},bubbles:!0}))}catch(Y){if(Z=!0,console.error(`[HMR] Error updating component ${$.name}:`,Y),this.config.errorRecovery){if($.element&&Q)$.element.innerHTML=Q,console.log(`[HMR] Recovered previous state for: ${$.name}`);$.element?.dispatchEvent(new CustomEvent("stx:hmr-error",{detail:{error:Y},bubbles:!0}))}}if(!Z&&this.config.verbose)console.log(`[HMR] Successfully updated: ${$.name}`)}async updateComponent($,X){if(!$.element)return;let{html:Z,script:Q}=this.parseComponentCode(X.code);if(Z)$.element.innerHTML=Z;if(Q)await this.executeScript(Q,$);if($.render)$.element.innerHTML=$.render();this.reinitializeInteractivity($)}async updateStyles($,X){if(!$.element)return;let Z=X.code.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(!Z)return;let Q=Z[1],Y=$.id,J=document.querySelector(`style[data-stx-component="${Y}"]`);if(!J)J=document.createElement("style"),J.setAttribute("data-stx-component",Y),document.head.appendChild(J);if(J.textContent=Q,this.config.verbose)console.log(`[HMR] Updated styles for: ${$.name}`)}parseComponentCode($){let X=$,Z="",Q="",Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)Z=Y[1],X=X.replace(Y[0],"");let J=$.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(J)Q=J[1],X=X.replace(J[0],"");return{html:X.trim(),script:Z.trim(),style:Q.trim()}}async executeScript($,X){try{let Z={element:X.element,props:X.props,...typeof window<"u"?window.stx:{}},Q=`
3031
+ `}function yK($,X){let Z=[],Q=`${X}=`;for(let Y=0;Y<$.length;Y++){let J=$[Y];if(J.startsWith(Q)){let G=J.slice(Q.length);if(G)Z.push(G);continue}if(J===X){let G=$[Y+1];if(G!==void 0&&!G.startsWith("-"))Z.push(G),Y++}}return Z}class x7{instances=new Map;componentsByFile=new Map;stateSnapshots=new Map;config;constructor($={}){this.config={preserveState:$.preserveState??!0,maxStateAge:$.maxStateAge??30000,errorRecovery:$.errorRecovery??!0,verbose:$.verbose??!1,serializeState:$.serializeState??this.defaultSerializeState.bind(this),deserializeState:$.deserializeState??this.defaultDeserializeState.bind(this)}}register($){if(this.instances.set($.id,$),!this.componentsByFile.has($.name))this.componentsByFile.set($.name,new Set);if(this.componentsByFile.get($.name).add($.id),this.config.verbose)console.log(`[HMR] Registered component: ${$.name} (${$.id})`)}unregister($){let X=this.instances.get($);if(!X)return;if(this.componentsByFile.get(X.name)?.delete($),this.componentsByFile.get(X.name)?.size===0)this.componentsByFile.delete(X.name);if(this.stateSnapshots.delete($),X.cleanup?.(),this.instances.delete($),this.config.verbose)console.log(`[HMR] Unregistered component: ${X.name} (${$})`)}getInstancesByFile($){let X=this.componentsByFile.get($)||new Set;return Array.from(X).map((Z)=>this.instances.get(Z)).filter(Boolean)}getInstance($){return this.instances.get($)}captureState($){let X=this.instances.get($);if(!X||!this.config.preserveState)return;let Z=this.config.serializeState(X);if(this.stateSnapshots.set($,Z),this.config.verbose)console.log(`[HMR] Captured state for: ${X.name}`)}restoreState($){let X=this.instances.get($),Z=this.stateSnapshots.get($);if(!X||!Z||!this.config.preserveState)return!1;if(Date.now()-Z.timestamp>this.config.maxStateAge){if(this.stateSnapshots.delete($),this.config.verbose)console.log(`[HMR] State expired for: ${X.name}`);return!1}try{if(this.config.deserializeState(Z,X),this.config.verbose)console.log(`[HMR] Restored state for: ${X.name}`);return!0}catch(Q){return console.error(`[HMR] Failed to restore state for ${X.name}:`,Q),!1}}defaultSerializeState($){let X={},Z={};if($.element)$.element.querySelectorAll("[data-stx-ref]").forEach((Y)=>{let J=Y.getAttribute("data-stx-ref"),G=Y.getAttribute("data-stx-value");if(J&&G)try{X[J]=JSON.parse(G)}catch{X[J]=G}});return{refs:X,reactiveObjects:Z,custom:$.state?.custom||{},timestamp:Date.now()}}defaultDeserializeState($,X){if(X.element)Object.entries($.refs).forEach(([Z,Q])=>{let Y=X.element.querySelector(`[data-stx-ref="${Z}"]`);if(Y)Y.setAttribute("data-stx-value",JSON.stringify(Q)),Y.dispatchEvent(new CustomEvent("stx:state-restored",{detail:{name:Z,value:Q},bubbles:!0}))});X.state={...$,timestamp:Date.now()}}getAllInstances(){return Array.from(this.instances.values())}clear(){for(let $ of this.instances.values())$.cleanup?.();this.instances.clear(),this.componentsByFile.clear(),this.stateSnapshots.clear()}}class S7{registry;config;pendingUpdates=new Map;updateQueue=Promise.resolve();constructor($={}){this.config={preserveState:$.preserveState??!0,maxStateAge:$.maxStateAge??30000,errorRecovery:$.errorRecovery??!0,verbose:$.verbose??!1,serializeState:$.serializeState??(()=>({refs:{},reactiveObjects:{},custom:{},timestamp:Date.now()})),deserializeState:$.deserializeState??(()=>{})},this.registry=new x7(this.config)}register($){this.registry.register($)}unregister($){this.registry.unregister($)}async handleUpdate($){return this.updateQueue=this.updateQueue.then(()=>this.processUpdate($)),this.updateQueue}async processUpdate($){let X=this.registry.getInstancesByFile($.file);if(X.length===0){if(this.config.verbose)console.log(`[HMR] No instances found for: ${$.file}`);return}if(this.config.verbose)console.log(`[HMR] Updating ${X.length} instance(s) of: ${$.file}`);for(let Z of X)await this.updateInstance(Z,$);if(typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hmr-update",{detail:{file:$.file,count:X.length}}))}async updateInstance($,X){this.registry.captureState($.id);let Z=!1,Q=$.element?.innerHTML||"";try{if($.element?.dispatchEvent(new CustomEvent("stx:before-hmr-update",{bubbles:!0})),$.cleanup?.(),X.type==="style")await this.updateStyles($,X);else await this.updateComponent($,X);let Y=this.registry.restoreState($.id);if(!Y&&$.setup)await $.setup();$.element?.dispatchEvent(new CustomEvent("stx:after-hmr-update",{detail:{stateRestored:Y},bubbles:!0}))}catch(Y){if(Z=!0,console.error(`[HMR] Error updating component ${$.name}:`,Y),this.config.errorRecovery){if($.element&&Q)$.element.innerHTML=Q,console.log(`[HMR] Recovered previous state for: ${$.name}`);$.element?.dispatchEvent(new CustomEvent("stx:hmr-error",{detail:{error:Y},bubbles:!0}))}}if(!Z&&this.config.verbose)console.log(`[HMR] Successfully updated: ${$.name}`)}async updateComponent($,X){if(!$.element)return;let{html:Z,script:Q}=this.parseComponentCode(X.code);if(Z)$.element.innerHTML=Z;if(Q)await this.executeScript(Q,$);if($.render)$.element.innerHTML=$.render();this.reinitializeInteractivity($)}async updateStyles($,X){if(!$.element)return;let Z=X.code.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(!Z)return;let Q=Z[1],Y=$.id,J=document.querySelector(`style[data-stx-component="${Y}"]`);if(!J)J=document.createElement("style"),J.setAttribute("data-stx-component",Y),document.head.appendChild(J);if(J.textContent=Q,this.config.verbose)console.log(`[HMR] Updated styles for: ${$.name}`)}parseComponentCode($){let X=$,Z="",Q="",Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)Z=Y[1],X=X.replace(Y[0],"");let J=$.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(J)Q=J[1],X=X.replace(J[0],"");return{html:X.trim(),script:Z.trim(),style:Q.trim()}}async executeScript($,X){try{let Z={element:X.element,props:X.props,...typeof window<"u"?window.stx:{}},Q=`
3032
3032
  return (async function() {
3033
3033
  ${$}
3034
3034
  })()
3035
- `;await Function(...Object.keys(Z),Q)(...Object.values(Z))}catch(Z){throw console.error("[HMR] Script execution error:",Z),Z}}reinitializeInteractivity($){if(!$.element)return;$.element.querySelectorAll("[data-stx-events]").forEach((Z)=>{let Q=Z.getAttribute("data-stx-events");if(!Q)return;try{let Y=JSON.parse(Q);for(let[J,G]of Object.entries(Y))if(typeof window<"u"&&window.stx?.[G])Z.addEventListener(J,window.stx[G])}catch{}}),$.element.dispatchEvent(new CustomEvent("stx:reinitialize",{bubbles:!0}))}getRegistry(){return this.registry}async refresh($){let X=this.registry.getInstancesByFile($);for(let Z of X)if(Z.render&&Z.element)this.registry.captureState(Z.id),Z.element.innerHTML=Z.render(),this.registry.restoreState(Z.id),this.reinitializeInteractivity(Z)}}function VK($){return`
3035
+ `;await Function(...Object.keys(Z),Q)(...Object.values(Z))}catch(Z){throw console.error("[HMR] Script execution error:",Z),Z}}reinitializeInteractivity($){if(!$.element)return;$.element.querySelectorAll("[data-stx-events]").forEach((Z)=>{let Q=Z.getAttribute("data-stx-events");if(!Q)return;try{let Y=JSON.parse(Q);for(let[J,G]of Object.entries(Y))if(typeof window<"u"&&window.stx?.[G])Z.addEventListener(J,window.stx[G])}catch{}}),$.element.dispatchEvent(new CustomEvent("stx:reinitialize",{bubbles:!0}))}getRegistry(){return this.registry}async refresh($){let X=this.registry.getInstancesByFile($);for(let Z of X)if(Z.render&&Z.element)this.registry.captureState(Z.id),Z.element.innerHTML=Z.render(),this.registry.restoreState(Z.id),this.reinitializeInteractivity(Z)}}function gK($){return`
3036
3036
  <script data-stx-hmr-client>
3037
3037
  (function() {
3038
3038
  'use strict';
@@ -3259,7 +3259,7 @@ else {
3259
3259
  };
3260
3260
  })();
3261
3261
  </script>
3262
- `}function MK($,X,Z,Q){return`
3262
+ `}function fK($,X,Z,Q){return`
3263
3263
  <div data-stx-component="${$}" data-stx-name="${X}">
3264
3264
  ${Z}
3265
3265
  </div>
@@ -3299,8 +3299,8 @@ else {
3299
3299
  observer.observe(document.body, { childList: true, subtree: true });
3300
3300
  })();
3301
3301
  </script>
3302
- `}var H1=null;function EK($){if(!H1)H1=new I7($);return H1}function IK(){if(H1)H1.getRegistry().clear(),H1=null}function kZ($){let X={refs:$.refs||{},reactive:$.reactive||{},props:$.props||{},routeParams:$.routeParams||{},stores:$.stores||{},meta:$.meta||{},timestamp:Date.now()};return X.checksum=D7(X),JSON.stringify(X).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/'/g,"\\u0027")}function D7($){let X=JSON.stringify({refs:Object.keys($.refs||{}),reactive:Object.keys($.reactive||{}),props:Object.keys($.props||{})}),Z=0;for(let Q=0;Q<X.length;Q++){let Y=X.charCodeAt(Q);Z=(Z<<5)-Z+Y,Z=Z&Z}return Math.abs(Z).toString(36)}function xZ($){return`<script id="__STX_STATE__" type="application/json">${kZ($)}</script>`}function wK($){if($.length===0)return"";return`data-stx-events='${JSON.stringify($)}'`}function SZ(){if(typeof window>"u")return null;let $=document.getElementById("__STX_STATE__");if(!$)return null;try{let X=JSON.parse($.textContent||"{}");if(X.checksum){if(D7(X)!==X.checksum)console.warn("[Hydration] State checksum mismatch - state may be corrupted")}return X}catch(X){return console.error("[Hydration] Failed to parse state:",X),null}}class w7{state=null;options;root=null;isHydrated=!1;pendingComponents=new Map;hydratedComponents=new Set;constructor($={}){this.options={root:$.root||"#app",strict:$.strict??!1,onHydrating:$.onHydrating||(()=>{}),onHydrated:$.onHydrated||(()=>{}),onError:$.onError||console.error,performance:$.performance??!1,timeout:$.timeout??1e4}}async hydrate(){if(typeof window>"u")return;if(this.isHydrated)return;let $=this.options.performance?performance.now():0;try{this.root=typeof this.options.root==="string"?document.querySelector(this.options.root)||document.body:this.options.root,this.state=SZ(),this.options.onHydrating(),this.root.classList.add("stx-hydrating");let X=new Promise((Z,Q)=>{setTimeout(()=>Q(Error("Hydration timeout")),this.options.timeout)});if(await Promise.race([this.runHydration(),X]),this.isHydrated=!0,this.root.classList.remove("stx-hydrating"),this.root.classList.add("stx-hydrated"),this.options.performance){let Z=performance.now()-$;console.log(`[Hydration] Completed in ${Z.toFixed(2)}ms`)}this.options.onHydrated(),window.dispatchEvent(new CustomEvent("stx:hydrated"))}catch(X){this.root?.classList.remove("stx-hydrating"),this.root?.classList.add("stx-hydration-error"),this.options.onError(X),window.dispatchEvent(new CustomEvent("stx:hydration-error",{detail:{error:X}}))}}async runHydration(){if(!this.root)return;this.restoreGlobalState(),await this.hydrateComponents(),this.bindEventHandlers(),this.initializeReactiveBindings(),this.setupRouterIntegration()}restoreGlobalState(){if(!this.state)return;let $=window.stx;if(!$)return;if(this.state.routeParams&&$.setRouteParams)$.setRouteParams(this.state.routeParams);if(this.state.stores&&$.registerStore)Object.entries(this.state.stores).forEach(([X,Z])=>{$.registerStore(X,Z)});window.dispatchEvent(new CustomEvent("stx:state-restored",{detail:this.state}))}async hydrateComponents(){if(!this.root)return;let $=this.root.querySelectorAll("[data-stx-component]");for(let X of Array.from($)){let Z=X.getAttribute("data-stx-component"),Q=X.getAttribute("data-stx-name")||Z,Y=X.getAttribute("data-stx-hydrate")||"eager",J=X.getAttribute("data-stx-props");if(!Z)continue;let G={id:Z,name:Q||Z,strategy:Y,props:J?JSON.parse(J):{},events:[]};switch(this.pendingComponents.set(Z,G),G.strategy){case"eager":await this.hydrateComponent(X,G);break;case"lazy":case"visible":this.setupVisibleHydration(X,G);break;case"idle":this.setupIdleHydration(X,G);break;case"interaction":this.setupInteractionHydration(X,G);break}}}async hydrateComponent($,X){if(this.hydratedComponents.has(X.id))return;try{let Z=this.state?.refs[X.id]||this.state?.reactive[X.id]||{};this.restoreComponentState($,Z),this.bindComponentEvents($),this.initializeComponentReactivity($,X),this.hydratedComponents.add(X.id),$.classList.add("stx-hydrated"),$.setAttribute("data-hydrated","true"),$.dispatchEvent(new CustomEvent("stx:component-hydrated",{detail:{id:X.id,name:X.name},bubbles:!0}))}catch(Z){if(console.error(`[Hydration] Failed to hydrate component ${X.id}:`,Z),$.classList.add("stx-hydration-error"),this.options.strict)throw Z}}restoreComponentState($,X){if(!X||typeof X!=="object")return;$.querySelectorAll("[data-stx-bind]").forEach((Q)=>{let Y=Q.getAttribute("data-stx-bind");if(!Y||!X[Y])return;let J=X[Y];if(Q instanceof HTMLInputElement)if(Q.type==="checkbox"||Q.type==="radio")Q.checked=Boolean(J);else Q.value=String(J);else if(Q instanceof HTMLSelectElement)Q.value=String(J);else if(Q instanceof HTMLTextAreaElement)Q.value=String(J);else Q.textContent=String(J)})}setupVisibleHydration($,X){if(!("IntersectionObserver"in window)){this.hydrateComponent($,X);return}let Z=new IntersectionObserver((Q)=>{Q.forEach((Y)=>{if(Y.isIntersecting)Z.disconnect(),this.hydrateComponent($,X)})},{rootMargin:"100px",threshold:0});Z.observe($)}setupIdleHydration($,X){let Z=()=>this.hydrateComponent($,X);if("requestIdleCallback"in window)window.requestIdleCallback(Z,{timeout:2000});else setTimeout(Z,200)}setupInteractionHydration($,X){let Z=["mouseenter","touchstart","focusin"],Q=()=>{Z.forEach((Y)=>$.removeEventListener(Y,Q)),this.hydrateComponent($,X)};Z.forEach((Y)=>{$.addEventListener(Y,Q,{once:!0,passive:!0})})}bindEventHandlers(){if(!this.root)return;this.root.querySelectorAll("[data-stx-events]").forEach((X)=>this.bindElementEvents(X)),this.bindDirectiveEvents()}bindElementEvents($){let X=$.getAttribute("data-stx-events");if(!X)return;try{JSON.parse(X).forEach((Q)=>{this.bindSingleEvent($,Q)})}catch(Z){console.error("[Hydration] Failed to parse events:",Z)}}bindDirectiveEvents(){if(!this.root)return;["click","submit","input","change","focus","blur","keydown","keyup","keypress","mouseenter","mouseleave","touchstart","touchend","scroll","resize"].forEach((X)=>{let Z=`data-stx-on-${X}`;this.root.querySelectorAll(`[${Z}]`).forEach((Y)=>{let J=Y.getAttribute(Z);if(!J)return;this.bindSingleEvent(Y,{type:X,handler:J,modifiers:this.parseModifiers(Y,X)})})})}parseModifiers($,X){let Z=[],Q=$.getAttribute(`data-stx-${X}-modifiers`);if(Q)Z.push(...Q.split(",").map((Y)=>Y.trim()));return Z}bindSingleEvent($,X){let Z=this.resolveHandler(X.handler);if(!Z){console.warn(`[Hydration] Handler not found: ${X.handler}`);return}let Q=(G)=>{if(X.modifiers?.includes("prevent")||X.preventDefault)G.preventDefault();if(X.modifiers?.includes("stop")||X.stopPropagation)G.stopPropagation();try{Z.call($,G)}catch(W){console.error("[Hydration] Event handler error:",W)}},Y={};if(X.modifiers?.includes("once"))Y.once=!0;let J=X.modifiers??[];if(R7(X.type,{passive:J.includes("passive"),prevent:J.includes("prevent")||X.preventDefault,nonpassive:J.includes("nonpassive")}))Y.passive=!0;if(X.modifiers?.includes("capture"))Y.capture=!0;$.addEventListener(X.type,Q,Y)}resolveHandler($){let X=window.stx;if(X&&X[$])return X[$];if(window[$])return window[$];try{if($.match(/^\w+\+\+$/)||$.match(/^\w+--$/)){let Y=$.replace(/[+-]+$/,"");return()=>{if(X&&X[Y]){if(typeof X[Y].value<"u")if($.includes("++"))X[Y].value++;else X[Y].value--}}}let Z=$.match(/^(\w+)\s*=\s*(.+)$/);if(Z){let[,Y,J]=Z;return()=>{if(X&&X[Y]){let G=Function(`return ${J}`)();if(typeof X[Y].value<"u")X[Y].value=G}}}let Q=$.match(/^(\w+)\((.*)\)$/);if(Q){let[,Y,J]=Q;return(G)=>{let W=X?.[Y]||window[Y];if(W){let K=J?Function("$event",`return [${J}]`)(G):[];W(...K)}}}return(Y)=>{Function("$event","stx",$)(Y,X)}}catch{return null}}bindComponentEvents($){$.querySelectorAll("[data-stx-events]").forEach((Z)=>{this.bindElementEvents(Z)})}initializeComponentReactivity($,X){if(!window.stx)return;$.querySelectorAll("[data-stx-reactive]").forEach((Y)=>{let J=Y.getAttribute("data-stx-reactive");if(!J)return;this.setupReactiveBinding(Y,J)})}initializeReactiveBindings(){if(!this.root)return;this.getTextNodesWithExpressions(this.root).forEach(({node:Z,expressions:Q})=>{Q.forEach((Y)=>{this.setupTextNodeBinding(Z,Y)})}),this.root.querySelectorAll("[data-stx-bind-attrs]").forEach((Z)=>{let Q=Z.getAttribute("data-stx-bind-attrs");if(!Q)return;try{let Y=JSON.parse(Q);Object.entries(Y).forEach(([J,G])=>{this.setupAttributeBinding(Z,J,G)})}catch{}})}getTextNodesWithExpressions($){let X=[],Z=document.createTreeWalker($,NodeFilter.SHOW_TEXT),Q;while(Q=Z.nextNode()){let J=(Q.textContent||"").match(/\{\{\s*([^}]+)\s*\}\}/g);if(J)X.push({node:Q,expressions:J.map((G)=>G.replace(/\{\{\s*|\s*\}\}/g,""))})}return X}setupTextNodeBinding($,X){let Z=window.stx;if(!Z)return;let Q=$.textContent||"",Y=()=>{try{let G=Function("stx",`with(stx) { return ${X} }`)(Z);$.textContent=Q.replace(new RegExp(`\\{\\{\\s*${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\}\\}`),String(G))}catch{}};Y();let J=X.match(/^(\w+)(\.value)?$/);if(J&&Z[J[1]]?.subscribe)Z[J[1]].subscribe(Y)}setupAttributeBinding($,X,Z){let Q=window.stx;if(!Q)return;let Y=()=>{try{let G=Function("stx",`with(stx) { return ${Z} }`)(Q);if(typeof G==="boolean")if(G)$.setAttribute(X,"");else $.removeAttribute(X);else $.setAttribute(X,String(G))}catch{}};Y();let J=Z.match(/^(\w+)(\.value)?$/);if(J&&Q[J[1]]?.subscribe)Q[J[1]].subscribe(Y)}setupReactiveBinding($,X){let Z=window.stx;if(!Z)return;let Q=()=>{try{let J=Function("stx",`with(stx) { return ${X} }`)(Z);$.textContent=String(J)}catch{}};Q();let Y=X.match(/^(\w+)(\.value)?$/);if(Y&&Z[Y[1]]?.subscribe)Z[Y[1]].subscribe(Q)}setupRouterIntegration(){window.addEventListener("stx:navigate",($)=>{let{url:X}=$.detail||{};if(X){if(window.stx?.setRouteParams){let Q=new URL(X,window.location.origin)}}}),window.addEventListener("stx:load",()=>{this.hydrateComponents(),this.bindEventHandlers()})}get hydrated(){return this.isHydrated}getState(){return this.state}async hydrateById($){let X=this.pendingComponents.get($),Z=document.querySelector(`[data-stx-component="${$}"]`);if(X&&Z)await this.hydrateComponent(Z,X)}}function TK($){return`
3303
- ${$?xZ($):""}
3302
+ `}var O1=null;function hK($){if(!O1)O1=new S7($);return O1}function dK(){if(O1)O1.getRegistry().clear(),O1=null}function uZ($){let X={refs:$.refs||{},reactive:$.reactive||{},props:$.props||{},routeParams:$.routeParams||{},stores:$.stores||{},meta:$.meta||{},timestamp:Date.now()};return X.checksum=b7(X),JSON.stringify(X).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/'/g,"\\u0027")}function b7($){let X=JSON.stringify({refs:Object.keys($.refs||{}),reactive:Object.keys($.reactive||{}),props:Object.keys($.props||{})}),Z=0;for(let Q=0;Q<X.length;Q++){let Y=X.charCodeAt(Q);Z=(Z<<5)-Z+Y,Z=Z&Z}return Math.abs(Z).toString(36)}function mZ($){return`<script id="__STX_STATE__" type="application/json">${uZ($)}</script>`}function pK($){if($.length===0)return"";return`data-stx-events='${JSON.stringify($)}'`}function pZ(){if(typeof window>"u")return null;let $=document.getElementById("__STX_STATE__");if(!$)return null;try{let X=JSON.parse($.textContent||"{}");if(X.checksum){if(b7(X)!==X.checksum)console.warn("[Hydration] State checksum mismatch - state may be corrupted")}return X}catch(X){return console.error("[Hydration] Failed to parse state:",X),null}}class y7{state=null;options;root=null;isHydrated=!1;pendingComponents=new Map;hydratedComponents=new Set;constructor($={}){this.options={root:$.root||"#app",strict:$.strict??!1,onHydrating:$.onHydrating||(()=>{}),onHydrated:$.onHydrated||(()=>{}),onError:$.onError||console.error,performance:$.performance??!1,timeout:$.timeout??1e4}}async hydrate(){if(typeof window>"u")return;if(this.isHydrated)return;let $=this.options.performance?performance.now():0;try{this.root=typeof this.options.root==="string"?document.querySelector(this.options.root)||document.body:this.options.root,this.state=pZ(),this.options.onHydrating(),this.root.classList.add("stx-hydrating");let X=new Promise((Z,Q)=>{setTimeout(()=>Q(Error("Hydration timeout")),this.options.timeout)});if(await Promise.race([this.runHydration(),X]),this.isHydrated=!0,this.root.classList.remove("stx-hydrating"),this.root.classList.add("stx-hydrated"),this.options.performance){let Z=performance.now()-$;console.log(`[Hydration] Completed in ${Z.toFixed(2)}ms`)}this.options.onHydrated(),window.dispatchEvent(new CustomEvent("stx:hydrated"))}catch(X){this.root?.classList.remove("stx-hydrating"),this.root?.classList.add("stx-hydration-error"),this.options.onError(X),window.dispatchEvent(new CustomEvent("stx:hydration-error",{detail:{error:X}}))}}async runHydration(){if(!this.root)return;this.restoreGlobalState(),await this.hydrateComponents(),this.bindEventHandlers(),this.initializeReactiveBindings(),this.setupRouterIntegration()}restoreGlobalState(){if(!this.state)return;let $=window.stx;if(!$)return;if(this.state.routeParams&&$.setRouteParams)$.setRouteParams(this.state.routeParams);if(this.state.stores&&$.registerStore)Object.entries(this.state.stores).forEach(([X,Z])=>{$.registerStore(X,Z)});window.dispatchEvent(new CustomEvent("stx:state-restored",{detail:this.state}))}async hydrateComponents(){if(!this.root)return;let $=this.root.querySelectorAll("[data-stx-component]");for(let X of Array.from($)){let Z=X.getAttribute("data-stx-component"),Q=X.getAttribute("data-stx-name")||Z,Y=X.getAttribute("data-stx-hydrate")||"eager",J=X.getAttribute("data-stx-props");if(!Z)continue;let G={id:Z,name:Q||Z,strategy:Y,props:J?JSON.parse(J):{},events:[]};switch(this.pendingComponents.set(Z,G),G.strategy){case"eager":await this.hydrateComponent(X,G);break;case"lazy":case"visible":this.setupVisibleHydration(X,G);break;case"idle":this.setupIdleHydration(X,G);break;case"interaction":this.setupInteractionHydration(X,G);break}}}async hydrateComponent($,X){if(this.hydratedComponents.has(X.id))return;try{let Z=this.state?.refs[X.id]||this.state?.reactive[X.id]||{};this.restoreComponentState($,Z),this.bindComponentEvents($),this.initializeComponentReactivity($,X),this.hydratedComponents.add(X.id),$.classList.add("stx-hydrated"),$.setAttribute("data-hydrated","true"),$.dispatchEvent(new CustomEvent("stx:component-hydrated",{detail:{id:X.id,name:X.name},bubbles:!0}))}catch(Z){if(console.error(`[Hydration] Failed to hydrate component ${X.id}:`,Z),$.classList.add("stx-hydration-error"),this.options.strict)throw Z}}restoreComponentState($,X){if(!X||typeof X!=="object")return;$.querySelectorAll("[data-stx-bind]").forEach((Q)=>{let Y=Q.getAttribute("data-stx-bind");if(!Y||!X[Y])return;let J=X[Y];if(Q instanceof HTMLInputElement)if(Q.type==="checkbox"||Q.type==="radio")Q.checked=Boolean(J);else Q.value=String(J);else if(Q instanceof HTMLSelectElement)Q.value=String(J);else if(Q instanceof HTMLTextAreaElement)Q.value=String(J);else Q.textContent=String(J)})}setupVisibleHydration($,X){if(!("IntersectionObserver"in window)){this.hydrateComponent($,X);return}let Z=new IntersectionObserver((Q)=>{Q.forEach((Y)=>{if(Y.isIntersecting)Z.disconnect(),this.hydrateComponent($,X)})},{rootMargin:"100px",threshold:0});Z.observe($)}setupIdleHydration($,X){let Z=()=>this.hydrateComponent($,X);if("requestIdleCallback"in window)window.requestIdleCallback(Z,{timeout:2000});else setTimeout(Z,200)}setupInteractionHydration($,X){let Z=["mouseenter","touchstart","focusin"],Q=()=>{Z.forEach((Y)=>$.removeEventListener(Y,Q)),this.hydrateComponent($,X)};Z.forEach((Y)=>{$.addEventListener(Y,Q,{once:!0,passive:!0})})}bindEventHandlers(){if(!this.root)return;this.root.querySelectorAll("[data-stx-events]").forEach((X)=>this.bindElementEvents(X)),this.bindDirectiveEvents()}bindElementEvents($){let X=$.getAttribute("data-stx-events");if(!X)return;try{JSON.parse(X).forEach((Q)=>{this.bindSingleEvent($,Q)})}catch(Z){console.error("[Hydration] Failed to parse events:",Z)}}bindDirectiveEvents(){if(!this.root)return;["click","submit","input","change","focus","blur","keydown","keyup","keypress","mouseenter","mouseleave","touchstart","touchend","scroll","resize"].forEach((X)=>{let Z=`data-stx-on-${X}`;this.root.querySelectorAll(`[${Z}]`).forEach((Y)=>{let J=Y.getAttribute(Z);if(!J)return;this.bindSingleEvent(Y,{type:X,handler:J,modifiers:this.parseModifiers(Y,X)})})})}parseModifiers($,X){let Z=[],Q=$.getAttribute(`data-stx-${X}-modifiers`);if(Q)Z.push(...Q.split(",").map((Y)=>Y.trim()));return Z}bindSingleEvent($,X){let Z=this.resolveHandler(X.handler);if(!Z){console.warn(`[Hydration] Handler not found: ${X.handler}`);return}let Q=(G)=>{if(X.modifiers?.includes("prevent")||X.preventDefault)G.preventDefault();if(X.modifiers?.includes("stop")||X.stopPropagation)G.stopPropagation();try{Z.call($,G)}catch(W){console.error("[Hydration] Event handler error:",W)}},Y={};if(X.modifiers?.includes("once"))Y.once=!0;let J=X.modifiers??[];if(P7(X.type,{passive:J.includes("passive"),prevent:J.includes("prevent")||X.preventDefault,nonpassive:J.includes("nonpassive")}))Y.passive=!0;if(X.modifiers?.includes("capture"))Y.capture=!0;$.addEventListener(X.type,Q,Y)}resolveHandler($){let X=window.stx;if(X&&X[$])return X[$];if(window[$])return window[$];try{if($.match(/^\w+\+\+$/)||$.match(/^\w+--$/)){let Y=$.replace(/[+-]+$/,"");return()=>{if(X&&X[Y]){if(typeof X[Y].value<"u")if($.includes("++"))X[Y].value++;else X[Y].value--}}}let Z=$.match(/^(\w+)\s*=\s*(.+)$/);if(Z){let[,Y,J]=Z;return()=>{if(X&&X[Y]){let G=Function(`return ${J}`)();if(typeof X[Y].value<"u")X[Y].value=G}}}let Q=$.match(/^(\w+)\((.*)\)$/);if(Q){let[,Y,J]=Q;return(G)=>{let W=X?.[Y]||window[Y];if(W){let K=J?Function("$event",`return [${J}]`)(G):[];W(...K)}}}return(Y)=>{Function("$event","stx",$)(Y,X)}}catch{return null}}bindComponentEvents($){$.querySelectorAll("[data-stx-events]").forEach((Z)=>{this.bindElementEvents(Z)})}initializeComponentReactivity($,X){if(!window.stx)return;$.querySelectorAll("[data-stx-reactive]").forEach((Y)=>{let J=Y.getAttribute("data-stx-reactive");if(!J)return;this.setupReactiveBinding(Y,J)})}initializeReactiveBindings(){if(!this.root)return;this.getTextNodesWithExpressions(this.root).forEach(({node:Z,expressions:Q})=>{Q.forEach((Y)=>{this.setupTextNodeBinding(Z,Y)})}),this.root.querySelectorAll("[data-stx-bind-attrs]").forEach((Z)=>{let Q=Z.getAttribute("data-stx-bind-attrs");if(!Q)return;try{let Y=JSON.parse(Q);Object.entries(Y).forEach(([J,G])=>{this.setupAttributeBinding(Z,J,G)})}catch{}})}getTextNodesWithExpressions($){let X=[],Z=document.createTreeWalker($,NodeFilter.SHOW_TEXT),Q;while(Q=Z.nextNode()){let J=(Q.textContent||"").match(/\{\{\s*([^}]+)\s*\}\}/g);if(J)X.push({node:Q,expressions:J.map((G)=>G.replace(/\{\{\s*|\s*\}\}/g,""))})}return X}setupTextNodeBinding($,X){let Z=window.stx;if(!Z)return;let Q=$.textContent||"",Y=()=>{try{let G=Function("stx",`with(stx) { return ${X} }`)(Z);$.textContent=Q.replace(new RegExp(`\\{\\{\\s*${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\}\\}`),String(G))}catch{}};Y();let J=X.match(/^(\w+)(\.value)?$/);if(J&&Z[J[1]]?.subscribe)Z[J[1]].subscribe(Y)}setupAttributeBinding($,X,Z){let Q=window.stx;if(!Q)return;let Y=()=>{try{let G=Function("stx",`with(stx) { return ${Z} }`)(Q);if(typeof G==="boolean")if(G)$.setAttribute(X,"");else $.removeAttribute(X);else $.setAttribute(X,String(G))}catch{}};Y();let J=Z.match(/^(\w+)(\.value)?$/);if(J&&Q[J[1]]?.subscribe)Q[J[1]].subscribe(Y)}setupReactiveBinding($,X){let Z=window.stx;if(!Z)return;let Q=()=>{try{let J=Function("stx",`with(stx) { return ${X} }`)(Z);$.textContent=String(J)}catch{}};Q();let Y=X.match(/^(\w+)(\.value)?$/);if(Y&&Z[Y[1]]?.subscribe)Z[Y[1]].subscribe(Q)}setupRouterIntegration(){window.addEventListener("stx:navigate",($)=>{let{url:X}=$.detail||{};if(X){if(window.stx?.setRouteParams){let Q=new URL(X,window.location.origin)}}}),window.addEventListener("stx:load",()=>{this.hydrateComponents(),this.bindEventHandlers()})}get hydrated(){return this.isHydrated}getState(){return this.state}async hydrateById($){let X=this.pendingComponents.get($),Z=document.querySelector(`[data-stx-component="${$}"]`);if(X&&Z)await this.hydrateComponent(Z,X)}}function cK($){return`
3303
+ ${$?mZ($):""}
3304
3304
  <script data-stx-hydration-runtime>
3305
3305
  (function() {
3306
3306
  'use strict';
@@ -3397,7 +3397,7 @@ else {
3397
3397
  }
3398
3398
  })();
3399
3399
  </script>
3400
- `}var C5=null;function PZ($){if(!C5)C5=new w7($);return C5}async function CK($){await PZ($).hydrate()}function kK(){return`
3400
+ `}var S5=null;function cZ($){if(!S5)S5=new y7($);return S5}async function lK($){await cZ($).hydrate()}function iK(){return`
3401
3401
  <style data-stx-hydration-styles>
3402
3402
  /* Pre-hydration state */
3403
3403
  [data-stx-component]:not(.stx-hydrated) {
@@ -3430,9 +3430,9 @@ else {
3430
3430
  }
3431
3431
  }
3432
3432
  </style>
3433
- `}import T7 from"path";k6();class bZ{store=new Map;async get($){let X=this.store.get($);if(!X||X.expires<=Date.now()){if(X)this.store.delete($);return null}return{...X.data}}async set($,X,Z){this.store.set($,{data:{...X},expires:Date.now()+Z*1000})}async delete($){this.store.delete($)}}function yZ($,X){for(let Z of $.getSetCookie())X.append("Set-Cookie",Z);$.forEach((Z,Q)=>{if(Q.toLowerCase()!=="set-cookie")X.set(Q,Z)})}async function hK($,X={},Z={}){let Q=Z.viewsDir||"./views",Y=Z.layoutsDir||"./layouts",J=!$.includes("<")&&!$.includes("@"),G,W;if(J){if(W=T7.resolve(Q,$),!W.endsWith(".stx"))W+=".stx";if(!await Bun.file(W).exists())return new Response(`Template not found: ${$}`,{status:500});G=await Bun.file(W).text()}else G=$,W="inline-template.stx";let K={...X,props:X,__filename:W,__dirname:T7.dirname(W)};if(Z.ctx)K.csrf_token=Z.ctx.csrfToken,K.csrf_field=`<input type="hidden" name="_token" value="${Z.ctx.csrfToken}">`,K.old=Z.ctx.old,K.errors=Z.ctx.errors,K.session=Z.ctx.session,K.user=Z.ctx.user(),K.isAuthenticated=Z.ctx.isAuthenticated();let _=G.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(_){let H=_[1];G=G.replace(/<script\s+server\b[^>]*>[\s\S]*?<\/script>/gi,""),await E0(H,K,W)}let U={layoutsDir:Y,...Z.stxOptions},z=await I0(G,K,W,U,new Set),j=new Headers({"Content-Type":"text/html; charset=utf-8"});if(Z.ctx)yZ(Z.ctx.responseHeaders,j);return new Response(z,{headers:j})}var d1={stores:new Map,subscriptions:new Map};function vZ($,X){d1.stores.set($,X)}function k7($){return d1.stores.get($)}function gZ($){return d1.stores.has($)}function fZ(){return Array.from(d1.stores.keys())}var O1=new Map;function C7($){if($==="memory")return{getItem:(X)=>O1.get(X)??null,setItem:(X,Z)=>O1.set(X,Z),removeItem:(X)=>O1.delete(X)};if(typeof window>"u")return{getItem:(X)=>O1.get(X)??null,setItem:(X,Z)=>O1.set(X,Z),removeItem:(X)=>O1.delete(X)};return $==="local"?window.localStorage:window.sessionStorage}function hZ($,X){let Z={};for(let Q of X){let Y=Q.split("."),J=$,G=Z,W=!0;for(let K=0;K<Y.length-1;K++){let _=Y[K];if(J&&typeof J==="object"&&_ in J){if(J=J[_],!(_ in G))G[_]={};G=G[_]}else{W=!1;break}}if(W&&J&&typeof J==="object"){let K=Y[Y.length-1];if(K in J)G[K]=J[K]}}return Z}function x7($,X={}){let{name:Z,persist:Q,devtools:Y=!1,middleware:J=[],equals:G=(O,N)=>O===N}=X,W=$,K=new Set,_=null;if(Q){let O=C7(Q.storage||"local"),N=Q.key||`stx-store:${Z||"unnamed"}`,V=Q.deserialize||JSON.parse;try{let M=O.getItem(N);if(M){let q=V(M);if(Q.paths&&typeof q==="object"&&q!==null)W={...$,...q};else W=q}}catch{}}let U=(O)=>{if(!Q)return;let N=C7(Q.storage||"local"),V=Q.key||`stx-store:${Z||"unnamed"}`,M=Q.serialize||JSON.stringify,q=Q.paths&&typeof O==="object"&&O!==null?hZ(O,Q.paths):O;if(Q.debounce){if(_)clearTimeout(_);_=setTimeout(()=>{N.setItem(V,M(q))},Q.debounce)}else N.setItem(V,M(q))},F=(O,N)=>{for(let V of K)try{V(O,N)}catch(M){console.error("[stx-store] Subscriber error:",M)}},z=Y?(O,N)=>{if($7(Z||"unnamed",O,W,N),typeof window<"u")window.__STX_DEVTOOLS__?.onStoreChange?.(Z||"unnamed",O,N)}:()=>{},j=(O)=>{let N=W;if(!G(O,N))W=O,U(O),F(O,N),z("set",O)},H=j,L={get:()=>W,set:(O)=>{if(typeof O==="function")H(O(W));else H(O)},subscribe:(O)=>{return K.add(O),()=>{K.delete(O)}},update:(O)=>{if(typeof W!=="object"||W===null)throw Error("update() can only be used with object stores");let N=typeof O==="function"?O(W):O;L.set({...W,...N})},reset:()=>{L.set($),z("reset",$)},name:Z,destroy:()=>{if(K.clear(),_)clearTimeout(_);if(Z)d1.stores.delete(Z)}};for(let O of J.reverse())H=O(j,()=>W,L)(H);if(Z){if(vZ(Z,L),Y)e6(Z,W??{},{},[])}return L}function dZ($){let X=typeof $==="string"?k7($):$;if(!X)throw Error(`Store "${$}" not found`);return X.get()}function uZ($,X,Z){if(typeof X==="function"){if(typeof window<"u"&&window.stx?.defineStore)return window.stx.defineStore($,X,Z);return X()}let Q=X,{state:Y,getters:J={},actions:G={},persist:W,devtools:K=!0}=Q,_=typeof Y==="function"?Y():Y,U=W===!0?{storage:"local",key:`stx-store:${$}`}:W||void 0,F=x7(_,{name:$,persist:U,devtools:K}),z=new Proxy({},{get(j,H){let L=String(H);if(L==="$state")return F.get();if(L==="$subscribe")return F.subscribe;if(L==="$reset")return F.reset;if(L==="$patch")return(N)=>{if(typeof N==="function"){let M={...F.get()};N(M),F.set(M)}else F.update(N)};if(L==="_store")return F;if(L==="$id")return $;if(L in J)return J[L](F.get());if(L in G)return(...N)=>{return G[L].apply(z,N)};let O=F.get();if(O&&typeof O==="object"&&L in O)return O[L];return},set(j,H,L){let O=String(H);if(O.startsWith("$")||O==="_store")return!1;let N=F.get();if(N&&typeof N==="object")return F.set({...N,[O]:L}),!0;return!1},has(j,H){let L=String(H),O=F.get();return L.startsWith("$")||L==="_store"||L in J||L in G||O&&typeof O==="object"&&L in O},ownKeys(){let j=F.get();return[...j&&typeof j==="object"?Object.keys(j):[],...Object.keys(J),...Object.keys(G),"$state","$subscribe","$reset","$patch","$id"]},getOwnPropertyDescriptor(j,H){return{enumerable:!0,configurable:!0,get:()=>this.get(j,H,z)}}});return mZ.set($,z),z}var mZ=new Map;function pZ($){if(typeof window>"u")return;let X=window;X.__STX_STORES__=X.__STX_STORES__||{};for(let[Z,Q]of Object.entries($))X.__STX_STORES__[Z]=Q;window.dispatchEvent(new CustomEvent("stx:stores-ready",{detail:Object.keys($)}))}function l($,X={}){let Z=[];for(let[Y,J]of Object.entries(X)){if(J===void 0||J===null)continue;if(Array.isArray(J))Z.push(`${Y}=${encodeURIComponent(J.join(","))}`);else if(typeof J==="boolean"){if(J)Z.push(`${Y}=true`)}else Z.push(`${Y}=${encodeURIComponent(String(J))}`)}if(Z.length===0)return $;let Q=$.includes("?")?"&":"?";return`${$}${Q}${Z.join("&")}`}function S7($){let X=$.indexOf("?");if(X===-1)return{src:$,params:{}};let Z=$.slice(0,X),Q=$.slice(X+1),Y={};for(let J of Q.split("&")){let[G,W]=J.split("="),K=W?decodeURIComponent(W):"";if(K==="true")Y[G]=!0;else if(K==="false")Y[G]=!1;else if(/^-?\d+$/.test(K))Y[G]=Number.parseInt(K,10);else if(/^-?\d+\.\d+$/.test(K))Y[G]=Number.parseFloat(K);else if(K.includes(","))Y[G]=K.split(",");else Y[G]=K}return{src:Z,params:Y}}function k5(...$){let X={};for(let Z of $)if(Z)Object.assign(X,Z);return X}function P7($,X,Z,Q){let Y={w:X};if(Z)Y.h=Z;if(Q)Y.fit=Q;return l($,Y)}function b7($,X,Z,Q="center"){return l($,{w:X,h:Z,fit:"crop",crop:Q})}function y7($,X,Z="center"){return l($,{w:X,h:X,fit:"crop",crop:Z})}function v7($,X,Z){return l($,{w:X,h:Z,fit:"max"})}function g7($,X,Z){return l($,{w:X,h:Z,fit:"crop"})}function f7($,X){return l($,{blur:Math.min(2000,Math.max(0,X))})}function h7($,X){return l($,{sharp:Math.min(100,Math.max(0,X))})}function d7($){return l($,{sat:-100})}function u7($,X=100){return l($,{sepia:Math.min(100,Math.max(0,X))})}function m7($){return l($,{invert:!0})}function p7($,X){return l($,{bri:Math.min(100,Math.max(-100,X))})}function c7($,X){return l($,{con:Math.min(100,Math.max(-100,X))})}function l7($,X){return l($,{sat:Math.min(100,Math.max(-100,X))})}function i7($,X){return l($,{rot:(X%360+360)%360})}function a7($){return l($,{flip:"h"})}function s7($){return l($,{flip:"v"})}function r7($,X,Z){let Q={fm:X};if(Z!==void 0)Q.q=Z;return l($,Q)}function n7($,X){return l($,{q:Math.min(100,Math.max(1,X))})}function o7($,X=["format","compress"]){return l($,{auto:X})}function t7($,X,Z={}){return l($,{mark:X,markx:Z.x,marky:Z.y,markalpha:Z.alpha,markscale:Z.scale,markalign:Z.align})}var x5={web:{fm:"webp",q:80,auto:["format","compress"]},highQuality:{q:95},thumb:{w:150,h:150,fit:"crop",crop:"center"},avatar:{w:200,h:200,fit:"crop",crop:"faces"},social:{w:1200,h:630,fit:"crop"},preview:{w:400,q:70},placeholder:{w:20,blur:200,q:20}};function e7($,X,Z){return l($,k5(x5[X],Z))}function $8($,X,Z){return X.map((Q)=>l($,{...Z,w:Q}))}function X8($,X,Z=[1,2,3],Q){return Z.map((Y)=>l($,{...Q,w:Math.round(X*Y),dpr:Y}))}function Z8($){let X=[];if($.w!==void 0&&($.w<1||$.w>16383))X.push("Width must be between 1 and 16383");if($.h!==void 0&&($.h<1||$.h>16383))X.push("Height must be between 1 and 16383");if($.q!==void 0&&($.q<1||$.q>100))X.push("Quality must be between 1 and 100");if($.blur!==void 0&&($.blur<0||$.blur>2000))X.push("Blur must be between 0 and 2000");if($.rot!==void 0&&($.rot<0||$.rot>359))X.push("Rotation must be between 0 and 359");if($.dpr!==void 0&&($.dpr<1||$.dpr>5))X.push("DPR must be between 1 and 5");return{valid:X.length===0,errors:X}}function Q8($){let X={...$};if(X.w!==void 0)X.w=Math.min(16383,Math.max(1,X.w));if(X.h!==void 0)X.h=Math.min(16383,Math.max(1,X.h));if(X.q!==void 0)X.q=Math.min(100,Math.max(1,X.q));if(X.blur!==void 0)X.blur=Math.min(2000,Math.max(0,X.blur));if(X.rot!==void 0)X.rot=(X.rot%360+360)%360;if(X.dpr!==void 0)X.dpr=Math.min(5,Math.max(1,X.dpr));return X}function J8($){let{endpoint:X,accept:Z,maxSize:Q,maxFiles:Y=1,fieldName:J="file",preview:G=!1,dropzone:W=!0,multiple:K=!1,autoUpload:_=!0,showProgress:U=!0,disabled:F=!1,placeholder:z="Drop files here or click to select",label:j}=$,H=$.class||"",L=$.style||"",O=$.id||`stx-upload-${Math.random().toString(36).slice(2,8)}`,N=Array.isArray(Z)?Z.join(","):Z,V=`
3433
+ `}import v7 from"path";f6();class lZ{store=new Map;async get($){let X=this.store.get($);if(!X||X.expires<=Date.now()){if(X)this.store.delete($);return null}return{...X.data}}async set($,X,Z){this.store.set($,{data:{...X},expires:Date.now()+Z*1000})}async delete($){this.store.delete($)}}function iZ($,X){for(let Z of $.getSetCookie())X.append("Set-Cookie",Z);$.forEach((Z,Q)=>{if(Q.toLowerCase()!=="set-cookie")X.set(Q,Z)})}async function X9($,X={},Z={}){let Q=Z.viewsDir||"./views",Y=Z.layoutsDir||"./layouts",J=!$.includes("<")&&!$.includes("@"),G,W;if(J){if(W=v7.resolve(Q,$),!W.endsWith(".stx"))W+=".stx";if(!await Bun.file(W).exists())return new Response(`Template not found: ${$}`,{status:500});G=await Bun.file(W).text()}else G=$,W="inline-template.stx";let K={...X,props:X,__filename:W,__dirname:v7.dirname(W)};if(Z.ctx)K.csrf_token=Z.ctx.csrfToken,K.csrf_field=`<input type="hidden" name="_token" value="${Z.ctx.csrfToken}">`,K.old=Z.ctx.old,K.errors=Z.ctx.errors,K.session=Z.ctx.session,K.user=Z.ctx.user(),K.isAuthenticated=Z.ctx.isAuthenticated();let _=G.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(_){let H=_[1];G=G.replace(/<script\s+server\b[^>]*>[\s\S]*?<\/script>/gi,""),await E0(H,K,W)}let U={layoutsDir:Y,...Z.stxOptions},z=await I0(G,K,W,U,new Set),j=new Headers({"Content-Type":"text/html; charset=utf-8"});if(Z.ctx)iZ(Z.ctx.responseHeaders,j);return new Response(z,{headers:j})}var m1={stores:new Map,subscriptions:new Map};function aZ($,X){m1.stores.set($,X)}function f7($){return m1.stores.get($)}function sZ($){return m1.stores.has($)}function rZ(){return Array.from(m1.stores.keys())}var N1=new Map;function g7($){if($==="memory")return{getItem:(X)=>N1.get(X)??null,setItem:(X,Z)=>N1.set(X,Z),removeItem:(X)=>N1.delete(X)};if(typeof window>"u")return{getItem:(X)=>N1.get(X)??null,setItem:(X,Z)=>N1.set(X,Z),removeItem:(X)=>N1.delete(X)};return $==="local"?window.localStorage:window.sessionStorage}function nZ($,X){let Z={};for(let Q of X){let Y=Q.split("."),J=$,G=Z,W=!0;for(let K=0;K<Y.length-1;K++){let _=Y[K];if(J&&typeof J==="object"&&_ in J){if(J=J[_],!(_ in G))G[_]={};G=G[_]}else{W=!1;break}}if(W&&J&&typeof J==="object"){let K=Y[Y.length-1];if(K in J)G[K]=J[K]}}return Z}function h7($,X={}){let{name:Z,persist:Q,devtools:Y=!1,middleware:J=[],equals:G=(O,N)=>O===N}=X,W=$,K=new Set,_=null;if(Q){let O=g7(Q.storage||"local"),N=Q.key||`stx-store:${Z||"unnamed"}`,V=Q.deserialize||JSON.parse;try{let M=O.getItem(N);if(M){let A=V(M);if(Q.paths&&typeof A==="object"&&A!==null)W={...$,...A};else W=A}}catch{}}let U=(O)=>{if(!Q)return;let N=g7(Q.storage||"local"),V=Q.key||`stx-store:${Z||"unnamed"}`,M=Q.serialize||JSON.stringify,A=Q.paths&&typeof O==="object"&&O!==null?nZ(O,Q.paths):O;if(Q.debounce){if(_)clearTimeout(_);_=setTimeout(()=>{N.setItem(V,M(A))},Q.debounce)}else N.setItem(V,M(A))},F=(O,N)=>{for(let V of K)try{V(O,N)}catch(M){console.error("[stx-store] Subscriber error:",M)}},z=Y?(O,N)=>{if(K7(Z||"unnamed",O,W,N),typeof window<"u")window.__STX_DEVTOOLS__?.onStoreChange?.(Z||"unnamed",O,N)}:()=>{},j=(O)=>{let N=W;if(!G(O,N))W=O,U(O),F(O,N),z("set",O)},H=j,L={get:()=>W,set:(O)=>{if(typeof O==="function")H(O(W));else H(O)},subscribe:(O)=>{return K.add(O),()=>{K.delete(O)}},update:(O)=>{if(typeof W!=="object"||W===null)throw Error("update() can only be used with object stores");let N=typeof O==="function"?O(W):O;L.set({...W,...N})},reset:()=>{L.set($),z("reset",$)},name:Z,destroy:()=>{if(K.clear(),_)clearTimeout(_);if(Z)m1.stores.delete(Z)}};for(let O of J.reverse())H=O(j,()=>W,L)(H);if(Z){if(aZ(Z,L),Y)W7(Z,W??{},{},[])}return L}function oZ($){let X=typeof $==="string"?f7($):$;if(!X)throw Error(`Store "${$}" not found`);return X.get()}function tZ($,X,Z){if(typeof X==="function"){if(typeof window<"u"&&window.stx?.defineStore)return window.stx.defineStore($,X,Z);return X()}let Q=X,{state:Y,getters:J={},actions:G={},persist:W,devtools:K=!0}=Q,_=typeof Y==="function"?Y():Y,U=W===!0?{storage:"local",key:`stx-store:${$}`}:W||void 0,F=h7(_,{name:$,persist:U,devtools:K}),z=new Proxy({},{get(j,H){let L=String(H);if(L==="$state")return F.get();if(L==="$subscribe")return F.subscribe;if(L==="$reset")return F.reset;if(L==="$patch")return(N)=>{if(typeof N==="function"){let M={...F.get()};N(M),F.set(M)}else F.update(N)};if(L==="_store")return F;if(L==="$id")return $;if(L in J)return J[L](F.get());if(L in G)return(...N)=>{return G[L].apply(z,N)};let O=F.get();if(O&&typeof O==="object"&&L in O)return O[L];return},set(j,H,L){let O=String(H);if(O.startsWith("$")||O==="_store")return!1;let N=F.get();if(N&&typeof N==="object")return F.set({...N,[O]:L}),!0;return!1},has(j,H){let L=String(H),O=F.get();return L.startsWith("$")||L==="_store"||L in J||L in G||O&&typeof O==="object"&&L in O},ownKeys(){let j=F.get();return[...j&&typeof j==="object"?Object.keys(j):[],...Object.keys(J),...Object.keys(G),"$state","$subscribe","$reset","$patch","$id"]},getOwnPropertyDescriptor(j,H){return{enumerable:!0,configurable:!0,get:()=>this.get(j,H,z)}}});return eZ.set($,z),z}var eZ=new Map;function $Q($){if(typeof window>"u")return;let X=window;X.__STX_STORES__=X.__STX_STORES__||{};for(let[Z,Q]of Object.entries($))X.__STX_STORES__[Z]=Q;window.dispatchEvent(new CustomEvent("stx:stores-ready",{detail:Object.keys($)}))}function l($,X={}){let Z=[];for(let[Y,J]of Object.entries(X)){if(J===void 0||J===null)continue;if(Array.isArray(J))Z.push(`${Y}=${encodeURIComponent(J.join(","))}`);else if(typeof J==="boolean"){if(J)Z.push(`${Y}=true`)}else Z.push(`${Y}=${encodeURIComponent(String(J))}`)}if(Z.length===0)return $;let Q=$.includes("?")?"&":"?";return`${$}${Q}${Z.join("&")}`}function d7($){let X=$.indexOf("?");if(X===-1)return{src:$,params:{}};let Z=$.slice(0,X),Q=$.slice(X+1),Y={};for(let J of Q.split("&")){let[G,W]=J.split("="),K=W?decodeURIComponent(W):"";if(K==="true")Y[G]=!0;else if(K==="false")Y[G]=!1;else if(/^-?\d+$/.test(K))Y[G]=Number.parseInt(K,10);else if(/^-?\d+\.\d+$/.test(K))Y[G]=Number.parseFloat(K);else if(K.includes(","))Y[G]=K.split(",");else Y[G]=K}return{src:Z,params:Y}}function P5(...$){let X={};for(let Z of $)if(Z)Object.assign(X,Z);return X}function u7($,X,Z,Q){let Y={w:X};if(Z)Y.h=Z;if(Q)Y.fit=Q;return l($,Y)}function m7($,X,Z,Q="center"){return l($,{w:X,h:Z,fit:"crop",crop:Q})}function p7($,X,Z="center"){return l($,{w:X,h:X,fit:"crop",crop:Z})}function c7($,X,Z){return l($,{w:X,h:Z,fit:"max"})}function l7($,X,Z){return l($,{w:X,h:Z,fit:"crop"})}function i7($,X){return l($,{blur:Math.min(2000,Math.max(0,X))})}function a7($,X){return l($,{sharp:Math.min(100,Math.max(0,X))})}function s7($){return l($,{sat:-100})}function r7($,X=100){return l($,{sepia:Math.min(100,Math.max(0,X))})}function n7($){return l($,{invert:!0})}function o7($,X){return l($,{bri:Math.min(100,Math.max(-100,X))})}function t7($,X){return l($,{con:Math.min(100,Math.max(-100,X))})}function e7($,X){return l($,{sat:Math.min(100,Math.max(-100,X))})}function $8($,X){return l($,{rot:(X%360+360)%360})}function X8($){return l($,{flip:"h"})}function Z8($){return l($,{flip:"v"})}function Q8($,X,Z){let Q={fm:X};if(Z!==void 0)Q.q=Z;return l($,Q)}function Y8($,X){return l($,{q:Math.min(100,Math.max(1,X))})}function J8($,X=["format","compress"]){return l($,{auto:X})}function G8($,X,Z={}){return l($,{mark:X,markx:Z.x,marky:Z.y,markalpha:Z.alpha,markscale:Z.scale,markalign:Z.align})}var b5={web:{fm:"webp",q:80,auto:["format","compress"]},highQuality:{q:95},thumb:{w:150,h:150,fit:"crop",crop:"center"},avatar:{w:200,h:200,fit:"crop",crop:"faces"},social:{w:1200,h:630,fit:"crop"},preview:{w:400,q:70},placeholder:{w:20,blur:200,q:20}};function W8($,X,Z){return l($,P5(b5[X],Z))}function K8($,X,Z){return X.map((Q)=>l($,{...Z,w:Q}))}function _8($,X,Z=[1,2,3],Q){return Z.map((Y)=>l($,{...Q,w:Math.round(X*Y),dpr:Y}))}function U8($){let X=[];if($.w!==void 0&&($.w<1||$.w>16383))X.push("Width must be between 1 and 16383");if($.h!==void 0&&($.h<1||$.h>16383))X.push("Height must be between 1 and 16383");if($.q!==void 0&&($.q<1||$.q>100))X.push("Quality must be between 1 and 100");if($.blur!==void 0&&($.blur<0||$.blur>2000))X.push("Blur must be between 0 and 2000");if($.rot!==void 0&&($.rot<0||$.rot>359))X.push("Rotation must be between 0 and 359");if($.dpr!==void 0&&($.dpr<1||$.dpr>5))X.push("DPR must be between 1 and 5");return{valid:X.length===0,errors:X}}function B8($){let X={...$};if(X.w!==void 0)X.w=Math.min(16383,Math.max(1,X.w));if(X.h!==void 0)X.h=Math.min(16383,Math.max(1,X.h));if(X.q!==void 0)X.q=Math.min(100,Math.max(1,X.q));if(X.blur!==void 0)X.blur=Math.min(2000,Math.max(0,X.blur));if(X.rot!==void 0)X.rot=(X.rot%360+360)%360;if(X.dpr!==void 0)X.dpr=Math.min(5,Math.max(1,X.dpr));return X}function F8($){let{endpoint:X,accept:Z,maxSize:Q,maxFiles:Y=1,fieldName:J="file",preview:G=!1,dropzone:W=!0,multiple:K=!1,autoUpload:_=!0,showProgress:U=!0,disabled:F=!1,placeholder:z="Drop files here or click to select",label:j}=$,H=$.class||"",L=$.style||"",O=$.id||`stx-upload-${Math.random().toString(36).slice(2,8)}`,N=Array.isArray(Z)?Z.join(","):Z,V=`
3434
3434
  <div id="${O}" class="stx-upload${W?" stx-upload-dropzone":""}${F?" stx-upload-disabled":""}${H?" "+H:""}"${L?` style="${L}"`:""}>
3435
- ${j?`<label class="stx-upload-label">${Y8(j)}</label>`:""}
3435
+ ${j?`<label class="stx-upload-label">${L8(j)}</label>`:""}
3436
3436
  <div class="stx-upload-area" data-stx-upload-area>
3437
3437
  <input
3438
3438
  type="file"
@@ -3447,8 +3447,8 @@ else {
3447
3447
  <svg class="stx-upload-icon" viewBox="0 0 24 24" width="48" height="48">
3448
3448
  <path fill="currentColor" d="M9 16h6v-6h4l-7-7-7 7h4v6zm-4 2h14v2H5v-2z"/>
3449
3449
  </svg>
3450
- <span class="stx-upload-text">${Y8(z)}</span>
3451
- ${Q?`<span class="stx-upload-hint">Max size: ${xQ(Q)}</span>`:""}
3450
+ <span class="stx-upload-text">${L8(z)}</span>
3451
+ ${Q?`<span class="stx-upload-hint">Max size: ${mQ(Q)}</span>`:""}
3452
3452
  </div>
3453
3453
  </div>
3454
3454
  ${G?'<div class="stx-upload-previews" data-stx-upload-previews></div>':""}
@@ -3467,7 +3467,7 @@ else {
3467
3467
  var progressText = progress ? progress.querySelector('.stx-upload-progress-text') : null;
3468
3468
 
3469
3469
  var config = {
3470
- endpoint: '${kQ(X)}',
3470
+ endpoint: '${uQ(X)}',
3471
3471
  fieldName: '${J}',
3472
3472
  maxSize: ${Q||"null"},
3473
3473
  maxFiles: ${Y},
@@ -3589,7 +3589,7 @@ else {
3589
3589
  return '\uD83D\uDCC1';
3590
3590
  }
3591
3591
  })();
3592
- `.trim(),q=`
3592
+ `.trim(),A=`
3593
3593
  .stx-upload {
3594
3594
  font-family: system-ui, -apple-system, sans-serif;
3595
3595
  }
@@ -3719,7 +3719,7 @@ else {
3719
3719
  opacity: 0.5;
3720
3720
  pointer-events: none;
3721
3721
  }
3722
- `.trim();return{html:V,script:M,css:q}}function Y8($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function kQ($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function xQ($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(1)} MB`}async function S5($,X){let{endpoint:Z,method:Q="POST",headers:Y={},expirationSeconds:J=3600,oneTimeUse:G=!1,params:W={}}=X,K=JSON.stringify({url:$,expirationSeconds:J,oneTimeUse:G,...W}),_=await fetch(Z,{method:Q,headers:{"Content-Type":"application/json",...Y},body:Q!=="GET"?K:void 0});if(!_.ok)throw Error(`Failed to sign URL: ${_.status} ${_.statusText}`);let U=await _.json();return{url:U.url||U.signedUrl,signature:U.signature,expires:U.expires||Date.now()+J*1000,oneTimeUse:U.oneTimeUse||G}}async function P5($,X){let{endpoint:Z,method:Q="POST",headers:Y={},expirationSeconds:J=3600,oneTimeUse:G=!1,params:W={}}=X,K=JSON.stringify({urls:$,expirationSeconds:J,oneTimeUse:G,...W}),_=await fetch(Z,{method:Q,headers:{"Content-Type":"application/json",...Y},body:Q!=="GET"?K:void 0});if(!_.ok)throw Error(`Failed to batch sign URLs: ${_.status} ${_.statusText}`);let U=await _.json(),F=new Map,z=new Map;if(Array.isArray(U.results))for(let j of U.results)if(j.error)z.set(j.url,j.error);else F.set(j.url||j.originalUrl,{url:j.signedUrl||j.url,signature:j.signature,expires:j.expires||Date.now()+J*1000,oneTimeUse:j.oneTimeUse||G});else if(typeof U.signatures==="object"){for(let[j,H]of Object.entries(U.signatures)){let L=H;F.set(j,{url:L.signedUrl||L.url||j,signature:L.signature,expires:L.expires||Date.now()+J*1000,oneTimeUse:G})}if(U.errors)for(let[j,H]of Object.entries(U.errors))z.set(j,H)}return{signatures:F,errors:z}}async function G8($,X,Z=10){let Q=new Map,Y=new Map,J=[];for(let W=0;W<$.length;W+=Z)J.push($.slice(W,W+Z));let G=await Promise.all(J.map((W)=>P5(W,X)));for(let W of G){for(let[K,_]of W.signatures)Q.set(K,_);for(let[K,_]of W.errors)Y.set(K,_)}return{signatures:Q,errors:Y}}function b5($){return $.expires>Date.now()}function y5($){return Math.max(0,$.expires-Date.now())}function v5($,X=300000){return y5($)<X}async function m1($){if($.check)return await $.check();return!0}function V$($){let X={};if($.role)X.role=$.role;if($.permission)X.permission=$.permission;if($.userId)X.userId=$.userId;return X}var u1=new Map;async function W8($,X){let Z=`${$}:${X.endpoint}`,Q=u1.get(Z);if(Q&&b5(Q)&&!v5(Q))return Q;let Y=await S5($,X);return u1.set(Z,Y),Y}function K8(){u1.clear()}function _8(){let $=0,X=Date.now();for(let[Z,Q]of u1)if(Q.expires<=X)u1.delete(Z),$++;return $}function M$(){return`
3722
+ `.trim();return{html:V,script:M,css:A}}function L8($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function uQ($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function mQ($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(1)} MB`}async function y5($,X){let{endpoint:Z,method:Q="POST",headers:Y={},expirationSeconds:J=3600,oneTimeUse:G=!1,params:W={}}=X,K=JSON.stringify({url:$,expirationSeconds:J,oneTimeUse:G,...W}),_=await fetch(Z,{method:Q,headers:{"Content-Type":"application/json",...Y},body:Q!=="GET"?K:void 0});if(!_.ok)throw Error(`Failed to sign URL: ${_.status} ${_.statusText}`);let U=await _.json();return{url:U.url||U.signedUrl,signature:U.signature,expires:U.expires||Date.now()+J*1000,oneTimeUse:U.oneTimeUse||G}}async function v5($,X){let{endpoint:Z,method:Q="POST",headers:Y={},expirationSeconds:J=3600,oneTimeUse:G=!1,params:W={}}=X,K=JSON.stringify({urls:$,expirationSeconds:J,oneTimeUse:G,...W}),_=await fetch(Z,{method:Q,headers:{"Content-Type":"application/json",...Y},body:Q!=="GET"?K:void 0});if(!_.ok)throw Error(`Failed to batch sign URLs: ${_.status} ${_.statusText}`);let U=await _.json(),F=new Map,z=new Map;if(Array.isArray(U.results))for(let j of U.results)if(j.error)z.set(j.url,j.error);else F.set(j.url||j.originalUrl,{url:j.signedUrl||j.url,signature:j.signature,expires:j.expires||Date.now()+J*1000,oneTimeUse:j.oneTimeUse||G});else if(typeof U.signatures==="object"){for(let[j,H]of Object.entries(U.signatures)){let L=H;F.set(j,{url:L.signedUrl||L.url||j,signature:L.signature,expires:L.expires||Date.now()+J*1000,oneTimeUse:G})}if(U.errors)for(let[j,H]of Object.entries(U.errors))z.set(j,H)}return{signatures:F,errors:z}}async function z8($,X,Z=10){let Q=new Map,Y=new Map,J=[];for(let W=0;W<$.length;W+=Z)J.push($.slice(W,W+Z));let G=await Promise.all(J.map((W)=>v5(W,X)));for(let W of G){for(let[K,_]of W.signatures)Q.set(K,_);for(let[K,_]of W.errors)Y.set(K,_)}return{signatures:Q,errors:Y}}function g5($){return $.expires>Date.now()}function f5($){return Math.max(0,$.expires-Date.now())}function h5($,X=300000){return f5($)<X}async function c1($){if($.check)return await $.check();return!0}function I$($){let X={};if($.role)X.role=$.role;if($.permission)X.permission=$.permission;if($.userId)X.userId=$.userId;return X}var p1=new Map;async function j8($,X){let Z=`${$}:${X.endpoint}`,Q=p1.get(Z);if(Q&&g5(Q)&&!h5(Q))return Q;let Y=await y5($,X);return p1.set(Z,Y),Y}function H8(){p1.clear()}function O8(){let $=0,X=Date.now();for(let[Z,Q]of p1)if(Q.expires<=X)p1.delete(Z),$++;return $}function R$(){return`
3723
3723
  (function() {
3724
3724
  'use strict';
3725
3725
 
@@ -3793,7 +3793,7 @@ catch (error) {
3793
3793
  }
3794
3794
  };
3795
3795
  })();
3796
- `.trim()}async function B8($){let{src:X,alt:Z="",signatureEndpoint:Q="/api/sign",signatureConfig:Y={},auth:J,fallback:G,oneTimeUse:W=!0}=$,K=$.class,_=$.style;if(J){if(!await m1(J)){if(G)return{html:`<img src="${$0(G)}" alt="${$0(Z)}"${K?` class="${$0(K)}"`:""}${_?` style="${$0(_)}"`:""} />`};return{html:"<!-- Protected content: access denied -->"}}}let U={endpoint:Q,oneTimeUse:W,...Y,params:J?V$(J):Y.params},F=`stx-protected-${Math.random().toString(36).slice(2,8)}`,z=[`id="${F}"`,`data-protected-src="${$0(X)}"`,`data-signature-endpoint="${$0(Q)}"`,`alt="${$0(Z)}"`];if(G)z.push(`data-fallback="${$0(G)}"`),z.push(`src="${$0(G)}"`);else z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');if(K)z.push(`class="${$0(K)}"`);if(_)z.push(`style="${$0(_)}"`);let j=`
3796
+ `.trim()}async function A8($){let{src:X,alt:Z="",signatureEndpoint:Q="/api/sign",signatureConfig:Y={},auth:J,fallback:G,oneTimeUse:W=!0}=$,K=$.class,_=$.style;if(J){if(!await c1(J)){if(G)return{html:`<img src="${$0(G)}" alt="${$0(Z)}"${K?` class="${$0(K)}"`:""}${_?` style="${$0(_)}"`:""} />`};return{html:"<!-- Protected content: access denied -->"}}}let U={endpoint:Q,oneTimeUse:W,...Y,params:J?I$(J):Y.params},F=`stx-protected-${Math.random().toString(36).slice(2,8)}`,z=[`id="${F}"`,`data-protected-src="${$0(X)}"`,`data-signature-endpoint="${$0(Q)}"`,`alt="${$0(Z)}"`];if(G)z.push(`data-fallback="${$0(G)}"`),z.push(`src="${$0(G)}"`);else z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');if(K)z.push(`class="${$0(K)}"`);if(_)z.push(`style="${$0(_)}"`);let j=`
3797
3797
  (function() {
3798
3798
  var el = document.getElementById('${F}');
3799
3799
  if (!el) return;
@@ -3804,7 +3804,7 @@ catch (error) {
3804
3804
  expirationSeconds: ${Y.expirationSeconds||3600}
3805
3805
  });
3806
3806
  })();
3807
- `.trim();return{html:`<img ${z.join(" ")} />`,script:j}}async function L8($){let{src:X,signatureEndpoint:Z="/api/sign",signatureConfig:Q={},auth:Y,fallback:J,oneTimeUse:G=!0,poster:W,controls:K=!0,autoplay:_=!1,muted:U=!1,loop:F=!1}=$,z=$.class,j=$.style,H=$.alt;if(Y){if(!await m1(Y))return{html:"<!-- Protected video: access denied -->"}}let L=`stx-protected-video-${Math.random().toString(36).slice(2,8)}`,O=[`id="${L}"`,`data-protected-src="${$0(X)}"`,`data-signature-endpoint="${$0(Z)}"`];if(W)O.push(`poster="${$0(W)}"`);if(K)O.push("controls");if(_)O.push("autoplay");if(U)O.push("muted");if(F)O.push("loop");if(z)O.push(`class="${$0(z)}"`);if(j)O.push(`style="${$0(j)}"`);if(J)O.push(`data-fallback="${$0(J)}"`);let N=`
3807
+ `.trim();return{html:`<img ${z.join(" ")} />`,script:j}}async function q8($){let{src:X,signatureEndpoint:Z="/api/sign",signatureConfig:Q={},auth:Y,fallback:J,oneTimeUse:G=!0,poster:W,controls:K=!0,autoplay:_=!1,muted:U=!1,loop:F=!1}=$,z=$.class,j=$.style,H=$.alt;if(Y){if(!await c1(Y))return{html:"<!-- Protected video: access denied -->"}}let L=`stx-protected-video-${Math.random().toString(36).slice(2,8)}`,O=[`id="${L}"`,`data-protected-src="${$0(X)}"`,`data-signature-endpoint="${$0(Z)}"`];if(W)O.push(`poster="${$0(W)}"`);if(K)O.push("controls");if(_)O.push("autoplay");if(U)O.push("muted");if(F)O.push("loop");if(z)O.push(`class="${$0(z)}"`);if(j)O.push(`style="${$0(j)}"`);if(J)O.push(`data-fallback="${$0(J)}"`);let N=`
3808
3808
  (function() {
3809
3809
  var el = document.getElementById('${L}');
3810
3810
  if (!el) return;
@@ -3815,7 +3815,7 @@ catch (error) {
3815
3815
  expirationSeconds: ${Q.expirationSeconds||3600}
3816
3816
  });
3817
3817
  })();
3818
- `.trim();return{html:`<video ${O.join(" ")}></video>`,script:N}}async function F8($,X){let Z=/data-protected-src="([^"]+)"/g,Q=[],Y;while((Y=Z.exec($))!==null)Q.push(Y[1]);if(Q.length===0)return{html:$,script:""};let J=M$()+`
3818
+ `.trim();return{html:`<video ${O.join(" ")}></video>`,script:N}}async function V8($,X){let Z=/data-protected-src="([^"]+)"/g,Q=[],Y;while((Y=Z.exec($))!==null)Q.push(Y[1]);if(Q.length===0)return{html:$,script:""};let J=R$()+`
3819
3819
 
3820
3820
  `;return J+=`
3821
3821
  (function() {
@@ -3847,12 +3847,12 @@ else if (el.dataset.fallback) {
3847
3847
  });
3848
3848
  });
3849
3849
  })();
3850
- `.trim(),{html:$,script:J}}function z8($,X,Z){if(X.src)return{src:String(X.src),alt:String(X.alt||""),signatureEndpoint:String(X.signatureEndpoint||"/api/sign"),auth:X.auth,fallback:X.fallback?String(X.fallback):void 0,oneTimeUse:X.oneTimeUse!==!1};let Q=$.trim();if(Q.startsWith("@protected(")||Q.startsWith("("))Q=Q.replace(/^@protected\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Y=SQ(Q);return{src:U8(Y[0],Z)||"",alt:U8(Y[1],Z)||"",...typeof Y[2]==="object"?Y[2]:{}}}function SQ($){let X=[],Z="",Q=!1,Y="",J=0;for(let G=0;G<$.length;G++){let W=$[G],K=G>0?$[G-1]:"";if((W==='"'||W==="'")&&K!=="\\"){if(!Q)Q=!0,Y=W;else if(W===Y)Q=!1;else Z+=W;continue}if(!Q){if(W==="{")J++;if(W==="}")J--;if(W===","&&J===0){X.push(Z.trim()),Z="";continue}}Z+=W}if(Z.trim())X.push(Z.trim());return X}function U8($,X){if(typeof $!=="string")return $;let Z=$.trim();if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'"))return Z.slice(1,-1);if(X[Z]!==void 0)return X[Z];if(Z.startsWith("{"))try{return JSON.parse(Z)}catch{}return Z}function $0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function PQ($){let{src:X,apiKey:Z,bucket:Q,allowedTypes:Y,maxFileSize:J,multiple:G=!1,customStyles:W={},callbacks:K={}}=$,_=`stx-media-manager-${Math.random().toString(36).slice(2,8)}`,U={container:`#${_}`};if(Z)U.apiKey=Z;if(Q)U.bucket=Q;if(Y)U.allowedTypes=Y;if(J)U.maxFileSize=J;if(G)U.multiple=G;if(Object.keys(W).length>0)U.styles=W;let F=`<div id="${_}" class="stx-media-manager"></div>`,z=Object.entries(K).filter(([,H])=>H).map(([H,L])=>{return`manager.on('${H.replace(/^on/,"").toLowerCase()}', ${L});`}).join(`
3850
+ `.trim(),{html:$,script:J}}function M8($,X,Z){if(X.src)return{src:String(X.src),alt:String(X.alt||""),signatureEndpoint:String(X.signatureEndpoint||"/api/sign"),auth:X.auth,fallback:X.fallback?String(X.fallback):void 0,oneTimeUse:X.oneTimeUse!==!1};let Q=$.trim();if(Q.startsWith("@protected(")||Q.startsWith("("))Q=Q.replace(/^@protected\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Y=pQ(Q);return{src:N8(Y[0],Z)||"",alt:N8(Y[1],Z)||"",...typeof Y[2]==="object"?Y[2]:{}}}function pQ($){let X=[],Z="",Q=!1,Y="",J=0;for(let G=0;G<$.length;G++){let W=$[G],K=G>0?$[G-1]:"";if((W==='"'||W==="'")&&K!=="\\"){if(!Q)Q=!0,Y=W;else if(W===Y)Q=!1;else Z+=W;continue}if(!Q){if(W==="{")J++;if(W==="}")J--;if(W===","&&J===0){X.push(Z.trim()),Z="";continue}}Z+=W}if(Z.trim())X.push(Z.trim());return X}function N8($,X){if(typeof $!=="string")return $;let Z=$.trim();if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'"))return Z.slice(1,-1);if(X[Z]!==void 0)return X[Z];if(Z.startsWith("{"))try{return JSON.parse(Z)}catch{}return Z}function $0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function cQ($){let{src:X,apiKey:Z,bucket:Q,allowedTypes:Y,maxFileSize:J,multiple:G=!1,customStyles:W={},callbacks:K={}}=$,_=`stx-media-manager-${Math.random().toString(36).slice(2,8)}`,U={container:`#${_}`};if(Z)U.apiKey=Z;if(Q)U.bucket=Q;if(Y)U.allowedTypes=Y;if(J)U.maxFileSize=J;if(G)U.multiple=G;if(Object.keys(W).length>0)U.styles=W;let F=`<div id="${_}" class="stx-media-manager"></div>`,z=Object.entries(K).filter(([,H])=>H).map(([H,L])=>{return`manager.on('${H.replace(/^on/,"").toLowerCase()}', ${L});`}).join(`
3851
3851
  `),j=`
3852
3852
  (function() {
3853
3853
  // Load media manager script
3854
3854
  var script = document.createElement('script');
3855
- script.src = '${j8(X)}';
3855
+ script.src = '${E8(X)}';
3856
3856
  script.async = true;
3857
3857
 
3858
3858
  script.onload = function() {
@@ -3869,12 +3869,12 @@ else if (el.dataset.fallback) {
3869
3869
  };
3870
3870
 
3871
3871
  script.onerror = function() {
3872
- console.error('[stx] Failed to load media manager from:', '${j8(X)}');
3872
+ console.error('[stx] Failed to load media manager from:', '${E8(X)}');
3873
3873
  };
3874
3874
 
3875
3875
  document.head.appendChild(script);
3876
3876
  })();
3877
- `.trim();return{html:F,script:j}}function bQ($){let{accept:X="image/*",multiple:Z=!1,onSelect:Q="handleMediaSelect"}=$,Y=`stx-picker-${Math.random().toString(36).slice(2,8)}`,J=`
3877
+ `.trim();return{html:F,script:j}}function lQ($){let{accept:X="image/*",multiple:Z=!1,onSelect:Q="handleMediaSelect"}=$,Y=`stx-picker-${Math.random().toString(36).slice(2,8)}`,J=`
3878
3878
  <div id="${Y}" class="stx-media-picker" style="display:none;">
3879
3879
  <div class="stx-media-picker-backdrop"></div>
3880
3880
  <div class="stx-media-picker-modal">
@@ -4063,7 +4063,7 @@ else {
4063
4063
  border: none;
4064
4064
  color: white;
4065
4065
  }
4066
- `.trim();return{html:J,script:G,css:W}}function j8($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var N8={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"};function g5(){return"loading"in HTMLImageElement.prototype}function f5(){return"IntersectionObserver"in window}function q8($={}){let X={...N8,...$},Z=document.querySelectorAll(X.selector);if(Z.length===0)return()=>{};if(X.useNative&&g5())return Z.forEach((Y)=>{if(Y.tagName==="IMG"||Y.tagName==="IFRAME")i0(Y,X)}),()=>{};if(!f5())return Z.forEach((Y)=>i0(Y,X)),()=>{};let Q=new IntersectionObserver((Y)=>{Y.forEach((J)=>{if(J.isIntersecting){let G=J.target;i0(G,X),Q.unobserve(G)}})},{root:X.root,rootMargin:X.rootMargin,threshold:X.threshold});return Z.forEach((Y)=>Q.observe(Y)),()=>{Q.disconnect()}}function i0($,X={}){let{onLoad:Z,onLoaded:Q,onError:Y}=X;if(Z)Z($);let J=$.tagName==="IMG",G=$.tagName==="VIDEO",W=$.tagName==="IFRAME";if(J)H8($,Q,Y);else if(G)O8($,Q,Y);else if(W)yQ($,Q,Y);else{let K=$.querySelector("img[data-src], img[data-srcset]"),_=$.querySelector("video[data-src]");if(K)H8(K,()=>{if(Q)Q($)},(F)=>{if(Y)Y($,F)});else if(_)O8(_,()=>{if(Q)Q($)},(F)=>{if(Y)Y($,F)});$.querySelectorAll("source[data-srcset]").forEach((F)=>{let z=F;if(z.dataset.srcset)z.srcset=z.dataset.srcset,delete z.dataset.srcset;if(z.dataset.sizes)z.sizes=z.dataset.sizes,delete z.dataset.sizes})}}function H8($,X,Z){let Q=()=>{$.classList.add("stx-img-loaded"),$.style.opacity="1";let J=$.closest(".stx-img-placeholder");if(J)J.classList.add("stx-img-loaded");if(X)X($)},Y=()=>{if($.classList.add("stx-img-error"),Z)Z($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",Q,{once:!0}),$.addEventListener("error",Y,{once:!0}),$.dataset.srcset)$.srcset=$.dataset.srcset,delete $.dataset.srcset;if($.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.sizes)$.sizes=$.dataset.sizes,delete $.dataset.sizes}function O8($,X,Z){let Q=()=>{if($.classList.add("stx-video-loaded"),X)X($)},Y=()=>{if($.classList.add("stx-video-error"),Z)Z($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",Q,{once:!0}),$.addEventListener("error",Y,{once:!0}),$.querySelectorAll("source[data-src]").forEach((G)=>{let W=G;if(W.dataset.src)W.src=W.dataset.src,delete W.dataset.src}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.poster)$.poster=$.dataset.poster,delete $.dataset.poster;$.load()}function yQ($,X,Z){let Q=()=>{if($.classList.add("stx-iframe-loaded"),X)X($)},Y=()=>{if($.classList.add("stx-iframe-error"),Z)Z($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",Q,{once:!0}),$.addEventListener("error",Y,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function A8($){i0($,{})}function V8($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Z)=>i0(Z,{}))}function M8($={}){let X={...N8,...$};return new IntersectionObserver((Z,Q)=>{Z.forEach((Y)=>{if(Y.isIntersecting)i0(Y.target,X),Q.unobserve(Y.target)})},{root:X.root,rootMargin:X.rootMargin,threshold:X.threshold})}function E8($,X){$.observe(X)}function I8($){$.disconnect()}function E$(){return`
4066
+ `.trim();return{html:J,script:G,css:W}}function E8($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var D8={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"};function d5(){return"loading"in HTMLImageElement.prototype}function u5(){return"IntersectionObserver"in window}function w8($={}){let X={...D8,...$},Z=document.querySelectorAll(X.selector);if(Z.length===0)return()=>{};if(X.useNative&&d5())return Z.forEach((Y)=>{if(Y.tagName==="IMG"||Y.tagName==="IFRAME")i0(Y,X)}),()=>{};if(!u5())return Z.forEach((Y)=>i0(Y,X)),()=>{};let Q=new IntersectionObserver((Y)=>{Y.forEach((J)=>{if(J.isIntersecting){let G=J.target;i0(G,X),Q.unobserve(G)}})},{root:X.root,rootMargin:X.rootMargin,threshold:X.threshold});return Z.forEach((Y)=>Q.observe(Y)),()=>{Q.disconnect()}}function i0($,X={}){let{onLoad:Z,onLoaded:Q,onError:Y}=X;if(Z)Z($);let J=$.tagName==="IMG",G=$.tagName==="VIDEO",W=$.tagName==="IFRAME";if(J)I8($,Q,Y);else if(G)R8($,Q,Y);else if(W)iQ($,Q,Y);else{let K=$.querySelector("img[data-src], img[data-srcset]"),_=$.querySelector("video[data-src]");if(K)I8(K,()=>{if(Q)Q($)},(F)=>{if(Y)Y($,F)});else if(_)R8(_,()=>{if(Q)Q($)},(F)=>{if(Y)Y($,F)});$.querySelectorAll("source[data-srcset]").forEach((F)=>{let z=F;if(z.dataset.srcset)z.srcset=z.dataset.srcset,delete z.dataset.srcset;if(z.dataset.sizes)z.sizes=z.dataset.sizes,delete z.dataset.sizes})}}function I8($,X,Z){let Q=()=>{$.classList.add("stx-img-loaded"),$.style.opacity="1";let J=$.closest(".stx-img-placeholder");if(J)J.classList.add("stx-img-loaded");if(X)X($)},Y=()=>{if($.classList.add("stx-img-error"),Z)Z($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",Q,{once:!0}),$.addEventListener("error",Y,{once:!0}),$.dataset.srcset)$.srcset=$.dataset.srcset,delete $.dataset.srcset;if($.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.sizes)$.sizes=$.dataset.sizes,delete $.dataset.sizes}function R8($,X,Z){let Q=()=>{if($.classList.add("stx-video-loaded"),X)X($)},Y=()=>{if($.classList.add("stx-video-error"),Z)Z($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",Q,{once:!0}),$.addEventListener("error",Y,{once:!0}),$.querySelectorAll("source[data-src]").forEach((G)=>{let W=G;if(W.dataset.src)W.src=W.dataset.src,delete W.dataset.src}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.poster)$.poster=$.dataset.poster,delete $.dataset.poster;$.load()}function iQ($,X,Z){let Q=()=>{if($.classList.add("stx-iframe-loaded"),X)X($)},Y=()=>{if($.classList.add("stx-iframe-error"),Z)Z($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",Q,{once:!0}),$.addEventListener("error",Y,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function T8($){i0($,{})}function C8($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Z)=>i0(Z,{}))}function k8($={}){let X={...D8,...$};return new IntersectionObserver((Z,Q)=>{Z.forEach((Y)=>{if(Y.isIntersecting)i0(Y.target,X),Q.unobserve(Y.target)})},{root:X.root,rootMargin:X.rootMargin,threshold:X.threshold})}function x8($,X){$.observe(X)}function S8($){$.disconnect()}function D$(){return`
4067
4067
  (function() {
4068
4068
  'use strict';
4069
4069
 
@@ -4153,7 +4153,7 @@ else {
4153
4153
  window.STX.lazyLoad = loadElement;
4154
4154
  window.STX.initLazyLoading = init;
4155
4155
  })();
4156
- `.trim()}var vQ={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"};function h5($,X={}){let Z={...vQ,...X},Q=$.closest(".stx-img-placeholder");if(!Q){gQ($,Z);return}if(Q.style.setProperty("--stx-img-transition-duration",`${Z.duration}ms`),Q.style.setProperty("--stx-img-transition-easing",Z.easing),Z.loadingClass)Q.classList.add(Z.loadingClass);if($.complete&&$.naturalWidth>0)R8($,Q,Z);else $.addEventListener("load",()=>R8($,Q,Z),{once:!0}),$.addEventListener("error",()=>fQ($,Q,Z),{once:!0})}function gQ($,X){let Z=()=>{$.style.transition=`opacity ${X.duration}ms ${X.easing}`,$.style.opacity="1",$.classList.remove(X.loadingClass),$.classList.add(X.loadedClass)};if($.complete&&$.naturalWidth>0)Z();else $.style.opacity="0",$.classList.add(X.loadingClass),$.addEventListener("load",Z,{once:!0})}function R8($,X,Z){if(Z.loadingClass)X.classList.remove(Z.loadingClass);if(Z.loadedClass)X.classList.add(Z.loadedClass);if($.style.opacity="1",Z.removePlaceholder)setTimeout(()=>{X.style.backgroundImage="none"},Z.duration)}function fQ($,X,Z){if(Z.loadingClass)X.classList.remove(Z.loadingClass);X.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function D8($,X){let Z=I$($),Q=X.getContext("2d");if(!Q)return;X.width=Z.w,X.height=Z.h;let Y=Q.createImageData(Z.w,Z.h);Y.data.set(Z.rgba),Q.putImageData(Y,0,0)}function I$($){let X=$[0]|$[1]<<8|$[2]<<16,Z=(X&63)/63,Q=(X>>6&63)/31.5-1,Y=(X>>12&63)/31.5-1,J=(X>>18&31)/31,G=X>>23!==0,W=$[3]|$[4]<<8,K=(W>>3&63)/63,_=(W>>9&63)/63,U=W>>15!==0,F=Math.max(3,U?G?5:7:G?5:5),z=Math.max(3,U?G?5:5:G?5:7),j=32,H=32,L=new Uint8ClampedArray(4096);for(let O=0;O<32;O++)for(let N=0;N<32;N++){let V=(O*32+N)*4,M=N/31,q=O/31,A=Z+(M-0.5)*J*0.5+(q-0.5)*J*0.5,I=Q*(1-M*0.3),E=Y*(1-q*0.3),w=A-0.6666666666666666*I,D=(3*A-w+E)/2,T=D-E;L[V]=Math.max(0,Math.min(255,Math.round(D*255))),L[V+1]=Math.max(0,Math.min(255,Math.round(T*255))),L[V+2]=Math.max(0,Math.min(255,Math.round(w*255))),L[V+3]=255}return{w:32,h:32,rgba:L}}function w8($){let X=I$($),Z=document.createElement("canvas");Z.width=X.w,Z.height=X.h;let Q=Z.getContext("2d");if(!Q)return"";let Y=Q.createImageData(X.w,X.h);return Y.data.set(X.rgba),Q.putImageData(Y,0,0),Z.toDataURL("image/png")}function T8($){let X=atob($),Z=new Uint8Array(X.length);for(let Q=0;Q<X.length;Q++)Z[Q]=X.charCodeAt(Q);return Z}function C8($,X,Z=300){return new Promise((Q)=>{$.style.transition=`opacity ${Z}ms ease-out`,X.style.transition=`opacity ${Z}ms ease-out`,X.style.opacity="0",X.offsetWidth,$.style.opacity="0",X.style.opacity="1",setTimeout(Q,Z)})}function k8($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Z)=>{h5(Z,$)})}function R$(){return`
4156
+ `.trim()}var aQ={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"};function m5($,X={}){let Z={...aQ,...X},Q=$.closest(".stx-img-placeholder");if(!Q){sQ($,Z);return}if(Q.style.setProperty("--stx-img-transition-duration",`${Z.duration}ms`),Q.style.setProperty("--stx-img-transition-easing",Z.easing),Z.loadingClass)Q.classList.add(Z.loadingClass);if($.complete&&$.naturalWidth>0)P8($,Q,Z);else $.addEventListener("load",()=>P8($,Q,Z),{once:!0}),$.addEventListener("error",()=>rQ($,Q,Z),{once:!0})}function sQ($,X){let Z=()=>{$.style.transition=`opacity ${X.duration}ms ${X.easing}`,$.style.opacity="1",$.classList.remove(X.loadingClass),$.classList.add(X.loadedClass)};if($.complete&&$.naturalWidth>0)Z();else $.style.opacity="0",$.classList.add(X.loadingClass),$.addEventListener("load",Z,{once:!0})}function P8($,X,Z){if(Z.loadingClass)X.classList.remove(Z.loadingClass);if(Z.loadedClass)X.classList.add(Z.loadedClass);if($.style.opacity="1",Z.removePlaceholder)setTimeout(()=>{X.style.backgroundImage="none"},Z.duration)}function rQ($,X,Z){if(Z.loadingClass)X.classList.remove(Z.loadingClass);X.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function b8($,X){let Z=w$($),Q=X.getContext("2d");if(!Q)return;X.width=Z.w,X.height=Z.h;let Y=Q.createImageData(Z.w,Z.h);Y.data.set(Z.rgba),Q.putImageData(Y,0,0)}function w$($){let X=$[0]|$[1]<<8|$[2]<<16,Z=(X&63)/63,Q=(X>>6&63)/31.5-1,Y=(X>>12&63)/31.5-1,J=(X>>18&31)/31,G=X>>23!==0,W=$[3]|$[4]<<8,K=(W>>3&63)/63,_=(W>>9&63)/63,U=W>>15!==0,F=Math.max(3,U?G?5:7:G?5:5),z=Math.max(3,U?G?5:5:G?5:7),j=32,H=32,L=new Uint8ClampedArray(4096);for(let O=0;O<32;O++)for(let N=0;N<32;N++){let V=(O*32+N)*4,M=N/31,A=O/31,q=Z+(M-0.5)*J*0.5+(A-0.5)*J*0.5,I=Q*(1-M*0.3),E=Y*(1-A*0.3),w=q-0.6666666666666666*I,D=(3*q-w+E)/2,T=D-E;L[V]=Math.max(0,Math.min(255,Math.round(D*255))),L[V+1]=Math.max(0,Math.min(255,Math.round(T*255))),L[V+2]=Math.max(0,Math.min(255,Math.round(w*255))),L[V+3]=255}return{w:32,h:32,rgba:L}}function y8($){let X=w$($),Z=document.createElement("canvas");Z.width=X.w,Z.height=X.h;let Q=Z.getContext("2d");if(!Q)return"";let Y=Q.createImageData(X.w,X.h);return Y.data.set(X.rgba),Q.putImageData(Y,0,0),Z.toDataURL("image/png")}function v8($){let X=atob($),Z=new Uint8Array(X.length);for(let Q=0;Q<X.length;Q++)Z[Q]=X.charCodeAt(Q);return Z}function g8($,X,Z=300){return new Promise((Q)=>{$.style.transition=`opacity ${Z}ms ease-out`,X.style.transition=`opacity ${Z}ms ease-out`,X.style.opacity="0",X.offsetWidth,$.style.opacity="0",X.style.opacity="1",setTimeout(Q,Z)})}function f8($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Z)=>{m5(Z,$)})}function T$(){return`
4157
4157
  (function() {
4158
4158
  'use strict';
4159
4159
 
@@ -4215,7 +4215,7 @@ else {
4215
4215
  window.STX.initBlurUp = initBlurUp;
4216
4216
  window.STX.initAllBlurUp = init;
4217
4217
  })();
4218
- `.trim()}function D$(){return`
4218
+ `.trim()}function C$(){return`
4219
4219
  .stx-img-placeholder {
4220
4220
  position: relative;
4221
4221
  overflow: hidden;
@@ -4252,7 +4252,7 @@ else {
4252
4252
  .stx-img-error {
4253
4253
  opacity: 0.5;
4254
4254
  }
4255
- `.trim()}var hQ={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1};function d5($,X={}){if(X.maxSize&&$.size>X.maxSize)return{valid:!1,error:`File size (${x8($.size)}) exceeds maximum (${x8(X.maxSize)})`,code:"FILE_TOO_LARGE"};if(X.accept&&X.accept.length>0){if(!X.accept.some((Q)=>{if(Q.endsWith("/*")){let Y=Q.slice(0,-1);return $.type.startsWith(Y)}return $.type===Q}))return{valid:!1,error:`File type "${$.type}" is not allowed`,code:"INVALID_TYPE"}}return{valid:!0}}function x8($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}async function u5($,X,Z){let Q={...hQ,...X},Y=d5($,Q);if(!Y.valid)return{success:!1,error:Y.error,name:$.name,size:$.size,type:$.type};if(Q.chunkSize&&$.size>Q.chunkSize)return uQ($,Q,Z);return dQ($,Q,Z)}async function dQ($,X,Z){return new Promise((Q)=>{let Y=new XMLHttpRequest,J=Date.now(),G=0,W=J;Y.upload.addEventListener("progress",(_)=>{if(_.lengthComputable&&Z){let U=Date.now(),F=(U-W)/1000,z=_.loaded-G,j=F>0?z/F:0,H=_.total-_.loaded,L=j>0?H/j*1000:void 0;G=_.loaded,W=U,Z({file:$,loaded:_.loaded,total:_.total,percent:Math.round(_.loaded/_.total*100),speed:j,timeRemaining:L})}}),Y.addEventListener("load",()=>{if(Y.status>=200&&Y.status<300)try{let _=JSON.parse(Y.responseText);Q({success:!0,url:_.url,id:_.id,name:$.name,size:$.size,type:$.type,data:_})}catch{Q({success:!0,name:$.name,size:$.size,type:$.type})}else Q({success:!1,error:`Upload failed with status ${Y.status}`,name:$.name,size:$.size,type:$.type})}),Y.addEventListener("error",()=>{Q({success:!1,error:"Network error during upload",name:$.name,size:$.size,type:$.type})}),Y.addEventListener("timeout",()=>{Q({success:!1,error:"Upload timed out",name:$.name,size:$.size,type:$.type})});let K=new FormData;if(K.append(X.fieldName||"file",$),X.formData)for(let[_,U]of Object.entries(X.formData))K.append(_,U);if(Y.open(X.method||"POST",X.endpoint),Y.timeout=X.timeout||60000,Y.withCredentials=X.withCredentials||!1,X.headers)for(let[_,U]of Object.entries(X.headers))Y.setRequestHeader(_,U);Y.send(K)})}async function uQ($,X,Z){let Q=X.chunkSize,Y=Math.ceil($.size/Q),J=0,G;for(let W=0;W<Y;W++){let K=W*Q,_=Math.min(K+Q,$.size),U=$.slice(K,_),F=new FormData;if(F.append(X.fieldName||"file",U,$.name),F.append("chunk",String(W)),F.append("totalChunks",String(Y)),F.append("fileName",$.name),F.append("fileSize",String($.size)),F.append("fileType",$.type),G)F.append("uploadId",G);if(X.formData)for(let[z,j]of Object.entries(X.formData))F.append(z,j);try{let z=await fetch(X.endpoint,{method:X.method||"POST",headers:X.headers,credentials:X.withCredentials?"include":"same-origin",body:F});if(!z.ok)return{success:!1,error:`Chunk ${W+1}/${Y} failed with status ${z.status}`,name:$.name,size:$.size,type:$.type};let j=await z.json();if(!G&&j.uploadId)G=j.uploadId;if(J=_,Z)Z({file:$,loaded:J,total:$.size,percent:Math.round(J/$.size*100),chunk:W+1,totalChunks:Y});if(W===Y-1)return{success:!0,url:j.url,id:j.id||G,name:$.name,size:$.size,type:$.type,data:j}}catch(z){return{success:!1,error:`Chunk upload failed: ${z}`,name:$.name,size:$.size,type:$.type}}}return{success:!1,error:"Unknown error during chunked upload",name:$.name,size:$.size,type:$.type}}async function S8($,X,Z,Q){let Y=[];for(let J of $){let G=await u5(J,X,(W)=>{if(Z)Z(J,W)});if(Y.push(G),Q)Q(J,G)}return Y}function P8($,X=200){return new Promise((Z,Q)=>{if(!$.type.startsWith("image/")){Q(Error("File is not an image"));return}let Y=new FileReader;Y.onload=(J)=>{let G=new Image;G.onload=()=>{let W=document.createElement("canvas"),K=G.width,_=G.height;if(K>X||_>X)if(K>_)_=Math.round(_*X/K),K=X;else K=Math.round(K*X/_),_=X;W.width=K,W.height=_;let U=W.getContext("2d");if(U)U.drawImage(G,0,0,K,_),Z(W.toDataURL("image/jpeg",0.7));else Q(Error("Could not get canvas context"))},G.onerror=()=>Q(Error("Could not load image")),G.src=J.target?.result},Y.onerror=()=>Q(Error("Could not read file")),Y.readAsDataURL($)})}function b8($){return new Promise((X,Z)=>{if(!$.type.startsWith("video/")){Z(Error("File is not a video"));return}let Q=document.createElement("video"),Y=document.createElement("canvas");Q.preload="metadata",Q.muted=!0,Q.playsInline=!0,Q.onloadeddata=()=>{Q.currentTime=0.1},Q.onseeked=()=>{Y.width=Q.videoWidth,Y.height=Q.videoHeight;let J=Y.getContext("2d");if(J)J.drawImage(Q,0,0),X(Y.toDataURL("image/jpeg",0.7));else Z(Error("Could not get canvas context"));URL.revokeObjectURL(Q.src)},Q.onerror=()=>{URL.revokeObjectURL(Q.src),Z(Error("Could not load video"))},Q.src=URL.createObjectURL($)})}function w$(){return`
4255
+ `.trim()}var nQ={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1};function p5($,X={}){if(X.maxSize&&$.size>X.maxSize)return{valid:!1,error:`File size (${h8($.size)}) exceeds maximum (${h8(X.maxSize)})`,code:"FILE_TOO_LARGE"};if(X.accept&&X.accept.length>0){if(!X.accept.some((Q)=>{if(Q.endsWith("/*")){let Y=Q.slice(0,-1);return $.type.startsWith(Y)}return $.type===Q}))return{valid:!1,error:`File type "${$.type}" is not allowed`,code:"INVALID_TYPE"}}return{valid:!0}}function h8($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}async function c5($,X,Z){let Q={...nQ,...X},Y=p5($,Q);if(!Y.valid)return{success:!1,error:Y.error,name:$.name,size:$.size,type:$.type};if(Q.chunkSize&&$.size>Q.chunkSize)return tQ($,Q,Z);return oQ($,Q,Z)}async function oQ($,X,Z){return new Promise((Q)=>{let Y=new XMLHttpRequest,J=Date.now(),G=0,W=J;Y.upload.addEventListener("progress",(_)=>{if(_.lengthComputable&&Z){let U=Date.now(),F=(U-W)/1000,z=_.loaded-G,j=F>0?z/F:0,H=_.total-_.loaded,L=j>0?H/j*1000:void 0;G=_.loaded,W=U,Z({file:$,loaded:_.loaded,total:_.total,percent:Math.round(_.loaded/_.total*100),speed:j,timeRemaining:L})}}),Y.addEventListener("load",()=>{if(Y.status>=200&&Y.status<300)try{let _=JSON.parse(Y.responseText);Q({success:!0,url:_.url,id:_.id,name:$.name,size:$.size,type:$.type,data:_})}catch{Q({success:!0,name:$.name,size:$.size,type:$.type})}else Q({success:!1,error:`Upload failed with status ${Y.status}`,name:$.name,size:$.size,type:$.type})}),Y.addEventListener("error",()=>{Q({success:!1,error:"Network error during upload",name:$.name,size:$.size,type:$.type})}),Y.addEventListener("timeout",()=>{Q({success:!1,error:"Upload timed out",name:$.name,size:$.size,type:$.type})});let K=new FormData;if(K.append(X.fieldName||"file",$),X.formData)for(let[_,U]of Object.entries(X.formData))K.append(_,U);if(Y.open(X.method||"POST",X.endpoint),Y.timeout=X.timeout||60000,Y.withCredentials=X.withCredentials||!1,X.headers)for(let[_,U]of Object.entries(X.headers))Y.setRequestHeader(_,U);Y.send(K)})}async function tQ($,X,Z){let Q=X.chunkSize,Y=Math.ceil($.size/Q),J=0,G;for(let W=0;W<Y;W++){let K=W*Q,_=Math.min(K+Q,$.size),U=$.slice(K,_),F=new FormData;if(F.append(X.fieldName||"file",U,$.name),F.append("chunk",String(W)),F.append("totalChunks",String(Y)),F.append("fileName",$.name),F.append("fileSize",String($.size)),F.append("fileType",$.type),G)F.append("uploadId",G);if(X.formData)for(let[z,j]of Object.entries(X.formData))F.append(z,j);try{let z=await fetch(X.endpoint,{method:X.method||"POST",headers:X.headers,credentials:X.withCredentials?"include":"same-origin",body:F});if(!z.ok)return{success:!1,error:`Chunk ${W+1}/${Y} failed with status ${z.status}`,name:$.name,size:$.size,type:$.type};let j=await z.json();if(!G&&j.uploadId)G=j.uploadId;if(J=_,Z)Z({file:$,loaded:J,total:$.size,percent:Math.round(J/$.size*100),chunk:W+1,totalChunks:Y});if(W===Y-1)return{success:!0,url:j.url,id:j.id||G,name:$.name,size:$.size,type:$.type,data:j}}catch(z){return{success:!1,error:`Chunk upload failed: ${z}`,name:$.name,size:$.size,type:$.type}}}return{success:!1,error:"Unknown error during chunked upload",name:$.name,size:$.size,type:$.type}}async function d8($,X,Z,Q){let Y=[];for(let J of $){let G=await c5(J,X,(W)=>{if(Z)Z(J,W)});if(Y.push(G),Q)Q(J,G)}return Y}function u8($,X=200){return new Promise((Z,Q)=>{if(!$.type.startsWith("image/")){Q(Error("File is not an image"));return}let Y=new FileReader;Y.onload=(J)=>{let G=new Image;G.onload=()=>{let W=document.createElement("canvas"),K=G.width,_=G.height;if(K>X||_>X)if(K>_)_=Math.round(_*X/K),K=X;else K=Math.round(K*X/_),_=X;W.width=K,W.height=_;let U=W.getContext("2d");if(U)U.drawImage(G,0,0,K,_),Z(W.toDataURL("image/jpeg",0.7));else Q(Error("Could not get canvas context"))},G.onerror=()=>Q(Error("Could not load image")),G.src=J.target?.result},Y.onerror=()=>Q(Error("Could not read file")),Y.readAsDataURL($)})}function m8($){return new Promise((X,Z)=>{if(!$.type.startsWith("video/")){Z(Error("File is not a video"));return}let Q=document.createElement("video"),Y=document.createElement("canvas");Q.preload="metadata",Q.muted=!0,Q.playsInline=!0,Q.onloadeddata=()=>{Q.currentTime=0.1},Q.onseeked=()=>{Y.width=Q.videoWidth,Y.height=Q.videoHeight;let J=Y.getContext("2d");if(J)J.drawImage(Q,0,0),X(Y.toDataURL("image/jpeg",0.7));else Z(Error("Could not get canvas context"));URL.revokeObjectURL(Q.src)},Q.onerror=()=>{URL.revokeObjectURL(Q.src),Z(Error("Could not load video"))},Q.src=URL.createObjectURL($)})}function k$(){return`
4256
4256
  (function() {
4257
4257
  'use strict';
4258
4258
 
@@ -4320,20 +4320,20 @@ else {
4320
4320
  return { valid: true };
4321
4321
  };
4322
4322
  })();
4323
- `.trim()}function y8(){return{script:[E$(),R$(),w$()].join(`
4323
+ `.trim()}function p8(){return{script:[D$(),T$(),k$()].join(`
4324
4324
 
4325
- `),css:D$()}}function mQ(){let{script:$,css:X}=y8(),Z=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),Q=X.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Z,css:Q}}var Q_={enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3]},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}};import T$ from"fs";import Z1 from"path";async function v8($,X={},Z={}){let Q=await Bun.file($).text(),Y=Q.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),J=Y?Y[1]:"",G=Y?Q.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):Q;G=G.replace(/<script\s+client\s*>/gi,"<script>");let W={__filename:$,__dirname:Z1.dirname($),props:X,...X};if(J)await E0(J,W,$,{onFailure:(U)=>{if(U.kind==="unknown")return;Z.onServerScriptError?.({sourcePath:$,kind:U.kind,message:U.message})}});let K={...C$,...Z};return await I0(G,W,$,K,new Set)}async function pQ($){let X=performance.now(),Z={success:!0,views:[],errors:[],duration:0},{viewsDir:Q,outputDir:Y,componentsDir:J=Z1.join(Q,"components"),layoutsDir:G=Z1.join(Q,"layouts"),partialsDir:W=Z1.join(Q,"partials"),globalProps:K={},placeholders:_={},views:U,debug:F=!1,generateManifest:z=!0}=$;if(F)console.log("Building STX views..."),console.log(` Source: ${Q}`),console.log(` Output: ${Y}`);T$.mkdirSync(Y,{recursive:!0});let j={componentsDir:J,layoutsDir:G,partialsDir:W,debug:F},H;if(U&&U.length>0)H=U;else H=T$.readdirSync(Q).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let L of H){let O=Z1.join(Q,L.input),N=L.output||L.input.replace(/\.stx$/,".html"),V=Z1.join(Y,N);if(F)console.log(` Building ${L.input}...`);try{let M={...K,...L.props,..._},q=[],A=await v8(O,M,{...j,onServerScriptError:(I)=>{q.push(`${I.kind}: ${I.message}`)}});if(q.length>0)throw Error(`${q.length} <script server> block(s) failed, so this view would have been written with the content they produce missing:
4326
- ${q.join(`
4327
- `)}`);await Bun.write(V,A),Z.views.push(N)}catch(M){let q=M instanceof Error?M.message:String(M);if(Z.errors.push({file:L.input,error:q}),Z.success=!1,F)console.error(` Error: ${q}`)}}if(z){let L={buildTime:new Date().toISOString(),views:Z.views,placeholders:_,errors:Z.errors.length>0?Z.errors:void 0};await Bun.write(Z1.join(Y,"manifest.json"),JSON.stringify(L,null,2))}if(Z.duration=performance.now()-X,F)if(Z.success)console.log(`
4325
+ `),css:C$()}}function eQ(){let{script:$,css:X}=p8(),Z=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),Q=X.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Z,css:Q}}var A_={enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3]},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}};import x$ from"fs";import Z1 from"path";async function c8($,X={},Z={}){let Q=await Bun.file($).text(),Y=Q.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),J=Y?Y[1]:"",G=Y?Q.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):Q;G=G.replace(/<script\s+client\s*>/gi,"<script>");let W={__filename:$,__dirname:Z1.dirname($),props:X,...X};if(J)await E0(J,W,$,{onFailure:(U)=>{if(U.kind==="unknown")return;Z.onServerScriptError?.({sourcePath:$,kind:U.kind,message:U.message})}});let K={...S$,...Z};return await I0(G,W,$,K,new Set)}async function $Y($){let X=performance.now(),Z={success:!0,views:[],errors:[],duration:0},{viewsDir:Q,outputDir:Y,componentsDir:J=Z1.join(Q,"components"),layoutsDir:G=Z1.join(Q,"layouts"),partialsDir:W=Z1.join(Q,"partials"),globalProps:K={},placeholders:_={},views:U,debug:F=!1,generateManifest:z=!0}=$;if(F)console.log("Building STX views..."),console.log(` Source: ${Q}`),console.log(` Output: ${Y}`);x$.mkdirSync(Y,{recursive:!0});let j={componentsDir:J,layoutsDir:G,partialsDir:W,debug:F},H;if(U&&U.length>0)H=U;else H=x$.readdirSync(Q).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let L of H){let O=Z1.join(Q,L.input),N=L.output||L.input.replace(/\.stx$/,".html"),V=Z1.join(Y,N);if(F)console.log(` Building ${L.input}...`);try{let M={...K,...L.props,..._},A=[],q=await c8(O,M,{...j,onServerScriptError:(I)=>{A.push(`${I.kind}: ${I.message}`)}});if(A.length>0)throw Error(`${A.length} <script server> block(s) failed, so this view would have been written with the content they produce missing:
4326
+ ${A.join(`
4327
+ `)}`);await Bun.write(V,q),Z.views.push(N)}catch(M){let A=M instanceof Error?M.message:String(M);if(Z.errors.push({file:L.input,error:A}),Z.success=!1,F)console.error(` Error: ${A}`)}}if(z){let L={buildTime:new Date().toISOString(),views:Z.views,placeholders:_,errors:Z.errors.length>0?Z.errors:void 0};await Bun.write(Z1.join(Y,"manifest.json"),JSON.stringify(L,null,2))}if(Z.duration=performance.now()-X,F)if(Z.success)console.log(`
4328
4328
  \u2705 Built ${Z.views.length} views in ${Z.duration.toFixed(0)}ms`);else console.log(`
4329
- \u26A0\uFE0F Built ${Z.views.length} views with ${Z.errors.length} errors`);return Z}function q_($,X){let Z=T$.watch($.viewsDir,{recursive:!0},async(Q,Y)=>{if(!Y)return;if(Y.endsWith(".stx")||Y.endsWith(".ts")||Y.endsWith(".js")){if($.debug)console.log(`
4330
- File changed: ${Y}, rebuilding...`);let J=await pQ($);X?.(J)}});return{close:()=>Z.close()}}async function A_($,X={},Z={}){let Q={...Z,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await v8($,X,Q);Y=await cQ(Y),Y=Y.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),Y=Y.replace(/<style\b([^>]*)>[\s\S]*?<\/style>/gi,(G,W)=>/\bdata-(?:css=["']generated["']|stx-)/i.test(W)?"":G),Y=Y.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),Y=Y.replace(/\n\s*\n\s*\n/g,`
4329
+ \u26A0\uFE0F Built ${Z.views.length} views with ${Z.errors.length} errors`);return Z}function y_($,X){let Z=x$.watch($.viewsDir,{recursive:!0},async(Q,Y)=>{if(!Y)return;if(Y.endsWith(".stx")||Y.endsWith(".ts")||Y.endsWith(".js")){if($.debug)console.log(`
4330
+ File changed: ${Y}, rebuilding...`);let J=await $Y($);X?.(J)}});return{close:()=>Z.close()}}async function v_($,X={},Z={}){let Q={...Z,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await c8($,X,Q);Y=await XY(Y),Y=Y.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),Y=Y.replace(/<style\b([^>]*)>[\s\S]*?<\/style>/gi,(G,W)=>/\bdata-(?:css=["']generated["']|stx-)/i.test(W)?"":G),Y=Y.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),Y=Y.replace(/\n\s*\n\s*\n/g,`
4331
4331
 
4332
- `).trim();let J=aQ(Y);return{html:Y,text:J}}async function cQ($){try{let{generateCss:X,extractClassNames:Z}=await import("./chunk-rwwt24e3.js");if(Z($).size===0)return $;let Y=await X($);if(!Y)return $;let J=lQ(Y);if(J.size===0)return $;return $.replace(/(<[a-z][a-z0-9]*)((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s+)class\s*=\s*"([^"]*)"((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?>)/gi,(G,W,K,_,U,F)=>{let z=_.split(/\s+/).filter(Boolean),j=[];for(let N of z){let V=J.get(N);if(V)j.push(V)}if(j.length===0)return`${W}${K}class="${_}"${U}${F}`;let H=j.join("; "),O=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(O){let N=`${H}; ${O[1]}`,V=K.replace(/style\s*=\s*"[^"]*"/,`style="${N}"`),M=U.replace(/style\s*=\s*"[^"]*"/,`style="${N}"`);return`${W}${V}class="${_}"${M}${F}`}return`${W}${K}class="${_}" style="${H}"${U}${F}`})}catch{return $}}function lQ($){let X=new Map,Z=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Q=Z.exec($);while(Q!==null){let Y=Q[1].replace(/\\/g,""),J=Q[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Q=Z.exec($)}return X}function iQ($,X){let Z=X.replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim(),Q=$.replace(/&amp;/g,"&").trim();if(!Q||Q.startsWith("#")||/^javascript:/i.test(Q))return Z;let Y=Q.replace(/^mailto:/i,"").replace(/^https?:\/\//i,"").replace(/\/$/,"");if(!Z)return Q.replace(/^mailto:/i,"");if(Z.replace(/^https?:\/\//i,"").replace(/\/$/,"")===Y)return Z;return`${Z} (${Q.replace(/^mailto:/i,"")})`}function aQ($){return $.replace(/<head\b[\s\S]*?<\/head>/gi,"").replace(/<(style|script)\b[\s\S]*?<\/\1>/gi,"").replace(/<(div|span|p)\b[^>]*\bstyle="[^"]*display:\s*none[^"]*"[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<a\b[^>]*?\bhref\s*=\s*(?:"([^"]*)"|'([^']*)')[^>]*>([\s\S]*?)<\/a>/gi,(X,Z,Q,Y)=>iQ(Z??Q??"",Y)).replace(/<br\s*\/?>/gi,`
4332
+ `).trim();let J=YY(Y);return{html:Y,text:J}}async function XY($){try{let{generateCss:X,extractClassNames:Z}=await import("./chunk-n9cqrw9j.js");if(Z($).size===0)return $;let Y=await X($);if(!Y)return $;let J=ZY(Y);if(J.size===0)return $;return $.replace(/(<[a-z][a-z0-9]*)((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s+)class\s*=\s*"([^"]*)"((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?>)/gi,(G,W,K,_,U,F)=>{let z=_.split(/\s+/).filter(Boolean),j=[];for(let N of z){let V=J.get(N);if(V)j.push(V)}if(j.length===0)return`${W}${K}class="${_}"${U}${F}`;let H=j.join("; "),O=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(O){let N=`${H}; ${O[1]}`,V=K.replace(/style\s*=\s*"[^"]*"/,`style="${N}"`),M=U.replace(/style\s*=\s*"[^"]*"/,`style="${N}"`);return`${W}${V}class="${_}"${M}${F}`}return`${W}${K}class="${_}" style="${H}"${U}${F}`})}catch{return $}}function ZY($){let X=new Map,Z=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Q=Z.exec($);while(Q!==null){let Y=Q[1].replace(/\\/g,""),J=Q[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Q=Z.exec($)}return X}function QY($,X){let Z=X.replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim(),Q=$.replace(/&amp;/g,"&").trim();if(!Q||Q.startsWith("#")||/^javascript:/i.test(Q))return Z;let Y=Q.replace(/^mailto:/i,"").replace(/^https?:\/\//i,"").replace(/\/$/,"");if(!Z)return Q.replace(/^mailto:/i,"");if(Z.replace(/^https?:\/\//i,"").replace(/\/$/,"")===Y)return Z;return`${Z} (${Q.replace(/^mailto:/i,"")})`}function YY($){return $.replace(/<head\b[\s\S]*?<\/head>/gi,"").replace(/<(style|script)\b[\s\S]*?<\/\1>/gi,"").replace(/<(div|span|p)\b[^>]*\bstyle="[^"]*display:\s*none[^"]*"[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<a\b[^>]*?\bhref\s*=\s*(?:"([^"]*)"|'([^']*)')[^>]*>([\s\S]*?)<\/a>/gi,(X,Z,Q,Y)=>QY(Z??Q??"",Y)).replace(/<br\s*\/?>/gi,`
4333
4333
  `).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
4334
4334
  `).replace(/<\/td>/gi,"\t").replace(/<[^>]*>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&copy;/g,"(c)").replace(/&middot;/g,"-").replace(/\n\s*\n\s*\n/g,`
4335
4335
 
4336
- `).trim()}function sQ($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function rQ($){let X={};for(let Z of Object.keys($))if(!Z.startsWith("__"))X[Z]=$[Z];return X}function M_($){let{template:X,context:Z={},title:Q="stx App"}=$,Y=rQ(Z),J=sQ(JSON.stringify(Y));return`<!DOCTYPE html>
4336
+ `).trim()}function JY($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function GY($){let X={};for(let Z of Object.keys($))if(!Z.startsWith("__"))X[Z]=$[Z];return X}function f_($){let{template:X,context:Z={},title:Q="stx App"}=$,Y=GY(Z),J=JY(JSON.stringify(Y));return`<!DOCTYPE html>
4337
4337
  <html lang="en">
4338
4338
  <head>
4339
4339
  <meta charset="UTF-8">
@@ -4353,8 +4353,8 @@ File changed: ${Y}, rebuilding...`);let J=await pQ($);X?.(J)}});return{close:()=
4353
4353
  }
4354
4354
  </script>
4355
4355
  </body>
4356
- </html>`}var q1=Symbol.for("stx.Fragment"),nQ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),f8=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),h8={className:"class",htmlFor:"for",tabIndex:"tabindex",autoFocus:"autofocus",autoPlay:"autoplay",crossOrigin:"crossorigin",dateTime:"datetime",encType:"enctype",formAction:"formaction",formEncType:"formenctype",formMethod:"formmethod",formNoValidate:"formnovalidate",formTarget:"formtarget",frameBorder:"frameborder",hrefLang:"hreflang",httpEquiv:"http-equiv",inputMode:"inputmode",maxLength:"maxlength",mediaGroup:"mediagroup",minLength:"minlength",noModule:"nomodule",noValidate:"novalidate",playsInline:"playsinline",readOnly:"readonly",rowSpan:"rowspan",colSpan:"colspan",srcDoc:"srcdoc",srcLang:"srclang",srcSet:"srcset",useMap:"usemap"};function oQ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function m5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function d8($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[g8($)];return $.flat(1/0).map(g8).filter((X)=>X!=="")}function g8($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function A1($,X,Z){let{children:Q,ref:Y,key:J,...G}=X||{};return{type:$,props:Object.keys(G).length>0?G:null,children:d8(Q),key:Z??J??void 0,ref:Y??void 0}}var tQ=A1,eQ=A1;function u8($){return Object.entries($).filter(([,X])=>X!=null&&X!==!1).map(([X,Z])=>{let Q=X.replace(/[A-Z]/g,(J)=>`-${J.toLowerCase()}`),Y=typeof Z==="number"&&!Q.startsWith("--")&&Q!=="opacity"&&Q!=="z-index"&&Q!=="flex-grow"&&Q!=="flex-shrink"&&Q!=="order"&&Q!=="font-weight"&&Q!=="line-height"?`${Z}px`:String(Z);return`${Q}: ${Y}`}).join("; ")}function p5($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(p5).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,X])=>X).map(([X])=>X).join(" ");return""}function $Y($){if(!$)return"";let X=[];for(let[Z,Q]of Object.entries($)){if(Z==="key"||Z==="ref"||Z==="children"||Z==="innerHTML"||Z==="dangerouslySetInnerHTML")continue;if(Z.startsWith("on")&&typeof Q==="function")continue;let Y=h8[Z]||Z;if(Y==="class"||Y==="className"){let J=p5(Q);if(J)X.push(` class="${m5(J)}"`);continue}if(Y==="style"){let J=typeof Q==="string"?Q:u8(Q);if(J)X.push(` style="${m5(J)}"`);continue}if(f8.has(Y)){if(Q)X.push(` ${Y}`);continue}if(Q!=null&&Q!==!1)X.push(` ${Y}="${m5(String(Q))}"`)}return X.join("")}function N1($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return oQ($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(N1).join("");if($.type===q1)return $.children.map(N1).join("");if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return N1(J)}let X=$.type,Z=$Y($.props),Q=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Q!=null)return`<${X}${Z}>${Q}</${X}>`;if(nQ.has(X))return`<${X}${Z}>`;let Y=$.children.map(N1).join("");return`<${X}${Z}>${Y}</${X}>`}function XY($){return new ReadableStream({start(X){X.enqueue(N1($)),X.close()}})}function ZY($,X){if(!X)return;for(let[Z,Q]of Object.entries(X)){if(Z==="key"||Z==="ref"||Z==="children"||Z==="innerHTML"||Z==="dangerouslySetInnerHTML")continue;let Y=h8[Z]||Z;if(Z.startsWith("on")&&typeof Q==="function"){let J=Z.slice(2).toLowerCase();$.addEventListener(J,Q);continue}if(Y==="class"||Y==="className"){let J=p5(Q);if(J)$.setAttribute("class",J);continue}if(Y==="style"){let J=typeof Q==="string"?Q:u8(Q);if(J)$.setAttribute("style",J);continue}if(f8.has(Y)){if(Q)$.setAttribute(Y,"");continue}if(Q!=null&&Q!==!1)$.setAttribute(Y,String(Q))}}function p1($,X){if($==null||typeof $==="boolean")return;if(typeof $==="string"){X.appendChild(document.createTextNode($));return}if(typeof $==="number"){X.appendChild(document.createTextNode(String($)));return}if(Array.isArray($)){for(let Y of $)p1(Y,X);return}if($.type===q1){for(let Y of $.children)p1(Y,X);return}if(typeof $.type==="function"){let Y=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});p1(Y,X);return}let Z=document.createElement($.type);ZY(Z,$.props);let Q=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Q!=null)Z.innerHTML=Q;else for(let Y of $.children)p1(Y,Z);if($.ref){if(typeof $.ref==="function")$.ref(Z)}X.appendChild(Z)}function QY($){if($.when)return A1(q1,{children:$.children});return $.fallback??null}function YY($){let X=$.each;if(!X||X.length===0)return $.fallback??null;let Z=Array.isArray($.children)?$.children[0]:$.children,Q=X.map((Y,J)=>Z(Y,J));return A1(q1,{children:Q})}function JY($){return A1(q1,{children:$.children})}function GY($,X,...Z){let{key:Q,ref:Y,...J}=X||{};return{type:$,props:Object.keys(J).length>0?J:{},children:d8(Z.length===1?Z[0]:Z),key:Q??void 0,ref:Y??void 0}}function m8($,X){let Z=new Set,Q=new Map,Y=new Map,J={globalProperties:{},performance:!1,compilerOptions:{}},G={config:J,_components:Q,_directives:Y,_installedPlugins:Z,use(W,...K){if(Z.has(W))return G;if(Z.add(W),typeof W==="function")W(G,...K);else if(typeof W.install==="function")W.install(G,...K);return G},provide(W,K){return c5(W,K),G},component(W,K){if(!K)return Q.get(W);return Q.set(W,K),G},directive(W,K){if(!K)return Y.get(W);return Y.set(W,K),G},mount(W){if(typeof document<"u"){let K=globalThis.__stx_globals||(globalThis.__stx_globals={});Object.assign(K,J.globalProperties),document.querySelectorAll("[v-cloak]").forEach((_)=>{_.removeAttribute("v-cloak")})}return G},unmount(){Q.clear(),Y.clear(),Z.clear()}};return G}function WY($){return class extends HTMLElement{_component;_shadow;constructor(){super();this._shadow=this.attachShadow({mode:"open"}),this._component=$}connectedCallback(){if(this._component?.render){let X=this._component.render();if(typeof X==="string")this._shadow.innerHTML=X}else if(this._component?.template)this._shadow.innerHTML=this._component.template;else if(typeof this._component==="string")this._shadow.innerHTML=this._component}disconnectedCallback(){this._shadow.innerHTML=""}}}function KY($,...X){let Z=X[0]??{},Q=new Set,Y=String($).replace(/(\/)?:([^/?*]+)([?*])?/g,(W,K,_,U)=>{let F=Z[_];if(Q.add(_),F===void 0||F===null||F===""){if(U==="?")return"";return W}let z=Array.isArray(F)?F.map((j)=>encodeURIComponent(String(j))).join("/"):U==="*"?String(F).split("/").map((j)=>encodeURIComponent(j)).join("/"):encodeURIComponent(String(F));return`${K??""}${z}`}),J=Object.keys(Z).filter((W)=>!Q.has(W));if(J.length===0)return Y;let G=new URLSearchParams;for(let W of J){let K=Z[W];if(Array.isArray(K))K.forEach((_)=>G.append(W,String(_)));else if(K!==void 0&&K!==null)G.set(W,String(K))}return`${Y}?${G.toString()}`}import O0 from"fs";import G0 from"path";function p8($){try{return O0.statSync($).mtimeMs}catch{return null}}function k$($,X){let Z=Math.max(0,Math.round((X-$)/1000));if(Z<60)return`${Z}s ago`;if(Z<3600)return`${Math.round(Z/60)}m ago`;return`${Math.round(Z/3600)}h ago`}function _Y($,X){try{return globalThis.Bun?.resolveSync($,X)??null}catch{return null}}function c8($,X="stx"){let Z=G0.resolve($);for(let Q=0;Q<10;Q++){let Y=G0.join(Z,"pantry","@stacksjs",X);if(O0.existsSync(Y))return Y;let J=G0.dirname(Z);if(J===Z)break;Z=J}return null}var l8=["@stacksjs/stx","bun-plugin-stx"];function UY($){try{let X=O0.readFileSync(G0.join($,"package.json"),"utf8"),Z=JSON.parse(X)?.version;return typeof Z==="string"?Z:null}catch{return null}}function BY($,X=6){let Z=G0.resolve($),Q=[],Y=new Set;function J(W,K){if(K>X)return;let _;try{_=O0.realpathSync(W)}catch{return}if(Y.has(_))return;Y.add(_);for(let F of l8){let z=G0.join(W,F),j=UY(z);if(j!==null)Q.push({name:F,version:j,dir:G0.relative(Z,z)||z,nested:K>0})}let U;try{U=O0.readdirSync(W,{withFileTypes:!0})}catch{return}for(let F of U){if(!F.isDirectory()&&!F.isSymbolicLink())continue;if(F.name===".bin"||F.name===".cache")continue;let z=G0.join(W,F.name);if(F.name.startsWith("@")){let H;try{H=O0.readdirSync(z,{withFileTypes:!0})}catch{continue}for(let L of H){let O=G0.join(z,L.name,"node_modules");if(O0.existsSync(O))J(O,K+1)}continue}let j=G0.join(z,"node_modules");if(O0.existsSync(j))J(j,K+1)}}let G=G0.join(Z,"node_modules");if(O0.existsSync(G))J(G,0);return Q}function LY($){let X=[];for(let Z of l8){let Q=$.filter((G)=>G.name===Z);if(Q.length<=1)continue;let Y=[...new Set(Q.map((G)=>G.version))],J=Q.map((G)=>`${G.version} at ${G.dir}`).join("; ");if(Y.length===1){X.push({name:`${Z} copies`,status:"info",detail:`${Q.length} copies, all ${Y[0]} \u2014 duplicated but in agreement`});continue}X.push({name:`${Z} copies disagree`,status:"error",detail:`${Y.length} versions installed, so which one runs depends on who imports it: ${J}`,fix:`remove the nested copies, or add an overrides entry pinning ${Z}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${Z}/package.json' -exec grep -H '"version"' {} +`})}return X}async function FY($={}){let X=$.cwd?G0.resolve($.cwd):process.cwd(),Z=$.resolve??_Y,Q=Date.now(),Y=[],J=Z("@stacksjs/stx",X);Y.push(J?{name:"@stacksjs/stx resolves to",status:"ok",detail:J}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let G=Z("bun-plugin-stx",X);if(G)Y.push({name:"bun-plugin-stx resolves to",status:"ok",detail:G});for(let K of LY(BY(X)))Y.push(K);let W=c8(X,"stx");if(!W)Y.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let K=G0.join(W,"src/signals.ts"),_=[G0.join(W,"dist/index.js"),G0.join(W,"dist/signals.js")].find((H)=>O0.existsSync(H))||null,U=p8(K),F=_?p8(_):null;if(U==null)Y.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${W} but no src/signals.ts to compare`});else if(F==null)Y.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${W} && bun build.ts`});else if(F<U){let H=Math.round((U-F)/1000);Y.push({name:"pantry dist freshness",status:"error",detail:`dist (${k$(F,Q)}) is OLDER than src/signals.ts (${k$(U,Q)}) by ${H}s \u2014 your edit isn't built`,fix:`cd ${W} && bun build.ts`})}else Y.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${k$(U,Q)}, dist ${k$(F,Q)})`});let z=G0.join(X,"node_modules/@stacksjs/stx"),j=null;try{j=O0.lstatSync(z)}catch{j=null}if(!j)Y.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(j.isSymbolicLink()){let H=null;try{H=O0.realpathSync(z)}catch{}let L=(()=>{try{return O0.realpathSync(W)}catch{return W}})();Y.push(H===L?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${H||"(dangling)"}, not pantry`})}else Y.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(Y.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),$.generateRuntime)try{let _=$.generateRuntime().length;Y.push(_>1000?{name:"signals runtime",status:"ok",detail:`generated ${_.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${_} chars \u2014 suspiciously short`})}catch(K){Y.push({name:"signals runtime",status:"error",detail:`failed to generate: ${K.message}`})}return{checks:Y,ok:!Y.some((K)=>K.status==="error")}}function zY($){let X={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},Z=["stx runtime resolution:"];for(let Q of $.checks)if(Z.push(` ${X[Q.status]} ${Q.name}: ${Q.detail}`),Q.fix)Z.push(` \u2192 ${Q.fix}`);return Z.push(""),Z.push($.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),Z.join(`
4357
- `)}var{Glob:SY}=globalThis.Bun;import{cpSync as Z3,existsSync as p$,mkdirSync as Q3,readFileSync as Y3,readdirSync as PY,rmSync as bY,statSync as yY,unlinkSync as vY,writeFileSync as u$}from"fs";import{dirname as gY,join as P0,relative as fY}from"path";import J3 from"process";import a0 from"path";function a8($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function s8($,X,Z){let Q=a8(X),Y=Z?a8(Z):"";return`<!DOCTYPE html>
4356
+ </html>`}var q1=Symbol.for("stx.Fragment"),WY=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),i8=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),a8={className:"class",htmlFor:"for",tabIndex:"tabindex",autoFocus:"autofocus",autoPlay:"autoplay",crossOrigin:"crossorigin",dateTime:"datetime",encType:"enctype",formAction:"formaction",formEncType:"formenctype",formMethod:"formmethod",formNoValidate:"formnovalidate",formTarget:"formtarget",frameBorder:"frameborder",hrefLang:"hreflang",httpEquiv:"http-equiv",inputMode:"inputmode",maxLength:"maxlength",mediaGroup:"mediagroup",minLength:"minlength",noModule:"nomodule",noValidate:"novalidate",playsInline:"playsinline",readOnly:"readonly",rowSpan:"rowspan",colSpan:"colspan",srcDoc:"srcdoc",srcLang:"srclang",srcSet:"srcset",useMap:"usemap"};function KY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function l5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function s8($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[l8($)];return $.flat(1/0).map(l8).filter((X)=>X!=="")}function l8($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function V1($,X,Z){let{children:Q,ref:Y,key:J,...G}=X||{};return{type:$,props:Object.keys(G).length>0?G:null,children:s8(Q),key:Z??J??void 0,ref:Y??void 0}}var _Y=V1,UY=V1;function r8($){return Object.entries($).filter(([,X])=>X!=null&&X!==!1).map(([X,Z])=>{let Q=X.replace(/[A-Z]/g,(J)=>`-${J.toLowerCase()}`),Y=typeof Z==="number"&&!Q.startsWith("--")&&Q!=="opacity"&&Q!=="z-index"&&Q!=="flex-grow"&&Q!=="flex-shrink"&&Q!=="order"&&Q!=="font-weight"&&Q!=="line-height"?`${Z}px`:String(Z);return`${Q}: ${Y}`}).join("; ")}function i5($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(i5).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,X])=>X).map(([X])=>X).join(" ");return""}function BY($){if(!$)return"";let X=[];for(let[Z,Q]of Object.entries($)){if(Z==="key"||Z==="ref"||Z==="children"||Z==="innerHTML"||Z==="dangerouslySetInnerHTML")continue;if(Z.startsWith("on")&&typeof Q==="function")continue;let Y=a8[Z]||Z;if(Y==="class"||Y==="className"){let J=i5(Q);if(J)X.push(` class="${l5(J)}"`);continue}if(Y==="style"){let J=typeof Q==="string"?Q:r8(Q);if(J)X.push(` style="${l5(J)}"`);continue}if(i8.has(Y)){if(Q)X.push(` ${Y}`);continue}if(Q!=null&&Q!==!1)X.push(` ${Y}="${l5(String(Q))}"`)}return X.join("")}function A1($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return KY($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(A1).join("");if($.type===q1)return $.children.map(A1).join("");if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return A1(J)}let X=$.type,Z=BY($.props),Q=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Q!=null)return`<${X}${Z}>${Q}</${X}>`;if(WY.has(X))return`<${X}${Z}>`;let Y=$.children.map(A1).join("");return`<${X}${Z}>${Y}</${X}>`}function LY($){return new ReadableStream({start(X){X.enqueue(A1($)),X.close()}})}function FY($,X){if(!X)return;for(let[Z,Q]of Object.entries(X)){if(Z==="key"||Z==="ref"||Z==="children"||Z==="innerHTML"||Z==="dangerouslySetInnerHTML")continue;let Y=a8[Z]||Z;if(Z.startsWith("on")&&typeof Q==="function"){let J=Z.slice(2).toLowerCase();$.addEventListener(J,Q);continue}if(Y==="class"||Y==="className"){let J=i5(Q);if(J)$.setAttribute("class",J);continue}if(Y==="style"){let J=typeof Q==="string"?Q:r8(Q);if(J)$.setAttribute("style",J);continue}if(i8.has(Y)){if(Q)$.setAttribute(Y,"");continue}if(Q!=null&&Q!==!1)$.setAttribute(Y,String(Q))}}function l1($,X){if($==null||typeof $==="boolean")return;if(typeof $==="string"){X.appendChild(document.createTextNode($));return}if(typeof $==="number"){X.appendChild(document.createTextNode(String($)));return}if(Array.isArray($)){for(let Y of $)l1(Y,X);return}if($.type===q1){for(let Y of $.children)l1(Y,X);return}if(typeof $.type==="function"){let Y=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});l1(Y,X);return}let Z=document.createElement($.type);FY(Z,$.props);let Q=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Q!=null)Z.innerHTML=Q;else for(let Y of $.children)l1(Y,Z);if($.ref){if(typeof $.ref==="function")$.ref(Z)}X.appendChild(Z)}function zY($){if($.when)return V1(q1,{children:$.children});return $.fallback??null}function jY($){let X=$.each;if(!X||X.length===0)return $.fallback??null;let Z=Array.isArray($.children)?$.children[0]:$.children,Q=X.map((Y,J)=>Z(Y,J));return V1(q1,{children:Q})}function HY($){return V1(q1,{children:$.children})}function OY($,X,...Z){let{key:Q,ref:Y,...J}=X||{};return{type:$,props:Object.keys(J).length>0?J:{},children:s8(Z.length===1?Z[0]:Z),key:Q??void 0,ref:Y??void 0}}function n8($,X){let Z=new Set,Q=new Map,Y=new Map,J={globalProperties:{},performance:!1,compilerOptions:{}},G={config:J,_components:Q,_directives:Y,_installedPlugins:Z,use(W,...K){if(Z.has(W))return G;if(Z.add(W),typeof W==="function")W(G,...K);else if(typeof W.install==="function")W.install(G,...K);return G},provide(W,K){return a5(W,K),G},component(W,K){if(!K)return Q.get(W);return Q.set(W,K),G},directive(W,K){if(!K)return Y.get(W);return Y.set(W,K),G},mount(W){if(typeof document<"u"){let K=globalThis.__stx_globals||(globalThis.__stx_globals={});Object.assign(K,J.globalProperties),document.querySelectorAll("[v-cloak]").forEach((_)=>{_.removeAttribute("v-cloak")})}return G},unmount(){Q.clear(),Y.clear(),Z.clear()}};return G}function NY($){return class extends HTMLElement{_component;_shadow;constructor(){super();this._shadow=this.attachShadow({mode:"open"}),this._component=$}connectedCallback(){if(this._component?.render){let X=this._component.render();if(typeof X==="string")this._shadow.innerHTML=X}else if(this._component?.template)this._shadow.innerHTML=this._component.template;else if(typeof this._component==="string")this._shadow.innerHTML=this._component}disconnectedCallback(){this._shadow.innerHTML=""}}}function AY($,...X){let Z=X[0]??{},Q=new Set,Y=String($).replace(/(\/)?:([^/?*]+)([?*])?/g,(W,K,_,U)=>{let F=Z[_];if(Q.add(_),F===void 0||F===null||F===""){if(U==="?")return"";return W}let z=Array.isArray(F)?F.map((j)=>encodeURIComponent(String(j))).join("/"):U==="*"?String(F).split("/").map((j)=>encodeURIComponent(j)).join("/"):encodeURIComponent(String(F));return`${K??""}${z}`}),J=Object.keys(Z).filter((W)=>!Q.has(W));if(J.length===0)return Y;let G=new URLSearchParams;for(let W of J){let K=Z[W];if(Array.isArray(K))K.forEach((_)=>G.append(W,String(_)));else if(K!==void 0&&K!==null)G.set(W,String(K))}return`${Y}?${G.toString()}`}import O0 from"fs";import G0 from"path";function o8($){try{return O0.statSync($).mtimeMs}catch{return null}}function P$($,X){let Z=Math.max(0,Math.round((X-$)/1000));if(Z<60)return`${Z}s ago`;if(Z<3600)return`${Math.round(Z/60)}m ago`;return`${Math.round(Z/3600)}h ago`}function qY($,X){try{return globalThis.Bun?.resolveSync($,X)??null}catch{return null}}function t8($,X="stx"){let Z=G0.resolve($);for(let Q=0;Q<10;Q++){let Y=G0.join(Z,"pantry","@stacksjs",X);if(O0.existsSync(Y))return Y;let J=G0.dirname(Z);if(J===Z)break;Z=J}return null}var e8=["@stacksjs/stx","bun-plugin-stx"];function VY($){try{let X=O0.readFileSync(G0.join($,"package.json"),"utf8"),Z=JSON.parse(X)?.version;return typeof Z==="string"?Z:null}catch{return null}}function MY($,X=6){let Z=G0.resolve($),Q=[],Y=new Set;function J(W,K){if(K>X)return;let _;try{_=O0.realpathSync(W)}catch{return}if(Y.has(_))return;Y.add(_);for(let F of e8){let z=G0.join(W,F),j=VY(z);if(j!==null)Q.push({name:F,version:j,dir:G0.relative(Z,z)||z,nested:K>0})}let U;try{U=O0.readdirSync(W,{withFileTypes:!0})}catch{return}for(let F of U){if(!F.isDirectory()&&!F.isSymbolicLink())continue;if(F.name===".bin"||F.name===".cache")continue;let z=G0.join(W,F.name);if(F.name.startsWith("@")){let H;try{H=O0.readdirSync(z,{withFileTypes:!0})}catch{continue}for(let L of H){let O=G0.join(z,L.name,"node_modules");if(O0.existsSync(O))J(O,K+1)}continue}let j=G0.join(z,"node_modules");if(O0.existsSync(j))J(j,K+1)}}let G=G0.join(Z,"node_modules");if(O0.existsSync(G))J(G,0);return Q}function EY($){let X=[];for(let Z of e8){let Q=$.filter((G)=>G.name===Z);if(Q.length<=1)continue;let Y=[...new Set(Q.map((G)=>G.version))],J=Q.map((G)=>`${G.version} at ${G.dir}`).join("; ");if(Y.length===1){X.push({name:`${Z} copies`,status:"info",detail:`${Q.length} copies, all ${Y[0]} \u2014 duplicated but in agreement`});continue}X.push({name:`${Z} copies disagree`,status:"error",detail:`${Y.length} versions installed, so which one runs depends on who imports it: ${J}`,fix:`remove the nested copies, or add an overrides entry pinning ${Z}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${Z}/package.json' -exec grep -H '"version"' {} +`})}return X}async function IY($={}){let X=$.cwd?G0.resolve($.cwd):process.cwd(),Z=$.resolve??qY,Q=Date.now(),Y=[],J=Z("@stacksjs/stx",X);Y.push(J?{name:"@stacksjs/stx resolves to",status:"ok",detail:J}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let G=Z("bun-plugin-stx",X);if(G)Y.push({name:"bun-plugin-stx resolves to",status:"ok",detail:G});for(let K of EY(MY(X)))Y.push(K);let W=t8(X,"stx");if(!W)Y.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let K=G0.join(W,"src/signals.ts"),_=[G0.join(W,"dist/index.js"),G0.join(W,"dist/signals.js")].find((H)=>O0.existsSync(H))||null,U=o8(K),F=_?o8(_):null;if(U==null)Y.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${W} but no src/signals.ts to compare`});else if(F==null)Y.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${W} && bun build.ts`});else if(F<U){let H=Math.round((U-F)/1000);Y.push({name:"pantry dist freshness",status:"error",detail:`dist (${P$(F,Q)}) is OLDER than src/signals.ts (${P$(U,Q)}) by ${H}s \u2014 your edit isn't built`,fix:`cd ${W} && bun build.ts`})}else Y.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${P$(U,Q)}, dist ${P$(F,Q)})`});let z=G0.join(X,"node_modules/@stacksjs/stx"),j=null;try{j=O0.lstatSync(z)}catch{j=null}if(!j)Y.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(j.isSymbolicLink()){let H=null;try{H=O0.realpathSync(z)}catch{}let L=(()=>{try{return O0.realpathSync(W)}catch{return W}})();Y.push(H===L?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${H||"(dangling)"}, not pantry`})}else Y.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(Y.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),$.generateRuntime)try{let _=$.generateRuntime().length;Y.push(_>1000?{name:"signals runtime",status:"ok",detail:`generated ${_.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${_} chars \u2014 suspiciously short`})}catch(K){Y.push({name:"signals runtime",status:"error",detail:`failed to generate: ${K.message}`})}return{checks:Y,ok:!Y.some((K)=>K.status==="error")}}function RY($){let X={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},Z=["stx runtime resolution:"];for(let Q of $.checks)if(Z.push(` ${X[Q.status]} ${Q.name}: ${Q.detail}`),Q.fix)Z.push(` \u2192 ${Q.fix}`);return Z.push(""),Z.push($.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),Z.join(`
4357
+ `)}var{Glob:pY}=globalThis.Bun;import{cpSync as U3,existsSync as i$,mkdirSync as B3,readFileSync as L3,readdirSync as cY,rmSync as lY,statSync as iY,unlinkSync as aY,writeFileSync as c$}from"fs";import{dirname as sY,join as P0,relative as rY}from"path";import F3 from"process";import a0 from"path";function X3($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Z3($,X,Z){let Q=X3(X),Y=Z?X3(Z):"";return`<!DOCTYPE html>
4358
4358
  <html>
4359
4359
  <head>
4360
4360
  <title>stx Error</title>
@@ -4370,53 +4370,53 @@ File changed: ${Y}, rebuilding...`);let J=await pQ($);X?.(J)}});return{close:()=
4370
4370
  ${Y?`<div class="file-path">File: ${Y}</div>`:""}
4371
4371
  <pre>${Q}</pre>
4372
4372
  </body>
4373
- </html>`}function i8($){return{name:"bun-plugin-stx",async setup(X){let Z={};try{Z=await n0(process.cwd())}catch{}let Q={...C$,...Z,...$},Y=new Set;if(!X.config.root&&X.config.entrypoints?.length){let K=X.config.entrypoints.map((_)=>a0.dirname(a0.resolve(_))).reduce((_,U)=>{let F=_.split(a0.sep),z=U.split(a0.sep),j=0;while(j<F.length&&j<z.length&&F[j]===z[j])j++;return F.slice(0,j).join(a0.sep)});X.config.root=K}let J=Q.webComponents?.enabled?`./${a0.relative(a0.dirname(X.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",G=[];if(Q.webComponents?.enabled)try{let W=await B$(Q,Y);if(G.push(...W),Q.debug&&W.length>0)console.log(`Successfully built ${W.length} web components`)}catch(W){console.error("Failed to build web components:",W)}X.onResolve({filter:/^\//},(W)=>{if(W.path.startsWith("//"))return null;if(!W.importer)return null;return{external:!0,path:W.path}}),X.onLoad({filter:/\.md$/},async(W)=>{let K=W.path;try{let{content:_,data:U}=await k0(K,Q);return{contents:`// ${K}
4373
+ </html>`}function $3($){return{name:"bun-plugin-stx",async setup(X){let Z={};try{Z=await n0(process.cwd())}catch{}let Q={...S$,...Z,...$},Y=new Set;if(!X.config.root&&X.config.entrypoints?.length){let K=X.config.entrypoints.map((_)=>a0.dirname(a0.resolve(_))).reduce((_,U)=>{let F=_.split(a0.sep),z=U.split(a0.sep),j=0;while(j<F.length&&j<z.length&&F[j]===z[j])j++;return F.slice(0,j).join(a0.sep)});X.config.root=K}let J=Q.webComponents?.enabled?`./${a0.relative(a0.dirname(X.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",G=[];if(Q.webComponents?.enabled)try{let W=await z$(Q,Y);if(G.push(...W),Q.debug&&W.length>0)console.log(`Successfully built ${W.length} web components`)}catch(W){console.error("Failed to build web components:",W)}X.onResolve({filter:/^\//},(W)=>{if(W.path.startsWith("//"))return null;if(!W.importer)return null;return{external:!0,path:W.path}}),X.onLoad({filter:/\.md$/},async(W)=>{let K=W.path;try{let{content:_,data:U}=await k0(K,Q);return{contents:`// ${K}
4374
4374
  const content = ${JSON.stringify(_)};
4375
4375
  const data = ${JSON.stringify(U)};
4376
4376
 
4377
4377
  export { content, data };
4378
4378
  export { content as default };
4379
- `,loader:"js"}}catch(_){console.error("Markdown Processing Error:",_);let U=s8("Markdown Processing Error",_.message||"Unknown error",K);return{contents:`// ${K}
4379
+ `,loader:"js"}}catch(_){console.error("Markdown Processing Error:",_);let U=Z3("Markdown Processing Error",_.message||"Unknown error",K);return{contents:`// ${K}
4380
4380
  const content = ${JSON.stringify(U)};
4381
4381
  const data = {};
4382
4382
 
4383
4383
  export { content, data };
4384
4384
  export { content as default };
4385
- `,loader:"js"}}}),X.onLoad({filter:/\.(jsx|tsx)$/},async(W)=>{let K=W.path;try{let _=await Bun.file(K).text(),U=K.endsWith(".tsx")?"tsx":"jsx";return{contents:new Bun.Transpiler({loader:U,jsxOptimizationInline:!0}).transformSync(_),loader:"js"}}catch(_){return console.error("JSX Processing Error:",_),{contents:"export default function() { return null; }",loader:"js"}}}),X.onLoad({filter:/\.stx$/},async({path:W})=>{try{let K=new Set;if(Q.cache&&Q.cachePath){let V=await _$(W,Q);if(V){if(Q.debug)console.log(`Using cached version of ${W}`);return{contents:V,loader:"html"}}}let _=await Bun.file(W).text(),U=_,F=_.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(F)U=F[1].trim();let z=n8(_),j=z.client.map((V)=>V.fullTag),H=z.server.map((V)=>V.content),L=U;for(let V of H){let M=V.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");L=L.replace(new RegExp(`<script\\b[^>]*>${M}<\\/script>`,"gi"),"")}for(let V of j){let M=V.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");L=L.replace(M,"")}let O={__filename:W,__dirname:a0.dirname(W),__stx:{webComponentsPath:J,builtComponents:G},__stx_options:Q,__stx_sfc_mode:!0};for(let V of H)await E0(V,O,W);let N=L;if(N=await I0(N,O,W,Q,K),j.length>0){let V=O.__stx_event_bindings||[],q=(await Promise.all(j.map(async(I)=>{let E=I.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!E)return I;return r8(E[1],{eventBindings:V,templateContent:N})}))).join(`
4386
- `);if(N.match(/(<\/body>)/i))N=N.replace(/(<\/body>)/i,`${q}
4385
+ `,loader:"js"}}}),X.onLoad({filter:/\.(jsx|tsx)$/},async(W)=>{let K=W.path;try{let _=await Bun.file(K).text(),U=K.endsWith(".tsx")?"tsx":"jsx";return{contents:new Bun.Transpiler({loader:U,jsxOptimizationInline:!0}).transformSync(_),loader:"js"}}catch(_){return console.error("JSX Processing Error:",_),{contents:"export default function() { return null; }",loader:"js"}}}),X.onLoad({filter:/\.stx$/},async({path:W})=>{try{let K=new Set;if(Q.cache&&Q.cachePath){let V=await L$(W,Q);if(V){if(Q.debug)console.log(`Using cached version of ${W}`);return{contents:V,loader:"html"}}}let _=await Bun.file(W).text(),U=_,F=_.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(F)U=F[1].trim();let z=Y3(_),j=z.client.map((V)=>V.fullTag),H=z.server.map((V)=>V.content),L=U;for(let V of H){let M=V.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");L=L.replace(new RegExp(`<script\\b[^>]*>${M}<\\/script>`,"gi"),"")}for(let V of j){let M=V.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");L=L.replace(M,"")}let O={__filename:W,__dirname:a0.dirname(W),__stx:{webComponentsPath:J,builtComponents:G},__stx_options:Q,__stx_sfc_mode:!0};for(let V of H)await E0(V,O,W);let N=L;if(N=await I0(N,O,W,Q,K),j.length>0){let V=O.__stx_event_bindings||[],A=(await Promise.all(j.map(async(I)=>{let E=I.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!E)return I;return Q3(E[1],{eventBindings:V,templateContent:N})}))).join(`
4386
+ `);if(N.match(/(<\/body>)/i))N=N.replace(/(<\/body>)/i,`${A}
4387
4387
  $1`);else N+=`
4388
- ${q}`;O.__stx_event_bindings=[]}if(K.forEach((V)=>Y.add(V)),Q.cache&&Q.cachePath){if(await U$(W,N,K,Q),Q.debug)console.log(`Cached template ${W} with ${K.size} dependencies`)}return{contents:N,loader:"html"}}catch(K){return console.error("stx Plugin Error:",K),{contents:s8("stx Rendering Error",K.message||String(K),W),loader:"html"}}})}}}var o8=i8;function jY($,X){if(!$)return $;if(/^[a-z][a-z0-9+.-]*:/i.test($)||$.startsWith("//"))return $;return`${X}${$.startsWith("/")?"":"/"}${$}`}function x$($,X,Z={},Q="/"){let Y=X.seo??{},J=Z.title??Y.title??X.name,G=Z.description??Y.description??X.description??"",W=X.url.replace(/\/$/,""),K=`${W}${Q}`,_=jY(Z.image??Y.image,W),U=Y.siteName??X.name,F=Y.type??"website",z=Y.locale??"en_US",j=[];if(Y.favicon){let T=Y.favicon.toLowerCase().split(".").pop(),f=T==="svg"?"image/svg+xml":T==="ico"?"image/x-icon":T==="png"?"image/png":T==="jpg"||T==="jpeg"?"image/jpeg":"";j.push(`<link rel="icon"${f?` type="${f}"`:""} href="${F0(Y.favicon)}">`)}if(j.push(`<title>${HY(J)}</title>`,`<link rel="canonical" href="${F0(K)}">`,`<meta name="description" content="${F0(G)}">`,`<meta property="og:title" content="${F0(J)}">`,`<meta property="og:description" content="${F0(G)}">`,`<meta property="og:type" content="${F0(F)}">`,`<meta property="og:url" content="${F0(K)}">`,`<meta property="og:site_name" content="${F0(U)}">`,`<meta property="og:locale" content="${F0(z)}">`,`<meta name="twitter:card" content="${_?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${F0(J)}">`,`<meta name="twitter:description" content="${F0(G)}">`),_)j.push(`<meta property="og:image" content="${F0(_)}">`),j.push(`<meta name="twitter:image" content="${F0(_)}">`);if(Y.twitter)j.push(`<meta name="twitter:site" content="@${F0(Y.twitter.replace(/^@/,""))}">`),j.push(`<meta name="twitter:creator" content="@${F0(Y.twitter.replace(/^@/,""))}">`);let H=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(H.test($))$=$.replace(H,"");$=$.replace(/<!--\s*SEO\s*-->[\s\S]*?<!--\s*\/SEO\s*-->\s*/g,""),$=$.replace(/<meta\s+name="title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+property="og:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"");let L=$.search(/<\/head>/i),O=L===-1?$:$.slice(0,L),N=/^(?:stx App|stx Project|Document|Untitled)$/i,V=/<title[^>]*>([\s\S]*?)<\/title>/i.exec(O)?.[1]?.trim(),M=V===void 0||V===""||N.test(V),q=(T)=>{if(/^<title[\s>]/i.test(T))return/<title[\s>]/i.test(O)&&!M;if(/rel="canonical"/i.test(T))return/<link[^>]+rel=["']canonical["']/i.test(O);let v=/(?:property|name)="([^"]+)"/i.exec(T)?.[1];if(!v)return!1;return new RegExp(`<meta[^>]+(?:property|name)=["']${v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["']`,"i").test(O)},A=j.filter((T)=>!q(T));if(A.length===0)return $;let I=$,E=A.find((T)=>/^<title[\s>]/i.test(T));if(E&&M&&/<title[^>]*>[\s\S]*?<\/title>/i.test(I)){if(I=I.replace(/<title[^>]*>[\s\S]*?<\/title>/i,()=>E),A=A.filter((T)=>T!==E),A.length===0)return I}let w=`<!-- SEO -->
4389
- ${A.join(`
4388
+ ${A}`;O.__stx_event_bindings=[]}if(K.forEach((V)=>Y.add(V)),Q.cache&&Q.cachePath){if(await F$(W,N,K,Q),Q.debug)console.log(`Cached template ${W} with ${K.size} dependencies`)}return{contents:N,loader:"html"}}catch(K){return console.error("stx Plugin Error:",K),{contents:Z3("stx Rendering Error",K.message||String(K),W),loader:"html"}}})}}}var J3=$3;function DY($,X){if(!$)return $;if(/^[a-z][a-z0-9+.-]*:/i.test($)||$.startsWith("//"))return $;return`${X}${$.startsWith("/")?"":"/"}${$}`}function b$($,X,Z={},Q="/"){let Y=X.seo??{},J=Z.title??Y.title??X.name,G=Z.description??Y.description??X.description??"",W=X.url.replace(/\/$/,""),K=`${W}${Q}`,_=DY(Z.image??Y.image,W),U=Y.siteName??X.name,F=Y.type??"website",z=Y.locale??"en_US",j=[];if(Y.favicon){let T=Y.favicon.toLowerCase().split(".").pop(),f=T==="svg"?"image/svg+xml":T==="ico"?"image/x-icon":T==="png"?"image/png":T==="jpg"||T==="jpeg"?"image/jpeg":"";j.push(`<link rel="icon"${f?` type="${f}"`:""} href="${F0(Y.favicon)}">`)}if(j.push(`<title>${wY(J)}</title>`,`<link rel="canonical" href="${F0(K)}">`,`<meta name="description" content="${F0(G)}">`,`<meta property="og:title" content="${F0(J)}">`,`<meta property="og:description" content="${F0(G)}">`,`<meta property="og:type" content="${F0(F)}">`,`<meta property="og:url" content="${F0(K)}">`,`<meta property="og:site_name" content="${F0(U)}">`,`<meta property="og:locale" content="${F0(z)}">`,`<meta name="twitter:card" content="${_?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${F0(J)}">`,`<meta name="twitter:description" content="${F0(G)}">`),_)j.push(`<meta property="og:image" content="${F0(_)}">`),j.push(`<meta name="twitter:image" content="${F0(_)}">`);if(Y.twitter)j.push(`<meta name="twitter:site" content="@${F0(Y.twitter.replace(/^@/,""))}">`),j.push(`<meta name="twitter:creator" content="@${F0(Y.twitter.replace(/^@/,""))}">`);let H=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(H.test($))$=$.replace(H,"");$=$.replace(/<!--\s*SEO\s*-->[\s\S]*?<!--\s*\/SEO\s*-->\s*/g,""),$=$.replace(/<meta\s+name="title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+property="og:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"");let L=$.search(/<\/head>/i),O=L===-1?$:$.slice(0,L),N=/^(?:stx App|stx Project|Document|Untitled)$/i,V=/<title[^>]*>([\s\S]*?)<\/title>/i.exec(O)?.[1]?.trim(),M=V===void 0||V===""||N.test(V),A=(T)=>{if(/^<title[\s>]/i.test(T))return/<title[\s>]/i.test(O)&&!M;if(/rel="canonical"/i.test(T))return/<link[^>]+rel=["']canonical["']/i.test(O);let v=/(?:property|name)="([^"]+)"/i.exec(T)?.[1];if(!v)return!1;return new RegExp(`<meta[^>]+(?:property|name)=["']${v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["']`,"i").test(O)},q=j.filter((T)=>!A(T));if(q.length===0)return $;let I=$,E=q.find((T)=>/^<title[\s>]/i.test(T));if(E&&M&&/<title[^>]*>[\s\S]*?<\/title>/i.test(I)){if(I=I.replace(/<title[^>]*>[\s\S]*?<\/title>/i,()=>E),q=q.filter((T)=>T!==E),q.length===0)return I}let w=`<!-- SEO -->
4389
+ ${q.join(`
4390
4390
  `)}
4391
4391
  <!-- /SEO -->`,D=I.search(/<\/head>/i);if(D!==-1)return`${I.slice(0,D)}${w}
4392
4392
  ${I.slice(D)}`;if(/<head[^>]*>/i.test(I))return I.replace(/<head([^>]*)>/i,`<head$1>
4393
4393
  ${w}`);return`${w}
4394
- ${I}`}function F0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function HY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function S$($,X){let Z=$.url.replace(/\/$/,""),Q=new Date().toISOString().slice(0,10);return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',X.filter((J)=>J.page?.sitemap!==!1).map((J)=>{let G=`${Z}${J.path}`,W=J.page?.priority??(J.path==="/"?1:0.8),K=J.page?.changefreq??"monthly";return[" <url>",` <loc>${OY(G)}</loc>`,` <lastmod>${Q}</lastmod>`,` <changefreq>${K}</changefreq>`,` <priority>${W.toFixed(1)}</priority>`," </url>"].join(`
4394
+ ${I}`}function F0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function wY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function y$($,X){let Z=$.url.replace(/\/$/,""),Q=new Date().toISOString().slice(0,10);return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',X.filter((J)=>J.page?.sitemap!==!1).map((J)=>{let G=`${Z}${J.path}`,W=J.page?.priority??(J.path==="/"?1:0.8),K=J.page?.changefreq??"monthly";return[" <url>",` <loc>${TY(G)}</loc>`,` <lastmod>${Q}</lastmod>`,` <changefreq>${K}</changefreq>`,` <priority>${W.toFixed(1)}</priority>`," </url>"].join(`
4395
4395
  `)}).join(`
4396
4396
  `),"</urlset>",""].join(`
4397
- `)}function OY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function P$($){let X=$.robots??"allow";if(X===!1)return null;if(typeof X==="string"&&X!=="allow"&&X!=="disallow")return X.endsWith(`
4397
+ `)}function TY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function v$($){let X=$.robots??"allow";if(X===!1)return null;if(typeof X==="string"&&X!=="allow"&&X!=="disallow")return X.endsWith(`
4398
4398
  `)?X:`${X}
4399
4399
  `;let Z=$.sitemap!==!1?`Sitemap: ${$.url.replace(/\/$/,"")}/sitemap.xml
4400
4400
  `:"";if(X==="disallow")return["User-agent: *","Disallow: /","",Z].filter(Boolean).join(`
4401
4401
  `);return["User-agent: *","Allow: /","",Z].filter(Boolean).join(`
4402
- `)}var V1=null;async function NY(){if(V1!==null)return V1;try{let $=await import("./chunk-zwb8wv5p.js");if(typeof $.getRouterScript==="function")V1=$.getRouterScript();else V1=""}catch{V1=""}return V1}async function l5($,X){let Z=await NY();if(!Z)return $;let Q={interceptAllLinks:!0,container:"main",...X},J=`${`<script>window.__stxRouterConfig=${JSON.stringify(Q)};</script>
4402
+ `)}var M1=null;async function CY(){if(M1!==null)return M1;try{let $=await import("./chunk-0akydm2d.js");if(typeof $.getRouterScript==="function")M1=$.getRouterScript();else M1=""}catch{M1=""}return M1}async function s5($,X){let Z=await CY();if(!Z)return $;let Q={interceptAllLinks:!0,container:"main",...X},J=`${`<script>window.__stxRouterConfig=${JSON.stringify(Q)};</script>
4403
4403
  `}<script>${Z}</script>`;if(/<\/body>/i.test($))return $.replace(/<\/body>/i,`${J}
4404
4404
  </body>`);return`${$}
4405
- ${J}`}var qY=`window.__stxThemeIcon=function(isDark){try{var want=isDark?'dark':'light';var pick=document.querySelector('link[rel~="icon"][media*="prefers-color-scheme: '+want+'"]');if(!pick)return;var live=document.querySelector('link[rel~="icon"]:not([media])');if(!live){live=document.createElement('link');live.setAttribute('rel','icon');document.head.appendChild(live)}if(pick.type)live.setAttribute('type',pick.type);var href=pick.getAttribute('href');if(live.getAttribute('href')!==href)live.setAttribute('href',href)}catch(e){}};`,AY=($,X,Z,Q)=>`(function(){${qY}function read(){try{var k=${JSON.stringify(X)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify($)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(Q)}:${JSON.stringify(Z)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`,VY=($,X,Z)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Z)}:${JSON.stringify(X)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;function b$($,X){if(X.theme===!1)return $;let Z=$.includes(t8),Q=typeof X.theme==="object"&&X.theme!==null?X.theme:{},Y=Q.default??"dark",J=Q.storageKey??"theme",G=Q.colors?.light??"#ffffff",W=Q.colors?.dark??"#000000";if(Y==="dark"&&!Z){if(!/<html\b[^>]*\bclass=/.test($))$=$.replace(/<html\b([^>]*)>/i,'<html$1 class="dark">');else if(!/<html\b[^>]*\bclass="[^"]*\bdark\b/.test($))$=$.replace(/<html\b([^>]*\bclass=")([^"]*)(")/i,"<html$1$2 dark$3")}if(!$.includes("data-stx-theme-meta")&&/<head\b[^>]*>/i.test($)){let K=['<meta name="color-scheme" content="dark light" data-stx-theme-meta="1">',`<meta name="theme-color" media="(prefers-color-scheme: light)" content="${G}" data-stx-theme-meta="1">`,`<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${W}" data-stx-theme-meta="1">`].join(`
4405
+ ${J}`}var kY=`window.__stxThemeIcon=function(isDark){try{var want=isDark?'dark':'light';var pick=document.querySelector('link[rel~="icon"][media*="prefers-color-scheme: '+want+'"]');if(!pick)return;var live=document.querySelector('link[rel~="icon"]:not([media])');if(!live){live=document.createElement('link');live.setAttribute('rel','icon');document.head.appendChild(live)}if(pick.type)live.setAttribute('type',pick.type);var href=pick.getAttribute('href');if(live.getAttribute('href')!==href)live.setAttribute('href',href)}catch(e){}};`,xY=($,X,Z,Q)=>`(function(){${kY}function read(){try{var k=${JSON.stringify(X)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify($)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(Q)}:${JSON.stringify(Z)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`,SY=($,X,Z)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Z)}:${JSON.stringify(X)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;function g$($,X){if(X.theme===!1)return $;let Z=$.includes(G3),Q=typeof X.theme==="object"&&X.theme!==null?X.theme:{},Y=Q.default??"dark",J=Q.storageKey??"theme",G=Q.colors?.light??"#ffffff",W=Q.colors?.dark??"#000000";if(Y==="dark"&&!Z){if(!/<html\b[^>]*\bclass=/.test($))$=$.replace(/<html\b([^>]*)>/i,'<html$1 class="dark">');else if(!/<html\b[^>]*\bclass="[^"]*\bdark\b/.test($))$=$.replace(/<html\b([^>]*\bclass=")([^"]*)(")/i,"<html$1$2 dark$3")}if(!$.includes("data-stx-theme-meta")&&/<head\b[^>]*>/i.test($)){let K=['<meta name="color-scheme" content="dark light" data-stx-theme-meta="1">',`<meta name="theme-color" media="(prefers-color-scheme: light)" content="${G}" data-stx-theme-meta="1">`,`<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${W}" data-stx-theme-meta="1">`].join(`
4406
4406
  `);$=$.replace(/<head\b([^>]*)>/i,`<head$1>
4407
- ${K}`)}if(!Z&&!$.includes("__stxThemeGuard")&&/<head\b[^>]*>/i.test($)){let _=`<script data-stx-theme-guard="1">${`window.__STX_COLOR_MODE__=window.__STX_COLOR_MODE__||${JSON.stringify({storageKey:J,initialMode:Y,darkClass:"dark"})};`}${AY(Y,J,G,W)};window.__stxThemeGuard=1;</script>`;$=$.replace(/<head\b([^>]*)>/i,`<head$1>
4408
- ${_}`)}if(!Z&&!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let K=`<script data-stx-theme-toggle="1">${VY(J,G,W)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
4409
- </body>`)}return $}async function e8($,X){if($.length===0)return{succeeded:[],failed:[]};try{return await X($),{succeeded:[...$],failed:[]}}catch{}let Z=[],Q=[];for(let Y of $)try{await X([Y]),Z.push(Y)}catch(J){Q.push({entrypoint:Y,error:B1(J,Y)})}return{succeeded:Z,failed:Q}}import{existsSync as MY,readFileSync as EY}from"fs";import{join as IY,resolve as RY}from"path";import DY from"process";function v$($,X=DY.cwd()){let Z=$.i18n;if(!Z||!Array.isArray(Z.locales)||Z.locales.length===0)return null;let Q=Z.defaultLocale??Z.locales[0],Y=wY(Z,X);return{locales:Z.locales,defaultLocale:Q,labels:Z.labels??Object.fromEntries(Z.locales.map((J)=>[J,J.toUpperCase()])),translations:Y,pickerSelector:Z.pickerSelector??"#lang-picker"}}function wY($,X){let Z=$.translations??{},Q={},Y=$.translationsDir,J=Y===!1?null:RY(X,typeof Y==="string"&&Y?Y:"translations"),G=$.format??"json";for(let W of $.locales){let K=J?TY(J,W,G):{};Q[W]={...K,...Z[W]??{}}}return Q}function TY($,X,Z){let Q=Z==="json"?[`${X}.json`]:[`${X}.${Z}`,`${X}.${Z==="yaml"?"yml":"yaml"}`];for(let Y of Q){let J=IY($,Y);if(!MY(J))continue;try{let G=EY(J,"utf8"),W=Z==="json"?JSON.parse(G):CY(G);return $3(W)}catch{continue}}return{}}function $3($,X="",Z={}){if(!$||typeof $!=="object")return Z;for(let[Q,Y]of Object.entries($)){let J=X?`${X}.${Q}`:Q;if(Y&&typeof Y==="object"&&!Array.isArray(Y))$3(Y,J,Z);else if(typeof Y==="string")Z[J]=Y;else if(typeof Y==="number"||typeof Y==="boolean")Z[J]=String(Y)}return Z}function CY($){let X={},Z=[{obj:X,indent:-1}];for(let Q of $.split(`
4410
- `)){let Y=Q.replace(/#.*$/,"").trimEnd();if(!Y.trim())continue;let J=Y.search(/\S/);if(J===-1)continue;while(Z.length>1&&Z[Z.length-1].indent>=J)Z.pop();let G=Z[Z.length-1].obj,W=Y.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(!W)continue;let[,,K,_]=W,U=K.trim(),F=_.trim();if(F==="")G[U]={},Z.push({obj:G[U],indent:J});else G[U]=kY(F)}return X}function kY($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function i5($,X,Z){let Q=$.translations[X]?.[Z];if(typeof Q==="string")return Q;let Y=$.translations[$.defaultLocale]?.[Z];if(typeof Y==="string")return Y;return Z}function g$($,X,Z){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(Q,Y,J)=>{let G=i5(X,Z,J);return Y==="!"?G:xY(G)})}function s0($,X,Z){if(X===Z)return $;if($==="/")return`/${X}/`;if($==="/404.html")return`/${X}/404.html`;return`/${X}${$}`}function X3($,X){for(let Z of X){if($===`/${Z}`||$===`/${Z}/`)return{locale:Z,path:"/"};if($.startsWith(`/${Z}/`))return{locale:Z,path:$.slice(Z.length+1)}}return{locale:null,path:$}}function f$($,X,Z){let Q=$.replace(/\/$/,""),Y=[];for(let G of Z.locales){let W=`${Q}${s0(X,G,Z.defaultLocale)}`;Y.push(`<link rel="alternate" hreflang="${y$(G)}" href="${y$(W)}">`)}let J=`${Q}${s0(X,Z.defaultLocale,Z.defaultLocale)}`;return Y.push(`<link rel="alternate" hreflang="x-default" href="${y$(J)}">`),Y.join(`
4411
- `)}function h$($,X){let Z=`<meta name="stx-layout-group" content="i18n:${y$(X)}">`;if(/<meta name="stx-layout-group"[^>]*>/i.test($))return $.replace(/<meta name="stx-layout-group"[^>]*>/i,Z);if(/<\/head>/i.test($))return $.replace(/<\/head>/i,`${Z}
4407
+ ${K}`)}if(!Z&&!$.includes("__stxThemeGuard")&&/<head\b[^>]*>/i.test($)){let _=`<script data-stx-theme-guard="1">${`window.__STX_COLOR_MODE__=window.__STX_COLOR_MODE__||${JSON.stringify({storageKey:J,initialMode:Y,darkClass:"dark"})};`}${xY(Y,J,G,W)};window.__stxThemeGuard=1;</script>`;$=$.replace(/<head\b([^>]*)>/i,`<head$1>
4408
+ ${_}`)}if(!Z&&!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let K=`<script data-stx-theme-toggle="1">${SY(J,G,W)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
4409
+ </body>`)}return $}async function W3($,X){if($.length===0)return{succeeded:[],failed:[]};try{return await X($),{succeeded:[...$],failed:[]}}catch{}let Z=[],Q=[];for(let Y of $)try{await X([Y]),Z.push(Y)}catch(J){Q.push({entrypoint:Y,error:L1(J,Y)})}return{succeeded:Z,failed:Q}}import{existsSync as PY,readFileSync as bY}from"fs";import{join as yY,resolve as vY}from"path";import gY from"process";function h$($,X=gY.cwd()){let Z=$.i18n;if(!Z||!Array.isArray(Z.locales)||Z.locales.length===0)return null;let Q=Z.defaultLocale??Z.locales[0],Y=fY(Z,X);return{locales:Z.locales,defaultLocale:Q,labels:Z.labels??Object.fromEntries(Z.locales.map((J)=>[J,J.toUpperCase()])),translations:Y,pickerSelector:Z.pickerSelector??"#lang-picker"}}function fY($,X){let Z=$.translations??{},Q={},Y=$.translationsDir,J=Y===!1?null:vY(X,typeof Y==="string"&&Y?Y:"translations"),G=$.format??"json";for(let W of $.locales){let K=J?hY(J,W,G):{};Q[W]={...K,...Z[W]??{}}}return Q}function hY($,X,Z){let Q=Z==="json"?[`${X}.json`]:[`${X}.${Z}`,`${X}.${Z==="yaml"?"yml":"yaml"}`];for(let Y of Q){let J=yY($,Y);if(!PY(J))continue;try{let G=bY(J,"utf8"),W=Z==="json"?JSON.parse(G):dY(G);return K3(W)}catch{continue}}return{}}function K3($,X="",Z={}){if(!$||typeof $!=="object")return Z;for(let[Q,Y]of Object.entries($)){let J=X?`${X}.${Q}`:Q;if(Y&&typeof Y==="object"&&!Array.isArray(Y))K3(Y,J,Z);else if(typeof Y==="string")Z[J]=Y;else if(typeof Y==="number"||typeof Y==="boolean")Z[J]=String(Y)}return Z}function dY($){let X={},Z=[{obj:X,indent:-1}];for(let Q of $.split(`
4410
+ `)){let Y=Q.replace(/#.*$/,"").trimEnd();if(!Y.trim())continue;let J=Y.search(/\S/);if(J===-1)continue;while(Z.length>1&&Z[Z.length-1].indent>=J)Z.pop();let G=Z[Z.length-1].obj,W=Y.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(!W)continue;let[,,K,_]=W,U=K.trim(),F=_.trim();if(F==="")G[U]={},Z.push({obj:G[U],indent:J});else G[U]=uY(F)}return X}function uY($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function r5($,X,Z){let Q=$.translations[X]?.[Z];if(typeof Q==="string")return Q;let Y=$.translations[$.defaultLocale]?.[Z];if(typeof Y==="string")return Y;return Z}function d$($,X,Z){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(Q,Y,J)=>{let G=r5(X,Z,J);return Y==="!"?G:mY(G)})}function s0($,X,Z){if(X===Z)return $;if($==="/")return`/${X}/`;if($==="/404.html")return`/${X}/404.html`;return`/${X}${$}`}function _3($,X){for(let Z of X){if($===`/${Z}`||$===`/${Z}/`)return{locale:Z,path:"/"};if($.startsWith(`/${Z}/`))return{locale:Z,path:$.slice(Z.length+1)}}return{locale:null,path:$}}function u$($,X,Z){let Q=$.replace(/\/$/,""),Y=[];for(let G of Z.locales){let W=`${Q}${s0(X,G,Z.defaultLocale)}`;Y.push(`<link rel="alternate" hreflang="${f$(G)}" href="${f$(W)}">`)}let J=`${Q}${s0(X,Z.defaultLocale,Z.defaultLocale)}`;return Y.push(`<link rel="alternate" hreflang="x-default" href="${f$(J)}">`),Y.join(`
4411
+ `)}function m$($,X){let Z=`<meta name="stx-layout-group" content="i18n:${f$(X)}">`;if(/<meta name="stx-layout-group"[^>]*>/i.test($))return $.replace(/<meta name="stx-layout-group"[^>]*>/i,Z);if(/<\/head>/i.test($))return $.replace(/<\/head>/i,`${Z}
4412
4412
  </head>`);return`${Z}
4413
- ${$}`}function d$($,X){return`<script data-stx-lang-picker="1">window.__stxI18n=${JSON.stringify({locales:$.locales,defaultLocale:$.defaultLocale,current:X,pickerSelector:$.pickerSelector})};(function(){function cfg(){return window.__stxI18n}function localeFromPath(p){var d=cfg();for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/')return c;if(p.indexOf('/'+c+'/')===0)return c}return d.defaultLocale}function localePathFor(loc,p){var d=cfg();var stripped=p;for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/'){stripped='/';break}if(p.indexOf('/'+c+'/')===0){stripped=p.slice(c.length+1);break}}if(loc===d.defaultLocale)return stripped;if(stripped==='/')return '/'+loc+'/';return '/'+loc+stripped}cfg().localizeHref=function(href){try{var u=new URL(href,location.origin);if(u.origin!==location.origin)return href;return localePathFor(localeFromPath(location.pathname),u.pathname)+(u.search||'')+(u.hash||'')}catch(_){return href}};function syncFromUrl(){var d=cfg();var loc=localeFromPath(location.pathname);d.current=loc;var picker=document.querySelector(d.pickerSelector);if(picker){var btns=picker.querySelectorAll('[data-lang]');for(var i=0;i<btns.length;i++){var b=btns[i];if(b.getAttribute('data-lang')===loc)b.setAttribute('aria-current','true');else b.removeAttribute('aria-current')}}if(document.documentElement.lang!==loc)document.documentElement.lang=loc}function onLangClick(e){var d=cfg();var btn=e.target&&e.target.closest&&e.target.closest('[data-lang]');if(!btn)return;var picker=document.querySelector(d.pickerSelector);if(!picker||!picker.contains(btn))return;e.preventDefault();e.stopPropagation();var loc=btn.getAttribute('data-lang');if(!loc||loc===localeFromPath(location.pathname))return;var dest=localePathFor(loc,location.pathname);var r=window.__stxRouter;if(r&&r.navigate)r.navigate(dest,true,true);else location.assign(dest)}syncFromUrl();if(window.__stxLangPickerBound){document.removeEventListener('click',window.__stxLangPickerClick,true);window.removeEventListener('stx:navigate',window.__stxLangPickerSync);window.removeEventListener('popstate',window.__stxLangPickerSync)}window.__stxLangPickerClick=onLangClick;window.__stxLangPickerSync=syncFromUrl;window.__stxLangPickerBound=1;document.addEventListener('click',onLangClick,true);window.addEventListener('stx:navigate',syncFromUrl);window.addEventListener('popstate',syncFromUrl)})();</script>`}function y$($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function K3($){let X=Date.now(),Z=$.pagesDir??"pages",Q=$.outDir??"dist",Y=$.publicDir??"public";if(!$.noClean)bY(Q,{recursive:!0,force:!0});Q3(Q,{recursive:!0});let J=new SY(`${Z}/**/*.stx`),G=await Array.fromAsync(J.scan(".")),W=$.excludeDirs??["layouts","partials","components"],K=[],_=G.filter((q)=>{let A=q.slice(Z.length).replace(/^[\\/]+/,"");if(A.split(/[\\/]/).slice(0,-1).some((E)=>W.includes(E)))return K.push(q),!1;return!A.split(/[\\/]/).some((E)=>E.startsWith("_"))});if(K.length>0)console.warn(`[stx] ${K.length} file(s) under ${Z}/ skipped as non-pages: ${W.join(", ")}`);if(_.length===0)throw Error(`No .stx files found in ${Z}/`);let U=await e8(_,(q)=>Bun.build({entrypoints:q,outdir:Q,plugins:[o8()],naming:{entry:"[name].[ext]"}}));if(U.failed.length>0){for(let{entrypoint:q,error:A}of U.failed)console.error(`[stx] failed to build ${q}:
4414
- ${A}`);if(U.succeeded.length===0)throw Error(`Build failed: none of the ${_.length} page(s) could be built`);console.error(`[stx] ${U.failed.length} of ${_.length} page(s) skipped; the rest were built.`)}uY(Q);let F=n5(Q).filter((q)=>q.endsWith(".html")),z=v$($,J3.cwd()),j=new Set(F.map(m$));for(let q of F){let A=P0(Q,q),I=Y3(A,"utf8"),E=m$(q),w=z?z.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let D of w){let T=I;if(T=mY(T),z)T=g$(T,z,D);if(T=await J0(T,J3.cwd()),T=x$(T,$,$.pages?.[E],E),z)T=pY(T,$,z,D,E),T=cY(T,D,z.defaultLocale,j),T=h$(T,D);if(T=b$(T,$),T=lY(T),z)T=T.replace(/<\/body>/i,`${d$(z,D)}
4415
- </body>`);if($.spa!==!1)T=await l5(T,$.router);let f=z?dY(E,D,z.defaultLocale):q,c=P0(Q,f);if(Q3(hY(c),{recursive:!0}),u$(c,T),z&&D!==z.defaultLocale&&f!==q);}}let H=s5(Q);if(H.assets>0)console.log(`[stx] externalized ${H.assets} asset(s) from ${H.pages} page(s) (${(H.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let L=r5(Q);if(L.assets>0)console.log(`[stx] externalized ${L.assets} repeated asset(s) from ${L.pages} page(s) (${(L.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(p$(Y))Z3(Y,Q,{recursive:!0});let O=W3();if(O)Z3(O,P0(Q,G3),{recursive:!0});let N=P0(Q,"404.html");if(!p$(N)&&p$(P0(Q,"index.html"))){let q=Y3(P0(Q,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${iY($.name)}</title>`);u$(N,q)}if($.sitemap!==!1){let q=[],A=F.filter((E)=>E!=="404.html").map(m$),I=z?z.locales:[null];for(let E of A){let w=$.pages?.[E];for(let D of I){let T=D&&z?s0(E,D,z.defaultLocale):E;q.push({path:T,page:w})}}u$(P0(Q,"sitemap.xml"),S$($,q))}let V=P$($);if(V!==null)u$(P0(Q,"robots.txt"),V);let M=F.map(m$);return{outDir:Q,pages:M,durationMs:Date.now()-X}}function hY($){return gY($)}function dY($,X,Z){let Q=s0($,X,Z);if(Q==="/")return"index.html";let Y=Q.replace(/^\//,"").replace(/\/$/,"");if(!Y.includes("/")){if(X!==Z&&Y===X)return`${X}/index.html`;return`${Y}.html`}return`${Y}.html`.replace(/\.html\.html$/,".html")}function m$($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function n5($,X=$){let Z=[];if(!p$($))return Z;for(let Q of PY($,{withFileTypes:!0})){let Y=P0($,Q.name);if(Q.isDirectory())Z.push(...n5(Y,X));else Z.push(fY(X,Y))}return Z}function uY($){for(let X of n5($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(X))continue;let Z=P0($,X);try{if(yY(Z).size===0)vY(Z)}catch{}}}function mY($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function pY($,X,Z,Q,Y){if(!Z)return $;if(/<html\b[^>]*\blang=/i.test($))$=$.replace(/<html\b([^>]*)\blang="[^"]*"/i,`<html$1lang="${Q}"`);else $=$.replace(/<html\b([^>]*)>/i,`<html$1 lang="${Q}">`);let J=`${X.url.replace(/\/$/,"")}${s0(Y,Q,Z.defaultLocale)}`;if(/<link rel="canonical"/.test($))$=$.replace(/<link rel="canonical"[^>]*>/,`<link rel="canonical" href="${a5(J)}">`);let G=Q.includes("_")||Q.includes("-")?Q:Q.toLowerCase();if(/<meta property="og:locale"/.test($))$=$.replace(/<meta property="og:locale"[^>]*>/,`<meta property="og:locale" content="${a5(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${a5(J)}">`);let W=f$(X.url,Y,Z);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(K)=>`${W}
4416
- ${K}`);return $}function a5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function cY($,X,Z,Q){if(X===Z)return $;return $.replace(/<a\b([^>]*?)\bhref="(\/[^"]*)"([^>]*)>/gi,(Y,J,G,W)=>{if(G.startsWith("//"))return Y;if(G===`/${X}`||G===`/${X}/`||G.startsWith(`/${X}/`))return Y;let K=G.match(/^(\/[^?#]*)(.*)$/);if(!K)return Y;let[,_,U]=K,F=_==="/"?"/":_.replace(/\/$/,"");if(!Q.has(F))return Y;let z=F==="/"?`/${X}/`:`/${X}${F}`;return`<a${J}href="${z}${U}"${W}>`})}function lY($){if(/<main\b/i.test($)||/\bdata-stx-content\b/i.test($))return $;let X=$.match(/<body\b[^>]*>/i),Z=$.search(/<\/body\s*>/i);if(!X||Z<0)return $;let Q=X.index+X[0].length,Y=$.slice(Q,Z),J=0,G=[...Y.matchAll(/<\/nav>/gi)];if(G.length>0){let z=G[G.length-1];J=z.index+z[0].length}let W=Y.length,K=Y.search(/<footer\b/i);if(K!==-1)W=Math.min(W,K);let _=Y.search(/<script\b[^>]*data-stx-(?:theme-toggle|reparent-progress)\b/i);if(_!==-1)W=Math.min(W,_);if(W<=J)return $;let U=Y.slice(J,W);if(!U.trim())return $;let F=`${Y.slice(0,J)}
4413
+ ${$}`}function p$($,X){return`<script data-stx-lang-picker="1">window.__stxI18n=${JSON.stringify({locales:$.locales,defaultLocale:$.defaultLocale,current:X,pickerSelector:$.pickerSelector})};(function(){function cfg(){return window.__stxI18n}function localeFromPath(p){var d=cfg();for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/')return c;if(p.indexOf('/'+c+'/')===0)return c}return d.defaultLocale}function localePathFor(loc,p){var d=cfg();var stripped=p;for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/'){stripped='/';break}if(p.indexOf('/'+c+'/')===0){stripped=p.slice(c.length+1);break}}if(loc===d.defaultLocale)return stripped;if(stripped==='/')return '/'+loc+'/';return '/'+loc+stripped}cfg().localizeHref=function(href){try{var u=new URL(href,location.origin);if(u.origin!==location.origin)return href;return localePathFor(localeFromPath(location.pathname),u.pathname)+(u.search||'')+(u.hash||'')}catch(_){return href}};function syncFromUrl(){var d=cfg();var loc=localeFromPath(location.pathname);d.current=loc;var picker=document.querySelector(d.pickerSelector);if(picker){var btns=picker.querySelectorAll('[data-lang]');for(var i=0;i<btns.length;i++){var b=btns[i];if(b.getAttribute('data-lang')===loc)b.setAttribute('aria-current','true');else b.removeAttribute('aria-current')}}if(document.documentElement.lang!==loc)document.documentElement.lang=loc}function onLangClick(e){var d=cfg();var btn=e.target&&e.target.closest&&e.target.closest('[data-lang]');if(!btn)return;var picker=document.querySelector(d.pickerSelector);if(!picker||!picker.contains(btn))return;e.preventDefault();e.stopPropagation();var loc=btn.getAttribute('data-lang');if(!loc||loc===localeFromPath(location.pathname))return;var dest=localePathFor(loc,location.pathname);var r=window.__stxRouter;if(r&&r.navigate)r.navigate(dest,true,true);else location.assign(dest)}syncFromUrl();if(window.__stxLangPickerBound){document.removeEventListener('click',window.__stxLangPickerClick,true);window.removeEventListener('stx:navigate',window.__stxLangPickerSync);window.removeEventListener('popstate',window.__stxLangPickerSync)}window.__stxLangPickerClick=onLangClick;window.__stxLangPickerSync=syncFromUrl;window.__stxLangPickerBound=1;document.addEventListener('click',onLangClick,true);window.addEventListener('stx:navigate',syncFromUrl);window.addEventListener('popstate',syncFromUrl)})();</script>`}function f$($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function mY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function H3($){let X=Date.now(),Z=$.pagesDir??"pages",Q=$.outDir??"dist",Y=$.publicDir??"public";if(!$.noClean)lY(Q,{recursive:!0,force:!0});B3(Q,{recursive:!0});let J=new pY(`${Z}/**/*.stx`),G=await Array.fromAsync(J.scan(".")),W=$.excludeDirs??["layouts","partials","components"],K=[],_=G.filter((A)=>{let q=A.slice(Z.length).replace(/^[\\/]+/,"");if(q.split(/[\\/]/).slice(0,-1).some((E)=>W.includes(E)))return K.push(A),!1;return!q.split(/[\\/]/).some((E)=>E.startsWith("_"))});if(K.length>0)console.warn(`[stx] ${K.length} file(s) under ${Z}/ skipped as non-pages: ${W.join(", ")}`);if(_.length===0)throw Error(`No .stx files found in ${Z}/`);let U=await W3(_,(A)=>Bun.build({entrypoints:A,outdir:Q,plugins:[J3()],naming:{entry:"[name].[ext]"}}));if(U.failed.length>0){for(let{entrypoint:A,error:q}of U.failed)console.error(`[stx] failed to build ${A}:
4414
+ ${q}`);if(U.succeeded.length===0)throw Error(`Build failed: none of the ${_.length} page(s) could be built`);console.error(`[stx] ${U.failed.length} of ${_.length} page(s) skipped; the rest were built.`)}tY(Q);let F=e5(Q).filter((A)=>A.endsWith(".html")),z=h$($,F3.cwd()),j=new Set(F.map(l$));for(let A of F){let q=P0(Q,A),I=L3(q,"utf8"),E=l$(A),w=z?z.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let D of w){let T=I;if(T=eY(T),z)T=d$(T,z,D);if(T=await J0(T,F3.cwd()),T=b$(T,$,$.pages?.[E],E),z)T=$J(T,$,z,D,E),T=XJ(T,D,z.defaultLocale,j),T=m$(T,D);if(T=g$(T,$),T=ZJ(T),z)T=T.replace(/<\/body>/i,`${p$(z,D)}
4415
+ </body>`);if($.spa!==!1)T=await s5(T,$.router);let f=z?oY(E,D,z.defaultLocale):A,c=P0(Q,f);if(B3(nY(c),{recursive:!0}),c$(c,T),z&&D!==z.defaultLocale&&f!==A);}}let H=o5(Q);if(H.assets>0)console.log(`[stx] externalized ${H.assets} asset(s) from ${H.pages} page(s) (${(H.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let L=t5(Q);if(L.assets>0)console.log(`[stx] externalized ${L.assets} repeated asset(s) from ${L.pages} page(s) (${(L.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(i$(Y))U3(Y,Q,{recursive:!0});let O=j3();if(O)U3(O,P0(Q,z3),{recursive:!0});let N=P0(Q,"404.html");if(!i$(N)&&i$(P0(Q,"index.html"))){let A=L3(P0(Q,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${QJ($.name)}</title>`);c$(N,A)}if($.sitemap!==!1){let A=[],q=F.filter((E)=>E!=="404.html").map(l$),I=z?z.locales:[null];for(let E of q){let w=$.pages?.[E];for(let D of I){let T=D&&z?s0(E,D,z.defaultLocale):E;A.push({path:T,page:w})}}c$(P0(Q,"sitemap.xml"),y$($,A))}let V=v$($);if(V!==null)c$(P0(Q,"robots.txt"),V);let M=F.map(l$);return{outDir:Q,pages:M,durationMs:Date.now()-X}}function nY($){return sY($)}function oY($,X,Z){let Q=s0($,X,Z);if(Q==="/")return"index.html";let Y=Q.replace(/^\//,"").replace(/\/$/,"");if(!Y.includes("/")){if(X!==Z&&Y===X)return`${X}/index.html`;return`${Y}.html`}return`${Y}.html`.replace(/\.html\.html$/,".html")}function l$($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function e5($,X=$){let Z=[];if(!i$($))return Z;for(let Q of cY($,{withFileTypes:!0})){let Y=P0($,Q.name);if(Q.isDirectory())Z.push(...e5(Y,X));else Z.push(rY(X,Y))}return Z}function tY($){for(let X of e5($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(X))continue;let Z=P0($,X);try{if(iY(Z).size===0)aY(Z)}catch{}}}function eY($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function $J($,X,Z,Q,Y){if(!Z)return $;if(/<html\b[^>]*\blang=/i.test($))$=$.replace(/<html\b([^>]*)\blang="[^"]*"/i,`<html$1lang="${Q}"`);else $=$.replace(/<html\b([^>]*)>/i,`<html$1 lang="${Q}">`);let J=`${X.url.replace(/\/$/,"")}${s0(Y,Q,Z.defaultLocale)}`;if(/<link rel="canonical"/.test($))$=$.replace(/<link rel="canonical"[^>]*>/,`<link rel="canonical" href="${n5(J)}">`);let G=Q.includes("_")||Q.includes("-")?Q:Q.toLowerCase();if(/<meta property="og:locale"/.test($))$=$.replace(/<meta property="og:locale"[^>]*>/,`<meta property="og:locale" content="${n5(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${n5(J)}">`);let W=u$(X.url,Y,Z);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(K)=>`${W}
4416
+ ${K}`);return $}function n5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function XJ($,X,Z,Q){if(X===Z)return $;return $.replace(/<a\b([^>]*?)\bhref="(\/[^"]*)"([^>]*)>/gi,(Y,J,G,W)=>{if(G.startsWith("//"))return Y;if(G===`/${X}`||G===`/${X}/`||G.startsWith(`/${X}/`))return Y;let K=G.match(/^(\/[^?#]*)(.*)$/);if(!K)return Y;let[,_,U]=K,F=_==="/"?"/":_.replace(/\/$/,"");if(!Q.has(F))return Y;let z=F==="/"?`/${X}/`:`/${X}${F}`;return`<a${J}href="${z}${U}"${W}>`})}function ZJ($){if(/<main\b/i.test($)||/\bdata-stx-content\b/i.test($))return $;let X=$.match(/<body\b[^>]*>/i),Z=$.search(/<\/body\s*>/i);if(!X||Z<0)return $;let Q=X.index+X[0].length,Y=$.slice(Q,Z),J=0,G=[...Y.matchAll(/<\/nav>/gi)];if(G.length>0){let z=G[G.length-1];J=z.index+z[0].length}let W=Y.length,K=Y.search(/<footer\b/i);if(K!==-1)W=Math.min(W,K);let _=Y.search(/<script\b[^>]*data-stx-(?:theme-toggle|reparent-progress)\b/i);if(_!==-1)W=Math.min(W,_);if(W<=J)return $;let U=Y.slice(J,W);if(!U.trim())return $;let F=`${Y.slice(0,J)}
4417
4417
  <main>${U}</main>
4418
- ${Y.slice(W)}`;return`${$.slice(0,Q)}${F}${$.slice(Z)}`}function iY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _3($){return $}var aY=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),sY=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function rY($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nY($){let X=[],Z=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,Q;while((Q=Z.exec($))!==null)X.push([Q.index,Q.index+Q[0].length]);return X}function oY($,X){for(let[Z,Q]of $)if(X>=Z&&X<Q)return!0;return!1}function l$($,X){let Z=1,Q=0;for(let Y=0;Y<X&&Y<$.length;Y++)if($[Y]===`
4419
- `)Z++,Q=Y+1;return{line:Z,column:X-Q+1}}function tY($,X,Z){let Q=X.toLowerCase(),Y=$.length,J=1,G=Z;while(G<Y){let W=$.indexOf("<",G);if(W===-1)return-1;if(G=W,$.startsWith("<!--",G)){let U=$.indexOf("-->",G+4);if(U===-1)return-1;G=U+3;continue}if($[G+1]==="/"){let U=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(G,G+64));if(!U){G++;continue}if(U[1].toLowerCase()===Q){if(J--,G+=U[0].length,J===0)return G;continue}G+=U[0].length;continue}let K=/^<([a-z][\w-]*)\b/i.exec($.slice(G,G+64));if(!K){G++;continue}let _=$.indexOf(">",G);if(_===-1)return-1;if(K[1].toLowerCase()===Q&&$[_-1]!=="/")J++;G=_+1}return-1}function eY($,X,Z){let Q=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,Y;while((Y=Q.exec($))!==null){if(oY(X,Y.index))continue;let J=Y[1].toLowerCase().split(":")[0];if(aY.has(J))continue;let G=Y[3].trim();if(/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/.test(G)){let W=$.indexOf(Y[3],Y.index),{line:K,column:_}=l$($,W<0?Y.index:W);Z.push({ruleId:"stx/no-bare-function-ref-in-event",message:`Event handler @${Y[1]}="${G}" is a member path, which the runtime does not invoke \u2014 it only auto-calls a plain identifier. Call it: @${Y[1]}="${G}($event)".`,line:K,column:_,severity:"error"})}}}function U3($){let X=$.split("/"),Z=[];for(let Q of X){if(Q===""||Q===".")continue;if(Q==="..")Z.pop();else Z.push(Q)}return Z.join("/")}function $J($,X,Z){let Q=X.replace(/\\/g,"/"),Y=Q.indexOf("resources/stores/");if(Y===-1)return;let J=Q.slice(0,Y+16),G=Q.slice(0,Q.lastIndexOf("/")),W=/\b(import|export)\s+(type\s+)?([^'"]*?)\s*from\s*['"]([^'"]+)['"]/g,K;while((K=W.exec($))!==null){if(K[2])continue;let _=K[1],U=K[4],F;if(U.startsWith("."))F=!U3(`${G}/${U}`).startsWith(U3(J));else F=!0;if(F){let{line:z,column:j}=l$($,K.index),H=_==="export"?"Value re-export":"Value import";Z.push({ruleId:"stx/store-value-imports-must-be-local",message:`${H} from "${U}" is outside resources/stores/ and will be stripped from the store bundle. Use \`${_} type\`, or move the value into the stores dir.`,line:z,column:j,severity:"error"})}}}function XJ($){let X=$.trim(),Z=(G)=>{let W=G.match(/[A-Za-z_$][\w$]*/g);return W?W:[]},Q=/\bas\s+(.+)$/.exec(X);if(Q){let G=Q[1].trim(),W=/^([A-Za-z_$][\w$]*)\s*=>\s*([A-Za-z_$][\w$]*)/.exec(G);if(W)return[W[1],W[2]];let K=/^\(([^)]*)\)/.exec(G);if(K)return Z(K[1]);let _=/^([A-Za-z_$][\w$]*)/.exec(G);return _?[_[1]]:[]}let Y=/^\(([^)]*)\)\s+(?:in|of)\s+/.exec(X);if(Y)return Z(Y[1]);let J=/^([A-Za-z_$][\w$]*)\s+(?:in|of)\s+/.exec(X);return J?[J[1]]:[]}function ZJ($,X){let Z=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,Q;while((Q=Z.exec($))!==null){let Y=XJ(Q[1]);if(Y.length===0)continue;let J=$.lastIndexOf("<",Q.index);if(J===-1)continue;let G=/^<([a-z][\w-]*)/i.exec($.slice(J,J+64));if(!G)continue;let W=$.indexOf(">",Q.index);if(W===-1)continue;let _=$[W-1]==="/"||sY.has(G[1].toLowerCase())?W+1:tY($,G[1],W+1),U=_===-1?W+1:_,F=$.indexOf(Q[1],Q.index),z=$.slice(J,U);if(F>=0&&F+Q[1].length<=U){let j=F-J;z=z.slice(0,j)+" ".repeat(Q[1].length)+z.slice(j+Q[1].length)}for(let j of Y){let H=new RegExp(`(?<![.\\w$])${rY(j)}\\s*\\(`,"g"),L;while((L=H.exec(z))!==null){let O=J+L.index,{line:N,column:V}=l$($,O);X.push({ruleId:"stx/no-signal-call-in-for-iteration-var",message:`"${j}" is a :for iteration variable, not a signal \u2014 calling it as "${j}()" leaves it as a function and silently breaks comparisons. Use "${j}" directly.`,line:N,column:V,severity:"error"})}}}}function QJ($,X){let Z=/<!--([\s\S]*?)-->/g,Q;while((Q=Z.exec($))!==null){let J=Q[1].indexOf("`");if(J!==-1){let G=Q.index+4+J,{line:W,column:K}=l$($,G);X.push({ruleId:"stx/no-backticks-in-html-comments",message:"Backtick inside an HTML comment leaks into the merged setup function and flips the JS parser into template-literal mode. Remove it or rephrase the comment.",line:W,column:K,severity:"error"})}}}function c$($,X){return $?.[X]!==!1}function YJ($,X={}){let Z=[],Q=nY($),Y=(X.filePath??"").replace(/\\/g,"/"),J=X.fileKind??(/\/components?\//i.test(Y)?"component":/\/layouts?\//i.test(Y)?"layout":"view");if(c$(X.rules,"stx/no-bare-function-ref-in-event"))eY($,Q,Z);if(Y&&c$(X.rules,"stx/store-value-imports-must-be-local"))$J($,Y,Z);if(c$(X.rules,"stx/no-signal-call-in-for-iteration-var"))ZJ($,Z);if(c$(X.rules,"stx/no-backticks-in-html-comments"))QJ($,Z);Z.sort((W,K)=>W.line-K.line||W.column-K.column);let G=new Set;return Z.filter((W)=>{let K=`${W.ruleId}:${W.line}:${W.column}`;if(G.has(K))return!1;return G.add(K),!0})}function JJ($,X){return $.kind===X}K5();function B3($){if($===String)return"string";if($===Number)return"number";if($===Boolean)return"boolean";if($===Array)return"array";if($===Object)return"object";if($===Function)return"function";if($===Date)return"date";if($===Symbol)return"symbol";if(typeof $==="function"&&$.name)return $.name;return"unknown"}function GJ($,X){if($===null||$===void 0)return!0;if(X===String)return typeof $==="string";if(X===Number)return typeof $==="number"&&!Number.isNaN($);if(X===Boolean)return typeof $==="boolean";if(X===Array)return Array.isArray($);if(X===Object)return typeof $==="object"&&!Array.isArray($);if(X===Function)return typeof $==="function";if(X===Date)return $ instanceof Date;if(X===Symbol)return typeof $==="symbol";if(typeof X==="function")return $ instanceof X;return!0}function F3($,X,Z,Q){let Y=Q?`[${Q}]`:"";if(Z.required&&(X===void 0||X===null))return{prop:$,message:`${Y} Missing required prop: "${$}"`,value:X,expected:Z.type?B3(Z.type):void 0};if(X===void 0||X===null)return null;if(Z.type){let J=Array.isArray(Z.type)?Z.type:[Z.type];if(!J.some((W)=>GJ(X,W))){let W=J.map((K)=>B3(K)).join(" | ");return{prop:$,message:`${Y} Invalid prop type for "${$}": expected ${W}, got ${typeof X}`,value:X,expected:W}}}if(Z.validator){if(!Z.validator(X))return{prop:$,message:`${Y} Custom validation failed for prop "${$}"`,value:X}}return null}function WJ($){let X=globalThis.__STX_CURRENT_PROPS__||{};if(!$)return X;let Z={...X};for(let[Q,Y]of Object.entries($)){let J=typeof Y==="function"||Array.isArray(Y)?{type:Y}:Y||{};if(Z[Q]===void 0&&J.default!==void 0)Z[Q]=typeof J.default==="function"?J.default():J.default}return Z}function KJ($,X={}){let{componentName:Z,throwOnError:Q=!1,logWarnings:Y=!0}=X,J=globalThis.__STX_CURRENT_PROPS__||{},G={...J},W={valid:!0,errors:[],warnings:[]};for(let[K,_]of Object.entries($)){let U=typeof _==="function"||Array.isArray(_)?{type:_}:_||{};if(G[K]===void 0&&U.default!==void 0)G[K]=typeof U.default==="function"?U.default():U.default;let F=F3(K,G[K],U,Z);if(F){if(W.valid=!1,W.errors.push(F),Y)console.warn(F.message)}}for(let K of Object.keys(J))if(!(K in $)){let _=`${Z?`[${Z}]`:""} Unknown prop: "${K}"`;if(W.warnings.push(_),Y)console.warn(_)}if(Q&&!W.valid){let K=W.errors.map((_)=>_.message).join(`
4418
+ ${Y.slice(W)}`;return`${$.slice(0,Q)}${F}${$.slice(Z)}`}function QJ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function O3($){return $}var YJ=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),JJ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function GJ($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function WJ($){let X=[],Z=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,Q;while((Q=Z.exec($))!==null)X.push([Q.index,Q.index+Q[0].length]);return X}function KJ($,X){for(let[Z,Q]of $)if(X>=Z&&X<Q)return!0;return!1}function s$($,X){let Z=1,Q=0;for(let Y=0;Y<X&&Y<$.length;Y++)if($[Y]===`
4419
+ `)Z++,Q=Y+1;return{line:Z,column:X-Q+1}}function _J($,X,Z){let Q=X.toLowerCase(),Y=$.length,J=1,G=Z;while(G<Y){let W=$.indexOf("<",G);if(W===-1)return-1;if(G=W,$.startsWith("<!--",G)){let U=$.indexOf("-->",G+4);if(U===-1)return-1;G=U+3;continue}if($[G+1]==="/"){let U=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(G,G+64));if(!U){G++;continue}if(U[1].toLowerCase()===Q){if(J--,G+=U[0].length,J===0)return G;continue}G+=U[0].length;continue}let K=/^<([a-z][\w-]*)\b/i.exec($.slice(G,G+64));if(!K){G++;continue}let _=$.indexOf(">",G);if(_===-1)return-1;if(K[1].toLowerCase()===Q&&$[_-1]!=="/")J++;G=_+1}return-1}function UJ($,X,Z){let Q=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,Y;while((Y=Q.exec($))!==null){if(KJ(X,Y.index))continue;let J=Y[1].toLowerCase().split(":")[0];if(YJ.has(J))continue;let G=Y[3].trim();if(/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/.test(G)){let W=$.indexOf(Y[3],Y.index),{line:K,column:_}=s$($,W<0?Y.index:W);Z.push({ruleId:"stx/no-bare-function-ref-in-event",message:`Event handler @${Y[1]}="${G}" is a member path, which the runtime does not invoke \u2014 it only auto-calls a plain identifier. Call it: @${Y[1]}="${G}($event)".`,line:K,column:_,severity:"error"})}}}function N3($){let X=$.split("/"),Z=[];for(let Q of X){if(Q===""||Q===".")continue;if(Q==="..")Z.pop();else Z.push(Q)}return Z.join("/")}function BJ($,X,Z){let Q=X.replace(/\\/g,"/"),Y=Q.indexOf("resources/stores/");if(Y===-1)return;let J=Q.slice(0,Y+16),G=Q.slice(0,Q.lastIndexOf("/")),W=/\b(import|export)\s+(type\s+)?([^'"]*?)\s*from\s*['"]([^'"]+)['"]/g,K;while((K=W.exec($))!==null){if(K[2])continue;let _=K[1],U=K[4],F;if(U.startsWith("."))F=!N3(`${G}/${U}`).startsWith(N3(J));else F=!0;if(F){let{line:z,column:j}=s$($,K.index),H=_==="export"?"Value re-export":"Value import";Z.push({ruleId:"stx/store-value-imports-must-be-local",message:`${H} from "${U}" is outside resources/stores/ and will be stripped from the store bundle. Use \`${_} type\`, or move the value into the stores dir.`,line:z,column:j,severity:"error"})}}}function LJ($){let X=$.trim(),Z=(G)=>{let W=G.match(/[A-Za-z_$][\w$]*/g);return W?W:[]},Q=/\bas\s+(.+)$/.exec(X);if(Q){let G=Q[1].trim(),W=/^([A-Za-z_$][\w$]*)\s*=>\s*([A-Za-z_$][\w$]*)/.exec(G);if(W)return[W[1],W[2]];let K=/^\(([^)]*)\)/.exec(G);if(K)return Z(K[1]);let _=/^([A-Za-z_$][\w$]*)/.exec(G);return _?[_[1]]:[]}let Y=/^\(([^)]*)\)\s+(?:in|of)\s+/.exec(X);if(Y)return Z(Y[1]);let J=/^([A-Za-z_$][\w$]*)\s+(?:in|of)\s+/.exec(X);return J?[J[1]]:[]}function FJ($,X){let Z=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,Q;while((Q=Z.exec($))!==null){let Y=LJ(Q[1]);if(Y.length===0)continue;let J=$.lastIndexOf("<",Q.index);if(J===-1)continue;let G=/^<([a-z][\w-]*)/i.exec($.slice(J,J+64));if(!G)continue;let W=$.indexOf(">",Q.index);if(W===-1)continue;let _=$[W-1]==="/"||JJ.has(G[1].toLowerCase())?W+1:_J($,G[1],W+1),U=_===-1?W+1:_,F=$.indexOf(Q[1],Q.index),z=$.slice(J,U);if(F>=0&&F+Q[1].length<=U){let j=F-J;z=z.slice(0,j)+" ".repeat(Q[1].length)+z.slice(j+Q[1].length)}for(let j of Y){let H=new RegExp(`(?<![.\\w$])${GJ(j)}\\s*\\(`,"g"),L;while((L=H.exec(z))!==null){let O=J+L.index,{line:N,column:V}=s$($,O);X.push({ruleId:"stx/no-signal-call-in-for-iteration-var",message:`"${j}" is a :for iteration variable, not a signal \u2014 calling it as "${j}()" leaves it as a function and silently breaks comparisons. Use "${j}" directly.`,line:N,column:V,severity:"error"})}}}}function zJ($,X){let Z=/<!--([\s\S]*?)-->/g,Q;while((Q=Z.exec($))!==null){let J=Q[1].indexOf("`");if(J!==-1){let G=Q.index+4+J,{line:W,column:K}=s$($,G);X.push({ruleId:"stx/no-backticks-in-html-comments",message:"Backtick inside an HTML comment leaks into the merged setup function and flips the JS parser into template-literal mode. Remove it or rephrase the comment.",line:W,column:K,severity:"error"})}}}function a$($,X){return $?.[X]!==!1}function jJ($,X={}){let Z=[],Q=WJ($),Y=(X.filePath??"").replace(/\\/g,"/"),J=X.fileKind??(/\/components?\//i.test(Y)?"component":/\/layouts?\//i.test(Y)?"layout":"view");if(a$(X.rules,"stx/no-bare-function-ref-in-event"))UJ($,Q,Z);if(Y&&a$(X.rules,"stx/store-value-imports-must-be-local"))BJ($,Y,Z);if(a$(X.rules,"stx/no-signal-call-in-for-iteration-var"))FJ($,Z);if(a$(X.rules,"stx/no-backticks-in-html-comments"))zJ($,Z);Z.sort((W,K)=>W.line-K.line||W.column-K.column);let G=new Set;return Z.filter((W)=>{let K=`${W.ruleId}:${W.line}:${W.column}`;if(G.has(K))return!1;return G.add(K),!0})}function HJ($,X){return $.kind===X}B5();function A3($){if($===String)return"string";if($===Number)return"number";if($===Boolean)return"boolean";if($===Array)return"array";if($===Object)return"object";if($===Function)return"function";if($===Date)return"date";if($===Symbol)return"symbol";if(typeof $==="function"&&$.name)return $.name;return"unknown"}function OJ($,X){if($===null||$===void 0)return!0;if(X===String)return typeof $==="string";if(X===Number)return typeof $==="number"&&!Number.isNaN($);if(X===Boolean)return typeof $==="boolean";if(X===Array)return Array.isArray($);if(X===Object)return typeof $==="object"&&!Array.isArray($);if(X===Function)return typeof $==="function";if(X===Date)return $ instanceof Date;if(X===Symbol)return typeof $==="symbol";if(typeof X==="function")return $ instanceof X;return!0}function V3($,X,Z,Q){let Y=Q?`[${Q}]`:"";if(Z.required&&(X===void 0||X===null))return{prop:$,message:`${Y} Missing required prop: "${$}"`,value:X,expected:Z.type?A3(Z.type):void 0};if(X===void 0||X===null)return null;if(Z.type){let J=Array.isArray(Z.type)?Z.type:[Z.type];if(!J.some((W)=>OJ(X,W))){let W=J.map((K)=>A3(K)).join(" | ");return{prop:$,message:`${Y} Invalid prop type for "${$}": expected ${W}, got ${typeof X}`,value:X,expected:W}}}if(Z.validator){if(!Z.validator(X))return{prop:$,message:`${Y} Custom validation failed for prop "${$}"`,value:X}}return null}function NJ($){let X=globalThis.__STX_CURRENT_PROPS__||{};if(!$)return X;let Z={...X};for(let[Q,Y]of Object.entries($)){let J=typeof Y==="function"||Array.isArray(Y)?{type:Y}:Y||{};if(Z[Q]===void 0&&J.default!==void 0)Z[Q]=typeof J.default==="function"?J.default():J.default}return Z}function AJ($,X={}){let{componentName:Z,throwOnError:Q=!1,logWarnings:Y=!0}=X,J=globalThis.__STX_CURRENT_PROPS__||{},G={...J},W={valid:!0,errors:[],warnings:[]};for(let[K,_]of Object.entries($)){let U=typeof _==="function"||Array.isArray(_)?{type:_}:_||{};if(G[K]===void 0&&U.default!==void 0)G[K]=typeof U.default==="function"?U.default():U.default;let F=V3(K,G[K],U,Z);if(F){if(W.valid=!1,W.errors.push(F),Y)console.warn(F.message)}}for(let K of Object.keys(J))if(!(K in $)){let _=`${Z?`[${Z}]`:""} Unknown prop: "${K}"`;if(W.warnings.push(_),Y)console.warn(_)}if(Q&&!W.valid){let K=W.errors.map((_)=>_.message).join(`
4420
4420
  `);throw Error(`Prop validation failed:
4421
- ${K}`)}return{props:G,validation:W}}function _J($,X){let Z={...$};for(let[Q,Y]of Object.entries(X))if(Z[Q]===void 0)Z[Q]=typeof Y==="function"?Y():Y;return Z}function UJ($){return $}function BJ($){return{type:$,required:!0}}function LJ($,X){return{type:X,default:$}}function FJ($,X={}){return{...X,validator:$}}function zJ($,X={}){return{...X,validator:(Z)=>$.includes(Z)}}function jJ($,X={}){return{...X,type:Array,validator:(Z)=>{if(!Array.isArray(Z))return!1;return!0}}}function HJ($,X={}){return{...X,type:Object}}function OJ($,X,Z){if(!X)return $;let Q={};for(let[Y,J]of Object.entries(X)){let G=typeof J==="function"||Array.isArray(J)?{type:J}:J||{},W=$[Y];if(W===void 0&&G.default!==void 0)W=typeof G.default==="function"?G.default():G.default;if(!L3()){let K=F3(Y,W,G,Z);if(K)console.warn(K.message)}Q[Y]=W}for(let[Y,J]of Object.entries($))if(!(Y in Q))Q[Y]=J;return Q}var rB={};
4422
- export{qK as o,Q5 as p,E6 as q,y4 as r,y0 as s,Q$ as t,Y$ as u,J$ as v,G$ as w,D1 as x,j3 as y,H3 as z,O3 as A,N3 as B,q3 as C,A3 as D,X6 as E,M3 as F,E3 as G,VJ as H,MJ as I,EJ as J,I3 as K,IJ as L,R3 as M,RJ as N,DJ as O,wJ as P,TJ as Q,CJ as R,kJ as S,xJ as T,SJ as U,PJ as V,bJ as W,J1 as X,yJ as Y,vJ as Z,gJ as _,fJ as $,dJ as aa,uJ as ba,w3 as ca,T3 as da,mJ as ea,C3 as fa,pJ as ga,cJ as ha,lJ as ia,iJ as ja,aJ as ka,sJ as la,k3 as ma,x3 as na,rJ as oa,nJ as pa,S3 as qa,tJ as ra,ZG as sa,QG as ta,U6 as ua,h3 as va,d3 as wa,u3 as xa,m3 as ya,o$ as za,p3 as Aa,c3 as Ba,l3 as Ca,i3 as Da,JG as Ea,UG as Fa,BG as Ga,r3 as Ha,LG as Ia,e$ as Ja,HG as Ka,m4 as La,p4 as Ma,$X as Na,XX as Oa,ZX as Pa,Q7 as Qa,QX as Ra,YX as Sa,JX as Ta,GX as Ua,WX as Va,KX as Wa,_X as Xa,e2 as Ya,S1 as Za,QW as _a,YW as $a,UX as ab,BX as bb,zX as cb,q$ as db,JW as eb,GW as fb,WW as gb,KW as hb,_W as ib,UW as jb,BW as kb,LW as lb,FW as mb,zW as nb,jW as ob,HW as pb,AX as qb,NW as rb,MW as sb,EW as tb,A5 as ub,kW as vb,xW as wb,SW as xb,fX as yb,yW as zb,uW as Ab,mW as Bb,pW as Cb,cW as Db,lW as Eb,iW as Fb,YK as Gb,AZ as Hb,JK as Ib,VZ as Jb,MZ as Kb,A7 as Lb,V7 as Mb,KK as Nb,_K as Ob,UK as Pb,LK as Qb,FK as Rb,CZ as Sb,jK as Tb,HK as Ub,OK as Vb,w6 as Wb,I7 as Xb,VK as Yb,MK as Zb,EK as _b,IK as $b,kZ as ac,xZ as bc,wK as cc,SZ as dc,w7 as ec,TK as fc,PZ as gc,CK as hc,kK as ic,bZ as jc,hK as kc,k7 as lc,gZ as mc,fZ as nc,x7 as oc,dZ as pc,uZ as qc,pZ as rc,l as sc,S7 as tc,k5 as uc,P7 as vc,b7 as wc,y7 as xc,v7 as yc,g7 as zc,f7 as Ac,h7 as Bc,d7 as Cc,u7 as Dc,m7 as Ec,p7 as Fc,c7 as Gc,l7 as Hc,i7 as Ic,a7 as Jc,s7 as Kc,r7 as Lc,n7 as Mc,o7 as Nc,t7 as Oc,x5 as Pc,e7 as Qc,$8 as Rc,X8 as Sc,Z8 as Tc,Q8 as Uc,J8 as Vc,S5 as Wc,P5 as Xc,G8 as Yc,b5 as Zc,y5 as _c,v5 as $c,m1 as ad,V$ as bd,W8 as cd,K8 as dd,_8 as ed,M$ as fd,B8 as gd,L8 as hd,F8 as id,z8 as jd,PQ as kd,bQ as ld,g5 as md,f5 as nd,q8 as od,i0 as pd,A8 as qd,V8 as rd,M8 as sd,E8 as td,I8 as ud,E$ as vd,h5 as wd,D8 as xd,I$ as yd,w8 as zd,T8 as Ad,C8 as Bd,k8 as Cd,R$ as Dd,D$ as Ed,d5 as Fd,u5 as Gd,S8 as Hd,P8 as Id,b8 as Jd,w$ as Kd,y8 as Ld,mQ as Md,Q_ as Nd,v8 as Od,pQ as Pd,q_ as Qd,A_ as Rd,M_ as Sd,q1 as Td,A1 as Ud,tQ as Vd,eQ as Wd,N1 as Xd,XY as Yd,p1 as Zd,QY as _d,YY as $d,JY as ae,GY as be,m8 as ce,WY as de,KY as ee,c8 as fe,FY as ge,zY as he,x$ as ie,S$ as je,P$ as ke,b$ as le,v$ as me,i5 as ne,g$ as oe,s0 as pe,X3 as qe,f$ as re,h$ as se,d$ as te,K3 as ue,_3 as ve,YJ as we,JJ as xe,WJ as ye,KJ as ze,_J as Ae,UJ as Be,BJ as Ce,LJ as De,FJ as Ee,zJ as Fe,jJ as Ge,HJ as He,OJ as Ie,rB as Je,g4 as Ke,S6 as Le,h4 as Me,u4 as Ne};
4421
+ ${K}`)}return{props:G,validation:W}}function qJ($,X){let Z={...$};for(let[Q,Y]of Object.entries(X))if(Z[Q]===void 0)Z[Q]=typeof Y==="function"?Y():Y;return Z}function VJ($){return $}function MJ($){return{type:$,required:!0}}function EJ($,X){return{type:X,default:$}}function IJ($,X={}){return{...X,validator:$}}function RJ($,X={}){return{...X,validator:(Z)=>$.includes(Z)}}function DJ($,X={}){return{...X,type:Array,validator:(Z)=>{if(!Array.isArray(Z))return!1;return!0}}}function wJ($,X={}){return{...X,type:Object}}function TJ($,X,Z){if(!X)return $;let Q={};for(let[Y,J]of Object.entries(X)){let G=typeof J==="function"||Array.isArray(J)?{type:J}:J||{},W=$[Y];if(W===void 0&&G.default!==void 0)W=typeof G.default==="function"?G.default():G.default;if(!q3()){let K=V3(Y,W,G,Z);if(K)console.warn(K.message)}Q[Y]=W}for(let[Y,J]of Object.entries($))if(!(Y in Q))Q[Y]=J;return Q}var BL={};
4422
+ export{yK as o,G5 as p,x6 as q,i4 as r,y0 as s,G$ as t,W$ as u,K$ as v,_$ as w,T1 as x,E3 as y,I3 as z,R3 as A,D3 as B,w3 as C,T3 as D,C3 as E,k3 as F,x3 as G,_6 as H,P3 as I,b3 as J,gJ as K,fJ as L,hJ as M,y3 as N,dJ as O,v3 as P,uJ as Q,mJ as R,pJ as S,cJ as T,lJ as U,iJ as V,aJ as W,sJ as X,rJ as Y,nJ as Z,G1 as _,oJ as $,tJ as aa,eJ as ba,$G as ca,ZG as da,QG as ea,f3 as fa,h3 as ga,YG as ha,d3 as ia,JG as ja,GG as ka,WG as la,KG as ma,_G as na,UG as oa,u3 as pa,m3 as qa,BG as ra,LG as sa,p3 as ta,zG as ua,NG as va,AG as wa,N6 as xa,n3 as ya,o3 as za,t3 as Aa,e3 as Ba,$5 as Ca,$4 as Da,X4 as Ea,Z4 as Fa,Q4 as Ga,VG as Ha,DG as Ia,wG as Ja,G4 as Ka,TG as La,Z5 as Ma,SG as Na,e4 as Oa,$X as Pa,BX as Qa,LX as Ra,FX as Sa,B7 as Ta,zX as Ua,jX as Va,HX as Wa,OX as Xa,NX as Ya,AX as Za,qX as _a,jW as $a,b1 as ab,AW as bb,qW as cb,VX as db,MX as eb,RX as fb,M$ as gb,VW as hb,MW as ib,EW as jb,IW as kb,RW as lb,DW as mb,wW as nb,TW as ob,CW as pb,kW as qb,xW as rb,SW as sb,xX as tb,bW as ub,fW as vb,hW as wb,E5 as xb,iW as yb,aW as zb,sW as Ab,rX as Bb,oW as Cb,QK as Db,YK as Eb,JK as Fb,GK as Gb,WK as Hb,KK as Ib,qK as Jb,xZ as Kb,VK as Lb,SZ as Mb,PZ as Nb,T7 as Ob,C7 as Pb,IK as Qb,RK as Rb,DK as Sb,TK as Tb,CK as Ub,dZ as Vb,xK as Wb,SK as Xb,PK as Yb,y6 as Zb,S7 as _b,gK as $b,fK as ac,hK as bc,dK as cc,uZ as dc,mZ as ec,pK as fc,pZ as gc,y7 as hc,cK as ic,cZ as jc,lK as kc,iK as lc,lZ as mc,X9 as nc,f7 as oc,sZ as pc,rZ as qc,h7 as rc,oZ as sc,tZ as tc,$Q as uc,l as vc,d7 as wc,P5 as xc,u7 as yc,m7 as zc,p7 as Ac,c7 as Bc,l7 as Cc,i7 as Dc,a7 as Ec,s7 as Fc,r7 as Gc,n7 as Hc,o7 as Ic,t7 as Jc,e7 as Kc,$8 as Lc,X8 as Mc,Z8 as Nc,Q8 as Oc,Y8 as Pc,J8 as Qc,G8 as Rc,b5 as Sc,W8 as Tc,K8 as Uc,_8 as Vc,U8 as Wc,B8 as Xc,F8 as Yc,y5 as Zc,v5 as _c,z8 as $c,g5 as ad,f5 as bd,h5 as cd,c1 as dd,I$ as ed,j8 as fd,H8 as gd,O8 as hd,R$ as id,A8 as jd,q8 as kd,V8 as ld,M8 as md,cQ as nd,lQ as od,d5 as pd,u5 as qd,w8 as rd,i0 as sd,T8 as td,C8 as ud,k8 as vd,x8 as wd,S8 as xd,D$ as yd,m5 as zd,b8 as Ad,w$ as Bd,y8 as Cd,v8 as Dd,g8 as Ed,f8 as Fd,T$ as Gd,C$ as Hd,p5 as Id,c5 as Jd,d8 as Kd,u8 as Ld,m8 as Md,k$ as Nd,p8 as Od,eQ as Pd,A_ as Qd,c8 as Rd,$Y as Sd,y_ as Td,v_ as Ud,f_ as Vd,q1 as Wd,V1 as Xd,_Y as Yd,UY as Zd,A1 as _d,LY as $d,l1 as ae,zY as be,jY as ce,HY as de,OY as ee,n8 as fe,NY as ge,AY as he,t8 as ie,IY as je,RY as ke,b$ as le,y$ as me,v$ as ne,g$ as oe,h$ as pe,r5 as qe,d$ as re,s0 as se,_3 as te,u$ as ue,m$ as ve,p$ as we,H3 as xe,O3 as ye,jJ as ze,HJ as Ae,NJ as Be,AJ as Ce,qJ as De,VJ as Ee,MJ as Fe,EJ as Ge,IJ as He,RJ as Ie,DJ as Je,wJ as Ke,TJ as Le,BL as Me,s4 as Ne,d6 as Oe,n4 as Pe,t4 as Qe};