@stacksjs/stx 0.2.230 → 0.2.232

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 (185) hide show
  1. package/dist/chunk-0h46e2ng.js +2 -0
  2. package/dist/{chunk-0h08j951.js → chunk-17kxd17m.js} +1 -1
  3. package/dist/{chunk-z6ev72qj.js → chunk-1gdzz04h.js} +1 -1
  4. package/dist/{chunk-dedefnzd.js → chunk-1h0twjzw.js} +2 -2
  5. package/dist/{chunk-nstqd54d.js → chunk-1kg9sz9a.js} +1 -1
  6. package/dist/{chunk-zpvva2dh.js → chunk-1nztpv0g.js} +2 -2
  7. package/dist/chunk-1x91733n.js +2 -0
  8. package/dist/{chunk-rfky5t3a.js → chunk-264rn67f.js} +2 -2
  9. package/dist/chunk-27m136s4.js +2 -0
  10. package/dist/{chunk-njc6sven.js → chunk-2fspj91j.js} +1 -1
  11. package/dist/{chunk-ge69r310.js → chunk-2tew0h6f.js} +1 -1
  12. package/dist/{chunk-7918r5qc.js → chunk-2v320r60.js} +2 -2
  13. package/dist/{chunk-m38wyaes.js → chunk-2w64hysh.js} +2 -2
  14. package/dist/chunk-33zg81y6.js +2 -0
  15. package/dist/{chunk-ep2agtrk.js → chunk-35ezbs7m.js} +1 -1
  16. package/dist/chunk-3j404s9z.js +2 -0
  17. package/dist/{chunk-vr04z80c.js → chunk-3sy1cf6v.js} +1 -1
  18. package/dist/{chunk-n58aem37.js → chunk-3zdkcdvf.js} +2 -2
  19. package/dist/{chunk-by2p4by1.js → chunk-4awxsp8f.js} +2 -2
  20. package/dist/{chunk-mjv4ar2y.js → chunk-5cjnfn8d.js} +1 -1
  21. package/dist/chunk-5k5qczgz.js +2 -0
  22. package/dist/{chunk-s3x1p8ff.js → chunk-5v3dv3xv.js} +2 -2
  23. package/dist/{chunk-h1jzzy6t.js → chunk-6ea3th9j.js} +265 -265
  24. package/dist/chunk-6k94kwfr.js +2 -0
  25. package/dist/{chunk-c9v94scd.js → chunk-6qhezn34.js} +1 -1
  26. package/dist/{chunk-kqjxwz6c.js → chunk-74r77tz1.js} +2 -2
  27. package/dist/chunk-7dznwvcy.js +2 -0
  28. package/dist/{chunk-bqdbf8k2.js → chunk-7kpfk426.js} +2 -2
  29. package/dist/chunk-7t4yc43k.js +2 -0
  30. package/dist/{chunk-vs7843yp.js → chunk-81zcv66r.js} +1 -1
  31. package/dist/{chunk-vy3brhf3.js → chunk-87rj95tw.js} +3 -3
  32. package/dist/{chunk-5mrs8cs2.js → chunk-8m7fhky6.js} +1 -1
  33. package/dist/{chunk-snktca7b.js → chunk-94fee5jw.js} +1 -1
  34. package/dist/{chunk-cddj2p27.js → chunk-9agksxkk.js} +2 -2
  35. package/dist/chunk-aeyrfcn5.js +2 -0
  36. package/dist/{chunk-w6h9c3f6.js → chunk-akm700yc.js} +1 -1
  37. package/dist/chunk-anc397f7.js +2 -0
  38. package/dist/chunk-b1rj6fk4.js +2 -0
  39. package/dist/{chunk-5fy1k8m0.js → chunk-b34x0v3f.js} +2 -2
  40. package/dist/{chunk-cq6fsp6j.js → chunk-b6jhznkh.js} +1 -1
  41. package/dist/{chunk-zdrpkrgc.js → chunk-bjs711qv.js} +1 -1
  42. package/dist/chunk-bnwpg6fg.js +2 -0
  43. package/dist/{chunk-z6e0b8wv.js → chunk-c5411vve.js} +2 -2
  44. package/dist/{chunk-m54yzzn8.js → chunk-cs1dc1n7.js} +1 -1
  45. package/dist/chunk-cv0z0qpy.js +2 -0
  46. package/dist/{chunk-e6tvnnnz.js → chunk-d19bydks.js} +1 -1
  47. package/dist/{chunk-9ny96ccv.js → chunk-d2x4ma3m.js} +2 -2
  48. package/dist/chunk-ddqzxbkr.js +2 -0
  49. package/dist/chunk-dkt2rq3s.js +2 -0
  50. package/dist/{chunk-74pjj8d0.js → chunk-dq88kv1p.js} +1 -1
  51. package/dist/{chunk-n4ecxe8x.js → chunk-dtfgxjy9.js} +4 -4
  52. package/dist/{chunk-8309r1ea.js → chunk-dvb8vgfe.js} +2 -2
  53. package/dist/chunk-dxepdtt2.js +2 -0
  54. package/dist/{chunk-d550gf3h.js → chunk-eb9caxff.js} +1 -1
  55. package/dist/chunk-ege2zbez.js +2 -0
  56. package/dist/{chunk-0939bnyw.js → chunk-eqbr4jnw.js} +2 -2
  57. package/dist/{chunk-70v7vvry.js → chunk-evv58hf5.js} +1 -1
  58. package/dist/{chunk-zbsnkmne.js → chunk-exaa3t0c.js} +2 -2
  59. package/dist/chunk-f3r3x3bh.js +2 -0
  60. package/dist/{chunk-82qd7jw1.js → chunk-f48gnx24.js} +1 -1
  61. package/dist/{chunk-6pzgmp1h.js → chunk-fexeqbkk.js} +2 -2
  62. package/dist/{chunk-8hnyynhv.js → chunk-fgfb9fs0.js} +1 -1
  63. package/dist/{chunk-c0n802j1.js → chunk-frp9fc7j.js} +1 -1
  64. package/dist/{chunk-swy03mg9.js → chunk-fvjh7rx0.js} +1 -1
  65. package/dist/{chunk-dxd830pt.js → chunk-fzxjrdnv.js} +1 -1
  66. package/dist/chunk-g5bhgv8m.js +2 -0
  67. package/dist/{chunk-vwwn4h5j.js → chunk-geztp3y3.js} +1 -1
  68. package/dist/{chunk-6345zcg6.js → chunk-gjapb8k6.js} +1 -1
  69. package/dist/{chunk-0yw0x5qz.js → chunk-gtek2yzx.js} +1 -1
  70. package/dist/{chunk-4bbyk43z.js → chunk-gzf1dg38.js} +2 -2
  71. package/dist/{chunk-xcac3tkq.js → chunk-hh6yxbyv.js} +1 -1
  72. package/dist/{chunk-rhkwswq0.js → chunk-hjdqejae.js} +1 -1
  73. package/dist/{chunk-a2ppgamd.js → chunk-hk8j3eps.js} +1 -1
  74. package/dist/{chunk-efr3ejqt.js → chunk-ht51fz7w.js} +1 -1
  75. package/dist/{chunk-jw1besrt.js → chunk-j93x5fzs.js} +1 -1
  76. package/dist/{chunk-z87q7ee7.js → chunk-jd90twtr.js} +1 -1
  77. package/dist/chunk-js0r6bc9.js +2 -0
  78. package/dist/{chunk-jcped0kt.js → chunk-jy6madxa.js} +1 -1
  79. package/dist/{chunk-wvc7t11n.js → chunk-kaet6r9w.js} +1 -1
  80. package/dist/chunk-mgexc8xe.js +2 -0
  81. package/dist/{chunk-dmzc008f.js → chunk-mxva4zmq.js} +1 -1
  82. package/dist/chunk-nebfw3pc.js +2 -0
  83. package/dist/{chunk-k6b7gpk2.js → chunk-nhmq45hh.js} +1 -1
  84. package/dist/{chunk-572ttrsj.js → chunk-ntnv2f7a.js} +1 -1
  85. package/dist/chunk-pe06ke3f.js +2 -0
  86. package/dist/{chunk-s88yt309.js → chunk-pv9at6r1.js} +1 -1
  87. package/dist/{chunk-nf4tx374.js → chunk-pwfqgvyf.js} +2 -2
  88. package/dist/chunk-q253eftn.js +2 -0
  89. package/dist/chunk-q9p451rb.js +2 -0
  90. package/dist/chunk-qh9bw4w4.js +2 -0
  91. package/dist/chunk-qj0jaw5s.js +2 -0
  92. package/dist/{chunk-exr6hs21.js → chunk-qpt60465.js} +1 -1
  93. package/dist/chunk-qq5xar6q.js +2 -0
  94. package/dist/{chunk-5ys0zfgp.js → chunk-qsdv9c1c.js} +2 -2
  95. package/dist/{chunk-m0sgdvnk.js → chunk-r23ycexh.js} +1 -1
  96. package/dist/{chunk-ncvd7673.js → chunk-r84h7wxw.js} +1 -1
  97. package/dist/{chunk-9edt3qh6.js → chunk-rbke5wqk.js} +1 -1
  98. package/dist/chunk-rmrxs0qz.js +3 -0
  99. package/dist/chunk-s9669ak6.js +2 -0
  100. package/dist/{chunk-72w4hhbq.js → chunk-ssfhndm6.js} +1 -1
  101. package/dist/chunk-t68jcajf.js +2 -0
  102. package/dist/{chunk-6rjc6687.js → chunk-tbr46jye.js} +2 -2
  103. package/dist/chunk-tdj3gqaa.js +2 -0
  104. package/dist/{chunk-dn4gw490.js → chunk-ts9swsgf.js} +1 -1
  105. package/dist/chunk-ttmtwp1x.js +2 -0
  106. package/dist/{chunk-a6nnbnmb.js → chunk-tv4n71jy.js} +2 -2
  107. package/dist/{chunk-v7fsv3wn.js → chunk-v2qx1jrb.js} +1 -1
  108. package/dist/{chunk-z44ra321.js → chunk-v80629x2.js} +1 -1
  109. package/dist/{chunk-0vzvd62b.js → chunk-vgf3zdpb.js} +1 -1
  110. package/dist/{chunk-p13ggd30.js → chunk-vw7h103c.js} +2 -2
  111. package/dist/{chunk-5d4csjhx.js → chunk-vzskgbqj.js} +1 -1
  112. package/dist/{chunk-apk45qqk.js → chunk-ww9sz124.js} +1 -1
  113. package/dist/{chunk-myh6j9ab.js → chunk-xaqjtned.js} +1 -1
  114. package/dist/{chunk-t0jzk81v.js → chunk-xgtcq9bj.js} +1 -1
  115. package/dist/{chunk-6t89bck2.js → chunk-xkeyq622.js} +1 -1
  116. package/dist/{chunk-4j8vpk72.js → chunk-xvmvbkwy.js} +187 -185
  117. package/dist/{chunk-c4a2kfj0.js → chunk-y7z44vr9.js} +2 -2
  118. package/dist/chunk-ymnt0ze7.js +2 -0
  119. package/dist/{chunk-x8w319bf.js → chunk-ypajs9wd.js} +3 -3
  120. package/dist/chunk-yqtc8ax6.js +2 -0
  121. package/dist/{chunk-q891e1vj.js → chunk-yx8vftp0.js} +1 -1
  122. package/dist/{chunk-d62d38ss.js → chunk-z9tj6jq7.js} +1 -1
  123. package/dist/{chunk-tdt7b8kg.js → chunk-znjrab9a.js} +1 -1
  124. package/dist/cli.js +14 -14
  125. package/dist/craft-entry.js +1 -1
  126. package/dist/craft.js +1 -1
  127. package/dist/database.js +1 -1
  128. package/dist/includes.js +4 -1
  129. package/dist/index.d.ts +1 -0
  130. package/dist/index.js +1 -0
  131. package/dist/misc-directives.d.ts +8 -3
  132. package/dist/misc-directives.js +71 -2
  133. package/dist/page-action.d.ts +1 -1
  134. package/dist/page-action.js +4 -1
  135. package/dist/process.js +1 -1
  136. package/dist/production-server.js +1 -1
  137. package/dist/pwa.js +2 -2
  138. package/dist/signal-processing.d.ts +17 -0
  139. package/dist/signal-processing.js +6 -2
  140. package/dist/site-builder/build.js +3 -1
  141. package/dist/site-builder/i18n.d.ts +18 -0
  142. package/dist/site-builder/i18n.js +10 -0
  143. package/dist/site-builder/index.d.ts +1 -0
  144. package/dist/site-builder/index.js +1 -0
  145. package/dist/ssg.js +4 -4
  146. package/dist/ssr.js +15 -15
  147. package/dist/utils.js +8 -4
  148. package/dist/visual-testing.js +1 -1
  149. package/package.json +5 -5
  150. package/dist/chunk-1tmhht43.js +0 -2
  151. package/dist/chunk-38dwv9n5.js +0 -2
  152. package/dist/chunk-40rqwfqt.js +0 -2
  153. package/dist/chunk-47v621t0.js +0 -2
  154. package/dist/chunk-72ywcwe8.js +0 -2
  155. package/dist/chunk-764km47e.js +0 -2
  156. package/dist/chunk-800m4ehs.js +0 -2
  157. package/dist/chunk-8m0p3v0e.js +0 -2
  158. package/dist/chunk-8n8ae329.js +0 -2
  159. package/dist/chunk-a0a7vmgm.js +0 -2
  160. package/dist/chunk-akh7aqh0.js +0 -2
  161. package/dist/chunk-ccam7wfn.js +0 -2
  162. package/dist/chunk-cges9wnq.js +0 -2
  163. package/dist/chunk-d8efym0s.js +0 -2
  164. package/dist/chunk-dk06jv4n.js +0 -2
  165. package/dist/chunk-en8ajb6b.js +0 -2
  166. package/dist/chunk-erwwmzym.js +0 -2
  167. package/dist/chunk-g3qcyeb1.js +0 -2
  168. package/dist/chunk-h23wts30.js +0 -2
  169. package/dist/chunk-hkn78n7a.js +0 -2
  170. package/dist/chunk-hrdps19s.js +0 -2
  171. package/dist/chunk-jrcm4vzs.js +0 -2
  172. package/dist/chunk-m29rat2r.js +0 -2
  173. package/dist/chunk-n2fhxh9a.js +0 -2
  174. package/dist/chunk-nwxd1jee.js +0 -3
  175. package/dist/chunk-p58b19t0.js +0 -2
  176. package/dist/chunk-paz6f4m5.js +0 -2
  177. package/dist/chunk-qn2hsdy5.js +0 -2
  178. package/dist/chunk-rfpg019d.js +0 -2
  179. package/dist/chunk-t7zk4x6s.js +0 -2
  180. package/dist/chunk-wbegam4r.js +0 -2
  181. package/dist/chunk-wkmd8pfh.js +0 -2
  182. package/dist/chunk-x7rf15d3.js +0 -2
  183. package/dist/chunk-y8g3d192.js +0 -2
  184. package/dist/chunk-z4msg4y0.js +0 -2
  185. package/dist/chunk-zd7bn188.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{lg as _$,mg as G5}from"./chunk-nwxd1jee.js";import{Bg as Q1,Cg as b6,Dg as $5,Eg as B$,Fg as L$,Gg as y6,Hg as v6,wg as b7,yg as U$,zg as A6}from"./chunk-c4a2kfj0.js";import{Vi as Y$,Wi as J$}from"./chunk-rfky5t3a.js";import{Ej as u1,Fj as j1,Gj as O1,Hj as d$,Ij as u$,Jj as m5,Lj as p5}from"./chunk-k6b7gpk2.js";import{wk as v5,xk as g5}from"./chunk-n58aem37.js";import{Dk as c7,Ek as l7}from"./chunk-c0n802j1.js";import{gl as X1}from"./chunk-ncvd7673.js";import{$r as M0,Bq as O0,Gm as x6,Km as X5,Lr as G$,Mp as v7,Nm as N1,Om as M1,Pq as X6,Qq as E1,Tp as k6,Uo as Z$,Up as S6,Uq as m0,Yl as P7,Yr as E$,Zm as c1,_l as $6,_r as H1,an as B6,ap as j0,ds as V0,in as r$,ip as u0,jq as e$,kn as s$,lq as P6,mq as F6,nn as l1,om as d0,rn as n$,un as Q$,vn as L6,ym as a$}from"./chunk-h1jzzy6t.js";import{Js as B,Rs as W$,Ss as K$,Ws as o}from"./chunk-vy3brhf3.js";import{gt as S0}from"./chunk-t0jzk81v.js";import{Qt as t$,Rt as O6,Vt as M6,Wt as V6,ju as E6,ku as I6,lu as R6,mu as D6,nu as w6,ou as T6,qu as C6,uu as H6}from"./chunk-bqdbf8k2.js";import{Eu as p}from"./chunk-q891e1vj.js";var c5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function t7($,X,Q={}){let{storage:Z="local",serializer:Y=c5,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Q,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Z==="session"?sessionStorage:localStorage},U=()=>{let L=_();if(!L)return X;try{let H=L.getItem($);if(H===null)return X;let A=Y.read(H);if(J&&typeof X==="object"&&X!==null)return{...X,...A};return A}catch{return X}},z=(L)=>{let H=_();if(!H)return;try{if(L===null||L===void 0)H.removeItem($);else H.setItem($,Y.write(L))}catch(A){console.warn(`[useStorage] Failed to write key "${$}":`,A)}},F=U(),O=(L,H)=>{for(let A of W)try{A(L,H)}catch(q){console.error("[useStorage] Subscriber error:",q)}};if(K&&G){let L=(A)=>{if(A.key===$&&A.storageArea===_()){let q=F;try{F=A.newValue?Y.read(A.newValue):X}catch(M){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,M);return}O(F,q)}};window.addEventListener("storage",L);let H=globalThis.onDestroy;if(typeof H==="function")H(()=>window.removeEventListener("storage",L))}let j={get value(){return F},set value(L){let H=F;F=L,z(L),O(L,H)},get:()=>F,set:(L)=>{j.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let H=F;F=X,O(X,H)}},subscribe:(L)=>{return W.add(L),L(F,void 0),()=>W.delete(L)}};return j}function l5($,X,Q,Z,Y={}){let{serializer:J=c5,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(O)=>{if(O===null||O===void 0)return Z;try{let j=J.read(O);if(G&&typeof Z==="object"&&Z!==null)return{...Z,...j};return j}catch(j){return console.warn(`[${X}] Failed to read key "${Q}":`,j),Z}},F=m5((()=>{let O=_();if(!O)return Z;try{return U(O.getItem(Q))}catch(j){return console.warn(`[${X}] Cannot read "${Q}":`,j),Z}})());if(p5(()=>{let O=F(),j=_();if(!j)return;try{if(O===null||O===void 0)j.removeItem(Q);else j.setItem(Q,J.write(O))}catch(L){console.warn(`[${X}] Cannot persist "${Q}":`,L)}}),K&&W){let O=(L)=>{if(L.key!==Q)return;if(L.storageArea&&L.storageArea!==_())return;F.set(U(L.newValue))};window.addEventListener("storage",O);let j=globalThis.onDestroy;if(typeof j==="function")j(()=>window.removeEventListener("storage",O))}return F}function e7($,X,Q){return l5("local","useLocalStorage",$,X,Q)}function $3($,X,Q){return l5("session","useSessionStorage",$,X,Q)}function X3($="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 Z3($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Q=0;for(let Z in X)if(Object.prototype.hasOwnProperty.call(X,Z))Q+=(Z.length+(X.getItem(Z)?.length||0))*2;return Q}var l=null;function d1($,X,Q=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Q.has($))return!0;if(Q.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(!d1($[J],X[J],Q))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)||!d1(G,X.get(J),Q))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 Z=Object.keys($),Y=Object.keys(X);if(Z.length!==Y.length)return!1;for(let J of Z){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!d1($[J],X[J],Q))return!1}return!0}function WJ($){l=$}function KJ(){return l}function _J(){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 UJ($){let X=new Set,Q=new Set,Z=$,Y=Symbol("ref"),J={get value(){let G=u1();if(G)Q.add(G);return Z},set value(G){if(!Object.is(G,Z)){let W=Z;Z=G;for(let K of X)K(G,W);for(let K of Q)if(d$())u$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(l)l.scope.refs.set(Y,J);return J}var i5=new WeakMap;function J3($){let X=i5.get($);if(X)return X;let Q=new Map,Z=(G)=>{let W=Q.get(G);if(!W)return;for(let K of[...W])if(d$())u$(K);else K()},Y=(G,W)=>{if(!Q.has(G))Q.set(G,new Set);return Q.get(G).add(W),()=>{Q.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=u1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let z=Object.getPrototypeOf(_);if(z===Object.prototype||z===null)return J3(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),z=Reflect.set(G,W,K,_);if(!Object.is(K,U))Z(W);return z},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Z(W),K}});return i5.set($,J),J}function BJ($){let X,Q=!0,Z=new Set,Y=new Set,J=()=>{Q=!0,G()},G=()=>{if(Q){let K=X,_=j1(J);if(X=$(),O1(_),Q=!1,!Object.is(X,K)){for(let U of Z)U(X,K);for(let U of Y)U()}}},W=j1(J);return X=$(),Q=!1,O1(W),{get value(){let K=u1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Z.add(K),()=>{Z.delete(K)}}}}function G3($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function LJ($,X,Q={}){let{immediate:Z=!1,deep:Y=!1,flush:J="post"}=Q,G,W,K=!1,_=()=>{if(K)return;let j=O();if((Y?!d1(j,G):!Object.is(j,G))||Z)if(X(j,G),Y&&j!==null&&typeof j==="object")try{G=structuredClone(j)}catch{G=j}else G=j},U=(j)=>{if(J==="sync")j();else if(J==="pre")Promise.resolve().then(j);else G3(j)},z=!1,F=()=>{if(K||z)return;z=!0,U(()=>{z=!1,_()})},O=()=>{if(typeof $==="function"){let j=j1(F);try{return $()}finally{O1(j)}}return $.value};if(typeof $!=="function"){let j=$.subscribe(()=>{U(_)});W=()=>{K=!0,j()}}else W=()=>{K=!0};if(G=O(),Z)U(_);if(l)l.scope.cleanups.push(()=>W?.());return()=>W?.()}function FJ($,X,Q={}){let Z=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Z.push(G)}if(Q.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Z)J()}}function zJ($){let X,Q=!1,Z=()=>{if(Q)return;if(X)X();let Y=j1(Z);X=$(),O1(Y)};if(Z(),l)l.scope.cleanups.push(()=>{if(Q=!0,X)X()});return()=>{if(Q=!0,X)X()}}function jJ($){if(l)l.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function OJ($){if(l)l.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function HJ($){if(l)l.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function AJ($){if(l)l.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function qJ($){if(l)l.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function NJ($){if(l)l.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function s0($,X){let Q=$.hooks[X];for(let Z of Q)await Z()}async function MJ($){await s0($,"beforeMount"),$.isMounted=!0,await s0($,"mounted")}async function VJ($){if(!$.isMounted||$.isUnmounted)return;await s0($,"beforeUpdate"),await s0($,"updated")}async function EJ($){if($.isUnmounted)return;await s0($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await s0($,"unmounted")}function IJ(){return`
2
+ import{mg as _$,ng as K5}from"./chunk-rmrxs0qz.js";import{Ag as q6,Cg as Z1,Dg as y6,Eg as Q5,Fg as B$,Gg as L$,Hg as v6,Ig as g6,xg as y7,zg as U$}from"./chunk-y7z44vr9.js";import{Bj as c5,uj as u1,vj as O1,wj as H1,xj as m$,yj as p$,zj as p5}from"./chunk-nhmq45hh.js";import{Vj as Y$,Wj as J$}from"./chunk-264rn67f.js";import{xk as g5,yk as f5}from"./chunk-3zdkcdvf.js";import{Ek as l7,Fk as i7}from"./chunk-frp9fc7j.js";import{hl as Q1}from"./chunk-r84h7wxw.js";import{$l as X6,$o as S6,Dq as O0,Hm as x6,Lm as Z5,Nr as G$,Om as N1,Pm as M1,Rq as Q6,Sq as E1,Vo as Z$,Wq as p0,Zl as b7,Zo as X5,_m as c1,_r as E$,ap as z6,as as d0,bn as L6,bq as g7,bs as M0,fs as V0,iq as P6,jn as n$,jq as b6,ln as o$,on as l1,pm as u0,rp as j0,sn as t$,vn as Q$,wn as F6,zm as s$,zp as m0}from"./chunk-6ea3th9j.js";import{Ls as B,Ts as W$,Us as K$,Ys as o}from"./chunk-87rj95tw.js";import{it as S0}from"./chunk-xgtcq9bj.js";import{St as $5,Tt as H6,Xt as V6,Yt as E6,lu as I6,mu as R6,nu as D6,ou as w6,pu as T6,qu as C6,su as k6,wu as A6}from"./chunk-7kpfk426.js";import{Gu as p}from"./chunk-yx8vftp0.js";var l5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function e7($,X,Q={}){let{storage:Z="local",serializer:Y=l5,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Q,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Z==="session"?sessionStorage:localStorage},U=()=>{let L=_();if(!L)return X;try{let H=L.getItem($);if(H===null)return X;let q=Y.read(H);if(J&&typeof X==="object"&&X!==null)return{...X,...q};return q}catch{return X}},z=(L)=>{let H=_();if(!H)return;try{if(L===null||L===void 0)H.removeItem($);else H.setItem($,Y.write(L))}catch(q){console.warn(`[useStorage] Failed to write key "${$}":`,q)}},F=U(),j=(L,H)=>{for(let q of W)try{q(L,H)}catch(A){console.error("[useStorage] Subscriber error:",A)}};if(K&&G){let L=(q)=>{if(q.key===$&&q.storageArea===_()){let A=F;try{F=q.newValue?Y.read(q.newValue):X}catch(N){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,N);return}j(F,A)}};window.addEventListener("storage",L);let H=globalThis.onDestroy;if(typeof H==="function")H(()=>window.removeEventListener("storage",L))}let O={get value(){return F},set value(L){let H=F;F=L,z(L),j(L,H)},get:()=>F,set:(L)=>{O.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let H=F;F=X,j(X,H)}},subscribe:(L)=>{return W.add(L),L(F,void 0),()=>W.delete(L)}};return O}function i5($,X,Q,Z,Y={}){let{serializer:J=l5,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 Z;try{let O=J.read(j);if(G&&typeof Z==="object"&&Z!==null)return{...Z,...O};return O}catch(O){return console.warn(`[${X}] Failed to read key "${Q}":`,O),Z}},F=p5((()=>{let j=_();if(!j)return Z;try{return U(j.getItem(Q))}catch(O){return console.warn(`[${X}] Cannot read "${Q}":`,O),Z}})());if(c5(()=>{let j=F(),O=_();if(!O)return;try{if(j===null||j===void 0)O.removeItem(Q);else O.setItem(Q,J.write(j))}catch(L){console.warn(`[${X}] Cannot persist "${Q}":`,L)}}),K&&W){let j=(L)=>{if(L.key!==Q)return;if(L.storageArea&&L.storageArea!==_())return;F.set(U(L.newValue))};window.addEventListener("storage",j);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",j))}return F}function $3($,X,Q){return i5("local","useLocalStorage",$,X,Q)}function X3($,X,Q){return i5("session","useSessionStorage",$,X,Q)}function Q3($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function Z3($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function Y3($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Q=0;for(let Z in X)if(Object.prototype.hasOwnProperty.call(X,Z))Q+=(Z.length+(X.getItem(Z)?.length||0))*2;return Q}var l=null;function d1($,X,Q=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Q.has($))return!0;if(Q.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(!d1($[J],X[J],Q))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)||!d1(G,X.get(J),Q))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 Z=Object.keys($),Y=Object.keys(X);if(Z.length!==Y.length)return!1;for(let J of Z){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!d1($[J],X[J],Q))return!1}return!0}function _J($){l=$}function UJ(){return l}function BJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:J3()}}function J3(){return{refs:new Map,effects:new Set,cleanups:[]}}function LJ($){let X=new Set,Q=new Set,Z=$,Y=Symbol("ref"),J={get value(){let G=u1();if(G)Q.add(G);return Z},set value(G){if(!Object.is(G,Z)){let W=Z;Z=G;for(let K of X)K(G,W);for(let K of Q)if(m$())p$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(l)l.scope.refs.set(Y,J);return J}var a5=new WeakMap;function G3($){let X=a5.get($);if(X)return X;let Q=new Map,Z=(G)=>{let W=Q.get(G);if(!W)return;for(let K of[...W])if(m$())p$(K);else K()},Y=(G,W)=>{if(!Q.has(G))Q.set(G,new Set);return Q.get(G).add(W),()=>{Q.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=u1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let z=Object.getPrototypeOf(_);if(z===Object.prototype||z===null)return G3(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),z=Reflect.set(G,W,K,_);if(!Object.is(K,U))Z(W);return z},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Z(W),K}});return a5.set($,J),J}function FJ($){let X,Q=!0,Z=new Set,Y=new Set,J=()=>{Q=!0,G()},G=()=>{if(Q){let K=X,_=O1(J);if(X=$(),H1(_),Q=!1,!Object.is(X,K)){for(let U of Z)U(X,K);for(let U of Y)U()}}},W=O1(J);return X=$(),Q=!1,H1(W),{get value(){let K=u1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Z.add(K),()=>{Z.delete(K)}}}}function W3($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function zJ($,X,Q={}){let{immediate:Z=!1,deep:Y=!1,flush:J="post"}=Q,G,W,K=!1,_=()=>{if(K)return;let O=j();if((Y?!d1(O,G):!Object.is(O,G))||Z)if(X(O,G),Y&&O!==null&&typeof O==="object")try{G=structuredClone(O)}catch{G=O}else G=O},U=(O)=>{if(J==="sync")O();else if(J==="pre")Promise.resolve().then(O);else W3(O)},z=!1,F=()=>{if(K||z)return;z=!0,U(()=>{z=!1,_()})},j=()=>{if(typeof $==="function"){let O=O1(F);try{return $()}finally{H1(O)}}return $.value};if(typeof $!=="function"){let O=$.subscribe(()=>{U(_)});W=()=>{K=!0,O()}}else W=()=>{K=!0};if(G=j(),Z)U(_);if(l)l.scope.cleanups.push(()=>W?.());return()=>W?.()}function jJ($,X,Q={}){let Z=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Z.push(G)}if(Q.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Z)J()}}function OJ($){let X,Q=!1,Z=()=>{if(Q)return;if(X)X();let Y=O1(Z);X=$(),H1(Y)};if(Z(),l)l.scope.cleanups.push(()=>{if(Q=!0,X)X()});return()=>{if(Q=!0,X)X()}}function HJ($){if(l)l.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function AJ($){if(l)l.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function qJ($){if(l)l.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function NJ($){if(l)l.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function MJ($){if(l)l.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function VJ($){if(l)l.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function n0($,X){let Q=$.hooks[X];for(let Z of Q)await Z()}async function EJ($){await n0($,"beforeMount"),$.isMounted=!0,await n0($,"mounted")}async function IJ($){if(!$.isMounted||$.isUnmounted)return;await n0($,"beforeUpdate"),await n0($,"updated")}async function RJ($){if($.isUnmounted)return;await n0($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await n0($,"unmounted")}function DJ(){return`
3
3
  <script data-stx-client-runtime>
4
4
  (function() {
5
5
  'use strict';
@@ -178,11 +178,11 @@ import{lg as _$,mg as G5}from"./chunk-nwxd1jee.js";import{Bg as Q1,Cg as b6,Dg a
178
178
  });
179
179
  window.provide = provide;
180
180
  })();
181
- </script>`}function n0($,X){if(typeof window>"u")return X;return window[$]??X}function m1($,X){if(typeof window>"u")return;window[$]=X}function a5($){let Q=n0("__STX_STORES__",{})[$];if(!Q)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Q}function DJ($){return a5($)}function wJ($,X=5000){return new Promise((Q,Z)=>{let Y=Date.now(),J=()=>{let G=a5($);if(G)Q(G);else if(Date.now()-Y>X)Z(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(J)};J()})}function W3(){return n0("__STX_ROUTE_PARAMS__",{})}function K3($){return W3()[$]}function TJ($){let X=K3($);if(X===void 0)throw Error(`Route parameter "${$}" not found`);return X}function _3(){return n0("__STX_MIDDLEWARE_STATE__",{})}function CJ($){return _3()[$]}function xJ(){if(typeof window>"u")return;if(!n0("__STX_STORES__",null))m1("__STX_STORES__",{})}function kJ($,X){let Q=n0("__STX_STORES__",{});Q[$]=X,m1("__STX_STORES__",Q)}function SJ(){return n0("__STX_STORE_STATE__",null)}function PJ($){m1("__STX_ROUTE_PARAMS__",$)}function bJ($){m1("__STX_MIDDLEWARE_STATE__",$)}function U3(){return typeof window>"u"}function B3(){return typeof window<"u"}function yJ($){if(B3())$()}function vJ($){if(U3())$()}async function L3($){try{let X=await Bun.file($).text(),Q=F3(X),Z=z3(X,$),Y=j3(X,Q),J=O3(X,Q);return{file:$,metrics:Q,issues:Z,suggestions:Y,performance:J}}catch(X){throw Error(`Failed to analyze template ${$}: ${X instanceof Error?X.message:String(X)}`)}}function F3($){let X=$.split(`
181
+ </script>`}function o0($,X){if(typeof window>"u")return X;return window[$]??X}function m1($,X){if(typeof window>"u")return;window[$]=X}function r5($){let Q=o0("__STX_STORES__",{})[$];if(!Q)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Q}function TJ($){return r5($)}function CJ($,X=5000){return new Promise((Q,Z)=>{let Y=Date.now(),J=()=>{let G=r5($);if(G)Q(G);else if(Date.now()-Y>X)Z(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(J)};J()})}function K3(){return o0("__STX_ROUTE_PARAMS__",{})}function _3($){return K3()[$]}function kJ($){let X=_3($);if(X===void 0)throw Error(`Route parameter "${$}" not found`);return X}function U3(){return o0("__STX_MIDDLEWARE_STATE__",{})}function xJ($){return U3()[$]}function SJ(){if(typeof window>"u")return;if(!o0("__STX_STORES__",null))m1("__STX_STORES__",{})}function PJ($,X){let Q=o0("__STX_STORES__",{});Q[$]=X,m1("__STX_STORES__",Q)}function bJ(){return o0("__STX_STORE_STATE__",null)}function yJ($){m1("__STX_ROUTE_PARAMS__",$)}function vJ($){m1("__STX_MIDDLEWARE_STATE__",$)}function B3(){return typeof window>"u"}function L3(){return typeof window<"u"}function gJ($){if(L3())$()}function fJ($){if(B3())$()}async function F3($){try{let X=await Bun.file($).text(),Q=z3(X),Z=j3(X,$),Y=O3(X,Q),J=H3(X,Q);return{file:$,metrics:Q,issues:Z,suggestions:Y,performance:J}}catch(X){throw Error(`Failed to analyze template ${$}: ${X instanceof Error?X.message:String(X)}`)}}function z3($){let X=$.split(`
182
182
  `),Q=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=(Q?Q[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,z=($.match(/@(?:layout|extends)\(/g)||[]).length,F=0,O=0;for(let H of X)if(/@(?:if|unless|foreach|for|while|section)\b/.test(H)&&!/@end/.test(H)&&!/@else/.test(H))O++,F=Math.max(F,O);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(H))O--;let j=F>=4?3:0,L=Math.min(10,Math.ceil(J.total*0.5+_*0.1+U*0.3+(Y>10?Y*0.05:0)+j));return{lines:X.length,characters:$.length,directives:J,expressions:_,components:U,layouts:z,scriptLines:Y,complexity:L}}function z3($,X){let Q=[],Z=r5($,"if","endif");if(Z>0)Q.push({type:"error",category:"syntax",message:`Found ${Z} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let Y=r5($,"foreach","endforeach");if(Y>0)Q.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)Q.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)Q.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((z)=>!z.includes("alt="));if(U.length>0)Q.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)Q.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)Q.push({type:"info",category:"maintainability",message:`Found ${_} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return Q}function j3($,X){let Q=[];if(X.complexity>7)Q.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)Q.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(X.lines>100&&X.components===0)Q.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(X.expressions>20)Q.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let Z=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(Z&&Z.length>0)Q.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)Q.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(X.scriptLines>50)Q.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return Q}function O3($,X){let Q=1;if(Q+=X.directives.conditionals*0.1,Q+=X.directives.loops*0.5,Q+=X.directives.includes*2,Q+=X.expressions*0.05,Q+=X.components*1,X.scriptLines>10)Q+=X.scriptLines*0.1;let Z;if(X.expressions===0&&X.directives.total===0)Z="high";else if(X.expressions<5&&X.directives.total<3)Z="medium";else Z="low";let Y=[];if(Q>10)Y.push("Consider optimizing template complexity");if(Z==="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(Q*100)/100,complexityScore:X.complexity,cacheability:Z,recommendations:Y}}function r5($,X,Q){let Z=$.replace(/<!--[\s\S]*?-->/g,""),Y=(Z.match(new RegExp(`@${X}\\b`,"g"))||[]).length,J=(Z.match(new RegExp(`@${Q}\\b`,"g"))||[]).length;return Math.abs(Y-J)}async function fJ($=["**/*.stx"],X){let Q=[],Z=[];for(let J of $){let G=await Array.fromAsync(new Bun.Glob(J).scan({cwd:X||process.cwd(),onlyFiles:!0,absolute:!0}));Z.push(...G.filter((W)=>W.endsWith(".stx")))}for(let J of Z)try{let G=await L3(J);Q.push(G)}catch(G){console.warn(`Failed to analyze ${J}:`,G)}let Y=H3(Q);return{results:Q,summary:Y}}function H3($){let X=$.length,Q=$.reduce((_,U)=>_+U.metrics.lines,0),Z=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-Z/2))),K=[];if(Z>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:Q,avgComplexity:Math.round(Z*100)/100,totalIssues:Y,issuesByCategory:J,performanceScore:W,recommendations:K}}import p1 from"path";var s5=/<script\b[^>]*\bserver\b/i,A3=/<script\b[^>]*\bclient\b/i;async function mJ($){let X=performance.now(),Q=await H1($),Z=$||Q.root||process.cwd(),Y=[Q.build?.pagesDir||Q.pagesDir||"pages",Q.componentsDir||"components",Q.layoutsDir||"layouts",Q.partialsDir||"partials"].map((W)=>p1.resolve(Z,W)),J=[],G=0;for(let W of Y){let K=await n5(W);for(let _ of K){G++;let U=await Bun.file(_).text();if(s5.test(U))J.push(p1.relative(Z,_))}}return{mode:J.length>0?"ssr":"ssg",serverScriptFiles:J,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-X)}}async function pJ($){let X=await H1($),Q=$||X.root||process.cwd(),Z=p1.resolve(Q,X.componentsDir||"components"),Y=[],J=await n5(Z);for(let G of J){let W=await Bun.file(G).text(),K=s5.test(W),_=A3.test(W)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(W)&&!K;if(K&&_){let U=p1.relative(Q,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 n5($){let X=[];try{let Q=new Bun.Glob("**/*.stx");for await(let Z of Q.scan({cwd:$,absolute:!0}))X.push(Z)}catch{}return X}var o5={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},t5=["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 e5($){let X=new Map,Q=/@(\w+)/g,Z,Y=1,J=0;while((Z=Q.exec($))!==null){let G=Z[1],W=$.slice(J,Z.index);Y+=(W.match(/\n/g)||[]).length,J=Z.index;let K=Z.index-$.lastIndexOf(`
185
- `,Z.index-1);if(t5.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 q3($,X=[]){let Q=e5($),Z=new Set(Q.map((Y)=>Y.name));for(let Y of X)Z.add(Y);for(let Y of Array.from(Z))if(!Y.startsWith("end"))Z.add(`end${Y}`);return t5.filter((Y)=>!Z.has(Y))}function N3($){let X=[],Q={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"]},Z=new Set;for(let J of $)for(let[G,W]of Object.entries(Q))if(W.includes(J)){Z.add(G);break}for(let J of Z)X.push(`import { process${w3(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,z=($.match(/@(?:layout|extends)\(/g)||[]).length,F=0,j=0;for(let H of X)if(/@(?:if|unless|foreach|for|while|section)\b/.test(H)&&!/@end/.test(H)&&!/@else/.test(H))j++,F=Math.max(F,j);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(H))j--;let O=F>=4?3:0,L=Math.min(10,Math.ceil(J.total*0.5+_*0.1+U*0.3+(Y>10?Y*0.05:0)+O));return{lines:X.length,characters:$.length,directives:J,expressions:_,components:U,layouts:z,scriptLines:Y,complexity:L}}function j3($,X){let Q=[],Z=s5($,"if","endif");if(Z>0)Q.push({type:"error",category:"syntax",message:`Found ${Z} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let Y=s5($,"foreach","endforeach");if(Y>0)Q.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)Q.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)Q.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((z)=>!z.includes("alt="));if(U.length>0)Q.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)Q.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)Q.push({type:"info",category:"maintainability",message:`Found ${_} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return Q}function O3($,X){let Q=[];if(X.complexity>7)Q.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)Q.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(X.lines>100&&X.components===0)Q.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(X.expressions>20)Q.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let Z=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(Z&&Z.length>0)Q.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)Q.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(X.scriptLines>50)Q.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return Q}function H3($,X){let Q=1;if(Q+=X.directives.conditionals*0.1,Q+=X.directives.loops*0.5,Q+=X.directives.includes*2,Q+=X.expressions*0.05,Q+=X.components*1,X.scriptLines>10)Q+=X.scriptLines*0.1;let Z;if(X.expressions===0&&X.directives.total===0)Z="high";else if(X.expressions<5&&X.directives.total<3)Z="medium";else Z="low";let Y=[];if(Q>10)Y.push("Consider optimizing template complexity");if(Z==="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(Q*100)/100,complexityScore:X.complexity,cacheability:Z,recommendations:Y}}function s5($,X,Q){let Z=$.replace(/<!--[\s\S]*?-->/g,""),Y=(Z.match(new RegExp(`@${X}\\b`,"g"))||[]).length,J=(Z.match(new RegExp(`@${Q}\\b`,"g"))||[]).length;return Math.abs(Y-J)}async function dJ($=["**/*.stx"],X){let Q=[],Z=[];for(let J of $){let G=await Array.fromAsync(new Bun.Glob(J).scan({cwd:X||process.cwd(),onlyFiles:!0,absolute:!0}));Z.push(...G.filter((W)=>W.endsWith(".stx")))}for(let J of Z)try{let G=await F3(J);Q.push(G)}catch(G){console.warn(`Failed to analyze ${J}:`,G)}let Y=A3(Q);return{results:Q,summary:Y}}function A3($){let X=$.length,Q=$.reduce((_,U)=>_+U.metrics.lines,0),Z=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-Z/2))),K=[];if(Z>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:Q,avgComplexity:Math.round(Z*100)/100,totalIssues:Y,issuesByCategory:J,performanceScore:W,recommendations:K}}import p1 from"path";var n5=/<script\b[^>]*\bserver\b/i,q3=/<script\b[^>]*\bclient\b/i;async function cJ($){let X=performance.now(),Q=await d0($),Z=$||Q.root||process.cwd(),Y=[Q.build?.pagesDir||Q.pagesDir||"pages",Q.componentsDir||"components",Q.layoutsDir||"layouts",Q.partialsDir||"partials"].map((W)=>p1.resolve(Z,W)),J=[],G=0;for(let W of Y){let K=await o5(W);for(let _ of K){G++;let U=await Bun.file(_).text();if(n5.test(U))J.push(p1.relative(Z,_))}}return{mode:J.length>0?"ssr":"ssg",serverScriptFiles:J,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-X)}}async function lJ($){let X=await d0($),Q=$||X.root||process.cwd(),Z=p1.resolve(Q,X.componentsDir||"components"),Y=[],J=await o5(Z);for(let G of J){let W=await Bun.file(G).text(),K=n5.test(W),_=q3.test(W)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(W)&&!K;if(K&&_){let U=p1.relative(Q,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 o5($){let X=[];try{let Q=new Bun.Glob("**/*.stx");for await(let Z of Q.scan({cwd:$,absolute:!0}))X.push(Z)}catch{}return X}var t5={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},e5=["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 $6($){let X=new Map,Q=/@(\w+)/g,Z,Y=1,J=0;while((Z=Q.exec($))!==null){let G=Z[1],W=$.slice(J,Z.index);Y+=(W.match(/\n/g)||[]).length,J=Z.index;let K=Z.index-$.lastIndexOf(`
185
+ `,Z.index-1);if(e5.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 Q=$6($),Z=new Set(Q.map((Y)=>Y.name));for(let Y of X)Z.add(Y);for(let Y of Array.from(Z))if(!Y.startsWith("end"))Z.add(`end${Y}`);return e5.filter((Y)=>!Z.has(Y))}function M3($){let X=[],Q={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"]},Z=new Set;for(let J of $)for(let[G,W]of Object.entries(Q))if(W.includes(J)){Z.add(G);break}for(let J of Z)X.push(`import { process${T3(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 M3($,X={}){let Q=[],Z=/@if\(([^)]+)\)[\s\S]*?@endif/g,Y=$.matchAll(Z);for(let _ of Y){let U=_[1].trim();if(m$(U,X)===!1)Q.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(m$(U,X)===!0)Q.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 _)Q.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 _)Q.push({start:U.index,end:U.index+U[0].length,reason:"Debug code in production build"})}return Q}function V3($,X={}){let Q=M3($,X),Z=[];Q.sort((J,G)=>G.start-J.start);let Y=$;for(let J of Q)Y=Y.slice(0,J.start)+Y.slice(J.end),Z.push(J.reason);return{content:Y,removed:Z}}function m$($,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 Q=$.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(Q){let[,Z,Y,J]=Q,G=Z in X?X[Z]:void 0,W=m$(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 E3($,X){let Q=[],Z=$;return Z=Z.replace(/\{\{\s*(\w+)\s*\}\}/g,(Y,J)=>{if(J in X)return Q.push(`{{ ${J} }} -> ${X[J]}`),String(X[J]);return Y}),Z=Z.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 Q.push(`{{ ${J} ${G} ${W} }} -> ${U}`),String(U)}),{content:Z,folded:Q}}function I3($){let X=$,Q=[],Z=0;X=X.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(Y)=>{let J=`__PRESERVE_${Z++}__`;return Q.push({marker:J,content:Y}),J}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(Y)=>{let J=`__PRESERVE_${Z++}__`;return Q.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 Q){let G=X.indexOf(Y);if(G!==-1)X=X.slice(0,G)+J+X.slice(G+Y.length)}return X.trim()}function R3($){let X=new Map,Q=new Map,Z=/(['"])([^'"]{10,})\1/g,Y;while((Y=Z.exec($))!==null){let W=Y[2];Q.set(W,(Q.get(W)||0)+1)}let J=0,G=$;for(let[W,K]of Q)if(K>1){let _=`__STR_${J++}__`;X.set(_,W);let U=W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=new RegExp(`(['"])${U}\\1`,"g");G=G.replace(z,_)}return{content:G,pool:X,count:X.size}}function D3($,X={}){let Q={...o5,...X},Z=new Blob([$]).size,Y=$,J=[],G=[],W=[],K=[],_=0;if(Q.target==="production")Q.constants={...Q.constants,__ENV__:"production"};if(Q.deadCodeElimination){let F=V3(Y,Q.constants);if(Y=F.content,F.removed.length>0)J.push("Dead code elimination"),G.push(...F.removed.map((O)=>`Removed: ${O}`))}if(Q.constantFolding&&Object.keys(Q.constants).length>0){let F=E3(Y,Q.constants);if(Y=F.content,K=F.folded,K.length>0)J.push("Constant folding")}if(Q.treeShake){if(W=q3(Y,Q.preserveDirectives),W.length>0)J.push("Tree shaking")}if(Q.stringPooling){let F=R3(Y);if(Y=F.content,_=F.count,_>0)J.push("String pooling")}if(Q.minifyHtml){let F=I3(Y);if(F.length<Y.length)Y=F,J.push("HTML minification")}let U=new Blob([Y]).size,z=Z>0?Math.round((1-U/Z)*100):0;return{content:Y,originalSize:Z,optimizedSize:U,reduction:z,appliedOptimizations:J,removedDirectives:W,foldedConstants:K,pooledStrings:_,warnings:G}}async function lJ($,X={}){let Q={...o5,...X},Z=new Map,Y=[],J=0,G=0,W=new Set;for(let[z,F]of $){let O=D3(F,Q);Z.set(z,O),J+=O.originalSize,G+=O.optimizedSize,Y.push(...O.warnings.map((L)=>`${z}: ${L}`));let j=e5(F);for(let L of j)W.add(L.name)}let K;if(Q.treeShake)K=N3(Array.from(W));let _;if(Q.stringPooling)_=new Map;let U=J>0?Math.round((1-G/J)*100):0;return{templates:Z,directiveBundle:K,stringPool:_,totalOriginalSize:J,totalOptimizedSize:G,overallReduction:U,warnings:Y}}function w3($){return $.charAt(0).toUpperCase()+$.slice(1)}function Q6($,X){let Q={},Z=$.trim();if(Z.startsWith("{"))Z=Z.slice(1);if(Z.endsWith("}"))Z=Z.slice(0,-1);if(Z=Z.trim(),!Z)return Q;let Y=0;while(Y<Z.length){while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Y>=Z.length)break;let J="";if(Z[Y]==='"'||Z[Y]==="'"){let K=Z[Y];Y++;while(Y<Z.length&&Z[Y]!==K)if(Z[Y]==="\\"&&Y+1<Z.length)J+=Z[Y+1],Y+=2;else J+=Z[Y],Y++;Y++}else while(Y<Z.length&&/[\w$]/.test(Z[Y]))J+=Z[Y],Y++;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Z[Y]===":")Y++;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;let G,W=Y;if(Z[Y]==='"'||Z[Y]==="'"){let K=Z[Y];Y++;let _="";while(Y<Z.length&&Z[Y]!==K)if(Z[Y]==="\\"&&Y+1<Z.length)_+=Z[Y+1],Y+=2;else _+=Z[Y],Y++;Y++,G=_}else if(Z[Y]==="{"){let K=1;Y++;while(Y<Z.length&&K>0){if(Z[Y]==="{")K++;else if(Z[Y]==="}")K--;else if(Z[Y]==='"'||Z[Y]==="'"){let U=Z[Y];Y++;while(Y<Z.length&&Z[Y]!==U){if(Z[Y]==="\\")Y++;Y++}}Y++}let _=Z.slice(W,Y);G=Q6(_,X)}else if(Z[Y]==="["){let K=1;Y++;while(Y<Z.length&&K>0){if(Z[Y]==="[")K++;else if(Z[Y]==="]")K--;else if(Z[Y]==='"'||Z[Y]==="'"){let U=Z[Y];Y++;while(Y<Z.length&&Z[Y]!==U){if(Z[Y]==="\\")Y++;Y++}}Y++}let _=Z.slice(W,Y);try{G=JSON.parse(_.replace(/'/g,'"'))}catch{G=_}}else{let K="";while(Y<Z.length&&Z[Y]!==","&&!/\s/.test(Z[Y]))K+=Z[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)Q[J]=G;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Z[Y]===",")Y++}return Q}function nJ($,X,Q){let Z=[];for(let[Y,J]of Object.entries(X)){let G=$[Y];if(J.required&&(G===void 0||G===null)){Z.push(`Component "${Q}": 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=T3(G);if(!W.includes(K))Z.push(`Component "${Q}": Prop "${Y}" expected ${W.join(" | ")}, got ${K}`)}if(J.validator&&!J.validator(G))Z.push(`Component "${Q}": Prop "${Y}" failed custom validation`)}return Z}function oJ($,X){let Q={...$};for(let[Z,Y]of Object.entries(X))if(Q[Z]===void 0&&Y.default!==void 0)Q[Z]=typeof Y.default==="function"?Y.default():Y.default;return Q}function T3($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}var C3={name:"component",handler:async($,X,Q,Z)=>{if(X.length<1)return l1("Component","component directive requires at least the component name",c1.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=$6(U,Q),Object.keys(J).length===0)J=Q6(U,Q)}else{let z=U.trim(),F=Q[z];if(F&&typeof F==="object"&&!Array.isArray(F))J=F}}catch(U){let z=U instanceof Error?U.message:String(U);return console.error("Component props parsing error:",z),l1("Component",`Error parsing component props: ${z}`,c1.EVALUATION_ERROR)}let G=Q.__stx_options||{},W=G.componentsDir||"components",K=new Set;if(!Q.__processedComponents)Q.__processedComponents=new Set;let _=Q.__processedComponents;try{return await X6(Y,J,"",W,Q,Z,G,_,K)}catch(U){console.error("Component rendering error:",U);let z=U instanceof Error?U.message:String(U);return l1("Component",`Error rendering component: ${z}`,c1.COMPONENT_RENDER_ERROR)}},hasEndTag:!1};function tJ(){return[C3]}import{mkdir as x3,readFile as k3,readdir as S3,stat as Z6,writeFile as P3}from"fs/promises";import $0 from"path";var K6=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function b3($){return $.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join("")}function p$($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function y3($){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test($)&&!$.startsWith("xml")&&!/[A-Z]/.test($)}function v3($){if($===!0)return"open";if($==="open"||$==="closed")return $;return!1}async function g3($){let X=[];async function Q(Z){let Y=await S3(Z,{withFileTypes:!0});Y.sort((J,G)=>J.name.localeCompare(G.name));for(let J of Y){let G=$0.join(Z,J.name);if(J.isDirectory()){if(!J.name.startsWith(".")&&J.name!=="node_modules")await Q(G)}else if(J.isFile()&&J.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(J.name))X.push(G)}}return await Q($),X}function f3($,X){let Q=$.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!Q)return{};let Z=Q[1].trim();if(!Z)return{};try{return JSON.parse(Z)}catch(Y){throw Error(`${X}: <script component> must contain JSON metadata (${Y.message})`)}}function h3($,X){let Q={},Z=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let Y of Z){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(K6.has(K))throw Error(`${X}: client method "${K}" is reserved`);let _=G.lastIndex,U=1,z="",F=!1,O=_;for(;O<J.length&&U>0;O++){let L=J[O];if(F){F=!1;continue}if(z){if(L==="\\")F=!0;else if(L===z)z="";continue}if(L==='"'||L==="'"||L==="`")z=L;else if(L==="{")U++;else if(L==="}")U--}if(U!==0)throw Error(`${X}: unterminated client function "${K}"`);let j=W[0].includes("async")?"async ":"";Q[K]=`${j}${K}(${W[2]}) {${J.slice(_,O-1)}}`,G.lastIndex=O}}return Q}function d3($){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 Y6($){return[...$.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((X)=>X[1].trim()).filter(Boolean).join(`
198
+ `}function V3($,X={}){let Q=[],Z=/@if\(([^)]+)\)[\s\S]*?@endif/g,Y=$.matchAll(Z);for(let _ of Y){let U=_[1].trim();if(c$(U,X)===!1)Q.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(c$(U,X)===!0)Q.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 _)Q.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 _)Q.push({start:U.index,end:U.index+U[0].length,reason:"Debug code in production build"})}return Q}function E3($,X={}){let Q=V3($,X),Z=[];Q.sort((J,G)=>G.start-J.start);let Y=$;for(let J of Q)Y=Y.slice(0,J.start)+Y.slice(J.end),Z.push(J.reason);return{content:Y,removed:Z}}function c$($,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 Q=$.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(Q){let[,Z,Y,J]=Q,G=Z in X?X[Z]:void 0,W=c$(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 I3($,X){let Q=[],Z=$;return Z=Z.replace(/\{\{\s*(\w+)\s*\}\}/g,(Y,J)=>{if(J in X)return Q.push(`{{ ${J} }} -> ${X[J]}`),String(X[J]);return Y}),Z=Z.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 Q.push(`{{ ${J} ${G} ${W} }} -> ${U}`),String(U)}),{content:Z,folded:Q}}function R3($){let X=$,Q=[],Z=0;X=X.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(Y)=>{let J=`__PRESERVE_${Z++}__`;return Q.push({marker:J,content:Y}),J}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(Y)=>{let J=`__PRESERVE_${Z++}__`;return Q.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 Q){let G=X.indexOf(Y);if(G!==-1)X=X.slice(0,G)+J+X.slice(G+Y.length)}return X.trim()}function D3($){let X=new Map,Q=new Map,Z=/(['"])([^'"]{10,})\1/g,Y;while((Y=Z.exec($))!==null){let W=Y[2];Q.set(W,(Q.get(W)||0)+1)}let J=0,G=$;for(let[W,K]of Q)if(K>1){let _=`__STR_${J++}__`;X.set(_,W);let U=W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=new RegExp(`(['"])${U}\\1`,"g");G=G.replace(z,_)}return{content:G,pool:X,count:X.size}}function w3($,X={}){let Q={...t5,...X},Z=new Blob([$]).size,Y=$,J=[],G=[],W=[],K=[],_=0;if(Q.target==="production")Q.constants={...Q.constants,__ENV__:"production"};if(Q.deadCodeElimination){let F=E3(Y,Q.constants);if(Y=F.content,F.removed.length>0)J.push("Dead code elimination"),G.push(...F.removed.map((j)=>`Removed: ${j}`))}if(Q.constantFolding&&Object.keys(Q.constants).length>0){let F=I3(Y,Q.constants);if(Y=F.content,K=F.folded,K.length>0)J.push("Constant folding")}if(Q.treeShake){if(W=N3(Y,Q.preserveDirectives),W.length>0)J.push("Tree shaking")}if(Q.stringPooling){let F=D3(Y);if(Y=F.content,_=F.count,_>0)J.push("String pooling")}if(Q.minifyHtml){let F=R3(Y);if(F.length<Y.length)Y=F,J.push("HTML minification")}let U=new Blob([Y]).size,z=Z>0?Math.round((1-U/Z)*100):0;return{content:Y,originalSize:Z,optimizedSize:U,reduction:z,appliedOptimizations:J,removedDirectives:W,foldedConstants:K,pooledStrings:_,warnings:G}}async function aJ($,X={}){let Q={...t5,...X},Z=new Map,Y=[],J=0,G=0,W=new Set;for(let[z,F]of $){let j=w3(F,Q);Z.set(z,j),J+=j.originalSize,G+=j.optimizedSize,Y.push(...j.warnings.map((L)=>`${z}: ${L}`));let O=$6(F);for(let L of O)W.add(L.name)}let K;if(Q.treeShake)K=M3(Array.from(W));let _;if(Q.stringPooling)_=new Map;let U=J>0?Math.round((1-G/J)*100):0;return{templates:Z,directiveBundle:K,stringPool:_,totalOriginalSize:J,totalOptimizedSize:G,overallReduction:U,warnings:Y}}function T3($){return $.charAt(0).toUpperCase()+$.slice(1)}function Z6($,X){let Q={},Z=$.trim();if(Z.startsWith("{"))Z=Z.slice(1);if(Z.endsWith("}"))Z=Z.slice(0,-1);if(Z=Z.trim(),!Z)return Q;let Y=0;while(Y<Z.length){while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Y>=Z.length)break;let J="";if(Z[Y]==='"'||Z[Y]==="'"){let K=Z[Y];Y++;while(Y<Z.length&&Z[Y]!==K)if(Z[Y]==="\\"&&Y+1<Z.length)J+=Z[Y+1],Y+=2;else J+=Z[Y],Y++;Y++}else while(Y<Z.length&&/[\w$]/.test(Z[Y]))J+=Z[Y],Y++;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Z[Y]===":")Y++;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;let G,W=Y;if(Z[Y]==='"'||Z[Y]==="'"){let K=Z[Y];Y++;let _="";while(Y<Z.length&&Z[Y]!==K)if(Z[Y]==="\\"&&Y+1<Z.length)_+=Z[Y+1],Y+=2;else _+=Z[Y],Y++;Y++,G=_}else if(Z[Y]==="{"){let K=1;Y++;while(Y<Z.length&&K>0){if(Z[Y]==="{")K++;else if(Z[Y]==="}")K--;else if(Z[Y]==='"'||Z[Y]==="'"){let U=Z[Y];Y++;while(Y<Z.length&&Z[Y]!==U){if(Z[Y]==="\\")Y++;Y++}}Y++}let _=Z.slice(W,Y);G=Z6(_,X)}else if(Z[Y]==="["){let K=1;Y++;while(Y<Z.length&&K>0){if(Z[Y]==="[")K++;else if(Z[Y]==="]")K--;else if(Z[Y]==='"'||Z[Y]==="'"){let U=Z[Y];Y++;while(Y<Z.length&&Z[Y]!==U){if(Z[Y]==="\\")Y++;Y++}}Y++}let _=Z.slice(W,Y);try{G=JSON.parse(_.replace(/'/g,'"'))}catch{G=_}}else{let K="";while(Y<Z.length&&Z[Y]!==","&&!/\s/.test(Z[Y]))K+=Z[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)Q[J]=G;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Z[Y]===",")Y++}return Q}function tJ($,X,Q){let Z=[];for(let[Y,J]of Object.entries(X)){let G=$[Y];if(J.required&&(G===void 0||G===null)){Z.push(`Component "${Q}": 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=C3(G);if(!W.includes(K))Z.push(`Component "${Q}": Prop "${Y}" expected ${W.join(" | ")}, got ${K}`)}if(J.validator&&!J.validator(G))Z.push(`Component "${Q}": Prop "${Y}" failed custom validation`)}return Z}function eJ($,X){let Q={...$};for(let[Z,Y]of Object.entries(X))if(Q[Z]===void 0&&Y.default!==void 0)Q[Z]=typeof Y.default==="function"?Y.default():Y.default;return Q}function C3($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}var k3={name:"component",handler:async($,X,Q,Z)=>{if(X.length<1)return l1("Component","component directive requires at least the component name",c1.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=X6(U,Q),Object.keys(J).length===0)J=Z6(U,Q)}else{let z=U.trim(),F=Q[z];if(F&&typeof F==="object"&&!Array.isArray(F))J=F}}catch(U){let z=U instanceof Error?U.message:String(U);return console.error("Component props parsing error:",z),l1("Component",`Error parsing component props: ${z}`,c1.EVALUATION_ERROR)}let G=Q.__stx_options||{},W=G.componentsDir||"components",K=new Set;if(!Q.__processedComponents)Q.__processedComponents=new Set;let _=Q.__processedComponents;try{return await Q6(Y,J,"",W,Q,Z,G,_,K)}catch(U){console.error("Component rendering error:",U);let z=U instanceof Error?U.message:String(U);return l1("Component",`Error rendering component: ${z}`,c1.COMPONENT_RENDER_ERROR)}},hasEndTag:!1};function $G(){return[k3]}import{mkdir as x3,readFile as S3,readdir as P3,stat as Y6,writeFile as b3}from"fs/promises";import $0 from"path";var _6=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function y3($){return $.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join("")}function l$($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function v3($){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test($)&&!$.startsWith("xml")&&!/[A-Z]/.test($)}function g3($){if($===!0)return"open";if($==="open"||$==="closed")return $;return!1}async function f3($){let X=[];async function Q(Z){let Y=await P3(Z,{withFileTypes:!0});Y.sort((J,G)=>J.name.localeCompare(G.name));for(let J of Y){let G=$0.join(Z,J.name);if(J.isDirectory()){if(!J.name.startsWith(".")&&J.name!=="node_modules")await Q(G)}else if(J.isFile()&&J.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(J.name))X.push(G)}}return await Q($),X}function h3($,X){let Q=$.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!Q)return{};let Z=Q[1].trim();if(!Z)return{};try{return JSON.parse(Z)}catch(Y){throw Error(`${X}: <script component> must contain JSON metadata (${Y.message})`)}}function d3($,X){let Q={},Z=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let Y of Z){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(_6.has(K))throw Error(`${X}: client method "${K}" is reserved`);let _=G.lastIndex,U=1,z="",F=!1,j=_;for(;j<J.length&&U>0;j++){let L=J[j];if(F){F=!1;continue}if(z){if(L==="\\")F=!0;else if(L===z)z="";continue}if(L==='"'||L==="'"||L==="`")z=L;else if(L==="{")U++;else if(L==="}")U--}if(U!==0)throw Error(`${X}: unterminated client function "${K}"`);let O=W[0].includes("async")?"async ":"";Q[K]=`${O}${K}(${W[2]}) {${J.slice(_,j-1)}}`,G.lastIndex=j}}return Q}function u3($){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(`
199
199
 
200
- `)}function u3($){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 m3($){if($===void 0)return"object";if($==="true"||$==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test($))return"number";if(/^['"`]/.test($))return"string";return"object"}function p3($){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 c3($){let X=[],Q=0,Z=$.replace(/\{\{--[\s\S]*?--\}\}/g,""),Y=/@(if|elseif|else|endif|foreach|endforeach)\s*(?:\(([\s\S]*?)\))?/g,J,G=(W)=>{if(W==="")return;let K=0,_=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}/g,U;while(U=_.exec(W)){if(U.index>K)X.push(`out += ${JSON.stringify(W.slice(K,U.index))};`);X.push(U[1]!==void 0?`out += __raw(${U[1]});`:`out += __escape(${U[2]});`),K=U.index+U[0].length}if(K<W.length)X.push(`out += ${JSON.stringify(W.slice(K))};`)};while(J=Y.exec(Z))switch(G(Z.slice(Q,J.index)),Q=J.index+J[0].length,J[1]){case"if":X.push(`if (${J[2]}) {`);break;case"elseif":X.push(`} else if (${J[2]}) {`);break;case"else":X.push("} else {");break;case"endif":case"endforeach":X.push("}");break;case"foreach":{let W=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec((J[2]||"").trim());if(!W){X.push(`out += ${JSON.stringify(J[0])};`);break}let[,K,_,U]=W;X.push(_?`for (const [${_}, ${U}] of __entries(${K})) {`:`for (const ${U} of __values(${K})) {`);break}}return G(Z.slice(Q)),X.join(`
201
- `)}function l3($,X,Q){let Y=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].find((F)=>!/\bcomponent\b|\bstx:component\b|\bclient\b/i.test(F[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,(F)=>{if(/from\s*['"]stx['"]/.test(F))return"";return G.push(F.trim().replace(/(from\s*['"])(\.[^'"]*)(['"])/,(O,j,L,H)=>{let A=$0.resolve($0.dirname(X),L),q=$0.relative(Q,A);return`${j}${q.startsWith(".")?q:`./${q}`}${H}`})),""});let z=/const\s*\{([^}]*)\}\s*=\s*(?:withDefaults\s*\(\s*)?defineProps\s*<[^>]*>\s*\(\s*\)\s*(?:,\s*(\{[\s\S]*?\})\s*,?\s*\))?/.exec(J);if(z){for(let F of z[1].split(",")){let O=F.split(":")[0].trim();if(O)W.push(O)}for(let F of(z[2]||"").matchAll(/([A-Za-z_$][\w$]*)\s*:\s*([^,}]+)/g))K[F[1]]=F[2].trim();J=J.replace(z[0],"")}for(let F of J.matchAll(/(?:export\s+)?interface\s+[A-Za-z_$][\w$]*\s*\{([\s\S]*?)\n\}/g))for(let O of F[1].matchAll(/^\s*(?:\/\*\*[\s\S]*?\*\/\s*)?([A-Za-z_$][\w$]*)\??\s*:\s*([^\n;]+)/gm))_[O[1]]=O[2].trim();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 i3($){let X=new Set;return{template:$.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(Z,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 a3($){let X=[];return{template:$.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(Z,Y,J,G)=>{let W=X.length;return X.push({id:W,name:Y,expression:G}),` data-stx-bind-${W}=""`}),bindings:X}}function r3($){let X=new Set;for(let Q of $.matchAll(/<slot\b([^>]*)>/gi))X.add(Q[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...X].map((Q)=>({name:Q}))}function s3($){return[...new Set([...$.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((X)=>X[1]))].sort().map((X)=>({name:X}))}function J6($,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 n3($,X,Q){let Z=$0.isAbsolute(X.file)?X.file:$0.resolve($,X.file),Y=await k3(Z,"utf8"),J=f3(Y,Z),G=$0.basename(Z,".stx"),W=X.name||J.name||b3(G),K=`${p$(Q.prefix||"stx")}-${p$(G)}`,_=X.tag||J.tag||K;if(!W||!/^[A-Za-z_$][\w$]*$/.test(W))throw Error(`${Z}: invalid component class name "${W}"`);if(!y3(_))throw Error(`${Z}: invalid custom-element tag "${_}"; tags must be lowercase and contain a hyphen`);let U=X.properties||J.properties||J.props||{},z=Object.fromEntries(Object.entries(U).map(([M,V])=>[M,J6(M,V)])),F=i3(d3(Y)),O=a3(F.template),j=l3(Y,Z,$0.resolve(Q.outputDir)),L=c3(O.template);for(let M of j.propNames){if(z[M])continue;let V=j.defaults[M];z[M]=J6(M,{type:u3(j.declared[M])??m3(V),...V===void 0?{}:{default:p3(V)}})}let H=J.methods||{},A=X.methods||{},q=h3(Y,Z);return{file:$0.relative($,Z),sourcePath:Z,name:W,tag:_,description:X.description||J.description||"",template:O.template,styles:Y6(Y),shadowMode:v3(X.shadowDOM??J.shadowDOM??Q.shadowDOM),progressive:X.progressive??J.progressive??Q.progressive??!0,properties:z,events:X.events||J.events||{},methods:{...H,...A,...q},eventTypes:F.eventTypes,bindings:O.bindings,slots:r3(O.template),cssProperties:s3(Y6(Y)),scope:j,render:L}}function o3(){let $=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),X=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
200
+ `)}function m3($){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 p3($){if($===void 0)return"object";if($==="true"||$==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test($))return"number";if(/^['"`]/.test($))return"string";return"object"}function c3($){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 l3($){let X=[],Q=0,Z=$.replace(/\{\{--[\s\S]*?--\}\}/g,""),Y=/@(if|elseif|else|endif|foreach|endforeach)\s*(?:\(([\s\S]*?)\))?/g,J,G=(W)=>{if(W==="")return;let K=0,_=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}/g,U;while(U=_.exec(W)){if(U.index>K)X.push(`out += ${JSON.stringify(W.slice(K,U.index))};`);X.push(U[1]!==void 0?`out += __raw(${U[1]});`:`out += __escape(${U[2]});`),K=U.index+U[0].length}if(K<W.length)X.push(`out += ${JSON.stringify(W.slice(K))};`)};while(J=Y.exec(Z))switch(G(Z.slice(Q,J.index)),Q=J.index+J[0].length,J[1]){case"if":X.push(`if (${J[2]}) {`);break;case"elseif":X.push(`} else if (${J[2]}) {`);break;case"else":X.push("} else {");break;case"endif":case"endforeach":X.push("}");break;case"foreach":{let W=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec((J[2]||"").trim());if(!W){X.push(`out += ${JSON.stringify(J[0])};`);break}let[,K,_,U]=W;X.push(_?`for (const [${_}, ${U}] of __entries(${K})) {`:`for (const ${U} of __values(${K})) {`);break}}return G(Z.slice(Q)),X.join(`
201
+ `)}function i3($,X,Q){let Y=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].find((F)=>!/\bcomponent\b|\bstx:component\b|\bclient\b/i.test(F[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,(F)=>{if(/from\s*['"]stx['"]/.test(F))return"";return G.push(F.trim().replace(/(from\s*['"])(\.[^'"]*)(['"])/,(j,O,L,H)=>{let q=$0.resolve($0.dirname(X),L),A=$0.relative(Q,q);return`${O}${A.startsWith(".")?A:`./${A}`}${H}`})),""});let z=/const\s*\{([^}]*)\}\s*=\s*(?:withDefaults\s*\(\s*)?defineProps\s*<[^>]*>\s*\(\s*\)\s*(?:,\s*(\{[\s\S]*?\})\s*,?\s*\))?/.exec(J);if(z){for(let F of z[1].split(",")){let j=F.split(":")[0].trim();if(j)W.push(j)}for(let F of(z[2]||"").matchAll(/([A-Za-z_$][\w$]*)\s*:\s*([^,}]+)/g))K[F[1]]=F[2].trim();J=J.replace(z[0],"")}for(let F of J.matchAll(/(?:export\s+)?interface\s+[A-Za-z_$][\w$]*\s*\{([\s\S]*?)\n\}/g))for(let j of F[1].matchAll(/^\s*(?:\/\*\*[\s\S]*?\*\/\s*)?([A-Za-z_$][\w$]*)\??\s*:\s*([^\n;]+)/gm))_[j[1]]=j[2].trim();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 a3($){let X=new Set;return{template:$.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(Z,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 r3($){let X=[];return{template:$.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(Z,Y,J,G)=>{let W=X.length;return X.push({id:W,name:Y,expression:G}),` data-stx-bind-${W}=""`}),bindings:X}}function s3($){let X=new Set;for(let Q of $.matchAll(/<slot\b([^>]*)>/gi))X.add(Q[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...X].map((Q)=>({name:Q}))}function n3($){return[...new Set([...$.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((X)=>X[1]))].sort().map((X)=>({name:X}))}function G6($,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 o3($,X,Q){let Z=$0.isAbsolute(X.file)?X.file:$0.resolve($,X.file),Y=await S3(Z,"utf8"),J=h3(Y,Z),G=$0.basename(Z,".stx"),W=X.name||J.name||y3(G),K=`${l$(Q.prefix||"stx")}-${l$(G)}`,_=X.tag||J.tag||K;if(!W||!/^[A-Za-z_$][\w$]*$/.test(W))throw Error(`${Z}: invalid component class name "${W}"`);if(!v3(_))throw Error(`${Z}: invalid custom-element tag "${_}"; tags must be lowercase and contain a hyphen`);let U=X.properties||J.properties||J.props||{},z=Object.fromEntries(Object.entries(U).map(([N,V])=>[N,G6(N,V)])),F=a3(u3(Y)),j=r3(F.template),O=i3(Y,Z,$0.resolve(Q.outputDir)),L=l3(j.template);for(let N of O.propNames){if(z[N])continue;let V=O.defaults[N];z[N]=G6(N,{type:m3(O.declared[N])??p3(V),...V===void 0?{}:{default:c3(V)}})}let H=J.methods||{},q=X.methods||{},A=d3(Y,Z);return{file:$0.relative($,Z),sourcePath:Z,name:W,tag:_,description:X.description||J.description||"",template:j.template,styles:J6(Y),shadowMode:g3(X.shadowDOM??J.shadowDOM??Q.shadowDOM),progressive:X.progressive??J.progressive??Q.progressive??!0,properties:z,events:X.events||J.events||{},methods:{...H,...q,...A},eventTypes:F.eventTypes,bindings:j.bindings,slots:s3(j.template),cssProperties:n3(J6(Y)),scope:O,render:L}}function t3(){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;')
@@ -484,7 +484,7 @@ export function defineComponent(Component, definition) {
484
484
  }
485
485
  return Component;
486
486
  }
487
- `}function t3($){let X=JSON.stringify({tag:$.tag,template:$.template,styles:$.styles,shadowMode:$.shadowMode,progressive:$.progressive,properties:$.properties,eventTypes:$.eventTypes,bindings:$.bindings},null,2),Q=Object.entries($.methods).map(([W,K])=>{if(K6.has(W))throw Error(`${$.sourcePath}: method "${W}" is reserved`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(K.trim()))return` ${K.trim()}`;return` ${W}($event) {
487
+ `}function e3($){let X=JSON.stringify({tag:$.tag,template:$.template,styles:$.styles,shadowMode:$.shadowMode,progressive:$.progressive,properties:$.properties,eventTypes:$.eventTypes,bindings:$.bindings},null,2),Q=Object.entries($.methods).map(([W,K])=>{if(_6.has(W))throw Error(`${$.sourcePath}: method "${W}" is reserved`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(K.trim()))return` ${K.trim()}`;return` ${W}($event) {
488
488
  ${K}
489
489
  }`}).join(`
490
490
 
@@ -509,7 +509,7 @@ ${Q}${G}
509
509
 
510
510
  defineComponent(${$.name}, ${X});
511
511
  export default ${$.name};
512
- `}function i1($){switch($.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function e3($){let X=Object.entries($.properties).map(([J,G])=>` ${J}${G.required?"":"?"}: ${i1(G)}`).join(`
512
+ `}function i1($){switch($.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function $4($){let X=Object.entries($.properties).map(([J,G])=>` ${J}${G.required?"":"?"}: ${i1(G)}`).join(`
513
513
  `),Q=Object.entries($.properties).map(([J,G])=>` ${J}: ${i1(G)}`).join(`
514
514
  `),Z=Object.entries($.events).map(([J,G])=>` ${JSON.stringify(J)}: CustomEvent<${G.detailType||"unknown"}>`).join(`
515
515
  `),Y=Object.keys($.methods).map((J)=>` ${J}($event?: Event): unknown`).join(`
@@ -536,7 +536,7 @@ declare global {
536
536
  }
537
537
 
538
538
  export default ${$.name}
539
- `}function $4($){return`declare global {
539
+ `}function X4($){return`declare global {
540
540
  namespace JSX {
541
541
  interface IntrinsicElements {
542
542
  ${$.map((Q)=>{let Z=Object.entries(Q.properties).map(([J,G])=>` ${JSON.stringify(J)}?: ${i1(G)}`).join(`
@@ -555,9 +555,9 @@ ${Y}
555
555
  }
556
556
 
557
557
  export {}
558
- `}function X4($){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(([Q,Z])=>({kind:"field",name:Q,description:Z.description,type:{text:i1(Z)},default:Z.default===void 0?void 0:JSON.stringify(Z.default),attribute:Z.attribute===!1?void 0:Z.attribute||p$(Q),reflects:Z.reflect})),events:Object.entries(X.events).map(([Q,Z])=>({name:Q,description:Z.description,type:{text:`CustomEvent<${Z.detailType||"unknown"}>`}})),slots:X.slots,cssProperties:X.cssProperties}],exports:[{kind:"js",name:X.name,declaration:{name:X.name,module:`./${X.tag}.js`}}]}))}}function G6($){if(!$.styles)return"";let X=$.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(X))return X;return`@scope (${$.tag}) {
558
+ `}function Q4($){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(([Q,Z])=>({kind:"field",name:Q,description:Z.description,type:{text:i1(Z)},default:Z.default===void 0?void 0:JSON.stringify(Z.default),attribute:Z.attribute===!1?void 0:Z.attribute||l$(Q),reflects:Z.reflect})),events:Object.entries(X.events).map(([Q,Z])=>({name:Q,description:Z.description,type:{text:`CustomEvent<${Z.detailType||"unknown"}>`}})),slots:X.slots,cssProperties:X.cssProperties}],exports:[{kind:"js",name:X.name,declaration:{name:X.name,module:`./${X.tag}.js`}}]}))}}function W6($){if(!$.styles)return"";let X=$.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(X))return X;return`@scope (${$.tag}) {
559
559
  ${X}
560
- }`}function W6($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function Q4($){let X=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),Q=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),Z=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(`
560
+ }`}function K6($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function Z4($){let X=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),Q=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),Z=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(`
561
561
  `);return`const definitions = ${JSON.stringify(Y,null,2)};
562
562
  const escapeHTML = (value) => String(value ?? '')
563
563
  .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
@@ -591,21 +591,21 @@ export function renderComponent(tag, props = {}, slots = {}) {
591
591
  }
592
592
 
593
593
  ${J}
594
- `}async function QG($){let X=$0.resolve($.inputDir),Q=$0.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 g3(X)).map((L)=>({file:L}));if(!Y.length)throw Error(`No .stx components found in ${X}`);let J=await Promise.all(Y.map((L)=>n3(X,L,$)));J.sort((L,H)=>L.tag.localeCompare(H.tag));let G=J.filter((L,H)=>J.findIndex((A)=>A.tag===L.tag)!==H);if(G.length)throw Error(`Duplicate custom-element tag: ${G[0].tag}`);let W=J.filter((L,H)=>J.findIndex((A)=>A.name===L.name)!==H);if(W.length)throw Error(`Duplicate component class name: ${W[0].name}`);await x3(Q,{recursive:!0});let K=[],_=async(L,H)=>{let A=$0.join(Q,L);return await P3(A,H.endsWith(`
594
+ `}async function YG($){let X=$0.resolve($.inputDir),Q=$0.resolve($.outputDir);if(!(await Y6(X).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${X}`);let Y=$.components?.length?$.components:(await f3(X)).map((L)=>({file:L}));if(!Y.length)throw Error(`No .stx components found in ${X}`);let J=await Promise.all(Y.map((L)=>o3(X,L,$)));J.sort((L,H)=>L.tag.localeCompare(H.tag));let G=J.filter((L,H)=>J.findIndex((q)=>q.tag===L.tag)!==H);if(G.length)throw Error(`Duplicate custom-element tag: ${G[0].tag}`);let W=J.filter((L,H)=>J.findIndex((q)=>q.name===L.name)!==H);if(W.length)throw Error(`Duplicate component class name: ${W[0].name}`);await x3(Q,{recursive:!0});let K=[],_=async(L,H)=>{let q=$0.join(Q,L);return await b3(q,H.endsWith(`
595
595
  `)?H:`${H}
596
- `,"utf8"),K.push(A),A};await _("runtime.js",o3());for(let L of J){if(await _(`${L.tag}.js`,t3(L)),$.declarations!==!1)await _(`${L.tag}.d.ts`,e3(L));if($.css!==!1&&L.styles){let H=L.shadowMode?L.styles:G6(L);await _(`${L.tag}.css`,$.minify?W6(H):H)}}let U=J.map((L)=>`export { ${L.name}, default as ${L.name}Element } from './${L.tag}.js';`).join(`
597
- `);if(await _("index.js",U),await _("ssr.js",Q4(J)),$.declarations!==!1)await _("index.d.ts",J.map((L)=>`export * from './${L.tag}.js'`).join(`
598
- `)),await _("custom-elements.d.ts",$4(J)),await _("ssr.d.ts",`${J.map((L)=>`export declare const render${L.name}: (props?: ${L.name}Props, slots?: Record<string, string>) => string`).join(`
596
+ `,"utf8"),K.push(q),q};await _("runtime.js",t3());for(let L of J){if(await _(`${L.tag}.js`,e3(L)),$.declarations!==!1)await _(`${L.tag}.d.ts`,$4(L));if($.css!==!1&&L.styles){let H=L.shadowMode?L.styles:W6(L);await _(`${L.tag}.css`,$.minify?K6(H):H)}}let U=J.map((L)=>`export { ${L.name}, default as ${L.name}Element } from './${L.tag}.js';`).join(`
597
+ `);if(await _("index.js",U),await _("ssr.js",Z4(J)),$.declarations!==!1)await _("index.d.ts",J.map((L)=>`export * from './${L.tag}.js'`).join(`
598
+ `)),await _("custom-elements.d.ts",X4(J)),await _("ssr.d.ts",`${J.map((L)=>`export declare const render${L.name}: (props?: ${L.name}Props, slots?: Record<string, string>) => string`).join(`
599
599
  `)}
600
600
  export declare function renderComponent(tag: string, props?: Record<string, unknown>, slots?: Record<string, string>): string
601
601
  ${J.map((L)=>`import type { ${L.name}Props } from './${L.tag}.js'`).join(`
602
- `)}`);let z;if($.manifest!==!1)z=await _("custom-elements.json",JSON.stringify(X4(J),null,2));let F;if($.css!==!1){let L=J.filter((H)=>!H.shadowMode&&H.styles).map(G6).join(`
602
+ `)}`);let z;if($.manifest!==!1)z=await _("custom-elements.json",JSON.stringify(Q4(J),null,2));let F;if($.css!==!1){let L=J.filter((H)=>!H.shadowMode&&H.styles).map(W6).join(`
603
603
 
604
- `);if(L)F=await _("bundle.css",$.minify?W6(L):L)}let O;if($.bundle!==!1){O=$0.join(Q,"bundle.js");let L;try{L=await Bun.build({entrypoints:[$0.join(Q,"index.js")],outdir:Q,naming:"bundle.js",target:"browser",format:"esm",minify:$.minify??!0,sourcemap:$.sourcemap||"none"})}catch(H){let A=H instanceof AggregateError?H.errors:[H],q=A.map((M)=>String(M).trim()).filter(Boolean).join(`
605
- `);throw AggregateError(A,`Failed to bundle component library${q?`
606
- ${q}`:""}`)}if(!L.success){let H=L.logs.map((A)=>String(A).trim()).filter(Boolean).join(`
604
+ `);if(L)F=await _("bundle.css",$.minify?K6(L):L)}let j;if($.bundle!==!1){j=$0.join(Q,"bundle.js");let L;try{L=await Bun.build({entrypoints:[$0.join(Q,"index.js")],outdir:Q,naming:"bundle.js",target:"browser",format:"esm",minify:$.minify??!0,sourcemap:$.sourcemap||"none"})}catch(H){let q=H instanceof AggregateError?H.errors:[H],A=q.map((N)=>String(N).trim()).filter(Boolean).join(`
605
+ `);throw AggregateError(q,`Failed to bundle component library${A?`
606
+ ${A}`:""}`)}if(!L.success){let H=L.logs.map((q)=>String(q).trim()).filter(Boolean).join(`
607
607
  `);throw AggregateError(L.logs,`Failed to bundle component library${H?`
608
- ${H}`:""}`)}if(K.push(O),$.sourcemap==="external")K.push(`${O}.map`)}let j=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:$0.join(Q,`${L.tag}.js`)})),files:K,manifest:z,bundle:O,cssBundle:F,totalBytes:j.reduce((L,H)=>L+H,0)}}var{serve:B4}=globalThis.Bun;import l$ from"fs";import t0 from"path";function a1(){return`
608
+ ${H}`:""}`)}if(K.push(j),$.sourcemap==="external")K.push(`${j}.map`)}let O=await Promise.all(K.map(async(L)=>(await Y6(L)).size));return{components:J.map((L)=>({name:L.name,tag:L.tag,source:L.sourcePath,module:$0.join(Q,`${L.tag}.js`)})),files:K,manifest:z,bundle:j,cssBundle:F,totalBytes:O.reduce((L,H)=>L+H,0)}}var{serve:L4}=globalThis.Bun;import a$ from"fs";import e0 from"path";function a1(){return`
609
609
  /* Theme selector for code blocks */
610
610
  .theme-selector {
611
611
  margin: 1rem 0;
@@ -685,19 +685,19 @@ else {
685
685
  <span class="frontmatter-label">${X}:</span>
686
686
  <span>${Array.isArray(Q)?Q.join(", "):String(Q)}</span>
687
687
  </div>`).join("")}
688
- </div>`}import _6 from"net";async function Z4($){return new Promise((X)=>{let Q=_6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"0.0.0.0")})}async function Y4($){return new Promise((X)=>{let Q=_6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"::")})}async function J4($){if(!await Z4($))return!1;return await Y4($)}async function x0($,X=20){$=Number($);for(let Q=0;Q<X;Q++){let Z=$+Q;if(await J4(Z))return Z}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var G4={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function W4(){try{let $=await import("./chunk-x8w319bf.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function o0($,X={}){let Q={...G4,...X},Z=await W4();if(!Z)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 Z.openDevWindow($,{title:Q.title,width:Q.width,height:Q.height,darkMode:Q.darkMode,hotReload:Q.hotReload,titlebarHidden:Q.titlebarHidden,nativeSidebar:Q.nativeSidebar,sidebarWidth:Q.sidebarWidth,sidebarConfig:Q.sidebarConfig});if(Y&&Q.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 o1($){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=`
688
+ </div>`}import U6 from"net";async function Y4($){return new Promise((X)=>{let Q=U6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"0.0.0.0")})}async function J4($){return new Promise((X)=>{let Q=U6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"::")})}async function G4($){if(!await Y4($))return!1;return await J4($)}async function k0($,X=20){$=Number($);for(let Q=0;Q<X;Q++){let Z=$+Q;if(await G4(Z))return Z}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var W4={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function K4(){try{let $=await import("./chunk-ypajs9wd.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function t0($,X={}){let Q={...W4,...X},Z=await K4();if(!Z)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 Z.openDevWindow($,{title:Q.title,width:Q.width,height:Q.height,darkMode:Q.darkMode,hotReload:Q.hotReload,titlebarHidden:Q.titlebarHidden,nativeSidebar:Q.nativeSidebar,sidebarWidth:Q.sidebarWidth,sidebarConfig:Q.sidebarConfig});if(Y&&Q.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 o1($){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=`
689
689
  ${J}
690
690
  return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
691
- `,K=Function(G)();if(K)return K}catch(G){console.warn("Invalid sidebarConfig:",G)}}return{sections:[]}}let Q=$.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(Q)try{return JSON.parse(Q[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let Z=$.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(Z)try{let Y=Z[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 c$(){console.log(`
692
- 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`),c$()}function _4($){console.log(`${B.dim}Opening ${B.cyan}${$}${B.dim} in your browser...${B.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function k0($,X,Q){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),c$();let Z="";process.stdin.on("data",(Y)=>{if(Y==="\x03"){if(Q?.onQuit)Q.onQuit();X(),process.exit(0)}if(Z+=Y,Z.endsWith("\r")||Z.endsWith(`
693
- `)){let J=Z.trim().toLowerCase();Z="",U4(J,$,X,Q)}})}function U4($,X,Q,Z){switch($){case"o":if(Z?.onOpen)Z.onOpen();else _4(X);break;case"c":if(Z?.onClear)Z.onClear();else console.clear(),K4(X);break;case"q":if(Z?.onQuit)Z.onQuit();console.log(`${B.yellow}Stopping server...${B.reset}`),Q(),process.exit(0);break;case"h":if(Z?.onHelp)Z.onHelp();else c$();break;default:break}}async function i$($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=t0.resolve($);if(!l$.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:z,data:F}=await V0(Y,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:M0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),O=X.markdown?.syntaxHighlighting||M0.markdown?.syntaxHighlighting,j=O?.defaultTheme||"github-dark",L=["github-dark"],H=O?.additionalThemes||[],q=[...new Set([...L,...H])].map((M)=>`<option value="${M}"${M===j?" selected":""}>${M}</option>`).join(`
691
+ `,K=Function(G)();if(K)return K}catch(G){console.warn("Invalid sidebarConfig:",G)}}return{sections:[]}}let Q=$.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(Q)try{return JSON.parse(Q[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let Z=$.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(Z)try{let Y=Z[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 i$(){console.log(`
692
+ 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 _4($){console.log(`${B.green}Server running at ${B.cyan}${$}${B.reset}`),console.log(`Press ${B.cyan}Ctrl+C${B.reset} to stop the server`),i$()}function U4($){console.log(`${B.dim}Opening ${B.cyan}${$}${B.dim} in your browser...${B.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function x0($,X,Q){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),i$();let Z="";process.stdin.on("data",(Y)=>{if(Y==="\x03"){if(Q?.onQuit)Q.onQuit();X(),process.exit(0)}if(Z+=Y,Z.endsWith("\r")||Z.endsWith(`
693
+ `)){let J=Z.trim().toLowerCase();Z="",B4(J,$,X,Q)}})}function B4($,X,Q,Z){switch($){case"o":if(Z?.onOpen)Z.onOpen();else U4(X);break;case"c":if(Z?.onClear)Z.onClear();else console.clear(),_4(X);break;case"q":if(Z?.onQuit)Z.onQuit();console.log(`${B.yellow}Stopping server...${B.reset}`),Q(),process.exit(0);break;case"h":if(Z?.onHelp)Z.onHelp();else i$();break;default:break}}async function r$($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=e0.resolve($);if(!a$.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:z,data:F}=await V0(Y,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:M0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),j=X.markdown?.syntaxHighlighting||M0.markdown?.syntaxHighlighting,O=j?.defaultTheme||"github-dark",L=["github-dark"],H=j?.additionalThemes||[],A=[...new Set([...L,...H])].map((N)=>`<option value="${N}"${N===O?" selected":""}>${N}</option>`).join(`
694
694
  `);return J=`
695
695
  <!DOCTYPE html>
696
696
  <html lang="en">
697
697
  <head>
698
698
  <meta charset="UTF-8">
699
699
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
700
- <title>${L4(F.title||t0.basename(Y))}</title>
700
+ <title>${F4(F.title||e0.basename(Y))}</title>
701
701
  <!-- Syntax highlighting styles -->
702
702
  <style id="syntax-theme">
703
703
  :root {
@@ -844,7 +844,7 @@ Keyboard shortcuts:`),console.log(` ${B.cyan}o${B.reset} + Enter - Open in brow
844
844
  </head>
845
845
  <body>
846
846
  ${n1(F)}
847
- ${r1(q)}
847
+ ${r1(A)}
848
848
 
849
849
  ${z}
850
850
 
@@ -853,12 +853,12 @@ Keyboard shortcuts:`),console.log(` ${B.cyan}o${B.reset} + Enter - Open in brow
853
853
  </script>
854
854
  </body>
855
855
  </html>
856
- `,!0}catch(z){return console.error(`${B.red}Error processing Markdown file:${B.reset}`,z),!1}};if(!await G())return!1;let K=Q;try{if(K=await x0(Q),K!==Q)console.log(`${B.yellow}Port ${Q} 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 _=B4({port:K,fetch(z){if(new URL(z.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(z){return new Response(`<pre>${z}
856
+ `,!0}catch(z){return console.error(`${B.red}Error processing Markdown file:${B.reset}`,z),!1}};if(!await G())return!1;let K=Q;try{if(K=await k0(Q),K!==Q)console.log(`${B.yellow}Port ${Q} 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 _=L4({port:K,fetch(z){if(new URL(z.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(z){return new Response(`<pre>${z}
857
857
  ${z.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
858
858
  ${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(`
859
859
  ${B.bright}\u2192 ${B.cyan}http://localhost:${K}/${B.reset}`),console.log(`
860
- ${B.yellow}Routes:${B.reset}`);let U=t0.relative(process.cwd(),Y);if(console.log(` ${B.green}\u2514\u2500 /${B.reset} \u2192 ${B.bright}${U}${B.reset}`),console.log(`
861
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(_.url.toString(),()=>{if(Z)l$.watch(t0.dirname(Y),{recursive:!0}).close();_.stop()}),X.native)await o0(K,{title:t0.basename(Y,".md")});if(Z){let z=t0.dirname(Y);console.log(`${B.blue}Watching ${B.bright}${z}${B.reset} for changes...`);let F=l$.watch(z,{recursive:!0},async(O,j)=>{if(j&&j.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${j}${B.yellow} changed, reprocessing...${B.reset}`),await G()});process.on("SIGINT",()=>{F.close(),_.stop(),process.exit(0)})}return!0}function L4($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:z4}=globalThis.Bun;import H0 from"fs";import Z0 from"path";class U6{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,Q=20;for(let Z=0;Z<Q;Z++)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 ${Q} 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($),Q=0;for(let Z of this.clients)try{if(Z.readyState===1)Z.send(X),Q++}catch{this.clients.delete(Z)}if(this.options.verbose&&Q>0)console.log(`[HMR] Broadcast ${$.type} to ${Q} 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 F4($,X={}){let{showOverlay:Q=!0,reconnectInterval:Z=1000,maxReconnectAttempts:Y=10}=X;return`
860
+ ${B.yellow}Routes:${B.reset}`);let U=e0.relative(process.cwd(),Y);if(console.log(` ${B.green}\u2514\u2500 /${B.reset} \u2192 ${B.bright}${U}${B.reset}`),console.log(`
861
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),x0(_.url.toString(),()=>{if(Z)a$.watch(e0.dirname(Y),{recursive:!0}).close();_.stop()}),X.native)await t0(K,{title:e0.basename(Y,".md")});if(Z){let z=e0.dirname(Y);console.log(`${B.blue}Watching ${B.bright}${z}${B.reset} for changes...`);let F=a$.watch(z,{recursive:!0},async(j,O)=>{if(O&&O.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${O}${B.yellow} changed, reprocessing...${B.reset}`),await G()});process.on("SIGINT",()=>{F.close(),_.stop(),process.exit(0)})}return!0}function F4($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:j4}=globalThis.Bun;import H0 from"fs";import Z0 from"path";class B6{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,Q=20;for(let Z=0;Z<Q;Z++)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 ${Q} 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($),Q=0;for(let Z of this.clients)try{if(Z.readyState===1)Z.send(X),Q++}catch{this.clients.delete(Z)}if(this.options.verbose&&Q>0)console.log(`[HMR] Broadcast ${$.type} to ${Q} 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 z4($,X={}){let{showOverlay:Q=!0,reconnectInterval:Z=1000,maxReconnectAttempts:Y=10}=X;return`
862
862
  <script>
863
863
  (function() {
864
864
  // stx Hot Reload Client
@@ -1057,10 +1057,10 @@ else {
1057
1057
  };
1058
1058
  })();
1059
1059
  </script>
1060
- `}function D0($,X,Q={}){let Z=F4(X,Q),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Z+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Z}</html>`);return $+Z}function t1($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function e1($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Z)=>X.endsWith(Z))}function $$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Q)=>Q.test($))}var e0=null;function X$($){if(!e0)e0=new U6($);return e0}function A1(){if(e0)e0.stop(),e0=null}import q1 from"path";var $1={name:"bun-plugin-stx",async setup($){let Q={...await H1(),...$.config?.stx},Z=new Set,Y=Q.webComponents?.enabled?`./${q1.relative(q1.dirname($.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Q.webComponents?.enabled)try{let G=await G$(Q,Z);if(J.push(...G),Q.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(Q.cache&&Q.cachePath){let L=await Y$(G,Q);if(L){if(Q.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await n$(()=>Bun.file(G).text(),"",(L)=>{throw new s$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new s$(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:z}=a$.time("script-extraction",()=>{let L=K,H=Z$(K);if(H)L=H.content.trim();let A=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],q="",M=[];for(let N of A){let R=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",w=N.match(/<script\b([^>]*)>/i),C=w?w[1]:"";if(/\bserver\b/i.test(C))q=R;else M.push(N)}let V=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:q,templateContent:V,allScripts:M}}),F={__filename:G,__dirname:q1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await n$(()=>j0(_,F,G),void 0,(L)=>{let H=new r$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(Q$.log(H,{filePath:G,scriptContent:_}),Q.debug)throw H});let j=await a$.timeAsync("directive-processing",async()=>{return await O0(U,F,G,Q,W)});if(z.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-y8g3d192.js"),H=L(z.join(`
1061
- `),F),A=j.search(/<\/body>/i);if(A!==-1)j=j.slice(0,A)+H+`
1062
- `+j.slice(A);else j+=`
1063
- ${H}`}if(j=await F6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await J$(G,j,W,Q),Q.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:j,loader:"html"}}catch(W){let K=W instanceof Error?W:new r$(`Plugin processing failed: ${String(W)}`,G);if(Q$.log(K,{filePath:G,buildConfig:$.config}),L6.logDetailedError(K,{filePath:G,plugin:"bun-plugin-stx"}),Q.debug)console.error("stx Plugin Error:",K);let _=K,U=_.line||null,z=_.context||null;return{contents:Q.debug||B6()?`<!DOCTYPE html>
1060
+ `}function D0($,X,Q={}){let Z=z4(X,Q),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Z+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Z}</html>`);return $+Z}function t1($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function e1($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Z)=>X.endsWith(Z))}function $$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Q)=>Q.test($))}var $1=null;function X$($){if(!$1)$1=new B6($);return $1}function A1(){if($1)$1.stop(),$1=null}import q1 from"path";var X1={name:"bun-plugin-stx",async setup($){let Q={...await d0(),...$.config?.stx},Z=new Set,Y=Q.webComponents?.enabled?`./${q1.relative(q1.dirname($.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Q.webComponents?.enabled)try{let G=await G$(Q,Z);if(J.push(...G),Q.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(Q.cache&&Q.cachePath){let L=await Y$(G,Q);if(L){if(Q.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await t$(()=>Bun.file(G).text(),"",(L)=>{throw new o$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new o$(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:z}=s$.time("script-extraction",()=>{let L=K,H=Z$(K);if(H)L=H.content.trim();let q=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],A="",N=[];for(let M of q){let R=M.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",w=M.match(/<script\b([^>]*)>/i),C=w?w[1]:"";if(/\bserver\b/i.test(C))A=R;else N.push(M)}let V=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:A,templateContent:V,allScripts:N}}),F={__filename:G,__dirname:q1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await t$(()=>j0(_,F,G),void 0,(L)=>{let H=new n$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(Q$.log(H,{filePath:G,scriptContent:_}),Q.debug)throw H});let O=await s$.timeAsync("directive-processing",async()=>{return await O0(U,F,G,Q,W)});if(z.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-cv0z0qpy.js"),H=L(z.join(`
1061
+ `),F),q=O.search(/<\/body>/i);if(q!==-1)O=O.slice(0,q)+H+`
1062
+ `+O.slice(q);else O+=`
1063
+ ${H}`}if(O=await z6(O),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await J$(G,O,W,Q),Q.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:O,loader:"html"}}catch(W){let K=W instanceof Error?W:new n$(`Plugin processing failed: ${String(W)}`,G);if(Q$.log(K,{filePath:G,buildConfig:$.config}),F6.logDetailedError(K,{filePath:G,plugin:"bun-plugin-stx"}),Q.debug)console.error("stx Plugin Error:",K);let _=K,U=_.line||null,z=_.context||null;return{contents:Q.debug||L6()?`<!DOCTYPE html>
1064
1064
  <html lang="en">
1065
1065
  <head>
1066
1066
  <meta charset="UTF-8">
@@ -1083,16 +1083,16 @@ ${H}`}if(j=await F6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await J
1083
1083
 
1084
1084
  <div class="error-details">
1085
1085
  <h3>Error Details</h3>
1086
- <p><strong>File:</strong> <span class="file-path">${d0(G)}</span></p>
1087
- <p><strong>Error:</strong> ${d0(K.message)}</p>
1088
- ${U?`<p><strong>Line:</strong> ${d0(String(U))}</p>`:""}
1089
- ${z?`<p><strong>Context:</strong> ${d0(String(z))}</p>`:""}
1086
+ <p><strong>File:</strong> <span class="file-path">${u0(G)}</span></p>
1087
+ <p><strong>Error:</strong> ${u0(K.message)}</p>
1088
+ ${U?`<p><strong>Line:</strong> ${u0(String(U))}</p>`:""}
1089
+ ${z?`<p><strong>Context:</strong> ${u0(String(z))}</p>`:""}
1090
1090
  </div>
1091
1091
 
1092
1092
  ${K.stack?`
1093
1093
  <div class="error-details">
1094
1094
  <h3>Stack Trace</h3>
1095
- <pre class="error-code">${d0(K.stack)}</pre>
1095
+ <pre class="error-code">${u0(K.stack)}</pre>
1096
1096
  </div>`:""}
1097
1097
 
1098
1098
  <div class="help-section">
@@ -1101,7 +1101,7 @@ ${H}`}if(j=await F6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await J
1101
1101
  <li>Check the syntax of your stx directives (e.g., @if, @foreach)</li>
1102
1102
  <li>Verify that all variables used in the template are properly defined</li>
1103
1103
  <li>Ensure script tags have valid JavaScript/TypeScript syntax</li>
1104
- <li>Run <code>stx debug ${d0(q1.basename(G))}</code> for detailed analysis</li>
1104
+ <li>Run <code>stx debug ${u0(q1.basename(G))}</code> for detailed analysis</li>
1105
1105
  <li>Enable debug mode in your stx config for more detailed error messages</li>
1106
1106
  </ul>
1107
1107
  </div>
@@ -1120,12 +1120,12 @@ ${H}`}if(j=await F6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await J
1120
1120
  <h1>Something went wrong</h1>
1121
1121
  <p>An internal error occurred. Please try again later.</p>
1122
1122
  </body>
1123
- </html>`,loader:"html"}}})}};async function j4($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=Z0.resolve($);if(!H0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return i$(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=S0(process.cwd(),"output");H0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let q={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(w)=>{return{path:w.path,external:!0}})}},M=await Bun.build({entrypoints:[W],outdir:K,plugins:[q,$1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!M.success)return console.error(`${B.red}Build failed:${B.reset}`,M.logs),!1;let V=M.outputs.find((R)=>R.path.endsWith(".html"));if(!V)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(V.path).text(),!0}catch(q){return console.error(`${B.red}Error building stx file:${B.reset}`,q),!1}};if(!await U())return!1;let F=Z0.dirname(W);await W$(F);let O=Q;try{if(O=await x0(Q),O!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${O} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let q=X.hmrPort||O+1;J=X$({wsPort:q,verbose:!1}),G=J.start(q)}let j={},L=null;try{let{loadStxConfig:q}=await import("./chunk-8m0p3v0e.js"),M=await q();if(M?.apiRouter)L=M?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(M?.apiRoutes){j=M.apiRoutes;let V=Object.keys(j).length;if(V>0)console.log(`${B.blue}Loaded ${B.bright}${V} API route${V>1?"s":""}${B.reset}`)}if(M?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:N}=await import("./chunk-5mrs8cs2.js"),R=M.broadcasting;await V(R);let w=R.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${w}/ws${B.reset}`);let C=Z0.join(process.cwd(),"channels.ts");if(H0.existsSync(C))try{let I=await N(C);console.log(`${B.blue}Loaded ${B.bright}${I} broadcast channel${I!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(I){console.warn(`${B.yellow}Failed to load channels.ts: ${I.message}${B.reset}`)}}catch(V){console.warn(`${B.yellow}Broadcasting failed to start: ${V.message}${B.reset}`)}}catch{}if(console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${O}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let H=z4({port:O,async fetch(q){return _$(q,await(async()=>{let M=new URL(q.url);if(L)try{let C=await L.handleRequest(q);if(C.status!==404)return C}catch{}if(j[M.pathname])try{return await j[M.pathname](q)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(M.pathname==="/")return(async()=>{let I=await o(_||"");if(Y)I=D0(I,G);if(X.native)if(I.includes("<head>"))I=I.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(I.includes("<html"))I=I.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 I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;if(X.titlebarHidden)if(I.includes("<head>"))I=I.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(I.includes("<html"))I=I.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 I=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${I}`;return I})().then((I)=>new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let V=Z0.join(K,M.pathname);if(H0.existsSync(V)&&H0.statSync(V).isFile()){let C=Bun.file(V),I=Z0.extname(V).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let m=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),f=await C.text(),K0=m.transformSync(f);return new Response(K0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":E}})}let N=Z0.dirname(W),R=Z0.join(N,M.pathname);if(H0.existsSync(R)&&H0.statSync(R).isFile()){let C=Bun.file(R),I=Z0.extname(R).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let m=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),f=await C.text(),K0=m.transformSync(f);return new Response(K0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":E}})}let w=Z0.join(process.cwd(),"public",M.pathname);if(H0.existsSync(w)&&H0.statSync(w).isFile()){let C=Bun.file(w),I=Z0.extname(w).toLowerCase(),E="application/octet-stream";if(I===".ts"||I===".tsx"){let m=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),f=await C.text(),K0=m.transformSync(f);return new Response(K0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(q){return new Response(`<pre>${q}
1124
- ${q.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1123
+ </html>`,loader:"html"}}})}};async function O4($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=Z0.resolve($);if(!H0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return r$(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=S0(process.cwd(),"output");H0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let A={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(w)=>{return{path:w.path,external:!0}})}},N=await Bun.build({entrypoints:[W],outdir:K,plugins:[A,X1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!N.success)return console.error(`${B.red}Build failed:${B.reset}`,N.logs),!1;let V=N.outputs.find((R)=>R.path.endsWith(".html"));if(!V)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(V.path).text(),!0}catch(A){return console.error(`${B.red}Error building stx file:${B.reset}`,A),!1}};if(!await U())return!1;let F=Z0.dirname(W);await W$(F);let j=Q;try{if(j=await k0(Q),j!==Q)console.log(`${B.yellow}Port ${Q} 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 A=X.hmrPort||j+1;J=X$({wsPort:A,verbose:!1}),G=J.start(A)}let O={},L=null;try{let{loadStxConfig:A}=await import("./chunk-dxepdtt2.js"),N=await A();if(N?.apiRouter)L=N?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(N?.apiRoutes){O=N.apiRoutes;let V=Object.keys(O).length;if(V>0)console.log(`${B.blue}Loaded ${B.bright}${V} API route${V>1?"s":""}${B.reset}`)}if(N?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:M}=await import("./chunk-8m7fhky6.js"),R=N.broadcasting;await V(R);let w=R.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${w}/ws${B.reset}`);let C=Z0.join(process.cwd(),"channels.ts");if(H0.existsSync(C))try{let I=await M(C);console.log(`${B.blue}Loaded ${B.bright}${I} broadcast channel${I!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(I){console.warn(`${B.yellow}Failed to load channels.ts: ${I.message}${B.reset}`)}}catch(V){console.warn(`${B.yellow}Broadcasting failed to start: ${V.message}${B.reset}`)}}catch{}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 H=j4({port:j,async fetch(A){return _$(A,await(async()=>{let N=new URL(A.url);if(L)try{let C=await L.handleRequest(A);if(C.status!==404)return C}catch{}if(O[N.pathname])try{return await O[N.pathname](A)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(N.pathname==="/")return(async()=>{let I=await o(_||"");if(Y)I=D0(I,G);if(X.native)if(I.includes("<head>"))I=I.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(I.includes("<html"))I=I.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 I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;if(X.titlebarHidden)if(I.includes("<head>"))I=I.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(I.includes("<html"))I=I.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 I=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${I}`;return I})().then((I)=>new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let V=Z0.join(K,N.pathname);if(H0.existsSync(V)&&H0.statSync(V).isFile()){let C=Bun.file(V),I=Z0.extname(V).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let m=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),f=await C.text(),K0=m.transformSync(f);return new Response(K0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":E}})}let M=Z0.dirname(W),R=Z0.join(M,N.pathname);if(H0.existsSync(R)&&H0.statSync(R).isFile()){let C=Bun.file(R),I=Z0.extname(R).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let m=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),f=await C.text(),K0=m.transformSync(f);return new Response(K0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":E}})}let w=Z0.join(process.cwd(),"public",N.pathname);if(H0.existsSync(w)&&H0.statSync(w).isFile()){let C=Bun.file(w),I=Z0.extname(w).toLowerCase(),E="application/octet-stream";if(I===".ts"||I===".tsx"){let m=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),f=await C.text(),K0=m.transformSync(f);return new Response(K0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(A){return new Response(`<pre>${A}
1124
+ ${A.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1125
1125
  ${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(`
1126
- ${B.bright}\u2192 ${B.cyan}http://localhost:${O}/${B.reset}`),console.log(`
1127
- ${B.yellow}Routes:${B.reset}`);let A=Z0.relative(process.cwd(),W);if(console.log(` ${B.green}\u2514\u2500 /${B.reset} \u2192 ${B.bright}${A}${B.reset}`),console.log(`
1128
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(H.url.toString(),()=>{if(Z)H0.watch(Z0.dirname(W),{recursive:!0}).close();H.stop()}),X.native){let q=await Bun.file(W).text(),M=o1(q);await o0(O,{title:Z0.basename(W,".stx"),titlebarHidden:X.titlebarHidden===!0,nativeSidebar:!!M,sidebarConfig:M})}if(Z){let q=Z0.dirname(W);console.log(`${B.blue}Watching ${B.bright}${q}${B.reset} for changes...`);let M=H0.watch(q,{recursive:!0},async(V,N)=>{if(!N||$$(N))return;if(e1(N)){console.log(`${B.yellow}File ${B.bright}${N}${B.yellow} changed, rebuilding...${B.reset}`),u0.clear(),m0();let R=await U();if(await K$(F),Y&&J)if(R)J.reload(N);else J.error("Build failed - check console for details")}else if(t1(N)){if(console.log(`${B.cyan}CSS ${B.bright}${N}${B.cyan} changed${B.reset}`),Y&&J)J.updateCss(N)}});process.on("SIGINT",()=>{if(M.close(),J)A1();H.stop(),process.exit(0)})}return!0}var{serve:O4}=globalThis.Bun;import P0 from"fs";import X0 from"path";var z6=`
1126
+ ${B.bright}\u2192 ${B.cyan}http://localhost:${j}/${B.reset}`),console.log(`
1127
+ ${B.yellow}Routes:${B.reset}`);let q=Z0.relative(process.cwd(),W);if(console.log(` ${B.green}\u2514\u2500 /${B.reset} \u2192 ${B.bright}${q}${B.reset}`),console.log(`
1128
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),x0(H.url.toString(),()=>{if(Z)H0.watch(Z0.dirname(W),{recursive:!0}).close();H.stop()}),X.native){let A=await Bun.file(W).text(),N=o1(A);await t0(j,{title:Z0.basename(W,".stx"),titlebarHidden:X.titlebarHidden===!0,nativeSidebar:!!N,sidebarConfig:N})}if(Z){let A=Z0.dirname(W);console.log(`${B.blue}Watching ${B.bright}${A}${B.reset} for changes...`);let N=H0.watch(A,{recursive:!0},async(V,M)=>{if(!M||$$(M))return;if(e1(M)){console.log(`${B.yellow}File ${B.bright}${M}${B.yellow} changed, rebuilding...${B.reset}`),m0.clear(),p0();let R=await U();if(await K$(F),Y&&J)if(R)J.reload(M);else J.error("Build failed - check console for details")}else if(t1(M)){if(console.log(`${B.cyan}CSS ${B.bright}${M}${B.cyan} changed${B.reset}`),Y&&J)J.updateCss(M)}});process.on("SIGINT",()=>{if(N.close(),J)A1();H.stop(),process.exit(0)})}return!0}var{serve:H4}=globalThis.Bun;import P0 from"fs";import X0 from"path";var j6=`
1129
1129
  <script data-stx-helpers>
1130
1130
  (function() {
1131
1131
  'use strict'
@@ -1436,14 +1436,14 @@ else {
1436
1436
 
1437
1437
  })()
1438
1438
  </script>
1439
- `;H6();function q6($){if($.length===0)return"";if($.length===1)return $[0];let X=$.map((Z)=>Z.split(X0.sep)),Q=[];for(let Z=0;Z<X[0].length;Z++){let Y=X[0][Z];if(X.every((J)=>J[Z]===Y))Q.push(Y);else break}return Q.join(X0.sep)}async function H4($,X={}){let Q=X.port||3000,Z=X.watch!==!1;for(let j of $){let L=X0.resolve(j);if(!P0.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=S0(process.cwd(),"output");P0.mkdirSync(Y,{recursive:!0});let J=q6($.map((j)=>X0.dirname(X0.resolve(j))));console.log(`${B.blue}Processing ${B.bright}${$.length}${B.reset} files...`);let G={},W=[],K=async()=>{try{for(let j of $){let L=X0.resolve(j);if(L.endsWith(".md"))try{let{content:A,data:q}=await V0(L,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:M0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),M=X.markdown?.syntaxHighlighting||M0.markdown?.syntaxHighlighting,V=M?.defaultTheme||"github-dark",N=["github-dark"],R=M?.additionalThemes||[],C=[...new Set([...N,...R])].map((f)=>`<option value="${f}"${f===V?" selected":""}>${f}</option>`).join(`
1439
+ `;A6();function N6($){if($.length===0)return"";if($.length===1)return $[0];let X=$.map((Z)=>Z.split(X0.sep)),Q=[];for(let Z=0;Z<X[0].length;Z++){let Y=X[0][Z];if(X.every((J)=>J[Z]===Y))Q.push(Y);else break}return Q.join(X0.sep)}async function A4($,X={}){let Q=X.port||3000,Z=X.watch!==!1;for(let O of $){let L=X0.resolve(O);if(!P0.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=S0(process.cwd(),"output");P0.mkdirSync(Y,{recursive:!0});let J=N6($.map((O)=>X0.dirname(X0.resolve(O))));console.log(`${B.blue}Processing ${B.bright}${$.length}${B.reset} files...`);let G={},W=[],K=async()=>{try{for(let O of $){let L=X0.resolve(O);if(L.endsWith(".md"))try{let{content:q,data:A}=await V0(L,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:M0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),N=X.markdown?.syntaxHighlighting||M0.markdown?.syntaxHighlighting,V=N?.defaultTheme||"github-dark",M=["github-dark"],R=N?.additionalThemes||[],C=[...new Set([...M,...R])].map((f)=>`<option value="${f}"${f===V?" selected":""}>${f}</option>`).join(`
1440
1440
  `),I=`
1441
1441
  <!DOCTYPE html>
1442
1442
  <html lang="en">
1443
1443
  <head>
1444
1444
  <meta charset="UTF-8">
1445
1445
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
1446
- <title>${j6(q.title||X0.basename(L))}</title>
1446
+ <title>${O6(A.title||X0.basename(L))}</title>
1447
1447
  <!-- Syntax highlighting styles -->
1448
1448
  <style id="syntax-theme">
1449
1449
  :root {
@@ -1589,30 +1589,30 @@ else {
1589
1589
  </style>
1590
1590
  </head>
1591
1591
  <body>
1592
- ${n1(q)}
1592
+ ${n1(A)}
1593
1593
  ${r1(C)}
1594
1594
 
1595
- ${A}
1595
+ ${q}
1596
1596
 
1597
1597
  <script>
1598
1598
  ${s1()}
1599
1599
  </script>
1600
1600
  </body>
1601
1601
  </html>
1602
- `,m=`/${X0.relative(J,L).replace(/\.md$/,"")}`;if(m.endsWith("/index"))m=m.slice(0,-6)||"/";G[m||"/"]={filePath:L,content:I,fileType:"md"}}catch(A){console.error(`${B.red}Error processing Markdown file ${B.bright}${j}${B.reset}:`,A);continue}else{let A={name:"public-assets",setup(N){N.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},q;try{let N=await Bun.build({entrypoints:[L],outdir:Y,plugins:[A,$1],define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!N.success){console.error(`${B.red}Build failed for ${B.bright}${j}${B.reset}:`,X1(N.logs,L));continue}let R=N.outputs.find((w)=>w.path.endsWith(".html"));if(!R){console.error(`${B.red}No HTML output found for ${B.bright}${j}${B.reset}`);continue}q=await Bun.file(R.path).text()}catch(N){console.error(`${B.red}Build failed for ${B.bright}${j}${B.reset}:
1603
- ${X1(N,L)}`);continue}let V=`/${X0.relative(J,L).replace(/\.stx$/,"")}`;if(V.endsWith("/index"))V=V.slice(0,-6)||"/";if(V.includes("[")){let{regex:N,params:R}=O6(V);W.push({pattern:N,paramNames:R,filePath:L,routeTemplate:V,fileType:"stx"}),G[V]={filePath:L,content:q,fileType:"stx"}}else G[V||"/"]={filePath:L,content:q,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${B.red}No files were successfully processed${B.reset}`),!1;return!0}catch(j){return console.error(`${B.red}Error processing files:${B.reset}`,X1(j)),!1}};if(!await K())return!1;let U=Q;try{if(U=await x0(Q),U!==Q)console.log(`${B.yellow}Port ${Q} 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 z=O4({port:U,async fetch(j){let L=new URL(j.url),H=X0.join(process.cwd(),"public",L.pathname);if(P0.existsSync(H)&&P0.statSync(H).isFile()){let M=Bun.file(H),V=X0.extname(H).toLowerCase(),N="application/octet-stream";if(V===".ts"||V===".tsx"){let R=new Bun.Transpiler({loader:V===".tsx"?"tsx":"ts"}),w=await M.text(),C=R.transformSync(w);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(V){case".html":N="text/html";break;case".css":N="text/css";break;case".js":N="text/javascript";break;case".json":N="application/json";break;case".png":N="image/png";break;case".jpg":case".jpeg":N="image/jpeg";break;case".gif":N="image/gif";break;case".svg":N="image/svg+xml";break;case".ico":N="image/x-icon";break;case".woff":N="font/woff";break;case".woff2":N="font/woff2";break;case".ttf":N="font/ttf";break;case".otf":N="font/otf";break;case".eot":N="application/vnd.ms-fontobject";break}return new Response(M,{headers:{"Content-Type":N}})}let A=G[L.pathname];if(!A&&!L.pathname.endsWith("/"))A=G[`${L.pathname}/`];if(!A)for(let M of W){let V=L.pathname.match(M.pattern);if(V){let N=G[M.routeTemplate];if(N){let R={};for(let I=0;I<M.paramNames.length;I++)R[M.paramNames[I]]=decodeURIComponent(V[I+1]);let w=N.content,C=`<script>window.__routeParams = ${JSON.stringify(R)};</script>`;if(w.includes("</head>"))w=w.replace("</head>",`${C}
1604
- </head>`);else w=C+w;A={...N,content:w}}break}}if(A)return o(A.content).then((M)=>{if(M.includes("</head>"))M=M.replace("</head>",`${z6}
1605
- </head>`);return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let q=X0.join(Y,L.pathname);if(P0.existsSync(q)&&P0.statSync(q).isFile()){let M=Bun.file(q),V=X0.extname(q).toLowerCase(),N="text/plain";if(V===".ts"||V===".tsx"){let R=new Bun.Transpiler({loader:V===".tsx"?"tsx":"ts"}),w=await M.text(),C=R.transformSync(w);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(V){case".html":N="text/html";break;case".css":N="text/css";break;case".js":N="text/javascript";break;case".json":N="application/json";break;case".png":N="image/png";break;case".jpg":case".jpeg":N="image/jpeg";break;case".gif":N="image/gif";break;case".svg":N="image/svg+xml";break;case".ico":N="image/x-icon";break;case".woff":N="font/woff";break;case".woff2":N="font/woff2";break;case".ttf":N="font/ttf";break;case".otf":N="font/otf";break;case".eot":N="application/vnd.ms-fontobject";break}return new Response(M,{headers:{"Content-Type":N}})}if(L.pathname!=="/"&&G["/"]){let M=A6(j);return o(G["/"].content).then((V)=>{if(M){let N=V.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(N){let R=V.match(/<title[^>]*>([\s\S]*?)<\/title>/i),w=R?R[1]:"",C=`<!DOCTYPE html><html><head><title>${j6(w)}</title></head><body><main>${N[1]}</main></body></html>`;return new Response(C,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...Q1(),"Cache-Control":U$,Pragma:"no-cache",Expires:"0"}})}}return new Response(V,{headers:{"Content-Type":"text/html",...Q1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(j){return new Response(`<pre>${j}
1606
- ${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1602
+ `,m=`/${X0.relative(J,L).replace(/\.md$/,"")}`;if(m.endsWith("/index"))m=m.slice(0,-6)||"/";G[m||"/"]={filePath:L,content:I,fileType:"md"}}catch(q){console.error(`${B.red}Error processing Markdown file ${B.bright}${O}${B.reset}:`,q);continue}else{let q={name:"public-assets",setup(M){M.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},A;try{let M=await Bun.build({entrypoints:[L],outdir:Y,plugins:[q,X1],define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!M.success){console.error(`${B.red}Build failed for ${B.bright}${O}${B.reset}:`,Q1(M.logs,L));continue}let R=M.outputs.find((w)=>w.path.endsWith(".html"));if(!R){console.error(`${B.red}No HTML output found for ${B.bright}${O}${B.reset}`);continue}A=await Bun.file(R.path).text()}catch(M){console.error(`${B.red}Build failed for ${B.bright}${O}${B.reset}:
1603
+ ${Q1(M,L)}`);continue}let V=`/${X0.relative(J,L).replace(/\.stx$/,"")}`;if(V.endsWith("/index"))V=V.slice(0,-6)||"/";if(V.includes("[")){let{regex:M,params:R}=H6(V);W.push({pattern:M,paramNames:R,filePath:L,routeTemplate:V,fileType:"stx"}),G[V]={filePath:L,content:A,fileType:"stx"}}else G[V||"/"]={filePath:L,content:A,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${B.red}No files were successfully processed${B.reset}`),!1;return!0}catch(O){return console.error(`${B.red}Error processing files:${B.reset}`,Q1(O)),!1}};if(!await K())return!1;let U=Q;try{if(U=await k0(Q),U!==Q)console.log(`${B.yellow}Port ${Q} 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 z=H4({port:U,async fetch(O){let L=new URL(O.url),H=X0.join(process.cwd(),"public",L.pathname);if(P0.existsSync(H)&&P0.statSync(H).isFile()){let N=Bun.file(H),V=X0.extname(H).toLowerCase(),M="application/octet-stream";if(V===".ts"||V===".tsx"){let R=new Bun.Transpiler({loader:V===".tsx"?"tsx":"ts"}),w=await N.text(),C=R.transformSync(w);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(V){case".html":M="text/html";break;case".css":M="text/css";break;case".js":M="text/javascript";break;case".json":M="application/json";break;case".png":M="image/png";break;case".jpg":case".jpeg":M="image/jpeg";break;case".gif":M="image/gif";break;case".svg":M="image/svg+xml";break;case".ico":M="image/x-icon";break;case".woff":M="font/woff";break;case".woff2":M="font/woff2";break;case".ttf":M="font/ttf";break;case".otf":M="font/otf";break;case".eot":M="application/vnd.ms-fontobject";break}return new Response(N,{headers:{"Content-Type":M}})}let q=G[L.pathname];if(!q&&!L.pathname.endsWith("/"))q=G[`${L.pathname}/`];if(!q)for(let N of W){let V=L.pathname.match(N.pattern);if(V){let M=G[N.routeTemplate];if(M){let R={};for(let I=0;I<N.paramNames.length;I++)R[N.paramNames[I]]=decodeURIComponent(V[I+1]);let w=M.content,C=`<script>window.__routeParams = ${JSON.stringify(R)};</script>`;if(w.includes("</head>"))w=w.replace("</head>",`${C}
1604
+ </head>`);else w=C+w;q={...M,content:w}}break}}if(q)return o(q.content).then((N)=>{if(N.includes("</head>"))N=N.replace("</head>",`${j6}
1605
+ </head>`);return new Response(N,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let A=X0.join(Y,L.pathname);if(P0.existsSync(A)&&P0.statSync(A).isFile()){let N=Bun.file(A),V=X0.extname(A).toLowerCase(),M="text/plain";if(V===".ts"||V===".tsx"){let R=new Bun.Transpiler({loader:V===".tsx"?"tsx":"ts"}),w=await N.text(),C=R.transformSync(w);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(V){case".html":M="text/html";break;case".css":M="text/css";break;case".js":M="text/javascript";break;case".json":M="application/json";break;case".png":M="image/png";break;case".jpg":case".jpeg":M="image/jpeg";break;case".gif":M="image/gif";break;case".svg":M="image/svg+xml";break;case".ico":M="image/x-icon";break;case".woff":M="font/woff";break;case".woff2":M="font/woff2";break;case".ttf":M="font/ttf";break;case".otf":M="font/otf";break;case".eot":M="application/vnd.ms-fontobject";break}return new Response(N,{headers:{"Content-Type":M}})}if(L.pathname!=="/"&&G["/"]){let N=q6(O);return o(G["/"].content).then((V)=>{if(N){let M=V.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(M){let R=V.match(/<title[^>]*>([\s\S]*?)<\/title>/i),w=R?R[1]:"",C=`<!DOCTYPE html><html><head><title>${O6(w)}</title></head><body><main>${M[1]}</main></body></html>`;return new Response(C,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...Z1(),"Cache-Control":U$,Pragma:"no-cache",Expires:"0"}})}}return new Response(V,{headers:{"Content-Type":"text/html",...Z1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(O){return new Response(`<pre>${O}
1606
+ ${O.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1607
1607
  ${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(`
1608
1608
  ${B.bright}\u2192 ${B.cyan}http://localhost:${U}/${B.reset}`),console.log(`
1609
- ${B.yellow}Routes:${B.reset}`);let F=new Set(W.map((j)=>j.routeTemplate)),O=Object.entries(G).filter(([j])=>!F.has(j)).sort(([j],[L])=>j.localeCompare(L)).map(([j,L])=>({route:j==="/"?"/":j,filePath:X0.relative(process.cwd(),L.filePath),fileType:L.fileType}));for(let j of W){let L=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");O.push({route:L,filePath:X0.relative(process.cwd(),j.filePath),fileType:"stx"})}if(O.sort((j,L)=>j.route.localeCompare(L.route)),O.forEach((j,L)=>{let A=L===O.length-1?"\u2514\u2500 ":"\u251C\u2500 ",q=j.fileType==="md"?`${B.magenta}(markdown)${B.reset}`:"";console.log(` ${B.green}${A}${j.route}${B.reset} \u2192 ${B.bright}${j.filePath}${B.reset} ${q}`)}),console.log(`
1610
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(z.url.toString(),()=>{if(Z)P0.watch(J,{recursive:!0}).close();z.stop()}),Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let j=P0.watch(J,{recursive:!0},async(L,H)=>{if(!H)return;if(H.endsWith(".stx")||H.endsWith(".js")||H.endsWith(".ts")||H.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${H}${B.yellow} changed, rebuilding...${B.reset}`),u0.clear(),m0(),await K()});process.on("SIGINT",()=>{j.close(),z.stop(),process.exit(0)})}return!0}function j6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:A4}=globalThis.Bun;import Y0 from"fs";import g from"path";async function N6($){try{return X5(await Bun.file($).text())}catch{return}}function o$($){let X=Bun.file($),Q=g.extname($).toLowerCase(),Z={".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(Q)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Z[Q]||"application/octet-stream",...J}})}async function q4($=".",X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=g.resolve($),{loadStxConfig:K}=await import("./chunk-8m0p3v0e.js"),_=await K(W),U=_.root&&_.root!=="."?g.join(W,_.root):W,z=X.pagesDir||_.pagesDir||"pages",F=g.join(U,z);if(!Y0.existsSync(F))return console.error(`${B.red}Error: No '${z}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${F}${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 ${z}/index.stx for the homepage.${B.reset}`),!1;let O=e$(U,{pagesDir:z});if(O.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${F}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${O.length}${B.blue} routes${B.reset}`);let j=_?._pluginPageDirs||[],L=[];for(let{dir:D,prefix:T}of j)if(Y0.existsSync(D)){let k=e$(g.dirname(D),{pagesDir:g.basename(D)});for(let S of k){let b=T==="/"?S.pattern:`${T}${S.pattern==="/"?"":S.pattern}`;L.push({route:{...S,pattern:b},prefix:T})}if(k.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${k.length}${B.blue} routes at ${B.cyan}${T}${B.reset}`)}let H=new Map,A=null,q=null;if(X.stxOptions?.shell!==!1){if(q=await b6(W,X.stxOptions?.shell),q){if(A=await $5(q,X.stxOptions||{}),A)console.log(`${B.blue}Using app shell: ${B.bright}${g.relative(W,q)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}E6(),await R6(W);let M=I6();if(M.length>0)console.log(`${B.blue}Loaded ${B.bright}${M.length}${B.blue} middleware: ${B.dim}${M.join(", ")}${B.reset}`);let V={},N=null;try{let{loadStxConfig:D}=await import("./chunk-8m0p3v0e.js"),T=await D(W);if(T?.apiRouter)N=T?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(T?.apiRoutes){V=T.apiRoutes;let k=Object.keys(V).length;if(k>0)console.log(`${B.blue}Loaded ${B.bright}${k} API route${k>1?"s":""}${B.reset}`)}if(T?.broadcasting?.enabled)try{let{startBroadcasting:k,loadChannels:S}=await import("./chunk-5mrs8cs2.js"),b=T.broadcasting;await k(b);let _0=b.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${_0}/ws${B.reset}`);let W0=g.join(process.cwd(),"channels.ts");if(Y0.existsSync(W0))try{let C0=await S(W0);console.log(`${B.blue}Loaded ${B.bright}${C0} broadcast channel${C0!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(C0){console.warn(`${B.yellow}Failed to load channels.ts: ${C0.message}${B.reset}`)}}catch(k){console.warn(`${B.yellow}Broadcasting failed to start: ${k.message}${B.reset}`)}}catch{}let R=S0(W,"output");Y0.mkdirSync(R,{recursive:!0});let w=new Map,C=new Set,I=async(D)=>{let T=M6(F,D);if(!T)return null;try{let k=await Bun.build({entrypoints:[T],outdir:R,plugins:[$1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!k.success)return null;let S=k.outputs.find((b)=>b.path.endsWith(".html"));if(!S)return null;return await Bun.file(S.path).text()}catch{return null}},E=new Map,m=async(D,T)=>{try{let{processDirectives:k,extractVariables:S,defaultConfig:b,loadStxConfig:_0,injectRouterScript:W0}=await import("./chunk-8m0p3v0e.js"),{checkCache:C0,cacheTemplate:h$,readFileCached:r,templateCache:f1}=await import("./chunk-t7zk4x6s.js"),h1=await _0(W),x=(d)=>{if(!d)return d;if(g.isAbsolute(d))return d;return g.resolve(W,d)},y={...b,...h1,...X.stxOptions,autoShell:!0};if(X.debugDirectives)y.debug=!0;y.partialsDir=x(y.partialsDir),y.componentsDir=x(y.componentsDir),y.layoutsDir=x(y.layoutsDir),y.storesDir=x(y.storesDir||"stores"),y.cachePath=x(y.cachePath)??S0(W,"cache");let u=!T&&!X.profile,c=y.cache!==!1;if(c&&u){let d=f1.get(D.filePath);if(d)try{if((await Y0.promises.stat(D.filePath)).mtime.getTime()<=d.mtime){let z0=!0;for(let e of d.dependencies){if(!Y0.existsSync(e)){z0=!1;break}if((await Y0.promises.stat(e)).mtime.getTime()>d.mtime){z0=!1;break}}if(z0){let e=d.output;if(A)e=L$(e,{preserveHead:!0});let z1=E.get(D.filePath);return{route:D,content:e,status:z1?.status??await N6(D.filePath),headers:z1?.headers}}}}catch{}let L0=await C0(D.filePath,y);if(L0){let F0=L0;if(A)F0=L$(F0,{preserveHead:!0});let z0=E.get(D.filePath);return{route:D,content:F0,status:z0?.status??await N6(D.filePath),headers:z0?.headers}}}let s=c?await r(D.filePath):await Bun.file(D.filePath).text(),v=X5(s),{classifyAllScripts:U0}=await import("./chunk-8m0p3v0e.js"),B0=U0(s),a=B0.server.map((d)=>d.content),t=s;for(let d of B0.server)t=t.replace(d.fullTag,"");let n={__filename:D.filePath,__dirname:g.dirname(D.filePath),params:T??{},__stx_runtime_head:{}};for(let d of a)try{await S(d,n,D.filePath)}catch(L0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",D.filePath,L0?.message||L0)}let a0=new Set,N0;if(X.profile){let d=performance.now();N0=await k(t,n,D.filePath,y,a0);let L0=performance.now()-d,F0=g.relative(W,D.filePath)||D.filePath;console.log(`[stx:profile] ${F0} \u2192 ${L0.toFixed(2)}ms`)}else N0=await k(t,n,D.filePath,y,a0);if(!A)N0=await W0(N0,{router:y.router});{let{interpolateScriptExpressions:d}=await import("./chunk-y8g3d192.js");N0=N0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(L0,F0,z0)=>{if(!/function\s+__stx_setup_/.test(z0))return L0;return`<script${F0}>${d(z0,n)}</script>`})}if(A)N0=L$(N0,{preserveHead:!0});if(c&&u)await h$(D.filePath,N0,a0,y);let{extractStreamBoundaries:o7}=await import("./chunk-hkn78n7a.js"),r0=o7(n),F1=n.__streamTemplates;if(F1&&typeof F1==="object"&&Object.keys(F1).length>0){let d=n.streamBoundaries||{},L0={...y,autoShell:!1},F0=Object.keys(F1).map((e)=>({id:e,render:async()=>{let z1=typeof d[e]==="function"?await d[e]():void 0;return k(F1[e],{...n,$boundary:z1},D.filePath,L0,new Set)}})),z0=new Set(F0.map((e)=>e.id));r0=[...(r0||[]).filter((e)=>!z0.has(e.id)),...F0]}if(r0&&r0.length>0)C.add(D.pattern);else r0=void 0;let d5=N1(n),u5=M1(n);if(u)E.set(D.filePath,{status:d5,headers:u5});return{route:D,content:N0,status:d5??v,headers:u5,boundaries:r0}}catch(k){return console.error(`${B.red}Error building ${B.bright}${D.pattern}${B.reset}:`,k),null}},f=8,K0=async()=>{w.clear(),H.clear();for(let D=0;D<O.length;D+=f){let T=O.slice(D,D+f),k=await Promise.all(T.map((S)=>m(S)));for(let S of k)if(S)w.set(S.route.pattern,S)}for(let D=0;D<L.length;D+=f){let T=L.slice(D,D+f),k=await Promise.all(T.map(({route:S})=>m(S)));for(let S of k)if(S)H.set(S.route.pattern,S)}return w.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await K0())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await W$(W);let G0=Q;try{if(G0=await x0(Q),G0!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${G0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let D=X.hmrPort||G0+1;J=X$({wsPort:D,verbose:!1}),G=J.start(D)}let v1=(D,T)=>{let S=`<script data-stx-route-params>(function(){var p=${JSON.stringify(T).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(D.includes("</head>"))return D.replace("</head>",`${S}</head>`);if(D.includes("<body"))return D.replace(/<body([^>]*)>/,`<body$1>${S}`);return S+D};console.log(`${B.blue}Starting server...${B.reset}`);let g1=A4({port:G0,async fetch(D){let T=new URL(D.url),k=_?.publicDir||"public",S=g.join(W,k,T.pathname),b=g.join(W,T.pathname),_0=g.join(R,T.pathname),[W0,C0,h$]=await Promise.all([Y0.promises.stat(S).catch(()=>null),Y0.promises.stat(b).catch(()=>null),Y0.promises.stat(_0).catch(()=>null)]);if(W0?.isFile())return o$(S);if(C0?.isFile())return o$(b);if(h$?.isFile())return o$(_0);if(T.pathname.startsWith("/_stx/component/")){let x=decodeURIComponent(T.pathname.slice(16));if(x)try{let y=`<${x} />`,u={...buildConfig,autoShell:!1},c=await processDirectives(y,{},g.join(W,"components",`${x}.stx`),u,new Set);return new Response(c,{headers:{"Content-Type":"text/html"}})}catch(y){return new Response(`<div class="stx-async-error">${y.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(T.pathname==="/_stx/img"){let{handleImageRequest:x}=await import("./chunk-h23wts30.js"),y=await x(D,{publicDir:g.join(W,k),cacheDir:S0(W,"cache","img")});if(y)return y}if(N)try{let x=await N.handleRequest(D);if(x.status!==404)return x}catch{}if(V[T.pathname])try{return await V[T.pathname](D)}catch(x){return new Response(JSON.stringify({error:x.message}),{status:500,headers:{"Content-Type":"application/json"}})}let r=t$(T.pathname,O);if(r){let x=w.get(r.route.pattern),y=C.has(r.route.pattern);if(r.route.isDynamic&&Object.keys(r.params).length>0||y){let u=await m(r.route,r.params);if(u)x=u}if(x){let u=x.status??200,c=x.headers??{},s=(r.route.filePath?x6(await Bun.file(r.route.filePath).text().catch(()=>"")):null)??{};if(s.validate){if(!await s.validate({params:r.params})){let B0=await I(404);if(B0){let a=B0;if(a=await o(a,W),Y)a=D0(a,G);return new Response(a,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(s.middleware){let U0=D6(T.pathname,r.params,s,T.search),B0=w6(U0,null,D,{isServer:!0}),a=await T6(s.middleware,B0);if(a.redirect){let t=a.redirect.path,n=a.redirect.options.redirectCode||302,a0=new Headers(a.responseHeaders);return a0.set("Location",t),new Response(null,{status:n,headers:a0})}if(a.abort){let{statusCode:t,message:n}=a.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${t}</title></head><body><h1>Error ${t}</h1><p>${n}</p></body></html>`,{status:t,headers:{"Content-Type":"text/html"}})}if(Object.keys(a.state).length>0){let t=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(a.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;x.content=x.content.replace("</head>",`${t}</head>`)}}let v=x.content;if(A&&y6(D)){let U0=C6(v),B0=P6(v),a=v.match(/<title[^>]*>([\s\S]*?)<\/title>/i),t=a?a[1].trim():"";if(Object.keys(r.params).length>0)v=v1(v,r.params);v=await o(v,W);let n=_?.router?.container||"main";return v=v6(v,n),new Response(v,{status:u,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":U0.layout,"X-STX-Layout-Group":U0.group,"X-STX-Runtime":B0?"true":"false",...t&&{"X-STX-Title":encodeURIComponent(t)},[k6]:S6(),...Q1(),"Cache-Control":U$}})}if(A)v=B$(A,v);if(Object.keys(r.params).length>0)v=v1(v,r.params);if(v=await o(v,W),Y)v=D0(v,G);if(X.native)if(v.includes("<head>"))v=v.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 v="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+v;if(X.titlebarHidden)if(v.includes("<head>"))v=v.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 v=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${v}`;if(x.boundaries&&x.boundaries.length>0){let{renderStreamingPage:U0,streamToResponse:B0}=await import("./chunk-hkn78n7a.js");return B0(U0(v,x.boundaries,{timeoutMs:30000}),{status:u,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(v,{status:u,headers:{"Content-Type":"text/html",...Q1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...c}})}}if(L.length>0){let x=L.map((u)=>u.route),y=t$(T.pathname,x);if(y){let u=H.get(y.route.pattern);if(u){let c=u.content;if(A)c=B$(A,c);if(Object.keys(y.params).length>0)c=v1(c,y.params);if(c=await o(c,W),Y)c=D0(c,G);return new Response(c,{status:u.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:u}of j)if(u!=="/"&&T.pathname.startsWith(u)){let c=H.get(u)||H.get(u+"/");if(c){let s=c.content;if(A)s=B$(A,s);if(s=await o(s,W),Y)s=D0(s,G);return new Response(s,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let f1=w.get("/");if(f1){let x=f1.content;if(x=await o(x,W),Y)x=D0(x,G);if(X.native)if(x.includes("<head>"))x=x.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 x="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+x;return new Response(x,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let h1=await I(404);if(h1){let x=h1;if(x=await o(x,W),Y)x=D0(x,G);return new Response(x,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(D){let T=await I(500);if(T)return new Response(T,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${D}
1609
+ ${B.yellow}Routes:${B.reset}`);let F=new Set(W.map((O)=>O.routeTemplate)),j=Object.entries(G).filter(([O])=>!F.has(O)).sort(([O],[L])=>O.localeCompare(L)).map(([O,L])=>({route:O==="/"?"/":O,filePath:X0.relative(process.cwd(),L.filePath),fileType:L.fileType}));for(let O of W){let L=O.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");j.push({route:L,filePath:X0.relative(process.cwd(),O.filePath),fileType:"stx"})}if(j.sort((O,L)=>O.route.localeCompare(L.route)),j.forEach((O,L)=>{let q=L===j.length-1?"\u2514\u2500 ":"\u251C\u2500 ",A=O.fileType==="md"?`${B.magenta}(markdown)${B.reset}`:"";console.log(` ${B.green}${q}${O.route}${B.reset} \u2192 ${B.bright}${O.filePath}${B.reset} ${A}`)}),console.log(`
1610
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),x0(z.url.toString(),()=>{if(Z)P0.watch(J,{recursive:!0}).close();z.stop()}),Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let O=P0.watch(J,{recursive:!0},async(L,H)=>{if(!H)return;if(H.endsWith(".stx")||H.endsWith(".js")||H.endsWith(".ts")||H.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${H}${B.yellow} changed, rebuilding...${B.reset}`),m0.clear(),p0(),await K()});process.on("SIGINT",()=>{O.close(),z.stop(),process.exit(0)})}return!0}function O6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:q4}=globalThis.Bun;import Y0 from"fs";import g from"path";async function M6($){try{return Z5(await Bun.file($).text())}catch{return}}function e$($){let X=Bun.file($),Q=g.extname($).toLowerCase(),Z={".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(Q)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Z[Q]||"application/octet-stream",...J}})}async function N4($=".",X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=g.resolve($),{loadStxConfig:K}=await import("./chunk-dxepdtt2.js"),_=await K(W),U=_.root&&_.root!=="."?g.join(W,_.root):W,z=X.pagesDir||_.pagesDir||"pages",F=g.join(U,z);if(!Y0.existsSync(F))return console.error(`${B.red}Error: No '${z}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${F}${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 ${z}/index.stx for the homepage.${B.reset}`),!1;let j=X5(U,{pagesDir:z});if(j.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${F}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${j.length}${B.blue} routes${B.reset}`);let O=_?._pluginPageDirs||[],L=[];for(let{dir:D,prefix:T}of O)if(Y0.existsSync(D)){let x=X5(g.dirname(D),{pagesDir:g.basename(D)});for(let S of x){let b=T==="/"?S.pattern:`${T}${S.pattern==="/"?"":S.pattern}`;L.push({route:{...S,pattern:b},prefix:T})}if(x.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${x.length}${B.blue} routes at ${B.cyan}${T}${B.reset}`)}let H=new Map,q=null,A=null;if(X.stxOptions?.shell!==!1){if(A=await y6(W,X.stxOptions?.shell),A){if(q=await Q5(A,X.stxOptions||{}),q)console.log(`${B.blue}Using app shell: ${B.bright}${g.relative(W,A)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}I6(),await D6(W);let N=R6();if(N.length>0)console.log(`${B.blue}Loaded ${B.bright}${N.length}${B.blue} middleware: ${B.dim}${N.join(", ")}${B.reset}`);let V={},M=null;try{let{loadStxConfig:D}=await import("./chunk-dxepdtt2.js"),T=await D(W);if(T?.apiRouter)M=T?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(T?.apiRoutes){V=T.apiRoutes;let x=Object.keys(V).length;if(x>0)console.log(`${B.blue}Loaded ${B.bright}${x} API route${x>1?"s":""}${B.reset}`)}if(T?.broadcasting?.enabled)try{let{startBroadcasting:x,loadChannels:S}=await import("./chunk-8m7fhky6.js"),b=T.broadcasting;await x(b);let _0=b.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${_0}/ws${B.reset}`);let W0=g.join(process.cwd(),"channels.ts");if(Y0.existsSync(W0))try{let C0=await S(W0);console.log(`${B.blue}Loaded ${B.bright}${C0} broadcast channel${C0!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(C0){console.warn(`${B.yellow}Failed to load channels.ts: ${C0.message}${B.reset}`)}}catch(x){console.warn(`${B.yellow}Broadcasting failed to start: ${x.message}${B.reset}`)}}catch{}let R=S0(W,"output");Y0.mkdirSync(R,{recursive:!0});let w=new Map,C=new Set,I=async(D)=>{let T=V6(F,D);if(!T)return null;try{let x=await Bun.build({entrypoints:[T],outdir:R,plugins:[X1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!x.success)return null;let S=x.outputs.find((b)=>b.path.endsWith(".html"));if(!S)return null;return await Bun.file(S.path).text()}catch{return null}},E=new Map,m=async(D,T)=>{try{let{processDirectives:x,extractVariables:S,defaultConfig:b,loadStxConfig:_0,injectRouterScript:W0}=await import("./chunk-dxepdtt2.js"),{checkCache:C0,cacheTemplate:u$,readFileCached:r,templateCache:f1}=await import("./chunk-dkt2rq3s.js"),h1=await _0(W),k=(d)=>{if(!d)return d;if(g.isAbsolute(d))return d;return g.resolve(W,d)},y={...b,...h1,...X.stxOptions,autoShell:!0};if(X.debugDirectives)y.debug=!0;y.partialsDir=k(y.partialsDir),y.componentsDir=k(y.componentsDir),y.layoutsDir=k(y.layoutsDir),y.storesDir=k(y.storesDir||"stores"),y.cachePath=k(y.cachePath)??S0(W,"cache");let u=!T&&!X.profile,c=y.cache!==!1;if(c&&u){let d=f1.get(D.filePath);if(d)try{if((await Y0.promises.stat(D.filePath)).mtime.getTime()<=d.mtime){let z0=!0;for(let e of d.dependencies){if(!Y0.existsSync(e)){z0=!1;break}if((await Y0.promises.stat(e)).mtime.getTime()>d.mtime){z0=!1;break}}if(z0){let e=d.output;if(q)e=L$(e,{preserveHead:!0});let j1=E.get(D.filePath);return{route:D,content:e,status:j1?.status??await M6(D.filePath),headers:j1?.headers}}}}catch{}let L0=await C0(D.filePath,y);if(L0){let F0=L0;if(q)F0=L$(F0,{preserveHead:!0});let z0=E.get(D.filePath);return{route:D,content:F0,status:z0?.status??await M6(D.filePath),headers:z0?.headers}}}let s=c?await r(D.filePath):await Bun.file(D.filePath).text(),v=Z5(s),{classifyAllScripts:U0}=await import("./chunk-dxepdtt2.js"),B0=U0(s),a=B0.server.map((d)=>d.content),t=s;for(let d of B0.server)t=t.replace(d.fullTag,"");let n={__filename:D.filePath,__dirname:g.dirname(D.filePath),params:T??{},__stx_runtime_head:{}};for(let d of a)try{await S(d,n,D.filePath)}catch(L0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",D.filePath,L0?.message||L0)}let r0=new Set,N0;if(X.profile){let d=performance.now();N0=await x(t,n,D.filePath,y,r0);let L0=performance.now()-d,F0=g.relative(W,D.filePath)||D.filePath;console.log(`[stx:profile] ${F0} \u2192 ${L0.toFixed(2)}ms`)}else N0=await x(t,n,D.filePath,y,r0);if(!q)N0=await W0(N0,{router:y.router});{let{interpolateScriptExpressions:d}=await import("./chunk-cv0z0qpy.js");N0=N0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(L0,F0,z0)=>{if(!/function\s+__stx_setup_/.test(z0))return L0;return`<script${F0}>${d(z0,n)}</script>`})}if(q)N0=L$(N0,{preserveHead:!0});if(c&&u)await u$(D.filePath,N0,r0,y);let{extractStreamBoundaries:t7}=await import("./chunk-q253eftn.js"),s0=t7(n),z1=n.__streamTemplates;if(z1&&typeof z1==="object"&&Object.keys(z1).length>0){let d=n.streamBoundaries||{},L0={...y,autoShell:!1},F0=Object.keys(z1).map((e)=>({id:e,render:async()=>{let j1=typeof d[e]==="function"?await d[e]():void 0;return x(z1[e],{...n,$boundary:j1},D.filePath,L0,new Set)}})),z0=new Set(F0.map((e)=>e.id));s0=[...(s0||[]).filter((e)=>!z0.has(e.id)),...F0]}if(s0&&s0.length>0)C.add(D.pattern);else s0=void 0;let u5=N1(n),m5=M1(n);if(u)E.set(D.filePath,{status:u5,headers:m5});return{route:D,content:N0,status:u5??v,headers:m5,boundaries:s0}}catch(x){return console.error(`${B.red}Error building ${B.bright}${D.pattern}${B.reset}:`,x),null}},f=8,K0=async()=>{w.clear(),H.clear();for(let D=0;D<j.length;D+=f){let T=j.slice(D,D+f),x=await Promise.all(T.map((S)=>m(S)));for(let S of x)if(S)w.set(S.route.pattern,S)}for(let D=0;D<L.length;D+=f){let T=L.slice(D,D+f),x=await Promise.all(T.map(({route:S})=>m(S)));for(let S of x)if(S)H.set(S.route.pattern,S)}return w.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await K0())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await W$(W);let G0=Q;try{if(G0=await k0(Q),G0!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${G0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let D=X.hmrPort||G0+1;J=X$({wsPort:D,verbose:!1}),G=J.start(D)}let v1=(D,T)=>{let S=`<script data-stx-route-params>(function(){var p=${JSON.stringify(T).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(D.includes("</head>"))return D.replace("</head>",`${S}</head>`);if(D.includes("<body"))return D.replace(/<body([^>]*)>/,`<body$1>${S}`);return S+D};console.log(`${B.blue}Starting server...${B.reset}`);let g1=q4({port:G0,async fetch(D){let T=new URL(D.url),x=_?.publicDir||"public",S=g.join(W,x,T.pathname),b=g.join(W,T.pathname),_0=g.join(R,T.pathname),[W0,C0,u$]=await Promise.all([Y0.promises.stat(S).catch(()=>null),Y0.promises.stat(b).catch(()=>null),Y0.promises.stat(_0).catch(()=>null)]);if(W0?.isFile())return e$(S);if(C0?.isFile())return e$(b);if(u$?.isFile())return e$(_0);if(T.pathname.startsWith("/_stx/component/")){let k=decodeURIComponent(T.pathname.slice(16));if(k)try{let y=`<${k} />`,u={...buildConfig,autoShell:!1},c=await processDirectives(y,{},g.join(W,"components",`${k}.stx`),u,new Set);return new Response(c,{headers:{"Content-Type":"text/html"}})}catch(y){return new Response(`<div class="stx-async-error">${y.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(T.pathname==="/_stx/img"){let{handleImageRequest:k}=await import("./chunk-ddqzxbkr.js"),y=await k(D,{publicDir:g.join(W,x),cacheDir:S0(W,"cache","img")});if(y)return y}if(M)try{let k=await M.handleRequest(D);if(k.status!==404)return k}catch{}if(V[T.pathname])try{return await V[T.pathname](D)}catch(k){return new Response(JSON.stringify({error:k.message}),{status:500,headers:{"Content-Type":"application/json"}})}let r=$5(T.pathname,j);if(r){let k=w.get(r.route.pattern),y=C.has(r.route.pattern);if(r.route.isDynamic&&Object.keys(r.params).length>0||y){let u=await m(r.route,r.params);if(u)k=u}if(k){let u=k.status??200,c=k.headers??{},s=(r.route.filePath?x6(await Bun.file(r.route.filePath).text().catch(()=>"")):null)??{};if(s.validate){if(!await s.validate({params:r.params})){let B0=await I(404);if(B0){let a=B0;if(a=await o(a,W),Y)a=D0(a,G);return new Response(a,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(s.middleware){let U0=w6(T.pathname,r.params,s,T.search),B0=T6(U0,null,D,{isServer:!0}),a=await C6(s.middleware,B0);if(a.redirect){let t=a.redirect.path,n=a.redirect.options.redirectCode||302,r0=new Headers(a.responseHeaders);return r0.set("Location",t),new Response(null,{status:n,headers:r0})}if(a.abort){let{statusCode:t,message:n}=a.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${t}</title></head><body><h1>Error ${t}</h1><p>${n}</p></body></html>`,{status:t,headers:{"Content-Type":"text/html"}})}if(Object.keys(a.state).length>0){let t=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(a.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;k.content=k.content.replace("</head>",`${t}</head>`)}}let v=k.content;if(q&&v6(D)){let U0=k6(v),B0=S6(v),a=v.match(/<title[^>]*>([\s\S]*?)<\/title>/i),t=a?a[1].trim():"";if(Object.keys(r.params).length>0)v=v1(v,r.params);v=await o(v,W);let n=_?.router?.container||"main";return v=g6(v,n),new Response(v,{status:u,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":U0.layout,"X-STX-Layout-Group":U0.group,"X-STX-Runtime":B0?"true":"false",...t&&{"X-STX-Title":encodeURIComponent(t)},[P6]:b6(),...Z1(),"Cache-Control":U$}})}if(q)v=B$(q,v);if(Object.keys(r.params).length>0)v=v1(v,r.params);if(v=await o(v,W),Y)v=D0(v,G);if(X.native)if(v.includes("<head>"))v=v.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 v="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+v;if(X.titlebarHidden)if(v.includes("<head>"))v=v.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 v=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${v}`;if(k.boundaries&&k.boundaries.length>0){let{renderStreamingPage:U0,streamToResponse:B0}=await import("./chunk-q253eftn.js");return B0(U0(v,k.boundaries,{timeoutMs:30000}),{status:u,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(v,{status:u,headers:{"Content-Type":"text/html",...Z1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...c}})}}if(L.length>0){let k=L.map((u)=>u.route),y=$5(T.pathname,k);if(y){let u=H.get(y.route.pattern);if(u){let c=u.content;if(q)c=B$(q,c);if(Object.keys(y.params).length>0)c=v1(c,y.params);if(c=await o(c,W),Y)c=D0(c,G);return new Response(c,{status:u.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:u}of O)if(u!=="/"&&T.pathname.startsWith(u)){let c=H.get(u)||H.get(u+"/");if(c){let s=c.content;if(q)s=B$(q,s);if(s=await o(s,W),Y)s=D0(s,G);return new Response(s,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let f1=w.get("/");if(f1){let k=f1.content;if(k=await o(k,W),Y)k=D0(k,G);if(X.native)if(k.includes("<head>"))k=k.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 k="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+k;return new Response(k,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let h1=await I(404);if(h1){let k=h1;if(k=await o(k,W),Y)k=D0(k,G);return new Response(k,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(D){let T=await I(500);if(T)return new Response(T,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${D}
1611
1611
  ${D.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
1612
1612
  ${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(`
1613
1613
  ${B.bright}\u2192 ${B.cyan}http://localhost:${G0}/${B.reset}`),Y)console.log(`${B.dim} HMR: ws://localhost:${G}${B.reset}`);console.log(`
1614
- ${B.yellow}Routes:${B.reset}`);let i0=[...V6(O,W)];for(let{route:D}of L)i0.push(`${D.pattern}`);if(i0.forEach((D,T)=>{let S=T===i0.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${B.green}${S}${B.reset}${D}`)}),console.log(`
1615
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(g1.url.toString(),()=>{if(J)A1();g1.stop()}),X.native){let D,T=g.join(F,"index.stx");if(Y0.existsSync(T)){let S=await Bun.file(T).text();D=o1(S)}let k=_?.app?.window??{};await o0(G0,{title:_?.app?.head?.title||g.basename(W)||"stx App",width:k.width,height:k.height,darkMode:k.darkMode,hotReload:k.hotReload,titlebarHidden:k.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let D=(S)=>{return S.startsWith("public/")||S.startsWith("public\\")},T=(S)=>{let b=S.toLowerCase();return b.endsWith(".stx")||b.endsWith(".html")||b.endsWith(".md")},k=Y0.watch(W,{recursive:!0},async(S,b)=>{if(!b||$$(b))return;if(e1(b))if(D(b)){if(console.log(`${B.cyan}${b} changed${B.reset}`),Y&&J)J.reload(b)}else if(T(b)){console.log(`${B.yellow}${b} changed, rebuilding...${B.reset}`),u0.clear(),m0();try{let{invalidateFileCache:_0,templateCache:W0}=await import("./chunk-t7zk4x6s.js");_0(g.resolve(W,b)),W0.delete(g.resolve(W,b))}catch{}if(q&&b){if(g.resolve(W,b)===q||g.basename(q)===b){let W0=await $5(q,X.stxOptions||{});if(W0)A=W0}}if(await K0(),await K$(W),Y&&J)J.reload(b)}else{console.log(`${B.yellow}${b} changed, rebuilding...${B.reset}`),u0.clear(),m0();try{let{invalidateFileCache:_0,templateCache:W0}=await import("./chunk-t7zk4x6s.js");_0(g.resolve(W,b)),W0.delete(g.resolve(W,b))}catch{}if(await K0(),Y&&J)J.reload(b)}else if(t1(b)){if(console.log(`${B.cyan}CSS ${b} changed${B.reset}`),Y&&J)J.updateCss(b)}});process.on("SIGINT",()=>{if(k.close(),J)A1();g1.stop(),process.exit(0)})}return!0}var N4=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function M4($){let X=($||"").trim();if(!X)return null;if(/[\s>+~,:]/.test(X))return null;let Q={},Z=X,Y=Z.match(/^[a-z][\w-]*/i);if(Y)Q.tag=Y[0].toLowerCase(),Z=Z.slice(Y[0].length);while(Z.length>0){let J=Z.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(J){if(Q.attr=J[1],J[3]!==void 0&&J[3]!=="")Q.attrValue=J[3];Z=Z.slice(J[0].length);continue}let G=Z.match(/^#([\w-]+)/);if(G){Q.id=G[1],Z=Z.slice(G[0].length);continue}let W=Z.match(/^\.([\w-]+)/);if(W){Q.className=W[1],Z=Z.slice(W[0].length);continue}return null}if(!Q.tag&&!Q.attr&&!Q.id&&!Q.className)return null;return Q}function V4($,X){if(X.attr){if(!(X.attrValue===void 0?new RegExp(`\\b${X.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${X.attr}\\s*=\\s*(["'])\\s*${X.attrValue}\\s*\\1`,"i")).test($))return!1}if(X.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${X.id}\\s*\\1`,"i").test($))return!1}if(X.className){let Q=$.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!Q)return!1;if(!Q[2].split(/\s+/).includes(X.className))return!1}return!0}function bW($,X="main"){let Q=M4(X);if(!Q)return null;let Z=/<([a-z][\w-]*)\b([^>]*)>/gi,Y;while((Y=Z.exec($))!==null){let J=Y[1].toLowerCase(),G=Y[2]||"";if(G.trimEnd().endsWith("/")||N4.has(J))continue;if(Q.tag&&Q.tag!==J)continue;if(!V4(G,Q))continue;let W=Y[0],K=Y.index+W.length,_=new RegExp(`<(/?)${J}\\b([^>]*)>`,"gi");_.lastIndex=K;let U=1,z;while((z=_.exec($))!==null){let F=z[1]==="/";if(!F&&(z[2]||"").trimEnd().endsWith("/"))continue;if(U+=F?-1:1,U===0)return{openTag:W,openIndex:Y.index,start:K,end:z.index,tagName:J}}return null}return null}var P={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;P.enabled=!0,P.maxEvents=$.maxEvents||1000,P.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>P,getComponents:()=>Array.from(P.components.values()),getComponent:(X)=>P.components.get(X),getStores:()=>Array.from(P.stores.values()),getStore:(X)=>P.stores.get(X),getEvents:()=>P.events,getPerformance:()=>P.performance,selectComponent:(X)=>Z5(X),selectStore:(X)=>R4(X),inspectElement:(X)=>D4(X),highlightComponent:(X)=>u6(X),clearHighlight:()=>m6(),logComponentTree:()=>w4(),logStoreState:(X)=>T4(X),timeTravel:(X,Q)=>C4(X,Q)},k4(),x4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function I4(){P.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function g6($){if(!P.enabled)return;let X=P.components.get($);if(X){if(X.parentId){let Q=P.components.get(X.parentId);if(Q)Q.children=Q.children.filter((Z)=>Z!==$)}P.components.delete($),Q5({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function h6($,X,Q={},Z=[]){if(!P.enabled)return;let Y={id:$,state:X,getters:Q,actions:Z,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};P.stores.set($,Y),Q5({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function d6($,X,Q,Z,Y="state"){if(!P.enabled)return;let J=P.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Q,newValue:Z,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]:Z};Q5({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Q,newValue:Z}})}}function Q5($){if(!P.enabled)return;if(P.events.push($),P.events.length>P.maxEvents)P.events=P.events.slice(-P.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function Z5($){P.selectedComponent=$;let X=P.components.get($);if(X)u6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function R4($){P.selectedStore=$;let X=P.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function D4($){let X=$;while(X){let Q=X.getAttribute("data-stx-component-id");if(Q)return Z5(Q);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function u6($){m6();let X=P.components.get($);if(X?.element){let Q=document.createElement("div");Q.id="stx-devtools-highlight",Q.style.cssText=`
1614
+ ${B.yellow}Routes:${B.reset}`);let a0=[...E6(j,W)];for(let{route:D}of L)a0.push(`${D.pattern}`);if(a0.forEach((D,T)=>{let S=T===a0.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${B.green}${S}${B.reset}${D}`)}),console.log(`
1615
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),x0(g1.url.toString(),()=>{if(J)A1();g1.stop()}),X.native){let D,T=g.join(F,"index.stx");if(Y0.existsSync(T)){let S=await Bun.file(T).text();D=o1(S)}let x=_?.app?.window??{};await t0(G0,{title:_?.app?.head?.title||g.basename(W)||"stx App",width:x.width,height:x.height,darkMode:x.darkMode,hotReload:x.hotReload,titlebarHidden:x.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let D=(S)=>{return S.startsWith("public/")||S.startsWith("public\\")},T=(S)=>{let b=S.toLowerCase();return b.endsWith(".stx")||b.endsWith(".html")||b.endsWith(".md")},x=Y0.watch(W,{recursive:!0},async(S,b)=>{if(!b||$$(b))return;if(e1(b))if(D(b)){if(console.log(`${B.cyan}${b} changed${B.reset}`),Y&&J)J.reload(b)}else if(T(b)){console.log(`${B.yellow}${b} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:_0,templateCache:W0}=await import("./chunk-dkt2rq3s.js");_0(g.resolve(W,b)),W0.delete(g.resolve(W,b))}catch{}if(A&&b){if(g.resolve(W,b)===A||g.basename(A)===b){let W0=await Q5(A,X.stxOptions||{});if(W0)q=W0}}if(await K0(),await K$(W),Y&&J)J.reload(b)}else{console.log(`${B.yellow}${b} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:_0,templateCache:W0}=await import("./chunk-dkt2rq3s.js");_0(g.resolve(W,b)),W0.delete(g.resolve(W,b))}catch{}if(await K0(),Y&&J)J.reload(b)}else if(t1(b)){if(console.log(`${B.cyan}CSS ${b} changed${B.reset}`),Y&&J)J.updateCss(b)}});process.on("SIGINT",()=>{if(x.close(),J)A1();g1.stop(),process.exit(0)})}return!0}var M4=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V4($){let X=($||"").trim();if(!X)return null;if(/[\s>+~,:]/.test(X))return null;let Q={},Z=X,Y=Z.match(/^[a-z][\w-]*/i);if(Y)Q.tag=Y[0].toLowerCase(),Z=Z.slice(Y[0].length);while(Z.length>0){let J=Z.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(J){if(Q.attr=J[1],J[3]!==void 0&&J[3]!=="")Q.attrValue=J[3];Z=Z.slice(J[0].length);continue}let G=Z.match(/^#([\w-]+)/);if(G){Q.id=G[1],Z=Z.slice(G[0].length);continue}let W=Z.match(/^\.([\w-]+)/);if(W){Q.className=W[1],Z=Z.slice(W[0].length);continue}return null}if(!Q.tag&&!Q.attr&&!Q.id&&!Q.className)return null;return Q}function E4($,X){if(X.attr){if(!(X.attrValue===void 0?new RegExp(`\\b${X.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${X.attr}\\s*=\\s*(["'])\\s*${X.attrValue}\\s*\\1`,"i")).test($))return!1}if(X.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${X.id}\\s*\\1`,"i").test($))return!1}if(X.className){let Q=$.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!Q)return!1;if(!Q[2].split(/\s+/).includes(X.className))return!1}return!0}function vW($,X="main"){let Q=V4(X);if(!Q)return null;let Z=/<([a-z][\w-]*)\b([^>]*)>/gi,Y;while((Y=Z.exec($))!==null){let J=Y[1].toLowerCase(),G=Y[2]||"";if(G.trimEnd().endsWith("/")||M4.has(J))continue;if(Q.tag&&Q.tag!==J)continue;if(!E4(G,Q))continue;let W=Y[0],K=Y.index+W.length,_=new RegExp(`<(/?)${J}\\b([^>]*)>`,"gi");_.lastIndex=K;let U=1,z;while((z=_.exec($))!==null){let F=z[1]==="/";if(!F&&(z[2]||"").trimEnd().endsWith("/"))continue;if(U+=F?-1:1,U===0)return{openTag:W,openIndex:Y.index,start:K,end:z.index,tagName:J}}return null}return null}var P={enabled:!1,components:new Map,stores:new Map,events:[],performance:[],selectedComponent:null,selectedStore:null,maxEvents:1000,maxPerformance:500};function I4($={}){if(typeof window>"u")return;P.enabled=!0,P.maxEvents=$.maxEvents||1000,P.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>P,getComponents:()=>Array.from(P.components.values()),getComponent:(X)=>P.components.get(X),getStores:()=>Array.from(P.stores.values()),getStore:(X)=>P.stores.get(X),getEvents:()=>P.events,getPerformance:()=>P.performance,selectComponent:(X)=>J5(X),selectStore:(X)=>D4(X),inspectElement:(X)=>w4(X),highlightComponent:(X)=>m6(X),clearHighlight:()=>p6(),logComponentTree:()=>T4(),logStoreState:(X)=>C4(X),timeTravel:(X,Q)=>k4(X,Q)},S4(),x4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function R4(){P.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function f6($){if(!P.enabled)return;let X=P.components.get($);if(X){if(X.parentId){let Q=P.components.get(X.parentId);if(Q)Q.children=Q.children.filter((Z)=>Z!==$)}P.components.delete($),Y5({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function d6($,X,Q={},Z=[]){if(!P.enabled)return;let Y={id:$,state:X,getters:Q,actions:Z,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};P.stores.set($,Y),Y5({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function u6($,X,Q,Z,Y="state"){if(!P.enabled)return;let J=P.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Q,newValue:Z,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]:Z};Y5({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Q,newValue:Z}})}}function Y5($){if(!P.enabled)return;if(P.events.push($),P.events.length>P.maxEvents)P.events=P.events.slice(-P.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function J5($){P.selectedComponent=$;let X=P.components.get($);if(X)m6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function D4($){P.selectedStore=$;let X=P.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function w4($){let X=$;while(X){let Q=X.getAttribute("data-stx-component-id");if(Q)return J5(Q);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function m6($){p6();let X=P.components.get($);if(X?.element){let Q=document.createElement("div");Q.id="stx-devtools-highlight",Q.style.cssText=`
1616
1616
  position: absolute;
1617
1617
  background: rgba(59, 130, 246, 0.2);
1618
1618
  border: 2px solid #3b82f6;
@@ -1630,7 +1630,7 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(g1.
1630
1630
  font-family: monospace;
1631
1631
  border-radius: 4px;
1632
1632
  white-space: nowrap;
1633
- `,Y.textContent=`<${X.name}>`,Q.appendChild(Y),document.body.appendChild(Q)}}function m6(){let $=document.getElementById("stx-devtools-highlight");if($)$.remove()}function w4(){console.group("%c[STX DevTools] Component Tree","color: #10b981; font-weight: bold;");let $=Array.from(P.components.values()).filter((Q)=>!Q.parentId);function X(Q,Z){let Y=" ".repeat(Z);if(console.log(`${Y}%c<${Q.name}>%c id=${Q.id} renders=${Q.renderCount}`,"color: #3b82f6;","color: #6b7280;"),Object.keys(Q.props).length>0)console.log(`${Y} props:`,Q.props);if(Object.keys(Q.state).length>0)console.log(`${Y} state:`,Q.state);for(let J of Q.children){let G=P.components.get(J);if(G)X(G,Z+1)}}for(let Q of $)X(Q,0);console.groupEnd()}function T4($){console.group("%c[STX DevTools] Store State","color: #8b5cf6; font-weight: bold;");let X=$?[P.stores.get($)].filter(Boolean):Array.from(P.stores.values());for(let Q of X)if(Q)console.group(`Store: ${Q.id}`),console.log("State:",Q.state),console.log("Getters:",Q.getters),console.log("Actions:",Q.actions),console.log("History:",Q.history),console.groupEnd();console.groupEnd()}function C4($,X){let Q=P.stores.get(X);if(!Q)return;if($<0||$>=Q.history.length){console.warn("[STX DevTools] Invalid history index");return}let Z={};for(let Y=0;Y<=$;Y++){let J=Q.history[Y];if(J.type==="state"&&J.name!=="__init__")Z[J.name]=J.newValue;else if(J.name==="__init__")Object.assign(Z,J.newValue)}if(console.log(`%c[STX DevTools] Time traveled to index ${$}`,"color: #f59e0b;",Z),typeof window<"u"&&window.__STX_STORES__){let J=window.__STX_STORES__[X];if(J&&typeof J.$patch==="function")J.$patch(Z)}}function x4(){if(typeof MutationObserver>"u")return;new MutationObserver((X)=>{for(let Q of X)Q.removedNodes.forEach((Z)=>{if(Z instanceof HTMLElement){let Y=Z.getAttribute("data-stx-component-id");if(Y)g6(Y);Z.querySelectorAll("[data-stx-component-id]").forEach((J)=>{let G=J.getAttribute("data-stx-component-id");if(G)g6(G)})}})}).observe(document.body,{childList:!0,subtree:!0})}function k4(){if(typeof document>"u")return;if(document.getElementById("stx-devtools-panel"))return;let $=document.createElement("div");$.id="stx-devtools-panel",$.innerHTML=`
1633
+ `,Y.textContent=`<${X.name}>`,Q.appendChild(Y),document.body.appendChild(Q)}}function p6(){let $=document.getElementById("stx-devtools-highlight");if($)$.remove()}function T4(){console.group("%c[STX DevTools] Component Tree","color: #10b981; font-weight: bold;");let $=Array.from(P.components.values()).filter((Q)=>!Q.parentId);function X(Q,Z){let Y=" ".repeat(Z);if(console.log(`${Y}%c<${Q.name}>%c id=${Q.id} renders=${Q.renderCount}`,"color: #3b82f6;","color: #6b7280;"),Object.keys(Q.props).length>0)console.log(`${Y} props:`,Q.props);if(Object.keys(Q.state).length>0)console.log(`${Y} state:`,Q.state);for(let J of Q.children){let G=P.components.get(J);if(G)X(G,Z+1)}}for(let Q of $)X(Q,0);console.groupEnd()}function C4($){console.group("%c[STX DevTools] Store State","color: #8b5cf6; font-weight: bold;");let X=$?[P.stores.get($)].filter(Boolean):Array.from(P.stores.values());for(let Q of X)if(Q)console.group(`Store: ${Q.id}`),console.log("State:",Q.state),console.log("Getters:",Q.getters),console.log("Actions:",Q.actions),console.log("History:",Q.history),console.groupEnd();console.groupEnd()}function k4($,X){let Q=P.stores.get(X);if(!Q)return;if($<0||$>=Q.history.length){console.warn("[STX DevTools] Invalid history index");return}let Z={};for(let Y=0;Y<=$;Y++){let J=Q.history[Y];if(J.type==="state"&&J.name!=="__init__")Z[J.name]=J.newValue;else if(J.name==="__init__")Object.assign(Z,J.newValue)}if(console.log(`%c[STX DevTools] Time traveled to index ${$}`,"color: #f59e0b;",Z),typeof window<"u"&&window.__STX_STORES__){let J=window.__STX_STORES__[X];if(J&&typeof J.$patch==="function")J.$patch(Z)}}function x4(){if(typeof MutationObserver>"u")return;new MutationObserver((X)=>{for(let Q of X)Q.removedNodes.forEach((Z)=>{if(Z instanceof HTMLElement){let Y=Z.getAttribute("data-stx-component-id");if(Y)f6(Y);Z.querySelectorAll("[data-stx-component-id]").forEach((J)=>{let G=J.getAttribute("data-stx-component-id");if(G)f6(G)})}})}).observe(document.body,{childList:!0,subtree:!0})}function S4(){if(typeof document>"u")return;if(document.getElementById("stx-devtools-panel"))return;let $=document.createElement("div");$.id="stx-devtools-panel",$.innerHTML=`
1634
1634
  <style>
1635
1635
  #stx-devtools-panel {
1636
1636
  position: fixed;
@@ -1739,7 +1739,7 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(g1.
1739
1739
  <div id="stx-devtools-content">
1740
1740
  <div id="stx-devtools-components-tab"></div>
1741
1741
  </div>
1742
- `,document.body.appendChild($);let X=$.querySelector("#stx-devtools-header"),Q=$.querySelector("#stx-devtools-toggle");X?.addEventListener("click",()=>{if($.classList.toggle("open"),Q)Q.textContent=$.classList.contains("open")?"\u25BC":"\u25B2"});let Z=$.querySelectorAll(".stx-devtools-tab");Z.forEach((Y)=>{Y.addEventListener("click",()=>{Z.forEach((J)=>J.classList.remove("active")),Y.classList.add("active"),f6(Y.getAttribute("data-tab")||"components")})}),setInterval(()=>{let Y=$.querySelector(".stx-devtools-tab.active");if(Y&&$.classList.contains("open"))f6(Y.getAttribute("data-tab")||"components")},1000)}function f6($){let X=document.getElementById("stx-devtools-content");if(!X)return;switch($){case"components":X.innerHTML=S4();break;case"stores":X.innerHTML=P4();break;case"events":X.innerHTML=b4();break}X.querySelectorAll(".stx-devtools-component").forEach((Q)=>{Q.addEventListener("click",()=>{let Z=Q.getAttribute("data-id");if(Z)Z5(Z)})})}function S4(){let X=Array.from(P.components.values()).filter((Z)=>!Z.parentId);function Q(Z,Y){let J=Z.children.map((G)=>P.components.get(G)).filter(Boolean).map((G)=>Q(G,Y+1)).join("");return`
1742
+ `,document.body.appendChild($);let X=$.querySelector("#stx-devtools-header"),Q=$.querySelector("#stx-devtools-toggle");X?.addEventListener("click",()=>{if($.classList.toggle("open"),Q)Q.textContent=$.classList.contains("open")?"\u25BC":"\u25B2"});let Z=$.querySelectorAll(".stx-devtools-tab");Z.forEach((Y)=>{Y.addEventListener("click",()=>{Z.forEach((J)=>J.classList.remove("active")),Y.classList.add("active"),h6(Y.getAttribute("data-tab")||"components")})}),setInterval(()=>{let Y=$.querySelector(".stx-devtools-tab.active");if(Y&&$.classList.contains("open"))h6(Y.getAttribute("data-tab")||"components")},1000)}function h6($){let X=document.getElementById("stx-devtools-content");if(!X)return;switch($){case"components":X.innerHTML=P4();break;case"stores":X.innerHTML=b4();break;case"events":X.innerHTML=y4();break}X.querySelectorAll(".stx-devtools-component").forEach((Q)=>{Q.addEventListener("click",()=>{let Z=Q.getAttribute("data-id");if(Z)J5(Z)})})}function P4(){let X=Array.from(P.components.values()).filter((Z)=>!Z.parentId);function Q(Z,Y){let J=Z.children.map((G)=>P.components.get(G)).filter(Boolean).map((G)=>Q(G,Y+1)).join("");return`
1743
1743
  <div class="stx-devtools-component ${P.selectedComponent===Z.id?"selected":""}"
1744
1744
  data-id="${Z.id}"
1745
1745
  style="padding-left: ${Y*16+8}px">
@@ -1747,25 +1747,25 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(g1.
1747
1747
  <span class="stx-devtools-component-id">${Z.id}</span>
1748
1748
  </div>
1749
1749
  ${J}
1750
- `}if(X.length===0)return'<div style="color: #6b7280; padding: 8px;">No components registered</div>';return X.map((Z)=>Q(Z,0)).join("")}function P4(){let $=Array.from(P.stores.values());if($.length===0)return'<div style="color: #6b7280; padding: 8px;">No stores registered</div>';return $.map((X)=>`
1750
+ `}if(X.length===0)return'<div style="color: #6b7280; padding: 8px;">No components registered</div>';return X.map((Z)=>Q(Z,0)).join("")}function b4(){let $=Array.from(P.stores.values());if($.length===0)return'<div style="color: #6b7280; padding: 8px;">No stores registered</div>';return $.map((X)=>`
1751
1751
  <div class="stx-devtools-section">
1752
1752
  <div class="stx-devtools-section-title">${X.id}</div>
1753
1753
  <div class="stx-devtools-json">${JSON.stringify(X.state,null,2)}</div>
1754
1754
  </div>
1755
- `).join("")}function b4(){let $=P.events.slice(-20).reverse();if($.length===0)return'<div style="color: #6b7280; padding: 8px;">No events recorded</div>';return $.map((X)=>`
1755
+ `).join("")}function y4(){let $=P.events.slice(-20).reverse();if($.length===0)return'<div style="color: #6b7280; padding: 8px;">No events recorded</div>';return $.map((X)=>`
1756
1756
  <div style="padding: 4px 0; border-bottom: 1px solid #374151;">
1757
1757
  <span style="color: #60a5fa;">${X.type}</span>
1758
1758
  <span style="color: #6b7280; font-size: 10px; margin-left: 8px;">
1759
1759
  ${new Date(X.timestamp).toLocaleTimeString()}
1760
1760
  </span>
1761
1761
  </div>
1762
- `).join("")}import Y5 from"fs";import V1 from"path";async function y4($){try{let Q=(await Bun.file($).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!Q)return[];let Z=Q[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(Z))!==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 F=W.match(/@default\s+(.+?)(?:\s+|$)/i);if(F)_.default=F[1].trim();let O=W.split(`
1763
- `).map((j)=>j.trim().replace(/^\*\s*/,"")).filter((j)=>!j.startsWith("@")&&j.length>0);_.description=O.join(" ").trim(),Y.push(_)}if(Y.length===0){let W=Z.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(W){let _=W[1].split(",").map((U)=>U.trim()).filter(Boolean);for(let U of _){let[z]=U.split(":").map((F)=>F.trim());if(z)Y.push({name:z})}}}return Y}catch(X){return console.error(`Error extracting props from ${$}:`,X),[]}}async function v4($){try{let X=await Bun.file($).text(),Q=X.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||X.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(Q)return Q[1].split(`
1764
- `).map((Z)=>Z.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function g4($,X=!1,Q){let Z=V1.basename($,".stx"),Y=await y4($),J=await v4($),G="";if(X&&Q)G=`<${Q}></${Q}>`;else{let W=Y.map((K)=>{if(K.type==="boolean")return`:${K.name}="true"`;return`${K.name}="value"`}).join(`
1762
+ `).join("")}import G5 from"fs";import V1 from"path";async function v4($){try{let Q=(await Bun.file($).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!Q)return[];let Z=Q[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(Z))!==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 F=W.match(/@default\s+(.+?)(?:\s+|$)/i);if(F)_.default=F[1].trim();let j=W.split(`
1763
+ `).map((O)=>O.trim().replace(/^\*\s*/,"")).filter((O)=>!O.startsWith("@")&&O.length>0);_.description=j.join(" ").trim(),Y.push(_)}if(Y.length===0){let W=Z.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(W){let _=W[1].split(",").map((U)=>U.trim()).filter(Boolean);for(let U of _){let[z]=U.split(":").map((F)=>F.trim());if(z)Y.push({name:z})}}}return Y}catch(X){return console.error(`Error extracting props from ${$}:`,X),[]}}async function g4($){try{let X=await Bun.file($).text(),Q=X.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||X.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(Q)return Q[1].split(`
1764
+ `).map((Z)=>Z.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function f4($,X=!1,Q){let Z=V1.basename($,".stx"),Y=await v4($),J=await g4($),G="";if(X&&Q)G=`<${Q}></${Q}>`;else{let W=Y.map((K)=>{if(K.type==="boolean")return`:${K.name}="true"`;return`${K.name}="value"`}).join(`
1765
1765
  `);G=`<${Z}
1766
1766
  ${W}
1767
- />`}return{name:Z,path:$,description:J,props:Y,example:G,isWebComponent:X,tag:Q}}async function p6($){try{if(!await E1($))return console.warn(`Components directory does not exist: ${$}`),[];let X=await Y5.promises.readdir($,{withFileTypes:!0}),Q=[];for(let Z of X){let Y=V1.join($,Z.name);if(Z.isDirectory()){let J=await p6(Y);Q.push(...J)}else if(Z.isFile()&&Z.name.endsWith(".stx"))Q.push(Y)}return Q}catch(X){return console.error(`Error finding component files in ${$}:`,X),[]}}async function f4($,X){try{if(!await E1($))return[];let Q=await p6($),Z=[],Y=new Map;if(X?.components?.length)for(let J of X.components)Y.set(J.file,J);for(let J of Q){let G=Y.get(J),W=!!G,K=G?.tag,_=await g4(J,W,K);Z.push(_)}return Z}catch(Q){return console.error("Error generating component docs:",Q),[]}}async function h4($){try{if(!await E1($))return[];let X=await Y5.promises.readdir($,{withFileTypes:!0}),Q=[];for(let Z of X){if(!Z.isFile()||!Z.name.endsWith(".stx"))continue;let Y=V1.join($,Z.name),J=await Bun.file(Y).text(),G=V1.basename(Y,".stx"),W=J.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||J.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//),K=W?W[1].split(`
1768
- `).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,z=new Set,F;while((F=_.exec(J))!==null)z.add(F[1]);while((F=U.exec(J))!==null)if(F[1]&&F[1]!=="slot")z.add(F[1]);let O=/@([a-z]+)(?:\s*\(|\s+|$)/g,j=new Set;while((F=O.exec(J))!==null)j.add(F[1]);Q.push({name:G,path:Y,description:K,components:[...z],directives:[...j]})}return Q}catch(X){return console.error("Error generating template docs:",X),[]}}async function d4($=[]){try{let X=[{name:"if",description:"Conditionally render content based on a condition",hasEndTag:!0,example:`@if(user.isLoggedIn)
1767
+ />`}return{name:Z,path:$,description:J,props:Y,example:G,isWebComponent:X,tag:Q}}async function c6($){try{if(!await E1($))return console.warn(`Components directory does not exist: ${$}`),[];let X=await G5.promises.readdir($,{withFileTypes:!0}),Q=[];for(let Z of X){let Y=V1.join($,Z.name);if(Z.isDirectory()){let J=await c6(Y);Q.push(...J)}else if(Z.isFile()&&Z.name.endsWith(".stx"))Q.push(Y)}return Q}catch(X){return console.error(`Error finding component files in ${$}:`,X),[]}}async function h4($,X){try{if(!await E1($))return[];let Q=await c6($),Z=[],Y=new Map;if(X?.components?.length)for(let J of X.components)Y.set(J.file,J);for(let J of Q){let G=Y.get(J),W=!!G,K=G?.tag,_=await f4(J,W,K);Z.push(_)}return Z}catch(Q){return console.error("Error generating component docs:",Q),[]}}async function d4($){try{if(!await E1($))return[];let X=await G5.promises.readdir($,{withFileTypes:!0}),Q=[];for(let Z of X){if(!Z.isFile()||!Z.name.endsWith(".stx"))continue;let Y=V1.join($,Z.name),J=await Bun.file(Y).text(),G=V1.basename(Y,".stx"),W=J.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||J.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//),K=W?W[1].split(`
1768
+ `).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,z=new Set,F;while((F=_.exec(J))!==null)z.add(F[1]);while((F=U.exec(J))!==null)if(F[1]&&F[1]!=="slot")z.add(F[1]);let j=/@([a-z]+)(?:\s*\(|\s+|$)/g,O=new Set;while((F=j.exec(J))!==null)O.add(F[1]);Q.push({name:G,path:Y,description:K,components:[...z],directives:[...O]})}return Q}catch(X){return console.error("Error generating template docs:",X),[]}}async function u4($=[]){try{let X=[{name:"if",description:"Conditionally render content based on a condition",hasEndTag:!0,example:`@if(user.isLoggedIn)
1769
1769
  <p>Welcome, {{ user.name }}!</p>
1770
1770
  @endif`},{name:"else",description:"Provides an alternative if a condition is not met",hasEndTag:!1,example:`@if(user.isLoggedIn)
1771
1771
  <p>Welcome back!</p>
@@ -1785,7 +1785,7 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(g1.
1785
1785
  <p>Page {{ page }}</p>
1786
1786
  @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
1787
1787
  {{ This will be displayed as-is }}
1788
- @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 Q of $)X.push({name:Q.name,description:Q.description||"",hasEndTag:Q.hasEndTag||!1,example:""});return X}catch(X){return console.error("Error generating directive docs:",X),[]}}function u4($=[],X=[],Q=[],Z){let Y=`# stx Documentation
1788
+ @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 Q of $)X.push({name:Q.name,description:Q.description||"",hasEndTag:Q.hasEndTag||!1,example:""});return X}catch(X){return console.error("Error generating directive docs:",X),[]}}function m4($=[],X=[],Q=[],Z){let Y=`# stx Documentation
1789
1789
 
1790
1790
  `;if(Z)Y+=`${Z}
1791
1791
 
@@ -1827,7 +1827,7 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(g1.
1827
1827
 
1828
1828
  `,Y+=`#### Example
1829
1829
 
1830
- `,Y+="```html\n",Y+=J.example,Y+="\n```\n\n"}return Y}function m4($=[],X=[],Q=[],Z){let Y=`<!DOCTYPE html>
1830
+ `,Y+="```html\n",Y+=J.example,Y+="\n```\n\n"}return Y}function p4($=[],X=[],Q=[],Z){let Y=`<!DOCTYPE html>
1831
1831
  <html lang="en">
1832
1832
  <head>
1833
1833
  <meta charset="UTF-8">
@@ -1898,23 +1898,23 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(g1.
1898
1898
  <td>@${J.name}</td>
1899
1899
  <td>${J.description||"-"}</td>
1900
1900
  <td>${J.hasEndTag?"Yes":"No"}</td>
1901
- </tr>`;Y+="</tbody></table>";for(let J of Q)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 p4($=[],X=[],Q=[],Z){return JSON.stringify({components:$,templates:X,directives:Q,extraContent:Z||""},null,2)}async function c4($){try{let{componentsDir:X,templatesDir:Q,webComponentsConfig:Z,customDirectives:Y,config:J}=$;if(!J.enabled)return!1;let G=J.outputDir||"docs";if(await Y5.promises.mkdir(G,{recursive:!0}),console.log("Generating documentation..."),X)console.log(`Components directory: ${X}`);if(Q)console.log(`Templates directory: ${Q}`);console.log(`Output directory: ${G}`);let W=[];if(J.components!==!1&&X)console.log("Generating component documentation..."),W=await f4(X,Z),console.log(`Found ${W.length} components`);let K=[];if(J.templates!==!1&&Q)console.log("Generating template documentation..."),K=await h4(Q),console.log(`Found ${K.length} templates`);let _=[];if(J.directives!==!1)console.log("Generating directive documentation..."),_=await d4(Y),console.log(`Found ${_.length} directives`);let U=J.format||"markdown",z=J.extraContent,F="",O="";switch(U){case"markdown":F=u4(W,K,_,z),O="md";break;case"html":F=m4(W,K,_,z),O="html";break;case"json":F=p4(W,K,_,z),O="json";break;default:throw Error(`Unsupported documentation format: ${U}`)}let j=V1.join(G,`stx-docs.${O}`);return await Bun.write(j,F),console.log(`Documentation generated: ${j}`),!0}catch(X){return console.error("Error generating documentation:",X),!1}}async function uW($){let X={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Q=$.componentsDir||M0.componentsDir,Z=$.templatesDir||".";return c4({componentsDir:Q,templatesDir:Z,webComponentsConfig:M0.webComponents,customDirectives:M0.customDirectives,config:X})}import Z1 from"process";function I1(){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 lW(){let $=I1();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function iW(){return I1().platform!=="unknown"}function l4($){return{get(X){if($&&X in $){let Q=$[X];return typeof Q==="string"?Q: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 Q=this.get(X);if(Q===void 0)throw Error(`Environment variable "${X}" is not set`);return Q},has(X){return this.get(X)!==void 0},all(){let X={};if($){for(let[Q,Z]of Object.entries($))if(typeof Z==="string")X[Q]=Z}if(typeof globalThis<"u"&&"Deno"in globalThis){let Q=globalThis.Deno.env.toObject();Object.assign(X,Q)}if(Z1.env){for(let[Q,Z]of Object.entries(Z1.env))if(Z!==void 0)X[Q]=Z}return X}}}function i4($){let X=I1();if(X.platform==="cloudflare"&&$)return $;if(X.platform==="deno"&&"Deno"in globalThis)return a4();if(X.platform==="node"||X.platform==="bun")return r4();return}function a4(){let $=null,X=async()=>{if(!$)$=await globalThis.Deno.openKv();return $};return{async get(Q){return(await(await X()).get(["stx",Q])).value},async getWithMetadata(Q){let Z=await X(),Y=await Z.get(["stx",Q]),J=await Z.get(["stx-meta",Q]);return{value:Y.value,metadata:J.value}},async put(Q,Z,Y){let J=await X(),G=Y?.expirationTtl?Y.expirationTtl*1000:void 0;if(await J.set(["stx",Q],Z,G?{expireIn:G}:void 0),Y?.metadata)await J.set(["stx-meta",Q],Y.metadata,G?{expireIn:G}:void 0)},async delete(Q){let Z=await X();await Z.delete(["stx",Q]),await Z.delete(["stx-meta",Q])},async list(Q){let Z=await X(),Y=Q?.prefix?["stx",Q.prefix]:["stx"],J=Z.list({prefix:Y,limit:Q?.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 r4(){let $=new Map,X=()=>{let Q=Date.now();for(let[Z,Y]of $.entries())if(Y.expiration&&Y.expiration<Q)$.delete(Z)};return{async get(Q){X();let Z=$.get(Q);if(!Z)return null;if(Z.expiration&&Z.expiration<Date.now())return $.delete(Q),null;return Z.value},async getWithMetadata(Q){X();let Z=$.get(Q);if(!Z)return{value:null,metadata:null};if(Z.expiration&&Z.expiration<Date.now())return $.delete(Q),{value:null,metadata:null};return{value:Z.value,metadata:Z.metadata||null}},async put(Q,Z,Y){let J=Y?.expiration?Y.expiration*1000:Y?.expirationTtl?Date.now()+Y.expirationTtl*1000:void 0;$.set(Q,{value:Z,metadata:Y?.metadata,expiration:J})},async delete(Q){$.delete(Q)},async list(Q){X();let Z=[];for(let[Y,J]of $.entries()){if(Q?.prefix&&!Y.startsWith(Q.prefix))continue;if(Z.push({name:Y,expiration:J.expiration,metadata:J.metadata}),Q?.limit&&Z.length>=Q.limit)break}return{keys:Z,list_complete:!0}}}}function s4(){let $=I1();if($.platform==="cloudflare"&&"caches"in globalThis)return n4();if($.supportsStreaming)return o4();return}function n4(){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 o4(){let $=new Map,X=60000;return{async match(Q){let Z=Q.url,Y=$.get(Z);if(!Y)return;if(Date.now()>Y.expiration){$.delete(Z);return}return Y.response.clone()},async put(Q,Z){let Y=Q.url,J=Z.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:Z.clone(),expiration:Date.now()+G})},async delete(Q){return $.delete(Q.url)}}}function t4(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function e4($,X){if(X.platform==="cloudflare"){let Q=$.cf;if(Q)return{city:Q.city,country:Q.country,countryCode:Q.country,region:Q.region,latitude:Q.latitude?Number.parseFloat(Q.latitude):void 0,longitude:Q.longitude?Number.parseFloat(Q.longitude):void 0,timezone:Q.timezone}}if(X.platform==="vercel"){let Q={},Z=$.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(Z)Q.city=decodeURIComponent(Z);if(Y)Q.countryCode=Y;if(J)Q.region=J;if(G)Q.latitude=Number.parseFloat(G);if(W)Q.longitude=Number.parseFloat(W);return Object.keys(Q).length>0?Q:void 0}if(X.platform==="netlify"){let Q={},Z=$.headers.get("x-nf-geo-city"),Y=$.headers.get("x-nf-geo-country");if(Z)Q.city=Z;if(Y)Q.countryCode=Y;return Object.keys(Q).length>0?Q:void 0}return}function J5($,X,Q){let Z=new Headers($.headers);if(X.origins==="*")Z.set("Access-Control-Allow-Origin","*");else if(X.origins&&Q&&X.origins.includes(Q))Z.set("Access-Control-Allow-Origin",Q),Z.set("Vary","Origin");if(X.methods)Z.set("Access-Control-Allow-Methods",X.methods.join(", "));if(X.headers)Z.set("Access-Control-Allow-Headers",X.headers.join(", "));if(X.exposeHeaders)Z.set("Access-Control-Expose-Headers",X.exposeHeaders.join(", "));if(X.credentials)Z.set("Access-Control-Allow-Credentials","true");if(X.maxAge)Z.set("Access-Control-Max-Age",String(X.maxAge));return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z})}function F$($){let X=I1();return async(Q,Z)=>{let Y=performance.now(),J=t4(),G={runtime:X,platform:Z||{},requestId:J,geo:e4(Q,X),timing:{start:Y,getElapsed:()=>performance.now()-Y},kv:i4(Z?.KV),cache:s4(),env:l4(Z?.env)};try{if(Q.method==="OPTIONS"&&$.cors){let K=new Response(null,{status:204});return K=J5(K,$.cors,Q.headers.get("Origin")||void 0),K}if($.cache?.enabled&&Q.method==="GET"&&G.cache){if(c6(Q,$.cache)){let _=await G.cache.match(Q);if(_){let U=new Response(_.body,_);return U.headers.set("X-Cache","HIT"),U.headers.set("X-Request-Id",J),$.cors?J5(U,$.cors,Q.headers.get("Origin")||void 0):U}}}let W;if($.middleware&&$.middleware.length>0)W=await $X(Q,G,$.middleware,async()=>{let K=await $.render(Q,G);return typeof K==="string"?new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}}):K});else{let K=await $.render(Q,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&&Q.method==="GET"&&G.cache){if(c6(Q,$.cache)&&W.status===200){let _=$.cache.ttl||60,U=W.clone();U.headers.set("Cache-Control",`public, max-age=${_}`),await G.cache.put(Q,U),W.headers.set("X-Cache","MISS")}}if($.cors)W=J5(W,$.cors,Q.headers.get("Origin")||void 0);return W}catch(W){let K=W instanceof Error?W:Error(String(W));if($.onError)return $.onError(K,Q);return new Response(`Internal Server Error: ${K.message}`,{status:500,headers:{"Content-Type":"text/plain","X-Request-Id":J}})}}}function c6($,X){let Z=new URL($.url).pathname;if(X.excludePaths){for(let Y of X.excludePaths)if(Y.test(Z))return!1}if(X.includePaths){for(let Y of X.includePaths)if(Y.test(Z))return!0;return!1}return!0}async function $X($,X,Q,Z){let Y=0,J=async()=>{if(Y>=Q.length)return Z();let G=Q[Y];return Y++,G($,X,J)};return J()}function aW($,X){let Q=new Headers(X?.headers);return Q.set("Content-Type","text/html; charset=utf-8"),Q.set("Transfer-Encoding","chunked"),new Response($,{...X,headers:Q})}function rW(){let $=new TextEncoder;return new TransformStream({transform(X,Q){Q.enqueue($.encode(X))}})}function sW($){let X=new TextEncoder;return new ReadableStream({async start(Q){for await(let Z of $)Q.enqueue(X.encode(Z));Q.close()}})}function nW($){let X=F$($);return{async fetch(Q,Z,Y){return X(Q,{env:Z,ctx:Y,KV:Z.KV})}}}function oW($){let X=F$($);return(Q)=>X(Q,{})}function tW($){let X=F$($);return(Q)=>X(Q,{})}function eW($){let X=F$($);return(Q,Z)=>{return X(Q,{netlifyContext:Z})}}function $2($){let X=$.headers.get("Cookie");if(!X)return{};let Q={};for(let Z of X.split(";")){let[Y,J]=Z.split("=").map((G)=>G.trim());if(Y&&J)Q[Y]=decodeURIComponent(J)}return Q}function X2($,X,Q){return G5($,X,Q)}function Q2($,X){let Q=new Headers(X?.headers);return Q.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify($),{...X,headers:Q})}function Z2($,X=302){return new Response(null,{status:X,headers:{Location:$}})}function Y2($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var i6={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function XX($,X={}){let Q={...i6,...X};if($.trim()==="")return`
1902
- `;let Z=$;if(Q.trimTrailingWhitespace)Z=Z.replace(/[ \t]+$/gm,"");if(Z=ZX(Z,Q),Z=WX(Z,Q),Z=YX(Z,Q),Q.trimTrailingWhitespace)Z=Z.replace(/[ \t]+$/gm,""),Z=Z.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(Z=Z.replace(/\r\n/g,`
1901
+ </tr>`;Y+="</tbody></table>";for(let J of Q)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 c4($=[],X=[],Q=[],Z){return JSON.stringify({components:$,templates:X,directives:Q,extraContent:Z||""},null,2)}async function l4($){try{let{componentsDir:X,templatesDir:Q,webComponentsConfig:Z,customDirectives:Y,config:J}=$;if(!J.enabled)return!1;let G=J.outputDir||"docs";if(await G5.promises.mkdir(G,{recursive:!0}),console.log("Generating documentation..."),X)console.log(`Components directory: ${X}`);if(Q)console.log(`Templates directory: ${Q}`);console.log(`Output directory: ${G}`);let W=[];if(J.components!==!1&&X)console.log("Generating component documentation..."),W=await h4(X,Z),console.log(`Found ${W.length} components`);let K=[];if(J.templates!==!1&&Q)console.log("Generating template documentation..."),K=await d4(Q),console.log(`Found ${K.length} templates`);let _=[];if(J.directives!==!1)console.log("Generating directive documentation..."),_=await u4(Y),console.log(`Found ${_.length} directives`);let U=J.format||"markdown",z=J.extraContent,F="",j="";switch(U){case"markdown":F=m4(W,K,_,z),j="md";break;case"html":F=p4(W,K,_,z),j="html";break;case"json":F=c4(W,K,_,z),j="json";break;default:throw Error(`Unsupported documentation format: ${U}`)}let O=V1.join(G,`stx-docs.${j}`);return await Bun.write(O,F),console.log(`Documentation generated: ${O}`),!0}catch(X){return console.error("Error generating documentation:",X),!1}}async function pW($){let X={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Q=$.componentsDir||M0.componentsDir,Z=$.templatesDir||".";return l4({componentsDir:Q,templatesDir:Z,webComponentsConfig:M0.webComponents,customDirectives:M0.customDirectives,config:X})}import Y1 from"process";function I1(){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(Y1.versions?.node)return{platform:"node",version:Y1.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 $=I1();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function rW(){return I1().platform!=="unknown"}function i4($){return{get(X){if($&&X in $){let Q=$[X];return typeof Q==="string"?Q:void 0}if(typeof globalThis<"u"&&"Deno"in globalThis)return globalThis.Deno.env.get(X);if(Y1.env)return Y1.env[X];return},getOrThrow(X){let Q=this.get(X);if(Q===void 0)throw Error(`Environment variable "${X}" is not set`);return Q},has(X){return this.get(X)!==void 0},all(){let X={};if($){for(let[Q,Z]of Object.entries($))if(typeof Z==="string")X[Q]=Z}if(typeof globalThis<"u"&&"Deno"in globalThis){let Q=globalThis.Deno.env.toObject();Object.assign(X,Q)}if(Y1.env){for(let[Q,Z]of Object.entries(Y1.env))if(Z!==void 0)X[Q]=Z}return X}}}function a4($){let X=I1();if(X.platform==="cloudflare"&&$)return $;if(X.platform==="deno"&&"Deno"in globalThis)return r4();if(X.platform==="node"||X.platform==="bun")return s4();return}function r4(){let $=null,X=async()=>{if(!$)$=await globalThis.Deno.openKv();return $};return{async get(Q){return(await(await X()).get(["stx",Q])).value},async getWithMetadata(Q){let Z=await X(),Y=await Z.get(["stx",Q]),J=await Z.get(["stx-meta",Q]);return{value:Y.value,metadata:J.value}},async put(Q,Z,Y){let J=await X(),G=Y?.expirationTtl?Y.expirationTtl*1000:void 0;if(await J.set(["stx",Q],Z,G?{expireIn:G}:void 0),Y?.metadata)await J.set(["stx-meta",Q],Y.metadata,G?{expireIn:G}:void 0)},async delete(Q){let Z=await X();await Z.delete(["stx",Q]),await Z.delete(["stx-meta",Q])},async list(Q){let Z=await X(),Y=Q?.prefix?["stx",Q.prefix]:["stx"],J=Z.list({prefix:Y,limit:Q?.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 s4(){let $=new Map,X=()=>{let Q=Date.now();for(let[Z,Y]of $.entries())if(Y.expiration&&Y.expiration<Q)$.delete(Z)};return{async get(Q){X();let Z=$.get(Q);if(!Z)return null;if(Z.expiration&&Z.expiration<Date.now())return $.delete(Q),null;return Z.value},async getWithMetadata(Q){X();let Z=$.get(Q);if(!Z)return{value:null,metadata:null};if(Z.expiration&&Z.expiration<Date.now())return $.delete(Q),{value:null,metadata:null};return{value:Z.value,metadata:Z.metadata||null}},async put(Q,Z,Y){let J=Y?.expiration?Y.expiration*1000:Y?.expirationTtl?Date.now()+Y.expirationTtl*1000:void 0;$.set(Q,{value:Z,metadata:Y?.metadata,expiration:J})},async delete(Q){$.delete(Q)},async list(Q){X();let Z=[];for(let[Y,J]of $.entries()){if(Q?.prefix&&!Y.startsWith(Q.prefix))continue;if(Z.push({name:Y,expiration:J.expiration,metadata:J.metadata}),Q?.limit&&Z.length>=Q.limit)break}return{keys:Z,list_complete:!0}}}}function n4(){let $=I1();if($.platform==="cloudflare"&&"caches"in globalThis)return o4();if($.supportsStreaming)return t4();return}function o4(){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 t4(){let $=new Map,X=60000;return{async match(Q){let Z=Q.url,Y=$.get(Z);if(!Y)return;if(Date.now()>Y.expiration){$.delete(Z);return}return Y.response.clone()},async put(Q,Z){let Y=Q.url,J=Z.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:Z.clone(),expiration:Date.now()+G})},async delete(Q){return $.delete(Q.url)}}}function e4(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function $X($,X){if(X.platform==="cloudflare"){let Q=$.cf;if(Q)return{city:Q.city,country:Q.country,countryCode:Q.country,region:Q.region,latitude:Q.latitude?Number.parseFloat(Q.latitude):void 0,longitude:Q.longitude?Number.parseFloat(Q.longitude):void 0,timezone:Q.timezone}}if(X.platform==="vercel"){let Q={},Z=$.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(Z)Q.city=decodeURIComponent(Z);if(Y)Q.countryCode=Y;if(J)Q.region=J;if(G)Q.latitude=Number.parseFloat(G);if(W)Q.longitude=Number.parseFloat(W);return Object.keys(Q).length>0?Q:void 0}if(X.platform==="netlify"){let Q={},Z=$.headers.get("x-nf-geo-city"),Y=$.headers.get("x-nf-geo-country");if(Z)Q.city=Z;if(Y)Q.countryCode=Y;return Object.keys(Q).length>0?Q:void 0}return}function W5($,X,Q){let Z=new Headers($.headers);if(X.origins==="*")Z.set("Access-Control-Allow-Origin","*");else if(X.origins&&Q&&X.origins.includes(Q))Z.set("Access-Control-Allow-Origin",Q),Z.set("Vary","Origin");if(X.methods)Z.set("Access-Control-Allow-Methods",X.methods.join(", "));if(X.headers)Z.set("Access-Control-Allow-Headers",X.headers.join(", "));if(X.exposeHeaders)Z.set("Access-Control-Expose-Headers",X.exposeHeaders.join(", "));if(X.credentials)Z.set("Access-Control-Allow-Credentials","true");if(X.maxAge)Z.set("Access-Control-Max-Age",String(X.maxAge));return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z})}function F$($){let X=I1();return async(Q,Z)=>{let Y=performance.now(),J=e4(),G={runtime:X,platform:Z||{},requestId:J,geo:$X(Q,X),timing:{start:Y,getElapsed:()=>performance.now()-Y},kv:a4(Z?.KV),cache:n4(),env:i4(Z?.env)};try{if(Q.method==="OPTIONS"&&$.cors){let K=new Response(null,{status:204});return K=W5(K,$.cors,Q.headers.get("Origin")||void 0),K}if($.cache?.enabled&&Q.method==="GET"&&G.cache){if(l6(Q,$.cache)){let _=await G.cache.match(Q);if(_){let U=new Response(_.body,_);return U.headers.set("X-Cache","HIT"),U.headers.set("X-Request-Id",J),$.cors?W5(U,$.cors,Q.headers.get("Origin")||void 0):U}}}let W;if($.middleware&&$.middleware.length>0)W=await XX(Q,G,$.middleware,async()=>{let K=await $.render(Q,G);return typeof K==="string"?new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}}):K});else{let K=await $.render(Q,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&&Q.method==="GET"&&G.cache){if(l6(Q,$.cache)&&W.status===200){let _=$.cache.ttl||60,U=W.clone();U.headers.set("Cache-Control",`public, max-age=${_}`),await G.cache.put(Q,U),W.headers.set("X-Cache","MISS")}}if($.cors)W=W5(W,$.cors,Q.headers.get("Origin")||void 0);return W}catch(W){let K=W instanceof Error?W:Error(String(W));if($.onError)return $.onError(K,Q);return new Response(`Internal Server Error: ${K.message}`,{status:500,headers:{"Content-Type":"text/plain","X-Request-Id":J}})}}}function l6($,X){let Z=new URL($.url).pathname;if(X.excludePaths){for(let Y of X.excludePaths)if(Y.test(Z))return!1}if(X.includePaths){for(let Y of X.includePaths)if(Y.test(Z))return!0;return!1}return!0}async function XX($,X,Q,Z){let Y=0,J=async()=>{if(Y>=Q.length)return Z();let G=Q[Y];return Y++,G($,X,J)};return J()}function sW($,X){let Q=new Headers(X?.headers);return Q.set("Content-Type","text/html; charset=utf-8"),Q.set("Transfer-Encoding","chunked"),new Response($,{...X,headers:Q})}function nW(){let $=new TextEncoder;return new TransformStream({transform(X,Q){Q.enqueue($.encode(X))}})}function oW($){let X=new TextEncoder;return new ReadableStream({async start(Q){for await(let Z of $)Q.enqueue(X.encode(Z));Q.close()}})}function tW($){let X=F$($);return{async fetch(Q,Z,Y){return X(Q,{env:Z,ctx:Y,KV:Z.KV})}}}function eW($){let X=F$($);return(Q)=>X(Q,{})}function $2($){let X=F$($);return(Q)=>X(Q,{})}function X2($){let X=F$($);return(Q,Z)=>{return X(Q,{netlifyContext:Z})}}function Q2($){let X=$.headers.get("Cookie");if(!X)return{};let Q={};for(let Z of X.split(";")){let[Y,J]=Z.split("=").map((G)=>G.trim());if(Y&&J)Q[Y]=decodeURIComponent(J)}return Q}function Z2($,X,Q){return K5($,X,Q)}function Y2($,X){let Q=new Headers(X?.headers);return Q.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify($),{...X,headers:Q})}function J2($,X=302){return new Response(null,{status:X,headers:{Location:$}})}function G2($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var a6={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function QX($,X={}){let Q={...a6,...X};if($.trim()==="")return`
1902
+ `;let Z=$;if(Q.trimTrailingWhitespace)Z=Z.replace(/[ \t]+$/gm,"");if(Z=YX(Z,Q),Z=KX(Z,Q),Z=JX(Z,Q),Q.trimTrailingWhitespace)Z=Z.replace(/[ \t]+$/gm,""),Z=Z.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(Z=Z.replace(/\r\n/g,`
1903
1903
  `).replace(/\r/g,`
1904
1904
  `),!Z.endsWith(`
1905
1905
  `))Z+=`
1906
- `;return Z}function G2($,X={}){let Q={...i6,...X};if($.trim()==="")return`
1906
+ `;return Z}function K2($,X={}){let Q={...a6,...X};if($.trim()==="")return`
1907
1907
  `;let Z=$;if(Z=Z.replace(/^( *)```(html|stx)\n([\s\S]*?)^( *)```/gm,(Y,J,G,W,K)=>{let _=W.split(`
1908
1908
  `),U=_.filter((L)=>L.trim().length>0);if(U.length===0)return Y;let z=Math.min(...U.map((L)=>{let H=L.match(/^( *)/);return H?H[1].length:0})),F=_.map((L)=>{if(L.trim().length===0)return"";return L.substring(z)}).join(`
1909
- `),j=XX(F,Q).trimEnd().split(`
1909
+ `),O=QX(F,Q).trimEnd().split(`
1910
1910
  `).map((L)=>{if(L.trim().length===0)return"";return J+L}).join(`
1911
1911
  `);return`${J}\`\`\`${G}
1912
- ${j}
1912
+ ${O}
1913
1913
  ${J}\`\`\``}),Q.trimTrailingWhitespace)Z=Z.replace(/[ \t]+$/gm,"");if(Z=Z.replace(/\r\n/g,`
1914
1914
  `).replace(/\r/g,`
1915
1915
  `),!Z.endsWith(`
1916
1916
  `))Z+=`
1917
- `;return Z}function QX($){let X=$,Q=[],Z="__PROTECTED_BLOCK_";return X=X.replace(/(<(?:pre|code|textarea)[^>]*>)([\s\S]*?)(<\/(?:pre|code|textarea)>)/gi,(Y)=>{let J=Q.length;return Q.push(Y),`${Z}${J}__`}),X=X.replace(/(@(?:if|foreach|for|while|unless|section|component|slot|push|prepend|error|auth|guest|can)(?:\((?:[^()'"]|'[^']*'|"[^"]*"|\((?:[^()'"]|'[^']*'|"[^"]*")*\))*\))?)/g,`
1917
+ `;return Z}function ZX($){let X=$,Q=[],Z="__PROTECTED_BLOCK_";return X=X.replace(/(<(?:pre|code|textarea)[^>]*>)([\s\S]*?)(<\/(?:pre|code|textarea)>)/gi,(Y)=>{let J=Q.length;return Q.push(Y),`${Z}${J}__`}),X=X.replace(/(@(?:if|foreach|for|while|unless|section|component|slot|push|prepend|error|auth|guest|can)(?:\((?:[^()'"]|'[^']*'|"[^"]*"|\((?:[^()'"]|'[^']*'|"[^"]*")*\))*\))?)/g,`
1918
1918
  $1
1919
1919
  `),X=X.replace(/(@end\w+)/g,`
1920
1920
  $1
@@ -1928,10 +1928,10 @@ ${G}`}),X=X.replace(/(<\/[^>]+>)(?=<|$)/g,(Y,J,G,W)=>{let K=W.substring(Math.max
1928
1928
  `}),X=X.replace(new RegExp(`${Z}(\\d+)__`,"g"),(Y,J)=>{return Q[Number.parseInt(J,10)]}),X=X.replace(/\n{2,}/g,`
1929
1929
  `),X=X.split(`
1930
1930
  `).map((Y)=>Y.trim()).join(`
1931
- `),X=X.replace(/^\n+/,"").replace(/\n+$/,""),X}function ZX($,X){let Z=QX($).split(`
1932
- `),Y=[],J=0,G=!1,W=X.useTabs?"\t":" ".repeat(X.indentSize);for(let K=0;K<Z.length;K++){let _=Z[K],U=_.trim();if(U===""){Y.push("");continue}let z=U.match(/<script\b/i),F=U.match(/<\/script>/i);if(G&&!F){Y.push(_);continue}let O=U===">";if(l6(U)&&!U.startsWith("<")&&!U.startsWith("@")){Y.push(W.repeat(J)+U);continue}let j=U.startsWith("@end"),L=U.startsWith("@else")||U.startsWith("@elseif"),H=U.startsWith("@")&&GX(U),A=U.startsWith("<!DOCTYPE")||U.startsWith("<!doctype"),q=U.startsWith("<!--"),M=U.startsWith("</"),V=U.startsWith("<")&&!M&&!q&&!A,N=U.includes("/>")||JX(U),R=l6(U);if(M||j)J=Math.max(0,J-1);let w=L?Math.max(0,J-1):J;if(O)Y.push(_);else Y.push(W.repeat(w)+U);if(V&&!N&&!R&&!O||H)J++;if(z)G=!0;if(F)G=!1}return Y.join(`
1933
- `)}function YX($,X){if($=$.replace(/@(if|elseif|foreach|for|while)\s*\(\s*([^)]+)\s*\)/g,(Q,Z,Y)=>{let J=Y.trim().replace(/\s+/g," ");return`@${Z}(${J})`}),$=$.replace(/@(csrf|method)\s*\(\s*([^)]*)\s*\)/g,(Q,Z,Y)=>{if(Y.trim()==="")return`@${Z}`;return`@${Z}(${Y.trim()})`}),X.normalizeWhitespace)$=$.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Q,Z)=>{return`{{ ${Z.trim()} }}`}),$=$.replace(/\{!!\s*([^!]+)\s*!!\}/g,(Q,Z)=>{return`{!! ${Z.trim()} !!}`});return $}function JX($){let X=["br","hr","img","input","meta","link","area","base","col","embed","source","track","wbr"];if($.includes("/>"))return!0;let Q=$.match(/<(\w+)/);if(Q){let Z=Q[1];return X.includes(Z.toLowerCase())}return!1}function l6($){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test($)}function GX($){let X=["if","unless","foreach","for","while","section","push","component","slot","markdown","wrap","error"];for(let Q of X)if($.startsWith(`@${Q}`))return!$.includes(`@end${Q}`);return!1}function WX($,X){if(!X.sortAttributes)return $;return $.replace(/<(\w+)([^>]*)>/g,(Q,Z,Y)=>{if(!Y.trim())return Q;if(Y.includes("<")||Y.includes(`
1934
- `)||Y.includes("@"))return Q;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`<${Z}${K?` ${K}`:""}>`})}import a6 from"fs";import W5 from"path";var U2={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 B2($="index.stx",X={}){try{let Q=X.force||!1,Z=W5.resolve(process.cwd(),$);if(await Bun.file(Z).exists()){if(!Q)throw Error(`File ${$} already exists. Use --force to overwrite.`);console.warn(`File ${$} already exists. Overwriting...`)}let Y=W5.dirname(Z);if(!a6.existsSync(Y))a6.mkdirSync(Y,{recursive:!0});let J;if(X.template){let G=W5.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=r6(X.preset),console.warn(`Using '${X.preset}' preset template`);else J=r6("basic");return await Bun.write(Z,J),console.warn(`Created new stx file: ${$}`),!0}catch(Q){return console.error(`Error creating file: ${Q instanceof Error?Q.message:String(Q)}`),!1}}function r6($){switch($){case"basic":return s6();case"component":return KX();case"layout":return _X();case"blog":return UX();case"api":return BX();case"app":return LX();default:return s6()}}function s6(){return`<script>
1931
+ `),X=X.replace(/^\n+/,"").replace(/\n+$/,""),X}function YX($,X){let Z=ZX($).split(`
1932
+ `),Y=[],J=0,G=!1,W=X.useTabs?"\t":" ".repeat(X.indentSize);for(let K=0;K<Z.length;K++){let _=Z[K],U=_.trim();if(U===""){Y.push("");continue}let z=U.match(/<script\b/i),F=U.match(/<\/script>/i);if(G&&!F){Y.push(_);continue}let j=U===">";if(i6(U)&&!U.startsWith("<")&&!U.startsWith("@")){Y.push(W.repeat(J)+U);continue}let O=U.startsWith("@end"),L=U.startsWith("@else")||U.startsWith("@elseif"),H=U.startsWith("@")&&WX(U),q=U.startsWith("<!DOCTYPE")||U.startsWith("<!doctype"),A=U.startsWith("<!--"),N=U.startsWith("</"),V=U.startsWith("<")&&!N&&!A&&!q,M=U.includes("/>")||GX(U),R=i6(U);if(N||O)J=Math.max(0,J-1);let w=L?Math.max(0,J-1):J;if(j)Y.push(_);else Y.push(W.repeat(w)+U);if(V&&!M&&!R&&!j||H)J++;if(z)G=!0;if(F)G=!1}return Y.join(`
1933
+ `)}function JX($,X){if($=$.replace(/@(if|elseif|foreach|for|while)\s*\(\s*([^)]+)\s*\)/g,(Q,Z,Y)=>{let J=Y.trim().replace(/\s+/g," ");return`@${Z}(${J})`}),$=$.replace(/@(csrf|method)\s*\(\s*([^)]*)\s*\)/g,(Q,Z,Y)=>{if(Y.trim()==="")return`@${Z}`;return`@${Z}(${Y.trim()})`}),X.normalizeWhitespace)$=$.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Q,Z)=>{return`{{ ${Z.trim()} }}`}),$=$.replace(/\{!!\s*([^!]+)\s*!!\}/g,(Q,Z)=>{return`{!! ${Z.trim()} !!}`});return $}function GX($){let X=["br","hr","img","input","meta","link","area","base","col","embed","source","track","wbr"];if($.includes("/>"))return!0;let Q=$.match(/<(\w+)/);if(Q){let Z=Q[1];return X.includes(Z.toLowerCase())}return!1}function i6($){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test($)}function WX($){let X=["if","unless","foreach","for","while","section","push","component","slot","markdown","wrap","error"];for(let Q of X)if($.startsWith(`@${Q}`))return!$.includes(`@end${Q}`);return!1}function KX($,X){if(!X.sortAttributes)return $;return $.replace(/<(\w+)([^>]*)>/g,(Q,Z,Y)=>{if(!Y.trim())return Q;if(Y.includes("<")||Y.includes(`
1934
+ `)||Y.includes("@"))return Q;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`<${Z}${K?` ${K}`:""}>`})}import r6 from"fs";import _5 from"path";var L2={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 F2($="index.stx",X={}){try{let Q=X.force||!1,Z=_5.resolve(process.cwd(),$);if(await Bun.file(Z).exists()){if(!Q)throw Error(`File ${$} already exists. Use --force to overwrite.`);console.warn(`File ${$} already exists. Overwriting...`)}let Y=_5.dirname(Z);if(!r6.existsSync(Y))r6.mkdirSync(Y,{recursive:!0});let J;if(X.template){let G=_5.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=s6(X.preset),console.warn(`Using '${X.preset}' preset template`);else J=s6("basic");return await Bun.write(Z,J),console.warn(`Created new stx file: ${$}`),!0}catch(Q){return console.error(`Error creating file: ${Q instanceof Error?Q.message:String(Q)}`),!1}}function s6($){switch($){case"basic":return n6();case"component":return _X();case"layout":return UX();case"blog":return BX();case"api":return LX();case"app":return FX();default:return n6()}}function n6(){return`<script>
1935
1935
  const title = "My stx Page"
1936
1936
  const description = "A page built with stx"
1937
1937
  const features = [
@@ -1956,7 +1956,7 @@ const features = [
1956
1956
  </div>
1957
1957
  @endforeach
1958
1958
  </main>
1959
- @endsection`}function KX(){return`{{-- Component: Card --}}
1959
+ @endsection`}function _X(){return`{{-- Component: Card --}}
1960
1960
  {{-- Props: title, variant, collapsible --}}
1961
1961
  {{-- Usage: @component('card', { title: "Hello", variant: "primary", collapsible: true }) Content @endcomponent --}}
1962
1962
  <script>
@@ -2001,7 +2001,7 @@ const features = [
2001
2001
  .card.collapsed .card__toggle { transform: rotate(-90deg); }
2002
2002
  .card__body { padding: 1rem; }
2003
2003
  .card.collapsed .card__body { display: none; }
2004
- </style>`}function _X(){return`<!DOCTYPE html>
2004
+ </style>`}function UX(){return`<!DOCTYPE html>
2005
2005
  <html lang="en">
2006
2006
  <head>
2007
2007
  <meta charset="UTF-8">
@@ -2052,7 +2052,7 @@ const features = [
2052
2052
 
2053
2053
  @yield('scripts')
2054
2054
  </body>
2055
- </html>`}function UX(){return`<script>
2055
+ </html>`}function BX(){return`<script>
2056
2056
  // Article metadata
2057
2057
  const title = "My Blog Post"
2058
2058
  const author = "Your Name"
@@ -2097,7 +2097,7 @@ const features = [
2097
2097
  <p>Wrap up your thoughts here.</p>
2098
2098
  </div>
2099
2099
  </article>
2100
- @endsection`}function BX(){return`<script>
2100
+ @endsection`}function LX(){return`<script>
2101
2101
  // API endpoint configuration
2102
2102
  const endpoint = "/api/data"
2103
2103
  const method = "GET"
@@ -2132,7 +2132,7 @@ const features = [
2132
2132
  }
2133
2133
  @else
2134
2134
  {{ JSON.stringify(data, null, 2) }}
2135
- @endif`}function LX(){return`<!DOCTYPE html>
2135
+ @endif`}function FX(){return`<!DOCTYPE html>
2136
2136
  <html lang="en">
2137
2137
  <head>
2138
2138
  <meta charset="UTF-8">
@@ -2357,8 +2357,8 @@ const features = [
2357
2357
  })();
2358
2358
  </script>
2359
2359
  </body>
2360
- </html>`}import{createHash as FX}from"crypto";import{existsSync as R1,mkdirSync as zX,readFileSync as K5,writeFileSync as jX,readdirSync as OX,statSync as HX}from"fs";import{basename as D1,dirname as w0,extname as w1,join as E0,relative as n6}from"path";import{gzipSync as AX}from"zlib";var o6={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 _5{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...o6,...$}}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[Q,Z]of $)await this.buildEntry(Q,Z);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((Q,Z)=>{let Y=D1(Q,w1(Q));$.set(Y,Q)});else if(typeof X==="object")Object.entries(X).forEach(([Q,Z])=>{$.set(Q,Z)});return $}async buildEntry($,X){if(!await Bun.file(X).exists()){this.errors.push(`Entry point not found: ${X}`);return}let Q=await Bun.file(X).text(),Z=w1(X),Y=Q,J="js";if(Z===".stx"||Z===".html")J="html",Y=await this.processTemplate(Q,X);else if(Z===".css")J="css",Y=await this.processCss(Q,X);else if(Z===".js"||Z===".ts")J="js",Y=await this.processScript(Q,X);Y=await this.runPluginTransform(Y,X);let G=this.generateHash(Y),W=this.getOutputName($,J,G),K=E0(this.config.outDir,W);this.ensureDir(w0(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 E0(w0($),"..",X);return E0(w0($),X)}async processTemplate($,X){let Q=$,Z=[],Y=[];if(Q=Q.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(R1(_)){let U=K5(_,"utf-8");Z.push(`// Source: ${K[1]}
2361
- ${U}`)}else this.warnings.push(`External script not found: ${_}`)}return""}),Q=Q.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(R1(_)){let U=K5(_,"utf-8");Y.push(`/* Source: ${K[1]} */
2360
+ </html>`}import{createHash as zX}from"crypto";import{existsSync as R1,mkdirSync as jX,readFileSync as U5,writeFileSync as OX,readdirSync as HX,statSync as AX}from"fs";import{basename as D1,dirname as w0,extname as w1,join as E0,relative as o6}from"path";import{gzipSync as qX}from"zlib";var t6={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 B5{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...t6,...$}}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[Q,Z]of $)await this.buildEntry(Q,Z);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((Q,Z)=>{let Y=D1(Q,w1(Q));$.set(Y,Q)});else if(typeof X==="object")Object.entries(X).forEach(([Q,Z])=>{$.set(Q,Z)});return $}async buildEntry($,X){if(!await Bun.file(X).exists()){this.errors.push(`Entry point not found: ${X}`);return}let Q=await Bun.file(X).text(),Z=w1(X),Y=Q,J="js";if(Z===".stx"||Z===".html")J="html",Y=await this.processTemplate(Q,X);else if(Z===".css")J="css",Y=await this.processCss(Q,X);else if(Z===".js"||Z===".ts")J="js",Y=await this.processScript(Q,X);Y=await this.runPluginTransform(Y,X);let G=this.generateHash(Y),W=this.getOutputName($,J,G),K=E0(this.config.outDir,W);this.ensureDir(w0(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 E0(w0($),"..",X);return E0(w0($),X)}async processTemplate($,X){let Q=$,Z=[],Y=[];if(Q=Q.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(R1(_)){let U=U5(_,"utf-8");Z.push(`// Source: ${K[1]}
2361
+ ${U}`)}else this.warnings.push(`External script not found: ${_}`)}return""}),Q=Q.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(R1(_)){let U=U5(_,"utf-8");Y.push(`/* Source: ${K[1]} */
2362
2362
  ${U}`)}else this.warnings.push(`External stylesheet not found: ${_}`)}return""}),Q=Q.replace(/<script\b(?![^>]*\bstx-inline\b)([^>]*)>([\s\S]*?)<\/script>/gi,(J,G,W)=>{if(/\bsrc=/.test(G))return J;if(W.trim())Z.push(W);return""}),Q=Q.replace(/<style\b[^>]*>([\s\S]*?)<\/style>/gi,(J,G)=>{if(G.trim())Y.push(G);return""}),Z.length>0){let J=Z.join(`
2363
2363
 
2364
2364
  `),G=this.generateHash(J).slice(0,8),W=`assets/app.${G}.js`,K=E0(this.config.outDir,W);this.ensureDir(w0(K)),await Bun.write(K,J),this.outputs.push({path:K,type:"js",size:Buffer.byteLength(J),hash:G,sources:[X]});let _=Q.lastIndexOf("</body>");if(_!==-1)Q=Q.slice(0,_)+`<script src="${this.config.publicPath}${W}"></script>
@@ -2366,7 +2366,7 @@ ${U}`)}else this.warnings.push(`External stylesheet not found: ${_}`)}return""})
2366
2366
 
2367
2367
  `),G=this.generateHash(J).slice(0,8),W=`assets/app.${G}.css`,K=E0(this.config.outDir,W);this.ensureDir(w0(K)),await Bun.write(K,J),this.outputs.push({path:K,type:"css",size:Buffer.byteLength(J),hash:G,sources:[X]}),Q=Q.replace("</head>",`<link rel="stylesheet" href="${this.config.publicPath}${W}">
2368
2368
  </head>`)}return Q}async processCss($,X){let Q=$;if(typeof this.config.minify==="object"&&this.config.minify.css)Q=this.minifyCss(Q);return Q}async processScript($,X){let Q=$;if(this.config.define)for(let[Z,Y]of Object.entries(this.config.define))Q=Q.replace(new RegExp(Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),Y);return Q}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(`
2369
- `),Q=this.generateHash(X).slice(0,8),Z=(this.config.css?.filename||"assets/[name].[hash].css").replace("[name]","styles").replace("[hash]",Q),Y=E0(this.config.outDir,Z);this.ensureDir(w0(Y)),await Bun.write(Y,X),this.outputs.push({path:Y,type:"css",size:Buffer.byteLength(X),hash:Q})}async processAssets(){let $=E0(w0(this.config.outDir),"public");if(!R1($))return;let X=this.config.assets||{},Q=X.include||[];this.walkDir($,(Z)=>{let Y=w1(Z).slice(1).toLowerCase();if(!Q.includes(Y))return;let J=K5(Z),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]",D1(Z,w1(Z))).replace("[hash]",W).replace("[ext]",w1(Z)),_=E0(this.config.outDir,K);this.ensureDir(w0(_)),jX(_,J),this.assetHashes.set(Z,K),this.assets.push({name:D1(Z),file:K,size:G,source:Z}),this.outputs.push({path:_,type:"asset",size:G,hash:W,sources:[Z]})})}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 Q=await Bun.file(X.path).text(),Z=Q;if(X.type==="js"&&$.js)Z=this.minifyJs(Q);else if(X.type==="css"&&$.css)Z=this.minifyCss(Q);else if(X.type==="html"&&$.html)Z=this.minifyHtml(Q);if(Z!==Q)await Bun.write(X.path,Z),X.size=Buffer.byteLength(Z)}}minifyJs($){let X=typeof this.config.minify==="object"?this.config.minify:{},Q=$;if(Q=Q.replace(/\/\*[\s\S]*?\*\//g,""),Q=Q.replace(/\/\/.*$/gm,""),X.dropConsole)Q=Q.replace(/console\.(log|debug|info|warn)\([^)]*\);?/g,"");if(X.dropDebugger)Q=Q.replace(/debugger;?/g,"");return Q=Q.replace(/\s+/g," "),Q=Q.replace(/\s*([{};,:])\s*/g,"$1"),Q=Q.replace(/;\}/g,"}"),Q.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(),Q=[];for(let W of $.sources||[])if(await Bun.file(W).exists())Q.push(await Bun.file(W).text());else Q.push(null);let Z={version:3,file:D1($.path),sources:$.sources||[],sourcesContent:Q,mappings:"",names:[]},Y=`${$.path}.map`;await Bun.write(Y,JSON.stringify(Z));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(Z)).toString("base64")}`:D1(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:HX(Y).size})}}async fingerprintAssets(){for(let $ of this.outputs)if($.type==="html"){let X=await Bun.file($.path).text();for(let[Q,Z]of this.assetHashes){let Y=n6(w0($.path),Q);X=X.replace(new RegExp(Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),`${this.config.publicPath}${Z}`)}await Bun.write($.path,X)}}async compressOutputs(){let $=this.config.compression||{},X=$.threshold||1024;for(let Q of this.outputs){if(Q.type==="map")continue;if(Q.size<X)continue;let Z=Buffer.from(await Bun.file(Q.path).arrayBuffer());if($.gzip){let Y=AX(Z,{level:9}),J=`${Q.path}.gz`;await Bun.write(J,Y),Q.gzipSize=Y.length}if($.brotli)try{let{brotliCompressSync:Y}=await import("zlib"),J=Y(Z);await Bun.write(`${Q.path}.br`,J)}catch{}}}async analyzeBundle(){let $=typeof this.config.analyze==="object"?this.config.analyze:{},X=$.format||"text",Q={outputs:this.outputs.map((G)=>({path:n6(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)},Z;if(X==="json")Z=JSON.stringify(Q,null,2);else if(X==="html")Z=this.generateAnalysisHtml(Q);else Z=this.generateAnalysisText(Q);let Y=$.filename||`bundle-analysis.${X==="html"?"html":X==="json"?"json":"txt"}`,J=E0(this.config.outDir,Y);await Bun.write(J,Z),console.log(`
2369
+ `),Q=this.generateHash(X).slice(0,8),Z=(this.config.css?.filename||"assets/[name].[hash].css").replace("[name]","styles").replace("[hash]",Q),Y=E0(this.config.outDir,Z);this.ensureDir(w0(Y)),await Bun.write(Y,X),this.outputs.push({path:Y,type:"css",size:Buffer.byteLength(X),hash:Q})}async processAssets(){let $=E0(w0(this.config.outDir),"public");if(!R1($))return;let X=this.config.assets||{},Q=X.include||[];this.walkDir($,(Z)=>{let Y=w1(Z).slice(1).toLowerCase();if(!Q.includes(Y))return;let J=U5(Z),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]",D1(Z,w1(Z))).replace("[hash]",W).replace("[ext]",w1(Z)),_=E0(this.config.outDir,K);this.ensureDir(w0(_)),OX(_,J),this.assetHashes.set(Z,K),this.assets.push({name:D1(Z),file:K,size:G,source:Z}),this.outputs.push({path:_,type:"asset",size:G,hash:W,sources:[Z]})})}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 Q=await Bun.file(X.path).text(),Z=Q;if(X.type==="js"&&$.js)Z=this.minifyJs(Q);else if(X.type==="css"&&$.css)Z=this.minifyCss(Q);else if(X.type==="html"&&$.html)Z=this.minifyHtml(Q);if(Z!==Q)await Bun.write(X.path,Z),X.size=Buffer.byteLength(Z)}}minifyJs($){let X=typeof this.config.minify==="object"?this.config.minify:{},Q=$;if(Q=Q.replace(/\/\*[\s\S]*?\*\//g,""),Q=Q.replace(/\/\/.*$/gm,""),X.dropConsole)Q=Q.replace(/console\.(log|debug|info|warn)\([^)]*\);?/g,"");if(X.dropDebugger)Q=Q.replace(/debugger;?/g,"");return Q=Q.replace(/\s+/g," "),Q=Q.replace(/\s*([{};,:])\s*/g,"$1"),Q=Q.replace(/;\}/g,"}"),Q.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(),Q=[];for(let W of $.sources||[])if(await Bun.file(W).exists())Q.push(await Bun.file(W).text());else Q.push(null);let Z={version:3,file:D1($.path),sources:$.sources||[],sourcesContent:Q,mappings:"",names:[]},Y=`${$.path}.map`;await Bun.write(Y,JSON.stringify(Z));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(Z)).toString("base64")}`:D1(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[Q,Z]of this.assetHashes){let Y=o6(w0($.path),Q);X=X.replace(new RegExp(Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),`${this.config.publicPath}${Z}`)}await Bun.write($.path,X)}}async compressOutputs(){let $=this.config.compression||{},X=$.threshold||1024;for(let Q of this.outputs){if(Q.type==="map")continue;if(Q.size<X)continue;let Z=Buffer.from(await Bun.file(Q.path).arrayBuffer());if($.gzip){let Y=qX(Z,{level:9}),J=`${Q.path}.gz`;await Bun.write(J,Y),Q.gzipSize=Y.length}if($.brotli)try{let{brotliCompressSync:Y}=await import("zlib"),J=Y(Z);await Bun.write(`${Q.path}.br`,J)}catch{}}}async analyzeBundle(){let $=typeof this.config.analyze==="object"?this.config.analyze:{},X=$.format||"text",Q={outputs:this.outputs.map((G)=>({path:o6(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)},Z;if(X==="json")Z=JSON.stringify(Q,null,2);else if(X==="html")Z=this.generateAnalysisHtml(Q);else Z=this.generateAnalysisText(Q);let Y=$.filename||`bundle-analysis.${X==="html"?"html":X==="json"?"json":"txt"}`,J=E0(this.config.outDir,Y);await Bun.write(J,Z),console.log(`
2370
2370
  \uD83D\uDCCA Bundle Analysis`),console.log("\u2500".repeat(50));for(let G of Q.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(Q.totalSize)} (gzip: ${this.formatSize(Q.totalGzipSize)})`),console.log("")}generateAnalysisHtml($){return`<!DOCTYPE html>
2371
2371
  <html>
2372
2372
  <head>
@@ -2407,44 +2407,44 @@ ${U}`)}else this.warnings.push(`External stylesheet not found: ${_}`)}return""})
2407
2407
  </table>
2408
2408
  </body>
2409
2409
  </html>`}generateAnalysisText($){let X=["Bundle Analysis","=".repeat(50),""];for(let Q of $.outputs)X.push(`${Q.path}`),X.push(` Size: ${Q.sizeFormatted}${Q.gzipSizeFormatted?` (gzip: ${Q.gzipSizeFormatted})`:""}`),X.push("");return X.push("=".repeat(50)),X.push(`Total: ${this.formatSize($.totalSize)} (gzip: ${this.formatSize($.totalGzipSize)})`),X.join(`
2410
- `)}async runPluginHook($,X){if(!this.config.plugins)return;for(let Q of this.config.plugins){let Z=Q[$];if(typeof Z==="function")await Z.call(Q,X||this)}}async runPluginTransform($,X){if(!this.config.plugins)return $;let Q=$;for(let Z of this.config.plugins)if(Z.transform){let Y=await Z.transform(Q,X);if(Y!=null)Q=Y}return Q}generateHash($){return FX("sha256").update($).digest("hex")}getOutputName($,X,Q){let Z=X==="html"?".html":X==="css"?".css":X==="js"?".js":"";return`${$}.${Q.slice(0,8)}${Z}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!R1($))zX($,{recursive:!0})}walkDir($,X){if(!R1($))return;let Q=OX($,{withFileTypes:!0});for(let Z of Q){let Y=E0($,Z.name);if(Z.isDirectory())this.walkDir(Y,X);else X(Y)}}getResult(){let $=Date.now()-this.startTime,X=this.outputs.reduce((Z,Y)=>Z+Y.size,0),Q=this.outputs.reduce((Z,Y)=>Z+(Y.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:X,gzipSize:Q,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function A2($){return new _5($).build()}function q2($){return new _5($)}function N2($){return{...o6,...$}}var V2="f9c3713";import{existsSync as T1,mkdirSync as U5}from"fs";import{join as b0,dirname as qX}from"path";import{execSync as t6}from"child_process";var T2={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 C2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.template||"default",Y=b0(process.cwd(),$);if(T1(Y))return Q.success=!1,Q.message=`Directory ${$} already exists`,Q;try{U5(Y,{recursive:!0});let J=NX(Z);for(let W of J)U5(b0(Y,W),{recursive:!0});let G=MX(Z,$,X);for(let[W,K]of Object.entries(G)){let _=b0(Y,W);C1(qX(_)),await Bun.write(_,K),Q.files.push(W)}if(!X.skipGit)try{t6("git init",{cwd:Y,stdio:"ignore"}),await Bun.write(b0(Y,".gitignore"),xX()),Q.files.push(".gitignore")}catch{Q.errors.push("Failed to initialize git repository")}if(!X.skipInstall){let W=X.packageManager||oX();try{console.log(`
2411
- Installing dependencies with ${W}...`),t6(`${W} install`,{cwd:Y,stdio:"inherit"})}catch{Q.errors.push("Failed to install dependencies")}}Q.message=`Created project: ${$}`,console.log(`
2410
+ `)}async runPluginHook($,X){if(!this.config.plugins)return;for(let Q of this.config.plugins){let Z=Q[$];if(typeof Z==="function")await Z.call(Q,X||this)}}async runPluginTransform($,X){if(!this.config.plugins)return $;let Q=$;for(let Z of this.config.plugins)if(Z.transform){let Y=await Z.transform(Q,X);if(Y!=null)Q=Y}return Q}generateHash($){return zX("sha256").update($).digest("hex")}getOutputName($,X,Q){let Z=X==="html"?".html":X==="css"?".css":X==="js"?".js":"";return`${$}.${Q.slice(0,8)}${Z}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!R1($))jX($,{recursive:!0})}walkDir($,X){if(!R1($))return;let Q=HX($,{withFileTypes:!0});for(let Z of Q){let Y=E0($,Z.name);if(Z.isDirectory())this.walkDir(Y,X);else X(Y)}}getResult(){let $=Date.now()-this.startTime,X=this.outputs.reduce((Z,Y)=>Z+Y.size,0),Q=this.outputs.reduce((Z,Y)=>Z+(Y.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:X,gzipSize:Q,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function N2($){return new B5($).build()}function M2($){return new B5($)}function V2($){return{...t6,...$}}var I2="f9c3713";import{existsSync as T1,mkdirSync as L5}from"fs";import{join as b0,dirname as NX}from"path";import{execSync as e6}from"child_process";var k2={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 x2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.template||"default",Y=b0(process.cwd(),$);if(T1(Y))return Q.success=!1,Q.message=`Directory ${$} already exists`,Q;try{L5(Y,{recursive:!0});let J=MX(Z);for(let W of J)L5(b0(Y,W),{recursive:!0});let G=VX(Z,$,X);for(let[W,K]of Object.entries(G)){let _=b0(Y,W);C1(NX(_)),await Bun.write(_,K),Q.files.push(W)}if(!X.skipGit)try{e6("git init",{cwd:Y,stdio:"ignore"}),await Bun.write(b0(Y,".gitignore"),xX()),Q.files.push(".gitignore")}catch{Q.errors.push("Failed to initialize git repository")}if(!X.skipInstall){let W=X.packageManager||tX();try{console.log(`
2411
+ Installing dependencies with ${W}...`),e6(`${W} install`,{cwd:Y,stdio:"inherit"})}catch{Q.errors.push("Failed to install dependencies")}}Q.message=`Created project: ${$}`,console.log(`
2412
2412
  \u2705 ${Q.message}
2413
2413
 
2414
2414
  Next steps:
2415
2415
  cd ${$}
2416
2416
  ${X.packageManager||"bun"} run dev
2417
- `)}catch(J){Q.success=!1,Q.message=`Failed to create project: ${J}`}return Q}function NX($){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 MX($,X,Q){let Z={};if(Z["package.json"]=DX(X,$,Q),Z["stx.config.ts"]=wX($,Q),Z["README.md"]=CX(X,$),Q.typescript!==!1)Z["tsconfig.json"]=TX();switch($){case"minimal":Z["src/index.stx"]=kX();break;case"blog":Z["pages/index.stx"]=yX(),Z["pages/[slug].stx"]=vX(),Z["layouts/app.stx"]=gX(),Z["components/PostCard.stx"]=fX();break;case"dashboard":Z["pages/index.stx"]=hX(),Z["pages/settings.stx"]=dX(),Z["layouts/app.stx"]=uX(),Z["components/Sidebar.stx"]=mX(),Z["components/StatsCard.stx"]=pX(),Z["src/stores/dashboard.ts"]=cX();break;case"landing":Z["pages/index.stx"]=lX(),Z["layouts/app.stx"]=iX(),Z["src/sections/Hero.stx"]=aX(),Z["src/sections/Features.stx"]=rX(),Z["src/sections/Pricing.stx"]=sX(),Z["components/Button.stx"]=nX();break;case"full":Z["pages/index.stx"]=e6(),Z["pages/about.stx"]=SX(),Z["layouts/app.stx"]=$8(),Z["components/Header.stx"]=X8(),Z["components/Footer.stx"]=Q8(),Z["src/stores/app.ts"]=Z8(),Z["src/i18n/en.json"]=PX("en"),Z["test/example.test.ts"]=bX();break;default:Z["pages/index.stx"]=e6(),Z["layouts/app.stx"]=$8(),Z["components/Header.stx"]=X8(),Z["components/Footer.stx"]=Q8(),Z["src/stores/app.ts"]=Z8()}return Z}async function x2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"components",Y=B5($),J=b0(Z,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Q.success=!1,Q.message=`Component ${Y} already exists. Use --force to overwrite.`,Q;try{C1(Z);let G=VX(Y,X);await Bun.write(J,G),Q.files.push(J),Q.message=`Created component: ${J}`,console.log(`\u2705 ${Q.message}`)}catch(G){Q.success=!1,Q.message=`Failed to create component: ${G}`}return Q}async function k2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"pages",Y=$.toLowerCase().replace(/\s+/g,"-"),J=b0(Z,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Q.success=!1,Q.message=`Page ${Y} already exists. Use --force to overwrite.`,Q;try{C1(Z);let G=EX(Y,X);await Bun.write(J,G),Q.files.push(J),Q.message=`Created page: ${J}`,console.log(`\u2705 ${Q.message}`)}catch(G){Q.success=!1,Q.message=`Failed to create page: ${G}`}return Q}async function S2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"src/stores",Y=tX($),J=b0(Z,`${Y}.ts`);if(await Bun.file(J).exists()&&!X.force)return Q.success=!1,Q.message=`Store ${Y} already exists. Use --force to overwrite.`,Q;try{C1(Z);let G=IX(Y,X);await Bun.write(J,G),Q.files.push(J),Q.message=`Created store: ${J}`,console.log(`\u2705 ${Q.message}`)}catch(G){Q.success=!1,Q.message=`Failed to create store: ${G}`}return Q}async function P2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"layouts",Y=$.toLowerCase().replace(/\s+/g,"-"),J=b0(Z,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Q.success=!1,Q.message=`Layout ${Y} already exists. Use --force to overwrite.`,Q;try{C1(Z);let G=RX(Y,X);await Bun.write(J,G),Q.files.push(J),Q.message=`Created layout: ${J}`,console.log(`\u2705 ${Q.message}`)}catch(G){Q.success=!1,Q.message=`Failed to create layout: ${G}`}return Q}function VX($,X){let Q=[];if(Q.push(`{{-- Component: ${$} --}}`),X.props!==!1)Q.push(`<script>
2417
+ `)}catch(J){Q.success=!1,Q.message=`Failed to create project: ${J}`}return Q}function MX($){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 VX($,X,Q){let Z={};if(Z["package.json"]=wX(X,$,Q),Z["stx.config.ts"]=TX($,Q),Z["README.md"]=kX(X,$),Q.typescript!==!1)Z["tsconfig.json"]=CX();switch($){case"minimal":Z["src/index.stx"]=SX();break;case"blog":Z["pages/index.stx"]=vX(),Z["pages/[slug].stx"]=gX(),Z["layouts/app.stx"]=fX(),Z["components/PostCard.stx"]=hX();break;case"dashboard":Z["pages/index.stx"]=dX(),Z["pages/settings.stx"]=uX(),Z["layouts/app.stx"]=mX(),Z["components/Sidebar.stx"]=pX(),Z["components/StatsCard.stx"]=cX(),Z["src/stores/dashboard.ts"]=lX();break;case"landing":Z["pages/index.stx"]=iX(),Z["layouts/app.stx"]=aX(),Z["src/sections/Hero.stx"]=rX(),Z["src/sections/Features.stx"]=sX(),Z["src/sections/Pricing.stx"]=nX(),Z["components/Button.stx"]=oX();break;case"full":Z["pages/index.stx"]=$8(),Z["pages/about.stx"]=PX(),Z["layouts/app.stx"]=X8(),Z["components/Header.stx"]=Q8(),Z["components/Footer.stx"]=Z8(),Z["src/stores/app.ts"]=Y8(),Z["src/i18n/en.json"]=bX("en"),Z["test/example.test.ts"]=yX();break;default:Z["pages/index.stx"]=$8(),Z["layouts/app.stx"]=X8(),Z["components/Header.stx"]=Q8(),Z["components/Footer.stx"]=Z8(),Z["src/stores/app.ts"]=Y8()}return Z}async function S2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"components",Y=F5($),J=b0(Z,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Q.success=!1,Q.message=`Component ${Y} already exists. Use --force to overwrite.`,Q;try{C1(Z);let G=EX(Y,X);await Bun.write(J,G),Q.files.push(J),Q.message=`Created component: ${J}`,console.log(`\u2705 ${Q.message}`)}catch(G){Q.success=!1,Q.message=`Failed to create component: ${G}`}return Q}async function P2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"pages",Y=$.toLowerCase().replace(/\s+/g,"-"),J=b0(Z,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Q.success=!1,Q.message=`Page ${Y} already exists. Use --force to overwrite.`,Q;try{C1(Z);let G=IX(Y,X);await Bun.write(J,G),Q.files.push(J),Q.message=`Created page: ${J}`,console.log(`\u2705 ${Q.message}`)}catch(G){Q.success=!1,Q.message=`Failed to create page: ${G}`}return Q}async function b2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"src/stores",Y=eX($),J=b0(Z,`${Y}.ts`);if(await Bun.file(J).exists()&&!X.force)return Q.success=!1,Q.message=`Store ${Y} already exists. Use --force to overwrite.`,Q;try{C1(Z);let G=RX(Y,X);await Bun.write(J,G),Q.files.push(J),Q.message=`Created store: ${J}`,console.log(`\u2705 ${Q.message}`)}catch(G){Q.success=!1,Q.message=`Failed to create store: ${G}`}return Q}async function y2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"layouts",Y=$.toLowerCase().replace(/\s+/g,"-"),J=b0(Z,`${Y}.stx`);if(await Bun.file(J).exists()&&!X.force)return Q.success=!1,Q.message=`Layout ${Y} already exists. Use --force to overwrite.`,Q;try{C1(Z);let G=DX(Y,X);await Bun.write(J,G),Q.files.push(J),Q.message=`Created layout: ${J}`,console.log(`\u2705 ${Q.message}`)}catch(G){Q.success=!1,Q.message=`Failed to create layout: ${G}`}return Q}function EX($,X){let Q=[];if(Q.push(`{{-- Component: ${$} --}}`),X.props!==!1)Q.push(`<script>
2418
2418
  // Props
2419
2419
  const title = props.title || '${$}'
2420
2420
  const variant = props.variant || 'default'
2421
2421
  </script>
2422
- `);if(Q.push(`<div class="${p0($)} ${p0($)}--{{ variant }}">
2422
+ `);if(Q.push(`<div class="${c0($)} ${c0($)}--{{ variant }}">
2423
2423
  <h3>{{ title }}</h3>
2424
- <div class="${p0($)}__content">
2424
+ <div class="${c0($)}__content">
2425
2425
  {{ slot }}
2426
2426
  </div>
2427
2427
  </div>`),X.styles!==!1)Q.push(`
2428
2428
  <style scoped>
2429
- .${p0($)} {
2429
+ .${c0($)} {
2430
2430
  padding: 1rem;
2431
2431
  border-radius: 8px;
2432
2432
  background: #f8f9fa;
2433
2433
  }
2434
2434
 
2435
- .${p0($)}--primary {
2435
+ .${c0($)}--primary {
2436
2436
  border-left: 3px solid #3498db;
2437
2437
  }
2438
2438
 
2439
- .${p0($)}--success {
2439
+ .${c0($)}--success {
2440
2440
  border-left: 3px solid #2ecc71;
2441
2441
  }
2442
2442
 
2443
- .${p0($)}__content {
2443
+ .${c0($)}__content {
2444
2444
  margin-top: 0.5rem;
2445
2445
  }
2446
2446
  </style>`);return Q.join(`
2447
- `)}function EX($,X){let Q=B5($.replace(/-/g," ")),Z=[];if(Z.push(`<script>
2447
+ `)}function IX($,X){let Q=F5($.replace(/-/g," ")),Z=[];if(Z.push(`<script>
2448
2448
  const title = '${Q}'
2449
2449
  const description = 'Page description'
2450
2450
  </script>
@@ -2457,7 +2457,7 @@ const description = 'Page description'
2457
2457
  <p>{{ description }}</p>
2458
2458
  </div>
2459
2459
  @endsection`),Z.join(`
2460
- `)}function IX($,X){let Q=`${$}Store`,Z=`${B5($)}State`,Y=`import { defineStore } from 'stx'
2460
+ `)}function RX($,X){let Q=`${$}Store`,Z=`${F5($)}State`,Y=`import { defineStore } from 'stx'
2461
2461
 
2462
2462
  interface ${Z} {
2463
2463
  // Add your state properties here
@@ -2505,7 +2505,7 @@ finally {
2505
2505
  ],
2506
2506
  },
2507
2507
  `;return Y+=`})
2508
- `,Y}function RX($,X){let Q=`<!DOCTYPE html>
2508
+ `,Y}function DX($,X){let Q=`<!DOCTYPE html>
2509
2509
  <html lang="en">
2510
2510
  <head>
2511
2511
  <meta charset="UTF-8">
@@ -2552,7 +2552,7 @@ finally {
2552
2552
 
2553
2553
  `;return Q+=` @yield('scripts')
2554
2554
  </body>
2555
- </html>`,Q}function DX($,X,Q){let Z={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(Q.typescript!==!1)Z.devDependencies.typescript="^5.0.0";if(Q.tailwind)Z.devDependencies.tailwindcss="^3.0.0";if(X==="full")Z.scripts.test="bun test",Z.scripts.lint="bun run lint";return JSON.stringify(Z,null,2)}function wX($,X){return`import { defineConfig } from 'stx'
2555
+ </html>`,Q}function wX($,X,Q){let Z={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(Q.typescript!==!1)Z.devDependencies.typescript="^5.0.0";if(Q.tailwind)Z.devDependencies.tailwindcss="^3.0.0";if(X==="full")Z.scripts.test="bun test",Z.scripts.lint="bun run lint";return JSON.stringify(Z,null,2)}function TX($,X){return`import { defineConfig } from 'stx'
2556
2556
 
2557
2557
  export default defineConfig({
2558
2558
  // Template directories
@@ -2573,7 +2573,7 @@ ${X.pwa?` pwa: { enabled: true },
2573
2573
  // Analytics (configure when ready)
2574
2574
  // analytics: { enabled: true, driver: 'fathom', fathom: { siteId: 'YOUR_SITE_ID' } },
2575
2575
  })
2576
- `}function TX(){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 CX($,X){return`# ${$}
2576
+ `}function CX(){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 kX($,X){return`# ${$}
2577
2577
 
2578
2578
  A stx project created with the \`${X}\` template.
2579
2579
 
@@ -2630,7 +2630,7 @@ Thumbs.db
2630
2630
 
2631
2631
  # Logs
2632
2632
  *.log
2633
- `}function kX(){return`<!DOCTYPE html>
2633
+ `}function SX(){return`<!DOCTYPE html>
2634
2634
  <html lang="en">
2635
2635
  <head>
2636
2636
  <meta charset="UTF-8">
@@ -2646,7 +2646,7 @@ Thumbs.db
2646
2646
  <p>Edit <code>src/index.stx</code> to get started.</p>
2647
2647
  </body>
2648
2648
  </html>
2649
- `}function e6(){return`<script>
2649
+ `}function $8(){return`<script>
2650
2650
  const title = 'Welcome to stx'
2651
2651
  const features = [
2652
2652
  { icon: '\u26A1', name: 'Fast', desc: 'Built on Bun for blazing speed' },
@@ -2675,7 +2675,7 @@ const features = [
2675
2675
  @endforeach
2676
2676
  </div>
2677
2677
  @endsection
2678
- `}function SX(){return`<script>
2678
+ `}function PX(){return`<script>
2679
2679
  const title = 'About'
2680
2680
  </script>
2681
2681
 
@@ -2687,7 +2687,7 @@ const title = 'About'
2687
2687
  <h1>{{ title }}</h1>
2688
2688
  <p>This is the about page.</p>
2689
2689
  @endsection
2690
- `}function $8(){return`<!DOCTYPE html>
2690
+ `}function X8(){return`<!DOCTYPE html>
2691
2691
  <html lang="en">
2692
2692
  <head>
2693
2693
  <meta charset="UTF-8">
@@ -2710,7 +2710,7 @@ const title = 'About'
2710
2710
  @yield('scripts')
2711
2711
  </body>
2712
2712
  </html>
2713
- `}function X8(){return`<header class="header">
2713
+ `}function Q8(){return`<header class="header">
2714
2714
  <nav class="nav container">
2715
2715
  <a href="/" class="logo">stx</a>
2716
2716
  <div class="nav-links">
@@ -2727,7 +2727,7 @@ const title = 'About'
2727
2727
  .nav-links a { color: rgba(255,255,255,0.8); margin-left: 1.5rem; text-decoration: none; }
2728
2728
  .nav-links a:hover { color: white; }
2729
2729
  </style>
2730
- `}function Q8(){return`<footer class="footer">
2730
+ `}function Z8(){return`<footer class="footer">
2731
2731
  <div class="container">
2732
2732
  <p>&copy; {{ new Date().getFullYear() }} Built with stx</p>
2733
2733
  </div>
@@ -2736,7 +2736,7 @@ const title = 'About'
2736
2736
  <style scoped>
2737
2737
  .footer { background: #f8f9fa; padding: 2rem 0; margin-top: 4rem; text-align: center; color: #666; }
2738
2738
  </style>
2739
- `}function Z8(){return`import { defineStore } from 'stx'
2739
+ `}function Y8(){return`import { defineStore } from 'stx'
2740
2740
 
2741
2741
  interface AppState {
2742
2742
  theme: 'light' | 'dark'
@@ -2763,14 +2763,14 @@ export const appStore = defineStore('app', {
2763
2763
  strategies: [{ key: 'app-preferences', storage: localStorage }],
2764
2764
  },
2765
2765
  })
2766
- `}function PX($){return JSON.stringify({common:{welcome:"Welcome",home:"Home",about:"About",contact:"Contact"},messages:{loading:"Loading...",error:"An error occurred"}},null,2)}function bX(){return`import { describe, expect, it } from 'bun:test'
2766
+ `}function bX($){return JSON.stringify({common:{welcome:"Welcome",home:"Home",about:"About",contact:"Contact"},messages:{loading:"Loading...",error:"An error occurred"}},null,2)}function yX(){return`import { describe, expect, it } from 'bun:test'
2767
2767
 
2768
2768
  describe('Example', () => {
2769
2769
  it('should work', () => {
2770
2770
  expect(1 + 1).toBe(2)
2771
2771
  })
2772
2772
  })
2773
- `}function yX(){return"<!-- Blog index -->"}function vX(){return"<!-- Blog post -->"}function gX(){return`<!DOCTYPE html>
2773
+ `}function vX(){return"<!-- Blog index -->"}function gX(){return"<!-- Blog post -->"}function fX(){return`<!DOCTYPE html>
2774
2774
  <html lang="en">
2775
2775
  <head>
2776
2776
  <meta charset="UTF-8">
@@ -2810,7 +2810,7 @@ describe('Example', () => {
2810
2810
  </footer>
2811
2811
  @yield('scripts')
2812
2812
  </body>
2813
- </html>`}function fX(){return"<!-- Post card -->"}function hX(){return"<!-- Dashboard index -->"}function dX(){return"<!-- Settings -->"}function uX(){return`<!DOCTYPE html>
2813
+ </html>`}function hX(){return"<!-- Post card -->"}function dX(){return"<!-- Dashboard index -->"}function uX(){return"<!-- Settings -->"}function mX(){return`<!DOCTYPE html>
2814
2814
  <html lang="en">
2815
2815
  <head>
2816
2816
  <meta charset="UTF-8">
@@ -2846,7 +2846,7 @@ describe('Example', () => {
2846
2846
  </div>
2847
2847
  @yield('scripts')
2848
2848
  </body>
2849
- </html>`}function mX(){return"<!-- Sidebar -->"}function pX(){return"<!-- Stats card -->"}function cX(){return"// Dashboard store"}function lX(){return"<!-- Landing page -->"}function iX(){return`<!DOCTYPE html>
2849
+ </html>`}function pX(){return"<!-- Sidebar -->"}function cX(){return"<!-- Stats card -->"}function lX(){return"// Dashboard store"}function iX(){return"<!-- Landing page -->"}function aX(){return`<!DOCTYPE html>
2850
2850
  <html lang="en">
2851
2851
  <head>
2852
2852
  <meta charset="UTF-8">
@@ -2881,17 +2881,17 @@ describe('Example', () => {
2881
2881
  </footer>
2882
2882
  @yield('scripts')
2883
2883
  </body>
2884
- </html>`}function aX(){return"<!-- Hero section -->"}function rX(){return"<!-- Features -->"}function sX(){return"<!-- Pricing -->"}function nX(){return"<!-- Button -->"}function C1($){if(!T1($))U5($,{recursive:!0})}function oX(){if(T1("bun.lockb"))return"bun";if(T1("pnpm-lock.yaml"))return"pnpm";if(T1("yarn.lock"))return"yarn";return"bun"}function B5($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function tX($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function p0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:eX}=globalThis.Bun;import x1 from"fs";import y0 from"path";function c2($,X=200,Q={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Q}})}async function Y8($){let{loadStxConfig:X}=await import("./chunk-erwwmzym.js");return{...await X($.configDir??process.cwd()).catch(()=>({})),...$.stxOptions??{}}}async function $Q($={}){let{port:X=3000,root:Q=".",watch:Z=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=y0.resolve(Q),U=await Y8($),z=new Map;async function F(q){let M=x1.statSync(q),V=`${q}:${M.mtimeMs}`,N=z.get(V);if(N)return{content:N.content,status:N.status,headers:N.headers};for(let T of z.keys())if(T.startsWith(`${q}:`)&&T!==V)z.delete(T);let R=await Bun.file(q).text(),w=R,C=Z$(R);if(C)w=C.content.trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[],m=[],f;while((f=I.exec(R))!==null){let T=f[1],k=f[2],S=f[0];if(T.includes("server"))m.push(k);else E.push(S)}let K0=R.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],h5=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),G0={__filename:q,__dirname:y0.dirname(q)};for(let T of m)await j0(T,G0,q);let q0=await O0(h5,G0,q,U,new Set);if(K0.length>0){let T=K0.join(`
2884
+ </html>`}function rX(){return"<!-- Hero section -->"}function sX(){return"<!-- Features -->"}function nX(){return"<!-- Pricing -->"}function oX(){return"<!-- Button -->"}function C1($){if(!T1($))L5($,{recursive:!0})}function tX(){if(T1("bun.lockb"))return"bun";if(T1("pnpm-lock.yaml"))return"pnpm";if(T1("yarn.lock"))return"yarn";return"bun"}function F5($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function eX($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function c0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:$Q}=globalThis.Bun;import k1 from"fs";import y0 from"path";function i2($,X=200,Q={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Q}})}async function J8($){let{loadStxConfig:X}=await import("./chunk-anc397f7.js");return{...await X($.configDir??process.cwd()).catch(()=>({})),...$.stxOptions??{}}}async function XQ($={}){let{port:X=3000,root:Q=".",watch:Z=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=y0.resolve(Q),U=await J8($),z=new Map;async function F(A){let N=k1.statSync(A),V=`${A}:${N.mtimeMs}`,M=z.get(V);if(M)return{content:M.content,status:M.status,headers:M.headers};for(let T of z.keys())if(T.startsWith(`${A}:`)&&T!==V)z.delete(T);let R=await Bun.file(A).text(),w=R,C=Z$(R);if(C)w=C.content.trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[],m=[],f;while((f=I.exec(R))!==null){let T=f[1],x=f[2],S=f[0];if(T.includes("server"))m.push(x);else E.push(S)}let K0=R.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],d5=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),G0={__filename:A,__dirname:y0.dirname(A)};for(let T of m)await j0(T,G0,A);let q0=await O0(d5,G0,A,U,new Set);if(K0.length>0){let T=K0.join(`
2885
2885
  `);if(q0.match(/(<\/head>)/i))q0=q0.replace(/(<\/head>)/i,`${T}
2886
- $1`)}if(E.length>0){let{interpolateScriptsInTemplate:T}=await import("./chunk-y8g3d192.js"),k=T(E.join(`
2887
- `),G0);if(q0.match(/(<\/body>)/i))q0=q0.replace(/(<\/body>)/i,`${k}
2886
+ $1`)}if(E.length>0){let{interpolateScriptsInTemplate:T}=await import("./chunk-cv0z0qpy.js"),x=T(E.join(`
2887
+ `),G0);if(q0.match(/(<\/body>)/i))q0=q0.replace(/(<\/body>)/i,`${x}
2888
2888
  $1`);else q0+=`
2889
- ${k}`}let i0=N1(G0),D=M1(G0);return z.set(V,{content:q0,mtime:M.mtimeMs,status:i0,headers:D}),{content:q0,status:i0,headers:D}}async function O(q){let M=x1.statSync(q),V=`${q}:${M.mtimeMs}`,N=z.get(V);if(N)return N.content;let{content:R}=await V0(q,U);return z.set(V,{content:R,mtime:M.mtimeMs}),R}function j(q){let M=q.startsWith("/")?q.slice(1):q,V=[M,`${M}.stx`,`${M}.md`,`${M}.html`,y0.join(M,"index.stx"),y0.join(M,"index.md"),y0.join(M,"index.html")];for(let N of V){let R=y0.join(_,N);if(x1.existsSync(R)&&x1.statSync(R).isFile())return R}return null}async function L(q){let M=new URL(q.url),V=async()=>{if(J[M.pathname])return await J[M.pathname](q);if(Y){let R=await Y(q);if(R)return R}let N=j(M.pathname);if(!N){if(W)return await W(q);return new Response("Not Found",{status:404})}try{let R,w="text/html",C,I;if(N.endsWith(".stx")){let E=await F(N);R=E.content,C=E.status,I=E.headers}else if(N.endsWith(".md"))R=await O(N);else if(N.endsWith(".html"))R=await Bun.file(N).text();else if(N.endsWith(".css"))R=await Bun.file(N).text(),w="text/css";else if(N.endsWith(".js"))R=await Bun.file(N).text(),w="text/javascript";else if(N.endsWith(".json"))R=await Bun.file(N).text(),w="application/json";else return new Response(Bun.file(N));return new Response(R,{status:C??200,headers:{"Content-Type":w,...I}})}catch(R){if(K)return await K(R,q);let w=R instanceof Error?R.message:String(R),I=U?.debug===!0?`<h1>Error</h1><pre>${w}
2890
- ${R instanceof Error?R.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(I,{status:500,headers:{"Content-Type":"text/html"}})}};for(let N=G.length-1;N>=0;N--){let R=G[N],w=V;V=async()=>await R(q,w)}return await V()}let H=eX({port:X,fetch:async(q)=>_$(q,await L(q))}),A=null;if(Z)A=x1.watch(_,{recursive:!0},(q,M)=>{if(M&&(M.endsWith(".stx")||M.endsWith(".md")||M.endsWith(".html")))z.clear()});return{server:H,url:H.url.toString(),stop(){if(A)A.close();H.stop()}}}async function l2($,X={}){let Q=y0.resolve($);if(!await Bun.file(Q).exists())throw Error(`File not found: ${Q}`);let Z=Q.endsWith(".md"),Y=Q.endsWith(".stx");if(!Z&&!Y)throw Error(`Unsupported file type: ${Q}. Only .stx and .md files are supported.`);let J=await Y8(X);return await $Q({...X,root:y0.dirname(Q),routes:{"/":async()=>{let G,W=200,K;if(Z){let{content:_}=await V0(Q,J);G=_}else{let _=await Bun.file(Q).text(),U=[],z=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,F;while((F=z.exec(_))!==null)if(F[1].includes("server"))U.push(F[2]);let O=U.join(`
2891
- `),j=_.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),L={};if(O.trim())await j0(O,L,Q);G=await O0(j,L,Q,J,new Set),W=N1(L)??200,K=M1(L)}return new Response(G,{status:W,headers:{"Content-Type":"text/html",...K}})},...X.routes}})}function XQ($){return $}function QQ($){return $}import{existsSync as ZQ,readFileSync as YQ}from"fs";var JQ={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},J8={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 G8{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...JQ,...$},this.options.includeBuiltins)Object.entries(J8).forEach(([X,Q])=>{this.variables.set(X,Q)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([X,Q])=>{this.variables.set(X,Q)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!ZQ($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let X=YQ($,"utf-8");return this.checkTemplate(X,$)}checkTemplate($,X="<inline>"){this.currentFile=X,this.errors=[],this.warnings=[];let Q=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Q)this.analyzeScript(Q[1],$.indexOf(Q[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,X){let Q=$.split(`
2889
+ ${x}`}let a0=N1(G0),D=M1(G0);return z.set(V,{content:q0,mtime:N.mtimeMs,status:a0,headers:D}),{content:q0,status:a0,headers:D}}async function j(A){let N=k1.statSync(A),V=`${A}:${N.mtimeMs}`,M=z.get(V);if(M)return M.content;let{content:R}=await V0(A,U);return z.set(V,{content:R,mtime:N.mtimeMs}),R}function O(A){let N=A.startsWith("/")?A.slice(1):A,V=[N,`${N}.stx`,`${N}.md`,`${N}.html`,y0.join(N,"index.stx"),y0.join(N,"index.md"),y0.join(N,"index.html")];for(let M of V){let R=y0.join(_,M);if(k1.existsSync(R)&&k1.statSync(R).isFile())return R}return null}async function L(A){let N=new URL(A.url),V=async()=>{if(J[N.pathname])return await J[N.pathname](A);if(Y){let R=await Y(A);if(R)return R}let M=O(N.pathname);if(!M){if(W)return await W(A);return new Response("Not Found",{status:404})}try{let R,w="text/html",C,I;if(M.endsWith(".stx")){let E=await F(M);R=E.content,C=E.status,I=E.headers}else if(M.endsWith(".md"))R=await j(M);else if(M.endsWith(".html"))R=await Bun.file(M).text();else if(M.endsWith(".css"))R=await Bun.file(M).text(),w="text/css";else if(M.endsWith(".js"))R=await Bun.file(M).text(),w="text/javascript";else if(M.endsWith(".json"))R=await Bun.file(M).text(),w="application/json";else return new Response(Bun.file(M));return new Response(R,{status:C??200,headers:{"Content-Type":w,...I}})}catch(R){if(K)return await K(R,A);let w=R instanceof Error?R.message:String(R),I=U?.debug===!0?`<h1>Error</h1><pre>${w}
2890
+ ${R instanceof Error?R.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(I,{status:500,headers:{"Content-Type":"text/html"}})}};for(let M=G.length-1;M>=0;M--){let R=G[M],w=V;V=async()=>await R(A,w)}return await V()}let H=$Q({port:X,fetch:async(A)=>_$(A,await L(A))}),q=null;if(Z)q=k1.watch(_,{recursive:!0},(A,N)=>{if(N&&(N.endsWith(".stx")||N.endsWith(".md")||N.endsWith(".html")))z.clear()});return{server:H,url:H.url.toString(),stop(){if(q)q.close();H.stop()}}}async function a2($,X={}){let Q=y0.resolve($);if(!await Bun.file(Q).exists())throw Error(`File not found: ${Q}`);let Z=Q.endsWith(".md"),Y=Q.endsWith(".stx");if(!Z&&!Y)throw Error(`Unsupported file type: ${Q}. Only .stx and .md files are supported.`);let J=await J8(X);return await XQ({...X,root:y0.dirname(Q),routes:{"/":async()=>{let G,W=200,K;if(Z){let{content:_}=await V0(Q,J);G=_}else{let _=await Bun.file(Q).text(),U=[],z=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,F;while((F=z.exec(_))!==null)if(F[1].includes("server"))U.push(F[2]);let j=U.join(`
2891
+ `),O=_.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),L={};if(j.trim())await j0(j,L,Q);G=await O0(O,L,Q,J,new Set),W=N1(L)??200,K=M1(L)}return new Response(G,{status:W,headers:{"Content-Type":"text/html",...K}})},...X.routes}})}function QQ($){return $}function ZQ($){return $}import{existsSync as YQ,readFileSync as JQ}from"fs";var GQ={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},G8={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 W8{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...GQ,...$},this.options.includeBuiltins)Object.entries(G8).forEach(([X,Q])=>{this.variables.set(X,Q)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([X,Q])=>{this.variables.set(X,Q)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!YQ($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let X=JQ($,"utf-8");return this.checkTemplate(X,$)}checkTemplate($,X="<inline>"){this.currentFile=X,this.errors=[],this.warnings=[];let Q=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Q)this.analyzeScript(Q[1],$.indexOf(Q[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,X){let Q=$.split(`
2892
2892
  `),Z=this.getLineNumber(X);for(let Y=0;Y<Q.length;Y++){let J=Q[Y],G=Z+Y;this.extractTypedVariables(J,G),this.extractInterfaces(J,Q,Y,G),this.extractTypeAliases(J,G)}}extractTypedVariables($,X){let Q=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*:\s*([^=]+?)\s*=/);if(Q){let[,J,G]=Q,W=this.parseTypeAnnotation(G.trim());this.variables.set(J,W);return}let Z=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(.+)/);if(Z){let[,J,G]=Z,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,Q,Z){let Y=$.match(/(?:export\s+)?interface\s+(\w+)\s*\{/);if(Y){let[,J]=Y,G={},W=1,K=Q+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[,z,F]=U;G[z]=this.parseTypeAnnotation(F.trim())}K++}this.variables.set(J,{kind:"object",name:J,properties:G})}}extractTypeAliases($,X){let Q=$.match(/(?:export\s+)?type\s+(\w+)\s*=\s*(.+)/);if(Q){let[,Z,Y]=Q,J=this.parseTypeAnnotation(Y.trim());J.name=Z,this.variables.set(Z,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 Q=X.match(/^Array<(.+)>$/);if(Q)return{kind:"array",elementType:this.parseTypeAnnotation(Q[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 Q=X.slice(1,-1).trim();if(Q){let Z=this.splitByComma(Q)[0];if(Z)return{kind:"array",elementType:this.inferType(Z.trim())}}return{kind:"array",elementType:{kind:"primitive",value:"any"}}}if(X.startsWith("{")){let Q={},Z=this.extractObjectLiteral(X);for(let[Y,J]of Object.entries(Z))Q[Y]=this.inferType(J);return{kind:"object",properties:Q}}if(X.includes("=>")){let Q=X.match(/^\(([^)]*)\)\s*(?::\s*(\w+))?\s*=>/);if(Q){let Z=this.parseParams(Q[1]),Y=Q[2]?this.parseTypeAnnotation(Q[2]):{kind:"primitive",value:"any"};return{kind:"function",params:Z,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 Q=X.split("(")[0],Z=this.variables.get(Q);if(Z?.kind==="function"&&Z.returnType)return Z.returnType}return{kind:"primitive",value:"any"}}parseParams($){if(!$.trim())return[];let X=[],Q=this.splitByComma($);for(let Z of Q){let Y=Z.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,Q;while((Q=X.exec($))!==null){let Y=Q[1].trim(),J=Q.index,G=this.getLineNumber(J,$),W=this.getColumn(J,$);if(!Y)continue;if(Y.startsWith("!")||Y.endsWith("!"))continue;this.checkExpression(Y,G,W)}let Z=/\{!!([\s\S]*?)!!\}/g;while((Q=Z.exec($))!==null){let Y=Q[1].trim(),J=Q.index,G=this.getLineNumber(J,$),W=this.getColumn(J,$);if(!Y)continue;this.checkExpression(Y,G,W)}}checkExpression($,X,Q){if($.includes("?")&&$.includes(":")){let J=$.split("?");this.checkExpression(J[0].trim(),X,Q);let G=J.slice(1).join("?").split(":");if(G.length>=2)this.checkExpression(G[0].trim(),X,Q),this.checkExpression(G.slice(1).join(":").trim(),X,Q);return}for(let J of["&&","||","??"])if($.includes(J)){$.split(J).forEach((W)=>this.checkExpression(W.trim(),X,Q));return}for(let J of["===","!==","==","!=",">=","<=",">","<"])if($.includes(J)){$.split(J).forEach((W)=>this.checkExpression(W.trim(),X,Q));return}if($.startsWith("!")){this.checkExpression($.slice(1).trim(),X,Q);return}if(this.isLiteral($))return;let Z=$.match(/^(\w+(?:\.\w+)*)\s*\(/);if(Z){let J=Z[1],G=this.resolvePropertyAccess(J);if(G.kind!=="function"&&G.value!=="any")this.addWarning(`'${J}' is not a function`,X,Q,$);return}if($.includes(".")){if(this.resolvePropertyAccess($).value==="undefined"&&this.options.checkPropertyAccess)this.addWarning(`Property access '${$}' may be undefined`,X,Q,$);return}let Y=$.match(/^\w+/)?.[0];if(Y&&!this.variables.has(Y))this.addError(`Variable '${Y}' is not defined`,X,Q,$)}checkDirectives($){let X=/@if\s*\(([^)]+)\)/g,Q;while((Q=X.exec($))!==null){let G=Q[1].trim(),W=Q.index,K=this.getLineNumber(W,$),_=this.getColumn(W,$);this.checkExpression(G,K,_)}let Z=/@foreach\s*\((\w+)\s+(?:as|in)\s+(\w+)(?:\s*,\s*(\w+))?\)/g;while((Q=Z.exec($))!==null){let[,G,W,K]=Q,_=Q.index,U=this.getLineNumber(_,$),z=this.getColumn(_,$);if(!this.variables.has(G))this.addError(`Collection '${G}' is not defined`,U,z,Q[0]);else{let F=this.variables.get(G);if(F.kind==="array"&&F.elementType)this.variables.set(W,F.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((Q=Y.exec($))!==null){let G=Q[1].trim(),W=Q.index,K=this.getLineNumber(W,$),_=this.getColumn(W,$);this.checkExpression(G,K,_)}let J=/@switch\s*\(([^)]+)\)/g;while((Q=J.exec($))!==null){let G=Q[1].trim(),W=Q.index,K=this.getLineNumber(W,$),_=this.getColumn(W,$);this.checkExpression(G,K,_)}}resolvePropertyAccess($){let X=$.split("."),Q=this.variables.get(X[0])||{kind:"primitive",value:"any"};for(let Z=1;Z<X.length;Z++){let Y=X[Z].replace(/\(\)$/,"");if(Q.kind==="object"&&Q.properties)if(Q.properties[Y])Q=Q.properties[Y];else if(!this.options.allowAny)return{kind:"primitive",value:"undefined"};else Q={kind:"primitive",value:"any"};else if(Q.kind==="array"&&Q.elementType)if(["length"].includes(Y))Q={kind:"primitive",value:"number"};else if(["map","filter","find","forEach","some","every","reduce"].includes(Y))Q={kind:"function",returnType:{kind:"primitive",value:"any"}};else if(["join"].includes(Y))Q={kind:"function",returnType:{kind:"primitive",value:"string"}};else Q={kind:"primitive",value:"any"};else if(Q.kind==="primitive"&&Q.value==="string")if(["length"].includes(Y))Q={kind:"primitive",value:"number"};else if(["toUpperCase","toLowerCase","trim","slice","substring"].includes(Y))Q={kind:"function",returnType:{kind:"primitive",value:"string"}};else if(["split"].includes(Y))Q={kind:"function",returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}};else Q={kind:"primitive",value:"any"};else Q={kind:"primitive",value:"any"}}return Q}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={},Q=$.slice(1,-1).trim();if(!Q)return X;let Z=this.splitByComma(Q);for(let Y of Z){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=[],Q="",Z=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==="(")Z++;if(G==="}"||G==="]"||G===")")Z--;if(G===","&&Z===0){X.push(Q.trim()),Q="";continue}}Q+=G}if(Q.trim())X.push(Q.trim());return X}getLineNumber($,X){return((X||"").slice(0,$).match(/\n/g)||[]).length+1}getColumn($,X){let Z=X.slice(0,$).lastIndexOf(`
2893
- `);return $-Z}addError($,X,Q,Z,Y,J){this.errors.push({message:$,file:this.currentFile,line:X,column:Q,expression:Z,expected:Y,received:J,severity:"error"})}addWarning($,X,Q,Z,Y,J){let G={message:$,file:this.currentFile,line:X,column:Q,expression:Z,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(J8).forEach(([$,X])=>{this.variables.set($,X)})}}function W8($){return new G8($)}function r2($,X){return W8(X).checkFile($)}function s2($,X){return W8(X).checkTemplate($)}function n2($){let X=[];for(let Q of $.errors){if(X.push(`\x1B[31merror\x1B[0m: ${Q.message}`),X.push(` --> ${Q.file}:${Q.line}:${Q.column}`),Q.expression)X.push(" |"),X.push(` | ${Q.expression}`),X.push(" |");if(Q.expected&&Q.received)X.push(` expected: ${Q.expected}`),X.push(` received: ${Q.received}`);X.push("")}for(let Q of $.warnings){if(X.push(`\x1B[33mwarning\x1B[0m: ${Q.message}`),X.push(` --> ${Q.file}:${Q.line}:${Q.column}`),Q.expression)X.push(" |"),X.push(` | ${Q.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(`
2894
- `)}var F5=typeof window<"u"&&typeof document<"u";async function L5($,X,Q){if(!F5)return;try{let Z=$.getAttribute("data-island-id"),Y=document.querySelector(`script[data-island-props="${Z}"]`),J=Y?JSON.parse(Y.textContent||"{}"):{},G=await Q(),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(Z){console.error(`Failed to hydrate island "${X}":`,Z)}}function t2($){if(!F5)return;let X=document.querySelectorAll("[data-island]"),Q=[];if(X.forEach((Z)=>{let Y=Z.getAttribute("data-island"),J=Z.getAttribute("data-priority")||"lazy";if(!Y||!$[Y]||Z.getAttribute("data-hydrated")==="true")return;if(J==="eager")L5(Z,Y,$[Y]);else Q.push([Z,Y])}),Q.length>0&&"IntersectionObserver"in window){let Z=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")L5(G,W,$[W]),Z.unobserve(G)}})},{rootMargin:"200px",threshold:0});Q.forEach(([Y])=>{Z.observe(Y)})}else setTimeout(()=>{Q.forEach(([Z,Y])=>{if(Z.getAttribute("data-hydrated")!=="true")L5(Z,Y,$[Y])})},1000)}function e2($){if(!F5)return;Object.entries($).forEach(([X,Q])=>{try{let Y=Q.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(Z){console.warn(`Failed to preload island handler for "${X}":`,Z)}})}var J1=typeof window<"u"&&typeof document<"u",j5={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999},J0=null,I0=0,k1=!1,z5=null,Y1=null,T0=null;function K8($){if(!J1)return null;let X=document.getElementById("stx-loading-indicator");if(X)X.remove();let Q=document.createElement("div");Q.id="stx-loading-indicator";let Z=$.initialColor?`linear-gradient(to right, ${$.initialColor}, ${$.color})`:$.color;Q.style.cssText=`
2893
+ `);return $-Z}addError($,X,Q,Z,Y,J){this.errors.push({message:$,file:this.currentFile,line:X,column:Q,expression:Z,expected:Y,received:J,severity:"error"})}addWarning($,X,Q,Z,Y,J){let G={message:$,file:this.currentFile,line:X,column:Q,expression:Z,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(G8).forEach(([$,X])=>{this.variables.set($,X)})}}function K8($){return new W8($)}function n2($,X){return K8(X).checkFile($)}function o2($,X){return K8(X).checkTemplate($)}function t2($){let X=[];for(let Q of $.errors){if(X.push(`\x1B[31merror\x1B[0m: ${Q.message}`),X.push(` --> ${Q.file}:${Q.line}:${Q.column}`),Q.expression)X.push(" |"),X.push(` | ${Q.expression}`),X.push(" |");if(Q.expected&&Q.received)X.push(` expected: ${Q.expected}`),X.push(` received: ${Q.received}`);X.push("")}for(let Q of $.warnings){if(X.push(`\x1B[33mwarning\x1B[0m: ${Q.message}`),X.push(` --> ${Q.file}:${Q.line}:${Q.column}`),Q.expression)X.push(" |"),X.push(` | ${Q.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(`
2894
+ `)}var j5=typeof window<"u"&&typeof document<"u";async function z5($,X,Q){if(!j5)return;try{let Z=$.getAttribute("data-island-id"),Y=document.querySelector(`script[data-island-props="${Z}"]`),J=Y?JSON.parse(Y.textContent||"{}"):{},G=await Q(),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(Z){console.error(`Failed to hydrate island "${X}":`,Z)}}function $K($){if(!j5)return;let X=document.querySelectorAll("[data-island]"),Q=[];if(X.forEach((Z)=>{let Y=Z.getAttribute("data-island"),J=Z.getAttribute("data-priority")||"lazy";if(!Y||!$[Y]||Z.getAttribute("data-hydrated")==="true")return;if(J==="eager")z5(Z,Y,$[Y]);else Q.push([Z,Y])}),Q.length>0&&"IntersectionObserver"in window){let Z=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")z5(G,W,$[W]),Z.unobserve(G)}})},{rootMargin:"200px",threshold:0});Q.forEach(([Y])=>{Z.observe(Y)})}else setTimeout(()=>{Q.forEach(([Z,Y])=>{if(Z.getAttribute("data-hydrated")!=="true")z5(Z,Y,$[Y])})},1000)}function XK($){if(!j5)return;Object.entries($).forEach(([X,Q])=>{try{let Y=Q.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(Z){console.warn(`Failed to preload island handler for "${X}":`,Z)}})}var G1=typeof window<"u"&&typeof document<"u",H5={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999},J0=null,I0=0,x1=!1,O5=null,J1=null,T0=null;function _8($){if(!G1)return null;let X=document.getElementById("stx-loading-indicator");if(X)X.remove();let Q=document.createElement("div");Q.id="stx-loading-indicator";let Z=$.initialColor?`linear-gradient(to right, ${$.initialColor}, ${$.color})`:$.color;Q.style.cssText=`
2895
2895
  position: fixed;
2896
2896
  top: 0;
2897
2897
  left: 0;
@@ -2922,7 +2922,7 @@ ${R instanceof Error?R.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An err
2922
2922
  0% { transform: translateX(-100%); }
2923
2923
  100% { transform: translateX(100%); }
2924
2924
  }
2925
- `,document.head.appendChild(J)}return document.body.appendChild(Q),Q}function z$($,X){if(!J1||!J0)return;if(I0=Math.min(Math.max($,0),100),z5)cancelAnimationFrame(z5);z5=requestAnimationFrame(()=>{if(!J0)return;J0.style.opacity=I0>0?"1":"0",J0.style.transform=`scaleX(${I0/100})`})}function GQ($){if(!J1)return;if(k1=!0,I0=0,!J0)J0=K8($);if(Y1)clearTimeout(Y1);if(T0)clearInterval(T0);z$(10,$),T0=setInterval(()=>{if(!k1)return;let X=90-I0,Q=Math.max(0.5,X*0.1);if(I0<90)z$(I0+Q,$)},$.throttle)}function WQ($){if(!J1)return;if(k1=!1,T0)clearInterval(T0),T0=null;z$(100,$),Y1=setTimeout(()=>{if(J0)J0.style.opacity="0";setTimeout(()=>{if(I0=0,J0)J0.style.transform="scaleX(0)"},300)},200)}function KQ(){if(!J1)return;if(k1=!1,I0=0,T0)clearInterval(T0),T0=null;if(Y1)clearTimeout(Y1),Y1=null;if(J0)J0.style.opacity="0",J0.style.transform="scaleX(0)"}function _Q($){let X={...j5,...$};return{start:()=>GQ(X),set:(Q)=>z$(Q,X),finish:()=>WQ(X),clear:()=>KQ(),get state(){return{isLoading:k1,progress:I0,error:!1}}}}var c0=null;function XK($){if(!J1)return;if(c0)c0(),c0=null;let X={...j5,...$},Q=_Q(X);J0=K8(X);let Z=!1,Y=(U)=>{let F=U.target.closest("a");if(!F)return;let O=F.getAttribute("href");if(!O)return;if(O.startsWith("http")||O.startsWith("#")||O.startsWith("mailto:")||O.startsWith("tel:")||F.target==="_blank"||F.hasAttribute("download"))return;Z=!0,Q.start()},J=()=>{if(!Z)Q.start(),Z=!0},G=()=>{if(Z||X.autoFinish)Q.finish(),Z=!1};document.addEventListener("click",Y),window.addEventListener("popstate",J),window.addEventListener("load",G);let W=window.fetch,K=0,_=async function(...U){let z=typeof U[0]==="string"?U[0]:U[0].url,F=z.includes("/api/")||z.startsWith("/api");if(F){if(K++,K===1&&!Z)Q.start()}try{return await W.apply(this,U)}finally{if(F){if(K--,K===0&&!Z)Q.finish()}}};window.fetch=_,c0=()=>{if(document.removeEventListener("click",Y),window.removeEventListener("popstate",J),window.removeEventListener("load",G),window.fetch===_)window.fetch=W}}function QK(){if(c0)c0(),c0=null}function ZK($){let X={...j5,...$},Q=X.initialColor?`linear-gradient(to right, ${X.initialColor}, ${X.color})`:X.color;return`
2925
+ `,document.head.appendChild(J)}return document.body.appendChild(Q),Q}function z$($,X){if(!G1||!J0)return;if(I0=Math.min(Math.max($,0),100),O5)cancelAnimationFrame(O5);O5=requestAnimationFrame(()=>{if(!J0)return;J0.style.opacity=I0>0?"1":"0",J0.style.transform=`scaleX(${I0/100})`})}function WQ($){if(!G1)return;if(x1=!0,I0=0,!J0)J0=_8($);if(J1)clearTimeout(J1);if(T0)clearInterval(T0);z$(10,$),T0=setInterval(()=>{if(!x1)return;let X=90-I0,Q=Math.max(0.5,X*0.1);if(I0<90)z$(I0+Q,$)},$.throttle)}function KQ($){if(!G1)return;if(x1=!1,T0)clearInterval(T0),T0=null;z$(100,$),J1=setTimeout(()=>{if(J0)J0.style.opacity="0";setTimeout(()=>{if(I0=0,J0)J0.style.transform="scaleX(0)"},300)},200)}function _Q(){if(!G1)return;if(x1=!1,I0=0,T0)clearInterval(T0),T0=null;if(J1)clearTimeout(J1),J1=null;if(J0)J0.style.opacity="0",J0.style.transform="scaleX(0)"}function UQ($){let X={...H5,...$};return{start:()=>WQ(X),set:(Q)=>z$(Q,X),finish:()=>KQ(X),clear:()=>_Q(),get state(){return{isLoading:x1,progress:I0,error:!1}}}}var l0=null;function ZK($){if(!G1)return;if(l0)l0(),l0=null;let X={...H5,...$},Q=UQ(X);J0=_8(X);let Z=!1,Y=(U)=>{let F=U.target.closest("a");if(!F)return;let j=F.getAttribute("href");if(!j)return;if(j.startsWith("http")||j.startsWith("#")||j.startsWith("mailto:")||j.startsWith("tel:")||F.target==="_blank"||F.hasAttribute("download"))return;Z=!0,Q.start()},J=()=>{if(!Z)Q.start(),Z=!0},G=()=>{if(Z||X.autoFinish)Q.finish(),Z=!1};document.addEventListener("click",Y),window.addEventListener("popstate",J),window.addEventListener("load",G);let W=window.fetch,K=0,_=async function(...U){let z=typeof U[0]==="string"?U[0]:U[0].url,F=z.includes("/api/")||z.startsWith("/api");if(F){if(K++,K===1&&!Z)Q.start()}try{return await W.apply(this,U)}finally{if(F){if(K--,K===0&&!Z)Q.finish()}}};window.fetch=_,l0=()=>{if(document.removeEventListener("click",Y),window.removeEventListener("popstate",J),window.removeEventListener("load",G),window.fetch===_)window.fetch=W}}function YK(){if(l0)l0(),l0=null}function JK($){let X={...H5,...$},Q=X.initialColor?`linear-gradient(to right, ${X.initialColor}, ${X.color})`:X.color;return`
2926
2926
  <div id="stx-loading-indicator" style="
2927
2927
  position: fixed;
2928
2928
  top: 0;
@@ -3016,11 +3016,11 @@ ${R instanceof Error?R.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An err
3016
3016
  window.addEventListener('load', function() { window.stxLoading.finish(); });
3017
3017
  })();
3018
3018
  </script>
3019
- `}function JK($,X){let Q=[],Z=`${X}=`;for(let Y=0;Y<$.length;Y++){let J=$[Y];if(J.startsWith(Z)){let G=J.slice(Z.length);if(G)Q.push(G);continue}if(J===X){let G=$[Y+1];if(G!==void 0&&!G.startsWith("-"))Q.push(G),Y++}}return Q}class _8{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((Q)=>this.instances.get(Q)).filter(Boolean)}getInstance($){return this.instances.get($)}captureState($){let X=this.instances.get($);if(!X||!this.config.preserveState)return;let Q=this.config.serializeState(X);if(this.stateSnapshots.set($,Q),this.config.verbose)console.log(`[HMR] Captured state for: ${X.name}`)}restoreState($){let X=this.instances.get($),Q=this.stateSnapshots.get($);if(!X||!Q||!this.config.preserveState)return!1;if(Date.now()-Q.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(Q,X),this.config.verbose)console.log(`[HMR] Restored state for: ${X.name}`);return!0}catch(Z){return console.error(`[HMR] Failed to restore state for ${X.name}:`,Z),!1}}defaultSerializeState($){let X={},Q={};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:Q,custom:$.state?.custom||{},timestamp:Date.now()}}defaultDeserializeState($,X){if(X.element)Object.entries($.refs).forEach(([Q,Z])=>{let Y=X.element.querySelector(`[data-stx-ref="${Q}"]`);if(Y)Y.setAttribute("data-stx-value",JSON.stringify(Z)),Y.dispatchEvent(new CustomEvent("stx:state-restored",{detail:{name:Q,value:Z},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 U8{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 _8(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 Q of X)await this.updateInstance(Q,$);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 Q=!1,Z=$.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(Q=!0,console.error(`[HMR] Error updating component ${$.name}:`,Y),this.config.errorRecovery){if($.element&&Z)$.element.innerHTML=Z,console.log(`[HMR] Recovered previous state for: ${$.name}`);$.element?.dispatchEvent(new CustomEvent("stx:hmr-error",{detail:{error:Y},bubbles:!0}))}}if(!Q&&this.config.verbose)console.log(`[HMR] Successfully updated: ${$.name}`)}async updateComponent($,X){if(!$.element)return;let{html:Q,script:Z}=this.parseComponentCode(X.code);if(Q)$.element.innerHTML=Q;if(Z)await this.executeScript(Z,$);if($.render)$.element.innerHTML=$.render();this.reinitializeInteractivity($)}async updateStyles($,X){if(!$.element)return;let Q=X.code.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(!Q)return;let Z=Q[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=Z,this.config.verbose)console.log(`[HMR] Updated styles for: ${$.name}`)}parseComponentCode($){let X=$,Q="",Z="",Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)Q=Y[1],X=X.replace(Y[0],"");let J=$.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(J)Z=J[1],X=X.replace(J[0],"");return{html:X.trim(),script:Q.trim(),style:Z.trim()}}async executeScript($,X){try{let Q={element:X.element,props:X.props,...typeof window<"u"?window.stx:{}},Z=`
3019
+ `}function WK($,X){let Q=[],Z=`${X}=`;for(let Y=0;Y<$.length;Y++){let J=$[Y];if(J.startsWith(Z)){let G=J.slice(Z.length);if(G)Q.push(G);continue}if(J===X){let G=$[Y+1];if(G!==void 0&&!G.startsWith("-"))Q.push(G),Y++}}return Q}class U8{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((Q)=>this.instances.get(Q)).filter(Boolean)}getInstance($){return this.instances.get($)}captureState($){let X=this.instances.get($);if(!X||!this.config.preserveState)return;let Q=this.config.serializeState(X);if(this.stateSnapshots.set($,Q),this.config.verbose)console.log(`[HMR] Captured state for: ${X.name}`)}restoreState($){let X=this.instances.get($),Q=this.stateSnapshots.get($);if(!X||!Q||!this.config.preserveState)return!1;if(Date.now()-Q.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(Q,X),this.config.verbose)console.log(`[HMR] Restored state for: ${X.name}`);return!0}catch(Z){return console.error(`[HMR] Failed to restore state for ${X.name}:`,Z),!1}}defaultSerializeState($){let X={},Q={};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:Q,custom:$.state?.custom||{},timestamp:Date.now()}}defaultDeserializeState($,X){if(X.element)Object.entries($.refs).forEach(([Q,Z])=>{let Y=X.element.querySelector(`[data-stx-ref="${Q}"]`);if(Y)Y.setAttribute("data-stx-value",JSON.stringify(Z)),Y.dispatchEvent(new CustomEvent("stx:state-restored",{detail:{name:Q,value:Z},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 B8{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 U8(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 Q of X)await this.updateInstance(Q,$);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 Q=!1,Z=$.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(Q=!0,console.error(`[HMR] Error updating component ${$.name}:`,Y),this.config.errorRecovery){if($.element&&Z)$.element.innerHTML=Z,console.log(`[HMR] Recovered previous state for: ${$.name}`);$.element?.dispatchEvent(new CustomEvent("stx:hmr-error",{detail:{error:Y},bubbles:!0}))}}if(!Q&&this.config.verbose)console.log(`[HMR] Successfully updated: ${$.name}`)}async updateComponent($,X){if(!$.element)return;let{html:Q,script:Z}=this.parseComponentCode(X.code);if(Q)$.element.innerHTML=Q;if(Z)await this.executeScript(Z,$);if($.render)$.element.innerHTML=$.render();this.reinitializeInteractivity($)}async updateStyles($,X){if(!$.element)return;let Q=X.code.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(!Q)return;let Z=Q[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=Z,this.config.verbose)console.log(`[HMR] Updated styles for: ${$.name}`)}parseComponentCode($){let X=$,Q="",Z="",Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)Q=Y[1],X=X.replace(Y[0],"");let J=$.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(J)Z=J[1],X=X.replace(J[0],"");return{html:X.trim(),script:Q.trim(),style:Z.trim()}}async executeScript($,X){try{let Q={element:X.element,props:X.props,...typeof window<"u"?window.stx:{}},Z=`
3020
3020
  return (async function() {
3021
3021
  ${$}
3022
3022
  })()
3023
- `;await Function(...Object.keys(Q),Z)(...Object.values(Q))}catch(Q){throw console.error("[HMR] Script execution error:",Q),Q}}reinitializeInteractivity($){if(!$.element)return;$.element.querySelectorAll("[data-stx-events]").forEach((Q)=>{let Z=Q.getAttribute("data-stx-events");if(!Z)return;try{let Y=JSON.parse(Z);for(let[J,G]of Object.entries(Y))if(typeof window<"u"&&window.stx?.[G])Q.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 Q of X)if(Q.render&&Q.element)this.registry.captureState(Q.id),Q.element.innerHTML=Q.render(),this.registry.restoreState(Q.id),this.reinitializeInteractivity(Q)}}function WK($){return`
3023
+ `;await Function(...Object.keys(Q),Z)(...Object.values(Q))}catch(Q){throw console.error("[HMR] Script execution error:",Q),Q}}reinitializeInteractivity($){if(!$.element)return;$.element.querySelectorAll("[data-stx-events]").forEach((Q)=>{let Z=Q.getAttribute("data-stx-events");if(!Z)return;try{let Y=JSON.parse(Z);for(let[J,G]of Object.entries(Y))if(typeof window<"u"&&window.stx?.[G])Q.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 Q of X)if(Q.render&&Q.element)this.registry.captureState(Q.id),Q.element.innerHTML=Q.render(),this.registry.restoreState(Q.id),this.reinitializeInteractivity(Q)}}function _K($){return`
3024
3024
  <script data-stx-hmr-client>
3025
3025
  (function() {
3026
3026
  'use strict';
@@ -3247,7 +3247,7 @@ else {
3247
3247
  };
3248
3248
  })();
3249
3249
  </script>
3250
- `}function KK($,X,Q,Z){return`
3250
+ `}function UK($,X,Q,Z){return`
3251
3251
  <div data-stx-component="${$}" data-stx-name="${X}">
3252
3252
  ${Q}
3253
3253
  </div>
@@ -3287,8 +3287,8 @@ else {
3287
3287
  observer.observe(document.body, { childList: true, subtree: true });
3288
3288
  })();
3289
3289
  </script>
3290
- `}var G1=null;function _K($){if(!G1)G1=new U8($);return G1}function UK(){if(G1)G1.getRegistry().clear(),G1=null}function UQ($){let X={refs:$.refs||{},reactive:$.reactive||{},props:$.props||{},routeParams:$.routeParams||{},stores:$.stores||{},meta:$.meta||{},timestamp:Date.now()};return X.checksum=B8(X),JSON.stringify(X).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/'/g,"\\u0027")}function B8($){let X=JSON.stringify({refs:Object.keys($.refs||{}),reactive:Object.keys($.reactive||{}),props:Object.keys($.props||{})}),Q=0;for(let Z=0;Z<X.length;Z++){let Y=X.charCodeAt(Z);Q=(Q<<5)-Q+Y,Q=Q&Q}return Math.abs(Q).toString(36)}function BQ($){return`<script id="__STX_STATE__" type="application/json">${UQ($)}</script>`}function LK($){if($.length===0)return"";return`data-stx-events='${JSON.stringify($)}'`}function LQ(){if(typeof window>"u")return null;let $=document.getElementById("__STX_STATE__");if(!$)return null;try{let X=JSON.parse($.textContent||"{}");if(X.checksum){if(B8(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 L8{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=LQ(),this.options.onHydrating(),this.root.classList.add("stx-hydrating");let X=new Promise((Q,Z)=>{setTimeout(()=>Z(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 Q=performance.now()-$;console.log(`[Hydration] Completed in ${Q.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,Q])=>{$.registerStore(X,Q)});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 Q=X.getAttribute("data-stx-component"),Z=X.getAttribute("data-stx-name")||Q,Y=X.getAttribute("data-stx-hydrate")||"eager",J=X.getAttribute("data-stx-props");if(!Q)continue;let G={id:Q,name:Z||Q,strategy:Y,props:J?JSON.parse(J):{},events:[]};switch(this.pendingComponents.set(Q,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 Q=this.state?.refs[X.id]||this.state?.reactive[X.id]||{};this.restoreComponentState($,Q),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(Q){if(console.error(`[Hydration] Failed to hydrate component ${X.id}:`,Q),$.classList.add("stx-hydration-error"),this.options.strict)throw Q}}restoreComponentState($,X){if(!X||typeof X!=="object")return;$.querySelectorAll("[data-stx-bind]").forEach((Z)=>{let Y=Z.getAttribute("data-stx-bind");if(!Y||!X[Y])return;let J=X[Y];if(Z instanceof HTMLInputElement)if(Z.type==="checkbox"||Z.type==="radio")Z.checked=Boolean(J);else Z.value=String(J);else if(Z instanceof HTMLSelectElement)Z.value=String(J);else if(Z instanceof HTMLTextAreaElement)Z.value=String(J);else Z.textContent=String(J)})}setupVisibleHydration($,X){if(!("IntersectionObserver"in window)){this.hydrateComponent($,X);return}let Q=new IntersectionObserver((Z)=>{Z.forEach((Y)=>{if(Y.isIntersecting)Q.disconnect(),this.hydrateComponent($,X)})},{rootMargin:"100px",threshold:0});Q.observe($)}setupIdleHydration($,X){let Q=()=>this.hydrateComponent($,X);if("requestIdleCallback"in window)window.requestIdleCallback(Q,{timeout:2000});else setTimeout(Q,200)}setupInteractionHydration($,X){let Q=["mouseenter","touchstart","focusin"],Z=()=>{Q.forEach((Y)=>$.removeEventListener(Y,Z)),this.hydrateComponent($,X)};Q.forEach((Y)=>{$.addEventListener(Y,Z,{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((Z)=>{this.bindSingleEvent($,Z)})}catch(Q){console.error("[Hydration] Failed to parse events:",Q)}}bindDirectiveEvents(){if(!this.root)return;["click","submit","input","change","focus","blur","keydown","keyup","keypress","mouseenter","mouseleave","touchstart","touchend","scroll","resize"].forEach((X)=>{let Q=`data-stx-on-${X}`;this.root.querySelectorAll(`[${Q}]`).forEach((Y)=>{let J=Y.getAttribute(Q);if(!J)return;this.bindSingleEvent(Y,{type:X,handler:J,modifiers:this.parseModifiers(Y,X)})})})}parseModifiers($,X){let Q=[],Z=$.getAttribute(`data-stx-${X}-modifiers`);if(Z)Q.push(...Z.split(",").map((Y)=>Y.trim()));return Q}bindSingleEvent($,X){let Q=this.resolveHandler(X.handler);if(!Q){console.warn(`[Hydration] Handler not found: ${X.handler}`);return}let Z=(J)=>{if(X.modifiers?.includes("prevent")||X.preventDefault)J.preventDefault();if(X.modifiers?.includes("stop")||X.stopPropagation)J.stopPropagation();try{Q.call($,J)}catch(G){console.error("[Hydration] Event handler error:",G)}},Y={};if(X.modifiers?.includes("once"))Y.once=!0;if(X.modifiers?.includes("passive"))Y.passive=!0;if(X.modifiers?.includes("capture"))Y.capture=!0;$.addEventListener(X.type,Z,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 Q=$.match(/^(\w+)\s*=\s*(.+)$/);if(Q){let[,Y,J]=Q;return()=>{if(X&&X[Y]){let G=Function(`return ${J}`)();if(typeof X[Y].value<"u")X[Y].value=G}}}let Z=$.match(/^(\w+)\((.*)\)$/);if(Z){let[,Y,J]=Z;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((Q)=>{this.bindElementEvents(Q)})}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:Q,expressions:Z})=>{Z.forEach((Y)=>{this.setupTextNodeBinding(Q,Y)})}),this.root.querySelectorAll("[data-stx-bind-attrs]").forEach((Q)=>{let Z=Q.getAttribute("data-stx-bind-attrs");if(!Z)return;try{let Y=JSON.parse(Z);Object.entries(Y).forEach(([J,G])=>{this.setupAttributeBinding(Q,J,G)})}catch{}})}getTextNodesWithExpressions($){let X=[],Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),Z;while(Z=Q.nextNode()){let J=(Z.textContent||"").match(/\{\{\s*([^}]+)\s*\}\}/g);if(J)X.push({node:Z,expressions:J.map((G)=>G.replace(/\{\{\s*|\s*\}\}/g,""))})}return X}setupTextNodeBinding($,X){let Q=window.stx;if(!Q)return;let Z=$.textContent||"",Y=()=>{try{let G=Function("stx",`with(stx) { return ${X} }`)(Q);$.textContent=Z.replace(new RegExp(`\\{\\{\\s*${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\}\\}`),String(G))}catch{}};Y();let J=X.match(/^(\w+)(\.value)?$/);if(J&&Q[J[1]]?.subscribe)Q[J[1]].subscribe(Y)}setupAttributeBinding($,X,Q){let Z=window.stx;if(!Z)return;let Y=()=>{try{let G=Function("stx",`with(stx) { return ${Q} }`)(Z);if(typeof G==="boolean")if(G)$.setAttribute(X,"");else $.removeAttribute(X);else $.setAttribute(X,String(G))}catch{}};Y();let J=Q.match(/^(\w+)(\.value)?$/);if(J&&Z[J[1]]?.subscribe)Z[J[1]].subscribe(Y)}setupReactiveBinding($,X){let Q=window.stx;if(!Q)return;let Z=()=>{try{let J=Function("stx",`with(stx) { return ${X} }`)(Q);$.textContent=String(J)}catch{}};Z();let Y=X.match(/^(\w+)(\.value)?$/);if(Y&&Q[Y[1]]?.subscribe)Q[Y[1]].subscribe(Z)}setupRouterIntegration(){window.addEventListener("stx:navigate",($)=>{let{url:X}=$.detail||{};if(X){if(window.stx?.setRouteParams){let Z=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($),Q=document.querySelector(`[data-stx-component="${$}"]`);if(X&&Q)await this.hydrateComponent(Q,X)}}function FK($){return`
3291
- ${$?BQ($):""}
3290
+ `}var W1=null;function BK($){if(!W1)W1=new B8($);return W1}function LK(){if(W1)W1.getRegistry().clear(),W1=null}function BQ($){let X={refs:$.refs||{},reactive:$.reactive||{},props:$.props||{},routeParams:$.routeParams||{},stores:$.stores||{},meta:$.meta||{},timestamp:Date.now()};return X.checksum=L8(X),JSON.stringify(X).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/'/g,"\\u0027")}function L8($){let X=JSON.stringify({refs:Object.keys($.refs||{}),reactive:Object.keys($.reactive||{}),props:Object.keys($.props||{})}),Q=0;for(let Z=0;Z<X.length;Z++){let Y=X.charCodeAt(Z);Q=(Q<<5)-Q+Y,Q=Q&Q}return Math.abs(Q).toString(36)}function LQ($){return`<script id="__STX_STATE__" type="application/json">${BQ($)}</script>`}function zK($){if($.length===0)return"";return`data-stx-events='${JSON.stringify($)}'`}function FQ(){if(typeof window>"u")return null;let $=document.getElementById("__STX_STATE__");if(!$)return null;try{let X=JSON.parse($.textContent||"{}");if(X.checksum){if(L8(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 F8{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=FQ(),this.options.onHydrating(),this.root.classList.add("stx-hydrating");let X=new Promise((Q,Z)=>{setTimeout(()=>Z(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 Q=performance.now()-$;console.log(`[Hydration] Completed in ${Q.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,Q])=>{$.registerStore(X,Q)});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 Q=X.getAttribute("data-stx-component"),Z=X.getAttribute("data-stx-name")||Q,Y=X.getAttribute("data-stx-hydrate")||"eager",J=X.getAttribute("data-stx-props");if(!Q)continue;let G={id:Q,name:Z||Q,strategy:Y,props:J?JSON.parse(J):{},events:[]};switch(this.pendingComponents.set(Q,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 Q=this.state?.refs[X.id]||this.state?.reactive[X.id]||{};this.restoreComponentState($,Q),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(Q){if(console.error(`[Hydration] Failed to hydrate component ${X.id}:`,Q),$.classList.add("stx-hydration-error"),this.options.strict)throw Q}}restoreComponentState($,X){if(!X||typeof X!=="object")return;$.querySelectorAll("[data-stx-bind]").forEach((Z)=>{let Y=Z.getAttribute("data-stx-bind");if(!Y||!X[Y])return;let J=X[Y];if(Z instanceof HTMLInputElement)if(Z.type==="checkbox"||Z.type==="radio")Z.checked=Boolean(J);else Z.value=String(J);else if(Z instanceof HTMLSelectElement)Z.value=String(J);else if(Z instanceof HTMLTextAreaElement)Z.value=String(J);else Z.textContent=String(J)})}setupVisibleHydration($,X){if(!("IntersectionObserver"in window)){this.hydrateComponent($,X);return}let Q=new IntersectionObserver((Z)=>{Z.forEach((Y)=>{if(Y.isIntersecting)Q.disconnect(),this.hydrateComponent($,X)})},{rootMargin:"100px",threshold:0});Q.observe($)}setupIdleHydration($,X){let Q=()=>this.hydrateComponent($,X);if("requestIdleCallback"in window)window.requestIdleCallback(Q,{timeout:2000});else setTimeout(Q,200)}setupInteractionHydration($,X){let Q=["mouseenter","touchstart","focusin"],Z=()=>{Q.forEach((Y)=>$.removeEventListener(Y,Z)),this.hydrateComponent($,X)};Q.forEach((Y)=>{$.addEventListener(Y,Z,{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((Z)=>{this.bindSingleEvent($,Z)})}catch(Q){console.error("[Hydration] Failed to parse events:",Q)}}bindDirectiveEvents(){if(!this.root)return;["click","submit","input","change","focus","blur","keydown","keyup","keypress","mouseenter","mouseleave","touchstart","touchend","scroll","resize"].forEach((X)=>{let Q=`data-stx-on-${X}`;this.root.querySelectorAll(`[${Q}]`).forEach((Y)=>{let J=Y.getAttribute(Q);if(!J)return;this.bindSingleEvent(Y,{type:X,handler:J,modifiers:this.parseModifiers(Y,X)})})})}parseModifiers($,X){let Q=[],Z=$.getAttribute(`data-stx-${X}-modifiers`);if(Z)Q.push(...Z.split(",").map((Y)=>Y.trim()));return Q}bindSingleEvent($,X){let Q=this.resolveHandler(X.handler);if(!Q){console.warn(`[Hydration] Handler not found: ${X.handler}`);return}let Z=(J)=>{if(X.modifiers?.includes("prevent")||X.preventDefault)J.preventDefault();if(X.modifiers?.includes("stop")||X.stopPropagation)J.stopPropagation();try{Q.call($,J)}catch(G){console.error("[Hydration] Event handler error:",G)}},Y={};if(X.modifiers?.includes("once"))Y.once=!0;if(X.modifiers?.includes("passive"))Y.passive=!0;if(X.modifiers?.includes("capture"))Y.capture=!0;$.addEventListener(X.type,Z,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 Q=$.match(/^(\w+)\s*=\s*(.+)$/);if(Q){let[,Y,J]=Q;return()=>{if(X&&X[Y]){let G=Function(`return ${J}`)();if(typeof X[Y].value<"u")X[Y].value=G}}}let Z=$.match(/^(\w+)\((.*)\)$/);if(Z){let[,Y,J]=Z;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((Q)=>{this.bindElementEvents(Q)})}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:Q,expressions:Z})=>{Z.forEach((Y)=>{this.setupTextNodeBinding(Q,Y)})}),this.root.querySelectorAll("[data-stx-bind-attrs]").forEach((Q)=>{let Z=Q.getAttribute("data-stx-bind-attrs");if(!Z)return;try{let Y=JSON.parse(Z);Object.entries(Y).forEach(([J,G])=>{this.setupAttributeBinding(Q,J,G)})}catch{}})}getTextNodesWithExpressions($){let X=[],Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),Z;while(Z=Q.nextNode()){let J=(Z.textContent||"").match(/\{\{\s*([^}]+)\s*\}\}/g);if(J)X.push({node:Z,expressions:J.map((G)=>G.replace(/\{\{\s*|\s*\}\}/g,""))})}return X}setupTextNodeBinding($,X){let Q=window.stx;if(!Q)return;let Z=$.textContent||"",Y=()=>{try{let G=Function("stx",`with(stx) { return ${X} }`)(Q);$.textContent=Z.replace(new RegExp(`\\{\\{\\s*${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\}\\}`),String(G))}catch{}};Y();let J=X.match(/^(\w+)(\.value)?$/);if(J&&Q[J[1]]?.subscribe)Q[J[1]].subscribe(Y)}setupAttributeBinding($,X,Q){let Z=window.stx;if(!Z)return;let Y=()=>{try{let G=Function("stx",`with(stx) { return ${Q} }`)(Z);if(typeof G==="boolean")if(G)$.setAttribute(X,"");else $.removeAttribute(X);else $.setAttribute(X,String(G))}catch{}};Y();let J=Q.match(/^(\w+)(\.value)?$/);if(J&&Z[J[1]]?.subscribe)Z[J[1]].subscribe(Y)}setupReactiveBinding($,X){let Q=window.stx;if(!Q)return;let Z=()=>{try{let J=Function("stx",`with(stx) { return ${X} }`)(Q);$.textContent=String(J)}catch{}};Z();let Y=X.match(/^(\w+)(\.value)?$/);if(Y&&Q[Y[1]]?.subscribe)Q[Y[1]].subscribe(Z)}setupRouterIntegration(){window.addEventListener("stx:navigate",($)=>{let{url:X}=$.detail||{};if(X){if(window.stx?.setRouteParams){let Z=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($),Q=document.querySelector(`[data-stx-component="${$}"]`);if(X&&Q)await this.hydrateComponent(Q,X)}}function jK($){return`
3291
+ ${$?LQ($):""}
3292
3292
  <script data-stx-hydration-runtime>
3293
3293
  (function() {
3294
3294
  'use strict';
@@ -3385,7 +3385,7 @@ else {
3385
3385
  }
3386
3386
  })();
3387
3387
  </script>
3388
- `}var O5=null;function FQ($){if(!O5)O5=new L8($);return O5}async function zK($){await FQ($).hydrate()}function jK(){return`
3388
+ `}var A5=null;function zQ($){if(!A5)A5=new F8($);return A5}async function OK($){await zQ($).hydrate()}function HK(){return`
3389
3389
  <style data-stx-hydration-styles>
3390
3390
  /* Pre-hydration state */
3391
3391
  [data-stx-component]:not(.stx-hydrated) {
@@ -3418,14 +3418,14 @@ else {
3418
3418
  }
3419
3419
  }
3420
3420
  </style>
3421
- `}import F8 from"path";H6();class zQ{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,Q){this.store.set($,{data:{...X},expires:Date.now()+Q*1000})}async delete($){this.store.delete($)}}async function IK($,X={},Q={}){let Z=Q.viewsDir||"./views",Y=Q.layoutsDir||"./layouts",J=!$.includes("<")&&!$.includes("@"),G,W;if(J){if(W=F8.resolve(Z,$),!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:F8.dirname(W)};if(Q.ctx)K.csrf_token=Q.ctx.csrfToken,K.csrf_field=`<input type="hidden" name="_token" value="${Q.ctx.csrfToken}">`,K.old=Q.ctx.old,K.errors=Q.ctx.errors,K.session=Q.ctx.session,K.user=Q.ctx.user(),K.isAuthenticated=Q.ctx.isAuthenticated();let _=G.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(_){let j=_[1];G=G.replace(/<script\s+server\b[^>]*>[\s\S]*?<\/script>/gi,""),await j0(j,K,W)}let U={layoutsDir:Y,...Q.stxOptions},F=await O0(G,K,W,U,new Set),O=new Headers({"Content-Type":"text/html; charset=utf-8"});if(Q.ctx)Q.ctx.responseHeaders.forEach((j,L)=>{O.set(L,j)});return new Response(F,{headers:O})}var S1={stores:new Map,subscriptions:new Map};function jQ($,X){S1.stores.set($,X)}function j8($){return S1.stores.get($)}function OQ($){return S1.stores.has($)}function HQ(){return Array.from(S1.stores.keys())}var W1=new Map;function z8($){if($==="memory")return{getItem:(X)=>W1.get(X)??null,setItem:(X,Q)=>W1.set(X,Q),removeItem:(X)=>W1.delete(X)};if(typeof window>"u")return{getItem:(X)=>W1.get(X)??null,setItem:(X,Q)=>W1.set(X,Q),removeItem:(X)=>W1.delete(X)};return $==="local"?window.localStorage:window.sessionStorage}function AQ($,X){let Q={};for(let Z of X){let Y=Z.split("."),J=$,G=Q,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 Q}function O8($,X={}){let{name:Q,persist:Z,devtools:Y=!1,middleware:J=[],equals:G=(H,A)=>H===A}=X,W=$,K=new Set,_=null;if(Z){let H=z8(Z.storage||"local"),A=Z.key||`stx-store:${Q||"unnamed"}`,q=Z.deserialize||JSON.parse;try{let M=H.getItem(A);if(M){let V=q(M);if(Z.paths&&typeof V==="object"&&V!==null)W={...$,...V};else W=V}}catch{}}let U=(H)=>{if(!Z)return;let A=z8(Z.storage||"local"),q=Z.key||`stx-store:${Q||"unnamed"}`,M=Z.serialize||JSON.stringify,V=Z.paths&&typeof H==="object"&&H!==null?AQ(H,Z.paths):H;if(Z.debounce){if(_)clearTimeout(_);_=setTimeout(()=>{A.setItem(q,M(V))},Z.debounce)}else A.setItem(q,M(V))},z=(H,A)=>{for(let q of K)try{q(H,A)}catch(M){console.error("[stx-store] Subscriber error:",M)}},F=Y?(H,A)=>{if(d6(Q||"unnamed",H,W,A),typeof window<"u")window.__STX_DEVTOOLS__?.onStoreChange?.(Q||"unnamed",H,A)}:()=>{},O=(H)=>{let A=W;if(!G(H,A))W=H,U(H),z(H,A),F("set",H)},j=O,L={get:()=>W,set:(H)=>{if(typeof H==="function")j(H(W));else j(H)},subscribe:(H)=>{return K.add(H),()=>{K.delete(H)}},update:(H)=>{if(typeof W!=="object"||W===null)throw Error("update() can only be used with object stores");let A=typeof H==="function"?H(W):H;L.set({...W,...A})},reset:()=>{L.set($),F("reset",$)},name:Q,destroy:()=>{if(K.clear(),_)clearTimeout(_);if(Q)S1.stores.delete(Q)}};for(let H of J.reverse())j=H(O,()=>W,L)(j);if(Q){if(jQ(Q,L),Y)h6(Q,W??{},{},[])}return L}function qQ($){let X=typeof $==="string"?j8($):$;if(!X)throw Error(`Store "${$}" not found`);return X.get()}function NQ($,X,Q){if(typeof X==="function"){if(typeof window<"u"&&window.stx?.defineStore)return window.stx.defineStore($,X,Q);return X()}let Z=X,{state:Y,getters:J={},actions:G={},persist:W,devtools:K=!0}=Z,_=typeof Y==="function"?Y():Y,U=W===!0?{storage:"local",key:`stx-store:${$}`}:W||void 0,z=O8(_,{name:$,persist:U,devtools:K}),F=new Proxy({},{get(O,j){let L=String(j);if(L==="$state")return z.get();if(L==="$subscribe")return z.subscribe;if(L==="$reset")return z.reset;if(L==="$patch")return(A)=>{if(typeof A==="function"){let M={...z.get()};A(M),z.set(M)}else z.update(A)};if(L==="_store")return z;if(L==="$id")return $;if(L in J)return J[L](z.get());if(L in G)return(...A)=>{return G[L].apply(F,A)};let H=z.get();if(H&&typeof H==="object"&&L in H)return H[L];return},set(O,j,L){let H=String(j);if(H.startsWith("$")||H==="_store")return!1;let A=z.get();if(A&&typeof A==="object")return z.set({...A,[H]:L}),!0;return!1},has(O,j){let L=String(j),H=z.get();return L.startsWith("$")||L==="_store"||L in J||L in G||H&&typeof H==="object"&&L in H},ownKeys(){let O=z.get();return[...O&&typeof O==="object"?Object.keys(O):[],...Object.keys(J),...Object.keys(G),"$state","$subscribe","$reset","$patch","$id"]},getOwnPropertyDescriptor(O,j){return{enumerable:!0,configurable:!0,get:()=>this.get(O,j,F)}}});return MQ.set($,F),F}var MQ=new Map;function VQ($){if(typeof window>"u")return;let X=window;X.__STX_STORES__=X.__STX_STORES__||{};for(let[Q,Z]of Object.entries($))X.__STX_STORES__[Q]=Z;window.dispatchEvent(new CustomEvent("stx:stores-ready",{detail:Object.keys($)}))}function h($,X={}){let Q=[];for(let[Y,J]of Object.entries(X)){if(J===void 0||J===null)continue;if(Array.isArray(J))Q.push(`${Y}=${encodeURIComponent(J.join(","))}`);else if(typeof J==="boolean"){if(J)Q.push(`${Y}=true`)}else Q.push(`${Y}=${encodeURIComponent(String(J))}`)}if(Q.length===0)return $;let Z=$.includes("?")?"&":"?";return`${$}${Z}${Q.join("&")}`}function H8($){let X=$.indexOf("?");if(X===-1)return{src:$,params:{}};let Q=$.slice(0,X),Z=$.slice(X+1),Y={};for(let J of Z.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:Q,params:Y}}function H5(...$){let X={};for(let Q of $)if(Q)Object.assign(X,Q);return X}function A8($,X,Q,Z){let Y={w:X};if(Q)Y.h=Q;if(Z)Y.fit=Z;return h($,Y)}function q8($,X,Q,Z="center"){return h($,{w:X,h:Q,fit:"crop",crop:Z})}function N8($,X,Q="center"){return h($,{w:X,h:X,fit:"crop",crop:Q})}function M8($,X,Q){return h($,{w:X,h:Q,fit:"max"})}function V8($,X,Q){return h($,{w:X,h:Q,fit:"crop"})}function E8($,X){return h($,{blur:Math.min(2000,Math.max(0,X))})}function I8($,X){return h($,{sharp:Math.min(100,Math.max(0,X))})}function R8($){return h($,{sat:-100})}function D8($,X=100){return h($,{sepia:Math.min(100,Math.max(0,X))})}function w8($){return h($,{invert:!0})}function T8($,X){return h($,{bri:Math.min(100,Math.max(-100,X))})}function C8($,X){return h($,{con:Math.min(100,Math.max(-100,X))})}function x8($,X){return h($,{sat:Math.min(100,Math.max(-100,X))})}function k8($,X){return h($,{rot:(X%360+360)%360})}function S8($){return h($,{flip:"h"})}function P8($){return h($,{flip:"v"})}function b8($,X,Q){let Z={fm:X};if(Q!==void 0)Z.q=Q;return h($,Z)}function y8($,X){return h($,{q:Math.min(100,Math.max(1,X))})}function v8($,X=["format","compress"]){return h($,{auto:X})}function g8($,X,Q={}){return h($,{mark:X,markx:Q.x,marky:Q.y,markalpha:Q.alpha,markscale:Q.scale,markalign:Q.align})}var A5={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 f8($,X,Q){return h($,H5(A5[X],Q))}function h8($,X,Q){return X.map((Z)=>h($,{...Q,w:Z}))}function d8($,X,Q=[1,2,3],Z){return Q.map((Y)=>h($,{...Z,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 m8($){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 c8($){let{endpoint:X,accept:Q,maxSize:Z,maxFiles:Y=1,fieldName:J="file",preview:G=!1,dropzone:W=!0,multiple:K=!1,autoUpload:_=!0,showProgress:U=!0,disabled:z=!1,placeholder:F="Drop files here or click to select",label:O}=$,j=$.class||"",L=$.style||"",H=$.id||`stx-upload-${Math.random().toString(36).slice(2,8)}`,A=Array.isArray(Q)?Q.join(","):Q,q=`
3422
- <div id="${H}" class="stx-upload${W?" stx-upload-dropzone":""}${z?" stx-upload-disabled":""}${j?" "+j:""}"${L?` style="${L}"`:""}>
3423
- ${O?`<label class="stx-upload-label">${p8(O)}</label>`:""}
3421
+ `}import z8 from"path";A6();class jQ{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,Q){this.store.set($,{data:{...X},expires:Date.now()+Q*1000})}async delete($){this.store.delete($)}}function OQ($,X){for(let Q of $.getSetCookie())X.append("Set-Cookie",Q);$.forEach((Q,Z)=>{if(Z.toLowerCase()!=="set-cookie")X.set(Z,Q)})}async function DK($,X={},Q={}){let Z=Q.viewsDir||"./views",Y=Q.layoutsDir||"./layouts",J=!$.includes("<")&&!$.includes("@"),G,W;if(J){if(W=z8.resolve(Z,$),!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:z8.dirname(W)};if(Q.ctx)K.csrf_token=Q.ctx.csrfToken,K.csrf_field=`<input type="hidden" name="_token" value="${Q.ctx.csrfToken}">`,K.old=Q.ctx.old,K.errors=Q.ctx.errors,K.session=Q.ctx.session,K.user=Q.ctx.user(),K.isAuthenticated=Q.ctx.isAuthenticated();let _=G.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(_){let O=_[1];G=G.replace(/<script\s+server\b[^>]*>[\s\S]*?<\/script>/gi,""),await j0(O,K,W)}let U={layoutsDir:Y,...Q.stxOptions},F=await O0(G,K,W,U,new Set),j=new Headers({"Content-Type":"text/html; charset=utf-8"});if(Q.ctx)OQ(Q.ctx.responseHeaders,j);return new Response(F,{headers:j})}var S1={stores:new Map,subscriptions:new Map};function HQ($,X){S1.stores.set($,X)}function O8($){return S1.stores.get($)}function AQ($){return S1.stores.has($)}function qQ(){return Array.from(S1.stores.keys())}var K1=new Map;function j8($){if($==="memory")return{getItem:(X)=>K1.get(X)??null,setItem:(X,Q)=>K1.set(X,Q),removeItem:(X)=>K1.delete(X)};if(typeof window>"u")return{getItem:(X)=>K1.get(X)??null,setItem:(X,Q)=>K1.set(X,Q),removeItem:(X)=>K1.delete(X)};return $==="local"?window.localStorage:window.sessionStorage}function NQ($,X){let Q={};for(let Z of X){let Y=Z.split("."),J=$,G=Q,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 Q}function H8($,X={}){let{name:Q,persist:Z,devtools:Y=!1,middleware:J=[],equals:G=(H,q)=>H===q}=X,W=$,K=new Set,_=null;if(Z){let H=j8(Z.storage||"local"),q=Z.key||`stx-store:${Q||"unnamed"}`,A=Z.deserialize||JSON.parse;try{let N=H.getItem(q);if(N){let V=A(N);if(Z.paths&&typeof V==="object"&&V!==null)W={...$,...V};else W=V}}catch{}}let U=(H)=>{if(!Z)return;let q=j8(Z.storage||"local"),A=Z.key||`stx-store:${Q||"unnamed"}`,N=Z.serialize||JSON.stringify,V=Z.paths&&typeof H==="object"&&H!==null?NQ(H,Z.paths):H;if(Z.debounce){if(_)clearTimeout(_);_=setTimeout(()=>{q.setItem(A,N(V))},Z.debounce)}else q.setItem(A,N(V))},z=(H,q)=>{for(let A of K)try{A(H,q)}catch(N){console.error("[stx-store] Subscriber error:",N)}},F=Y?(H,q)=>{if(u6(Q||"unnamed",H,W,q),typeof window<"u")window.__STX_DEVTOOLS__?.onStoreChange?.(Q||"unnamed",H,q)}:()=>{},j=(H)=>{let q=W;if(!G(H,q))W=H,U(H),z(H,q),F("set",H)},O=j,L={get:()=>W,set:(H)=>{if(typeof H==="function")O(H(W));else O(H)},subscribe:(H)=>{return K.add(H),()=>{K.delete(H)}},update:(H)=>{if(typeof W!=="object"||W===null)throw Error("update() can only be used with object stores");let q=typeof H==="function"?H(W):H;L.set({...W,...q})},reset:()=>{L.set($),F("reset",$)},name:Q,destroy:()=>{if(K.clear(),_)clearTimeout(_);if(Q)S1.stores.delete(Q)}};for(let H of J.reverse())O=H(j,()=>W,L)(O);if(Q){if(HQ(Q,L),Y)d6(Q,W??{},{},[])}return L}function MQ($){let X=typeof $==="string"?O8($):$;if(!X)throw Error(`Store "${$}" not found`);return X.get()}function VQ($,X,Q){if(typeof X==="function"){if(typeof window<"u"&&window.stx?.defineStore)return window.stx.defineStore($,X,Q);return X()}let Z=X,{state:Y,getters:J={},actions:G={},persist:W,devtools:K=!0}=Z,_=typeof Y==="function"?Y():Y,U=W===!0?{storage:"local",key:`stx-store:${$}`}:W||void 0,z=H8(_,{name:$,persist:U,devtools:K}),F=new Proxy({},{get(j,O){let L=String(O);if(L==="$state")return z.get();if(L==="$subscribe")return z.subscribe;if(L==="$reset")return z.reset;if(L==="$patch")return(q)=>{if(typeof q==="function"){let N={...z.get()};q(N),z.set(N)}else z.update(q)};if(L==="_store")return z;if(L==="$id")return $;if(L in J)return J[L](z.get());if(L in G)return(...q)=>{return G[L].apply(F,q)};let H=z.get();if(H&&typeof H==="object"&&L in H)return H[L];return},set(j,O,L){let H=String(O);if(H.startsWith("$")||H==="_store")return!1;let q=z.get();if(q&&typeof q==="object")return z.set({...q,[H]:L}),!0;return!1},has(j,O){let L=String(O),H=z.get();return L.startsWith("$")||L==="_store"||L in J||L in G||H&&typeof H==="object"&&L in H},ownKeys(){let j=z.get();return[...j&&typeof j==="object"?Object.keys(j):[],...Object.keys(J),...Object.keys(G),"$state","$subscribe","$reset","$patch","$id"]},getOwnPropertyDescriptor(j,O){return{enumerable:!0,configurable:!0,get:()=>this.get(j,O,F)}}});return EQ.set($,F),F}var EQ=new Map;function IQ($){if(typeof window>"u")return;let X=window;X.__STX_STORES__=X.__STX_STORES__||{};for(let[Q,Z]of Object.entries($))X.__STX_STORES__[Q]=Z;window.dispatchEvent(new CustomEvent("stx:stores-ready",{detail:Object.keys($)}))}function h($,X={}){let Q=[];for(let[Y,J]of Object.entries(X)){if(J===void 0||J===null)continue;if(Array.isArray(J))Q.push(`${Y}=${encodeURIComponent(J.join(","))}`);else if(typeof J==="boolean"){if(J)Q.push(`${Y}=true`)}else Q.push(`${Y}=${encodeURIComponent(String(J))}`)}if(Q.length===0)return $;let Z=$.includes("?")?"&":"?";return`${$}${Z}${Q.join("&")}`}function A8($){let X=$.indexOf("?");if(X===-1)return{src:$,params:{}};let Q=$.slice(0,X),Z=$.slice(X+1),Y={};for(let J of Z.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:Q,params:Y}}function q5(...$){let X={};for(let Q of $)if(Q)Object.assign(X,Q);return X}function q8($,X,Q,Z){let Y={w:X};if(Q)Y.h=Q;if(Z)Y.fit=Z;return h($,Y)}function N8($,X,Q,Z="center"){return h($,{w:X,h:Q,fit:"crop",crop:Z})}function M8($,X,Q="center"){return h($,{w:X,h:X,fit:"crop",crop:Q})}function V8($,X,Q){return h($,{w:X,h:Q,fit:"max"})}function E8($,X,Q){return h($,{w:X,h:Q,fit:"crop"})}function I8($,X){return h($,{blur:Math.min(2000,Math.max(0,X))})}function R8($,X){return h($,{sharp:Math.min(100,Math.max(0,X))})}function D8($){return h($,{sat:-100})}function w8($,X=100){return h($,{sepia:Math.min(100,Math.max(0,X))})}function T8($){return h($,{invert:!0})}function C8($,X){return h($,{bri:Math.min(100,Math.max(-100,X))})}function k8($,X){return h($,{con:Math.min(100,Math.max(-100,X))})}function x8($,X){return h($,{sat:Math.min(100,Math.max(-100,X))})}function S8($,X){return h($,{rot:(X%360+360)%360})}function P8($){return h($,{flip:"h"})}function b8($){return h($,{flip:"v"})}function y8($,X,Q){let Z={fm:X};if(Q!==void 0)Z.q=Q;return h($,Z)}function v8($,X){return h($,{q:Math.min(100,Math.max(1,X))})}function g8($,X=["format","compress"]){return h($,{auto:X})}function f8($,X,Q={}){return h($,{mark:X,markx:Q.x,marky:Q.y,markalpha:Q.alpha,markscale:Q.scale,markalign:Q.align})}var N5={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 h8($,X,Q){return h($,q5(N5[X],Q))}function d8($,X,Q){return X.map((Z)=>h($,{...Q,w:Z}))}function u8($,X,Q=[1,2,3],Z){return Q.map((Y)=>h($,{...Z,w:Math.round(X*Y),dpr:Y}))}function m8($){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 p8($){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 l8($){let{endpoint:X,accept:Q,maxSize:Z,maxFiles:Y=1,fieldName:J="file",preview:G=!1,dropzone:W=!0,multiple:K=!1,autoUpload:_=!0,showProgress:U=!0,disabled:z=!1,placeholder:F="Drop files here or click to select",label:j}=$,O=$.class||"",L=$.style||"",H=$.id||`stx-upload-${Math.random().toString(36).slice(2,8)}`,q=Array.isArray(Q)?Q.join(","):Q,A=`
3422
+ <div id="${H}" class="stx-upload${W?" stx-upload-dropzone":""}${z?" stx-upload-disabled":""}${O?" "+O:""}"${L?` style="${L}"`:""}>
3423
+ ${j?`<label class="stx-upload-label">${c8(j)}</label>`:""}
3424
3424
  <div class="stx-upload-area" data-stx-upload-area>
3425
3425
  <input
3426
3426
  type="file"
3427
3427
  name="${J}"
3428
- ${A?`accept="${A}"`:""}
3428
+ ${q?`accept="${q}"`:""}
3429
3429
  ${K?"multiple":""}
3430
3430
  ${z?"disabled":""}
3431
3431
  class="stx-upload-input"
@@ -3435,14 +3435,14 @@ else {
3435
3435
  <svg class="stx-upload-icon" viewBox="0 0 24 24" width="48" height="48">
3436
3436
  <path fill="currentColor" d="M9 16h6v-6h4l-7-7-7 7h4v6zm-4 2h14v2H5v-2z"/>
3437
3437
  </svg>
3438
- <span class="stx-upload-text">${p8(F)}</span>
3439
- ${Z?`<span class="stx-upload-hint">Max size: ${UZ(Z)}</span>`:""}
3438
+ <span class="stx-upload-text">${c8(F)}</span>
3439
+ ${Z?`<span class="stx-upload-hint">Max size: ${LZ(Z)}</span>`:""}
3440
3440
  </div>
3441
3441
  </div>
3442
3442
  ${G?'<div class="stx-upload-previews" data-stx-upload-previews></div>':""}
3443
3443
  ${U?'<div class="stx-upload-progress" data-stx-upload-progress style="display:none;"><div class="stx-upload-progress-bar"></div><span class="stx-upload-progress-text">0%</span></div>':""}
3444
3444
  </div>
3445
- `.trim(),M=`
3445
+ `.trim(),N=`
3446
3446
  (function() {
3447
3447
  var container = document.getElementById('${H}');
3448
3448
  if (!container) return;
@@ -3455,11 +3455,11 @@ else {
3455
3455
  var progressText = progress ? progress.querySelector('.stx-upload-progress-text') : null;
3456
3456
 
3457
3457
  var config = {
3458
- endpoint: '${_Z(X)}',
3458
+ endpoint: '${BZ(X)}',
3459
3459
  fieldName: '${J}',
3460
3460
  maxSize: ${Z||"null"},
3461
3461
  maxFiles: ${Y},
3462
- accept: ${A?JSON.stringify(A.split(",")):"null"},
3462
+ accept: ${q?JSON.stringify(q.split(",")):"null"},
3463
3463
  autoUpload: ${_}
3464
3464
  };
3465
3465
 
@@ -3707,7 +3707,7 @@ else {
3707
3707
  opacity: 0.5;
3708
3708
  pointer-events: none;
3709
3709
  }
3710
- `.trim();return{html:q,script:M,css:V}}function p8($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function _Z($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function UZ($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(1)} MB`}async function q5($,X){let{endpoint:Q,method:Z="POST",headers:Y={},expirationSeconds:J=3600,oneTimeUse:G=!1,params:W={}}=X,K=JSON.stringify({url:$,expirationSeconds:J,oneTimeUse:G,...W}),_=await fetch(Q,{method:Z,headers:{"Content-Type":"application/json",...Y},body:Z!=="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 N5($,X){let{endpoint:Q,method:Z="POST",headers:Y={},expirationSeconds:J=3600,oneTimeUse:G=!1,params:W={}}=X,K=JSON.stringify({urls:$,expirationSeconds:J,oneTimeUse:G,...W}),_=await fetch(Q,{method:Z,headers:{"Content-Type":"application/json",...Y},body:Z!=="GET"?K:void 0});if(!_.ok)throw Error(`Failed to batch sign URLs: ${_.status} ${_.statusText}`);let U=await _.json(),z=new Map,F=new Map;if(Array.isArray(U.results))for(let O of U.results)if(O.error)F.set(O.url,O.error);else z.set(O.url||O.originalUrl,{url:O.signedUrl||O.url,signature:O.signature,expires:O.expires||Date.now()+J*1000,oneTimeUse:O.oneTimeUse||G});else if(typeof U.signatures==="object"){for(let[O,j]of Object.entries(U.signatures)){let L=j;z.set(O,{url:L.signedUrl||L.url||O,signature:L.signature,expires:L.expires||Date.now()+J*1000,oneTimeUse:G})}if(U.errors)for(let[O,j]of Object.entries(U.errors))F.set(O,j)}return{signatures:z,errors:F}}async function l8($,X,Q=10){let Z=new Map,Y=new Map,J=[];for(let W=0;W<$.length;W+=Q)J.push($.slice(W,W+Q));let G=await Promise.all(J.map((W)=>N5(W,X)));for(let W of G){for(let[K,_]of W.signatures)Z.set(K,_);for(let[K,_]of W.errors)Y.set(K,_)}return{signatures:Z,errors:Y}}function M5($){return $.expires>Date.now()}function V5($){return Math.max(0,$.expires-Date.now())}function E5($,X=300000){return V5($)<X}async function b1($){if($.check)return await $.check();return!0}function j$($){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 i8($,X){let Q=`${$}:${X.endpoint}`,Z=P1.get(Q);if(Z&&M5(Z)&&!E5(Z))return Z;let Y=await q5($,X);return P1.set(Q,Y),Y}function a8(){P1.clear()}function r8(){let $=0,X=Date.now();for(let[Q,Z]of P1)if(Z.expires<=X)P1.delete(Q),$++;return $}function O$(){return`
3710
+ `.trim();return{html:A,script:N,css:V}}function c8($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function BZ($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function LZ($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(1)} MB`}async function M5($,X){let{endpoint:Q,method:Z="POST",headers:Y={},expirationSeconds:J=3600,oneTimeUse:G=!1,params:W={}}=X,K=JSON.stringify({url:$,expirationSeconds:J,oneTimeUse:G,...W}),_=await fetch(Q,{method:Z,headers:{"Content-Type":"application/json",...Y},body:Z!=="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:Q,method:Z="POST",headers:Y={},expirationSeconds:J=3600,oneTimeUse:G=!1,params:W={}}=X,K=JSON.stringify({urls:$,expirationSeconds:J,oneTimeUse:G,...W}),_=await fetch(Q,{method:Z,headers:{"Content-Type":"application/json",...Y},body:Z!=="GET"?K:void 0});if(!_.ok)throw Error(`Failed to batch sign URLs: ${_.status} ${_.statusText}`);let U=await _.json(),z=new Map,F=new Map;if(Array.isArray(U.results))for(let j of U.results)if(j.error)F.set(j.url,j.error);else z.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,O]of Object.entries(U.signatures)){let L=O;z.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,O]of Object.entries(U.errors))F.set(j,O)}return{signatures:z,errors:F}}async function i8($,X,Q=10){let Z=new Map,Y=new Map,J=[];for(let W=0;W<$.length;W+=Q)J.push($.slice(W,W+Q));let G=await Promise.all(J.map((W)=>V5(W,X)));for(let W of G){for(let[K,_]of W.signatures)Z.set(K,_);for(let[K,_]of W.errors)Y.set(K,_)}return{signatures:Z,errors:Y}}function E5($){return $.expires>Date.now()}function I5($){return Math.max(0,$.expires-Date.now())}function R5($,X=300000){return I5($)<X}async function b1($){if($.check)return await $.check();return!0}function j$($){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 a8($,X){let Q=`${$}:${X.endpoint}`,Z=P1.get(Q);if(Z&&E5(Z)&&!R5(Z))return Z;let Y=await M5($,X);return P1.set(Q,Y),Y}function r8(){P1.clear()}function s8(){let $=0,X=Date.now();for(let[Q,Z]of P1)if(Z.expires<=X)P1.delete(Q),$++;return $}function O$(){return`
3711
3711
  (function() {
3712
3712
  'use strict';
3713
3713
 
@@ -3781,7 +3781,7 @@ catch (error) {
3781
3781
  }
3782
3782
  };
3783
3783
  })();
3784
- `.trim()}async function n8($){let{src:X,alt:Q="",signatureEndpoint:Z="/api/sign",signatureConfig:Y={},auth:J,fallback:G,oneTimeUse:W=!0}=$,K=$.class,_=$.style;if(J){if(!await b1(J)){if(G)return{html:`<img src="${i(G)}" alt="${i(Q)}"${K?` class="${i(K)}"`:""}${_?` style="${i(_)}"`:""} />`};return{html:"<!-- Protected content: access denied -->"}}}let U={endpoint:Z,oneTimeUse:W,...Y,params:J?j$(J):Y.params},z=`stx-protected-${Math.random().toString(36).slice(2,8)}`,F=[`id="${z}"`,`data-protected-src="${i(X)}"`,`data-signature-endpoint="${i(Z)}"`,`alt="${i(Q)}"`];if(G)F.push(`data-fallback="${i(G)}"`),F.push(`src="${i(G)}"`);else F.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');if(K)F.push(`class="${i(K)}"`);if(_)F.push(`style="${i(_)}"`);let O=`
3784
+ `.trim()}async function o8($){let{src:X,alt:Q="",signatureEndpoint:Z="/api/sign",signatureConfig:Y={},auth:J,fallback:G,oneTimeUse:W=!0}=$,K=$.class,_=$.style;if(J){if(!await b1(J)){if(G)return{html:`<img src="${i(G)}" alt="${i(Q)}"${K?` class="${i(K)}"`:""}${_?` style="${i(_)}"`:""} />`};return{html:"<!-- Protected content: access denied -->"}}}let U={endpoint:Z,oneTimeUse:W,...Y,params:J?j$(J):Y.params},z=`stx-protected-${Math.random().toString(36).slice(2,8)}`,F=[`id="${z}"`,`data-protected-src="${i(X)}"`,`data-signature-endpoint="${i(Z)}"`,`alt="${i(Q)}"`];if(G)F.push(`data-fallback="${i(G)}"`),F.push(`src="${i(G)}"`);else F.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');if(K)F.push(`class="${i(K)}"`);if(_)F.push(`style="${i(_)}"`);let j=`
3785
3785
  (function() {
3786
3786
  var el = document.getElementById('${z}');
3787
3787
  if (!el) return;
@@ -3792,7 +3792,7 @@ catch (error) {
3792
3792
  expirationSeconds: ${Y.expirationSeconds||3600}
3793
3793
  });
3794
3794
  })();
3795
- `.trim();return{html:`<img ${F.join(" ")} />`,script:O}}async function o8($){let{src:X,signatureEndpoint:Q="/api/sign",signatureConfig:Z={},auth:Y,fallback:J,oneTimeUse:G=!0,poster:W,controls:K=!0,autoplay:_=!1,muted:U=!1,loop:z=!1}=$,F=$.class,O=$.style,j=$.alt;if(Y){if(!await b1(Y))return{html:"<!-- Protected video: access denied -->"}}let L=`stx-protected-video-${Math.random().toString(36).slice(2,8)}`,H=[`id="${L}"`,`data-protected-src="${i(X)}"`,`data-signature-endpoint="${i(Q)}"`];if(W)H.push(`poster="${i(W)}"`);if(K)H.push("controls");if(_)H.push("autoplay");if(U)H.push("muted");if(z)H.push("loop");if(F)H.push(`class="${i(F)}"`);if(O)H.push(`style="${i(O)}"`);if(J)H.push(`data-fallback="${i(J)}"`);let A=`
3795
+ `.trim();return{html:`<img ${F.join(" ")} />`,script:j}}async function t8($){let{src:X,signatureEndpoint:Q="/api/sign",signatureConfig:Z={},auth:Y,fallback:J,oneTimeUse:G=!0,poster:W,controls:K=!0,autoplay:_=!1,muted:U=!1,loop:z=!1}=$,F=$.class,j=$.style,O=$.alt;if(Y){if(!await b1(Y))return{html:"<!-- Protected video: access denied -->"}}let L=`stx-protected-video-${Math.random().toString(36).slice(2,8)}`,H=[`id="${L}"`,`data-protected-src="${i(X)}"`,`data-signature-endpoint="${i(Q)}"`];if(W)H.push(`poster="${i(W)}"`);if(K)H.push("controls");if(_)H.push("autoplay");if(U)H.push("muted");if(z)H.push("loop");if(F)H.push(`class="${i(F)}"`);if(j)H.push(`style="${i(j)}"`);if(J)H.push(`data-fallback="${i(J)}"`);let q=`
3796
3796
  (function() {
3797
3797
  var el = document.getElementById('${L}');
3798
3798
  if (!el) return;
@@ -3803,7 +3803,7 @@ catch (error) {
3803
3803
  expirationSeconds: ${Z.expirationSeconds||3600}
3804
3804
  });
3805
3805
  })();
3806
- `.trim();return{html:`<video ${H.join(" ")}></video>`,script:A}}async function t8($,X){let Q=/data-protected-src="([^"]+)"/g,Z=[],Y;while((Y=Q.exec($))!==null)Z.push(Y[1]);if(Z.length===0)return{html:$,script:""};let J=O$()+`
3806
+ `.trim();return{html:`<video ${H.join(" ")}></video>`,script:q}}async function e8($,X){let Q=/data-protected-src="([^"]+)"/g,Z=[],Y;while((Y=Q.exec($))!==null)Z.push(Y[1]);if(Z.length===0)return{html:$,script:""};let J=O$()+`
3807
3807
 
3808
3808
  `;return J+=`
3809
3809
  (function() {
@@ -3835,12 +3835,12 @@ else if (el.dataset.fallback) {
3835
3835
  });
3836
3836
  });
3837
3837
  })();
3838
- `.trim(),{html:$,script:J}}function e8($,X,Q){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 Z=$.trim();if(Z.startsWith("@protected(")||Z.startsWith("("))Z=Z.replace(/^@protected\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Y=BZ(Z);return{src:s8(Y[0],Q)||"",alt:s8(Y[1],Q)||"",...typeof Y[2]==="object"?Y[2]:{}}}function BZ($){let X=[],Q="",Z=!1,Y="",J=0;for(let G=0;G<$.length;G++){let W=$[G],K=G>0?$[G-1]:"";if((W==='"'||W==="'")&&K!=="\\"){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1;else Q+=W;continue}if(!Z){if(W==="{")J++;if(W==="}")J--;if(W===","&&J===0){X.push(Q.trim()),Q="";continue}}Q+=W}if(Q.trim())X.push(Q.trim());return X}function s8($,X){if(typeof $!=="string")return $;let Q=$.trim();if(Q.startsWith('"')&&Q.endsWith('"')||Q.startsWith("'")&&Q.endsWith("'"))return Q.slice(1,-1);if(X[Q]!==void 0)return X[Q];if(Q.startsWith("{"))try{return JSON.parse(Q)}catch{}return Q}function i($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function LZ($){let{src:X,apiKey:Q,bucket:Z,allowedTypes:Y,maxFileSize:J,multiple:G=!1,customStyles:W={},callbacks:K={}}=$,_=`stx-media-manager-${Math.random().toString(36).slice(2,8)}`,U={container:`#${_}`};if(Q)U.apiKey=Q;if(Z)U.bucket=Z;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 z=`<div id="${_}" class="stx-media-manager"></div>`,F=Object.entries(K).filter(([,j])=>j).map(([j,L])=>{return`manager.on('${j.replace(/^on/,"").toLowerCase()}', ${L});`}).join(`
3839
- `),O=`
3838
+ `.trim(),{html:$,script:J}}function $7($,X,Q){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 Z=$.trim();if(Z.startsWith("@protected(")||Z.startsWith("("))Z=Z.replace(/^@protected\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Y=FZ(Z);return{src:n8(Y[0],Q)||"",alt:n8(Y[1],Q)||"",...typeof Y[2]==="object"?Y[2]:{}}}function FZ($){let X=[],Q="",Z=!1,Y="",J=0;for(let G=0;G<$.length;G++){let W=$[G],K=G>0?$[G-1]:"";if((W==='"'||W==="'")&&K!=="\\"){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1;else Q+=W;continue}if(!Z){if(W==="{")J++;if(W==="}")J--;if(W===","&&J===0){X.push(Q.trim()),Q="";continue}}Q+=W}if(Q.trim())X.push(Q.trim());return X}function n8($,X){if(typeof $!=="string")return $;let Q=$.trim();if(Q.startsWith('"')&&Q.endsWith('"')||Q.startsWith("'")&&Q.endsWith("'"))return Q.slice(1,-1);if(X[Q]!==void 0)return X[Q];if(Q.startsWith("{"))try{return JSON.parse(Q)}catch{}return Q}function i($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function zZ($){let{src:X,apiKey:Q,bucket:Z,allowedTypes:Y,maxFileSize:J,multiple:G=!1,customStyles:W={},callbacks:K={}}=$,_=`stx-media-manager-${Math.random().toString(36).slice(2,8)}`,U={container:`#${_}`};if(Q)U.apiKey=Q;if(Z)U.bucket=Z;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 z=`<div id="${_}" class="stx-media-manager"></div>`,F=Object.entries(K).filter(([,O])=>O).map(([O,L])=>{return`manager.on('${O.replace(/^on/,"").toLowerCase()}', ${L});`}).join(`
3839
+ `),j=`
3840
3840
  (function() {
3841
3841
  // Load media manager script
3842
3842
  var script = document.createElement('script');
3843
- script.src = '${$7(X)}';
3843
+ script.src = '${X7(X)}';
3844
3844
  script.async = true;
3845
3845
 
3846
3846
  script.onload = function() {
@@ -3857,12 +3857,12 @@ else if (el.dataset.fallback) {
3857
3857
  };
3858
3858
 
3859
3859
  script.onerror = function() {
3860
- console.error('[stx] Failed to load media manager from:', '${$7(X)}');
3860
+ console.error('[stx] Failed to load media manager from:', '${X7(X)}');
3861
3861
  };
3862
3862
 
3863
3863
  document.head.appendChild(script);
3864
3864
  })();
3865
- `.trim();return{html:z,script:O}}function FZ($){let{accept:X="image/*",multiple:Q=!1,onSelect:Z="handleMediaSelect"}=$,Y=`stx-picker-${Math.random().toString(36).slice(2,8)}`,J=`
3865
+ `.trim();return{html:z,script:j}}function jZ($){let{accept:X="image/*",multiple:Q=!1,onSelect:Z="handleMediaSelect"}=$,Y=`stx-picker-${Math.random().toString(36).slice(2,8)}`,J=`
3866
3866
  <div id="${Y}" class="stx-media-picker" style="display:none;">
3867
3867
  <div class="stx-media-picker-backdrop"></div>
3868
3868
  <div class="stx-media-picker-modal">
@@ -4051,7 +4051,7 @@ else {
4051
4051
  border: none;
4052
4052
  color: white;
4053
4053
  }
4054
- `.trim();return{html:J,script:G,css:W}}function $7($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Z7={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"};function I5(){return"loading"in HTMLImageElement.prototype}function R5(){return"IntersectionObserver"in window}function Y7($={}){let X={...Z7,...$},Q=document.querySelectorAll(X.selector);if(Q.length===0)return()=>{};if(X.useNative&&I5())return Q.forEach((Y)=>{if(Y.tagName==="IMG"||Y.tagName==="IFRAME")v0(Y,X)}),()=>{};if(!R5())return Q.forEach((Y)=>v0(Y,X)),()=>{};let Z=new IntersectionObserver((Y)=>{Y.forEach((J)=>{if(J.isIntersecting){let G=J.target;v0(G,X),Z.unobserve(G)}})},{root:X.root,rootMargin:X.rootMargin,threshold:X.threshold});return Q.forEach((Y)=>Z.observe(Y)),()=>{Z.disconnect()}}function v0($,X={}){let{onLoad:Q,onLoaded:Z,onError:Y}=X;if(Q)Q($);let J=$.tagName==="IMG",G=$.tagName==="VIDEO",W=$.tagName==="IFRAME";if(J)X7($,Z,Y);else if(G)Q7($,Z,Y);else if(W)zZ($,Z,Y);else{let K=$.querySelector("img[data-src], img[data-srcset]"),_=$.querySelector("video[data-src]");if(K)X7(K,()=>{if(Z)Z($)},(z)=>{if(Y)Y($,z)});else if(_)Q7(_,()=>{if(Z)Z($)},(z)=>{if(Y)Y($,z)});$.querySelectorAll("source[data-srcset]").forEach((z)=>{let F=z;if(F.dataset.srcset)F.srcset=F.dataset.srcset,delete F.dataset.srcset;if(F.dataset.sizes)F.sizes=F.dataset.sizes,delete F.dataset.sizes})}}function X7($,X,Q){let Z=()=>{$.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"),Q)Q($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",Z,{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 Q7($,X,Q){let Z=()=>{if($.classList.add("stx-video-loaded"),X)X($)},Y=()=>{if($.classList.add("stx-video-error"),Q)Q($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",Z,{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 zZ($,X,Q){let Z=()=>{if($.classList.add("stx-iframe-loaded"),X)X($)},Y=()=>{if($.classList.add("stx-iframe-error"),Q)Q($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",Z,{once:!0}),$.addEventListener("error",Y,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function J7($){v0($,{})}function G7($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Q)=>v0(Q,{}))}function W7($={}){let X={...Z7,...$};return new IntersectionObserver((Q,Z)=>{Q.forEach((Y)=>{if(Y.isIntersecting)v0(Y.target,X),Z.unobserve(Y.target)})},{root:X.root,rootMargin:X.rootMargin,threshold:X.threshold})}function K7($,X){$.observe(X)}function _7($){$.disconnect()}function H$(){return`
4054
+ `.trim();return{html:J,script:G,css:W}}function X7($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Y7={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"};function D5(){return"loading"in HTMLImageElement.prototype}function w5(){return"IntersectionObserver"in window}function J7($={}){let X={...Y7,...$},Q=document.querySelectorAll(X.selector);if(Q.length===0)return()=>{};if(X.useNative&&D5())return Q.forEach((Y)=>{if(Y.tagName==="IMG"||Y.tagName==="IFRAME")v0(Y,X)}),()=>{};if(!w5())return Q.forEach((Y)=>v0(Y,X)),()=>{};let Z=new IntersectionObserver((Y)=>{Y.forEach((J)=>{if(J.isIntersecting){let G=J.target;v0(G,X),Z.unobserve(G)}})},{root:X.root,rootMargin:X.rootMargin,threshold:X.threshold});return Q.forEach((Y)=>Z.observe(Y)),()=>{Z.disconnect()}}function v0($,X={}){let{onLoad:Q,onLoaded:Z,onError:Y}=X;if(Q)Q($);let J=$.tagName==="IMG",G=$.tagName==="VIDEO",W=$.tagName==="IFRAME";if(J)Q7($,Z,Y);else if(G)Z7($,Z,Y);else if(W)OZ($,Z,Y);else{let K=$.querySelector("img[data-src], img[data-srcset]"),_=$.querySelector("video[data-src]");if(K)Q7(K,()=>{if(Z)Z($)},(z)=>{if(Y)Y($,z)});else if(_)Z7(_,()=>{if(Z)Z($)},(z)=>{if(Y)Y($,z)});$.querySelectorAll("source[data-srcset]").forEach((z)=>{let F=z;if(F.dataset.srcset)F.srcset=F.dataset.srcset,delete F.dataset.srcset;if(F.dataset.sizes)F.sizes=F.dataset.sizes,delete F.dataset.sizes})}}function Q7($,X,Q){let Z=()=>{$.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"),Q)Q($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",Z,{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 Z7($,X,Q){let Z=()=>{if($.classList.add("stx-video-loaded"),X)X($)},Y=()=>{if($.classList.add("stx-video-error"),Q)Q($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",Z,{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 OZ($,X,Q){let Z=()=>{if($.classList.add("stx-iframe-loaded"),X)X($)},Y=()=>{if($.classList.add("stx-iframe-error"),Q)Q($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",Z,{once:!0}),$.addEventListener("error",Y,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function G7($){v0($,{})}function W7($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Q)=>v0(Q,{}))}function K7($={}){let X={...Y7,...$};return new IntersectionObserver((Q,Z)=>{Q.forEach((Y)=>{if(Y.isIntersecting)v0(Y.target,X),Z.unobserve(Y.target)})},{root:X.root,rootMargin:X.rootMargin,threshold:X.threshold})}function _7($,X){$.observe(X)}function U7($){$.disconnect()}function H$(){return`
4055
4055
  (function() {
4056
4056
  'use strict';
4057
4057
 
@@ -4141,7 +4141,7 @@ else {
4141
4141
  window.STX.lazyLoad = loadElement;
4142
4142
  window.STX.initLazyLoading = init;
4143
4143
  })();
4144
- `.trim()}var jZ={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"};function D5($,X={}){let Q={...jZ,...X},Z=$.closest(".stx-img-placeholder");if(!Z){OZ($,Q);return}if(Z.style.setProperty("--stx-img-transition-duration",`${Q.duration}ms`),Z.style.setProperty("--stx-img-transition-easing",Q.easing),Q.loadingClass)Z.classList.add(Q.loadingClass);if($.complete&&$.naturalWidth>0)U7($,Z,Q);else $.addEventListener("load",()=>U7($,Z,Q),{once:!0}),$.addEventListener("error",()=>HZ($,Z,Q),{once:!0})}function OZ($,X){let Q=()=>{$.style.transition=`opacity ${X.duration}ms ${X.easing}`,$.style.opacity="1",$.classList.remove(X.loadingClass),$.classList.add(X.loadedClass)};if($.complete&&$.naturalWidth>0)Q();else $.style.opacity="0",$.classList.add(X.loadingClass),$.addEventListener("load",Q,{once:!0})}function U7($,X,Q){if(Q.loadingClass)X.classList.remove(Q.loadingClass);if(Q.loadedClass)X.classList.add(Q.loadedClass);if($.style.opacity="1",Q.removePlaceholder)setTimeout(()=>{X.style.backgroundImage="none"},Q.duration)}function HZ($,X,Q){if(Q.loadingClass)X.classList.remove(Q.loadingClass);X.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function B7($,X){let Q=A$($),Z=X.getContext("2d");if(!Z)return;X.width=Q.w,X.height=Q.h;let Y=Z.createImageData(Q.w,Q.h);Y.data.set(Q.rgba),Z.putImageData(Y,0,0)}function A$($){let X=$[0]|$[1]<<8|$[2]<<16,Q=(X&63)/63,Z=(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,z=Math.max(3,U?G?5:7:G?5:5),F=Math.max(3,U?G?5:5:G?5:7),O=32,j=32,L=new Uint8ClampedArray(4096);for(let H=0;H<32;H++)for(let A=0;A<32;A++){let q=(H*32+A)*4,M=A/31,V=H/31,N=Q+(M-0.5)*J*0.5+(V-0.5)*J*0.5,R=Z*(1-M*0.3),w=Y*(1-V*0.3),C=N-0.6666666666666666*R,I=(3*N-C+w)/2,E=I-w;L[q]=Math.max(0,Math.min(255,Math.round(I*255))),L[q+1]=Math.max(0,Math.min(255,Math.round(E*255))),L[q+2]=Math.max(0,Math.min(255,Math.round(C*255))),L[q+3]=255}return{w:32,h:32,rgba:L}}function L7($){let X=A$($),Q=document.createElement("canvas");Q.width=X.w,Q.height=X.h;let Z=Q.getContext("2d");if(!Z)return"";let Y=Z.createImageData(X.w,X.h);return Y.data.set(X.rgba),Z.putImageData(Y,0,0),Q.toDataURL("image/png")}function F7($){let X=atob($),Q=new Uint8Array(X.length);for(let Z=0;Z<X.length;Z++)Q[Z]=X.charCodeAt(Z);return Q}function z7($,X,Q=300){return new Promise((Z)=>{$.style.transition=`opacity ${Q}ms ease-out`,X.style.transition=`opacity ${Q}ms ease-out`,X.style.opacity="0",X.offsetWidth,$.style.opacity="0",X.style.opacity="1",setTimeout(Z,Q)})}function j7($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Q)=>{D5(Q,$)})}function q$(){return`
4144
+ `.trim()}var HZ={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"};function T5($,X={}){let Q={...HZ,...X},Z=$.closest(".stx-img-placeholder");if(!Z){AZ($,Q);return}if(Z.style.setProperty("--stx-img-transition-duration",`${Q.duration}ms`),Z.style.setProperty("--stx-img-transition-easing",Q.easing),Q.loadingClass)Z.classList.add(Q.loadingClass);if($.complete&&$.naturalWidth>0)B7($,Z,Q);else $.addEventListener("load",()=>B7($,Z,Q),{once:!0}),$.addEventListener("error",()=>qZ($,Z,Q),{once:!0})}function AZ($,X){let Q=()=>{$.style.transition=`opacity ${X.duration}ms ${X.easing}`,$.style.opacity="1",$.classList.remove(X.loadingClass),$.classList.add(X.loadedClass)};if($.complete&&$.naturalWidth>0)Q();else $.style.opacity="0",$.classList.add(X.loadingClass),$.addEventListener("load",Q,{once:!0})}function B7($,X,Q){if(Q.loadingClass)X.classList.remove(Q.loadingClass);if(Q.loadedClass)X.classList.add(Q.loadedClass);if($.style.opacity="1",Q.removePlaceholder)setTimeout(()=>{X.style.backgroundImage="none"},Q.duration)}function qZ($,X,Q){if(Q.loadingClass)X.classList.remove(Q.loadingClass);X.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function L7($,X){let Q=A$($),Z=X.getContext("2d");if(!Z)return;X.width=Q.w,X.height=Q.h;let Y=Z.createImageData(Q.w,Q.h);Y.data.set(Q.rgba),Z.putImageData(Y,0,0)}function A$($){let X=$[0]|$[1]<<8|$[2]<<16,Q=(X&63)/63,Z=(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,z=Math.max(3,U?G?5:7:G?5:5),F=Math.max(3,U?G?5:5:G?5:7),j=32,O=32,L=new Uint8ClampedArray(4096);for(let H=0;H<32;H++)for(let q=0;q<32;q++){let A=(H*32+q)*4,N=q/31,V=H/31,M=Q+(N-0.5)*J*0.5+(V-0.5)*J*0.5,R=Z*(1-N*0.3),w=Y*(1-V*0.3),C=M-0.6666666666666666*R,I=(3*M-C+w)/2,E=I-w;L[A]=Math.max(0,Math.min(255,Math.round(I*255))),L[A+1]=Math.max(0,Math.min(255,Math.round(E*255))),L[A+2]=Math.max(0,Math.min(255,Math.round(C*255))),L[A+3]=255}return{w:32,h:32,rgba:L}}function F7($){let X=A$($),Q=document.createElement("canvas");Q.width=X.w,Q.height=X.h;let Z=Q.getContext("2d");if(!Z)return"";let Y=Z.createImageData(X.w,X.h);return Y.data.set(X.rgba),Z.putImageData(Y,0,0),Q.toDataURL("image/png")}function z7($){let X=atob($),Q=new Uint8Array(X.length);for(let Z=0;Z<X.length;Z++)Q[Z]=X.charCodeAt(Z);return Q}function j7($,X,Q=300){return new Promise((Z)=>{$.style.transition=`opacity ${Q}ms ease-out`,X.style.transition=`opacity ${Q}ms ease-out`,X.style.opacity="0",X.offsetWidth,$.style.opacity="0",X.style.opacity="1",setTimeout(Z,Q)})}function O7($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Q)=>{T5(Q,$)})}function q$(){return`
4145
4145
  (function() {
4146
4146
  'use strict';
4147
4147
 
@@ -4240,7 +4240,7 @@ else {
4240
4240
  .stx-img-error {
4241
4241
  opacity: 0.5;
4242
4242
  }
4243
- `.trim()}var AZ={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1};function w5($,X={}){if(X.maxSize&&$.size>X.maxSize)return{valid:!1,error:`File size (${O7($.size)}) exceeds maximum (${O7(X.maxSize)})`,code:"FILE_TOO_LARGE"};if(X.accept&&X.accept.length>0){if(!X.accept.some((Z)=>{if(Z.endsWith("/*")){let Y=Z.slice(0,-1);return $.type.startsWith(Y)}return $.type===Z}))return{valid:!1,error:`File type "${$.type}" is not allowed`,code:"INVALID_TYPE"}}return{valid:!0}}function O7($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}async function T5($,X,Q){let Z={...AZ,...X},Y=w5($,Z);if(!Y.valid)return{success:!1,error:Y.error,name:$.name,size:$.size,type:$.type};if(Z.chunkSize&&$.size>Z.chunkSize)return NZ($,Z,Q);return qZ($,Z,Q)}async function qZ($,X,Q){return new Promise((Z)=>{let Y=new XMLHttpRequest,J=Date.now(),G=0,W=J;Y.upload.addEventListener("progress",(_)=>{if(_.lengthComputable&&Q){let U=Date.now(),z=(U-W)/1000,F=_.loaded-G,O=z>0?F/z:0,j=_.total-_.loaded,L=O>0?j/O*1000:void 0;G=_.loaded,W=U,Q({file:$,loaded:_.loaded,total:_.total,percent:Math.round(_.loaded/_.total*100),speed:O,timeRemaining:L})}}),Y.addEventListener("load",()=>{if(Y.status>=200&&Y.status<300)try{let _=JSON.parse(Y.responseText);Z({success:!0,url:_.url,id:_.id,name:$.name,size:$.size,type:$.type,data:_})}catch{Z({success:!0,name:$.name,size:$.size,type:$.type})}else Z({success:!1,error:`Upload failed with status ${Y.status}`,name:$.name,size:$.size,type:$.type})}),Y.addEventListener("error",()=>{Z({success:!1,error:"Network error during upload",name:$.name,size:$.size,type:$.type})}),Y.addEventListener("timeout",()=>{Z({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 NZ($,X,Q){let Z=X.chunkSize,Y=Math.ceil($.size/Z),J=0,G;for(let W=0;W<Y;W++){let K=W*Z,_=Math.min(K+Z,$.size),U=$.slice(K,_),z=new FormData;if(z.append(X.fieldName||"file",U,$.name),z.append("chunk",String(W)),z.append("totalChunks",String(Y)),z.append("fileName",$.name),z.append("fileSize",String($.size)),z.append("fileType",$.type),G)z.append("uploadId",G);if(X.formData)for(let[F,O]of Object.entries(X.formData))z.append(F,O);try{let F=await fetch(X.endpoint,{method:X.method||"POST",headers:X.headers,credentials:X.withCredentials?"include":"same-origin",body:z});if(!F.ok)return{success:!1,error:`Chunk ${W+1}/${Y} failed with status ${F.status}`,name:$.name,size:$.size,type:$.type};let O=await F.json();if(!G&&O.uploadId)G=O.uploadId;if(J=_,Q)Q({file:$,loaded:J,total:$.size,percent:Math.round(J/$.size*100),chunk:W+1,totalChunks:Y});if(W===Y-1)return{success:!0,url:O.url,id:O.id||G,name:$.name,size:$.size,type:$.type,data:O}}catch(F){return{success:!1,error:`Chunk upload failed: ${F}`,name:$.name,size:$.size,type:$.type}}}return{success:!1,error:"Unknown error during chunked upload",name:$.name,size:$.size,type:$.type}}async function H7($,X,Q,Z){let Y=[];for(let J of $){let G=await T5(J,X,(W)=>{if(Q)Q(J,W)});if(Y.push(G),Z)Z(J,G)}return Y}function A7($,X=200){return new Promise((Q,Z)=>{if(!$.type.startsWith("image/")){Z(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,_),Q(W.toDataURL("image/jpeg",0.7));else Z(Error("Could not get canvas context"))},G.onerror=()=>Z(Error("Could not load image")),G.src=J.target?.result},Y.onerror=()=>Z(Error("Could not read file")),Y.readAsDataURL($)})}function q7($){return new Promise((X,Q)=>{if(!$.type.startsWith("video/")){Q(Error("File is not a video"));return}let Z=document.createElement("video"),Y=document.createElement("canvas");Z.preload="metadata",Z.muted=!0,Z.playsInline=!0,Z.onloadeddata=()=>{Z.currentTime=0.1},Z.onseeked=()=>{Y.width=Z.videoWidth,Y.height=Z.videoHeight;let J=Y.getContext("2d");if(J)J.drawImage(Z,0,0),X(Y.toDataURL("image/jpeg",0.7));else Q(Error("Could not get canvas context"));URL.revokeObjectURL(Z.src)},Z.onerror=()=>{URL.revokeObjectURL(Z.src),Q(Error("Could not load video"))},Z.src=URL.createObjectURL($)})}function M$(){return`
4243
+ `.trim()}var NZ={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1};function C5($,X={}){if(X.maxSize&&$.size>X.maxSize)return{valid:!1,error:`File size (${H7($.size)}) exceeds maximum (${H7(X.maxSize)})`,code:"FILE_TOO_LARGE"};if(X.accept&&X.accept.length>0){if(!X.accept.some((Z)=>{if(Z.endsWith("/*")){let Y=Z.slice(0,-1);return $.type.startsWith(Y)}return $.type===Z}))return{valid:!1,error:`File type "${$.type}" is not allowed`,code:"INVALID_TYPE"}}return{valid:!0}}function H7($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}async function k5($,X,Q){let Z={...NZ,...X},Y=C5($,Z);if(!Y.valid)return{success:!1,error:Y.error,name:$.name,size:$.size,type:$.type};if(Z.chunkSize&&$.size>Z.chunkSize)return VZ($,Z,Q);return MZ($,Z,Q)}async function MZ($,X,Q){return new Promise((Z)=>{let Y=new XMLHttpRequest,J=Date.now(),G=0,W=J;Y.upload.addEventListener("progress",(_)=>{if(_.lengthComputable&&Q){let U=Date.now(),z=(U-W)/1000,F=_.loaded-G,j=z>0?F/z:0,O=_.total-_.loaded,L=j>0?O/j*1000:void 0;G=_.loaded,W=U,Q({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);Z({success:!0,url:_.url,id:_.id,name:$.name,size:$.size,type:$.type,data:_})}catch{Z({success:!0,name:$.name,size:$.size,type:$.type})}else Z({success:!1,error:`Upload failed with status ${Y.status}`,name:$.name,size:$.size,type:$.type})}),Y.addEventListener("error",()=>{Z({success:!1,error:"Network error during upload",name:$.name,size:$.size,type:$.type})}),Y.addEventListener("timeout",()=>{Z({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 VZ($,X,Q){let Z=X.chunkSize,Y=Math.ceil($.size/Z),J=0,G;for(let W=0;W<Y;W++){let K=W*Z,_=Math.min(K+Z,$.size),U=$.slice(K,_),z=new FormData;if(z.append(X.fieldName||"file",U,$.name),z.append("chunk",String(W)),z.append("totalChunks",String(Y)),z.append("fileName",$.name),z.append("fileSize",String($.size)),z.append("fileType",$.type),G)z.append("uploadId",G);if(X.formData)for(let[F,j]of Object.entries(X.formData))z.append(F,j);try{let F=await fetch(X.endpoint,{method:X.method||"POST",headers:X.headers,credentials:X.withCredentials?"include":"same-origin",body:z});if(!F.ok)return{success:!1,error:`Chunk ${W+1}/${Y} failed with status ${F.status}`,name:$.name,size:$.size,type:$.type};let j=await F.json();if(!G&&j.uploadId)G=j.uploadId;if(J=_,Q)Q({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(F){return{success:!1,error:`Chunk upload failed: ${F}`,name:$.name,size:$.size,type:$.type}}}return{success:!1,error:"Unknown error during chunked upload",name:$.name,size:$.size,type:$.type}}async function A7($,X,Q,Z){let Y=[];for(let J of $){let G=await k5(J,X,(W)=>{if(Q)Q(J,W)});if(Y.push(G),Z)Z(J,G)}return Y}function q7($,X=200){return new Promise((Q,Z)=>{if(!$.type.startsWith("image/")){Z(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,_),Q(W.toDataURL("image/jpeg",0.7));else Z(Error("Could not get canvas context"))},G.onerror=()=>Z(Error("Could not load image")),G.src=J.target?.result},Y.onerror=()=>Z(Error("Could not read file")),Y.readAsDataURL($)})}function N7($){return new Promise((X,Q)=>{if(!$.type.startsWith("video/")){Q(Error("File is not a video"));return}let Z=document.createElement("video"),Y=document.createElement("canvas");Z.preload="metadata",Z.muted=!0,Z.playsInline=!0,Z.onloadeddata=()=>{Z.currentTime=0.1},Z.onseeked=()=>{Y.width=Z.videoWidth,Y.height=Z.videoHeight;let J=Y.getContext("2d");if(J)J.drawImage(Z,0,0),X(Y.toDataURL("image/jpeg",0.7));else Q(Error("Could not get canvas context"));URL.revokeObjectURL(Z.src)},Z.onerror=()=>{URL.revokeObjectURL(Z.src),Q(Error("Could not load video"))},Z.src=URL.createObjectURL($)})}function M$(){return`
4244
4244
  (function() {
4245
4245
  'use strict';
4246
4246
 
@@ -4308,18 +4308,18 @@ else {
4308
4308
  return { valid: true };
4309
4309
  };
4310
4310
  })();
4311
- `.trim()}function N7(){return{script:[H$(),q$(),M$()].join(`
4311
+ `.trim()}function M7(){return{script:[H$(),q$(),M$()].join(`
4312
4312
 
4313
- `),css:N$()}}function MZ(){let{script:$,css:X}=N7(),Q=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),Z=X.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Q,css:Z}}var m_={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 V$ from"fs";import l0 from"path";async function M7($,X={},Q={}){let Z=await Bun.file($).text(),Y=Z.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),J=Y?Y[1]:"",G=Y?Z.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):Z;G=G.replace(/<script\s+client\s*>/gi,"<script>");let W={__filename:$,__dirname:l0.dirname($),props:X,...X};if(J)await j0(J,W,$);let K={...E$,...Q};return await O0(G,W,$,K,new Set)}async function VZ($){let X=performance.now(),Q={success:!0,views:[],errors:[],duration:0},{viewsDir:Z,outputDir:Y,componentsDir:J=l0.join(Z,"components"),layoutsDir:G=l0.join(Z,"layouts"),partialsDir:W=l0.join(Z,"partials"),globalProps:K={},placeholders:_={},views:U,debug:z=!1,generateManifest:F=!0}=$;if(z)console.log("Building STX views..."),console.log(` Source: ${Z}`),console.log(` Output: ${Y}`);V$.mkdirSync(Y,{recursive:!0});let O={componentsDir:J,layoutsDir:G,partialsDir:W,debug:z},j;if(U&&U.length>0)j=U;else j=V$.readdirSync(Z).filter((H)=>H.endsWith(".stx")).map((H)=>({input:H}));for(let L of j){let H=l0.join(Z,L.input),A=L.output||L.input.replace(/\.stx$/,".html"),q=l0.join(Y,A);if(z)console.log(` Building ${L.input}...`);try{let M={...K,...L.props,..._},V=await M7(H,M,O);await Bun.write(q,V),Q.views.push(A)}catch(M){let V=M instanceof Error?M.message:String(M);if(Q.errors.push({file:L.input,error:V}),Q.success=!1,z)console.error(` Error: ${V}`)}}if(F){let L={buildTime:new Date().toISOString(),views:Q.views,placeholders:_,errors:Q.errors.length>0?Q.errors:void 0};await Bun.write(l0.join(Y,"manifest.json"),JSON.stringify(L,null,2))}if(Q.duration=performance.now()-X,z)if(Q.success)console.log(`
4313
+ `),css:N$()}}function EZ(){let{script:$,css:X}=M7(),Q=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),Z=X.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Q,css:Z}}var c_={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 V$ from"fs";import i0 from"path";async function V7($,X={},Q={}){let Z=await Bun.file($).text(),Y=Z.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),J=Y?Y[1]:"",G=Y?Z.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):Z;G=G.replace(/<script\s+client\s*>/gi,"<script>");let W={__filename:$,__dirname:i0.dirname($),props:X,...X};if(J)await j0(J,W,$);let K={...E$,...Q};return await O0(G,W,$,K,new Set)}async function IZ($){let X=performance.now(),Q={success:!0,views:[],errors:[],duration:0},{viewsDir:Z,outputDir:Y,componentsDir:J=i0.join(Z,"components"),layoutsDir:G=i0.join(Z,"layouts"),partialsDir:W=i0.join(Z,"partials"),globalProps:K={},placeholders:_={},views:U,debug:z=!1,generateManifest:F=!0}=$;if(z)console.log("Building STX views..."),console.log(` Source: ${Z}`),console.log(` Output: ${Y}`);V$.mkdirSync(Y,{recursive:!0});let j={componentsDir:J,layoutsDir:G,partialsDir:W,debug:z},O;if(U&&U.length>0)O=U;else O=V$.readdirSync(Z).filter((H)=>H.endsWith(".stx")).map((H)=>({input:H}));for(let L of O){let H=i0.join(Z,L.input),q=L.output||L.input.replace(/\.stx$/,".html"),A=i0.join(Y,q);if(z)console.log(` Building ${L.input}...`);try{let N={...K,...L.props,..._},V=await V7(H,N,j);await Bun.write(A,V),Q.views.push(q)}catch(N){let V=N instanceof Error?N.message:String(N);if(Q.errors.push({file:L.input,error:V}),Q.success=!1,z)console.error(` Error: ${V}`)}}if(F){let L={buildTime:new Date().toISOString(),views:Q.views,placeholders:_,errors:Q.errors.length>0?Q.errors:void 0};await Bun.write(i0.join(Y,"manifest.json"),JSON.stringify(L,null,2))}if(Q.duration=performance.now()-X,z)if(Q.success)console.log(`
4314
4314
  \u2705 Built ${Q.views.length} views in ${Q.duration.toFixed(0)}ms`);else console.log(`
4315
- \u26A0\uFE0F Built ${Q.views.length} views with ${Q.errors.length} errors`);return Q}function Y9($,X){let Q=V$.watch($.viewsDir,{recursive:!0},async(Z,Y)=>{if(!Y)return;if(Y.endsWith(".stx")||Y.endsWith(".ts")||Y.endsWith(".js")){if($.debug)console.log(`
4316
- File changed: ${Y}, rebuilding...`);let J=await VZ($);X?.(J)}});return{close:()=>Q.close()}}async function J9($,X={},Q={}){let Z={...Q,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await M7($,X,Z);Y=await EZ(Y),Y=Y.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),Y=Y.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),Y=Y.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),Y=Y.replace(/\n\s*\n\s*\n/g,`
4315
+ \u26A0\uFE0F Built ${Q.views.length} views with ${Q.errors.length} errors`);return Q}function G9($,X){let Q=V$.watch($.viewsDir,{recursive:!0},async(Z,Y)=>{if(!Y)return;if(Y.endsWith(".stx")||Y.endsWith(".ts")||Y.endsWith(".js")){if($.debug)console.log(`
4316
+ File changed: ${Y}, rebuilding...`);let J=await IZ($);X?.(J)}});return{close:()=>Q.close()}}async function W9($,X={},Q={}){let Z={...Q,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await V7($,X,Z);Y=await RZ(Y),Y=Y.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),Y=Y.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),Y=Y.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),Y=Y.replace(/\n\s*\n\s*\n/g,`
4317
4317
 
4318
- `).trim();let J=RZ(Y);return{html:Y,text:J}}async function EZ($){try{let{generateCrosswindCSS:X,extractClassNames:Q}=await import("./chunk-v7fsv3wn.js");if(Q($).size===0)return $;let Y=await X($);if(!Y)return $;let J=IZ(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,z)=>{let F=_.split(/\s+/).filter(Boolean),O=[];for(let A of F){let q=J.get(A);if(q)O.push(q)}if(O.length===0)return`${W}${K}class="${_}"${U}${z}`;let j=O.join("; "),H=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(H){let A=`${j}; ${H[1]}`,q=K.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`),M=U.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`);return`${W}${q}class="${_}"${M}${z}`}return`${W}${K}class="${_}" style="${j}"${U}${z}`})}catch{return $}}function IZ($){let X=new Map,Q=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Z=Q.exec($);while(Z!==null){let Y=Z[1].replace(/\\/g,""),J=Z[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Z=Q.exec($)}return X}function RZ($){return $.replace(/<br\s*\/?>/gi,`
4318
+ `).trim();let J=wZ(Y);return{html:Y,text:J}}async function RZ($){try{let{generateCrosswindCSS:X,extractClassNames:Q}=await import("./chunk-v2qx1jrb.js");if(Q($).size===0)return $;let Y=await X($);if(!Y)return $;let J=DZ(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,z)=>{let F=_.split(/\s+/).filter(Boolean),j=[];for(let q of F){let A=J.get(q);if(A)j.push(A)}if(j.length===0)return`${W}${K}class="${_}"${U}${z}`;let O=j.join("; "),H=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(H){let q=`${O}; ${H[1]}`,A=K.replace(/style\s*=\s*"[^"]*"/,`style="${q}"`),N=U.replace(/style\s*=\s*"[^"]*"/,`style="${q}"`);return`${W}${A}class="${_}"${N}${z}`}return`${W}${K}class="${_}" style="${O}"${U}${z}`})}catch{return $}}function DZ($){let X=new Map,Q=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Z=Q.exec($);while(Z!==null){let Y=Z[1].replace(/\\/g,""),J=Z[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Z=Q.exec($)}return X}function wZ($){return $.replace(/<br\s*\/?>/gi,`
4319
4319
  `).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
4320
4320
  `).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,`
4321
4321
 
4322
- `).trim()}function DZ($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function wZ($){let X={};for(let Q of Object.keys($))if(!Q.startsWith("__"))X[Q]=$[Q];return X}function W9($){let{template:X,context:Q={},title:Z="stx App"}=$,Y=wZ(Q),J=DZ(JSON.stringify(Y));return`<!DOCTYPE html>
4322
+ `).trim()}function TZ($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function CZ($){let X={};for(let Q of Object.keys($))if(!Q.startsWith("__"))X[Q]=$[Q];return X}function _9($){let{template:X,context:Q={},title:Z="stx App"}=$,Y=CZ(Q),J=TZ(JSON.stringify(Y));return`<!DOCTYPE html>
4323
4323
  <html lang="en">
4324
4324
  <head>
4325
4325
  <meta charset="UTF-8">
@@ -4339,7 +4339,7 @@ File changed: ${Y}, rebuilding...`);let J=await VZ($);X?.(J)}});return{close:()=
4339
4339
  }
4340
4340
  </script>
4341
4341
  </body>
4342
- </html>`}var A0=null;function TZ($,X){if(A0)A0.provides.set($,X);else I$.set($,X)}function CZ($,X){let Q=A0;while(Q){if(Q.provides.has($))return Q.provides.get($);Q=Q.parent}if(I$.has($))return I$.get($);return X}var I$=new Map;function C5($,X){I$.set($,X)}function xZ($){let X=A0,Q=X?.el,Z=Array.isArray($)?$:$&&typeof $==="object"?Object.keys($):[];if(Q&&Z.length>0){let J=Q.__stx_component_emits||=Object.create(null);for(let G of Z)J[G]=!0}let Y=(J,...G)=>{if(typeof document>"u")return;if(Q){let W=Q.__stx_component_emits||=Object.create(null);W[J]=!0,Q.dispatchEvent(new CustomEvent(J,{detail:G.length===1?G[0]:G,bubbles:!0,cancelable:!0}))}};if(X)X.emit=Y;return Y}function kZ($){if(A0)A0.exposed=$}function SZ($){let X=Promise.resolve();return $?X.then($):X}function PZ($){if(A0)A0.errorCapturedHooks.push($)}function bZ($,X,Q){let Z=X?.parent;while(Z){for(let Y of Z.errorCapturedHooks)if(Y($,X,Q)===!1)return;Z=Z.parent}}function yZ(){return A0?.slots??{}}function vZ(){return A0?.slots??{}}function gZ(){return A0?.attrs??{}}function fZ($){let X=$.__provides?new Map(Object.entries($.__provides)):new Map;return{...$,__provides:X,__provide(Q,Z){X.set(Q,Z)},__inject(Q,Z){if(X.has(Q))return X.get(Q);if($.__provides){let Y=$.__provides instanceof Map?$.__provides:new Map(Object.entries($.__provides));if(Y.has(Q))return Y.get(Q)}return Z}}}function hZ(){return`
4342
+ </html>`}var A0=null;function kZ($,X){if(A0)A0.provides.set($,X);else I$.set($,X)}function xZ($,X){let Q=A0;while(Q){if(Q.provides.has($))return Q.provides.get($);Q=Q.parent}if(I$.has($))return I$.get($);return X}var I$=new Map;function x5($,X){I$.set($,X)}function SZ($){let X=A0,Q=X?.el,Z=Array.isArray($)?$:$&&typeof $==="object"?Object.keys($):[];if(Q&&Z.length>0){let J=Q.__stx_component_emits||=Object.create(null);for(let G of Z)J[G]=!0}let Y=(J,...G)=>{if(typeof document>"u")return;if(Q){let W=Q.__stx_component_emits||=Object.create(null);W[J]=!0,Q.dispatchEvent(new CustomEvent(J,{detail:G.length===1?G[0]:G,bubbles:!0,cancelable:!0}))}};if(X)X.emit=Y;return Y}function PZ($){if(A0)A0.exposed=$}function bZ($){let X=Promise.resolve();return $?X.then($):X}function yZ($){if(A0)A0.errorCapturedHooks.push($)}function vZ($,X,Q){let Z=X?.parent;while(Z){for(let Y of Z.errorCapturedHooks)if(Y($,X,Q)===!1)return;Z=Z.parent}}function gZ(){return A0?.slots??{}}function fZ(){return A0?.slots??{}}function hZ(){return A0?.attrs??{}}function dZ($){let X=$.__provides?new Map(Object.entries($.__provides)):new Map;return{...$,__provides:X,__provide(Q,Z){X.set(Q,Z)},__inject(Q,Z){if(X.has(Q))return X.get(Q);if($.__provides){let Y=$.__provides instanceof Map?$.__provides:new Map(Object.entries($.__provides));if(Y.has(Q))return Y.get(Q)}return Z}}}function uZ(){return`
4343
4343
  // STX Composition API Runtime
4344
4344
  (function() {
4345
4345
  const _provides = new Map();
@@ -4404,8 +4404,8 @@ File changed: ${Y}, rebuilding...`);let J=await VZ($);X?.(J)}});return{close:()=
4404
4404
  return refs;
4405
4405
  };
4406
4406
  })();
4407
- `}var _1=Symbol.for("stx.Fragment"),dZ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),E7=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"]),I7={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 uZ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function x5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function R7($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[V7($)];return $.flat(1/0).map(V7).filter((X)=>X!=="")}function V7($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function U1($,X,Q){let{children:Z,ref:Y,key:J,...G}=X||{};return{type:$,props:Object.keys(G).length>0?G:null,children:R7(Z),key:Q??J??void 0,ref:Y??void 0}}var mZ=U1,pZ=U1;function D7($){return Object.entries($).filter(([,X])=>X!=null&&X!==!1).map(([X,Q])=>{let Z=X.replace(/[A-Z]/g,(J)=>`-${J.toLowerCase()}`),Y=typeof Q==="number"&&!Z.startsWith("--")&&Z!=="opacity"&&Z!=="z-index"&&Z!=="flex-grow"&&Z!=="flex-shrink"&&Z!=="order"&&Z!=="font-weight"&&Z!=="line-height"?`${Q}px`:String(Q);return`${Z}: ${Y}`}).join("; ")}function k5($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(k5).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,X])=>X).map(([X])=>X).join(" ");return""}function cZ($){if(!$)return"";let X=[];for(let[Q,Z]of Object.entries($)){if(Q==="key"||Q==="ref"||Q==="children"||Q==="innerHTML"||Q==="dangerouslySetInnerHTML")continue;if(Q.startsWith("on")&&typeof Z==="function")continue;let Y=I7[Q]||Q;if(Y==="class"||Y==="className"){let J=k5(Z);if(J)X.push(` class="${x5(J)}"`);continue}if(Y==="style"){let J=typeof Z==="string"?Z:D7(Z);if(J)X.push(` style="${x5(J)}"`);continue}if(E7.has(Y)){if(Z)X.push(` ${Y}`);continue}if(Z!=null&&Z!==!1)X.push(` ${Y}="${x5(String(Z))}"`)}return X.join("")}function K1($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return uZ($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(K1).join("");if($.type===_1)return $.children.map(K1).join("");if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return K1(J)}let X=$.type,Q=cZ($.props),Z=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Z!=null)return`<${X}${Q}>${Z}</${X}>`;if(dZ.has(X))return`<${X}${Q}>`;let Y=$.children.map(K1).join("");return`<${X}${Q}>${Y}</${X}>`}function lZ($){return new ReadableStream({start(X){X.enqueue(K1($)),X.close()}})}function iZ($,X){if(!X)return;for(let[Q,Z]of Object.entries(X)){if(Q==="key"||Q==="ref"||Q==="children"||Q==="innerHTML"||Q==="dangerouslySetInnerHTML")continue;let Y=I7[Q]||Q;if(Q.startsWith("on")&&typeof Z==="function"){let J=Q.slice(2).toLowerCase();$.addEventListener(J,Z);continue}if(Y==="class"||Y==="className"){let J=k5(Z);if(J)$.setAttribute("class",J);continue}if(Y==="style"){let J=typeof Z==="string"?Z:D7(Z);if(J)$.setAttribute("style",J);continue}if(E7.has(Y)){if(Z)$.setAttribute(Y,"");continue}if(Z!=null&&Z!==!1)$.setAttribute(Y,String(Z))}}function y1($,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 $)y1(Y,X);return}if($.type===_1){for(let Y of $.children)y1(Y,X);return}if(typeof $.type==="function"){let Y=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});y1(Y,X);return}let Q=document.createElement($.type);iZ(Q,$.props);let Z=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Z!=null)Q.innerHTML=Z;else for(let Y of $.children)y1(Y,Q);if($.ref){if(typeof $.ref==="function")$.ref(Q)}X.appendChild(Q)}function aZ($){if($.when)return U1(_1,{children:$.children});return $.fallback??null}function rZ($){let X=$.each;if(!X||X.length===0)return $.fallback??null;let Q=Array.isArray($.children)?$.children[0]:$.children,Z=X.map((Y,J)=>Q(Y,J));return U1(_1,{children:Z})}function sZ($){return U1(_1,{children:$.children})}function nZ($,X,...Q){let{key:Z,ref:Y,...J}=X||{};return{type:$,props:Object.keys(J).length>0?J:{},children:R7(Q.length===1?Q[0]:Q),key:Z??void 0,ref:Y??void 0}}function w7($,X){let Q=new Set,Z=new Map,Y=new Map,J={globalProperties:{},performance:!1,compilerOptions:{}},G={config:J,_components:Z,_directives:Y,_installedPlugins:Q,use(W,...K){if(Q.has(W))return G;if(Q.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 Z.get(W);return Z.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(){Z.clear(),Y.clear(),Q.clear()}};return G}function oZ($){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 tZ($,...X){let Q=X[0]??{},Z=new Set,Y=String($).replace(/(\/)?:([^/?*]+)([?*])?/g,(W,K,_,U)=>{let z=Q[_];if(Z.add(_),z===void 0||z===null||z===""){if(U==="?")return"";return W}let F=Array.isArray(z)?z.map((O)=>encodeURIComponent(String(O))).join("/"):U==="*"?String(z).split("/").map((O)=>encodeURIComponent(O)).join("/"):encodeURIComponent(String(z));return`${K??""}${F}`}),J=Object.keys(Q).filter((W)=>!Z.has(W));if(J.length===0)return Y;let G=new URLSearchParams;for(let W of J){let K=Q[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 B1 from"fs";import g0 from"path";function T7($){try{return B1.statSync($).mtimeMs}catch{return null}}function R$($,X){let Q=Math.max(0,Math.round((X-$)/1000));if(Q<60)return`${Q}s ago`;if(Q<3600)return`${Math.round(Q/60)}m ago`;return`${Math.round(Q/3600)}h ago`}function eZ($,X){try{return globalThis.Bun?.resolveSync($,X)??null}catch{return null}}function C7($,X="stx"){let Q=g0.resolve($);for(let Z=0;Z<10;Z++){let Y=g0.join(Q,"pantry","@stacksjs",X);if(B1.existsSync(Y))return Y;let J=g0.dirname(Q);if(J===Q)break;Q=J}return null}async function $Y($={}){let X=$.cwd?g0.resolve($.cwd):process.cwd(),Q=$.resolve??eZ,Z=Date.now(),Y=[],J=Q("@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=Q("bun-plugin-stx",X);if(G)Y.push({name:"bun-plugin-stx resolves to",status:"ok",detail:G});let W=C7(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((j)=>B1.existsSync(j))||null,U=T7(K),z=_?T7(_):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(z==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(z<U){let j=Math.round((U-z)/1000);Y.push({name:"pantry dist freshness",status:"error",detail:`dist (${R$(z,Z)}) is OLDER than src/signals.ts (${R$(U,Z)}) by ${j}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 ${R$(U,Z)}, dist ${R$(z,Z)})`});let F=g0.join(X,"node_modules/@stacksjs/stx"),O=null;try{O=B1.lstatSync(F)}catch{O=null}if(!O)Y.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(O.isSymbolicLink()){let j=null;try{j=B1.realpathSync(F)}catch{}let L=(()=>{try{return B1.realpathSync(W)}catch{return W}})();Y.push(j===L?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${j||"(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 XY($){let X={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},Q=["stx runtime resolution:"];for(let Z of $.checks)if(Q.push(` ${X[Z.status]} ${Z.name}: ${Z.detail}`),Z.fix)Q.push(` \u2192 ${Z.fix}`);return Q.push(""),Q.push($.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),Q.join(`
4408
- `)}var{Glob:AY}=globalThis.Bun;import{cpSync as d7,existsSync as v$,mkdirSync as u7,readFileSync as m7,readdirSync as qY,rmSync as NY,statSync as MY,unlinkSync as VY,writeFileSync as b$}from"fs";import{dirname as EY,join as R0,relative as IY}from"path";import p7 from"process";import f0 from"path";function k7($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function S7($,X,Q){let Z=k7(X),Y=Q?k7(Q):"";return`<!DOCTYPE html>
4407
+ `}var U1=Symbol.for("stx.Fragment"),mZ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),I7=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"]),R7={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 pZ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function S5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function D7($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[E7($)];return $.flat(1/0).map(E7).filter((X)=>X!=="")}function E7($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function B1($,X,Q){let{children:Z,ref:Y,key:J,...G}=X||{};return{type:$,props:Object.keys(G).length>0?G:null,children:D7(Z),key:Q??J??void 0,ref:Y??void 0}}var cZ=B1,lZ=B1;function w7($){return Object.entries($).filter(([,X])=>X!=null&&X!==!1).map(([X,Q])=>{let Z=X.replace(/[A-Z]/g,(J)=>`-${J.toLowerCase()}`),Y=typeof Q==="number"&&!Z.startsWith("--")&&Z!=="opacity"&&Z!=="z-index"&&Z!=="flex-grow"&&Z!=="flex-shrink"&&Z!=="order"&&Z!=="font-weight"&&Z!=="line-height"?`${Q}px`:String(Q);return`${Z}: ${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 iZ($){if(!$)return"";let X=[];for(let[Q,Z]of Object.entries($)){if(Q==="key"||Q==="ref"||Q==="children"||Q==="innerHTML"||Q==="dangerouslySetInnerHTML")continue;if(Q.startsWith("on")&&typeof Z==="function")continue;let Y=R7[Q]||Q;if(Y==="class"||Y==="className"){let J=P5(Z);if(J)X.push(` class="${S5(J)}"`);continue}if(Y==="style"){let J=typeof Z==="string"?Z:w7(Z);if(J)X.push(` style="${S5(J)}"`);continue}if(I7.has(Y)){if(Z)X.push(` ${Y}`);continue}if(Z!=null&&Z!==!1)X.push(` ${Y}="${S5(String(Z))}"`)}return X.join("")}function _1($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return pZ($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(_1).join("");if($.type===U1)return $.children.map(_1).join("");if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return _1(J)}let X=$.type,Q=iZ($.props),Z=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Z!=null)return`<${X}${Q}>${Z}</${X}>`;if(mZ.has(X))return`<${X}${Q}>`;let Y=$.children.map(_1).join("");return`<${X}${Q}>${Y}</${X}>`}function aZ($){return new ReadableStream({start(X){X.enqueue(_1($)),X.close()}})}function rZ($,X){if(!X)return;for(let[Q,Z]of Object.entries(X)){if(Q==="key"||Q==="ref"||Q==="children"||Q==="innerHTML"||Q==="dangerouslySetInnerHTML")continue;let Y=R7[Q]||Q;if(Q.startsWith("on")&&typeof Z==="function"){let J=Q.slice(2).toLowerCase();$.addEventListener(J,Z);continue}if(Y==="class"||Y==="className"){let J=P5(Z);if(J)$.setAttribute("class",J);continue}if(Y==="style"){let J=typeof Z==="string"?Z:w7(Z);if(J)$.setAttribute("style",J);continue}if(I7.has(Y)){if(Z)$.setAttribute(Y,"");continue}if(Z!=null&&Z!==!1)$.setAttribute(Y,String(Z))}}function y1($,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 $)y1(Y,X);return}if($.type===U1){for(let Y of $.children)y1(Y,X);return}if(typeof $.type==="function"){let Y=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});y1(Y,X);return}let Q=document.createElement($.type);rZ(Q,$.props);let Z=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Z!=null)Q.innerHTML=Z;else for(let Y of $.children)y1(Y,Q);if($.ref){if(typeof $.ref==="function")$.ref(Q)}X.appendChild(Q)}function sZ($){if($.when)return B1(U1,{children:$.children});return $.fallback??null}function nZ($){let X=$.each;if(!X||X.length===0)return $.fallback??null;let Q=Array.isArray($.children)?$.children[0]:$.children,Z=X.map((Y,J)=>Q(Y,J));return B1(U1,{children:Z})}function oZ($){return B1(U1,{children:$.children})}function tZ($,X,...Q){let{key:Z,ref:Y,...J}=X||{};return{type:$,props:Object.keys(J).length>0?J:{},children:D7(Q.length===1?Q[0]:Q),key:Z??void 0,ref:Y??void 0}}function T7($,X){let Q=new Set,Z=new Map,Y=new Map,J={globalProperties:{},performance:!1,compilerOptions:{}},G={config:J,_components:Z,_directives:Y,_installedPlugins:Q,use(W,...K){if(Q.has(W))return G;if(Q.add(W),typeof W==="function")W(G,...K);else if(typeof W.install==="function")W.install(G,...K);return G},provide(W,K){return x5(W,K),G},component(W,K){if(!K)return Z.get(W);return Z.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(){Z.clear(),Y.clear(),Q.clear()}};return G}function eZ($){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 $Y($,...X){let Q=X[0]??{},Z=new Set,Y=String($).replace(/(\/)?:([^/?*]+)([?*])?/g,(W,K,_,U)=>{let z=Q[_];if(Z.add(_),z===void 0||z===null||z===""){if(U==="?")return"";return W}let F=Array.isArray(z)?z.map((j)=>encodeURIComponent(String(j))).join("/"):U==="*"?String(z).split("/").map((j)=>encodeURIComponent(j)).join("/"):encodeURIComponent(String(z));return`${K??""}${F}`}),J=Object.keys(Q).filter((W)=>!Z.has(W));if(J.length===0)return Y;let G=new URLSearchParams;for(let W of J){let K=Q[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 L1 from"fs";import g0 from"path";function C7($){try{return L1.statSync($).mtimeMs}catch{return null}}function R$($,X){let Q=Math.max(0,Math.round((X-$)/1000));if(Q<60)return`${Q}s ago`;if(Q<3600)return`${Math.round(Q/60)}m ago`;return`${Math.round(Q/3600)}h ago`}function XY($,X){try{return globalThis.Bun?.resolveSync($,X)??null}catch{return null}}function k7($,X="stx"){let Q=g0.resolve($);for(let Z=0;Z<10;Z++){let Y=g0.join(Q,"pantry","@stacksjs",X);if(L1.existsSync(Y))return Y;let J=g0.dirname(Q);if(J===Q)break;Q=J}return null}async function QY($={}){let X=$.cwd?g0.resolve($.cwd):process.cwd(),Q=$.resolve??XY,Z=Date.now(),Y=[],J=Q("@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=Q("bun-plugin-stx",X);if(G)Y.push({name:"bun-plugin-stx resolves to",status:"ok",detail:G});let W=k7(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((O)=>L1.existsSync(O))||null,U=C7(K),z=_?C7(_):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(z==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(z<U){let O=Math.round((U-z)/1000);Y.push({name:"pantry dist freshness",status:"error",detail:`dist (${R$(z,Z)}) is OLDER than src/signals.ts (${R$(U,Z)}) by ${O}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 ${R$(U,Z)}, dist ${R$(z,Z)})`});let F=g0.join(X,"node_modules/@stacksjs/stx"),j=null;try{j=L1.lstatSync(F)}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 O=null;try{O=L1.realpathSync(F)}catch{}let L=(()=>{try{return L1.realpathSync(W)}catch{return W}})();Y.push(O===L?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${O||"(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"},Q=["stx runtime resolution:"];for(let Z of $.checks)if(Q.push(` ${X[Z.status]} ${Z.name}: ${Z.detail}`),Z.fix)Q.push(` \u2192 ${Z.fix}`);return Q.push(""),Q.push($.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),Q.join(`
4408
+ `)}var{Glob:NY}=globalThis.Bun;import{cpSync as u7,existsSync as f$,mkdirSync as m7,readFileSync as p7,readdirSync as MY,rmSync as VY,statSync as EY,unlinkSync as IY,writeFileSync as v$}from"fs";import{dirname as RY,join as R0,relative as DY}from"path";import c7 from"process";import f0 from"path";function S7($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function P7($,X,Q){let Z=S7(X),Y=Q?S7(Q):"";return`<!DOCTYPE html>
4409
4409
  <html>
4410
4410
  <head>
4411
4411
  <title>stx Error</title>
@@ -4421,51 +4421,53 @@ File changed: ${Y}, rebuilding...`);let J=await VZ($);X?.(J)}});return{close:()=
4421
4421
  ${Y?`<div class="file-path">File: ${Y}</div>`:""}
4422
4422
  <pre>${Z}</pre>
4423
4423
  </body>
4424
- </html>`}function x7($){return{name:"bun-plugin-stx",async setup(X){let Q={...E$,...$},Z=new Set;if(!X.config.root&&X.config.entrypoints?.length){let W=X.config.entrypoints.map((K)=>f0.dirname(f0.resolve(K))).reduce((K,_)=>{let U=K.split(f0.sep),z=_.split(f0.sep),F=0;while(F<U.length&&F<z.length&&U[F]===z[F])F++;return U.slice(0,F).join(f0.sep)});X.config.root=W}let Y=Q.webComponents?.enabled?`./${f0.relative(f0.dirname(X.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Q.webComponents?.enabled)try{let G=await G$(Q,Z);if(J.push(...G),Q.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}X.onResolve({filter:/^\//},(G)=>{if(G.path.startsWith("//"))return null;if(!G.importer)return null;return{external:!0,path:G.path}}),X.onLoad({filter:/\.md$/},async(G)=>{let W=G.path;try{let{content:K,data:_}=await V0(W,Q);return{contents:`// ${W}
4425
- const content = ${JSON.stringify(K)};
4426
- const data = ${JSON.stringify(_)};
4424
+ </html>`}function x7($){return{name:"bun-plugin-stx",async setup(X){let Q={};try{Q=await d0(process.cwd())}catch{}let Z={...E$,...Q,...$},Y=new Set;if(!X.config.root&&X.config.entrypoints?.length){let K=X.config.entrypoints.map((_)=>f0.dirname(f0.resolve(_))).reduce((_,U)=>{let z=_.split(f0.sep),F=U.split(f0.sep),j=0;while(j<z.length&&j<F.length&&z[j]===F[j])j++;return z.slice(0,j).join(f0.sep)});X.config.root=K}let J=Z.webComponents?.enabled?`./${f0.relative(f0.dirname(X.config?.outdir||"dist"),Z.webComponents.outputDir||"dist/web-components")}`:"/web-components",G=[];if(Z.webComponents?.enabled)try{let W=await G$(Z,Y);if(G.push(...W),Z.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 V0(K,Z);return{contents:`// ${K}
4425
+ const content = ${JSON.stringify(_)};
4426
+ const data = ${JSON.stringify(U)};
4427
4427
 
4428
4428
  export { content, data };
4429
4429
  export { content as default };
4430
- `,loader:"js"}}catch(K){console.error("Markdown Processing Error:",K);let _=S7("Markdown Processing Error",K.message||"Unknown error",W);return{contents:`// ${W}
4431
- const content = ${JSON.stringify(_)};
4430
+ `,loader:"js"}}catch(_){console.error("Markdown Processing Error:",_);let U=P7("Markdown Processing Error",_.message||"Unknown error",K);return{contents:`// ${K}
4431
+ const content = ${JSON.stringify(U)};
4432
4432
  const data = {};
4433
4433
 
4434
4434
  export { content, data };
4435
4435
  export { content as default };
4436
- `,loader:"js"}}}),X.onLoad({filter:/\.(jsx|tsx)$/},async(G)=>{let W=G.path;try{let K=await Bun.file(W).text(),_=W.endsWith(".tsx")?"tsx":"jsx";return{contents:new Bun.Transpiler({loader:_,jsxOptimizationInline:!0}).transformSync(K),loader:"js"}}catch(K){return console.error("JSX Processing Error:",K),{contents:"export default function() { return null; }",loader:"js"}}}),X.onLoad({filter:/\.stx$/},async({path:G})=>{try{let W=new Set;if(Q.cache&&Q.cachePath){let A=await Y$(G,Q);if(A){if(Q.debug)console.log(`Using cached version of ${G}`);return{contents:A,loader:"html"}}}let K=await Bun.file(G).text(),_=K,U=K.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(U)_=U[1].trim();let z=b7(K),F=z.client.map((A)=>A.fullTag),O=z.server.map((A)=>A.content),j=_;for(let A of O){let q=A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");j=j.replace(new RegExp(`<script\\b[^>]*>${q}<\\/script>`,"gi"),"")}for(let A of F){let q=A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");j=j.replace(q,"")}let L={__filename:G,__dirname:f0.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J},__stx_options:Q,__stx_sfc_mode:!0};for(let A of O)await j0(A,L,G);let H=j;if(H=await O0(H,L,G,Q,W),F.length>0){let A=L.__stx_event_bindings||[],M=(await Promise.all(F.map(async(N)=>{let R=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!R)return N;return P7(R[1],{eventBindings:A,templateContent:H})}))).join(`
4437
- `);if(H.match(/(<\/body>)/i))H=H.replace(/(<\/body>)/i,`${M}
4438
- $1`);else H+=`
4439
- ${M}`;L.__stx_event_bindings=[]}if(W.forEach((A)=>Z.add(A)),Q.cache&&Q.cachePath){if(await J$(G,H,W,Q),Q.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:H,loader:"html"}}catch(W){return console.error("stx Plugin Error:",W),{contents:S7("stx Rendering Error",W.message||String(W),G),loader:"html"}}})}}}var y7=x7;function D$($,X,Q={},Z="/"){let Y=X.seo??{},J=Q.title??Y.title??X.name,G=Q.description??Y.description??X.description??"",W=Q.image??Y.image,K=`${X.url.replace(/\/$/,"")}${Z}`,_=Y.siteName??X.name,U=Y.type??"website",z=Y.locale??"en_US",F=[];if(Y.favicon){let I=Y.favicon.toLowerCase().split(".").pop(),E=I==="svg"?"image/svg+xml":I==="ico"?"image/x-icon":I==="png"?"image/png":I==="jpg"||I==="jpeg"?"image/jpeg":"";F.push(`<link rel="icon"${E?` type="${E}"`:""} href="${Q0(Y.favicon)}">`)}if(F.push(`<title>${QY(J)}</title>`,`<link rel="canonical" href="${Q0(K)}">`,`<meta name="description" content="${Q0(G)}">`,`<meta property="og:title" content="${Q0(J)}">`,`<meta property="og:description" content="${Q0(G)}">`,`<meta property="og:type" content="${Q0(U)}">`,`<meta property="og:url" content="${Q0(K)}">`,`<meta property="og:site_name" content="${Q0(_)}">`,`<meta property="og:locale" content="${Q0(z)}">`,`<meta name="twitter:card" content="${W?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${Q0(J)}">`,`<meta name="twitter:description" content="${Q0(G)}">`),W)F.push(`<meta property="og:image" content="${Q0(W)}">`),F.push(`<meta name="twitter:image" content="${Q0(W)}">`);if(Y.twitter)F.push(`<meta name="twitter:site" content="@${Q0(Y.twitter.replace(/^@/,""))}">`),F.push(`<meta name="twitter:creator" content="@${Q0(Y.twitter.replace(/^@/,""))}">`);let O=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(O.test($))$=$.replace(O,"");$=$.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 j=$.search(/<\/head>/i),L=j===-1?$:$.slice(0,j),H=/^(?:stx App|stx Project|Document|Untitled)$/i,A=/<title[^>]*>([\s\S]*?)<\/title>/i.exec(L)?.[1]?.trim(),q=A===void 0||A===""||H.test(A),M=(I)=>{if(/^<title[\s>]/i.test(I))return/<title[\s>]/i.test(L)&&!q;if(/rel="canonical"/i.test(I))return/<link[^>]+rel=["']canonical["']/i.test(L);let f=/(?:property|name)="([^"]+)"/i.exec(I)?.[1];if(!f)return!1;return new RegExp(`<meta[^>]+(?:property|name)=["']${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["']`,"i").test(L)},V=F.filter((I)=>!M(I));if(V.length===0)return $;let N=$,R=V.find((I)=>/^<title[\s>]/i.test(I));if(R&&q&&/<title[^>]*>[\s\S]*?<\/title>/i.test(N)){if(N=N.replace(/<title[^>]*>[\s\S]*?<\/title>/i,()=>R),V=V.filter((I)=>I!==R),V.length===0)return N}let w=`<!-- SEO -->
4436
+ `,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(Z.cache&&Z.cachePath){let A=await Y$(W,Z);if(A){if(Z.debug)console.log(`Using cached version of ${W}`);return{contents:A,loader:"html"}}}let _=await Bun.file(W).text(),U=_,z=_.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(z)U=z[1].trim();let F=y7(_),j=F.client.map((A)=>A.fullTag),O=F.server.map((A)=>A.content),L=U;for(let A of O){let N=A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");L=L.replace(new RegExp(`<script\\b[^>]*>${N}<\\/script>`,"gi"),"")}for(let A of j){let N=A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");L=L.replace(N,"")}let H={__filename:W,__dirname:f0.dirname(W),__stx:{webComponentsPath:J,builtComponents:G},__stx_options:Z,__stx_sfc_mode:!0};for(let A of O)await j0(A,H,W);let q=L;if(q=await O0(q,H,W,Z,K),j.length>0){let A=H.__stx_event_bindings||[],V=(await Promise.all(j.map(async(R)=>{let w=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!w)return R;return b7(w[1],{eventBindings:A,templateContent:q})}))).join(`
4437
+ `);if(q.match(/(<\/body>)/i))q=q.replace(/(<\/body>)/i,`${V}
4438
+ $1`);else q+=`
4439
+ ${V}`;H.__stx_event_bindings=[]}if(K.forEach((A)=>Y.add(A)),Z.cache&&Z.cachePath){if(await J$(W,q,K,Z),Z.debug)console.log(`Cached template ${W} with ${K.size} dependencies`)}return{contents:q,loader:"html"}}catch(K){return console.error("stx Plugin Error:",K),{contents:P7("stx Rendering Error",K.message||String(K),W),loader:"html"}}})}}}var v7=x7;function D$($,X,Q={},Z="/"){let Y=X.seo??{},J=Q.title??Y.title??X.name,G=Q.description??Y.description??X.description??"",W=Q.image??Y.image,K=`${X.url.replace(/\/$/,"")}${Z}`,_=Y.siteName??X.name,U=Y.type??"website",z=Y.locale??"en_US",F=[];if(Y.favicon){let I=Y.favicon.toLowerCase().split(".").pop(),E=I==="svg"?"image/svg+xml":I==="ico"?"image/x-icon":I==="png"?"image/png":I==="jpg"||I==="jpeg"?"image/jpeg":"";F.push(`<link rel="icon"${E?` type="${E}"`:""} href="${Q0(Y.favicon)}">`)}if(F.push(`<title>${YY(J)}</title>`,`<link rel="canonical" href="${Q0(K)}">`,`<meta name="description" content="${Q0(G)}">`,`<meta property="og:title" content="${Q0(J)}">`,`<meta property="og:description" content="${Q0(G)}">`,`<meta property="og:type" content="${Q0(U)}">`,`<meta property="og:url" content="${Q0(K)}">`,`<meta property="og:site_name" content="${Q0(_)}">`,`<meta property="og:locale" content="${Q0(z)}">`,`<meta name="twitter:card" content="${W?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${Q0(J)}">`,`<meta name="twitter:description" content="${Q0(G)}">`),W)F.push(`<meta property="og:image" content="${Q0(W)}">`),F.push(`<meta name="twitter:image" content="${Q0(W)}">`);if(Y.twitter)F.push(`<meta name="twitter:site" content="@${Q0(Y.twitter.replace(/^@/,""))}">`),F.push(`<meta name="twitter:creator" content="@${Q0(Y.twitter.replace(/^@/,""))}">`);let j=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(j.test($))$=$.replace(j,"");$=$.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 O=$.search(/<\/head>/i),L=O===-1?$:$.slice(0,O),H=/^(?:stx App|stx Project|Document|Untitled)$/i,q=/<title[^>]*>([\s\S]*?)<\/title>/i.exec(L)?.[1]?.trim(),A=q===void 0||q===""||H.test(q),N=(I)=>{if(/^<title[\s>]/i.test(I))return/<title[\s>]/i.test(L)&&!A;if(/rel="canonical"/i.test(I))return/<link[^>]+rel=["']canonical["']/i.test(L);let f=/(?:property|name)="([^"]+)"/i.exec(I)?.[1];if(!f)return!1;return new RegExp(`<meta[^>]+(?:property|name)=["']${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["']`,"i").test(L)},V=F.filter((I)=>!N(I));if(V.length===0)return $;let M=$,R=V.find((I)=>/^<title[\s>]/i.test(I));if(R&&A&&/<title[^>]*>[\s\S]*?<\/title>/i.test(M)){if(M=M.replace(/<title[^>]*>[\s\S]*?<\/title>/i,()=>R),V=V.filter((I)=>I!==R),V.length===0)return M}let w=`<!-- SEO -->
4440
4440
  ${V.join(`
4441
4441
  `)}
4442
- <!-- /SEO -->`,C=N.search(/<\/head>/i);if(C!==-1)return`${N.slice(0,C)}${w}
4443
- ${N.slice(C)}`;if(/<head[^>]*>/i.test(N))return N.replace(/<head([^>]*)>/i,`<head$1>
4442
+ <!-- /SEO -->`,C=M.search(/<\/head>/i);if(C!==-1)return`${M.slice(0,C)}${w}
4443
+ ${M.slice(C)}`;if(/<head[^>]*>/i.test(M))return M.replace(/<head([^>]*)>/i,`<head$1>
4444
4444
  ${w}`);return`${w}
4445
- ${N}`}function Q0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function QY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function w$($,X){let Q=$.url.replace(/\/$/,""),Z=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=`${Q}${J.path}`,W=J.page?.priority??(J.path==="/"?1:0.8),K=J.page?.changefreq??"monthly";return[" <url>",` <loc>${ZY(G)}</loc>`,` <lastmod>${Z}</lastmod>`,` <changefreq>${K}</changefreq>`,` <priority>${W.toFixed(1)}</priority>`," </url>"].join(`
4445
+ ${M}`}function Q0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function YY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function w$($,X){let Q=$.url.replace(/\/$/,""),Z=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=`${Q}${J.path}`,W=J.page?.priority??(J.path==="/"?1:0.8),K=J.page?.changefreq??"monthly";return[" <url>",` <loc>${JY(G)}</loc>`,` <lastmod>${Z}</lastmod>`,` <changefreq>${K}</changefreq>`,` <priority>${W.toFixed(1)}</priority>`," </url>"].join(`
4446
4446
  `)}).join(`
4447
4447
  `),"</urlset>",""].join(`
4448
- `)}function ZY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function T$($){let X=$.robots??"allow";if(X===!1)return null;if(typeof X==="string"&&X!=="allow"&&X!=="disallow")return X.endsWith(`
4448
+ `)}function JY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function T$($){let X=$.robots??"allow";if(X===!1)return null;if(typeof X==="string"&&X!=="allow"&&X!=="disallow")return X.endsWith(`
4449
4449
  `)?X:`${X}
4450
4450
  `;let Q=$.sitemap!==!1?`Sitemap: ${$.url.replace(/\/$/,"")}/sitemap.xml
4451
4451
  `:"";if(X==="disallow")return["User-agent: *","Disallow: /","",Q].filter(Boolean).join(`
4452
4452
  `);return["User-agent: *","Allow: /","",Q].filter(Boolean).join(`
4453
- `)}var L1=null;async function YY(){if(L1!==null)return L1;try{let $=await import("./chunk-0yw0x5qz.js");if(typeof $.getRouterScript==="function")L1=$.getRouterScript();else L1=""}catch{L1=""}return L1}async function S5($,X){let Q=await YY();if(!Q)return $;let Z={interceptAllLinks:!0,container:"main",...X},J=`${`<script>window.__stxRouterConfig=${JSON.stringify(Z)};</script>
4453
+ `)}var F1=null;async function GY(){if(F1!==null)return F1;try{let $=await import("./chunk-gtek2yzx.js");if(typeof $.getRouterScript==="function")F1=$.getRouterScript();else F1=""}catch{F1=""}return F1}async function b5($,X){let Q=await GY();if(!Q)return $;let Z={interceptAllLinks:!0,container:"main",...X},J=`${`<script>window.__stxRouterConfig=${JSON.stringify(Z)};</script>
4454
4454
  `}<script>${Q}</script>`;if(/<\/body>/i.test($))return $.replace(/<\/body>/i,`${J}
4455
4455
  </body>`);return`${$}
4456
- ${J}`}var JY=`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){}};`,GY=($,X,Q,Z)=>`(function(){${JY}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(Z)}:${JSON.stringify(Q)};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)})();`,WY=($,X,Q)=>`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(Q)}:${JSON.stringify(X)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;function C$($,X){if(X.theme===!1)return $;let Q=$.includes(v7),Z=typeof X.theme==="object"&&X.theme!==null?X.theme:{},Y=Z.default??"dark",J=Z.storageKey??"theme",G=Z.colors?.light??"#ffffff",W=Z.colors?.dark??"#000000";if(Y==="dark"&&!Q){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(`
4456
+ ${J}`}var WY=`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){}};`,KY=($,X,Q,Z)=>`(function(){${WY}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(Z)}:${JSON.stringify(Q)};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)})();`,_Y=($,X,Q)=>`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(Q)}:${JSON.stringify(X)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;function C$($,X){if(X.theme===!1)return $;let Q=$.includes(g7),Z=typeof X.theme==="object"&&X.theme!==null?X.theme:{},Y=Z.default??"dark",J=Z.storageKey??"theme",G=Z.colors?.light??"#ffffff",W=Z.colors?.dark??"#000000";if(Y==="dark"&&!Q){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(`
4457
4457
  `);$=$.replace(/<head\b([^>]*)>/i,`<head$1>
4458
- ${K}`)}if(!Q&&!$.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"})};`}${GY(Y,J,G,W)};window.__stxThemeGuard=1;</script>`;$=$.replace(/<head\b([^>]*)>/i,`<head$1>
4459
- ${_}`)}if(!Q&&!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let K=`<script data-stx-theme-toggle="1">${WY(J,G,W)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
4460
- </body>`)}return $}async function g7($,X){if($.length===0)return{succeeded:[],failed:[]};try{return await X($),{succeeded:[...$],failed:[]}}catch{}let Q=[],Z=[];for(let Y of $)try{await X([Y]),Q.push(Y)}catch(J){Z.push({entrypoint:Y,error:X1(J,Y)})}return{succeeded:Q,failed:Z}}import{existsSync as KY,readFileSync as _Y}from"fs";import{join as UY,resolve as BY}from"path";import LY from"process";function x$($,X=LY.cwd()){let Q=$.i18n;if(!Q||!Array.isArray(Q.locales)||Q.locales.length===0)return null;let Z=Q.defaultLocale??Q.locales[0],Y=FY(Q,X);return{locales:Q.locales,defaultLocale:Z,labels:Q.labels??Object.fromEntries(Q.locales.map((J)=>[J,J.toUpperCase()])),translations:Y,pickerSelector:Q.pickerSelector??"#lang-picker"}}function FY($,X){let Q=$.translations??{},Z={},Y=$.translationsDir,J=Y===!1?null:BY(X,typeof Y==="string"&&Y?Y:"translations"),G=$.format??"json";for(let W of $.locales){let K=J?zY(J,W,G):{};Z[W]={...K,...Q[W]??{}}}return Z}function zY($,X,Q){let Z=Q==="json"?[`${X}.json`]:[`${X}.${Q}`,`${X}.${Q==="yaml"?"yml":"yaml"}`];for(let Y of Z){let J=UY($,Y);if(!KY(J))continue;try{let G=_Y(J,"utf8"),W=Q==="json"?JSON.parse(G):jY(G);return f7(W)}catch{continue}}return{}}function f7($,X="",Q={}){if(!$||typeof $!=="object")return Q;for(let[Z,Y]of Object.entries($)){let J=X?`${X}.${Z}`:Z;if(Y&&typeof Y==="object"&&!Array.isArray(Y))f7(Y,J,Q);else if(typeof Y==="string")Q[J]=Y;else if(typeof Y==="number"||typeof Y==="boolean")Q[J]=String(Y)}return Q}function jY($){let X={},Q=[{obj:X,indent:-1}];for(let Z of $.split(`
4461
- `)){let Y=Z.replace(/#.*$/,"").trimEnd();if(!Y.trim())continue;let J=Y.search(/\S/);if(J===-1)continue;while(Q.length>1&&Q[Q.length-1].indent>=J)Q.pop();let G=Q[Q.length-1].obj,W=Y.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(!W)continue;let[,,K,_]=W,U=K.trim(),z=_.trim();if(z==="")G[U]={},Q.push({obj:G[U],indent:J});else G[U]=OY(z)}return X}function OY($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function b5($,X,Q){let Z=$.translations[X]?.[Q];if(typeof Z==="string")return Z;let Y=$.translations[$.defaultLocale]?.[Q];if(typeof Y==="string")return Y;return Q}function k$($,X,Q){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(Z,Y,J)=>{let G=b5(X,Q,J);return Y==="!"?G:HY(G)})}function h0($,X,Q){if(X===Q)return $;if($==="/")return`/${X}/`;if($==="/404.html")return`/${X}/404.html`;return`/${X}${$}`}function h7($,X){for(let Q of X){if($===`/${Q}`||$===`/${Q}/`)return{locale:Q,path:"/"};if($.startsWith(`/${Q}/`))return{locale:Q,path:$.slice(Q.length+1)}}return{locale:null,path:$}}function S$($,X,Q){let Z=$.replace(/\/$/,""),Y=[];for(let G of Q.locales){let W=`${Z}${h0(X,G,Q.defaultLocale)}`;Y.push(`<link rel="alternate" hreflang="${P5(G)}" href="${P5(W)}">`)}let J=`${Z}${h0(X,Q.defaultLocale,Q.defaultLocale)}`;return Y.push(`<link rel="alternate" hreflang="x-default" href="${P5(J)}">`),Y.join(`
4462
- `)}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 P5($){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;")}async function i7($){let X=Date.now(),Q=$.pagesDir??"pages",Z=$.outDir??"dist",Y=$.publicDir??"public";if(!$.noClean)NY(Z,{recursive:!0,force:!0});u7(Z,{recursive:!0});let J=new AY(`${Q}/**/*.stx`),G=await Array.fromAsync(J.scan(".")),W=$.excludeDirs??["layouts","partials","components"],K=[],_=G.filter((V)=>{let N=V.slice(Q.length).replace(/^[\\/]+/,"");if(N.split(/[\\/]/).slice(0,-1).some((w)=>W.includes(w)))return K.push(V),!1;return!N.split(/[\\/]/).some((w)=>w.startsWith("_"))});if(K.length>0)console.warn(`[stx] ${K.length} file(s) under ${Q}/ skipped as non-pages: ${W.join(", ")}`);if(_.length===0)throw Error(`No .stx files found in ${Q}/`);let U=await g7(_,(V)=>Bun.build({entrypoints:V,outdir:Z,plugins:[y7()],naming:{entry:"[name].[ext]"}}));if(U.failed.length>0){for(let{entrypoint:V,error:N}of U.failed)console.error(`[stx] failed to build ${V}:
4463
- ${N}`);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.`)}wY(Z);let z=f5(Z).filter((V)=>V.endsWith(".html")),F=x$($,p7.cwd()),O=new Set(z.map(y$));for(let V of z){let N=R0(Z,V),R=m7(N,"utf8"),w=y$(V),C=F?F.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let I of C){let E=R;if(E=TY(E),F)E=k$(E,F,I);if(E=await o(E,p7.cwd()),E=D$(E,$,$.pages?.[w],w),F)E=CY(E,$,F,I,w),E=xY(E,I,F.defaultLocale,O);if(E=C$(E,$),E=kY(E),F)E=E.replace(/<\/body>/i,`${P$(F,I)}
4464
- </body>`);if($.spa!==!1)E=await S5(E,$.router);let m=F?DY(w,I,F.defaultLocale):V,f=R0(Z,m);if(u7(RY(f),{recursive:!0}),b$(f,E),F&&I!==F.defaultLocale&&m!==V);}}let j=v5(Z);if(j.assets>0)console.log(`[stx] externalized ${j.assets} asset(s) from ${j.pages} page(s) (${(j.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let L=g5(Z);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(v$(Y))d7(Y,Z,{recursive:!0});let H=l7();if(H)d7(H,R0(Z,c7),{recursive:!0});let A=R0(Z,"404.html");if(!v$(A)&&v$(R0(Z,"index.html"))){let V=m7(R0(Z,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${SY($.name)}</title>`);b$(A,V)}if($.sitemap!==!1){let V=[],N=z.filter((w)=>w!=="404.html").map(y$),R=F?F.locales:[null];for(let w of N){let C=$.pages?.[w];for(let I of R){let E=I&&F?h0(w,I,F.defaultLocale):w;V.push({path:E,page:C})}}b$(R0(Z,"sitemap.xml"),w$($,V))}let q=T$($);if(q!==null)b$(R0(Z,"robots.txt"),q);let M=z.map(y$);return{outDir:Z,pages:M,durationMs:Date.now()-X}}function RY($){return EY($)}function DY($,X,Q){let Z=h0($,X,Q);if(Z==="/")return"index.html";let Y=Z.replace(/^\//,"").replace(/\/$/,"");if(!Y.includes("/")){if(X!==Q&&Y===X)return`${X}/index.html`;return`${Y}.html`}return`${Y}.html`.replace(/\.html\.html$/,".html")}function y$($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function f5($,X=$){let Q=[];if(!v$($))return Q;for(let Z of qY($,{withFileTypes:!0})){let Y=R0($,Z.name);if(Z.isDirectory())Q.push(...f5(Y,X));else Q.push(IY(X,Y))}return Q}function wY($){for(let X of f5($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(X))continue;let Q=R0($,X);try{if(MY(Q).size===0)VY(Q)}catch{}}}function TY($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function CY($,X,Q,Z,Y){if(!Q)return $;if(/<html\b[^>]*\blang=/i.test($))$=$.replace(/<html\b([^>]*)\blang="[^"]*"/i,`<html$1lang="${Z}"`);else $=$.replace(/<html\b([^>]*)>/i,`<html$1 lang="${Z}">`);let J=`${X.url.replace(/\/$/,"")}${h0(Y,Z,Q.defaultLocale)}`;if(/<link rel="canonical"/.test($))$=$.replace(/<link rel="canonical"[^>]*>/,`<link rel="canonical" href="${y5(J)}">`);let G=Z.includes("_")||Z.includes("-")?Z:Z.toLowerCase();if(/<meta property="og:locale"/.test($))$=$.replace(/<meta property="og:locale"[^>]*>/,`<meta property="og:locale" content="${y5(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${y5(J)}">`);let W=S$(X.url,Y,Q);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(K)=>`${W}
4465
- ${K}`);return $}function y5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xY($,X,Q,Z){if(X===Q)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,z=_==="/"?"/":_.replace(/\/$/,"");if(!Z.has(z))return Y;let F=z==="/"?`/${X}/`:`/${X}${z}`;return`<a${J}href="${F}${U}"${W}>`})}function kY($){if(/<main\b/i.test($)||/\bdata-stx-content\b/i.test($))return $;let X=$.match(/<body\b[^>]*>/i),Q=$.search(/<\/body\s*>/i);if(!X||Q<0)return $;let Z=X.index+X[0].length,Y=$.slice(Z,Q),J=0,G=[...Y.matchAll(/<\/nav>/gi)];if(G.length>0){let F=G[G.length-1];J=F.index+F[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 z=`${Y.slice(0,J)}
4458
+ ${K}`)}if(!Q&&!$.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"})};`}${KY(Y,J,G,W)};window.__stxThemeGuard=1;</script>`;$=$.replace(/<head\b([^>]*)>/i,`<head$1>
4459
+ ${_}`)}if(!Q&&!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let K=`<script data-stx-theme-toggle="1">${_Y(J,G,W)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
4460
+ </body>`)}return $}async function f7($,X){if($.length===0)return{succeeded:[],failed:[]};try{return await X($),{succeeded:[...$],failed:[]}}catch{}let Q=[],Z=[];for(let Y of $)try{await X([Y]),Q.push(Y)}catch(J){Z.push({entrypoint:Y,error:Q1(J,Y)})}return{succeeded:Q,failed:Z}}import{existsSync as UY,readFileSync as BY}from"fs";import{join as LY,resolve as FY}from"path";import zY from"process";function x$($,X=zY.cwd()){let Q=$.i18n;if(!Q||!Array.isArray(Q.locales)||Q.locales.length===0)return null;let Z=Q.defaultLocale??Q.locales[0],Y=jY(Q,X);return{locales:Q.locales,defaultLocale:Z,labels:Q.labels??Object.fromEntries(Q.locales.map((J)=>[J,J.toUpperCase()])),translations:Y,pickerSelector:Q.pickerSelector??"#lang-picker"}}function jY($,X){let Q=$.translations??{},Z={},Y=$.translationsDir,J=Y===!1?null:FY(X,typeof Y==="string"&&Y?Y:"translations"),G=$.format??"json";for(let W of $.locales){let K=J?OY(J,W,G):{};Z[W]={...K,...Q[W]??{}}}return Z}function OY($,X,Q){let Z=Q==="json"?[`${X}.json`]:[`${X}.${Q}`,`${X}.${Q==="yaml"?"yml":"yaml"}`];for(let Y of Z){let J=LY($,Y);if(!UY(J))continue;try{let G=BY(J,"utf8"),W=Q==="json"?JSON.parse(G):HY(G);return h7(W)}catch{continue}}return{}}function h7($,X="",Q={}){if(!$||typeof $!=="object")return Q;for(let[Z,Y]of Object.entries($)){let J=X?`${X}.${Z}`:Z;if(Y&&typeof Y==="object"&&!Array.isArray(Y))h7(Y,J,Q);else if(typeof Y==="string")Q[J]=Y;else if(typeof Y==="number"||typeof Y==="boolean")Q[J]=String(Y)}return Q}function HY($){let X={},Q=[{obj:X,indent:-1}];for(let Z of $.split(`
4461
+ `)){let Y=Z.replace(/#.*$/,"").trimEnd();if(!Y.trim())continue;let J=Y.search(/\S/);if(J===-1)continue;while(Q.length>1&&Q[Q.length-1].indent>=J)Q.pop();let G=Q[Q.length-1].obj,W=Y.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(!W)continue;let[,,K,_]=W,U=K.trim(),z=_.trim();if(z==="")G[U]={},Q.push({obj:G[U],indent:J});else G[U]=AY(z)}return X}function AY($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function y5($,X,Q){let Z=$.translations[X]?.[Q];if(typeof Z==="string")return Z;let Y=$.translations[$.defaultLocale]?.[Q];if(typeof Y==="string")return Y;return Q}function S$($,X,Q){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(Z,Y,J)=>{let G=y5(X,Q,J);return Y==="!"?G:qY(G)})}function h0($,X,Q){if(X===Q)return $;if($==="/")return`/${X}/`;if($==="/404.html")return`/${X}/404.html`;return`/${X}${$}`}function d7($,X){for(let Q of X){if($===`/${Q}`||$===`/${Q}/`)return{locale:Q,path:"/"};if($.startsWith(`/${Q}/`))return{locale:Q,path:$.slice(Q.length+1)}}return{locale:null,path:$}}function P$($,X,Q){let Z=$.replace(/\/$/,""),Y=[];for(let G of Q.locales){let W=`${Z}${h0(X,G,Q.defaultLocale)}`;Y.push(`<link rel="alternate" hreflang="${k$(G)}" href="${k$(W)}">`)}let J=`${Z}${h0(X,Q.defaultLocale,Q.defaultLocale)}`;return Y.push(`<link rel="alternate" hreflang="x-default" href="${k$(J)}">`),Y.join(`
4462
+ `)}function b$($,X){let Q=`<meta name="stx-layout-group" content="i18n:${k$(X)}">`;if(/<meta name="stx-layout-group"[^>]*>/i.test($))return $.replace(/<meta name="stx-layout-group"[^>]*>/i,Q);if(/<\/head>/i.test($))return $.replace(/<\/head>/i,`${Q}
4463
+ </head>`);return`${Q}
4464
+ ${$}`}function y$($,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 k$($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function qY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function a7($){let X=Date.now(),Q=$.pagesDir??"pages",Z=$.outDir??"dist",Y=$.publicDir??"public";if(!$.noClean)VY(Z,{recursive:!0,force:!0});m7(Z,{recursive:!0});let J=new NY(`${Q}/**/*.stx`),G=await Array.fromAsync(J.scan(".")),W=$.excludeDirs??["layouts","partials","components"],K=[],_=G.filter((V)=>{let M=V.slice(Q.length).replace(/^[\\/]+/,"");if(M.split(/[\\/]/).slice(0,-1).some((w)=>W.includes(w)))return K.push(V),!1;return!M.split(/[\\/]/).some((w)=>w.startsWith("_"))});if(K.length>0)console.warn(`[stx] ${K.length} file(s) under ${Q}/ skipped as non-pages: ${W.join(", ")}`);if(_.length===0)throw Error(`No .stx files found in ${Q}/`);let U=await f7(_,(V)=>Bun.build({entrypoints:V,outdir:Z,plugins:[v7()],naming:{entry:"[name].[ext]"}}));if(U.failed.length>0){for(let{entrypoint:V,error:M}of U.failed)console.error(`[stx] failed to build ${V}:
4465
+ ${M}`);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.`)}CY(Z);let z=h5(Z).filter((V)=>V.endsWith(".html")),F=x$($,c7.cwd()),j=new Set(z.map(g$));for(let V of z){let M=R0(Z,V),R=p7(M,"utf8"),w=g$(V),C=F?F.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let I of C){let E=R;if(E=kY(E),F)E=S$(E,F,I);if(E=await o(E,c7.cwd()),E=D$(E,$,$.pages?.[w],w),F)E=xY(E,$,F,I,w),E=SY(E,I,F.defaultLocale,j),E=b$(E,I);if(E=C$(E,$),E=PY(E),F)E=E.replace(/<\/body>/i,`${y$(F,I)}
4466
+ </body>`);if($.spa!==!1)E=await b5(E,$.router);let m=F?TY(w,I,F.defaultLocale):V,f=R0(Z,m);if(m7(wY(f),{recursive:!0}),v$(f,E),F&&I!==F.defaultLocale&&m!==V);}}let O=g5(Z);if(O.assets>0)console.log(`[stx] externalized ${O.assets} asset(s) from ${O.pages} page(s) (${(O.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let L=f5(Z);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(f$(Y))u7(Y,Z,{recursive:!0});let H=i7();if(H)u7(H,R0(Z,l7),{recursive:!0});let q=R0(Z,"404.html");if(!f$(q)&&f$(R0(Z,"index.html"))){let V=p7(R0(Z,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${bY($.name)}</title>`);v$(q,V)}if($.sitemap!==!1){let V=[],M=z.filter((w)=>w!=="404.html").map(g$),R=F?F.locales:[null];for(let w of M){let C=$.pages?.[w];for(let I of R){let E=I&&F?h0(w,I,F.defaultLocale):w;V.push({path:E,page:C})}}v$(R0(Z,"sitemap.xml"),w$($,V))}let A=T$($);if(A!==null)v$(R0(Z,"robots.txt"),A);let N=z.map(g$);return{outDir:Z,pages:N,durationMs:Date.now()-X}}function wY($){return RY($)}function TY($,X,Q){let Z=h0($,X,Q);if(Z==="/")return"index.html";let Y=Z.replace(/^\//,"").replace(/\/$/,"");if(!Y.includes("/")){if(X!==Q&&Y===X)return`${X}/index.html`;return`${Y}.html`}return`${Y}.html`.replace(/\.html\.html$/,".html")}function g$($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function h5($,X=$){let Q=[];if(!f$($))return Q;for(let Z of MY($,{withFileTypes:!0})){let Y=R0($,Z.name);if(Z.isDirectory())Q.push(...h5(Y,X));else Q.push(DY(X,Y))}return Q}function CY($){for(let X of h5($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(X))continue;let Q=R0($,X);try{if(EY(Q).size===0)IY(Q)}catch{}}}function kY($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function xY($,X,Q,Z,Y){if(!Q)return $;if(/<html\b[^>]*\blang=/i.test($))$=$.replace(/<html\b([^>]*)\blang="[^"]*"/i,`<html$1lang="${Z}"`);else $=$.replace(/<html\b([^>]*)>/i,`<html$1 lang="${Z}">`);let J=`${X.url.replace(/\/$/,"")}${h0(Y,Z,Q.defaultLocale)}`;if(/<link rel="canonical"/.test($))$=$.replace(/<link rel="canonical"[^>]*>/,`<link rel="canonical" href="${v5(J)}">`);let G=Z.includes("_")||Z.includes("-")?Z:Z.toLowerCase();if(/<meta property="og:locale"/.test($))$=$.replace(/<meta property="og:locale"[^>]*>/,`<meta property="og:locale" content="${v5(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${v5(J)}">`);let W=P$(X.url,Y,Q);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(K)=>`${W}
4467
+ ${K}`);return $}function v5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function SY($,X,Q,Z){if(X===Q)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,z=_==="/"?"/":_.replace(/\/$/,"");if(!Z.has(z))return Y;let F=z==="/"?`/${X}/`:`/${X}${z}`;return`<a${J}href="${F}${U}"${W}>`})}function PY($){if(/<main\b/i.test($)||/\bdata-stx-content\b/i.test($))return $;let X=$.match(/<body\b[^>]*>/i),Q=$.search(/<\/body\s*>/i);if(!X||Q<0)return $;let Z=X.index+X[0].length,Y=$.slice(Z,Q),J=0,G=[...Y.matchAll(/<\/nav>/gi)];if(G.length>0){let F=G[G.length-1];J=F.index+F[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 z=`${Y.slice(0,J)}
4466
4468
  <main>${U}</main>
4467
- ${Y.slice(W)}`;return`${$.slice(0,Z)}${z}${$.slice(Q)}`}function SY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function a7($){return $}var PY=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),bY=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function yY($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vY($){let X=[],Q=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,Z;while((Z=Q.exec($))!==null)X.push([Z.index,Z.index+Z[0].length]);return X}function gY($,X){for(let[Q,Z]of $)if(X>=Q&&X<Z)return!0;return!1}function f$($,X){let Q=1,Z=0;for(let Y=0;Y<X&&Y<$.length;Y++)if($[Y]===`
4468
- `)Q++,Z=Y+1;return{line:Q,column:X-Z+1}}function fY($,X,Q){let Z=X.toLowerCase(),Y=$.length,J=1,G=Q;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()===Z){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()===Z&&$[_-1]!=="/")J++;G=_+1}return-1}function hY($,X,Q){let Z=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,Y;while((Y=Z.exec($))!==null){if(gY(X,Y.index))continue;let J=Y[1].toLowerCase().split(":")[0];if(PY.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:_}=f$($,W<0?Y.index:W);Q.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 r7($){let X=$.split("/"),Q=[];for(let Z of X){if(Z===""||Z===".")continue;if(Z==="..")Q.pop();else Q.push(Z)}return Q.join("/")}function dY($,X,Q){let Z=X.replace(/\\/g,"/"),Y=Z.indexOf("resources/stores/");if(Y===-1)return;let J=Z.slice(0,Y+16),G=Z.slice(0,Z.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],z;if(U.startsWith("."))z=!r7(`${G}/${U}`).startsWith(r7(J));else z=!0;if(z){let{line:F,column:O}=f$($,K.index),j=_==="export"?"Value re-export":"Value import";Q.push({ruleId:"stx/store-value-imports-must-be-local",message:`${j} 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:F,column:O,severity:"error"})}}}function uY($){let X=$.trim(),Q=(G)=>{let W=G.match(/[A-Za-z_$][\w$]*/g);return W?W:[]},Z=/\bas\s+(.+)$/.exec(X);if(Z){let G=Z[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 Q(K[1]);let _=/^([A-Za-z_$][\w$]*)/.exec(G);return _?[_[1]]:[]}let Y=/^\(([^)]*)\)\s+(?:in|of)\s+/.exec(X);if(Y)return Q(Y[1]);let J=/^([A-Za-z_$][\w$]*)\s+(?:in|of)\s+/.exec(X);return J?[J[1]]:[]}function mY($,X){let Q=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,Z;while((Z=Q.exec($))!==null){let Y=uY(Z[1]);if(Y.length===0)continue;let J=$.lastIndexOf("<",Z.index);if(J===-1)continue;let G=/^<([a-z][\w-]*)/i.exec($.slice(J,J+64));if(!G)continue;let W=$.indexOf(">",Z.index);if(W===-1)continue;let _=$[W-1]==="/"||bY.has(G[1].toLowerCase())?W+1:fY($,G[1],W+1),U=_===-1?W+1:_,z=$.indexOf(Z[1],Z.index),F=$.slice(J,U);if(z>=0&&z+Z[1].length<=U){let O=z-J;F=F.slice(0,O)+" ".repeat(Z[1].length)+F.slice(O+Z[1].length)}for(let O of Y){let j=new RegExp(`(?<![.\\w$])${yY(O)}\\s*\\(`,"g"),L;while((L=j.exec(F))!==null){let H=J+L.index,{line:A,column:q}=f$($,H);X.push({ruleId:"stx/no-signal-call-in-for-iteration-var",message:`"${O}" is a :for iteration variable, not a signal \u2014 calling it as "${O}()" leaves it as a function and silently breaks comparisons. Use "${O}" directly.`,line:A,column:q,severity:"error"})}}}}function pY($,X){let Q=/<!--([\s\S]*?)-->/g,Z;while((Z=Q.exec($))!==null){let J=Z[1].indexOf("`");if(J!==-1){let G=Z.index+4+J,{line:W,column:K}=f$($,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 g$($,X){return $?.[X]!==!1}function cY($,X={}){let Q=[],Z=vY($),Y=(X.filePath??"").replace(/\\/g,"/"),J=X.fileKind??(/\/components?\//i.test(Y)?"component":/\/layouts?\//i.test(Y)?"layout":"view");if(g$(X.rules,"stx/no-bare-function-ref-in-event"))hY($,Z,Q);if(Y&&g$(X.rules,"stx/store-value-imports-must-be-local"))dY($,Y,Q);if(g$(X.rules,"stx/no-signal-call-in-for-iteration-var"))mY($,Q);if(g$(X.rules,"stx/no-backticks-in-html-comments"))pY($,Q);Q.sort((W,K)=>W.line-K.line||W.column-K.column);let G=new Set;return Q.filter((W)=>{let K=`${W.ruleId}:${W.line}:${W.column}`;if(G.has(K))return!1;return G.add(K),!0})}function lY($,X){return $.kind===X}function s7($){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 iY($,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 n7($,X,Q,Z){let Y=Z?`[${Z}]`:"";if(Q.required&&(X===void 0||X===null))return{prop:$,message:`${Y} Missing required prop: "${$}"`,value:X,expected:Q.type?s7(Q.type):void 0};if(X===void 0||X===null)return null;if(Q.type){let J=Array.isArray(Q.type)?Q.type:[Q.type];if(!J.some((W)=>iY(X,W))){let W=J.map((K)=>s7(K)).join(" | ");return{prop:$,message:`${Y} Invalid prop type for "${$}": expected ${W}, got ${typeof X}`,value:X,expected:W}}}if(Q.validator){if(!Q.validator(X))return{prop:$,message:`${Y} Custom validation failed for prop "${$}"`,value:X}}return null}function aY($){let X=globalThis.__STX_CURRENT_PROPS__||{};if(!$)return X;let Q={...X};for(let[Z,Y]of Object.entries($)){let J=typeof Y==="function"||Array.isArray(Y)?{type:Y}:Y||{};if(Q[Z]===void 0&&J.default!==void 0)Q[Z]=typeof J.default==="function"?J.default():J.default}return Q}function rY($,X={}){let{componentName:Q,throwOnError:Z=!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 z=n7(K,G[K],U,Q);if(z){if(W.valid=!1,W.errors.push(z),Y)console.warn(z.message)}}for(let K of Object.keys(J))if(!(K in $)){let _=`${Q?`[${Q}]`:""} Unknown prop: "${K}"`;if(W.warnings.push(_),Y)console.warn(_)}if(Z&&!W.valid){let K=W.errors.map((_)=>_.message).join(`
4469
+ ${Y.slice(W)}`;return`${$.slice(0,Z)}${z}${$.slice(Q)}`}function bY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function r7($){return $}var yY=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),vY=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function gY($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fY($){let X=[],Q=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,Z;while((Z=Q.exec($))!==null)X.push([Z.index,Z.index+Z[0].length]);return X}function hY($,X){for(let[Q,Z]of $)if(X>=Q&&X<Z)return!0;return!1}function d$($,X){let Q=1,Z=0;for(let Y=0;Y<X&&Y<$.length;Y++)if($[Y]===`
4470
+ `)Q++,Z=Y+1;return{line:Q,column:X-Z+1}}function dY($,X,Q){let Z=X.toLowerCase(),Y=$.length,J=1,G=Q;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()===Z){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()===Z&&$[_-1]!=="/")J++;G=_+1}return-1}function uY($,X,Q){let Z=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,Y;while((Y=Z.exec($))!==null){if(hY(X,Y.index))continue;let J=Y[1].toLowerCase().split(":")[0];if(yY.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:_}=d$($,W<0?Y.index:W);Q.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 s7($){let X=$.split("/"),Q=[];for(let Z of X){if(Z===""||Z===".")continue;if(Z==="..")Q.pop();else Q.push(Z)}return Q.join("/")}function mY($,X,Q){let Z=X.replace(/\\/g,"/"),Y=Z.indexOf("resources/stores/");if(Y===-1)return;let J=Z.slice(0,Y+16),G=Z.slice(0,Z.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],z;if(U.startsWith("."))z=!s7(`${G}/${U}`).startsWith(s7(J));else z=!0;if(z){let{line:F,column:j}=d$($,K.index),O=_==="export"?"Value re-export":"Value import";Q.push({ruleId:"stx/store-value-imports-must-be-local",message:`${O} 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:F,column:j,severity:"error"})}}}function pY($){let X=$.trim(),Q=(G)=>{let W=G.match(/[A-Za-z_$][\w$]*/g);return W?W:[]},Z=/\bas\s+(.+)$/.exec(X);if(Z){let G=Z[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 Q(K[1]);let _=/^([A-Za-z_$][\w$]*)/.exec(G);return _?[_[1]]:[]}let Y=/^\(([^)]*)\)\s+(?:in|of)\s+/.exec(X);if(Y)return Q(Y[1]);let J=/^([A-Za-z_$][\w$]*)\s+(?:in|of)\s+/.exec(X);return J?[J[1]]:[]}function cY($,X){let Q=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,Z;while((Z=Q.exec($))!==null){let Y=pY(Z[1]);if(Y.length===0)continue;let J=$.lastIndexOf("<",Z.index);if(J===-1)continue;let G=/^<([a-z][\w-]*)/i.exec($.slice(J,J+64));if(!G)continue;let W=$.indexOf(">",Z.index);if(W===-1)continue;let _=$[W-1]==="/"||vY.has(G[1].toLowerCase())?W+1:dY($,G[1],W+1),U=_===-1?W+1:_,z=$.indexOf(Z[1],Z.index),F=$.slice(J,U);if(z>=0&&z+Z[1].length<=U){let j=z-J;F=F.slice(0,j)+" ".repeat(Z[1].length)+F.slice(j+Z[1].length)}for(let j of Y){let O=new RegExp(`(?<![.\\w$])${gY(j)}\\s*\\(`,"g"),L;while((L=O.exec(F))!==null){let H=J+L.index,{line:q,column:A}=d$($,H);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:q,column:A,severity:"error"})}}}}function lY($,X){let Q=/<!--([\s\S]*?)-->/g,Z;while((Z=Q.exec($))!==null){let J=Z[1].indexOf("`");if(J!==-1){let G=Z.index+4+J,{line:W,column:K}=d$($,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 h$($,X){return $?.[X]!==!1}function iY($,X={}){let Q=[],Z=fY($),Y=(X.filePath??"").replace(/\\/g,"/"),J=X.fileKind??(/\/components?\//i.test(Y)?"component":/\/layouts?\//i.test(Y)?"layout":"view");if(h$(X.rules,"stx/no-bare-function-ref-in-event"))uY($,Z,Q);if(Y&&h$(X.rules,"stx/store-value-imports-must-be-local"))mY($,Y,Q);if(h$(X.rules,"stx/no-signal-call-in-for-iteration-var"))cY($,Q);if(h$(X.rules,"stx/no-backticks-in-html-comments"))lY($,Q);Q.sort((W,K)=>W.line-K.line||W.column-K.column);let G=new Set;return Q.filter((W)=>{let K=`${W.ruleId}:${W.line}:${W.column}`;if(G.has(K))return!1;return G.add(K),!0})}function aY($,X){return $.kind===X}function n7($){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 rY($,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 o7($,X,Q,Z){let Y=Z?`[${Z}]`:"";if(Q.required&&(X===void 0||X===null))return{prop:$,message:`${Y} Missing required prop: "${$}"`,value:X,expected:Q.type?n7(Q.type):void 0};if(X===void 0||X===null)return null;if(Q.type){let J=Array.isArray(Q.type)?Q.type:[Q.type];if(!J.some((W)=>rY(X,W))){let W=J.map((K)=>n7(K)).join(" | ");return{prop:$,message:`${Y} Invalid prop type for "${$}": expected ${W}, got ${typeof X}`,value:X,expected:W}}}if(Q.validator){if(!Q.validator(X))return{prop:$,message:`${Y} Custom validation failed for prop "${$}"`,value:X}}return null}function sY($){let X=globalThis.__STX_CURRENT_PROPS__||{};if(!$)return X;let Q={...X};for(let[Z,Y]of Object.entries($)){let J=typeof Y==="function"||Array.isArray(Y)?{type:Y}:Y||{};if(Q[Z]===void 0&&J.default!==void 0)Q[Z]=typeof J.default==="function"?J.default():J.default}return Q}function nY($,X={}){let{componentName:Q,throwOnError:Z=!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 z=o7(K,G[K],U,Q);if(z){if(W.valid=!1,W.errors.push(z),Y)console.warn(z.message)}}for(let K of Object.keys(J))if(!(K in $)){let _=`${Q?`[${Q}]`:""} Unknown prop: "${K}"`;if(W.warnings.push(_),Y)console.warn(_)}if(Z&&!W.valid){let K=W.errors.map((_)=>_.message).join(`
4469
4471
  `);throw Error(`Prop validation failed:
4470
- ${K}`)}return{props:G,validation:W}}function sY($,X){let Q={...$};for(let[Z,Y]of Object.entries(X))if(Q[Z]===void 0)Q[Z]=typeof Y==="function"?Y():Y;return Q}function nY($){return $}function oY($){return{type:$,required:!0}}function tY($,X){return{type:X,default:$}}function eY($,X={}){return{...X,validator:$}}function $J($,X={}){return{...X,validator:(Q)=>$.includes(Q)}}function XJ($,X={}){return{...X,type:Array,validator:(Q)=>{if(!Array.isArray(Q))return!1;return!0}}}function QJ($,X={}){return{...X,type:Object}}function ZJ($,X,Q){if(!X)return $;let Z={};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;{let K=n7(Y,W,G,Q);if(K)console.warn(K.message)}Z[Y]=W}for(let[Y,J]of Object.entries($))if(!(Y in Z))Z[Y]=J;return Z}var _B={};
4471
- export{JK as o,i$ as p,U6 as q,F4 as r,D0 as s,t1 as t,e1 as u,$$ as v,X$ as w,A1 as x,t7 as y,e7 as z,$3 as A,X3 as B,Q3 as C,Z3 as D,WJ as E,KJ as F,_J as G,Y3 as H,UJ as I,J3 as J,BJ as K,LJ as L,FJ as M,zJ as N,jJ as O,OJ as P,HJ as Q,AJ as R,qJ as S,NJ as T,s0 as U,MJ as V,VJ as W,EJ as X,IJ as Y,DJ as Z,wJ as _,W3 as $,K3 as aa,TJ as ba,_3 as ca,CJ as da,xJ as ea,kJ as fa,SJ as ga,PJ as ha,bJ as ia,U3 as ja,B3 as ka,yJ as la,vJ as ma,L3 as na,fJ as oa,mJ as pa,pJ as qa,e5 as ra,q3 as sa,N3 as ta,M3 as ua,V3 as va,m$ as wa,E3 as xa,I3 as ya,R3 as za,D3 as Aa,lJ as Ba,nJ as Ca,oJ as Da,C3 as Ea,tJ as Fa,QG as Ga,M4 as Ha,bW as Ia,E4 as Ja,I4 as Ka,y4 as La,v4 as Ma,g4 as Na,p6 as Oa,f4 as Pa,h4 as Qa,d4 as Ra,u4 as Sa,m4 as Ta,p4 as Ua,c4 as Va,uW as Wa,I1 as Xa,lW as Ya,iW as Za,l4 as _a,i4 as $a,s4 as ab,F$ as bb,aW as cb,rW as db,sW as eb,nW as fb,oW as gb,tW as hb,eW as ib,$2 as jb,X2 as kb,Q2 as lb,Z2 as mb,Y2 as nb,XX as ob,G2 as pb,U2 as qb,B2 as rb,_5 as sb,A2 as tb,q2 as ub,N2 as vb,V2 as wb,T2 as xb,C2 as yb,x2 as zb,k2 as Ab,S2 as Bb,P2 as Cb,c2 as Db,$Q as Eb,l2 as Fb,XQ as Gb,QQ as Hb,G8 as Ib,W8 as Jb,r2 as Kb,s2 as Lb,n2 as Mb,t2 as Nb,e2 as Ob,_Q as Pb,XK as Qb,QK as Rb,ZK as Sb,z6 as Tb,U8 as Ub,WK as Vb,KK as Wb,_K as Xb,UK as Yb,UQ as Zb,BQ as _b,LK as $b,LQ as ac,L8 as bc,FK as cc,FQ as dc,zK as ec,jK as fc,zQ as gc,IK as hc,j8 as ic,OQ as jc,HQ as kc,O8 as lc,qQ as mc,NQ as nc,VQ as oc,h as pc,H8 as qc,H5 as rc,A8 as sc,q8 as tc,N8 as uc,M8 as vc,V8 as wc,E8 as xc,I8 as yc,R8 as zc,D8 as Ac,w8 as Bc,T8 as Cc,C8 as Dc,x8 as Ec,k8 as Fc,S8 as Gc,P8 as Hc,b8 as Ic,y8 as Jc,v8 as Kc,g8 as Lc,A5 as Mc,f8 as Nc,h8 as Oc,d8 as Pc,u8 as Qc,m8 as Rc,c8 as Sc,q5 as Tc,N5 as Uc,l8 as Vc,M5 as Wc,V5 as Xc,E5 as Yc,b1 as Zc,j$ as _c,i8 as $c,a8 as ad,r8 as bd,O$ as cd,n8 as dd,o8 as ed,t8 as fd,e8 as gd,LZ as hd,FZ as id,I5 as jd,R5 as kd,Y7 as ld,v0 as md,J7 as nd,G7 as od,W7 as pd,K7 as qd,_7 as rd,H$ as sd,D5 as td,B7 as ud,A$ as vd,L7 as wd,F7 as xd,z7 as yd,j7 as zd,q$ as Ad,N$ as Bd,w5 as Cd,T5 as Dd,H7 as Ed,A7 as Fd,q7 as Gd,M$ as Hd,N7 as Id,MZ as Jd,m_ as Kd,M7 as Ld,VZ as Md,Y9 as Nd,J9 as Od,W9 as Pd,TZ as Qd,CZ as Rd,C5 as Sd,xZ as Td,kZ as Ud,SZ as Vd,PZ as Wd,bZ as Xd,yZ as Yd,vZ as Zd,gZ as _d,fZ as $d,hZ as ae,_1 as be,U1 as ce,mZ as de,pZ as ee,K1 as fe,lZ as ge,y1 as he,aZ as ie,rZ as je,sZ as ke,nZ as le,w7 as me,oZ as ne,tZ as oe,C7 as pe,$Y as qe,XY as re,D$ as se,w$ as te,T$ as ue,C$ as ve,x$ as we,b5 as xe,k$ as ye,h0 as ze,h7 as Ae,S$ as Be,P$ as Ce,i7 as De,a7 as Ee,cY as Fe,lY as Ge,aY as He,rY as Ie,sY as Je,nY as Ke,oY as Le,tY as Me,eY as Ne,$J as Oe,XJ as Pe,QJ as Qe,ZJ as Re,_B as Se,j4 as Te,q6 as Ue,H4 as Ve,q4 as We};
4472
+ ${K}`)}return{props:G,validation:W}}function oY($,X){let Q={...$};for(let[Z,Y]of Object.entries(X))if(Q[Z]===void 0)Q[Z]=typeof Y==="function"?Y():Y;return Q}function tY($){return $}function eY($){return{type:$,required:!0}}function $J($,X){return{type:X,default:$}}function XJ($,X={}){return{...X,validator:$}}function QJ($,X={}){return{...X,validator:(Q)=>$.includes(Q)}}function ZJ($,X={}){return{...X,type:Array,validator:(Q)=>{if(!Array.isArray(Q))return!1;return!0}}}function YJ($,X={}){return{...X,type:Object}}function JJ($,X,Q){if(!X)return $;let Z={};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;{let K=o7(Y,W,G,Q);if(K)console.warn(K.message)}Z[Y]=W}for(let[Y,J]of Object.entries($))if(!(Y in Z))Z[Y]=J;return Z}var BB={};
4473
+ export{WK as o,r$ as p,B6 as q,z4 as r,D0 as s,t1 as t,e1 as u,$$ as v,X$ as w,A1 as x,e7 as y,$3 as z,X3 as A,Q3 as B,Z3 as C,Y3 as D,_J as E,UJ as F,BJ as G,J3 as H,LJ as I,G3 as J,FJ as K,zJ as L,jJ as M,OJ as N,HJ as O,AJ as P,qJ as Q,NJ as R,MJ as S,VJ as T,n0 as U,EJ as V,IJ as W,RJ as X,DJ as Y,TJ as Z,CJ as _,K3 as $,_3 as aa,kJ as ba,U3 as ca,xJ as da,SJ as ea,PJ as fa,bJ as ga,yJ as ha,vJ as ia,B3 as ja,L3 as ka,gJ as la,fJ as ma,F3 as na,dJ as oa,cJ as pa,lJ as qa,$6 as ra,N3 as sa,M3 as ta,V3 as ua,E3 as va,c$ as wa,I3 as xa,R3 as ya,D3 as za,w3 as Aa,aJ as Ba,tJ as Ca,eJ as Da,k3 as Ea,$G as Fa,YG as Ga,V4 as Ha,vW as Ia,I4 as Ja,R4 as Ka,v4 as La,g4 as Ma,f4 as Na,c6 as Oa,h4 as Pa,d4 as Qa,u4 as Ra,m4 as Sa,p4 as Ta,c4 as Ua,l4 as Va,pW as Wa,I1 as Xa,aW as Ya,rW as Za,i4 as _a,a4 as $a,n4 as ab,F$ as bb,sW as cb,nW as db,oW as eb,tW as fb,eW as gb,$2 as hb,X2 as ib,Q2 as jb,Z2 as kb,Y2 as lb,J2 as mb,G2 as nb,QX as ob,K2 as pb,L2 as qb,F2 as rb,B5 as sb,N2 as tb,M2 as ub,V2 as vb,I2 as wb,k2 as xb,x2 as yb,S2 as zb,P2 as Ab,b2 as Bb,y2 as Cb,i2 as Db,XQ as Eb,a2 as Fb,QQ as Gb,ZQ as Hb,W8 as Ib,K8 as Jb,n2 as Kb,o2 as Lb,t2 as Mb,$K as Nb,XK as Ob,UQ as Pb,ZK as Qb,YK as Rb,JK as Sb,j6 as Tb,B8 as Ub,_K as Vb,UK as Wb,BK as Xb,LK as Yb,BQ as Zb,LQ as _b,zK as $b,FQ as ac,F8 as bc,jK as cc,zQ as dc,OK as ec,HK as fc,jQ as gc,DK as hc,O8 as ic,AQ as jc,qQ as kc,H8 as lc,MQ as mc,VQ as nc,IQ as oc,h as pc,A8 as qc,q5 as rc,q8 as sc,N8 as tc,M8 as uc,V8 as vc,E8 as wc,I8 as xc,R8 as yc,D8 as zc,w8 as Ac,T8 as Bc,C8 as Cc,k8 as Dc,x8 as Ec,S8 as Fc,P8 as Gc,b8 as Hc,y8 as Ic,v8 as Jc,g8 as Kc,f8 as Lc,N5 as Mc,h8 as Nc,d8 as Oc,u8 as Pc,m8 as Qc,p8 as Rc,l8 as Sc,M5 as Tc,V5 as Uc,i8 as Vc,E5 as Wc,I5 as Xc,R5 as Yc,b1 as Zc,j$ as _c,a8 as $c,r8 as ad,s8 as bd,O$ as cd,o8 as dd,t8 as ed,e8 as fd,$7 as gd,zZ as hd,jZ as id,D5 as jd,w5 as kd,J7 as ld,v0 as md,G7 as nd,W7 as od,K7 as pd,_7 as qd,U7 as rd,H$ as sd,T5 as td,L7 as ud,A$ as vd,F7 as wd,z7 as xd,j7 as yd,O7 as zd,q$ as Ad,N$ as Bd,C5 as Cd,k5 as Dd,A7 as Ed,q7 as Fd,N7 as Gd,M$ as Hd,M7 as Id,EZ as Jd,c_ as Kd,V7 as Ld,IZ as Md,G9 as Nd,W9 as Od,_9 as Pd,kZ as Qd,xZ as Rd,x5 as Sd,SZ as Td,PZ as Ud,bZ as Vd,yZ as Wd,vZ as Xd,gZ as Yd,fZ as Zd,hZ as _d,dZ as $d,uZ as ae,U1 as be,B1 as ce,cZ as de,lZ as ee,_1 as fe,aZ as ge,y1 as he,sZ as ie,nZ as je,oZ as ke,tZ as le,T7 as me,eZ as ne,$Y as oe,k7 as pe,QY as qe,ZY as re,D$ as se,w$ as te,T$ as ue,C$ as ve,x$ as we,y5 as xe,S$ as ye,h0 as ze,d7 as Ae,P$ as Be,b$ as Ce,y$ as De,a7 as Ee,r7 as Fe,iY as Ge,aY as He,sY as Ie,nY as Je,oY as Ke,tY as Le,eY as Me,$J as Ne,XJ as Oe,QJ as Pe,ZJ as Qe,YJ as Re,JJ as Se,BB as Te,O4 as Ue,N6 as Ve,A4 as We,N4 as Xe};