@stacksjs/stx 0.2.84 → 0.2.86

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 (48) hide show
  1. package/dist/app-shell.js +50 -50
  2. package/dist/build-mode-detector.js +95 -95
  3. package/dist/build-views.js +149 -149
  4. package/dist/build.js +37 -37
  5. package/dist/cli.js +51 -51
  6. package/dist/component-processing.js +16 -16
  7. package/dist/component-renderer.js +32 -32
  8. package/dist/components.js +95 -95
  9. package/dist/dev-server/index.js +36 -36
  10. package/dist/dev-server/serve-app.js +50 -50
  11. package/dist/dev-server/serve-file.js +50 -50
  12. package/dist/dev-server/serve-markdown.js +36 -36
  13. package/dist/dev-server/serve-multi.js +49 -49
  14. package/dist/dev-server.js +50 -50
  15. package/dist/docs.js +96 -96
  16. package/dist/dynamic-components.js +32 -32
  17. package/dist/includes.js +32 -32
  18. package/dist/index.js +50 -50
  19. package/dist/interactive.js +96 -96
  20. package/dist/lazy-loader.js +95 -95
  21. package/dist/plugin.js +44 -44
  22. package/dist/process.js +31 -31
  23. package/dist/production-builder.js +31 -31
  24. package/dist/production-server.js +31 -31
  25. package/dist/pwa/index.js +95 -95
  26. package/dist/pwa/offline.js +95 -95
  27. package/dist/pwa.js +84 -84
  28. package/dist/render.js +153 -153
  29. package/dist/serve.js +106 -106
  30. package/dist/site-builder/build.js +97 -97
  31. package/dist/site-builder/index.js +38 -38
  32. package/dist/ssg.js +13 -13
  33. package/dist/ssr.js +83 -83
  34. package/dist/story/cli.js +36 -36
  35. package/dist/story/commands/dev.js +36 -36
  36. package/dist/story/commands/index.js +36 -36
  37. package/dist/story/index.js +36 -36
  38. package/dist/story/renderer.js +96 -96
  39. package/dist/story/server.js +36 -36
  40. package/dist/story/visual-testing.js +96 -96
  41. package/dist/streaming.js +32 -32
  42. package/dist/template-compiler.js +24 -24
  43. package/dist/template-hydrator.js +110 -110
  44. package/dist/testing.js +95 -95
  45. package/dist/utils.js +32 -32
  46. package/dist/variable-extractor.js +11 -11
  47. package/dist/web-components.js +95 -95
  48. package/package.json +7 -5
@@ -720,7 +720,7 @@ catch (e) {
720
720
  }
721
721
  throw e;
722
722
  }
723
- `),K=G([]);if(J.length===Z.length)return jZ(K,J,G);return jZ((...B)=>{let U=Array(Q.length);for(let _=0;_<Q.length;_++)U[_]=B[Q[_]];return K(...U)},J,G,(B)=>{K=G(B)})}function jZ($,Z,X,Y){let J=/^(\w+) is not defined$/,G=$,K=[],W=new Set(Z);return(...B)=>{for(let U=0;U<=8;U++)try{return G(...B)}catch(_){let z=_ instanceof Error?_.message:"",j=J.exec(z);if(!(_ instanceof ReferenceError)||!j)return;let q=j[1];if(W.has(q)||FZ.has(q))return;W.add(q),K.push(q),G=X(K),Y?.(K)}return}}function u5($){let Z=$.trim(),X=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let Y of X)if(Y.test(Z))return!1;return!0}var hG,HZ,OZ,dG,LZ,uG,FZ;var L0=T(()=>{hG={maxSanitizeDepth:10,allowBracketNotation:!1},HZ={...hG},OZ=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],dG=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),LZ=new Set(["__proto__","constructor","prototype"]),uG=/[\w)\]]\s*\[\s*['"]/;FZ=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"])});function m5($,Z){let X=iG++,Y=`<!--__STX_${$.toUpperCase()}_${X}__-->`;return nG.set(Y,{type:$,expression:Z}),Y}var iG=0,nG;var S$=T(()=>{nG=new Map});function VZ($,Z,X,Y){X.lastIndex=Z;let Q=X.exec($);if(!Q||Q.index!==Z)return-1;Y.lastIndex=X.lastIndex;let J=Y.exec($);if(!J)return-1;return J.index+J[0].length}function p5($,Z){return VZ($,Z,rG,sG)}function NZ($,Z){return VZ($,Z,oG,aG)}function AZ($,Z){if(!$.startsWith("<!--",Z))return-1;let X=$.indexOf("-->",Z+4);if(X===-1)return-1;return X+3}function C$($,Z,X){let Y=[],Q="",J=0,G=$.length,K=!1,W=null;while(J<G){let B=$[J];if(K){if(Q+=B,W){if(B===W)W=null}else if(B==='"'||B==="'")W=B;else if(B===">")K=!1;J++;continue}if(B==="<"){let U=Z($,J);if(U>J){Q+=X($.slice(J,U),Y.length),Y.push($.slice(J,U)),J=U;continue}if(/^<\/?[a-zA-Z]/.test($.slice(J,J+2)))K=!0;Q+=B,J++;continue}Q+=B,J++}return{output:Q,tokens:Y}}function R4($){let{output:Z,tokens:X}=C$($,p5,(Y,Q)=>`\x00STX_SCRIPT_${Q}\x00`);return{output:Z,scripts:X}}function M4($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(X,Y)=>Z[+Y]??"")}var rG,sG,oG,aG;var c5=T(()=>{rG=/<script\b[^>]*>/iy,sG=/<\/script\s*>/ig,oG=/<style\b[^>]*>/iy,aG=/<\/style\s*>/ig});var I4={};a(I4,{usesSignalsInScript:()=>Z$,unescapeHtml:()=>T4,registerFilters:()=>eG,registerFilter:()=>MZ,processExpressions:()=>i0,interpolateScriptsInTemplate:()=>ZK,interpolateScriptExpressions:()=>IZ,getAllFilters:()=>TZ,evaluateExpression:()=>g0,escapeHtml:()=>j0,defaultFilters:()=>P$,clearCustomFilters:()=>$K,applyFilters:()=>EZ});function tG($){let Z=wZ.get($);if(!Z){let X=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${X}(?!\\w)`,"g"),wZ.set($,Z)}return Z.lastIndex=0,Z}function MZ($,Z){if($ in P$)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);b$[$]=Z}function eG($){for(let[Z,X]of Object.entries($))MZ(Z,X)}function TZ(){return{...P$,...b$}}function $K(){for(let $ of Object.keys(b$))delete b$[$]}function j0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Z$($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Z.exec($))!==null){let Y=X[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(Y))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test($))return!0;return!1}function RZ($,Z){let X=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],Y=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),Q="",J=!1,G=0;for(let B=0;B<Y.length;B++){let U=Y[B];if(!J&&U==="`"){J=!0,G=0;continue}if(J){if(U==="`"&&G===0){J=!1;continue}if(U==="$"&&Y[B+1]==="{"){G++,B++;continue}if(U==="}"&&G>0){G--;continue}continue}Q+=U}Y=Q;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,W;while((W=K.exec(Y))!==null){let B=W[1];if(!Y.substring(0,W.index).trimEnd().endsWith(".")){if(!X.includes(B)&&!(B in Z))return!1}}return!0}function IZ($,Z){let X=$;return X=X.replace(/\{!!([\s\S]*?)!!\}/g,(Y,Q)=>{try{let J=g0(Q,Z);if(J===void 0)return Y;return J===null?"":String(J)}catch{return Y}}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(Y,Q)=>{let J=Q.trim();if(/^__[A-Z_]+__$/.test(J))return Y;try{let G=g0(Q,Z);if(G===void 0)return Y;return JSON.stringify(G)}catch{return Y}}),X}function ZK($,Z,X={}){return $.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(Y,Q,J)=>{if(/\bsrc\s*=/.test(Q))return Y;if(/\bdata-raw\b/.test(Q))return Y;if(/\btype\s*=\s*["']application\/json["']/.test(Q))return Y;if(X.skipServer&&/\bserver\b/.test(Q))return Y;let G=IZ(J,Z);return`<script${Q}>${G}</script>`})}function i0($,Z,X,Y){let Q=$,J=(U,_)=>{let z=NZ(U,_);if(z===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(U.slice(_,z))?-1:z},G=(U,_,z,j)=>{let q=z.length,{output:H,tokens:L}=C$(U,_,(F,O)=>j(q+O));return z.push(...L),H},K=[];Q=G(Q,J,K,(U)=>`<!--__STX_STYLE_${U}__-->`);let W=[];Q=G(Q,p5,W,(U)=>`<!--__STX_SCRIPT_EXPR_${U}__-->`);let B=Y?.forceSignals===!0||Z$($);Q=Q.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(U,_,z)=>{try{let j=g0(_,Z);return j!==void 0&&j!==null?String(j):""}catch(j){let q=j instanceof Error?j.message:String(j);return G0("Expression",`Error evaluating: {{{ ${_.trim()}}}}: ${q}`,X,$,z,U)}}),Q=Q.replace(/\{!!([\s\S]*?)!!\}/g,(U,_,z)=>{try{let j=g0(_,Z);if(j===void 0&&Z.__stx_buildMode==="compile")return m5("raw",_.trim());return j!==void 0&&j!==null?String(j):""}catch(j){if(Z.__stx_buildMode==="compile")return m5("raw",_.trim());let q=j instanceof Error?j.message:String(j);return G0("Expression",`Error evaluating: {!! ${_.trim()} !!}: ${q}`,X,$,z,U)}}),Q=G(Q,p5,W,(U)=>`<!--__STX_SCRIPT_EXPR_${U}__-->`),Q=G(Q,J,K,(U)=>`<!--__STX_STYLE_${U}__-->`),Q=Q.replace(/\{\{([\s\S]*?)\}\}/g,(U,_,z)=>{let j=_.trim(),q=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,F=j.match(H)?.[1],O=F&&((F in Z)||q.includes(F)),V=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,A=j.match(V),N=A&&!q.includes(A[1])&&!(A[1]in Z);if(/^__[A-Z_]+__$/.test(j))return"";try{let w=g0(_,Z);if(w===void 0&&B&&!RZ(j,Z))return U;if(w===void 0&&Z.__stx_buildMode==="compile"&&!B)return m5("expr",j);return w!==void 0&&w!==null?j0(String(w)):""}catch(w){if(B&&!RZ(j,Z))return U;if(N)return U;let R=w instanceof Error?w.message:String(w);return G0("Expression",`Error evaluating: {{ ${j} }}: ${R}`,X,$,z,U)}});for(let U=0;U<W.length;U++)Q=Q.replace(`<!--__STX_SCRIPT_EXPR_${U}__-->`,()=>W[U]);for(let U=0;U<K.length;U++)Q=Q.replace(`<!--__STX_STYLE_${U}__-->`,()=>K[U]);return Q}function EZ($,Z,X){if(!Z.trim())return $;let Y=$,Q=Z.trim();while(Q.length>0){let J=Q.match(/^(\w+)/);if(!J)break;let G=J[1];Q=Q.substring(G.length).trim();let K=b$[G]||P$[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(TZ()).join(", ")}`);let W=[];if(Q.startsWith(":")){let B=Q.match(/^:([^|\s]+)/);if(B){let U=B[1].trim();try{let _=Number(U);W=[Number.isNaN(_)?U:_]}catch{W=[U]}Q=Q.substring(B[0].length).trim()}}else if(Q.startsWith("(")){let B=1,U=1;while(B>0&&U<Q.length){if(Q[U]==="(")B++;if(Q[U]===")")B--;U++}if(B===0){let _=Q.substring(1,U-1).trim();if(_)try{if(_.startsWith("{")&&_.endsWith("}"))W=[g0(`(${_})`,X,!0)];else{let z=[],j="",q=null,H=0,L=0,F=0,O=!1;for(let V=0;V<_.length;V++){let A=_[V];if(O){j+=A,O=!1;continue}if(A==="\\"){j+=A,O=!0;continue}if(q){if(j+=A,A===q)q=null;continue}if(A==='"'||A==="'"||A==="`"){q=A,j+=A;continue}if(A==="(")H++;else if(A===")")H--;else if(A==="[")L++;else if(A==="]")L--;else if(A==="{")F++;else if(A==="}")F--;if(A===","&&H===0&&L===0&&F===0){z.push(j),j="";continue}j+=A}if(j)z.push(j);W=z.map((V)=>{let A=V.trim();return g0(A,X,!0)})}}catch{W=[_]}Q=Q.substring(U).trim()}}try{Y=K(Y,X,...W)}catch(B){let U=B instanceof Error?B.message:String(B);throw Error(`Error applying filter '${G}': ${U}`)}if(Q.startsWith("|"))Q=Q.substring(1).trim();else break}return Y}function XK($){let Z=!1,X="",Y=0,Q=0,J=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],B=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,X=W;else if(W===X)Z=!1,X="";continue}if(Z&&X==="`"&&W==="$"&&B==="{"){let U=1;K+=2;while(K<$.length&&U>0){if($[K]==="{")U++;else if($[K]==="}")U--;if(U>0)K++}continue}if(Z)continue;if(W==="(")Y++;else if(W===")")Y--;else if(W==="[")Q++;else if(W==="]")Q--;else if(W==="{")J++;else if(W==="}")J--;if(W==="|"&&Y===0&&Q===0&&J===0){if(B==="|"){K++;continue}if(B==="="){K++;continue}return K}}return-1}function g0($,Z,X=!1){try{let Y=$.trim(),Q=XK(Y);if(Q>0){let J=Y.substring(0,Q).trim(),G=Y.substring(Q+1).trim(),K=g0(J,Z,!0);return EZ(K,G,Z)}if(!X0(Y)){if(!X)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${Y}`);return Z0(Y,Z)}try{let J=Object.keys(Z),G=Object.values(Z);return Y0(Y,J)(...G)}catch{return Z0(Y,Z)}}catch(Y){if(Y instanceof ReferenceError){let Q=/(\b\w+)\s+is not defined/.exec(Y.message);if(Q){let J=Q[1],G=YK(J,Object.keys(Z));if(G&&G!==J)Y.message=`${Y.message} \u2014 did you mean '${G}'?`}}if(!X)console.error(`Error evaluating expression: ${$}`,Y);throw Y}}function YK($,Z){let X=null;for(let Q of Z){if(Q===$)continue;let J=JK($,Q);if(X===null||J<X.dist)X={key:Q,dist:J}}if(!X)return null;let Y=Math.max($.length,X.key.length);if(X.dist<=2||X.dist/Y<=0.35)return X.key;return null}function JK($,Z){if($===Z)return 0;if($.length===0)return Z.length;if(Z.length===0)return $.length;let[X,Y]=$.length<Z.length?[$,Z]:[Z,$],Q=Array(X.length+1),J=Array(X.length+1);for(let G=0;G<=X.length;G++)Q[G]=G;for(let G=1;G<=Y.length;G++){J[0]=G;for(let K=1;K<=X.length;K++){let W=X[K-1]===Y[G-1]?0:1;J[K]=Math.min(J[K-1]+1,Q[K]+1,Q[K-1]+W)}for(let K=0;K<=X.length;K++)Q[K]=J[K]}return Q[X.length]}function T4($){if(!$)return"";return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}var b$,wZ,P$;var T0=T(()=>{L0();Q0();S$();c5();b$={},wZ=new Map;P$={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let X=String($);return X.charAt(0).toUpperCase()+X.slice(1)},number:($,Z,X=0)=>{if($===void 0||$===null)return"";try{let Y=Number($);return Number.isNaN(Y)?"":Y.toFixed(Number.parseInt(String(X),10))}catch{return""}},fmt:($,Z,X="en-US")=>{if($===void 0||$===null)return"";try{let Y=Number($);if(Number.isNaN(Y))return String($);return Y.toLocaleString(X)}catch{return String($)}},join:($,Z,X=",")=>{if(!Array.isArray($))return"";return $.join(String(X))},escape:($,Z)=>{if($===void 0||$===null)return"";return j0(String($))},translate:($,Z,X={})=>{if(!Z||!Z.__translations)return $;let Y=Z.__translations,Q=Z.__i18nConfig?.fallbackToKey??!0,J=String($).split("."),G=Y;for(let W of J){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return Q?$:"";let K=String(G);return Object.entries(X).forEach(([W,B])=>{K=K.replace(tG(W),String(B))}),K},t:($,Z,X={})=>{return P$.translate($,Z,X)},truncate:($,Z,X=50,Y="...")=>{if($===void 0||$===null)return"";let Q=String($);if(Q.length<=X)return Q;if(X<=Y.length)return Y.substring(0,X);return Q.substring(0,X-Y.length)+Y},date:($,Z,X="short",Y="en-US")=>{if($===void 0||$===null)return"";try{let Q=$ instanceof Date?$:new Date($);if(Number.isNaN(Q.getTime()))return String($);let J={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(X==="iso")return Q.toISOString();return new Intl.DateTimeFormat(Y,J[X]||J.short).format(Q)}catch{return String($)}},currency:($,Z,X="USD",Y="en-US")=>{if($===void 0||$===null)return"";try{let Q=Number($);if(Number.isNaN(Q))return String($);return new Intl.NumberFormat(Y,{style:"currency",currency:X}).format(Q)}catch{return String($)}},pluralize:($,Z,X,Y)=>{let Q=Number($);if(Number.isNaN(Q))return X;let J=Y||`${X}s`;return Q===1?X:J},first:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[0];return String($).charAt(0)},last:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[$.length-1];let X=String($);return X.charAt(X.length-1)},length:($,Z)=>{if($===void 0||$===null)return 0;if(Array.isArray($)||typeof $==="string")return $.length;if($ instanceof Map||$ instanceof Set)return $.size;if(typeof $==="object")return Object.keys($).length;return 0},json:($,Z,X=!1)=>{if($===void 0)return"undefined";if($===null)return"null";try{return X?JSON.stringify($,null,2):JSON.stringify($)}catch{return String($)}},default:($,Z,X="")=>{return $===void 0||$===null||$===""?X:$},reverse:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return[...$].reverse();return String($).split("").reverse().join("")},slice:($,Z,X=0,Y)=>{if($===void 0||$===null)return"";if(Array.isArray($)||typeof $==="string")return $.slice(X,Y);return $},replace:($,Z,X,Y="")=>{if($===void 0||$===null)return"";let Q=X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(Q,"g"),()=>Y)},stripTags:($,Z)=>{if($===void 0||$===null)return"";return String($).replace(/<[^>]*>/g,"")},urlencode:($,Z)=>{if($===void 0||$===null)return"";return encodeURIComponent(String($))},abs:($,Z)=>{let X=Number($);return Number.isNaN(X)?0:Math.abs(X)},round:($,Z,X=0)=>{let Y=Number($);if(Number.isNaN(Y))return 0;let Q=10**X;return Math.round(Y*Q)/Q}}});class y${cache=new Map;maxSize;constructor($=100){this.maxSize=$}get($){if(!this.cache.has($))return;let Z=this.cache.get($);return this.cache.delete($),this.cache.set($,Z),Z}set($,Z){if(this.cache.has($))this.cache.delete($);else if(this.cache.size>=this.maxSize){let X=this.cache.keys().next().value;if(X!==void 0)this.cache.delete(X)}this.cache.set($,Z)}has($){return this.cache.has($)}delete($){return this.cache.delete($)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}function Y$($,Z){if(Z?.includes("g"))return new RegExp($,Z);let X=`${$}:${Z||""}`;if(!X$.has(X)){if(X$.size>=QK){let Y=X$.keys().next().value;if(Y)X$.delete(Y)}X$.set(X,new RegExp($,Z))}return X$.get(X)}class DZ{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),X=Z.sort().join(","),Y=this.pool.find((K)=>K.context.join(",")===X);if(Y)return Y.func;let Q=this.fnCache,J=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let B=`${X}:${W}`,U=Q.get(B);if(!U){if(Q.size>=J){let _=Q.keys().next().value;if(_)Q.delete(_)}U=Function(...Z,`
723
+ `),K=G([]);if(J.length===Z.length)return jZ(K,J,G);return jZ((...B)=>{let U=Array(Q.length);for(let _=0;_<Q.length;_++)U[_]=B[Q[_]];return K(...U)},J,G,(B)=>{K=G(B)})}function jZ($,Z,X,Y){let J=/^(\w+) is not defined$/,G=$,K=[],W=new Set(Z);return(...B)=>{for(let U=0;U<=8;U++)try{return G(...B)}catch(_){let z=_ instanceof Error?_.message:"",j=J.exec(z);if(!(_ instanceof ReferenceError)||!j)return;let q=j[1];if(W.has(q)||FZ.has(q))return;W.add(q),K.push(q),G=X(K),Y?.(K)}return}}function u5($){let Z=$.trim(),X=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let Y of X)if(Y.test(Z))return!1;return!0}var hG,HZ,OZ,dG,LZ,uG,FZ;var L0=T(()=>{hG={maxSanitizeDepth:10,allowBracketNotation:!1},HZ={...hG},OZ=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],dG=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),LZ=new Set(["__proto__","constructor","prototype"]),uG=/[\w)\]]\s*\[\s*['"]/;FZ=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"])});function m5($,Z){let X=iG++,Y=`<!--__STX_${$.toUpperCase()}_${X}__-->`;return nG.set(Y,{type:$,expression:Z}),Y}var iG=0,nG;var S$=T(()=>{nG=new Map});function VZ($,Z,X,Y){X.lastIndex=Z;let Q=X.exec($);if(!Q||Q.index!==Z)return-1;Y.lastIndex=X.lastIndex;let J=Y.exec($);if(!J)return-1;return J.index+J[0].length}function p5($,Z){return VZ($,Z,rG,sG)}function NZ($,Z){return VZ($,Z,oG,aG)}function AZ($,Z){if(!$.startsWith("<!--",Z))return-1;let X=$.indexOf("-->",Z+4);if(X===-1)return-1;return X+3}function C$($,Z,X){let Y=[],Q="",J=0,G=$.length,K=!1,W=null;while(J<G){let B=$[J];if(K){if(Q+=B,W){if(B===W)W=null}else if(B==='"'||B==="'")W=B;else if(B===">")K=!1;J++;continue}if(B==="<"){let U=Z($,J);if(U>J){Q+=X($.slice(J,U),Y.length),Y.push($.slice(J,U)),J=U;continue}if(/^<\/?[a-zA-Z]/.test($.slice(J,J+2)))K=!0;Q+=B,J++;continue}Q+=B,J++}return{output:Q,tokens:Y}}function R4($){let{output:Z,tokens:X}=C$($,p5,(Y,Q)=>`\x00STX_SCRIPT_${Q}\x00`);return{output:Z,scripts:X}}function M4($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(X,Y)=>Z[+Y]??"")}var rG,sG,oG,aG;var c5=T(()=>{rG=/<script\b[^>]*>/iy,sG=/<\/script\s*>/ig,oG=/<style\b[^>]*>/iy,aG=/<\/style\s*>/ig});var I4={};a(I4,{usesSignalsInScript:()=>Z$,unescapeHtml:()=>T4,registerFilters:()=>eG,registerFilter:()=>MZ,processExpressions:()=>i0,interpolateScriptsInTemplate:()=>ZK,interpolateScriptExpressions:()=>IZ,getAllFilters:()=>TZ,evaluateExpression:()=>g0,escapeHtml:()=>j0,defaultFilters:()=>P$,clearCustomFilters:()=>$K,applyFilters:()=>EZ});function tG($){let Z=wZ.get($);if(!Z){let X=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${X}(?!\\w)`,"g"),wZ.set($,Z)}return Z.lastIndex=0,Z}function MZ($,Z){if($ in P$)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);b$[$]=Z}function eG($){for(let[Z,X]of Object.entries($))MZ(Z,X)}function TZ(){return{...P$,...b$}}function $K(){for(let $ of Object.keys(b$))delete b$[$]}function j0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Z$($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Z.exec($))!==null){let Y=X[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(Y))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test($))return!0;return!1}function RZ($,Z){let X=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],Y=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),Q="",J=!1,G=0;for(let B=0;B<Y.length;B++){let U=Y[B];if(!J&&U==="`"){J=!0,G=0;continue}if(J){if(U==="`"&&G===0){J=!1;continue}if(U==="$"&&Y[B+1]==="{"){G++,B++;continue}if(U==="}"&&G>0){G--;continue}continue}Q+=U}Y=Q;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,W;while((W=K.exec(Y))!==null){let B=W[1];if(!Y.substring(0,W.index).trimEnd().endsWith(".")){if(!X.includes(B)&&!(B in Z))return!1}}return!0}function IZ($,Z){let X=$;return X=X.replace(/\{!!([\s\S]*?)!!\}/g,(Y,Q)=>{try{let J=g0(Q,Z);if(J===void 0)return Y;return J===null?"":String(J)}catch{return Y}}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(Y,Q)=>{let J=Q.trim();if(/^__[A-Z_]+__$/.test(J))return Y;try{let G=g0(Q,Z);if(G===void 0)return Y;return JSON.stringify(G)}catch{return Y}}),X}function ZK($,Z,X={}){return $.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(Y,Q,J)=>{if(/\bsrc\s*=/.test(Q))return Y;if(/\bdata-raw\b/.test(Q))return Y;if(/\btype\s*=\s*["']application\/json["']/.test(Q))return Y;if(X.skipServer&&/\bserver\b/.test(Q))return Y;let G=IZ(J,Z);return`<script${Q}>${G}</script>`})}function i0($,Z,X,Y){let Q=$,J=(U,_)=>{let z=NZ(U,_);if(z===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(U.slice(_,z))?-1:z},G=(U,_,z,j)=>{let q=z.length,{output:H,tokens:L}=C$(U,_,(F,O)=>j(q+O));return z.push(...L),H},K=[];Q=G(Q,J,K,(U)=>`<!--__STX_STYLE_${U}__-->`);let W=[];Q=G(Q,p5,W,(U)=>`<!--__STX_SCRIPT_EXPR_${U}__-->`);let B=Y?.forceSignals===!0||Z$($);Q=Q.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(U,_,z)=>{try{let j=g0(_,Z);return j!==void 0&&j!==null?String(j):""}catch(j){let q=j instanceof Error?j.message:String(j);return G0("Expression",`Error evaluating: {{{ ${_.trim()}}}}: ${q}`,X,$,z,U)}}),Q=Q.replace(/\{!!([\s\S]*?)!!\}/g,(U,_,z)=>{try{let j=g0(_,Z);if(j===void 0&&Z.__stx_buildMode==="compile")return m5("raw",_.trim());return j!==void 0&&j!==null?String(j):""}catch(j){if(Z.__stx_buildMode==="compile")return m5("raw",_.trim());let q=j instanceof Error?j.message:String(j);return G0("Expression",`Error evaluating: {!! ${_.trim()} !!}: ${q}`,X,$,z,U)}}),Q=G(Q,p5,W,(U)=>`<!--__STX_SCRIPT_EXPR_${U}__-->`),Q=G(Q,J,K,(U)=>`<!--__STX_STYLE_${U}__-->`),Q=Q.replace(/\{\{([\s\S]*?)\}\}/g,(U,_,z)=>{let j=_.trim(),q=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,F=j.match(H)?.[1],O=F&&((F in Z)||q.includes(F)),V=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,A=j.match(V),N=A&&!q.includes(A[1])&&!(A[1]in Z);if(/^__[A-Z_]+__$/.test(j))return"";try{let w=g0(_,Z);if(w===void 0&&B&&!RZ(j,Z))return U;if(w===void 0&&Z.__stx_buildMode==="compile"&&!B)return m5("expr",j);return w!==void 0&&w!==null?j0(String(w)):""}catch(w){if(B&&!RZ(j,Z))return U;if(N)return U;let R=w instanceof Error?w.message:String(w);return G0("Expression",`Error evaluating: {{ ${j} }}: ${R}`,X,$,z,U)}});for(let U=0;U<W.length;U++)Q=Q.replace(`<!--__STX_SCRIPT_EXPR_${U}__-->`,()=>W[U]);for(let U=0;U<K.length;U++)Q=Q.replace(`<!--__STX_STYLE_${U}__-->`,()=>K[U]);return Q}function EZ($,Z,X){if(!Z.trim())return $;let Y=$,Q=Z.trim();while(Q.length>0){let J=Q.match(/^(\w+)/);if(!J)break;let G=J[1];Q=Q.substring(G.length).trim();let K=b$[G]||P$[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(TZ()).join(", ")}`);let W=[];if(Q.startsWith(":")){let B=Q.match(/^:([^|\s]+)/);if(B){let U=B[1].trim();try{let _=Number(U);W=[Number.isNaN(_)?U:_]}catch{W=[U]}Q=Q.substring(B[0].length).trim()}}else if(Q.startsWith("(")){let B=1,U=1;while(B>0&&U<Q.length){if(Q[U]==="(")B++;if(Q[U]===")")B--;U++}if(B===0){let _=Q.substring(1,U-1).trim();if(_)try{if(_.startsWith("{")&&_.endsWith("}"))W=[g0(`(${_})`,X,!0)];else{let z=[],j="",q=null,H=0,L=0,F=0,O=!1;for(let V=0;V<_.length;V++){let A=_[V];if(O){j+=A,O=!1;continue}if(A==="\\"){j+=A,O=!0;continue}if(q){if(j+=A,A===q)q=null;continue}if(A==='"'||A==="'"||A==="`"){q=A,j+=A;continue}if(A==="(")H++;else if(A===")")H--;else if(A==="[")L++;else if(A==="]")L--;else if(A==="{")F++;else if(A==="}")F--;if(A===","&&H===0&&L===0&&F===0){z.push(j),j="";continue}j+=A}if(j)z.push(j);W=z.map((V)=>{let A=V.trim();return g0(A,X,!0)})}}catch{W=[_]}Q=Q.substring(U).trim()}}try{Y=K(Y,X,...W)}catch(B){let U=B instanceof Error?B.message:String(B);throw Error(`Error applying filter '${G}': ${U}`)}if(Q.startsWith("|"))Q=Q.substring(1).trim();else break}return Y}function XK($){let Z=!1,X="",Y=0,Q=0,J=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],B=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,X=W;else if(W===X)Z=!1,X="";continue}if(Z&&X==="`"&&W==="$"&&B==="{"){let U=1;K+=2;while(K<$.length&&U>0){if($[K]==="{")U++;else if($[K]==="}")U--;if(U>0)K++}continue}if(Z)continue;if(W==="(")Y++;else if(W===")")Y--;else if(W==="[")Q++;else if(W==="]")Q--;else if(W==="{")J++;else if(W==="}")J--;if(W==="|"&&Y===0&&Q===0&&J===0){if(B==="|"){K++;continue}if(B==="="){K++;continue}return K}}return-1}function g0($,Z,X=!1){try{let Y=$.trim(),Q=XK(Y);if(Q>0){let J=Y.substring(0,Q).trim(),G=Y.substring(Q+1).trim(),K=g0(J,Z,!0);return EZ(K,G,Z)}if(!X0(Y)){if(!X)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${Y}`);return Z0(Y,Z)}try{let J=Object.keys(Z),G=Object.values(Z);return Y0(Y,J)(...G)}catch{return Z0(Y,Z)}}catch(Y){if(Y instanceof ReferenceError){let Q=/(\b\w+)\s+is not defined/.exec(Y.message);if(Q){let J=Q[1],G=YK(J,Object.keys(Z));if(G&&G!==J)Y.message=`${Y.message} \u2014 did you mean '${G}'?`}}if(!X)console.error(`Error evaluating expression: ${$}`,Y);throw Y}}function YK($,Z){let X=null;for(let Q of Z){if(Q===$)continue;let J=JK($,Q);if(X===null||J<X.dist)X={key:Q,dist:J}}if(!X)return null;let Y=Math.max($.length,X.key.length);if(X.dist<=2||X.dist/Y<=0.35)return X.key;return null}function JK($,Z){if($===Z)return 0;if($.length===0)return Z.length;if(Z.length===0)return $.length;let[X,Y]=$.length<Z.length?[$,Z]:[Z,$],Q=Array(X.length+1),J=Array(X.length+1);for(let G=0;G<=X.length;G++)Q[G]=G;for(let G=1;G<=Y.length;G++){J[0]=G;for(let K=1;K<=X.length;K++){let W=X[K-1]===Y[G-1]?0:1;J[K]=Math.min(J[K-1]+1,Q[K]+1,Q[K-1]+W)}for(let K=0;K<=X.length;K++)Q[K]=J[K]}return Q[X.length]}function T4($){if(!$)return"";return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}var b$,wZ,P$;var I0=T(()=>{L0();Q0();S$();c5();b$={},wZ=new Map;P$={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let X=String($);return X.charAt(0).toUpperCase()+X.slice(1)},number:($,Z,X=0)=>{if($===void 0||$===null)return"";try{let Y=Number($);return Number.isNaN(Y)?"":Y.toFixed(Number.parseInt(String(X),10))}catch{return""}},fmt:($,Z,X="en-US")=>{if($===void 0||$===null)return"";try{let Y=Number($);if(Number.isNaN(Y))return String($);return Y.toLocaleString(X)}catch{return String($)}},join:($,Z,X=",")=>{if(!Array.isArray($))return"";return $.join(String(X))},escape:($,Z)=>{if($===void 0||$===null)return"";return j0(String($))},translate:($,Z,X={})=>{if(!Z||!Z.__translations)return $;let Y=Z.__translations,Q=Z.__i18nConfig?.fallbackToKey??!0,J=String($).split("."),G=Y;for(let W of J){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return Q?$:"";let K=String(G);return Object.entries(X).forEach(([W,B])=>{K=K.replace(tG(W),String(B))}),K},t:($,Z,X={})=>{return P$.translate($,Z,X)},truncate:($,Z,X=50,Y="...")=>{if($===void 0||$===null)return"";let Q=String($);if(Q.length<=X)return Q;if(X<=Y.length)return Y.substring(0,X);return Q.substring(0,X-Y.length)+Y},date:($,Z,X="short",Y="en-US")=>{if($===void 0||$===null)return"";try{let Q=$ instanceof Date?$:new Date($);if(Number.isNaN(Q.getTime()))return String($);let J={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(X==="iso")return Q.toISOString();return new Intl.DateTimeFormat(Y,J[X]||J.short).format(Q)}catch{return String($)}},currency:($,Z,X="USD",Y="en-US")=>{if($===void 0||$===null)return"";try{let Q=Number($);if(Number.isNaN(Q))return String($);return new Intl.NumberFormat(Y,{style:"currency",currency:X}).format(Q)}catch{return String($)}},pluralize:($,Z,X,Y)=>{let Q=Number($);if(Number.isNaN(Q))return X;let J=Y||`${X}s`;return Q===1?X:J},first:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[0];return String($).charAt(0)},last:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[$.length-1];let X=String($);return X.charAt(X.length-1)},length:($,Z)=>{if($===void 0||$===null)return 0;if(Array.isArray($)||typeof $==="string")return $.length;if($ instanceof Map||$ instanceof Set)return $.size;if(typeof $==="object")return Object.keys($).length;return 0},json:($,Z,X=!1)=>{if($===void 0)return"undefined";if($===null)return"null";try{return X?JSON.stringify($,null,2):JSON.stringify($)}catch{return String($)}},default:($,Z,X="")=>{return $===void 0||$===null||$===""?X:$},reverse:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return[...$].reverse();return String($).split("").reverse().join("")},slice:($,Z,X=0,Y)=>{if($===void 0||$===null)return"";if(Array.isArray($)||typeof $==="string")return $.slice(X,Y);return $},replace:($,Z,X,Y="")=>{if($===void 0||$===null)return"";let Q=X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(Q,"g"),()=>Y)},stripTags:($,Z)=>{if($===void 0||$===null)return"";return String($).replace(/<[^>]*>/g,"")},urlencode:($,Z)=>{if($===void 0||$===null)return"";return encodeURIComponent(String($))},abs:($,Z)=>{let X=Number($);return Number.isNaN(X)?0:Math.abs(X)},round:($,Z,X=0)=>{let Y=Number($);if(Number.isNaN(Y))return 0;let Q=10**X;return Math.round(Y*Q)/Q}}});class y${cache=new Map;maxSize;constructor($=100){this.maxSize=$}get($){if(!this.cache.has($))return;let Z=this.cache.get($);return this.cache.delete($),this.cache.set($,Z),Z}set($,Z){if(this.cache.has($))this.cache.delete($);else if(this.cache.size>=this.maxSize){let X=this.cache.keys().next().value;if(X!==void 0)this.cache.delete(X)}this.cache.set($,Z)}has($){return this.cache.has($)}delete($){return this.cache.delete($)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}function Y$($,Z){if(Z?.includes("g"))return new RegExp($,Z);let X=`${$}:${Z||""}`;if(!X$.has(X)){if(X$.size>=QK){let Y=X$.keys().next().value;if(Y)X$.delete(Y)}X$.set(X,new RegExp($,Z))}return X$.get(X)}class DZ{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),X=Z.sort().join(","),Y=this.pool.find((K)=>K.context.join(",")===X);if(Y)return Y.func;let Q=this.fnCache,J=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let B=`${X}:${W}`,U=Q.get(B);if(!U){if(Q.size>=J){let _=Q.keys().next().value;if(_)Q.delete(_)}U=Function(...Z,`
724
724
  'use strict';
725
725
  try {
726
726
  return ${W};
@@ -731,8 +731,8 @@ catch (e) {
731
731
  }
732
732
  throw e;
733
733
  }
734
- `),Q.set(B,U)}return U(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class kZ{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,X]of Object.entries($))this.setBudget(Z,X)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,X]of this.budgets.entries())$[Z]=X;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let X=performance.now(),Y=Z(),Q=performance.now()-X;return this.recordTime($,Q),this.checkBudget($,Q),Y}async timeAsync($,Z){if(!this.enabled)return Z();let X=performance.now(),Y=await Z(),Q=performance.now()-X;return this.recordTime($,Q),this.checkBudget($,Q),Y}checkBudget($,Z){let X=this.budgets.get($);if(!X)return;let Y=Z/X.maxTime*100,Q=X.warnThreshold!==void 0?Z>=X.maxTime*X.warnThreshold&&Z<X.maxTime:!1,J=Z>=X.maxTime;if(!Q&&!J)return;let G={label:$,actualTime:Z,budgetTime:X.maxTime,exceedancePercent:Y,timestamp:new Date,isWarning:Q};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(G)}catch{}let K=Q?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${Y.toFixed(1)}% of ${X.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${X.maxTime}ms budget by ${(Y-100).toFixed(1)}%)`;switch(X.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(J)throw Error(K);else console.warn(K);break}}recordTime($,Z){let X=this.metrics.get($);if(X)X.count++,X.totalTime+=Z,X.maxTime=Math.max(X.maxTime,Z),X.minTime=Math.min(X.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let X=this.metrics.get($);if(!X)return{};let Y=this.budgets.get($);return{count:X.count,avgTime:X.totalTime/X.count,totalTime:X.totalTime,maxTime:X.maxTime,minTime:X.minTime,budget:Y?.maxTime,budgetUtilization:Y?X.totalTime/X.count/Y.maxTime*100:void 0}}let Z={};for(let[X,Y]of this.metrics.entries()){let Q=this.budgets.get(X);Z[X]={count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:Q?.maxTime,budgetUtilization:Q?Y.totalTime/Y.count/Q.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,X=0;for(let Y of this.violations)if($[Y.label]=($[Y.label]||0)+1,Y.isWarning)Z++;else X++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:X}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function GK(){if(!E4)E4=new kZ;return E4}var X$,QK=500,ML,E4=null,x$;var v1=T(()=>{X$=new Map;ML=new DZ;x$=new Proxy({},{get($,Z){return GK()[Z]}})});var x;var v$=T(()=>{x={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"}});import SZ from"fs";import J0 from"path";function S4($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function k4($,Z){if(f1.has($))f1.delete($);else if(f1.size>=KK)f1.delete(f1.keys().next().value);f1.set($,Z)}async function WK($){if(!B1)return null;try{let Z=Bun.file(J0.join(B1,`cw-${S4($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function UK($,Z){if(!B1)return;try{if(!SZ.existsSync(B1))SZ.mkdirSync(B1,{recursive:!0});await Bun.write(J0.join(B1,`cw-${S4($)}.css`),Z)}catch{}}async function bZ($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function BK(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",X=process.cwd();while(X!==J0.dirname(X))$.push(J0.join(X,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(J0.join(X,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(J0.join(X,"pantry","@cwcss","crosswind","dist","index.js")),$.push(J0.join(X,"pantry","@cwcss","crosswind","src","index.ts")),$.push(J0.join(X,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(J0.join(X,"pantry","@stacksjs","crosswind","dist","index.js")),X=J0.dirname(X);if(Z){let Y=[J0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),J0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),J0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),J0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),J0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),J0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(J0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(J0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function _K(){if(CZ)return f$;CZ=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let X of $){let Y=await bZ(X);if(Y){if(f$=Y,!process.env.STACKS_DEV_QUIET)console.log(`${x.green}[Crosswind]${x.reset} CSS engine loaded`);return f$}}let Z=BK();for(let X of Z)if(await Bun.file(X).exists()){let Y=await bZ(X);if(Y){if(f$=Y,!process.env.STACKS_DEV_QUIET)console.log(`${x.green}[Crosswind]${x.reset} CSS engine loaded from ${J0.dirname(J0.dirname(X))}`);return f$}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${x.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${x.reset}`),console.warn(`${x.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${x.reset}`),null}}async function zK($){try{let{loadConfigWithResult:Z}=await import("bunfig"),X=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!X?.path||!X.config||Object.keys(X.config).length===0)return null;let Y=J0.relative($,X.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${x.green}[Crosswind]${x.reset} Loaded config from ${Y||X.path}`);return X.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${x.yellow}[Crosswind]${x.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}function PZ($){let Z=new Set,X=/class\s*=\s*["']([^"']+)["']/gi,Y=X.exec($);while(Y!==null){for(let G of Y[1].split(/\s+/))if(G.trim())Z.add(G.trim());Y=X.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let W of K.slice(1,-1).split(/\s+/))if(W.trim())Z.add(W.trim())}J=Q.exec($)}return Z}async function yZ($,Z){try{let X=await _K();if(!X)return"";let Y=PZ($);if(Y.size===0)return"";let Q=Z?J0.resolve(Z):process.cwd();if(!B1)B1=J0.join(Q,".stx/cache");let J=[...Y].sort().join(" "),G=`${D4||"default"}::${J}`,K=f1.get(G);if(K!==void 0)return k4(G,K),K;let W=await WK(G);if(W!==null)return k4(G,W),W;if(!l5){let N=null;try{let{loadStxConfig:w}=await Promise.resolve().then(() => (I0(),xZ)),R=await w(Q);if(R.css)if(typeof R.css==="string"){let M=J0.isAbsolute(R.css)?R.css:J0.resolve(Q,R.css);if(await Bun.file(M).exists()){let I=await import(M);N=I.default||I,console.log(`${x.green}[Crosswind]${x.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(N={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let M=J0.isAbsolute(R.css.config)?R.css.config:J0.resolve(Q,R.css.config);if(await Bun.file(M).exists()){let I=await import(M);N={...I.default||I,...N}}}console.log(`${x.green}[Crosswind]${x.reset} Using inline CSS config from stx.config.ts`)}}catch{}l5=N||await zK(Q);try{D4=S4(JSON.stringify(l5??{}))}catch{D4="unhashable"}}let B=X.defaultConfig||X.config,U=l5||{},_=B.theme||{},j=(U.theme||{}).extend||{},q={..._};if(Object.keys(j).length>0)q.extend=j;let H=[...B.safelist||[],...U.safelist||[]],L={...B,...U,content:[],output:"",preflight:!0,minify:!1,theme:q,safelist:H},F=new X.CSSGenerator(L);for(let N of H)F.generate(N);for(let N of Y)F.generate(N);let O=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[N,w]of Object.entries(V)){if(!Y.has(N)&&!H.includes(N))continue;let R=w.split(/\s+/).filter(Boolean);for(let M of R)F.generate(M)}O=F.toCSS(!0,!1);let A=O.split(`
735
- `);for(let[N,w]of Object.entries(V)){if(!Y.has(N)&&!H.includes(N))continue;let R=w.split(/\s+/).filter(Boolean),M=[],I=[];for(let E of R){let D=E.startsWith("dark:"),S=`.${(D?E.slice(5):E).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let C=0;C<A.length;C++){let y=A[C].trim();if(y===`${S} {`||y.startsWith(`${S} {`)){let m=C,g="";while(m<A.length){if(g+=A[m],A[m].includes("}"))break;m++}let p=g.match(/\{([^}]+)\}/);if(p)if(D)I.push(p[1].trim());else M.push(p[1].trim());break}}}if(M.length)O+=`
734
+ `),Q.set(B,U)}return U(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class kZ{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,X]of Object.entries($))this.setBudget(Z,X)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,X]of this.budgets.entries())$[Z]=X;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let X=performance.now(),Y=Z(),Q=performance.now()-X;return this.recordTime($,Q),this.checkBudget($,Q),Y}async timeAsync($,Z){if(!this.enabled)return Z();let X=performance.now(),Y=await Z(),Q=performance.now()-X;return this.recordTime($,Q),this.checkBudget($,Q),Y}checkBudget($,Z){let X=this.budgets.get($);if(!X)return;let Y=Z/X.maxTime*100,Q=X.warnThreshold!==void 0?Z>=X.maxTime*X.warnThreshold&&Z<X.maxTime:!1,J=Z>=X.maxTime;if(!Q&&!J)return;let G={label:$,actualTime:Z,budgetTime:X.maxTime,exceedancePercent:Y,timestamp:new Date,isWarning:Q};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(G)}catch{}let K=Q?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${Y.toFixed(1)}% of ${X.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${X.maxTime}ms budget by ${(Y-100).toFixed(1)}%)`;switch(X.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(J)throw Error(K);else console.warn(K);break}}recordTime($,Z){let X=this.metrics.get($);if(X)X.count++,X.totalTime+=Z,X.maxTime=Math.max(X.maxTime,Z),X.minTime=Math.min(X.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let X=this.metrics.get($);if(!X)return{};let Y=this.budgets.get($);return{count:X.count,avgTime:X.totalTime/X.count,totalTime:X.totalTime,maxTime:X.maxTime,minTime:X.minTime,budget:Y?.maxTime,budgetUtilization:Y?X.totalTime/X.count/Y.maxTime*100:void 0}}let Z={};for(let[X,Y]of this.metrics.entries()){let Q=this.budgets.get(X);Z[X]={count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:Q?.maxTime,budgetUtilization:Q?Y.totalTime/Y.count/Q.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,X=0;for(let Y of this.violations)if($[Y.label]=($[Y.label]||0)+1,Y.isWarning)Z++;else X++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:X}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function GK(){if(!E4)E4=new kZ;return E4}var X$,QK=500,ML,E4=null,x$;var v1=T(()=>{X$=new Map;ML=new DZ;x$=new Proxy({},{get($,Z){return GK()[Z]}})});var x;var v$=T(()=>{x={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"}});import SZ from"fs";import J0 from"path";function S4($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function k4($,Z){if(f1.has($))f1.delete($);else if(f1.size>=KK)f1.delete(f1.keys().next().value);f1.set($,Z)}async function WK($){if(!B1)return null;try{let Z=Bun.file(J0.join(B1,`cw-${S4($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function UK($,Z){if(!B1)return;try{if(!SZ.existsSync(B1))SZ.mkdirSync(B1,{recursive:!0});await Bun.write(J0.join(B1,`cw-${S4($)}.css`),Z)}catch{}}async function bZ($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function BK(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",X=process.cwd();while(X!==J0.dirname(X))$.push(J0.join(X,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(J0.join(X,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(J0.join(X,"pantry","@cwcss","crosswind","dist","index.js")),$.push(J0.join(X,"pantry","@cwcss","crosswind","src","index.ts")),$.push(J0.join(X,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(J0.join(X,"pantry","@stacksjs","crosswind","dist","index.js")),X=J0.dirname(X);if(Z){let Y=[J0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),J0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),J0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),J0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),J0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),J0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(J0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(J0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function _K(){if(CZ)return f$;CZ=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let X of $){let Y=await bZ(X);if(Y){if(f$=Y,!process.env.STACKS_DEV_QUIET)console.log(`${x.green}[Crosswind]${x.reset} CSS engine loaded`);return f$}}let Z=BK();for(let X of Z)if(await Bun.file(X).exists()){let Y=await bZ(X);if(Y){if(f$=Y,!process.env.STACKS_DEV_QUIET)console.log(`${x.green}[Crosswind]${x.reset} CSS engine loaded from ${J0.dirname(J0.dirname(X))}`);return f$}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${x.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${x.reset}`),console.warn(`${x.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${x.reset}`),null}}async function zK($){try{let{loadConfigWithResult:Z}=await import("bunfig"),X=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!X?.path||!X.config||Object.keys(X.config).length===0)return null;let Y=J0.relative($,X.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${x.green}[Crosswind]${x.reset} Loaded config from ${Y||X.path}`);return X.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${x.yellow}[Crosswind]${x.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}function PZ($){let Z=new Set,X=/class\s*=\s*["']([^"']+)["']/gi,Y=X.exec($);while(Y!==null){for(let G of Y[1].split(/\s+/))if(G.trim())Z.add(G.trim());Y=X.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let W of K.slice(1,-1).split(/\s+/))if(W.trim())Z.add(W.trim())}J=Q.exec($)}return Z}async function yZ($,Z){try{let X=await _K();if(!X)return"";let Y=PZ($);if(Y.size===0)return"";let Q=Z?J0.resolve(Z):process.cwd();if(!B1)B1=J0.join(Q,".stx/cache");let J=[...Y].sort().join(" "),G=`${D4||"default"}::${J}`,K=f1.get(G);if(K!==void 0)return k4(G,K),K;let W=await WK(G);if(W!==null)return k4(G,W),W;if(!l5){let N=null;try{let{loadStxConfig:w}=await Promise.resolve().then(() => (E0(),xZ)),R=await w(Q);if(R.css)if(typeof R.css==="string"){let M=J0.isAbsolute(R.css)?R.css:J0.resolve(Q,R.css);if(await Bun.file(M).exists()){let I=await import(M);N=I.default||I,console.log(`${x.green}[Crosswind]${x.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(N={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let M=J0.isAbsolute(R.css.config)?R.css.config:J0.resolve(Q,R.css.config);if(await Bun.file(M).exists()){let I=await import(M);N={...I.default||I,...N}}}console.log(`${x.green}[Crosswind]${x.reset} Using inline CSS config from stx.config.ts`)}}catch{}l5=N||await zK(Q);try{D4=S4(JSON.stringify(l5??{}))}catch{D4="unhashable"}}let B=X.defaultConfig||X.config,U=l5||{},_=B.theme||{},j=(U.theme||{}).extend||{},q={..._};if(Object.keys(j).length>0)q.extend=j;let H=[...B.safelist||[],...U.safelist||[]],L={...B,...U,content:[],output:"",preflight:!0,minify:!1,theme:q,safelist:H},F=new X.CSSGenerator(L);for(let N of H)F.generate(N);for(let N of Y)F.generate(N);let O=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[N,w]of Object.entries(V)){if(!Y.has(N)&&!H.includes(N))continue;let R=w.split(/\s+/).filter(Boolean);for(let M of R)F.generate(M)}O=F.toCSS(!0,!1);let A=O.split(`
735
+ `);for(let[N,w]of Object.entries(V)){if(!Y.has(N)&&!H.includes(N))continue;let R=w.split(/\s+/).filter(Boolean),M=[],I=[];for(let E of R){let D=E.startsWith("dark:"),S=`.${(D?E.slice(5):E).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<A.length;b++){let y=A[b].trim();if(y===`${S} {`||y.startsWith(`${S} {`)){let m=b,g="";while(m<A.length){if(g+=A[m],A[m].includes("}"))break;m++}let p=g.match(/\{([^}]+)\}/);if(p)if(D)I.push(p[1].trim());else M.push(p[1].trim());break}}}if(M.length)O+=`
736
736
  .${N} { ${M.join(" ")} }`;if(I.length)O+=`
737
737
  @media (prefers-color-scheme: dark) { .dark .${N} { ${I.join(" ")} } }`}return k4(G,O),UK(G,O),O}catch(X){return console.warn("Failed to generate Crosswind CSS:",X),""}}async function a0($,Z){let X=await yZ($,Z);if(!X)return $;let Y=`<style data-crosswind="generated">
738
738
  ${X}
@@ -1623,7 +1623,7 @@ window.__stx_reactive = (function() {
1623
1623
  ${yK()}
1624
1624
  ${X}
1625
1625
  </script>`}function aZ($,Z,X){if(oZ=0,!fK($))return $;let Y=SK($);if(Y.length===0)return $;let Q=vK($,Y),J=xK(Y,Z),G=Q.lastIndexOf("</body>");if(G!==-1)Q=Q.slice(0,G)+J+`
1626
- `+Q.slice(G);else Q+=J;return Q}function vK($,Z){let X=$;for(let Y of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${i5(Y.stateExpr)}["']`,"gi").exec(X);if(J)Y.id=J[1],Y.selector=`[data-stx-scope="${Y.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${i5(Y.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(X);if(K)Y.id=K[1],Y.selector=`[data-stx-scope="${Y.id}"]`;else X=X.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${i5(Y.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${Y.id}" $2$3$4`),X=X.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${i5(Y.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${Y.id}" $2$3$4`)}}return X=X.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),X=X.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),X=X.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),X=X.replace(/\s*x-init\s*=\s*'[^']*'/g,""),X}function fK($){return/x-data\s*=\s*["']/.test($)}var oZ=0,kK=0;var tZ=T(()=>{T0()});function _1($,Z){try{let X=$.trim();if(X0(X))return Y0(X,Object.keys(Z))(...Object.values(Z));else return Z0(X,Z)}catch{return!1}}var x4=T(()=>{L0()});function v4($){for(let[Z,X]of Object.entries(n))if(X===$)return Z;return}var n;var n5=T(()=>{n={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603}});function g$(){return!1}function g1(){return!g$()||process.env.STX_DEBUG==="true"}function r5(){return!1}import gK from"path";function s5(){return{...f4}}function o5($){if(!f4.showRelativePaths||!$)return $;let Z=f4.baseDir||process.cwd();try{let X=gK.relative(Z,$);return X.startsWith("..")?$:X}catch{return $}}var hK,f4,h$,t0,d$,a5;var t5=T(()=>{n5();hK={showRelativePaths:!1,enableAutoRecovery:g1(),logRecoveryWarnings:!0},f4={...hK};h$=class h$ extends Error{code;filePath;line;column;context;numericCode;constructor($,Z,X,Y,Q,J,G){super($);this.code=Z;this.filePath=X;this.line=Y;this.column=Q;this.context=J;if(this.name="StxError",this.numericCode=G||n.EVALUATION_ERROR,this.filePath)this.filePath=o5(this.filePath)}};t0=class t0 extends h${constructor($,Z,X,Y,Q,J){super($,"stx_RUNTIME_ERROR",Z,X,Y,Q,J||n.EVALUATION_ERROR);this.name="StxRuntimeError"}};d$=class d$ extends h${constructor($,Z,X,Y,Q,J){super($,"stx_FILE_ERROR",Z,X,Y,Q,J||n.FILE_NOT_FOUND);this.name="StxFileError"}};a5=class a5 extends h${isFatal=!0;constructor($,Z,X,Y,Q,J){super($,"stx_VALIDATION_ERROR",Z,X,Y,Q,J||n.DOM_API_VIOLATION);this.name="StxValidationError"}}});function $X($){let{type:Z,message:X,code:Y,filePath:Q,line:J,column:G,template:K,offset:W,snippet:B,suggestion:U,format:_="text"}=$,z=J,j=G;if(!z&&K&&W!==void 0){let O=lK(K,W);z=O.line,j=O.column}let q=Q?o5(Q):void 0,H=Y?v4(Y):void 0,L={type:Z,code:Y,codeName:H,message:X,filePath:q,line:z,column:j,snippet:B,suggestion:U,timestamp:new Date().toISOString()},F;switch(_){case"html":F=uK(L);break;case"json":F=JSON.stringify(L,null,2);break;case"console":F=mK(L,K,W);break;case"text":default:F=dK(L,K,W);break}return{formatted:F,data:L}}function dK($,Z,X){let Y=[],Q=$.code?` [${$.codeName||$.code}]`:"";if(Y.push(`[${$.type} Error${Q}]`),$.filePath){let J=$.filePath;if($.line){if(J+=`:${$.line}`,$.column)J+=`:${$.column}`}Y.push(`at ${J}`)}if(Y.push(`
1626
+ `+Q.slice(G);else Q+=J;return Q}function vK($,Z){let X=$;for(let Y of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${i5(Y.stateExpr)}["']`,"gi").exec(X);if(J)Y.id=J[1],Y.selector=`[data-stx-scope="${Y.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${i5(Y.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(X);if(K)Y.id=K[1],Y.selector=`[data-stx-scope="${Y.id}"]`;else X=X.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${i5(Y.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${Y.id}" $2$3$4`),X=X.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${i5(Y.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${Y.id}" $2$3$4`)}}return X=X.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),X=X.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),X=X.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),X=X.replace(/\s*x-init\s*=\s*'[^']*'/g,""),X}function fK($){return/x-data\s*=\s*["']/.test($)}var oZ=0,kK=0;var tZ=T(()=>{I0()});function _1($,Z){try{let X=$.trim();if(X0(X))return Y0(X,Object.keys(Z))(...Object.values(Z));else return Z0(X,Z)}catch{return!1}}var x4=T(()=>{L0()});function v4($){for(let[Z,X]of Object.entries(n))if(X===$)return Z;return}var n;var n5=T(()=>{n={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603}});function g$(){return!1}function g1(){return!g$()||process.env.STX_DEBUG==="true"}function r5(){return!1}import gK from"path";function s5(){return{...f4}}function o5($){if(!f4.showRelativePaths||!$)return $;let Z=f4.baseDir||process.cwd();try{let X=gK.relative(Z,$);return X.startsWith("..")?$:X}catch{return $}}var hK,f4,h$,t0,d$,a5;var t5=T(()=>{n5();hK={showRelativePaths:!1,enableAutoRecovery:g1(),logRecoveryWarnings:!0},f4={...hK};h$=class h$ extends Error{code;filePath;line;column;context;numericCode;constructor($,Z,X,Y,Q,J,G){super($);this.code=Z;this.filePath=X;this.line=Y;this.column=Q;this.context=J;if(this.name="StxError",this.numericCode=G||n.EVALUATION_ERROR,this.filePath)this.filePath=o5(this.filePath)}};t0=class t0 extends h${constructor($,Z,X,Y,Q,J){super($,"stx_RUNTIME_ERROR",Z,X,Y,Q,J||n.EVALUATION_ERROR);this.name="StxRuntimeError"}};d$=class d$ extends h${constructor($,Z,X,Y,Q,J){super($,"stx_FILE_ERROR",Z,X,Y,Q,J||n.FILE_NOT_FOUND);this.name="StxFileError"}};a5=class a5 extends h${isFatal=!0;constructor($,Z,X,Y,Q,J){super($,"stx_VALIDATION_ERROR",Z,X,Y,Q,J||n.DOM_API_VIOLATION);this.name="StxValidationError"}}});function $X($){let{type:Z,message:X,code:Y,filePath:Q,line:J,column:G,template:K,offset:W,snippet:B,suggestion:U,format:_="text"}=$,z=J,j=G;if(!z&&K&&W!==void 0){let O=lK(K,W);z=O.line,j=O.column}let q=Q?o5(Q):void 0,H=Y?v4(Y):void 0,L={type:Z,code:Y,codeName:H,message:X,filePath:q,line:z,column:j,snippet:B,suggestion:U,timestamp:new Date().toISOString()},F;switch(_){case"html":F=uK(L);break;case"json":F=JSON.stringify(L,null,2);break;case"console":F=mK(L,K,W);break;case"text":default:F=dK(L,K,W);break}return{formatted:F,data:L}}function dK($,Z,X){let Y=[],Q=$.code?` [${$.codeName||$.code}]`:"";if(Y.push(`[${$.type} Error${Q}]`),$.filePath){let J=$.filePath;if($.line){if(J+=`:${$.line}`,$.column)J+=`:${$.column}`}Y.push(`at ${J}`)}if(Y.push(`
1627
1627
  ${$.message}`),Z&&$.line){let J=pK(Z,$.line,2);if(J)Y.push(`
1628
1628
  ${J}`)}if($.snippet)Y.push(`
1629
1629
  Snippet: ${$.snippet}`);if($.suggestion)Y.push(`
@@ -1647,9 +1647,9 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
1647
1647
  `)}writeToFile($){this.writeQueue=this.writeQueue.then(async()=>{try{let Z=await import("fs"),Y=(await import("path")).dirname(this.logFilePath);if(!Z.existsSync(Y))Z.mkdirSync(Y,{recursive:!0});await this.rotateIfNeeded(Z);let Q=`${this.formatEntry($)}
1648
1648
  `;Z.appendFileSync(this.logFilePath,Q,"utf-8")}catch(Z){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",Z)}})}async rotateIfNeeded($){try{if(!$.existsSync(this.logFilePath))return;if($.statSync(this.logFilePath).size<this.maxFileSize)return;for(let X=this.maxLogFiles-1;X>=1;X--){let Y=`${this.logFilePath}.${X}`,Q=`${this.logFilePath}.${X+1}`;if($.existsSync(Y))if(X>=this.maxLogFiles-1)$.unlinkSync(Y);else $.renameSync(Y,Q)}if(this.maxLogFiles<=1)$.writeFileSync(this.logFilePath,"");else $.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(Z){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",Z)}}getRecentErrors($=10){return this.errors.slice(-$)}getErrorsByType($){return this.errors.filter((Z)=>Z.error.constructor.name===$)}getErrorsByLevel($){return this.errors.filter((Z)=>Z.level===$)}clear(){this.errors.length=0}async clearLogFile(){try{let $=await import("fs");if($.existsSync(this.logFilePath))$.writeFileSync(this.logFilePath,"","utf-8")}catch($){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",$)}}getStats(){let $={},Z={error:0,warning:0,info:0};for(let X of this.errors){let Y=X.error.constructor.name;$[Y]=($[Y]||0)+1;let Q=X.level||"error";Z[Q]=(Z[Q]||0)+1}return{total:this.errors.length,byType:$,byLevel:Z}}async exportToFile($,Z="json"){let X=await import("fs"),Q=(await import("path")).dirname($);if(!X.existsSync(Q))X.mkdirSync(Q,{recursive:!0});if(Z==="json"){let J=this.errors.map((G)=>({timestamp:G.timestamp.toISOString(),level:G.level||"error",type:G.error.constructor.name,message:G.error.message,stack:G.error.stack,context:G.context}));X.writeFileSync($,JSON.stringify(J,null,2),"utf-8")}else{let J=this.errors.map((G)=>this.formatEntry(G));X.writeFileSync($,J.join(`
1649
1649
 
1650
- `),"utf-8")}}async flush(){await this.writeQueue}}var g4,E0,u$;var XX=T(()=>{t5();g4={isEnabled(){return s5().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=s5();if(!Z.enableAutoRecovery)return{fixed:$,fixes:[]};let X=$,Y=[],Q=(X.match(/\{\{/g)||[]).length,J=(X.match(/\}\}/g)||[]).length;if(Q>J){let K=Q-J;X+="}}".repeat(K),Y.push(`Added ${K} missing closing braces '}}'`)}let G=["if","foreach","for","switch","section"];for(let K of G){let W=(X.match(new RegExp(`@${K}\\b`,"g"))||[]).length,B=(X.match(new RegExp(`@end${K}\\b`,"g"))||[]).length;if(W>B){let U=W-B;for(let _=0;_<U;_++)X+=`
1651
- @end${K}`;Y.push(`Added ${U} missing @end${K}`)}}if(Y.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),Y.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:X,fixes:Y}},createFallbackContent($,Z){if(g1())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};E0=new h4,u$={isDevelopment(){return g1()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let X=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)X.push(`Context: ${JSON.stringify(Z,null,2)}`);return X.push("========================"),X.join(`
1652
- `)}}});var YX=()=>{};var JX=T(()=>{n5();ZX();XX();YX();t5()});var d0=T(()=>{JX()});function b0($,Z,X,Y=0){let Q=0,J=Y,G=null,K=0,W=!1;while(J<$.length){let B=$[J];if(G&&W){W=!1,J++;continue}if(G&&B==="\\"){W=!0,J++;continue}if(W=!1,(B==='"'||B==="'"||B==="`")&&!G){G=B,J++;continue}if(B===G&&G!=="`"){G=null,J++;continue}if(G==="`"&&B==="$"&&$[J+1]==="{"){K++,J+=2;continue}if(K>0&&B==="}"){K--,J++;continue}if(B==="`"&&G==="`"&&K===0){G=null,J++;continue}if(G){J++;continue}if(B===Z)Q++;else if(B===X){if(Q--,Q===0)return J}J++}return-1}function z1($,Z){let X=iK($,Z);return X.ok?{expression:X.expression,endPos:X.endPos}:null}function iK($,Z){let X=Z;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!=="(")return{ok:!1,reason:"missing-open-paren",pos:X};let Y=b0($,"(",")",X);if(Y===-1)return{ok:!1,reason:"unclosed-paren",pos:X};return{ok:!0,expression:$.slice(X+1,Y),endPos:Y+1}}function h1($,Z,X,Y){let Q=1,J=Y,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${X}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let W=G.exec($),B=K.exec($),U=W?W.index:1/0,_=B?B.index:1/0;if(U<_)Q++,J=U+W[0].length;else if(_<1/0){if(Q--,Q===0)return _;J=_+B[0].length}else break}return-1}function QX($,Z){let X=$.slice(Z).match(/^@if\s*/);if(!X)return null;let Y=Z+X[0].length,Q=z1($,Y);if(!Q)return null;let J=Q.endPos,G=h1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),W=[],B=0,U="if",_=Q.expression,z=0,j=0;while(B<K.length){let q=K.indexOf("@",B);if(q===-1)break;B=q;let H=K.substring(q);if(/^@if\s*\(/.test(H)){j++,B++;continue}if(/^@endif(?![a-z])/.test(H)){j--,B+=6;continue}if(j===0){let L=H.match(/^@elseif\s*/);if(L){W.push({type:U,condition:_,content:K.substring(z,B),start:J+z,end:J+B});let F=B+L[0].length,O=z1(K,F);if(!O){B++;continue}U="elseif",_=O.expression,B=O.endPos,z=B;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:U,condition:_,content:K.substring(z,B),start:J+z,end:J+B}),U="else",_=void 0,B+=5,z=B;continue}}B++}return W.push({type:U,condition:_,content:K.slice(z),start:J+z,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function m$($){let Z=[],X=/@if\s*\(/g,Y=X.exec($);while(Y!==null){if(Z.some((G)=>Y.index>G.start&&Y.index<G.end)){Y=X.exec($);continue}let J=QX($,Y.index);if(J)Z.push(J),X.lastIndex=J.end;Y=X.exec($)}return Z}function e5($,Z,X){let Y=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(Y.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,W=K+J[0].length-1,B=b0($,"(",")",W);if(B===-1){J=Q.exec($);continue}let U=$.slice(W+1,B),_=B+1,z=h1($,Z,X,_);if(z===-1){J=Q.exec($);continue}let j=$.slice(_,z),q=z+`@${X}`.length;Y.push({fullMatch:$.slice(K,q),name:Z,params:U,content:j,start:K,end:q}),Q.lastIndex=q,J=Q.exec($)}return Y}function d4($,Z){let X=$.slice(Z).match(/^@switch\s*/);if(!X)return null;let Y=Z+X[0].length,Q=z1($,Y);if(!Q)return null;let J=Q.endPos,G=h1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),W=[],B=0,U=null,_=0;while(B<K.length){let z=K.slice(B),j=z.match(/^@switch\s*\(/),q=z.match(/^@endswitch(?![a-z])/);if(j){if(_++,U)U.content+=j[0];B+=j[0].length;continue}if(q){if(_--,U)U.content+=q[0];B+=q[0].length;continue}if(_>0){if(U)U.content+=K[B];B++;continue}let H=z.match(/^@case\s*/),L=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(U)W.push(U);let O=B+H[0].length,V=z1(K,O);if(!V){B++;continue}U={type:"case",value:V.expression,content:""},B=V.endPos}else if(L&&z.startsWith("@default")){if(U)W.push(U);U={type:"default",content:""},B+=L[0].length}else if(F&&z.startsWith("@break"))B+=F[0].length;else{if(U)U.content+=K[B];B++}}if(U)W.push(U);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:W,start:Z,end:G+10}}var GX=()=>{};var KX=()=>{};var p$=T(()=>{GX();KX()});function oK($,Z,X){let Y=$,Q=!0;while(Q){Q=!1;let J=Y.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=d4(Y,G);if(!K)break;try{let W;if(X0(K.expression))W=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else W=Z0(K.expression,Z);let B="",U=!1;for(let _ of K.cases)if(_.type==="default"){if(!U)B=_.content.trim()}else try{let z;if(_.value&&X0(_.value))z=Y0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=Z0(_.value,Z);if(W===z){B=_.content.trim(),U=!0;break}}catch{continue}Y=Y.substring(0,G)+B+Y.substring(K.end),Q=!0}catch(W){let B=W instanceof Error?W.message:String(W),U=r("Switch",`Error evaluating @switch expression: ${B}`,n.EVALUATION_ERROR);Y=Y.substring(0,G)+U+Y.substring(K.end);break}}return Y}function d1($,Z,X){let Y=$;Y=oK(Y,Z,X);{let J=!0;while(J){J=!1;let G=Y.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=z1(Y,K+7);if(!W)break;let B=W.endPos,U=h1(Y,"unless","endunless",B);if(U===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let _=Y.slice(B,U),z=W.expression,j=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(_))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(_))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(_))!==null)V.push({pos:A.index,type:"else"});V.sort((N,w)=>N.pos-w.pos);for(let N of V)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){j=N.pos;break}}let q;if(j!==-1){let H=_.slice(0,j),L=_.slice(j+5);q=`@if (${z})${L}@else ${H}@endif`}else q=`@if (!(${z}))${_}@endif`;Y=Y.substring(0,K)+q+Y.substring(U+10),J=!0}}Y=m4(Y,Z,X),Y=p4(Y,Z,X),Y=u4(Y,Z);let Q=()=>{let J=m$(Y);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let W="",B=!1;for(let U of K.branches){if(B)break;if(U.type==="else")W=U.content,B=!0;else try{let _;if(U.condition&&X0(U.condition))_=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)_=Z0(U.condition,Z);if(_)W=U.content,B=!0}catch(_){W=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${_ instanceof Error?_.message:String(_)}`,n.EVALUATION_ERROR),B=!0}}Y=Y.substring(0,K.start)+W+Y.substring(K.end)}catch(W){let B=W instanceof Error?W.message:String(W),U=r("If",`Error processing @if block: ${B}`,n.EVALUATION_ERROR);Y=Y.substring(0,K.start)+U+Y.substring(K.end)}}return!0};while(!0){let J=Y;if(!Q())break;if(Y===J)break}return Y}function WX($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let X=$[Z];if(X!=="'"&&X!=='"')return null;Z++;let Y=[];while(Z<$.length){let Q=$[Z];if(Q==="\\"&&Z+1<$.length){Y.push($[Z+1]),Z+=2;continue}if(Q===X){Z++;break}Y.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:Y.join(""),consumed:Z}}function u4($,Z){let X=$;function Y(K,W,B,U){let _=1,z=U,j=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),q=new RegExp(`@${B}(?![a-z])`,"g");while(z<K.length&&_>0){j.lastIndex=z,q.lastIndex=z;let H=j.exec(K),L=q.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)_++,z=F+H[0].length;else if(O<1/0){if(_--,_===0)return O;z=O+L[0].length}else break}return-1}function Q(K,W,B){let U=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${B}(?![a-z])`,"g"),j=/@else(?![a-z])/g,q=[],H;while((H=_.exec(K))!==null)q.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)q.push({pos:H.index,type:"close"});while((H=j.exec(K))!==null)q.push({pos:H.index,type:"else"});q.sort((L,F)=>L.pos-F.pos);for(let L of q)if(L.type==="open")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let W=X.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let B=W.index,U,_,z=X.slice(B+5),j=WX(z);if(j)U=j.value,_=B+5+j.consumed;else _=B+5;let q=Y(X,"auth","endauth",_);if(q===-1){console.warn(`[stx] @auth directive at position ${B} has no matching @endauth \u2014 the block was skipped.`);break}let H=X.slice(_,q),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?_1(`auth?.check && auth?.user?.[${U}]`,Z):_1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";X=X.substring(0,B)+O+X.substring(q+8),K=!0}}{let K=!0;while(K){K=!1;let W=X.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let B=W.index,U,_,z=X.slice(B+6),j=WX(z);if(j)U=j.value,_=B+6+j.consumed;else _=B+6;let q=Y(X,"guest","endguest",_);if(q===-1){console.warn(`[stx] @guest directive at position ${B} has no matching @endguest \u2014 the block was skipped.`);break}let H=X.slice(_,q),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?_1(`!auth?.check || !auth?.user?.[${U}]`,Z):_1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";X=X.substring(0,B)+O+X.substring(q+9),K=!0}}function J(K,W,B){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(W)U.push(W);if(B){let _=_1(B,Z);U.push(_)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,B=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let _=X.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,j=X.slice(z+`@${K}`.length),q=G(j);if(!q)break;let H=z+`@${K}`.length+q.paramsEnd,L=Y(X,K,W,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=X.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${B}\\s*\\(`,"g"),R=/@else(?![a-z])/g,M=[],I;while((I=A.exec(F))!==null)M.push({pos:I.index,type:"open"});while((I=N.exec(F))!==null)M.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)M.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)M.push({pos:I.index,type:"else"});M.sort((C,y)=>C.pos-y.pos);for(let C of M){if(C.type==="open"){V++;continue}if(C.type==="close"){V--;continue}if(V===0)O.push(C)}let E=[],D=0;for(let C=0;C<O.length;C++){let y=O[C];if(E.push({content:F.slice(D,y.pos),ability:void 0}),y.type==="elseDirective"){let m=F.slice(y.pos+`@${B}`.length),g=G(m);if(g){E[E.length-1]={content:F.slice(D,y.pos)},D=y.pos+`@${B}`.length+g.paramsEnd,E.push({content:"",ability:g.ability,type:g.type,id:g.id}),E.pop();let p=O[C+1],s=p?p.pos:F.length;E.push({content:F.slice(D,s),ability:g.ability,type:g.type,id:g.id}),D=s}}else D=y.pos+5}if(D<F.length){let C=E[E.length-1];if(O.length>0&&O[O.length-1].type==="else")E.push({content:F.slice(D),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(D)})}let k=J(q.ability,q.type,q.id),P=K==="can"?k:!k,S="";if(P)S=E[0]?.content||"";else{let C=!1;for(let y=1;y<E.length;y++){let m=E[y];if(m.isFinalElse){S=m.content,C=!0;break}if(m.ability){let g=J(m.ability,m.type,m.id);if(K==="can"?g:!g){S=m.content,C=!0;break}}}if(!C&&E.length>0){let y=E[E.length-1];if(y.isFinalElse)S=y.content}}X=X.substring(0,z)+S+X.substring(L+`@${W}`.length),U=!0}}return X}function m4($,Z,X){let Y=$;function Q(J,G,K,W,B){let U=!0;while(U){U=!1;let _=new RegExp(`@${G}\\s*\\(`),z=J.match(_);if(!z||z.index===void 0)break;let j=z.index,q=z1(J,j+`@${G}`.length);if(!q)break;let H=q.endPos,L=h1(J,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${j} has no matching @${K} \u2014 the block was skipped.`);break}let F=J.slice(H,L),O=q.expression,V=-1,A=0,N=0;while(N<F.length){let w=F.indexOf("@",N);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){V=w;break}N=w+1}try{let w=W(O.trim()),R;if(V!==-1){let M=F.slice(0,V),I=F.slice(V+5);R=w?M:I}else R=w?F:"";J=J.substring(0,j)+R+J.substring(L+`@${K}`.length),U=!0}catch(w){let R=w instanceof Error?w.message:String(w),M=r(B,`Error processing @${G} directive: ${R}`,n.EVALUATION_ERROR);J=J.substring(0,j)+M+J.substring(L+`@${K}`.length);break}}return J}return Y=Q(Y,"isset","endisset",(J)=>{let G=_1(J,Z);return G!==void 0&&G!==null},"Isset"),Y=Q(Y,"empty","endempty",(J)=>{let G=_1(J,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),Y}function p4($,Z,X){let Y=$,Q="development";function J(G,K,W,B){let U=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),j=new RegExp(`^@${W}(?![a-z])`),q=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(q);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let k=q.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;O+=k[0].length,B=Q===k[2]}let V=1,A=O,N=-1;while(V>0&&A<q.length){U.lastIndex=A,_.lastIndex=A;let k=U.exec(q),P=_.exec(q),S=k?k.index:1/0,C=P?P.index:1/0;if(S<C)V++,A=S+k[0].length;else if(C<1/0){if(V--,V===0){N=C;break}A=C+P[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=q.substring(O,N),R=-1,M=0,I=0;while(I<w.length){let k=w.indexOf("@",I);if(k===-1)break;let P=w.substring(k);if(z.test(P)){M++,I=k+1;continue}if(j.test(P)){M--,I=k+1;continue}if(M===0&&/^@else(?![a-z])/.test(P)){R=k;break}I=k+1}let E;if(R!==-1){let k=w.slice(0,R),P=w.slice(R+5);E=B?k:P}else E=B?w:"";let D=`@${W}`.length;q=q.substring(0,F)+E+q.substring(N+D),H=!0}return q}return Y=J(Y,"env","endenv",!1),Y=J(Y,"production","endproduction",Q==="production"),Y=J(Y,"development","enddevelopment",Q==="development"),Y=J(Y,"staging","endstaging",Q==="staging"),Y=J(Y,"testing","endtesting",Q==="testing"),Y}var $7=T(()=>{x4();d0();p$();L0()});function BX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function Z7($,Z){if(!$)return Z?.nonceGenerator?.()??BX();let X=UX.get($);if(!X)X=Z?.nonceGenerator?.()??BX(),UX.set($,X);return X}function aK($,Z){let X=[];for(let[Y,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)X.push(Y);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(Y==="script-src"||Y==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)X.push(`${Y} ${J.join(" ")}`)}}return X.join("; ")}function _X($,Z){return`<meta http-equiv="Content-Security-Policy" content="${aK($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function zX($,Z,X){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let Y=Z.useNonce?Z7(X,Z):void 0,Q=_X(Z.directives,Y);return $.replace(/<head([^>]*)>/,`<head$1>
1650
+ `),"utf-8")}}async flush(){await this.writeQueue}}var g4,D0,u$;var XX=T(()=>{t5();g4={isEnabled(){return s5().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=s5();if(!Z.enableAutoRecovery)return{fixed:$,fixes:[]};let X=$,Y=[],Q=(X.match(/\{\{/g)||[]).length,J=(X.match(/\}\}/g)||[]).length;if(Q>J){let K=Q-J;X+="}}".repeat(K),Y.push(`Added ${K} missing closing braces '}}'`)}let G=["if","foreach","for","switch","section"];for(let K of G){let W=(X.match(new RegExp(`@${K}\\b`,"g"))||[]).length,B=(X.match(new RegExp(`@end${K}\\b`,"g"))||[]).length;if(W>B){let U=W-B;for(let _=0;_<U;_++)X+=`
1651
+ @end${K}`;Y.push(`Added ${U} missing @end${K}`)}}if(Y.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),Y.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:X,fixes:Y}},createFallbackContent($,Z){if(g1())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};D0=new h4,u$={isDevelopment(){return g1()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let X=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)X.push(`Context: ${JSON.stringify(Z,null,2)}`);return X.push("========================"),X.join(`
1652
+ `)}}});var YX=()=>{};var JX=T(()=>{n5();ZX();XX();YX();t5()});var d0=T(()=>{JX()});function b0($,Z,X,Y=0){let Q=0,J=Y,G=null,K=0,W=!1;while(J<$.length){let B=$[J];if(G&&W){W=!1,J++;continue}if(G&&B==="\\"){W=!0,J++;continue}if(W=!1,(B==='"'||B==="'"||B==="`")&&!G){G=B,J++;continue}if(B===G&&G!=="`"){G=null,J++;continue}if(G==="`"&&B==="$"&&$[J+1]==="{"){K++,J+=2;continue}if(K>0&&B==="}"){K--,J++;continue}if(B==="`"&&G==="`"&&K===0){G=null,J++;continue}if(G){J++;continue}if(B===Z)Q++;else if(B===X){if(Q--,Q===0)return J}J++}return-1}function z1($,Z){let X=iK($,Z);return X.ok?{expression:X.expression,endPos:X.endPos}:null}function iK($,Z){let X=Z;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!=="(")return{ok:!1,reason:"missing-open-paren",pos:X};let Y=b0($,"(",")",X);if(Y===-1)return{ok:!1,reason:"unclosed-paren",pos:X};return{ok:!0,expression:$.slice(X+1,Y),endPos:Y+1}}function h1($,Z,X,Y){let Q=1,J=Y,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${X}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let W=G.exec($),B=K.exec($),U=W?W.index:1/0,_=B?B.index:1/0;if(U<_)Q++,J=U+W[0].length;else if(_<1/0){if(Q--,Q===0)return _;J=_+B[0].length}else break}return-1}function QX($,Z){let X=$.slice(Z).match(/^@if\s*/);if(!X)return null;let Y=Z+X[0].length,Q=z1($,Y);if(!Q)return null;let J=Q.endPos,G=h1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),W=[],B=0,U="if",_=Q.expression,z=0,j=0;while(B<K.length){let q=K.indexOf("@",B);if(q===-1)break;B=q;let H=K.substring(q);if(/^@if\s*\(/.test(H)){j++,B++;continue}if(/^@endif(?![a-z])/.test(H)){j--,B+=6;continue}if(j===0){let L=H.match(/^@elseif\s*/);if(L){W.push({type:U,condition:_,content:K.substring(z,B),start:J+z,end:J+B});let F=B+L[0].length,O=z1(K,F);if(!O){B++;continue}U="elseif",_=O.expression,B=O.endPos,z=B;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:U,condition:_,content:K.substring(z,B),start:J+z,end:J+B}),U="else",_=void 0,B+=5,z=B;continue}}B++}return W.push({type:U,condition:_,content:K.slice(z),start:J+z,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function m$($){let Z=[],X=/@if\s*\(/g,Y=X.exec($);while(Y!==null){if(Z.some((G)=>Y.index>G.start&&Y.index<G.end)){Y=X.exec($);continue}let J=QX($,Y.index);if(J)Z.push(J),X.lastIndex=J.end;Y=X.exec($)}return Z}function e5($,Z,X){let Y=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(Y.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,W=K+J[0].length-1,B=b0($,"(",")",W);if(B===-1){J=Q.exec($);continue}let U=$.slice(W+1,B),_=B+1,z=h1($,Z,X,_);if(z===-1){J=Q.exec($);continue}let j=$.slice(_,z),q=z+`@${X}`.length;Y.push({fullMatch:$.slice(K,q),name:Z,params:U,content:j,start:K,end:q}),Q.lastIndex=q,J=Q.exec($)}return Y}function d4($,Z){let X=$.slice(Z).match(/^@switch\s*/);if(!X)return null;let Y=Z+X[0].length,Q=z1($,Y);if(!Q)return null;let J=Q.endPos,G=h1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),W=[],B=0,U=null,_=0;while(B<K.length){let z=K.slice(B),j=z.match(/^@switch\s*\(/),q=z.match(/^@endswitch(?![a-z])/);if(j){if(_++,U)U.content+=j[0];B+=j[0].length;continue}if(q){if(_--,U)U.content+=q[0];B+=q[0].length;continue}if(_>0){if(U)U.content+=K[B];B++;continue}let H=z.match(/^@case\s*/),L=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(U)W.push(U);let O=B+H[0].length,V=z1(K,O);if(!V){B++;continue}U={type:"case",value:V.expression,content:""},B=V.endPos}else if(L&&z.startsWith("@default")){if(U)W.push(U);U={type:"default",content:""},B+=L[0].length}else if(F&&z.startsWith("@break"))B+=F[0].length;else{if(U)U.content+=K[B];B++}}if(U)W.push(U);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:W,start:Z,end:G+10}}var GX=()=>{};var KX=()=>{};var p$=T(()=>{GX();KX()});function oK($,Z,X){let Y=$,Q=!0;while(Q){Q=!1;let J=Y.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=d4(Y,G);if(!K)break;try{let W;if(X0(K.expression))W=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else W=Z0(K.expression,Z);let B="",U=!1;for(let _ of K.cases)if(_.type==="default"){if(!U)B=_.content.trim()}else try{let z;if(_.value&&X0(_.value))z=Y0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=Z0(_.value,Z);if(W===z){B=_.content.trim(),U=!0;break}}catch{continue}Y=Y.substring(0,G)+B+Y.substring(K.end),Q=!0}catch(W){let B=W instanceof Error?W.message:String(W),U=r("Switch",`Error evaluating @switch expression: ${B}`,n.EVALUATION_ERROR);Y=Y.substring(0,G)+U+Y.substring(K.end);break}}return Y}function d1($,Z,X){let Y=$;Y=oK(Y,Z,X);{let J=!0;while(J){J=!1;let G=Y.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=z1(Y,K+7);if(!W)break;let B=W.endPos,U=h1(Y,"unless","endunless",B);if(U===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let _=Y.slice(B,U),z=W.expression,j=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(_))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(_))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(_))!==null)V.push({pos:A.index,type:"else"});V.sort((N,w)=>N.pos-w.pos);for(let N of V)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){j=N.pos;break}}let q;if(j!==-1){let H=_.slice(0,j),L=_.slice(j+5);q=`@if (${z})${L}@else ${H}@endif`}else q=`@if (!(${z}))${_}@endif`;Y=Y.substring(0,K)+q+Y.substring(U+10),J=!0}}Y=m4(Y,Z,X),Y=p4(Y,Z,X),Y=u4(Y,Z);let Q=()=>{let J=m$(Y);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let W="",B=!1;for(let U of K.branches){if(B)break;if(U.type==="else")W=U.content,B=!0;else try{let _;if(U.condition&&X0(U.condition))_=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)_=Z0(U.condition,Z);if(_)W=U.content,B=!0}catch(_){W=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${_ instanceof Error?_.message:String(_)}`,n.EVALUATION_ERROR),B=!0}}Y=Y.substring(0,K.start)+W+Y.substring(K.end)}catch(W){let B=W instanceof Error?W.message:String(W),U=r("If",`Error processing @if block: ${B}`,n.EVALUATION_ERROR);Y=Y.substring(0,K.start)+U+Y.substring(K.end)}}return!0};while(!0){let J=Y;if(!Q())break;if(Y===J)break}return Y}function WX($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let X=$[Z];if(X!=="'"&&X!=='"')return null;Z++;let Y=[];while(Z<$.length){let Q=$[Z];if(Q==="\\"&&Z+1<$.length){Y.push($[Z+1]),Z+=2;continue}if(Q===X){Z++;break}Y.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:Y.join(""),consumed:Z}}function u4($,Z){let X=$;function Y(K,W,B,U){let _=1,z=U,j=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),q=new RegExp(`@${B}(?![a-z])`,"g");while(z<K.length&&_>0){j.lastIndex=z,q.lastIndex=z;let H=j.exec(K),L=q.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)_++,z=F+H[0].length;else if(O<1/0){if(_--,_===0)return O;z=O+L[0].length}else break}return-1}function Q(K,W,B){let U=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${B}(?![a-z])`,"g"),j=/@else(?![a-z])/g,q=[],H;while((H=_.exec(K))!==null)q.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)q.push({pos:H.index,type:"close"});while((H=j.exec(K))!==null)q.push({pos:H.index,type:"else"});q.sort((L,F)=>L.pos-F.pos);for(let L of q)if(L.type==="open")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let W=X.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let B=W.index,U,_,z=X.slice(B+5),j=WX(z);if(j)U=j.value,_=B+5+j.consumed;else _=B+5;let q=Y(X,"auth","endauth",_);if(q===-1){console.warn(`[stx] @auth directive at position ${B} has no matching @endauth \u2014 the block was skipped.`);break}let H=X.slice(_,q),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?_1(`auth?.check && auth?.user?.[${U}]`,Z):_1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";X=X.substring(0,B)+O+X.substring(q+8),K=!0}}{let K=!0;while(K){K=!1;let W=X.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let B=W.index,U,_,z=X.slice(B+6),j=WX(z);if(j)U=j.value,_=B+6+j.consumed;else _=B+6;let q=Y(X,"guest","endguest",_);if(q===-1){console.warn(`[stx] @guest directive at position ${B} has no matching @endguest \u2014 the block was skipped.`);break}let H=X.slice(_,q),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?_1(`!auth?.check || !auth?.user?.[${U}]`,Z):_1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";X=X.substring(0,B)+O+X.substring(q+9),K=!0}}function J(K,W,B){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(W)U.push(W);if(B){let _=_1(B,Z);U.push(_)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,B=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let _=X.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,j=X.slice(z+`@${K}`.length),q=G(j);if(!q)break;let H=z+`@${K}`.length+q.paramsEnd,L=Y(X,K,W,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=X.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${B}\\s*\\(`,"g"),R=/@else(?![a-z])/g,M=[],I;while((I=A.exec(F))!==null)M.push({pos:I.index,type:"open"});while((I=N.exec(F))!==null)M.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)M.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)M.push({pos:I.index,type:"else"});M.sort((b,y)=>b.pos-y.pos);for(let b of M){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let E=[],D=0;for(let b=0;b<O.length;b++){let y=O[b];if(E.push({content:F.slice(D,y.pos),ability:void 0}),y.type==="elseDirective"){let m=F.slice(y.pos+`@${B}`.length),g=G(m);if(g){E[E.length-1]={content:F.slice(D,y.pos)},D=y.pos+`@${B}`.length+g.paramsEnd,E.push({content:"",ability:g.ability,type:g.type,id:g.id}),E.pop();let p=O[b+1],s=p?p.pos:F.length;E.push({content:F.slice(D,s),ability:g.ability,type:g.type,id:g.id}),D=s}}else D=y.pos+5}if(D<F.length){let b=E[E.length-1];if(O.length>0&&O[O.length-1].type==="else")E.push({content:F.slice(D),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(D)})}let k=J(q.ability,q.type,q.id),P=K==="can"?k:!k,S="";if(P)S=E[0]?.content||"";else{let b=!1;for(let y=1;y<E.length;y++){let m=E[y];if(m.isFinalElse){S=m.content,b=!0;break}if(m.ability){let g=J(m.ability,m.type,m.id);if(K==="can"?g:!g){S=m.content,b=!0;break}}}if(!b&&E.length>0){let y=E[E.length-1];if(y.isFinalElse)S=y.content}}X=X.substring(0,z)+S+X.substring(L+`@${W}`.length),U=!0}}return X}function m4($,Z,X){let Y=$;function Q(J,G,K,W,B){let U=!0;while(U){U=!1;let _=new RegExp(`@${G}\\s*\\(`),z=J.match(_);if(!z||z.index===void 0)break;let j=z.index,q=z1(J,j+`@${G}`.length);if(!q)break;let H=q.endPos,L=h1(J,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${j} has no matching @${K} \u2014 the block was skipped.`);break}let F=J.slice(H,L),O=q.expression,V=-1,A=0,N=0;while(N<F.length){let w=F.indexOf("@",N);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){V=w;break}N=w+1}try{let w=W(O.trim()),R;if(V!==-1){let M=F.slice(0,V),I=F.slice(V+5);R=w?M:I}else R=w?F:"";J=J.substring(0,j)+R+J.substring(L+`@${K}`.length),U=!0}catch(w){let R=w instanceof Error?w.message:String(w),M=r(B,`Error processing @${G} directive: ${R}`,n.EVALUATION_ERROR);J=J.substring(0,j)+M+J.substring(L+`@${K}`.length);break}}return J}return Y=Q(Y,"isset","endisset",(J)=>{let G=_1(J,Z);return G!==void 0&&G!==null},"Isset"),Y=Q(Y,"empty","endempty",(J)=>{let G=_1(J,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),Y}function p4($,Z,X){let Y=$,Q="development";function J(G,K,W,B){let U=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),j=new RegExp(`^@${W}(?![a-z])`),q=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(q);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let k=q.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;O+=k[0].length,B=Q===k[2]}let V=1,A=O,N=-1;while(V>0&&A<q.length){U.lastIndex=A,_.lastIndex=A;let k=U.exec(q),P=_.exec(q),S=k?k.index:1/0,b=P?P.index:1/0;if(S<b)V++,A=S+k[0].length;else if(b<1/0){if(V--,V===0){N=b;break}A=b+P[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=q.substring(O,N),R=-1,M=0,I=0;while(I<w.length){let k=w.indexOf("@",I);if(k===-1)break;let P=w.substring(k);if(z.test(P)){M++,I=k+1;continue}if(j.test(P)){M--,I=k+1;continue}if(M===0&&/^@else(?![a-z])/.test(P)){R=k;break}I=k+1}let E;if(R!==-1){let k=w.slice(0,R),P=w.slice(R+5);E=B?k:P}else E=B?w:"";let D=`@${W}`.length;q=q.substring(0,F)+E+q.substring(N+D),H=!0}return q}return Y=J(Y,"env","endenv",!1),Y=J(Y,"production","endproduction",Q==="production"),Y=J(Y,"development","enddevelopment",Q==="development"),Y=J(Y,"staging","endstaging",Q==="staging"),Y=J(Y,"testing","endtesting",Q==="testing"),Y}var $7=T(()=>{x4();d0();p$();L0()});function BX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function Z7($,Z){if(!$)return Z?.nonceGenerator?.()??BX();let X=UX.get($);if(!X)X=Z?.nonceGenerator?.()??BX(),UX.set($,X);return X}function aK($,Z){let X=[];for(let[Y,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)X.push(Y);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(Y==="script-src"||Y==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)X.push(`${Y} ${J.join(" ")}`)}}return X.join("; ")}function _X($,Z){return`<meta http-equiv="Content-Security-Policy" content="${aK($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function zX($,Z,X){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let Y=Z.useNonce?Z7(X,Z):void 0,Q=_X(Z.directives,Y);return $.replace(/<head([^>]*)>/,`<head$1>
1653
1653
  ${Q}`)}function qX($,Z,X,Y){let Q=$,J=Y.csp;if(Q=Q.replace(/@csp\b/g,()=>{if(!J?.enabled||!J.directives)return"<!-- CSP not configured -->";let G=J.useNonce?Z7(Z,J):void 0;return _X(J.directives,G)}),Q=Q.replace(/@cspNonce\b/g,()=>{if(!J?.enabled||!J.useNonce)return"";return Z7(Z,J)}),J?.enabled&&J.useNonce)Z.cspNonce=Z7(Z,J);return Q}var UX;var c4=T(()=>{UX=new WeakMap});import tK from"crypto";function $W($=eK){let Z=tK.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return l4=Z,Z}function ZW(){if(!l4)$W();return l4}function XW($=jX){let Z=ZW();return`<input type="hidden" name="${$}" value="${Z}">`}function HX($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,X,Y)=>{return XW(Y||jX)})}var eK=40,jX="_token",l4=null;var OX=()=>{};async function LX($,Z,X,Y){if(!Y.customDirectives||Y.customDirectives.length===0)return $;let Q=$;for(let J of Y.customDirectives){if(!J.name||typeof J.handler!=="function"){if(Y.debug)console.warn("Invalid custom directive:",J);continue}if(J.hasEndTag)Q=await YW(Q,J,Z,X,Y);else Q=await JW(Q,J,Z,X,Y)}return Q}async function YW($,Z,X,Y,Q){let{name:J,handler:G}=Z,K=`@${J}`,W=`@end${J}`,B=$,U=Y$(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),_=[],z=U.exec(B);while(z!==null){let[j,q="",H=""]=z,L=z.index||0;try{let F=q?FX(q):[],O=H.trim(),V=await G(O,F,X,Y);_.push({original:j,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(Q.debug)console.error(`Error processing custom directive @${J}:`,F);_.push({original:j,processed:r("CustomDirective",`Error in @${J}${q?`(${q})`:""}: ${O}`,n.EVALUATION_ERROR),startIndex:L})}z=U.exec(B)}for(let j=_.length-1;j>=0;j--){let{original:q,processed:H}=_[j];B=B.replace(q,H)}return B}async function JW($,Z,X,Y,Q){let{name:J,handler:G}=Z,K=$,W=Y$(`@${J}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),B=[],U=W.exec(K);while(U!==null){let[j,q=""]=U,H=U.index||0;try{let L=FX(q),F=await G("",L,X,Y);B.push({original:j,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(Q.debug)console.error(`Error processing custom directive @${J}:`,L);B.push({original:j,processed:r("CustomDirective",`Error in @${J}(${q}): ${F}`,n.EVALUATION_ERROR),startIndex:H})}U=W.exec(K)}let _=Y$(`@${J}(?!\\w)(?!\\s*\\()`,"g"),z=_.exec(K);while(z!==null){let[j]=z,q=z.index||0;try{let H=await G("",[],X,Y);B.push({original:j,processed:H,startIndex:q})}catch(H){let L=H instanceof Error?H.message:String(H);if(Q.debug)console.error(`Error processing custom directive @${J}:`,H);B.push({original:j,processed:r("CustomDirective",`Error in @${J}: ${L}`,n.EVALUATION_ERROR),startIndex:q})}z=_.exec(K)}for(let j=B.length-1;j>=0;j--){let{original:q,processed:H}=B[j];K=K.replace(q,H)}return K}function FX($){if(!$.trim())return[];let Z=[],X="",Y=!1,Q="";for(let J=0;J<$.length;J++){let G=$[J];if((G==='"'||G==="'")&&(J===0||$[J-1]!=="\\"))if(!Y)Y=!0,Q=G;else if(G===Q)Y=!1;else X+=G;else if(G===","&&!Y)Z.push(X.trim()),X="";else X+=G}if(X.trim())Z.push(X.trim());return Z.map((J)=>{let G=J.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var i4=T(()=>{d0();v1()});var n4={};a(n4,{useTitle:()=>UW,useSeoMeta:()=>Y7,usePageTitle:()=>UW,useHead:()=>m1,resetHead:()=>GW,renderHtmlAttrs:()=>_W,renderHead:()=>BW,renderBodyAttrs:()=>zW,processTitleDirective:()=>HW,processMetaDirective:()=>OW,processHeadDirective:()=>jW,getPageMeta:()=>VX,getHead:()=>c$,definePageMeta:()=>WW,applyHead:()=>qW});function c$(){return q1}function VX(){return X7}function GW(){q1={},QW.length=0,X7={}}function m1($){q1=KW(q1,$)}function KW($,Z){return{title:Z.title??$.title,titleTemplate:Z.titleTemplate??$.titleTemplate,base:Z.base??$.base,meta:[...$.meta||[],...Z.meta||[]],link:[...$.link||[],...Z.link||[]],script:[...$.script||[],...Z.script||[]],style:[...$.style||[],...Z.style||[]],htmlAttrs:{...$.htmlAttrs,...Z.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...Z.bodyAttrs}}}function Y7($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let X=$.ogTitle??$.title,Y=$.ogDescription??$.description;if(X)Z.push({property:"og:title",content:X});if(Y)Z.push({property:"og:description",content:Y});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let Q=$.twitterTitle??$.title,J=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(Q)Z.push({name:"twitter:title",content:Q});if(J)Z.push({name:"twitter:description",content:J});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});m1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function WW($){if(X7={...X7,...$},$.title||$.description)Y7({title:$.title,description:$.description})}function UW($){let Z=typeof $==="function"?$():$;m1({title:Z})}function BW($=q1){let Z=[];if($.title){let X=$.title;if($.titleTemplate)X=typeof $.titleTemplate==="function"?$.titleTemplate(X):$.titleTemplate.replace("%s",X);Z.push(`<title>${u1(X)}</title>`)}if($.base){let X=Object.entries($.base).map(([Y,Q])=>`${Y}="${u1(Q)}"`).join(" ");Z.push(`<base ${X}>`)}for(let X of $.meta||[]){let Y=Object.entries(X).filter(([Q,J])=>J!==void 0).map(([Q,J])=>{return`${Q==="httpEquiv"?"http-equiv":Q}="${u1(String(J))}"`}).join(" ");Z.push(`<meta ${Y}>`)}for(let X of $.link||[]){let Y=Object.entries(X).filter(([Q,J])=>J!==void 0).map(([Q,J])=>`${Q}="${u1(String(J))}"`).join(" ");Z.push(`<link ${Y}>`)}for(let X of $.script||[]){let{content:Y,...Q}=X,J=Object.entries(Q).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${u1(String(K))}"`}).filter(Boolean).join(" ");if(Y)Z.push(`<script ${J}>${Y}</script>`);else Z.push(`<script ${J}></script>`)}for(let X of $.style||[]){let Y=X.type?` type="${X.type}"`:"";Z.push(`<style${Y}>${X.content}</style>`)}return Z.join(`
1654
1654
  `)}function _W($=q1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,X])=>`${Z}="${u1(X)}"`).join(" ")}function zW($=q1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,X])=>`${Z}="${u1(X)}"`).join(" ")}function u1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function qW($=q1){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let X=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(X){let Y=document.querySelector(X);if(!Y){if(Y=document.createElement("meta"),Z.name)Y.setAttribute("name",Z.name);if(Z.property)Y.setAttribute("property",Z.property);document.head.appendChild(Y)}Y.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let X=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,Y=document.querySelector(X);if(!Y)Y=document.createElement("link"),document.head.appendChild(Y);for(let[Q,J]of Object.entries(Z))if(J!==void 0)Y.setAttribute(Q,String(J))}if($.htmlAttrs)for(let[Z,X]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,X);if($.bodyAttrs)for(let[Z,X]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,X)}function jW($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(Y,Q)=>{return Z+=Q.trim()+`
1655
1655
  `,""}),headContent:Z.trim()}}function HW($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(X,Y,Q,J)=>{let G=Y?Q:Z[(J||"").trim()]??J;return m1({title:G}),""})}function OW($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(X,Y,Q,J,G,K)=>{let W=J?G:K,B=J?W:Z[(W||"").trim()]??W,_=Q.includes(":")?{property:Q,content:B}:{name:Q,content:B};return m1({meta:[_]}),""})}var q1,QW,X7;var p1=T(()=>{q1={},QW=[],X7={}});import LW from"crypto";function N0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function J7($,Z,X,Y){let Q=$||Z;return X?`${Q} ${Y}`:Q}function FW(){return LW.randomUUID()}function Q7($,Z){let X=$;return X=X.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let Y=FW();Z.csrf={token:Y}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${N0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),X=X.replace(/@method\(['"]([^'"]+)['"]\)/g,(Y,Q)=>{let J=Q.toUpperCase();if(Q&&!["GET","POST"].includes(J))return`<input type="hidden" name="_method" value="${N0(J)}">`;return Y}),X}function wX($,Z,X=AX){let Y=$;return Y=Y.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(Q,J,G,K,W,B="")=>{let U=J||G||"POST",_=K||W||"",z=j1(B),j=U.toUpperCase(),q=["GET","POST"].includes(j)?j:"POST",H=`<form method="${N0(q)}" action="${N0(_)}"${z?` ${z}`:""}>`;if(H+=`
@@ -1841,14 +1841,14 @@ else {
1841
1841
  }
1842
1842
  };
1843
1843
  })();
1844
- </script>`,iW,SX,CX;var K7=T(()=>{I0();T0();n0();Q0();Y6={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},c1=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,DX=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;iW=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;SX={name:"suspense",hasEndTag:!0,handler:($,Z,X,Y)=>{if(!Z||Z.length===0)throw Error("Suspense directive requires a name parameter");let Q=Z[0].replace(/['"`]/g,"");return`<!-- @suspense:${Q} -->${$}<!-- @endsuspense:${Q} -->`}},CX={name:"island",hasEndTag:!0,handler:($,Z,X,Y)=>{if(!Z||Z.length===0)throw Error("Island directive requires a name parameter");let Q=Z[0].replace(/['"`]/g,""),J=Z[1]?Z[1].replace(/['"`]/g,""):"lazy",G=`island-${Q}-${Math.random().toString(36).substring(2,9)}`,K=$.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),W=K?K[1].trim():"",B=K?$.replace(K[0],""):$;return`<div data-island="${Q}" data-island-id="${G}" data-priority="${J}">
1844
+ </script>`,iW,SX,CX;var K7=T(()=>{E0();I0();n0();Q0();Y6={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},c1=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,DX=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;iW=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;SX={name:"suspense",hasEndTag:!0,handler:($,Z,X,Y)=>{if(!Z||Z.length===0)throw Error("Suspense directive requires a name parameter");let Q=Z[0].replace(/['"`]/g,"");return`<!-- @suspense:${Q} -->${$}<!-- @endsuspense:${Q} -->`}},CX={name:"island",hasEndTag:!0,handler:($,Z,X,Y)=>{if(!Z||Z.length===0)throw Error("Island directive requires a name parameter");let Q=Z[0].replace(/['"`]/g,""),J=Z[1]?Z[1].replace(/['"`]/g,""):"lazy",G=`island-${Q}-${Math.random().toString(36).substring(2,9)}`,K=$.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),W=K?K[1].trim():"",B=K?$.replace(K[0],""):$;return`<div data-island="${Q}" data-island-id="${G}" data-priority="${J}">
1845
1845
  ${B}
1846
1846
  <script type="application/json" data-island-props="${G}">
1847
1847
  ${W?`{${W}}`:"{}"}
1848
1848
  </script>
1849
1849
  </div>`}}});var yX={};a(yX,{warnUnbalancedTags:()=>G6,findUnbalancedTags:()=>PX});function H1($){return $.replace(/[^\n]/g," ")}function PX($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,H1).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,H1).replace(/<!--[\s\S]*?-->/g,H1).replace(/\{\{\{[\s\S]*?\}\}\}/g,H1).replace(/\{\{[\s\S]*?\}\}/g,H1).replace(/\{!![\s\S]*?!!\}/g,H1).replace(/"[^"]*"/g,H1).replace(/'[^']*'/g,H1),X=new Map,Y=new Map,Q=/<(\/?)([A-Za-z][\w-]*)\b[^>]*?(\/?)>/g,J;while((J=Q.exec(Z))!==null){let K=J[1]==="/",W=J[2],B=J[3]==="/";if(ZU.has(W.toLowerCase()))continue;if(B)continue;if(K)Y.set(W,(Y.get(W)??0)+1);else{let U=X.get(W);if(U)U.count++;else{let _=Z.slice(0,J.index).split(`
1850
- `).length;X.set(W,{count:1,firstLine:_})}}}let G=[];for(let K of new Set([...X.keys(),...Y.keys()])){if(XU.has(K.toLowerCase()))continue;let W=X.get(K)?.count??0,B=Y.get(K)??0;if(W!==B)G.push({tag:K,opened:W,closed:B,firstOpenLine:X.get(K)?.firstLine??0})}return G}function G6($,Z){let X;try{X=PX($)}catch{return}if(X.length===0)return;let Y=`${Z}:${$.length}`;if(bX.has(Y))return;bX.add(Y);let Q=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:J,opened:G,closed:K,firstOpenLine:W}of X)if(G>K){let B=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 an unclosed <${J}>${B} may swallow the content that follows it.`)}else console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${J}>.`)}var ZU,XU,bX;var K6=T(()=>{ZU=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),XU=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);bX=new Set});import c0 from"path";import W6 from"fs";function xX($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function vX($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class fX{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,X,Y){let Q=$.endsWith(".stx")?$.slice(0,-4):$,J=Y?.__importedComponents;if(J){let j=[Q,Q.toLowerCase(),xX(Q),vX(Q)];for(let q of j)if(J.has(q))return J.get(q)}let G=[...new Set([`${Q}.stx`,`${xX(Q)}.stx`,`${vX(Q)}.stx`])];if(Q.startsWith("./")||Q.startsWith("../")){let j=c0.resolve(c0.dirname(Z),`${Q}.stx`);if(await l(j))return j;return null}let K=[],W=X.componentsDir||"",B=Y?.__originalFilePath;if(B)K.push(c0.join(c0.dirname(B),"components"));if(W)K.push(W);let U=c0.join(c0.dirname(Z),"components");if(!K.includes(U))K.push(U);let _=process.cwd(),z=[c0.resolve(_,"src/components"),c0.resolve(_,"components"),c0.resolve(import.meta.dir,"components")];for(let j of z)if(!K.includes(j))K.push(j);for(let j of K){if(!j)continue;for(let q of G){let H=c0.join(j,q);if(await l(H))return H}try{if(!W6.statSync(j,{throwIfNoEntry:!1})?.isDirectory())continue;let H=W6.readdirSync(j,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=c0.join(j,L.name);for(let O of G){let V=c0.join(F,O);if(await l(V))return V}}}catch{}}return null}}var y0;var U6=T(()=>{Q0();y0=new fX});function O1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function YU($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var B6;var _6=T(()=>{B6={name:"StxLink",aliases:["stx-link"],render($,Z,X){let Y=YU($),Q=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),J=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,W=[];if(Y.reactive)W.push(`:href="${O1(Y.value)}"`);else W.push(`href="${O1(Y.value)}"`);if(Q)W.push(`class="${O1(Q)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${O1(J)}"`),W.push(`data-stx-exact-active-class="${O1(G)}"`),K)W.push("data-stx-prefetch");let B=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[U,_]of Object.entries($.static)){if(B.has(U))continue;if(typeof _==="boolean"){if(_)W.push(O1(U))}else W.push(`${O1(U)}="${O1(_)}"`)}return`<a ${W.join(" ")}>${Z}</a>`}}});function H0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function D0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let X=$.static[Z];if(typeof X==="string")return X;return}function q6($,Z,X=!1){let Y=$.serverDynamic[Z];if(Y!==void 0)return Y!==!1&&Y!=="false";let Q=$.static[Z];if(Q!==void 0)return Q!=="false"&&Q!==!1;return X}function gX($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),X=[];for(let Y of Z)if(Y.includes(":")){let[Q,J]=Y.split(":"),G=JU[Q];if(G)X.push(`(max-width: ${G}px) ${J}`);else{let K=Number.parseInt(Q);if(!Number.isNaN(K))X.push(`(max-width: ${K}px) ${J}`)}}else X.push(Y);return X.join(", ")}function j6($,Z,X,Y){return Z.map((Q)=>`${s$($,Q,void 0,X,Y)} ${Q}w`).join(", ")}function QU($,Z,X,Y,Q){return Z.map((J)=>{let G=X?X*J:void 0;return`${s$($,G,void 0,Y,Q)} ${J}x`}).join(", ")}function s$($,Z,X,Y,Q){if(!Y||Y==="local"||Y==="static")return $;if(Y==="cloudinary"){let J=[];if(Z)J.push(`w_${Z}`);if(X)J.push(`h_${X}`);if(Q)J.push(`f_${Q}`);J.push("q_auto");let G=J.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(Y==="imgix"){let J=new URLSearchParams;if(Z)J.set("w",String(Z));if(X)J.set("h",String(X));if(Q)J.set("fm",Q);J.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}if(Y==="bunny"){let J=new URLSearchParams;if(Z)J.set("width",String(Z));if(X)J.set("height",String(X));if(Q)J.set("format",Q);let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}return $}function GU($,Z,X="#e5e7eb"){let Y=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${X}"/></svg>`;return`data:image/svg+xml;base64,${btoa(Y)}`}var JU,z6,H6;var O6=T(()=>{JU={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},z6=[320,640,768,1024,1280,1536,1920];H6={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,X){let Y=D0($,"src")||"",Q=D0($,"alt")||"",J=D0($,"width"),G=D0($,"height"),K=D0($,"sizes"),W=D0($,"srcset"),B=D0($,"densities"),U=D0($,"format"),_=D0($,"placeholder"),z=D0($,"placeholderColor")||"#e5e7eb",j=D0($,"provider"),q=D0($,"class")||D0($,"className")||"",H=D0($,"style")||"",L=D0($,"quality"),F=q6($,"lazy",!0),O=q6($,"preload",!1),V=q6($,"picture",!1)||!!U,A=J?Number.parseInt(J):void 0,N=G?Number.parseInt(G):void 0,w=W||"",R="";if(!w&&K)w=j6(Y,z6,j,U),R=gX(K);else if(!w&&B){let S=B.split(/\s+/).map((C)=>Number.parseFloat(C.replace("x","")));w=QU(Y,S,A,j,U)}else if(K)R=gX(K);let M=[];if(H)M.push(H);if(A&&N)M.push(`aspect-ratio:${A}/${N}`);if(_==="blur"||_==="color"||_==="thumbhash"){let S=GU(A||16,N||9,z);M.push(`background-image:url(${S})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat")}else if(_&&_!=="empty"&&_!=="none")M.push(`background-image:url(${H0(_)})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat");let I=s$(Y,A,N,j,U),E=[];if(E.push(`src="${H0(I)}"`),E.push(`alt="${H0(Q)}"`),J)E.push(`width="${H0(J)}"`);if(G)E.push(`height="${H0(G)}"`);if(F)E.push('loading="lazy"');if(E.push('decoding="async"'),q)E.push(`class="${H0(q)}"`);if(M.length>0)E.push(`style="${H0(M.join(";"))}"`);if(w)E.push(`srcset="${H0(w)}"`);if(R)E.push(`sizes="${H0(R)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[S,C]of Object.entries($.static)){if(D.has(S))continue;if(typeof C==="boolean"){if(C)E.push(H0(S))}else E.push(`${H0(S)}="${H0(C)}"`)}let k=`<img ${E.join(" ")} />`,P="";if(O){let C=U==="webp"?"image/webp":U==="avif"?"image/avif":"";P=`<link rel="preload" as="image" href="${H0(I)}"${C?` type="${C}"`:""}${w?` imagesrcset="${H0(w)}"`:""}${R?` imagesizes="${H0(R)}"`:""} />
1851
- `}if(V){let S=[];if(U==="avif"||U==="auto"){let C=s$(Y,A,N,j,"avif"),y=w?j6(Y,z6,j,"avif"):`${C}`;S.push(`<source type="image/avif" srcset="${H0(y)}"${R?` sizes="${H0(R)}"`:""} />`)}if(U==="webp"||U==="auto"){let C=s$(Y,A,N,j,"webp"),y=w?j6(Y,z6,j,"webp"):`${C}`;S.push(`<source type="image/webp" srcset="${H0(y)}"${R?` sizes="${H0(R)}"`:""} />`)}return`${P}<picture>
1850
+ `).length;X.set(W,{count:1,firstLine:_})}}}let G=[];for(let K of new Set([...X.keys(),...Y.keys()])){if(XU.has(K.toLowerCase()))continue;let W=X.get(K)?.count??0,B=Y.get(K)??0;if(W!==B)G.push({tag:K,opened:W,closed:B,firstOpenLine:X.get(K)?.firstLine??0})}return G}function G6($,Z){let X;try{X=PX($)}catch{return}if(X.length===0)return;let Y=`${Z}:${$.length}`;if(bX.has(Y))return;bX.add(Y);let Q=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:J,opened:G,closed:K,firstOpenLine:W}of X)if(G>K){let B=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 an unclosed <${J}>${B} may swallow the content that follows it.`)}else console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${J}>.`)}var ZU,XU,bX;var K6=T(()=>{ZU=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),XU=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);bX=new Set});import c0 from"path";import W6 from"fs";function xX($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function vX($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class fX{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,X,Y){let Q=$.endsWith(".stx")?$.slice(0,-4):$,J=Y?.__importedComponents;if(J){let j=[Q,Q.toLowerCase(),xX(Q),vX(Q)];for(let q of j)if(J.has(q))return J.get(q)}let G=[...new Set([`${Q}.stx`,`${xX(Q)}.stx`,`${vX(Q)}.stx`])];if(Q.startsWith("./")||Q.startsWith("../")){let j=c0.resolve(c0.dirname(Z),`${Q}.stx`);if(await l(j))return j;return null}let K=[],W=X.componentsDir||"",B=Y?.__originalFilePath;if(B)K.push(c0.join(c0.dirname(B),"components"));if(W)K.push(W);let U=c0.join(c0.dirname(Z),"components");if(!K.includes(U))K.push(U);let _=process.cwd(),z=[c0.resolve(_,"src/components"),c0.resolve(_,"components"),c0.resolve(import.meta.dir,"components")];for(let j of z)if(!K.includes(j))K.push(j);for(let j of K){if(!j)continue;for(let q of G){let H=c0.join(j,q);if(await l(H))return H}try{if(!W6.statSync(j,{throwIfNoEntry:!1})?.isDirectory())continue;let H=W6.readdirSync(j,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=c0.join(j,L.name);for(let O of G){let V=c0.join(F,O);if(await l(V))return V}}}catch{}}return null}}var y0;var U6=T(()=>{Q0();y0=new fX});function O1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function YU($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var B6;var _6=T(()=>{B6={name:"StxLink",aliases:["stx-link"],render($,Z,X){let Y=YU($),Q=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),J=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,W=[];if(Y.reactive)W.push(`:href="${O1(Y.value)}"`);else W.push(`href="${O1(Y.value)}"`);if(Q)W.push(`class="${O1(Q)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${O1(J)}"`),W.push(`data-stx-exact-active-class="${O1(G)}"`),K)W.push("data-stx-prefetch");let B=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[U,_]of Object.entries($.static)){if(B.has(U))continue;if(typeof _==="boolean"){if(_)W.push(O1(U))}else W.push(`${O1(U)}="${O1(_)}"`)}return`<a ${W.join(" ")}>${Z}</a>`}}});function H0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function k0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let X=$.static[Z];if(typeof X==="string")return X;return}function q6($,Z,X=!1){let Y=$.serverDynamic[Z];if(Y!==void 0)return Y!==!1&&Y!=="false";let Q=$.static[Z];if(Q!==void 0)return Q!=="false"&&Q!==!1;return X}function gX($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),X=[];for(let Y of Z)if(Y.includes(":")){let[Q,J]=Y.split(":"),G=JU[Q];if(G)X.push(`(max-width: ${G}px) ${J}`);else{let K=Number.parseInt(Q);if(!Number.isNaN(K))X.push(`(max-width: ${K}px) ${J}`)}}else X.push(Y);return X.join(", ")}function j6($,Z,X,Y){return Z.map((Q)=>`${s$($,Q,void 0,X,Y)} ${Q}w`).join(", ")}function QU($,Z,X,Y,Q){return Z.map((J)=>{let G=X?X*J:void 0;return`${s$($,G,void 0,Y,Q)} ${J}x`}).join(", ")}function s$($,Z,X,Y,Q){if(!Y||Y==="local"||Y==="static")return $;if(Y==="cloudinary"){let J=[];if(Z)J.push(`w_${Z}`);if(X)J.push(`h_${X}`);if(Q)J.push(`f_${Q}`);J.push("q_auto");let G=J.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(Y==="imgix"){let J=new URLSearchParams;if(Z)J.set("w",String(Z));if(X)J.set("h",String(X));if(Q)J.set("fm",Q);J.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}if(Y==="bunny"){let J=new URLSearchParams;if(Z)J.set("width",String(Z));if(X)J.set("height",String(X));if(Q)J.set("format",Q);let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}return $}function GU($,Z,X="#e5e7eb"){let Y=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${X}"/></svg>`;return`data:image/svg+xml;base64,${btoa(Y)}`}var JU,z6,H6;var O6=T(()=>{JU={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},z6=[320,640,768,1024,1280,1536,1920];H6={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,X){let Y=k0($,"src")||"",Q=k0($,"alt")||"",J=k0($,"width"),G=k0($,"height"),K=k0($,"sizes"),W=k0($,"srcset"),B=k0($,"densities"),U=k0($,"format"),_=k0($,"placeholder"),z=k0($,"placeholderColor")||"#e5e7eb",j=k0($,"provider"),q=k0($,"class")||k0($,"className")||"",H=k0($,"style")||"",L=k0($,"quality"),F=q6($,"lazy",!0),O=q6($,"preload",!1),V=q6($,"picture",!1)||!!U,A=J?Number.parseInt(J):void 0,N=G?Number.parseInt(G):void 0,w=W||"",R="";if(!w&&K)w=j6(Y,z6,j,U),R=gX(K);else if(!w&&B){let S=B.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));w=QU(Y,S,A,j,U)}else if(K)R=gX(K);let M=[];if(H)M.push(H);if(A&&N)M.push(`aspect-ratio:${A}/${N}`);if(_==="blur"||_==="color"||_==="thumbhash"){let S=GU(A||16,N||9,z);M.push(`background-image:url(${S})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat")}else if(_&&_!=="empty"&&_!=="none")M.push(`background-image:url(${H0(_)})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat");let I=s$(Y,A,N,j,U),E=[];if(E.push(`src="${H0(I)}"`),E.push(`alt="${H0(Q)}"`),J)E.push(`width="${H0(J)}"`);if(G)E.push(`height="${H0(G)}"`);if(F)E.push('loading="lazy"');if(E.push('decoding="async"'),q)E.push(`class="${H0(q)}"`);if(M.length>0)E.push(`style="${H0(M.join(";"))}"`);if(w)E.push(`srcset="${H0(w)}"`);if(R)E.push(`sizes="${H0(R)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[S,b]of Object.entries($.static)){if(D.has(S))continue;if(typeof b==="boolean"){if(b)E.push(H0(S))}else E.push(`${H0(S)}="${H0(b)}"`)}let k=`<img ${E.join(" ")} />`,P="";if(O){let b=U==="webp"?"image/webp":U==="avif"?"image/avif":"";P=`<link rel="preload" as="image" href="${H0(I)}"${b?` type="${b}"`:""}${w?` imagesrcset="${H0(w)}"`:""}${R?` imagesizes="${H0(R)}"`:""} />
1851
+ `}if(V){let S=[];if(U==="avif"||U==="auto"){let b=s$(Y,A,N,j,"avif"),y=w?j6(Y,z6,j,"avif"):`${b}`;S.push(`<source type="image/avif" srcset="${H0(y)}"${R?` sizes="${H0(R)}"`:""} />`)}if(U==="webp"||U==="auto"){let b=s$(Y,A,N,j,"webp"),y=w?j6(Y,z6,j,"webp"):`${b}`;S.push(`<source type="image/webp" srcset="${H0(y)}"${R?` sizes="${H0(R)}"`:""} />`)}return`${P}<picture>
1852
1852
  ${S.join(`
1853
1853
  `)}
1854
1854
  ${k}
@@ -1886,15 +1886,15 @@ ${k}
1886
1886
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
1887
1887
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
1888
1888
  </style>`}}});import{existsSync as UU,readFileSync as BU}from"fs";function _U($){try{return K0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let X of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(UU(X))return X;return null}function zU($){if(B7.has($))return B7.get($);let Z=_U($);if(!Z)return null;try{let X=JSON.parse(BU(Z,"utf8"));return B7.set($,X.icons),X.icons}catch{return null}}function K$($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}var B7,D6;var k6=T(()=>{B7=new Map;D6={name:"Icon",aliases:["icon","stx-icon"],render($,Z,X){let Y=K$($,"name")??K$($,"icon");if(!Y)return"<!-- Icon: missing name/icon prop -->";let Q="lucide",J=Y;if(Y.includes(":")){let O=Y.split(":");Q=O[0],J=O[1]}let G=r0(K$($,"size")||"24"),K=r0(K$($,"color")||"currentColor"),W=r0(K$($,"class")||""),B=r0(K$($,"style")||""),U=B7.get(Q)??zU(Q);if(!U)return`<!-- Icon: collection "${Q}" not loaded -->`;let _=U[J];if(!_)return`<!-- Icon: "${J}" not found in ${Q} -->`;let z=_.width||24,j=_.height||24,q=`0 0 ${z} ${j}`,H=_.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let L=W?` class="${W}"`:"",F=B?` style="${B}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${q}" fill="none"${L}${F}>${H}</svg>`}}});function pX($,...Z){for(let X of Z){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Y=$.static[X];if(typeof Y==="string")return Y}return}function cX($,Z){let X=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${Z}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),Y=$.match(X);if(!Y)return{region:null,rest:$};return{region:Y[2],rest:$.replace(Y[0],"")}}var S6;var C6=T(()=>{S6={name:"Suspense",aliases:["suspense"],render($,Z,X){let Y=cX(Z,"fallback"),Q=Y.rest,J=cX(Q,"error"),G=J.rest,K=Y.region??pX($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',W=J.region??pX($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${K}</div><div data-stx-suspense-error hidden>${W}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function _7($,...Z){for(let X of Z){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Y=$.static[X];if(typeof Y==="string")return Y}return}var b6;var P6=T(()=>{b6={name:"TransitionGroup",aliases:["transition-group"],render($,Z,X){let Y=(_7($,"name")||"v").replace(/["'<>]/g,""),Q=(_7($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",J=_7($,"class"),G=_7($,"id"),K=[`data-stx-transition-group="${Y}"`,J?`class="${J}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${Q} ${K}>${Z}</${Q}>`}}});function lX(){y0.registerBuiltin(B6),y0.registerBuiltin(H6),y0.registerBuiltin(L6),y0.registerBuiltin(N6),y0.registerBuiltin(w6),y0.registerBuiltin(M6),y0.registerBuiltin(I6),y0.registerBuiltin(D6),y0.registerBuiltin(S6),y0.registerBuiltin(b6)}var y6=T(()=>{_6();O6();F6();A6();R6();T6();E6();k6();C6();P6();U6();_6();O6();F6();A6();R6();T6();E6();k6();C6();P6()});function iX($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function nX($,Z,X){let Y=[],Q=0;while(Q<$.length){let J=$.indexOf("<",Q);if(J===-1)break;let K=$.slice(J+1).match(new RegExp(`^(${Z.source})`));if(!K){Q=J+1;continue}let W=K[1];if(X&&X.has(W.toLowerCase())){let H=J+1+W.length;while(H<$.length&&$[H]!==">")H++;Q=H+1;continue}let B=J+1+W.length,U=null,_=B,z=-1,j=!1;while(B<$.length){let H=$[B];if(U){if(H==="\\"&&B+1<$.length){B+=2;continue}if(H===U)U=null;B++;continue}if(H==='"'||H==="'"){U=H,B++;continue}if(H==="/"&&B+1<$.length&&$[B+1]===">"){z=B+2,j=!0;break}if(H===">"){z=B+1;break}B++}if(z===-1){Q=J+1;continue}let q=$.slice(_,j?z-2:z-1).trim();if(j)Y.push({fullMatch:$.slice(J,z),tagName:W,attributes:q,content:"",startIndex:J,endIndex:z,isSelfClosing:!0}),Q=z;else{let H=`<${W}`,L=`</${W}>`,F=1,O=z,V=-1;while(F>0&&O<$.length){let w=$.indexOf(H,O),R=$.indexOf(L,O);if(R===-1)break;if(w!==-1&&w<R){let M=$[w+H.length];if(M===" "||M===">"||M==="/"||M===`
1889
- `||M==="\t")F++;O=w+H.length}else{if(F--,F===0){V=R;break}O=R+L.length}}if(V===-1){Q=z;continue}let A=$.slice(z,V),N=V+L.length;Y.push({fullMatch:$.slice(J,N),tagName:W,attributes:q,content:A,startIndex:J,endIndex:N,isSelfClosing:!1}),Q=N}}return Y}function rX($,Z){try{let X=Buffer.from($,"base64").toString("utf8");return JSON.parse(X)}catch{}try{let X=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(X)}catch(X){if(Z?.debug)console.error("Error decoding __stx_ prop:",X);return $}}var sX=T(()=>{L0();Q0();c5()});var ZY={};a(ZY,{processESImports:()=>$Y,processComponents:()=>q7});import z7 from"fs";import u0 from"path";function HU($,Z,X){let Y={static:{},serverDynamic:{},clientReactive:{},events:{}},Q=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),J=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!Q.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){Y.events[W]=K;continue}if(W.startsWith("__stx_")){let B=J(W.slice(6));Y.serverDynamic[B]=rX(K,X);continue}if(W.startsWith(":")){let B=J(W.slice(1)),U=K==="true"?B:K;try{if(!X0(U)){if(X.debug)console.error(`Unsafe expression in :${B} binding: ${U}`);Y.clientReactive[B]=U;continue}let _=Object.keys(Z),j=Y0(U,_)(...Object.values(Z));if(j===void 0){let q=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(q.some((F)=>!H.has(F)&&!_.includes(F))){Y.clientReactive[B]=U;continue}}Y.serverDynamic[B]=j}catch{Y.clientReactive[B]=U}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let B=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(B)try{let U=B[1];if(X0(U)){let z=Y0(U,Object.keys(Z))(...Object.values(Z));Y.static[W]=z!=null?String(z):""}else{if(X.debug)console.error(`Unsafe expression in ${W}: ${U}`);Y.static[W]=K}}catch(U){if(X.debug)console.error(`Error evaluating expression for ${W}:`,U);Y.static[W]=K}else{let U=K,_=/\{\{\s*([\s\S]+?)\s*\}\}/g,z;while((z=_.exec(K))!==null)try{let j=z[1];if(!X0(j)){if(X.debug)console.error(`Unsafe expression in ${W}: ${j}`);continue}let H=Y0(j,Object.keys(Z))(...Object.values(Z));U=U.replace(z[0],String(H??""))}catch(j){if(X.debug)console.error(`Error evaluating expression in ${W}:`,j)}Y.static[W]=U}continue}Y.static[W]=K}return Y}function OU($){let Z={},X=0,Y=$.length;while(X<Y){while(X<Y&&/\s/.test($[X]))X++;if(X>=Y)break;let Q="";while(X<Y&&!/[\s=]/.test($[X]))Q+=$[X],X++;if(!Q)break;while(X<Y&&/\s/.test($[X]))X++;if(X<Y&&$[X]==="="){X++;while(X<Y&&/\s/.test($[X]))X++;let J="";if(X<Y&&($[X]==='"'||$[X]==="'")){let G=$[X];X++;while(X<Y){let K=$[X];if(K==="\\"&&X+1<Y){X++,J+=$[X],X++;continue}if(K===G){X++;break}J+=K,X++}}else while(X<Y&&!/\s/.test($[X]))J+=$[X],X++;Z[Q]=J}else Z[Q]="true"}return Z}function aX($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function LU($){let Z=new Set,X=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,Y;while((Y=X.exec($))!==null){let Q=Y[1];if(y0.isBuiltin(Q))Z.add(Q)}return[...Z].sort()}function FU($){let Z=tX.get($);if(Z)return Z;let X=new Map,Y=[u0.join($,"src"),u0.join($,"dist"),$];function Q(J,G){if(G>6)return;let K;try{K=z7.readdirSync(J,{withFileTypes:!0})}catch{return}for(let W of K){let B=u0.join(J,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;Q(B,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let U=W.name.slice(0,-4);if(!X.has(U))X.set(U,B);let _=U.toLowerCase();if(!X.has(_))X.set(_,B);let z=U.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!X.has(z))X.set(z,B)}}}for(let J of Y)if(Q(J,0),X.size>0)break;return tX.set($,X),X}function VU($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let X=Z;while(!0){let Y=u0.join(X,"node_modules",$);try{if(z7.statSync(Y).isDirectory())return Y}catch{}let Q=u0.dirname(X);if(Q===X)return null;X=Q}}async function $Y($,Z,X,Y,Q){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let J=Z.__importedComponents,G=u0.dirname(X),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(B,U,_)=>{let z=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,j=_,q,H=[];while((q=z.exec(_))!==null){let[L,F,O,V]=q,A=null,N=null;if(V.startsWith(".")||V.startsWith("/")){let M=u0.resolve(G,V);if(M.endsWith(".stx"))N=M;else{let I=`${M}.stx`;try{if(z7.statSync(I).isFile())N=I}catch{try{if(z7.statSync(M).isDirectory())A=M}catch{}}}}else A=VU(V,G);if(!A&&!N)continue;let w=!1,R=(M,I)=>{J.set(M,I),J.set(M.toLowerCase(),I);let E=M.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();J.set(E,I),Q.add(I)};if(O&&N)R(O,N),w=!0;else if(F){let M=F.slice(1,-1).split(",").map((E)=>E.trim()).filter(Boolean).map((E)=>{let D=E.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:E,local:E}}),I=A?FU(A):null;for(let{source:E,local:D}of M){let k=null;if(N)k=N;else if(I)k=I.get(E)??I.get(E.toLowerCase())??I.get(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(k)R(D,k),w=!0}}if(w)H.push({start:q.index,end:q.index+L.length})}if(H.length===0)return B;for(let L=H.length-1;L>=0;L--)j=j.slice(0,H[L].start)+j.slice(H[L].end);return`<script${U}>${j}</script>`}),K}async function NU($,Z,X,Y,Q){let J=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(J))!==null){let[B,U]=W,_=U.split(",").map((z)=>z.trim().replace(/^['"]|['"]$/g,"")).filter((z)=>z.length>0);for(let z of _){let j=z.split("/"),H=j[j.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[u0.resolve(u0.dirname(X),`${z}.stx`),u0.resolve(u0.dirname(X),z),u0.resolve(Y.componentsDir||"components",`${z}.stx`),u0.resolve(Y.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),Q.add(F),Y.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(Y.debug)console.warn(`Could not resolve imported component: ${z}`)}J=J.replace(B,""),K.lastIndex=0}return J}async function AU($,Z,X,Y,Q){let J=$,G=Y.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,B;while((B=W.exec(J))!==null){let U=B.index,_=U+B[0].length-1,z=1,j=_+1;while(j<J.length&&z>0){if(J[j]==="(")z++;else if(J[j]===")"){if(z--,z===0)break}j++}if(z!==0)break;let q=J.substring(_+1,j),H=j+1,L=q.match(/^\s*['"]([^'"]+)['"]/);if(!L){W.lastIndex=0;continue}let F=L[1],O,V=q.slice(L[0].length),A=V.match(/^\s*,\s*/);if(A)O=V.slice(A[0].length).trim();let N={};if(O)try{N=O0(O,Z)}catch(D){let k=D instanceof Error?D.message:String(D);J=J.replace(J.substring(U,H),`[Error parsing component props: ${k}]`);continue}let w="",R=H,I=J.substring(H).match(/^([\s\S]*?)@endcomponent/);if(I)w=I[1].trim(),R=H+I[0].length;let E=await F1(F,N,w,G,Z,X,Y,K,Q);J=J.substring(0,U)+E+J.substring(R),W.lastIndex=0}return J}async function wU($,Z,X,Y,Q){if(!$)return $;let J=$,G=Y.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=R4(J);return J=W.output,J=await z(J,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),J=await z(J,/[A-Z][a-zA-Z0-9]*/,!0),J=await z(J,/[a-z][a-z0-9]*/,!1,jU),J=M4(J,W.scripts),J;async function z(j,q,H,L){if(!j)return j;let F=j,O=nX(F,q,L);for(let V=O.length-1;V>=0;V--){let A=O[V],N=H?iX(A.tagName):A.tagName,w=OU(A.attributes),R=HU(w,Z,Y),M=y0.getBuiltin(A.tagName),I=M?await XY(N,G,Z,X,Y):!1;if(M&&!I){let P={context:Z,filePath:X,options:Y,dependencies:Q},S=M.render(R,A.content,P);if(Object.keys(R.clientReactive).length>0)S=eX(S,R.clientReactive);if(Object.keys(R.events).length>0){let C=Object.entries(R.events).map(([y,m])=>`${y}="${aX(m)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${C}`)}F=F.substring(0,A.startIndex)+S+F.substring(A.endIndex);continue}let E={};for(let[P,S]of Object.entries(R.static))E[P]=S;for(let[P,S]of Object.entries(R.serverDynamic))E[P]=S;let k=await F1(N,E,A.content,G,Z,X,Y,K,Q);if(Object.keys(R.clientReactive).length>0)k=eX(k,R.clientReactive);if(Object.keys(R.events).length>0){let P=k.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(P){let S=Object.entries(R.events).map(([y,m])=>`${y}="${aX(m)}"`).join(" "),C=P[1].length+P[2].length;k=k.substring(0,C)+" "+S+k.substring(C)}}F=F.substring(0,A.startIndex)+k+F.substring(A.endIndex)}return F}}function eX($,Z){let X=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!X)return $;let Y=Object.entries(Z).map(([J,G])=>`:${J}="${G.replace(/"/g,"&quot;")}"`).join(" "),Q=X[1].length+X[2].length;return $.substring(0,Q)+" "+Y+$.substring(Q)}async function q7($,Z,X,Y,Q){if(!oX)lX(),oX=!0;let J=await $Y($,Z,X,Y,Q);J=await NU(J,Z,X,Y,Q),J=await AU(J,Z,X,Y,Q);for(let G=0;G<3;G++){let K=J;if(J=await wU(J,Z,X,Y,Q),J===K)break}if(Y.debug){let G=LU(J);if(G.length>0)console.warn(`[stx] ${X}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return J}var oX=!1,jU,tX;var x6=T(()=>{U6();y6();sX();Q0();L0();jU=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);tX=new Map});var j7={};a(j7,{stripTypeScript:()=>KY,hasVariables:()=>zY,extractVariables:()=>P0,extractScriptFromTemplate:()=>_Y,convertToCommonJS:()=>f6});import W$ from"path";import a$ from"process";function RU($){let Z=[],X=0,Y=$.split(`
1889
+ `||M==="\t")F++;O=w+H.length}else{if(F--,F===0){V=R;break}O=R+L.length}}if(V===-1){Q=z;continue}let A=$.slice(z,V),N=V+L.length;Y.push({fullMatch:$.slice(J,N),tagName:W,attributes:q,content:A,startIndex:J,endIndex:N,isSelfClosing:!1}),Q=N}}return Y}function rX($,Z){try{let X=Buffer.from($,"base64").toString("utf8");return JSON.parse(X)}catch{}try{let X=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(X)}catch(X){if(Z?.debug)console.error("Error decoding __stx_ prop:",X);return $}}var sX=T(()=>{L0();Q0();c5()});var ZY={};a(ZY,{processESImports:()=>$Y,processComponents:()=>q7});import z7 from"fs";import u0 from"path";function HU($,Z,X){let Y={static:{},serverDynamic:{},clientReactive:{},events:{}},Q=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),J=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!Q.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){Y.events[W]=K;continue}if(W.startsWith("__stx_")){let B=J(W.slice(6));Y.serverDynamic[B]=rX(K,X);continue}if(W.startsWith(":")){let B=J(W.slice(1)),U=K==="true"?B:K;try{if(!X0(U)){if(X.debug)console.error(`Unsafe expression in :${B} binding: ${U}`);Y.clientReactive[B]=U;continue}let _=Object.keys(Z),j=Y0(U,_)(...Object.values(Z));if(j===void 0){let q=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(q.some((F)=>!H.has(F)&&!_.includes(F))){Y.clientReactive[B]=U;continue}}Y.serverDynamic[B]=j}catch{Y.clientReactive[B]=U}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let B=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(B)try{let U=B[1];if(X0(U)){let z=Y0(U,Object.keys(Z))(...Object.values(Z));Y.static[W]=z!=null?String(z):""}else{if(X.debug)console.error(`Unsafe expression in ${W}: ${U}`);Y.static[W]=K}}catch(U){if(X.debug)console.error(`Error evaluating expression for ${W}:`,U);Y.static[W]=K}else{let U=K,_=/\{\{\s*([\s\S]+?)\s*\}\}/g,z;while((z=_.exec(K))!==null)try{let j=z[1];if(!X0(j)){if(X.debug)console.error(`Unsafe expression in ${W}: ${j}`);continue}let H=Y0(j,Object.keys(Z))(...Object.values(Z));U=U.replace(z[0],String(H??""))}catch(j){if(X.debug)console.error(`Error evaluating expression in ${W}:`,j)}Y.static[W]=U}continue}Y.static[W]=K}return Y}function OU($){let Z={},X=0,Y=$.length;while(X<Y){while(X<Y&&/\s/.test($[X]))X++;if(X>=Y)break;let Q="";while(X<Y&&!/[\s=]/.test($[X]))Q+=$[X],X++;if(!Q)break;while(X<Y&&/\s/.test($[X]))X++;if(X<Y&&$[X]==="="){X++;while(X<Y&&/\s/.test($[X]))X++;let J="";if(X<Y&&($[X]==='"'||$[X]==="'")){let G=$[X];X++;while(X<Y){let K=$[X];if(K==="\\"&&X+1<Y){X++,J+=$[X],X++;continue}if(K===G){X++;break}J+=K,X++}}else while(X<Y&&!/\s/.test($[X]))J+=$[X],X++;Z[Q]=J}else Z[Q]="true"}return Z}function aX($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function LU($){let Z=new Set,X=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,Y;while((Y=X.exec($))!==null){let Q=Y[1];if(y0.isBuiltin(Q))Z.add(Q)}return[...Z].sort()}function FU($){let Z=tX.get($);if(Z)return Z;let X=new Map,Y=[u0.join($,"src"),u0.join($,"dist"),$];function Q(J,G){if(G>6)return;let K;try{K=z7.readdirSync(J,{withFileTypes:!0})}catch{return}for(let W of K){let B=u0.join(J,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;Q(B,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let U=W.name.slice(0,-4);if(!X.has(U))X.set(U,B);let _=U.toLowerCase();if(!X.has(_))X.set(_,B);let z=U.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!X.has(z))X.set(z,B)}}}for(let J of Y)if(Q(J,0),X.size>0)break;return tX.set($,X),X}function VU($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let X=Z;while(!0){let Y=u0.join(X,"node_modules",$);try{if(z7.statSync(Y).isDirectory())return Y}catch{}let Q=u0.dirname(X);if(Q===X)return null;X=Q}}async function $Y($,Z,X,Y,Q){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let J=Z.__importedComponents,G=u0.dirname(X),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(B,U,_)=>{let z=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,j=_,q,H=[];while((q=z.exec(_))!==null){let[L,F,O,V]=q,A=null,N=null;if(V.startsWith(".")||V.startsWith("/")){let M=u0.resolve(G,V);if(M.endsWith(".stx"))N=M;else{let I=`${M}.stx`;try{if(z7.statSync(I).isFile())N=I}catch{try{if(z7.statSync(M).isDirectory())A=M}catch{}}}}else A=VU(V,G);if(!A&&!N)continue;let w=!1,R=(M,I)=>{J.set(M,I),J.set(M.toLowerCase(),I);let E=M.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();J.set(E,I),Q.add(I)};if(O&&N)R(O,N),w=!0;else if(F){let M=F.slice(1,-1).split(",").map((E)=>E.trim()).filter(Boolean).map((E)=>{let D=E.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:E,local:E}}),I=A?FU(A):null;for(let{source:E,local:D}of M){let k=null;if(N)k=N;else if(I)k=I.get(E)??I.get(E.toLowerCase())??I.get(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(k)R(D,k),w=!0}}if(w)H.push({start:q.index,end:q.index+L.length})}if(H.length===0)return B;for(let L=H.length-1;L>=0;L--)j=j.slice(0,H[L].start)+j.slice(H[L].end);return`<script${U}>${j}</script>`}),K}async function NU($,Z,X,Y,Q){let J=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(J))!==null){let[B,U]=W,_=U.split(",").map((z)=>z.trim().replace(/^['"]|['"]$/g,"")).filter((z)=>z.length>0);for(let z of _){let j=z.split("/"),H=j[j.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[u0.resolve(u0.dirname(X),`${z}.stx`),u0.resolve(u0.dirname(X),z),u0.resolve(Y.componentsDir||"components",`${z}.stx`),u0.resolve(Y.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),Q.add(F),Y.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(Y.debug)console.warn(`Could not resolve imported component: ${z}`)}J=J.replace(B,""),K.lastIndex=0}return J}async function AU($,Z,X,Y,Q){let J=$,G=Y.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,B;while((B=W.exec(J))!==null){let U=B.index,_=U+B[0].length-1,z=1,j=_+1;while(j<J.length&&z>0){if(J[j]==="(")z++;else if(J[j]===")"){if(z--,z===0)break}j++}if(z!==0)break;let q=J.substring(_+1,j),H=j+1,L=q.match(/^\s*['"]([^'"]+)['"]/);if(!L){W.lastIndex=0;continue}let F=L[1],O,V=q.slice(L[0].length),A=V.match(/^\s*,\s*/);if(A)O=V.slice(A[0].length).trim();let N={};if(O)try{N=O0(O,Z)}catch(D){let k=D instanceof Error?D.message:String(D);J=J.replace(J.substring(U,H),`[Error parsing component props: ${k}]`);continue}let w="",R=H,I=J.substring(H).match(/^([\s\S]*?)@endcomponent/);if(I)w=I[1].trim(),R=H+I[0].length;let E=await F1(F,N,w,G,Z,X,Y,K,Q);J=J.substring(0,U)+E+J.substring(R),W.lastIndex=0}return J}async function wU($,Z,X,Y,Q){if(!$)return $;let J=$,G=Y.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=R4(J);return J=W.output,J=await z(J,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),J=await z(J,/[A-Z][a-zA-Z0-9]*/,!0),J=await z(J,/[a-z][a-z0-9]*/,!1,jU),J=M4(J,W.scripts),J;async function z(j,q,H,L){if(!j)return j;let F=j,O=nX(F,q,L);for(let V=O.length-1;V>=0;V--){let A=O[V],N=H?iX(A.tagName):A.tagName,w=OU(A.attributes),R=HU(w,Z,Y),M=y0.getBuiltin(A.tagName),I=M?await XY(N,G,Z,X,Y):!1;if(M&&!I){let P={context:Z,filePath:X,options:Y,dependencies:Q},S=M.render(R,A.content,P);if(Object.keys(R.clientReactive).length>0)S=eX(S,R.clientReactive);if(Object.keys(R.events).length>0){let b=Object.entries(R.events).map(([y,m])=>`${y}="${aX(m)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}F=F.substring(0,A.startIndex)+S+F.substring(A.endIndex);continue}let E={};for(let[P,S]of Object.entries(R.static))E[P]=S;for(let[P,S]of Object.entries(R.serverDynamic))E[P]=S;let k=await F1(N,E,A.content,G,Z,X,Y,K,Q);if(Object.keys(R.clientReactive).length>0)k=eX(k,R.clientReactive);if(Object.keys(R.events).length>0){let P=k.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(P){let S=Object.entries(R.events).map(([y,m])=>`${y}="${aX(m)}"`).join(" "),b=P[1].length+P[2].length;k=k.substring(0,b)+" "+S+k.substring(b)}}F=F.substring(0,A.startIndex)+k+F.substring(A.endIndex)}return F}}function eX($,Z){let X=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!X)return $;let Y=Object.entries(Z).map(([J,G])=>`:${J}="${G.replace(/"/g,"&quot;")}"`).join(" "),Q=X[1].length+X[2].length;return $.substring(0,Q)+" "+Y+$.substring(Q)}async function q7($,Z,X,Y,Q){if(!oX)lX(),oX=!0;let J=await $Y($,Z,X,Y,Q);J=await NU(J,Z,X,Y,Q),J=await AU(J,Z,X,Y,Q);for(let G=0;G<3;G++){let K=J;if(J=await wU(J,Z,X,Y,Q),J===K)break}if(Y.debug){let G=LU(J);if(G.length>0)console.warn(`[stx] ${X}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return J}var oX=!1,jU,tX;var x6=T(()=>{U6();y6();sX();Q0();L0();jU=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);tX=new Map});var j7={};a(j7,{stripTypeScript:()=>KY,hasVariables:()=>zY,extractVariables:()=>P0,extractScriptFromTemplate:()=>_Y,convertToCommonJS:()=>f6});import W$ from"path";import a$ from"process";function RU($){let Z=[],X=0,Y=$.split(`
1890
1890
  `);for(let Q of Y){let J=X,G=null,K=!1;for(let W=0;W<Q.length;W++){let B=Q[W];if(K){K=!1;continue}if(B==="\\"){K=!0;continue}if(G){if(B===G)G=null;continue}if(B==="'"||B==='"'||B==="`"){G=B;continue}if(B==="/"&&W+1<Q.length&&Q[W+1]==="/")break;if(B==="{")X++;else if(B==="}")X--}if(J===0){let W=Q.match(/(?:const|let|var)\s+(\w+)\s*=/);if(W)Z.push(W[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(Q)){let B=Q.match(/(?:const|let|var)\s+(\w+)/);if(B)Z.push(B[1])}else{let B=Q.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(B){let _=B[1].slice(1,-1).split(",").map((z)=>{let j=z.split(":");return(j.length>1?j[1]:j[0]).trim()}).filter((z)=>/^\w+$/.test(z));Z.push(..._)}}}}return[...new Set(Z)]}function KY($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function X(Y){if(!Y.includes(":"))return Y;let Q=[],J="",G=0,K=0,W=null;for(let B=0;B<Y.length;B++){let U=Y[B];if(W){if(J+=U,U===W)W=null;continue}if(U==='"'||U==="'"||U==="`"){W=U,J+=U;continue}if(U==="<")G++;else if(U===">"&&G>0)G--;else if(U==="(")K++;else if(U===")")K--;if(U===","&&G===0&&K===0){Q.push(J),J="";continue}J+=U}if(J)Q.push(J);return Q.map((B)=>{let U=B.trim(),_=U.startsWith("..."),z=_?U.slice(3):U,j=-1,q=0;for(let N=0;N<z.length;N++)if(z[N]==="<")q++;else if(z[N]===">")q--;else if(z[N]===":"&&q===0){j=N;break}if(j===-1)return B;let L=z.substring(0,j).trim().replace(/\?$/,""),F=z.substring(j+1),O=-1,V=0;for(let N=0;N<F.length;N++)if(F[N]==="<")V++;else if(F[N]===">")V--;else if(F[N]==="="&&V===0){O=N;break}let A=_?"...":"";if(O!==-1)return`${A}${L} = ${F.substring(O+1).trim()}`;return`${A}${L}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(Y,Q,J)=>{if(!J.includes(":"))return Y;return`${Q}(${X(J)})`});{let Y=/\b(function\s+\w*\s*)\(/g,Q,J=[];while((Q=Y.exec(Z))!==null){let G=Q.index+Q[0].length-1,K=1,W=G+1,B=0,U=null;while(W<Z.length&&K>0){let j=Z[W];if(U){if(j===U)U=null;W++;continue}if(j==='"'||j==="'"||j==="`"){U=j,W++;continue}if(j==="<")B++;else if(j===">"&&B>0)B--;else if(B===0){if(j==="(")K++;else if(j===")")K--}if(K>0)W++}if(K!==0)continue;let _=Z.substring(G+1,W);if(!_.includes(":"))continue;let z=X(_);J.push({start:G+1,end:W,replacement:z})}for(let G=J.length-1;G>=0;G--){let{start:K,end:W,replacement:B}=J[G];Z=Z.substring(0,K)+B+Z.substring(W)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(Y,Q)=>{if(!Q.includes(":"))return Y;if(Q.includes("{")||Q.includes("}"))return Y;return`(${Q.split(",").map((G)=>{let[K,...W]=G.split("="),B=K.split(":")[0].trim();if(W.length>0)return`${B} = ${W.join("=").trim()}`;return B}).join(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),Z=Z.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),Z=Z.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),Z=Z.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),Z=Z.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),Z=Z.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),Z=Z.replace(/\n\s*\n\s*\n/g,`
1891
1891
 
1892
- `),Z}async function P0($,Z,X,Y={}){if(!$.trim())return;let Q;try{let b=new Bun.Transpiler({loader:"ts",target:"browser",define:l0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),Q=b.transformSync(v)}catch{Q=KY($)}let J={exports:{}},G=J.exports,K=a$.cwd(),W={},B=[...Q.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((b)=>b[1]).filter((b)=>!b.startsWith("node:")&&!b.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(b));for(let b of B)try{let v=W$.resolve(K,"node_modules",b),f=W$.join(v,"package.json"),d=JSON.parse(K0("fs").readFileSync(f,"utf8")),c=d.main||"index.js";if(d.exports){let o=typeof d.exports==="string"?d.exports:d.exports["."];if(typeof o==="string")c=o;else if(o?.bun)c=o.bun;else if(o?.import)c=o.import;else if(o?.default)c=o.default}W[b]=await import(W$.resolve(v,c))}catch{}let U=(b)=>{if(W[b])return W[b];return K0(b)},_=Z.props||{},z=Object.assign((b)=>{if(!b)return _;let v={};for(let[f,d]of Object.entries(b)){let c=_[f];if(c!==void 0)v[f]=c;else if(typeof d==="function")v[f]=d();else v[f]=d}return v},_),j=(b)=>{if(!b)return _;let v={..._};for(let[f,d]of Object.entries(b)){let c=d&&typeof d==="object"&&!Array.isArray(d)?d:{type:d};if(v[f]===void 0&&c.default!==void 0)v[f]=typeof c.default==="function"?c.default():c.default}return v},q=()=>Z.slots||{},H=(b,v)=>{let f={...b};for(let[d,c]of Object.entries(v))if(f[d]===void 0)if(typeof c==="function")f[d]=c();else f[d]=c;return f},L=(b)=>{let v=()=>b;return v.set=(f)=>{},v.update=(f)=>{},v},F=(b)=>{let v,f=!1;return()=>{if(!f)try{v=b(),f=!0}catch{v=void 0}return v}},O=(b)=>{},V=(b)=>b(),A=(b)=>{},N=(b)=>{},w=(b)=>{},R=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),M=()=>({push:(b)=>{},replace:(b)=>{},back:()=>{},forward:()=>{},go:(b)=>{}}),I=(b)=>{m1(b);let v=Z.__stx_runtime_head||{},f=b||{};Z.__stx_runtime_head={...v,...f.title&&{title:f.title},meta:[...v.meta||[],...f.meta||[]],link:[...v.link||[],...f.link||[]],script:[...v.script||[],...f.script||[]],htmlAttrs:{...v.htmlAttrs||{},...f.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...f.bodyAttrs||{}}}},E=(b)=>{Y7(b);let v=c$();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(b)=>({value:b}),k=(b)=>b,P=(b)=>({value:typeof b==="function"?b():b}),S=(b,v)=>{},C=(b)=>{},y=(b)=>{},m=(b)=>b?b():Promise.resolve(),g=(b)=>(v,...f)=>{},p=(b)=>{},s=(b,v)=>{},M0=(b,v)=>v,Y1=()=>({value:"light"}),v0=()=>({value:!1}),S0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},$0=new Proxy(S0,{get(b,v){if(v in b)return b[v];return},set(b,v,f){return b[v]=f,!0}}),V0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},z0=console;try{let b=f6(Q,X),v=new Set(Object.keys(_)),f=Object.keys(Z).filter((e)=>!v.has(e)&&e!=="props"),d=f.map((e)=>Z[e]),c=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),o=[],W0=[];for(let[e,o0]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e))continue;if(c.has(e))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${e}\\b`).test(b))continue;o.push(e),W0.push(o0)}let f0=RU(b).map((e)=>`module.exports.${e} = typeof ${e} !== 'undefined' ? ${e} : module.exports.${e};`).join(`
1892
+ `),Z}async function P0($,Z,X,Y={}){if(!$.trim())return;let Q;try{let C=new Bun.Transpiler({loader:"ts",target:"browser",define:l0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),Q=C.transformSync(v)}catch{Q=KY($)}let J={exports:{}},G=J.exports,K=a$.cwd(),W={},B=[...Q.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((C)=>C[1]).filter((C)=>!C.startsWith("node:")&&!C.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(C));for(let C of B)try{let v=W$.resolve(K,"node_modules",C),f=W$.join(v,"package.json"),d=JSON.parse(K0("fs").readFileSync(f,"utf8")),c=d.main||"index.js";if(d.exports){let o=typeof d.exports==="string"?d.exports:d.exports["."];if(typeof o==="string")c=o;else if(o?.bun)c=o.bun;else if(o?.import)c=o.import;else if(o?.default)c=o.default}W[C]=await import(W$.resolve(v,c))}catch{}let U=(C)=>{if(W[C])return W[C];return K0(C)},_=Z.props||{},z=Object.assign((C)=>{if(!C)return _;let v={};for(let[f,d]of Object.entries(C)){let c=_[f];if(c!==void 0)v[f]=c;else if(typeof d==="function")v[f]=d();else v[f]=d}return v},_),j=(C)=>{if(!C)return _;let v={..._};for(let[f,d]of Object.entries(C)){let c=d&&typeof d==="object"&&!Array.isArray(d)?d:{type:d};if(v[f]===void 0&&c.default!==void 0)v[f]=typeof c.default==="function"?c.default():c.default}return v},q=()=>Z.slots||{},H=(C,v)=>{let f={...C};for(let[d,c]of Object.entries(v))if(f[d]===void 0)if(typeof c==="function")f[d]=c();else f[d]=c;return f},L=(C)=>{let v=()=>C;return v.set=(f)=>{},v.update=(f)=>{},v},F=(C)=>{let v,f=!1;return()=>{if(!f)try{v=C(),f=!0}catch{v=void 0}return v}},O=(C)=>{},V=(C)=>C(),A=(C)=>{},N=(C)=>{},w=(C)=>{},R=()=>{let C=Z.__stxServeContext,v=Z.__stxServeSearch??C?.search??"",f=C?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(v)),path:f,name:"",fullPath:f+v,hash:"",matched:[]}},M=()=>({push:(C)=>{},replace:(C)=>{},back:()=>{},forward:()=>{},go:(C)=>{}}),I=(C)=>{m1(C);let v=Z.__stx_runtime_head||{},f=C||{};Z.__stx_runtime_head={...v,...f.title&&{title:f.title},meta:[...v.meta||[],...f.meta||[]],link:[...v.link||[],...f.link||[]],script:[...v.script||[],...f.script||[]],htmlAttrs:{...v.htmlAttrs||{},...f.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...f.bodyAttrs||{}}}},E=(C)=>{Y7(C);let v=c$();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(C)=>({value:C}),k=(C)=>C,P=(C)=>({value:typeof C==="function"?C():C}),S=(C,v)=>{},b=(C)=>{},y=(C)=>{},m=(C)=>C?C():Promise.resolve(),g=(C)=>(v,...f)=>{},p=(C)=>{},s=(C,v)=>{},M0=(C,v)=>v,Y1=()=>({value:"light"}),v0=()=>({value:!1}),C0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},$0=new Proxy(C0,{get(C,v){if(v in C)return C[v];return},set(C,v,f){return C[v]=f,!0}}),V0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},z0=console;try{let C=f6(Q,X),v=new Set(Object.keys(_)),f=Object.keys(Z).filter((e)=>!v.has(e)&&e!=="props"),d=f.map((e)=>Z[e]),c=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),o=[],W0=[];for(let[e,o0]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e))continue;if(c.has(e))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${e}\\b`).test(C))continue;o.push(e),W0.push(o0)}let f0=RU(C).map((e)=>`module.exports.${e} = typeof ${e} !== 'undefined' ? ${e} : module.exports.${e};`).join(`
1893
1893
  `),k1=Z.params??{},_0=[],S1=[];for(let e=0;e<f.length;e++){if(f[e]==="params")continue;_0.push(f[e]),S1.push(d[e])}let b5=await Function("module","exports","require","props","$props","defineProps","withDefaults","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...o,..._0,`return (async () => {
1894
- ${b}
1894
+ ${C}
1895
1895
  ${f0}
1896
1896
  return module.exports
1897
- })()`)(J,G,U,_,z,j,H,L,F,O,V,A,N,w,R,M,I,E,D,k,P,S,C,y,m,g,p,q,s,M0,Y1,v0,$0,V0,z0,S0.confirm,S0.alert,S0.fetch,k1,...W0,...S1);if(Y.preserveExisting){for(let[e,o0]of Object.entries(b5))if(!(e in Z)||Z[e]===void 0)Z[e]=o0}else Object.assign(Z,b5);for(let[e,o0]of Object.entries(_))if(!(e in Z))Z[e]=o0}catch(b){if(a$.env.STX_DEBUG){let v=b instanceof Error?b.message:String(b);console.warn(`[stx] server <script> did not execute in ${X??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await DU(Q,Z,X)}catch(v){if(a$.env.STX_DEBUG){let f=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${X??"<unknown>"}: ${f}`)}}}}function f6($,Z){let X=Z?W$.dirname(Z):a$.cwd(),Y=$.split(`
1897
+ })()`)(J,G,U,_,z,j,H,L,F,O,V,A,N,w,R,M,I,E,D,k,P,S,b,y,m,g,p,q,s,M0,Y1,v0,$0,V0,z0,C0.confirm,C0.alert,C0.fetch,k1,...W0,...S1);if(Y.preserveExisting){for(let[e,o0]of Object.entries(b5))if(!(e in Z)||Z[e]===void 0)Z[e]=o0}else Object.assign(Z,b5);for(let[e,o0]of Object.entries(_))if(!(e in Z))Z[e]=o0}catch(C){if(a$.env.STX_DEBUG){let v=C instanceof Error?C.message:String(C);console.warn(`[stx] server <script> did not execute in ${X??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await DU(Q,Z,X)}catch(v){if(a$.env.STX_DEBUG){let f=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${X??"<unknown>"}: ${f}`)}}}}function f6($,Z){let X=Z?W$.dirname(Z):a$.cwd(),Y=$.split(`
1898
1898
  `),Q=[],J=0;while(J<Y.length){let G=Y[J].trim();if(G.startsWith("interface ")||G.startsWith("export interface ")||G.startsWith("type ")||G.startsWith("export type ")){if(G.includes("{")&&!G.includes("}")){let K=0;for(;J<Y.length;J++){for(let W of Y[J])if(W==="{")K++;else if(W==="}")K--;if(K<=0)break}}J++;continue}if(G.startsWith("definePageMeta(")){let K=0,W=!1;for(let B=J;B<Y.length&&!W;B++){let U=null,_=!1,z=Y[B];for(let j=0;j<z.length;j++){let q=z[j];if(_){_=!1;continue}if(q==="\\"){_=!0;continue}if(U){if(q===U)U=null;continue}if(q==='"'||q==="'"||q==="`"){U=q;continue}if(q==="(")K++;else if(q===")"){if(K--,K===0){J=B+1,W=!0;break}}}}if(!W)J=Y.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),B=G.match(/^import\s+['"](.+)['"]/),U=(_)=>{if(_.startsWith("."))return W$.resolve(X,_);return _};if(K){let[,_,z]=K,j=U(z);Q.push(`const ${_} = await import('${j}')`),Q.push(`module.exports.${_} = ${_};`)}else if(W){let[,_,z]=W,j=_.trim(),q=U(z);Q.push(`const { ${j} } = await import('${q}')`);for(let H of j.split(",")){let L=H.trim().split(/\s+as\s+/).pop()?.trim();if(L)Q.push(`module.exports.${L} = ${L};`)}}else if(B){let _=U(B[1]);Q.push(`await import('${_}')`)}else Q.push(G);J++;continue}if((G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")||G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var "))&&!G.includes("="))Q.push(Y[J]),J++;else if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=YY(Y,J),{type:W,name:B,value:U}=K;Q.push(`${W} ${B} = ${U};`),Q.push(`module.exports.${B} = ${B};`),J=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=v6(Y,J);Q.push(K.functionCode),Q.push(`module.exports.${K.name} = ${K.name};`),J=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=YY(Y,J),{type:W,name:B,value:U}=K;Q.push(`${W} ${B} = ${U};`),Q.push(`module.exports.${B} = ${B};`),J=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=v6(Y,J);Q.push(K.functionCode),Q.push(`module.exports.${K.name} = ${K.name};`),J=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=Y[J].replace(/^(\s*)export\s+default\s+/,"$1"),W=[...Y];W[J]=K;let B=v6(W,J);if(Q.push(B.functionCode),B.name)Q.push(`module.exports.default = ${B.name};`);J=B.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");Q.push(`module.exports.default = ${K};`),J++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let W=K[1],B=Y[J].replace(/^export\s+/,""),U=0,_=J;for(;_<Y.length;_++){let z=Y[_];for(let j of z)if(j==="{")U++;else if(j==="}")U--;if(_>J)B+=`
1899
1899
  `+z;if(U<=0&&_>=J)break}Q.push(B),Q.push(`module.exports.${W} = ${W};`),J=_+1}else Q.push(G),J++}else if(G.includes("module.exports"))Q.push(G),J++;else if(G.trim()&&!G.startsWith("//"))Q.push(G),J++;else J++}return MU(Q.join(`
1900
1900
  `),X)}function MU($,Z){let X=$.length,Y="",Q=0,J=null,G=!1,K=!1,W=0;while(Q<X){let B=$[Q],U=$[Q+1];if(G){if(Y+=B,B===`
@@ -1904,7 +1904,7 @@ ${N}`,nextIndex:O}}}}throw Error(`Failed to parse variable declaration: ${X}`)}l
1904
1904
  ${$[W]}`,W++;else break}return K=K.trim().replace(/;$/,""),{type:Q,name:J,value:K,nextIndex:W}}function v6($,Z){let X=$[Z].trim(),Y=X.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!Y)throw Error(`Failed to parse function declaration: ${X}`);let[,Q]=Y,J=X.replace(/^export\s+/,""),G=Z;if(IU(X)){let K=EU($,Z,J);J=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:Q,functionCode:J,nextIndex:G}}function JY($){let Z=$.trim();if(Z.startsWith("{"))return b0(Z,"{","}",0)===-1;if(Z.startsWith("["))return b0(Z,"[","]",0)===-1;return!BY(Z)}function BY($){let Z={paren:0,bracket:0,brace:0},X=null,Y=0;for(let Q=0;Q<$.length;Q++){let J=$[Q];if((Q>0?$[Q-1]:"")==="\\"&&X)continue;if((J==='"'||J==="'")&&!X){X=J;continue}if(J===X&&X!=="`"){X=null;continue}if(J==="`"&&!X){X="`";continue}if(J==="`"&&X==="`"&&Y===0){X=null;continue}if(X==="`"&&J==="$"&&$[Q+1]==="{"){Y++,Q++;continue}if(Y>0&&J==="{"){Y++;continue}if(Y>0&&J==="}"){Y--;continue}if(X)continue;if(J==="(")Z.paren++;else if(J===")")Z.paren--;else if(J==="[")Z.bracket++;else if(J==="]")Z.bracket--;else if(J==="{")Z.brace++;else if(J==="}")Z.brace--}return Z.paren===0&&Z.bracket===0&&Z.brace===0&&X===null}function IU($){let Z=$.indexOf("{");if(Z===-1)return!0;return b0($,"{","}",Z)===-1}function QY($,Z,X){let Y=X,Q=Z+1;while(Q<$.length&&!BY(Y)){let J=$[Q];Y+=`
1905
1905
  ${J}`,Q++}while(Q<$.length){let J=$[Q].trim();if(J.startsWith(".")||J.startsWith("?."))Y+=`
1906
1906
  ${$[Q]}`,Q++;else break}return{value:Y,nextIndex:Q}}function EU($,Z,X){let Y=X,Q=Z+1;while(Q<$.length){let J=Y.indexOf("{");if(J!==-1){if(b0(Y,"{","}",J)!==-1)break}let G=$[Q];Y+=`
1907
- ${G}`,Q++}return{functionCode:Y,nextIndex:Q}}function GY($,Z){let X=Z0($,Z)??Z0(`(${$})`,Z);if(X!==void 0)return X;if(!/\bprocess\b/.test($))return;let Y={...Z,process:Object.freeze({env:{...a$.env}})};try{return Function(...Object.keys(Y),`'use strict'; return (${$});`)(...Object.values(Y))}catch{try{return Function(...Object.keys(Y),`'use strict'; return ${$};`)(...Object.values(Y))}catch{return}}}async function DU($,Z,X){let Y=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let J of Y){let[,,G,K]=J;try{let W=K.trim().replace(/;$/,""),B=GY(W,Z);if(B!==void 0)Z[G]=B}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let Q=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let J of Q){let[,,G,K]=J;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),B=GY(W,Z);if(B!==void 0)Z[G]=B}catch{}}}function _Y($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),X=Z?Z[1]:"",Y=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:X,templateWithoutScript:Y}}function zY($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var V1=T(()=>{p1();C1();L0()});var VY={};a(VY,{processLoops:()=>g6});function CU($,Z){let X=/@component\s*\(/g,Y=$,Q,J=[];while((Q=X.exec(Y))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,B=K+1;while(B<Y.length&&W>0){if(Y[B]==="(")W++;else if(Y[B]===")"){if(W--,W===0)break}B++}if(W!==0)continue;let U=Y.substring(K+1,B),_=B+1,z=U.match(/^\s*['"]([^'"]+)['"]/);if(!z)continue;let j=z[1],q=U.slice(z[0].length),H=q.match(/^\s*,\s*/);if(!H)continue;let L=q.slice(H[0].length).trim();if(!L)continue;try{let F=O0(L,Z),O=JSON.stringify(F),V=`@component('${j}', ${O})`;J.push({start:G,end:_,replacement:V})}catch{continue}}for(let G=J.length-1;G>=0;G--){let{start:K,end:W,replacement:B}=J[G];Y=Y.substring(0,K)+B+Y.substring(W)}return Y}function H7($,Z,X){let Y=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),J;while((J=Q.exec(Y))!==null){let G=J.index,K=G+J[0].length-1,W=1,B=K+1,U=null,_=!1;while(B<Y.length&&W>0){let q=Y[B];if(_){_=!1,B++;continue}if(q==="\\"&&U){_=!0,B++;continue}if(U){if(q===U)U=null;B++;continue}if(q==='"'||q==="'"||q==="`"){U=q,B++;continue}if(q==="(")W++;else if(q===")"){if(W--,W===0)break}B++}if(W!==0)break;let z=Y.substring(K+1,B),j=X(z);Y=Y.substring(0,G)+j+Y.substring(B+1)}return Y}function bU($,Z){let X=$;return X=X.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(Y,Q)=>{if(Q in Z)return`:${Q}="${Q}"`;return Y}),X=X.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(Y,Q,J)=>{try{let G=Object.keys(Z),K=Object.values(Z);d5(J);let B=Y0(J,G)(...K),U=JSON.stringify(B),_=Buffer.from(U,"utf8").toString("base64");return`__stx_${Q}="${_}"`}catch(G){return Y}}),X}function PU($,Z){let X=$;return X=H7(X,"@break",(Y)=>{try{let J=`!!(${Y.trim()})`,G;if(X0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Z0(J,Z));return G?O7:""}catch{return""}}),X=H7(X,"@continue",(Y)=>{try{let J=`!!(${Y.trim()})`,G;if(X0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Z0(J,Z));return G?L7:""}catch{return""}}),X}function yU($){let Z=$;return Z=Z.replace(/@break(?!\()/g,O7),Z=Z.replace(/@continue(?!\()/g,L7),Z}function qY($){let Z=$.includes(O7),X=Z?$.substring(0,$.indexOf(O7)):$;return{hasBreak:Z,content:X}}function jY($){let Z=$.includes(L7),X=Z?$.substring(0,$.indexOf(L7)):$;return{hasContinue:Z,content:X}}function OY($){let Z=$;return Z=H7(Z,"@break",(X)=>{let Y=X.trim();if(!u5(Y))return"";return`\`; if (${Y}) { break; } result += \``}),Z=H7(Z,"@continue",(X)=>{let Y=X.trim();if(!u5(Y))return"";return`\`; if (${Y}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function xU($){let Z=/@forelse\s*\(/g,X,Y=[],Q=/@foreach\s*\(/g,J=/@endforeach/g,G;while((G=Q.exec($))!==null)Y.push({pos:G.index,delta:1});while((G=J.exec($))!==null)Y.push({pos:G.index,delta:-1});Y.sort((U,_)=>U.pos-_.pos);let K=[],W=0;for(let U of Y)W+=U.delta,K.push({pos:U.pos,depth:W});function B(U){let _=0,z=K.length-1,j=0;while(_<=z){let q=_+z>>1;if(K[q].pos<=U)j=K[q].depth,_=q+1;else z=q-1}return j}while((X=Z.exec($))!==null){if(B(X.index)>0)continue;let U=X.index,_=X.index+X[0].length-1,z=1,j=_+1,q=-1;while(j<$.length&&z>0){if($[j]==="(")z++;else if($[j]===")"){if(z--,z===0){q=j;break}}j++}if(q===-1)continue;let H=$.substring(_+1,q),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=q+1,A=1,N=V,w=/@forelse\s*\(/g,R=/@endforelse/g,M=-1;while(A>0&&N<$.length){w.lastIndex=N,R.lastIndex=N;let S=w.exec($),C=R.exec($);if(!C)break;if(S&&S.index<C.index)A++,N=S.index+S[0].length;else{if(A--,A===0){M=C.index;break}N=C.index+11}}if(M===-1)continue;let I=$.substring(V,M),E=M+11,D=-1,k=0,P=0;while(P<I.length){let S=I.indexOf("@",P);if(S===-1)break;let C=I.substring(S);if(/^@forelse\s*\(/.test(C))k++,P=S+1;else if(C.startsWith("@endforelse"))k--,P=S+11;else if(k===0&&C.startsWith("@empty")){if(I.length<=S+6||!/[a-z]/i.test(I[S+6])){D=S;break}P=S+1}else P=S+1}if(D===-1)continue;return{start:U,end:E,arrayExpr:F,itemVar:O,foreachContent:I.substring(0,D),emptyContent:I.substring(D+6)}}return null}function HY($,Z){let X=$;while(!0){let Y=xU(X);if(!Y)break;let{start:Q,end:J,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:B}=Y;try{let U;if(X0(G))U=Y0(G,Object.keys(Z))(...Object.values(Z));else U=Z0(G,Z);let _;if(!Array.isArray(U)||U.length===0)_=B;else _=`@foreach (${G} as ${K})${W}@endforeach`;X=X.substring(0,Q)+_+X.substring(J)}catch(U){let _=U instanceof Error?U.message:String(U),z=r("Forelse",`Error in @forelse(${G} as ${K}): ${_}`,n.EVALUATION_ERROR);X=X.substring(0,Q)+z+X.substring(J)}}return X}function g6($,Z,X,Y){let Q=$;Q=HY(Q,Z);function J(W){let B=/@foreach\s*\(/g,U;while((U=B.exec(W))!==null){let _=U.index,z=U.index+U[0].length-1,j=1,q=z+1,H=-1;while(q<W.length&&j>0){if(W[q]==="(")j++;else if(W[q]===")"){if(j--,j===0){H=q;break}}q++}if(H===-1)continue;let L=W.substring(z+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=_,V=L.substring(0,F),A=L.substring(F+4),N=H+1,w=1,R=N,M=/@foreach\s*\(/g,I=/@endforeach/g;while(w>0&&R<W.length){M.lastIndex=R,I.lastIndex=R;let E=M.exec(W),D=I.exec(W);if(!D)break;if(E&&E.index<D.index)w++,R=E.index+E[0].length;else{if(w--,w===0){let k=W.substring(N,D.index),P=D.index+11;return{start:O,end:P,arrayExpr:V,itemVar:A,content:k}}R=D.index+11}}}return null}function G(W,B){let U=W;while(!0){let _=J(U);if(!_)break;let{start:z,end:j,arrayExpr:q,itemVar:H,content:L}=_;try{let F=q.trim(),O;if(X0(F))O=Y0(F,Object.keys(B))(...Object.values(B));else O=Z0(F,B);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${F} is not iterable`,n.TYPE_ERROR);U=U.substring(0,z)+D+U.substring(j);continue}let A=Y?.loops?.useAltLoopVariable??SU,N=H.trim(),w=null,R,M=!1;if(N.includes("=>")){let D=N.split("=>").map((k)=>k.trim());if(D.length===2&&D[0]&&D[1])w=D[0],R=D[1];else R=N}else if(!N.startsWith("[")&&!N.startsWith("{")&&N.includes(",")){let D=N.split(",").map((k)=>k.trim());if(D.length===2&&D[0]&&D[1])R=D[0],w=D[1],M=!0;else R=N}else R=N;let I="",E=O;for(let D=0;D<E.length;D++){let k=E[D],P={index:D,iteration:D+1,first:D===0,last:D===E.length-1,count:E.length},S={...B,loop:P,$loop:P};if(R.startsWith("[")&&R.endsWith("]")){let g=R.slice(1,-1).split(",").map((p)=>p.trim());if(Array.isArray(k))g.forEach((p,s)=>{if(p)S[p]=k[s]});else S[R]=k}else S[R]=k;if(w)if(!M&&V&&Array.isArray(k)&&k.length===2)S[w]=k[0],S[R]=k[1];else S[w]=D;let C=PU(L,S),y=jY(C);if(y.hasContinue){I+=y.content;continue}let m=qY(C);if(m.hasBreak){I+=m.content;break}if(C=HY(C,S),C=G(C,S),C=d1(C,S,X),C=yU(C),m=qY(C),m.hasBreak){I+=m.content;break}if(y=jY(C),y.hasContinue){I+=y.content;continue}C=i0(C,S,X),C=bU(C,S),C=CU(C,S),I+=C}U=U.substring(0,z)+I+U.substring(j)}catch(F){let O=r("Foreach",`Error in @foreach(${q.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,n.EVALUATION_ERROR);U=U.substring(0,z)+O+U.substring(j)}}return U}Q=G(Q,Z),Q=FY(Q,Z,X,Y);let K=Y?.loops?.maxWhileIterations??kU;return Q=gU(Q,Z,K),Q}function LY($){return u5($)}function FY($,Z,X,Y){let Q=$,J=!0;while(J){J=!1;let G=Q.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,B=b0(Q,"(",")",W);if(B===-1)break;let U=Q.slice(W+1,B),_=B+1,z=e5(Q.slice(K),"for","endfor");if(z.length===0)break;let j=z[0].content,q=K+z[0].end;if(!LY(U)){let H=r("For",`Unsafe expression in @for: ${U}`,n.UNSAFE_EXPRESSION);Q=Q.substring(0,K)+H+Q.substring(q),J=!0;continue}try{let H=vU(U),L=/@(?:for|foreach|if|unless)\s*\(/.test(j);if(H.length>0&&L){let w=fU({forExpr:U,content:j,iterVarNames:H,context:Z,filePath:X,options:Y});Q=Q.substring(0,K)+w+Q.substring(q),J=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=j.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,R)=>{return`\${${R}}`});V=OY(V);let N=Function(...F,`
1907
+ ${G}`,Q++}return{functionCode:Y,nextIndex:Q}}function GY($,Z){let X=Z0($,Z)??Z0(`(${$})`,Z);if(X!==void 0)return X;if(!/\bprocess\b/.test($))return;let Y={...Z,process:Object.freeze({env:{...a$.env}})};try{return Function(...Object.keys(Y),`'use strict'; return (${$});`)(...Object.values(Y))}catch{try{return Function(...Object.keys(Y),`'use strict'; return ${$};`)(...Object.values(Y))}catch{return}}}async function DU($,Z,X){let Y=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let J of Y){let[,,G,K]=J;try{let W=K.trim().replace(/;$/,""),B=GY(W,Z);if(B!==void 0)Z[G]=B}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let Q=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let J of Q){let[,,G,K]=J;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),B=GY(W,Z);if(B!==void 0)Z[G]=B}catch{}}}function _Y($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),X=Z?Z[1]:"",Y=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:X,templateWithoutScript:Y}}function zY($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var V1=T(()=>{p1();C1();L0()});var VY={};a(VY,{processLoops:()=>g6});function CU($,Z){let X=/@component\s*\(/g,Y=$,Q,J=[];while((Q=X.exec(Y))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,B=K+1;while(B<Y.length&&W>0){if(Y[B]==="(")W++;else if(Y[B]===")"){if(W--,W===0)break}B++}if(W!==0)continue;let U=Y.substring(K+1,B),_=B+1,z=U.match(/^\s*['"]([^'"]+)['"]/);if(!z)continue;let j=z[1],q=U.slice(z[0].length),H=q.match(/^\s*,\s*/);if(!H)continue;let L=q.slice(H[0].length).trim();if(!L)continue;try{let F=O0(L,Z),O=JSON.stringify(F),V=`@component('${j}', ${O})`;J.push({start:G,end:_,replacement:V})}catch{continue}}for(let G=J.length-1;G>=0;G--){let{start:K,end:W,replacement:B}=J[G];Y=Y.substring(0,K)+B+Y.substring(W)}return Y}function H7($,Z,X){let Y=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),J;while((J=Q.exec(Y))!==null){let G=J.index,K=G+J[0].length-1,W=1,B=K+1,U=null,_=!1;while(B<Y.length&&W>0){let q=Y[B];if(_){_=!1,B++;continue}if(q==="\\"&&U){_=!0,B++;continue}if(U){if(q===U)U=null;B++;continue}if(q==='"'||q==="'"||q==="`"){U=q,B++;continue}if(q==="(")W++;else if(q===")"){if(W--,W===0)break}B++}if(W!==0)break;let z=Y.substring(K+1,B),j=X(z);Y=Y.substring(0,G)+j+Y.substring(B+1)}return Y}function bU($,Z){let X=$;return X=X.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(Y,Q)=>{if(Q in Z)return`:${Q}="${Q}"`;return Y}),X=X.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(Y,Q,J)=>{try{let G=Object.keys(Z),K=Object.values(Z);d5(J);let B=Y0(J,G)(...K),U=JSON.stringify(B),_=Buffer.from(U,"utf8").toString("base64");return`__stx_${Q}="${_}"`}catch(G){return Y}}),X}function PU($,Z){let X=$;return X=H7(X,"@break",(Y)=>{try{let J=`!!(${Y.trim()})`,G;if(X0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Z0(J,Z));return G?O7:""}catch{return""}}),X=H7(X,"@continue",(Y)=>{try{let J=`!!(${Y.trim()})`,G;if(X0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Z0(J,Z));return G?L7:""}catch{return""}}),X}function yU($){let Z=$;return Z=Z.replace(/@break(?!\()/g,O7),Z=Z.replace(/@continue(?!\()/g,L7),Z}function qY($){let Z=$.includes(O7),X=Z?$.substring(0,$.indexOf(O7)):$;return{hasBreak:Z,content:X}}function jY($){let Z=$.includes(L7),X=Z?$.substring(0,$.indexOf(L7)):$;return{hasContinue:Z,content:X}}function OY($){let Z=$;return Z=H7(Z,"@break",(X)=>{let Y=X.trim();if(!u5(Y))return"";return`\`; if (${Y}) { break; } result += \``}),Z=H7(Z,"@continue",(X)=>{let Y=X.trim();if(!u5(Y))return"";return`\`; if (${Y}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function xU($){let Z=/@forelse\s*\(/g,X,Y=[],Q=/@foreach\s*\(/g,J=/@endforeach/g,G;while((G=Q.exec($))!==null)Y.push({pos:G.index,delta:1});while((G=J.exec($))!==null)Y.push({pos:G.index,delta:-1});Y.sort((U,_)=>U.pos-_.pos);let K=[],W=0;for(let U of Y)W+=U.delta,K.push({pos:U.pos,depth:W});function B(U){let _=0,z=K.length-1,j=0;while(_<=z){let q=_+z>>1;if(K[q].pos<=U)j=K[q].depth,_=q+1;else z=q-1}return j}while((X=Z.exec($))!==null){if(B(X.index)>0)continue;let U=X.index,_=X.index+X[0].length-1,z=1,j=_+1,q=-1;while(j<$.length&&z>0){if($[j]==="(")z++;else if($[j]===")"){if(z--,z===0){q=j;break}}j++}if(q===-1)continue;let H=$.substring(_+1,q),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=q+1,A=1,N=V,w=/@forelse\s*\(/g,R=/@endforelse/g,M=-1;while(A>0&&N<$.length){w.lastIndex=N,R.lastIndex=N;let S=w.exec($),b=R.exec($);if(!b)break;if(S&&S.index<b.index)A++,N=S.index+S[0].length;else{if(A--,A===0){M=b.index;break}N=b.index+11}}if(M===-1)continue;let I=$.substring(V,M),E=M+11,D=-1,k=0,P=0;while(P<I.length){let S=I.indexOf("@",P);if(S===-1)break;let b=I.substring(S);if(/^@forelse\s*\(/.test(b))k++,P=S+1;else if(b.startsWith("@endforelse"))k--,P=S+11;else if(k===0&&b.startsWith("@empty")){if(I.length<=S+6||!/[a-z]/i.test(I[S+6])){D=S;break}P=S+1}else P=S+1}if(D===-1)continue;return{start:U,end:E,arrayExpr:F,itemVar:O,foreachContent:I.substring(0,D),emptyContent:I.substring(D+6)}}return null}function HY($,Z){let X=$;while(!0){let Y=xU(X);if(!Y)break;let{start:Q,end:J,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:B}=Y;try{let U;if(X0(G))U=Y0(G,Object.keys(Z))(...Object.values(Z));else U=Z0(G,Z);let _;if(!Array.isArray(U)||U.length===0)_=B;else _=`@foreach (${G} as ${K})${W}@endforeach`;X=X.substring(0,Q)+_+X.substring(J)}catch(U){let _=U instanceof Error?U.message:String(U),z=r("Forelse",`Error in @forelse(${G} as ${K}): ${_}`,n.EVALUATION_ERROR);X=X.substring(0,Q)+z+X.substring(J)}}return X}function g6($,Z,X,Y){let Q=$;Q=HY(Q,Z);function J(W){let B=/@foreach\s*\(/g,U;while((U=B.exec(W))!==null){let _=U.index,z=U.index+U[0].length-1,j=1,q=z+1,H=-1;while(q<W.length&&j>0){if(W[q]==="(")j++;else if(W[q]===")"){if(j--,j===0){H=q;break}}q++}if(H===-1)continue;let L=W.substring(z+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=_,V=L.substring(0,F),A=L.substring(F+4),N=H+1,w=1,R=N,M=/@foreach\s*\(/g,I=/@endforeach/g;while(w>0&&R<W.length){M.lastIndex=R,I.lastIndex=R;let E=M.exec(W),D=I.exec(W);if(!D)break;if(E&&E.index<D.index)w++,R=E.index+E[0].length;else{if(w--,w===0){let k=W.substring(N,D.index),P=D.index+11;return{start:O,end:P,arrayExpr:V,itemVar:A,content:k}}R=D.index+11}}}return null}function G(W,B){let U=W;while(!0){let _=J(U);if(!_)break;let{start:z,end:j,arrayExpr:q,itemVar:H,content:L}=_;try{let F=q.trim(),O;if(X0(F))O=Y0(F,Object.keys(B))(...Object.values(B));else O=Z0(F,B);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${F} is not iterable`,n.TYPE_ERROR);U=U.substring(0,z)+D+U.substring(j);continue}let A=Y?.loops?.useAltLoopVariable??SU,N=H.trim(),w=null,R,M=!1;if(N.includes("=>")){let D=N.split("=>").map((k)=>k.trim());if(D.length===2&&D[0]&&D[1])w=D[0],R=D[1];else R=N}else if(!N.startsWith("[")&&!N.startsWith("{")&&N.includes(",")){let D=N.split(",").map((k)=>k.trim());if(D.length===2&&D[0]&&D[1])R=D[0],w=D[1],M=!0;else R=N}else R=N;let I="",E=O;for(let D=0;D<E.length;D++){let k=E[D],P={index:D,iteration:D+1,first:D===0,last:D===E.length-1,count:E.length},S={...B,loop:P,$loop:P};if(R.startsWith("[")&&R.endsWith("]")){let g=R.slice(1,-1).split(",").map((p)=>p.trim());if(Array.isArray(k))g.forEach((p,s)=>{if(p)S[p]=k[s]});else S[R]=k}else S[R]=k;if(w)if(!M&&V&&Array.isArray(k)&&k.length===2)S[w]=k[0],S[R]=k[1];else S[w]=D;let b=PU(L,S),y=jY(b);if(y.hasContinue){I+=y.content;continue}let m=qY(b);if(m.hasBreak){I+=m.content;break}if(b=HY(b,S),b=G(b,S),b=d1(b,S,X),b=yU(b),m=qY(b),m.hasBreak){I+=m.content;break}if(y=jY(b),y.hasContinue){I+=y.content;continue}b=i0(b,S,X),b=bU(b,S),b=CU(b,S),I+=b}U=U.substring(0,z)+I+U.substring(j)}catch(F){let O=r("Foreach",`Error in @foreach(${q.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,n.EVALUATION_ERROR);U=U.substring(0,z)+O+U.substring(j)}}return U}Q=G(Q,Z),Q=FY(Q,Z,X,Y);let K=Y?.loops?.maxWhileIterations??kU;return Q=gU(Q,Z,K),Q}function LY($){return u5($)}function FY($,Z,X,Y){let Q=$,J=!0;while(J){J=!1;let G=Q.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,B=b0(Q,"(",")",W);if(B===-1)break;let U=Q.slice(W+1,B),_=B+1,z=e5(Q.slice(K),"for","endfor");if(z.length===0)break;let j=z[0].content,q=K+z[0].end;if(!LY(U)){let H=r("For",`Unsafe expression in @for: ${U}`,n.UNSAFE_EXPRESSION);Q=Q.substring(0,K)+H+Q.substring(q),J=!0;continue}try{let H=vU(U),L=/@(?:for|foreach|if|unless)\s*\(/.test(j);if(H.length>0&&L){let w=fU({forExpr:U,content:j,iterVarNames:H,context:Z,filePath:X,options:Y});Q=Q.substring(0,K)+w+Q.substring(q),J=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=j.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,R)=>{return`\${${R}}`});V=OY(V);let N=Function(...F,`
1908
1908
  let result = '';
1909
1909
  for (${U}) {
1910
1910
  result += \`${V}\`;
@@ -1926,7 +1926,7 @@ ${G}`,Q++}return{functionCode:Y,nextIndex:Q}}function GY($,Z){let X=Z0($,Z)??Z0(
1926
1926
  result += '<!-- [While Error [1104]]: Maximum iterations (${X}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
1927
1927
  }
1928
1928
  return result;
1929
- `)(...q);Y=Y.substring(0,G)+F+Y.substring(z),Q=!0}catch(j){let q=r("While",`Error in @while(${B}): ${j instanceof Error?j.message:String(j)}`,n.EVALUATION_ERROR);Y=Y.substring(0,G)+q+Y.substring(z),Q=!0}}return Y}var kU=1000,SU=!1,O7="<!--__STX_BREAK__-->",L7="<!--__STX_CONTINUE__-->";var F7=T(()=>{$7();d0();T0();p$();L0()});import B0 from"path";function h6($,Z){let X=0;for(let Y=Z;Y<$.length;Y++){let Q=$[Y];if(Q==="("||Q==="["||Q==="{")X++;else if(Q===")"||Q==="]"||Q==="}")X--;else if(Q===","&&X===0)return Y}return-1}function hU($,Z,X){let Y=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),J=Q.exec(Y);while(J){let G=J.index,K=G+J[0].length-1,W=1,B=K+1;while(B<Y.length&&W>0){if(Y[B]==="(")W++;else if(Y[B]===")")W--;B++}if(W!==0)break;let U=Y.substring(K+1,B-1),_=`${X}(${U})`;Y=Y.substring(0,G)+_+Y.substring(B),Q.lastIndex=G+_.length,J=Q.exec(Y)}return Y}function dU($){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test($)}function uU($){let Z=$,X=[],Y=new Set,Q=0,J=0,G=Z.length,K=(_)=>{J++;while(J<G){if(Z[J]==="\\"){J+=2;continue}if(Z[J]===_){J++;return}J++}},W=()=>{J++;while(J<G){if(Z[J]==="\\"){J+=2;continue}if(Z[J]==="`"){J++;return}if(Z[J]==="$"&&Z[J+1]==="{"){J+=2;let _=1;while(J<G&&_>0)if(Z[J]==="{")_++,J++;else if(Z[J]==="}")_--,J++;else if(Z[J]==="'"||Z[J]==='"')K(Z[J]);else if(Z[J]==="`")W();else J++;continue}J++}},B=()=>{if(Z[J]==="/"&&Z[J+1]==="/"){while(J<G&&Z[J]!==`
1929
+ `)(...q);Y=Y.substring(0,G)+F+Y.substring(z),Q=!0}catch(j){let q=r("While",`Error in @while(${B}): ${j instanceof Error?j.message:String(j)}`,n.EVALUATION_ERROR);Y=Y.substring(0,G)+q+Y.substring(z),Q=!0}}return Y}var kU=1000,SU=!1,O7="<!--__STX_BREAK__-->",L7="<!--__STX_CONTINUE__-->";var F7=T(()=>{$7();d0();I0();p$();L0()});import B0 from"path";function h6($,Z){let X=0;for(let Y=Z;Y<$.length;Y++){let Q=$[Y];if(Q==="("||Q==="["||Q==="{")X++;else if(Q===")"||Q==="]"||Q==="}")X--;else if(Q===","&&X===0)return Y}return-1}function hU($,Z,X){let Y=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),J=Q.exec(Y);while(J){let G=J.index,K=G+J[0].length-1,W=1,B=K+1;while(B<Y.length&&W>0){if(Y[B]==="(")W++;else if(Y[B]===")")W--;B++}if(W!==0)break;let U=Y.substring(K+1,B-1),_=`${X}(${U})`;Y=Y.substring(0,G)+_+Y.substring(B),Q.lastIndex=G+_.length,J=Q.exec(Y)}return Y}function dU($){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test($)}function uU($){let Z=$,X=[],Y=new Set,Q=0,J=0,G=Z.length,K=(_)=>{J++;while(J<G){if(Z[J]==="\\"){J+=2;continue}if(Z[J]===_){J++;return}J++}},W=()=>{J++;while(J<G){if(Z[J]==="\\"){J+=2;continue}if(Z[J]==="`"){J++;return}if(Z[J]==="$"&&Z[J+1]==="{"){J+=2;let _=1;while(J<G&&_>0)if(Z[J]==="{")_++,J++;else if(Z[J]==="}")_--,J++;else if(Z[J]==="'"||Z[J]==='"')K(Z[J]);else if(Z[J]==="`")W();else J++;continue}J++}},B=()=>{if(Z[J]==="/"&&Z[J+1]==="/"){while(J<G&&Z[J]!==`
1930
1930
  `)J++;return!0}if(Z[J]==="/"&&Z[J+1]==="*"){J+=2;while(J<G-1&&!(Z[J]==="*"&&Z[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(Q!==0)return;let _=Z.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(_){let q=_[2];if(!Y.has(q))X.push(q),Y.add(q);return}let z=Z.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(z){let q=z[1];if(!Y.has(q))X.push(q),Y.add(q);return}let j=Z.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(j){let q=j[1];if(!Y.has(q))X.push(q),Y.add(q)}};while(J<G){if(B())continue;if(Z[J]==="'"||Z[J]==='"'){K(Z[J]);continue}if(Z[J]==="`"){W();continue}if(Z[J]==="{"){Q++,J++;continue}if(Z[J]==="}"){Q--,J++;continue}if(Q===0&&/[a-z]/i.test(Z[J])&&(J===0||/\s|[;{}()]/.test(Z[J-1])))U();J++}return X.join(", ")}function AY($,Z=""){return`
1931
1931
  (function() {
1932
1932
  var { state, derived, effect, batch, onMount, onDestroy, defineStore, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, ref, reactive, computed, watch, watchEffect, defineProps, withDefaults, defineEmits, defineExpose, defineSlots } = window.stx;
@@ -1961,20 +1961,20 @@ ${uU($).split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>` try { __scopeR
1961
1961
  } finally {
1962
1962
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
1963
1963
  }
1964
- })();`}function pU($,Z){let X=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(X){let Q=(X[2]+X[3]).match(/data-stx-scope="([^"]*)"/);if(Q)return{html:$,mergedIntoExisting:Q[1]};let J=X[1],G=X[2],K=X[3];return{html:`${J}${G} data-stx-scope="${Z}"${K}${$.slice(X[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function lU($){if($.__onceStore instanceof Set)return $.__onceStore;return cU}async function d6($,Z,X,Y,Q,J=new Set){let G=Y.partialsDir||B0.join(B0.dirname(X),"partials");if(G&&!B0.isAbsolute(G))G=B0.resolve(process.cwd(),G);let K=hU($,"@partial","@include"),W=lU(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(q,H,L)=>{let F=H.trim(),O=`${X}:${F}`;if(W.has(O))return"";return W.add(O),H});{let q=/@includeIf\s*\(/g,H;while((H=q.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let A=K.substring(F+1,V-1),N=A.match(/^\s*['"]([^'"]+)['"]/);if(!N){q.lastIndex=V;continue}let w=N[1],R=B(w,G,X),M="";if(R&&await Bun.file(R).exists())Q.add(R),M=`@include(${A})`;K=K.substring(0,L)+M+K.substring(V),q.lastIndex=0}}for(let[q,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,A=1,N=V+1;while(N<K.length&&A>0){if(K[N]==="(")A++;else if(K[N]===")")A--;N++}if(A!==0)break;let w=K.substring(V+1,N-1),R=h6(w,0);if(R===-1){L.lastIndex=N;continue}let M=w.substring(0,R).trim(),I=w.substring(R+1).trim(),E=I.match(/^\s*['"]([^'"]+)['"]/);if(!E){L.lastIndex=N;continue}let D=E[1],k=I.substring(E[0].length),P,S=h6(k,0);if(S!==-1)P=k.substring(S+1).trim();try{let C=`Boolean(${M})`,y;if(X0(C)){let p=Y0(C,Object.keys(Z));y=Boolean(p(...Object.values(Z)))}else y=Boolean(Z0(C,Z));let m=H?!y:y,g="";if(m){let p=B(D,G,X);if(p&&await Bun.file(p).exists())Q.add(p);g=`@include('${D}'${P?`, ${P}`:""})`}K=K.substring(0,O)+g+K.substring(N),L.lastIndex=0}catch(C){let y=C instanceof Error?C.message:String(C),m=G0("Include",`Error evaluating ${q} condition: ${y}`,X,$,O);K=K.substring(0,O)+m+K.substring(N),L.lastIndex=0}}}{let q=/@each\s*\(/g,H;while((H=q.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let A=K.substring(F+1,V),N=K.substring(L,V+1),w=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){q.lastIndex=0,K=K.replace(N,"");continue}let[,R,M,I,E]=w;try{let D,k=M.trim();if(X0(k))D=Y0(k,Object.keys(Z))(...Object.values(Z));else D=Z0(k,Z);let P="";if(Array.isArray(D)&&D.length>0)for(let S of D){let C={...Z,[I]:S},y=await _(R,C,$,L);P+=y}else if(E)P=await _(E,{},$,L);K=K.substring(0,L)+P+K.substring(V+1),q.lastIndex=0}catch(D){let k=D instanceof Error?D.message:String(D);K=K.substring(0,L)+G0("Each",`Error in @each: ${k}`,X,$,L)+K.substring(V+1),q.lastIndex=0}}}{let q=/@includeFirst\s*\(/g,H;while((H=q.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let A=K.substring(F+1,V),N=K.substring(L,V+1),w=A.match(/^\s*(\[[^\]]+\])/);if(!w){q.lastIndex=0,K=K.replace(N,"");continue}let R=w[1],M=A.slice(w[0].length),I,E=M.match(/^\s*,\s*\{/);if(E){M=M.slice(E[0].length-1);let P=1,S=1;while(S<M.length&&P>0){if(M[S]==="{")P++;else if(M[S]==="}"){if(P--,P===0)break}S++}I=M.substring(0,S+1),M=M.slice(S+1)}let D,k=M.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)D=k[1];try{let P=JSON.parse(R.replace(/'/g,'"')),S={};if(I)try{S=O0(I,Z)}catch(y){let m=y instanceof Error?y.message:String(y);if(Y.debug){let g=G0("Include",`Error parsing includeFirst variables: ${m}`,X,$,L,N);K=K.replace(N,()=>g)}else K=K.replace(N,()=>D||"");continue}let C=!1;for(let y of P){let m=B(y,G,X);if(!m)continue;if(await l(m)){let g=await _(y,S,$,L);K=K.replace(N,()=>g),C=!0;break}}if(!C)if(D!==void 0)K=K.replace(N,()=>D);else if(Y.debug){let y=G0("Include",`None of the includeFirst paths exist: ${R}`,X,$,L,N);K=K.replace(N,()=>y)}else K=K.replace(N,"")}catch(P){let S=P instanceof Error?P.message:String(P),C=G0("Include",`Error processing @includeFirst: ${S}`,X,$,L,N);K=K.replace(N,()=>C)}q.lastIndex=0}}function B(q,H,L){try{let F=q;if(!q.endsWith(".stx"))F=`${q}.stx`;let O=B0.resolve(H),V=B0.resolve(B0.dirname(L)),A;if(!F.startsWith("./")&&!F.startsWith("../"))A=B0.resolve(H,F);else A=B0.resolve(V,F);let N=B0.normalize(A),w=N.startsWith(O+B0.sep)||N===O,R=N.startsWith(V+B0.sep)||N===V,M=!1,I=B0.dirname(V);if(N.startsWith(I+B0.sep)){if(!B0.relative(I,N).split(B0.sep).some((P)=>P.startsWith(".")&&P!=="."&&P!==".."))M=!0}if(!w&&!R&&!M)return console.error(`Security: Path traversal attempt blocked for include path: ${q}`),console.error(` Resolved to: ${N}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return N}catch(F){return console.error(`Error resolving path ${q}: ${F}`),null}}let U=B0.resolve(X);J.add(U);async function _(q,H={},L,F){let O=B(q,G,X);if(!O)return G0("Include",`Could not resolve path for include: ${q}`,X,L,F);let V=B0.resolve(O);if(J.has(V)){let A=[...J,V].map((N)=>B0.basename(N)).join(" -> ");return G0("Include",`Circular include detected: ${A}`,X,L,F)}try{Q.add(O);let A;if(!A)try{A=await Bun.file(O).text()}catch(g){let p=g instanceof Error?g.message:String(g);return G0("Include",`Error loading include file ${q}: ${p}`,X,L,F)}if(A&&A.includes("@stream")){let{processStreamDirectives:g}=await Promise.resolve().then(() => (K7(),Q6));A=g(A,Z)}if(A&&(Y.debug||!g$()&&!r5()))try{let{warnUnbalancedTags:g}=await Promise.resolve().then(() => (K6(),yX));g(A,O)}catch{}let N=A;try{let{processESImports:g}=await Promise.resolve().then(() => (x6(),ZY));await g(A,Z,O,Y,Q)}catch(g){if(Y.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,g instanceof Error?g.message:g)}let w=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(w)N=w[1].trim();let M=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),I="";if(M)I=`<style${M[1]}>${M[2]}</style>`;N=N.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),N=N.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let E={...Z};for(let[g,p]of Object.entries(H))E[g]=p;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k=[...A.matchAll(D)],P="",S=null;for(let g of k){let p=g[1]||"",s=g[2]||"",M0=p.includes("server"),Y1=y1(p),v0="";try{let{extractAndStripCssImports:$0,renderVendorStyleTags:V0}=await Promise.resolve().then(() => (P1(),qZ)),z0=$0(s,{filePath:O,projectRoot:process.cwd()});s=z0.code,v0=V0(z0.styles)}catch($0){if(Y.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,$0 instanceof Error?$0.message:$0)}if(Y1&&s.trim())s=x1(s);if(!M0)try{let{hasUserImports:$0,bundleClientScript:V0}=await Promise.resolve().then(() => (g5(),f5));if($0(s))s=await V0(s,O,{projectRoot:process.cwd()})}catch($0){if(Y.debug)console.warn(`[stx] bundler skipped for ${O}:`,$0 instanceof Error?$0.message:$0)}let S0=dU(s);if(S0&&!M0){S=`stx_scope_${B0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++NY}`;let $0=Q1(s),V0=mU($0,S);P+=`${v0}<script data-stx-scoped>${V0}</script>
1965
- `;continue}if(M0)try{let{extractVariables:$0}=await Promise.resolve().then(() => (V1(),j7));await $0(s,E,O)}catch($0){if(Y.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,$0)}if(!M0&&!S0){let $0=p.replace(/\bclient\b/i,"").trim();S=`stx_scope_${B0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++NY}`;let V0=Q1(s),z0=`
1964
+ })();`}function pU($,Z){let X=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(X){let Q=(X[2]+X[3]).match(/data-stx-scope="([^"]*)"/);if(Q)return{html:$,mergedIntoExisting:Q[1]};let J=X[1],G=X[2],K=X[3];return{html:`${J}${G} data-stx-scope="${Z}"${K}${$.slice(X[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function lU($){if($.__onceStore instanceof Set)return $.__onceStore;return cU}async function d6($,Z,X,Y,Q,J=new Set){let G=Y.partialsDir||B0.join(B0.dirname(X),"partials");if(G&&!B0.isAbsolute(G))G=B0.resolve(process.cwd(),G);let K=hU($,"@partial","@include"),W=lU(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(q,H,L)=>{let F=H.trim(),O=`${X}:${F}`;if(W.has(O))return"";return W.add(O),H});{let q=/@includeIf\s*\(/g,H;while((H=q.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let A=K.substring(F+1,V-1),N=A.match(/^\s*['"]([^'"]+)['"]/);if(!N){q.lastIndex=V;continue}let w=N[1],R=B(w,G,X),M="";if(R&&await Bun.file(R).exists())Q.add(R),M=`@include(${A})`;K=K.substring(0,L)+M+K.substring(V),q.lastIndex=0}}for(let[q,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,A=1,N=V+1;while(N<K.length&&A>0){if(K[N]==="(")A++;else if(K[N]===")")A--;N++}if(A!==0)break;let w=K.substring(V+1,N-1),R=h6(w,0);if(R===-1){L.lastIndex=N;continue}let M=w.substring(0,R).trim(),I=w.substring(R+1).trim(),E=I.match(/^\s*['"]([^'"]+)['"]/);if(!E){L.lastIndex=N;continue}let D=E[1],k=I.substring(E[0].length),P,S=h6(k,0);if(S!==-1)P=k.substring(S+1).trim();try{let b=`Boolean(${M})`,y;if(X0(b)){let p=Y0(b,Object.keys(Z));y=Boolean(p(...Object.values(Z)))}else y=Boolean(Z0(b,Z));let m=H?!y:y,g="";if(m){let p=B(D,G,X);if(p&&await Bun.file(p).exists())Q.add(p);g=`@include('${D}'${P?`, ${P}`:""})`}K=K.substring(0,O)+g+K.substring(N),L.lastIndex=0}catch(b){let y=b instanceof Error?b.message:String(b),m=G0("Include",`Error evaluating ${q} condition: ${y}`,X,$,O);K=K.substring(0,O)+m+K.substring(N),L.lastIndex=0}}}{let q=/@each\s*\(/g,H;while((H=q.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let A=K.substring(F+1,V),N=K.substring(L,V+1),w=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){q.lastIndex=0,K=K.replace(N,"");continue}let[,R,M,I,E]=w;try{let D,k=M.trim();if(X0(k))D=Y0(k,Object.keys(Z))(...Object.values(Z));else D=Z0(k,Z);let P="";if(Array.isArray(D)&&D.length>0)for(let S of D){let b={...Z,[I]:S},y=await _(R,b,$,L);P+=y}else if(E)P=await _(E,{},$,L);K=K.substring(0,L)+P+K.substring(V+1),q.lastIndex=0}catch(D){let k=D instanceof Error?D.message:String(D);K=K.substring(0,L)+G0("Each",`Error in @each: ${k}`,X,$,L)+K.substring(V+1),q.lastIndex=0}}}{let q=/@includeFirst\s*\(/g,H;while((H=q.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let A=K.substring(F+1,V),N=K.substring(L,V+1),w=A.match(/^\s*(\[[^\]]+\])/);if(!w){q.lastIndex=0,K=K.replace(N,"");continue}let R=w[1],M=A.slice(w[0].length),I,E=M.match(/^\s*,\s*\{/);if(E){M=M.slice(E[0].length-1);let P=1,S=1;while(S<M.length&&P>0){if(M[S]==="{")P++;else if(M[S]==="}"){if(P--,P===0)break}S++}I=M.substring(0,S+1),M=M.slice(S+1)}let D,k=M.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)D=k[1];try{let P=JSON.parse(R.replace(/'/g,'"')),S={};if(I)try{S=O0(I,Z)}catch(y){let m=y instanceof Error?y.message:String(y);if(Y.debug){let g=G0("Include",`Error parsing includeFirst variables: ${m}`,X,$,L,N);K=K.replace(N,()=>g)}else K=K.replace(N,()=>D||"");continue}let b=!1;for(let y of P){let m=B(y,G,X);if(!m)continue;if(await l(m)){let g=await _(y,S,$,L);K=K.replace(N,()=>g),b=!0;break}}if(!b)if(D!==void 0)K=K.replace(N,()=>D);else if(Y.debug){let y=G0("Include",`None of the includeFirst paths exist: ${R}`,X,$,L,N);K=K.replace(N,()=>y)}else K=K.replace(N,"")}catch(P){let S=P instanceof Error?P.message:String(P),b=G0("Include",`Error processing @includeFirst: ${S}`,X,$,L,N);K=K.replace(N,()=>b)}q.lastIndex=0}}function B(q,H,L){try{let F=q;if(!q.endsWith(".stx"))F=`${q}.stx`;let O=B0.resolve(H),V=B0.resolve(B0.dirname(L)),A;if(!F.startsWith("./")&&!F.startsWith("../"))A=B0.resolve(H,F);else A=B0.resolve(V,F);let N=B0.normalize(A),w=N.startsWith(O+B0.sep)||N===O,R=N.startsWith(V+B0.sep)||N===V,M=!1,I=B0.dirname(V);if(N.startsWith(I+B0.sep)){if(!B0.relative(I,N).split(B0.sep).some((P)=>P.startsWith(".")&&P!=="."&&P!==".."))M=!0}if(!w&&!R&&!M)return console.error(`Security: Path traversal attempt blocked for include path: ${q}`),console.error(` Resolved to: ${N}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return N}catch(F){return console.error(`Error resolving path ${q}: ${F}`),null}}let U=B0.resolve(X);J.add(U);async function _(q,H={},L,F){let O=B(q,G,X);if(!O)return G0("Include",`Could not resolve path for include: ${q}`,X,L,F);let V=B0.resolve(O);if(J.has(V)){let A=[...J,V].map((N)=>B0.basename(N)).join(" -> ");return G0("Include",`Circular include detected: ${A}`,X,L,F)}try{Q.add(O);let A;if(!A)try{A=await Bun.file(O).text()}catch(g){let p=g instanceof Error?g.message:String(g);return G0("Include",`Error loading include file ${q}: ${p}`,X,L,F)}if(A&&A.includes("@stream")){let{processStreamDirectives:g}=await Promise.resolve().then(() => (K7(),Q6));A=g(A,Z)}if(A&&(Y.debug||!g$()&&!r5()))try{let{warnUnbalancedTags:g}=await Promise.resolve().then(() => (K6(),yX));g(A,O)}catch{}let N=A;try{let{processESImports:g}=await Promise.resolve().then(() => (x6(),ZY));await g(A,Z,O,Y,Q)}catch(g){if(Y.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,g instanceof Error?g.message:g)}let w=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(w)N=w[1].trim();let M=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),I="";if(M)I=`<style${M[1]}>${M[2]}</style>`;N=N.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),N=N.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let E={...Z};for(let[g,p]of Object.entries(H))E[g]=p;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k=[...A.matchAll(D)],P="",S=null;for(let g of k){let p=g[1]||"",s=g[2]||"",M0=p.includes("server"),Y1=y1(p),v0="";try{let{extractAndStripCssImports:$0,renderVendorStyleTags:V0}=await Promise.resolve().then(() => (P1(),qZ)),z0=$0(s,{filePath:O,projectRoot:process.cwd()});s=z0.code,v0=V0(z0.styles)}catch($0){if(Y.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,$0 instanceof Error?$0.message:$0)}if(Y1&&s.trim())s=x1(s);if(!M0)try{let{hasUserImports:$0,bundleClientScript:V0}=await Promise.resolve().then(() => (g5(),f5));if($0(s))s=await V0(s,O,{projectRoot:process.cwd()})}catch($0){if(Y.debug)console.warn(`[stx] bundler skipped for ${O}:`,$0 instanceof Error?$0.message:$0)}let C0=dU(s);if(C0&&!M0){S=`stx_scope_${B0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++NY}`;let $0=Q1(s),V0=mU($0,S);P+=`${v0}<script data-stx-scoped>${V0}</script>
1965
+ `;continue}if(M0)try{let{extractVariables:$0}=await Promise.resolve().then(() => (V1(),j7));await $0(s,E,O)}catch($0){if(Y.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,$0)}if(!M0&&!C0){let $0=p.replace(/\bclient\b/i,"").trim();S=`stx_scope_${B0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++NY}`;let V0=Q1(s),z0=`
1966
1966
  if (!window.stx._scopes) window.stx._scopes = {};
1967
1967
  window.stx._scopes['${S}'] = { __destroyCallbacks: __destroyHooks };
1968
- `,b=AY(V0,z0);P+=`${v0}<script data-stx-scoped${$0?` ${$0}`:""}>${b}</script>
1969
- `}}if(S){let g=pU(N,S);if(N=g.html,g.mergedIntoExisting)P=P.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${g.mergedIntoExisting}']`),S=g.mergedIntoExisting}if(N.includes("@include")||N.includes("@partial"))N=await d6(N,E,O,Y,Q,J);let{processLoops:C}=await Promise.resolve().then(() => (F7(),VY)),y=C(N,E,O);y=d1(y,E,O);let m=Z$(A);if(y=i0(y,E,O,{forceSignals:m}),I)y+=`
1968
+ `,C=AY(V0,z0);P+=`${v0}<script data-stx-scoped${$0?` ${$0}`:""}>${C}</script>
1969
+ `}}if(S){let g=pU(N,S);if(N=g.html,g.mergedIntoExisting)P=P.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${g.mergedIntoExisting}']`),S=g.mergedIntoExisting}if(N.includes("@include")||N.includes("@partial"))N=await d6(N,E,O,Y,Q,J);let{processLoops:b}=await Promise.resolve().then(() => (F7(),VY)),y=b(N,E,O);y=d1(y,E,O);let m=Z$(A);if(y=i0(y,E,O,{forceSignals:m}),I)y+=`
1970
1970
  `+I;if(P)y+=`
1971
1971
  `+P;return y}catch(A){let N=A instanceof Error?A.message:String(A);return G0("Include",`Error processing include ${q}: ${N}`,X,L,F)}}let z=/@include\s*\(/g,j;while((j=z.exec(K))!==null){let q=j.index,H=q+j[0].length-1,L=1,F=H+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let O=K.substring(q,F),V=K.substring(H+1,F-1),A=V.match(/^\s*['"]([^'"]+)['"]/);if(!A){z.lastIndex=F;continue}let N=A[1],w,R=V.substring(A[0].length),M=h6(R,0);if(M!==-1)w=R.substring(M+1).trim();let I={};if(w)try{I=O0(w,Z)}catch(D){let k=D instanceof Error?D.message:String(D);K=K.replace(O,G0("Include",`Error parsing include variables for ${N}: ${k}`,X,$,q)),z.lastIndex=0;continue}let E=await _(N,I,$,q);K=K.substring(0,q)+E+K.substring(F),z.lastIndex=0}return K}function u6($,Z){let X=$;function Y(Q,J,G,K){let W=Q,B=!0;while(B){B=!1;let U=new RegExp(`@${J}\\(['"]([^'"]+)['"]\\)`),_=W.match(U);if(!_||_.index===void 0)break;let z=_.index,j=_[1],q=z+_[0].length,H=new RegExp(`@${J}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=q,V=-1;while(F>0&&O<W.length){let N=W.slice(O),w=N.match(H),R=N.match(L),M=w?O+w.index:1/0,I=R?O+R.index:1/0;if(M<I)F++,O=M+(w[0].length||1);else if(I<1/0){if(F--,F===0){V=I;break}O=I+G.length+1}else break}if(V===-1)break;let A=W.slice(q,V);if(!Z[j])Z[j]=[];if(K)Z[j].unshift(A);else Z[j].push(A);W=W.substring(0,z)+W.substring(V+`@${G}`.length),B=!0}return W}return X=Y(X,"push","endpush",!1),X=Y(X,"prepend","endprepend",!0),X}function m6($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(X,Y)=>{if(!Z[Y]||Z[Y].length===0)return"";return Z[Y].join(`
1972
- `)})}var NY=0,V7,cU;var U$=T(()=>{$7();T0();v1();L0();Q0();V7=new y$(500),cU=new Set});import*as p6 from"path";async function wY($,Z,X=""){if(p6.basename(X)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return MY($,Z,X,"@js","@endjs")}async function RY($,Z,X=""){if(p6.basename(X)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((J)=>({...J,displayName:`User ${J.id}: ${J.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return MY($,Z,X,"@ts","@endts")}async function MY($,Z,X,Y,Q){let J=$,G=Y$(`${Y}([\\s\\S]*?)${Q}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:B,content:U,index:_}of K)try{let z=Object.keys(Z),j=Object.values(Z),q=U.trim();if(Y==="@ts")q=q.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let L=(q.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((N)=>N.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=L.length>0?`return { ${L.join(", ")} };`:"return {};",O=`
1972
+ `)})}var NY=0,V7,cU;var U$=T(()=>{$7();I0();v1();L0();Q0();V7=new y$(500),cU=new Set});import*as p6 from"path";async function wY($,Z,X=""){if(p6.basename(X)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return MY($,Z,X,"@js","@endjs")}async function RY($,Z,X=""){if(p6.basename(X)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((J)=>({...J,displayName:`User ${J.id}: ${J.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return MY($,Z,X,"@ts","@endts")}async function MY($,Z,X,Y,Q){let J=$,G=Y$(`${Y}([\\s\\S]*?)${Q}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:B,content:U,index:_}of K)try{let z=Object.keys(Z),j=Object.values(Z),q=U.trim();if(Y==="@ts")q=q.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let L=(q.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((N)=>N.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=L.length>0?`return { ${L.join(", ")} };`:"return {};",O=`
1973
1973
  ${q}
1974
1974
  ${F}
1975
1975
  `,A=Function(...z,O)(...j);if(A&&typeof A==="object")Object.assign(Z,A);J=J.replace(B,"")}catch(z){console.error(`Error executing ${Y} code block in ${X}:`,z);let j=z instanceof Error?z.message:String(z),q=G0(`${Y} Directive`,`Error executing code: ${j}`,X,$,_,B);console.error(q),J=J.replace(B,"")}return J}var TY=T(()=>{v1();Q0()});function iU($,Z="_method"){let X=$.toUpperCase();if(X==="GET"||X==="POST")return"";return`<input type="hidden" name="${Z}" value="${X}">`}function IY($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,X,Y,Q,J)=>{return iU(Y,J||"_method")})}async function EY($,Z,X,Y,Q){if(!Y.middleware||Y.middleware.length===0)return $;let J=$,G=Y.middleware.filter((K)=>K.timing===Q);if(G.length===0)return J;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(Y.debug)console.warn("Invalid middleware:",K);continue}try{let W=await K.handler(J,Z,X,Y);if(typeof W==="string")J=W;else if(Y.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(W){if(Y.debug)console.error(`Error in middleware ${K.name}:`,W);if(Y.debug){let B=G0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,X,$);J=J.replace(/<body[^>]*>/,`$&
1976
1976
  <div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${j0(B)}</div>
1977
- `)}}}return J}async function DY($,Z,X,Y){return EY($,Z,X,Y,"before")}async function kY($,Z,X,Y){return EY($,Z,X,Y,"after")}var c6=T(()=>{T0();Q0()});import{defineRoute as rN,defineRoutes as sN,resetRoutes as oN,route as aN,setAppUrl as tN}from"stx-router";import{route as nU}from"stx-router";function SY($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,X,Y,Q,J)=>{try{let G=Q?O0(Q,{}):{};return nU(Y,G,J==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var CY=T(()=>{L0()});function bY($,Z,X,Y){let Q=$;Q=Q.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,W,B)=>{if(!B&&W.includes(":")){let U=W.split(":"),_=W,z=U.length>1?U[1]:"";if(z&&Z[z])B=Z[z];else if(_.startsWith("og:")&&Z.openGraph&&Z.openGraph[U[1]])B=Z.openGraph[U[1]];else B="";return B?`<meta property="${i(_)}" content="${i(B)}">`:""}return B?`<meta name="${i(W)}" content="${i(B)}">`:""});let J=/@metaTag\s*\(/g,G;while((G=J.exec(Q))!==null){let K=G.index,W=K+G[0].length-1,B=1,U=W+1;while(U<Q.length&&B>0){if(Q[U]==="(")B++;else if(Q[U]===")"){if(B--,B===0)break}U++}if(B!==0)break;let _=Q.substring(W+1,U).trim(),z=U+1,j=(()=>{try{let q=O0(_,Z);if(!q)return"";let H="<meta";if(q.name)H+=` name="${i(String(q.name))}"`;if(q.property)H+=` property="${i(String(q.property))}"`;if(q.httpEquiv)H+=` http-equiv="${i(String(q.httpEquiv))}"`;if(q.content)H+=` content="${i(String(q.content))}"`;return H+=">",H}catch(q){let H=q instanceof Error?q.message:String(q);return r("MetaTag",H,n.EVALUATION_ERROR)}})();Q=Q.substring(0,K)+j+Q.substring(z),J.lastIndex=0}return Q}function PY($,Z,X){let Y=$,Q=/@structuredData\s*\(/g,J;while((J=Q.exec(Y))!==null){let G=J.index,K=G+J[0].length-1,W=1,B=K+1;while(B<Y.length&&W>0){if(Y[B]==="(")W++;else if(Y[B]===")"){if(W--,W===0)break}B++}if(W!==0)break;let U=Y.substring(K+1,B).trim(),_=B+1,z=(()=>{try{let j=O0(U,Z);if(!j)return"";if(!j["@context"])j["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(j).replace(/<\//g,"<\\/")}</script>`}catch(j){let q=j instanceof Error?j.message:String(j);return r("StructuredData",q,n.EVALUATION_ERROR)}})();Y=Y.substring(0,G)+z+Y.substring(_),Q.lastIndex=0}return Y}function yY($,Z,X,Y){let Q=$,J=/@seo\s*\(\s*\{/g,G;while((G=J.exec(Q))!==null){let K=Q.indexOf("{",G.index+4),W=1,B=K+1,U=null,_=!1;while(B<Q.length&&W>0){let F=Q[B];if(_){_=!1,B++;continue}if(F==="\\"&&U){_=!0,B++;continue}if(U){if(F===U)U=null;B++;continue}if(F==='"'||F==="'"||F==="`"){U=F,B++;continue}if(F==="{")W++;else if(F==="}")W--;B++}if(W!==0)break;let z=Q.substring(B).match(/^\s*\)/);if(!z)break;let j=B+z[0].length,q=Q.substring(K,B),H=Q.substring(G.index,j),L=((F)=>{try{let O=O0(F,Z);if(!O)return"";let V="";if(O.title)V+=`<title>${i(O.title)}</title>
1977
+ `)}}}return J}async function DY($,Z,X,Y){return EY($,Z,X,Y,"before")}async function kY($,Z,X,Y){return EY($,Z,X,Y,"after")}var c6=T(()=>{I0();Q0()});import{defineRoute as rN,defineRoutes as sN,resetRoutes as oN,route as aN,setAppUrl as tN}from"stx-router";import{route as nU}from"stx-router";function SY($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,X,Y,Q,J)=>{try{let G=Q?O0(Q,{}):{};return nU(Y,G,J==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var CY=T(()=>{L0()});function bY($,Z,X,Y){let Q=$;Q=Q.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,W,B)=>{if(!B&&W.includes(":")){let U=W.split(":"),_=W,z=U.length>1?U[1]:"";if(z&&Z[z])B=Z[z];else if(_.startsWith("og:")&&Z.openGraph&&Z.openGraph[U[1]])B=Z.openGraph[U[1]];else B="";return B?`<meta property="${i(_)}" content="${i(B)}">`:""}return B?`<meta name="${i(W)}" content="${i(B)}">`:""});let J=/@metaTag\s*\(/g,G;while((G=J.exec(Q))!==null){let K=G.index,W=K+G[0].length-1,B=1,U=W+1;while(U<Q.length&&B>0){if(Q[U]==="(")B++;else if(Q[U]===")"){if(B--,B===0)break}U++}if(B!==0)break;let _=Q.substring(W+1,U).trim(),z=U+1,j=(()=>{try{let q=O0(_,Z);if(!q)return"";let H="<meta";if(q.name)H+=` name="${i(String(q.name))}"`;if(q.property)H+=` property="${i(String(q.property))}"`;if(q.httpEquiv)H+=` http-equiv="${i(String(q.httpEquiv))}"`;if(q.content)H+=` content="${i(String(q.content))}"`;return H+=">",H}catch(q){let H=q instanceof Error?q.message:String(q);return r("MetaTag",H,n.EVALUATION_ERROR)}})();Q=Q.substring(0,K)+j+Q.substring(z),J.lastIndex=0}return Q}function PY($,Z,X){let Y=$,Q=/@structuredData\s*\(/g,J;while((J=Q.exec(Y))!==null){let G=J.index,K=G+J[0].length-1,W=1,B=K+1;while(B<Y.length&&W>0){if(Y[B]==="(")W++;else if(Y[B]===")"){if(W--,W===0)break}B++}if(W!==0)break;let U=Y.substring(K+1,B).trim(),_=B+1,z=(()=>{try{let j=O0(U,Z);if(!j)return"";if(!j["@context"])j["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(j).replace(/<\//g,"<\\/")}</script>`}catch(j){let q=j instanceof Error?j.message:String(j);return r("StructuredData",q,n.EVALUATION_ERROR)}})();Y=Y.substring(0,G)+z+Y.substring(_),Q.lastIndex=0}return Y}function yY($,Z,X,Y){let Q=$,J=/@seo\s*\(\s*\{/g,G;while((G=J.exec(Q))!==null){let K=Q.indexOf("{",G.index+4),W=1,B=K+1,U=null,_=!1;while(B<Q.length&&W>0){let F=Q[B];if(_){_=!1,B++;continue}if(F==="\\"&&U){_=!0,B++;continue}if(U){if(F===U)U=null;B++;continue}if(F==='"'||F==="'"||F==="`"){U=F,B++;continue}if(F==="{")W++;else if(F==="}")W--;B++}if(W!==0)break;let z=Q.substring(B).match(/^\s*\)/);if(!z)break;let j=B+z[0].length,q=Q.substring(K,B),H=Q.substring(G.index,j),L=((F)=>{try{let O=O0(F,Z);if(!O)return"";let V="";if(O.title)V+=`<title>${i(O.title)}</title>
1978
1978
  `,V+=`<meta name="title" content="${i(O.title)}">
1979
1979
  `;if(O.description)V+=`<meta name="description" content="${i(O.description)}">
1980
1980
  `;if(O.keywords){let A=Array.isArray(O.keywords)?O.keywords.join(", "):O.keywords;V+=`<meta name="keywords" content="${i(A)}">
@@ -7306,7 +7306,7 @@ ${q}
7306
7306
  </script>`;Y=Y.replace(B,H),J.lastIndex=0}catch(q){}}let K=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,W;while((W=K.exec(Y))!==null){let[B,U,_,z]=W,j=U+z;if(BJ(_))continue;if(/rel=["']stylesheet["']/.test(j)||_.endsWith(".css")){let H=await _J(_,Q,Z);if(H)try{let L=await Bun.file(H).text();X.add(H);let F=`<style>
7307
7307
  /* Source: ${_} */
7308
7308
  ${L}
7309
- </style>`;Y=Y.replace(B,F),K.lastIndex=0}catch(L){}}}return Y}var qJ=T(()=>{C1()});function q3($,Z){let X=$,Y=/@json\s*\(/g,Q;while((Q=Y.exec(X))!==null){let J=Q.index,G=J+Q[0].length-1,K=1,W=G+1,B=null,U=!1;while(W<X.length&&K>0){let V=X[W];if(U){U=!1,W++;continue}if(V==="\\"&&B){U=!0,W++;continue}if(B){if(V===B)B=null;W++;continue}if(V==='"'||V==="'"||V==="`"){B=V,W++;continue}if(V==="(")K++;else if(V===")"){if(K--,K===0)break}W++}if(K!==0)break;let _=X.substring(G+1,W).trim(),z=X.substring(J,W+1),j=-1,q=0,H=null,L=!1;for(let V=0;V<_.length;V++){let A=_[V];if(L){L=!1;continue}if(A==="\\"&&H){L=!0;continue}if(H){if(A===H)H=null;continue}if(A==='"'||A==="'"||A==="`"){H=A;continue}if(A==="("||A==="["||A==="{")q++;else if(A===")"||A==="]"||A==="}")q--;if(A===","&&q===0){j=V;break}}let F=j>=0?_.substring(0,j).trim():_,O=j>=0?_.substring(j+1).trim():void 0;try{let V=F.trim(),A;if(X0(V))A=Y0(V,Object.keys(Z))(...Object.values(Z));else A=void 0;let N;if(O==="true")N=JSON.stringify(A,null,2);else N=JSON.stringify(A);let w=N.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");X=X.substring(0,J)+w+X.substring(W+1),Y.lastIndex=J+w.length}catch(V){E0.log(V instanceof Error?V:Error(String(V)),{directive:"@json"},"error"),Y.lastIndex=J+z.length}}return X}function j3($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function jJ($){let Z=$,X=/@memo\s*\(/g,Y,Q=[];while((Y=X.exec(Z))!==null){let J=Y.index,G=J+Y[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let B=Z.slice(G,W-1).trim(),U=W,_=Z.slice(U),z=_.indexOf("@endmemo");if(z===-1)continue;let j=_.slice(0,z),q=U+z+8,H=j.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),L=H?H[0].length:0,F=j.slice(L),O=j.match(/(\s*)$/),V=O?O[0].length:0,A=F.slice(0,F.length-V),N=A.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),w;if(N){let[R,M,I="",E]=N,D=`<${M}${I} data-stx-memo="${B}"${E}>`;w=j.slice(0,L)+D+A.slice(R.length)+j.slice(L+A.length)}else w=`${j.slice(0,L)}<div data-stx-memo="${B}">${A}</div>${j.slice(L+A.length)}`;Q.push({start:J,end:q,replacement:w}),X.lastIndex=q}for(let J=Q.length-1;J>=0;J--){let G=Q[J];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function H3($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function HJ($){let X=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),Y="",Q=0,J;while((J=X.exec($))!==null){let G=J.index,K=G+J[0].length,W=!1,B=!1,U=-1;while(K<$.length){let H=$[K];if(W){if(H==="'")W=!1}else if(B){if(H==='"')B=!1}else if(H==="'")W=!0;else if(H==='"')B=!0;else if(H===">"){U=K;break}K++}if(U===-1)continue;if($.slice(G,U+1).includes("x-cloak"))continue;let z=$.slice(U+1),j=z.indexOf("</"),q=j>=0?z.slice(0,j):z.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(q))Y+=$.slice(Q,U)+" x-cloak>",Q=U+1}return Y+=$.slice(Q),Y}function OJ($){let Z=/<[a-z][\w-]*/gi,X="",Y=0,Q;while((Q=Z.exec($))!==null){let J=Q.index,G=Q[0].slice(1).toLowerCase();if(G==="script"||G==="style"){let q=`</${G}>`,H=$.toLowerCase().indexOf(q,J);if(H!==-1)Z.lastIndex=H+q.length;continue}let K=J+Q[0].length,W=!1,B=!1,U=-1;while(K<$.length){let q=$[K];if(W){if(q==="'")W=!1}else if(B){if(q==='"')B=!1}else if(q==="'")W=!0;else if(q==='"')B=!0;else if(q===">"){U=K;break}K++}if(U===-1)continue;let _=$.slice(J+Q[0].length,U);if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(_))continue;if(!dB.test(_))continue;let z=$[U-1]==="/",j=z?U-1:U;X+=`${$.slice(Y,j)} x-cloak${z?" ":""}`,Y=j}return X+=$.slice(Y),X}var dB;var O3=T(()=>{d0();L0();dB=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/});function L3($,Z,X){let Y=typeof X==="boolean"?{enabled:X,failOnViolation:X}:X??{enabled:!1},Q=Y.allowPatterns??[],J=[];for(let{pattern:G,message:K,suggestion:W}of uB){if(Q.some((U)=>K.includes(U)||G.source.includes(U)))continue;G.lastIndex=0;let B=$.match(G);if(B&&B.length>0){let U=$.split(`
7309
+ </style>`;Y=Y.replace(B,F),K.lastIndex=0}catch(L){}}}return Y}var qJ=T(()=>{C1()});function q3($,Z){let X=$,Y=/@json\s*\(/g,Q;while((Q=Y.exec(X))!==null){let J=Q.index,G=J+Q[0].length-1,K=1,W=G+1,B=null,U=!1;while(W<X.length&&K>0){let V=X[W];if(U){U=!1,W++;continue}if(V==="\\"&&B){U=!0,W++;continue}if(B){if(V===B)B=null;W++;continue}if(V==='"'||V==="'"||V==="`"){B=V,W++;continue}if(V==="(")K++;else if(V===")"){if(K--,K===0)break}W++}if(K!==0)break;let _=X.substring(G+1,W).trim(),z=X.substring(J,W+1),j=-1,q=0,H=null,L=!1;for(let V=0;V<_.length;V++){let A=_[V];if(L){L=!1;continue}if(A==="\\"&&H){L=!0;continue}if(H){if(A===H)H=null;continue}if(A==='"'||A==="'"||A==="`"){H=A;continue}if(A==="("||A==="["||A==="{")q++;else if(A===")"||A==="]"||A==="}")q--;if(A===","&&q===0){j=V;break}}let F=j>=0?_.substring(0,j).trim():_,O=j>=0?_.substring(j+1).trim():void 0;try{let V=F.trim(),A;if(X0(V))A=Y0(V,Object.keys(Z))(...Object.values(Z));else A=void 0;let N;if(O==="true")N=JSON.stringify(A,null,2);else N=JSON.stringify(A);let w=N.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");X=X.substring(0,J)+w+X.substring(W+1),Y.lastIndex=J+w.length}catch(V){D0.log(V instanceof Error?V:Error(String(V)),{directive:"@json"},"error"),Y.lastIndex=J+z.length}}return X}function j3($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function jJ($){let Z=$,X=/@memo\s*\(/g,Y,Q=[];while((Y=X.exec(Z))!==null){let J=Y.index,G=J+Y[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let B=Z.slice(G,W-1).trim(),U=W,_=Z.slice(U),z=_.indexOf("@endmemo");if(z===-1)continue;let j=_.slice(0,z),q=U+z+8,H=j.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),L=H?H[0].length:0,F=j.slice(L),O=j.match(/(\s*)$/),V=O?O[0].length:0,A=F.slice(0,F.length-V),N=A.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),w;if(N){let[R,M,I="",E]=N,D=`<${M}${I} data-stx-memo="${B}"${E}>`;w=j.slice(0,L)+D+A.slice(R.length)+j.slice(L+A.length)}else w=`${j.slice(0,L)}<div data-stx-memo="${B}">${A}</div>${j.slice(L+A.length)}`;Q.push({start:J,end:q,replacement:w}),X.lastIndex=q}for(let J=Q.length-1;J>=0;J--){let G=Q[J];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function H3($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function HJ($){let X=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),Y="",Q=0,J;while((J=X.exec($))!==null){let G=J.index,K=G+J[0].length,W=!1,B=!1,U=-1;while(K<$.length){let H=$[K];if(W){if(H==="'")W=!1}else if(B){if(H==='"')B=!1}else if(H==="'")W=!0;else if(H==='"')B=!0;else if(H===">"){U=K;break}K++}if(U===-1)continue;if($.slice(G,U+1).includes("x-cloak"))continue;let z=$.slice(U+1),j=z.indexOf("</"),q=j>=0?z.slice(0,j):z.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(q))Y+=$.slice(Q,U)+" x-cloak>",Q=U+1}return Y+=$.slice(Q),Y}function OJ($){let Z=/<[a-z][\w-]*/gi,X="",Y=0,Q;while((Q=Z.exec($))!==null){let J=Q.index,G=Q[0].slice(1).toLowerCase();if(G==="script"||G==="style"){let q=`</${G}>`,H=$.toLowerCase().indexOf(q,J);if(H!==-1)Z.lastIndex=H+q.length;continue}let K=J+Q[0].length,W=!1,B=!1,U=-1;while(K<$.length){let q=$[K];if(W){if(q==="'")W=!1}else if(B){if(q==='"')B=!1}else if(q==="'")W=!0;else if(q==='"')B=!0;else if(q===">"){U=K;break}K++}if(U===-1)continue;let _=$.slice(J+Q[0].length,U);if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(_))continue;if(!dB.test(_))continue;let z=$[U-1]==="/",j=z?U-1:U;X+=`${$.slice(Y,j)} x-cloak${z?" ":""}`,Y=j}return X+=$.slice(Y),X}var dB;var O3=T(()=>{d0();L0();dB=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/});function L3($,Z,X){let Y=typeof X==="boolean"?{enabled:X,failOnViolation:X}:X??{enabled:!1},Q=Y.allowPatterns??[],J=[];for(let{pattern:G,message:K,suggestion:W}of uB){if(Q.some((U)=>K.includes(U)||G.source.includes(U)))continue;G.lastIndex=0;let B=$.match(G);if(B&&B.length>0){let U=$.split(`
7310
7310
  `),_=[];U.forEach((j,q)=>{if(G.lastIndex=0,G.test(j))_.push(q+1)});let z=_.length>0?` (line${_.length>1?"s":""}: ${_.join(", ")})`:"";J.push(` \u2717 ${K}${z}
7311
7311
  \u2192 ${W}`)}}if(J.length>0&&Y.enabled){let K=`[STX] DOM API violation in ${Z.split("/").pop()||Z}:
7312
7312
  ${J.join(`
@@ -7316,7 +7316,7 @@ ${_.trim()}`)}catch(_){console.warn(`[stx] Failed to load store ${U}:`,_)}if(K.l
7316
7316
  ${K.join(`
7317
7317
 
7318
7318
  `)}
7319
- })();`;return q$.set(Z,B),B}function pB(){q$.clear()}var q$;var FJ=T(()=>{I0();C1();q$=new Map});var NJ={};a(NJ,{processDeferDirectives:()=>rB});function cB(){return`stx-defer-${++VJ}`}function lB($){let Z=$.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(Z)return{trigger:Z[1],value:Z[2]};return{trigger:"immediate"}}function iB($,Z,X){let{trigger:Y,value:Q}=lB(Z),J=X,G,K,W,B=X.match(/@placeholder\s*([\s\S]*?)(?=@loading|@error|$)/);if(B)G=B[1].trim(),J=J.replace(/@placeholder[\s\S]*?(?=@loading|@error|$)/,"");let U=X.match(/@loading\s*([\s\S]*?)(?=@error|$)/);if(U)K=U[1].trim(),J=J.replace(/@loading[\s\S]*?(?=@error|$)/,"");let _=X.match(/@error(?:\s*\(\s*(\w+)\s*\))?\s*([\s\S]*)$/);if(_)W=_[2].trim(),J=J.replace(/@error(?:\s*\(\s*\w+\s*\))?[\s\S]*$/,"");return J=J.trim(),{trigger:Y,triggerValue:Q,content:J,placeholder:G,loading:K,error:W}}function nB($,Z){let{trigger:X,triggerValue:Y}=Z,Q;switch(X){case"visible":Q=`
7319
+ })();`;return q$.set(Z,B),B}function pB(){q$.clear()}var q$;var FJ=T(()=>{E0();C1();q$=new Map});var NJ={};a(NJ,{processDeferDirectives:()=>rB});function cB(){return`stx-defer-${++VJ}`}function lB($){let Z=$.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(Z)return{trigger:Z[1],value:Z[2]};return{trigger:"immediate"}}function iB($,Z,X){let{trigger:Y,value:Q}=lB(Z),J=X,G,K,W,B=X.match(/@placeholder\s*([\s\S]*?)(?=@loading|@error|$)/);if(B)G=B[1].trim(),J=J.replace(/@placeholder[\s\S]*?(?=@loading|@error|$)/,"");let U=X.match(/@loading\s*([\s\S]*?)(?=@error|$)/);if(U)K=U[1].trim(),J=J.replace(/@loading[\s\S]*?(?=@error|$)/,"");let _=X.match(/@error(?:\s*\(\s*(\w+)\s*\))?\s*([\s\S]*)$/);if(_)W=_[2].trim(),J=J.replace(/@error(?:\s*\(\s*\w+\s*\))?[\s\S]*$/,"");return J=J.trim(),{trigger:Y,triggerValue:Q,content:J,placeholder:G,loading:K,error:W}}function nB($,Z){let{trigger:X,triggerValue:Y}=Z,Q;switch(X){case"visible":Q=`
7320
7320
  const observer = new IntersectionObserver((entries) => {
7321
7321
  if (entries[0].isIntersecting) {
7322
7322
  observer.disconnect();
@@ -10019,31 +10019,31 @@ if ('serviceWorker' in navigator) {
10019
10019
  `),...B.htmlAttrs&&{htmlAttrs:{...K.htmlAttrs||{},...B.htmlAttrs}},...B.bodyAttrs&&{bodyAttrs:{...K.bodyAttrs||{},...B.bodyAttrs}}},L=o6(G);if(G=a6(G,H),L)G=rY(G,K);let F=G.match(/<!-- stx-layout: ([^ ]+) -->/);if(F&&G.includes("<head")){let V=F[1],A=zz(V);G=G.replace("<head>",`<head>
10020
10020
  <meta name="stx-layout" content="${E2(V)}">
10021
10021
  <meta name="stx-layout-group" content="${E2(A)}">`)}let O=G.match(/function (__stx_setup_\d+_\d+)\(/);if(O&&G.includes("<body")&&!G.match(/<body[^>]*data-stx=/)){G=G.replace(/<body([^>]*)>/,`<body$1 data-stx="${O[1]}">`);let V=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${O[1]}"`,"i");G=G.replace(V,"$1")}}if(J)G=nY(G);if(J)try{let{getStoreScript:K}=await Promise.resolve().then(() => (FJ(),LJ)),W=Y.storesDir,B=await K(W);if(B){let U=`<script data-stx-stores>${B}</script>`,_=G.indexOf("<script data-stx-scoped>");if(_!==-1){let z=G.indexOf("</script>",_+24);if(z!==-1){let j=z+9;G=G.slice(0,j)+`
10022
- `+U+G.slice(j)}}}}catch{}if(J&&Z.__stx_inject_css!==!1)G=await a0(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof a5)throw G;let K=G instanceof Error?G.message:String(G),W=new t0(`Template processing failed: ${K}`,X,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(E0.log(W,{filePath:X,context:Z}),u$.logDetailedError(W,{filePath:X,template:$.substring(0,500)}),Y.debug)throw W;return g4.createFallbackContent("Template Processing",W)}}async function jz($,Z,X,Y,Q){let J=process.cwd(),G={...Y,partialsDir:Y.partialsDir&&!x0.isAbsolute(Y.partialsDir)?x0.resolve(J,Y.partialsDir):Y.partialsDir,componentsDir:Y.componentsDir&&!x0.isAbsolute(Y.componentsDir)?x0.resolve(J,Y.componentsDir):Y.componentsDir,layoutsDir:Y.layoutsDir&&!x0.isAbsolute(Y.layoutsDir)?x0.resolve(J,Y.layoutsDir):Y.layoutsDir},K=G,W=$;await Lz(X,Z),Oz(Z,K),W=await G1(()=>DY(W,Z,X,K),W,(O)=>{E0.log(O,{filePath:X,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${X}: ${O.message}`)}),W=W.replace(/\{\{--[\s\S]*?--\}\}/g,"");let B=C$(W,AZ,(O,V)=>`\x00STX_HTML_COMMENT_${V}\x00`);W=B.output;let U=B.tokens,_=(O)=>U.length===0?O:O.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(V,A)=>U[Number(A)]??""),z="\x00STX_ESCAPED_AT\x00";W=W.replace(/@@/g,z),W=W.replace(/@\{\{([\s\S]*?)\}\}/g,(O,V)=>{return`{{ ${V} }}`}),W=mY(W),W=await zJ(W,X,Q);let j={};W=u6(W,j);let q={...Z.__sections||{}},H="",L=/@nolayout\b/.test(W);if(L)W=W.replace(/@nolayout\b\s*/g,"");let F=W.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F)H=F[1],W=W.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");if(!H&&!L&&K.defaultLayout){let O=/<!DOCTYPE\s/i.test(W),V=/@section\s*\(/.test(W);if(!O||V){let A="",N=x0.dirname(X),w=K.layoutsDir?x0.dirname(K.layoutsDir):process.cwd();for(let R=0;R<20;R++){let M=x0.join(N,"_layout.stx");if(await l(M)){A=M;break}let I=x0.dirname(N);if(I===N||I.length<w.length)break;N=I}if(A)H=A;else if(K.layoutsDir){let R=x0.isAbsolute(K.layoutsDir)?K.layoutsDir:x0.resolve(process.cwd(),K.layoutsDir),M=x0.join(R,`${K.defaultLayout}.stx`);if(await l(M))H=M}if(H&&!V)W=`@section('content')
10022
+ `+U+G.slice(j)}}}}catch{}if(J&&Z.__stx_inject_css!==!1)G=await a0(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof a5)throw G;let K=G instanceof Error?G.message:String(G),W=new t0(`Template processing failed: ${K}`,X,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(D0.log(W,{filePath:X,context:Z}),u$.logDetailedError(W,{filePath:X,template:$.substring(0,500)}),Y.debug)throw W;return g4.createFallbackContent("Template Processing",W)}}async function jz($,Z,X,Y,Q){let J=process.cwd(),G={...Y,partialsDir:Y.partialsDir&&!x0.isAbsolute(Y.partialsDir)?x0.resolve(J,Y.partialsDir):Y.partialsDir,componentsDir:Y.componentsDir&&!x0.isAbsolute(Y.componentsDir)?x0.resolve(J,Y.componentsDir):Y.componentsDir,layoutsDir:Y.layoutsDir&&!x0.isAbsolute(Y.layoutsDir)?x0.resolve(J,Y.layoutsDir):Y.layoutsDir},K=G,W=$;await Lz(X,Z),Oz(Z,K),W=await G1(()=>DY(W,Z,X,K),W,(O)=>{D0.log(O,{filePath:X,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${X}: ${O.message}`)}),W=W.replace(/\{\{--[\s\S]*?--\}\}/g,"");let B=C$(W,AZ,(O,V)=>`\x00STX_HTML_COMMENT_${V}\x00`);W=B.output;let U=B.tokens,_=(O)=>U.length===0?O:O.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(V,A)=>U[Number(A)]??""),z="\x00STX_ESCAPED_AT\x00";W=W.replace(/@@/g,z),W=W.replace(/@\{\{([\s\S]*?)\}\}/g,(O,V)=>{return`{{ ${V} }}`}),W=mY(W),W=await zJ(W,X,Q);let j={};W=u6(W,j);let q={...Z.__sections||{}},H="",L=/@nolayout\b/.test(W);if(L)W=W.replace(/@nolayout\b\s*/g,"");let F=W.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F)H=F[1],W=W.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");if(!H&&!L&&K.defaultLayout){let O=/<!DOCTYPE\s/i.test(W),V=/@section\s*\(/.test(W);if(!O||V){let A="",N=x0.dirname(X),w=K.layoutsDir?x0.dirname(K.layoutsDir):process.cwd();for(let R=0;R<20;R++){let M=x0.join(N,"_layout.stx");if(await l(M)){A=M;break}let I=x0.dirname(N);if(I===N||I.length<w.length)break;N=I}if(A)H=A;else if(K.layoutsDir){let R=x0.isAbsolute(K.layoutsDir)?K.layoutsDir:x0.resolve(process.cwd(),K.layoutsDir),M=x0.join(R,`${K.defaultLayout}.stx`);if(await l(M))H=M}if(H&&!V)W=`@section('content')
10023
10023
  ${W.trim()}
10024
10024
  @endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(O,V,A)=>{return q[V]=A,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(O,V,A)=>{if(/^(['"]).*\1$/.test(A.trim()))return O;try{let N=Z0(A.trim(),Z);if(N===void 0)return O;return q[V]=String(N??""),""}catch{return O}}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(O,V,A)=>{if(A.includes("@parent"))q[V]=A.replace("@parent",r1);else q[V]=A.trim();return""}),Z.__sections=q,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(O,V,A)=>{return q[V]||A||""}),!("slot"in Z)||Z.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return q.content||""});if(W=m6(W,j),H){let O=[];if(W=W.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi,(V)=>{return O.push(V),""}),O.length>0){let V=O.join(`
10025
10025
  `);q.content=q.content?`${q.content}
10026
- ${V}`:V,Z.__sections=q}}if(H)try{let O;if(x0.isAbsolute(H))O=H,Q.add(H);else O=await G1(()=>p7(H,X,G,Q),null,()=>{throw new t0(`Failed to resolve layout path: ${H}`,X,void 0,void 0,`Layout referenced from ${X}`)});if(!O){let M=`Layout not found: ${H} (referenced from ${X})`;if(E0.log(Error(M),{layoutPath:H,filePath:X},"warning"),G.debug)throw new t0(M,X);return W}let V=await G1(()=>Bun.file(O).text(),"",()=>{throw new t0(`Failed to read layout file: ${O}`,X,void 0,void 0,"Layout content could not be loaded")}),A=V.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(A){if(G.debug)console.log(`Found nested layout: ${A[1]} in ${O}`);let M={},I=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(k,P,S)=>{return M[P]=S.trim(),""});for(let[k,P]of Object.entries(M))if(q[k]&&q[k].includes(r1)){let S=q[k].indexOf(r1);q[k]=q[k].slice(0,S)+P+q[k].slice(S+r1.length)}else if(!q[k])q[k]=P;let E={...Z,__sections:q},D=`@layout('${A[1]}')${I}`;return await U0(D,E,O,G,Q)}let N=V.replace(/\{\{--[\s\S]*?--\}\}/g,""),w=u6(N,j),R={};return w=w.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(M,I,E)=>{return R[I]=E.trim(),`@slot('${I}')`}),w=w.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(M,I,E)=>{if(q[I]){let D=q[I];if(D.includes(r1)){let k=R[I]||"",P=D.indexOf(r1);D=D.slice(0,P)+k+D.slice(P+r1.length)}return D}return E||""}),w=Hz(w,q),w=w.replace(/\{\{\s*slot\s*\}\}/g,()=>{return q.content||""}),w=m6(w,j),Z.__originalFilePath=X,W=await D2(w,Z,O,G,Q),W=`<!-- stx-layout: ${H} -->
10027
- ${W}`,_(W)}catch(O){return E0.log(O instanceof Error?O:Error(String(O)),{layoutPath:H,filePath:X},"error"),`[Error processing layout: ${O instanceof Error?O.message:String(O)}]`}return _(await D2(W,Z,X,G,Q))}function Hz($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(X,Y,Q)=>{let J=Z[Y];if(J!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(J))return J}return Q||""})}function Oz($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let X=Z.envPrefix||"STX_PUBLIC_",Y={};for(let[Q,J]of Object.entries(process.env))if(Q.startsWith(X)&&J!==void 0)Y[Q]=J;$.$env=Y}async function Lz($,Z){await G1(()=>gY($,Z),void 0,(X)=>{E0.log(X,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${X.message}`)})}async function Fz($,Z,X){let Y=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=Y.exec($))!==null){let J=Q[1],G=Q[2];if(!/\bserver\b/.test(J)||!G.trim())continue;try{let{extractVariables:W}=await Promise.resolve().then(() => (V1(),j7));await W(G,Z,X,{preserveExisting:!0})}catch(W){let B=W instanceof Error?W:Error(String(W));E0.log(B,{filePath:X,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${X}: ${B.message}`)}}}async function Vz($,Z,X){try{let{interpolateScriptsInTemplate:Y}=await Promise.resolve().then(() => (T0(),I4));return Y($,Z,{skipServer:!0})}catch(Y){let Q=Y instanceof Error?Y:Error(String(Y));return E0.log(Q,{filePath:X,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${X}: ${Q.message}`),$}}async function D2($,Z,X,Y,Q){let J=$,G=Y;if(await Fz(J,Z,X),J=await Vz(J,Z,X),J=await wY(J,Z,X),J=await RY(J,Z,X),J=await LX(J,Z,X,G),Z$(J))J=W3(J,Z),J=B3(J,Z);J=U3(J);let{processStreamDirectives:K}=await Promise.resolve().then(() => (K7(),Q6));J=K(J,Z),J=g6(J,Z,X,G),J=await q7(J,Z,X,G,Q),J=await pY(J,Z,X,G,Q),J=$Z(J,Z,X,G);let{processDeferDirectives:W}=await Promise.resolve().then(() => NJ);J=W(J,Z,X);let{processTeleportDirectives:B}=await Promise.resolve().then(() => wJ);J=B(J,Z,X);let{processTransitionDirectives:U,processTransitionAttributes:_}=await Promise.resolve().then(() => IJ);J=U(J,Z,X),J=_(J);let{processErrorBoundaryDirectives:z}=await Promise.resolve().then(() => DJ);J=z(J,Z,X);let{processSuspenseDirectives:j}=await Promise.resolve().then(() => kJ);J=j(J,Z,X);let{processAsyncDirectives:q}=await Promise.resolve().then(() => PJ);J=q(J,Z,X);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => xJ);J=H(J,Z,X);let{processVirtualListDirectives:L,processVirtualGridDirectives:F,processInfiniteListDirectives:O}=await Promise.resolve().then(() => (A3(),dJ));J=L(J,Z,X),J=F(J,Z,X),J=O(J,Z,X);let{processPartialHydrationDirectives:V,processStaticDirectives:A}=await Promise.resolve().then(() => (w3(),$2));J=V(J,Z,X),J=A(J);let{processComputedDirectives:N,processWatchDirectives:w}=await Promise.resolve().then(() => (z2(),_2));J=N(J,Z,X),J=w(J,Z,X);let{processFormValidationDirectives:R}=await Promise.resolve().then(() => (L2(),O2));J=R(J,Z,X);let{processHeadDirective:M,processTitleDirective:I,processMetaDirective:E,resetHead:D}=await Promise.resolve().then(() => (p1(),n4));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)D();let k=M(J);if(J=k.content,k.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${k.headContent}
10026
+ ${V}`:V,Z.__sections=q}}if(H)try{let O;if(x0.isAbsolute(H))O=H,Q.add(H);else O=await G1(()=>p7(H,X,G,Q),null,()=>{throw new t0(`Failed to resolve layout path: ${H}`,X,void 0,void 0,`Layout referenced from ${X}`)});if(!O){let M=`Layout not found: ${H} (referenced from ${X})`;if(D0.log(Error(M),{layoutPath:H,filePath:X},"warning"),G.debug)throw new t0(M,X);return W}let V=await G1(()=>Bun.file(O).text(),"",()=>{throw new t0(`Failed to read layout file: ${O}`,X,void 0,void 0,"Layout content could not be loaded")}),A=V.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(A){if(G.debug)console.log(`Found nested layout: ${A[1]} in ${O}`);let M={},I=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(k,P,S)=>{return M[P]=S.trim(),""});for(let[k,P]of Object.entries(M))if(q[k]&&q[k].includes(r1)){let S=q[k].indexOf(r1);q[k]=q[k].slice(0,S)+P+q[k].slice(S+r1.length)}else if(!q[k])q[k]=P;let E={...Z,__sections:q},D=`@layout('${A[1]}')${I}`;return await U0(D,E,O,G,Q)}let N=V.replace(/\{\{--[\s\S]*?--\}\}/g,""),w=u6(N,j),R={};return w=w.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(M,I,E)=>{return R[I]=E.trim(),`@slot('${I}')`}),w=w.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(M,I,E)=>{if(q[I]){let D=q[I];if(D.includes(r1)){let k=R[I]||"",P=D.indexOf(r1);D=D.slice(0,P)+k+D.slice(P+r1.length)}return D}return E||""}),w=Hz(w,q),w=w.replace(/\{\{\s*slot\s*\}\}/g,()=>{return q.content||""}),w=m6(w,j),Z.__originalFilePath=X,W=await D2(w,Z,O,G,Q),W=`<!-- stx-layout: ${H} -->
10027
+ ${W}`,_(W)}catch(O){return D0.log(O instanceof Error?O:Error(String(O)),{layoutPath:H,filePath:X},"error"),`[Error processing layout: ${O instanceof Error?O.message:String(O)}]`}return _(await D2(W,Z,X,G,Q))}function Hz($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(X,Y,Q)=>{let J=Z[Y];if(J!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(J))return J}return Q||""})}function Oz($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let X=Z.envPrefix||"STX_PUBLIC_",Y={};for(let[Q,J]of Object.entries(process.env))if(Q.startsWith(X)&&J!==void 0)Y[Q]=J;$.$env=Y}async function Lz($,Z){await G1(()=>gY($,Z),void 0,(X)=>{D0.log(X,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${X.message}`)})}async function Fz($,Z,X){let Y=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=Y.exec($))!==null){let J=Q[1],G=Q[2];if(!/\bserver\b/.test(J)||!G.trim())continue;try{let{extractVariables:W}=await Promise.resolve().then(() => (V1(),j7));await W(G,Z,X,{preserveExisting:!0})}catch(W){let B=W instanceof Error?W:Error(String(W));D0.log(B,{filePath:X,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${X}: ${B.message}`)}}}async function Vz($,Z,X){try{let{interpolateScriptsInTemplate:Y}=await Promise.resolve().then(() => (I0(),I4));return Y($,Z,{skipServer:!0})}catch(Y){let Q=Y instanceof Error?Y:Error(String(Y));return D0.log(Q,{filePath:X,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${X}: ${Q.message}`),$}}async function D2($,Z,X,Y,Q){let J=$,G=Y;if(await Fz(J,Z,X),J=await Vz(J,Z,X),J=await wY(J,Z,X),J=await RY(J,Z,X),J=await LX(J,Z,X,G),Z$(J))J=W3(J,Z),J=B3(J,Z);J=U3(J);let{processStreamDirectives:K}=await Promise.resolve().then(() => (K7(),Q6));J=K(J,Z),J=g6(J,Z,X,G),J=await q7(J,Z,X,G,Q),J=await pY(J,Z,X,G,Q),J=$Z(J,Z,X,G);let{processDeferDirectives:W}=await Promise.resolve().then(() => NJ);J=W(J,Z,X);let{processTeleportDirectives:B}=await Promise.resolve().then(() => wJ);J=B(J,Z,X);let{processTransitionDirectives:U,processTransitionAttributes:_}=await Promise.resolve().then(() => IJ);J=U(J,Z,X),J=_(J);let{processErrorBoundaryDirectives:z}=await Promise.resolve().then(() => DJ);J=z(J,Z,X);let{processSuspenseDirectives:j}=await Promise.resolve().then(() => kJ);J=j(J,Z,X);let{processAsyncDirectives:q}=await Promise.resolve().then(() => PJ);J=q(J,Z,X);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => xJ);J=H(J,Z,X);let{processVirtualListDirectives:L,processVirtualGridDirectives:F,processInfiniteListDirectives:O}=await Promise.resolve().then(() => (A3(),dJ));J=L(J,Z,X),J=F(J,Z,X),J=O(J,Z,X);let{processPartialHydrationDirectives:V,processStaticDirectives:A}=await Promise.resolve().then(() => (w3(),$2));J=V(J,Z,X),J=A(J);let{processComputedDirectives:N,processWatchDirectives:w}=await Promise.resolve().then(() => (z2(),_2));J=N(J,Z,X),J=w(J,Z,X);let{processFormValidationDirectives:R}=await Promise.resolve().then(() => (L2(),O2));J=R(J,Z,X);let{processHeadDirective:M,processTitleDirective:I,processMetaDirective:E,resetHead:D}=await Promise.resolve().then(() => (p1(),n4));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)D();let k=M(J);if(J=k.content,k.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${k.headContent}
10028
10028
  `;if(J=I(J,Z),J=E(J,Z),J=SY(J),J=u4(J,Z),J=HX(J),J=IY(J),J=await d6(J,Z,X,G,Q),J=await q7(J,Z,X,G,Q),J=J.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),J=H3(J),J=d1(J,Z,X),J=m4(J,Z),J=p4(J,Z),J=Q7(J,Z),J=wX(J,Z),J=RX(J,Z),J=await S2(J,Z,X,G),J=await k2(J,Z,X),J=await EX(J,Z,X,G),J=n8(J,Z,X,G),J=bY(J,Z,X,G),J=PY(J,Z,X),J=yY(J,Z,X,G),J=qX(J,Z,X,G),J=q3(J,Z),J=j3(J),J=jJ(J),!G.skipEventDirectives)J=nZ(J,Z,X);if(J=aZ(J,Z,X),G.debug){let f=/\bx-data\s*=/.test(J),d=h7($);if(f&&d)console.warn(`[stx] ${X}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
10029
10029
  Both work on the same page, but they manage separate scopes.
10030
- Prefer signals (state/derived/effect) for new components.`)}J=l6(J,Z),J=await i0(J,Z,X),J=HJ(J),J=OJ(J),J=dZ(J);let{processXElementDirectives:P}=await Promise.resolve().then(() => N2);J=P(J);let S=Z.__originalFilePath||X,C=e1(Z);if(J=await _3(J,G,S,C),J=await kY(J,Z,X,G),G.media?.image?.autoSiblings){let f=G.publicDir||"public",{rewriteImagesWithSiblings:d}=await Promise.resolve().then(() => (R3(),w2));J=await d(J,{publicDir:f})}if(G.seo?.enabled)J=xY(J,Z,G);let y=(f,d)=>{if(!d)return f;if(/<\/head>/i.test(f))return f.replace(/<\/head>/i,`${d}
10030
+ Prefer signals (state/derived/effect) for new components.`)}J=l6(J,Z),J=await i0(J,Z,X),J=HJ(J),J=OJ(J),J=dZ(J);let{processXElementDirectives:P}=await Promise.resolve().then(() => N2);J=P(J);let S=Z.__originalFilePath||X,b=e1(Z);if(J=await _3(J,G,S,b),J=await kY(J,Z,X,G),G.media?.image?.autoSiblings){let f=G.publicDir||"public",{rewriteImagesWithSiblings:d}=await Promise.resolve().then(() => (R3(),w2));J=await d(J,{publicDir:f})}if(G.seo?.enabled)J=xY(J,Z,G);let y=(f,d)=>{if(!d)return f;if(/<\/head>/i.test(f))return f.replace(/<\/head>/i,`${d}
10031
10031
  </head>`);if(/<head\b[^>]*>/i.test(f))return f.replace(/(<head\b[^>]*>)/i,`$1
10032
10032
  ${d}`);if(/<html\b[^>]*>/i.test(f))return f.replace(/(<html\b[^>]*>)/i,`$1
10033
10033
  <head>
10034
10034
  ${d}
10035
10035
  </head>`);return f},{renderHead:m,getHead:g}=await Promise.resolve().then(() => (p1(),n4)),p=Z.__stx_runtime_head,s=p&&(p.title||p.meta?.length||p.link?.length)?p:g();if(s.title||s.meta?.length||s.link?.length){let f=m(s);if(f)J=y(J,f)}if(k.headContent)J=y(J,k.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)J=zX(J,G.csp,Z);if(G.analytics?.enabled)J=uZ(J,G);if(G.heatmap?.enabled)J=QZ(J,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:f}=await Promise.resolve().then(() => (I2(),T2));J=f(J,G)}let M0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(J),Y1=/\bSTX\.\w+/.test(J),v0=/window\.STX\s*=/.test(J);if(M0&&Y1&&!v0){let d=`<script data-stx-scoped>
10036
10036
  ${vZ()}
10037
- </script>`;if(J.includes("</head>")){let c=J.indexOf("</head>"),W0=J.slice(0,c).indexOf("<script");if(W0!==-1){let C0=J.slice(0,W0),f0=J.slice(W0);J=C0+d+`
10037
+ </script>`;if(J.includes("</head>")){let c=J.indexOf("</head>"),W0=J.slice(0,c).indexOf("<script");if(W0!==-1){let T0=J.slice(0,W0),f0=J.slice(W0);J=T0+d+`
10038
10038
  `+f0}else J=J.replace("</head>",`${d}
10039
10039
  </head>`)}else if(J.includes("<body"))J=J.replace(/<body([^>]*)>/,`<body$1>
10040
10040
  ${d}`);else J=d+`
10041
- `+J}{let f=/<script\s+server\b[^>]*>/gi,d,c=[];while((d=f.exec(J))!==null){let o=d.index+d[0].length,W0=qz(J,o);if(W0===-1)continue;let C0=W0+9;while(C0<J.length&&/\s/.test(J[C0]))C0++;c.push({start:d.index,end:C0})}for(let o=c.length-1;o>=0;o--){let{start:W0,end:C0}=c[o];J=J.substring(0,W0)+J.substring(C0)}}let S0=w7(J,X);if(S0.hasScoped)J=S0.html;let $0=Z.__stx_event_bindings||[],V0=!1,z0=[],b=/\s:[a-z][\w.-]*\s*=/.test(J),{scanScriptTags:v}=await Promise.resolve().then(() => (z3(),UJ));for(let f of v(J,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))z0.push({match:f.fullMatch,attrs:f.attrs,content:f.body});for(let{match:f,attrs:d,content:c}of z0){V0=!0;let o=c;L3(c,X,Y.strict);let W0=await $$(c,{eventBindings:$0,attrs:d,hasColonDirectives:b,templateContent:$,filePath:X,projectRoot:process.cwd(),production:Y.buildMode==="compile",serverData:C});J=J.replace(f,()=>W0)}if(V0)Z.__stx_event_bindings=[];return J}var r1="<!--PARENT_CONTENT_PLACEHOLDER-->";var n0=T(()=>{J$();c5();y5();fZ();b4();P4();v5();x5();y4();P1();tZ();L$();$7();c4();OX();i4();d0();p1();T0();r4();X6();U$();TY();F7();c7();c6();v1();CY();N7();Q0();hY();i6();n6();r6();R7();z3();x6();qJ();O3();F3();L0();K6();O3();F3()});var C2=()=>{};var v2={};a(v2,{renderSlot:()=>P2,processSlots:()=>x2,parseSlots:()=>b2,parseSlotElement:()=>Az,extractSlotContent:()=>Mz,applySlots:()=>Tz});function Nz($,Z){let X=1,Y=Z,Q="<template",J="</template";while(Y<$.length&&X>0){let G=$.indexOf("<",Y);if(G===-1)break;if(Y=G,$.startsWith(Q,Y)&&(Y+Q.length>=$.length||/[\s>\/]/.test($[Y+Q.length]))){X++,Y+=Q.length;continue}if($.startsWith(J,Y)){let K=$.indexOf(">",Y+J.length);if(K!==-1){if(X--,X===0)return K+1;Y=K+1;continue}}Y++}return X===0?Y:-1}function b2($){let Z={default:"",named:new Map},X=$,Y=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,Q=[],J;while((J=Y.exec($))!==null){let[U,_,z,j,q]=J,H=_||z||j,L=J.index+U.length,F=Nz($,L);if(F!==-1){let O=$.slice(L,F-11).trim();Q.push({start:J.index,end:F,slotName:H,content:O,propsBinding:q||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:q||void 0})}}Q.sort((U,_)=>_.start-U.start);for(let U of Q)X=X.slice(0,U.start)+X.slice(U.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,W;while((W=K.exec(X))!==null){let[U,_,z,j,q,H]=W,L=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=q.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${_}${O?" "+O:""}>${H}</${_}>`;G.push({start:W.index,end:W.index+U.length,slotName:j,element:V})}let B=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((W=B.exec(X))!==null){let[U,_,z,j,q]=W,H=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=q.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${_}${F?" "+F:""} />`;G.push({start:W.index,end:W.index+U.length,slotName:j,element:O})}G.sort((U,_)=>_.start-U.start);for(let U of G){let _=Z.named.get(U.slotName);if(_)_.content+=U.element;else Z.named.set(U.slotName,{name:U.slotName,content:U.element});X=X.slice(0,U.start)+X.slice(U.end)}return Z.default=X.trim(),Z}function Az($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),X=Z?Z[1]:"",Y={},Q=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,J;while((J=Q.exec($))!==null)Y[J[1]]=J[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:X,props:Y,defaultContent:K}}async function P2($,Z,X,Y){if(!$)return X;let Q=$.content;if($.propsBinding&&Object.keys(Z).length>0){let J=$.propsBinding.trim(),G={...Y};if(J.startsWith("{")&&J.endsWith("}")){let K=J.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[B,U]=W.split(":").map((z)=>z.trim()),_=U||B;if(Z[B]!==void 0)G[_]=Z[B]}}else G[J]=Z;Q=wz(Q,G)}return Q}function wz($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(X,Y)=>{try{let Q=Y.trim(),J=y2(Q,Z);return j0(String(J??""))}catch{return`{{ ${Y} }}`}})}function y2($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let Y=$.split("."),Q=Z;for(let J of Y)if(Q&&typeof Q==="object"&&J in Q)Q=Q[J];else return;return Q}let X=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(X){let[,Y,Q,J]=X,G=Z[Y],K=parseInt(J,10);if(typeof G==="number")switch(Q){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!X0($))return;return Y0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function x2($,Z,X){let Y=$;Y=await Rz(Y,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,B)=>{let U=Z.named.get(K),_=B?.trim()||"",z=W||"",j={},q=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=q.exec(z))!==null){let L=H[1],F=H[2];j[L]=y2(F,X)}return await P2(U,j,_,X)});let J=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return Y=Y.replace(J,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),Y}async function Rz($,Z,X){let Y=[],Q=[];$.replace(Z,(K,...W)=>{let B=W[W.length-2];return Q.push({match:K,index:B}),Y.push(X(K,...W.slice(0,-2))),K});let J=await Promise.all(Y),G=$;for(let K=Q.length-1;K>=0;K--){let{match:W,index:B}=Q[K];G=G.slice(0,B)+J[K]+G.slice(B+W.length)}return G}function Mz($){let Z=b2($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function Tz($,Z,X,Y){return await x2($,{default:Z,named:X},Y)}var I3=T(()=>{T0();L0()});import Iz from"fs";import u from"path";function f2($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Dz($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function y1($){return!Dz($)}function x1($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let X=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(J)=>{let G=X.length;return X.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(J)=>{let G=X.length;return X.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(J)=>{let G=X.length;return X.push(J),`"__STX_EXPR_${G}__"`});let Q=new Bun.Transpiler({loader:"ts",target:"browser",define:l0()}).transformSync(Z);for(let J=0;J<X.length;J++)Q=Q.replace(`"__STX_EXPR_${J}__"`,X[J]),Q=Q.replace(`'__STX_EXPR_${J}__'`,X[J]);return Q}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function kz($){let Z=[],X=new Set,Y=0,Q=0,J=$.length,G=(U)=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]===U){Q++;return}Q++}},K=()=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]==="`"){Q++;return}if($[Q]==="$"&&$[Q+1]==="{"){Q+=2;let U=1;while(Q<J&&U>0)if($[Q]==="{")U++,Q++;else if($[Q]==="}")U--,Q++;else if($[Q]==="'"||$[Q]==='"')G($[Q]);else if($[Q]==="`")K();else Q++;continue}Q++}},W=()=>{if($[Q]==="/"&&$[Q+1]==="/"){while(Q<J&&$[Q]!==`
10042
- `)Q++;return!0}if($[Q]==="/"&&$[Q+1]==="*"){Q+=2;while(Q<J-1&&!($[Q]==="*"&&$[Q+1]==="/"))Q++;return Q+=2,!0}return!1},B=()=>{if(Y!==0)return;let U=$.slice(Q).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(U){let q=U[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.length-1].trim()});for(let H of q)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!X.has(H))Z.push(H),X.add(H);return}let _=$.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(_){let q=_[2];if(!X.has(q))Z.push(q),X.add(q);return}let z=$.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(z){let q=z[1];if(!X.has(q))Z.push(q),X.add(q);return}let j=$.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(j){let q=j[1];if(!X.has(q))Z.push(q),X.add(q)}};while(Q<J){if(W())continue;if($[Q]==="'"||$[Q]==='"'){G($[Q]);continue}if($[Q]==="`"){K();continue}if($[Q]==="{"){Y++,Q++;continue}if($[Q]==="}"){Y--,Q++;continue}if(Y===0&&/[a-z]/i.test($[Q])&&(Q===0||/\s|[;{}()]/.test($[Q-1])))B();Q++}return Z}function Sz($){let Z=[],X=0,Y=0,Q=null;for(let J=0;J<$.length;J++){let G=$[J];if(Q){if(G==="\\"){J++;continue}if(G===Q)Q=null;continue}if(G==='"'||G==="'"||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{")X++;else if(G===")"||G==="]"||G==="}")X--;else if(G===","&&X===0)Z.push($.slice(Y,J)),Y=J+1}if(Y<$.length)Z.push($.slice(Y));return Z}function Cz($){let Z=0,X=null;for(let Y=0;Y<$.length;Y++){let Q=$[Y];if(X){if(Q==="\\"){Y++;continue}if(Q===X)X=null;continue}if(Q==='"'||Q==="'"||Q==="`"){X=Q;continue}if(Q==="("||Q==="["||Q==="{")Z++;else if(Q===")"||Q==="]"||Q==="}")Z--;else if(Q==="="&&Z===0){let J=$[Y-1],G=$[Y+1];if(J==="!"||J==="<"||J===">"||J==="=")continue;if(G==="="||G===">")continue;return Y}}return-1}function bz($,Z){try{let X=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!X)return;let Y=X.index-1;while(Y>=0&&/\s/.test($[Y]))Y--;if($[Y]!=="}")return;let Q=Y,J=0,G=-1;for(;Y>=0;Y--){let W=$[Y];if(W==="}")J++;else if(W==="{"){if(J--,J===0){G=Y;break}}}if(G===-1)return;let K=$.slice(G+1,Q);for(let W of Sz(K)){let B=W.trim();if(!B||B.startsWith("..."))continue;let U=Cz(B);if(U===-1)continue;let _=B.slice(0,U).trim();if(!/^[A-Z_$][\w$]*$/i.test(_))continue;if(Z[_]!==void 0)continue;let z=B.slice(U+1).trim();if(!z)continue;try{let j=Object.keys(Z),q=Function(...j,`"use strict"; return (${z});`);Z[_]=q(...j.map((H)=>Z[H]))}catch{}}}catch{}}async function XY($,Z,X,Y,Q){let J=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=X.__importedComponents;if(W){for(let L of[J,J.toLowerCase(),G(J),K(J)])if(W.has(L))return!0}let B=[...new Set([`${J}.stx`,`${G(J)}.stx`,`${K(J)}.stx`])],U=typeof Q.root==="string"?u.resolve(Q.root):void 0,_=U??u.dirname(Y),z=[],j=(L)=>{if(L&&!z.includes(L))z.push(L)},q=X.__originalFilePath;if(q)j(u.join(u.dirname(q),"components"));j(Z),j(u.join(u.dirname(Y),"components")),j(Q.componentsDir);let H=Q._pluginComponentDirs;if(Array.isArray(H))for(let L of H)j(typeof L==="string"?L:null);if(U)j(u.resolve(U,"resources/views/components")),j(u.resolve(U,"resources/components")),j(u.resolve(U,"src/components")),j(u.resolve(U,"components"));if(J.startsWith("./")||J.startsWith("../"))return l(u.resolve(u.dirname(Y),`${J}.stx`));for(let L of z){let F=u.isAbsolute(L)?L:u.resolve(_,L);for(let O of B)if(await l(u.join(F,O)))return!0}return!1}function Pz($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function F1($,Z,X,Y,Q,J,G,K=new Set,W){let{extractVariables:B}=await Promise.resolve().then(() => (V1(),j7)),U=K??new Set;if(U.has($))return`[Circular component reference: ${$}]`;let _=new Set(U);_.add($);let z=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let j=z&&z!=="load"&&Pz(z)?z:"";try{let q=(b)=>b.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(b)=>b.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,O=Q.__importedComponents;if(O){let b=[L,L.toLowerCase(),q(L),H(L)];for(let v of b)if(O.has(v)){F=O.get(v);break}}let V=[];if(!F){let b=[`${L}.stx`,`${q(L)}.stx`,`${H(L)}.stx`],v=[...new Set(b)],f=Q.__originalFilePath,d=[];if(f){let _0=u.join(u.dirname(f),"components");d.push(_0)}if(Y)d.push(Y);let c=u.join(u.dirname(J),"components");if(!d.includes(c))d.push(c);if(G.componentsDir&&G.componentsDir!==Y&&!d.includes(G.componentsDir))d.push(G.componentsDir);let o=G._pluginComponentDirs;if(Array.isArray(o)){for(let _0 of o)if(typeof _0==="string"&&!d.includes(_0))d.push(_0)}let W0=typeof G.root==="string"?u.resolve(G.root):void 0,C0=W0??u.dirname(J),f0=[];if(W0)f0.push(u.resolve(W0,"resources/views/components")),f0.push(u.resolve(W0,"resources/components")),f0.push(u.resolve(W0,"src/components")),f0.push(u.resolve(W0,"components"));f0.push(u.resolve(import.meta.dir,"components"));for(let _0 of f0)if(!d.includes(_0))d.push(_0);let k1=[...new Set(d.map((_0)=>{if(!_0)return _0;return u.isAbsolute(_0)?_0:u.resolve(C0,_0)}))];if(d.length=0,d.push(...k1),L.startsWith("./")||L.startsWith("../"))F=u.resolve(u.dirname(J),`${L}.stx`),V.push(F);else for(let _0 of d){if(!_0)continue;for(let S1 of v){let E$=u.join(_0,S1);if(V.push(E$),await l(E$)){F=E$;break}}if(F)break;if(!F)try{let S1=await import("fs");if(!S1.statSync(_0,{throwIfNoEntry:!1})?.isDirectory())continue;let b5=8,e=[{path:_0,depth:0}];while(e.length>0&&!F){let o0=e.pop();if(o0.depth>=b5)continue;let V4;try{V4=S1.readdirSync(o0.path,{withFileTypes:!0})}catch{continue}for(let P5 of V4){if(!P5.isDirectory())continue;if(P5.name==="node_modules"||P5.name.startsWith("."))continue;let i8=u.join(o0.path,P5.name);for(let JG of v){let N4=u.join(i8,JG);if(V.push(N4),await l(N4)){F=N4;break}}if(F)break;e.push({path:i8,depth:o0.depth+1})}}}catch{}if(F)break}}if(!F||!await l(F)){let b=V.length>0?`
10041
+ `+J}{let f=/<script\s+server\b[^>]*>/gi,d,c=[];while((d=f.exec(J))!==null){let o=d.index+d[0].length,W0=qz(J,o);if(W0===-1)continue;let T0=W0+9;while(T0<J.length&&/\s/.test(J[T0]))T0++;c.push({start:d.index,end:T0}),f.lastIndex=T0}for(let o=c.length-1;o>=0;o--){let{start:W0,end:T0}=c[o];J=J.substring(0,W0)+J.substring(T0)}}let C0=w7(J,X);if(C0.hasScoped)J=C0.html;let $0=Z.__stx_event_bindings||[],V0=!1,z0=[],C=/\s:[a-z][\w.-]*\s*=/.test(J),{scanScriptTags:v}=await Promise.resolve().then(() => (z3(),UJ));for(let f of v(J,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))z0.push({match:f.fullMatch,attrs:f.attrs,content:f.body});for(let{match:f,attrs:d,content:c}of z0){V0=!0;let o=c;L3(c,X,Y.strict);let W0=await $$(c,{eventBindings:$0,attrs:d,hasColonDirectives:C,templateContent:$,filePath:X,projectRoot:process.cwd(),production:Y.buildMode==="compile",serverData:b});J=J.replace(f,()=>W0)}if(V0)Z.__stx_event_bindings=[];return J}var r1="<!--PARENT_CONTENT_PLACEHOLDER-->";var n0=T(()=>{J$();c5();y5();fZ();b4();P4();v5();x5();y4();P1();tZ();L$();$7();c4();OX();i4();d0();p1();I0();r4();X6();U$();TY();F7();c7();c6();v1();CY();N7();Q0();hY();i6();n6();r6();R7();z3();x6();qJ();O3();F3();L0();K6();O3();F3()});var C2=()=>{};var v2={};a(v2,{renderSlot:()=>P2,processSlots:()=>x2,parseSlots:()=>b2,parseSlotElement:()=>Az,extractSlotContent:()=>Mz,applySlots:()=>Tz});function Nz($,Z){let X=1,Y=Z,Q="<template",J="</template";while(Y<$.length&&X>0){let G=$.indexOf("<",Y);if(G===-1)break;if(Y=G,$.startsWith(Q,Y)&&(Y+Q.length>=$.length||/[\s>\/]/.test($[Y+Q.length]))){X++,Y+=Q.length;continue}if($.startsWith(J,Y)){let K=$.indexOf(">",Y+J.length);if(K!==-1){if(X--,X===0)return K+1;Y=K+1;continue}}Y++}return X===0?Y:-1}function b2($){let Z={default:"",named:new Map},X=$,Y=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,Q=[],J;while((J=Y.exec($))!==null){let[U,_,z,j,q]=J,H=_||z||j,L=J.index+U.length,F=Nz($,L);if(F!==-1){let O=$.slice(L,F-11).trim();Q.push({start:J.index,end:F,slotName:H,content:O,propsBinding:q||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:q||void 0})}}Q.sort((U,_)=>_.start-U.start);for(let U of Q)X=X.slice(0,U.start)+X.slice(U.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,W;while((W=K.exec(X))!==null){let[U,_,z,j,q,H]=W,L=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=q.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${_}${O?" "+O:""}>${H}</${_}>`;G.push({start:W.index,end:W.index+U.length,slotName:j,element:V})}let B=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((W=B.exec(X))!==null){let[U,_,z,j,q]=W,H=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=q.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${_}${F?" "+F:""} />`;G.push({start:W.index,end:W.index+U.length,slotName:j,element:O})}G.sort((U,_)=>_.start-U.start);for(let U of G){let _=Z.named.get(U.slotName);if(_)_.content+=U.element;else Z.named.set(U.slotName,{name:U.slotName,content:U.element});X=X.slice(0,U.start)+X.slice(U.end)}return Z.default=X.trim(),Z}function Az($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),X=Z?Z[1]:"",Y={},Q=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,J;while((J=Q.exec($))!==null)Y[J[1]]=J[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:X,props:Y,defaultContent:K}}async function P2($,Z,X,Y){if(!$)return X;let Q=$.content;if($.propsBinding&&Object.keys(Z).length>0){let J=$.propsBinding.trim(),G={...Y};if(J.startsWith("{")&&J.endsWith("}")){let K=J.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[B,U]=W.split(":").map((z)=>z.trim()),_=U||B;if(Z[B]!==void 0)G[_]=Z[B]}}else G[J]=Z;Q=wz(Q,G)}return Q}function wz($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(X,Y)=>{try{let Q=Y.trim(),J=y2(Q,Z);return j0(String(J??""))}catch{return`{{ ${Y} }}`}})}function y2($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let Y=$.split("."),Q=Z;for(let J of Y)if(Q&&typeof Q==="object"&&J in Q)Q=Q[J];else return;return Q}let X=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(X){let[,Y,Q,J]=X,G=Z[Y],K=parseInt(J,10);if(typeof G==="number")switch(Q){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!X0($))return;return Y0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function x2($,Z,X){let Y=$;Y=await Rz(Y,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,B)=>{let U=Z.named.get(K),_=B?.trim()||"",z=W||"",j={},q=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=q.exec(z))!==null){let L=H[1],F=H[2];j[L]=y2(F,X)}return await P2(U,j,_,X)});let J=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return Y=Y.replace(J,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),Y}async function Rz($,Z,X){let Y=[],Q=[];$.replace(Z,(K,...W)=>{let B=W[W.length-2];return Q.push({match:K,index:B}),Y.push(X(K,...W.slice(0,-2))),K});let J=await Promise.all(Y),G=$;for(let K=Q.length-1;K>=0;K--){let{match:W,index:B}=Q[K];G=G.slice(0,B)+J[K]+G.slice(B+W.length)}return G}function Mz($){let Z=b2($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function Tz($,Z,X,Y){return await x2($,{default:Z,named:X},Y)}var I3=T(()=>{I0();L0()});import Iz from"fs";import u from"path";function f2($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Dz($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function y1($){return!Dz($)}function x1($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let X=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(J)=>{let G=X.length;return X.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(J)=>{let G=X.length;return X.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(J)=>{let G=X.length;return X.push(J),`"__STX_EXPR_${G}__"`});let Q=new Bun.Transpiler({loader:"ts",target:"browser",define:l0()}).transformSync(Z);for(let J=0;J<X.length;J++)Q=Q.replace(`"__STX_EXPR_${J}__"`,X[J]),Q=Q.replace(`'__STX_EXPR_${J}__'`,X[J]);return Q}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function kz($){let Z=[],X=new Set,Y=0,Q=0,J=$.length,G=(U)=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]===U){Q++;return}Q++}},K=()=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]==="`"){Q++;return}if($[Q]==="$"&&$[Q+1]==="{"){Q+=2;let U=1;while(Q<J&&U>0)if($[Q]==="{")U++,Q++;else if($[Q]==="}")U--,Q++;else if($[Q]==="'"||$[Q]==='"')G($[Q]);else if($[Q]==="`")K();else Q++;continue}Q++}},W=()=>{if($[Q]==="/"&&$[Q+1]==="/"){while(Q<J&&$[Q]!==`
10042
+ `)Q++;return!0}if($[Q]==="/"&&$[Q+1]==="*"){Q+=2;while(Q<J-1&&!($[Q]==="*"&&$[Q+1]==="/"))Q++;return Q+=2,!0}return!1},B=()=>{if(Y!==0)return;let U=$.slice(Q).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(U){let q=U[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.length-1].trim()});for(let H of q)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!X.has(H))Z.push(H),X.add(H);return}let _=$.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(_){let q=_[2];if(!X.has(q))Z.push(q),X.add(q);return}let z=$.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(z){let q=z[1];if(!X.has(q))Z.push(q),X.add(q);return}let j=$.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(j){let q=j[1];if(!X.has(q))Z.push(q),X.add(q)}};while(Q<J){if(W())continue;if($[Q]==="'"||$[Q]==='"'){G($[Q]);continue}if($[Q]==="`"){K();continue}if($[Q]==="{"){Y++,Q++;continue}if($[Q]==="}"){Y--,Q++;continue}if(Y===0&&/[a-z]/i.test($[Q])&&(Q===0||/\s|[;{}()]/.test($[Q-1])))B();Q++}return Z}function Sz($){let Z=[],X=0,Y=0,Q=null;for(let J=0;J<$.length;J++){let G=$[J];if(Q){if(G==="\\"){J++;continue}if(G===Q)Q=null;continue}if(G==='"'||G==="'"||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{")X++;else if(G===")"||G==="]"||G==="}")X--;else if(G===","&&X===0)Z.push($.slice(Y,J)),Y=J+1}if(Y<$.length)Z.push($.slice(Y));return Z}function Cz($){let Z=0,X=null;for(let Y=0;Y<$.length;Y++){let Q=$[Y];if(X){if(Q==="\\"){Y++;continue}if(Q===X)X=null;continue}if(Q==='"'||Q==="'"||Q==="`"){X=Q;continue}if(Q==="("||Q==="["||Q==="{")Z++;else if(Q===")"||Q==="]"||Q==="}")Z--;else if(Q==="="&&Z===0){let J=$[Y-1],G=$[Y+1];if(J==="!"||J==="<"||J===">"||J==="=")continue;if(G==="="||G===">")continue;return Y}}return-1}function bz($,Z){try{let X=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!X)return;let Y=X.index-1;while(Y>=0&&/\s/.test($[Y]))Y--;if($[Y]!=="}")return;let Q=Y,J=0,G=-1;for(;Y>=0;Y--){let W=$[Y];if(W==="}")J++;else if(W==="{"){if(J--,J===0){G=Y;break}}}if(G===-1)return;let K=$.slice(G+1,Q);for(let W of Sz(K)){let B=W.trim();if(!B||B.startsWith("..."))continue;let U=Cz(B);if(U===-1)continue;let _=B.slice(0,U).trim();if(!/^[A-Z_$][\w$]*$/i.test(_))continue;if(Z[_]!==void 0)continue;let z=B.slice(U+1).trim();if(!z)continue;try{let j=Object.keys(Z),q=Function(...j,`"use strict"; return (${z});`);Z[_]=q(...j.map((H)=>Z[H]))}catch{}}}catch{}}async function XY($,Z,X,Y,Q){let J=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=X.__importedComponents;if(W){for(let L of[J,J.toLowerCase(),G(J),K(J)])if(W.has(L))return!0}let B=[...new Set([`${J}.stx`,`${G(J)}.stx`,`${K(J)}.stx`])],U=typeof Q.root==="string"?u.resolve(Q.root):void 0,_=U??u.dirname(Y),z=[],j=(L)=>{if(L&&!z.includes(L))z.push(L)},q=X.__originalFilePath;if(q)j(u.join(u.dirname(q),"components"));j(Z),j(u.join(u.dirname(Y),"components")),j(Q.componentsDir);let H=Q._pluginComponentDirs;if(Array.isArray(H))for(let L of H)j(typeof L==="string"?L:null);if(U)j(u.resolve(U,"resources/views/components")),j(u.resolve(U,"resources/components")),j(u.resolve(U,"src/components")),j(u.resolve(U,"components"));if(J.startsWith("./")||J.startsWith("../"))return l(u.resolve(u.dirname(Y),`${J}.stx`));for(let L of z){let F=u.isAbsolute(L)?L:u.resolve(_,L);for(let O of B)if(await l(u.join(F,O)))return!0}return!1}function Pz($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function F1($,Z,X,Y,Q,J,G,K=new Set,W){let{extractVariables:B}=await Promise.resolve().then(() => (V1(),j7)),U=K??new Set;if(U.has($))return`[Circular component reference: ${$}]`;let _=new Set(U);_.add($);let z=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let j=z&&z!=="load"&&Pz(z)?z:"";try{let q=(C)=>C.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(C)=>C.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,O=Q.__importedComponents;if(O){let C=[L,L.toLowerCase(),q(L),H(L)];for(let v of C)if(O.has(v)){F=O.get(v);break}}let V=[];if(!F){let C=[`${L}.stx`,`${q(L)}.stx`,`${H(L)}.stx`],v=[...new Set(C)],f=Q.__originalFilePath,d=[];if(f){let _0=u.join(u.dirname(f),"components");d.push(_0)}if(Y)d.push(Y);let c=u.join(u.dirname(J),"components");if(!d.includes(c))d.push(c);if(G.componentsDir&&G.componentsDir!==Y&&!d.includes(G.componentsDir))d.push(G.componentsDir);let o=G._pluginComponentDirs;if(Array.isArray(o)){for(let _0 of o)if(typeof _0==="string"&&!d.includes(_0))d.push(_0)}let W0=typeof G.root==="string"?u.resolve(G.root):void 0,T0=W0??u.dirname(J),f0=[];if(W0)f0.push(u.resolve(W0,"resources/views/components")),f0.push(u.resolve(W0,"resources/components")),f0.push(u.resolve(W0,"src/components")),f0.push(u.resolve(W0,"components"));f0.push(u.resolve(import.meta.dir,"components"));for(let _0 of f0)if(!d.includes(_0))d.push(_0);let k1=[...new Set(d.map((_0)=>{if(!_0)return _0;return u.isAbsolute(_0)?_0:u.resolve(T0,_0)}))];if(d.length=0,d.push(...k1),L.startsWith("./")||L.startsWith("../"))F=u.resolve(u.dirname(J),`${L}.stx`),V.push(F);else for(let _0 of d){if(!_0)continue;for(let S1 of v){let E$=u.join(_0,S1);if(V.push(E$),await l(E$)){F=E$;break}}if(F)break;if(!F)try{let S1=await import("fs");if(!S1.statSync(_0,{throwIfNoEntry:!1})?.isDirectory())continue;let b5=8,e=[{path:_0,depth:0}];while(e.length>0&&!F){let o0=e.pop();if(o0.depth>=b5)continue;let V4;try{V4=S1.readdirSync(o0.path,{withFileTypes:!0})}catch{continue}for(let P5 of V4){if(!P5.isDirectory())continue;if(P5.name==="node_modules"||P5.name.startsWith("."))continue;let i8=u.join(o0.path,P5.name);for(let JG of v){let N4=u.join(i8,JG);if(V.push(N4),await l(N4)){F=N4;break}}if(F)break;e.push({path:i8,depth:o0.depth+1})}}}catch{}if(F)break}}if(!F||!await l(F)){let C=V.length>0?`
10043
10043
  Searched paths:
10044
10044
  ${V.map((v)=>` - ${v}`).join(`
10045
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${b}`}W.add(F);let A;if(l7.has(F))A=l7.get(F);else try{A=await Bun.file(F).text(),l7.set(F,A)}catch(b){return`[Error loading component: ${b instanceof Error?b.message:String(b)}]`}let N=new Set(["__originalFilePath","__importedComponents"]),w={};for(let[b,v]of Object.entries(Q))if(!b.startsWith("__")||N.has(b))w[b]=v;let R={...w,...Z,props:Z,slot:X,__processedComponents:_,__sections:{}};bz(A,R);let M=A,I=M.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(I)M=I[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...A.matchAll(E)],k=[];for(let b of D){let v=b[1]||"",f=b[2]||"",d=v.includes("server");if(y1(v)&&f.trim())f=x1(f);if(d&&f)try{await B(f,R,F)}catch(o){}if(!d){let o=f.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(o.includes("{{")&&o.includes("}}"))o=i0(o,R,F);let W0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");k.push(`<script${W0}>${o}</script>`)}}let P=A.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=P?P[1]:"",C=P?P[2]:"",y="",m=S&&/\bscoped\b/i.test(S);if(P)y=`<style${S}>${C}</style>`;let g=M;if(g=g.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),P)g=g.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let b=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(g=g.replace(b,(f,d)=>{let c=d.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(c)v.push(`<style${c[1]}>${c[2]}</style>`);return""}),g=g.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)y=`${y}${v.join(`
10046
- `)}`}if(X&&g.includes("{{ text || slot }}"))g=g.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>X);let{extractSlotContent:p,applySlots:s}=await Promise.resolve().then(() => (I3(),v2)),{defaultSlot:M0,namedSlots:Y1}=p(X);g=await s(g,M0||X,Y1,R);for(let[b,v]of Object.entries(R))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let f=T4(v);R[b]=f}}let v0=k.some((b)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(b)),S0={...G,componentsDir:u.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:v0,defaultLayout:void 0};R.__stxProcessingDepth=(Q.__stxProcessingDepth||0)+1;let $0=await U0(g,R,F,S0,W),V0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++Ez}_${Math.random().toString(36).slice(2,8)}`,z0=$0;if(v0){let b="";if(Object.keys(Z).length>0)try{b=` data-stx-props="${f2(JSON.stringify(Z))}"`}catch{}let v=j?` stx-hydrate="${f2(j)}"`:"";if(z0=`<div data-stx-scope="${V0}"${b}${v}>${$0}</div>`,z0=k.map((d)=>{let c=d.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!c)return d;let[,o,W0]=c,C0=Q1(W0),f0=`
10045
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${C}`}W.add(F);let A;if(l7.has(F))A=l7.get(F);else try{A=await Bun.file(F).text(),l7.set(F,A)}catch(C){return`[Error loading component: ${C instanceof Error?C.message:String(C)}]`}let N=new Set(["__originalFilePath","__importedComponents"]),w={};for(let[C,v]of Object.entries(Q))if(!C.startsWith("__")||N.has(C))w[C]=v;let R={...w,...Z,props:Z,slot:X,__processedComponents:_,__sections:{}};bz(A,R);let M=A,I=M.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(I)M=I[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...A.matchAll(E)],k=[];for(let C of D){let v=C[1]||"",f=C[2]||"",d=v.includes("server");if(y1(v)&&f.trim())f=x1(f);if(d&&f)try{await B(f,R,F)}catch(o){}if(!d){let o=f.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(o.includes("{{")&&o.includes("}}"))o=i0(o,R,F);let W0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");k.push(`<script${W0}>${o}</script>`)}}let P=A.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=P?P[1]:"",b=P?P[2]:"",y="",m=S&&/\bscoped\b/i.test(S);if(P)y=`<style${S}>${b}</style>`;let g=M;if(g=g.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),P)g=g.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let C=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(g=g.replace(C,(f,d)=>{let c=d.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(c)v.push(`<style${c[1]}>${c[2]}</style>`);return""}),g=g.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)y=`${y}${v.join(`
10046
+ `)}`}if(X&&g.includes("{{ text || slot }}"))g=g.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>X);let{extractSlotContent:p,applySlots:s}=await Promise.resolve().then(() => (I3(),v2)),{defaultSlot:M0,namedSlots:Y1}=p(X);g=await s(g,M0||X,Y1,R);for(let[C,v]of Object.entries(R))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let f=T4(v);R[C]=f}}let v0=k.some((C)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(C)),C0={...G,componentsDir:u.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:v0,defaultLayout:void 0};R.__stxProcessingDepth=(Q.__stxProcessingDepth||0)+1;let $0=await U0(g,R,F,C0,W),V0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++Ez}_${Math.random().toString(36).slice(2,8)}`,z0=$0;if(v0){let C="";if(Object.keys(Z).length>0)try{C=` data-stx-props="${f2(JSON.stringify(Z))}"`}catch{}let v=j?` stx-hydrate="${f2(j)}"`:"";if(z0=`<div data-stx-scope="${V0}"${C}${v}>${$0}</div>`,z0=k.map((d)=>{let c=d.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!c)return d;let[,o,W0]=c,T0=Q1(W0),f0=`
10047
10047
  (function() {
10048
10048
  const { state, derived, effect, batch, defineEmits, defineExpose, defineSlots, defineProps, withDefaults, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, inject, ref, reactive, computed, watch, watchEffect, nextTick } = window.stx;
10049
10049
  const __scope = window.stx._scopes = window.stx._scopes || {};
@@ -10055,12 +10055,12 @@ ${V.map((v)=>` - ${v}`).join(`
10055
10055
  const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
10056
10056
  const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
10057
10057
 
10058
- ${C0}
10058
+ ${T0}
10059
10059
 
10060
10060
  // Register all defined signals and functions in this scope
10061
10061
  const __localVars = {};
10062
10062
  try {
10063
- ${kz(C0).map((k1)=>`if (typeof ${k1} !== 'undefined') __localVars['${k1}'] = ${k1};`).join(`
10063
+ ${kz(T0).map((k1)=>`if (typeof ${k1} !== 'undefined') __localVars['${k1}'] = ${k1};`).join(`
10064
10064
  `)}
10065
10065
  }
10066
10066
  catch (e) {}
@@ -10069,9 +10069,9 @@ catch (e) {}
10069
10069
  `)+`
10070
10070
  `+z0,y)z0+=`
10071
10071
  `+y}else{if(y)z0+=`
10072
- `+y;if(k.length>0){let b=R.__stx_event_bindings||[],v=e1(R),f=await Promise.all(k.map(async(d)=>{let c=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!c)return d;return await $$(c[1],{eventBindings:b,templateContent:z0,filePath:F,projectRoot:process.cwd(),serverData:v})}));z0+=`
10072
+ `+y;if(k.length>0){let C=R.__stx_event_bindings||[],v=e1(R),f=await Promise.all(k.map(async(d)=>{let c=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!c)return d;return await $$(c[1],{eventBindings:C,templateContent:z0,filePath:F,projectRoot:process.cwd(),serverData:v})}));z0+=`
10073
10073
  `+f.join(`
10074
- `),R.__stx_event_bindings=[]}}if(m){let b=w7(z0,F);if(b.hasScoped)z0=b.html}return z0}catch(q){return`[Error processing component: ${q instanceof Error?q.message:String(q)}]`}finally{U.delete($)}}async function l($){return Bun.file($).exists()}function E3($,Z){let X=u.resolve(Z),Y=u.resolve($),Q=X.endsWith(u.sep)?X:X+u.sep;if(Y===X||Y.startsWith(Q))return Y;return null}async function p7($,Z,X,Y){let Q=await yz($,Z,X,Y);if(Q===null)return null;let J=E3(Q,process.cwd());if(J)return J;let G=[X.root,X.layoutsDir,X.componentsDir,X.partialsDir,X.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=u.isAbsolute(K)?K:u.resolve(process.cwd(),K);if(E3(Q,W))return u.resolve(Q)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${Q} (template: ${$}, from: ${Z})`),null}async function yz($,Z,X,Y){if(X.debug)console.log(`Resolving template path: ${$} from ${Z}`);let Q=u.dirname(Z),J=process.cwd();if($.startsWith("/")){let z=u.join(J,$),j=E3(z,J);if(!j)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(X.debug)console.log(`Checking absolute path: ${j}`);if(await l(j)&&Y)Y.add(j);return j}let G=u.join(Q,$);if(await l(G)){if(X.debug)console.log(`Found direct path: ${G}`);if(Y)Y.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let z of[".stx",".tsx",".jsx"]){let j=`${G}${z}`;if(await l(j)){if(X.debug)console.log(`Found direct path with extension: ${j}`);if(Y)Y.add(j);return j}}let K="",W=u.resolve(Q),B=process.cwd();for(let z=0;z<10;z++){let j=u.join(W,"layouts"),q=!1;try{q=Iz.statSync(j,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(q){K=j;break}let H=u.dirname(W);if(H===W||H.length<B.length)break;W=H}if(K){let z=$.startsWith("layouts/")?$.slice(8):$,j=u.join(K,z);if(await l(j)){if(X.debug)console.log(`Found in current layouts dir: ${j}`);if(Y)Y.add(j);return j}if(!z.endsWith(".stx")){let q=`${j}.stx`;if(await l(q)){if(X.debug)console.log(`Found in current layouts dir with extension: ${q}`);if(Y)Y.add(q);return q}}}if(X.layoutsDir){let z=u.isAbsolute(X.layoutsDir)?X.layoutsDir:u.resolve(process.cwd(),X.layoutsDir),j=$.startsWith("layouts/")?$.slice(8):$,q=u.join(z,j);if(await l(q)){if(X.debug)console.log(`Found in options.layoutsDir: ${q}`);if(Y)Y.add(q);return q}if(!$.endsWith(".stx")){let H=`${q}.stx`;if(await l(H)){if(X.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(Y)Y.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let z=$.split("layouts/"),j=u.join(X.partialsDir||Q,"layouts",z[1]);if(await l(j)){if(X.debug)console.log(`Found in layouts path: ${j}`);if(Y)Y.add(j);return j}if(!j.endsWith(".stx")){let q=`${j}.stx`;if(await l(q)){if(X.debug)console.log(`Found in layouts path with extension: ${q}`);if(Y)Y.add(q);return q}}}if(X.partialsDir){if(K=u.join(X.partialsDir,"layouts"),await l(K)){let z=u.join(K,$);if(await l(z)){if(X.debug)console.log(`Found in partials layouts dir: ${z}`);if(Y)Y.add(z);return z}if(!$.endsWith(".stx")){let j=`${z}.stx`;if(await l(j)){if(X.debug)console.log(`Found in partials layouts dir with extension: ${j}`);if(Y)Y.add(j);return j}}}}let U=X.partialsDir||u.join(process.cwd(),"views"),_=u.join(U,$);if(await l(_)){if(X.debug)console.log(`Found in views path: ${_}`);if(Y)Y.add(_);return _}if(!$.endsWith(".stx")){let z=`${_}.stx`;if(await l(z)){if(X.debug)console.log(`Found in views path with extension: ${z}`);if(Y)Y.add(z);return z}}if(Q.includes("temp")){let z=u.join(u.dirname(Q),"layouts",$);if(await l(z)){if(X.debug)console.log(`Found in temp layouts dir: ${z}`);if(Y)Y.add(z);return z}if(!$.endsWith(".stx")){let j=`${z}.stx`;if(await l(j)){if(X.debug)console.log(`Found in temp layouts dir with extension: ${j}`);if(Y)Y.add(j);return j}}}if(X.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function g2($,Z,X){let Y=0,Q="",J="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10074
+ `),R.__stx_event_bindings=[]}}if(m){let C=w7(z0,F);if(C.hasScoped)z0=C.html}return z0}catch(q){return`[Error processing component: ${q instanceof Error?q.message:String(q)}]`}finally{U.delete($)}}async function l($){return Bun.file($).exists()}function E3($,Z){let X=u.resolve(Z),Y=u.resolve($),Q=X.endsWith(u.sep)?X:X+u.sep;if(Y===X||Y.startsWith(Q))return Y;return null}async function p7($,Z,X,Y){let Q=await yz($,Z,X,Y);if(Q===null)return null;let J=E3(Q,process.cwd());if(J)return J;let G=[X.root,X.layoutsDir,X.componentsDir,X.partialsDir,X.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=u.isAbsolute(K)?K:u.resolve(process.cwd(),K);if(E3(Q,W))return u.resolve(Q)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${Q} (template: ${$}, from: ${Z})`),null}async function yz($,Z,X,Y){if(X.debug)console.log(`Resolving template path: ${$} from ${Z}`);let Q=u.dirname(Z),J=process.cwd();if($.startsWith("/")){let z=u.join(J,$),j=E3(z,J);if(!j)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(X.debug)console.log(`Checking absolute path: ${j}`);if(await l(j)&&Y)Y.add(j);return j}let G=u.join(Q,$);if(await l(G)){if(X.debug)console.log(`Found direct path: ${G}`);if(Y)Y.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let z of[".stx",".tsx",".jsx"]){let j=`${G}${z}`;if(await l(j)){if(X.debug)console.log(`Found direct path with extension: ${j}`);if(Y)Y.add(j);return j}}let K="",W=u.resolve(Q),B=process.cwd();for(let z=0;z<10;z++){let j=u.join(W,"layouts"),q=!1;try{q=Iz.statSync(j,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(q){K=j;break}let H=u.dirname(W);if(H===W||H.length<B.length)break;W=H}if(K){let z=$.startsWith("layouts/")?$.slice(8):$,j=u.join(K,z);if(await l(j)){if(X.debug)console.log(`Found in current layouts dir: ${j}`);if(Y)Y.add(j);return j}if(!z.endsWith(".stx")){let q=`${j}.stx`;if(await l(q)){if(X.debug)console.log(`Found in current layouts dir with extension: ${q}`);if(Y)Y.add(q);return q}}}if(X.layoutsDir){let z=u.isAbsolute(X.layoutsDir)?X.layoutsDir:u.resolve(process.cwd(),X.layoutsDir),j=$.startsWith("layouts/")?$.slice(8):$,q=u.join(z,j);if(await l(q)){if(X.debug)console.log(`Found in options.layoutsDir: ${q}`);if(Y)Y.add(q);return q}if(!$.endsWith(".stx")){let H=`${q}.stx`;if(await l(H)){if(X.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(Y)Y.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let z=$.split("layouts/"),j=u.join(X.partialsDir||Q,"layouts",z[1]);if(await l(j)){if(X.debug)console.log(`Found in layouts path: ${j}`);if(Y)Y.add(j);return j}if(!j.endsWith(".stx")){let q=`${j}.stx`;if(await l(q)){if(X.debug)console.log(`Found in layouts path with extension: ${q}`);if(Y)Y.add(q);return q}}}if(X.partialsDir){if(K=u.join(X.partialsDir,"layouts"),await l(K)){let z=u.join(K,$);if(await l(z)){if(X.debug)console.log(`Found in partials layouts dir: ${z}`);if(Y)Y.add(z);return z}if(!$.endsWith(".stx")){let j=`${z}.stx`;if(await l(j)){if(X.debug)console.log(`Found in partials layouts dir with extension: ${j}`);if(Y)Y.add(j);return j}}}}let U=X.partialsDir||u.join(process.cwd(),"views"),_=u.join(U,$);if(await l(_)){if(X.debug)console.log(`Found in views path: ${_}`);if(Y)Y.add(_);return _}if(!$.endsWith(".stx")){let z=`${_}.stx`;if(await l(z)){if(X.debug)console.log(`Found in views path with extension: ${z}`);if(Y)Y.add(z);return z}}if(Q.includes("temp")){let z=u.join(u.dirname(Q),"layouts",$);if(await l(z)){if(X.debug)console.log(`Found in temp layouts dir: ${z}`);if(Y)Y.add(z);return z}if(!$.endsWith(".stx")){let j=`${z}.stx`;if(await l(j)){if(X.debug)console.log(`Found in temp layouts dir with extension: ${j}`);if(Y)Y.add(j);return j}}}if(X.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function g2($,Z,X){let Y=0,Q="",J="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10075
10075
  `),K=0;for(let W=0;W<G.length;W++)if(K+=G[W].length+1,K>=Z){Y=W+1,Q=G[W].trim();let B=Math.max(0,W-2),U=Math.min(G.length,W+3);J=G.slice(B,U).map((_,z)=>{let j=B+z+1;return`${j===Y?"> ":" "}${j}: ${_}`}).join(`
10076
10076
  `);break}}else if(X){let G=$.indexOf(X);if(G>=0)return g2($,G)}}catch{}return{lineNumber:Y,lineContent:Q,context:J}}function G0($,Z,X,Y,Q,J){let{lineNumber:G,context:K}=g2(Y,Q,J),W=X.split("/").pop(),B=0;if(typeof Q==="number"&&Q>=0&&Y){let _=Y.lastIndexOf(`
10077
10077
  `,Math.max(0,Q-1));B=Q-(_+1)+1}let U="";if(G>0)U+=`
@@ -10086,7 +10086,7 @@ ${t.yellow}${t.bold}Message:${t.reset} ${Z}
10086
10086
  `,K)U+=`
10087
10087
  ${t.blue}${t.bold}Context:${t.reset}
10088
10088
  ${t.dim}${K}${t.reset}
10089
- `;return U}function i7(){l7.clear()}var l7,Ez=0,t;var Q0=T(()=>{P1();T0();v1();n0();C1();R7();C2();V1();l7=new y$(500);t={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"}});async function k2($,Z,X=""){let Y=$,Q=[],J=/@markdown(?:\([^)]*\))?/g,G;while((G=J.exec($))!==null){let K=G.index,W=G[0].match(/@markdown\(([^)]*)\)/),B=W?W[1]:"",U=K+G[0].length,_=1,z=U,j=-1;while(_>0&&z<$.length){let L=$.indexOf("@markdown",z),F=$.indexOf("@endmarkdown",z);if(F===-1)break;if(L!==-1&&L<F&&L!==K){let O=$[L+9];if(O==="("||O===`
10089
+ `;return U}function i7(){l7.clear()}var l7,Ez=0,t;var Q0=T(()=>{P1();I0();v1();n0();C1();R7();C2();V1();l7=new y$(500);t={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"}});async function k2($,Z,X=""){let Y=$,Q=[],J=/@markdown(?:\([^)]*\))?/g,G;while((G=J.exec($))!==null){let K=G.index,W=G[0].match(/@markdown\(([^)]*)\)/),B=W?W[1]:"",U=K+G[0].length,_=1,z=U,j=-1;while(_>0&&z<$.length){let L=$.indexOf("@markdown",z),F=$.indexOf("@endmarkdown",z);if(F===-1)break;if(L!==-1&&L<F&&L!==K){let O=$[L+9];if(O==="("||O===`
10090
10090
  `||O==="\r"||O===" "||O===void 0)_++;z=L+9}else{if(_--,_===0){j=F;break}z=F+12}}if(j===-1)continue;let q=$.slice(U,j),H=$.slice(K,j+12);Q.push({fullMatch:H,options:B,content:q,index:K}),J.lastIndex=j+12}for(let{fullMatch:K,options:W,content:B,index:U}of Q)try{let _={};if(W)W.split(",").forEach((q)=>{let H=q.trim();if(H)_[H]=!0});let z={gfm:_.gfm??!0,breaks:_.breaks??!1},j=D$(B.trim(),z);Y=Y.split(K).join(j)}catch(_){let z=_ instanceof Error?_.message:String(_),j=G0("Markdown Directive",`Error processing markdown: ${z}`,X,$,U,K);Y=Y.split(K).join(j)}return Y}async function h2($,Z,X,Y){let Q={gfm:!0,breaks:!1};return Z.forEach((J)=>{let G=J.trim().replace(/['"]/g,"");if(G==="breaks")Q.breaks=!0;if(G==="no-gfm")Q.gfm=!1}),D$($.trim(),Q)}var c7=T(()=>{Q0()});function fz($){if(xz.set($.name,$),$.client)vz.set($.name,$.client)}function F$($){return fz($),{name:$.name,hasEndTag:$.hasEndTag??!0,description:$.description,handler:async(X,Y,Q,J)=>{let G=gz(Y,$.defaults);if($.validate){let W=$.validate(G);if(W!==!0){let B=typeof W==="string"?W:`Invalid parameters for @${$.name}`;throw Error(B)}}let K=X;if($.transform)K=await $.transform(X,G,Q,J);if($.clientScript){let W=$.clientScript(G);K+=`<script>${W}</script>`}if($.css){let W=$.css(G);K+=`<style>${W}</style>`}return K}}}function gz($,Z){let X={...Z};for(let Y of $){let Q=Y.indexOf(":"),J=Y.indexOf("="),G=Q>=0&&(J<0||Q<J)?Q:J;if(G>=0){let K=Y.slice(0,G).trim(),W=Y.slice(G+1).trim();if(W==="true")W=!0;else if(W==="false")W=!1;else if(W==="null")W=null;else if(!Number.isNaN(Number(W)))W=Number(W);else if(typeof W==="string"&&W.startsWith("{"))try{W=JSON.parse(W)}catch{}X[K]=W}else{let K=Object.keys(X).filter((W)=>!Z||!(W in Z)).length;X[K===0?"value":`arg${K}`]=Y}}return X}var xz,vz;var J5=T(()=>{xz=new Map,vz=new Map});function Q5($,Z=M1,X={},Y){return Z.sort((Q,J)=>Q-J).map((Q)=>{return`${o1($,{...X,w:Q,fm:Y})} ${Q}w`}).join(", ")}function n7($,Z,X=D3,Y={},Q){return X.sort((J,G)=>J-G).map((J)=>{let G=Math.round(Z*J);return`${o1($,{...Y,w:G,dpr:J,fm:Q})} ${J}x`}).join(", ")}function G5($,Z="100vw"){if(!$||Object.keys($).length===0)return Z;let Y=Object.entries($).map(([Q,J])=>{let G=/^\d+$/.test(Q)?`${Q}px`:Q;return{bp:G,size:J,numericBp:Number.parseInt(G)||0}}).sort((Q,J)=>Q.numericBp-J.numericBp).map(({bp:Q,size:J})=>`(max-width: ${Q}) ${J}`);return Y.push(Z),Y.join(", ")}function o1($,Z={}){let X=Object.entries(Z).filter(([,J])=>J!==void 0&&J!==null).map(([J,G])=>{if(Array.isArray(G))return[J,G.join(",")];return[J,String(G)]});if(X.length===0)return $;let Y=X.map(([J,G])=>`${J}=${encodeURIComponent(G)}`).join("&"),Q=$.includes("?")?"&":"?";return`${$}${Q}${Y}`}function K5($){return k3[$]||"application/octet-stream"}var M1,D3,s1,k3;var r7=T(()=>{M1=[320,480,640,768,1024,1280,1536,1920,2560],D3=[1,1.5,2,3],s1=["avif","webp","jpeg"],k3={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"}});async function hz(){try{return await import("ts-images")}catch{return null}}async function b3($,Z={}){let X={...C3,...Z},Y=await hz();if(Y)try{return await dz($,X,Y)}catch(Q){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${Q}`)}return uz($,X)}async function dz($,Z,X){let{generatePlaceholder:Y,generateThumbHash:Q}=X,G={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[Z.strategy]||"blur";if(Z.strategy==="thumbhash")return{dataURL:(await Q($)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let K=await Y($,{width:Z.width,height:Z.height,quality:Z.quality,blurLevel:Z.blurLevel,strategy:G,base64Encode:!0});return{dataURL:K.dataURL,width:K.width,height:K.height,aspectRatio:K.aspectRatio,originalWidth:K.originalWidth,originalHeight:K.originalHeight,strategy:Z.strategy,dominantColor:K.dominantColor,css:K.css}}function uz($,Z){let X=Z.width||20,Y=Z.height||X,Q="#e5e7eb",J=`<svg xmlns="http://www.w3.org/2000/svg" width="${X}" height="${Y}" viewBox="0 0 ${X} ${Y}"><rect fill="#e5e7eb" width="${X}" height="${Y}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(J)}`,width:X,height:Y,aspectRatio:X/Y,originalWidth:0,originalHeight:0,strategy:Z.strategy,dominantColor:"#e5e7eb"}}function s7($,Z,X={}){let Y=X.transitionDuration||300,Q=X.easing||"ease-out";return`
10091
10091
  #${$} {
10092
10092
  --stx-img-transition-duration: ${Y}ms;
@@ -10133,8 +10133,8 @@ ${t.dim}${K}${t.reset}
10133
10133
  filter: blur(0);
10134
10134
  transform: scale(1);
10135
10135
  }
10136
- `.trim();S3=new Map});import{createHash as d2}from"crypto";import{readFile as mz,stat as u2}from"fs/promises";async function w0($){try{let Z=await mz($);return d2("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function y3($){return d2("sha256").update($).digest("hex").slice(0,16)}function U5($,Z){let X=JSON.stringify(Z,Object.keys(Z).sort());return`${y3($)}-${y3(X)}`}async function a7($){try{return(await u2($)).mtimeMs}catch{return 0}}async function A0($){try{return await u2($),!0}catch{return!1}}var T1=()=>{};import{mkdir as pz,readFile as cz,writeFile as lz,readdir as FR,rm as iz,stat as VR}from"fs/promises";import{join as p2,dirname as nz}from"path";async function rz($){try{await pz($,{recursive:!0})}catch{}}function c2($,Z,X){return p2($,X,`${Z}.json`)}async function m2($,Z,X){if((Date.now()-$.createdAt)/86400000>X)return!1;if(await a7(Z)!==$.srcMtime)return!1;return!0}async function B5($,Z,X,Y=x3){if(!Y.enabled)return null;let Q=U5($,Z),J=V$.get(Q);if(J){if(await m2(J,$,Y.maxAge))return J.lastAccessedAt=Date.now(),J.data;V$.delete(Q)}let G=c2(Y.directory,Q,X);if(await A0(G))try{let K=await cz(G,"utf-8"),W=JSON.parse(K);if(await m2(W,$,Y.maxAge))return W.lastAccessedAt=Date.now(),V$.set(Q,W),W.data}catch{}return null}async function _5($,Z,X,Y,Q=x3){if(!Q.enabled)return;let J=U5($,Z),G=await w0($),K=await a7($),W={key:J,src:$,srcHash:G,srcMtime:K,optionsHash:U5("",Z),data:X,createdAt:Date.now(),lastAccessedAt:Date.now()};V$.set(J,W);let B=c2(Q.directory,J,Y);try{await rz(nz(B)),await lz(B,JSON.stringify(W,null,2))}catch(U){console.warn(`[stx-media] Failed to write cache: ${U}`)}}async function z5($,Z=x3){if($==="all")V$.clear();else V$.clear();let X=$==="all"?["image","video"]:[$];for(let Y of X){let Q=p2(Z.directory,Y);try{await iz(Q,{recursive:!0,force:!0})}catch{}}}var V$,x3;var t7=T(()=>{T1();V$=new Map,x3={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class q5{config;constructor($={}){this.config={...sz,...$}}async get($,Z){return B5($,Z,"image",this.config)}async set($,Z,X){return _5($,Z,X,"image",this.config)}async clear(){return z5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function v3($){if(!e7)e7=new q5($);else if($)e7.updateConfig($);return e7}async function j5($,Z,X){let Y=X?{directory:`${X.outputDir}/../.cache`}:{};return v3(Y).get($,Z)}async function H5($,Z,X,Y){let Q=Y?{directory:`${Y.outputDir}/../.cache`}:{};return v3(Q).set($,Z,X)}async function f3(){return v3().clear()}var sz,e7=null;var g3=T(()=>{t7();sz={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as oz,basename as az,extname as tz,join as ez}from"path";import{mkdir as $q}from"fs/promises";async function h3(){try{return await import("ts-images")}catch{return null}}function l2($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function Zq($,Z){let X=Z?l2(Z):l2("web"),Y=$.formatQuality||{};return{jpeg:{...X.jpeg,...Y.jpeg},png:{...X.png,...Y.png},webp:{...X.webp,...Y.webp},avif:{...X.avif,...Y.avif}}}async function d3($,Z,X){let Y=await h3();if(!Y)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Q=await j5($,Z,X);if(Q)return Q;try{let J=oz($);if(!await A0(J))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=Zq(X,Z.preset),K=X.outputDir||"dist/images",W=X.baseUrl||"/images";await $q(K,{recursive:!0});let B=await w0(J),U=az($,tz($)),_=Z.outputFormat?[Z.outputFormat]:X.defaultFormats||["avif","webp","jpeg"],z={src:$,processed:!0,variants:[],hash:B},j=null;if(Z.transformations&&Z.transformations.length>0)j=await $4(J,Z.transformations,Y);for(let q of _){let H=G[q]||{},L=`${U}-${B}.${q}`,F=ez(K,L);try{let O=await Y.optimizeImage({input:j||J,output:F,format:q,quality:H.quality,progressive:H.progressive});if(O){if(z.variants.push({path:F,url:`${W}/${L}`,width:O.width||0,height:O.height||0,format:q,size:O.outputSize||0}),!z.originalWidth&&O.width)z.originalWidth=O.width,z.originalHeight=O.height}}catch(O){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${q}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let q=await Y.generateThumbHash(J);z.placeholder=q.dataUrl}catch(q){z.errors=z.errors||[],z.errors.push(`Failed to generate thumbhash: ${q}`)}if(Z.useDominantColor)try{let q=await Y.generatePlaceholder(J,{strategy:"dominant-color"});z.dominantColor=q.dominantColor}catch(q){z.errors=z.errors||[],z.errors.push(`Failed to extract dominant color: ${q}`)}return await H5($,Z,z,X),z}catch(J){return{src:$,processed:!1,errors:[`Processing failed: ${J}`]}}}async function u3($,Z,X,Y){let Q=await h3();if(!Q)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Q.optimizeImage({input:$,output:Y,format:Z,quality:X}))?.outputSize}}catch(J){return{success:!1,error:String(J)}}}async function $4($,Z,X){let Y=X||await h3();if(!Y)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Q=await Y.decode($);for(let J of Z){let G=J.options||{};switch(J.type){case"resize":if(G.width||G.height)Q=await Y.resize(Q,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Q=await Y.blur(Q,G.sigma);break;case"sharpen":if(G.amount!==void 0)Q=await Y.sharpen(Q,G.amount);break;case"grayscale":Q=await Y.grayscale(Q);break;case"rotate":if(G.angle!==void 0)Q=await Y.rotate(Q,G.angle);break;case"flip":Q=await Y.flip(Q);break;case"flop":Q=await Y.flop(Q);break;case"brightness":if(G.value!==void 0)Q=await Y.brightness(Q,G.value);break;case"contrast":if(G.value!==void 0)Q=await Y.contrast(Q,G.value);break;case"saturation":if(G.value!==void 0)Q=await Y.saturation(Q,G.value);break}}return await Y.encode(Q,"png")}catch(Q){return console.error(`[stx-media] Transformation failed: ${Q}`),null}}var i2=T(()=>{T1();g3()});import{resolve as Xq,basename as Yq,extname as Jq,join as Qq}from"path";import{mkdir as Gq}from"fs/promises";async function Kq(){try{return await import("ts-images")}catch{return null}}async function m3($,Z,X){let Y=await Kq();if(!Y)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Q=Xq($);if(!await A0(Q))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let J=Z.responsiveWidths||X.breakpoints||Wq,G=Z.formats||X.defaultFormats||["avif","webp","jpeg"],K=X.outputDir||"dist/images",W=X.baseUrl||"/images";await Gq(K,{recursive:!0});let B=await w0(Q),U=Yq($,Jq($)),_=X.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},z={src:$,byFormat:{},srcsets:{}};for(let q of G){z.byFormat[q]=[];let H=[];for(let L of J){let F=`${U}-${L}w-${B}.${q}`,O=Qq(K,F),V=`${W}/${F}`;try{let A=_[q]?.quality||80;if(await A0(O)){z.byFormat[q].push({path:O,url:V,width:L,height:0,format:q,size:0}),H.push(`${V} ${L}w`);continue}let N=await Y.processImage({input:Q,output:O,format:q,quality:A,resize:{width:L}});if(N)z.byFormat[q].push({path:O,url:V,width:L,height:N.height||Math.round(L*(N.height||1)/(N.width||1)),format:q,size:N.outputSize||0}),H.push(`${V} ${L}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${q} at ${L}w: ${A}`)}}z.srcsets[q]=H.join(", ")}let j=Z.placeholder||X.placeholderStrategy||"thumbhash";if(j!=="none")try{if(j==="thumbhash"){let q=await Y.generateThumbHash(Q);z.placeholder={dataURL:q.dataUrl,width:q.width||32,height:q.height||32,strategy:"thumbhash"}}else{let q=await Y.generatePlaceholder(Q,{strategy:j,width:20});z.placeholder={dataURL:q.dataURL,width:q.width,height:q.height,strategy:j}}}catch(q){console.warn(`[stx-media] Failed to generate placeholder: ${q}`)}return z.sizes=Z.sizes||Uq(J),z}catch(J){return console.error(`[stx-media] Responsive generation failed: ${J}`),null}}function Uq($){let Z=[...$].sort((Y,Q)=>Y-Q),X=[];for(let Y=0;Y<Z.length-1;Y++){let Q=Z[Y];X.push(`(max-width: ${Q}px) ${Q}px`)}return X.push(`${Z[Z.length-1]}px`),X.join(", ")}function p3($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((X)=>X.dpr).map((X)=>`${X.url} ${X.dpr}x`).join(", ");return $.map((X)=>`${X.url} ${X.width}w`).join(", ")}var Wq;var n2=T(()=>{T1();Wq=[320,480,640,768,1024,1280,1536,1920]});var r2={};a(r2,{setCachedImageResult:()=>H5,processImage:()=>d3,optimizeImage:()=>u3,getCachedImageResult:()=>j5,generateSrcset:()=>p3,generateResponsiveVariants:()=>m3,clearImageCache:()=>f3,applyTransformations:()=>$4,ImageProcessorCache:()=>q5});var c3=T(()=>{i2();n2();g3()});async function Bq(){try{return await Promise.resolve().then(() => (c3(),r2))}catch($){if(!s2)console.warn("[stx-media] Image processor not available, some features disabled:",$),s2=!0;return null}}async function N$($,Z={}){let X=Z,Y=$;if(Y.process&&!Y.skipOptimization){if(X.tsImagesConfig?.enabled&&!X.isDev)return jq(Y,X)}if(X.processedResult?.processed)return r3($,X.processedResult,Z);if(X.responsiveVariants)return e2($,X.responsiveVariants,Z);let{src:Q,alt:J,width:G,height:K,sizes:W,widths:B=M1,dpr:U,formats:_=s1,quality:z=l3,params:j={},placeholder:q="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":X4,decoding:V=Z4,fetchpriority:A,objectFit:N,objectPosition:w,crossorigin:R,referrerpolicy:M}=$,I=$.class,E=$.style,D=$.id,k=$.data||{},{isDev:P=!1,baseUrl:S=""}=Z;if(P&&!Z.optimize)return qq($);let C,y,m=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(q!=="none"&&!F)try{C=await o7(Q,{strategy:q,...H}),y=s7(m,C,H)}catch{}let g=U!==void 0&&G!==void 0,p;if(g)p=zq($,m,C,Z);else p=await _q($,m,C,Z);let s;if(F){let v0=_.includes("webp")?"webp":_[0],S0=Q5(Q,B,{...j,q:z},v0),$0=typeof W==="object"?G5(W):W||"100vw";s=`<link rel="preload" as="image" imagesrcset="${S0}" imagesizes="${$0}" />`}let M0=[];if(!o2&&q!=="none")M0.push(W5),o2=!0;if(y)M0.push(y);let Y1=L?t2(m):void 0;return{html:p,preloadLink:s,css:M0.length>0?M0.join(`
10137
- `):void 0,script:Y1}}async function _q($,Z,X,Y){let{src:Q,alt:J,width:G,height:K,sizes:W,widths:B=M1,formats:U=s1,quality:_=l3,params:z={},lazy:j=!0,priority:q=!1,loading:H=q?"eager":X4,decoding:L=Z4,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:A,referrerpolicy:N}=$,w=$.class,R=$.style,M=$.data||{},I=typeof W==="object"?G5(W):W||"100vw",E=[];for(let P of U){let S=Q5(Q,B,{...z,q:_},P),C=K5(P);if(j&&!q)E.push(` <source type="${C}" data-srcset="${S}" data-sizes="${I}" />`);else E.push(` <source type="${C}" srcset="${S}" sizes="${I}" />`)}let D=i3({src:o1(Q,{...z,q:_}),alt:J,width:G,height:K,loading:q?void 0:H,decoding:L,fetchpriority:q?"high":F,objectFit:O,objectPosition:V,crossorigin:A,referrerpolicy:N,className:a2(w,X),style:n3(R,O,V,X),lazy:j&&!q,data:M}),k;if(X){let P=`background-image: url('${X.dataURL}'); background-size: cover; background-position: center;`;k=`<div id="${Z}" class="stx-img-placeholder" style="${P}">
10136
+ `.trim();S3=new Map});import{createHash as d2}from"crypto";import{readFile as mz,stat as u2}from"fs/promises";async function w0($){try{let Z=await mz($);return d2("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function y3($){return d2("sha256").update($).digest("hex").slice(0,16)}function U5($,Z){let X=JSON.stringify(Z,Object.keys(Z).sort());return`${y3($)}-${y3(X)}`}async function a7($){try{return(await u2($)).mtimeMs}catch{return 0}}async function A0($){try{return await u2($),!0}catch{return!1}}var T1=()=>{};import{mkdir as pz,readFile as cz,writeFile as lz,readdir as FR,rm as iz,stat as VR}from"fs/promises";import{join as p2,dirname as nz}from"path";async function rz($){try{await pz($,{recursive:!0})}catch{}}function c2($,Z,X){return p2($,X,`${Z}.json`)}async function m2($,Z,X){if((Date.now()-$.createdAt)/86400000>X)return!1;if(await a7(Z)!==$.srcMtime)return!1;return!0}async function B5($,Z,X,Y=x3){if(!Y.enabled)return null;let Q=U5($,Z),J=V$.get(Q);if(J){if(await m2(J,$,Y.maxAge))return J.lastAccessedAt=Date.now(),J.data;V$.delete(Q)}let G=c2(Y.directory,Q,X);if(await A0(G))try{let K=await cz(G,"utf-8"),W=JSON.parse(K);if(await m2(W,$,Y.maxAge))return W.lastAccessedAt=Date.now(),V$.set(Q,W),W.data}catch{}return null}async function _5($,Z,X,Y,Q=x3){if(!Q.enabled)return;let J=U5($,Z),G=await w0($),K=await a7($),W={key:J,src:$,srcHash:G,srcMtime:K,optionsHash:U5("",Z),data:X,createdAt:Date.now(),lastAccessedAt:Date.now()};V$.set(J,W);let B=c2(Q.directory,J,Y);try{await rz(nz(B)),await lz(B,JSON.stringify(W,null,2))}catch(U){console.warn(`[stx-media] Failed to write cache: ${U}`)}}async function z5($,Z=x3){if($==="all")V$.clear();else V$.clear();let X=$==="all"?["image","video"]:[$];for(let Y of X){let Q=p2(Z.directory,Y);try{await iz(Q,{recursive:!0,force:!0})}catch{}}}var V$,x3;var t7=T(()=>{T1();V$=new Map,x3={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class q5{config;constructor($={}){this.config={...sz,...$}}async get($,Z){return B5($,Z,"image",this.config)}async set($,Z,X){return _5($,Z,X,"image",this.config)}async clear(){return z5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function v3($){if(!e7)e7=new q5($);else if($)e7.updateConfig($);return e7}async function j5($,Z,X){let Y=X?{directory:`${X.outputDir}/../.cache`}:{};return v3(Y).get($,Z)}async function H5($,Z,X,Y){let Q=Y?{directory:`${Y.outputDir}/../.cache`}:{};return v3(Q).set($,Z,X)}async function f3(){return v3().clear()}var sz,e7=null;var g3=T(()=>{t7();sz={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as oz,basename as az,extname as tz,join as ez}from"path";import{mkdir as $q}from"fs/promises";async function h3(){try{return await import("ts-images")}catch{return null}}function l2($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function Zq($,Z){let X=Z?l2(Z):l2("web"),Y=$.formatQuality||{};return{jpeg:{...X.jpeg,...Y.jpeg},png:{...X.png,...Y.png},webp:{...X.webp,...Y.webp},avif:{...X.avif,...Y.avif}}}async function d3($,Z,X){let Y=await h3();if(!Y)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Q=await j5($,Z,X);if(Q)return Q;try{let J=oz($);if(!await A0(J))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=Zq(X,Z.preset),K=X.outputDir||"dist/images",W=X.baseUrl||"/images";await $q(K,{recursive:!0});let B=await w0(J),U=az($,tz($)),_=Z.outputFormat?[Z.outputFormat]:X.defaultFormats||["avif","webp","jpeg"],z={src:$,processed:!0,variants:[],hash:B},j=null;if(Z.transformations&&Z.transformations.length>0)j=await $4(J,Z.transformations,Y);for(let q of _){let H=G[q]||{},L=`${U}-${B}.${q}`,F=ez(K,L);try{let O=await Y.optimizeImage({input:j||J,output:F,format:q,quality:H.quality,progressive:H.progressive});if(O){if(z.variants.push({path:F,url:`${W}/${L}`,width:O.width||0,height:O.height||0,format:q,size:O.outputSize||0}),!z.originalWidth&&O.width)z.originalWidth=O.width,z.originalHeight=O.height}}catch(O){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${q}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let q=await Y.generateThumbHash(J);z.placeholder=q.dataUrl}catch(q){z.errors=z.errors||[],z.errors.push(`Failed to generate thumbhash: ${q}`)}if(Z.useDominantColor)try{let q=await Y.generatePlaceholder(J,{strategy:"dominant-color"});z.dominantColor=q.dominantColor}catch(q){z.errors=z.errors||[],z.errors.push(`Failed to extract dominant color: ${q}`)}return await H5($,Z,z,X),z}catch(J){return{src:$,processed:!1,errors:[`Processing failed: ${J}`]}}}async function u3($,Z,X,Y){let Q=await h3();if(!Q)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Q.optimizeImage({input:$,output:Y,format:Z,quality:X}))?.outputSize}}catch(J){return{success:!1,error:String(J)}}}async function $4($,Z,X){let Y=X||await h3();if(!Y)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Q=await Y.decode($);for(let J of Z){let G=J.options||{};switch(J.type){case"resize":if(G.width||G.height)Q=await Y.resize(Q,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Q=await Y.blur(Q,G.sigma);break;case"sharpen":if(G.amount!==void 0)Q=await Y.sharpen(Q,G.amount);break;case"grayscale":Q=await Y.grayscale(Q);break;case"rotate":if(G.angle!==void 0)Q=await Y.rotate(Q,G.angle);break;case"flip":Q=await Y.flip(Q);break;case"flop":Q=await Y.flop(Q);break;case"brightness":if(G.value!==void 0)Q=await Y.brightness(Q,G.value);break;case"contrast":if(G.value!==void 0)Q=await Y.contrast(Q,G.value);break;case"saturation":if(G.value!==void 0)Q=await Y.saturation(Q,G.value);break}}return await Y.encode(Q,"png")}catch(Q){return console.error(`[stx-media] Transformation failed: ${Q}`),null}}var i2=T(()=>{T1();g3()});import{resolve as Xq,basename as Yq,extname as Jq,join as Qq}from"path";import{mkdir as Gq}from"fs/promises";async function Kq(){try{return await import("ts-images")}catch{return null}}async function m3($,Z,X){let Y=await Kq();if(!Y)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Q=Xq($);if(!await A0(Q))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let J=Z.responsiveWidths||X.breakpoints||Wq,G=Z.formats||X.defaultFormats||["avif","webp","jpeg"],K=X.outputDir||"dist/images",W=X.baseUrl||"/images";await Gq(K,{recursive:!0});let B=await w0(Q),U=Yq($,Jq($)),_=X.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},z={src:$,byFormat:{},srcsets:{}};for(let q of G){z.byFormat[q]=[];let H=[];for(let L of J){let F=`${U}-${L}w-${B}.${q}`,O=Qq(K,F),V=`${W}/${F}`;try{let A=_[q]?.quality||80;if(await A0(O)){z.byFormat[q].push({path:O,url:V,width:L,height:0,format:q,size:0}),H.push(`${V} ${L}w`);continue}let N=await Y.processImage({input:Q,output:O,format:q,quality:A,resize:{width:L}});if(N)z.byFormat[q].push({path:O,url:V,width:L,height:N.height||Math.round(L*(N.height||1)/(N.width||1)),format:q,size:N.outputSize||0}),H.push(`${V} ${L}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${q} at ${L}w: ${A}`)}}z.srcsets[q]=H.join(", ")}let j=Z.placeholder||X.placeholderStrategy||"thumbhash";if(j!=="none")try{if(j==="thumbhash"){let q=await Y.generateThumbHash(Q);z.placeholder={dataURL:q.dataUrl,width:q.width||32,height:q.height||32,strategy:"thumbhash"}}else{let q=await Y.generatePlaceholder(Q,{strategy:j,width:20});z.placeholder={dataURL:q.dataURL,width:q.width,height:q.height,strategy:j}}}catch(q){console.warn(`[stx-media] Failed to generate placeholder: ${q}`)}return z.sizes=Z.sizes||Uq(J),z}catch(J){return console.error(`[stx-media] Responsive generation failed: ${J}`),null}}function Uq($){let Z=[...$].sort((Y,Q)=>Y-Q),X=[];for(let Y=0;Y<Z.length-1;Y++){let Q=Z[Y];X.push(`(max-width: ${Q}px) ${Q}px`)}return X.push(`${Z[Z.length-1]}px`),X.join(", ")}function p3($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((X)=>X.dpr).map((X)=>`${X.url} ${X.dpr}x`).join(", ");return $.map((X)=>`${X.url} ${X.width}w`).join(", ")}var Wq;var n2=T(()=>{T1();Wq=[320,480,640,768,1024,1280,1536,1920]});var r2={};a(r2,{setCachedImageResult:()=>H5,processImage:()=>d3,optimizeImage:()=>u3,getCachedImageResult:()=>j5,generateSrcset:()=>p3,generateResponsiveVariants:()=>m3,clearImageCache:()=>f3,applyTransformations:()=>$4,ImageProcessorCache:()=>q5});var c3=T(()=>{i2();n2();g3()});async function Bq(){try{return await Promise.resolve().then(() => (c3(),r2))}catch($){if(!s2)console.warn("[stx-media] Image processor not available, some features disabled:",$),s2=!0;return null}}async function N$($,Z={}){let X=Z,Y=$;if(Y.process&&!Y.skipOptimization){if(X.tsImagesConfig?.enabled&&!X.isDev)return jq(Y,X)}if(X.processedResult?.processed)return r3($,X.processedResult,Z);if(X.responsiveVariants)return e2($,X.responsiveVariants,Z);let{src:Q,alt:J,width:G,height:K,sizes:W,widths:B=M1,dpr:U,formats:_=s1,quality:z=l3,params:j={},placeholder:q="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":X4,decoding:V=Z4,fetchpriority:A,objectFit:N,objectPosition:w,crossorigin:R,referrerpolicy:M}=$,I=$.class,E=$.style,D=$.id,k=$.data||{},{isDev:P=!1,baseUrl:S=""}=Z;if(P&&!Z.optimize)return qq($);let b,y,m=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(q!=="none"&&!F)try{b=await o7(Q,{strategy:q,...H}),y=s7(m,b,H)}catch{}let g=U!==void 0&&G!==void 0,p;if(g)p=zq($,m,b,Z);else p=await _q($,m,b,Z);let s;if(F){let v0=_.includes("webp")?"webp":_[0],C0=Q5(Q,B,{...j,q:z},v0),$0=typeof W==="object"?G5(W):W||"100vw";s=`<link rel="preload" as="image" imagesrcset="${C0}" imagesizes="${$0}" />`}let M0=[];if(!o2&&q!=="none")M0.push(W5),o2=!0;if(y)M0.push(y);let Y1=L?t2(m):void 0;return{html:p,preloadLink:s,css:M0.length>0?M0.join(`
10137
+ `):void 0,script:Y1}}async function _q($,Z,X,Y){let{src:Q,alt:J,width:G,height:K,sizes:W,widths:B=M1,formats:U=s1,quality:_=l3,params:z={},lazy:j=!0,priority:q=!1,loading:H=q?"eager":X4,decoding:L=Z4,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:A,referrerpolicy:N}=$,w=$.class,R=$.style,M=$.data||{},I=typeof W==="object"?G5(W):W||"100vw",E=[];for(let P of U){let S=Q5(Q,B,{...z,q:_},P),b=K5(P);if(j&&!q)E.push(` <source type="${b}" data-srcset="${S}" data-sizes="${I}" />`);else E.push(` <source type="${b}" srcset="${S}" sizes="${I}" />`)}let D=i3({src:o1(Q,{...z,q:_}),alt:J,width:G,height:K,loading:q?void 0:H,decoding:L,fetchpriority:q?"high":F,objectFit:O,objectPosition:V,crossorigin:A,referrerpolicy:N,className:a2(w,X),style:n3(R,O,V,X),lazy:j&&!q,data:M}),k;if(X){let P=`background-image: url('${X.dataURL}'); background-size: cover; background-position: center;`;k=`<div id="${Z}" class="stx-img-placeholder" style="${P}">
10138
10138
  <picture>
10139
10139
  ${E.join(`
10140
10140
  `)}
@@ -10193,7 +10193,7 @@ ${N.join(`
10193
10193
  ${N.join(`
10194
10194
  `)}
10195
10195
  <img ${R.join(" ")} />
10196
- </picture>`;let P=[];if(Z.placeholder)P.push(W5);let S=G?t2(q):void 0,C;if(K&&V)C=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:k,preloadLink:C,css:P.length>0?P.join(`
10196
+ </picture>`;let P=[];if(Z.placeholder)P.push(W5);let S=G?t2(q):void 0,b;if(K&&V)b=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:k,preloadLink:b,css:P.length>0?P.join(`
10197
10197
  `):void 0,script:S}}async function e2($,Z,X){let Y={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[Q,J]of Object.entries(Z.byFormat))if(J)Y.variants.push(...J);return r3($,Y,X)}var s2=!1,l3=80,Z4="async",X4="lazy",o2=!1;var s3=T(()=>{r7();P3()});function a3(){return F$({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,X,Y)=>{let{src:Q,alt:J,options:G}=Hq($,Z,X);if(!Q)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:Q,alt:J||"",widths:G.widths||M1,formats:G.formats||s1,quality:G.quality,sizes:G.sizes,dpr:G.dpr,params:G.params,placeholder:G.placeholder,placeholderOptions:G.placeholderOptions,lazy:G.lazy!==!1,priority:G.priority||!1,loading:G.loading,decoding:G.decoding,fetchpriority:G.fetchpriority,objectFit:G.objectFit,objectPosition:G.objectPosition,class:G.class,style:G.style,id:G.id,width:G.width,height:G.height},W=X.__isDev||!1,B=await N$(K,{isDev:W}),U=B.html;if(B.preloadLink)U=B.preloadLink+`
10198
10198
  `+U;if(B.css)U+=`
10199
10199
  <style>${B.css}</style>`;if(B.script)U+=`
@@ -10228,7 +10228,7 @@ ${N.join(`
10228
10228
  `),S=`<video ${k.join(" ")}>
10229
10229
  ${P}
10230
10230
  Your browser does not support the video tag.
10231
- </video>`,C;if(H)C=`
10231
+ </video>`,b;if(H)b=`
10232
10232
  (function() {
10233
10233
  var video = document.getElementById('${E}');
10234
10234
  if (!video) return;
@@ -10263,7 +10263,7 @@ ${P}
10263
10263
 
10264
10264
  observer.observe(video);
10265
10265
  })();
10266
- `.trim();return{html:S,script:C}}function Dq($,Z,X){let{width:Y=640,height:Q=360}=X,J=X.class,G=X.style,K=X.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,W,B=null;switch(Z){case"youtube":B=Sq($),W=B?`https://www.youtube-nocookie.com/embed/${B}`:$;break;case"vimeo":B=Cq($),W=B?`https://player.vimeo.com/video/${B}`:$;break;case"dailymotion":B=$.split("/").pop()||"",W=`https://www.dailymotion.com/embed/video/${B}`;break;case"twitch":B=$.split("/").pop()||"",W=`https://player.twitch.tv/?video=${B}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:W=$}let U=[`id="${K}"`,`src="${F0(W)}"`,`width="${Y}"`,`height="${Q}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(J)U.push(`class="${F0(J)}"`);if(G)U.push(`style="${F0(G)}"`);if(X.lazy)U.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
10266
+ `.trim();return{html:S,script:b}}function Dq($,Z,X){let{width:Y=640,height:Q=360}=X,J=X.class,G=X.style,K=X.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,W,B=null;switch(Z){case"youtube":B=Sq($),W=B?`https://www.youtube-nocookie.com/embed/${B}`:$;break;case"vimeo":B=Cq($),W=B?`https://player.vimeo.com/video/${B}`:$;break;case"dailymotion":B=$.split("/").pop()||"",W=`https://www.dailymotion.com/embed/video/${B}`;break;case"twitch":B=$.split("/").pop()||"",W=`https://player.twitch.tv/?video=${B}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:W=$}let U=[`id="${K}"`,`src="${F0(W)}"`,`width="${Y}"`,`height="${Q}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(J)U.push(`class="${F0(J)}"`);if(G)U.push(`style="${F0(G)}"`);if(X.lazy)U.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
10267
10267
  <iframe ${U.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
10268
10268
  </div>`}}function kq($,Z={}){let{src:X,sources:Y=[],poster:Q,controls:J=!0,autoplay:G=!1,muted:K=!1,loop:W=!1,preload:B="metadata",playsinline:U=!0,lazy:_=!0,width:z,height:j}=$,q=$.class,H=$.style,L=$.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,F={src:Y.length>0?Y:X,autoplay:G,loop:W,muted:K,playsinline:U,preload:B,poster:Q,controls:J,title:$.title},O=["position: relative",z?`width: ${typeof z==="number"?z+"px":z}`:"width: 100%",j?`height: ${typeof j==="number"?j+"px":j}`:"",H||""].filter(Boolean).join("; "),V=`
10269
10269
  <div
@@ -11066,7 +11066,7 @@ ${U}
11066
11066
  customElements.define('${Z}', ${G});
11067
11067
  `}async function A9($,Z,X,Y){if(Z.length<1)return r("WebComponent","@webcomponent directive requires at least the tag name parameter",n.INVALID_DIRECTIVE_SYNTAX);let Q=Z[0].replace(/['"]/g,""),G=(X.__stx_options||{}).componentsDir||"components",K=[I1.join(I1.dirname(Y),G,`${Q}.stx`),I1.join(process.cwd(),G,`${Q}.stx`),I1.join(I1.dirname(Y),`${Q}.stx`)],W=null;for(let _ of K)if(await l(_)){W=await Bun.file(_).text();break}if(!W)return r("WebComponent",`Component file not found: ${Q}.stx`,n.FILE_NOT_FOUND);let B=rq(W,Q);return`<script type="module">
11068
11068
  ${sq(B)}
11069
- </script>`}var H8=T(()=>{d0();Q0()});var R9={};a(R9,{timingPlugin:()=>eq,pluginManager:()=>w9,definePlugin:()=>M5,debugPlugin:()=>tq,createVariablesPlugin:()=>$j,createFilterPlugin:()=>aq,createDirectivePlugin:()=>oq,PluginManager:()=>O8});function M5($){return $}class O8{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let X of $.dependencies)if(!this.plugins.has(X))throw Error(`Plugin "${$.name}" depends on "${X}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[X,Y]of this.plugins)if(Y.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${X}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let X=await Z.onError($);if(X){if(X.template!==void 0)$.template=X.template;if(X.context)$.context={...$.context,...X.context};if(X.metadata)$.metadata={...$.metadata,...X.metadata};if(X.skip)return $}}catch(X){console.error(`Error in plugin "${Z.name}" onError hook:`,X)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let X={...Z};for(let Y of this.sortedPlugins){let Q=Y[$];if(Q)try{let J=await Q(X);if(J){if(J.template!==void 0)X.template=J.template;if(J.context)X.context={...X.context,...J.context};if(J.metadata)X.metadata={...X.metadata,...J.metadata};if(J.skip)break}}catch(J){console.error(`Error in plugin "${Y.name}" ${$} hook:`,J)}}return X}async runDirectiveHooks($,Z,X){let Y={...X};for(let Q of this.sortedPlugins){let J=Q[$];if(J)try{let G=await J(Z,Y);if(G){if(G.template!==void 0)Y.template=G.template;if(G.context)Y.context={...Y.context,...G.context};if(G.metadata)Y.metadata={...Y.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Q.name}" ${$} hook:`,G)}}return Y}}function oq($,Z,X={}){return{name:$,...X,registerDirectives:()=>Z}}function aq($,Z,X={}){return{name:$,...X,registerFilters:()=>Z}}function $j($){return M5({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var w9,tq,eq;var L8=T(()=>{w9=new O8;tq=M5({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),eq=M5({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let X=performance.now()-Z;console.log(`[stx-timing] Processing took ${X.toFixed(2)}ms`)}}})});var xZ={};a(xZ,{validateConfig:()=>Jj,loadStxConfig:()=>Z1,defineStxConfig:()=>Yj,defaultConfig:()=>e0,config:()=>E1});import F8 from"fs";import k0 from"path";import{loadConfigWithResult as Zj}from"bunfig";function Xj($,Z){let X=Z||"pages";if($)return{root:$,pagesDir:X};let Y=k0.join(process.cwd(),"resources","views"),Q=k0.join(process.cwd(),"resources","layouts");if(F8.existsSync(Y)&&F8.existsSync(Q))return{root:"resources",pagesDir:"views"};let J=k0.join(process.cwd(),"resources","views","pages");if(F8.existsSync(J))return{root:"resources/views",pagesDir:X};return{root:".",pagesDir:X}}async function Z1($){if(!$){if(A$)return A$;if(U4)return U4}let Z=$?k0.resolve($):process.cwd(),X=M9.get(Z);if(X)return X;let Y=(async()=>{let J=(await Zj({name:"stx",alias:"ui",cwd:Z,defaultConfig:e0,verbose:!1})).config,G=Xj(J.root,J.pagesDir);if(J.root=G.root,J.pagesDir=G.pagesDir,J.root&&J.root!=="."){let K=J.root;if(J.partialsDir&&!k0.isAbsolute(J.partialsDir))J.partialsDir=k0.join(K,J.partialsDir);if(J.componentsDir&&!k0.isAbsolute(J.componentsDir))J.componentsDir=k0.join(K,J.componentsDir);if(J.layoutsDir&&!k0.isAbsolute(J.layoutsDir))J.layoutsDir=k0.join(K,J.layoutsDir)}if(J.plugins&&J.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (L8(),R9)),W=[],B=[];for(let U of J.plugins){let _=typeof U==="string"?U:U[0],z=typeof U==="string"?{}:U[1]||{};try{let j,q;try{j=await import(_),q=k0.dirname(K0.resolve(_))}catch{let L=k0.resolve(process.cwd(),_);j=await import(L),q=k0.dirname(L)}let H=j.default||j;if(K.register(H,J),H.components){let L=k0.resolve(q,H.components);W.push(L)}if(H.pages){let L=k0.resolve(q,H.pages),F=z.path||"/";B.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{J.customDirectives=J.customDirectives||[],J.customDirectives.push(F)},addRoute:(F,O)=>{J.apiRoutes=J.apiRoutes||{},J.apiRoutes[F]=O},addMiddleware:(F)=>{J.middleware=J.middleware||[],J.middleware.push(F)},pluginDir:q,config:J};await H.setup(z,L)}console.log(`[stx] Plugin loaded: ${H.name||_}`)}catch(j){console.warn(`[stx] Failed to load plugin ${_}:`,j.message)}}J._pluginComponentDirs=W,J._pluginPageDirs=B}return J})();if(M9.set(Z,Y),!$)U4=Y,Y.then((Q)=>{A$=Q}).catch(()=>{});return Y}function Yj($){return $}function Jj($){let Z=[],X=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let Y=["auto","manual","sections"];if(!Y.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let Y=["json","yaml","yml","js"];if(!Y.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let Y=["AA","AAA"];if(!Y.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let Y=["progressive","islands"];if(!Y.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${Y.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let Y=["none","eager","lazy"];if(!Y.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((Y,Q)=>{if(!Y.name||typeof Y.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!Y.handler||typeof Y.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((Y,Q)=>{if(!Y.name||typeof Y.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!Y.handler||typeof Y.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!Y.timing||!["before","after"].includes(Y.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)X.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)X.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let Y=["fullscreen","standalone","minimal-ui","browser"];if(!Y.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${Y.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let Y=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!Y.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${Y.join(", ")}`,severity:"error"})}if($.pwa.routes){let Y=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Q,J)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${J}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!Y.includes(Q.strategy))Z.push({path:`pwa.routes[${J}].strategy`,message:`PWA route strategy must be one of: ${Y.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${J}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${J}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let Y=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((J)=>!Y.includes(J)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${Y.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)X.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)X.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:X}}var e0,A$=null,M9,U4=null,E1;var I0=T(()=>{y5();x5();A4();v5();c7();t3();j8();V9();N7();H8();e0={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:h2,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:A9,hasEndTag:!1,description:"Include a web component in the template"},r8,s8,vY,fY,o8,t8,e8,a8,YZ,GZ,Y4,W4,...F9],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{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],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},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}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};M9=new Map;E1=new Proxy(e0,{get($,Z){if(A$&&Z in A$)return A$[Z];if(!U4)Z1().catch((X)=>{console.warn("[stx] Failed to load config file:",X?.message||X)});return $[Z]}})});import Qj from"fs";import V8 from"path";import{createHighlighter as Gj}from"ts-syntax-highlighter";async function T5($,Z={}){try{if(!await l($))throw Error(`Markdown file not found: ${$}`);let Y=(await Qj.promises.stat($)).mtime.getTime();if(Z.cache&&N8.has($)){let _=N8.get($);if(_.updatedAt>=Y)return{content:_.content,data:_.data}}let Q=await Bun.file($).text(),{data:J,content:G}=WZ(Q),K=Z.markdown||E1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},B=D$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)B=await Kj(B,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:B,data:J||{}};if(Z.cache)N8.set($,{...U,updatedAt:Y});return U}catch(X){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,X);let Y=X instanceof Error?X.message:String(X);return{content:G0("Markdown File",`Error reading/parsing markdown file: ${Y}`,$,"",0,""),data:{}}}}async function Kj($,Z,X){let Y=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!B4)try{B4=await Gj({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,W,B,U)=>{let _=U.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),z=B||(X?"text":"");if(!z)return K;try{if(!B4.getSupportedLanguages().includes(z))return K;return(await B4.highlight(_,z,{theme:Z})).html}catch(j){console.error(`Error highlighting code block with language ${B}:`,j)}return K},J=$,G=$.matchAll(Y);for(let K of G){let[W,B,U,_]=K,z=await Q(W,B,U,_);J=J.replace(W,z)}return J}async function S2($,Z,X="",Y={}){return await Wj($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,B)=>{try{let U=K;if(!V8.isAbsolute(K))U=V8.resolve(V8.dirname(X),K);let _={};if(W)try{try{_=JSON.parse(W)}catch{if(Y.debug)console.warn("Using safer alternative for parsing JS object literal");let O=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let A=V.indexOf(":");if(A>0){let N=V.substring(0,A).trim(),w=V.substring(A+1).trim(),R=w.startsWith('"')&&w.endsWith('"'),M=w.startsWith("'")&&w.endsWith("'");if(R||M)w=w.substring(1,w.length-1);_[N]=w}}}}catch(F){if(Y.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:z,data:j}=await T5(U,Y),q={...Z,...j,..._},H=z,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return q[V]!==void 0?String(q[V]):F}),H}catch(U){let _=U instanceof Error?U.message:String(U);return G0("Markdown File",`Error including markdown file: ${_}`,X,$,B,G)}})}async function Wj($,Z,X){let Y=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],W=Q.index,B=Q;Y.push(X(...B).then((U)=>({match:K,replacement:U,index:W})))}let J=await Promise.all(Y);J.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of J)G=G.replace(K,()=>W);return G}var N8,B4=null;var L$=T(()=>{I0();Q0();N8=new Map});var T9=`
11069
+ </script>`}var H8=T(()=>{d0();Q0()});var R9={};a(R9,{timingPlugin:()=>eq,pluginManager:()=>w9,definePlugin:()=>M5,debugPlugin:()=>tq,createVariablesPlugin:()=>$j,createFilterPlugin:()=>aq,createDirectivePlugin:()=>oq,PluginManager:()=>O8});function M5($){return $}class O8{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let X of $.dependencies)if(!this.plugins.has(X))throw Error(`Plugin "${$.name}" depends on "${X}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[X,Y]of this.plugins)if(Y.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${X}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let X=await Z.onError($);if(X){if(X.template!==void 0)$.template=X.template;if(X.context)$.context={...$.context,...X.context};if(X.metadata)$.metadata={...$.metadata,...X.metadata};if(X.skip)return $}}catch(X){console.error(`Error in plugin "${Z.name}" onError hook:`,X)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let X={...Z};for(let Y of this.sortedPlugins){let Q=Y[$];if(Q)try{let J=await Q(X);if(J){if(J.template!==void 0)X.template=J.template;if(J.context)X.context={...X.context,...J.context};if(J.metadata)X.metadata={...X.metadata,...J.metadata};if(J.skip)break}}catch(J){console.error(`Error in plugin "${Y.name}" ${$} hook:`,J)}}return X}async runDirectiveHooks($,Z,X){let Y={...X};for(let Q of this.sortedPlugins){let J=Q[$];if(J)try{let G=await J(Z,Y);if(G){if(G.template!==void 0)Y.template=G.template;if(G.context)Y.context={...Y.context,...G.context};if(G.metadata)Y.metadata={...Y.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Q.name}" ${$} hook:`,G)}}return Y}}function oq($,Z,X={}){return{name:$,...X,registerDirectives:()=>Z}}function aq($,Z,X={}){return{name:$,...X,registerFilters:()=>Z}}function $j($){return M5({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var w9,tq,eq;var L8=T(()=>{w9=new O8;tq=M5({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),eq=M5({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let X=performance.now()-Z;console.log(`[stx-timing] Processing took ${X.toFixed(2)}ms`)}}})});var xZ={};a(xZ,{validateConfig:()=>Jj,loadStxConfig:()=>Z1,defineStxConfig:()=>Yj,defaultConfig:()=>e0,config:()=>E1});import F8 from"fs";import S0 from"path";import{loadConfigWithResult as Zj}from"bunfig";function Xj($,Z){let X=Z||"pages";if($)return{root:$,pagesDir:X};let Y=S0.join(process.cwd(),"resources","views"),Q=S0.join(process.cwd(),"resources","layouts");if(F8.existsSync(Y)&&F8.existsSync(Q))return{root:"resources",pagesDir:"views"};let J=S0.join(process.cwd(),"resources","views","pages");if(F8.existsSync(J))return{root:"resources/views",pagesDir:X};return{root:".",pagesDir:X}}async function Z1($){if(!$){if(A$)return A$;if(U4)return U4}let Z=$?S0.resolve($):process.cwd(),X=M9.get(Z);if(X)return X;let Y=(async()=>{let J=(await Zj({name:"stx",alias:"ui",cwd:Z,defaultConfig:e0,verbose:!1})).config,G=Xj(J.root,J.pagesDir);if(J.root=G.root,J.pagesDir=G.pagesDir,J.root&&J.root!=="."){let K=J.root;if(J.partialsDir&&!S0.isAbsolute(J.partialsDir))J.partialsDir=S0.join(K,J.partialsDir);if(J.componentsDir&&!S0.isAbsolute(J.componentsDir))J.componentsDir=S0.join(K,J.componentsDir);if(J.layoutsDir&&!S0.isAbsolute(J.layoutsDir))J.layoutsDir=S0.join(K,J.layoutsDir)}if(J.plugins&&J.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (L8(),R9)),W=[],B=[];for(let U of J.plugins){let _=typeof U==="string"?U:U[0],z=typeof U==="string"?{}:U[1]||{};try{let j,q;try{j=await import(_),q=S0.dirname(K0.resolve(_))}catch{let L=S0.resolve(process.cwd(),_);j=await import(L),q=S0.dirname(L)}let H=j.default||j;if(K.register(H,J),H.components){let L=S0.resolve(q,H.components);W.push(L)}if(H.pages){let L=S0.resolve(q,H.pages),F=z.path||"/";B.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{J.customDirectives=J.customDirectives||[],J.customDirectives.push(F)},addRoute:(F,O)=>{J.apiRoutes=J.apiRoutes||{},J.apiRoutes[F]=O},addMiddleware:(F)=>{J.middleware=J.middleware||[],J.middleware.push(F)},pluginDir:q,config:J};await H.setup(z,L)}console.log(`[stx] Plugin loaded: ${H.name||_}`)}catch(j){console.warn(`[stx] Failed to load plugin ${_}:`,j.message)}}J._pluginComponentDirs=W,J._pluginPageDirs=B}return J})();if(M9.set(Z,Y),!$)U4=Y,Y.then((Q)=>{A$=Q}).catch(()=>{});return Y}function Yj($){return $}function Jj($){let Z=[],X=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let Y=["auto","manual","sections"];if(!Y.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let Y=["json","yaml","yml","js"];if(!Y.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let Y=["AA","AAA"];if(!Y.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let Y=["progressive","islands"];if(!Y.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${Y.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let Y=["none","eager","lazy"];if(!Y.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((Y,Q)=>{if(!Y.name||typeof Y.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!Y.handler||typeof Y.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((Y,Q)=>{if(!Y.name||typeof Y.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!Y.handler||typeof Y.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!Y.timing||!["before","after"].includes(Y.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)X.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)X.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let Y=["fullscreen","standalone","minimal-ui","browser"];if(!Y.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${Y.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let Y=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!Y.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${Y.join(", ")}`,severity:"error"})}if($.pwa.routes){let Y=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Q,J)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${J}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!Y.includes(Q.strategy))Z.push({path:`pwa.routes[${J}].strategy`,message:`PWA route strategy must be one of: ${Y.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${J}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${J}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let Y=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((J)=>!Y.includes(J)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${Y.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)X.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)X.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:X}}var e0,A$=null,M9,U4=null,E1;var E0=T(()=>{y5();x5();A4();v5();c7();t3();j8();V9();N7();H8();e0={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:h2,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:A9,hasEndTag:!1,description:"Include a web component in the template"},r8,s8,vY,fY,o8,t8,e8,a8,YZ,GZ,Y4,W4,...F9],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{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],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},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}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};M9=new Map;E1=new Proxy(e0,{get($,Z){if(A$&&Z in A$)return A$[Z];if(!U4)Z1().catch((X)=>{console.warn("[stx] Failed to load config file:",X?.message||X)});return $[Z]}})});import Qj from"fs";import V8 from"path";import{createHighlighter as Gj}from"ts-syntax-highlighter";async function T5($,Z={}){try{if(!await l($))throw Error(`Markdown file not found: ${$}`);let Y=(await Qj.promises.stat($)).mtime.getTime();if(Z.cache&&N8.has($)){let _=N8.get($);if(_.updatedAt>=Y)return{content:_.content,data:_.data}}let Q=await Bun.file($).text(),{data:J,content:G}=WZ(Q),K=Z.markdown||E1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},B=D$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)B=await Kj(B,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:B,data:J||{}};if(Z.cache)N8.set($,{...U,updatedAt:Y});return U}catch(X){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,X);let Y=X instanceof Error?X.message:String(X);return{content:G0("Markdown File",`Error reading/parsing markdown file: ${Y}`,$,"",0,""),data:{}}}}async function Kj($,Z,X){let Y=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!B4)try{B4=await Gj({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,W,B,U)=>{let _=U.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),z=B||(X?"text":"");if(!z)return K;try{if(!B4.getSupportedLanguages().includes(z))return K;return(await B4.highlight(_,z,{theme:Z})).html}catch(j){console.error(`Error highlighting code block with language ${B}:`,j)}return K},J=$,G=$.matchAll(Y);for(let K of G){let[W,B,U,_]=K,z=await Q(W,B,U,_);J=J.replace(W,z)}return J}async function S2($,Z,X="",Y={}){return await Wj($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,B)=>{try{let U=K;if(!V8.isAbsolute(K))U=V8.resolve(V8.dirname(X),K);let _={};if(W)try{try{_=JSON.parse(W)}catch{if(Y.debug)console.warn("Using safer alternative for parsing JS object literal");let O=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let A=V.indexOf(":");if(A>0){let N=V.substring(0,A).trim(),w=V.substring(A+1).trim(),R=w.startsWith('"')&&w.endsWith('"'),M=w.startsWith("'")&&w.endsWith("'");if(R||M)w=w.substring(1,w.length-1);_[N]=w}}}}catch(F){if(Y.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:z,data:j}=await T5(U,Y),q={...Z,...j,..._},H=z,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return q[V]!==void 0?String(q[V]):F}),H}catch(U){let _=U instanceof Error?U.message:String(U);return G0("Markdown File",`Error including markdown file: ${_}`,X,$,B,G)}})}async function Wj($,Z,X){let Y=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],W=Q.index,B=Q;Y.push(X(...B).then((U)=>({match:K,replacement:U,index:W})))}let J=await Promise.all(Y);J.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of J)G=G.replace(K,()=>W);return G}var N8,B4=null;var L$=T(()=>{E0();Q0();N8=new Map});var T9=`
11070
11070
  <script data-stx-helpers>
11071
11071
  (function() {
11072
11072
  'use strict'
@@ -11386,7 +11386,7 @@ ${H}
11386
11386
  </div>`}else if(X.placeholder==="color"){let F=Q.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");H=`<div id="${L}" class="stx-image-placeholder" style="background-color: ${F};">
11387
11387
  ${H}
11388
11388
  </div>`}}if(X.priority&&z){let L=t1(z.format);H=`<link rel="preload" as="image" href="${W1(z.url)}" type="${L}" />
11389
- `+H}return H}function W1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var E8,Ej;var f9=T(()=>{J5();T$();E8=new Map;Ej=v9()});var g9=T(()=>{T$()});var D8=T(()=>{T$();R3();C9();y9();f9();g9()});var h9=()=>{};import{abortNavigation as fT,clearMiddleware as yj,createClientCookieManager as gT,createMiddlewareContext as xj,createRouteLocation as vj,createServerCookieManager as hT,createStorageManager as dT,defineMiddleware as uT,getMiddleware as mT,getMiddlewareNames as fj,hasMiddleware as pT,loadMiddlewareFromDirectory as gj,navigateTo as cT,registerMiddleware as lT,runMiddleware as hj}from"stx-router";var k8=()=>{};var S8=()=>{};import{extractLayoutMetadata as d9}from"stx-router/layout-metadata";var I$=T(()=>{S8()});var u9=T(()=>{I0()});import{getRouterScript as YI}from"stx-router";var C8=T(()=>{b7()});var m9=T(()=>{I0()});var p9=()=>{};import{Broadcast as UI,BroadcastServer as BI}from"ts-broadcasting";import{channel as qI}from"ts-broadcasting";import{Broadcast as HI,BroadcastServer as OI}from"ts-broadcasting";var c9=()=>{};var l9=T(()=>{d0();L0();Q0()});function b8(){return`
11389
+ `+H}return H}function W1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var E8,Ej;var f9=T(()=>{J5();T$();E8=new Map;Ej=v9()});var g9=T(()=>{T$()});var D8=T(()=>{T$();R3();C9();y9();f9();g9()});var h9=()=>{};import{abortNavigation as fT,clearMiddleware as yj,createClientCookieManager as gT,createMiddlewareContext as xj,createRouteLocation as vj,createServerCookieManager as hT,createStorageManager as dT,defineMiddleware as uT,getMiddleware as mT,getMiddlewareNames as fj,hasMiddleware as pT,loadMiddlewareFromDirectory as gj,navigateTo as cT,registerMiddleware as lT,runMiddleware as hj}from"stx-router";var k8=()=>{};var S8=()=>{};import{extractLayoutMetadata as d9}from"stx-router/layout-metadata";var I$=T(()=>{S8()});var u9=T(()=>{E0()});import{getRouterScript as YI}from"stx-router";var C8=T(()=>{b7()});var m9=T(()=>{E0()});var p9=()=>{};import{Broadcast as UI,BroadcastServer as BI}from"ts-broadcasting";import{channel as qI}from"ts-broadcasting";import{Broadcast as HI,BroadcastServer as OI}from"ts-broadcasting";var c9=()=>{};var l9=T(()=>{d0();L0();Q0()});function b8(){return`
11390
11390
  /* Theme selector for code blocks */
11391
11391
  .theme-selector {
11392
11392
  margin: 1rem 0;
@@ -11468,14 +11468,14 @@ else {
11468
11468
  </div>`).join("")}
11469
11469
  </div>`}var i9=()=>{};import n9 from"net";async function dj($){return new Promise((Z)=>{let X=n9.createServer();X.once("error",()=>Z(!1)),X.once("listening",()=>{X.close(()=>Z(!0))}),X.listen($,"0.0.0.0")})}async function uj($){return new Promise((Z)=>{let X=n9.createServer();X.once("error",()=>Z(!1)),X.once("listening",()=>{X.close(()=>Z(!0))}),X.listen($,"::")})}async function mj($){if(!await dj($))return!1;return await uj($)}async function D5($,Z=20){$=Number($);for(let X=0;X<Z;X++){let Y=$+X;if(await mj(Y))return Y}throw Error(`Could not find an available port between ${$} and ${$+Z-1}`)}var r9=()=>{};var s9=T(()=>{v$()});function v8(){console.log(`
11470
11470
  Keyboard shortcuts:`),console.log(` ${x.cyan}o${x.reset} + Enter - Open in browser`),console.log(` ${x.cyan}c${x.reset} + Enter - Clear console`),console.log(` ${x.cyan}q${x.reset} + Enter (or ${x.cyan}Ctrl+C${x.reset}) - Quit server`),console.log(` ${x.cyan}h${x.reset} + Enter - Show this help`)}function pj($){console.log(`${x.green}Server running at ${x.cyan}${$}${x.reset}`),console.log(`Press ${x.cyan}Ctrl+C${x.reset} to stop the server`),v8()}function cj($){console.log(`${x.dim}Opening ${x.cyan}${$}${x.dim} in your browser...${x.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function k5($,Z,X){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),v8();let Y="";process.stdin.on("data",(Q)=>{if(Q==="\x03"){if(X?.onQuit)X.onQuit();Z(),process.exit(0)}if(Y+=Q,Y.endsWith("\r")||Y.endsWith(`
11471
- `)){let J=Y.trim().toLowerCase();Y="",lj(J,$,Z,X)}})}function lj($,Z,X,Y){switch($){case"o":if(Y?.onOpen)Y.onOpen();else cj(Z);break;case"c":if(Y?.onClear)Y.onClear();else console.clear(),pj(Z);break;case"q":if(Y?.onQuit)Y.onQuit();console.log(`${x.yellow}Stopping server...${x.reset}`),X(),process.exit(0);break;case"h":if(Y?.onHelp)Y.onHelp();else v8();break;default:break}}var o9=T(()=>{v$()});var a9=()=>{};var S5=T(()=>{v$();J$();i9();r9();s9();o9();a9()});var f8=T(()=>{L$();I0();S5()});var e9=T(()=>{U$();O4();Q0();S5();f8()});import{matchRoute as oI,Router as aI}from"stx-router";import{findErrorPage as XH,formatRoutes as YH,generateRouteManifest as $E,generateRouteTypes as ZE,matchRoute as JH}from"stx-router";var L4=()=>{};var $Q=T(()=>{I$();U$();O4();L4();k8();p1();Q0();S5()});var ZQ=T(()=>{f8();e9();YQ();$Q()});var JQ=T(()=>{I0();Q0()});var QQ=()=>{};var GQ=()=>{};var KQ=()=>{};var WQ=()=>{};var UQ=T(()=>{T0();n0()});var F4=()=>{};var BQ=()=>{};var g8=T(()=>{n0();I0();S$();I$()});var _Q=T(()=>{L4();C8();g8();F4();I$();J$();I0()});var h8=T(()=>{V1();T0();S$()});var zQ=T(()=>{F4();h8();I$()});var qQ=()=>{};var jQ=T(()=>{L$();n0();Q0()});var HQ=()=>{};var OQ=()=>{};var LQ=()=>{};class FQ{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 Z=this.instances.get($);if(!Z)return;if(this.componentsByFile.get(Z.name)?.delete($),this.componentsByFile.get(Z.name)?.size===0)this.componentsByFile.delete(Z.name);if(this.stateSnapshots.delete($),Z.cleanup?.(),this.instances.delete($),this.config.verbose)console.log(`[HMR] Unregistered component: ${Z.name} (${$})`)}getInstancesByFile($){let Z=this.componentsByFile.get($)||new Set;return Array.from(Z).map((X)=>this.instances.get(X)).filter(Boolean)}getInstance($){return this.instances.get($)}captureState($){let Z=this.instances.get($);if(!Z||!this.config.preserveState)return;let X=this.config.serializeState(Z);if(this.stateSnapshots.set($,X),this.config.verbose)console.log(`[HMR] Captured state for: ${Z.name}`)}restoreState($){let Z=this.instances.get($),X=this.stateSnapshots.get($);if(!Z||!X||!this.config.preserveState)return!1;if(Date.now()-X.timestamp>this.config.maxStateAge){if(this.stateSnapshots.delete($),this.config.verbose)console.log(`[HMR] State expired for: ${Z.name}`);return!1}try{if(this.config.deserializeState(X,Z),this.config.verbose)console.log(`[HMR] Restored state for: ${Z.name}`);return!0}catch(Y){return console.error(`[HMR] Failed to restore state for ${Z.name}:`,Y),!1}}defaultSerializeState($){let Z={},X={};if($.element)$.element.querySelectorAll("[data-stx-ref]").forEach((Q)=>{let J=Q.getAttribute("data-stx-ref"),G=Q.getAttribute("data-stx-value");if(J&&G)try{Z[J]=JSON.parse(G)}catch{Z[J]=G}});return{refs:Z,reactiveObjects:X,custom:$.state?.custom||{},timestamp:Date.now()}}defaultDeserializeState($,Z){if(Z.element)Object.entries($.refs).forEach(([X,Y])=>{let Q=Z.element.querySelector(`[data-stx-ref="${X}"]`);if(Q)Q.setAttribute("data-stx-value",JSON.stringify(Y)),Q.dispatchEvent(new CustomEvent("stx:state-restored",{detail:{name:X,value:Y},bubbles:!0}))});Z.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 UH{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 FQ(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 Z=this.registry.getInstancesByFile($.file);if(Z.length===0){if(this.config.verbose)console.log(`[HMR] No instances found for: ${$.file}`);return}if(this.config.verbose)console.log(`[HMR] Updating ${Z.length} instance(s) of: ${$.file}`);for(let X of Z)await this.updateInstance(X,$);if(typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hmr-update",{detail:{file:$.file,count:Z.length}}))}async updateInstance($,Z){this.registry.captureState($.id);let X=!1,Y=$.element?.innerHTML||"";try{if($.element?.dispatchEvent(new CustomEvent("stx:before-hmr-update",{bubbles:!0})),$.cleanup?.(),Z.type==="style")await this.updateStyles($,Z);else await this.updateComponent($,Z);let Q=this.registry.restoreState($.id);if(!Q&&$.setup)await $.setup();$.element?.dispatchEvent(new CustomEvent("stx:after-hmr-update",{detail:{stateRestored:Q},bubbles:!0}))}catch(Q){if(X=!0,console.error(`[HMR] Error updating component ${$.name}:`,Q),this.config.errorRecovery){if($.element&&Y)$.element.innerHTML=Y,console.log(`[HMR] Recovered previous state for: ${$.name}`);$.element?.dispatchEvent(new CustomEvent("stx:hmr-error",{detail:{error:Q},bubbles:!0}))}}if(!X&&this.config.verbose)console.log(`[HMR] Successfully updated: ${$.name}`)}async updateComponent($,Z){if(!$.element)return;let{html:X,script:Y}=this.parseComponentCode(Z.code);if(X)$.element.innerHTML=X;if(Y)await this.executeScript(Y,$);if($.render)$.element.innerHTML=$.render();this.reinitializeInteractivity($)}async updateStyles($,Z){if(!$.element)return;let X=Z.code.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(!X)return;let Y=X[1],Q=$.id,J=document.querySelector(`style[data-stx-component="${Q}"]`);if(!J)J=document.createElement("style"),J.setAttribute("data-stx-component",Q),document.head.appendChild(J);if(J.textContent=Y,this.config.verbose)console.log(`[HMR] Updated styles for: ${$.name}`)}parseComponentCode($){let Z=$,X="",Y="",Q=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Q)X=Q[1],Z=Z.replace(Q[0],"");let J=$.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(J)Y=J[1],Z=Z.replace(J[0],"");return{html:Z.trim(),script:X.trim(),style:Y.trim()}}async executeScript($,Z){try{let X={element:Z.element,props:Z.props,...typeof window<"u"?window.stx:{}},Y=`
11471
+ `)){let J=Y.trim().toLowerCase();Y="",lj(J,$,Z,X)}})}function lj($,Z,X,Y){switch($){case"o":if(Y?.onOpen)Y.onOpen();else cj(Z);break;case"c":if(Y?.onClear)Y.onClear();else console.clear(),pj(Z);break;case"q":if(Y?.onQuit)Y.onQuit();console.log(`${x.yellow}Stopping server...${x.reset}`),X(),process.exit(0);break;case"h":if(Y?.onHelp)Y.onHelp();else v8();break;default:break}}var o9=T(()=>{v$()});var a9=()=>{};var S5=T(()=>{v$();J$();i9();r9();s9();o9();a9()});var f8=T(()=>{L$();E0();S5()});var e9=T(()=>{U$();O4();Q0();S5();f8()});import{matchRoute as oI,Router as aI}from"stx-router";import{findErrorPage as XH,formatRoutes as YH,generateRouteManifest as $E,generateRouteTypes as ZE,matchRoute as JH}from"stx-router";var L4=()=>{};var $Q=T(()=>{I$();U$();O4();L4();k8();p1();Q0();S5()});var ZQ=T(()=>{f8();e9();YQ();$Q()});var JQ=T(()=>{E0();Q0()});var QQ=()=>{};var GQ=()=>{};var KQ=()=>{};var WQ=()=>{};var UQ=T(()=>{I0();n0()});var F4=()=>{};var BQ=()=>{};var g8=T(()=>{n0();E0();S$();I$()});var _Q=T(()=>{L4();C8();g8();F4();I$();J$();E0()});var h8=T(()=>{V1();I0();S$()});var zQ=T(()=>{F4();h8();I$()});var qQ=()=>{};var jQ=T(()=>{L$();n0();Q0()});var HQ=()=>{};var OQ=()=>{};var LQ=()=>{};class FQ{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 Z=this.instances.get($);if(!Z)return;if(this.componentsByFile.get(Z.name)?.delete($),this.componentsByFile.get(Z.name)?.size===0)this.componentsByFile.delete(Z.name);if(this.stateSnapshots.delete($),Z.cleanup?.(),this.instances.delete($),this.config.verbose)console.log(`[HMR] Unregistered component: ${Z.name} (${$})`)}getInstancesByFile($){let Z=this.componentsByFile.get($)||new Set;return Array.from(Z).map((X)=>this.instances.get(X)).filter(Boolean)}getInstance($){return this.instances.get($)}captureState($){let Z=this.instances.get($);if(!Z||!this.config.preserveState)return;let X=this.config.serializeState(Z);if(this.stateSnapshots.set($,X),this.config.verbose)console.log(`[HMR] Captured state for: ${Z.name}`)}restoreState($){let Z=this.instances.get($),X=this.stateSnapshots.get($);if(!Z||!X||!this.config.preserveState)return!1;if(Date.now()-X.timestamp>this.config.maxStateAge){if(this.stateSnapshots.delete($),this.config.verbose)console.log(`[HMR] State expired for: ${Z.name}`);return!1}try{if(this.config.deserializeState(X,Z),this.config.verbose)console.log(`[HMR] Restored state for: ${Z.name}`);return!0}catch(Y){return console.error(`[HMR] Failed to restore state for ${Z.name}:`,Y),!1}}defaultSerializeState($){let Z={},X={};if($.element)$.element.querySelectorAll("[data-stx-ref]").forEach((Q)=>{let J=Q.getAttribute("data-stx-ref"),G=Q.getAttribute("data-stx-value");if(J&&G)try{Z[J]=JSON.parse(G)}catch{Z[J]=G}});return{refs:Z,reactiveObjects:X,custom:$.state?.custom||{},timestamp:Date.now()}}defaultDeserializeState($,Z){if(Z.element)Object.entries($.refs).forEach(([X,Y])=>{let Q=Z.element.querySelector(`[data-stx-ref="${X}"]`);if(Q)Q.setAttribute("data-stx-value",JSON.stringify(Y)),Q.dispatchEvent(new CustomEvent("stx:state-restored",{detail:{name:X,value:Y},bubbles:!0}))});Z.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 UH{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 FQ(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 Z=this.registry.getInstancesByFile($.file);if(Z.length===0){if(this.config.verbose)console.log(`[HMR] No instances found for: ${$.file}`);return}if(this.config.verbose)console.log(`[HMR] Updating ${Z.length} instance(s) of: ${$.file}`);for(let X of Z)await this.updateInstance(X,$);if(typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hmr-update",{detail:{file:$.file,count:Z.length}}))}async updateInstance($,Z){this.registry.captureState($.id);let X=!1,Y=$.element?.innerHTML||"";try{if($.element?.dispatchEvent(new CustomEvent("stx:before-hmr-update",{bubbles:!0})),$.cleanup?.(),Z.type==="style")await this.updateStyles($,Z);else await this.updateComponent($,Z);let Q=this.registry.restoreState($.id);if(!Q&&$.setup)await $.setup();$.element?.dispatchEvent(new CustomEvent("stx:after-hmr-update",{detail:{stateRestored:Q},bubbles:!0}))}catch(Q){if(X=!0,console.error(`[HMR] Error updating component ${$.name}:`,Q),this.config.errorRecovery){if($.element&&Y)$.element.innerHTML=Y,console.log(`[HMR] Recovered previous state for: ${$.name}`);$.element?.dispatchEvent(new CustomEvent("stx:hmr-error",{detail:{error:Q},bubbles:!0}))}}if(!X&&this.config.verbose)console.log(`[HMR] Successfully updated: ${$.name}`)}async updateComponent($,Z){if(!$.element)return;let{html:X,script:Y}=this.parseComponentCode(Z.code);if(X)$.element.innerHTML=X;if(Y)await this.executeScript(Y,$);if($.render)$.element.innerHTML=$.render();this.reinitializeInteractivity($)}async updateStyles($,Z){if(!$.element)return;let X=Z.code.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(!X)return;let Y=X[1],Q=$.id,J=document.querySelector(`style[data-stx-component="${Q}"]`);if(!J)J=document.createElement("style"),J.setAttribute("data-stx-component",Q),document.head.appendChild(J);if(J.textContent=Y,this.config.verbose)console.log(`[HMR] Updated styles for: ${$.name}`)}parseComponentCode($){let Z=$,X="",Y="",Q=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Q)X=Q[1],Z=Z.replace(Q[0],"");let J=$.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(J)Y=J[1],Z=Z.replace(J[0],"");return{html:Z.trim(),script:X.trim(),style:Y.trim()}}async executeScript($,Z){try{let X={element:Z.element,props:Z.props,...typeof window<"u"?window.stx:{}},Y=`
11472
11472
  return (async function() {
11473
11473
  ${$}
11474
11474
  })()
11475
- `;await Function(...Object.keys(X),Y)(...Object.values(X))}catch(X){throw console.error("[HMR] Script execution error:",X),X}}reinitializeInteractivity($){if(!$.element)return;$.element.querySelectorAll("[data-stx-events]").forEach((X)=>{let Y=X.getAttribute("data-stx-events");if(!Y)return;try{let Q=JSON.parse(Y);for(let[J,G]of Object.entries(Q))if(typeof window<"u"&&window.stx?.[G])X.addEventListener(J,window.stx[G])}catch{}}),$.element.dispatchEvent(new CustomEvent("stx:reinitialize",{bubbles:!0}))}getRegistry(){return this.registry}async refresh($){let Z=this.registry.getInstancesByFile($);for(let X of Z)if(X.render&&X.element)this.registry.captureState(X.id),X.element.innerHTML=X.render(),this.registry.restoreState(X.id),this.reinitializeInteractivity(X)}}var VQ=()=>{};var NQ=()=>{};var AQ=T(()=>{d0();n0();Q0()});var wQ=()=>{};var RQ=()=>{};var MQ=T(()=>{s3();t3();r7();P3();RQ()});var TQ=()=>{};var d8=()=>{};var kQ=T(()=>{d8()});var SQ=T(()=>{d8();kQ()});var u8=()=>{};var m8=()=>{};var p8=()=>{};var xQ=T(()=>{u8();m8();p8();u8();m8();p8()});var vQ=T(()=>{T1();t7()});var fQ=T(()=>{MQ();c3();z8();_8();TQ();SQ();xQ();vQ()});var gQ=T(()=>{V1();I0();n0()});var c8=()=>{};var hQ=()=>{};var dQ=T(()=>{c8()});var uQ=T(()=>{I0();V1();n0();P1()});var mQ=()=>{};var l8=()=>{};import tk from"bun-plugin-stx";var tQ=T(()=>{J$();l8()});var eQ=T(()=>{tQ();l8()});var $G=()=>{};var ZG=()=>{};var XG=T(()=>{ZG()});var YG=T(()=>{w8();D8();Q0();y6();C1();wQ();i6();c8();hQ();dQ();L8();J$();mQ();eQ();$G();h9();p1();k8();r4();y5();P4();x5();L$();I$();x4();u9();C8();m9();p9();c9();x7();l9();I0();c4();i4();w8();ZQ();J5();JQ();QQ();GQ();d0();y4();T0();KQ();v5();X6();U$();WQ();UQ();F7();c7();c6();p$();F4();S$();n0();BQ();_Q();zQ();L4();qQ();S8();N7();jQ();R7();g8();h8();K7();HQ();H8();A3();w3();OQ();LQ();b4();P1();VQ();NQ();AQ();D8();fQ();gQ();b7();n6();r6();uQ();Q0();I3();XG()});import C5 from"path";var H4;var O4=T(()=>{YG();d0();T0();v1();n0();H4={name:"bun-plugin-stx",async setup($){let X={...await Z1(),...$.config?.stx},Y=new Set,Q=X.webComponents?.enabled?`./${C5.relative(C5.dirname($.config?.outdir||"dist"),X.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(X.webComponents?.enabled)try{let G=await N9(X,Y);if(J.push(...G),X.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 K=new Set;if(X.cache&&X.cachePath){let H=await J3(G,X);if(H){if(X.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await G1(()=>Bun.file(G).text(),"",(H)=>{throw new d$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new d$(`stx file is empty: ${G}`,G);let{scriptContent:B,templateContent:U,allScripts:_}=x$.time("script-extraction",()=>{let H=W,L=W.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(L)H=L[1].trim();let F=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],O="",V=[];for(let N of F){let w=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=N.match(/<script\b([^>]*)>/i),M=R?R[1]:"";if(/\bserver\b/i.test(M))O=w;else V.push(N)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:O,templateContent:A,allScripts:V}}),z={__filename:G,__dirname:C5.dirname(G),__stx:{webComponentsPath:Q,builtComponents:J}};await G1(()=>P0(B,z,G),void 0,(H)=>{let L=new t0(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,B.substring(0,100));if(E0.log(L,{filePath:G,scriptContent:B}),X.debug)throw L});let q=await x$.timeAsync("directive-processing",async()=>{return await U0(U,z,G,X,K)});if(_.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (T0(),I4)),L=H(_.join(`
11475
+ `;await Function(...Object.keys(X),Y)(...Object.values(X))}catch(X){throw console.error("[HMR] Script execution error:",X),X}}reinitializeInteractivity($){if(!$.element)return;$.element.querySelectorAll("[data-stx-events]").forEach((X)=>{let Y=X.getAttribute("data-stx-events");if(!Y)return;try{let Q=JSON.parse(Y);for(let[J,G]of Object.entries(Q))if(typeof window<"u"&&window.stx?.[G])X.addEventListener(J,window.stx[G])}catch{}}),$.element.dispatchEvent(new CustomEvent("stx:reinitialize",{bubbles:!0}))}getRegistry(){return this.registry}async refresh($){let Z=this.registry.getInstancesByFile($);for(let X of Z)if(X.render&&X.element)this.registry.captureState(X.id),X.element.innerHTML=X.render(),this.registry.restoreState(X.id),this.reinitializeInteractivity(X)}}var VQ=()=>{};var NQ=()=>{};var AQ=T(()=>{d0();n0();Q0()});var wQ=()=>{};var RQ=()=>{};var MQ=T(()=>{s3();t3();r7();P3();RQ()});var TQ=()=>{};var d8=()=>{};var kQ=T(()=>{d8()});var SQ=T(()=>{d8();kQ()});var u8=()=>{};var m8=()=>{};var p8=()=>{};var xQ=T(()=>{u8();m8();p8();u8();m8();p8()});var vQ=T(()=>{T1();t7()});var fQ=T(()=>{MQ();c3();z8();_8();TQ();SQ();xQ();vQ()});var gQ=T(()=>{V1();E0();n0()});var c8=()=>{};var hQ=()=>{};var dQ=T(()=>{c8()});var uQ=T(()=>{E0();V1();n0();P1()});var mQ=()=>{};var l8=()=>{};import tk from"bun-plugin-stx";var tQ=T(()=>{J$();l8()});var eQ=T(()=>{tQ();l8()});var $G=()=>{};var ZG=()=>{};var XG=T(()=>{ZG()});var YG=T(()=>{w8();D8();Q0();y6();C1();wQ();i6();c8();hQ();dQ();L8();J$();mQ();eQ();$G();h9();p1();k8();r4();y5();P4();x5();L$();I$();x4();u9();C8();m9();p9();c9();x7();l9();E0();c4();i4();w8();ZQ();J5();JQ();QQ();GQ();d0();y4();I0();KQ();v5();X6();U$();WQ();UQ();F7();c7();c6();p$();F4();S$();n0();BQ();_Q();zQ();L4();qQ();S8();N7();jQ();R7();g8();h8();K7();HQ();H8();A3();w3();OQ();LQ();b4();P1();VQ();NQ();AQ();D8();fQ();gQ();b7();n6();r6();uQ();Q0();I3();XG()});import C5 from"path";var H4;var O4=T(()=>{YG();d0();I0();v1();n0();H4={name:"bun-plugin-stx",async setup($){let X={...await Z1(),...$.config?.stx},Y=new Set,Q=X.webComponents?.enabled?`./${C5.relative(C5.dirname($.config?.outdir||"dist"),X.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(X.webComponents?.enabled)try{let G=await N9(X,Y);if(J.push(...G),X.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 K=new Set;if(X.cache&&X.cachePath){let H=await J3(G,X);if(H){if(X.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await G1(()=>Bun.file(G).text(),"",(H)=>{throw new d$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new d$(`stx file is empty: ${G}`,G);let{scriptContent:B,templateContent:U,allScripts:_}=x$.time("script-extraction",()=>{let H=W,L=W.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(L)H=L[1].trim();let F=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],O="",V=[];for(let N of F){let w=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=N.match(/<script\b([^>]*)>/i),M=R?R[1]:"";if(/\bserver\b/i.test(M))O=w;else V.push(N)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:O,templateContent:A,allScripts:V}}),z={__filename:G,__dirname:C5.dirname(G),__stx:{webComponentsPath:Q,builtComponents:J}};await G1(()=>P0(B,z,G),void 0,(H)=>{let L=new t0(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,B.substring(0,100));if(D0.log(L,{filePath:G,scriptContent:B}),X.debug)throw L});let q=await x$.timeAsync("directive-processing",async()=>{return await U0(U,z,G,X,K)});if(_.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (I0(),I4)),L=H(_.join(`
11476
11476
  `),z),F=q.search(/<\/body>/i);if(F!==-1)q=q.slice(0,F)+L+`
11477
11477
  `+q.slice(F);else q+=`
11478
- ${L}`}if(q=await v7(q),K.forEach((H)=>Y.add(H)),X.cache&&X.cachePath){if(await Q3(G,q,K,X),X.debug)console.log(`Cached template ${G} with ${K.size} dependencies`)}return{contents:q,loader:"html"}}catch(K){let W=K instanceof Error?K:new t0(`Plugin processing failed: ${String(K)}`,G);if(E0.log(W,{filePath:G,buildConfig:$.config}),u$.logDetailedError(W,{filePath:G,plugin:"bun-plugin-stx"}),X.debug)console.error("stx Plugin Error:",W);let B=W,U=B.line||null,_=B.context||null;return{contents:X.debug||g1()?`<!DOCTYPE html>
11478
+ ${L}`}if(q=await v7(q),K.forEach((H)=>Y.add(H)),X.cache&&X.cachePath){if(await Q3(G,q,K,X),X.debug)console.log(`Cached template ${G} with ${K.size} dependencies`)}return{contents:q,loader:"html"}}catch(K){let W=K instanceof Error?K:new t0(`Plugin processing failed: ${String(K)}`,G);if(D0.log(W,{filePath:G,buildConfig:$.config}),u$.logDetailedError(W,{filePath:G,plugin:"bun-plugin-stx"}),X.debug)console.error("stx Plugin Error:",W);let B=W,U=B.line||null,_=B.context||null;return{contents:X.debug||g1()?`<!DOCTYPE html>
11479
11479
  <html lang="en">
11480
11480
  <head>
11481
11481
  <meta charset="UTF-8">
@@ -11705,4 +11705,4 @@ ${q.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
11705
11705
  ${x.blue}stx${x.reset} ${x.green}${process.env.stx_VERSION||"v0.0.10"}${x.reset} ${x.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${x.reset}`),console.log(`
11706
11706
  ${x.bright}\u2192 ${x.cyan}http://localhost:${U}/${x.reset}`),console.log(`
11707
11707
  ${x.yellow}Routes:${x.reset}`);let z=new Set(K.map((q)=>q.routeTemplate)),j=Object.entries(G).filter(([q])=>!z.has(q)).sort(([q],[H])=>q.localeCompare(H)).map(([q,H])=>({route:q==="/"?"/":q,filePath:R0.relative(process.cwd(),H.filePath),fileType:H.fileType}));for(let q of K){let H=q.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");j.push({route:H,filePath:R0.relative(process.cwd(),q.filePath),fileType:"stx"})}if(j.sort((q,H)=>q.route.localeCompare(H.route)),j.forEach((q,H)=>{let F=H===j.length-1?"\u2514\u2500 ":"\u251C\u2500 ",O=q.fileType==="md"?`${x.magenta}(markdown)${x.reset}`:"";console.log(` ${x.green}${F}${q.route}${x.reset} \u2192 ${x.bright}${q.filePath}${x.reset} ${O}`)}),console.log(`
11708
- Press ${x.cyan}h${x.reset} + ${x.cyan}Enter${x.reset} to show shortcuts`),k5(_.url.toString(),()=>{if(Y)D1.watch(J,{recursive:!0}).close();_.stop()}),Y){console.log(`${x.blue}Watching for changes...${x.reset}`);let q=D1.watch(J,{recursive:!0},async(H,L)=>{if(!L)return;if(L.endsWith(".stx")||L.endsWith(".js")||L.endsWith(".ts")||L.endsWith(".md"))console.log(`${x.yellow}File ${x.bright}${L}${x.yellow} changed, rebuilding...${x.reset}`),V7.clear(),i7(),await W()});process.on("SIGINT",()=>{q.close(),_.stop(),process.exit(0)})}return!0}var YQ=T(()=>{L$();I0();U$();O4();Q0();S5()});YQ();export{WH as serveMultipleStxFiles,XQ as findCommonDir};
11708
+ Press ${x.cyan}h${x.reset} + ${x.cyan}Enter${x.reset} to show shortcuts`),k5(_.url.toString(),()=>{if(Y)D1.watch(J,{recursive:!0}).close();_.stop()}),Y){console.log(`${x.blue}Watching for changes...${x.reset}`);let q=D1.watch(J,{recursive:!0},async(H,L)=>{if(!L)return;if(L.endsWith(".stx")||L.endsWith(".js")||L.endsWith(".ts")||L.endsWith(".md"))console.log(`${x.yellow}File ${x.bright}${L}${x.yellow} changed, rebuilding...${x.reset}`),V7.clear(),i7(),await W()});process.on("SIGINT",()=>{q.close(),_.stop(),process.exit(0)})}return!0}var YQ=T(()=>{L$();E0();U$();O4();Q0();S5()});YQ();export{WH as serveMultipleStxFiles,XQ as findCommonDir};