@stacksjs/stx 0.2.198 → 0.2.200

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 (52) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-1yk07x7b.js → chunk-0kp3c02b.js} +1 -1
  3. package/dist/{chunk-338316c2.js → chunk-1ms6ey5t.js} +1 -1
  4. package/dist/{chunk-12nvcvtn.js → chunk-237jkeca.js} +1 -1
  5. package/dist/{chunk-14ynv5ah.js → chunk-241d3ex6.js} +1 -1
  6. package/dist/{chunk-5v64c8tr.js → chunk-2f80w68h.js} +1 -1
  7. package/dist/{chunk-tywvd1zc.js → chunk-31xczh3c.js} +1 -1
  8. package/dist/{chunk-g19skgmw.js → chunk-3jfg5kdy.js} +2 -2
  9. package/dist/{chunk-yab6d6kb.js → chunk-4v5fsrdd.js} +1 -1
  10. package/dist/{chunk-q020t182.js → chunk-6v4ddvfk.js} +1 -1
  11. package/dist/{chunk-r6p4ws0a.js → chunk-6wx32fa5.js} +17 -17
  12. package/dist/{chunk-6msvxnbr.js → chunk-79m0qkj6.js} +1 -1
  13. package/dist/{chunk-0w0mrtme.js → chunk-8a1524ge.js} +1 -1
  14. package/dist/{chunk-rdf7d42n.js → chunk-8gf8p3hq.js} +1 -1
  15. package/dist/{chunk-v3ryxw4v.js → chunk-a438xffx.js} +1 -1
  16. package/dist/{chunk-avwj12at.js → chunk-a4mcc2dm.js} +1 -1
  17. package/dist/{chunk-p5kp35dy.js → chunk-ajr4qgbe.js} +1 -1
  18. package/dist/{chunk-1thssz8x.js → chunk-b5nws5vh.js} +1 -1
  19. package/dist/{chunk-4a4h28pp.js → chunk-cd8qdf35.js} +1 -1
  20. package/dist/{chunk-3m49eb4v.js → chunk-ebrcakdt.js} +1 -1
  21. package/dist/{chunk-s018d32j.js → chunk-eqq7k4g0.js} +1 -1
  22. package/dist/{chunk-vj320kyr.js → chunk-fk5a0t90.js} +1 -1
  23. package/dist/{chunk-yv340gxj.js → chunk-gfgpf7h8.js} +1 -1
  24. package/dist/{chunk-2zkj69dg.js → chunk-haawrsc8.js} +1 -1
  25. package/dist/{chunk-y35rktea.js → chunk-hdtca0hs.js} +1 -1
  26. package/dist/{chunk-5anpcnde.js → chunk-hryeb88f.js} +1 -1
  27. package/dist/{chunk-fd77g6t6.js → chunk-hx338p3h.js} +1 -1
  28. package/dist/{chunk-z5cm0bwn.js → chunk-jn49sc7r.js} +1 -1
  29. package/dist/{chunk-bpa2jeyw.js → chunk-m1awve2j.js} +1 -1
  30. package/dist/{chunk-hyyzp99b.js → chunk-macr4195.js} +1 -1
  31. package/dist/{chunk-r4qnvxhv.js → chunk-mvb60bhh.js} +1 -1
  32. package/dist/{chunk-5xd7vge2.js → chunk-n4v5733m.js} +1 -1
  33. package/dist/{chunk-ede7zpjf.js → chunk-ncgvbje8.js} +1 -1
  34. package/dist/{chunk-q4gp9egt.js → chunk-pa6gyr8e.js} +1 -1
  35. package/dist/{chunk-5mkkre22.js → chunk-q02jg1pk.js} +1 -1
  36. package/dist/{chunk-937effkz.js → chunk-qw5gmsv7.js} +1 -1
  37. package/dist/{chunk-dxfcyj8t.js → chunk-seac724e.js} +1 -1
  38. package/dist/{chunk-7kger0se.js → chunk-tke3ff0z.js} +2 -2
  39. package/dist/{chunk-yr2wc2pa.js → chunk-v9yzmqsh.js} +1 -1
  40. package/dist/{chunk-zqbw8zqq.js → chunk-vx8cht59.js} +1 -1
  41. package/dist/{chunk-118a77bs.js → chunk-wjqswn35.js} +147 -147
  42. package/dist/{chunk-w29sv5jf.js → chunk-wzytd8fh.js} +1 -1
  43. package/dist/{chunk-7s0wfa4e.js → chunk-xgejppzh.js} +1 -1
  44. package/dist/cli.js +8 -8
  45. package/dist/craft-entry.js +1 -1
  46. package/dist/craft.js +1 -1
  47. package/dist/inline-assets.js +1 -1
  48. package/dist/pwa.js +1 -1
  49. package/dist/serve.d.ts +1 -0
  50. package/dist/serve.js +8 -5
  51. package/dist/ssg.js +2 -2
  52. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{if as Z$,jf as $5}from"./chunk-yr2wc2pa.js";import{Kg as R7,Lg as I6,Mg as s$,Ng as Y$,Og as J$,Pg as D6,Qg as w6}from"./chunk-s018d32j.js";import{Ri as t1,Si as e1}from"./chunk-bpa2jeyw.js";import{Aj as y1,Bj as L1,Cj as F1,Dj as b$,Ej as y$,Fj as b5,Hj as y5}from"./chunk-3es366z4.js";import{sk as x5,tk as k5}from"./chunk-ycn1vnv2.js";import{Ak as y7,zk as b7}from"./chunk-yckd6ks5.js";import{cl as $1}from"./chunk-zgvga8rc.js";import{Aq as A1,Bm as M6,Dp as V6,Eo as o1,Ep as E6,Eq as p0,Ir as O$,Jm as f1,Kr as z1,Lr as A0,Mm as Z6,Mo as B0,Pr as q0,Ul as E7,Um as p$,Uo as m0,Vp as r$,Wl as i5,Wm as c$,Xp as R6,Yp as J6,Zm as h1,bn as l$,en as n1,fn as Y6,jm as u0,lq as L0,tm as m$,vr as $$,wp as D7,zq as a5}from"./chunk-r6p4ws0a.js";import{Bs as X$,Cs as Q$,Gs as s,ts as B}from"./chunk-tywvd1zc.js";import{Ls as S0}from"./chunk-cbc56wpd.js";import{Ot as z6,Pt as j6,Qt as O6,Rt as H6,St as A6,Tt as q6,Vt as N6,Zt as _6,tt as a$,ut as K6,yt as L6,zt as F6}from"./chunk-3952ykhb.js";import{hu as i}from"./chunk-pw0rzgpv.js";var v5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function p7($,X,Q={}){let{storage:Z="local",serializer:Y=v5,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 g5($,X,Q,Z,Y={}){let{serializer:J=v5,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=b5((()=>{let O=_();if(!O)return Z;try{return U(O.getItem(Q))}catch(j){return console.warn(`[${X}] Cannot read "${Q}":`,j),Z}})());if(y5(()=>{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 c7($,X,Q){return g5("local","useLocalStorage",$,X,Q)}function l7($,X,Q){return g5("session","useSessionStorage",$,X,Q)}function i7($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function a7($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function r7($="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 b1($,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(!b1($[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)||!b1(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(!b1($[J],X[J],Q))return!1}return!0}function tY($){l=$}function eY(){return l}function $J(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:s7()}}function s7(){return{refs:new Map,effects:new Set,cleanups:[]}}function XJ($){let X=new Set,Q=new Set,Z=$,Y=Symbol("ref"),J={get value(){let G=y1();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(b$())y$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(l)l.scope.refs.set(Y,J);return J}var f5=new WeakMap;function n7($){let X=f5.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(b$())y$(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=y1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let z=Object.getPrototypeOf(_);if(z===Object.prototype||z===null)return n7(_)}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 f5.set($,J),J}function QJ($){let X,Q=!0,Z=new Set,Y=new Set,J=()=>{Q=!0,G()},G=()=>{if(Q){let K=X,_=L1(J);if(X=$(),F1(_),Q=!1,!Object.is(X,K)){for(let U of Z)U(X,K);for(let U of Y)U()}}},W=L1(J);return X=$(),Q=!1,F1(W),{get value(){let K=y1();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 o7($){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 j=O();if((Y?!b1(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 o7(j)},z=!1,F=()=>{if(K||z)return;z=!0,U(()=>{z=!1,_()})},O=()=>{if(typeof $==="function"){let j=L1(F);try{return $()}finally{F1(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 YJ($,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 JJ($){let X,Q=!1,Z=()=>{if(Q)return;if(X)X();let Y=L1(Z);X=$(),F1(Y)};if(Z(),l)l.scope.cleanups.push(()=>{if(Q=!0,X)X()});return()=>{if(Q=!0,X)X()}}function GJ($){if(l)l.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function WJ($){if(l)l.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function KJ($){if(l)l.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function _J($){if(l)l.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function UJ($){if(l)l.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function BJ($){if(l)l.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function r0($,X){let Q=$.hooks[X];for(let Z of Q)await Z()}async function LJ($){await r0($,"beforeMount"),$.isMounted=!0,await r0($,"mounted")}async function FJ($){if(!$.isMounted||$.isUnmounted)return;await r0($,"beforeUpdate"),await r0($,"updated")}async function zJ($){if($.isUnmounted)return;await r0($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await r0($,"unmounted")}function jJ(){return`
2
+ import{if as Z$,jf as $5}from"./chunk-v9yzmqsh.js";import{Kg as I7,Lg as I6,Mg as s$,Ng as Y$,Og as J$,Pg as D6,Qg as w6}from"./chunk-eqq7k4g0.js";import{Ri as t1,Si as e1}from"./chunk-m1awve2j.js";import{Aj as y1,Bj as L1,Cj as F1,Dj as b$,Ej as y$,Fj as b5,Hj as y5}from"./chunk-3es366z4.js";import{sk as x5,tk as k5}from"./chunk-ycn1vnv2.js";import{Ak as v7,zk as y7}from"./chunk-yckd6ks5.js";import{cl as $1}from"./chunk-zgvga8rc.js";import{Aq as A1,Bm as M6,Dp as V6,Eo as o1,Ep as E6,Eq as p0,Ir as H$,Jm as f1,Kr as z1,Lr as A0,Mm as Z6,Mo as B0,Pr as q0,Ul as R7,Um as p$,Uo as m0,Vp as r$,Wl as i5,Wm as c$,Xp as R6,Yp as J6,Zm as h1,bn as l$,en as n1,fn as Y6,jm as u0,lq as L0,tm as m$,vr as $$,wp as w7,zq as a5}from"./chunk-6wx32fa5.js";import{Bs as X$,Cs as Q$,Gs as s,ts as B}from"./chunk-31xczh3c.js";import{Ls as S0}from"./chunk-cbc56wpd.js";import{Ot as z6,Pt as j6,Qt as H6,Rt as O6,St as A6,Tt as q6,Vt as N6,Zt as _6,tt as a$,ut as K6,yt as L6,zt as F6}from"./chunk-3952ykhb.js";import{hu as c}from"./chunk-pw0rzgpv.js";var v5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function c7($,X,Q={}){let{storage:Z="local",serializer:Y=v5,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 O=L.getItem($);if(O===null)return X;let A=Y.read(O);if(J&&typeof X==="object"&&X!==null)return{...X,...A};return A}catch{return X}},z=(L)=>{let O=_();if(!O)return;try{if(L===null||L===void 0)O.removeItem($);else O.setItem($,Y.write(L))}catch(A){console.warn(`[useStorage] Failed to write key "${$}":`,A)}},F=U(),H=(L,O)=>{for(let A of W)try{A(L,O)}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}H(F,q)}};window.addEventListener("storage",L);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",L))}let j={get value(){return F},set value(L){let O=F;F=L,z(L),H(L,O)},get:()=>F,set:(L)=>{j.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let O=F;F=X,H(X,O)}},subscribe:(L)=>{return W.add(L),L(F,void 0),()=>W.delete(L)}};return j}function g5($,X,Q,Z,Y={}){let{serializer:J=v5,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(H)=>{if(H===null||H===void 0)return Z;try{let j=J.read(H);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=b5((()=>{let H=_();if(!H)return Z;try{return U(H.getItem(Q))}catch(j){return console.warn(`[${X}] Cannot read "${Q}":`,j),Z}})());if(y5(()=>{let H=F(),j=_();if(!j)return;try{if(H===null||H===void 0)j.removeItem(Q);else j.setItem(Q,J.write(H))}catch(L){console.warn(`[${X}] Cannot persist "${Q}":`,L)}}),K&&W){let H=(L)=>{if(L.key!==Q)return;if(L.storageArea&&L.storageArea!==_())return;F.set(U(L.newValue))};window.addEventListener("storage",H);let j=globalThis.onDestroy;if(typeof j==="function")j(()=>window.removeEventListener("storage",H))}return F}function l7($,X,Q){return g5("local","useLocalStorage",$,X,Q)}function i7($,X,Q){return g5("session","useSessionStorage",$,X,Q)}function a7($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function r7($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function s7($="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 i=null;function b1($,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(!b1($[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)||!b1(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(!b1($[J],X[J],Q))return!1}return!0}function eY($){i=$}function $J(){return i}function XJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:n7()}}function n7(){return{refs:new Map,effects:new Set,cleanups:[]}}function QJ($){let X=new Set,Q=new Set,Z=$,Y=Symbol("ref"),J={get value(){let G=y1();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(b$())y$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(i)i.scope.refs.set(Y,J);return J}var f5=new WeakMap;function o7($){let X=f5.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(b$())y$(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=y1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let z=Object.getPrototypeOf(_);if(z===Object.prototype||z===null)return o7(_)}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 f5.set($,J),J}function ZJ($){let X,Q=!0,Z=new Set,Y=new Set,J=()=>{Q=!0,G()},G=()=>{if(Q){let K=X,_=L1(J);if(X=$(),F1(_),Q=!1,!Object.is(X,K)){for(let U of Z)U(X,K);for(let U of Y)U()}}},W=L1(J);return X=$(),Q=!1,F1(W),{get value(){let K=y1();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 t7($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function YJ($,X,Q={}){let{immediate:Z=!1,deep:Y=!1,flush:J="post"}=Q,G,W,K=!1,_=()=>{if(K)return;let j=H();if((Y?!b1(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 t7(j)},z=!1,F=()=>{if(K||z)return;z=!0,U(()=>{z=!1,_()})},H=()=>{if(typeof $==="function"){let j=L1(F);try{return $()}finally{F1(j)}}return $.value};if(typeof $!=="function"){let j=$.subscribe(()=>{U(_)});W=()=>{K=!0,j()}}else W=()=>{K=!0};if(G=H(),Z)U(_);if(i)i.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 GJ($){let X,Q=!1,Z=()=>{if(Q)return;if(X)X();let Y=L1(Z);X=$(),F1(Y)};if(Z(),i)i.scope.cleanups.push(()=>{if(Q=!0,X)X()});return()=>{if(Q=!0,X)X()}}function WJ($){if(i)i.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function KJ($){if(i)i.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function _J($){if(i)i.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function UJ($){if(i)i.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function BJ($){if(i)i.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function LJ($){if(i)i.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function r0($,X){let Q=$.hooks[X];for(let Z of Q)await Z()}async function FJ($){await r0($,"beforeMount"),$.isMounted=!0,await r0($,"mounted")}async function zJ($){if(!$.isMounted||$.isUnmounted)return;await r0($,"beforeUpdate"),await r0($,"updated")}async function jJ($){if($.isUnmounted)return;await r0($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await r0($,"unmounted")}function HJ(){return`
3
3
  <script data-stx-client-runtime>
4
4
  (function() {
5
5
  'use strict';
@@ -178,11 +178,11 @@ import{if as Z$,jf as $5}from"./chunk-yr2wc2pa.js";import{Kg as R7,Lg as I6,Mg a
178
178
  });
179
179
  window.provide = provide;
180
180
  })();
181
- </script>`}function v$($){for(let X of $.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let Q=X[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!Q)continue;let Z=Number(Q[1]);if(Number.isInteger(Z)&&Z>=100&&Z<=599)return Z}return}function s0($,X){if(typeof window>"u")return X;return window[$]??X}function v1($,X){if(typeof window>"u")return;window[$]=X}function h5($){let Q=s0("__STX_STORES__",{})[$];if(!Q)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Q}function AJ($){return h5($)}function qJ($,X=5000){return new Promise((Q,Z)=>{let Y=Date.now(),J=()=>{let G=h5($);if(G)Q(G);else if(Date.now()-Y>X)Z(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(J)};J()})}function t7(){return s0("__STX_ROUTE_PARAMS__",{})}function e7($){return t7()[$]}function NJ($){let X=e7($);if(X===void 0)throw Error(`Route parameter "${$}" not found`);return X}function $3(){return s0("__STX_MIDDLEWARE_STATE__",{})}function MJ($){return $3()[$]}function VJ(){if(typeof window>"u")return;if(!s0("__STX_STORES__",null))v1("__STX_STORES__",{})}function EJ($,X){let Q=s0("__STX_STORES__",{});Q[$]=X,v1("__STX_STORES__",Q)}function RJ(){return s0("__STX_STORE_STATE__",null)}function IJ($){v1("__STX_ROUTE_PARAMS__",$)}function DJ($){v1("__STX_MIDDLEWARE_STATE__",$)}function X3(){return typeof window>"u"}function Q3(){return typeof window<"u"}function wJ($){if(Q3())$()}function TJ($){if(X3())$()}async function Z3($){try{let X=await Bun.file($).text(),Q=Y3(X),Z=J3(X,$),Y=G3(X,Q),J=W3(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 Y3($){let X=$.split(`
181
+ </script>`}function v$($){for(let X of $.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let Q=X[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!Q)continue;let Z=Number(Q[1]);if(Number.isInteger(Z)&&Z>=100&&Z<=599)return Z}return}function s0($,X){if(typeof window>"u")return X;return window[$]??X}function v1($,X){if(typeof window>"u")return;window[$]=X}function h5($){let Q=s0("__STX_STORES__",{})[$];if(!Q)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Q}function qJ($){return h5($)}function NJ($,X=5000){return new Promise((Q,Z)=>{let Y=Date.now(),J=()=>{let G=h5($);if(G)Q(G);else if(Date.now()-Y>X)Z(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(J)};J()})}function e7(){return s0("__STX_ROUTE_PARAMS__",{})}function $3($){return e7()[$]}function MJ($){let X=$3($);if(X===void 0)throw Error(`Route parameter "${$}" not found`);return X}function X3(){return s0("__STX_MIDDLEWARE_STATE__",{})}function VJ($){return X3()[$]}function EJ(){if(typeof window>"u")return;if(!s0("__STX_STORES__",null))v1("__STX_STORES__",{})}function RJ($,X){let Q=s0("__STX_STORES__",{});Q[$]=X,v1("__STX_STORES__",Q)}function IJ(){return s0("__STX_STORE_STATE__",null)}function DJ($){v1("__STX_ROUTE_PARAMS__",$)}function wJ($){v1("__STX_MIDDLEWARE_STATE__",$)}function Q3(){return typeof window>"u"}function Z3(){return typeof window<"u"}function TJ($){if(Z3())$()}function CJ($){if(Q3())$()}async function Y3($){try{let X=await Bun.file($).text(),Q=J3(X),Z=G3(X,$),Y=W3(X,Q),J=K3(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 J3($){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 J3($,X){let Q=[],Z=d5($,"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=d5($,"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 G3($,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 W3($,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 d5($,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 xJ($=["**/*.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 Z3(J);Q.push(G)}catch(G){console.warn(`Failed to analyze ${J}:`,G)}let Y=K3(Q);return{results:Q,summary:Y}}function K3($){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 g1 from"path";var u5=/<script\b[^>]*\bserver\b/i,_3=/<script\b[^>]*\bclient\b/i;async function bJ($){let X=performance.now(),Q=await z1($),Z=$||Q.root||process.cwd(),Y=[Q.build?.pagesDir||Q.pagesDir||"pages",Q.componentsDir||"components",Q.layoutsDir||"layouts",Q.partialsDir||"partials"].map((W)=>g1.resolve(Z,W)),J=[],G=0;for(let W of Y){let K=await m5(W);for(let _ of K){G++;let U=await Bun.file(_).text();if(u5.test(U))J.push(g1.relative(Z,_))}}return{mode:J.length>0?"ssr":"ssg",serverScriptFiles:J,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-X)}}async function yJ($){let X=await z1($),Q=$||X.root||process.cwd(),Z=g1.resolve(Q,X.componentsDir||"components"),Y=[],J=await m5(Z);for(let G of J){let W=await Bun.file(G).text(),K=u5.test(W),_=_3.test(W)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(W)&&!K;if(K&&_){let U=g1.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 m5($){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 p5={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},c5=["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 l5($){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(c5.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 U3($,X=[]){let Q=l5($),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 c5.filter((Y)=>!Z.has(Y))}function B3($){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${A3(J)} } from './${J}'`);let Y=$.filter((J)=>!J.startsWith("end")).map((J)=>` '${J}': true`).join(`,
183
+ `).length,J={conditionals:($.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:($.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:($.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};J.total=J.conditionals+J.loops+J.includes+J.custom;let G=($.match(/\{\{[\s\S]*?\}\}/g)||[]).length,W=($.match(/\{!![\s\S]*?!!\}/g)||[]).length,K=($.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,_=G+W+K,U=($.match(/<[A-Z][^>]*>/g)||[]).length,z=($.match(/@(?:layout|extends)\(/g)||[]).length,F=0,H=0;for(let O of X)if(/@(?:if|unless|foreach|for|while|section)\b/.test(O)&&!/@end/.test(O)&&!/@else/.test(O))H++,F=Math.max(F,H);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(O))H--;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 G3($,X){let Q=[],Z=d5($,"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=d5($,"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 W3($,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 K3($,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 d5($,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 kJ($=["**/*.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 Y3(J);Q.push(G)}catch(G){console.warn(`Failed to analyze ${J}:`,G)}let Y=_3(Q);return{results:Q,summary:Y}}function _3($){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 g1 from"path";var u5=/<script\b[^>]*\bserver\b/i,U3=/<script\b[^>]*\bclient\b/i;async function yJ($){let X=performance.now(),Q=await z1($),Z=$||Q.root||process.cwd(),Y=[Q.build?.pagesDir||Q.pagesDir||"pages",Q.componentsDir||"components",Q.layoutsDir||"layouts",Q.partialsDir||"partials"].map((W)=>g1.resolve(Z,W)),J=[],G=0;for(let W of Y){let K=await m5(W);for(let _ of K){G++;let U=await Bun.file(_).text();if(u5.test(U))J.push(g1.relative(Z,_))}}return{mode:J.length>0?"ssr":"ssg",serverScriptFiles:J,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-X)}}async function vJ($){let X=await z1($),Q=$||X.root||process.cwd(),Z=g1.resolve(Q,X.componentsDir||"components"),Y=[],J=await m5(Z);for(let G of J){let W=await Bun.file(G).text(),K=u5.test(W),_=U3.test(W)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(W)&&!K;if(K&&_){let U=g1.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 m5($){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 p5={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},c5=["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 l5($){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(c5.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 B3($,X=[]){let Q=l5($),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 c5.filter((Y)=>!Z.has(Y))}function L3($){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${q3(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 L3($,X={}){let Q=[],Z=/@if\(([^)]+)\)[\s\S]*?@endif/g,Y=$.matchAll(Z);for(let _ of Y){let U=_[1].trim();if(g$(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(g$(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 F3($,X={}){let Q=L3($,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 g$($,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=g$(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 z3($,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 j3($){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 O3($){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 H3($,X={}){let Q={...p5,...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=F3(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=z3(Y,Q.constants);if(Y=F.content,K=F.folded,K.length>0)J.push("Constant folding")}if(Q.treeShake){if(W=U3(Y,Q.preserveDirectives),W.length>0)J.push("Tree shaking")}if(Q.stringPooling){let F=O3(Y);if(Y=F.content,_=F.count,_>0)J.push("String pooling")}if(Q.minifyHtml){let F=j3(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 gJ($,X={}){let Q={...p5,...X},Z=new Map,Y=[],J=0,G=0,W=new Set;for(let[z,F]of $){let O=H3(F,Q);Z.set(z,O),J+=O.originalSize,G+=O.optimizedSize,Y.push(...O.warnings.map((L)=>`${z}: ${L}`));let j=l5(F);for(let L of j)W.add(L.name)}let K;if(Q.treeShake)K=B3(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 A3($){return $.charAt(0).toUpperCase()+$.slice(1)}function r5($,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=r5(_,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 mJ($,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=q3(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 pJ($,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 q3($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}var N3={name:"component",handler:async($,X,Q,Z)=>{if(X.length<1)return h1("Component","component directive requires at least the component name",f1.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=i5(U,Q),Object.keys(J).length===0)J=r5(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),h1("Component",`Error parsing component props: ${z}`,f1.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 a5(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 h1("Component",`Error rendering component: ${z}`,f1.COMPONENT_RENDER_ERROR)}},hasEndTag:!1};function cJ(){return[N3]}import{mkdir as M3,readFile as V3,readdir as E3,stat as s5,writeFile as R3}from"fs/promises";import o from"path";var $6=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function I3($){return $.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join("")}function f$($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function D3($){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test($)&&!$.startsWith("xml")&&!/[A-Z]/.test($)}function w3($){if($===!0)return"open";if($==="open"||$==="closed")return $;return!1}async function T3($){let X=[];async function Q(Z){let Y=await E3(Z,{withFileTypes:!0});Y.sort((J,G)=>J.name.localeCompare(G.name));for(let J of Y){let G=o.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 C3($,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 x3($,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,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 k3($){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 n5($){return[...$.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((X)=>X[1].trim()).filter(Boolean).join(`
198
+ `}function F3($,X={}){let Q=[],Z=/@if\(([^)]+)\)[\s\S]*?@endif/g,Y=$.matchAll(Z);for(let _ of Y){let U=_[1].trim();if(g$(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(g$(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 z3($,X={}){let Q=F3($,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 g$($,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=g$(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 j3($,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 H3($){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 O3($){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 A3($,X={}){let Q={...p5,...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=z3(Y,Q.constants);if(Y=F.content,F.removed.length>0)J.push("Dead code elimination"),G.push(...F.removed.map((H)=>`Removed: ${H}`))}if(Q.constantFolding&&Object.keys(Q.constants).length>0){let F=j3(Y,Q.constants);if(Y=F.content,K=F.folded,K.length>0)J.push("Constant folding")}if(Q.treeShake){if(W=B3(Y,Q.preserveDirectives),W.length>0)J.push("Tree shaking")}if(Q.stringPooling){let F=O3(Y);if(Y=F.content,_=F.count,_>0)J.push("String pooling")}if(Q.minifyHtml){let F=H3(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 fJ($,X={}){let Q={...p5,...X},Z=new Map,Y=[],J=0,G=0,W=new Set;for(let[z,F]of $){let H=A3(F,Q);Z.set(z,H),J+=H.originalSize,G+=H.optimizedSize,Y.push(...H.warnings.map((L)=>`${z}: ${L}`));let j=l5(F);for(let L of j)W.add(L.name)}let K;if(Q.treeShake)K=L3(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 q3($){return $.charAt(0).toUpperCase()+$.slice(1)}function r5($,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=r5(_,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 pJ($,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=N3(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 cJ($,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 N3($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}var M3={name:"component",handler:async($,X,Q,Z)=>{if(X.length<1)return h1("Component","component directive requires at least the component name",f1.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=i5(U,Q),Object.keys(J).length===0)J=r5(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),h1("Component",`Error parsing component props: ${z}`,f1.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 a5(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 h1("Component",`Error rendering component: ${z}`,f1.COMPONENT_RENDER_ERROR)}},hasEndTag:!1};function lJ(){return[M3]}import{mkdir as V3,readFile as E3,readdir as R3,stat as s5,writeFile as I3}from"fs/promises";import o from"path";var $6=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function D3($){return $.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join("")}function f$($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function w3($){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test($)&&!$.startsWith("xml")&&!/[A-Z]/.test($)}function T3($){if($===!0)return"open";if($==="open"||$==="closed")return $;return!1}async function C3($){let X=[];async function Q(Z){let Y=await R3(Z,{withFileTypes:!0});Y.sort((J,G)=>J.name.localeCompare(G.name));for(let J of Y){let G=o.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 x3($,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 k3($,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,H=_;for(;H<J.length&&U>0;H++){let L=J[H];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(_,H-1)}}`,G.lastIndex=H}}return Q}function S3($){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 n5($){return[...$.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((X)=>X[1].trim()).filter(Boolean).join(`
199
199
 
200
- `)}function S3($){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 b3($){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 y3($){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 v3($,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=o.resolve(o.dirname(X),L),q=o.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 g3($){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 f3($){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 h3($){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 d3($){return[...new Set([...$.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((X)=>X[1]))].sort().map((X)=>({name:X}))}function o5($,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 u3($,X,Q){let Z=o.isAbsolute(X.file)?X.file:o.resolve($,X.file),Y=await V3(Z,"utf8"),J=C3(Y,Z),G=o.basename(Z,".stx"),W=X.name||J.name||I3(G),K=`${f$(Q.prefix||"stx")}-${f$(G)}`,_=X.tag||J.tag||K;if(!W||!/^[A-Za-z_$][\w$]*$/.test(W))throw Error(`${Z}: invalid component class name "${W}"`);if(!D3(_))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,o5(M,V)])),F=g3(k3(Y)),O=f3(F.template),j=v3(Y,Z,o.resolve(Q.outputDir)),L=y3(O.template);for(let M of j.propNames){if(z[M])continue;let V=j.defaults[M];z[M]=o5(M,{type:S3(j.declared[M])??P3(V),...V===void 0?{}:{default:b3(V)}})}let H=J.methods||{},A=X.methods||{},q=x3(Y,Z);return{file:o.relative($,Z),sourcePath:Z,name:W,tag:_,description:X.description||J.description||"",template:O.template,styles:n5(Y),shadowMode:w3(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:h3(O.template),cssProperties:d3(n5(Y)),scope:j,render:L}}function m3(){let $=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),X=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
200
+ `)}function P3($){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 b3($){if($===void 0)return"object";if($==="true"||$==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test($))return"number";if(/^['"`]/.test($))return"string";return"object"}function y3($){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 v3($){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 g3($,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*['"])(\.[^'"]*)(['"])/,(H,j,L,O)=>{let A=o.resolve(o.dirname(X),L),q=o.relative(Q,A);return`${j}${q.startsWith(".")?q:`./${q}`}${O}`})),""});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 H=F.split(":")[0].trim();if(H)W.push(H)}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 H of F[1].matchAll(/^\s*(?:\/\*\*[\s\S]*?\*\/\s*)?([A-Za-z_$][\w$]*)\??\s*:\s*([^\n;]+)/gm))_[H[1]]=H[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 f3($){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 h3($){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 d3($){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 u3($){return[...new Set([...$.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((X)=>X[1]))].sort().map((X)=>({name:X}))}function o5($,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 m3($,X,Q){let Z=o.isAbsolute(X.file)?X.file:o.resolve($,X.file),Y=await E3(Z,"utf8"),J=x3(Y,Z),G=o.basename(Z,".stx"),W=X.name||J.name||D3(G),K=`${f$(Q.prefix||"stx")}-${f$(G)}`,_=X.tag||J.tag||K;if(!W||!/^[A-Za-z_$][\w$]*$/.test(W))throw Error(`${Z}: invalid component class name "${W}"`);if(!w3(_))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,o5(M,V)])),F=f3(S3(Y)),H=h3(F.template),j=g3(Y,Z,o.resolve(Q.outputDir)),L=v3(H.template);for(let M of j.propNames){if(z[M])continue;let V=j.defaults[M];z[M]=o5(M,{type:P3(j.declared[M])??b3(V),...V===void 0?{}:{default:y3(V)}})}let O=J.methods||{},A=X.methods||{},q=k3(Y,Z);return{file:o.relative($,Z),sourcePath:Z,name:W,tag:_,description:X.description||J.description||"",template:H.template,styles:n5(Y),shadowMode:T3(X.shadowDOM??J.shadowDOM??Q.shadowDOM),progressive:X.progressive??J.progressive??Q.progressive??!0,properties:z,events:X.events||J.events||{},methods:{...O,...A,...q},eventTypes:F.eventTypes,bindings:H.bindings,slots:d3(H.template),cssProperties:u3(n5(Y)),scope:j,render:L}}function p3(){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 p3($){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) {
487
+ `}function c3($){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 d1($){switch($.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function c3($){let X=Object.entries($.properties).map(([J,G])=>` ${J}${G.required?"":"?"}: ${d1(G)}`).join(`
512
+ `}function d1($){switch($.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function l3($){let X=Object.entries($.properties).map(([J,G])=>` ${J}${G.required?"":"?"}: ${d1(G)}`).join(`
513
513
  `),Q=Object.entries($.properties).map(([J,G])=>` ${J}: ${d1(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 l3($){return`declare global {
539
+ `}function i3($){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)}?: ${d1(G)}`).join(`
@@ -555,9 +555,9 @@ ${Y}
555
555
  }
556
556
 
557
557
  export {}
558
- `}function i3($){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:d1(Z)},default:Z.default===void 0?void 0:JSON.stringify(Z.default),attribute:Z.attribute===!1?void 0:Z.attribute||f$(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 t5($){if(!$.styles)return"";let X=$.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(X))return X;return`@scope (${$.tag}) {
558
+ `}function a3($){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:d1(Z)},default:Z.default===void 0?void 0:JSON.stringify(Z.default),attribute:Z.attribute===!1?void 0:Z.attribute||f$(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 t5($){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 e5($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function a3($){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 e5($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function r3($){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 rJ($){let X=o.resolve($.inputDir),Q=o.resolve($.outputDir);if(!(await s5(X).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${X}`);let Y=$.components?.length?$.components:(await T3(X)).map((L)=>({file:L}));if(!Y.length)throw Error(`No .stx components found in ${X}`);let J=await Promise.all(Y.map((L)=>u3(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 M3(Q,{recursive:!0});let K=[],_=async(L,H)=>{let A=o.join(Q,L);return await R3(A,H.endsWith(`
595
- `)?H:`${H}
596
- `,"utf8"),K.push(A),A};await _("runtime.js",m3());for(let L of J){if(await _(`${L.tag}.js`,p3(L)),$.declarations!==!1)await _(`${L.tag}.d.ts`,c3(L));if($.css!==!1&&L.styles){let H=L.shadowMode?L.styles:t5(L);await _(`${L.tag}.css`,$.minify?e5(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",a3(J)),$.declarations!==!1)await _("index.d.ts",J.map((L)=>`export * from './${L.tag}.js'`).join(`
598
- `)),await _("custom-elements.d.ts",l3(J)),await _("ssr.d.ts",`${J.map((L)=>`export declare const render${L.name}: (props?: ${L.name}Props, slots?: Record<string, string>) => string`).join(`
594
+ `}async function sJ($){let X=o.resolve($.inputDir),Q=o.resolve($.outputDir);if(!(await s5(X).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${X}`);let Y=$.components?.length?$.components:(await C3(X)).map((L)=>({file:L}));if(!Y.length)throw Error(`No .stx components found in ${X}`);let J=await Promise.all(Y.map((L)=>m3(X,L,$)));J.sort((L,O)=>L.tag.localeCompare(O.tag));let G=J.filter((L,O)=>J.findIndex((A)=>A.tag===L.tag)!==O);if(G.length)throw Error(`Duplicate custom-element tag: ${G[0].tag}`);let W=J.filter((L,O)=>J.findIndex((A)=>A.name===L.name)!==O);if(W.length)throw Error(`Duplicate component class name: ${W[0].name}`);await V3(Q,{recursive:!0});let K=[],_=async(L,O)=>{let A=o.join(Q,L);return await I3(A,O.endsWith(`
595
+ `)?O:`${O}
596
+ `,"utf8"),K.push(A),A};await _("runtime.js",p3());for(let L of J){if(await _(`${L.tag}.js`,c3(L)),$.declarations!==!1)await _(`${L.tag}.d.ts`,l3(L));if($.css!==!1&&L.styles){let O=L.shadowMode?L.styles:t5(L);await _(`${L.tag}.css`,$.minify?e5(O):O)}}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",r3(J)),$.declarations!==!1)await _("index.d.ts",J.map((L)=>`export * from './${L.tag}.js'`).join(`
598
+ `)),await _("custom-elements.d.ts",i3(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(i3(J),null,2));let F;if($.css!==!1){let L=J.filter((H)=>!H.shadowMode&&H.styles).map(t5).join(`
602
+ `)}`);let z;if($.manifest!==!1)z=await _("custom-elements.json",JSON.stringify(a3(J),null,2));let F;if($.css!==!1){let L=J.filter((O)=>!O.shadowMode&&O.styles).map(t5).join(`
603
603
 
604
- `);if(L)F=await _("bundle.css",$.minify?e5(L):L)}let O;if($.bundle!==!1){O=o.join(Q,"bundle.js");let L;try{L=await Bun.build({entrypoints:[o.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(`
604
+ `);if(L)F=await _("bundle.css",$.minify?e5(L):L)}let H;if($.bundle!==!1){H=o.join(Q,"bundle.js");let L;try{L=await Bun.build({entrypoints:[o.join(Q,"index.js")],outdir:Q,naming:"bundle.js",target:"browser",format:"esm",minify:$.minify??!0,sourcemap:$.sourcemap||"none"})}catch(O){let A=O instanceof AggregateError?O.errors:[O],q=A.map((M)=>String(M).trim()).filter(Boolean).join(`
605
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(`
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 s5(L)).size));return{components:J.map((L)=>({name:L.name,tag:L.tag,source:L.sourcePath,module:o.join(Q,`${L.tag}.js`)})),files:K,manifest:z,bundle:O,cssBundle:F,totalBytes:j.reduce((L,H)=>L+H,0)}}var{serve:Q4}=globalThis.Bun;import d$ from"fs";import o0 from"path";function u1(){return`
606
+ ${q}`:""}`)}if(!L.success){let O=L.logs.map((A)=>String(A).trim()).filter(Boolean).join(`
607
+ `);throw AggregateError(L.logs,`Failed to bundle component library${O?`
608
+ ${O}`:""}`)}if(K.push(H),$.sourcemap==="external")K.push(`${H}.map`)}let j=await Promise.all(K.map(async(L)=>(await s5(L)).size));return{components:J.map((L)=>({name:L.name,tag:L.tag,source:L.sourcePath,module:o.join(Q,`${L.tag}.js`)})),files:K,manifest:z,bundle:H,cssBundle:F,totalBytes:j.reduce((L,O)=>L+O,0)}}var{serve:Z4}=globalThis.Bun;import d$ from"fs";import o0 from"path";function u1(){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 X6 from"net";async function r3($){return new Promise((X)=>{let Q=X6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"0.0.0.0")})}async function s3($){return new Promise((X)=>{let Q=X6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"::")})}async function n3($){if(!await r3($))return!1;return await s3($)}async function x0($,X=20){$=Number($);for(let Q=0;Q<X;Q++){let Z=$+Q;if(await n3(Z))return Z}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var o3={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function t3(){try{let $=await import("./chunk-k03b9z9e.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function n0($,X={}){let Q={...o3,...X},Z=await t3();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 l1($){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 X6 from"net";async function s3($){return new Promise((X)=>{let Q=X6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"0.0.0.0")})}async function n3($){return new Promise((X)=>{let Q=X6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"::")})}async function o3($){if(!await s3($))return!1;return await n3($)}async function x0($,X=20){$=Number($);for(let Q=0;Q<X;Q++){let Z=$+Q;if(await o3(Z))return Z}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var t3={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function e3(){try{let $=await import("./chunk-k03b9z9e.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function n0($,X={}){let Q={...t3,...X},Z=await e3();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 l1($){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
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 h$(){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 e3($){console.log(`${B.green}Server running at ${B.cyan}${$}${B.reset}`),console.log(`Press ${B.cyan}Ctrl+C${B.reset} to stop the server`),h$()}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(),h$();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="",X4(J,$,X,Q)}})}function X4($,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(),e3(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 h$();break;default:break}}async function u$($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=o0.resolve($);if(!d$.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 q0(Y,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:A0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),O=X.markdown?.syntaxHighlighting||A0.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(`
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`),h$()}function X4($){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(),h$();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="",Q4(J,$,X,Q)}})}function Q4($,X,Q,Z){switch($){case"o":if(Z?.onOpen)Z.onOpen();else X4(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 h$();break;default:break}}async function u$($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=o0.resolve($);if(!d$.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 q0(Y,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:A0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),H=X.markdown?.syntaxHighlighting||A0.markdown?.syntaxHighlighting,j=H?.defaultTheme||"github-dark",L=["github-dark"],O=H?.additionalThemes||[],q=[...new Set([...L,...O])].map((M)=>`<option value="${M}"${M===j?" selected":""}>${M}</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>${Z4(F.title||o0.basename(Y))}</title>
700
+ <title>${Y4(F.title||o0.basename(Y))}</title>
701
701
  <!-- Syntax highlighting styles -->
702
702
  <style id="syntax-theme">
703
703
  :root {
@@ -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 _=Q4({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 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 _=Z4({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
860
  ${B.yellow}Routes:${B.reset}`);let U=o0.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)d$.watch(o0.dirname(Y),{recursive:!0}).close();_.stop()}),X.native)await n0(K,{title:o0.basename(Y,".md")});if(Z){let z=o0.dirname(Y);console.log(`${B.blue}Watching ${B.bright}${z}${B.reset} for changes...`);let F=d$.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 Z4($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:J4}=globalThis.Bun;import F0 from"fs";import $0 from"path";class Q6{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 Y4($,X={}){let{showOverlay:Q=!0,reconnectInterval:Z=1000,maxReconnectAttempts:Y=10}=X;return`
861
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(_.url.toString(),()=>{if(Z)d$.watch(o0.dirname(Y),{recursive:!0}).close();_.stop()}),X.native)await n0(K,{title:o0.basename(Y,".md")});if(Z){let z=o0.dirname(Y);console.log(`${B.blue}Watching ${B.bright}${z}${B.reset} for changes...`);let F=d$.watch(z,{recursive:!0},async(H,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 Y4($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:G4}=globalThis.Bun;import F0 from"fs";import $0 from"path";class Q6{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 J4($,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 I0($,X,Q={}){let Z=Y4(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 i1($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function a1($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Z)=>X.endsWith(Z))}function r1($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Q)=>Q.test($))}var t0=null;function s1($){if(!t0)t0=new Q6($);return t0}function j1(){if(t0)t0.stop(),t0=null}import O1 from"path";var e0={name:"bun-plugin-stx",async setup($){let Q={...await z1(),...$.config?.stx},Z=new Set,Y=Q.webComponents?.enabled?`./${O1.relative(O1.dirname($.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Q.webComponents?.enabled)try{let G=await $$(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 t1(G,Q);if(L){if(Q.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await l$(()=>Bun.file(G).text(),"",(L)=>{throw new c$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new c$(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:z}=m$.time("script-extraction",()=>{let L=K,H=o1(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 E=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=E;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:O1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await l$(()=>B0(_,F,G),void 0,(L)=>{let H=new p$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(n1.log(H,{filePath:G,scriptContent:_}),Q.debug)throw H});let j=await m$.timeAsync("directive-processing",async()=>{return await L0(U,F,G,Q,W)});if(z.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-yv340gxj.js"),H=L(z.join(`
1061
- `),F),A=j.search(/<\/body>/i);if(A!==-1)j=j.slice(0,A)+H+`
1060
+ `}function I0($,X,Q={}){let Z=J4(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 i1($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function a1($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Z)=>X.endsWith(Z))}function r1($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Q)=>Q.test($))}var t0=null;function s1($){if(!t0)t0=new Q6($);return t0}function j1(){if(t0)t0.stop(),t0=null}import H1 from"path";var e0={name:"bun-plugin-stx",async setup($){let Q={...await z1(),...$.config?.stx},Z=new Set,Y=Q.webComponents?.enabled?`./${H1.relative(H1.dirname($.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Q.webComponents?.enabled)try{let G=await $$(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 t1(G,Q);if(L){if(Q.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await l$(()=>Bun.file(G).text(),"",(L)=>{throw new c$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new c$(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:z}=m$.time("script-extraction",()=>{let L=K,O=o1(K);if(O)L=O.content.trim();let A=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],q="",M=[];for(let N of A){let E=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=E;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:H1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await l$(()=>B0(_,F,G),void 0,(L)=>{let O=new p$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(n1.log(O,{filePath:G,scriptContent:_}),Q.debug)throw O});let j=await m$.timeAsync("directive-processing",async()=>{return await L0(U,F,G,Q,W)});if(z.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-gfgpf7h8.js"),O=L(z.join(`
1061
+ `),F),A=j.search(/<\/body>/i);if(A!==-1)j=j.slice(0,A)+O+`
1062
1062
  `+j.slice(A);else j+=`
1063
- ${H}`}if(j=await J6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await e1(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 p$(`Plugin processing failed: ${String(W)}`,G);if(n1.log(K,{filePath:G,buildConfig:$.config}),Y6.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||Z6()?`<!DOCTYPE html>
1063
+ ${O}`}if(j=await J6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await e1(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 p$(`Plugin processing failed: ${String(W)}`,G);if(n1.log(K,{filePath:G,buildConfig:$.config}),Y6.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||Z6()?`<!DOCTYPE html>
1064
1064
  <html lang="en">
1065
1065
  <head>
1066
1066
  <meta charset="UTF-8">
@@ -1101,7 +1101,7 @@ ${H}`}if(j=await J6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await e
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 ${u0(O1.basename(G))}</code> for detailed analysis</li>
1104
+ <li>Run <code>stx debug ${u0(H1.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 J6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await e
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 G4($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=$0.resolve($);if(!F0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return u$(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");F0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let q={name:"public-assets",setup(E){E.onResolve({filter:/^\/(images|fonts|assets|public)\//},(w)=>{return{path:w.path,external:!0}})}},M=await Bun.build({entrypoints:[W],outdir:K,plugins:[q,e0],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((E)=>E.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=$0.dirname(W);await X$(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=s1({wsPort:q,verbose:!1}),G=J.start(q)}let j={},L=null;try{let{loadStxConfig:q}=await import("./chunk-hyyzp99b.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-nenge2m2.js"),E=M.broadcasting;await V(E);let w=E.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${w}/ws${B.reset}`);let C=$0.join(process.cwd(),"channels.ts");if(F0.existsSync(C))try{let R=await N(C);console.log(`${B.blue}Loaded ${B.bright}${R} broadcast channel${R!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(R){console.warn(`${B.yellow}Failed to load channels.ts: ${R.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=J4({port:O,async fetch(q){return Z$(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 R=await s(_||"");if(Y)R=I0(R,G);if(X.native)if(R.includes("<head>"))R=R.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(R.includes("<html"))R=R.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 R="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+R;if(X.titlebarHidden)if(R.includes("<head>"))R=R.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(R.includes("<html"))R=R.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 R=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${R}`;return R})().then((R)=>new Response(R,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let V=$0.join(K,M.pathname);if(F0.existsSync(V)&&F0.statSync(V).isFile()){let C=Bun.file(V),R=$0.extname(V).toLowerCase(),I="text/plain";if(R===".ts"||R===".tsx"){let m=new Bun.Transpiler({loader:R===".tsx"?"tsx":"ts"}),h=await C.text(),E0=m.transformSync(h);return new Response(E0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(R){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":I}})}let N=$0.dirname(W),E=$0.join(N,M.pathname);if(F0.existsSync(E)&&F0.statSync(E).isFile()){let C=Bun.file(E),R=$0.extname(E).toLowerCase(),I="text/plain";if(R===".ts"||R===".tsx"){let m=new Bun.Transpiler({loader:R===".tsx"?"tsx":"ts"}),h=await C.text(),E0=m.transformSync(h);return new Response(E0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(R){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":I}})}let w=$0.join(process.cwd(),"public",M.pathname);if(F0.existsSync(w)&&F0.statSync(w).isFile()){let C=Bun.file(w),R=$0.extname(w).toLowerCase(),I="application/octet-stream";if(R===".ts"||R===".tsx"){let m=new Bun.Transpiler({loader:R===".tsx"?"tsx":"ts"}),h=await C.text(),E0=m.transformSync(h);return new Response(E0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(R){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})})())},error(q){return new Response(`<pre>${q}
1123
+ </html>`,loader:"html"}}})}};async function W4($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=$0.resolve($);if(!F0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return u$(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");F0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let q={name:"public-assets",setup(E){E.onResolve({filter:/^\/(images|fonts|assets|public)\//},(w)=>{return{path:w.path,external:!0}})}},M=await Bun.build({entrypoints:[W],outdir:K,plugins:[q,e0],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((E)=>E.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=$0.dirname(W);await X$(F);let H=Q;try{if(H=await x0(Q),H!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${H} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let q=X.hmrPort||H+1;J=s1({wsPort:q,verbose:!1}),G=J.start(q)}let j={},L=null;try{let{loadStxConfig:q}=await import("./chunk-macr4195.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-nenge2m2.js"),E=M.broadcasting;await V(E);let w=E.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${w}/ws${B.reset}`);let C=$0.join(process.cwd(),"channels.ts");if(F0.existsSync(C))try{let R=await N(C);console.log(`${B.blue}Loaded ${B.bright}${R} broadcast channel${R!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(R){console.warn(`${B.yellow}Failed to load channels.ts: ${R.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:${H}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let O=G4({port:H,async fetch(q){return Z$(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 R=await s(_||"");if(Y)R=I0(R,G);if(X.native)if(R.includes("<head>"))R=R.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(R.includes("<html"))R=R.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 R="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+R;if(X.titlebarHidden)if(R.includes("<head>"))R=R.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(R.includes("<html"))R=R.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 R=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${R}`;return R})().then((R)=>new Response(R,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let V=$0.join(K,M.pathname);if(F0.existsSync(V)&&F0.statSync(V).isFile()){let C=Bun.file(V),R=$0.extname(V).toLowerCase(),I="text/plain";if(R===".ts"||R===".tsx"){let m=new Bun.Transpiler({loader:R===".tsx"?"tsx":"ts"}),h=await C.text(),E0=m.transformSync(h);return new Response(E0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(R){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":I}})}let N=$0.dirname(W),E=$0.join(N,M.pathname);if(F0.existsSync(E)&&F0.statSync(E).isFile()){let C=Bun.file(E),R=$0.extname(E).toLowerCase(),I="text/plain";if(R===".ts"||R===".tsx"){let m=new Bun.Transpiler({loader:R===".tsx"?"tsx":"ts"}),h=await C.text(),E0=m.transformSync(h);return new Response(E0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(R){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":I}})}let w=$0.join(process.cwd(),"public",M.pathname);if(F0.existsSync(w)&&F0.statSync(w).isFile()){let C=Bun.file(w),R=$0.extname(w).toLowerCase(),I="application/octet-stream";if(R===".ts"||R===".tsx"){let m=new Bun.Transpiler({loader:R===".tsx"?"tsx":"ts"}),h=await C.text(),E0=m.transformSync(h);return new Response(E0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(R){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})})())},error(q){return new Response(`<pre>${q}
1124
1124
  ${q.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(`
1126
+ ${B.bright}\u2192 ${B.cyan}http://localhost:${H}/${B.reset}`),console.log(`
1127
1127
  ${B.yellow}Routes:${B.reset}`);let A=$0.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)F0.watch($0.dirname(W),{recursive:!0}).close();H.stop()}),X.native){let q=await Bun.file(W).text(),M=l1(q);await n0(O,{title:$0.basename(W,".stx"),titlebarHidden:X.titlebarHidden===!0,nativeSidebar:!!M,sidebarConfig:M})}if(Z){let q=$0.dirname(W);console.log(`${B.blue}Watching ${B.bright}${q}${B.reset} for changes...`);let M=F0.watch(q,{recursive:!0},async(V,N)=>{if(!N||r1(N))return;if(a1(N)){console.log(`${B.yellow}File ${B.bright}${N}${B.yellow} changed, rebuilding...${B.reset}`),m0.clear(),p0();let E=await U();if(await Q$(F),Y&&J)if(E)J.reload(N);else J.error("Build failed - check console for details")}else if(i1(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)j1();H.stop(),process.exit(0)})}return!0}var{serve:W4}=globalThis.Bun;import P0 from"fs";import t from"path";var G6=`
1128
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(O.url.toString(),()=>{if(Z)F0.watch($0.dirname(W),{recursive:!0}).close();O.stop()}),X.native){let q=await Bun.file(W).text(),M=l1(q);await n0(H,{title:$0.basename(W,".stx"),titlebarHidden:X.titlebarHidden===!0,nativeSidebar:!!M,sidebarConfig:M})}if(Z){let q=$0.dirname(W);console.log(`${B.blue}Watching ${B.bright}${q}${B.reset} for changes...`);let M=F0.watch(q,{recursive:!0},async(V,N)=>{if(!N||r1(N))return;if(a1(N)){console.log(`${B.yellow}File ${B.bright}${N}${B.yellow} changed, rebuilding...${B.reset}`),m0.clear(),p0();let E=await U();if(await Q$(F),Y&&J)if(E)J.reload(N);else J.error("Build failed - check console for details")}else if(i1(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)j1();O.stop(),process.exit(0)})}return!0}var{serve:K4}=globalThis.Bun;import P0 from"fs";import t from"path";var G6=`
1129
1129
  <script data-stx-helpers>
1130
1130
  (function() {
1131
1131
  'use strict'
@@ -1436,7 +1436,7 @@ else {
1436
1436
 
1437
1437
  })()
1438
1438
  </script>
1439
- `;_6();function U6($){if($.length===0)return"";if($.length===1)return $[0];let X=$.map((Z)=>Z.split(t.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(t.sep)}async function K4($,X={}){let Q=X.port||3000,Z=X.watch!==!1;for(let j of $){let L=t.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=U6($.map((j)=>t.dirname(t.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=t.resolve(j);if(L.endsWith(".md"))try{let{content:A,data:q}=await q0(L,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:A0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),M=X.markdown?.syntaxHighlighting||A0.markdown?.syntaxHighlighting,V=M?.defaultTheme||"github-dark",N=["github-dark"],E=M?.additionalThemes||[],C=[...new Set([...N,...E])].map((h)=>`<option value="${h}"${h===V?" selected":""}>${h}</option>`).join(`
1439
+ `;_6();function U6($){if($.length===0)return"";if($.length===1)return $[0];let X=$.map((Z)=>Z.split(t.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(t.sep)}async function _4($,X={}){let Q=X.port||3000,Z=X.watch!==!1;for(let j of $){let L=t.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=U6($.map((j)=>t.dirname(t.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=t.resolve(j);if(L.endsWith(".md"))try{let{content:A,data:q}=await q0(L,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:A0.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),M=X.markdown?.syntaxHighlighting||A0.markdown?.syntaxHighlighting,V=M?.defaultTheme||"github-dark",N=["github-dark"],E=M?.additionalThemes||[],C=[...new Set([...N,...E])].map((h)=>`<option value="${h}"${h===V?" selected":""}>${h}</option>`).join(`
1440
1440
  `),R=`
1441
1441
  <!DOCTYPE html>
1442
1442
  <html lang="en">
@@ -1600,19 +1600,19 @@ else {
1600
1600
  </body>
1601
1601
  </html>
1602
1602
  `,m=`/${t.relative(J,L).replace(/\.md$/,"")}`;if(m.endsWith("/index"))m=m.slice(0,-6)||"/";G[m||"/"]={filePath:L,content:R,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)\//},(E)=>{return{path:E.path,external:!0}})}},q;try{let N=await Bun.build({entrypoints:[L],outdir:Y,plugins:[A,e0],define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!N.success){console.error(`${B.red}Build failed for ${B.bright}${j}${B.reset}:`,$1(N.logs,L));continue}let E=N.outputs.find((w)=>w.path.endsWith(".html"));if(!E){console.error(`${B.red}No HTML output found for ${B.bright}${j}${B.reset}`);continue}q=await Bun.file(E.path).text()}catch(N){console.error(`${B.red}Build failed for ${B.bright}${j}${B.reset}:
1603
- ${$1(N,L)}`);continue}let V=`/${t.relative(J,L).replace(/\.stx$/,"")}`;if(V.endsWith("/index"))V=V.slice(0,-6)||"/";if(V.includes("[")){let{regex:N,params:E}=K6(V);W.push({pattern:N,paramNames:E,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}`,$1(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=W4({port:U,async fetch(j){let L=new URL(j.url),H=t.join(process.cwd(),"public",L.pathname);if(P0.existsSync(H)&&P0.statSync(H).isFile()){let M=Bun.file(H),V=t.extname(H).toLowerCase(),N="application/octet-stream";if(V===".ts"||V===".tsx"){let E=new Bun.Transpiler({loader:V===".tsx"?"tsx":"ts"}),w=await M.text(),C=E.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 E={};for(let R=0;R<M.paramNames.length;R++)E[M.paramNames[R]]=decodeURIComponent(V[R+1]);let w=N.content,C=`<script>window.__routeParams = ${JSON.stringify(E)};</script>`;if(w.includes("</head>"))w=w.replace("</head>",`${C}
1603
+ ${$1(N,L)}`);continue}let V=`/${t.relative(J,L).replace(/\.stx$/,"")}`;if(V.endsWith("/index"))V=V.slice(0,-6)||"/";if(V.includes("[")){let{regex:N,params:E}=K6(V);W.push({pattern:N,paramNames:E,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}`,$1(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=K4({port:U,async fetch(j){let L=new URL(j.url),O=t.join(process.cwd(),"public",L.pathname);if(P0.existsSync(O)&&P0.statSync(O).isFile()){let M=Bun.file(O),V=t.extname(O).toLowerCase(),N="application/octet-stream";if(V===".ts"||V===".tsx"){let E=new Bun.Transpiler({loader:V===".tsx"?"tsx":"ts"}),w=await M.text(),C=E.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 E={};for(let R=0;R<M.paramNames.length;R++)E[M.paramNames[R]]=decodeURIComponent(V[R+1]);let w=N.content,C=`<script>window.__routeParams = ${JSON.stringify(E)};</script>`;if(w.includes("</head>"))w=w.replace("</head>",`${C}
1604
1604
  </head>`);else w=C+w;A={...N,content:w}}break}}if(A)return s(A.content).then((M)=>{if(M.includes("</head>"))M=M.replace("</head>",`${G6}
1605
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=t.join(Y,L.pathname);if(P0.existsSync(q)&&P0.statSync(q).isFile()){let M=Bun.file(q),V=t.extname(q).toLowerCase(),N="text/plain";if(V===".ts"||V===".tsx"){let E=new Bun.Transpiler({loader:V===".tsx"?"tsx":"ts"}),w=await M.text(),C=E.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=j.headers.get("X-STX-Router")==="true";return s(G["/"].content).then((V)=>{if(M){let N=V.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(N){let E=V.match(/<title[^>]*>([\s\S]*?)<\/title>/i),w=E?E[1]:"",C=`<!DOCTYPE html><html><head><title>${W6(w)}</title></head><body><main>${N[1]}</main></body></html>`;return new Response(C,{headers:{"Content-Type":"text/html","X-STX-Partial":"true","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}return new Response(V,{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(j){return new Response(`<pre>${j}
1606
1606
  ${j.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:t.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:t.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}`),m0.clear(),p0(),await K()});process.on("SIGINT",()=>{j.close(),z.stop(),process.exit(0)})}return!0}function W6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:_4}=globalThis.Bun;import X0 from"fs";import g from"path";async function B6($){try{return v$(await Bun.file($).text())}catch{return}}function i$($){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 U4($=".",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-hyyzp99b.js"),_=await K(W),U=_.root&&_.root!=="."?g.join(W,_.root):W,z=X.pagesDir||_.pagesDir||"pages",F=g.join(U,z);if(!X0.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=r$(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(X0.existsSync(D)){let b=r$(g.dirname(D),{pagesDir:g.basename(D)});for(let S of b){let y=T==="/"?S.pattern:`${T}${S.pattern==="/"?"":S.pattern}`;L.push({route:{...S,pattern:y},prefix:T})}if(b.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${b.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 I6(W,X.stxOptions?.shell),q){if(A=await s$(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}`)}}z6(),await O6(W);let M=j6();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-hyyzp99b.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 b=Object.keys(V).length;if(b>0)console.log(`${B.blue}Loaded ${B.bright}${b} API route${b>1?"s":""}${B.reset}`)}if(T?.broadcasting?.enabled)try{let{startBroadcasting:b,loadChannels:S}=await import("./chunk-nenge2m2.js"),y=T.broadcasting;await b(y);let G0=y.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${G0}/ws${B.reset}`);let Y0=g.join(process.cwd(),"channels.ts");if(X0.existsSync(Y0))try{let T0=await S(Y0);console.log(`${B.blue}Loaded ${B.bright}${T0} broadcast channel${T0!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(T0){console.warn(`${B.yellow}Failed to load channels.ts: ${T0.message}${B.reset}`)}}catch(b){console.warn(`${B.yellow}Broadcasting failed to start: ${b.message}${B.reset}`)}}catch{}let E=S0(W,"output");X0.mkdirSync(E,{recursive:!0});let w=new Map,C=new Set,R=async(D)=>{let T=L6(F,D);if(!T)return null;try{let b=await Bun.build({entrypoints:[T],outdir:E,plugins:[e0],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!b.success)return null;let S=b.outputs.find((y)=>y.path.endsWith(".html"));if(!S)return null;return await Bun.file(S.path).text()}catch{return null}},I=async(D,T)=>{try{let{processDirectives:b,extractVariables:S,defaultConfig:y,loadStxConfig:G0,injectRouterScript:Y0}=await import("./chunk-hyyzp99b.js"),{checkCache:T0,cacheTemplate:S$,readFileCached:r,templateCache:S1}=await import("./chunk-5xd7vge2.js"),P1=await G0(W),x=(u)=>{if(!u)return u;if(g.isAbsolute(u))return u;return g.resolve(W,u)},v={...y,...P1,...X.stxOptions,autoShell:!0};if(X.debugDirectives)v.debug=!0;v.partialsDir=x(v.partialsDir),v.componentsDir=x(v.componentsDir),v.layoutsDir=x(v.layoutsDir),v.storesDir=x(v.storesDir||"stores"),v.cachePath=x(v.cachePath)??S0(W,"cache");let p=!T&&!X.profile,d=v.cache!==!1;if(d&&p){let u=S1.get(D.filePath);if(u)try{if((await X0.promises.stat(D.filePath)).mtime.getTime()<=u.mtime){let C0=!0;for(let n of u.dependencies){if(!X0.existsSync(n)){C0=!1;break}if((await X0.promises.stat(n)).mtime.getTime()>u.mtime){C0=!1;break}}if(C0){let n=u.output;if(A)n=J$(n,{preserveHead:!0});return{route:D,content:n,status:await B6(D.filePath)}}}}catch{}let _0=await T0(D.filePath,v);if(_0){let U0=_0;if(A)U0=J$(U0,{preserveHead:!0});return{route:D,content:U0,status:await B6(D.filePath)}}}let k=d?await r(D.filePath):await Bun.file(D.filePath).text(),W0=v$(k),{classifyAllScripts:j0}=await import("./chunk-hyyzp99b.js"),c=j0(k),J0=c.server.map((u)=>u.content),O0=k;for(let u of c.server)O0=O0.replace(u.fullTag,"");let K0={__filename:D.filePath,__dirname:g.dirname(D.filePath),params:T??{},__stx_runtime_head:{}};for(let u of J0)try{await S(u,K0,D.filePath)}catch(_0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",D.filePath,_0?.message||_0)}let P$=new Set,H0;if(X.profile){let u=performance.now();H0=await b(O0,K0,D.filePath,v,P$);let _0=performance.now()-u,U0=g.relative(W,D.filePath)||D.filePath;console.log(`[stx:profile] ${U0} \u2192 ${_0.toFixed(2)}ms`)}else H0=await b(O0,K0,D.filePath,v,P$);if(!A)H0=await Y0(H0,{router:v.router});{let{interpolateScriptExpressions:u}=await import("./chunk-yv340gxj.js");H0=H0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(_0,U0,C0)=>{if(!/function\s+__stx_setup_/.test(C0))return _0;return`<script${U0}>${u(C0,K0)}</script>`})}if(A)H0=J$(H0,{preserveHead:!0});if(d&&p)await S$(D.filePath,H0,P$,v);let{extractStreamBoundaries:m7}=await import("./chunk-v3ryxw4v.js"),a0=m7(K0),B1=K0.__streamTemplates;if(B1&&typeof B1==="object"&&Object.keys(B1).length>0){let u=K0.streamBoundaries||{},_0={...v,autoShell:!1},U0=Object.keys(B1).map((n)=>({id:n,render:async()=>{let P5=typeof u[n]==="function"?await u[n]():void 0;return b(B1[n],{...K0,$boundary:P5},D.filePath,_0,new Set)}})),C0=new Set(U0.map((n)=>n.id));a0=[...(a0||[]).filter((n)=>!C0.has(n.id)),...U0]}if(a0&&a0.length>0)C.add(D.pattern);else a0=void 0;return{route:D,content:H0,status:W0,boundaries:a0}}catch(b){return console.error(`${B.red}Error building ${B.bright}${D.pattern}${B.reset}:`,b),null}},m=8,h=async()=>{w.clear(),H.clear();for(let D=0;D<O.length;D+=m){let T=O.slice(D,D+m),b=await Promise.all(T.map((S)=>I(S)));for(let S of b)if(S)w.set(S.route.pattern,S)}for(let D=0;D<L.length;D+=m){let T=L.slice(D,D+m),b=await Promise.all(T.map(({route:S})=>I(S)));for(let S of b)if(S)H.set(S.route.pattern,S)}return w.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await h())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await X$(W);let R0=Q;try{if(R0=await x0(Q),R0!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${R0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let D=X.hmrPort||R0+1;J=s1({wsPort:D,verbose:!1}),G=J.start(D)}let d0=(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 k1=_4({port:R0,async fetch(D){let T=new URL(D.url),b=_?.publicDir||"public",S=g.join(W,b,T.pathname),y=g.join(W,T.pathname),G0=g.join(E,T.pathname),[Y0,T0,S$]=await Promise.all([X0.promises.stat(S).catch(()=>null),X0.promises.stat(y).catch(()=>null),X0.promises.stat(G0).catch(()=>null)]);if(Y0?.isFile())return i$(S);if(T0?.isFile())return i$(y);if(S$?.isFile())return i$(G0);if(T.pathname.startsWith("/_stx/component/")){let x=decodeURIComponent(T.pathname.slice(16));if(x)try{let v=`<${x} />`,p={...buildConfig,autoShell:!1},d=await processDirectives(v,{},g.join(W,"components",`${x}.stx`),p,new Set);return new Response(d,{headers:{"Content-Type":"text/html"}})}catch(v){return new Response(`<div class="stx-async-error">${v.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(T.pathname==="/_stx/img"){let{handleImageRequest:x}=await import("./chunk-xz019t7t.js"),v=await x(D,{publicDir:g.join(W,b),cacheDir:S0(W,"cache","img")});if(v)return v}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=a$(T.pathname,O);if(r){let x=w.get(r.route.pattern),v=C.has(r.route.pattern);if(r.route.isDynamic&&Object.keys(r.params).length>0||v){let p=await I(r.route,r.params);if(p)x=p}if(x){let p=x.status??200,d=(r.route.filePath?M6(await Bun.file(r.route.filePath).text().catch(()=>"")):null)??{};if(d.validate){if(!await d.validate({params:r.params})){let j0=await R(404);if(j0){let c=j0;if(c=await s(c,W),Y)c=I0(c,G);return new Response(c,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(d.middleware){let W0=H6(T.pathname,r.params,d,T.search),j0=A6(W0,null,D,{isServer:!0}),c=await q6(d.middleware,j0);if(c.redirect){let J0=c.redirect.path,O0=c.redirect.options.redirectCode||302,K0=new Headers(c.responseHeaders);return K0.set("Location",J0),new Response(null,{status:O0,headers:K0})}if(c.abort){let{statusCode:J0,message:O0}=c.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${J0}</title></head><body><h1>Error ${J0}</h1><p>${O0}</p></body></html>`,{status:J0,headers:{"Content-Type":"text/html"}})}if(Object.keys(c.state).length>0){let J0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(c.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;x.content=x.content.replace("</head>",`${J0}</head>`)}}let k=x.content;if(A&&D6(D)){let W0=N6(k),j0=R6(k),c=k.match(/<title[^>]*>([\s\S]*?)<\/title>/i),J0=c?c[1].trim():"";if(Object.keys(r.params).length>0)k=d0(k,r.params);k=await s(k,W);let O0=_?.router?.container||"main";return k=w6(k,O0),new Response(k,{status:p,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":W0.layout,"X-STX-Layout-Group":W0.group,"X-STX-Runtime":j0?"true":"false",...J0&&{"X-STX-Title":encodeURIComponent(J0)},[V6]:E6(),"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(A)k=Y$(A,k);if(Object.keys(r.params).length>0)k=d0(k,r.params);if(k=await s(k,W),Y)k=I0(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;if(X.titlebarHidden)if(k.includes("<head>"))k=k.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 k=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${k}`;if(x.boundaries&&x.boundaries.length>0){let{renderStreamingPage:W0,streamToResponse:j0}=await import("./chunk-v3ryxw4v.js");return j0(W0(k,x.boundaries,{timeoutMs:30000}),{status:p,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(k,{status:p,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(L.length>0){let x=L.map((p)=>p.route),v=a$(T.pathname,x);if(v){let p=H.get(v.route.pattern);if(p){let d=p.content;if(A)d=Y$(A,d);if(Object.keys(v.params).length>0)d=d0(d,v.params);if(d=await s(d,W),Y)d=I0(d,G);return new Response(d,{status:p.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:p}of j)if(p!=="/"&&T.pathname.startsWith(p)){let d=H.get(p)||H.get(p+"/");if(d){let k=d.content;if(A)k=Y$(A,k);if(k=await s(k,W),Y)k=I0(k,G);return new Response(k,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let S1=w.get("/");if(S1){let x=S1.content;if(x=await s(x,W),Y)x=I0(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 P1=await R(404);if(P1){let x=P1;if(x=await s(x,W),Y)x=I0(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 R(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((j)=>j.routeTemplate)),H=Object.entries(G).filter(([j])=>!F.has(j)).sort(([j],[L])=>j.localeCompare(L)).map(([j,L])=>({route:j==="/"?"/":j,filePath:t.relative(process.cwd(),L.filePath),fileType:L.fileType}));for(let j of W){let L=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");H.push({route:L,filePath:t.relative(process.cwd(),j.filePath),fileType:"stx"})}if(H.sort((j,L)=>j.route.localeCompare(L.route)),H.forEach((j,L)=>{let A=L===H.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,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${O}${B.yellow} changed, rebuilding...${B.reset}`),m0.clear(),p0(),await K()});process.on("SIGINT",()=>{j.close(),z.stop(),process.exit(0)})}return!0}function W6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:U4}=globalThis.Bun;import X0 from"fs";import g from"path";async function B6($){try{return v$(await Bun.file($).text())}catch{return}}function i$($){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 B4($=".",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-macr4195.js"),_=await K(W),U=_.root&&_.root!=="."?g.join(W,_.root):W,z=X.pagesDir||_.pagesDir||"pages",F=g.join(U,z);if(!X0.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 H=r$(U,{pagesDir:z});if(H.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}${H.length}${B.blue} routes${B.reset}`);let j=_?._pluginPageDirs||[],L=[];for(let{dir:D,prefix:T}of j)if(X0.existsSync(D)){let b=r$(g.dirname(D),{pagesDir:g.basename(D)});for(let S of b){let y=T==="/"?S.pattern:`${T}${S.pattern==="/"?"":S.pattern}`;L.push({route:{...S,pattern:y},prefix:T})}if(b.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${b.length}${B.blue} routes at ${B.cyan}${T}${B.reset}`)}let O=new Map,A=null,q=null;if(X.stxOptions?.shell!==!1){if(q=await I6(W,X.stxOptions?.shell),q){if(A=await s$(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}`)}}z6(),await H6(W);let M=j6();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-macr4195.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 b=Object.keys(V).length;if(b>0)console.log(`${B.blue}Loaded ${B.bright}${b} API route${b>1?"s":""}${B.reset}`)}if(T?.broadcasting?.enabled)try{let{startBroadcasting:b,loadChannels:S}=await import("./chunk-nenge2m2.js"),y=T.broadcasting;await b(y);let G0=y.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${G0}/ws${B.reset}`);let Y0=g.join(process.cwd(),"channels.ts");if(X0.existsSync(Y0))try{let T0=await S(Y0);console.log(`${B.blue}Loaded ${B.bright}${T0} broadcast channel${T0!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(T0){console.warn(`${B.yellow}Failed to load channels.ts: ${T0.message}${B.reset}`)}}catch(b){console.warn(`${B.yellow}Broadcasting failed to start: ${b.message}${B.reset}`)}}catch{}let E=S0(W,"output");X0.mkdirSync(E,{recursive:!0});let w=new Map,C=new Set,R=async(D)=>{let T=L6(F,D);if(!T)return null;try{let b=await Bun.build({entrypoints:[T],outdir:E,plugins:[e0],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!b.success)return null;let S=b.outputs.find((y)=>y.path.endsWith(".html"));if(!S)return null;return await Bun.file(S.path).text()}catch{return null}},I=async(D,T)=>{try{let{processDirectives:b,extractVariables:S,defaultConfig:y,loadStxConfig:G0,injectRouterScript:Y0}=await import("./chunk-macr4195.js"),{checkCache:T0,cacheTemplate:S$,readFileCached:r,templateCache:S1}=await import("./chunk-n4v5733m.js"),P1=await G0(W),x=(u)=>{if(!u)return u;if(g.isAbsolute(u))return u;return g.resolve(W,u)},v={...y,...P1,...X.stxOptions,autoShell:!0};if(X.debugDirectives)v.debug=!0;v.partialsDir=x(v.partialsDir),v.componentsDir=x(v.componentsDir),v.layoutsDir=x(v.layoutsDir),v.storesDir=x(v.storesDir||"stores"),v.cachePath=x(v.cachePath)??S0(W,"cache");let p=!T&&!X.profile,d=v.cache!==!1;if(d&&p){let u=S1.get(D.filePath);if(u)try{if((await X0.promises.stat(D.filePath)).mtime.getTime()<=u.mtime){let C0=!0;for(let n of u.dependencies){if(!X0.existsSync(n)){C0=!1;break}if((await X0.promises.stat(n)).mtime.getTime()>u.mtime){C0=!1;break}}if(C0){let n=u.output;if(A)n=J$(n,{preserveHead:!0});return{route:D,content:n,status:await B6(D.filePath)}}}}catch{}let _0=await T0(D.filePath,v);if(_0){let U0=_0;if(A)U0=J$(U0,{preserveHead:!0});return{route:D,content:U0,status:await B6(D.filePath)}}}let k=d?await r(D.filePath):await Bun.file(D.filePath).text(),W0=v$(k),{classifyAllScripts:j0}=await import("./chunk-macr4195.js"),l=j0(k),J0=l.server.map((u)=>u.content),H0=k;for(let u of l.server)H0=H0.replace(u.fullTag,"");let K0={__filename:D.filePath,__dirname:g.dirname(D.filePath),params:T??{},__stx_runtime_head:{}};for(let u of J0)try{await S(u,K0,D.filePath)}catch(_0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",D.filePath,_0?.message||_0)}let P$=new Set,O0;if(X.profile){let u=performance.now();O0=await b(H0,K0,D.filePath,v,P$);let _0=performance.now()-u,U0=g.relative(W,D.filePath)||D.filePath;console.log(`[stx:profile] ${U0} \u2192 ${_0.toFixed(2)}ms`)}else O0=await b(H0,K0,D.filePath,v,P$);if(!A)O0=await Y0(O0,{router:v.router});{let{interpolateScriptExpressions:u}=await import("./chunk-gfgpf7h8.js");O0=O0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(_0,U0,C0)=>{if(!/function\s+__stx_setup_/.test(C0))return _0;return`<script${U0}>${u(C0,K0)}</script>`})}if(A)O0=J$(O0,{preserveHead:!0});if(d&&p)await S$(D.filePath,O0,P$,v);let{extractStreamBoundaries:p7}=await import("./chunk-a438xffx.js"),a0=p7(K0),B1=K0.__streamTemplates;if(B1&&typeof B1==="object"&&Object.keys(B1).length>0){let u=K0.streamBoundaries||{},_0={...v,autoShell:!1},U0=Object.keys(B1).map((n)=>({id:n,render:async()=>{let P5=typeof u[n]==="function"?await u[n]():void 0;return b(B1[n],{...K0,$boundary:P5},D.filePath,_0,new Set)}})),C0=new Set(U0.map((n)=>n.id));a0=[...(a0||[]).filter((n)=>!C0.has(n.id)),...U0]}if(a0&&a0.length>0)C.add(D.pattern);else a0=void 0;return{route:D,content:O0,status:W0,boundaries:a0}}catch(b){return console.error(`${B.red}Error building ${B.bright}${D.pattern}${B.reset}:`,b),null}},m=8,h=async()=>{w.clear(),O.clear();for(let D=0;D<H.length;D+=m){let T=H.slice(D,D+m),b=await Promise.all(T.map((S)=>I(S)));for(let S of b)if(S)w.set(S.route.pattern,S)}for(let D=0;D<L.length;D+=m){let T=L.slice(D,D+m),b=await Promise.all(T.map(({route:S})=>I(S)));for(let S of b)if(S)O.set(S.route.pattern,S)}return w.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await h())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await X$(W);let R0=Q;try{if(R0=await x0(Q),R0!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${R0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let D=X.hmrPort||R0+1;J=s1({wsPort:D,verbose:!1}),G=J.start(D)}let d0=(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 k1=U4({port:R0,async fetch(D){let T=new URL(D.url),b=_?.publicDir||"public",S=g.join(W,b,T.pathname),y=g.join(W,T.pathname),G0=g.join(E,T.pathname),[Y0,T0,S$]=await Promise.all([X0.promises.stat(S).catch(()=>null),X0.promises.stat(y).catch(()=>null),X0.promises.stat(G0).catch(()=>null)]);if(Y0?.isFile())return i$(S);if(T0?.isFile())return i$(y);if(S$?.isFile())return i$(G0);if(T.pathname.startsWith("/_stx/component/")){let x=decodeURIComponent(T.pathname.slice(16));if(x)try{let v=`<${x} />`,p={...buildConfig,autoShell:!1},d=await processDirectives(v,{},g.join(W,"components",`${x}.stx`),p,new Set);return new Response(d,{headers:{"Content-Type":"text/html"}})}catch(v){return new Response(`<div class="stx-async-error">${v.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(T.pathname==="/_stx/img"){let{handleImageRequest:x}=await import("./chunk-xz019t7t.js"),v=await x(D,{publicDir:g.join(W,b),cacheDir:S0(W,"cache","img")});if(v)return v}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=a$(T.pathname,H);if(r){let x=w.get(r.route.pattern),v=C.has(r.route.pattern);if(r.route.isDynamic&&Object.keys(r.params).length>0||v){let p=await I(r.route,r.params);if(p)x=p}if(x){let p=x.status??200,d=(r.route.filePath?M6(await Bun.file(r.route.filePath).text().catch(()=>"")):null)??{};if(d.validate){if(!await d.validate({params:r.params})){let j0=await R(404);if(j0){let l=j0;if(l=await s(l,W),Y)l=I0(l,G);return new Response(l,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(d.middleware){let W0=O6(T.pathname,r.params,d,T.search),j0=A6(W0,null,D,{isServer:!0}),l=await q6(d.middleware,j0);if(l.redirect){let J0=l.redirect.path,H0=l.redirect.options.redirectCode||302,K0=new Headers(l.responseHeaders);return K0.set("Location",J0),new Response(null,{status:H0,headers:K0})}if(l.abort){let{statusCode:J0,message:H0}=l.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${J0}</title></head><body><h1>Error ${J0}</h1><p>${H0}</p></body></html>`,{status:J0,headers:{"Content-Type":"text/html"}})}if(Object.keys(l.state).length>0){let J0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(l.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;x.content=x.content.replace("</head>",`${J0}</head>`)}}let k=x.content;if(A&&D6(D)){let W0=N6(k),j0=R6(k),l=k.match(/<title[^>]*>([\s\S]*?)<\/title>/i),J0=l?l[1].trim():"";if(Object.keys(r.params).length>0)k=d0(k,r.params);k=await s(k,W);let H0=_?.router?.container||"main";return k=w6(k,H0),new Response(k,{status:p,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":W0.layout,"X-STX-Layout-Group":W0.group,"X-STX-Runtime":j0?"true":"false",...J0&&{"X-STX-Title":encodeURIComponent(J0)},[V6]:E6(),"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(A)k=Y$(A,k);if(Object.keys(r.params).length>0)k=d0(k,r.params);if(k=await s(k,W),Y)k=I0(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;if(X.titlebarHidden)if(k.includes("<head>"))k=k.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 k=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${k}`;if(x.boundaries&&x.boundaries.length>0){let{renderStreamingPage:W0,streamToResponse:j0}=await import("./chunk-a438xffx.js");return j0(W0(k,x.boundaries,{timeoutMs:30000}),{status:p,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(k,{status:p,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(L.length>0){let x=L.map((p)=>p.route),v=a$(T.pathname,x);if(v){let p=O.get(v.route.pattern);if(p){let d=p.content;if(A)d=Y$(A,d);if(Object.keys(v.params).length>0)d=d0(d,v.params);if(d=await s(d,W),Y)d=I0(d,G);return new Response(d,{status:p.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:p}of j)if(p!=="/"&&T.pathname.startsWith(p)){let d=O.get(p)||O.get(p+"/");if(d){let k=d.content;if(A)k=Y$(A,k);if(k=await s(k,W),Y)k=I0(k,G);return new Response(k,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let S1=w.get("/");if(S1){let x=S1.content;if(x=await s(x,W),Y)x=I0(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 P1=await R(404);if(P1){let x=P1;if(x=await s(x,W),Y)x=I0(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 R(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:${R0}/${B.reset}`),Y)console.log(`${B.dim} HMR: ws://localhost:${G}${B.reset}`);console.log(`
1614
- ${B.yellow}Routes:${B.reset}`);let Z0=[...F6(O,W)];for(let{route:D}of L)Z0.push(`${D.pattern}`);if(Z0.forEach((D,T)=>{let S=T===Z0.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(k1.url.toString(),()=>{if(J)j1();k1.stop()}),X.native){let D,T=g.join(F,"index.stx");if(X0.existsSync(T)){let S=await Bun.file(T).text();D=l1(S)}let b=_?.app?.window??{};await n0(R0,{title:_?.app?.head?.title||g.basename(W)||"stx App",width:b.width,height:b.height,darkMode:b.darkMode,hotReload:b.hotReload,titlebarHidden:b.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 y=S.toLowerCase();return y.endsWith(".stx")||y.endsWith(".html")||y.endsWith(".md")},b=X0.watch(W,{recursive:!0},async(S,y)=>{if(!y||r1(y))return;if(a1(y))if(D(y)){if(console.log(`${B.cyan}${y} changed${B.reset}`),Y&&J)J.reload(y)}else if(T(y)){console.log(`${B.yellow}${y} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:G0,templateCache:Y0}=await import("./chunk-5xd7vge2.js");G0(g.resolve(W,y)),Y0.delete(g.resolve(W,y))}catch{}if(q&&y){if(g.resolve(W,y)===q||g.basename(q)===y){let Y0=await s$(q,X.stxOptions||{});if(Y0)A=Y0}}if(await h(),await Q$(W),Y&&J)J.reload(y)}else{console.log(`${B.yellow}${y} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:G0,templateCache:Y0}=await import("./chunk-5xd7vge2.js");G0(g.resolve(W,y)),Y0.delete(g.resolve(W,y))}catch{}if(await h(),Y&&J)J.reload(y)}else if(i1(y)){if(console.log(`${B.cyan}CSS ${y} changed${B.reset}`),Y&&J)J.updateCss(y)}});process.on("SIGINT",()=>{if(b.close(),J)j1();k1.stop(),process.exit(0)})}return!0}var B4=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function L4($){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 F4($,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 RW($,X="main"){let Q=L4(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("/")||B4.has(J))continue;if(Q.tag&&Q.tag!==J)continue;if(!F4(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 z4($={}){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)=>o$(X),selectStore:(X)=>O4(X),inspectElement:(X)=>H4(X),highlightComponent:(X)=>S6(X),clearHighlight:()=>P6(),logComponentTree:()=>A4(),logStoreState:(X)=>q4(X),timeTravel:(X,Q)=>N4(X,Q)},V4(),M4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function j4(){P.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function T6($){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($),n$({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function x6($,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),n$({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function k6($,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};n$({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Q,newValue:Z}})}}function n$($){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 o$($){P.selectedComponent=$;let X=P.components.get($);if(X)S6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function O4($){P.selectedStore=$;let X=P.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function H4($){let X=$;while(X){let Q=X.getAttribute("data-stx-component-id");if(Q)return o$(Q);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function S6($){P6();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 Z0=[...F6(H,W)];for(let{route:D}of L)Z0.push(`${D.pattern}`);if(Z0.forEach((D,T)=>{let S=T===Z0.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(k1.url.toString(),()=>{if(J)j1();k1.stop()}),X.native){let D,T=g.join(F,"index.stx");if(X0.existsSync(T)){let S=await Bun.file(T).text();D=l1(S)}let b=_?.app?.window??{};await n0(R0,{title:_?.app?.head?.title||g.basename(W)||"stx App",width:b.width,height:b.height,darkMode:b.darkMode,hotReload:b.hotReload,titlebarHidden:b.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 y=S.toLowerCase();return y.endsWith(".stx")||y.endsWith(".html")||y.endsWith(".md")},b=X0.watch(W,{recursive:!0},async(S,y)=>{if(!y||r1(y))return;if(a1(y))if(D(y)){if(console.log(`${B.cyan}${y} changed${B.reset}`),Y&&J)J.reload(y)}else if(T(y)){console.log(`${B.yellow}${y} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:G0,templateCache:Y0}=await import("./chunk-n4v5733m.js");G0(g.resolve(W,y)),Y0.delete(g.resolve(W,y))}catch{}if(q&&y){if(g.resolve(W,y)===q||g.basename(q)===y){let Y0=await s$(q,X.stxOptions||{});if(Y0)A=Y0}}if(await h(),await Q$(W),Y&&J)J.reload(y)}else{console.log(`${B.yellow}${y} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:G0,templateCache:Y0}=await import("./chunk-n4v5733m.js");G0(g.resolve(W,y)),Y0.delete(g.resolve(W,y))}catch{}if(await h(),Y&&J)J.reload(y)}else if(i1(y)){if(console.log(`${B.cyan}CSS ${y} changed${B.reset}`),Y&&J)J.updateCss(y)}});process.on("SIGINT",()=>{if(b.close(),J)j1();k1.stop(),process.exit(0)})}return!0}var L4=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function F4($){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 z4($,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 IW($,X="main"){let Q=F4(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("/")||L4.has(J))continue;if(Q.tag&&Q.tag!==J)continue;if(!z4(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 j4($={}){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)=>o$(X),selectStore:(X)=>O4(X),inspectElement:(X)=>A4(X),highlightComponent:(X)=>S6(X),clearHighlight:()=>P6(),logComponentTree:()=>q4(),logStoreState:(X)=>N4(X),timeTravel:(X,Q)=>M4(X,Q)},E4(),V4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function H4(){P.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function T6($){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($),n$({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function x6($,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),n$({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function k6($,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};n$({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Q,newValue:Z}})}}function n$($){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 o$($){P.selectedComponent=$;let X=P.components.get($);if(X)S6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function O4($){P.selectedStore=$;let X=P.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function A4($){let X=$;while(X){let Q=X.getAttribute("data-stx-component-id");if(Q)return o$(Q);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function S6($){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(k1.
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 P6(){let $=document.getElementById("stx-devtools-highlight");if($)$.remove()}function A4(){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 q4($){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 N4($,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 M4(){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)T6(Y);Z.querySelectorAll("[data-stx-component-id]").forEach((J)=>{let G=J.getAttribute("data-stx-component-id");if(G)T6(G)})}})}).observe(document.body,{childList:!0,subtree:!0})}function V4(){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 q4(){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 N4($){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 M4($,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 V4(){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)T6(Y);Z.querySelectorAll("[data-stx-component-id]").forEach((J)=>{let G=J.getAttribute("data-stx-component-id");if(G)T6(G)})}})}).observe(document.body,{childList:!0,subtree:!0})}function E4(){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(k1.
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"),C6(Y.getAttribute("data-tab")||"components")})}),setInterval(()=>{let Y=$.querySelector(".stx-devtools-tab.active");if(Y&&$.classList.contains("open"))C6(Y.getAttribute("data-tab")||"components")},1000)}function C6($){let X=document.getElementById("stx-devtools-content");if(!X)return;switch($){case"components":X.innerHTML=E4();break;case"stores":X.innerHTML=R4();break;case"events":X.innerHTML=I4();break}X.querySelectorAll(".stx-devtools-component").forEach((Q)=>{Q.addEventListener("click",()=>{let Z=Q.getAttribute("data-id");if(Z)o$(Z)})})}function E4(){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"),C6(Y.getAttribute("data-tab")||"components")})}),setInterval(()=>{let Y=$.querySelector(".stx-devtools-tab.active");if(Y&&$.classList.contains("open"))C6(Y.getAttribute("data-tab")||"components")},1000)}function C6($){let X=document.getElementById("stx-devtools-content");if(!X)return;switch($){case"components":X.innerHTML=R4();break;case"stores":X.innerHTML=I4();break;case"events":X.innerHTML=D4();break}X.querySelectorAll(".stx-devtools-component").forEach((Q)=>{Q.addEventListener("click",()=>{let Z=Q.getAttribute("data-id");if(Z)o$(Z)})})}function R4(){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(k1.
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 R4(){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 I4(){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 I4(){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 D4(){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 t$ from"fs";import H1 from"path";async function D4($){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 w4($){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 T4($,X=!1,Q){let Z=H1.basename($,".stx"),Y=await D4($),J=await w4($),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 t$ from"fs";import O1 from"path";async function w4($){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 H=W.split(`
1763
+ `).map((j)=>j.trim().replace(/^\*\s*/,"")).filter((j)=>!j.startsWith("@")&&j.length>0);_.description=H.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 T4($){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 C4($,X=!1,Q){let Z=O1.basename($,".stx"),Y=await w4($),J=await T4($),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 b6($){try{if(!await A1($))return console.warn(`Components directory does not exist: ${$}`),[];let X=await t$.promises.readdir($,{withFileTypes:!0}),Q=[];for(let Z of X){let Y=H1.join($,Z.name);if(Z.isDirectory()){let J=await b6(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 C4($,X){try{if(!await A1($))return[];let Q=await b6($),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 T4(J,W,K);Z.push(_)}return Z}catch(Q){return console.error("Error generating component docs:",Q),[]}}async function x4($){try{if(!await A1($))return[];let X=await t$.promises.readdir($,{withFileTypes:!0}),Q=[];for(let Z of X){if(!Z.isFile()||!Z.name.endsWith(".stx"))continue;let Y=H1.join($,Z.name),J=await Bun.file(Y).text(),G=H1.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 k4($=[]){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 b6($){try{if(!await A1($))return console.warn(`Components directory does not exist: ${$}`),[];let X=await t$.promises.readdir($,{withFileTypes:!0}),Q=[];for(let Z of X){let Y=O1.join($,Z.name);if(Z.isDirectory()){let J=await b6(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 x4($,X){try{if(!await A1($))return[];let Q=await b6($),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 C4(J,W,K);Z.push(_)}return Z}catch(Q){return console.error("Error generating component docs:",Q),[]}}async function k4($){try{if(!await A1($))return[];let X=await t$.promises.readdir($,{withFileTypes:!0}),Q=[];for(let Z of X){if(!Z.isFile()||!Z.name.endsWith(".stx"))continue;let Y=O1.join($,Z.name),J=await Bun.file(Y).text(),G=O1.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 H=/@([a-z]+)(?:\s*\(|\s+|$)/g,j=new Set;while((F=H.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 S4($=[]){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(k1.
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 S4($=[],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 P4($=[],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(k1.
1827
1827
 
1828
1828
  `,Y+=`#### Example
1829
1829
 
1830
- `,Y+="```html\n",Y+=J.example,Y+="\n```\n\n"}return Y}function P4($=[],X=[],Q=[],Z){let Y=`<!DOCTYPE html>
1830
+ `,Y+="```html\n",Y+=J.example,Y+="\n```\n\n"}return Y}function b4($=[],X=[],Q=[],Z){let Y=`<!DOCTYPE html>
1831
1831
  <html lang="en">
1832
1832
  <head>
1833
1833
  <meta charset="UTF-8">
@@ -1898,15 +1898,15 @@ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(k1.
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 b4($=[],X=[],Q=[],Z){return JSON.stringify({components:$,templates:X,directives:Q,extraContent:Z||""},null,2)}async function y4($){try{let{componentsDir:X,templatesDir:Q,webComponentsConfig:Z,customDirectives:Y,config:J}=$;if(!J.enabled)return!1;let G=J.outputDir||"docs";if(await t$.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 C4(X,Z),console.log(`Found ${W.length} components`);let K=[];if(J.templates!==!1&&Q)console.log("Generating template documentation..."),K=await x4(Q),console.log(`Found ${K.length} templates`);let _=[];if(J.directives!==!1)console.log("Generating directive documentation..."),_=await k4(Y),console.log(`Found ${_.length} directives`);let U=J.format||"markdown",z=J.extraContent,F="",O="";switch(U){case"markdown":F=S4(W,K,_,z),O="md";break;case"html":F=P4(W,K,_,z),O="html";break;case"json":F=b4(W,K,_,z),O="json";break;default:throw Error(`Unsupported documentation format: ${U}`)}let j=H1.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 kW($){let X={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Q=$.componentsDir||A0.componentsDir,Z=$.templatesDir||".";return y4({componentsDir:Q,templatesDir:Z,webComponentsConfig:A0.webComponents,customDirectives:A0.customDirectives,config:X})}import X1 from"process";function q1(){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(X1.versions?.node)return{platform:"node",version:X1.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 yW(){let $=q1();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function vW(){return q1().platform!=="unknown"}function v4($){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(X1.env)return X1.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(X1.env){for(let[Q,Z]of Object.entries(X1.env))if(Z!==void 0)X[Q]=Z}return X}}}function g4($){let X=q1();if(X.platform==="cloudflare"&&$)return $;if(X.platform==="deno"&&"Deno"in globalThis)return f4();if(X.platform==="node"||X.platform==="bun")return h4();return}function f4(){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 h4(){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 d4(){let $=q1();if($.platform==="cloudflare"&&"caches"in globalThis)return u4();if($.supportsStreaming)return m4();return}function u4(){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 m4(){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 p4(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function c4($,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 e$($,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 G$($){let X=q1();return async(Q,Z)=>{let Y=performance.now(),J=p4(),G={runtime:X,platform:Z||{},requestId:J,geo:c4(Q,X),timing:{start:Y,getElapsed:()=>performance.now()-Y},kv:g4(Z?.KV),cache:d4(),env:v4(Z?.env)};try{if(Q.method==="OPTIONS"&&$.cors){let K=new Response(null,{status:204});return K=e$(K,$.cors,Q.headers.get("Origin")||void 0),K}if($.cache?.enabled&&Q.method==="GET"&&G.cache){if(y6(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?e$(U,$.cors,Q.headers.get("Origin")||void 0):U}}}let W;if($.middleware&&$.middleware.length>0)W=await l4(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(y6(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=e$(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 y6($,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 l4($,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 gW($,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 fW(){let $=new TextEncoder;return new TransformStream({transform(X,Q){Q.enqueue($.encode(X))}})}function hW($){let X=new TextEncoder;return new ReadableStream({async start(Q){for await(let Z of $)Q.enqueue(X.encode(Z));Q.close()}})}function dW($){let X=G$($);return{async fetch(Q,Z,Y){return X(Q,{env:Z,ctx:Y,KV:Z.KV})}}}function uW($){let X=G$($);return(Q)=>X(Q,{})}function mW($){let X=G$($);return(Q)=>X(Q,{})}function pW($){let X=G$($);return(Q,Z)=>{return X(Q,{netlifyContext:Z})}}function cW($){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 lW($,X,Q){return $5($,X,Q)}function iW($,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 aW($,X=302){return new Response(null,{status:X,headers:{Location:$}})}function rW($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var g6={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function i4($,X={}){let Q={...g6,...X};if($.trim()==="")return`
1902
- `;let Z=$;if(Q.trimTrailingWhitespace)Z=Z.replace(/[ \t]+$/gm,"");if(Z=r4(Z,Q),Z=t4(Z,Q),Z=s4(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 y4($=[],X=[],Q=[],Z){return JSON.stringify({components:$,templates:X,directives:Q,extraContent:Z||""},null,2)}async function v4($){try{let{componentsDir:X,templatesDir:Q,webComponentsConfig:Z,customDirectives:Y,config:J}=$;if(!J.enabled)return!1;let G=J.outputDir||"docs";if(await t$.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 x4(X,Z),console.log(`Found ${W.length} components`);let K=[];if(J.templates!==!1&&Q)console.log("Generating template documentation..."),K=await k4(Q),console.log(`Found ${K.length} templates`);let _=[];if(J.directives!==!1)console.log("Generating directive documentation..."),_=await S4(Y),console.log(`Found ${_.length} directives`);let U=J.format||"markdown",z=J.extraContent,F="",H="";switch(U){case"markdown":F=P4(W,K,_,z),H="md";break;case"html":F=b4(W,K,_,z),H="html";break;case"json":F=y4(W,K,_,z),H="json";break;default:throw Error(`Unsupported documentation format: ${U}`)}let j=O1.join(G,`stx-docs.${H}`);return await Bun.write(j,F),console.log(`Documentation generated: ${j}`),!0}catch(X){return console.error("Error generating documentation:",X),!1}}async function SW($){let X={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Q=$.componentsDir||A0.componentsDir,Z=$.templatesDir||".";return v4({componentsDir:Q,templatesDir:Z,webComponentsConfig:A0.webComponents,customDirectives:A0.customDirectives,config:X})}import X1 from"process";function q1(){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(X1.versions?.node)return{platform:"node",version:X1.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 vW(){let $=q1();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function gW(){return q1().platform!=="unknown"}function g4($){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(X1.env)return X1.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(X1.env){for(let[Q,Z]of Object.entries(X1.env))if(Z!==void 0)X[Q]=Z}return X}}}function f4($){let X=q1();if(X.platform==="cloudflare"&&$)return $;if(X.platform==="deno"&&"Deno"in globalThis)return h4();if(X.platform==="node"||X.platform==="bun")return d4();return}function h4(){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 d4(){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 u4(){let $=q1();if($.platform==="cloudflare"&&"caches"in globalThis)return m4();if($.supportsStreaming)return p4();return}function m4(){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 p4(){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 c4(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function l4($,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 e$($,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 G$($){let X=q1();return async(Q,Z)=>{let Y=performance.now(),J=c4(),G={runtime:X,platform:Z||{},requestId:J,geo:l4(Q,X),timing:{start:Y,getElapsed:()=>performance.now()-Y},kv:f4(Z?.KV),cache:u4(),env:g4(Z?.env)};try{if(Q.method==="OPTIONS"&&$.cors){let K=new Response(null,{status:204});return K=e$(K,$.cors,Q.headers.get("Origin")||void 0),K}if($.cache?.enabled&&Q.method==="GET"&&G.cache){if(y6(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?e$(U,$.cors,Q.headers.get("Origin")||void 0):U}}}let W;if($.middleware&&$.middleware.length>0)W=await i4(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(y6(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=e$(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 y6($,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 i4($,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 fW($,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 hW(){let $=new TextEncoder;return new TransformStream({transform(X,Q){Q.enqueue($.encode(X))}})}function dW($){let X=new TextEncoder;return new ReadableStream({async start(Q){for await(let Z of $)Q.enqueue(X.encode(Z));Q.close()}})}function uW($){let X=G$($);return{async fetch(Q,Z,Y){return X(Q,{env:Z,ctx:Y,KV:Z.KV})}}}function mW($){let X=G$($);return(Q)=>X(Q,{})}function pW($){let X=G$($);return(Q)=>X(Q,{})}function cW($){let X=G$($);return(Q,Z)=>{return X(Q,{netlifyContext:Z})}}function lW($){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 iW($,X,Q){return $5($,X,Q)}function aW($,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 rW($,X=302){return new Response(null,{status:X,headers:{Location:$}})}function sW($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var g6={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function a4($,X={}){let Q={...g6,...X};if($.trim()==="")return`
1902
+ `;let Z=$;if(Q.trimTrailingWhitespace)Z=Z.replace(/[ \t]+$/gm,"");if(Z=s4(Z,Q),Z=e4(Z,Q),Z=n4(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 nW($,X={}){let Q={...g6,...X};if($.trim()==="")return`
1906
+ `;return Z}function oW($,X={}){let Q={...g6,...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
- `),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=i4(F,Q).trimEnd().split(`
1908
+ `),U=_.filter((L)=>L.trim().length>0);if(U.length===0)return Y;let z=Math.min(...U.map((L)=>{let O=L.match(/^( *)/);return O?O[1].length:0})),F=_.map((L)=>{if(L.trim().length===0)return"";return L.substring(z)}).join(`
1909
+ `),j=a4(F,Q).trimEnd().split(`
1910
1910
  `).map((L)=>{if(L.trim().length===0)return"";return J+L}).join(`
1911
1911
  `);return`${J}\`\`\`${G}
1912
1912
  ${j}
@@ -1914,7 +1914,7 @@ ${J}\`\`\``}),Q.trimTrailingWhitespace)Z=Z.replace(/[ \t]+$/gm,"");if(Z=Z.replac
1914
1914
  `).replace(/\r/g,`
1915
1915
  `),!Z.endsWith(`
1916
1916
  `))Z+=`
1917
- `;return Z}function a4($){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 r4($){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 r4($,X){let Z=a4($).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(v6(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("@")&&o4(U),A=U.startsWith("<!DOCTYPE")||U.startsWith("<!doctype"),q=U.startsWith("<!--"),M=U.startsWith("</"),V=U.startsWith("<")&&!M&&!q&&!A,N=U.includes("/>")||n4(U),E=v6(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&&!E&&!O||H)J++;if(z)G=!0;if(F)G=!1}return Y.join(`
1933
- `)}function s4($,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 n4($){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 v6($){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test($)}function o4($){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 t4($,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 f6 from"fs";import X5 from"path";var $2={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 X2($="index.stx",X={}){try{let Q=X.force||!1,Z=X5.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=X5.dirname(Z);if(!f6.existsSync(Y))f6.mkdirSync(Y,{recursive:!0});let J;if(X.template){let G=X5.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=h6(X.preset),console.warn(`Using '${X.preset}' preset template`);else J=h6("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 h6($){switch($){case"basic":return d6();case"component":return e4();case"layout":return $X();case"blog":return XX();case"api":return QX();case"app":return ZX();default:return d6()}}function d6(){return`<script>
1931
+ `),X=X.replace(/^\n+/,"").replace(/\n+$/,""),X}function s4($,X){let Z=r4($).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 H=U===">";if(v6(U)&&!U.startsWith("<")&&!U.startsWith("@")){Y.push(W.repeat(J)+U);continue}let j=U.startsWith("@end"),L=U.startsWith("@else")||U.startsWith("@elseif"),O=U.startsWith("@")&&t4(U),A=U.startsWith("<!DOCTYPE")||U.startsWith("<!doctype"),q=U.startsWith("<!--"),M=U.startsWith("</"),V=U.startsWith("<")&&!M&&!q&&!A,N=U.includes("/>")||o4(U),E=v6(U);if(M||j)J=Math.max(0,J-1);let w=L?Math.max(0,J-1):J;if(H)Y.push(_);else Y.push(W.repeat(w)+U);if(V&&!N&&!E&&!H||O)J++;if(z)G=!0;if(F)G=!1}return Y.join(`
1933
+ `)}function n4($,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 o4($){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 v6($){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test($)}function t4($){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 e4($,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 f6 from"fs";import X5 from"path";var X2={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 Q2($="index.stx",X={}){try{let Q=X.force||!1,Z=X5.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=X5.dirname(Z);if(!f6.existsSync(Y))f6.mkdirSync(Y,{recursive:!0});let J;if(X.template){let G=X5.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=h6(X.preset),console.warn(`Using '${X.preset}' preset template`);else J=h6("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 h6($){switch($){case"basic":return d6();case"component":return $X();case"layout":return XX();case"blog":return QX();case"api":return ZX();case"app":return YX();default:return d6()}}function d6(){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 e4(){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 XX(){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 XX(){return`<script>
2055
+ </html>`}function QX(){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 QX(){return`<script>
2100
+ @endsection`}function ZX(){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 ZX(){return`<!DOCTYPE html>
2135
+ @endif`}function YX(){return`<!DOCTYPE html>
2136
2136
  <html lang="en">
2137
2137
  <head>
2138
2138
  <meta charset="UTF-8">
@@ -2357,7 +2357,7 @@ const features = [
2357
2357
  })();
2358
2358
  </script>
2359
2359
  </body>
2360
- </html>`}import{createHash as YX}from"crypto";import{existsSync as N1,mkdirSync as JX,readFileSync as Q5,writeFileSync as GX,readdirSync as WX,statSync as KX}from"fs";import{basename as M1,dirname as D0,extname as V1,join as N0,relative as u6}from"path";import{gzipSync as _X}from"zlib";var m6={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 Z5{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...m6,...$}}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=M1(Q,V1(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=V1(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=N0(this.config.outDir,W);this.ensureDir(D0(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 N0(D0($),"..",X);return N0(D0($),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(N1(_)){let U=Q5(_,"utf-8");Z.push(`// Source: ${K[1]}
2360
+ </html>`}import{createHash as JX}from"crypto";import{existsSync as N1,mkdirSync as GX,readFileSync as Q5,writeFileSync as WX,readdirSync as KX,statSync as _X}from"fs";import{basename as M1,dirname as D0,extname as V1,join as N0,relative as u6}from"path";import{gzipSync as UX}from"zlib";var m6={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 Z5{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...m6,...$}}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=M1(Q,V1(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=V1(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=N0(this.config.outDir,W);this.ensureDir(D0(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 N0(D0($),"..",X);return N0(D0($),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(N1(_)){let U=Q5(_,"utf-8");Z.push(`// Source: ${K[1]}
2361
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(N1(_)){let U=Q5(_,"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
 
@@ -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=N0(this.config.outDir,W);this.ensureDir(D0(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=N0(this.config.outDir,Z);this.ensureDir(D0(Y)),await Bun.write(Y,X),this.outputs.push({path:Y,type:"css",size:Buffer.byteLength(X),hash:Q})}async processAssets(){let $=N0(D0(this.config.outDir),"public");if(!N1($))return;let X=this.config.assets||{},Q=X.include||[];this.walkDir($,(Z)=>{let Y=V1(Z).slice(1).toLowerCase();if(!Q.includes(Y))return;let J=Q5(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]",M1(Z,V1(Z))).replace("[hash]",W).replace("[ext]",V1(Z)),_=N0(this.config.outDir,K);this.ensureDir(D0(_)),GX(_,J),this.assetHashes.set(Z,K),this.assets.push({name:M1(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:M1($.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")}`:M1(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:KX(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=u6(D0($.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=_X(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:u6(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=N0(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=N0(this.config.outDir,Z);this.ensureDir(D0(Y)),await Bun.write(Y,X),this.outputs.push({path:Y,type:"css",size:Buffer.byteLength(X),hash:Q})}async processAssets(){let $=N0(D0(this.config.outDir),"public");if(!N1($))return;let X=this.config.assets||{},Q=X.include||[];this.walkDir($,(Z)=>{let Y=V1(Z).slice(1).toLowerCase();if(!Q.includes(Y))return;let J=Q5(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]",M1(Z,V1(Z))).replace("[hash]",W).replace("[ext]",V1(Z)),_=N0(this.config.outDir,K);this.ensureDir(D0(_)),WX(_,J),this.assetHashes.set(Z,K),this.assets.push({name:M1(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:M1($.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")}`:M1(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:_X(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=u6(D0($.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=UX(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:u6(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=N0(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,14 +2407,14 @@ ${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 YX("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(!N1($))JX($,{recursive:!0})}walkDir($,X){if(!N1($))return;let Q=WX($,{withFileTypes:!0});for(let Z of Q){let Y=N0($,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 K2($){return new Z5($).build()}function _2($){return new Z5($)}function U2($){return{...m6,...$}}var L2="f9c3713";import{existsSync as E1,mkdirSync as Y5}from"fs";import{join as b0,dirname as UX}from"path";import{execSync as p6}from"child_process";var A2={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 q2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.template||"default",Y=b0(process.cwd(),$);if(E1(Y))return Q.success=!1,Q.message=`Directory ${$} already exists`,Q;try{Y5(Y,{recursive:!0});let J=BX(Z);for(let W of J)Y5(b0(Y,W),{recursive:!0});let G=LX(Z,$,X);for(let[W,K]of Object.entries(G)){let _=b0(Y,W);R1(UX(_)),await Bun.write(_,K),Q.files.push(W)}if(!X.skipGit)try{p6("git init",{cwd:Y,stdio:"ignore"}),await Bun.write(b0(Y,".gitignore"),MX()),Q.files.push(".gitignore")}catch{Q.errors.push("Failed to initialize git repository")}if(!X.skipInstall){let W=X.packageManager||mX();try{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 JX("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(!N1($))GX($,{recursive:!0})}walkDir($,X){if(!N1($))return;let Q=KX($,{withFileTypes:!0});for(let Z of Q){let Y=N0($,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 _2($){return new Z5($).build()}function U2($){return new Z5($)}function B2($){return{...m6,...$}}var F2="f9c3713";import{existsSync as E1,mkdirSync as Y5}from"fs";import{join as b0,dirname as BX}from"path";import{execSync as p6}from"child_process";var q2={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 N2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.template||"default",Y=b0(process.cwd(),$);if(E1(Y))return Q.success=!1,Q.message=`Directory ${$} already exists`,Q;try{Y5(Y,{recursive:!0});let J=LX(Z);for(let W of J)Y5(b0(Y,W),{recursive:!0});let G=FX(Z,$,X);for(let[W,K]of Object.entries(G)){let _=b0(Y,W);R1(BX(_)),await Bun.write(_,K),Q.files.push(W)}if(!X.skipGit)try{p6("git init",{cwd:Y,stdio:"ignore"}),await Bun.write(b0(Y,".gitignore"),VX()),Q.files.push(".gitignore")}catch{Q.errors.push("Failed to initialize git repository")}if(!X.skipInstall){let W=X.packageManager||pX();try{console.log(`
2411
2411
  Installing dependencies with ${W}...`),p6(`${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 BX($){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 LX($,X,Q){let Z={};if(Z["package.json"]=HX(X,$,Q),Z["stx.config.ts"]=AX($,Q),Z["README.md"]=NX(X,$),Q.typescript!==!1)Z["tsconfig.json"]=qX();switch($){case"minimal":Z["src/index.stx"]=VX();break;case"blog":Z["pages/index.stx"]=DX(),Z["pages/[slug].stx"]=wX(),Z["layouts/app.stx"]=TX(),Z["components/PostCard.stx"]=CX();break;case"dashboard":Z["pages/index.stx"]=xX(),Z["pages/settings.stx"]=kX(),Z["layouts/app.stx"]=SX(),Z["components/Sidebar.stx"]=PX(),Z["components/StatsCard.stx"]=bX(),Z["src/stores/dashboard.ts"]=yX();break;case"landing":Z["pages/index.stx"]=vX(),Z["layouts/app.stx"]=gX(),Z["src/sections/Hero.stx"]=fX(),Z["src/sections/Features.stx"]=hX(),Z["src/sections/Pricing.stx"]=dX(),Z["components/Button.stx"]=uX();break;case"full":Z["pages/index.stx"]=c6(),Z["pages/about.stx"]=EX(),Z["layouts/app.stx"]=l6(),Z["components/Header.stx"]=i6(),Z["components/Footer.stx"]=a6(),Z["src/stores/app.ts"]=r6(),Z["src/i18n/en.json"]=RX("en"),Z["test/example.test.ts"]=IX();break;default:Z["pages/index.stx"]=c6(),Z["layouts/app.stx"]=l6(),Z["components/Header.stx"]=i6(),Z["components/Footer.stx"]=a6(),Z["src/stores/app.ts"]=r6()}return Z}async function N2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"components",Y=J5($),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{R1(Z);let G=FX(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 M2($,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{R1(Z);let G=zX(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 V2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"src/stores",Y=pX($),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{R1(Z);let G=jX(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 E2($,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{R1(Z);let G=OX(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 FX($,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 LX($){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 FX($,X,Q){let Z={};if(Z["package.json"]=AX(X,$,Q),Z["stx.config.ts"]=qX($,Q),Z["README.md"]=MX(X,$),Q.typescript!==!1)Z["tsconfig.json"]=NX();switch($){case"minimal":Z["src/index.stx"]=EX();break;case"blog":Z["pages/index.stx"]=wX(),Z["pages/[slug].stx"]=TX(),Z["layouts/app.stx"]=CX(),Z["components/PostCard.stx"]=xX();break;case"dashboard":Z["pages/index.stx"]=kX(),Z["pages/settings.stx"]=SX(),Z["layouts/app.stx"]=PX(),Z["components/Sidebar.stx"]=bX(),Z["components/StatsCard.stx"]=yX(),Z["src/stores/dashboard.ts"]=vX();break;case"landing":Z["pages/index.stx"]=gX(),Z["layouts/app.stx"]=fX(),Z["src/sections/Hero.stx"]=hX(),Z["src/sections/Features.stx"]=dX(),Z["src/sections/Pricing.stx"]=uX(),Z["components/Button.stx"]=mX();break;case"full":Z["pages/index.stx"]=c6(),Z["pages/about.stx"]=RX(),Z["layouts/app.stx"]=l6(),Z["components/Header.stx"]=i6(),Z["components/Footer.stx"]=a6(),Z["src/stores/app.ts"]=r6(),Z["src/i18n/en.json"]=IX("en"),Z["test/example.test.ts"]=DX();break;default:Z["pages/index.stx"]=c6(),Z["layouts/app.stx"]=l6(),Z["components/Header.stx"]=i6(),Z["components/Footer.stx"]=a6(),Z["src/stores/app.ts"]=r6()}return Z}async function M2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"components",Y=J5($),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{R1(Z);let G=zX(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 V2($,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{R1(Z);let G=jX(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 E2($,X={}){let Q={success:!0,message:"",files:[],errors:[]},Z=X.dir||"src/stores",Y=cX($),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{R1(Z);let G=HX(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 R2($,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{R1(Z);let G=OX(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 zX($,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'
@@ -2444,7 +2444,7 @@ const variant = props.variant || 'default'
2444
2444
  margin-top: 0.5rem;
2445
2445
  }
2446
2446
  </style>`);return Q.join(`
2447
- `)}function zX($,X){let Q=J5($.replace(/-/g," ")),Z=[];if(Z.push(`<script>
2447
+ `)}function jX($,X){let Q=J5($.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 jX($,X){let Q=`${$}Store`,Z=`${J5($)}State`,Y=`import { defineStore } from 'stx'
2460
+ `)}function HX($,X){let Q=`${$}Store`,Z=`${J5($)}State`,Y=`import { defineStore } from 'stx'
2461
2461
 
2462
2462
  interface ${Z} {
2463
2463
  // Add your state properties here
@@ -2552,7 +2552,7 @@ finally {
2552
2552
 
2553
2553
  `;return Q+=` @yield('scripts')
2554
2554
  </body>
2555
- </html>`,Q}function HX($,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 AX($,X){return`import { defineConfig } from 'stx'
2555
+ </html>`,Q}function AX($,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 qX($,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 qX(){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 NX($,X){return`# ${$}
2576
+ `}function NX(){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 MX($,X){return`# ${$}
2577
2577
 
2578
2578
  A stx project created with the \`${X}\` template.
2579
2579
 
@@ -2605,7 +2605,7 @@ src/
2605
2605
 
2606
2606
  - [stx Documentation](https://stx.dev/docs)
2607
2607
  - [stx GitHub](https://github.com/stacksjs/stx)
2608
- `}function MX(){return`# Dependencies
2608
+ `}function VX(){return`# Dependencies
2609
2609
  node_modules/
2610
2610
  .bun/
2611
2611
 
@@ -2630,7 +2630,7 @@ Thumbs.db
2630
2630
 
2631
2631
  # Logs
2632
2632
  *.log
2633
- `}function VX(){return`<!DOCTYPE html>
2633
+ `}function EX(){return`<!DOCTYPE html>
2634
2634
  <html lang="en">
2635
2635
  <head>
2636
2636
  <meta charset="UTF-8">
@@ -2675,7 +2675,7 @@ const features = [
2675
2675
  @endforeach
2676
2676
  </div>
2677
2677
  @endsection
2678
- `}function EX(){return`<script>
2678
+ `}function RX(){return`<script>
2679
2679
  const title = 'About'
2680
2680
  </script>
2681
2681
 
@@ -2763,14 +2763,14 @@ export const appStore = defineStore('app', {
2763
2763
  strategies: [{ key: 'app-preferences', storage: localStorage }],
2764
2764
  },
2765
2765
  })
2766
- `}function RX($){return JSON.stringify({common:{welcome:"Welcome",home:"Home",about:"About",contact:"Contact"},messages:{loading:"Loading...",error:"An error occurred"}},null,2)}function IX(){return`import { describe, expect, it } from 'bun:test'
2766
+ `}function IX($){return JSON.stringify({common:{welcome:"Welcome",home:"Home",about:"About",contact:"Contact"},messages:{loading:"Loading...",error:"An error occurred"}},null,2)}function DX(){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 DX(){return"<!-- Blog index -->"}function wX(){return"<!-- Blog post -->"}function TX(){return`<!DOCTYPE html>
2773
+ `}function wX(){return"<!-- Blog index -->"}function TX(){return"<!-- Blog post -->"}function CX(){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 CX(){return"<!-- Post card -->"}function xX(){return"<!-- Dashboard index -->"}function kX(){return"<!-- Settings -->"}function SX(){return`<!DOCTYPE html>
2813
+ </html>`}function xX(){return"<!-- Post card -->"}function kX(){return"<!-- Dashboard index -->"}function SX(){return"<!-- Settings -->"}function PX(){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 PX(){return"<!-- Sidebar -->"}function bX(){return"<!-- Stats card -->"}function yX(){return"// Dashboard store"}function vX(){return"<!-- Landing page -->"}function gX(){return`<!DOCTYPE html>
2849
+ </html>`}function bX(){return"<!-- Sidebar -->"}function yX(){return"<!-- Stats card -->"}function vX(){return"// Dashboard store"}function gX(){return"<!-- Landing page -->"}function fX(){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 fX(){return"<!-- Hero section -->"}function hX(){return"<!-- Features -->"}function dX(){return"<!-- Pricing -->"}function uX(){return"<!-- Button -->"}function R1($){if(!E1($))Y5($,{recursive:!0})}function mX(){if(E1("bun.lockb"))return"bun";if(E1("pnpm-lock.yaml"))return"pnpm";if(E1("yarn.lock"))return"yarn";return"bun"}function J5($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function pX($){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:cX}=globalThis.Bun;import I1 from"fs";import y0 from"path";function P2($,X=200,Q={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Q}})}async function lX($={}){let{port:X=3000,root:Q=".",stxOptions:Z={},watch:Y=!0,onRequest:J,routes:G={},middleware:W=[],on404:K,onError:_}=$,U=y0.resolve(Q),z=new Map;async function F(q){let M=I1.statSync(q),V=`${q}:${M.mtimeMs}`,N=z.get(V);if(N)return N.content;for(let D of z.keys())if(D.startsWith(`${q}:`)&&D!==V)z.delete(D);let E=await Bun.file(q).text(),w=E,C=o1(E);if(C)w=C.content.trim();let R=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],m=[],h;while((h=R.exec(E))!==null){let D=h[1],T=h[2],b=h[0];if(D.includes("server"))m.push(T);else I.push(b)}let E0=E.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],R0=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),d0={__filename:q,__dirname:y0.dirname(q)};for(let D of m)await B0(D,d0,q);let Z0=await L0(R0,d0,q,Z,new Set);if(E0.length>0){let D=E0.join(`
2884
+ </html>`}function hX(){return"<!-- Hero section -->"}function dX(){return"<!-- Features -->"}function uX(){return"<!-- Pricing -->"}function mX(){return"<!-- Button -->"}function R1($){if(!E1($))Y5($,{recursive:!0})}function pX(){if(E1("bun.lockb"))return"bun";if(E1("pnpm-lock.yaml"))return"pnpm";if(E1("yarn.lock"))return"yarn";return"bun"}function J5($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function cX($){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:lX}=globalThis.Bun;import I1 from"fs";import y0 from"path";function b2($,X=200,Q={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Q}})}async function s6($){let{loadStxConfig:X}=await import("./chunk-6v4ddvfk.js");return{...await X($.configDir??process.cwd()).catch(()=>({})),...$.stxOptions??{}}}async function iX($={}){let{port:X=3000,root:Q=".",watch:Z=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=y0.resolve(Q),U=await s6($),z=new Map;async function F(q){let M=I1.statSync(q),V=`${q}:${M.mtimeMs}`,N=z.get(V);if(N)return N.content;for(let D of z.keys())if(D.startsWith(`${q}:`)&&D!==V)z.delete(D);let E=await Bun.file(q).text(),w=E,C=o1(E);if(C)w=C.content.trim();let R=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],m=[],h;while((h=R.exec(E))!==null){let D=h[1],T=h[2],b=h[0];if(D.includes("server"))m.push(T);else I.push(b)}let E0=E.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],R0=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),d0={__filename:q,__dirname:y0.dirname(q)};for(let D of m)await B0(D,d0,q);let Z0=await L0(R0,d0,q,U,new Set);if(E0.length>0){let D=E0.join(`
2885
2885
  `);if(Z0.match(/(<\/head>)/i))Z0=Z0.replace(/(<\/head>)/i,`${D}
2886
- $1`)}if(I.length>0){let{interpolateScriptsInTemplate:D}=await import("./chunk-yv340gxj.js"),T=D(I.join(`
2886
+ $1`)}if(I.length>0){let{interpolateScriptsInTemplate:D}=await import("./chunk-gfgpf7h8.js"),T=D(I.join(`
2887
2887
  `),d0);if(Z0.match(/(<\/body>)/i))Z0=Z0.replace(/(<\/body>)/i,`${T}
2888
2888
  $1`);else Z0+=`
2889
- ${T}`}return z.set(V,{content:Z0,mtime:M.mtimeMs}),Z0}async function O(q){let M=I1.statSync(q),V=`${q}:${M.mtimeMs}`,N=z.get(V);if(N)return N.content;let{content:E}=await q0(q,Z);return z.set(V,{content:E,mtime:M.mtimeMs}),E}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 E=y0.join(U,N);if(I1.existsSync(E)&&I1.statSync(E).isFile())return E}return null}async function L(q){let M=new URL(q.url),V=async()=>{if(G[M.pathname])return await G[M.pathname](q);if(J){let E=await J(q);if(E)return E}let N=j(M.pathname);if(!N){if(K)return await K(q);return new Response("Not Found",{status:404})}try{let E,w="text/html";if(N.endsWith(".stx"))E=await F(N);else if(N.endsWith(".md"))E=await O(N);else if(N.endsWith(".html"))E=await Bun.file(N).text();else if(N.endsWith(".css"))E=await Bun.file(N).text(),w="text/css";else if(N.endsWith(".js"))E=await Bun.file(N).text(),w="text/javascript";else if(N.endsWith(".json"))E=await Bun.file(N).text(),w="application/json";else return new Response(Bun.file(N));return new Response(E,{headers:{"Content-Type":w}})}catch(E){if(_)return await _(E,q);let w=E instanceof Error?E.message:String(E),R=Z?.debug===!0?`<h1>Error</h1><pre>${w}
2890
- ${E instanceof Error?E.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(R,{status:500,headers:{"Content-Type":"text/html"}})}};for(let N=W.length-1;N>=0;N--){let E=W[N],w=V;V=async()=>await E(q,w)}return await V()}let H=cX({port:X,fetch:async(q)=>Z$(q,await L(q))}),A=null;if(Y)A=I1.watch(U,{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 b2($,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.`);return await lX({...X,root:y0.dirname(Q),routes:{"/":async()=>{let J;if(Z){let{content:G}=await q0(Q,X.stxOptions);J=G}else{let G=await Bun.file(Q).text(),W=[],K=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,_;while((_=K.exec(G))!==null)if(_[1].includes("server"))W.push(_[2]);let U=W.join(`
2891
- `),z=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),F={};if(U.trim())await B0(U,F,Q);let O=new Set;J=await L0(z,F,Q,X.stxOptions||{},O)}return new Response(J,{headers:{"Content-Type":"text/html"}})},...X.routes}})}function iX($){return $}function aX($){return $}import{existsSync as rX,readFileSync as sX}from"fs";var nX={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},s6={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 n6{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...nX,...$},this.options.includeBuiltins)Object.entries(s6).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=[],!rX($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let X=sX($,"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
+ ${T}`}return z.set(V,{content:Z0,mtime:M.mtimeMs}),Z0}async function H(q){let M=I1.statSync(q),V=`${q}:${M.mtimeMs}`,N=z.get(V);if(N)return N.content;let{content:E}=await q0(q,U);return z.set(V,{content:E,mtime:M.mtimeMs}),E}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 E=y0.join(_,N);if(I1.existsSync(E)&&I1.statSync(E).isFile())return E}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 E=await Y(q);if(E)return E}let N=j(M.pathname);if(!N){if(W)return await W(q);return new Response("Not Found",{status:404})}try{let E,w="text/html";if(N.endsWith(".stx"))E=await F(N);else if(N.endsWith(".md"))E=await H(N);else if(N.endsWith(".html"))E=await Bun.file(N).text();else if(N.endsWith(".css"))E=await Bun.file(N).text(),w="text/css";else if(N.endsWith(".js"))E=await Bun.file(N).text(),w="text/javascript";else if(N.endsWith(".json"))E=await Bun.file(N).text(),w="application/json";else return new Response(Bun.file(N));return new Response(E,{headers:{"Content-Type":w}})}catch(E){if(K)return await K(E,q);let w=E instanceof Error?E.message:String(E),R=U?.debug===!0?`<h1>Error</h1><pre>${w}
2890
+ ${E instanceof Error?E.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(R,{status:500,headers:{"Content-Type":"text/html"}})}};for(let N=G.length-1;N>=0;N--){let E=G[N],w=V;V=async()=>await E(q,w)}return await V()}let O=lX({port:X,fetch:async(q)=>Z$(q,await L(q))}),A=null;if(Z)A=I1.watch(_,{recursive:!0},(q,M)=>{if(M&&(M.endsWith(".stx")||M.endsWith(".md")||M.endsWith(".html")))z.clear()});return{server:O,url:O.url.toString(),stop(){if(A)A.close();O.stop()}}}async function y2($,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 s6(X);return await iX({...X,root:y0.dirname(Q),routes:{"/":async()=>{let G;if(Z){let{content:W}=await q0(Q,J);G=W}else{let W=await Bun.file(Q).text(),K=[],_=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=_.exec(W))!==null)if(U[1].includes("server"))K.push(U[2]);let z=K.join(`
2891
+ `),F=W.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),H={};if(z.trim())await B0(z,H,Q);G=await L0(F,H,Q,J,new Set)}return new Response(G,{headers:{"Content-Type":"text/html"}})},...X.routes}})}function aX($){return $}function rX($){return $}import{existsSync as sX,readFileSync as nX}from"fs";var oX={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},n6={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 o6{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...oX,...$},this.options.includeBuiltins)Object.entries(n6).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=[],!sX($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let X=nX($,"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(s6).forEach(([$,X])=>{this.variables.set($,X)})}}function o6($){return new n6($)}function g2($,X){return o6(X).checkFile($)}function f2($,X){return o6(X).checkTemplate($)}function h2($){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 W5=typeof window<"u"&&typeof document<"u";async function G5($,X,Q){if(!W5)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 u2($){if(!W5)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")G5(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")G5(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")G5(Z,Y,$[Y])})},1000)}function m2($){if(!W5)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 Z1=typeof window<"u"&&typeof document<"u",_5={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999},Q0=null,M0=0,D1=!1,K5=null,Q1=null,w0=null;function t6($){if(!Z1)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(n6).forEach(([$,X])=>{this.variables.set($,X)})}}function t6($){return new o6($)}function f2($,X){return t6(X).checkFile($)}function h2($,X){return t6(X).checkTemplate($)}function d2($){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 W5=typeof window<"u"&&typeof document<"u";async function G5($,X,Q){if(!W5)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 m2($){if(!W5)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")G5(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")G5(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")G5(Z,Y,$[Y])})},1000)}function p2($){if(!W5)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 Z1=typeof window<"u"&&typeof document<"u",_5={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999},Q0=null,M0=0,D1=!1,K5=null,Q1=null,w0=null;function e6($){if(!Z1)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 @@ ${E instanceof Error?E.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 W$($,X){if(!Z1||!Q0)return;if(M0=Math.min(Math.max($,0),100),K5)cancelAnimationFrame(K5);K5=requestAnimationFrame(()=>{if(!Q0)return;Q0.style.opacity=M0>0?"1":"0",Q0.style.transform=`scaleX(${M0/100})`})}function oX($){if(!Z1)return;if(D1=!0,M0=0,!Q0)Q0=t6($);if(Q1)clearTimeout(Q1);if(w0)clearInterval(w0);W$(10,$),w0=setInterval(()=>{if(!D1)return;let X=90-M0,Q=Math.max(0.5,X*0.1);if(M0<90)W$(M0+Q,$)},$.throttle)}function tX($){if(!Z1)return;if(D1=!1,w0)clearInterval(w0),w0=null;W$(100,$),Q1=setTimeout(()=>{if(Q0)Q0.style.opacity="0";setTimeout(()=>{if(M0=0,Q0)Q0.style.transform="scaleX(0)"},300)},200)}function eX(){if(!Z1)return;if(D1=!1,M0=0,w0)clearInterval(w0),w0=null;if(Q1)clearTimeout(Q1),Q1=null;if(Q0)Q0.style.opacity="0",Q0.style.transform="scaleX(0)"}function $Q($){let X={..._5,...$};return{start:()=>oX(X),set:(Q)=>W$(Q,X),finish:()=>tX(X),clear:()=>eX(),get state(){return{isLoading:D1,progress:M0,error:!1}}}}var l0=null;function c2($){if(!Z1)return;if(l0)l0(),l0=null;let X={..._5,...$},Q=$Q(X);Q0=t6(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=_,l0=()=>{if(document.removeEventListener("click",Y),window.removeEventListener("popstate",J),window.removeEventListener("load",G),window.fetch===_)window.fetch=W}}function l2(){if(l0)l0(),l0=null}function i2($){let X={..._5,...$},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 W$($,X){if(!Z1||!Q0)return;if(M0=Math.min(Math.max($,0),100),K5)cancelAnimationFrame(K5);K5=requestAnimationFrame(()=>{if(!Q0)return;Q0.style.opacity=M0>0?"1":"0",Q0.style.transform=`scaleX(${M0/100})`})}function tX($){if(!Z1)return;if(D1=!0,M0=0,!Q0)Q0=e6($);if(Q1)clearTimeout(Q1);if(w0)clearInterval(w0);W$(10,$),w0=setInterval(()=>{if(!D1)return;let X=90-M0,Q=Math.max(0.5,X*0.1);if(M0<90)W$(M0+Q,$)},$.throttle)}function eX($){if(!Z1)return;if(D1=!1,w0)clearInterval(w0),w0=null;W$(100,$),Q1=setTimeout(()=>{if(Q0)Q0.style.opacity="0";setTimeout(()=>{if(M0=0,Q0)Q0.style.transform="scaleX(0)"},300)},200)}function $Q(){if(!Z1)return;if(D1=!1,M0=0,w0)clearInterval(w0),w0=null;if(Q1)clearTimeout(Q1),Q1=null;if(Q0)Q0.style.opacity="0",Q0.style.transform="scaleX(0)"}function XQ($){let X={..._5,...$};return{start:()=>tX(X),set:(Q)=>W$(Q,X),finish:()=>eX(X),clear:()=>$Q(),get state(){return{isLoading:D1,progress:M0,error:!1}}}}var l0=null;function l2($){if(!Z1)return;if(l0)l0(),l0=null;let X={..._5,...$},Q=XQ(X);Q0=e6(X);let Z=!1,Y=(U)=>{let F=U.target.closest("a");if(!F)return;let H=F.getAttribute("href");if(!H)return;if(H.startsWith("http")||H.startsWith("#")||H.startsWith("mailto:")||H.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 i2(){if(l0)l0(),l0=null}function a2($){let X={..._5,...$},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 @@ ${E instanceof Error?E.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 r2($,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 e6{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 $8{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 e6(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 s2($,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 X8{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=`
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 n2($){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 o2($){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 o2($,X,Q,Z){return`
3250
+ `}function t2($,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 Y1=null;function t2($){if(!Y1)Y1=new $8($);return Y1}function e2(){if(Y1)Y1.getRegistry().clear(),Y1=null}function XQ($){let X={refs:$.refs||{},reactive:$.reactive||{},props:$.props||{},routeParams:$.routeParams||{},stores:$.stores||{},meta:$.meta||{},timestamp:Date.now()};return X.checksum=X8(X),JSON.stringify(X).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/'/g,"\\u0027")}function X8($){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 QQ($){return`<script id="__STX_STATE__" type="application/json">${XQ($)}</script>`}function XK($){if($.length===0)return"";return`data-stx-events='${JSON.stringify($)}'`}function ZQ(){if(typeof window>"u")return null;let $=document.getElementById("__STX_STATE__");if(!$)return null;try{let X=JSON.parse($.textContent||"{}");if(X.checksum){if(X8(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 Q8{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=ZQ(),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 QK($){return`
3291
- ${$?QQ($):""}
3290
+ `}var Y1=null;function e2($){if(!Y1)Y1=new X8($);return Y1}function $K(){if(Y1)Y1.getRegistry().clear(),Y1=null}function QQ($){let X={refs:$.refs||{},reactive:$.reactive||{},props:$.props||{},routeParams:$.routeParams||{},stores:$.stores||{},meta:$.meta||{},timestamp:Date.now()};return X.checksum=Q8(X),JSON.stringify(X).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/'/g,"\\u0027")}function Q8($){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 ZQ($){return`<script id="__STX_STATE__" type="application/json">${QQ($)}</script>`}function QK($){if($.length===0)return"";return`data-stx-events='${JSON.stringify($)}'`}function YQ(){if(typeof window>"u")return null;let $=document.getElementById("__STX_STATE__");if(!$)return null;try{let X=JSON.parse($.textContent||"{}");if(X.checksum){if(Q8(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 Z8{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=YQ(),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 ZK($){return`
3291
+ ${$?ZQ($):""}
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 U5=null;function YQ($){if(!U5)U5=new Q8($);return U5}async function ZK($){await YQ($).hydrate()}function YK(){return`
3388
+ `}var U5=null;function JQ($){if(!U5)U5=new Z8($);return U5}async function YK($){await JQ($).hydrate()}function JK(){return`
3389
3389
  <style data-stx-hydration-styles>
3390
3390
  /* Pre-hydration state */
3391
3391
  [data-stx-component]:not(.stx-hydrated) {
@@ -3418,9 +3418,9 @@ else {
3418
3418
  }
3419
3419
  }
3420
3420
  </style>
3421
- `}import Z8 from"path";_6();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($)}}async function FK($,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 j=_[1];G=G.replace(/<script\s+server\b[^>]*>[\s\S]*?<\/script>/gi,""),await B0(j,K,W)}let U={layoutsDir:Y,...Q.stxOptions},F=await L0(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 w1={stores:new Map,subscriptions:new Map};function GQ($,X){w1.stores.set($,X)}function J8($){return w1.stores.get($)}function WQ($){return w1.stores.has($)}function KQ(){return Array.from(w1.stores.keys())}var J1=new Map;function Y8($){if($==="memory")return{getItem:(X)=>J1.get(X)??null,setItem:(X,Q)=>J1.set(X,Q),removeItem:(X)=>J1.delete(X)};if(typeof window>"u")return{getItem:(X)=>J1.get(X)??null,setItem:(X,Q)=>J1.set(X,Q),removeItem:(X)=>J1.delete(X)};return $==="local"?window.localStorage:window.sessionStorage}function _Q($,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 G8($,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=Y8(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=Y8(Z.storage||"local"),q=Z.key||`stx-store:${Q||"unnamed"}`,M=Z.serialize||JSON.stringify,V=Z.paths&&typeof H==="object"&&H!==null?_Q(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(k6(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)w1.stores.delete(Q)}};for(let H of J.reverse())j=H(O,()=>W,L)(j);if(Q){if(GQ(Q,L),Y)x6(Q,W??{},{},[])}return L}function UQ($){let X=typeof $==="string"?J8($):$;if(!X)throw Error(`Store "${$}" not found`);return X.get()}function BQ($,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=G8(_,{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 LQ.set($,F),F}var LQ=new Map;function FQ($){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 f($,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 W8($){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 B5(...$){let X={};for(let Q of $)if(Q)Object.assign(X,Q);return X}function K8($,X,Q,Z){let Y={w:X};if(Q)Y.h=Q;if(Z)Y.fit=Z;return f($,Y)}function _8($,X,Q,Z="center"){return f($,{w:X,h:Q,fit:"crop",crop:Z})}function U8($,X,Q="center"){return f($,{w:X,h:X,fit:"crop",crop:Q})}function B8($,X,Q){return f($,{w:X,h:Q,fit:"max"})}function L8($,X,Q){return f($,{w:X,h:Q,fit:"crop"})}function F8($,X){return f($,{blur:Math.min(2000,Math.max(0,X))})}function z8($,X){return f($,{sharp:Math.min(100,Math.max(0,X))})}function j8($){return f($,{sat:-100})}function O8($,X=100){return f($,{sepia:Math.min(100,Math.max(0,X))})}function H8($){return f($,{invert:!0})}function A8($,X){return f($,{bri:Math.min(100,Math.max(-100,X))})}function q8($,X){return f($,{con:Math.min(100,Math.max(-100,X))})}function N8($,X){return f($,{sat:Math.min(100,Math.max(-100,X))})}function M8($,X){return f($,{rot:(X%360+360)%360})}function V8($){return f($,{flip:"h"})}function E8($){return f($,{flip:"v"})}function R8($,X,Q){let Z={fm:X};if(Q!==void 0)Z.q=Q;return f($,Z)}function I8($,X){return f($,{q:Math.min(100,Math.max(1,X))})}function D8($,X=["format","compress"]){return f($,{auto:X})}function w8($,X,Q={}){return f($,{mark:X,markx:Q.x,marky:Q.y,markalpha:Q.alpha,markscale:Q.scale,markalign:Q.align})}var L5={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 T8($,X,Q){return f($,B5(L5[X],Q))}function C8($,X,Q){return X.map((Z)=>f($,{...Q,w:Z}))}function x8($,X,Q=[1,2,3],Z){return Q.map((Y)=>f($,{...Z,w:Math.round(X*Y),dpr:Y}))}function k8($){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 S8($){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 b8($){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 Y8 from"path";_6();class GQ{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 zK($,X={},Q={}){let Z=Q.viewsDir||"./views",Y=Q.layoutsDir||"./layouts",J=!$.includes("<")&&!$.includes("@"),G,W;if(J){if(W=Y8.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:Y8.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 B0(j,K,W)}let U={layoutsDir:Y,...Q.stxOptions},F=await L0(G,K,W,U,new Set),H=new Headers({"Content-Type":"text/html; charset=utf-8"});if(Q.ctx)Q.ctx.responseHeaders.forEach((j,L)=>{H.set(L,j)});return new Response(F,{headers:H})}var w1={stores:new Map,subscriptions:new Map};function WQ($,X){w1.stores.set($,X)}function G8($){return w1.stores.get($)}function KQ($){return w1.stores.has($)}function _Q(){return Array.from(w1.stores.keys())}var J1=new Map;function J8($){if($==="memory")return{getItem:(X)=>J1.get(X)??null,setItem:(X,Q)=>J1.set(X,Q),removeItem:(X)=>J1.delete(X)};if(typeof window>"u")return{getItem:(X)=>J1.get(X)??null,setItem:(X,Q)=>J1.set(X,Q),removeItem:(X)=>J1.delete(X)};return $==="local"?window.localStorage:window.sessionStorage}function UQ($,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 W8($,X={}){let{name:Q,persist:Z,devtools:Y=!1,middleware:J=[],equals:G=(O,A)=>O===A}=X,W=$,K=new Set,_=null;if(Z){let O=J8(Z.storage||"local"),A=Z.key||`stx-store:${Q||"unnamed"}`,q=Z.deserialize||JSON.parse;try{let M=O.getItem(A);if(M){let V=q(M);if(Z.paths&&typeof V==="object"&&V!==null)W={...$,...V};else W=V}}catch{}}let U=(O)=>{if(!Z)return;let A=J8(Z.storage||"local"),q=Z.key||`stx-store:${Q||"unnamed"}`,M=Z.serialize||JSON.stringify,V=Z.paths&&typeof O==="object"&&O!==null?UQ(O,Z.paths):O;if(Z.debounce){if(_)clearTimeout(_);_=setTimeout(()=>{A.setItem(q,M(V))},Z.debounce)}else A.setItem(q,M(V))},z=(O,A)=>{for(let q of K)try{q(O,A)}catch(M){console.error("[stx-store] Subscriber error:",M)}},F=Y?(O,A)=>{if(k6(Q||"unnamed",O,W,A),typeof window<"u")window.__STX_DEVTOOLS__?.onStoreChange?.(Q||"unnamed",O,A)}:()=>{},H=(O)=>{let A=W;if(!G(O,A))W=O,U(O),z(O,A),F("set",O)},j=H,L={get:()=>W,set:(O)=>{if(typeof O==="function")j(O(W));else j(O)},subscribe:(O)=>{return K.add(O),()=>{K.delete(O)}},update:(O)=>{if(typeof W!=="object"||W===null)throw Error("update() can only be used with object stores");let A=typeof O==="function"?O(W):O;L.set({...W,...A})},reset:()=>{L.set($),F("reset",$)},name:Q,destroy:()=>{if(K.clear(),_)clearTimeout(_);if(Q)w1.stores.delete(Q)}};for(let O of J.reverse())j=O(H,()=>W,L)(j);if(Q){if(WQ(Q,L),Y)x6(Q,W??{},{},[])}return L}function BQ($){let X=typeof $==="string"?G8($):$;if(!X)throw Error(`Store "${$}" not found`);return X.get()}function LQ($,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=W8(_,{name:$,persist:U,devtools:K}),F=new Proxy({},{get(H,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 O=z.get();if(O&&typeof O==="object"&&L in O)return O[L];return},set(H,j,L){let O=String(j);if(O.startsWith("$")||O==="_store")return!1;let A=z.get();if(A&&typeof A==="object")return z.set({...A,[O]:L}),!0;return!1},has(H,j){let L=String(j),O=z.get();return L.startsWith("$")||L==="_store"||L in J||L in G||O&&typeof O==="object"&&L in O},ownKeys(){let H=z.get();return[...H&&typeof H==="object"?Object.keys(H):[],...Object.keys(J),...Object.keys(G),"$state","$subscribe","$reset","$patch","$id"]},getOwnPropertyDescriptor(H,j){return{enumerable:!0,configurable:!0,get:()=>this.get(H,j,F)}}});return FQ.set($,F),F}var FQ=new Map;function zQ($){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 f($,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 K8($){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 B5(...$){let X={};for(let Q of $)if(Q)Object.assign(X,Q);return X}function _8($,X,Q,Z){let Y={w:X};if(Q)Y.h=Q;if(Z)Y.fit=Z;return f($,Y)}function U8($,X,Q,Z="center"){return f($,{w:X,h:Q,fit:"crop",crop:Z})}function B8($,X,Q="center"){return f($,{w:X,h:X,fit:"crop",crop:Q})}function L8($,X,Q){return f($,{w:X,h:Q,fit:"max"})}function F8($,X,Q){return f($,{w:X,h:Q,fit:"crop"})}function z8($,X){return f($,{blur:Math.min(2000,Math.max(0,X))})}function j8($,X){return f($,{sharp:Math.min(100,Math.max(0,X))})}function H8($){return f($,{sat:-100})}function O8($,X=100){return f($,{sepia:Math.min(100,Math.max(0,X))})}function A8($){return f($,{invert:!0})}function q8($,X){return f($,{bri:Math.min(100,Math.max(-100,X))})}function N8($,X){return f($,{con:Math.min(100,Math.max(-100,X))})}function M8($,X){return f($,{sat:Math.min(100,Math.max(-100,X))})}function V8($,X){return f($,{rot:(X%360+360)%360})}function E8($){return f($,{flip:"h"})}function R8($){return f($,{flip:"v"})}function I8($,X,Q){let Z={fm:X};if(Q!==void 0)Z.q=Q;return f($,Z)}function D8($,X){return f($,{q:Math.min(100,Math.max(1,X))})}function w8($,X=["format","compress"]){return f($,{auto:X})}function T8($,X,Q={}){return f($,{mark:X,markx:Q.x,marky:Q.y,markalpha:Q.alpha,markscale:Q.scale,markalign:Q.align})}var L5={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 C8($,X,Q){return f($,B5(L5[X],Q))}function x8($,X,Q){return X.map((Z)=>f($,{...Q,w:Z}))}function k8($,X,Q=[1,2,3],Z){return Q.map((Y)=>f($,{...Z,w:Math.round(X*Y),dpr:Y}))}function S8($){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 y8($){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:H}=$,j=$.class||"",L=$.style||"",O=$.id||`stx-upload-${Math.random().toString(36).slice(2,8)}`,A=Array.isArray(Q)?Q.join(","):Q,q=`
3422
+ <div id="${O}" class="stx-upload${W?" stx-upload-dropzone":""}${z?" stx-upload-disabled":""}${j?" "+j:""}"${L?` style="${L}"`:""}>
3423
+ ${H?`<label class="stx-upload-label">${b8(H)}</label>`:""}
3424
3424
  <div class="stx-upload-area" data-stx-upload-area>
3425
3425
  <input
3426
3426
  type="file"
@@ -3435,8 +3435,8 @@ 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: ${XZ(Z)}</span>`:""}
3438
+ <span class="stx-upload-text">${b8(F)}</span>
3439
+ ${Z?`<span class="stx-upload-hint">Max size: ${QZ(Z)}</span>`:""}
3440
3440
  </div>
3441
3441
  </div>
3442
3442
  ${G?'<div class="stx-upload-previews" data-stx-upload-previews></div>':""}
@@ -3444,7 +3444,7 @@ else {
3444
3444
  </div>
3445
3445
  `.trim(),M=`
3446
3446
  (function() {
3447
- var container = document.getElementById('${H}');
3447
+ var container = document.getElementById('${O}');
3448
3448
  if (!container) return;
3449
3449
 
3450
3450
  var input = container.querySelector('[data-stx-upload-input]');
@@ -3455,7 +3455,7 @@ 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: '${XZ(X)}',
3459
3459
  fieldName: '${J}',
3460
3460
  maxSize: ${Z||"null"},
3461
3461
  maxFiles: ${Y},
@@ -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 XZ($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(1)} MB`}async function F5($,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 z5($,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 y8($,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)=>z5(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 j5($){return $.expires>Date.now()}function O5($){return Math.max(0,$.expires-Date.now())}function H5($,X=300000){return O5($)<X}async function C1($){if($.check)return await $.check();return!0}function K$($){let X={};if($.role)X.role=$.role;if($.permission)X.permission=$.permission;if($.userId)X.userId=$.userId;return X}var T1=new Map;async function v8($,X){let Q=`${$}:${X.endpoint}`,Z=T1.get(Q);if(Z&&j5(Z)&&!H5(Z))return Z;let Y=await F5($,X);return T1.set(Q,Y),Y}function g8(){T1.clear()}function f8(){let $=0,X=Date.now();for(let[Q,Z]of T1)if(Z.expires<=X)T1.delete(Q),$++;return $}function _$(){return`
3710
+ `.trim();return{html:q,script:M,css:V}}function b8($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function XZ($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function QZ($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(1)} MB`}async function F5($,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 z5($,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 H of U.results)if(H.error)F.set(H.url,H.error);else z.set(H.url||H.originalUrl,{url:H.signedUrl||H.url,signature:H.signature,expires:H.expires||Date.now()+J*1000,oneTimeUse:H.oneTimeUse||G});else if(typeof U.signatures==="object"){for(let[H,j]of Object.entries(U.signatures)){let L=j;z.set(H,{url:L.signedUrl||L.url||H,signature:L.signature,expires:L.expires||Date.now()+J*1000,oneTimeUse:G})}if(U.errors)for(let[H,j]of Object.entries(U.errors))F.set(H,j)}return{signatures:z,errors:F}}async function v8($,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)=>z5(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 j5($){return $.expires>Date.now()}function H5($){return Math.max(0,$.expires-Date.now())}function O5($,X=300000){return H5($)<X}async function C1($){if($.check)return await $.check();return!0}function K$($){let X={};if($.role)X.role=$.role;if($.permission)X.permission=$.permission;if($.userId)X.userId=$.userId;return X}var T1=new Map;async function g8($,X){let Q=`${$}:${X.endpoint}`,Z=T1.get(Q);if(Z&&j5(Z)&&!O5(Z))return Z;let Y=await F5($,X);return T1.set(Q,Y),Y}function f8(){T1.clear()}function h8(){let $=0,X=Date.now();for(let[Q,Z]of T1)if(Z.expires<=X)T1.delete(Q),$++;return $}function _$(){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 d8($){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 C1(J)){if(G)return{html:`<img src="${a(G)}" alt="${a(Q)}"${K?` class="${a(K)}"`:""}${_?` style="${a(_)}"`:""} />`};return{html:"<!-- Protected content: access denied -->"}}}let U={endpoint:Z,oneTimeUse:W,...Y,params:J?K$(J):Y.params},z=`stx-protected-${Math.random().toString(36).slice(2,8)}`,F=[`id="${z}"`,`data-protected-src="${a(X)}"`,`data-signature-endpoint="${a(Z)}"`,`alt="${a(Q)}"`];if(G)F.push(`data-fallback="${a(G)}"`),F.push(`src="${a(G)}"`);else F.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');if(K)F.push(`class="${a(K)}"`);if(_)F.push(`style="${a(_)}"`);let O=`
3784
+ `.trim()}async function u8($){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 C1(J)){if(G)return{html:`<img src="${a(G)}" alt="${a(Q)}"${K?` class="${a(K)}"`:""}${_?` style="${a(_)}"`:""} />`};return{html:"<!-- Protected content: access denied -->"}}}let U={endpoint:Z,oneTimeUse:W,...Y,params:J?K$(J):Y.params},z=`stx-protected-${Math.random().toString(36).slice(2,8)}`,F=[`id="${z}"`,`data-protected-src="${a(X)}"`,`data-signature-endpoint="${a(Z)}"`,`alt="${a(Q)}"`];if(G)F.push(`data-fallback="${a(G)}"`),F.push(`src="${a(G)}"`);else F.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');if(K)F.push(`class="${a(K)}"`);if(_)F.push(`style="${a(_)}"`);let H=`
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 u8($){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 C1(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="${a(X)}"`,`data-signature-endpoint="${a(Q)}"`];if(W)H.push(`poster="${a(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="${a(F)}"`);if(O)H.push(`style="${a(O)}"`);if(J)H.push(`data-fallback="${a(J)}"`);let A=`
3795
+ `.trim();return{html:`<img ${F.join(" ")} />`,script:H}}async function m8($){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,H=$.style,j=$.alt;if(Y){if(!await C1(Y))return{html:"<!-- Protected video: access denied -->"}}let L=`stx-protected-video-${Math.random().toString(36).slice(2,8)}`,O=[`id="${L}"`,`data-protected-src="${a(X)}"`,`data-signature-endpoint="${a(Q)}"`];if(W)O.push(`poster="${a(W)}"`);if(K)O.push("controls");if(_)O.push("autoplay");if(U)O.push("muted");if(z)O.push("loop");if(F)O.push(`class="${a(F)}"`);if(H)O.push(`style="${a(H)}"`);if(J)O.push(`data-fallback="${a(J)}"`);let A=`
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 m8($,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=_$()+`
3806
+ `.trim();return{html:`<video ${O.join(" ")}></video>`,script:A}}async function p8($,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=_$()+`
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 p8($,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=QZ(Z);return{src:h8(Y[0],Q)||"",alt:h8(Y[1],Q)||"",...typeof Y[2]==="object"?Y[2]:{}}}function QZ($){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 h8($,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 a($){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(([,j])=>j).map(([j,L])=>{return`manager.on('${j.replace(/^on/,"").toLowerCase()}', ${L});`}).join(`
3839
- `),O=`
3838
+ `.trim(),{html:$,script:J}}function c8($,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=ZZ(Z);return{src:d8(Y[0],Q)||"",alt:d8(Y[1],Q)||"",...typeof Y[2]==="object"?Y[2]:{}}}function ZZ($){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 d8($,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 a($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function YZ($){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
+ `),H=`
3840
3840
  (function() {
3841
3841
  // Load media manager script
3842
3842
  var script = document.createElement('script');
3843
- script.src = '${c8(X)}';
3843
+ script.src = '${l8(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:', '${c8(X)}');
3860
+ console.error('[stx] Failed to load media manager from:', '${l8(X)}');
3861
3861
  };
3862
3862
 
3863
3863
  document.head.appendChild(script);
3864
3864
  })();
3865
- `.trim();return{html:z,script:O}}function YZ($){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:H}}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 c8($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var a8={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"};function A5(){return"loading"in HTMLImageElement.prototype}function q5(){return"IntersectionObserver"in window}function r8($={}){let X={...a8,...$},Q=document.querySelectorAll(X.selector);if(Q.length===0)return()=>{};if(X.useNative&&A5())return Q.forEach((Y)=>{if(Y.tagName==="IMG"||Y.tagName==="IFRAME")v0(Y,X)}),()=>{};if(!q5())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)l8($,Z,Y);else if(G)i8($,Z,Y);else if(W)JZ($,Z,Y);else{let K=$.querySelector("img[data-src], img[data-srcset]"),_=$.querySelector("video[data-src]");if(K)l8(K,()=>{if(Z)Z($)},(z)=>{if(Y)Y($,z)});else if(_)i8(_,()=>{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 l8($,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 i8($,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 JZ($,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 s8($){v0($,{})}function n8($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Q)=>v0(Q,{}))}function o8($={}){let X={...a8,...$};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 t8($,X){$.observe(X)}function e8($){$.disconnect()}function U$(){return`
4054
+ `.trim();return{html:J,script:G,css:W}}function l8($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var r8={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"};function A5(){return"loading"in HTMLImageElement.prototype}function q5(){return"IntersectionObserver"in window}function s8($={}){let X={...r8,...$},Q=document.querySelectorAll(X.selector);if(Q.length===0)return()=>{};if(X.useNative&&A5())return Q.forEach((Y)=>{if(Y.tagName==="IMG"||Y.tagName==="IFRAME")v0(Y,X)}),()=>{};if(!q5())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)i8($,Z,Y);else if(G)a8($,Z,Y);else if(W)GZ($,Z,Y);else{let K=$.querySelector("img[data-src], img[data-srcset]"),_=$.querySelector("video[data-src]");if(K)i8(K,()=>{if(Z)Z($)},(z)=>{if(Y)Y($,z)});else if(_)a8(_,()=>{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 i8($,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 a8($,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 GZ($,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 n8($){v0($,{})}function o8($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Q)=>v0(Q,{}))}function t8($={}){let X={...r8,...$};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 e8($,X){$.observe(X)}function $7($){$.disconnect()}function U$(){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 GZ={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"};function N5($,X={}){let Q={...GZ,...X},Z=$.closest(".stx-img-placeholder");if(!Z){WZ($,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)$7($,Z,Q);else $.addEventListener("load",()=>$7($,Z,Q),{once:!0}),$.addEventListener("error",()=>KZ($,Z,Q),{once:!0})}function WZ($,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 $7($,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 KZ($,X,Q){if(Q.loadingClass)X.classList.remove(Q.loadingClass);X.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function X7($,X){let Q=B$($),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 B$($){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,E=Z*(1-M*0.3),w=Y*(1-V*0.3),C=N-0.6666666666666666*E,R=(3*N-C+w)/2,I=R-w;L[q]=Math.max(0,Math.min(255,Math.round(R*255))),L[q+1]=Math.max(0,Math.min(255,Math.round(I*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 Q7($){let X=B$($),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 Y7($,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)=>{N5(Q,$)})}function L$(){return`
4144
+ `.trim()}var WZ={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"};function N5($,X={}){let Q={...WZ,...X},Z=$.closest(".stx-img-placeholder");if(!Z){KZ($,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)X7($,Z,Q);else $.addEventListener("load",()=>X7($,Z,Q),{once:!0}),$.addEventListener("error",()=>_Z($,Z,Q),{once:!0})}function KZ($,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 X7($,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 _Z($,X,Q){if(Q.loadingClass)X.classList.remove(Q.loadingClass);X.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function Q7($,X){let Q=B$($),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 B$($){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),H=32,j=32,L=new Uint8ClampedArray(4096);for(let O=0;O<32;O++)for(let A=0;A<32;A++){let q=(O*32+A)*4,M=A/31,V=O/31,N=Q+(M-0.5)*J*0.5+(V-0.5)*J*0.5,E=Z*(1-M*0.3),w=Y*(1-V*0.3),C=N-0.6666666666666666*E,R=(3*N-C+w)/2,I=R-w;L[q]=Math.max(0,Math.min(255,Math.round(R*255))),L[q+1]=Math.max(0,Math.min(255,Math.round(I*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 Z7($){let X=B$($),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 Y7($){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 G7($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Q)=>{N5(Q,$)})}function L$(){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 _Z={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1};function M5($,X={}){if(X.maxSize&&$.size>X.maxSize)return{valid:!1,error:`File size (${G7($.size)}) exceeds maximum (${G7(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 G7($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}async function V5($,X,Q){let Z={..._Z,...X},Y=M5($,Z);if(!Y.valid)return{success:!1,error:Y.error,name:$.name,size:$.size,type:$.type};if(Z.chunkSize&&$.size>Z.chunkSize)return BZ($,Z,Q);return UZ($,Z,Q)}async function UZ($,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 BZ($,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 W7($,X,Q,Z){let Y=[];for(let J of $){let G=await V5(J,X,(W)=>{if(Q)Q(J,W)});if(Y.push(G),Z)Z(J,G)}return Y}function K7($,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 _7($){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 z$(){return`
4243
+ `.trim()}var UZ={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1};function M5($,X={}){if(X.maxSize&&$.size>X.maxSize)return{valid:!1,error:`File size (${W7($.size)}) exceeds maximum (${W7(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 W7($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}async function V5($,X,Q){let Z={...UZ,...X},Y=M5($,Z);if(!Y.valid)return{success:!1,error:Y.error,name:$.name,size:$.size,type:$.type};if(Z.chunkSize&&$.size>Z.chunkSize)return LZ($,Z,Q);return BZ($,Z,Q)}async function BZ($,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,H=z>0?F/z:0,j=_.total-_.loaded,L=H>0?j/H*1000:void 0;G=_.loaded,W=U,Q({file:$,loaded:_.loaded,total:_.total,percent:Math.round(_.loaded/_.total*100),speed:H,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 LZ($,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,H]of Object.entries(X.formData))z.append(F,H);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 H=await F.json();if(!G&&H.uploadId)G=H.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:H.url,id:H.id||G,name:$.name,size:$.size,type:$.type,data:H}}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 K7($,X,Q,Z){let Y=[];for(let J of $){let G=await V5(J,X,(W)=>{if(Q)Q(J,W)});if(Y.push(G),Z)Z(J,G)}return Y}function _7($,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 U7($){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 z$(){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 U7(){return{script:[U$(),L$(),z$()].join(`
4311
+ `.trim()}function B7(){return{script:[U$(),L$(),z$()].join(`
4312
4312
 
4313
- `),css:F$()}}function LZ(){let{script:$,css:X}=U7(),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 k_={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 j$ from"fs";import i0 from"path";async function B7($,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 B0(J,W,$);let K={...O$,...Q};return await L0(G,W,$,K,new Set)}async function FZ($){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}`);j$.mkdirSync(Y,{recursive:!0});let O={componentsDir:J,layoutsDir:G,partialsDir:W,debug:z},j;if(U&&U.length>0)j=U;else j=j$.readdirSync(Z).filter((H)=>H.endsWith(".stx")).map((H)=>({input:H}));for(let L of j){let H=i0.join(Z,L.input),A=L.output||L.input.replace(/\.stx$/,".html"),q=i0.join(Y,A);if(z)console.log(` Building ${L.input}...`);try{let M={...K,...L.props,..._},V=await B7(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(i0.join(Y,"manifest.json"),JSON.stringify(L,null,2))}if(Q.duration=performance.now()-X,z)if(Q.success)console.log(`
4313
+ `),css:F$()}}function FZ(){let{script:$,css:X}=B7(),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 S_={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 j$ from"fs";import i0 from"path";async function L7($,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 B0(J,W,$);let K={...H$,...Q};return await L0(G,W,$,K,new Set)}async function zZ($){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}`);j$.mkdirSync(Y,{recursive:!0});let H={componentsDir:J,layoutsDir:G,partialsDir:W,debug:z},j;if(U&&U.length>0)j=U;else j=j$.readdirSync(Z).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let L of j){let O=i0.join(Z,L.input),A=L.output||L.input.replace(/\.stx$/,".html"),q=i0.join(Y,A);if(z)console.log(` Building ${L.input}...`);try{let M={...K,...L.props,..._},V=await L7(O,M,H);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(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 a_($,X){let Q=j$.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 FZ($);X?.(J)}});return{close:()=>Q.close()}}async function r_($,X={},Q={}){let Z={...Q,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await B7($,X,Z);Y=await zZ(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 r_($,X){let Q=j$.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 zZ($);X?.(J)}});return{close:()=>Q.close()}}async function s_($,X={},Q={}){let Z={...Q,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await L7($,X,Z);Y=await jZ(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=OZ(Y);return{html:Y,text:J}}async function zZ($){try{let{generateCrosswindCSS:X,extractClassNames:Q}=await import("./chunk-1yk07x7b.js");if(Q($).size===0)return $;let Y=await X($);if(!Y)return $;let J=jZ(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 jZ($){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 OZ($){return $.replace(/<br\s*\/?>/gi,`
4318
+ `).trim();let J=OZ(Y);return{html:Y,text:J}}async function jZ($){try{let{generateCrosswindCSS:X,extractClassNames:Q}=await import("./chunk-0kp3c02b.js");if(Q($).size===0)return $;let Y=await X($);if(!Y)return $;let J=HZ(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),H=[];for(let A of F){let q=J.get(A);if(q)H.push(q)}if(H.length===0)return`${W}${K}class="${_}"${U}${z}`;let j=H.join("; "),O=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(O){let A=`${j}; ${O[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 HZ($){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 OZ($){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 HZ($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function AZ($){let X={};for(let Q of Object.keys($))if(!Q.startsWith("__"))X[Q]=$[Q];return X}function n_($){let{template:X,context:Q={},title:Z="stx App"}=$,Y=AZ(Q),J=HZ(JSON.stringify(Y));return`<!DOCTYPE html>
4322
+ `).trim()}function AZ($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function qZ($){let X={};for(let Q of Object.keys($))if(!Q.startsWith("__"))X[Q]=$[Q];return X}function o_($){let{template:X,context:Q={},title:Z="stx App"}=$,Y=qZ(Q),J=AZ(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 FZ($);X?.(J)}});return{close:()=
4339
4339
  }
4340
4340
  </script>
4341
4341
  </body>
4342
- </html>`}var z0=null;function qZ($,X){if(z0)z0.provides.set($,X);else H$.set($,X)}function NZ($,X){let Q=z0;while(Q){if(Q.provides.has($))return Q.provides.get($);Q=Q.parent}if(H$.has($))return H$.get($);return X}var H$=new Map;function E5($,X){H$.set($,X)}function MZ($){let X=z0,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 VZ($){if(z0)z0.exposed=$}function EZ($){let X=Promise.resolve();return $?X.then($):X}function RZ($){if(z0)z0.errorCapturedHooks.push($)}function IZ($,X,Q){let Z=X?.parent;while(Z){for(let Y of Z.errorCapturedHooks)if(Y($,X,Q)===!1)return;Z=Z.parent}}function DZ(){return z0?.slots??{}}function wZ(){return z0?.slots??{}}function TZ(){return z0?.attrs??{}}function CZ($){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 xZ(){return`
4342
+ </html>`}var z0=null;function NZ($,X){if(z0)z0.provides.set($,X);else O$.set($,X)}function MZ($,X){let Q=z0;while(Q){if(Q.provides.has($))return Q.provides.get($);Q=Q.parent}if(O$.has($))return O$.get($);return X}var O$=new Map;function E5($,X){O$.set($,X)}function VZ($){let X=z0,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 EZ($){if(z0)z0.exposed=$}function RZ($){let X=Promise.resolve();return $?X.then($):X}function IZ($){if(z0)z0.errorCapturedHooks.push($)}function DZ($,X,Q){let Z=X?.parent;while(Z){for(let Y of Z.errorCapturedHooks)if(Y($,X,Q)===!1)return;Z=Z.parent}}function wZ(){return z0?.slots??{}}function TZ(){return z0?.slots??{}}function CZ(){return z0?.attrs??{}}function xZ($){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 kZ(){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 FZ($);X?.(J)}});return{close:()=
4404
4404
  return refs;
4405
4405
  };
4406
4406
  })();
4407
- `}var W1=Symbol.for("stx.Fragment"),kZ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),F7=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"]),z7={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 SZ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function R5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function j7($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[L7($)];return $.flat(1/0).map(L7).filter((X)=>X!=="")}function L7($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function K1($,X,Q){let{children:Z,ref:Y,key:J,...G}=X||{};return{type:$,props:Object.keys(G).length>0?G:null,children:j7(Z),key:Q??J??void 0,ref:Y??void 0}}var PZ=K1,bZ=K1;function O7($){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 I5($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(I5).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,X])=>X).map(([X])=>X).join(" ");return""}function yZ($){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=z7[Q]||Q;if(Y==="class"||Y==="className"){let J=I5(Z);if(J)X.push(` class="${R5(J)}"`);continue}if(Y==="style"){let J=typeof Z==="string"?Z:O7(Z);if(J)X.push(` style="${R5(J)}"`);continue}if(F7.has(Y)){if(Z)X.push(` ${Y}`);continue}if(Z!=null&&Z!==!1)X.push(` ${Y}="${R5(String(Z))}"`)}return X.join("")}function G1($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return SZ($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(G1).join("");if($.type===W1)return $.children.map(G1).join("");if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return G1(J)}let X=$.type,Q=yZ($.props),Z=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Z!=null)return`<${X}${Q}>${Z}</${X}>`;if(kZ.has(X))return`<${X}${Q}>`;let Y=$.children.map(G1).join("");return`<${X}${Q}>${Y}</${X}>`}function vZ($){return new ReadableStream({start(X){X.enqueue(G1($)),X.close()}})}function gZ($,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=z7[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=I5(Z);if(J)$.setAttribute("class",J);continue}if(Y==="style"){let J=typeof Z==="string"?Z:O7(Z);if(J)$.setAttribute("style",J);continue}if(F7.has(Y)){if(Z)$.setAttribute(Y,"");continue}if(Z!=null&&Z!==!1)$.setAttribute(Y,String(Z))}}function x1($,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 $)x1(Y,X);return}if($.type===W1){for(let Y of $.children)x1(Y,X);return}if(typeof $.type==="function"){let Y=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});x1(Y,X);return}let Q=document.createElement($.type);gZ(Q,$.props);let Z=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Z!=null)Q.innerHTML=Z;else for(let Y of $.children)x1(Y,Q);if($.ref){if(typeof $.ref==="function")$.ref(Q)}X.appendChild(Q)}function fZ($){if($.when)return K1(W1,{children:$.children});return $.fallback??null}function hZ($){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 K1(W1,{children:Z})}function dZ($){return K1(W1,{children:$.children})}function uZ($,X,...Q){let{key:Z,ref:Y,...J}=X||{};return{type:$,props:Object.keys(J).length>0?J:{},children:j7(Q.length===1?Q[0]:Q),key:Z??void 0,ref:Y??void 0}}function H7($,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 E5(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 mZ($){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 pZ($,...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 _1 from"fs";import g0 from"path";function A7($){try{return _1.statSync($).mtimeMs}catch{return null}}function A$($,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 cZ($,X){try{return globalThis.Bun?.resolveSync($,X)??null}catch{return null}}function q7($,X="stx"){let Q=g0.resolve($);for(let Z=0;Z<10;Z++){let Y=g0.join(Q,"pantry","@stacksjs",X);if(_1.existsSync(Y))return Y;let J=g0.dirname(Q);if(J===Q)break;Q=J}return null}async function lZ($={}){let X=$.cwd?g0.resolve($.cwd):process.cwd(),Q=$.resolve??cZ,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=q7(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)=>_1.existsSync(j))||null,U=A7(K),z=_?A7(_):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 (${A$(z,Z)}) is OLDER than src/signals.ts (${A$(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 ${A$(U,Z)}, dist ${A$(z,Z)})`});let F=g0.join(X,"node_modules/@stacksjs/stx"),O=null;try{O=_1.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=_1.realpathSync(F)}catch{}let L=(()=>{try{return _1.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 iZ($){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:_Y}=globalThis.Bun;import{cpSync as x7,existsSync as C$,mkdirSync as k7,readFileSync as S7,readdirSync as UY,rmSync as BY,statSync as LY,unlinkSync as FY,writeFileSync as w$}from"fs";import{dirname as zY,join as V0,relative as jY}from"path";import P7 from"process";import f0 from"path";function M7($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function V7($,X,Q){let Z=M7(X),Y=Q?M7(Q):"";return`<!DOCTYPE html>
4407
+ `}var W1=Symbol.for("stx.Fragment"),SZ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),z7=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"]),j7={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 R5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function H7($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[F7($)];return $.flat(1/0).map(F7).filter((X)=>X!=="")}function F7($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function K1($,X,Q){let{children:Z,ref:Y,key:J,...G}=X||{};return{type:$,props:Object.keys(G).length>0?G:null,children:H7(Z),key:Q??J??void 0,ref:Y??void 0}}var bZ=K1,yZ=K1;function O7($){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 I5($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(I5).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,X])=>X).map(([X])=>X).join(" ");return""}function vZ($){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=j7[Q]||Q;if(Y==="class"||Y==="className"){let J=I5(Z);if(J)X.push(` class="${R5(J)}"`);continue}if(Y==="style"){let J=typeof Z==="string"?Z:O7(Z);if(J)X.push(` style="${R5(J)}"`);continue}if(z7.has(Y)){if(Z)X.push(` ${Y}`);continue}if(Z!=null&&Z!==!1)X.push(` ${Y}="${R5(String(Z))}"`)}return X.join("")}function G1($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return PZ($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(G1).join("");if($.type===W1)return $.children.map(G1).join("");if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return G1(J)}let X=$.type,Q=vZ($.props),Z=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Z!=null)return`<${X}${Q}>${Z}</${X}>`;if(SZ.has(X))return`<${X}${Q}>`;let Y=$.children.map(G1).join("");return`<${X}${Q}>${Y}</${X}>`}function gZ($){return new ReadableStream({start(X){X.enqueue(G1($)),X.close()}})}function fZ($,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=j7[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=I5(Z);if(J)$.setAttribute("class",J);continue}if(Y==="style"){let J=typeof Z==="string"?Z:O7(Z);if(J)$.setAttribute("style",J);continue}if(z7.has(Y)){if(Z)$.setAttribute(Y,"");continue}if(Z!=null&&Z!==!1)$.setAttribute(Y,String(Z))}}function x1($,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 $)x1(Y,X);return}if($.type===W1){for(let Y of $.children)x1(Y,X);return}if(typeof $.type==="function"){let Y=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});x1(Y,X);return}let Q=document.createElement($.type);fZ(Q,$.props);let Z=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(Z!=null)Q.innerHTML=Z;else for(let Y of $.children)x1(Y,Q);if($.ref){if(typeof $.ref==="function")$.ref(Q)}X.appendChild(Q)}function hZ($){if($.when)return K1(W1,{children:$.children});return $.fallback??null}function dZ($){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 K1(W1,{children:Z})}function uZ($){return K1(W1,{children:$.children})}function mZ($,X,...Q){let{key:Z,ref:Y,...J}=X||{};return{type:$,props:Object.keys(J).length>0?J:{},children:H7(Q.length===1?Q[0]:Q),key:Z??void 0,ref:Y??void 0}}function A7($,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 E5(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 pZ($){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 cZ($,...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((H)=>encodeURIComponent(String(H))).join("/"):U==="*"?String(z).split("/").map((H)=>encodeURIComponent(H)).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 _1 from"fs";import g0 from"path";function q7($){try{return _1.statSync($).mtimeMs}catch{return null}}function A$($,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 lZ($,X){try{return globalThis.Bun?.resolveSync($,X)??null}catch{return null}}function N7($,X="stx"){let Q=g0.resolve($);for(let Z=0;Z<10;Z++){let Y=g0.join(Q,"pantry","@stacksjs",X);if(_1.existsSync(Y))return Y;let J=g0.dirname(Q);if(J===Q)break;Q=J}return null}async function iZ($={}){let X=$.cwd?g0.resolve($.cwd):process.cwd(),Q=$.resolve??lZ,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=N7(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)=>_1.existsSync(j))||null,U=q7(K),z=_?q7(_):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 (${A$(z,Z)}) is OLDER than src/signals.ts (${A$(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 ${A$(U,Z)}, dist ${A$(z,Z)})`});let F=g0.join(X,"node_modules/@stacksjs/stx"),H=null;try{H=_1.lstatSync(F)}catch{H=null}if(!H)Y.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(H.isSymbolicLink()){let j=null;try{j=_1.realpathSync(F)}catch{}let L=(()=>{try{return _1.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 aZ($){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:UY}=globalThis.Bun;import{cpSync as k7,existsSync as C$,mkdirSync as S7,readFileSync as P7,readdirSync as BY,rmSync as LY,statSync as FY,unlinkSync as zY,writeFileSync as w$}from"fs";import{dirname as jY,join as V0,relative as HY}from"path";import b7 from"process";import f0 from"path";function V7($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function E7($,X,Q){let Z=V7(X),Y=Q?V7(Q):"";return`<!DOCTYPE html>
4409
4409
  <html>
4410
4410
  <head>
4411
4411
  <title>stx Error</title>
@@ -4421,51 +4421,51 @@ File changed: ${Y}, rebuilding...`);let J=await FZ($);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 N7($){return{name:"bun-plugin-stx",async setup(X){let Q={...O$,...$},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 $$(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 q0(W,Q);return{contents:`// ${W}
4424
+ </html>`}function M7($){return{name:"bun-plugin-stx",async setup(X){let Q={...H$,...$},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 $$(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 q0(W,Q);return{contents:`// ${W}
4425
4425
  const content = ${JSON.stringify(K)};
4426
4426
  const data = ${JSON.stringify(_)};
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 _=V7("Markdown Processing Error",K.message||"Unknown error",W);return{contents:`// ${W}
4430
+ `,loader:"js"}}catch(K){console.error("Markdown Processing Error:",K);let _=E7("Markdown Processing Error",K.message||"Unknown error",W);return{contents:`// ${W}
4431
4431
  const content = ${JSON.stringify(_)};
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 t1(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=R7(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 B0(A,L,G);let H=j;if(H=await L0(H,L,G,Q,W),F.length>0){let A=L.__stx_event_bindings||[],M=(await Promise.all(F.map(async(N)=>{let E=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!E)return N;return E7(E[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 e1(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:V7("stx Rendering Error",W.message||String(W),G),loader:"html"}}})}}}var I7=N7;function q$($,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 R=Y.favicon.toLowerCase().split(".").pop(),I=R==="svg"?"image/svg+xml":R==="ico"?"image/x-icon":R==="png"?"image/png":R==="jpg"||R==="jpeg"?"image/jpeg":"";F.push(`<link rel="icon"${I?` type="${I}"`:""} href="${e(Y.favicon)}">`)}if(F.push(`<title>${aZ(J)}</title>`,`<link rel="canonical" href="${e(K)}">`,`<meta name="description" content="${e(G)}">`,`<meta property="og:title" content="${e(J)}">`,`<meta property="og:description" content="${e(G)}">`,`<meta property="og:type" content="${e(U)}">`,`<meta property="og:url" content="${e(K)}">`,`<meta property="og:site_name" content="${e(_)}">`,`<meta property="og:locale" content="${e(z)}">`,`<meta name="twitter:card" content="${W?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${e(J)}">`,`<meta name="twitter:description" content="${e(G)}">`),W)F.push(`<meta property="og:image" content="${e(W)}">`),F.push(`<meta name="twitter:image" content="${e(W)}">`);if(Y.twitter)F.push(`<meta name="twitter:site" content="@${e(Y.twitter.replace(/^@/,""))}">`),F.push(`<meta name="twitter:creator" content="@${e(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=(R)=>{if(/^<title[\s>]/i.test(R))return/<title[\s>]/i.test(L)&&!q;if(/rel="canonical"/i.test(R))return/<link[^>]+rel=["']canonical["']/i.test(L);let h=/(?:property|name)="([^"]+)"/i.exec(R)?.[1];if(!h)return!1;return new RegExp(`<meta[^>]+(?:property|name)=["']${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["']`,"i").test(L)},V=F.filter((R)=>!M(R));if(V.length===0)return $;let N=$,E=V.find((R)=>/^<title[\s>]/i.test(R));if(E&&q&&/<title[^>]*>[\s\S]*?<\/title>/i.test(N)){if(N=N.replace(/<title[^>]*>[\s\S]*?<\/title>/i,()=>E),V=V.filter((R)=>R!==E),V.length===0)return N}let w=`<!-- SEO -->
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 t1(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=I7(K),F=z.client.map((A)=>A.fullTag),H=z.server.map((A)=>A.content),j=_;for(let A of H){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 H)await B0(A,L,G);let O=j;if(O=await L0(O,L,G,Q,W),F.length>0){let A=L.__stx_event_bindings||[],M=(await Promise.all(F.map(async(N)=>{let E=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!E)return N;return R7(E[1],{eventBindings:A,templateContent:O})}))).join(`
4437
+ `);if(O.match(/(<\/body>)/i))O=O.replace(/(<\/body>)/i,`${M}
4438
+ $1`);else O+=`
4439
+ ${M}`;L.__stx_event_bindings=[]}if(W.forEach((A)=>Z.add(A)),Q.cache&&Q.cachePath){if(await e1(G,O,W,Q),Q.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:O,loader:"html"}}catch(W){return console.error("stx Plugin Error:",W),{contents:E7("stx Rendering Error",W.message||String(W),G),loader:"html"}}})}}}var D7=M7;function q$($,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 R=Y.favicon.toLowerCase().split(".").pop(),I=R==="svg"?"image/svg+xml":R==="ico"?"image/x-icon":R==="png"?"image/png":R==="jpg"||R==="jpeg"?"image/jpeg":"";F.push(`<link rel="icon"${I?` type="${I}"`:""} href="${e(Y.favicon)}">`)}if(F.push(`<title>${rZ(J)}</title>`,`<link rel="canonical" href="${e(K)}">`,`<meta name="description" content="${e(G)}">`,`<meta property="og:title" content="${e(J)}">`,`<meta property="og:description" content="${e(G)}">`,`<meta property="og:type" content="${e(U)}">`,`<meta property="og:url" content="${e(K)}">`,`<meta property="og:site_name" content="${e(_)}">`,`<meta property="og:locale" content="${e(z)}">`,`<meta name="twitter:card" content="${W?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${e(J)}">`,`<meta name="twitter:description" content="${e(G)}">`),W)F.push(`<meta property="og:image" content="${e(W)}">`),F.push(`<meta name="twitter:image" content="${e(W)}">`);if(Y.twitter)F.push(`<meta name="twitter:site" content="@${e(Y.twitter.replace(/^@/,""))}">`),F.push(`<meta name="twitter:creator" content="@${e(Y.twitter.replace(/^@/,""))}">`);let H=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(H.test($))$=$.replace(H,"");$=$.replace(/<!--\s*SEO\s*-->[\s\S]*?<!--\s*\/SEO\s*-->\s*/g,""),$=$.replace(/<meta\s+name="title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+property="og:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"");let j=$.search(/<\/head>/i),L=j===-1?$:$.slice(0,j),O=/^(?:stx App|stx Project|Document|Untitled)$/i,A=/<title[^>]*>([\s\S]*?)<\/title>/i.exec(L)?.[1]?.trim(),q=A===void 0||A===""||O.test(A),M=(R)=>{if(/^<title[\s>]/i.test(R))return/<title[\s>]/i.test(L)&&!q;if(/rel="canonical"/i.test(R))return/<link[^>]+rel=["']canonical["']/i.test(L);let h=/(?:property|name)="([^"]+)"/i.exec(R)?.[1];if(!h)return!1;return new RegExp(`<meta[^>]+(?:property|name)=["']${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["']`,"i").test(L)},V=F.filter((R)=>!M(R));if(V.length===0)return $;let N=$,E=V.find((R)=>/^<title[\s>]/i.test(R));if(E&&q&&/<title[^>]*>[\s\S]*?<\/title>/i.test(N)){if(N=N.replace(/<title[^>]*>[\s\S]*?<\/title>/i,()=>E),V=V.filter((R)=>R!==E),V.length===0)return N}let w=`<!-- SEO -->
4440
4440
  ${V.join(`
4441
4441
  `)}
4442
4442
  <!-- /SEO -->`,C=N.search(/<\/head>/i);if(C!==-1)return`${N.slice(0,C)}${w}
4443
4443
  ${N.slice(C)}`;if(/<head[^>]*>/i.test(N))return N.replace(/<head([^>]*)>/i,`<head$1>
4444
4444
  ${w}`);return`${w}
4445
- ${N}`}function e($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function aZ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function N$($,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>${rZ(G)}</loc>`,` <lastmod>${Z}</lastmod>`,` <changefreq>${K}</changefreq>`,` <priority>${W.toFixed(1)}</priority>`," </url>"].join(`
4445
+ ${N}`}function e($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rZ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function N$($,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>${sZ(G)}</loc>`,` <lastmod>${Z}</lastmod>`,` <changefreq>${K}</changefreq>`,` <priority>${W.toFixed(1)}</priority>`," </url>"].join(`
4446
4446
  `)}).join(`
4447
4447
  `),"</urlset>",""].join(`
4448
- `)}function rZ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function M$($){let X=$.robots??"allow";if(X===!1)return null;if(typeof X==="string"&&X!=="allow"&&X!=="disallow")return X.endsWith(`
4448
+ `)}function sZ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function M$($){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 U1=null;async function sZ(){if(U1!==null)return U1;try{let $=await import("./chunk-3nmpfsw5.js");if(typeof $.getRouterScript==="function")U1=$.getRouterScript();else U1=""}catch{U1=""}return U1}async function D5($,X){let Q=await sZ();if(!Q)return $;let Z={interceptAllLinks:!0,container:"main",...X},J=`${`<script>window.__stxRouterConfig=${JSON.stringify(Z)};</script>
4453
+ `)}var U1=null;async function nZ(){if(U1!==null)return U1;try{let $=await import("./chunk-3nmpfsw5.js");if(typeof $.getRouterScript==="function")U1=$.getRouterScript();else U1=""}catch{U1=""}return U1}async function D5($,X){let Q=await nZ();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 nZ=`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){}};`,oZ=($,X,Q,Z)=>`(function(){${nZ}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)})();`,tZ=($,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 V$($,X){if(X.theme===!1)return $;let Q=$.includes(D7),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 oZ=`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){}};`,tZ=($,X,Q,Z)=>`(function(){${oZ}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)})();`,eZ=($,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 V$($,X){if(X.theme===!1)return $;let Q=$.includes(w7),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"})};`}${oZ(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">${tZ(J,G,W)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
4460
- </body>`)}return $}async function w7($,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:$1(J,Y)})}return{succeeded:Q,failed:Z}}import{existsSync as eZ,readFileSync as $Y}from"fs";import{join as XY,resolve as QY}from"path";import ZY from"process";function E$($,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=YY(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 YY($,X){let Q=$.translations??{},Z={},Y=$.translationsDir,J=Y===!1?null:QY(X,typeof Y==="string"&&Y?Y:"translations"),G=$.format??"json";for(let W of $.locales){let K=J?JY(J,W,G):{};Z[W]={...K,...Q[W]??{}}}return Z}function JY($,X,Q){let Z=Q==="json"?[`${X}.json`]:[`${X}.${Q}`,`${X}.${Q==="yaml"?"yml":"yaml"}`];for(let Y of Z){let J=XY($,Y);if(!eZ(J))continue;try{let G=$Y(J,"utf8"),W=Q==="json"?JSON.parse(G):GY(G);return T7(W)}catch{continue}}return{}}function T7($,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))T7(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 GY($){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]=WY(z)}return X}function WY($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function T5($,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 R$($,X,Q){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(Z,Y,J)=>{let G=T5(X,Q,J);return Y==="!"?G:KY(G)})}function h0($,X,Q){if(X===Q)return $;if($==="/")return`/${X}/`;if($==="/404.html")return`/${X}/404.html`;return`/${X}${$}`}function C7($,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 I$($,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="${w5(G)}" href="${w5(W)}">`)}let J=`${Z}${h0(X,Q.defaultLocale,Q.defaultLocale)}`;return Y.push(`<link rel="alternate" hreflang="x-default" href="${w5(J)}">`),Y.join(`
4462
- `)}function D$($,X){return`<script data-stx-lang-picker="1">window.__stxI18n=${JSON.stringify({locales:$.locales,defaultLocale:$.defaultLocale,current:X,pickerSelector:$.pickerSelector})};(function(){function cfg(){return window.__stxI18n}function localeFromPath(p){var d=cfg();for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/')return c;if(p.indexOf('/'+c+'/')===0)return c}return d.defaultLocale}function localePathFor(loc,p){var d=cfg();var stripped=p;for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/'){stripped='/';break}if(p.indexOf('/'+c+'/')===0){stripped=p.slice(c.length+1);break}}if(loc===d.defaultLocale)return stripped;if(stripped==='/')return '/'+loc+'/';return '/'+loc+stripped}cfg().localizeHref=function(href){try{var u=new URL(href,location.origin);if(u.origin!==location.origin)return href;return localePathFor(localeFromPath(location.pathname),u.pathname)+(u.search||'')+(u.hash||'')}catch(_){return href}};function syncFromUrl(){var d=cfg();var loc=localeFromPath(location.pathname);d.current=loc;var picker=document.querySelector(d.pickerSelector);if(picker){var btns=picker.querySelectorAll('[data-lang]');for(var i=0;i<btns.length;i++){var b=btns[i];if(b.getAttribute('data-lang')===loc)b.setAttribute('aria-current','true');else b.removeAttribute('aria-current')}}if(document.documentElement.lang!==loc)document.documentElement.lang=loc}function onLangClick(e){var d=cfg();var btn=e.target&&e.target.closest&&e.target.closest('[data-lang]');if(!btn)return;var picker=document.querySelector(d.pickerSelector);if(!picker||!picker.contains(btn))return;e.preventDefault();e.stopPropagation();var loc=btn.getAttribute('data-lang');if(!loc||loc===localeFromPath(location.pathname))return;var dest=localePathFor(loc,location.pathname);var r=window.__stxRouter;if(r&&r.navigate)r.navigate(dest,true,true);else location.assign(dest)}syncFromUrl();if(window.__stxLangPickerBound){document.removeEventListener('click',window.__stxLangPickerClick,true);window.removeEventListener('stx:navigate',window.__stxLangPickerSync);window.removeEventListener('popstate',window.__stxLangPickerSync)}window.__stxLangPickerClick=onLangClick;window.__stxLangPickerSync=syncFromUrl;window.__stxLangPickerBound=1;document.addEventListener('click',onLangClick,true);window.addEventListener('stx:navigate',syncFromUrl);window.addEventListener('popstate',syncFromUrl)})();</script>`}function w5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function KY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function v7($){let X=Date.now(),Q=$.pagesDir??"pages",Z=$.outDir??"dist",Y=$.publicDir??"public";if(!$.noClean)BY(Z,{recursive:!0,force:!0});k7(Z,{recursive:!0});let J=new _Y(`${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 w7(_,(V)=>Bun.build({entrypoints:V,outdir:Z,plugins:[I7()],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.`)}AY(Z);let z=S5(Z).filter((V)=>V.endsWith(".html")),F=E$($,P7.cwd()),O=new Set(z.map(T$));for(let V of z){let N=V0(Z,V),E=S7(N,"utf8"),w=T$(V),C=F?F.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let R of C){let I=E;if(I=qY(I),F)I=R$(I,F,R);if(I=await s(I,P7.cwd()),I=q$(I,$,$.pages?.[w],w),F)I=NY(I,$,F,R,w),I=MY(I,R,F.defaultLocale,O);if(I=V$(I,$),I=VY(I),F)I=I.replace(/<\/body>/i,`${D$(F,R)}
4464
- </body>`);if($.spa!==!1)I=await D5(I,$.router);let m=F?HY(w,R,F.defaultLocale):V,h=V0(Z,m);if(k7(OY(h),{recursive:!0}),w$(h,I),F&&R!==F.defaultLocale&&m!==V);}}let j=x5(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=k5(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(C$(Y))x7(Y,Z,{recursive:!0});let H=y7();if(H)x7(H,V0(Z,b7),{recursive:!0});let A=V0(Z,"404.html");if(!C$(A)&&C$(V0(Z,"index.html"))){let V=S7(V0(Z,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${EY($.name)}</title>`);w$(A,V)}if($.sitemap!==!1){let V=[],N=z.filter((w)=>w!=="404.html").map(T$),E=F?F.locales:[null];for(let w of N){let C=$.pages?.[w];for(let R of E){let I=R&&F?h0(w,R,F.defaultLocale):w;V.push({path:I,page:C})}}w$(V0(Z,"sitemap.xml"),N$($,V))}let q=M$($);if(q!==null)w$(V0(Z,"robots.txt"),q);let M=z.map(T$);return{outDir:Z,pages:M,durationMs:Date.now()-X}}function OY($){return zY($)}function HY($,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 T$($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function S5($,X=$){let Q=[];if(!C$($))return Q;for(let Z of UY($,{withFileTypes:!0})){let Y=V0($,Z.name);if(Z.isDirectory())Q.push(...S5(Y,X));else Q.push(jY(X,Y))}return Q}function AY($){for(let X of S5($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(X))continue;let Q=V0($,X);try{if(LY(Q).size===0)FY(Q)}catch{}}}function qY($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function NY($,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="${C5(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="${C5(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${C5(J)}">`);let W=I$(X.url,Y,Q);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(K)=>`${W}
4465
- ${K}`);return $}function C5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function MY($,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 VY($){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"})};`}${tZ(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">${eZ(J,G,W)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
4460
+ </body>`)}return $}async function T7($,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:$1(J,Y)})}return{succeeded:Q,failed:Z}}import{existsSync as $Y,readFileSync as XY}from"fs";import{join as QY,resolve as ZY}from"path";import YY from"process";function E$($,X=YY.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:ZY(X,typeof Y==="string"&&Y?Y:"translations"),G=$.format??"json";for(let W of $.locales){let K=J?GY(J,W,G):{};Z[W]={...K,...Q[W]??{}}}return Z}function GY($,X,Q){let Z=Q==="json"?[`${X}.json`]:[`${X}.${Q}`,`${X}.${Q==="yaml"?"yml":"yaml"}`];for(let Y of Z){let J=QY($,Y);if(!$Y(J))continue;try{let G=XY(J,"utf8"),W=Q==="json"?JSON.parse(G):WY(G);return C7(W)}catch{continue}}return{}}function C7($,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))C7(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 WY($){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]=KY(z)}return X}function KY($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function T5($,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 R$($,X,Q){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(Z,Y,J)=>{let G=T5(X,Q,J);return Y==="!"?G:_Y(G)})}function h0($,X,Q){if(X===Q)return $;if($==="/")return`/${X}/`;if($==="/404.html")return`/${X}/404.html`;return`/${X}${$}`}function x7($,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 I$($,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="${w5(G)}" href="${w5(W)}">`)}let J=`${Z}${h0(X,Q.defaultLocale,Q.defaultLocale)}`;return Y.push(`<link rel="alternate" hreflang="x-default" href="${w5(J)}">`),Y.join(`
4462
+ `)}function D$($,X){return`<script data-stx-lang-picker="1">window.__stxI18n=${JSON.stringify({locales:$.locales,defaultLocale:$.defaultLocale,current:X,pickerSelector:$.pickerSelector})};(function(){function cfg(){return window.__stxI18n}function localeFromPath(p){var d=cfg();for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/')return c;if(p.indexOf('/'+c+'/')===0)return c}return d.defaultLocale}function localePathFor(loc,p){var d=cfg();var stripped=p;for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/'){stripped='/';break}if(p.indexOf('/'+c+'/')===0){stripped=p.slice(c.length+1);break}}if(loc===d.defaultLocale)return stripped;if(stripped==='/')return '/'+loc+'/';return '/'+loc+stripped}cfg().localizeHref=function(href){try{var u=new URL(href,location.origin);if(u.origin!==location.origin)return href;return localePathFor(localeFromPath(location.pathname),u.pathname)+(u.search||'')+(u.hash||'')}catch(_){return href}};function syncFromUrl(){var d=cfg();var loc=localeFromPath(location.pathname);d.current=loc;var picker=document.querySelector(d.pickerSelector);if(picker){var btns=picker.querySelectorAll('[data-lang]');for(var i=0;i<btns.length;i++){var b=btns[i];if(b.getAttribute('data-lang')===loc)b.setAttribute('aria-current','true');else b.removeAttribute('aria-current')}}if(document.documentElement.lang!==loc)document.documentElement.lang=loc}function onLangClick(e){var d=cfg();var btn=e.target&&e.target.closest&&e.target.closest('[data-lang]');if(!btn)return;var picker=document.querySelector(d.pickerSelector);if(!picker||!picker.contains(btn))return;e.preventDefault();e.stopPropagation();var loc=btn.getAttribute('data-lang');if(!loc||loc===localeFromPath(location.pathname))return;var dest=localePathFor(loc,location.pathname);var r=window.__stxRouter;if(r&&r.navigate)r.navigate(dest,true,true);else location.assign(dest)}syncFromUrl();if(window.__stxLangPickerBound){document.removeEventListener('click',window.__stxLangPickerClick,true);window.removeEventListener('stx:navigate',window.__stxLangPickerSync);window.removeEventListener('popstate',window.__stxLangPickerSync)}window.__stxLangPickerClick=onLangClick;window.__stxLangPickerSync=syncFromUrl;window.__stxLangPickerBound=1;document.addEventListener('click',onLangClick,true);window.addEventListener('stx:navigate',syncFromUrl);window.addEventListener('popstate',syncFromUrl)})();</script>`}function w5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _Y($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function g7($){let X=Date.now(),Q=$.pagesDir??"pages",Z=$.outDir??"dist",Y=$.publicDir??"public";if(!$.noClean)LY(Z,{recursive:!0,force:!0});S7(Z,{recursive:!0});let J=new UY(`${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 T7(_,(V)=>Bun.build({entrypoints:V,outdir:Z,plugins:[D7()],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.`)}qY(Z);let z=S5(Z).filter((V)=>V.endsWith(".html")),F=E$($,b7.cwd()),H=new Set(z.map(T$));for(let V of z){let N=V0(Z,V),E=P7(N,"utf8"),w=T$(V),C=F?F.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let R of C){let I=E;if(I=NY(I),F)I=R$(I,F,R);if(I=await s(I,b7.cwd()),I=q$(I,$,$.pages?.[w],w),F)I=MY(I,$,F,R,w),I=VY(I,R,F.defaultLocale,H);if(I=V$(I,$),I=EY(I),F)I=I.replace(/<\/body>/i,`${D$(F,R)}
4464
+ </body>`);if($.spa!==!1)I=await D5(I,$.router);let m=F?AY(w,R,F.defaultLocale):V,h=V0(Z,m);if(S7(OY(h),{recursive:!0}),w$(h,I),F&&R!==F.defaultLocale&&m!==V);}}let j=x5(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=k5(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(C$(Y))k7(Y,Z,{recursive:!0});let O=v7();if(O)k7(O,V0(Z,y7),{recursive:!0});let A=V0(Z,"404.html");if(!C$(A)&&C$(V0(Z,"index.html"))){let V=P7(V0(Z,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${RY($.name)}</title>`);w$(A,V)}if($.sitemap!==!1){let V=[],N=z.filter((w)=>w!=="404.html").map(T$),E=F?F.locales:[null];for(let w of N){let C=$.pages?.[w];for(let R of E){let I=R&&F?h0(w,R,F.defaultLocale):w;V.push({path:I,page:C})}}w$(V0(Z,"sitemap.xml"),N$($,V))}let q=M$($);if(q!==null)w$(V0(Z,"robots.txt"),q);let M=z.map(T$);return{outDir:Z,pages:M,durationMs:Date.now()-X}}function OY($){return jY($)}function AY($,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 T$($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function S5($,X=$){let Q=[];if(!C$($))return Q;for(let Z of BY($,{withFileTypes:!0})){let Y=V0($,Z.name);if(Z.isDirectory())Q.push(...S5(Y,X));else Q.push(HY(X,Y))}return Q}function qY($){for(let X of S5($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(X))continue;let Q=V0($,X);try{if(FY(Q).size===0)zY(Q)}catch{}}}function NY($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function MY($,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="${C5(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="${C5(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${C5(J)}">`);let W=I$(X.url,Y,Q);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(K)=>`${W}
4465
+ ${K}`);return $}function C5($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function VY($,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 EY($){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
4466
  <main>${U}</main>
4467
- ${Y.slice(W)}`;return`${$.slice(0,Z)}${z}${$.slice(Q)}`}function EY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function g7($){return $}var RY=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),IY=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function DY($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wY($){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 TY($,X){for(let[Q,Z]of $)if(X>=Q&&X<Z)return!0;return!1}function k$($,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 CY($,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 xY($,X,Q){let Z=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,Y;while((Y=Z.exec($))!==null){if(TY(X,Y.index))continue;let J=Y[1].toLowerCase().split(":")[0];if(RY.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:_}=k$($,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 f7($){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 kY($,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=!f7(`${G}/${U}`).startsWith(f7(J));else z=!0;if(z){let{line:F,column:O}=k$($,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 SY($){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 PY($,X){let Q=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,Z;while((Z=Q.exec($))!==null){let Y=SY(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]==="/"||IY.has(G[1].toLowerCase())?W+1:CY($,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$])${DY(O)}\\s*\\(`,"g"),L;while((L=j.exec(F))!==null){let H=J+L.index,{line:A,column:q}=k$($,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 bY($,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}=k$($,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 x$($,X){return $?.[X]!==!1}function yY($,X={}){let Q=[],Z=wY($),Y=(X.filePath??"").replace(/\\/g,"/"),J=X.fileKind??(/\/components?\//i.test(Y)?"component":/\/layouts?\//i.test(Y)?"layout":"view");if(x$(X.rules,"stx/no-bare-function-ref-in-event"))xY($,Z,Q);if(Y&&x$(X.rules,"stx/store-value-imports-must-be-local"))kY($,Y,Q);if(x$(X.rules,"stx/no-signal-call-in-for-iteration-var"))PY($,Q);if(x$(X.rules,"stx/no-backticks-in-html-comments"))bY($,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 vY($,X){return $.kind===X}function h7($){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 gY($,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 d7($,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?h7(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)=>gY(X,W))){let W=J.map((K)=>h7(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 fY($){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 hY($,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=d7(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(`
4467
+ ${Y.slice(W)}`;return`${$.slice(0,Z)}${z}${$.slice(Q)}`}function RY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function f7($){return $}var IY=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),DY=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function wY($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function TY($){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 CY($,X){for(let[Q,Z]of $)if(X>=Q&&X<Z)return!0;return!1}function k$($,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 xY($,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 kY($,X,Q){let Z=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,Y;while((Y=Z.exec($))!==null){if(CY(X,Y.index))continue;let J=Y[1].toLowerCase().split(":")[0];if(IY.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:_}=k$($,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 h7($){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 SY($,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=!h7(`${G}/${U}`).startsWith(h7(J));else z=!0;if(z){let{line:F,column:H}=k$($,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:H,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 bY($,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]==="/"||DY.has(G[1].toLowerCase())?W+1:xY($,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 H=z-J;F=F.slice(0,H)+" ".repeat(Z[1].length)+F.slice(H+Z[1].length)}for(let H of Y){let j=new RegExp(`(?<![.\\w$])${wY(H)}\\s*\\(`,"g"),L;while((L=j.exec(F))!==null){let O=J+L.index,{line:A,column:q}=k$($,O);X.push({ruleId:"stx/no-signal-call-in-for-iteration-var",message:`"${H}" is a :for iteration variable, not a signal \u2014 calling it as "${H}()" leaves it as a function and silently breaks comparisons. Use "${H}" directly.`,line:A,column:q,severity:"error"})}}}}function yY($,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}=k$($,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 x$($,X){return $?.[X]!==!1}function vY($,X={}){let Q=[],Z=TY($),Y=(X.filePath??"").replace(/\\/g,"/"),J=X.fileKind??(/\/components?\//i.test(Y)?"component":/\/layouts?\//i.test(Y)?"layout":"view");if(x$(X.rules,"stx/no-bare-function-ref-in-event"))kY($,Z,Q);if(Y&&x$(X.rules,"stx/store-value-imports-must-be-local"))SY($,Y,Q);if(x$(X.rules,"stx/no-signal-call-in-for-iteration-var"))bY($,Q);if(x$(X.rules,"stx/no-backticks-in-html-comments"))yY($,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 gY($,X){return $.kind===X}function d7($){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 fY($,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 u7($,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?d7(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)=>fY(X,W))){let W=J.map((K)=>d7(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 hY($){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 dY($,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=u7(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
4469
  `);throw Error(`Prop validation failed:
4470
- ${K}`)}return{props:G,validation:W}}function dY($,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 uY($){return $}function mY($){return{type:$,required:!0}}function pY($,X){return{type:X,default:$}}function cY($,X={}){return{...X,validator:$}}function lY($,X={}){return{...X,validator:(Q)=>$.includes(Q)}}function iY($,X={}){return{...X,type:Array,validator:(Q)=>{if(!Array.isArray(Q))return!1;return!0}}}function aY($,X={}){return{...X,type:Object}}function rY($,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=d7(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 aU={};
4471
- export{r2 as o,u$ as p,Q6 as q,Y4 as r,I0 as s,i1 as t,a1 as u,r1 as v,s1 as w,j1 as x,p7 as y,c7 as z,l7 as A,i7 as B,a7 as C,r7 as D,tY as E,eY as F,$J as G,s7 as H,XJ as I,n7 as J,QJ as K,ZJ as L,YJ as M,JJ as N,GJ as O,WJ as P,KJ as Q,_J as R,UJ as S,BJ as T,r0 as U,LJ as V,FJ as W,zJ as X,jJ as Y,v$ as Z,AJ as _,qJ as $,t7 as aa,e7 as ba,NJ as ca,$3 as da,MJ as ea,VJ as fa,EJ as ga,RJ as ha,IJ as ia,DJ as ja,X3 as ka,Q3 as la,wJ as ma,TJ as na,Z3 as oa,xJ as pa,bJ as qa,yJ as ra,l5 as sa,U3 as ta,B3 as ua,L3 as va,F3 as wa,g$ as xa,z3 as ya,j3 as za,O3 as Aa,H3 as Ba,gJ as Ca,mJ as Da,pJ as Ea,N3 as Fa,cJ as Ga,rJ as Ha,L4 as Ia,RW as Ja,z4 as Ka,j4 as La,D4 as Ma,w4 as Na,T4 as Oa,b6 as Pa,C4 as Qa,x4 as Ra,k4 as Sa,S4 as Ta,P4 as Ua,b4 as Va,y4 as Wa,kW as Xa,q1 as Ya,yW as Za,vW as _a,v4 as $a,g4 as ab,d4 as bb,G$ as cb,gW as db,fW as eb,hW as fb,dW as gb,uW as hb,mW as ib,pW as jb,cW as kb,lW as lb,iW as mb,aW as nb,rW as ob,i4 as pb,nW as qb,$2 as rb,X2 as sb,Z5 as tb,K2 as ub,_2 as vb,U2 as wb,L2 as xb,A2 as yb,q2 as zb,N2 as Ab,M2 as Bb,V2 as Cb,E2 as Db,P2 as Eb,lX as Fb,b2 as Gb,iX as Hb,aX as Ib,n6 as Jb,o6 as Kb,g2 as Lb,f2 as Mb,h2 as Nb,u2 as Ob,m2 as Pb,$Q as Qb,c2 as Rb,l2 as Sb,i2 as Tb,G6 as Ub,$8 as Vb,n2 as Wb,o2 as Xb,t2 as Yb,e2 as Zb,XQ as _b,QQ as $b,XK as ac,ZQ as bc,Q8 as cc,QK as dc,YQ as ec,ZK as fc,YK as gc,JQ as hc,FK as ic,J8 as jc,WQ as kc,KQ as lc,G8 as mc,UQ as nc,BQ as oc,FQ as pc,f as qc,W8 as rc,B5 as sc,K8 as tc,_8 as uc,U8 as vc,B8 as wc,L8 as xc,F8 as yc,z8 as zc,j8 as Ac,O8 as Bc,H8 as Cc,A8 as Dc,q8 as Ec,N8 as Fc,M8 as Gc,V8 as Hc,E8 as Ic,R8 as Jc,I8 as Kc,D8 as Lc,w8 as Mc,L5 as Nc,T8 as Oc,C8 as Pc,x8 as Qc,k8 as Rc,S8 as Sc,b8 as Tc,F5 as Uc,z5 as Vc,y8 as Wc,j5 as Xc,O5 as Yc,H5 as Zc,C1 as _c,K$ as $c,v8 as ad,g8 as bd,f8 as cd,_$ as dd,d8 as ed,u8 as fd,m8 as gd,p8 as hd,ZZ as id,YZ as jd,A5 as kd,q5 as ld,r8 as md,v0 as nd,s8 as od,n8 as pd,o8 as qd,t8 as rd,e8 as sd,U$ as td,N5 as ud,X7 as vd,B$ as wd,Q7 as xd,Z7 as yd,Y7 as zd,J7 as Ad,L$ as Bd,F$ as Cd,M5 as Dd,V5 as Ed,W7 as Fd,K7 as Gd,_7 as Hd,z$ as Id,U7 as Jd,LZ as Kd,k_ as Ld,B7 as Md,FZ as Nd,a_ as Od,r_ as Pd,n_ as Qd,qZ as Rd,NZ as Sd,E5 as Td,MZ as Ud,VZ as Vd,EZ as Wd,RZ as Xd,IZ as Yd,DZ as Zd,wZ as _d,TZ as $d,CZ as ae,xZ as be,W1 as ce,K1 as de,PZ as ee,bZ as fe,G1 as ge,vZ as he,x1 as ie,fZ as je,hZ as ke,dZ as le,uZ as me,H7 as ne,mZ as oe,pZ as pe,q7 as qe,lZ as re,iZ as se,q$ as te,N$ as ue,M$ as ve,V$ as we,E$ as xe,T5 as ye,R$ as ze,h0 as Ae,C7 as Be,I$ as Ce,D$ as De,v7 as Ee,g7 as Fe,yY as Ge,vY as He,fY as Ie,hY as Je,dY as Ke,uY as Le,mY as Me,pY as Ne,cY as Oe,lY as Pe,iY as Qe,aY as Re,rY as Se,aU as Te,G4 as Ue,U6 as Ve,K4 as We,U4 as Xe};
4470
+ ${K}`)}return{props:G,validation:W}}function uY($,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 mY($){return $}function pY($){return{type:$,required:!0}}function cY($,X){return{type:X,default:$}}function lY($,X={}){return{...X,validator:$}}function iY($,X={}){return{...X,validator:(Q)=>$.includes(Q)}}function aY($,X={}){return{...X,type:Array,validator:(Q)=>{if(!Array.isArray(Q))return!1;return!0}}}function rY($,X={}){return{...X,type:Object}}function sY($,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=u7(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 rU={};
4471
+ export{s2 as o,u$ as p,Q6 as q,J4 as r,I0 as s,i1 as t,a1 as u,r1 as v,s1 as w,j1 as x,c7 as y,l7 as z,i7 as A,a7 as B,r7 as C,s7 as D,eY as E,$J as F,XJ as G,n7 as H,QJ as I,o7 as J,ZJ as K,YJ as L,JJ as M,GJ as N,WJ as O,KJ as P,_J as Q,UJ as R,BJ as S,LJ as T,r0 as U,FJ as V,zJ as W,jJ as X,HJ as Y,v$ as Z,qJ as _,NJ as $,e7 as aa,$3 as ba,MJ as ca,X3 as da,VJ as ea,EJ as fa,RJ as ga,IJ as ha,DJ as ia,wJ as ja,Q3 as ka,Z3 as la,TJ as ma,CJ as na,Y3 as oa,kJ as pa,yJ as qa,vJ as ra,l5 as sa,B3 as ta,L3 as ua,F3 as va,z3 as wa,g$ as xa,j3 as ya,H3 as za,O3 as Aa,A3 as Ba,fJ as Ca,pJ as Da,cJ as Ea,M3 as Fa,lJ as Ga,sJ as Ha,F4 as Ia,IW as Ja,j4 as Ka,H4 as La,w4 as Ma,T4 as Na,C4 as Oa,b6 as Pa,x4 as Qa,k4 as Ra,S4 as Sa,P4 as Ta,b4 as Ua,y4 as Va,v4 as Wa,SW as Xa,q1 as Ya,vW as Za,gW as _a,g4 as $a,f4 as ab,u4 as bb,G$ as cb,fW as db,hW as eb,dW as fb,uW as gb,mW as hb,pW as ib,cW as jb,lW as kb,iW as lb,aW as mb,rW as nb,sW as ob,a4 as pb,oW as qb,X2 as rb,Q2 as sb,Z5 as tb,_2 as ub,U2 as vb,B2 as wb,F2 as xb,q2 as yb,N2 as zb,M2 as Ab,V2 as Bb,E2 as Cb,R2 as Db,b2 as Eb,iX as Fb,y2 as Gb,aX as Hb,rX as Ib,o6 as Jb,t6 as Kb,f2 as Lb,h2 as Mb,d2 as Nb,m2 as Ob,p2 as Pb,XQ as Qb,l2 as Rb,i2 as Sb,a2 as Tb,G6 as Ub,X8 as Vb,o2 as Wb,t2 as Xb,e2 as Yb,$K as Zb,QQ as _b,ZQ as $b,QK as ac,YQ as bc,Z8 as cc,ZK as dc,JQ as ec,YK as fc,JK as gc,GQ as hc,zK as ic,G8 as jc,KQ as kc,_Q as lc,W8 as mc,BQ as nc,LQ as oc,zQ as pc,f as qc,K8 as rc,B5 as sc,_8 as tc,U8 as uc,B8 as vc,L8 as wc,F8 as xc,z8 as yc,j8 as zc,H8 as Ac,O8 as Bc,A8 as Cc,q8 as Dc,N8 as Ec,M8 as Fc,V8 as Gc,E8 as Hc,R8 as Ic,I8 as Jc,D8 as Kc,w8 as Lc,T8 as Mc,L5 as Nc,C8 as Oc,x8 as Pc,k8 as Qc,S8 as Rc,P8 as Sc,y8 as Tc,F5 as Uc,z5 as Vc,v8 as Wc,j5 as Xc,H5 as Yc,O5 as Zc,C1 as _c,K$ as $c,g8 as ad,f8 as bd,h8 as cd,_$ as dd,u8 as ed,m8 as fd,p8 as gd,c8 as hd,YZ as id,JZ as jd,A5 as kd,q5 as ld,s8 as md,v0 as nd,n8 as od,o8 as pd,t8 as qd,e8 as rd,$7 as sd,U$ as td,N5 as ud,Q7 as vd,B$ as wd,Z7 as xd,Y7 as yd,J7 as zd,G7 as Ad,L$ as Bd,F$ as Cd,M5 as Dd,V5 as Ed,K7 as Fd,_7 as Gd,U7 as Hd,z$ as Id,B7 as Jd,FZ as Kd,S_ as Ld,L7 as Md,zZ as Nd,r_ as Od,s_ as Pd,o_ as Qd,NZ as Rd,MZ as Sd,E5 as Td,VZ as Ud,EZ as Vd,RZ as Wd,IZ as Xd,DZ as Yd,wZ as Zd,TZ as _d,CZ as $d,xZ as ae,kZ as be,W1 as ce,K1 as de,bZ as ee,yZ as fe,G1 as ge,gZ as he,x1 as ie,hZ as je,dZ as ke,uZ as le,mZ as me,A7 as ne,pZ as oe,cZ as pe,N7 as qe,iZ as re,aZ as se,q$ as te,N$ as ue,M$ as ve,V$ as we,E$ as xe,T5 as ye,R$ as ze,h0 as Ae,x7 as Be,I$ as Ce,D$ as De,g7 as Ee,f7 as Fe,vY as Ge,gY as He,hY as Ie,dY as Je,uY as Ke,mY as Le,pY as Me,cY as Ne,lY as Oe,iY as Pe,aY as Qe,rY as Re,sY as Se,rU as Te,W4 as Ue,U6 as Ve,_4 as We,B4 as Xe};